#shubham_1306

1 messages · Page 1 of 1 (latest)

honest quiverBOT
lusty hedge
#

Hi, let me help you with this.

hardy comet
#

Hello

lusty hedge
hardy comet
#

So I need to create a customer first?

lusty hedge
#

Yes, however this is not related to the question that you asked initially.

hardy comet
#

Yeah I get it but my concern is that if the customer is created previously and we just hit the api for subscription payment will be directly deducted from the added account of customer without asking for confirmation or any client side secret?

lusty hedge
#

It depends if you have a Payment Method set up for future payments.

#

But if you don't provide a payment method you can use the generated client_secret to collect the payment details on the frontend from the customer.

hardy comet
#

yeah thats sound better, so the client secret will be there in the same api?

lusty hedge
hardy comet
#

Like when I currently call a subscription for a user without any default payment methods this is what I get:

{
"error": {
"code": "resource_missing",
"doc_url": "https://stripe.com/docs/error-codes/resource-missing",
"message": "This customer has no attached payment source or default payment method. Please consider adding a default payment method. For more information, visit https://stripe.com/docs/billing/subscriptions/payment-methods-setting#payment-method-priority.",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_fHFcjFPHmJr8uU?t=1698237589",
"type": "invalid_request_error"
}
}

Learn more about error codes and how to resolve them.

Learn how to specify which payment methods are allowed for a subscription.

#

These are the request params
let data = qs.stringify({
'items[0][price]': 'price_1NpUU7SFSc1Kz6ix7E8qkBis',
'items[0][quantity]': '1',
'customer': 'cus_OpNH5Kx2xWree9',
'add_invoice_items[0][price]': 'price_1NpUa5SFSc1Kz6ix2vN9BTu3',
'add_invoice_items[0][quantity]': '1'
});

lusty hedge
#

You are missing:

...
payment_behavior: 'default_incomplete',
payment_settings: { save_default_payment_method: 'on_subscription' },
expand: ['latest_invoice.payment_intent'],
hardy comet
#

Oh OK thanks now it works

lusty hedge
#

Happy to help.