Are you looking for test card numbers?

Would you like to contact support?

Payment-method icon

PayPal Redirect Component

Add PayPal to an existing Components integration.

If you have an existing Android Components integration, you can use our Redirect Component to redirect the shopper to complete the payment. As with other redirect payment methods, you need to handle the redirect after the shopper returns to your app.

Before you begin

This page explains how to add PayPal to your existing Android Components integration. The Android Components integration works the same way for all payment methods. If you haven't done this integration yet, refer to our Components integration guide.

Before starting your PayPal integration:

  1. Make sure that you have set up your back end implementation for making API requests.
  2. Add PayPal in your Customer Area.

Create developer and sandbox accounts

To test your integration, you need a PayPal developer account. Under your developer account you create a PayPal sandbox environment and a PayPal Business and Personal sandbox account to test payments.

  1. Create a PayPal developer account, if you don't already have one.
  2. Under your developer account, create PayPal Business and Personal sandbox accounts.
    To be able to see your test payments later, it is important that you create your sandbox accounts under your PayPal developer account.

See the PayPal sandbox testing guide for more information.
The following table shows the PayPal accounts that you need for your test integration:

Account type Description Use it to
Developer PayPal developer account. Access the PayPal developer dashboard, create and manage Business and Personal sandbox accounts.
Business PayPal sandbox Business account.
For example, ending in @business.example.com
Add PayPal as a payment method in your test Customer Area. Provide the Merchant ID and email address of this account. For more information, see Add payment methods to your account.
Personal PayPal sandbox Personal account.
For example, ending in @personal.example.com
Test payments from a shopper's side.

Set up third-party API access on your PayPal account

To connect your PayPal account to your Adyen integration, you have to grant third-party permissions to Adyen in your PayPal Business account. To do that:

  1. Log in to your PayPal test store with the test Business account.
  2. Follow PayPal's instructions on granting third-party permissions.
    For Third Party Permission Username, use sell1_1287491142_biz_api1.adyen.com.
    Under Permissions, select:
    • Use Express Checkout to process payments.
    • Issue a refund for a specific transaction.
    • Process your shopper's credit or debit card payments.
    • Authorize and capture your PayPal transactions.
    • Obtain information about a single transaction.
    • Obtain authorization for pre-approved payments and initiate pre-approved transactions.
    • Generate consolidated reports for all accounts, if available in your region.
    • Use Express Checkout to process mobile payments, if you plan on supporting mobile payments.
    If you're using PayPal for recurring payments, also select:
    • Charge an existing customer based on a prior transaction.
    • Create and manage Recurring Payments.
    If you're using MassPay, also select:
    • Obtain your PayPal account balance.
    • Initiate transactions to multiple recipients in a single batch.

Get your PayPal Merchant ID

When you add PayPal as a payment method in your Customer Area, you need to provide your PayPal Merchant ID. Your PayPal Merchant ID is generated when you create your test and your live PayPal Business accounts, and consists of 13 randomly generated alphanumeric characters.

To get your PayPal Merchant ID:
  1. Log in to PayPal with your test Business account.
  2. Find your Merchant ID.
    • Go to Profile > Account Settings.
    • Under Business profile, select Business information.
    • Copy or write down your PayPal Merchant ID.

Show PayPal in your payment form

Include PayPal in the list of available payment methods. You don't need to collect any information from the shopper in your payment form.

  1. Specify in your /paymentMethods request:

The response contains paymentMethod.type: paypal.

We provide logos for PayPal which you can use on your payment form. For more information, refer to Downloading logos.

Make a payment

When the shopper proceeds to pay, you need to:

  1. From your server, make a POST /payments request, specifying:

    • paymentMethod.type: Set this to paypal.
    • channel: The platform where a payment transaction takes place.
    • returnUrl: URL to where the shopper should be redirected back to after they complete the payment. Get this URL from the Component in the RedirectComponent.getReturnUrl(context).
    curl https://checkout-test.adyen.com/v68/payments \
    -H "x-API-key: YOUR_X-API-KEY" \
    -H "content-type: application/json" \
    -d '{
     "merchantAccount":"YOUR_MERCHANT_ACCOUNT",
     "shopperReference": "YOUR_UNIQUE_SHOPPER_ID",
     "reference":"YOUR_ORDER_NUMBER",
     "amount":{
       "currency":"EUR",
       "value":1000
      },
     "{hint:state.data.paymentMethod from onSubmit}paymentMethod{/hint}":{
       "type":"paypal"
     },
     "returnUrl":"adyencheckout://your.package.name"
    }'
    # Set your X-API-KEY with the API key from the Customer Area.
    adyen = Adyen::Client.new
    adyen.api_key = "YOUR_X-API-KEY"
    
    response = adyen.checkout.payments({
      :amount => {
        :currency => "EUR",
        :value => 1000
      },
      :reference => "YOUR_ORDER_NUMBER",
      :paymentMethod => {
        :type => "paypal",
        :subtype => ""
      },
      :merchantAccount => "YOUR_MERCHANT_ACCOUNT"
    })
    // Set YOUR_X-API-KEY with the API key from the Customer Area.
    // Change to Environment.LIVE and add the Live URL prefix when you're ready to accept live payments.
        Client client = new Client("YOUR_X-API-KEY", Environment.TEST);
        Checkout checkout = new Checkout(client);
    
        PaymentsRequest paymentsRequest = new PaymentsRequest();
    
        String merchantAccount = "YOUR_MERCHANT_ACCOUNT";
        paymentsRequest.setMerchantAccount(merchantAccount);
    
        Amount amount = new Amount();
        amount.setCurrency("EUR");
        amount.setValue(1000L);
        paymentsRequest.setAmount(amount);
    
        PayPalDetails payPalDetails = new PayPalDetails();
        payPalDetails.setSubtype(state.data.paymentMethod.);
    
        paymentsRequest.setPaymentMethod(payPalDetails);
    
        paymentsRequest.setReference("YOUR_ORDER_NUMBER");
    
        PaymentsResponse paymentsResponse = checkout.payments(paymentsRequest);
    // Set your X-API-KEY with the API key from the Customer Area.
    $client = new \Adyen\Client();
    $client->setXApiKey("YOUR_X-API-KEY");
    $service = new \Adyen\Service\Checkout($client);
    
    $params = array(
      "amount" => array(
        "currency" => "EUR",
        "value" => 1000
      ),
      "reference" => "YOUR_ORDER_NUMBER",
      "paymentMethod" => array(
        "type" => "paypal",
        "subtype" => ""
      ),
      "merchantAccount" => "YOUR_MERCHANT_ACCOUNT"
    );
    $result = $service->payments($params);
    #Set your X-API-KEY with the API key from the Customer Area.
    adyen = Adyen.Adyen()
    adyen.client.xapikey = 'YOUR_X-API-KEY'
    
    result = adyen.checkout.payments({
       'amount': {
          'value': 1000,
          'currency': 'EUR'
       },
       'reference': 'YOUR_ORDER_NUMBER',
       'paymentMethod': {
          'type': 'paypal',
          'subtype': ''
       },
       'merchantAccount': 'YOUR_MERCHANT_ACCOUNT'
    })
    // Set your X-API-KEY with the API key from the Customer Area.
    const {Client, Config, CheckoutAPI} = require('@adyen/api-library');
    const config = new Config();
    // Set your X-API-KEY with the API key from the Customer Area.
    config.apiKey = '[API_KEY]';
    config.merchantAccount = '[YOUR_MERCHANT_ACCOUNT]';
    const client = new Client({ config });
    client.setEnvironment("TEST");
    const checkout = new CheckoutAPI(client);
    checkout.payments({
        amount: { currency: "EUR", value: 1000 },
        paymentMethod: {
            type: 'paypal',
            subtype: ''
        },
        reference: "YOUR_ORDER_NUMBER",
        merchantAccount: config.merchantAccount
    }).then(res => res);

    The /payments response contains:

    • action: Object containing information about the redirect.
    /payments response
    {
       "resultCode":"RedirectShopper",
       "action":{
          "paymentData":"Ab02b4c0!BQABAgCSZT7t...",
          "paymentMethodType":"paypal",
          "url":"https://test.adyen.com/hpp/checkout.shtml?u=redirectPayPal&p=eJxtkt..",
          "method":"GET",
          "type":"redirect"
       },
       "details":[
          {
             "key":"payload",
             "type":"text"
          }
       ],
       ...
    }
  2. Pass the action object to your client app.

Handle the redirect

  1. Use the Redirect Component to redirect the shopper to PayPal.
  2. After the shopper returns to your app, make a POST /payments/details request from your server, providing:

    • details: The actionComponentData.details object from the Redirect Component.

    /payments/details request
    curl https://checkout-test.adyen.com/v68/payments/details \
    -H "x-API-key: YOUR_X-API-KEY" \
    -H "content-type: application/json" \
    -d '{
     "details": {
       "redirectResult": "eyJ0cmFuc1N0YXR1cyI6IlkifQ=="
    }
    }'

You receive a response containing:

  • resultCode: Use this to present the payment result to your shopper.
  • pspReference: Our unique identifier for the transaction.

/payments/details response
{
      "resultCode": "Authorised",
      "pspReference": "PPKFQ89R6QRXGN82"
}

Present the payment result

Use the resultCode that you received in the /payments/details response to present the payment result to your shopper.
The resultCode values you can receive for PayPal are:

resultCode Description Action to take
Authorised The payment was successful. Inform the shopper that the payment has been successful.
See note 1
Pending or
Received
The shopper has completed the payment but the final result is not yet known. Inform the shopper that you've received their order, and are waiting for the payment to be completed.
You will receive the final result of the payment in an AUTHORISATION webhook.
Error There was an error when the payment was being processed. Inform the shopper that there was an error processing their payment.
You will receive more information about the error in the AUTHORISATION webhook. The webhook contains a refusalReason, indicating the cause of the error.
Refused The payment was refused by the shopper's bank. Ask the shopper to try the payment again using a different payment method.
Cancelled The shopper canceled the PayPal payment. Ask the shopper to select a different payment method.

1 If you use any standard risk rules or have configured any custom risk rules that might trigger after authorisation, you should monitor webhooks carefully to determine the status of a payment.

Wait for webhooks to know the outcome of the payment. The webhooks you can receive for PayPal are:

eventCode success field Description Action to take
AUTHORISATION false The transaction failed. Cancel the order and inform the shopper that the payment failed.
AUTHORISATION true The shopper successfully completed the payment. Inform the shopper that the payment has been successful and proceed with the order.
OFFER_CLOSED true The shopper did not complete the payment. Cancel the order and inform the shopper that the payment timed out.
To receive this event code as part of your standard webhooks, see non-default event codes.

Include more details in webhooks

You can include more PayPal details in your standard webhooks. When you enable additional settings, you can get the following PayPal specific information returned as additionalData in your standard webhooks:

Setting Description Fields included in additionalData
Include PayPal Details Receive the PayPal details of the shopper.
  • paypalEmail – The email address of the shopper's PayPal account
  • paypalPayerId – The shopper's PayPal Payer ID
  • paypalPayerStatus – Whether the shopper's account has been Verified by PayPal
  • paypalAddressStatus – Whether the shopper's address has been Confirmed by PayPal
  • paypalProtectionEligibility – Whether the payment is eligible for PayPal Seller Protection
  • paypalPayerResidenceCountry – The shopper's country of residence

To include PayPal details in your standard webhooks:

  1. In your Customer Area, go to Developers > Webhooks.
  2. Next to Standard Notification, select the edit webhook icon .
  3. Under Additional Settings, select Include PayPal Details.
  4. Select Save Configuration.

Recurring payments

Enable recurring payments

To enable recurring payments for PayPal:

  1. Contact PayPal Support to enable Reference Transactions on your seller account. For this, you will need your Merchant ID.
  2. Enable the recurring permissions on your PayPal account. Follow the steps described in the third-party API permission setup section, and also grant the permissions Charge an existing customer based on a prior transaction and Create and manage Recurring Payments.

Configure webhooks

You can get details about recurring payments in the AUTHORISATION and RECURRING_CONTRACT webhooks.

AUTHORISATION webhook

To receive the recurring.recurringDetailReference and the recurring.shopperReference in the additionalDetails of the AUTHORISATION webhook:

  1. Log in to your Customer Area with your company-level account.
  2. Go to Developers > Additional data.
  3. Under Payment, select Recurring details.

RECURRING_CONTRACT webhook

Make sure that your server is able to receive RECURRING_CONTRACT as part of your standard webhooks.

For instructions, see non-default event codes and additional settings.

Make a recurring payment

You can make recurring payments once you've enabled recurring payments on your PayPal account, and configured webhooks. To do this:

  1. Create a shopper token.
  2. Use the token to make future payments for the shopper.

Create a token

To create a token, include in your /payments request:

  • storePaymentMethod: true
  • shopperReference: Your unique identifier for the shopper.
  • When making a zero-auth transaction with amount.value: 0, you must also include shopperEmail .

When the payment has been settled, you receive a webhook containing:

  • eventCode: RECURRING_CONTRACT
  • originalReference: The pspReference of the initial payment.
  • pspReference: This is the token that you need to make recurring payments for this shopper.

Make a payment with a token

To make a payment with the token, include in your /payments request:

  • paymentMethod.storedPaymentMethodId: The pspReference from the RECURRING_CONTRACT.
    You can also get this value by using the /listRecurringDetails endpoint.
  • shopperReference: The unique shopper identifier that you specified when creating the token.
  • shopperInteractionContAuth.
  • recurringProcessingModel: CardOnFile, Subscription or UnscheduledCardOnFile.

For more information about the shopperInteraction and recurringProcessingModel fields, refer to Recurring transaction types.

Set up PayPal Seller Protection

PayPal Seller Protection only applies to physical goods.

If you participate in the PayPal Seller Protection program, make sure that you submit the following fields in your payment requests:

The details provided in these fields will populate the Ship to section of the PayPal checkout.
We recommend that you check that your setup is working correctly with a test payment. Make sure that you submit the correct fields, and that the test payment is marked as eligible for PayPal Seller Protection in the transaction details.

Test and go live

Test your integration

When you are done setting up your integration, use your PayPal developer sandbox accounts to test the PayPal Smart Payment Buttons payment flow. There are two types of accounts that you'll use to test how your integration handles the flow:

  • Business: used to simulate your role as a merchant when testing payments.
  • Personal: used to simulate the role of a shopper when testing payments.

You can check the status of a PayPal test payment in your Customer Area > Transactions > Payments.

Before you go live

Create a live account

For live operations, you will need another PayPal Business account. To create one:

  1. Go to the PayPal website, select Sign Up and follow the instructions.
    We strongly recommend that you use a generic company email address for your live PayPal Business account instead of a personal email address. This is to prevent having to configure a new account for your business in the future, should the personal email address no longer be in use for any reason. The email address for your live PayPal Business account will also be displayed on the payment receipt the shopper receives from PayPal.
  2. After you create your live Business account, make sure to activate it.

To set up your live PayPal Business account:

  1. Log in to your live PayPal Business account.
  2. Grant third-party access on your live account.
  3. Retrieve your live PayPal Merchant ID.

Add PayPal to your live Customer Area

  1. Add PayPal to your live Customer Area. Provide:
    • Your email address. Use your live PayPal Business email address.
    • Your account ID. Use your live PayPal Merchant ID.
    • Whether you want to enable authorisation first, and capture the payment later. By default, payments will be captured immediately after authorisation. Check this box only if payments should not be captured immediately.

In the live environment, note that PayPal will only be available if:

  • The shopper is logged in to their PayPal account.
  • The shopper has at least one valid payment method on their PayPal account.

See also