Testing and Go Live
You can test your PayPal integration in the Braintree sandbox environment in 2 ways:
- Mocked PayPal testing (default)
- Behaves similarly to production but does not allow for end-to-end testing
- Uses Braintree sandbox test values to simulate PayPal responses in your Braintree sandbox
- Allows you to confirm that your client- and server-side configurations are correct and that you are receiving appropriate responses for your requests
- Does not return data to your PayPal sandbox account
- Does not work with the PayPal Checkout component of the JavaScript v3 SDK
- Linked PayPal testing
- Requires additional setup
- Directly connects your Braintree sandbox account to your PayPal sandbox account
- Returns data to both sandbox accounts
- Allows you to test the full functionality of your PayPal integration (e.g. transaction reporting, email receipts)
Do not use your PayPal business account as the PayPal customer account when paying for test transactions in the linked PayPal flow or in production. Doing so will result in declines.
Mocked PayPal testing
Use your Braintree sandbox API credentials and the test values on our Testing page to ensure your client and server integrations with Braintree are working as expected.
Any testing you do in the mocked PayPal flow will only be reflected in your Braintree sandbox – no data will be sent to your PayPal sandbox. If you'd like to do complete end-to-end testing, see linked PayPal testing.
Linked PayPal testing
In order to link a PayPal sandbox test account to your Braintree sandbox account, you will need the API credentials for that PayPal sandbox test account.
If you don't already have a PayPal sandbox test account for testing your Braintree integration, create a new one by following these steps:
- Create a PayPal business sandbox account:
- Log into the PayPal Developer Dashboard
- Navigate to Sandbox > Accounts
- Select the account type as Business
- Select the same Country as your Braintree sandbox account
- Select Create Account
- Go to the Create New App page:
- Create an app to get sandbox API credentials
- Select the same sandbox developer account as the test account created in step 1
- Note the following Sandbox API Credentials for the new app you created:
- Email address associated with this app
- Client ID
- Secret
After you successfully link your PayPal account with your Braintree account, some fake nonces (such as fake-paypal-one-time-nonce) may stop working.
Once you have those PayPal sandbox API credentials, enter them in your Braintree sandbox:
- Log into your Braintree sandbox Control Panel
- Navigate to Settings > Account Settings > Payment Methods > PayPal
- Select Link Sandbox
- Enter the Email address, Client ID, and Client Secret for your PayPal sandbox test account
- Select Link PayPal Sandbox
Testing App Switch
In this experience the SDK will attempt to switch to the PayPal App after calling tokenize if the PayPal App is installed and the user meets eligibility requirements. If the switch into the PayPal App cannot be completed, the SDK will fall back to the ASWebAuthenticationSession experience.
App Switch allows PayPal customers who have the PayPal app installed to complete their transaction in the PayPal app, streamlining checkout with strong multi-factor authentication. This feature can be tested in both the PayPal production app and sandbox environments. To test App Switch, make sure that:
- Your integration is App Switch-eligible.
- You have completed the PayPal App Switch integration.
Test your integration using the PayPal production app
Prerequisites
- Available for developers in the United States only.
- You have completed the App Switch integration.
- Your integration is App Switch eligible.
To see what the consumer experience will be for your PayPal App Switch integration, download the PayPal app from the App Store and run through the checkout success flow.
The email you use to sign in to the PayPal app must match the email passed in userAuthenticationEmail during checkout. See the App Switch integration guide for details.
If you want your team outside of the United States to test, use the PayPal Sandbox App described below.
Verify your integration
After completing a test transaction, confirm that:
- The buyer was redirected to the PayPal app and authenticated successfully.
- The buyer was returned to your app after approving the transaction.
- Your server received a valid payment nonce and the transaction completed successfully.
Test your integration using the PayPal sandbox app
Prerequisites
- Available for development teams inside and outside the United States.
- You have completed the App Switch integration.
- A Firebase account is required to access the sandbox app.
The PayPal Sandbox App lets your development team inside and outside the United States test what a PayPal consumer will see through the App Switch experience.
Delete all existing PayPal apps before installing the sandbox build. The sandbox app overrides the existing production app.
- Open the Firebase App Distribution link to join the tester program.
- Enter your email address to receive an invite.
- Open the invite email on your device and select Get Started.
Note
If you have already accepted the invite, open the Firebase App Distribution app directly and skip to step 4.
- Locate the latest build in the list and select the Download link for that build.
- Trust the enterprise developer certificate: Go to Settings → General → VPN & Device Management, find the PayPal certificate, and select Trust.
Note
If the Trust option does not appear in VPN & Device Management, check that your device is running iOS 16 or later. If the path differs on your iOS version, look for Device Management or Profiles under General.
- Select Install to download the app.
- Select Open to launch the app. You may be asked to sign in again using the same account from step 2.
Verify your integration
After installing and signing in to the sandbox app, run a test transaction and confirm that:
- Your app switches context to the PayPal sandbox app after the buyer initiates checkout.
- The buyer can authenticate and approve the transaction in the sandbox app.
- The buyer is returned to your app and the transaction completes successfully.
FAQ
- What if I have both the PayPal production app and the sandbox app installed?
- For the best experience, only install the sandbox app. The production PayPal app may interfere when switching from your app to the PayPal app. Delete the production app before installing the sandbox build.
- What if I have a real credit card linked to the test account?
- After App Switch, when you are redirected back to the merchant app, do not select Complete Transaction. If you have a real credit card linked to the test account, selecting Complete Transaction will charge the credit card.
- How do I revert to the PayPal production app after testing?
- Delete the sandbox build app and download PayPal from the App Store.
- I am testing using the Braintree Demo application. Do I need to change any settings?
-
Review the settings and select the following:
- Integration: PayPal - Web Checkout
- Environment: Sandbox
- Authorization Type: Tokenization Key
-
Review the settings and select the following:
- I get an "Untrusted Enterprise Developer" error when opening the sandbox app. What do I do?
- Go to Settings → General → VPN & Device Management. Find the PayPal enterprise certificate and select Trust. Reopen the app.
Two use cases available for testing
First, enable App Switch in your PayPal sandbox app
To test the App Switch experience, enable the following login methods:
- Login to your PayPal app. On the home screen, select the Avatar icon.
- On the Personal account screen, select the Login and security option to open the Login and Security screen.
- Locate the face-id/fingerprint toggle and select the preferred option.
- Locate the Extend your login session toggle and select the preferred option.
Use case 1: Change payment method
- Complete your checkout flow in your sample app.
- Select the PayPal button to checkout.
- Authenticate in the PayPal sandbox app.
- Change the payment method.
- Select Pay Now.
- Return to your merchant app with a payment confirmation screen.
Use case 2: Cancel payment
- Complete your checkout flow in your sample app.
- Select the PayPal button to checkout.
- Authenticate in the PayPal sandbox app.
- On the pay sheet, select Cancel.
- Verify the pay sheet closes and your app presents the appropriate flow.
Use cases not available for testing
- System errors
- App launch failure
- Activity feed updates
- Non-app Switch flow screens
Go Live
Your sandbox account is not linked to your production account in any way. Nothing created in the sandbox will transfer to production. This includes processing options and recurring billing settings. Your login information, merchant ID, and API keys will also be different.
Create an API user
Production API credentials, including your API keys, must be entered into your server-side code to connect API calls to the Braintree gateway. While each user in your gateway has their own unique set of API keys, only one set can be included in your integration.
We do not recommend including an individual user's API credentials. If you ever need to delete or suspend that user, this could break your connection to Braintree and result in failed transactions.
Get production credentials
Log into your production account as the API user to obtain your API credentials. You'll need the:
- Production merchant ID
- Production public key
- Production private key
Keep in mind that public and private keys are both environment- and user-specific.
Update production account settings
Make sure your production account settings mirror the ones in your tested sandbox configuration. Be sure to recreate any recurring billing plans or settings if you plan to use recurring billing in production.
Update live server configuration
In your server code, update your configuration to production values:
- Ruby
gateway = Braintree::Gateway.new(
:environment => :production,
:merchant_id => "use_your_merchant_id",
:public_key => "use_your_public_key",
:private_key => "use_your_private_key",
)- C#
var gateway = new BraintreeGateway
{
Environment = Braintree.Environment.PRODUCTION,
MerchantId = "YOUR_PRODUCTION_MERCHANT_ID",
PublicKey = "YOUR_PRODUCTION_PUBLIC_KEY",
PrivateKey = "YOUR_PRODUCTION_PRIVATE_KEY"
}- Python
gateway = braintree.BraintreeGateway(
braintree.Configuration(
braintree.Environment.Production,
merchant_id="use_your_merchant_id",
public_key="use_your_public_key",
private_key="use_your_private_key"
)
)- PHP
$gateway = new Braintree\Gateway([
'environment' => 'production',
'merchantId' => 'use_your_merchant_id',
'publicKey' => 'use_your_public_key',
'privateKey' => 'use_your_private_key'
]);- Node
const gateway = new braintree.BraintreeGateway({
environment: braintree.Environment.Production,
merchantId: "YOUR_PRODUCTION_MERCHANT_ID",
publicKey: "YOUR_PRODUCTION_PUBLIC_KEY",
privateKey: "YOUR_PRODUCTION_PRIVATE_KEY"
});- Java
BraintreeGateway gateway = new BraintreeGateway(
Environment.PRODUCTION,
"YOUR_PRODUCTION_MERCHANT_ID",
"YOUR_PRODUCTION_PUBLIC_KEY",
"YOUR_PRODUCTION_PRIVATE_KEY"
);Once you have updated these values and configured your preferred processing settings, the live production environment will function similarly to the sandbox environment you've been using for development. Learn more about the differences between production and the sandbox.
On the client side, no configuration updates are needed when you make the switch to production – your client obtains its client token from your server, which is all the configuration it needs.
Test transactions in production
Real payment methods must be used in the production environment. Test values from the sandbox testing page will not work. This means that every test transaction that you allow to settle in your production account will debit funds from the associated payment method and fees will be assessed. Be sure to test with reasonable amounts and only run a limited number of transactions.