#Gadbit-setupintents

1 messages · Page 1 of 1 (latest)

abstract gulch
quick slate
#

So, if a customer has a trialing subscription, will that payment method be charged when the trial period expires without setting that payment method as default?

#

Assuming that customer doesn't have another payment method attached.

abstract gulch
#

No, you'd still need to set it as the default (either on the Customer at invoice_settings.default_payment_method on the Subscription at default_payment_method). Just because a PM is attached to a customer doesn't mean we consider it the default (even if the customer only has a single one attached).

quick slate
#

Oh, OK. So, i have a problem. In my app, when a customer subscribes for the first time, the subscription is created with "trial_from_plan: true". However, when the subscription is created, the payment method is not required due to $0 amount invoice, so, any payment method is attached.

#

I have to create a setup intent first, in order to check if the payment method (card) is a valid one.

#

In this way, when the setup intent is confirmed (because the card is a valid one), that payment method is attached to the customer and i would expect when the trial period expires, charge that customer's payment method.

#

So, if the setup intent is created first, the subscription doesn't exist, so how can i set the default_payment_method for the subsciption?

abstract gulch
quick slate
#

I was doing like that. However, i noticed when a "trial_from_plan: true" subscription is created, the invoice is paid immediatly and the subscription status is trialing automatically without collecting the payment method.

abstract gulch
#

Yes, the Subscription will still be created and Invoice is paid immediately because it's for $0

quick slate
#

So, how can i associate a payment method to that subscription?

#

In advance, an apology, but that is the part that is not clear to me.

#

Just for adding more details, i'm not using checkout, it's a custom integration where i'm using a Card Field on the client side (mobile app) and when the user clicks on Subscribe button, a "trial_from_plan: true" subscription is created if it's the first time for that customer, otherwise a normal subscription (without trial) is created. Everything works well for normal subscription, since it is default_incomplete, so i return a client secret to the client side to confirm the payment intent and the CardField's payment method is associated to the subscription.

#

However, in "trial_from_plan: true" subscription, i can't return a client secret to the client side to confirm the payment/setup intent for attaching it to the customer or associate it to the subscription, since the invoice already has been paid.

#

And latestInvoice.paymentIntent is null

abstract gulch
#

Let me lay this all out:

  1. Create a Subscription w/ payment_behavior: default_incomplete and payment_settings.save_default_payment_method: on_subscription. Also be sure to expand pending_setup_intent in your creation request.
  2. Even with trial_from_plan: true set on the Subscription, you should still see pending_setup_intent set on the Subscription. You can use the client secret from that Setup Intent to collect payment details
quick slate
#

OK. So, when i return the pending_setup_intent.clientSecret to the client side, i need to confirmSetupIntent, right?

abstract gulch
#

Yup!

quick slate
#

Once the setup intent is confirmed, i don't need to do anything else, right?

long wren
#

if it's confirmed successfully that's correct

quick slate
#

I see.

#

So, it's possible that the customer enters an invalid card and their subscription is still trialing.

#

That is, the customer can avoid the subscription screen once he has realized that his card is not valid and exit the process.

long wren
#

Yes it's possible

quick slate
#

OK. I really appreciate your help and your patience.

#

Thanks a lot.