#sarvesh3742
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- sarvesh3742, 1 hour ago, 2 messages
hello! how can I help?
Hi, I would like to create subscription with 7 days trial period for Monthly and Yearly Subscriptions.
$subscription = $stripe->subscriptions->create([
'customer' => $stripe_customer_id,
'items' => [[
'price' => $stripePriceId,
]],
'metadata' => $metaData,
'trial_period_days' => 7,
'payment_behavior' => 'default_incomplete',
'payment_settings' => ['save_default_payment_method' => 'on_subscription'],
'expand' => ['latest_invoice.payment_intent'],
]);
This is something I am using, but it was not asking the card details and received payment invoice.paid webhook event
what could be the reason
that's expected behaviour, to collect payment method details for a Subscription that has a $0 first payment, you'll want to expand [0] the pending_setup_intent [1] when creating the Subscription and use that to initialize the Payment Element.
[0] https://stripe.com/docs/api/expanding_objects
[1] https://stripe.com/docs/api/subscriptions/object#subscription_object-pending_setup_intent
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
if you want an example on how to handle Subscriptions which may have either a PaymentIntent or SetupIntent, you can look at steps 6 & 7 on this page : https://stripe.com/docs/payments/accept-a-payment-deferred?platform=web&type=subscription#create-intent
ok os If I use
'trial_period_days' => 7,
'expand' => ['latest_invoice.payment_intent', 'pending_setup_intent'],
So it will create subscription with $0 initially and user can get access to site by receiving invoice.paid status - Paid ?
after 7 days trial period is over, it will send again a webhook by charing customer cards and payment status as paid again?
in which steps user can enter their card details in 0 or 1 step?
So it will create subscription with $0 initially and user can get access to site by receiving invoice.paid status - Paid ?
Yes
after 7 days trial period is over, it will send again a webhook by charing customer cards and payment status as paid again?
yes, as the customer has filled their payment method using the intial pending_setup_intent
'expand' => ['latest_invoice.payment_intent', '**latest_invoice.**pending_setup_intent'],
in which steps user can enter their card details in 0 or 1 step?
in 0
ok, and in webhook events which field we need to check for 0 and 1 step to see whether it is trial payment or acutual payment happen for the user and he can access the project after trial period is over
In the webhook event including a Subscription Object, you can check the trial* fields, for example:
https://stripe.com/docs/api/subscriptions/object#subscription_object-trial_end