I am creating a setup intent and receiving the payment method's id from it. Then I am creating a customer using the following code
customer = Stripe::Customer.create({
email: current_user.email,
description: "Customer for subscription",
payment_method: params[:payment_method]
})
It is returning the following response
{
"id": "cus_IZmhg4VhIwFUBI",
"object": "customer",
"address": null,
"balance": 0,
"created": 1608037176,
"currency": null,
"default_source": null,
"delinquent": false,
"description": "Customer for subscription",
"discount": null,
"email": "[email protected]",
"invoice_prefix": "76BF0C5E",
"invoice_settings": {
"custom_fields": null,
"default_payment_method": null,
"footer": null
},
"livemode": false,
"metadata": {
},
"name": null,
"next_invoice_sequence": 1,
"phone": null,
"preferred_locales": [
],
"shipping": null,
"tax_exempt": "none"
}
The problem is, it is not attaching the payment method to the customer, when I try to create a subscription using the customer object, it returns the following error:
Stripe::InvalidRequestError (This customer has no attached payment source or default payment method.):
But when I look in the dashboard, the payment method is already attached with the customer
payment_method? - Daniel Sindrestean