#yusuf1998-flutter
1 messages ยท Page 1 of 1 (latest)
Starting up a new thread for you - can you give me a summary of what the issue is?
for iOS we faced issues, currently while testing apple pay works fine on Simulator. but not working on real device, we did follow all the steps here (https://stripe.com/docs/apple-pay?platform=react-native), and when running the app on a physical device (logged in with a sandbox account) can click on Apple Pay button and the payment sheet is visible, it starts processing the payment but we get this error on the logs (PlatformException(Failed, Payment not completed, null, null) and also same message on the payment UI "Payment not completed".
here is the code snippet:
`Future<void> _handleApplePayPress() async {
try {
var support = await stripe.Stripe.instance.checkApplePaySupport();
if (support) {
// 1. Present Apple Pay sheet
await stripe.Stripe.instance.presentApplePay(
stripe.ApplePayPresentParams(
cartItems: [
stripe.ApplePayCartSummaryItem(
label: widget.plan['name'] ?? 'Test Plan',
amount: widget.plan['price']?.toString() ?? "0.01",
),
],
country: 'us',
currency: "usd",
),
);
// 2. fetch Intent Client Secret from backend
final response = await provider!.fetchPaymentIntentClientSecret(
currency: 'usd',
plan_name: widget.plan['name'],
price: widget.plan['price'].toString(),
tracking_id: trackingId,
);
if (response['status'] != 'success') return;
var data = response['data'];
final clientSecret = data['client_secret'];
// 2. Confirm apple pay payment
await stripe.Stripe.instance.confirmApplePayPayment(clientSecret);
setState(() {
_loaderTitle = 'Processing...';
});
_onPaymentSuccess();
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Apple pay is not supported on your device.'),
),
);
}
} catch (e) {
print(e);
}
}`
๐ Give me a few minutes and I'll take a look
Sure thanks.
Did you have an example payment intent ID on hand that we can look at?
And are you seeing any device logs/anything else?
here is some logs by plugin.
[ "additional_info": [], "publishable_key": "pk_test_51HvPBeJ864fdlIq9โโ", "install ": "C ", "pay_var ": "legacy ", "apple_pay_enabled ": 1, "plugin_type ": "flutter ", "bindings_version ": "21.12 .0 ", "ocr_type ": "none", "product_usage ": ["STPApplePayContext ", "STPPaymentCardTextField "], "event ": "stripeios.token_creation ", "device_type ": "iPhone14,5 ", "token_type ": "apple_pay ", "app_version ": "1.1 .2 ", "analytics_ua ": "analytics.stripeios - 1.0 ", "os_version ": "15.5 ", "app_name ": "dvhapp " ]
this is all I get as logs. don't have any other logs.
as the function after the first step, doesn't run the 2nd step to get the Intent ID from backend. and falls to the exception.
Exception returns PlatformException(Failed, Payment not completed, null, null
Do you have Payment Intent ID like pi_xxx?
No there's no payment intent.
So you're saying your code doesn't reach the line fetchPaymentIntentClientSecret? Have you added breakpoints to confirm whether the presentApplePay call is failing or whether it's fetchPaymentIntentClientSecret?
Yes, code doesn't reach the line fetchPaymentIntentClientSecret
I have not added the break point, but I added log statements before and after presentApplePay before log is visible on logs, and then I can see the catch exception is logged.
Gotcha
and just to check - are you using one of our official libraries, or a third-party one?
I'm using flutter, so it's flutter_stripe
(https://github.com/flutter-stripe/flutter_stripe) package, I believe Stripe doesn't have an official library for flutter, if I'm wrong please correct me.
Ah! Glad I double checked ๐
๐
Okay, so any tips here?
I'm sorry, It's getting late for me,
I hope this will be open until the issue is resolved.
Still looking - the flutter library isn't one we own, and typically the error message would be helpful for debugging this
Have you made sure to add your Merchant ID in XCode? https://stripe.com/docs/apple-pay?platform=react-native#xcode-pay
Yes, the merchant ID is in XCode
and the device you're using has real cards added to the apple wallet?
No the device is using sandbox tester account, to test apple pay.
https://developer.apple.com/apple-pay/sandbox-testing/
Ah, can you try adding a real card to the wallet and see if that makes a difference?
(In test mode we'll never make an actual charge)
Actually that's the main issue, until I can't make a test payment with test account and also stripe test keys (publishable, secret).
We can't push the app to the app store and to be used live.
`
initializeStripe() async {
stripe.Stripe.publishableKey = "pk_test_51HvPBeJ864fdlIq96jicWnkFFfeoGK75TGGKVaLgqytjlaMuFFjV5-----";
stripe.Stripe.merchantIdentifier = 'merchant.com.vehiclehistory.app';
await stripe.Stripe.instance.applySettings();
var support = await stripe.Stripe.instance.checkApplePaySupport();
`
Support returns true because a test card is added to wallet.
as I said earlier it's working fine on Simulator. and I can make the test payment.
Just for the sake of testing right now and confirming that's the issue can you just try to add a real card and see if you get past the error you're seeing though?
Ohhh, so you're suggesting I should add a real card with a real apple id?
yup!
Currently I don't have a real card with myself, as our co-workers aren't available at the moment, can I do this tomorrow and share the results?
yes, that's fine
Thanks
sure, then will share the results tomorrow.
This thread has been archived. If you need help with anything else please ask in #dev-help or contact Stripe Support: https://support.stripe.com/contact
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
@unreal oracle I have re-opened this thread. Can you tell me what further help you need here?
Hey,
Thanks, yes as Karbi asked me to try testing with a real card, when I added a real card to wallet, and opened the app to test the apple pay, there was no apple pay button.
might be because this var support = await stripe.Stripe.instance.checkApplePaySupport(); line of code returns false.
now I'm wondering as I followed all the steps here, https://stripe.com/docs/apple-pay?platform=react-native
Why it's not working.
Can you check this page on that same device and tell me if you see the ApplePay button there? https://stripe.com/docs/stripe-js/elements/payment-request-button
If you can't it is possible that checkApplePaySupport is returning false because the wallet isn't set up
Thanks for checking. Sounds like the issue is with the app, catching upon this thread to see where we may want to look next
Thanks
๐ I'm also back, give me a few minutes to catch up
Hey Karbi ๐ ,
GREAT!
Sure
Is there possibly a mismatch in your bundle ID and merchant ID?
this is the bundle id com.vehiclehistory.app and here is the merchant id: merchant.com.vehiclehistory.app
so I believe no
Ah! Actually - are you testing with a Mastercard card, or a different brand?
for sandbox testing, I used test Mastercard.
For real card I asked a friend to test, let me confirm with him.
๐ I'll look into some other possibilities in the mean time
He used this card, TD Access Card
Interesting - I wonder if this is because it's because this is classifed as an interac card, which is not one we support by default (you need to change your code slightly to support it)
I don't know how you'd enable it through the flutter package you're using, but with our ios library you're set additionalEnabledApplePayNetworks to [.interac] to include it
Great, thanks I'll check it and see if I can add support, MasterCard should work, right?
Yeah I believe mastercard would work - you can see the list of one we have enabled by default here https://github.com/stripe/stripe-ios/blob/3fdd5cb4ac44f651d7cc8ee31e4406806f37effa/StripeCore/StripeCore/Source/API Bindings/StripeAPI.swift#L88
Got it, thanks,
I believe the flutter_stripe using the same SDK you have for react-native and if react-native sdk has this option to add additional pay network, then this might also have.
Anyways I'll ask to find a MasterCard and try testing with MasterCard, I'll share the results here. I'll share the results tomorrow
Thanks for assisting ๐
Happy to help! and thanks for being so patient - these issues can be hard to debug, and it's especially hard since the flutter package you're using isn't surfacing useful errors that would let us dig in more
๐
Hi ๐
The payment with real card worked. and now I'm surprised why it's not working with a sandbox account?
Because while submitting the app, under apple review, they may try the payment with sandbox account, and if it not work, they'll not approve the app.
hurray! awesome to hear it was at least working with a real card
let me try and look into possible reasons why it may not be working with sandbox accounts - I know in the past we generally don't recommend testing with sandbox accounts, but I'm not sure of the specific reasons why
Thanks, yes it was cool!
Okay sure.
Do you mind sharing your account ID here really quick?
Stripe account ID?
yup
If you go to this page (https://dashboard.stripe.com/settings/account) and search for "acct_" you should be able to find it
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
acct_1HvPBeJ864fdlIq9
When you were testing with the sandbox, which test card were you using?
Okay let me check
It was on Tuesday 19 July
MasterCard
FPAN: 5204 2477 5000 1471
Expiration Date: 11/2022
CVC: 111
It's very possible that this just doesn't work end-to-end with Apply Pay Sandbox accounts + Stripe, but just to be sure can you try the 4761 1200 1000 0492 card (w/ Expiration Date: 11/2022, CVV: 533) instead? If that doesn't work I would push on the app store reviewers and tell them that testing Stripe + Apple Pay expects you to use real cards to test this out fully, and that it does work