Search…
PayPal
Accept payment from consumers using PayPal to transfer funds online.

PayPal Express Checkout (Digital Wallet)

PayPal is a payment service that facilitates payments between parties through online funds transfers. PayPal allows customers to establish an account on its website, which is connected to a user's credit card or checking account.
You can find an example of integration here.
Use the PayPay Billing Agreement for subscriptions. That includes any instance where the cart contains both subscription and non-subscription products.
Create a PayPal payment method for your app or website in four easy steps:

Step 1: Build the PayPal objects

Build the PayPal objects.

PayPal source request object

A PayPal Source Request object requires the following fields.
Field
Value
type
payPal
sessionId
The payment session identifier.
payPal
A PayPal Source Details object that includes the details of the transaction.

Step 2: Create a PayPal source using DigitalRiver.js

Use the DigitalRiver.js library to create and mount elements to the HTML container.
1
{
2
"returnUrl": "http://mypage.com",
3
"cancelUrl": "https://mypage.com/cancel",
4
}
Copied!
Field
Required/Optional
Description
returnUrl
Required
If you choose to utilize the full redirect flow, this is where you will redirect your customer to after authorizing within the PayPal experience.
cancelUrl
Required
If you choose to utilize the full redirect flow, this is where you will redirect your customer to after canceling within the PayPal experience.
JavaScript
1
var data = {
2
"type": "payPal",
3
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
4
"payPal": {
5
"returnUrl": "http://mypage.com",
6
"cancelUrl": "https://mypage.com/cancel"
7
}
8
}
9
10
digitalriver.createSource(data).then(function(result) {
11
if (result.error) {
12
//handle errors
13
} else {
14
var source = result.source;
15
//send source to back end
16
sendToBackend(source);
17
}
18
});
Copied!

PayPal source response example

Source response
1
{
2
"clientId": "gc",
3
"channelId": "drdod15",
4
"liveMode": false,
5
"id": "d6a44e5d-1373-4013-847d-10deb4ded4df",
6
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
7
"clientSecret": "d6a44e5d-1373-4013-847d-10deb4ded4df_ddd44e5d-1373-4013-847d-10deb4ded4df",
8
"type": "payPal",
9
"reusable": false,
10
"amount": "10.00",
11
"currency": "USD",
12
"state": "pending_redirect",
13
"creationIp": "209.87.178.4",
14
"createdTime": "2019-05-22T00:00:46.975Z",
15
"updatedTime": "2019-05-22T00:00:46.975Z",
16
"flow": "redirect",
17
"redirect": {
18
"redirectUrl": "https://api.digitalriver.com:443/payments/redirects/b8f2207b-8236-4608-b5a2-812790d42ed8?apiKey=pk_test_6cb0fe9ce3124093a9ad906f6c589e2ds",
19
"returnUrl": "https://example.com?action=paymentSuccess",
20
"cancelUrl": "https://example.com?action=paymentFailure"
21
},
22
"payPal": {
23
"shipping": {
24
"recipient": "John Doe",
25
"phoneNumber": "555-555-1212",
26
"address": {
27
"line1": "54321 Fake St.",
28
"line2": "Apt. 3C",
29
"city": "Minnetonka",
30
"state": "MN",
31
"country": "US",
32
"postalCode": "55341"
33
}
34
},
35
"token": "EC-1HD67063RG318840B"
36
}
37
} "clientSecret": "d6a44e5d-1373-4013-847d-10deb4ded4df_ddd44e5d-1373-4013-847d-10deb4ded4df",
38
"type": "payPal",
39
"reusable": false,
40
"amount": "10.00",
41
"currency": "USD",
42
"state": "pending",
43
"creationIp": "209.87.178.4",
44
"createdTime": "2019-05-22T00:00:46.975Z",
45
"updatedTime": "2019-05-22T00:00:46.975Z",
46
"flow": "redirect",
47
"redirect": {
48
"redirectUrl": "https://api.digitalriver.com:443/payments/redirects/b8f2207b-8236-4608-b5a2-812790d42ed8?apiKey=pk_test_6cb0fe9ce3124093a9ad906f6c589e2ds",
49
"returnUrl": "https://example.com?action=paymentSuccess",
50
"cancelUrl": "https://example.com?action=paymentFailure"
51
},
52
"payPal": {
53
"shipping": {
54
"recipient": "John Doe",
55
"phoneNumber": "555-555-1212",
56
"address": {
57
"line1": "10380 Bren Road W",
58
"line2": "",
59
"city": "Minnetonka",
60
"state": "MN",
61
"country": "US",
62
"postalCode": "55343"
63
}
64
},
65
"token": "EC-1HD67063RG318840B"
66
}
67
}
Copied!

Step 3: Authorize a PayPal source

When you create a PayPal source, the customer is required to authorize the charge at PayPal. You can accomplish this by either redirecting the customer to PayPal or using the PayPal SDK to authorize the charge as part of your experience.

Redirecting the customer to PayPal for authorization

To redirect your customer to PayPal for authorization, use the redirectUrl parameter in your createSource response.
1
window.location.href = sourceResponse.redirect.redirectUrl;
Copied!
At PayPal, the customer can authorize or cancel the transaction when presented with the transaction details. If the authorization is successful, the customer will be redirected to the PayPal Return URL parameter you specified when you created the source. If the customer cancels, they will be returned to the PayPal Cancel URL parameter you specified.

Using the PayPal SDK to authorize payment

Use the PayPal Checkout SDK to streamline the authorizing PayPal transactions. This will allow you to control things like the appearance of the PayPal button and embed the entire experience into your workflow.
Example:
  1. 1.
    Include the PayPal Checkout SDK on your page and specify a location where the button will appear.
  2. 2.
    Use the PayPal SDK to customize and place the PayPal button on your page. The PayPal SDK returns two functions, onAuthorize and onCancel. If the payment was authorized, use the source you created earlier by attaching to an order or cart.
HTML
1
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
2
<div id="paypal-button"></div>
Copied!
JavaScript
1
var paypalSourceData = {
2
"type": "payPal",
3
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
4
"payPal": {
5
"returnUrl": redirectUrl,
6
"cancelUrl": cancelUrl,
7
}
8
};
9
10
paypal.Button.render({
11
// Configure environment
12
env: 'sandbox',
13
// Customize button (optional)
14
locale: 'en_US',
15
style: {
16
label: 'checkout',
17
size: 'responsive',
18
color: 'gold',
19
shape: 'rect',
20
layout: 'horizontal',
21
fundingicons: 'false',
22
tagline: 'false'
23
},
24
// Set up a payment
25
payment: function(data, actions) {
26
return digitalriver.createSource(paypalSourceData).then(function(result) {
27
if (result.error) {
28
//handle the errors that were returned
29
handleErrors(result.error)
30
} else {
31
return result.source.payPal.token;
32
}
33
});
34
},
35
// Execute the payment
36
onAuthorize: function(data, actions) {
37
//the payment has been authorized, use the source and attach it to your customer's account.
38
doSomething();
39
},
40
onCancel: function(data) {
41
//the payment has been cancelled, do something to try and get the shopper back on track
42
doSomethingElse();
43
}
44
}, '#paypal-button');
Copied!
PayPal login

Step 4: Use the authorized source

Once authorized, you can use the source by attaching it to a cart.
POST /v1/shoppers/me/carts/active/apply-payment-method
1
{
2
"paymentMethod": {
3
"sourceId": "e7ba0595-059c-460c-bad8-2812123b9313"
4
}
5
}
Copied!

PayPal Billing Agreement

The PayPal Billing Agreement allows consumers to use their PayPal account to make recurring payments when they purchase a subscription product by clicking the PayPal button. Consumers have the option to choose to auto-renew or manually renew.
Currency supported: All currencies available in supported countries.
You can find an example of the integration here.
Create a PayPal Billing Agreement payment method for your app or website in four easy steps:

Step 1: Build a PayPal Billing Agreement source request object

Build the PayPal Billing Agreement Source Request object. A PayPal Billing Agreement Source Request object requires the following fields.
Field
Value
type
payPalBilling
sessionId
The payment session identifier.
payPalBilling
A PayPal Source Details object that includes the details of the transaction.

Step 2: Create a PayPal Billing Agreement source using DigitalRiver.js

Use the DigitalRiver.js library to create and mount elements to the HTML container.
JavaScript
1
var data = {
2
"type": "payPalBilling",
3
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
4
"payPal": {
5
"returnUrl": "http://mypage.com",
6
"cancelUrl": "https://mypage.com/cancel"
7
}
8
}
9
10
digitalriver.createSource(data).then(function(result) {
11
if (result.error) {
12
//handle errors
13
} else {
14
var source = result.source;
15
//send source to back end
16
sendToBackend(source);
17
}
18
});
Copied!

PayPal Billing source example

PayPal Billing source response
1
{
2
"clientId": "gc",
3
"channelId": "drdod15",
4
"liveMode": false,
5
"id": "d6a44e5d-1373-4013-847d-10deb4ded4df",
6
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
7
"clientSecret": "d6a44e5d-1373-4013-847d-10deb4ded4df_accd4e5d-1373-4013-847d-10deb4ded4df",
8
"type": "payPalBilling",
9
"reusable": false,
10
"amount": "10.00",
11
"currency": "USD",
12
"state": "pending",
13
"creationIp": "209.87.178.4",
14
"createdTime": "2019-05-22T00:00:46.975Z",
15
"updatedTime": "2019-05-22T00:00:46.975Z",
16
"flow": "redirect",
17
"redirect": {
18
"redirectUrl": "https://api.digitalriver.com:443/payments/redirects/b8f2207b-8236-4608-b5a2-812790d42ed8?apiKey=pk_test_6cb0fe9ce3124093a9ad906f6c589e2ds",
19
"returnUrl": "https://example.com?action=paymentSuccess",
20
"cancelUrl": "https://example.com?action=paymentFailure"
21
},
22
"payPalBilling": {
23
"shipping": {
24
"recipient": "John Doe",
25
"phoneNumber": "555-555-1212",
26
"address": {
27
"line1": "10380 Bren Road W",
28
"line2": "",
29
"city": "Minnetonka",
30
"state": "MN",
31
"country": "US",
32
"postalCode": "55343"
33
}
34
},
35
"token": "EC-1HD67063RG318840B"
36
}
37
}
Copied!

Step 3: Authorize a PayPal Billing Agreement source

When you create a PayPal Billing Agreement source, the customer is required to authorize the charge through PayPal. You can accomplish this by either redirecting the customer to PayPal or use the PayPal SDK to authorize the charge as part of your experience.

Redirecting the customer to PayPal for authorization

To redirect your customer to PayPal for authorization, use the redirectUrl parameter in your createSource response.
HTML
1
window.location.href = sourceResponse.redirect.redirectUrl;
Copied!
PayPal will present the customer with the transaction details where they can authorize, or cancel the transaction. A successful authorization redirects the customer to the PayPal Return URL parameter you specified when you created the source. If the customer cancels, they will return to the PayPal Cancel URL parameter you specified when you created the source.

Using the PayPal SDK to authorize payment

Use the PayPal Checkout SDK to streamline the authorizing PayPal transactions. This will allow you to control things like the appearance of the PayPal button and embed the entire experience into your workflow.
Example:
  1. 1.
    Include the PayPal Checkout SDK on your page and specify a location where the button will appear.
  2. 2.
    Use the PayPal SDK to customize and place the PayPal button on your page. The PayPal SDK returns two functions, onAuthorize and onCancel. If the payment was authorized, use the source you created earlier by attaching to a shopper or customer.
JavaScript
1
var paypalSourceData = {
2
"type": "payPalBilling",
3
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
4
"payPalBilling": {
5
"returnUrl": redirectUrl,
6
"cancelUrl": cancelUrl,
7
}
8
};
9
10
paypal.Button.render({
11
// Configure environment
12
env: 'sandbox',
13
// Customize button (optional)
14
locale: 'en_US',
15
style: {
16
label: 'checkout',
17
size: 'responsive',
18
color: 'gold',
19
shape: 'rect',
20
layout: 'horizontal',
21
fundingicons: 'false',
22
tagline: 'false'
23
},
24
// Set up a payment
25
payment: function(data, actions) {
26
return digitalriver.createSource(paypalSourceData).then(function(result) {
27
if (result.error) {
28
//handle the errors that were returned
29
handleErrors(result.error)
30
} else {
31
return result.source.payPal.token;
32
}
33
});
34
},
35
// Execute the payment
36
onAuthorize: function(data, actions) {
37
//the payment has been authorized, use the source and attach it to your customer's account.
38
doSomething();
39
},
40
onCancel: function(data) {
41
//the payment has been cancelled, do something to try and get the shopper back on track
42
doSomethingElse();
43
}
44
}, '#paypal-button');
Copied!
PayPal login

Step 4: Use the authorized source

Once authorized, you can use the source by attaching it to a cart or attaching it to a shopper.

Option 1. Attach the source to a cart

POST /v1/shoppers/me/carts/active/apply-payment-method
1
{
2
"paymentMethod": {
3
"sourceId": "e7ba0595-059c-460c-bad8-2812123b9313"
4
}
5
}
Copied!

Option 2. Attach the source to a shopper

POST /v1/shoppers/me/payment-options
1
{
2
"paymentOption": {
3
"nickName": "My Token",
4
"isDefault": "true",
5
"sourceId": "61033d62-c0f4-4a7e-b844-07daf26ba84e"
6
}
7
}
Copied!

PayPal Pay Later

PayPal Pay in 3

Additional setup optional: If you are interested in promoting Pay in 3, contact your Customer Success Representative. The Representative will provide the set-up instructions for Pay in 3 banners. Click here to access the upstream promotional banners.
PayPal Pay in 3 is a short-term card installment payment option automatically provided by PayPal Express Checkout Wallet when a customer signs in to PayPal Checkout. Presents within the PayPal wallet on a category known as "Pay Later". Note that PayPal Pay in 3 does not support recurring subscriptions. No additional setup is required to present this payment method in the PayPal Express Checkout Wallet. If the shopper's purchase history along with the items in checkout qualify, PayPal Pay in 3 will be available as a payment method.
PayPal Pay in 3 allows shoppers to pay for physical good purchases as follows:
  • United Kingdom: three interest-free monthly payments for purchases between £45 - £2,000 with the first payment due at checkout.
When a customer selects this payment method, a "soft hit" will appear in their credit report.

PayPal Pay in 4

Additional setup optional: If you are interested in promoting Pay in 4, contact your Customer Success Representative. The Representative will provide the set-up instructions for Pay in 4 banners. Click here to access the upstream promotional banners.
PayPal Pay in 4 is a short-term card installment payment option automatically provided by PayPal Express Checkout Wallet. Presents within the PayPal wallet on a category known as "Pay Later". Note that PayPal Pay in 4 does not support recurring subscriptions. No additional setup is required to present this payment method in the PayPal Express Checkout Wallet. If the shopper's purchase history along with the items in checkout qualify, PayPal Pay in 3 will be available as a payment method.
PayPal Pay in 4 allows shoppers to pay for physical good purchases as follows:
  • France: four interest-free monthly payments for purchases between €30 to €2,000 with the first payment due at checkout.
  • United States: four interest-free biweekly payments for purchases between $30 to $600 with the first payment due at checkout.
  • Australia: four interest-free biweekly payments for purchases between AUD $50 to $1,500 with the first payment due at checkout.
When a customer selects this payment method, a "soft hit" will appear in their credit report.

PayPal RatenZahlung

PayPal RatenZahlung is a pay later option available through PayPal Express Checkout Wallet. Presents within the PayPal wallet on a category known as "Pay Later". Note that PayPal RatenZahlung does not support recurring subscriptions. No additional setup is required to present this payment method in the PayPal Express Checkout Wallet. If the shopper's purchase history along with the items in the checkout qualify, PayPal RatenZahlung will be available as a payment method. PayPal RatenZahlung allows shoppers to pay for physical good purchases as follows:
  • Germany: shopper selects three, six, twelve, or twenty-four monthly payments with an interest rate of 9.99% for purchases between €99 to €5,000 with the first payment due at checkout

PayPal Credit

Additional Setup Required: If you are interested in using PayPal Credit, contact your Account Manager. The Account Manager will send set up instructions for PayPal Credit banners after you sign the client addendum.
PayPal Credit allows consumers to buy online and pay later for their products. This payment method is accepted in thousands of online stores and is available everywhere PayPal is accepted (as long as the PayPal Credit and PayPal accounts are linked). PayPal Credit uses the date of birth and last 4 digits of SSN to approve or deny a consumer for a line of credit, and the applicant will be notified within seconds whether they have been approved or not.
Create a PayPal payment method for your app or website in four easy steps:
Step 1: Build a Credit source request object
Build a Credit Source Request object. A PayPal Billing Credit Source Request object requires the following fields.
Field
Value
type
payPalCredit
sessionId
The payment session identifier.
payPalCredit
A PayPal Source Details object that includes the details of the transaction.
Step 2: Create a PayPal Credit source using DigitalRiver.js
Use the DigitalRiver.js library to create and mount elements to the HTML container.
JavaScript
1
var data = {
2
"type": "payPalCredit",
3
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
4
"payPal": {
5
"returnUrl": "http://mypage.com",
6
"cancelUrl": "https://mypage.com/cancel"
7
}
8
}
9
10
digitalriver.createSource(data).then(function(result) {
11
if (result.error) {
12
//handle errors
13
} else {
14
var source = result.source;
15
//send source to back end
16
sendToBackend(source);
17
}
18
});
Copied!

PayPal Credit source response example

Source response
1
{
2
"clientId": "gc",
3
"channelId": "drdod15",
4
"liveMode": false,
5
"id": "d6a44e5d-1373-4013-847d-10deb4ded4df",
6
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
7
"clientSecret": "d6a44e5d-1373-4013-847d-10deb4ded4df_ssdd4e5d-1373-4013-847d-10deb4ded4df",
8
"type": "payPal",
9
"reusable": false,
10
"amount": "120.99",
11
"currency": "USD",
12
"state": "pending_redirect",
13
"creationIp": "209.87.178.4",
14
"createdTime": "2019-05-22T00:00:46.975Z",
15
"updatedTime": "2019-05-22T00:00:46.975Z",
16
"flow": "redirect",
17
"redirect": {
18
"redirectUrl": "https://api.digitalriver.com:443/payments/redirects/b8f2207b-8236-4608-b5a2-812790d42ed8?apiKey=pk_test_6cb0fe9ce3124093a9ad906f6c589e2ds",
19
"returnUrl": "https://example.com?action=paymentSuccess",
20
"cancelUrl": "https://example.com?action=paymentFailure"
21
},
22
"payPalCredit": {
23
"shipping": {
24
"recipient": "John Doe",
25
"phoneNumber": "555-555-1212",
26
"address": {
27
"line1": "54321 Fake St.",
28
"line2": "Apt. 3C",
29
"city": "Minnetonka",
30
"state": "MN",
31
"country": "US",
32
"postalCode": "55341"
33
}
34
},
35
"token": "EC-1HD67063RG318840B"
36
}
37
}
Copied!
Step 3: Authorize a PayPal Credit source
When you create a PayPal Credit Source, the customer is required to authorize the charge at PayPal. You can accomplish this by either redirecting the customer to PayPal or use the PayPal SDK to authorize the charge as part of your experience.

Redirecting the customer to PayPal for authorization

To redirect your customer to PayPal for authorization, use the redirectUrl parameter in your createSource response.
Redirect example
1
window.location.href = sourceResponse.redirect.redirectUrl;
Copied!
PayPal will present the customer with the transaction details where they can authorize or cancel the transaction. A successful authorization redirects the customer to the PayPal Return URL parameter you specified when you created the source. If the customer cancels, they will return to the PayPal Cancel URL parameter you specified when you created the source.

Using the PayPal SDK to authorize payment

Use the PayPal Checkout SDK to streamline the authorizing PayPal transactions. This will allow you to control things like the appearance of the PayPal button and embed the entire experience into your workflow.
Example:
  1. 1.
    Include the PayPal Checkout SDK on your page and specify a location where the button will appear.
    1
    <script src="https://www.paypalobjects.com/api/checkout.js"></script>
    2
    <div id="paypal-button"></div>
    Copied!
  2. 2.
    Use the PayPal SDK to customize and place the PayPal button on your page. The PayPal SDK returns two functions, onAuthorize and onCancel. If the payment was authorized, use the source you created earlier by attaching to an order or cart.
    1
    var paypalSourceData = {
    2
    "type": "payPal",
    3
    "sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
    4
    "payPal": {
    5
    "returnUrl": redirectUrl,
    6
    "cancelUrl": cancelUrl
    7
    }
    8
    };
    9
    10
    paypal.Button.render({
    11
    // Configure environment
    12
    env: 'sandbox',
    13
    // Customize button (optional)
    14
    locale: 'en_US',
    15
    style: {
    16
    label: 'credit',
    17
    size: 'responsive',
    18
    color: 'blue',
    19
    shape: 'rect',
    20
    layout: 'horizontal',
    21
    fundingicons: 'false',
    22
    tagline: 'false'
    23
    },
    24
    // Set up a payment
    25
    payment: function(data, actions) {
    26
    return digitalriver.createSource(paypalSourceData).then(function(result) {
    27
    if (result.error) {
    28
    //handle the errors that were returned
    29
    handleErrors(result.error)
    30
    } else {
    31
    return result.source.payPalCredit.token;
    32
    }
    33
    });
    34
    },
    35
    // Execute the payment
    36
    onAuthorize: function(data, actions) {
    37
    //the payment has been authorized, use the source and attach it to your customer's account.
    38
    doSomething();
    39
    },
    40
    onCancel: function(data) {
    41
    //the payment has been cancelled, do something to try and get the shopper back on track
    42
    doSomethingElse();
    43
    }
    44
    }, '#paypal-button');
    Copied!
  3. 3.
    Include the PayPal Checkout SDK on your page and specify a location where the button will appear.
    1
    <script src="https://www.paypalobjects.com/api/checkout.js"></script>
    2
    <div id="paypal-button"></div>
    Copied!
  4. 4.
    Use the PayPal SDK to customize and place the PayPal button on your page. The PayPal SDK returns two functions, onAuthorize and onCancel. If the payment was authorized, use the source you created earlier by attaching to an order or cart.
    1
    z var paypalSourceData = {
    2
    "type": "payPal",
    3
    "amount": 10,
    4
    "currency": "USD",
    5
    }
    6
    };
    7
    8
    paypal.Button.render({
    9
    // Configure environment
    10
    env: 'sandbox',
    11
    // Customize button (optional)
    12
    locale: 'en_US',
    13
    style: {
    14
    label: 'credit',
    15
    size: 'responsive',
    16
    color: 'blue',
    17
    shape: 'rect',
    18
    layout: 'horizontal',
    19
    fundingicons: 'false',
    20
    tagline: 'false'
    21
    },
    22
    // Set up a payment
    23
    payment: function(data, actions) {
    24
    return digitalriver.createSource(paypalSourceData).then(function(result) {
    25
    if (result.error) {
    26
    //handle the errors that were returned
    27
    handleErrors(result.error)
    28
    } else {
    29
    return result.source.payPalCredit.token;
    30
    }
    31
    });
    32
    },
    33
    // Execute the payment
    34
    onAuthorize: function(data, actions) {
    35
    //the payment has been authorized, use the source and attach it to your customer's account.
    36
    doSomething();
    37
    },
    38
    onCancel: function(data) {
    39
    //the payment has been cancelled, do something to try and get the shopper back on track
    40
    doSomethingElse();
    41
    }
    42
    }, '#paypal-button');
    43
    44
    paypal.Button.render({
    45
    // Configure environment
    46
    env: 'sandbox',
    47
    // Customize button (optional)
    48
    locale: 'en_US',
    49
    style: {
    50
    label: 'credit',
    51
    size: 'responsive',
    52
    color: 'blue',
    53
    shape: 'rect',
    54
    layout: 'horizontal',
    55
    fundingicons: 'false',
    56
    tagline: 'false'
    57
    },
    58
    // Set up a payment
    59
    payment: function(data, actions) {
    60
    return digitalriver.createSource(paypalSourceData).then(function(result) {
    61
    if (result.error) {
    62
    //handle the errors that were returned
    63
    handleErrors(result.error)
    64
    } else {
    65
    return result.source.payPalCredit.token;
    66
    }
    67
    });
    68
    },
    69
    // Execute the payment
    70
    onAuthorize: function(data, actions) {
    71
    //the payment has been authorized, use the source and attach it to your customer's account.
    72
    doSomething();
    73
    },
    74
    onCancel: function(data) {
    75
    //the payment has been cancelled, do something to try and get the shopper back on track
    76
    doSomethingElse();
    77
    }
    78
    }, '#paypal-button');
    Copied!
Step 4: Use the Authorized source
Once authorized, you can use the source by attaching it to a cart.

Attach the source to a cart

POST /v1/shoppers/me/carts/active/apply-payment-method
1
{
2
"paymentMethod": {
3
"sourceId": "e7ba0595-059c-460c-bad8-2812123b9313"
4
}
5
}
Copied!

Supported markets

Additional setup optional: If you are interested in promoting Pay in 4, contact your Customer Success Representative. The Representative will provide the set-up instructions for PayPal in 4 banners.
Pay in 4 is a short-term card installment payment option automatically provided by PayPal when a customer signs in to PayPal Checkout. Pay in 4 allows United States shoppers to pay for physical good purchases ranging from $30 - $600 in four interest-free payments every two weeks over six weeks, with the first payment due at checkout. This option is currently only available in the United States.
For information on supported markets and currencies for Drop-in and DigitalRiver.js, go to:
When a customer selects this payment method, a "soft hit" will appear in their credit report.
Last modified 3mo ago