#yusuf1998-flutter

1 messages ยท Page 1 of 1 (latest)

frigid narwhal
#

Starting up a new thread for you - can you give me a summary of what the issue is?

unreal oracle
#

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".

Allow customers to securely make payments using Apple Pay on their iPhone, iPad, and Apple Watch.

#

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);
}

}`

frigid narwhal
#

๐Ÿ‘ Give me a few minutes and I'll take a look

unreal oracle
frigid narwhal
#

Did you have an example payment intent ID on hand that we can look at?

#

And are you seeing any device logs/anything else?

unreal oracle
#

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

frigid narwhal
#

Do you have Payment Intent ID like pi_xxx?

unreal oracle
frigid narwhal
#

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?

unreal oracle
#

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.

frigid narwhal
#

Gotcha

#

and just to check - are you using one of our official libraries, or a third-party one?

unreal oracle
frigid narwhal
#

Ah! Glad I double checked ๐Ÿ™‚

unreal oracle
#

๐Ÿ™‚
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.

frigid narwhal
#

Still looking - the flutter library isn't one we own, and typically the error message would be helpful for debugging this

unreal oracle
#

Yes, the merchant ID is in XCode

frigid narwhal
#

and the device you're using has real cards added to the apple wallet?

unreal oracle
frigid narwhal
#

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)

unreal oracle
#

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.

frigid narwhal
#

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?

unreal oracle
#

Ohhh, so you're suggesting I should add a real card with a real apple id?

frigid narwhal
#

yup!

unreal oracle
#

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?

frigid narwhal
#

yes, that's fine

unreal oracle
#

Thanks
sure, then will share the results tomorrow.

cedar ridgeBOT
#

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

fallen radish
#

@unreal oracle I have re-opened this thread. Can you tell me what further help you need here?

unreal oracle
#

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.

fallen radish
#

If you can't it is possible that checkApplePaySupport is returning false because the wallet isn't set up

unreal oracle
#

Okay

#

the button is visible

fallen radish
#

Thanks for checking. Sounds like the issue is with the app, catching upon this thread to see where we may want to look next

unreal oracle
#

Thanks

frigid narwhal
#

๐Ÿ‘‹ I'm also back, give me a few minutes to catch up

unreal oracle
#

Hey Karbi ๐Ÿ‘‹ ,
GREAT!
Sure

frigid narwhal
#

Is there possibly a mismatch in your bundle ID and merchant ID?

unreal oracle
#

this is the bundle id com.vehiclehistory.app and here is the merchant id: merchant.com.vehiclehistory.app

#

so I believe no

frigid narwhal
#

Ah! Actually - are you testing with a Mastercard card, or a different brand?

unreal oracle
#

for sandbox testing, I used test Mastercard.
For real card I asked a friend to test, let me confirm with him.

frigid narwhal
#

๐Ÿ‘ I'll look into some other possibilities in the mean time

unreal oracle
#

He used this card, TD Access Card

frigid narwhal
#

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

unreal oracle
#

Great, thanks I'll check it and see if I can add support, MasterCard should work, right?

frigid narwhal
unreal oracle
#

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 ๐Ÿ™‚

frigid narwhal
#

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

frigid narwhal
#

๐Ÿ‘‹

unreal oracle
#

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.

frigid narwhal
#

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

unreal oracle
frigid narwhal
#

Do you mind sharing your account ID here really quick?

unreal oracle
#

Stripe account ID?

frigid narwhal
#

yup

unreal oracle
#

one sec

#

sorry having network issues, where can i find the account ID?

frigid narwhal
unreal oracle
#

acct_1HvPBeJ864fdlIq9

frigid narwhal
#

When you were testing with the sandbox, which test card were you using?

unreal oracle
#

Okay let me check

#

It was on Tuesday 19 July
MasterCard
FPAN: 5204 2477 5000 1471
Expiration Date: 11/2022
CVC: 111

frigid narwhal
#

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