Payment Request Example
Your own button opens the browser's payment sheet (Apple Pay, Google Pay, Link or a saved card). usePaymentRequest() creates the PaymentRequest and checks canMakePayment(); when the customer authorizes, the paymentmethod handler creates a PaymentIntent on the server and confirms it with useConfirmCardPayment().
Prefer the Express Checkout Element
For new integrations Stripe recommends the Express Checkout Element, which renders the wallet buttons for you. Use usePaymentRequest to keep an existing custom-button integration working.
Try the demo
The demo runs in Stripe test mode against the demo backend at backend.vuestripe.com, so nothing is charged. The demo takes a $10.99 test payment. The button only appears when this browser has a wallet or a saved card and the page is served over HTTPS. Otherwise the demo shows the canMakePayment result, No wallet in this browser.
Pay with the browser's payment sheet
How the demo works
usePaymentRequest()creates aPaymentRequestfor $10.99 (countryUS, currencyusd) that asks for the payer's name and email, and runscanMakePayment(). The demo prints the result: the wallets this browser offers, orNo wallet in this browser.- The Pay $10.99 button calls
show(), which opens the browser's payment sheet. - When the customer authorizes the payment, the request emits
paymentmethod. The handler, registered withon('paymentmethod', ...), asks the backend to create a PaymentIntent for $10.99. - It then calls
confirmCardPayment()fromuseConfirmCardPayment()with the new PaymentMethod ID andhandleActions: false, so the sheet can close before any 3D Secure step. - The handler closes the sheet with
event.complete('success')orevent.complete('fail'). If the PaymentIntent needs an action such as 3D Secure, it callsconfirmCardPayment()again to run it. - When the PaymentIntent status is
succeeded, the demo shows the PaymentIntent ID.
See also
How-to guide: Add Apple Pay, Google Pay and Link buttons, with the Express Checkout Element that replaces this API. Reference: usePaymentRequest and useConfirmCardPayment.
