#reikob

1 messages · Page 1 of 1 (latest)

frigid muskBOT
verbal harness
real cove
#

mm okay so I cant update the total amount like below?
cartObject has totalAmount property which updates the amount once the discount been applied
useEffect(() => {
if (stripe && cartObject) {
const pr = stripe.paymentRequest({
country: 'AU',
currency: 'aud',
total: {
label: 'Cart total',
amount: cartObject.totalAmount
},
requestPayerName: true,
requestPayerEmail: true,
requestShipping: false
});
console.log(pr);
// Check the availability of the Payment Request API.
pr.canMakePayment().then((result) => {
if (result) {
console.log('result', result);
setPaymentRequest(pr);
}
});
}
}, [stripe, cartObject]);

verbal harness
#

This is for payment request initiation. If you wish to update an existing payment request button, then paymentRequest.update(...) should be used

real cove
#

ahh okay, can I get an example of how to use paymentRequest.update()? to change the totalAmount?

#

do I need to store the return object to pr and add below code too?
pr.canMakePayment().then((result) => {
if (result) {
console.log('result', result);
setPaymentRequest(pr);
}
});

verbal harness
real cove
#

so I dont need to call canMakePayment() again after calling paymentRequest.update()?

verbal harness
#

You shouldn't need to

#

I'd recommend giving a try to check if it works

real cove
#

okay, thank you!