startPayment( )


Starts a payment.

Before using the startPayment() function, you will 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 startPayment() function returns a Promise that resolves to a PaymentResult object when the user completes the payment process. Only use this result for display purposes. For business decisions, such as updating collection data, use the onPaymentUpdate event.

Starting a payment prompts the user to select a payment method and continue the payment process with the options specified in the options parameter.

Before calling startPayment(), create a payment and generate a value for the paymentId parameter. You can do this by calling createPayment() from your site's backend.

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

Use the options parameter to:

  • Determine whether a user info page is shown at the beginning of the process.
  • Determine whether a thank you page is shown at the end of the process.
  • Determine whether a terms and conditions affirmation checkbox and link are shown.

Notes:

  • To work with the Pay API, you need to save and publish your site.

  • The backend createPayment() function takes a PaymentInfo parameter that defines the information for a payment. 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.

  • The showThankYouPage option only applies to your Wix site's Thank You page. In-app browsers have their own separate Thank You pages which are unaffected by this setting.

Method Declaration
Copy
Method Parameters
paymentIdstringRequired

The payment ID returned by createPayment() or another app, such as Wix Pricing Plans' createOnlineOrder().


optionsPaymentOptions

Payment process options.

Returns
Return Type:Promise<PaymentResult>
Was this helpful?
Yes
No