Hello everyone and good night :)
I am trying to obtain the payment_method details i.e. card and billing address details from the stripe.confirmSetup call in javascript. I have tried to expand the payment_method parameter with no luck so far. I can retrieve the needed details with a subsequent api call with the newly created payment method but am trying to avoid that if possible.
My code is as follows:
const form = document.getElementById("payment-form");
const stripe = Stripe('pk_test.....s'),
form.addEventListener('submit', async (event) => {
event.preventDefault();
stripe.confirmSetup({
clientSecret : "seti_...",
redirect : "if_required",
confirmParams : {
return_url : "example.com/returnURL.php"
}
}).then(function(result){
if(result.error){
document.getElementById("error-message").textContent = result.error.message;
}else{
console.log(result.setupIntent);
}
});
Thanks for your help! - Midgeypoo
There is not a way to pass an expand
parameter on a SetupIntent confirmation. When you pass this, you'll get an error stripe.confirmSetup() parameter: expand is not a recognized parameter.
To get data from the payment_method
, you can make a separate request to retrieve the SetupIntent, on the client side using the expand parameter. There are a subset of properties that will be returned when using a publishable key with retrieving the Setup Intent which are marked with RETRIEVABLE WITH PUBLISHABLE KEY in the API document and payment_method
is one.