#Giriraj
1 messages · Page 1 of 1 (latest)
hello! can you share your site's url for me to take a closer look?
i have did just this step
https://stripe.com/docs/stripe-js/elements/payment-request-button?client=react
yes sure
- click on any slot then click on
claim one session - it's redirect to second page then you can see
yes
honestly, the only reason i can think of is something about your Apple Pay setup / config on your device isn't correct. I would suggest asking a couple of your other colleagues to try it out too
ok, i have did this step only.
should i need to add another step?
what other step are you referring to?
the Apple Pay button shows fine for me, so it's got nothing to do with your code
ok, but how can i create paymentintent?
it's mentioned in step 4 and 5 of that document you shared
you would create the PaymentIntent on your backend server.
you can take a look at the example : https://stripe.com/docs/payments/quickstart for the backend server code. It's not specifically for the Payment Request Button but it can serve as reference
ok checking
but i have used Elements for Add new Card button
you can click on Add new card button and see
I'm afraid I don't understand the problem - can you try phrasing your question to describe what you're seeing, and what is the behaviour you're expecting to see instead?
let me download your provided link code and let me check
prior to this, you were asking how to create the PaymentIntent. I pointed you to that quickstart guide : https://stripe.com/docs/payments/quickstart as reference for how to create the PaymentIntent on your server. As i've mentioned, that guide is not for the Payment Request Button, but you can use that guide as a reference to understand how to go about creating a PaymentIntent on your backend server
wait i m checking
let me share one example just let me know it's ok or not
const paymentRequest = stripe.paymentRequest({
country: 'US',
currency: 'usd',
total: {
label: 'Demo total',
amount: totalPayPrice * 100,
},
});
paymentRequest.canMakePayment().then(result => {
console.log("result*************", result)
if (result) {
setPaymentRequest(pr);
}
});
paymentRequest.on('paymentmethod', async (ev) => {
const {paymentIntent, error: confirmError} = await stripe.confirmCardPayment(
clientSecret,
{payment_method: ev.paymentMethod.id},
{handleActions: false}
);
if (confirmError) {
ev.complete('fail');
} else {
ev.complete('success');
if (paymentIntent.status === "requires_action") {
const {error} = await stripe.confirmCardPayment(clientSecret);
if (error) {
// The payment failed -- ask your customer for a new payment method.
} else {
// The payment has succeeded.
}
} else {
// The payment has succeeded.
}
}
});
can i put this code inside useEffect. can i use pr.canMakePayment() and paymentRequest.on() method ?
then payment is working?
you can try it out