#AlexT
1 messages · Page 1 of 1 (latest)
objCustomer.InvoiceSettings.DefaultPaymentMethodId = ObjIntent.PaymentMethodId
This API endpoint and the code snippet should do exactly what you're looking for: https://stripe.com/docs/api/payment_methods/attach
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
This PaymentMethod was previously used without being attached to a Customer or was detached from a Customer, and may not be used again
what is the sequence of events here?
I want to charge and if the charge is successful then attach the payment method to the ustomre for future billing
Using the "Save payment details during payment"
Ah, how are you accepting payments right now? For context: you can usually setup the Payment Method to be automatically attached to the customer, and that will only happen if that payment was successful
I am following the instruction here "https://stripe.com/docs/payments/save-during-payment"
How do I attache it automatically?
It says it is saved to customer But i dont see it as default
Ahhh, okay, so the Customer already has the Payment Method attached? In other words, there is a payment_method on the customer object?
let me check real quick
My guess is that you need to do this step to make sure the Payment Method can be charged again at a later time: https://stripe.com/docs/payments/save-during-payment?platform=web#save-payment-details-for-future-use
{
"id": "cus_NmNNrDdHwAf33k",
"object": "customer",
"address": null,
"balance": 0,
"cash_balance": null,
"created": 1682439681,
"currency": null,
"default_source": null,
"delinquent": false,
"description": null,
"discount": null,
"email": "v2@atintegrated.com",
"invoice_credit_balance": null,
"invoice_prefix": "0A8467F5",
"invoice_settings": {
"custom_fields": null,
"default_payment_method": null,
"footer": null,
"rendering_options": null
},
"livemode": false,
"metadata": {},
"name": "John Doe",
"next_invoice_sequence": 1,
"phone": null,
"preferred_locales": [],
"shipping": null,
"sources": null,
"subscriptions": null,
"tax": null,
"tax_exempt": "none",
"tax_ids": null,
"test_clock": null
}}
I got it
objCustomer.InvoiceSettings.DefaultPaymentMethodId = ObjIntent.PaymentMethodId
Service.Update(ObjIntent.CustomerId, Nothing)
Okay, so there is no Payment Method set. So you want to follow the step I sent above to setup the Payment Method for future usage, then check the invoice_settings.default_payment_method to make sure it's there. If it's not, you can set it explicitly by updating the customer with this API call: https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-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.