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:
- making test payment
- refund
- partial refund
- chargeback
- saving account
- deleting saved account
- charging with saved account
- getting the list of saved accounts
Create test PayPal account
To test the payment process, you need to create an account for PayPal sandbox mode:
- Open the PayPal Developer website.
- Log in to your account or create a new one.
- Go to the
Sandbox accounts tab. - On the
Sandbox test accounts page, clickCreate account . - Select the
Personal (Buyer Account) account type and choose the country. - Click
Create .
The created account is shown in the list of sandbox accounts.
You can also use information from existing sandbox accounts:
sb-xmxij16980134@business.example.com | oi9_m_KW |
sb-p7pju16979920@business.example.com | 7%%p8ioS |
Test one-time purchase
Make test payment
- Open the payment UI in sandbox mode.
- Choose the PayPal payment method.
- In the
Mock Response Code field, enter0
or leave the field empty. - In the ZIP Code field, enter any 5 digits.
- Click Pay. You will be redirected to a window to log in to your PayPal account.
- Enter information about your sandbox account:
Email ID as the email address andSystem Generated Password as the password. To find this information:- Log in to your account on the PayPal Developer website.
- Go to the
Sandbox accounts tab. - On the
Sandbox test accounts page, choose a sandbox account. - Click ••• and select View/Edit account from the drop-down list. You will see the data in the modal window that opens.
- Complete the test payment.
After completing a successful test payment, your PayPal account is saved in the list of payment methods.
To see detailed information, including fees, about transactions made in sandbox mode:
- Open your Publisher Account.
- Go to Accounting > Transaction registry.
- Check the Show test transactions box.
Additionally, you can see the transactions’ details and request refunds in Publisher Account in the Support > Transaction search section.
Refund
- Configure the Refund webhook.
- Make a successful test payment.
- Call the Request refund API method.
A notification about the payment refund will be sent to the webhook URL.
Partial refund
- Configure the Partial refund webhook.
- Make a successful test payment.
- 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:
- Configure the Refund webhook.
- Make a successful test payment.
- Call the Request chargeback API method.
You will receive a Refund webhook with the following code:
Code | Reason | Description |
---|---|---|
2 | Chargeback | Transaction chargeback requested. |
Test saved account
Save account
You can test saving an account in the payment UI:Save account while making test payment
- Configure the Add payment account webhook.
- Open the payment UI in sandbox mode.
- Choose PayPal as a payment method.
- In the
Mock Response Code field, enter0
or leave the field empty. - In the ZIP Code field, enter any 5 digits.
- Check the Never ask again box.
- Click Pay. You will be redirected to a window to log in to your PayPal account.
- Enter information about your sandbox account.
- 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
- Configure the Add payment account webhook.
- Open the payment UI in sandbox mode.
- Go to Saved.
- Click the pencil icon and choose Add new method.
- Choose PayPal.
- In the
Mock Response Code field, enter0
or leave the field empty. - In the ZIP Code field, enter any 5 digits.
- Click Save. You will be redirected to a window to log in to your PayPal account.
- To complete settings, enter information about your sandbox account.
- 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
- Configure the Remove payment account webhook.
- 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
- Configure the Remove payment account webhook.
- Open the payment UI in sandbox mode.
- Go to Saved.
- Click the pencil icon.
- Click Edit methods.
- 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:- a one-time charge (e.g., purchase with a saved card)
- regular charges (e.g., subscription payment)
Charge balance of saved account via API
- Configure the Payment webhook.
- Save account in the sandbox mode.
- 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
- Configure the Payment webhook.
- Save the account in sandbox mode.
- Open the payment UI in sandbox mode.
- Click the account from the list of saved payment accounts.
- Click Pay.
A notification about a successful payment is sent to the webhook URL.
Get list of saved accounts
- Save accounts in the sandbox mode.
- Call the Get saved accounts API method.
You will get masked data in the response.
Generate errors
- Open payment UI in sandbox mode.
- Choose the PayPal payment method.
- In the
Mock Response Code field, enter an error code from the list that you want to test, or leave the field empty. - In the ZIP Code field, enter any 5 digits.
- 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 | Test scenario |
---|---|
1501 , 1057 , 1015 , 3006 , 1801 , 1803 , 1039 | Any test scenarios. |
3031 , 1203 , 1039 , 3006 , 1201 , 1002 , 1089 , 2031 , 1046 , 5004 | Payment 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 , 1044 | Payment with saving an account. |
3031 , 1203 , 1039 , 3006 , 1201 , 1002 , 1089 , 2031 , 1046 , 5004 | Payment with a saved account. |
Found a typo or other text error? Select the text and press Ctrl+Enter.