createPayment( )


Creates a new payment.

Before using the createPayment() function, you need to set up your site to accept payments. To learn more, see 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.

The createPayment() function returns a Promise that resolves to a Payment object when the payment has been created.

Creating a payment is the first step in the process of accepting a payment from a user. After creating the payment, call startPayment() from your site's client-side code using the payment ID returned by createPayment. The startPayment() function prompts the user to select a payment method and continue the payment process.

To understand how createPayment() is used in a typical payment lifecycle, see Typical Payment Lifecycle.

Note:

  • To work with the Pay API, you need to save and publish your site.
  • For security reasons you should always create the PaymentInfo object in backend code. Do not pass payment information from client-side code. Doing so opens a vulnerability that a malicious user can exploit to change payment information, such as the price of an item being purchased.
  • To learn more about how to keep your payment code secure, see Security Considerations When Working with Wix Code.
Method Declaration
Copy
Method Parameters
paymentInfoPaymentInfoRequired

The information for the payment being created.

Returns
Return Type:Promise<Payment>
Did this help?