#sunagimo_api
1 messages · Page 1 of 1 (latest)
đź‘‹ Welcome to your new thread!
⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đź”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1361511873836613684
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
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.
- sunagimo_api, 15 hours ago, 8 messages
- sunagimo_api, 3 days ago, 14 messages
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
In the dashboard, the card registered as a payment method is displayed.
However, it is not included in the invoice_settings of the Customer object.
I implemented it using the payment_method.id obtained from the SetupIntent on the frontend, but I got the following error:
The customer does not have a payment method with the ID pm_1RDjOGJeNdmp8jhmP0ddVmEa. The payment method must be attached to the customer.
Is it not possible to set the invoice settings directly without attaching the payment method to the customer first?
hello! Maybe you'll want to consider the deferred Intent flow : https://docs.stripe.com/payments/accept-a-payment-deferred?platform=web&type=subscription where you can ensure the customer intends to make payment first
Is it not possible to set the invoice settings directly without attaching the payment method to the customer first?
No it's not possible unless the PaymentMethod is already attached to the customer
Thank you! Based on your advice, I was able to register invoice_settings.default_payment_method by first creating the customer, then calling Stripe::PaymentMethod.attach, and finally using Stripe::Customer.update!
wait sorry, i'm a bit confused. You shouldn't be calling Stripe::PaymentMethod.attach directly
you should always be using either a SetupIntent or PaymentIntent to attach the PaymentMethod to the customer
are you creating one-off invoices?
No, It's subscription
have you had the chance to take a look at this flow? https://docs.stripe.com/payments/accept-a-payment-deferred?platform=web&type=subscription
you'll only create a customer and subscription when the customer submits their payment details
Is there a way to register the card information in advance and set it as the default payment method?
Can you share more on why you would want to register the card information in advance and set it as the default payment method?
Typically, the attachment to the customer is automatically done when you use the SetupIntent / PaymentIntent generated via the Subscription / Invoice. After the PaymentIntent or SetupIntent is successful, then you set the default payment method on the customer to that PaymentMethod
To be clear, you should never directly attach a PaymentMethod to a customer that has not been created through either a PaymentIntent or SetupIntent. If you directly attach a PaymentMethod to a customer that has not been created through either a PaymentIntent or SetupIntent, the PaymentMethod is not correctly set up for future usage. This could possibly result in a higher rate of declines.
Initially, I registered the subscription via a setup intent, but this does not include the default payment method in the customer object. We need to register the default card because it’s necessary for displaying the customer’s default payment information in our service. On the other hand, if we can retrieve the default card from the customer object, there would be no need to register it. By the way, invoice.settings is null.
If you follow this guide : https://docs.stripe.com/payments/accept-a-payment-deferred?platform=web&type=subscription, what you can do is after the first invoice is paid for the subscription, you can update the customer with the default payment method. You can listen to the invoice.paid event and check if billing_reason=subscription_create
This is the customer we just created. https://dashboard.stripe.com/test/customers/cus_S8FkTRjY3fveip
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
alright, what's your question about the above customer?
customers retrieve cus_S8FkTRjY3fveip
{
"id":
"cus_S8FkTRjY3fveip"
,
"object":
"customer",
"address":
null,
"balance":
0,
"created":
1744684105
,
"currency":
"jpy",
"default_source":
null,
"delinquent":
false,
"description":
null,
"discount":
null,
"email":
"mayue.arai@foriio.com",
"invoice_prefix":
"BEA933DF",
"invoice_settings": {
"custom_fields":
null,
"default_payment_method":
null,
"footer":
null,
"rendering_options":
null,
},
"livemode":
false,
"metadata": {},
"name":
"qweqwq",
"next_invoice_sequence":
2,
"phone":
null,
"preferred_locales": [],
"shipping":
null,
"tax_exempt":
"none",
"test_clock":
default_payment_method , invoice settings also null
How can I retrieve the default payment method?
So it looks like you're creating a Subscription that has no amount that needs to be paid first.
I see you have a SetupIntent previously created with this customer. After the SetupIntent is successful, and the PaymentMethod has been attached to the customer, you would use https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method to update the customer's default payment method
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
How is the PaymentMethod attached to the customer? What are the conditions for that?
Here is our current implementation:
setup_intent = Stripe::SetupIntent.create(
automatic_payment_methods: { enabled: true, allow_redirects: 'never' },
)
Stripe::Customer.create({ payment_method: paymentmethodId, email: email, name: name })
ah, I see you're missing the customer parameter in the SetupIntent. If you include the customer id when creating the SetupIntent, the SetupIntent will automatically attach the payment method to the customer when it is successful
So in the end, the simplest approach is to create the customer first and then create the setup intent. Thank you—this helped clarify my thoughts.