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

Finish transaction is called too quickly #581

Closed
solidfox opened this issue Jul 4, 2019 · 14 comments
Closed

Finish transaction is called too quickly #581

solidfox opened this issue Jul 4, 2019 · 14 comments
Assignees
Labels
🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt 🏃🏻‍♀️ in progress Currently working on 📱 iOS Related to iOS

Comments

@solidfox
Copy link
Contributor

solidfox commented Jul 4, 2019

Issuehunt badges

Version of react-native-iap

3.2.4

Version of react-native

0.59.9

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

iOS (Android not yet confirmed)

Expected behavior

  1. A purchase goes through at the StoreKit side.
  2. The receipt is sent to the react-native-iap subscription.
  3. Something goes wrong and sending the receipt to the server fails.
  4. User restarts the app.
  5. StoreKit re-emits the SKPaymentTransactionStatePurchased event.
  6. The receipt is sent to the react-native-iap subscription.
  7. Receipt is sent to the app's server for validation and processing.
  8. The purchased content is assigned to the user on the server.
  9. The server acknowledges the delivery to the client.
  10. The client finishes the StoreKit transaction through react-native-iap.

Actual behavior

  1. A purchase goes through at the StoreKit side.
  2. react-native-iap finishes the StoreKit transaction automatically. 😱
  3. The receipt is sent to the react-native-iap subscription.
  4. Something goes wrong and sending the receipt to the server fails.
  5. User has paid for content that was never delivered.
  6. End of the world.

Tested environment (Emulator? Real Device?)

This can be determined directly from this line of code: https://github.com/dooboolab/react-native-iap/blob/df1483db059cddeb6fd1244d583288e5e7f6b20e/ios/RNIapIos.m#L414

Steps to reproduce the behavior


IssueHunt Summary

solidfox solidfox has been rewarded.

Backers (Total: $30.00)

Submitted pull Requests


Tips


IssueHunt has been backed by the following sponsors. Become a sponsor

@solidfox
Copy link
Contributor Author

solidfox commented Jul 4, 2019

I'll go ahead and try to solve this on the iOS side but I'd be very happy if someone could tell me if this is handled on the Android side?

@solidfox
Copy link
Contributor Author

solidfox commented Jul 4, 2019

This seems to serve the same purpose as acknowledging a purchase on Android so it should fit well into that existing api.

Edit: that should be consumeAsync for consumables.

@hyochan hyochan added 📱 iOS Related to iOS 🕵️‍♂️ need more investigation Need investigation on current issue labels Jul 4, 2019
@hyochan
Copy link
Owner

hyochan commented Jul 4, 2019

Could you kindly support us with PR or any docs that we can go over?

@solidfox
Copy link
Contributor Author

solidfox commented Jul 5, 2019

Absolutely, I'll try to make time to do a PR next week. In the meantime here is the apple documentation that explains that one should deliver the purchased material before calling finishTransaction and that SK will persist and keep providing the transaction to the observer until finish has been called.

The Provide Content and Finish the Transaction section in this document

@solidfox
Copy link
Contributor Author

solidfox commented Jul 5, 2019

I believe the correct way to handle this would be to simply expose the finishTransaction method in the react-native-iap library. To avoid breaking changes I'd suggest adding a parameter dangerouslyFinishTransactionAutomatically to the requestPurchase function and default that too true. Then do console warnings for anyone not explicitly setting that parameter that they should update their flow. The parameter can then be removed or defaulted to false in v4.0.0.

@hyochan
Copy link
Owner

hyochan commented Jul 7, 2019

@solidfox Sounds great!! Looking forward for your PR!

@hyochan
Copy link
Owner

hyochan commented Jul 9, 2019

@solidfox How are you going with this? Would you prefer better performance if we can reward on the update? I will charge extra $30 for this for your help.

@issuehunt-oss
Copy link

issuehunt-oss bot commented Jul 9, 2019

@hyochan has funded $30.00 to this issue.


@solidfox
Copy link
Contributor Author

solidfox commented Jul 9, 2019

@hyochan I started working on it today but got a bit caught up in getting the example running only to realize that the example isn't able to make purchases anyway so I guess I'll test it in my own use case.

I also noticed the remains of this commit that seems to be trying to achieve what I'm doing: edfbd12

Only seems to be cruft left though so I guess it was removed at some point?

solidfox added a commit to solidfox/react-native-iap that referenced this issue Jul 9, 2019
@solidfox
Copy link
Contributor Author

solidfox commented Jul 9, 2019

Would it be possible to get access to the flow in the documentation to add in registering the purchase with the apps server and acknowledging / finishing the transaction?

@hyochan
Copy link
Owner

hyochan commented Jul 12, 2019

@solidfox Hey great request! If you tell me your email address, I'll invite you to that diagram in draw.io

@hyochan hyochan added 🏃🏻‍♀️ in progress Currently working on and removed 🕵️‍♂️ need more investigation Need investigation on current issue labels Jul 12, 2019
@solidfox
Copy link
Contributor Author

@hyochan Thanks! You can send the invite to daniel.schlaug at gmail.

@hyochan
Copy link
Owner

hyochan commented Jul 14, 2019

@solidfox I've just shared the diagram to your email. Thanks!

@issuehunt-oss
Copy link

issuehunt-oss bot commented Jul 15, 2019

@hyochan has rewarded $21.00 to @solidfox. See it on IssueHunt

  • 💰 Total deposit: $30.00
  • 🎉 Repository reward(20%): $6.00
  • 🔧 Service fee(10%): $3.00

@issuehunt-oss issuehunt-oss bot added 🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt and removed 💵 Funded on Issuehunt This issue has been funded on Issuehunt labels Jul 15, 2019
ming436534 pushed a commit to ming436534/react-native-iap that referenced this issue Jul 19, 2019
* 'master' of https://github.com/dooboolab/react-native-iap: (107 commits)
  Release 3.3.4
  Keep valid SKUs in memory
  chore(package): update flow-bin to version 0.103.0
  Fixes hyochan#600
  Added missing types on updates in 3.3.0
  chore(package): update @types/react-native to version 0.60.2
  Release 3.3.1 (hyochan#596)
  Update travis with yarn
  Fix flow type for purchaseUpdatedListener
  Upgrade example project rn version
  chore(package): update @types/react-native to version 0.60.1
  Fix hyochan#581 finishTransaction called automatically (hyochan#589)
  Update index.js.flow
  chore(package): update lockfile yarn.lock
  chore(package): update @types/react-native to version 0.60.0
  chore(package): update lockfile yarn.lock
  chore(package): update @types/react to version 16.8.23
  Fixes hyochan#577 (hyochan#578)
  Update @types/react-native to the latest version 🚀 (hyochan#575)
  Improve README (hyochan#574)
  ...

# Conflicts:
#	ios/RNIapIos.m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎁 Rewarded on Issuehunt This issue has been rewarded on Issuehunt 🏃🏻‍♀️ in progress Currently working on 📱 iOS Related to iOS
Projects
None yet
Development

No branches or pull requests

3 participants
@solidfox @hyochan and others