chirag04 / react-native-in-app-utils

A react-native wrapper for handling in-app payments
MIT License
890 stars 185 forks source link

It won't purchase... ever. Help please! #50

Closed chemimartinez77 closed 7 years ago

chemimartinez77 commented 8 years ago

Hello everybody,

Here is my issue. I've done this:

var products = [
   'com.xyz.abc',
];
InAppUtils.loadProducts(products, (error, products) => {
   //update store here.
});

and also this:

var productIdentifier = 'com.xyz.abc';
InAppUtils.purchaseProduct(productIdentifier, (error, response) => {
   // NOTE for v3.0: User can cancel the payment which will be availble as error object here.
   if(response && response.productIdentifier) {
      AlertIOS.alert('Purchase Successful', 'Your Transaction ID is ' + response.transactionIdentifier);
      //unlock store here.
   }
});

The thing is that everything seems to go well but it never enters the piece of code where the store has to be unlocked.

When I tap on the icon of the inAPP purchase product, it opens the dialog to buy it. If I buy it, it does nothing. Not even an alert. It's like InAppUtils.purchaseProduct now would be working differently. It never callsback. All the management lays on the purchaseProduct method and it says the product has been purchased but not with the alert or alerts I'm trying to use.

Can anyone help? Thanks in advance!

chirag04 commented 8 years ago

are you getting the callback for purchaseProduct? see if you have an error

var productIdentifier = 'com.xyz.abc';
InAppUtils.purchaseProduct(productIdentifier, (error, response) => {
     console.log(error, response);
});
chemimartinez77 commented 8 years ago

@chirag04 I'm not getting the callback. Take a look at my real code and the log. I can't understand why it isn't working. By the way, I already purchase it in Sandbox Mode so if I say yes to continue buying, the app throws a dialogue saying if I want to download it again. May it has to do with restorePurchases? Thank you again and much more for being so fast!

      var productIdentifier = 'xxx.yyy.zzz.productName';
      console.log('Identificador de producto: '+ productIdentifier);
      InAppUtils.purchaseProduct(productIdentifier, (error, response) => {
        console.log('Working?');
         // NOTE for v3.0: User can cancel the payment which will be availble as error object here.
         console.log(error, response);
         if(response) console.log('Respuesta: '+response);
         if(response && response.productIdentifier) {
            Alert.alert('Purchase Successful', 'Your Transaction ID is ' + response.transactionIdentifier);
            //unlock store here.

         }
      });

And the log says:

2016-10-25 15:58:19.311 [info][tid:com.facebook.react.JavaScript] Identificador de producto: xxx.yyy.zzz.productName 2016-10-25 15:58:19.310988 ProjectName[950:613723] Identificador de producto: xxx.yyy.zzz.productName 2016-10-25 15:58:19.313470 ProjectName[950:613683] purchasing

chirag04 commented 8 years ago

it seems like the purchase did went through. Not sure whats going on with the callback.

Can you put debug point here and see which case it's executing and see if callback is empty or something: https://github.com/chirag04/react-native-in-app-utils/blob/master/InAppUtils/InAppUtils.m#L32

chemimartinez77 commented 8 years ago

Thanks, debugging right now. I'll let you notice when I'm done.

chemimartinez77 commented 8 years ago

It seems to run all the way through the code. Seems to be working ok. Can you take a look?

chirag04 commented 8 years ago

well. i'm assuming callback in that screenshot exists. you should be getting the js callback.

chemimartinez77 commented 8 years ago

Yes, it exists. But it's something quite unreadable. Any hint?

chemimartinez77 commented 8 years ago

@chirag04 Hello again, I'm really confused at this point. Any hint? Thank you so much again

chirag04 commented 8 years ago

@chemimartinez77 if the callback exists you should see something in JS land. Not sure what's going on.

cc @marcgreenstock @grabbou Not sure if you guys are still using this lib. If yes have you guys seen anything like this?

chemimartinez77 commented 8 years ago

@chirag04 Tahnks for your fast response. Hoping to find a solution soon 👍

namestise commented 8 years ago

@chemimartinez77 this happen to me as well.

Try submit your app. After Apple accept your app, try download from app store and purchase your in app purchase. In my case, purchase happen. Not sure why. Maybe something went wrong with sandbox mode.

Dacello commented 7 years ago

Was anyone able to solve this? We are seeing this happen for our in app purchases in an app that is in production. Our code does what is suggested in the docs

var productIdentifier = 'com.xyz.abc';
InAppUtils.purchaseProduct(productIdentifier, (error, response) => {
   if(response && response.productIdentifier) {
      AlertIOS.alert('Purchase Successful', 'Your Transaction ID is ' + response.transactionIdentifier);
      //unlock store here.
   } else {
      AlertIOS.alert('We could not complete your transaction.', error)
   }
});

and the error contains the message "could not connect to iTunes store." It seems like the response doesnt have the productIdentifier in it or just doesnt exist?

Please help!

chirag04 commented 7 years ago

could not connect to iTunes store that seems like something wrong with app store. is it a consistent error or a temporary one?

Dacello commented 7 years ago

Consistent. Whats weird is it seems like the purchase actually goes through - I can tell that my subscription has been activated (this is an auto renewable subscription)

chirag04 commented 7 years ago

I haven't tested this lib with subscriptions. Happy to accept a PR for this.

Dacello commented 7 years ago

Dang. It actually has been working for us until now. I have a hunch that its because this is a case where the subscription already existed, was canceled, and then repurchased during the remaining pay period. Will investigate further and see if we can figure it out.

smowden commented 7 years ago

@Dacello have you been able to make this work (subscriptions)?

edit: subscriptions didnt work for me because I forgot to add a localization in iTunes connect

kawashimaken commented 7 years ago

Something strange happened, now I can restore all purchase data, but can not purchase, neither can I confirm receipt, the error are, [can not connect to iTunes], if it can not connect to iTunes why it can restore all purchase data? @chirag04 I am not sure if it is related to yesterday's fix. The environment is the same, and react native side did not have any change...

chirag04 commented 7 years ago

@kawashimaken it's not related to yesterday's fix.

'cannot connect to iTunes' can happen when the store is actually down or your products are not available for sale or are under review etc. Make sure your products are ready.

kawashimaken commented 7 years ago

@chirag04 Thank you for clearing up. The strange part is, till this morning (my time), I can purchase well when I tested it, and now I can not purchase, but the restore purchase data works well...

machris commented 7 years ago

I see it triggers a SKPaymentTransactionStateFailed just before the Confirmation alert dialog pops up by Apple, without even tapping on the final "Buy" option.

chirag04 commented 7 years ago

@machris can you put a breakpoint there and see the actual reason. There are many external factors into play here.

machris commented 7 years ago

"Cannot connect to iTunes Store" is the reason that comes with the SKPaymentTransaction

however why would it trigger in the first place as , the "Buy" confirmation button on the alert dialog is not yet tapped. It throws a SKPaymentTransactionStateFailed just upon showing the alert dialog.

kawashimaken commented 7 years ago

I can confirm the same with @machris the sequence is (1) in my app, click buy button (2) "Cannot connect to iTunes Store" error alert appears FIRST with error message shows "Cannot connect to iTunes Store" (3) THEN Apple buy dialog shows up, I click [purchase] button, the dialog disappear and nothing happens (4) click [ok] button on error dialog, error dialog disappear and nothing happens

@chirag04 @machris Just one piece of information. One friend of mine, using pure native code (objective-c), and of course his code has nothing to do with react native or this lib, however He started to get the same error [Error Domain=SKErrorDomain Code=0 "Cannot connect to iTunes Store"] no matter how he tried (reboot the device, re-create BundleID, re-create Sandbox tester id ...etc) I started to wonder if that Apple side may have change something (API) around purchase procedures? So, I assume that the test server for Sandbox tester might have a certain problem somehow at this time, I sent the same code to iTunesconnect, use testflight to download and test with my real-world iTunes id, but the result turns out the same, same error.

but InAppUtils.loadProducts and InAppUtils.restorePurchases just works fine!

Any ideas?

flybayer commented 7 years ago

@kawashimaken I have the exact same thing as you.

My code was working with the sandbox a few days ago but yesterday this started happening.

The first version of my app is in App Store review, so we'll see what happens.

flybayer commented 7 years ago

We are not alone

https://forums.developer.apple.com/thread/75063

kawashimaken commented 7 years ago

@flybayer yes, It started from yesterday!

flybayer commented 7 years ago

So, my app was approved and is now in the store!

But, in-app purchase is completely broken in the production app. I'm not even getting the price.

I'm going to contact Apple

kawashimaken commented 7 years ago

@flybayer Wow, it is speechless...

kawashimaken commented 7 years ago

Almost everyone on the planet is reporting this problem :-( https://forums.developer.apple.com/community/system-frameworks/in-app-purchase

machris commented 7 years ago

This issue with the iTunes Sandbox has been now sorted by Apple. This issue can close