#sendre

1 messages · Page 1 of 1 (latest)

strange monolithBOT
remote harbor
tame sapphire
#

Yes, our backend now pass the pending_setup_intent.client_secret to the frontend when using trial, but we get the exception as seen in this image..

remote harbor
#

hmm, that seems unrelated really

#

this is in Android I think? or iOS?

leaden leaf
#

It's iOS using flutter.

#

This is the code for init and presenting the paymentsheet

 await Stripe.instance.initPaymentSheet(
      paymentSheetParameters: SetupPaymentSheetParameters(
        // Main params
        merchantDisplayName: (await PackageInfo.fromPlatform()).appName,
        style: ThemeMode.light,
        appearance: stripeTheme,
        // Customer keys
        customerId: response.customerId,
        paymentIntentClientSecret: response.paymentIntentClientSecret,
        customerEphemeralKeySecret: response.customerEphemeralKeySecret,
      ),
    );
    await Stripe.instance.presentPaymentSheet();
remote harbor
#

you have to use setupIntentClientSecret not paymentIntentClientSecret

#

because you're using a SetupIntent. But yes, I'm aware that quite complicates the frontend through having to branch or use different views

leaden leaf
#

Thanks, will try that now. Is setupIntentClientSecret only when using trials and paymentIntentClientSecret for regular use? It has worked fine with paymentIntentClientSecret until now.

remote harbor
#

I would say so yes. If there's a trial, then as you say, the invoice is paid immediately, and no payment is required. So invoice.payment_intent is null. But a SetupIntent can be used to collect the payment details instead without charging them

#

unfortunately our products don't handle this use case terribly well, we optimised for "start a trial without a card, and add the card at some point during it", so it takes a bit of custom work to handle payment data at the start of the trial, but can be done

leaden leaf
#

Your suggestion worked. Thanks for the help!

tame sapphire
#

Is it possible to require a card to start the trial? Or should this be handled through e.g. webhooks on our end?

remote harbor
#

so in that case it becomes a bit more complicated

#

as I said this isn't natively supported. What you'd have to do is

  • create your own SetupIntent(instead of creating the subscription and using the one from it's pending_setup_intent)
  • collect card details to confirm that SetupIntent on the frontend, same as above
  • when handling the success of that, set the card from the SetupIntent as the default_payment_method for the customer, and create the trial subscription on the backend
  • (nothing else to do on the frontend at this point)
tame sapphire
#

Ok, thanks for the help!