Introduction
To process payments on your site, first set up your site to accept payments as described in About Accepting Payments. When setting up your site to accept payments, be sure to select the payment methods you want to offer and set your payment currency. You can also set up a list of alternative currencies to display your prices in. Use the currency objects and the currency conversion dropdown element to set up and display product prices in different currencies.
Typical Payment Lifecycle
The following list outlines the steps taken in a typical payment lifecycle:
- A site visitor clicks a button to start the payment process.
- The button's event handler calls a backend function.
- A
PaymentInfo
object containing information about the payment, such as the payment amount, is created in the backend function. - The backend function calls
createPayment()
using thePaymentInfo
object and returns the generatedPayment
object to the calling client-side event handler. - The event handler then calls the
startPayment()
function with the id from thePayment
object, which opens the payment popup on your site. - The site visitor enters the payment information.
- The event handler optionally handles the returned
PaymentResult
. - Handle additional status updates to the payment transaction using the
onPaymentUpdate()
event.
To use the Pay API, import wixPayFrontend
from the wix-pay-frontend
module:
javascript | Copy Codeimport wixPayFrontend from 'wix-pay-frontend';
Note: To work with the Pay API, you need to save and publish your site.
Was this helpful?