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)

Mocked PayPal testingAnchorIcon

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 testingAnchorIcon

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:

  1. 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
  2. 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
  3. Note the following Sandbox API Credentials for the new app you created:
    • Email address associated with this app
    • Client ID
    • Secret

Once you have those PayPal sandbox API credentials, enter them in your Braintree sandbox:

  1. Log into your Braintree sandbox Control Panel
  2. Navigate to Settings > Account Settings > Payment Methods > PayPal
  3. Select Link Sandbox
  4. Enter the Email address, Client ID, and Client Secret for your PayPal sandbox test account
  5. Select Link PayPal Sandbox

Testing App SwitchAnchorIcon

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 appAnchorIcon

PrerequisitesAnchorIcon

  • 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.

If you want your team outside of the United States to test, use the PayPal Sandbox App described below.

Verify your integrationAnchorIcon

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 appAnchorIcon

PrerequisitesAnchorIcon

  • 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.

  1. Open the Firebase App Distribution link to join the tester program.
  2. Enter your email address to receive an invite.
  3. Open the invite email on your device and select Get Started.
  4. Locate the latest build in the list and select the Download link for that build.
  5. Trust the enterprise developer certificate: Go to SettingsGeneralVPN & Device Management, find the PayPal certificate, and select Trust.
  6. Select Install to download the app.
  7. Select Open to launch the app. You may be asked to sign in again using the same account from step 2.

Verify your integrationAnchorIcon

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.

FAQAnchorIcon

  1. 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.
  2. 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.
  3. How do I revert to the PayPal production app after testing?
    • Delete the sandbox build app and download PayPal from the App Store.
  4. 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
  5. 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 testingAnchorIcon

First, enable App Switch in your PayPal sandbox appAnchorIcon

To test the App Switch experience, enable the following login methods:

  1. Login to your PayPal app. On the home screen, select the Avatar icon.
  2. On the Personal account screen, select the Login and security option to open the Login and Security screen.
  3. Locate the face-id/fingerprint toggle and select the preferred option.
  4. Locate the Extend your login session toggle and select the preferred option.

Use case 1: Change payment methodAnchorIcon

  1. Complete your checkout flow in your sample app.
  2. Select the PayPal button to checkout.
  3. Authenticate in the PayPal sandbox app.
  4. Change the payment method.
  5. Select Pay Now.
  6. Return to your merchant app with a payment confirmation screen.

Use case 2: Cancel paymentAnchorIcon

  1. Complete your checkout flow in your sample app.
  2. Select the PayPal button to checkout.
  3. Authenticate in the PayPal sandbox app.
  4. On the pay sheet, select Cancel.
  5. Verify the pay sheet closes and your app presents the appropriate flow.

Use cases not available for testingAnchorIcon

  • System errors
  • App launch failure
  • Activity feed updates
  • Non-app Switch flow screens

Go LiveAnchorIcon

Create an API userAnchorIcon

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.

Instead, create a new user specifically designated as the API user, whose API keys can be used for your integration. This user should be set up with an email address that is not associated with a single employee and should have Account Admin permissions in order to avoid issues such as an authorization errorauthorization errorauthorization errorauthorization errorauthorization errorauthorization error.

Get production credentialsAnchorIcon

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 settingsAnchorIcon

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 configurationAnchorIcon

In your server code, update your configuration to production values:

  1. 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",
)
  1. C#
var gateway = new BraintreeGateway
{
    Environment = Braintree.Environment.PRODUCTION,
    MerchantId = "YOUR_PRODUCTION_MERCHANT_ID",
    PublicKey = "YOUR_PRODUCTION_PUBLIC_KEY",
    PrivateKey = "YOUR_PRODUCTION_PRIVATE_KEY"
}
  1. 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"
    )
)
  1. PHP
$gateway = new Braintree\Gateway([
    'environment' => 'production',
    'merchantId' => 'use_your_merchant_id',
    'publicKey' => 'use_your_public_key',
    'privateKey' => 'use_your_private_key'
]);
  1. 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"
});
  1. 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 productionAnchorIcon

It is important to test your production account by creating a couple of low-value sale transactions for each of the payment method types you plan to accept. Be sure to submit the transactions for settlement, and then confirm that the funds have deposited into your bank account. This typically happens a few days after they have settled.