Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buyProductWithOfferIOS fails with E_UNKNOWN error #516

Closed
cl2205 opened this issue Jun 12, 2019 · 9 comments
Closed

buyProductWithOfferIOS fails with E_UNKNOWN error #516

cl2205 opened this issue Jun 12, 2019 · 9 comments
Assignees
Labels
🙏 help wanted Extra attention is needed 📱 iOS Related to iOS 🚶🏻 stale Stale

Comments

@cl2205
Copy link

cl2205 commented Jun 12, 2019

Version of react-native-iap

2.5.5

Version of react-native

0.59.3

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

iOS

Expected behavior

A purchase with an Apple Subscription Offer discount applied should succeed with some feedback, ie. 'Purchase was successful' modal from StoreKit. The discount transaction should also be reflected in the ios receipt thereafter.

Actual behavior

I'm able to get up to getting the StoreKit modals for seeing the correct discount price from the subscription offer and confirming the subscription, but it fails at the end w/ this Alert modal: Unable to Purchase Contact the developer for more information.

Can also confirm that the transaction is also missing from the iOS receipt.

On the other hand, I can confirm that a regular purchase transaction without any subscription offer succeeds in the current sandbox environment and am able to connect to the iTunes Store.

Here's the error stack:

{
    framesToPop: 1,
    code: 'E_UNKNOWN',
    nativeStackIOS: [
      '0   shine                               0x00000001050b9524 RCTJSErrorFromCodeMessageAndNSError + 156',
      '1   shine                               0x0000000105060dfc __41-[RCTModuleMethod processMethodSignature]_block_invoke_2.129 + 176',
      '2   shine                               0x0000000104fb9e18 -[RNIapIos rejectPromisesForKey:code:message:error:] + 512',
      '3   shine                               0x0000000104fbd124 __45-[RNIapIos paymentQueue:updatedTransactions:]_block_invoke + 312',
      '4   libdispatch.dylib                   0x000000018ce01884 <redacted> + 20',
      '5   libdispatch.dylib                   0x000000018ce0e404 <redacted> + 60',
      '6   shine                               0x0000000104fbced0 -[RNIapIos paymentQueue:updatedTransactions:] + 908',
      '7   libdispatch.dylib                   0x000000018ce00304 <redacted> + 32',
      '8   libdispatch.dylib                   0x000000018ce01884 <redacted> + 20',
      '9   libdispatch.dylib                   0x000000018ce0d73c _dispatch_main_queue_callback_4CF + 1012',
      '10  CoreFoundation                      0x000000018d382024 <redacted> + 16',
      '11  CoreFoundation                      0x000000018d37ccd4 <redacted> + 1888',
      '12  CoreFoundation                      0x000000018d37c254 CFRunLoopRunSpecific + 452',
      '13  GraphicsServices                    0x000000018f5bbd8c GSEventRunModal + 108',
      '14  UIKitCore                           0x00000001ba6c44c0 UIApplicationMain + 216',
      '15  shine                               0x0000000104cda748 main + 124',
      '16  libdyld.dylib                       0x000000018ce38fd8 <redacted> + 4'
    ],
    domain: 'SKErrorDomain',
    userInfo: {
      NSLocalizedDescription: 'Cannot connect to iTunes Store'
    }

Tested environment (Emulator? Real Device?)

On a real device using a Sandbox account

Steps to reproduce the behavior

  • Set up a subscription offer on App Store Connect
  • Make a signature request to your server and get a returned offer containing the required signature string, nonce, timestamp, and keyIdentifier
  • Create a subscription offer complete with signature, and call RNIap.buyProductWithOfferIO with productId, uid, and offer
@hyochan
Copy link
Owner

hyochan commented Jun 12, 2019

@cl2205 I've not had test this feature throughly done in #455. @sck-v Could you assist this?

P.S. It looks like you can't even connect to iTunes Store which means your sandbox account has issue in testing billing.

@hyochan hyochan added 🙏 help wanted Extra attention is needed 📱 iOS Related to iOS labels Jun 12, 2019
@cl2205
Copy link
Author

cl2205 commented Jun 12, 2019

Thanks @hyochan. I'm able to consistently connect to the iTunes store and make a regular purchase transaction (via buySubscription()) using the sandbox account -- just not with buyProductWithOffer()

@hyochan
Copy link
Owner

hyochan commented Jun 12, 2019

@cl2205 That's bit strange since the error message is NSLocalizedDescription: 'Cannot connect to iTunes Store'. Could you kindly provide your codes here?

@cl2205
Copy link
Author

cl2205 commented Jun 12, 2019

@hyochan here you go (using mock offer data here):

// Purchase with Subscription Offer

const offer = {
    identifier: 'TESTOFFER', // from iTunes products discounts array
    keyIdentifier: 'MYK3Y1D' // from server,
    nonce: <nonce>, // from server
    signature: <base64-encoded-string>, // from server
    timestamp: 1560290457029 // from server
    };

  const sku = 'com.myteam.myapp.iap.monthly';
  const uid = <applicationUsername-string>; // I've tried using both empty str and non-empty str values here. This is an optional string value for `applicationUsername` that can be an empty str as noted in the server signature docs: https://developer.apple.com/documentation/storekit/in-app_purchase/generating_a_signature_for_subscription_offers?language=objc
  
  const products = await loadProducts();   // this is successful
  const response = await RNIap.buyProductWithOfferIOS(sku, uid, offer); // StoreKit shows discount is applied but when confirming the purchase, transaction fails w/ above error
     

---------
// Regular Purchase

const sku = 'com.myteam.myapp.iap.monthly';
const response = await RNIap.buySubscription(sku);  // this is successful

@hyochan
Copy link
Owner

hyochan commented Jun 18, 2019

@cl2205 Have you solved the issue? I've looked through here and seems below will help.
image

@cl2205
Copy link
Author

cl2205 commented Jun 19, 2019

@hyochan thanks for sharing that thread!

I do seem to have resolved the issue of getting that particular alert of Unable to Purchase - Contact the developer for more information. and it does seem to have been related to the applicationUsername length. Thank you much for your help on that.

Unfortunately another issue I'm running into now is that the transaction still fails. Now I'm getting the system success modal of 'You're all set. The purchase was successful' even though the transaction fails with an SKError code of 0 -- basically the issue described in this thread except it's happening even with an expired subscription for me: https://forums.developer.apple.com/thread/118286

@stale
Copy link

stale bot commented Sep 17, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@stale stale bot added the 🚶🏻 stale Stale label Sep 17, 2019
@stale
Copy link

stale bot commented Oct 17, 2019

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@caoyongfeng0214
Copy link

@hyochan thanks for sharing that thread!

I do seem to have resolved the issue of getting that particular alert of Unable to Purchase - Contact the developer for more information. and it does seem to have been related to the applicationUsername length. Thank you much for your help on that.

Unfortunately another issue I'm running into now is that the transaction still fails. Now I'm getting the system success modal of 'You're all set. The purchase was successful' even though the transaction fails with an SKError code of 0 -- basically the issue described in this thread except it's happening even with an expired subscription for me: https://forums.developer.apple.com/thread/118286

How did you fix Unable to Purchase - Contact the developer for more information?
Please help me. #2629

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙏 help wanted Extra attention is needed 📱 iOS Related to iOS 🚶🏻 stale Stale
Projects
None yet
Development

No branches or pull requests

4 participants