#arielbo-payments

1 messages · Page 1 of 1 (latest)

main adder
orchid wasp
#

hi karbi

#

I will tell you more context, of my problem,

main adder
#

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

orchid wasp
#

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);

main adder
#

You would have to make another request to your backend before orderComplete that updates the Payment Intent with the metadata you need

orchid wasp
#

could you give me some example please?

main adder
white stratus
#

hello, catching up here

orchid wasp
#

hi syn

white stratus
#

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

orchid wasp
#

thanks a lot

white stratus
orchid wasp
#

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);
  }
});
white stratus
#

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.

orchid wasp
#

can I use fetch update_metada_endpoint.php ?

white stratus
#

yep, something like that

orchid wasp
white stratus
#

Do you know this information ahead of time?

orchid wasp
#

I cant put in when I create the payment intent, becouse I dont have still the information of the client

white stratus
#

This also sounds like information you could put on a Customer object

#

ok so you only get it later, fine

orchid wasp
white stratus
#

so yea you'll to manage that request to your backend to make the update then

orchid wasp
#

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 {

white stratus
#

Yep, just like your other fetch call, you should set that up for updating the metadata