#arielbo-payments
1 messages · Page 1 of 1 (latest)
Hello! I don't believe you can add metadata to that call to confirmCardPayment you'd have to do it in a separate update request
I have implement this sample https://stripe.com/docs/payments/integration-builder-card and I need to add some metadata before the success payment
ar payWithCard = function(stripe, card, clientSecret) {
loading(true);
stripe
.confirmCardPayment(clientSecret, {
receipt_email: document.getElementById('email').value,
payment_method: {
card: card
}
})
.then(function(result) {
if (result.error) {
// Show error to your customer
showError(result.error.message);
} else {
// The payment succeeded!
orderComplete(result.paymentIntent.id);
}
});
please could you advice me to use some method or parameter? to add my own metadata please before to orderComplete(result.paymentIntent.id);
You would have to make another request to your backend before orderComplete that updates the Payment Intent with the metadata you need
could you give me some example please?
We don't have a specific example/sample for it - but you would just add a new endpoint to your backend that makes the update request (https://stripe.com/docs/api/payment_intents/update#update_payment_intent-metadata)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
hello, catching up here
hi syn
Does what karbi shared help you? You'll have to make a call to your back end to set the metadata on the payment intent
I m use php stripe, please could you tell me how can I do this call ?
thanks a lot
We include this in our API docs as an example, in fact 🙂
https://stripe.com/docs/api/payment_intents/update?lang=php#update_payment_intent-metadata
$stripe = new \Stripe\StripeClient(
'sk_test_123sR'
);
$stripe->paymentIntents->update(
'pi_456',
['metadata' => ['order_id' => '6735']]
);
yes I see this but my problem is that I m in the client public side with
stripe
.confirmCardPayment(clientSecret, {
receipt_email: document.getElementById('email').value,
payment_method: {
card: card
}
})
$stripe = new \Stripe\StripeClient(
'sk_test_123sR'
);
$stripe->paymentIntents->update(
'pi_456',
['metadata' => ['order_id' => '6735']]
);
.then(function(result) {
if (result.error) {
// Show error to your customer
showError(result.error.message);
} else {
// The payment succeeded!
orderComplete(result.paymentIntent.id);
}
});
I need for example some like this, my problem is how update before the orderComplete(result.paymentIntent.id);
Ok sure, but you'll need to have your JS client code call an endpoint on your PHP server to send that updates metadata, or otherwise include it when you create the payment intent.
can I use fetch update_metada_endpoint.php ?
yep, something like that
you can see my develop in here https://www.derechoteca.com/order/d-lex-bolivia-mensual my problem is that I need to save in metadata paymentintent, for example, email, name, lastname, pass and this before to orderComplete(result.paymentIntent.id);
Do you know this information ahead of time?
I cant put in when I create the payment intent, becouse I dont have still the information of the client
This also sounds like information you could put on a Customer object
ok so you only get it later, fine
no becouse is a new user and is with out sesion
so yea you'll to manage that request to your backend to make the update then
yes of course, too I put this data in customer objetc
I try with fetch and creating another endpoint
well I try using fetch before order complet
billing_details: {
name: document.getElementById('cus_name').value + document.getElementById('cus_lastname').value,
},
},
})
fetch ................................
.then(function(result) {
if (result.error) {
// Show error to your customer
showError(result.error.message);
} else {
Yep, just like your other fetch call, you should set that up for updating the metadata