#Alexey.Drabushev
1 messages · Page 1 of 1 (latest)
req_Dpjk0uyS1rgk7B
Here the issue is Stripe blocked that payment. So ask your customer to try with a different card.
yes. I understand. but the question is "how can I hanlde the tokens request, if I use { PaymentRequestButtonElement, Elements } from '@stripe/react-stripe-js';
"
in order to show the error message
I'm not sure I understand. What are you trying to achieve?
If user trying to pay with the blocked card, just putting the card details in payment form, I can show him/her an error message using the stripe.createPaymentMethod request.
But when it happens via Apple Pay I don't have an access to this method. I use paymentRequest.on('paymentmethod'), but the tokens (screenshot) request doing before
Which error message exactly you would like to display? The one in error.message from your screenshot above?
And currently what error message is displayed to users? Car you share a screesnshot?
yes, I want to show error.message.
but I didn't show any UI alerts because I don't know how to handle tokens request
I'm using the flow like this:
const pr = stripe.current.paymentRequest({});
pr.canMakePayment().then((result) => {
if (result) {
setPaymentRequest(pr);
}
});
pr.on('paymentmethod', async (e) => {
onPurchaseClick();
});
<Elements stripe={stripePromise}>
<PaymentRequestContainer>
<PaymentRequestButtonElement
options={{ paymentRequest }}
/>
</PaymentRequestContainer>
</Elements>
I don't think you can access this error message directly. Instead it's up to know to display errors in the if (confirmError) {} and if (error) {} in the code here: https://stripe.com/docs/stripe-js/elements/payment-request-button?client=react#react-complete-payment