#Th3FalleN
1 messages · Page 1 of 1 (latest)
Can you share an example of what you mean?
If you have already collected a payment method and saved it for future use, you should not need to use any Elements again to complete a payment
we want to allow them to update their billing information when checking out though
so for example...
<LinkAuthenticationElement className="email-field" onChange={ event => {
if (event.complete) {
setBillingEmail(event.value.email);
}
} } />
<AddressElement options={ {
mode: 'billing',
} }
onChange={ event => {
if (event.complete) {
setAddressData(event.value);
}
} }
// options={ {
// mode: 'billing',
// defaultValues: {
// name: account.credit_name,
// address: {
// line1: account.billing_address,
// line2: '',
// city: account.billing_city,
// state: account.billing_state,
// postal_code: account.billing_zip,
// country: 'US',
// },
// },
// } }
/>
</Fragment>```
would i need to provide those default values or is there a way to tell it to use a payment method id and it gets the details?
and also this applies for when we want to update their billing info which would require the same thing
Ah I see, you're trying to prefill an address based on billing details of a payment method? I think you've got the right idea already using the default values -- but consider you could omit the address element UI entirely if the customer wanted to use an address you already have.
i plan to offer a UI like this... https://p181.p1.n0.cdn.getcloudapp.com/items/JruyEbkj/4b64fb4a-8a0b-47a2-bd79-e3c5a40767b4.jpg?v=3e329a40e814cb1a434888c2b672485e
but when they go to edit that information i want it to already have their current info
Got it -- then I think you're already doing this well!
NP 🙂
so that works fine for the address field but not for the payment one, what would be the best way to offer the option to use the saved method or create a new one?
essentially im trying to do what https://stripe.com/docs/billing/subscriptions/share-update-payment-link 's link would but in our ui
You would choose the UI for this based on the customer attached payment methods, you could eg present the last 4 digits of cards & brand
that's a fair point because my setup intent has the payment method on it already....
you are a wise man
Then you can use that payment method ID to confirm the payment using the type-specific confirmation, eg for a card:
https://stripe.com/docs/js/payment_intents/confirm_card_payment#stripe_confirm_card_payment-data-payment_method
But if the customer wants to use a new payment method, you reveal the Payment Element or whatever ELements you prefer for collection and confirm using the Element (instead of the PM id)
thanks!
so in that picture i sent... since their subscription information can be changed after a payment-intent is created, i would need to
- update their payment-intent.
2.then update the subscription, - then confirm a card payment. right?
YOu're asking about payment intents and subscriptions. Are you referring the the payment intent associated with a previously failed subscription invoice payment, or separate payments from the subscription?
in this flow they are updating their subscription
So if there is no pending payment (say replacing mid-cycle) you'd update the subscription default_payment_method or Customer invoice_settings[default_payment_method] and that would get used for the next invoice payment