Test PayPal in sandbox mode

Sandbox mode is a stand-alone environment that supports all the features of a live environment, except real and declined payments. You can access sandbox mode by sending “mode”:“sandbox” when you get the token.

To open the payment UI, use this link and specify the obtained token there: https://sandbox-secure.xsolla.com/paystation4/?token={token}.

In sandbox mode, you can test the following payment UI interaction scenarios for PayPal:

Note
For each scenario, you can also test generating errors.

Create test PayPal account

To test the payment process, you need to create an account for PayPal sandbox mode:

  1. Open the PayPal Developer website.
  2. Log in to your account or create a new one.
  3. Go to the Sandbox accounts tab.
  4. On the Sandbox test accounts page, click Create account.
  5. Select the Personal (Buyer Account) account type and choose the country.
  6. Click Create.

The created account is shown in the list of sandbox accounts.

You can also use information from existing sandbox accounts:

Test one-time purchase

Make test payment

  1. Open the payment UI in sandbox mode.
  2. Choose the PayPal payment method.
  3. In the Mock Response Code field, enter 0 or leave the field empty.
  4. In the ZIP Code field, enter any 5 digits.
  1. Click Pay. You will be redirected to a window to log in to your PayPal account.
  2. Enter information about your sandbox account: Email ID as the email address and System Generated Password as the password. To find this information:
    1. Log in to your account on the PayPal Developer website.
    2. Go to the Sandbox accounts tab.
    3. On the Sandbox test accounts page, choose a sandbox account.
    4. Click ••• and select View/Edit account from the drop-down list. You will see the data in the modal window that opens.
  3. Complete the test payment.
The transaction ID is shown on the page after completing the payment:

After completing a successful test payment, your PayPal account is saved in the list of payment methods.

To see transactions made in sandbox mode:
  1. Open your Publisher Account.
  2. Go to Accounting > Transaction registry.
  3. Check the Show test transactions box.

Refund

  1. Configure the Refund webhook.
  2. Make a successful test payment.
  3. Call the Request refund API method.

A notification about the payment refund will be sent to the webhook URL.

Partial refund

  1. Configure the Partial refund webhook.
  2. Make a successful test payment.
  3. Call the Request partial refund API method.

A notification about the partial payment refund will be sent to the webhook URL.

Chargeback

A separate API call for sandbox mode was developed to test this scenario without any bank participation.

To test chargeback:

  1. Configure the Refund webhook.
  2. Make a successful test payment.
  3. Call the Request chargeback API method.

You will receive a Refund webhook with the following code:

CodeReasonDescription
2ChargebackTransaction chargeback requested.

Test saved account

Save account

You can test saving an account in the payment UI:

Save account while making test payment

  1. Configure the Add payment account webhook.
  2. Open the payment UI in sandbox mode.
  3. Choose PayPal as a payment method.
  4. In the Mock Response Code field, enter 0 or leave the field empty.
  5. In the ZIP Code field, enter any 5 digits.
  6. Check the Never ask again box.
  7. Click Pay. You will be redirected to a window to log in to your PayPal account.
  8. Enter information about your sandbox account.
  9. Complete the test payment.

A notification about adding a new account is sent to the webhook URL.

The saved account is displayed in the Saved methods section.

Save account in payment UI

  1. Configure the Add payment account webhook.
  2. Open the payment UI in sandbox mode.
  3. Go to Saved.
  4. Click the pencil icon and choose Add new method.
  5. Choose PayPal.
  6. In the Mock Response Code field, enter 0 or leave the field empty.
  7. In the ZIP Code field, enter any 5 digits.
  8. Click Save. You will be redirected to a window to log in to your PayPal account.
  9. To complete settings, enter information about your sandbox account.
  10. Click Save and Continue.

A notification about adding a new account is sent to the webhook URL.

The saved account is displayed in the Saved methods section.

Delete saved account

You can test deleting a saved account:

Delete saved account via API

  1. Configure the Remove payment account webhook.
  2. Call the Delete saved accounts API method.

A notification about deleting an account is sent to the webhook URL.

Delete saved account in payment UI

  1. Configure the Remove payment account webhook.
  2. Open the payment UI in sandbox mode.
  3. Go to Saved.
  4. Click the pencil icon.
  5. Click Edit methods.
  6. Choose an account and click the bin icon.

A notification about deleting an account is sent to the webhook URL.

Charge with balance of saved account

You can test a payment with a saved account:
Note
You can test both:
  • a one-time charge (e.g., purchase with a saved card)
  • regular charges (e.g., subscription payment)

Charge balance of saved account via API

  1. Configure the Payment webhook.
  2. Save account in the sandbox mode.
  3. Call the Charge with saved account API method.

A notification about a successful payment is sent to the webhook URL.

Charge balance of saved account in payment UI

  1. Configure the Payment webhook.
  2. Save the account in sandbox mode.
  3. Open the payment UI in sandbox mode.
  4. Click the account from the list of saved payment accounts.
  5. Click Pay.

A notification about a successful payment is sent to the webhook URL.

Get list of saved accounts

  1. Save accounts in the sandbox mode.
  2. Call the Get saved accounts API method.

You will get masked data in the response.

Generate errors

  1. Open payment UI in sandbox mode.
  2. Choose the PayPal payment method.
  3. In the Mock Response Code field, enter an error code from the list that you want to test, or leave the field empty.
  4. In the ZIP Code field, enter any 5 digits.
  5. Click Pay. You will be redirected to your PayPal account to complete the payment.

The error message will appear on the payment UI.

Error codes:

Error codesTest scenario
1501, 1057, 1015, 3006, 1801, 1803, 1039Any test scenarios.
3031, 1203, 1039, 3006, 1201, 1002, 1089, 2031, 1046, 5004Payment without saving an account.
1084, 1089, 1071, 1501, 1207, 1021, 1022, 1002, 5020, 5022, 3031, 1091, 1203, 1039, 3006, 1201, 1002, 1089, 2031, 1046, 5004, 2030, 1059, 3022, 1803, 1090, 2001, 1000, 1050, 1044Payment with saving an account.
3031, 1203, 1039, 3006, 1201, 1002, 1089, 2031, 1046, 5004Payment with a saved account.
Was this article helpful?
Thank you!
Is there anything we can improve? Message
We’re sorry to hear that
Please explain why this article wasn’t helpful to you. Message
Thank you for your feedback!
We’ll review your message and use it to help us improve your experience.
Rate this page
Rate this page
Is there anything we can improve?

Don’t want to answer

Thank you for your feedback!
Last updated: January 31, 2024

Found a typo or other text error? Select the text and press Ctrl+Enter.

Report a problem
We always review our content. Your feedback helps us improve it.
Provide an email so we can follow up
Thank you for your feedback!