#puttekool
1 messages · Page 1 of 1 (latest)
No, payment element doesn't support displaying saved payment method yet.
Maybe use Legacy Elements ?
You mean Card Element? No it doesn't support it either.
Yes something like first taking the card element 1. const {error, paymentMethod} = await stripe.createPaymentMethod({
type: 'card',
card: elements.getElement(CardElement),
}); 2. Then using the info from it to update customer:
const response = await fetch('/update-payment-method', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
customerId: 'cus_123', // fake id
paymentMethodId: paymentMethod.id,
})
So using your secure inputs including validation to make changes on customer.
Ok, so basically you want to create a payment method and then attach it to a customer? And you want to know how to achieve it with PaymentElement?
Yes, It looks like the PaymentElement needs an paymentIntent, but my intent is not to make a payment but change the default card number. More like maybe using PaymentElement on this: https://stripe.com/docs/payments/checkout/subscriptions/update-payment-details. Cus when I looked at the customer portal flow it looks like there is a PaymentElement and thought it can be used without doing a payment 🙂
https://stripe.com/docs/payments/accept-a-payment-deferred?type=payment you can use the deferred flow to render a payment element without a intent