#iambhanu-subscription-approve-payment
1 messages ยท Page 1 of 1 (latest)
Hi ๐ the flow sounds a bit complex, so I'm not exactly sure this is what you're looking for, please let me know if it doesn't accomplish what you're hoping.
You can look at using default_incomplete as the payment_behavior for the Subscription. That will cause the Subscription to be created in an incomplete state, and it will remain there until you confirm the first payment.
https://stripe.com/docs/api/subscriptions/create#create_subscription-payment_behavior
Yes, I already use, this method but in this case I want to retrieve the payment method of the user and save it in the subscription so when the admin approves the request, I will do the subscription paid for a particular user subscription.
I'm sorry, I'm not grasping what you're asking if there is a question in there. Are you providing the ID of the Payment Method you created as the Subscription's default_payment_method when you're creating the Subscription?
https://stripe.com/docs/api/subscriptions/create#create_subscription-default_payment_method
iambhanu-subscription-approve-payment
Can you just let me know, how can I do that like if a user creates a subscription with the provided parameters and I just want to subscription should be paid when the admin wants or you can when the admin triggers something at this time I will perform a code of stripe, the particular subscription user has purchased that will be paid at that time.
\Stripe\Subscription::create([
'customer' => $customer->id,
'items' => [[
'price' => $price_id,
'quantity' => 1,
]],
'payment_behavior' => 'default_incomplete',
'payment_settings' => ['save_default_payment_method' => 'on_subscription'],
'expand' => ['latest_invoice.payment_intent'],
]);
Oh, sorry, I think I understand now.
What I would recommend is:
- Use a Setup Intent to render your Payment Element and collect payment method details from your customer:
https://stripe.com/docs/payments/save-and-reuse?platform=web&ui=elements - Create the Subscription, setting:
payment_behaviortodefault_incomplete
default_payment_methodto the ID of the Payment Method created by the Setup Intent from Step 1. - When you're ready to process the first payment for the Subscription, confirm the first Invoice's Payment Intent. (You will want to have a flow ready in case the payment fails because an SCA/3DS challenge needs to be completed, in which case you'll need to bring your customer back on-session to complete that authentication challenge)
๐ stepping in here as toby needed to step away
When a coach creates a profile, they will have to fill in all the validated profiles and have to submit their profile for validation. After the successfully validated by the admin coach can buy the subscription. This is our current scenario.
Now my client want,
can we request the coach to subscribe first before submitting their profile?
And then we only debit when the admin validates the profiles (=official date of the start of the subcription)?
Yeah what toby suggested is the correct flow in this case.
You collect a payment method via a SetupIntent
Then you create the Subscription later once the admin validates the profile.
so the subscription will be created with different ID and updated in the database instead of the above screenshot right?
Not sure what ID you are referencing.
But you would control when the Subscription is created here
I am referring subscription ID
Ok, So I need to collect only the payment method using "stripe.confirmSetup()" right?
That's correct
Can I update the stripe subscription "incomplete" to "paid"?
It will automatically update to active when the latest invoice is paid
If you are starting the Subscription later on after collecting the PaymentMethod then you can actually use payment_behavior: allow_incomplete
Which will trigger a charge attempt immediately on the first Invoice
This will work since you already have a PaymentMethod
When a coach buys the subscription, I am just collecting the payment information of them and creating a subscription with the status of "Incomplete". When admin validates the profile, can I update the subscription "incomplete" to 'active' and the invoice paid? If "yes" can you suggest me the code? what code I can use to paid the existing subscription?
Well do you want the Subscription start date to be when you collect the payment method or when the admin validates the profile?