#thenakidninja_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/1281206069602812041
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
hi! not sure what you mean โ you're passing the information to billing_details so it's the billing address on the card. If you want to pass shipping and see it on the Dashboard, you can โ it's https://docs.stripe.com/js/payment_intents/confirm_payment#confirm_payment_intent-options-confirmParams-shipping
await stripe.confirmPayment({ elements, clientSecret, payment_method_data: { billing_details: { name : ${shippingDetails.first_name} ${shippingDetails.last_name}, email : customerDetails.email, phone : shippingDetails.phone, address: { city : shippingDetails.city, country : shippingDetails.country_code, line1 : shippingDetails.address_1, line2 : shippingDetails.address_2, postal_code : shippingDetails.postal_code, }, } }, confirmParams: { receipt_email: customerDetails.email }, // Uncomment below if you only want redirect for redirect-based payments redirect: "if_required" }).then(({error,paymentIntent})=>{ if(error){ console.log(error) } if(paymentIntent){ console.log(paymentIntent) } }); }
I think I can see where I am going wrong, I think payment_method_data has a required 'type' field?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
your code is fine
it just doesn't pass the address to shipping
await stripe.confirmPayment({
elements,
clientSecret,
shipping : {... } // TODO https://docs.stripe.com/js/payment_intents/confirm_payment#confirm_payment_intent-options-confirmParams-shipping
payment_method_data: {
billing_details: {
name : ${shippingDetails.first_name} ${shippingDetails.last_name},
email : customerDetails.email,
phone : shippingDetails.phone,
address: {
city : shippingDetails.city,
country : shippingDetails.country_code,
line1 : shippingDetails.address_1,
line2 : shippingDetails.address_2,
postal_code : shippingDetails.postal_code,
},
}
},
confirmParams: {
receipt_email: customerDetails.email
},
// Uncomment below if you only want redirect for redirect-based payments
redirect: "if_required"
}).then(({error,paymentIntent})=>{
if(error){
console.log(error)
}
if(paymentIntent){
console.log(paymentIntent)
}
});
}
if you want to pass a shipping address, pass it there ^^
await stripe.confirmPayment({ elements, clientSecret, shipping: { name : ${shippingDetails.first_name} ${shippingDetails.last_name}, email : customerDetails.email, phone : shippingDetails.phone, address: { city : shippingDetails.city, country : shippingDetails.country_code, line1 : shippingDetails.address_1, line2 : shippingDetails.address_2, postal_code : shippingDetails.postal_code, }, }, // payment_method_data: { // billing_details: { // name : ${shippingDetails.first_name} ${shippingDetails.last_name}, // email : customerDetails.email, // phone : shippingDetails.phone, // address: { // city : shippingDetails.city, // country : shippingDetails.country_code, // line1 : shippingDetails.address_1, // line2 : shippingDetails.address_2, // postal_code : shippingDetails.postal_code, // }, // } // }, confirmParams: { receipt_email: customerDetails.email }, // Uncomment below if you only want redirect for redirect-based payments redirect: "if_required" }).then(({error,paymentIntent})=>{ if(error){ console.log(error) } if(paymentIntent){ console.log(paymentIntent) } }); }
you can pass both(billing_details and shipping) if you want, and that gives all the information to the Stripe Dashboard
you didn't need to comment out billing_details
ah so you need both?
you don't need both, but you can pass both if you want.
So It should work right?
Like I should see the address of the customer here?
I was using <Card/> Element before and I was getting this
The billing details is set on the Payment Method, not the Customer directly when confirming an intent like that
But yes it's surfaced in the Dashboard UI like your screenshot
Sorry king i'm confused. How would I achieve the last screen shot I sent using the code I sent?
I thought passing billing_details into payment_method_data updated that
This, but uncomment the payment_method_data parameter as my colleagues noted
Yeah I have:
await stripe.confirmPayment({
elements,
clientSecret,
shipping: {
name :${shippingDetails.first_name} ${shippingDetails.last_name},
email : customerDetails.email,
phone : shippingDetails.phone,
address: {
city : shippingDetails.city,
country : shippingDetails.country_code,
line1 : shippingDetails.address_1,
line2 : shippingDetails.address_2,
postal_code : shippingDetails.postal_code,
},
},
payment_method_data: {
billing_details: {
name :${shippingDetails.first_name} ${shippingDetails.last_name},
email : customerDetails.email,
phone : shippingDetails.phone,
address: {
city : shippingDetails.city,
country : shippingDetails.country_code,
line1 : shippingDetails.address_1,
line2 : shippingDetails.address_2,
postal_code : shippingDetails.postal_code,
},
}
},
confirmParams: {
receipt_email: customerDetails.email
},
// Uncomment below if you only want redirect for redirect-based payments
redirect: "if_required"
}).then(({error,paymentIntent})=>{
if(error){
console.log(error)
}
if(paymentIntent){
fetcher.submit(null, {method: "POST"})
}
});
}
OK, then I'm not sure what the issue is?
Doing this shows up in the dashboard like
Without the customer shipping details
Sorry man forgive me aha
Because that's the payment method details. There's no concept of shipping details on those objects, there's just set on the payment itself. What's the pi_xxx ID?
pi_3PvdhgBCmvfPHMB30klm2DeT
I was following this if it helps any?
Yeah your code is wrong actually which is why the shipping data isn't set on the intent. You need to move the shipping parameter into the confirmParams hash: https://docs.stripe.com/js/payment_intents/confirm_payment#confirm_payment_intent-options-confirmParams-shipping
aaaaaaaaah
Sorry, overlooked that myself
No problem, glad I could help!
Is there anywhere I can like leave feedback? Tell ya boss to give you a raise?