#carson-testing-paymentrequest
1 messages · Page 1 of 1 (latest)
Hi there 👋 you're right, putting test cards into Google Pay isn't an option. But, if you initialize the page with a test key, then we don't actually charge the selected card. Instead we swap the transaction to hit a test card.
You should see test in saying "(WON'T BE CHARGED)" near the pay button.
hm that's interesting, i'm initializing with a test key, but it's bringing up my currently logged in user's card
do i need to log out of google on chrome or something for this to work?
It'll still show the cards of the user you're logged in as (in my screenshot that is actually a prepaid gift card) it just won't charge that card.
right
but is it possible to test cards that throw errors?
or how to people test the error logic for payment request?
Oh, you're trying to test failures, apologies for not picking up on that sooner.
no worries
@slate ginkgo sorry for the delay, the server got quite busy. One solution here is to listen for the paymentmethod event where it creates the pm_123 for the card in Google Pay and then you can call confirmCardPayment() and pass a different PaymentMethod id such as pm_card_chargeDeclined for example to trigger a decline
no problem at all. i will give that a try
seemed to work! one last thing is, is there a method to actually close the payment request interface? something like paymentRequest.hide()?
for instance i want to hide the interface and show an error message to the user if they encounter an error
https://stripe.com/docs/stripe-js/elements/payment-request-button?html-or-react=html#html-js-complete-payment are the docs. You're in the callback so you do ev.complete('fail');
ah ok, yeah i have that, but the fail doesn't seem to actually hide the window
passing fail seems to show a generic error in the google payment interface but doesn't actually hide it
@slate ginkgo you can't control this unfortunately, it's up to each "provider". Google Pay will show the error and wait for the customer to dismiss the UI while Apple Pay shows the error for a few seconds and then hides the UI