PayPal

Accept payment from consumers using PayPal to transfer funds online.

Digital River offers the following payment methods for PayPal: PayPal, PayPal Billing Agreement, and PayPal Credit.

PayPal

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.

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

amount

The total value of the transaction.

currency

The currency of the transaction.

payPal

A PayPal Source Details object that includes the details of the transaction.

PayPal source details object

The PayPal source details object requires the following fields.

{
"returnUrl": "http://mypage.com",
"cancelUrl": "https://mypage.com/cancel",
"items": [{
"name": "Cell Phone (Unlocked)",
"quantity": 1,
"unitAmount": 100
},
{
"name": "Headphones",
"quantity": 1,
"unitAmount": 15
}
],
"taxAmount": 0.99,
"shippingAmount": 5,
"amountsEstimated": true,
"shipping": {
"recipient": "John Doe",
"phoneNumber": "555-555-1212",
"address": {
"line1": "54321 Fake St.",
"line2": "Apt. 3C",
"city": "Minnetonka",
"state": "MN",
"country": "US",
"postalCode": "55341"
}
}
}

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.

items

Required

An array of PayPal Item objects.

taxAmount

Required

The value of the total tax amount of the transaction.

shippingAmount

Required

The value of the total shipping amount of the transaction.

amountsEstimated

Required

A true/false flag to identify these amounts as estimated within the PayPal experience. You can use this when authorization requires a final calculation of shipping rates or taxes.

requestShipping

Required

A true/false flag to tell PayPal to request the shipping address from the Shopper within the PayPal experience.

shipping

Optional

A PayPal Shipping Information object that may be populated if you have already captured the shipping address and wish to pre-populate it within the PayPal experience.

PayPal Item object

A PayPal Item object requires the following fields.

{
"name": "Cell Phone (Unlocked)",
"quantity": 1,
"unitAmount": 100
}

Field

Required/Optional

Description

name

Required

The name of the item that appears in the PayPal authorize screen.

quantity

Required

The quantity of the item that appears in the PayPal authorize screen.

unitAmount

Required

The amount of the item.

PayPal Shipping information object

A PayPal shipping information object requires the following fields.

{
"recipient": "John Doe",
"phoneNumber": "555-555-1212",
"address": {
"line1": "54321 Fake St.",
"line2": "Apt. 3C",
"city": "Minnetonka",
"state": "MN",
"country": "US",
"postalCode": "55341",
"country": "US"
}
}

Field

Required/Optional

Description

recipient

Required

The first and last name of the person receiving the shipment.

phoneNumber

Required

The phone number of the person receiving the shipment.

address

Required

A PayPal shipping address object which contains the shipping address of the person receiving the shipment.

PayPal shipping address object

A PayPal shipping address object requires the following fields.

{
"line1": "54321 Fake St.",
"line2": "Apt. 3C",
"city": "Minnetonka",
"state": "MN",
"country": "US",
"postalCode": "55341"
}

Field

Required/Optional

Description

line1

Required

Line 1 of the customer's billing address.

line2

Required

Line 2 of the Customer's billing address.

city

Required

City of the customer's billing address.

state

Required

State of the customer's billing address.

postalCode

Required

Postal code of the customer's billing address.

country

Required

Country of the customer's billing address.

Step 2. Create a PayPal source using DigitalRiver.js

To create a PayPal payment source, you must use the createSource method exposed via DigitalRiver.js.

JavaScript
JavaScript
var data = {
"type": "payPal",
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
"payPal": {
"returnUrl": "http://mypage.com",
"cancelUrl": "https://mypage.com/cancel"
}
}
digitalriver.createSource(data).then(function(result) {
if (result.error) {
//handle errors
} else {
var source = result.source;
//send source to back end
sendToBackend(source);
}
});

PayPal source response example

Source response
Source response
{
"clientId": "gc",
"channelId": "drdod15",
"liveMode": false,
{
"clientId": "gc",
"channelId": "drdod15",
"liveMode": false,
"id": "d6a44e5d-1373-4013-847d-10deb4ded4df",
"clientSecret": "d6a44e5d-1373-4013-847d-10deb4ded4df_ddd44e5d-1373-4013-847d-10deb4ded4df",
"type": "payPal",
"reusable": false,
"amount": "10.00",
"currency": "USD",
"state": "pending_redirect",
"creationIp": "209.87.178.4",
"createdTime": "2019-05-22T00:00:46.975Z",
"updatedTime": "2019-05-22T00:00:46.975Z",
"flow": "redirect",
"redirect": {
"redirectUrl": "https://api.digitalriver.com:443/payments/redirects/b8f2207b-8236-4608-b5a2-812790d42ed8?apiKey=pk_test_6cb0fe9ce3124093a9ad906f6c589e2ds",
"returnUrl": "https://example.com?action=paymentSuccess",
"cancelUrl": "https://example.com?action=paymentFailure"
},
"payPal": {
"shipping": {
"recipient": "John Doe",
"phoneNumber": "555-555-1212",
"address": {
"line1": "54321 Fake St.",
"line2": "Apt. 3C",
"city": "Minnetonka",
"state": "MN",
"country": "US",
"postalCode": "55341"
}
},
"token": "EC-1HD67063RG318840B"
}
} "clientSecret": "d6a44e5d-1373-4013-847d-10deb4ded4df_ddd44e5d-1373-4013-847d-10deb4ded4df",
"type": "payPal",
"reusable": false,
"amount": "10.00",
"currency": "USD",
"state": "pending",
"creationIp": "209.87.178.4",
"createdTime": "2019-05-22T00:00:46.975Z",
"updatedTime": "2019-05-22T00:00:46.975Z",
"flow": "redirect",
"redirect": {
"redirectUrl": "https://api.digitalriver.com:443/payments/redirects/b8f2207b-8236-4608-b5a2-812790d42ed8?apiKey=pk_test_6cb0fe9ce3124093a9ad906f6c589e2ds",
"returnUrl": "https://example.com?action=paymentSuccess",
"cancelUrl": "https://example.com?action=paymentFailure"
},
"payPal": {
"shipping": {
"recipient": "John Doe",
"phoneNumber": "555-555-1212",
"address": {
"line1": "10380 Bren Road W",
"line2": "",
"city": "Minnetonka",
"state": "MN",
"country": "US",
"postalCode": "55343"
}
},
"token": "EC-1HD67063RG318840B"
}
}

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.

window.location.href = sourceResponse.redirect.redirectUrl;

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. Include the PayPal Checkout SDK on your page and specify a location where the button will appear.

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

HTML
HTML
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<div id="paypal-button"></div>
JavaScript
JavaScript
var paypalSourceData = {
"type": "payPal",
"amount": 10,
"currency": "USD",
"payPal": {
"returnUrl": redirectUrl,
"cancelUrl": cancelUrl,
"items": [{
"name": "Universe A1+ 256GB (Unlocked)",
"quantity": 1,
"unitAmount": 959.99,
},
{
"name": "AKG Y50BT On-Ear Bluetooth Headphones",
"quantity": 1,
"unitAmount": 0,
}
],
"taxAmount": 67.20,
"shippingAmount": 0,
"amountsEstimated": true,
"requestShipping": true,
"shipping": {
"recipient": "John Doe",
"phoneNumber": "555-555-1212",
"address": {
"line1": "10380 Bren Road W",
"line2": "",
"city": "Minnetonka",
"state": "MN",
"country": "US",
"postalCode": "55343"
}
}
}
};
paypal.Button.render({
// Configure environment
env: 'sandbox',
// Customize button (optional)
locale: 'en_US',
style: {
label: 'checkout',
size: 'responsive',
color: 'gold',
shape: 'rect',
layout: 'horizontal',
fundingicons: 'false',
tagline: 'false'
},
// Set up a payment
payment: function(data, actions) {
return digitalriver.createSource(paypalSourceData).then(function(result) {
if (result.error) {
//handle the errors that were returned
handleErrors(result.error)
} else {
return result.source.payPal.token;
}
});
},
// Execute the payment
onAuthorize: function(data, actions) {
//the payment has been authorized, use the source and attach it to your customer's account.
doSomething();
},
onCancel: function(data) {
//the payment has been cancelled, do something to try and get the shopper back on track
doSomethingElse();
}
}, '#paypal-button');
PayPal login

Step 4. Use the Authorized source

Once authorized, you can use the source by attaching it to a checkout.

Attach the source to a checkout

POST /checkouts/{id}
POST /checkouts/{id}
{
"customerId": "5774321008",
"sourceId": "src_a78cfeae-f7ae-4719-8e1c-d05ec04e4d37"
}

Supported geographies

PayPal supports the following geographies and currencies.

Supported geographies

American Samoa (AS), Andorra (AD), Austria (AT), Australia (AU), Bangladesh (BD), Belgium (BE), Bouvet Islands (BV), Brazil (BR), British Indian Ocean Territory (IO), Belgium (BE), Canada (CA), Christmas Island (CX), Cocos Islands (CC), Cook Islands (CK), Cyprus (CY), Czech Republic (CZ), Denmark (DK), Ecuador (EC), El Salvador (SV), Estonia (EE), Faroe Islands (FO), Finland (FI), France (FR), French Guiana (GF), Germany (DE), Greenland (GL), Greece (GR), Guam (GU), Heard Island & McDonald Islands (HM), Hong Kong (HK), Hungary (HU), Ireland (IE), Israel (IL), Italy (IT), Japan (JP), Kiribati (KI), Latvia (LV), Liechtenstein (LI), Lithuania (LT), Luxembourg (LU), Malta (MT), Marshall Islands (MH), Mexico (MX), Micronesia (FM), Monaco (MC), Netherlands (NL), New Zealand (NZ), Niue (NU), Norfolk Island (NF), Northern Mariana Islands (MP), Norway (NO), Panama (PA), Peru (PE), Philippines (PH), Poland (PL), Pitcairn Islands (PN), Puerto Rico (PR), Portugal (PT), Reunion (RE), Romania (RO), Russia (RU), Saint Pierre & Miquelon (PM), San Marino (SM), Singapore (SG), Slovakia (SK), Slovenia (SI), South Georgia & South Sandwich Islands (GS), Spain (ES), Svalbard & Jan Mayen Islands (SJ), Sweden (SE), Switzerland (CH), Taiwan (TW), Thailand (TH), Tokelau (TK), Tristan da Cunha (SH), Turks & Caicos Islands (TC), Tuvalu (TV), United Kingdom (GB), United States (US), United States Minor Outlying Islands (UM), Vatican (VA), Venezuela (VE)

Supported currencies

AUD, BRL, CAD, CHF, CZK, DKK, EUR, GBP, HKD, HUF, ILS, JPY, MXN, NOK, NZD, PHP, PLN, RUB, SEK, SGD, THB, TWD, USD

PayPal Billing Agreement

The PayPal billing agreement allows consumers to use their PayPal account to make recurring subscription payments. 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

A PayPal billing agreement source request object requires the following fields.

Field

Value

type

payPalBilling

amount

The total value of the transaction.

currency

The currency of the transaction.

payPalBilling

A PayPal source details object that includes the details of the transaction.

Step 2. Create a PayPal billing agreement source using DigitalRiver.js

To create a PayPal billing agreement payment source, you must use the createSource method exposed via DigitalRiver.js.

JavaScript
JavaScript
var data = {
"type": "payPalBilling",
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
"payPal": {
"returnUrl": "http://mypage.com",
"cancelUrl": "https://mypage.com/cancel"
}
}
digitalriver.createSource(data).then(function(result) {
if (result.error) {
//handle errors
} else {
var source = result.source;
//send source to back end
sendToBackend(source);
}
});

PayPal billing source example

PayPal Billing source response
PayPal Billing source response
{
"clientId": "gc",
"channelId": "drdod15",
"liveMode": false,
"id": "d6a44e5d-1373-4013-847d-10deb4ded4df",
"clientSecret": "d6a44e5d-1373-4013-847d-10deb4ded4df_accd4e5d-1373-4013-847d-10deb4ded4df",
"type": "payPalBilling",
"reusable": false,
"amount": "10.00",
"currency": "USD",
"state": "pending",
"creationIp": "209.87.178.4",
"createdTime": "2019-05-22T00:00:46.975Z",
"updatedTime": "2019-05-22T00:00:46.975Z",
"flow": "redirect",
"redirect": {
"redirectUrl": "https://api.digitalriver.com:443/payments/redirects/b8f2207b-8236-4608-b5a2-812790d42ed8?apiKey=pk_test_6cb0fe9ce3124093a9ad906f6c589e2ds",
"returnUrl": "https://example.com?action=paymentSuccess",
"cancelUrl": "https://example.com?action=paymentFailure"
},
"payPalBilling": {
"shipping": {
"recipient": "John Doe",
"phoneNumber": "555-555-1212",
"address": {
"line1": "10380 Bren Road W",
"line2": "",
"city": "Minnetonka",
"state": "MN",
"country": "US",
"postalCode": "55343"
}
},
"token": "EC-1HD67063RG318840B"
}
}
PayPal Billing source response
PayPal Billing source response
{
"clientId": "gc",
"channelId": "drdod15",
"liveMode": false,
"id": "d6a44e5d-1373-4013-847d-10deb4ded4df",
"clientSecret": "d6a44e5d-1373-4013-847d-10deb4ded4df_accd4e5d-1373-4013-847d-10deb4ded4df",
"type": "payPalBilling",
"reusable": false,
"amount": "10.00",
"currency": "USD",
"state": "pending",
"creationIp": "209.87.178.4",
"createdTime": "2019-05-22T00:00:46.975Z",
"updatedTime": "2019-05-22T00:00:46.975Z",
"flow": "redirect",
"redirect": {
"redirectUrl": "https://api.digitalriver.com:443/payments/redirects/b8f2207b-8236-4608-b5a2-812790d42ed8?apiKey=pk_test_6cb0fe9ce3124093a9ad906f6c589e2ds",
"returnUrl": "https://example.com?action=paymentSuccess",
"cancelUrl": "https://example.com?action=paymentFailure"
},
"payPalBilling": {
"shipping": {
"recipient": "John Doe",
"phoneNumber": "555-555-1212",
"address": {
"line1": "10380 Bren Road W",
"line2": "",
"city": "Minnetonka",
"state": "MN",
"country": "US",
"postalCode": "55343"
}
},
"token": "EC-1HD67063RG318840B"
}
}

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
HTML
window.location.href = sourceResponse.redirect.redirectUrl;

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. Include the PayPal Checkout SDK on your page and specify a location where the button will appear.

  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
JavaScript
var paypalSourceData = {
"type": "payPalBilling",
"amount": 10,
"currency": "USD",
"payPalBilling": {
"returnUrl": redirectUrl,
"cancelUrl": cancelUrl,
"items": [{
"name": "Universe A1+ 256GB (Unlocked)",
"quantity": 1,
"unitAmount": 959.99,
},
{
"name": "AKG Y50BT On-Ear Bluetooth Headphones",
"quantity": 1,
"unitAmount": 0,
}
],
"taxAmount": 67.20,
"shippingAmount": 0,
"amountsEstimated": true,
"requestShipping": true,
"shipping": {
"recipient": "John Doe",
"phoneNumber": "555-555-1212",
"address": {
"line1": "10380 Bren Road W",
"line2": "",
"city": "Minnetonka",
"state": "MN",
"country": "US",
"postalCode": "55343"
}
}
}
};
paypal.Button.render({
// Configure environment
env: 'sandbox',
// Customize button (optional)
locale: 'en_US',
style: {
label: 'checkout',
size: 'responsive',
color: 'gold',
shape: 'rect',
layout: 'horizontal',
fundingicons: 'false',
tagline: 'false'
},
// Set up a payment
payment: function(data, actions) {
return digitalriver.createSource(paypalSourceData).then(function(result) {
if (result.error) {
//handle the errors that were returned
handleErrors(result.error)
} else {
return result.source.payPal.token;
}
});
},
// Execute the payment
onAuthorize: function(data, actions) {
//the payment has been authorized, use the source and attach it to your customer's account.
doSomething();
},
onCancel: function(data) {
//the payment has been cancelled, do something to try and get the shopper back on track
doSomethingElse();
}
}, '#paypal-button');
PayPal login

Step 4. Use the authorized source

Once authorized, you can use the source by attaching it to a checkout or attaching it to a customer or shopper for multiple uses.

Option 1. Attach the source to a checkout

POST /checkouts/{id}
POST /checkouts/{id}
{
"customerId": "5774321008",
"sourceId": "src_a78cfeae-f7ae-4719-8e1c-d05ec04e4d37"
}

Option 2. Attach the source to a customer

POST /customers/{id}/sources/{sourcesId}
POST /customers/{id}/sources/{sourcesId}
{
"id": "5774321008",
"sourceId": "src_a78cfeae-f7ae-4719-8e1c-d05ec04e4d37"
}

Supported geographies

PayPal billing agreement supports the following geographies and currencies.

Supported geographies

American Samoa (AS), Andorra (AD), Austria (AT), Australia (AU), Bangladesh (BD), Belgium (BE), Bouvet Islands (BV), Bulgaria (BG), Brazil (BR), British Indian Ocean Territory (IO), Canada (CA), Cocos Islands (CC), Cook Islands (CK), Christmas Island (CX), Cyprus (CY), Czech Republic (CZ), Denmark (DK), Ecuador (EC), El Salvador (SV), Estonia (EE), Faroe Islands (FO), Finland (FI), France (FR), French Guiana (GF), Germany (DE), Great Britain (GB), Greece (GR), Greenland (GL), Guam (GU), Heard Island & McDonald Islands (HM), Hong Kong (HK), Hungary (HU), Ireland (IE), Israel (IL), Italy (IT), Jordan (JO), Kiribati (KI), Liechtenstein (LI), Lithuania (LT), Luxembourg (LU), Latvia (LV), Malta (MT), Marshall Islands (MH), Mexico (MX), Micronesia (FM), Monaco (MC), Netherlands (NL), New Zealand (NZ), Niue (NU), Norfolk Island (NF), Northern Mariana Islands Malta (MP), Panama (PA), Peru (PE), Philippines (PH), Pitcairn Islands (PN), Poland (PL), Portugal (PT), Puerto Rico (PR), Reunion (RE), Romania (RO), Russia (RU), Saint Pierre & Miquelon (PM), San Marino (SM), Saudi Arabia (SA), Singapore (SG), Slovakia (SK), Slovenia (SI), South Georgia & South Sandwich Islands (GS), Spain (ES), Svalbard & Jan Mayen Islands (SJ), Sweden (SE), Switzerland (CH), Taiwan (TW), Thailand (TH), Tokelau (TK), Tristan da Cunha (SH), Turks & Caicos Islands (TC), Tuvalu (TV), United States (US), US Minor Outlying Islands (UM), Vatican (VA), Venezuela (VE)

Supported currencies

AUD, BRL, CAD, CHF, CZK, DKK, EUR, GBP, HKD, HUF, ILS, JPY, MXN, NOK, NZD, PHP, PLN, RUB, SEK, SGD, THB, TWD, USD

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

A PayPal billing credit source request object requires the following fields.

Field

Value

type

payPalCredit

amount

The total value of the transaction.

currency

The currency of the transaction.

payPalCredit

A PayPal Source Details object that includes the details of the transaction.

Step 2. Create a PayPal Credit source using DigitalRiver.js

To create a PayPal Credit payment source, you must use the createSource method exposed via DigitalRiver.js.

JavaScript
JavaScript
var data = {
"type": "payPalCredit",
"sessionId": "ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
"payPal": {
"returnUrl": "http://mypage.com",
"cancelUrl": "https://mypage.com/cancel"
}
}
digitalriver.createSource(data).then(function(result) {
if (result.error) {
//handle errors
} else {
var source = result.source;
//send source to back end
sendToBackend(source);
}
});

PayPal Credit source response example

Source response
Source response
{
"clientId": "gc",
"channelId": "drdod15",
"liveMode": false,
"id": "d6a44e5d-1373-4013-847d-10deb4ded4df",
"clientSecret": "d6a44e5d-1373-4013-847d-10deb4ded4df_ssdd4e5d-1373-4013-847d-10deb4ded4df",
"type": "payPal",
"reusable": false,
"amount": "120.99",
"currency": "USD",
"state": "pending_redirect",
"creationIp": "209.87.178.4",
"createdTime": "2019-05-22T00:00:46.975Z",
"updatedTime": "2019-05-22T00:00:46.975Z",
"flow": "redirect",
"redirect": {
"redirectUrl": "https://api.digitalriver.com:443/payments/redirects/b8f2207b-8236-4608-b5a2-812790d42ed8?apiKey=pk_test_6cb0fe9ce3124093a9ad906f6c589e2ds",
"returnUrl": "https://example.com?action=paymentSuccess",
"cancelUrl": "https://example.com?action=paymentFailure"
},
"payPalCredit": {
"shipping": {
"recipient": "John Doe",
"phoneNumber": "555-555-1212",
"address": {
"line1": "54321 Fake St.",
"line2": "Apt. 3C",
"city": "Minnetonka",
"state": "MN",
"country": "US",
"postalCode": "55341"
}
},
"token": "EC-1HD67063RG318840B"
}
}

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
Redirect example
window.location.href = sourceResponse.redirect.redirectUrl;

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. Include the PayPal Checkout SDK on your page and specify a location where the button will appear.

    <script src="https://www.paypalobjects.com/api/checkout.js"></script>
    <div id="paypal-button"></div>
  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 checkout.

    var paypalSourceData = {
    "type": "payPal",
    "amount": 10,
    "currency": "USD",
    "payPal": {
    "returnUrl": redirectUrl,
    "cancelUrl": cancelUrl,
    "items": [{
    "name": "Universe A1+ 256GB (Unlocked)",
    "quantity": 1,
    "unitAmount": 959.99,
    },
    {
    "name": "AKG Y50BT On-Ear Bluetooth Headphones",
    "quantity": 1,
    "unitAmount": 0,
    }
    ],
    "taxAmount": 67.20,
    "shippingAmount": 0,
    "amountsEstimated": true,
    "requestShipping": true,
    "shipping": {
    "recipient": "John Doe",
    "phoneNumber": "555-555-1212",
    "address": {
    "line1": "54321 Fake St.",
    "line2": "Apt. 3C",
    "city": "Minnetonka",
    "state": "MN",
    "country": "US",
    "postalCode": "55341"
    }
    }
    }
    };
    paypal.Button.render({
    // Configure environment
    env: 'sandbox',
    // Customize button (optional)
    locale: 'en_US',
    style: {
    label: 'credit',
    size: 'responsive',
    color: 'blue',
    shape: 'rect',
    layout: 'horizontal',
    fundingicons: 'false',
    tagline: 'false'
    },
    // Set up a payment
    payment: function(data, actions) {
    return digitalriver.createSource(paypalSourceData).then(function(result) {
    if (result.error) {
    //handle the errors that were returned
    handleErrors(result.error)
    } else {
    return result.source.payPalCredit.token;
    }
    });
    },
    // Execute the payment
    onAuthorize: function(data, actions) {
    //the payment has been authorized, use the source and attach it to your customer's account.
    doSomething();
    },
    onCancel: function(data) {
    //the payment has been cancelled, do something to try and get the shopper back on track
    doSomethingElse();
    }
    }, '#paypal-button');

Step 4. Use the Authorized source

Once authorized, you can use the source by attaching it to a checkout.

Attach the source to a checkout

POST /checkouts/{id}
POST /checkouts/{id}
{
"customerId": "5774321008",
"sourceId": "src_a78cfeae-f7ae-4719-8e1c-d05ec04e4d37"
}

Supported geographies

PayPal Credit supports the following geographies and currencies.

Supported geographies

United States (US)

Supported currencies

USD

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

When a customer selects this payment method, a "soft hit" will appear in their credit report.