-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[in_app_purchase] Fix finishing purchases upon payment dialog cancel… #3106
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@googlebot I signed it! |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
04b5870
to
a8a1909
Compare
285a35c
to
51e8c04
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this!
|
||
NSArray<SKPaymentTransaction *> *pendingTransactions = | ||
[self.paymentQueueHandler getUnfinishedTransactions]; | ||
|
||
for (SKPaymentTransaction *transaction in pendingTransactions) { | ||
if ([transaction.transactionIdentifier isEqualToString:transactionIdentifier]) { | ||
// If the user cancels the purchase dialog we won't have a transactionIdentifier. So if it is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these two words break the line. Same below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reformatted the comment
@@ -103,9 +103,11 @@ class SKPaymentQueueWrapper { | |||
/// finishTransaction:]`](https://developer.apple.com/documentation/storekit/skpaymentqueue/1506003-finishtransaction?language=objc). | |||
Future<void> finishTransaction( | |||
SKPaymentTransactionWrapper transaction) async { | |||
Map requestMap = transaction.toFinishMap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer lightweight generic. Consider adding a type for the Map
. For example: Map<String, String>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
51e8c04
to
a4ae198
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks.
a4ae198
to
1d25eee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the version needs to be updated from pubspec.yaml
Still getting an error after calling completePurchase method in version 0.3.4+11. EDIT: Worked with latest version 0.3.4+12 |
Hi! I'm experiencing the same error PlatformException(storekit_invalid_argument, Argument type of finishTransaction is not a Dictionary, null, null) EDIT: My bad, it is working after switching to a new sandbox account (IDK if it has something to do but just in case) and also running flutter clean! Thanks for the fix! |
Updated to version 0.3.4+12 but it still not pop up purchase dialog :(. Anyone has same error ?? |
@DangKhoi1997 I think dialog not showing up is a different issue and not related to this PR. Apple Pay UI/dialog is not showing up is related to not finishing transactions. Can you try something similar to following code to see if your problem is solved:
|
* master: [in_app_purchase] Android Code Inspection and Clean up (flutter#3120) Android Code Inspection and Clean up (flutter#3117) [in_app_purchase] Fix finishing purchases upon payment cancellation (flutter#3106) [google_maps_flutter_web] Fix convert.dart issues (flutter#3093) [multiple] Opt-out tests of null-safety (flutter#3113) [webview_flutter] add public documentation. (flutter#3114) in_app_purchase: started supported null as a parameter for the sandbox arguement (flutter#3110) [connectivity] Android Code Inspection and Clean up (flutter#3051) [android_intent] Android Code Inspection and Clean up (flutter#3043) Remove `io.flutter.embedded_views_preview` from README [google_maps_flutter] Fix headline in the readme (flutter#3100) [webview_flutter] Add new entrypoint that uses hybrid composition on Android (flutter#3067) [google_maps_flutter] Out of developers preview, bump to 1.0.0 (flutter#3091) [url_launcher_web] Move third_party under src. (flutter#3080) [plugin_platform_interface] Fix homepage in pubspec.yaml (flutter#3088) [connectivity_for_web] Fix homepage in pubspec.yaml (flutter#3089) [in_app_purchase] Update typo in example main.dart (flutter#3073)
Updated to latest version 0.3.4+12 but we are still not able to buy again whenever we cancel the purchase dialogue. The button works fine if we complete the purchase flow and I am able to buy many time if the purchase flow ends correct, but whenever I cancel and try to tap again the button it won’t open the purchase dialogue. Do we need to add any additional code to our implementation? |
@daoc13 do you find any solution for this issue :(( |
@hai199580 I did not find a solution for this issue. I recommend you to use Revenue Cat, we implemented it in 4 hours and it works fine. I will keep using Revenue Cat until this issue is solved. Hope it helps! |
Description
This PR fixes finishing purchases upon payment dialog cancellation on iOS.
When the user cancels the payment dialog there is no
transactionIdentifier
which means the transaction cannot be finished in the current implementation and therefore not initiated again.Duplicate of:
Related Issues
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
).flutter analyze
) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?