I'm trying to implement stripe payment on my web app, Node and react is the stack.
newSubscription = await stripe.subscriptions.create({
customer: {{customerid},
items: [
{
price: {{price}},
},
],
payment_behavior: 'default_incomplete',
expand: ['pending_setup_intent'],
trial_period_days: 7,
off_session: true,
});
i tried to pass both client secretes to element, but when trail is active. In that case i'm getting the setup intent client secrete so that the element throughs some error. `
{
"error": {
"code": "resource_missing",
"doc_url": "https://stripe.com/docs/error-codes/resource-missing",
"message": "No such payment_intent: 'seti_XXXXXXXXXXXXX'",
"param": "intent",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_XXXXXXXXXXX",
"type": "invalid_request_error"
}
}
` how to solve this issue, i want trail activated subscription, when trails ends the user must be credited with that amount.
When you include a trial period in your subscription, a $0 invoice is generated initially, which doesn't require payment. This way you are creating a SetupIntent, instead of PaymentIntent. You can see it in the ID prefix: seti_…
. Since there is no payment happening right away, SetupIntent allows you to store the payment details, which, in turn, the subscription can use for recurring payments.
Therefore, you should use the confirmSetup method, when the user submits the form.