Coder Social home page Coder Social logo

iaphub / react-native-iaphub Goto Github PK

View Code? Open in Web Editor NEW
319.0 6.0 21.0 2.28 MB

The easiest way to implement IAP (In-app purchase) in your React Native app.

Home Page: https://www.iaphub.com/

License: MIT License

JavaScript 24.94% Java 10.46% Objective-C 7.52% Ruby 4.29% Kotlin 18.36% Swift 13.80% TypeScript 19.56% Objective-C++ 1.08%
react-native in-app-purchase in-app-billing in-app-receipt google-play itunes react-native-iap

react-native-iaphub's Introduction

IAPHUB

npm npm Shoutem

We've simplified in-app purchases for you. Say goodbye to wasting time and resources reinventing the wheel.
At IAPHUB, we've developed all the necessary tools for selling in-app purchases and subscriptions, managing your customers, and boosting your revenue. ๐Ÿš€

Getting Started

Please refer to our Quickstart Guide for step-by-step instructions on integrating IAPHUB into your React Native app.

You can also learn all about our SDK methods in our comprehensive SDK Reference.

UI

The package provides all the methods of the IAPHUB SDK for easy implementation of in-app purchases, but it does not include any user interface (UI). If you prefer a plug-and-play component with built-in UI, consider exploring react-native-iaphub-ui.

Upgrades

If you're upgrading to a new major version of the plugin, please consult our migration guides:

  • For transitioning from v7.X.X to v8.X.X, refer to this guide.
  • For transitioning from v6.X.X to v7.X.X, refer to this guide.

Example

You can check our Example app.

react-native-iaphub's People

Contributors

adamnbowen avatar centrual avatar deepfinessed avatar devinjameson avatar iaphub avatar kurtfurbush avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

react-native-iaphub's Issues

No visible @interface for 'SKPaymentQueue' declares the selector 'presentCodeRedemptionSheet'

Version of react-native-iap

5.2.0

Version of react-native

0.61.5

XCode 11.5

Platforms you faced the error (IOS or Android or both?)

iOS

Expected behavior

Build successful

Actual behavior

Build failed, 2 warnings, 1 error

dooboolab-community/react-native-iap#1204

Tested environment (Emulator? Real Device?)

Sim, emu

Steps to reproduce the behavior

yarn add -E [email protected]
yarn add -E [email protected]
pod install

XCode > Clean
XCode > Build (or via RN CLI)

getProductsForSale() returning user_id_invalid error

Hey everybody, I'm having this error every time that I call IapHub.getProductsForSale() I receive a user_id_invalid, does anyone knows why this is happening?

const _init = async () => {
  try {
    await IapHub.init({
      // The app id is available on the settings page of your app
      appId: Config.IAPHUB_APPID,
      // The (client) api key is available on the settings page of your app
      apiKey: Config.IAPHUB_APIKEY,
      // App environment (production by default, other environments must be created on the IAPHUB dashboard)
      environment: __DEV__ ? 'staging' : 'production'
    })
    console.log('init SUCCESS ===>')
    _userSetup()
  } catch (e) {
    console.log('init FAIL ===>', e)
    reportError(e, { iapMeta: 'init' })
  }
}

const _userSetup = async () => {
  const userToken = await loadString(verificationKey)

  try {
    await IapHub.setUserId(userToken)
    console.log('setUserId SUCCESS ===>')
  } catch (e) {
    console.log('setUserId FAIL ===>', e)
    reportError(e, { iapMeta: 'setUserId', userToken })
  }
}

// error on the function down below:
export const GetProducts = async (): Promise<Array<IapHubProductInformation>> | undefined => {
  let res: IapHubProductInformation[]
  try {
    res = await IapHub.getProductsForSale()
    console.log("getProductsForSale SUCCESS ----->", res);
  } catch (e) {
    console.log('getProductsForSale FAIL ===>', e);
    reportError(e, { iapMeta: 'getProductsForSale' }) 
  }
  return res
}

the response from GetProducts() is:

error: user_id_invalid

Screen Shot 2020-12-18 at 10 25 18

I've tried to change to deviceId and the same error happened and there isn't much information about it, do you guys have any clue about that?

Weird behavior with getProductsForSale()

Hi all,

I'm running into an issue where when I call:

Iaphub.getProductsForSale()

I correctly get a network call that has the products, however the function returns an empty array. I have published a listing, not sure why im getting an empty array when i do see the product in the network call that this library is performing.

Please see screenshot below.

image

P.S: Interestingly, this library performs two calls (not sure why). Here's the second which responds with nothing:

image

Any help is appreciated

TLDR:

  1. Calling Iaphub.getProductsForSale()
  2. Getting an empty array
  3. Seeing that the products are being fetched in network call but still getting an empty array when using getProductsForSale

Missing pod install instructions in documation

Hey, thanks for your work!

I am currently working on integrating it into my app. However I found that after I installed it with npm using your instructions, and trying to run it on ios, it gave me an error

error Could not find the following native modules: RNIap. Did you forget to run "pod install" ?

I think it could benefit putting it in your install instructions that this is a provided step.

Questions regarding the pricing

Hi,

I have some questions regarding what is called an active user.
Does calling the Iaphub.init() method, make the user counted as active, or only when calling setUserId() ?

If not, do you have a list of methods that would count the user as active ?

When is the first moment that the user is counted as active ?

Is there an API endpoint to create products on the fly?

Is there a way to create products to the dashboard other than manually doing it? We provide white label apps to clients and these clients have their own dashboard for setting up products on their end.

We could ask them to create the product on their own google play console and apple connect thats not a problem. But it would be nice if they could just fill out a form with their product SKU on our end then we can submit it to IAPHUB via API endpoint for faster transactions.

Is this process currently available or we have no way for automating the product creation?

Android crashes with: RNIapModule.buyItemByType got 8 arguments, expected 7

We've had our android implementation working fine, but out of the blue we're now getting a crash when trying to use await Iaphub.buy(sku)

Versions:
"react-native-iap": "^4.6.3", "react-native-iaphub": "^4.1.3",

09-26 19:08:31.188  8531  8950 E unknown:ReactNative: com.facebook.react.bridge.NativeArgumentsParseException: RNIapModule.buyItemByType got 8 arguments, expected 7
09-26 19:08:31.188  8531  8950 E unknown:ReactNative: 	at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:349)
09-26 19:08:31.188  8531  8950 E unknown:ReactNative: 	at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151)
09-26 19:08:31.188  8531  8950 E unknown:ReactNative: 	at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
09-26 19:08:31.188  8531  8950 E unknown:ReactNative: 	at android.os.Handler.handleCallback(Handler.java:873)
09-26 19:08:31.188  8531  8950 E unknown:ReactNative: 	at android.os.Handler.dispatchMessage(Handler.java:99)
09-26 19:08:31.188  8531  8950 E unknown:ReactNative: 	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
09-26 19:08:31.188  8531  8950 E unknown:ReactNative: 	at android.os.Looper.loop(Looper.java:193)
09-26 19:08:31.188  8531  8950 E unknown:ReactNative: 	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226)
09-26 19:08:31.188  8531  8950 E unknown:ReactNative: 	at java.lang.Thread.run(Thread.java:764)
09-26 19:08:31.188  8531  8950 E unknown:ReactNative: Exception in native call
09-26 19:08:31.188  8531  8950 E unknown:ReactNative: com.facebook.react.bridge.NativeArgumentsParseException: RNIapModule.buyItemByType got 8 arguments, expected 7
09-26 19:08:31.188  8531  8950 E unknown:ReactNative: 	at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:349)
09-26 19:08:31.188  8531  8950 E unknown:ReactNative: 	at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151)
09-26 19:08:31.188  8531  8950 E unknown:ReactNative: 	at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
09-26 19:08:31.188  8531  8950 E unknown:ReactNative: 	at android.os.Handler.handleCallback(Handler.java:873)
09-26 19:08:31.188  8531  8950 E unknown:ReactNative: 	at android.os.Handler.dispatchMessage(Handler.java:99)
09-26 19:08:31.188  8531  8950 E unknown:ReactNative: 	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
09-26 19:08:31.188  8531  8950 E unknown:ReactNative: 	at android.os.Looper.loop(Looper.java:193)
09-26 19:08:31.188  8531  8950 E unknown:ReactNative: 	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226)
09-26 19:08:31.188  8531  8950 E unknown:ReactNative: 	at java.lang.Thread.run(Thread.java:764)```

subscription does not work on iOS 13.5 "Error: The operation couldn't be completed. (SKErrorDomain error 0)"

Hello everyone, I've set up a subscription group on apple connect and did the same in iaphub dashboard. I've also configured a sandbox testing account and created a storekit file for testing on an iOS emulator. It works fine on iOS 14.x simulators and i'm able to subscribe to the monthly plans that I have created. However, when trying to subscribe on iOS 13.5 simulator I get the following error: Error: The operation couldn't be completed. (SKErrorDomain error 0).

It's worth mentioning that everything works fine on Android and i'm able to subscribe and manage subscriptions.

React native: 0.63.4
react-native-iap: 5.1.3
react-native-iaphub: 6.0.3

TypeError: Cannot read property 'startListening' of undefined

infoLog.js:16 Running "Loader" with {"rootTag":21}
core.js:37 TypeError: Cannot read property 'startListening' of undefined
    at Object.purchaseUpdatedListener (index.js:605)
    at Iaphub.init$ (index.js:88)
    at tryCatch (runtime.js:45)
    at Generator.invoke [as _invoke] (runtime.js:274)
    at Generator.prototype.<computed> [as next] (runtime.js:97)
    at tryCatch (runtime.js:45)
    at invoke (runtime.js:135)
    at runtime.js:145
    at tryCallOne (core.js:37)
    at core.js:123

Error is at

// Init listeners
RNIap.purchaseUpdatedListener(async (purchase) => {
// If the user isn't logged we save the event in a queue (that will be executed when the user login)
if (!this.isLogged) {
this.purchaseUpdatedEvents.push(purchase);
}
// Otherwise we process the receipt
else {
await this.processReceipt(purchase);
}
});
RNIap.purchaseErrorListener((err) => {
// If the user isn't logged we save the event in a queue (that will be executed when the user login)
if (!this.isLogged) {
this.purchaseErrorEvents.push(err);
}
// Otherwise we trigger the error
else {
this.emitPurchaseError(err);
}
});

'Reciept failed'

I am moving over from react-native-iap to react-native-iaphub (due to the hub having inbuilt webhooks for subscription changes), however during development on my staging environment, I am constantly getting 'the processing of a receipt has failed' notification emails.

I have setup that the Iaphub is initialised at the correct place on app startup, I then login in a user at the correct stage too - I can get a list of productsForSale where I need to, so that's working fine.

However, it's when I use the Iaphub.buy(productSku) I have issues. It's for both consumables and renewable subscriptions. I have setup the shared secret for iOS and the Google Play credentials for Android, so the processing should go through fine... As I said at the beginning, I am moving over from react-native-iap, and the purchases/subscriptions worked fine there - and I believe you use this package anyway as a dependency for iaphub.

I tried adding my card to move to a 'production plan` in case it was that however, that hail mary didn't work.

Am I missing something?

IapHub.buy() doesn't return anything

When I try to use the buy() method it doesn't do anything after the purchase is done, blocking me from doing anything after it. It seems as if the promise is never finished, the code never reaches console.log(transaction) or finally {}. This used to work a couple of days ago. I do see they receipt in the IAPHUB dashboard though.

try {
  const transaction = await IapHub.buy('product_sku')
  console.log(transaction)
} catch (err) {
  console.log(err)
} finally {
  console.log('finally done')
}

I also see this in the Xcode logs:

 Purchase Started !!
2020-07-23 00:09:26.745113-0400 Development[1039:184402] 




 Purchase Successful !! 




.

So the purchase is successful.

react-native-iaphub v3.0.9
react-native-iap v4.4.3
react-native v0.63.2

Webhook not triggered!

Hi guys!

I setted up a webhook in firebase cloud-functions but when i trigger a purchase event then nothing happen. When i update the webhook endpoint on iaphub settings, the test trigger is successful and i get the test request. Should i call some other api call or do you have any idea?
Would be great to give some advice.

Thx, for helping me.

Getting TypeError: IAPHub.init is not a function

"react-native": "^0.63.2",
"react-native-iap": "5.1.3",
"react-native-iaphub": "^6.0.5",

Code
import * as IAPHub from 'react-native-iaphub'
import { useDispatch } from 'react-redux'

const init = async () => {
await IAPHub.init({
appId: "id",
apiKey: "key",
environment: "production"
})
}

I'll be really thankful if someone can help me out with this

No active products returned

Version

6.0.4

Current Behavior

Not returning the active products from the published listing.

Expected Behavior

It should show the list of active products when I query them using getActiveProducts method.

Other info

react-native v0.63.2
react-native-iap v5.2.0

feature request: execute callback when android is done processing payment

On android, when you initiate the IapHub.buy() function, it shows the google play purchase UI. When the payment in finished processing in the google play purchase UI is still takes some time before the buy() Promise is resolved. (I assume it verifies the purchase receipt during this time.) However, as soon as the google play purchase UI is closed I would like to show an element letting the user know that his payment is being processed further. Would it be possible to pass a callback to the buy() function that is executed as soon as the google play purchase UI closes?

Error (plan_limit_reached)

Today I'm getting this error, while fetching products with this function => Iaphub.getProductsForSale()
Error: "api request returned an error (plan_limit_reached)"

I can't get the products...

But I did not even pushed the IAP feature to production, and there are just 10 "test users", so the 500 active users limit was not reached.

Why the userId must not be public?

My userIds are provided by Firebase auth via Google/Apple/Facebook and are somewhat discoverable. What could go wrong if I used it in await Iaphub.setUserId(...)? I am going to use webhooks (will call Google Cloud Functions) to write on the DB that the user has made the purchase / refunded

productsForSale is empty

Hi Team,
Thanks for the great library and the product. I'm running into an issue and hope you can help.

I followed the instructions and created a product and also published the listing on IAP HUB. But, when I fetch the user profile (.getUser()), the productsForSale is coming as an empty array.

Can you please let me know what might be going wrong here?

Thanks!

[QUESTION] Webhooks, restore

Hello,
Thanks for this great plugin

I have some questions:

  • if I have no server to send for the webhook I can use this plugin ? I would like to save my purchases later, but not yet possible?
  • my app doesn't have a login, so i use the deviceID for the ID of user, if the user changes the phone, he will suddenly have the option of being able to restore his purchases, right?

Thanks,

Manually trigger a webhook?

We have 2 different teams working on a iap feature. One for the mobile that handles the iap and the backend that will manage the webhook events. Is there a way to make test purchase, refund, etc and trigger the webhook smanually for specific type of events? or is this only achievable by completely setting up the prerequisite process for the mobile app?

Subscription modification error!

Hi guys! I get always purchase error when i want to change the subscription product. I got success from itunes, but ipahub library drop error with the case of error "Couldn't buy product for many other reasons (the user shouldn't be charged)", but i got the success product change from iaphub too, but doesnt change the subscription product. Maybe this is a sandbox issue, or something wrong?

Thx for help.

Wanted to say thanks!

I've been working with iap for over then 6 years, and this is one of the best libraries that closes a full cycle
If you got here from Google by accident, they did you the best favour ever

Easy integration.
Great example.
ANND they take all the server processing which is horrible at apple

In the example, I would have included a scenario, of how the app changes upon the iap being complete, how to maintain it, and how to react when the member cancelled his purchase

8 arguments expected in buyItemByType

Just tried to update to the most recent version 5.1.0 (along with the recommended react native iap V4.6.3) and I'm getting this error. I don't have a lot more information that I'm sure would be helpful, but hopefully this report helps in some way.

RNIapModule.buyItemByType got 7 arguments, expected 8

TypeScript definitions

Hi,

Thx for this wonderful plugin, it help a lot the inapp purchase headache.

Is there a plan for having TypeScript definitions in the future, would be helpful ๐Ÿ˜„

Regards
Alexis

Questions about library

I just had few questions about the library, I'm not sure about some things

  • How does restore work ? We would like to avoid accounts and use deviceID. If the user has a new device how does the restore method work ? We have to set the old device ID as userId and call restore ?
  • Does Iaphub.getActiveProducts() count as an active user api call ? Because we would like to avoid having each user counted as active user just because we are checking if the user has subscribed and has access to premium features.

Best regards

Play store may be down

[Error: The service is unreachable. This may be your internet connection, or the Play Store may be down.]

async initIapHUB() { IAPHub.init({ appId: '[]', apiKey: '[]', environment: 'production', }) .then(() => { IAPHub.setUserId(deviceId) .then(() => { IAPHub.getProductsForSale() .then((products) => { console.log(products); }) .catch(err => { console.log(err); }); }) .catch(err => { console.log(err); }); }) .catch(err => { console.log(err); }); }
This is because i am using debug mode?
Playstore is already login.

Thank you

Delete test users

Hello,

I am testing the service and I reached the maximum number of users but they are all users I created in sandbox to test the platform. How can I delete them?

Thanks!

Refund webhook not being called (at least on dev env, auto subscription and on Google)

Hey, my purchase system is almost working 100%, purchase, paused, renew etc webhooks being called as they should, but today when testing the Refund (so I can disable the features to the user) in dev env, no webhook was being called when the refund was processed.

I received the successful refund e-mail from Google, with a matching orderId (GPA.3362-0910-4103-82193), but still nothing happened by IAPHUB. The only webhook received after the refund, was the purchase expiration itself (which maybe shouldn't be called, as the refund happens before the expire)

Purchase webhook, before refund
{
  id: '6006cef1a897c30e257b8617',
  type: 'purchase',
  createdDate: '2021-01-19T12:22:09.402Z',
  version: '1.2.0',
  data: {
    id: '6006cef1a897c30e257b8613',
    purchaseDate: '2021-01-19T12:22:04.536Z',
    quantity: 1,
    platform: 'android',
    country: 'BR',
    tags: {},
    orderId: 'GPA.3362-0910-4103-82193',
    app: '5fcee799c9cf7c0eb55c04dd',
    user: '6005fd6a14a85c0ea55f279a',
    product: '5fd7b8f48195d60eaa122705',
    receipt: '6006cef0a897c30e257b8610',
    listing: '5fd18d765c877f0e20fe992c',
    store: '5fd18d765c877f0e20fe992e',
    currency: 'BRL',
    price: 74.99,
    convertedCurrency: 'BRL',
    convertedPrice: 74.99,
    isSandbox: true,
    isRefunded: false,
    isSubscription: true,
    isSubscriptionActive: true,
    isSubscriptionRenewable: true,
    isSubscriptionRetryPeriod: false,
    isSubscriptionGracePeriod: false,
    isSubscriptionPaused: false,
    isTrialConversion: false,
    subscriptionState: 'active',
    subscriptionPeriodType: 'normal',
    expirationDate: '2021-01-19T12:33:59.596Z',
    originalPurchase: '6006cef1a897c30e257b8613',
    userId: 'EW4UWtLtJihjoS1yeSszTmC8jlgx',
    productSku: 'app_contador.os_android.id_license.id2_1.t_3m.v_2',
    productType: 'renewable_subscription'
  }
}
Expire webhook, some time after the refund (but not actually the refund webhook)
{
  id: '6006d218452f872787e95519',
  type: 'subscription_expire',
  createdDate: '2021-01-19T12:35:36.819Z',
  version: '1.2.0',
  data: {
    id: '6006cef1a897c30e257b8613',
    purchaseDate: '2021-01-19T12:22:04.536Z',
    quantity: 1,
    platform: 'android',
    country: 'BR',
    tags: {},
    orderId: 'GPA.3362-0910-4103-82193',
    app: '5fcee799c9cf7c0eb55c04dd',
    user: '6005fd6a14a85c0ea55f279a',
    product: '5fd7b8f48195d60eaa122705',
    receipt: '6006cef0a897c30e257b8610',
    listing: '5fd18d765c877f0e20fe992c',
    store: '5fd18d765c877f0e20fe992e',
    currency: 'BRL',
    price: 74.99,
    convertedCurrency: 'BRL',
    convertedPrice: 74.99,
    isSandbox: true,
    isRefunded: false,
    isSubscription: true,
    isSubscriptionActive: false,
    isSubscriptionRenewable: false,
    isSubscriptionRetryPeriod: false,
    isSubscriptionGracePeriod: false,
    isSubscriptionPaused: false,
    isTrialConversion: false,
    subscriptionState: 'expired',
    subscriptionPeriodType: 'normal',
    subscriptionCancelReason: 'customer_cancelled',
    expirationDate: '2021-01-19T12:23:37.797Z',
    originalPurchase: '6006cef1a897c30e257b8613',
    userId: 'EW4UWtLtJihjoS1yeSszTmC8jlgx',
    productSku: 'app_contador.os_android.id_license.id2_1.t_3m.v_2',
    productType: 'renewable_subscription'
  }
}

Questions:

  1. Is this intended / known bug?
  2. Will that also happen on prod?
  3. On a working-as-expected refund webhook, what will be the subscriptionState field?

About Google Play local pricing and more

The Google Play console supports special IAP prices depending the user Country.

However, the IAPHUB console has just one price field. How is used this price field? Just for the statistics?

As Apple don't allow special prices depending of the location, I had the idea of naming my SKUs with "license_us_3m_1", being us the country code (any, maybe using 'zz' for fallback), 3m the subscription period, and 1 the version of the product. The frontend would then get its location (already managed to do that with Cloud Functions 'x-appengine-country' request header), and always select the highest product version, and the corresponding country code, or the fallback one.

Do you have any experience with special prices for countries? Have any better idea?

Restore not working anymore

Hello,

Restore function always returning "Can not connect to iTunes" error for the last version of SDK. Buy functionality is working as expected.

Have a great day!

published_listing_not_found error

Hello ๐Ÿ‘‹

Running into the error in the title.

  1. I have run the init.
  2. I set the user's id
  3. I try to call getProductsForSale() and i get a 400 with published_listing_not_found.

I couldn't find any mention of this in the documentation or on github. What does this error mean?

Thank you,

Receipt Failure

Is anyone else constantly getting receipt failure errors? I'm in sandbox mode testing on a real iOS device for a subscription purchase. The actual in-app purchase flow works(click buy, input sandbox password, confirm, get alert box from apple that purchase was successful, etc) but after that every single time I get the error "FOUND: Error: Receipt validation on IAPHUB failed, receipt processing will be retried". Any suggestions on how to fix this? My function is exactly the same as the example buy function on the repo:
try {
var transaction = await Iaphub.buy("PRODUCTSKU", {
// Optional property to override the default proration mode on Android (https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.ProrationMode)
androidProrationMode: 1,
// Optional callback triggered before the receipt is processed
onReceiptProcess: (receipt) => {
console.log('Purchase success, processing receipt...');
}
});

/*

  • The purchase has been successful but we need to check that the webhook to our server was successful as well
  • If the webhook request failed, IAPHUB will send you an alert and retry again in 1 minute, 10 minutes, 1 hour and 24 hours.
  • You can retry the webhook directly from the dashboard as well
    /
    if (transaction.webhookStatus == "failed") {
    Alert.alert(
    "Purchase delayed",
    "Your purchase was successful but we need some more time to validate it, should arrive soon! Otherwise contact the support ([email protected])"
    );
    }
    // Everything was successful! Yay!
    else {
    Alert.alert(
    "Purchase successful",
    "Your purchase has been processed successfully!"
    );
    }
    } catch (err) {
    // Purchase popup cancelled by the user (ios only)
    if (err.code == "user_cancelled") return
    // Couldn't buy product because it has been bought in the past but hasn't been consumed (restore needed)
    else if (err.code == "product_already_owned") {
    Alert.alert(
    "Product already owned",
    "Please restore your purchases in order to fix that issue",
    [
    {text: 'Cancel', style: 'cancel'},
    {text: 'Restore', onPress: () => Iaphub.restore()}
    ]
    );
    }
    // The payment has been deferred (awaiting approval from parental control)
    else if (err.code == "deferred_payment") {
    Alert.alert(
    "Purchase awaiting approval",
    "Your purchase is awaiting approval from the parental control"
    );
    }
    /
  • The receipt has been processed on IAPHUB but something went wrong
  • It is probably because of an issue with the configuration of your app or a call to the Itunes/GooglePlay API that failed
  • IAPHUB will send you an email notification when a receipt fails, by checking the receipt on the dashboard you'll find a detailed report of the error
  • After fixing the issue (if there's any), just click on the 'New report' button in order to process the receipt again
  • If it is an error contacting the Itunes/GooglePlay API, IAPHUB will retry to process the receipt automatically as well
    /
    else if (err.code == "receipt_validation_failed") {
    Alert.alert(
    "We're having trouble validating your transaction",
    "Give us some time, we'll retry to validate your transaction ASAP!"
    );
    }
    /
  • The receipt has been processed on IAPHUB but is invalid
  • It could be a fraud attempt, using apps such as Freedom or Lucky Patcher on an Android rooted device
    /
    else if (err.code == "receipt_invalid") {
    Alert.alert(
    "Purchase error",
    "We were not able to process your purchase, if you've been charged please contact the support ([email protected])"
    );
    }
    /
  • The receipt hasn't been validated on IAPHUB (Could be an issue like a network error...)
  • The user will have to restore its purchases in order to validate the transaction
  • An automatic restore should be triggered on every relaunch of your app since the transaction hasn't been 'finished'
  • Android should automatically refund transactions that are not 'finished' after 3 days
    */
    else if (err.code == "receipt_request_failed") {
    Alert.alert(
    "We're having trouble validating your transaction",
    "Please try to restore your purchases later (Button in the settings) or contact the support ([email protected])"
    );
    }
    // Couldn't buy product for many other reasons (the user shouldn't be charged)
    else {
    Alert.alert(
    "Purchase error",
    "We were not able to process your purchase, please try again later or contact the support ([email protected])"
    );
    }
    }

Skus not found on Android

Hi, i try to get products from IapHub but on android got always error, that skus not found. I tried wit react-native-iap and its worked, on ios iaphub works as expected.
Is it development error, or Iaphub settings error, but i have green light at android setup block?
Do you have any idea what should i do?

Iinit state is undefined.

Thx
Daniel

Auto-renewable subscription doesn't renew on Sandbox

Hey guys, how's everything?

I'm setting up IAPHUB on my React Native App and using Webhooks on a node backend. Yesterday, while testing, I noticed that all my purchases weren't being renewed, even though all my subscriptions are set as Auto-renewable subscription. When I click on the webhook to see more information, I've noticed this field on the request body:

"subscriptionCancelReason":"customer_cancelled"

The funny thing is that I haven't canceled the subscription at any anytime and throughout the last week, I wasn't getting this kind of behavior, all my subscriptions were auto-renewing. Is this normal when I'm using the Sandbox environment? Or it can be something on my app or our backend? Again, this just started happening yesterday.

Thanks in advance!

getProductsForSale() not returning all products

I've been killing myself on this one.

I cannot get getProductsForSale() to return more than one product, even though I have two fully setup in the IAPHub Dashboard and on App Store Connect.

On App Store Connect, one product is already for sale and live on the store, the other is "Ready for Review" but the "Cleared for Sale" checkbox is checked. Both of them are non-consumable (not subscriptions).

react-native-iap: 4.6.3
react-native-iaphub: 5.1.0

  • iOS 14.2 (testing on-device)
  • iPhone XS

Here's the code I'm using (somewhat simplified/overstylized for clarity):

    import IAPHub from 'react-native-iaphub';
    ...
    const deviceId = DeviceInfo.getUniqueId();
    IAPHub.init({
      appId: '[removed my appID]',
      apiKey: '[removed my apiKey]',
      environment: 'production',
    })
    .then(() => {
      IAPHub.setUserId(deviceId)
      .then(() => {
        IAPHub.getProductsForSale()
        .then((products) => {
          console.log(products);  // *** here's where I'm expecting two products to return, but only get one... or zero...
        })
        .catch(err => {
          console.log(err);
        });
      })
      .catch(err => {
        console.log(err);
      });
    })
    .catch(err => {
      console.log(err);
    });

My device is only returning ONE of the TWO in-app purchases from getProductsForSale().

Strangely, the result seems to change if I change the userID. For a while, one user was returning [] from getProductsForSale(). I changed its userID and then it started returning one product. But not two.

If it helps, the product being returned is the one currently for sale on the App Store.

No errors are returned.

Am I missing the correct way to get ALL products for sale?

Update types for `getActiveProducts` and export subscription states

Even though getActiveProducts takes options as arguments, as specified in the README, it looks like these options haven't been added to the typings.

Also it would be useful to have the subscription states: active, grace_period, retry_period, and paused exported for type safety reasons.

Massive thanks to you all for making this package, it's a life saver, and so easy to use!

Question regarding payment

Hi,
i have a question regarding the scope of this library. Does this library support the ui that the user chooses with what card he will pay, or do i have to install another library to support this, for example:
image

Thanks.

Example > Android : !need extra step

step to reproduce :

  1. download example
  2. npm i
  3. npx react-native run-android

ERROR >

What went wrong:
A problem occurred configuring project ':app'.

SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/Users/asd/Downloads/react-native-iaphub-master/Example/android/local.properties'.

Solution >
1.create new file named local.properties in Android/ folder
2.add this sdk.dir=/Users/asd/Library/Android/sdk
3. run again

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.