Notice of non-liability:
PayPal, Inc. is providing the information i n this document t o you “AS-IS” with all faults. PayPal, Inc. makes no warranties of any kind (whether express,
implied or statutory) with respect to the information co ntained herein. PayPal, Inc. assumes no liability for damages (whether direct or indirect), caused
by errors or omissions, or resulting from the use of this document or the information contained in this document or resulting f rom the application or use
of the product or service described herein. PayPal, Inc. reserves the right to make changes to any information herein without further notice.
Digital Goods for Express Checkout streamlines the checkout process for buyers and keeps
buyers on your website.
“Introducing Digital Goods Payments” on page 9
Introducing Digital Goods Payments
Digital goods payments combine JavaScript with the Express Checkout API to streamline the
checkout process for buyers of digital goods.
Digital goods are items such as e-books, music files, and digital images distributed in
electronic format. The buyer can conveniently purchase digital goods during checkout with a
minimum of clicks without leaving your website or interrupting their online activities.
The following figure encapsulates digital goods payments:
PayPal for digital goods payments
To make a payment for a digital goods item, the buyer:
1. Clicks Pay With PayPal.
The button click triggers the call to the SetExpressCheckout API operation. PayPal
redirects the buyer to a lightbox overlaying your website.
2. Clicks Pay to accept the order.
The button click triggers JavaScript code that closes the lightbox.
Digital Goods Integration Guide - EC EditionJanuary 20129
Introducing Digital Goods for Express Checkout
1
Introducing Digital Goods Payments
3. Confirms the order on your page after the lightbox closes.
4. Resumes activity on your page.
Express Checkout Buttons
The button you place on your web page to initiate PayPal digital goods transactions is
available at the following URL:
NOTE: Do not host copies of the PayPal images locally on your servers. Outdated PayPal
images reduce buyer confidence in your site.
Digital Goods Payments In More Detail
To the buyer, the digital goods payment process appears to be built into your website. The
digital goods payment process occurs in a lightbox that temporarily overlays your website.
Your buyer’s digital goods payment experience depends upon two factors:
1. The value you set for the experience type variable on your web page
You determine how the digital goods flow appears to your buyers by setting (or not setting)
the experience type variable (expType) on your web page
(For details on setting expType, see “JavaScript Functions For Digital Goods Payments”
on page 28).
2. Whether the buyer is remembered from a previous transaction
Your buyers partially determine the digital goods flow by choosing whether to check the
“remember me” box on the login page. (Checking the box creates a “remember me cookie”
on the buyer’s machine that lets them skip the login page on subsequent visits.)
The following table describes the possible digital goods (DG) flows that the combination of
expType and “Remember Me Cookie” present to a buyer:
expType Remember Me CookieDG Flow Experience
instantNoThe login page opens in a mini-browser.
YesThe merchant review page opens in a lightbox, and a mask is
applied over the underlying web page.
miniNoThe login page opens in a mini-browser, and a mask is applied
YesThe merchant review page opens in a mini-browser, and a
mask is applied over the underlying web page.
popupNoThe login page opens in a mini-browser, and a mask is not
applied to the underlying web page.
YesThe merchant review page opens in a mini-browser, and a
mask is not applied to the underlying web page.
(not set)NoA launch page opens in a lightbox. From here the buyer can
log in (the flow then proceeds to the login page in a minibrowser) or sign up with PayPal, or pay as a guest.
YesDG opens the merchant review page in a lightbox, and a mask
is applied over the underlying web page.
NOTE: New DG Merchants: Set expTyp e to ‘instant’ for the best performance.
Existing DG Merchants: You can bypass the legacy flow’s lightbox launch page by
setting expType, or leave your web page unchanged to maintain the current behavior.
1
Digital Goods Flows
This section shows examples of different Digital Goods flows. The first example shows the
DG Instant flow (expType set to ‘instant’) for a new buyer (or a buyer who didn’t check
the “remember me” box on the login page). The second example shows the same DG Instant
flow for a returning buyer who checked the “remember me” box. The third example shows the
legacy flow (expType is unset) for a new buyer.
The buyer initiates all DG flows by clicking Pay with PayPal:
1. The expType variable is set to ‘instant’ and the buyer is new:
The DG flow opens the Log in to your PayPal account page in a mini-browser, with a
mask over the underlying page:
Digital Goods Integration Guide - EC EditionJanuary 201211
Introducing Digital Goods for Express Checkout
1
Introducing Digital Goods Payments
From this page, the buyer can log in (optionally checking the “remember me” box for
subsequent purchases if there is little risk of their account being misused), or cancel the
transaction.
IMPORTANT: Opting in to the remember me behavior does not guarantee that the buyer
will not be asked to provide log-in credentials.
Buyers without a PayPal account can sign up for one, or proceed as a guest and complete
their purchase with a credit card.
NOTE: Guest checkout provides only the visual benefits of a digital goods payment. It
does not reduce the payment steps.
After successfully logging in, the digital flow presents the You are about to pay page in a
mini-browser:
If the buyer chooses Cancel, PayPal redirects the buyer’s browser to the cancel URL
specified in the SetExpressCheckout API operation’s request message. If the buyer
chooses Pay, the Thank you for using PayPal page appears in the mini-browser:
Digital Goods Integration Guide - EC EditionJanuary 201213
Introducing Digital Goods for Express Checkout
1
Introducing Digital Goods Payments
When the buyer clicks Close, PayPal redirects the buyer’s browser to the return URL
specified in the SetExpressCheckout API operation’s request message.
2. The expType varible is set to ‘instant’ and the buyer checked the “remember me” box:
The digital goods flow skips the login screen and the flow proceeds directly to the payment
page in a lightbox:
The PayPal server calls your callback server to instantly update the PayPal pages based on
shipping options changes the buyer selects.
Parallel payments
Parameter fields describe the details of up to 10 payments. Digital goods supports passing a
value for one payment only.
Immediate Payment
Immediate Payment checks that you receive payment at the time the buyer commits to a
purchase (instant payment methods only).
Authorization and Capture API
SetCustomerBillingAgreement API
Giropay
Incentives
Several fields in the Recurring Payments API and in the Reference Transaction API are not
relevant for digital goods transactions and thus are not supported. Do not use the API fields in
the following lists for digital goods operations.
1
Unsupported Fields in the Recurring Payments and Reference Transaction Name/Value
Pair (NVP) APIs:
This chapter describes how to integrate Digital Goods for Express Checkout with your
website.
“Overview of Digital Goods Integration” on page 19
“Integrating Digital Goods Payments With Express Checkout” on page 22
Overview of Digital Goods Integration
There are two possible ways to integrate the digital goods flow with Express Checkout:
Merchants using PHP can use the PHP Wizard, located here: https://www.paypal-
labs.com/integrationwizard/.
Merchants using other platforms must take the manual approach to integration. Future
releases will feature integration wizards for other platforms.
In either event, when the integration is successfully completed, you will have added the digital
goods JavaScript to the page, set up code to invoke the digital goods flow, and specified URLs
for return and cancel pages.
The following figure summarizes the manual integration steps for the digital goods payments
flow:
Digital Goods Integration Guide - EC EditionJanuary 201219
The numbers in the figure correspond to the following steps:
1. Add the dg.js JavaScript (provided by PayPal) to the webpage on which you implement
the Pay With PayPal button. This script manages the PayPal digital goods payments flow.
This flow appears in a lightbox overlaying your webpage.
2. Place the Pay With PayPal button on the same webpage on which you add the dg.js
script.
3. When the buyer clicks Pay With PayPal, call the S etExpressCheckout API operation.
NOTE: Make sure that your API version is 65.1 or greater for each PayPal API call that
you make.
Pass details of the items purchased and other parameter fields required in digital goods
transactions. See “Setting Up A Digital Goods Payment Transaction” on page 22for
details.
4. A successful response returns a token to identify the digital goods transaction. Y o u pass the
token in subsequent Express Checkout API operations related to this transaction.
5. Redirect the buyer to the digital goods flow. Append the token returned in the
SetExpressCheckout response to the redirect URL.
2
If this is the first time the buyer is purchasing digital goods on your page, a mini-browser
displays that lets the buyer log in to PayPal and initiate approval for the payment.
6. After the buyer clicks Pay to approve or cancel, PayPal redirects the buyer to the respective
return or cancel URL page on your site. PayPal passes the token and the buyer’s Payer ID
with the redirect.
7. If the buyer approves payment, you can optionally call GetEx pressCheckoutDetails
to obtain buyer details to display to your webpage.
8. If the buyer approves payment, call DoExpressCheckoutPayment to complete the
payment, including the details of the items purchased.
9. Add JavaScript code to your return and cancel URL pages to close the digital goods
lightbox.
10.Fulfill the buyer’s order from your webpage.
Download the digital goods and provide a purchase confirmation .
NOTE: Make sure that you test your integration before taking your pages live.
Digital Goods Integration Guide - EC EditionJanuary 201221
Integrating Digital Goods for Express Checkout
2
Integrating Digital Goods Payments With Express Checkout
Integrating Digital Goods Payments With Express
Checkout
Integrating PayPal digital goods payments with the Express Checkout API requires
implementing the following API operations: SetExpressCheckout and
DoExpressCheckoutPayment. Optionally, you can implement
GetExpressCheckoutDetails.
Setting Up A Digital Goods Payment Transaction
To set up a digital goods payment transaction, call the SetExpressC heckout API request
operation. Provide sufficient information to initiate and redirect the buyer to the digital goods
payment flow.
This example assumes that you have set up the mechanism to communicate with the PayPal
server and you have a PayPal Business account with API credentials. It also assumes that the
payment action is a final sale.
NOTE: Use API version 65.1 or greater for all API calls for digital goods payments.
To set up a transaction, you specify values in the SetExpressCheckout request and then
call the API. The values you specify control the options available to you and the buyer.
NOTE: In the call to SetExpressCheckout, you are required to pass values for each digital
goods item the buyer is purchasing and to set the item category field to Digital. (For
details on these parameters, see step 7 in the setup procedure that follows.) To obtain
the discount rate for digital goods, you also must pass these parameters and values in
the call to DoExpressCheckoutPayment.
To set up the transaction:
1. Pass the total amount of the payment as the value of PAYMENTREQUEST_0_AMT; include
the currency if it is not in US dollars. For example:
PAYMENTREQUEST_0_AMT=amount
PAYMENTREQUEST_0_CURRENCYCODE= currencyID
Specify the total amount of the transaction. Regardless of the specified currency, the format
must have a decimal point. There must be exactly 2 digits to the right of the decimal point.
There can be an optional thousands separator to the left. The separator must be a comma.
For example, specify EUR 2.000,00 as 2000.00 or 2,000.00. The specified amount cannot
exceed USD $10,000.00, regardless of the currency used.
2. If you pass in a tax amount for each item, set PAYMENTREQUEST_0_TAXAMT to the total
Integrating Digital Goods Payments With Express Checkout
3. Specify the return URL to a page on your site.
RETURNURL=https://...
The return URL is the page to which PayPal redirects your buyer after the buyer approves
the payment. Typically this is a secure page (https://...) on your site.
NOTE: You can use the return URL to pass parameters between pages on your site. For
example, you can set your return URL to specify additional parameters using the
https://www.
parameters become available as request parameters on the page specified by the
return URL.
If you do not require the buyer to explicitly review and confirm the payment on your
review page, the buyer can confirm payment on PayPal. Add th e token and the
value commit as a name/value pair to the return URL:
https://www.paypal.com/incontext?token=
mit
4. Specify the cancel URL.
yourcompany.com/page.html?param=value... syntax. The
useraction
TOKENReturned&useraction=com
2
The cancel URL is the page to which PayPal redirects your buyer if the buyer does not
approve the payment. Typically, this is the secure page (https://...) on your site from
which you redirected the buyer to the PayPal digital goods payments flow.
NOTE: You can pass SetExpressC heckout request values as parameters in your URL
to have the values available, if necessary, after PayPal redirects to your URL.
CANCELURL=cancel_url
5. If you pass a value for PAYMENTREQUEST_0_PAYMENTACTION, you must pass the value
Sale (default).
6. Set PAYMENTREQUEST_0_ITEMAMT to the total of all items in the order.
7. Pass values for the following parameters for each item the buyer is purchasing.
– L_PAYMENTREQUEST_0_NAM E
n
– L_PAYMENTREQUEST_0_AMT n
– L_PAYMENTREQUEST_0_QTY n
– L_PAYMENTREQUEST_0_ITE MCATEGORYn (you must set the value to Digital)
NOTE: Make sure L_PAYMENTREQUEST_0_ITEMCATEGORY is set to Dig ital for every
item in the DoExpressCheckoutPayment request as well as
SetExpressCheckout. Failing to do so will result in incorrect fee calculations.
8. Set REQCONFIRMSHIPPING to 0.
9. Set NOSHIPPING to 1.
Digital Goods Integration Guide - EC EditionJanuary 201223
Integrating Digital Goods for Express Checkout
2
Integrating Digital Goods Payments With Express Checkout
10.Execute the SetExpressCheckout API operation to set up the Express Checkout
transaction.
11. Test that the response to the SetExpressCheckout API operation was successful.
Upon success, the SetExpressCheckout API operation returns a token. PayPal uses the
token to associate the execution of API operations and commands with a specific instance
of the checkout experience.
12.If calling the SetExpressCheckout API was successful, redirect the buyer to the digital
goods payments flow with the following redirect URL. Append the token value returned in
the SetExpressCheckout response to the URL:
SetExpressCheckout Example For Digital Goods
The following is an example of SetExpressCheckout parameters and values for a digital
goods payments transaction.
T o redirect you r buyer to the PayPal digital go ods payments flow, specify this URL along with
the token returned by the SetExpressCheckout API operation.
Integrating Digital Goods Payments With Express Checkout
After the buyer approves the payment or cancels, PayPal redirects back to the return or cancel
URL:
Return URL—If the buyer approves the payment, PayPal redirects to the return URL with
the token you passed in the redirect to PayPal and the buyer’s unique identifier (Payer ID).
Cancel URL—If the buyer cancels, PayPal redirects to the cancel URL with the token that
you passed in the redirect to PayPal.
After PayPal Redirects the Buyer To Your Web Page
The actions you take after PayPal redirects the buyer back to your web page depend upon
whether the buyer approves or cancels the order.
If the buyer approves the order and pays for the digital goods, do the following:
1. Optionally, call the GetExpressCheckoutDetails API operation to obtain details
about the buyer to display to your webpage.
2. Call DoExpressCheckout to complete payment.
2
Completing the Digital Goods Transaction
To complete the digital goods transaction after the buyer approves the order, call the
DoExpressCheckoutPayment API operation.
When calling DoExpressCheckoutPayment, do the following:
1. Pass the token and Payer ID returned by PayPal when it redirected the buyer back to your
site.
TOKEN=tokenValue
PAYERID=payerId
2. Pass the total amount of the payment as the value of PAYMENTREQUEST_0_AMT; include
the currency if it is not in US dollars.
Specify the total amount of the transaction. Regardless of the specified currency, the format
must have decimal point. The decimal point must include exactly 2 digits to the right and
an optional thousands separator to the left, which must be a comma.
For example, specify EUR 2.000,00 as 2000.00 or 2,000.00. The specified amount cannot
exceed USD $10,000.00, regardless of the currency used.
For best performance, place the path to the JavaScript file just before the closing </body>
element in your page.
2. Customize and include the following code after the JavaScript file. Replace "submitBtn"
with the ID of your HTML form button.
<script>
var dg = new PAYPAL.apps.DGFlow({
// the HTML ID of the form sub mit button which c alls setEC
trigger: "submitBtn"
// the experience type: instan t or mini
expType: ’instant’
});
</script>
NOTE: Do not set a target for the redirect on button click.
3. Include the following JavaScript code on the return URL and cancel URL pages. The
JavaScript closes the digital goods payment flow in the overlay window and sends the
buyer to the correct page.
Integrating Digital Goods Payments With Express Checkout
NOTE: Make sure that you include content to be displayed in case the customer has
JavaScript disabled on their browser. You should include a link to deliver the content
if the purchase completes successfully.
<script>
if (window.opener){
window.close();
}
else if (top.dg.isOpen() == tr ue){
top.dg.closeFlow();
}
</script>
T o update the page asynchronously without reloading, you need to make some Ajax calls as in
the following example. This is the preferred method for closing the digital go ods paymen ts
flow. For other options, see “Integrating Digital Goods W ith Flash - Third-Party Merchant” on
page 51.
<!-- Use result of DoEC to sen d the buyer to the correct page -->
<!DOCTYPE html>
<html>
<head>
<title></title>
<script>
// Sample AJAX code us ing jQuery (any AJ AX
// library works)
$.ajax({
url: 'http://example.com/path_to_fulfillment_content',
type: 'GET',
error: function () {
// Handle error cases
},
success: function ( response){
// Replace conte nt on page, initia te
// download, etc .
}
});
</script>
</head>
<body>
<!-- Include non-JavaScript co ntent here -->
If this page does not redirect <a href="[page to deliver content
to non-JS customer]">Click Her e</a>
</body>
</html>
2
Digital Goods Integration Guide - EC EditionJanuary 201227
Integrating Digital Goods for Express Checkout
2
Integrating Digital Goods Payments With Express Checkout
JavaScript Functions For Digital Goods Payments
Include dg.js on any page that invokes or terminates the digital goods payments flow. The
JavaScript functions in dg.js set up and control the PayPal lightbox and mini-browser.
Function and SignatureDescription
PAYPAL.apps.DGFlow = function
({trigger:
HTML_id_of_event_triggering_flow
expType: experience_type
})
Sets up the digital goods payment flow.
Set the experience type variable (expType) to:
instant—DG flow in lightbox, with overlay mask
mini—DG flow in mini-browser with overlay mask
popup—DG flow in mini-browser
Leave expType unset for the legacy DG flow.
setTrigger: function (
id)Adds a trigger for the flow, where id is the HTML ID of the
event that triggers the flow. The flow must first be set up by
calling PAYPAL.apps.DGFlow.
startFlow: function (
url)Explicitly starts the digital goods flow, where url is the URL
that triggers the flow.
NOTE: Y ou are only required to explicitly start the flow when
there is no triggering event; for example, when you
want to associate digital goods payments with playing
a Flash movie.
closeFlow: function ()Closes the mini-browser or lightbox associated with the flow.
Use this function after the buyer completes or cancels the
payment.
isOpen: function ()Determines whether the flow is still active.
You can use the RefundTransaction PayPal API operation to issue refunds.
Use the RefundTransaction API to issue one or more refunds associated with a
transaction, such as a transaction created by a capture of a payment. The transaction is
identified by a transaction ID that PayPal assigns when the payment is captured.
NOTE: You cannot make a refund if the transaction occurred after the refund period has
passed; typically, the refund period is 60 days.
You can refund amounts up to the total amount of the original transaction. If you specify a a
full refund, the entire amount is refunded. If you specify a partial refund, you must specify the
amount to refund, the currency, and a description of the refund, which is called a memo.
When you call the RefundTransactio n API, PayPal responds with another transaction ID,
which is associated with the refund (not the original transaction), and additional information
about the refund. This information identifies
the gross amount of the refund, which is returned to the payer
the amount of the refund associated with the original transaction fee, which is returned to
you
the net amount of the refund, which is deducted from your balance
To issue a refund
1. In the RefundTransaction request, specify the transaction ID of the transaction whose
payment you want to refund.
TRANSACTIONID=transaction_id
2. Specify the kind of refund, which is either Full or Partial.
REFUNDTYPE=Full
or
REFUNDTYPE=Partial
3. For a partial refund, specify the refund amount, including the currency.
AMT=amount
CURRENCYCODE=currencyID
Digital Goods Integration Guide - EC EditionJanuary 201231
Issuing Refunds
3
4. For a partial refund, specify the memo description.
NOTE=description
5. Execute the RefundTransaction operation.
6. Check the acknowledgement status in the RefundTransaction response to ensure that
Set up a recurring payment to handle subscription and other payments that occur on a fixed
schedule.
How Recurring Payments Work
Recurring Payments Terms
Options for Creating a Recurring Payments Profile
Recurring Payments With the Express Checkout API
Recurring Payments Profile Status
Getting Recurring Payments Profile Information
Modifying a Recurring Payments Profile
Billing the Outstanding Amount of a Profile
Recurring Payments Notifications
How Recurring Payments Work
To view a video that demonstrates how to set up Recurring Payments, navigate to: Recurring
Payments Demo
When you support recurring payments for a buyer, you create a recurring payments profile.
The profile contains information about the recurring payments, including details for an
optional trial period and a regular payment period. Both periods contain information about the
payment frequency and payment amounts, including shipping and tax, if applicable.
After creating a profile, PayPal automatically queues payments based on the billing start date,
billing frequency, and billin g amount. Payments reoccur until th e profile expires, t here are too
many failed payments to continue, or you cancel the profile.
NOTE: When using Express Checkout, the buyer can also cancel a recurring payments
profile.
PayPal funds queued payments using the normal payment method hierarchy within the buyer’s
PayPal account.
After creating a recurring payments profile, you can view profile details or cancel the profile
from your PayPal account. You can also access recurring payments reports from the PayPal
Business Overview page.
Also, after creating a recurring payments profile, you can use the Recurring Payments API to
do the following:
Get information details about a recurring payments profile.
Digital Goods Integration Guide - EC EditionJanuary 201233
Handling Recurring Payments
4
Recurring Payments T erms
Change the status of a recurring payments profile.
Update the details of the recurring payments profile.
Bill the outstanding amount of the recurring payments profile.
Limitations
The current release of the Recurring Payments API has the following limitations:
A profile can have at most one optional trial period and a single regular payment period.
The profile start date may not be earlier than the profile creation date.
Recurring Payments with Express Checkout also has the following limitations:
To be able to create a recurring payments profile for the buyer, you must ensure that the
buyer’s PayPal account includes an active credit card.
You can create a maximum of 10 recurring payments profiles during checkout.
You can increase the profile amount by only 20% in each 180-day interval after you create
the profile.
Recurring Payments Terms
The following table lists and describes terms that are commonly used in the context of PayPal
recurring payments.
Recurring Payments Terms
TermDefinition
Recurring payments profileYour record of a recurring transaction for a single buyer. The profile
includes all information required to automatically bill the buyer a fixed
amount of money at a fixed interval.
Billing cycleMake one payment per billing cycle. Each billing cycle has 2 components:
The billing period specifies the unit to calculate the billing cycle (such as
days or months).
The billing frequency specifies the number of billing periods that make
up the billing cycle.
For example, if the billing period is Month and the billing frequency is 2, the
billing cycle is 2 months. If the billing period is Week and the billing
frequency is 6, PayPal schedules the payments every 6 weeks.
Regular payment periodThe main subscription period for this profile, which defines a payment
amount for each billing cycle. The regular payment period begins after the
trial period, if you specify a trial period for the profile.
Trial periodAn optional subscription period before the regular payment period begins. A
trial period may not have the same billing cycles and payment amounts as
the regular payment period.
Payment amountThe amount the buyer pays for each billing cycle.
Outstanding balanceIf a payment fails for any reason, PayPal adds that amount to the profile’s
outstanding balance.
Profile IDAn alphanumeric string (generated by PayPal) th at uniquely identifies a
recurring profile. You can specify the Profile ID in the
TransactionSearch API operation to ob tain all payments associated
with the identified profile.
Options for Creating a Recurring Payments Profile
You can create a recurring payments profile that allows a regular payment period, an optional
trial period, an initial payment, and other options.
4
Specifying the Regular Payment Period
Each recurring payments profile has a regular payment period that defines the amount and
frequency of the payment. The following table lists the required fields for specifying the
regular payment period.
Required fields for specifying a regular payment period
NVPSOAPDescription
PROFILESTARTDATERecurringPaymentsProfileDet
ails.BillingStartDate
BILLINGPERIODSc heduleDetails.
PaymentPeriod.BillingPeriod
The date when billing for this profile
begins.
NOTE: The profile may take up to 24
hours for activation.
The unit of measure for the billing cycle.
Must be one of the following:
Day
W eek
S emiMonth
M onth
Y ear
Digital Goods Integration Guide - EC EditionJanuary 201235
Handling Recurring Payments
4
Options for Creating a Recurring Payments Profile
NVPSOAPDescription
BILLINGFREQUENCYScheduleDetails.
PaymentPeriod.BillingFreque
ncy
AMTScheduleDetails.
PaymentPeriod.Amount
You can optionally include a value for TOTALBILLINGCYCLES (SOAP field
ScheduleDetails.PaymentPeriod.TotalBill ingCycles), which specifies the total
number of billing cycles in the regular payment period. If you either do not specify a value or
specify the value 0, the payments continue until PayPal (or the buyer) cancels or suspends the
profile. If the value is greater than 0, the regular payment period continues for the specified
number of billing cycles.
You can also specify an optional shipping amount or tax amount for the regular payment
period.
Including an Optional Trial Period
The number of billing periods that make
up one billing cycle. The combination of
billing frequency and billing period must
be less than or equal to one year.
NOTE: If the billing period is
SemiMonth, the billing
frequency must be 1.
Amount to bill for each billing cycle.
You can optionally include a trial period in the profile by specifying the following fields in the
CreateRecurringPaymentsProfile request. The following table lists the required fields
for creating an optional trial period.
Required fields for specifying a trial period
NVPSOAP
TRIALBILLINGPERIODScheduleDetails.TrialPeriod.Bil lingPeriod
TRIALBILLINGFREQUENCYScheduleDetails.TrialPeriod.Bil lingFrequency
TRIALAMTScheduleDetails.TrialPeriod.Amo unt
TRIALTOTALBILLINGCYCLESScheduleDetails.TrialPeriod.Tot alBillingCycles
Specifying an Initial Payment
You can optionally specify an initial non-recurring payment when the recurring payments
profile is created by including the following fields in the
CreateRecurringPaymentsProfile request:
By default, PayPal does not activate the profile if the initial payment amount fails. To override
this default behavior, set the FAILEDINITAMTACTION field to ContinueOnFailur e. If the
initial payment amount fails, ContinueOnFailure instructs PayPal to add the failed
payment amount to the outstanding balance due on this recurring payment profile.
If you do not set FAILEDINITAMTACTION or set it to CancelOnFailure, PayPal creates the
recurring payment profile. However, PayPal places the profile into a pending status until the
initial payment completes. If the initial payment clears, PayPal notifies you by Instant
Payment Notification (IPN) that it has activated the pending profile. If the payment fails,
PayPal notifies you by IPN that it has canceled the pending profile.
If you created the profile using Express Checkout, the buyer receives an email stating that
PayPal cleared the initial payment or canceled the pending profile.
4
Maximum Number of Failed Payments
By including the MAXFAILEDPAYMENTS field in the CreateRecurringPayment sProfile
request, you set the number of failed payments allowed before PayPal automatically suspends
the profile. PayPal sends you an IPN message when the number of failed payments reaches the
maximum number specified.
Billing the Outstanding Amount
If a payment fails for any reason, PayPal adds the billing amount (including shipping and tax,
if applicable) to the profile’s outstanding balance. Use the AUTOBILLOUTAMT field in the
CreateRecurringPaymentsProfile request to specify whether PayPal should add the
outstanding amount to the payment amount for the next billing cycle.
Whether or not you choose to include the outstanding amount with the payment for the next
billing cycle, you can also use the BillOutstandingAmount API to programmatically
collect that amount at any time.
Identifying Items as Digital or Physical Goods
Set all the payment details item fields in the following table in the
CreateRecurringPaymentsProfile request. If all items are digital goods, be sure to set
the item category field to Digital to get the discount rate for digital goods.
Digital Goods Integration Guide - EC EditionJanuary 201237
Handling Recurring Payments
4
Recurring Payments With the Express Checkout API
Required fields for specifying item details
NVPSOAPDescription
L_PAYMENTREQUEST_0_
ITEMCATEGORY
L_PAYMENTREQUEST_0_
NAME
n
L_PAYMENTREQUEST_0_
n
AMT
L_PAYMENTREQUEST_0_
n
QTY
n
ItemCategoryFor digital goods, this field must be set to
Digital.
Digital
P hysical
NameItem name.
AmountCost of item.
QuantityItem quantity.
Recurring Payments With the Express Checkout API
During the checkout flow, you can create one or more recurring payments and mix recurring
payments with other purchases.
The following diagram illustrates the typical processing flow to create recurring payments
during checkout.
The circled numbers in the diagram correspond to the numbered steps in the following table:
NOTE: For digital goods, you must use API version 65.1 or greater.
Digital Goods Integration Guide - EC EditionJanuary 201239
Handling Recurring Payments
4
Recurring Payments With the Express Checkout API
Recurring payments processing flow
Step Merchant...PayPal...
1Adds JavaScript to your webpage to create the
PayPal digital goods payments flow, which appears
in a lightbox overlaying your webpage (Digital
Goods only).
2 Places the Pay With PayPal button on your
webpage.
3Calls SetExpressCheckout, setting up one or
more billing agreements in the request.
4Returns a token that identifies the transaction to the
merchant.
5Redirects buyer’s browser to:
https://www.paypal.com/cgibin/webscr?cmd=_express-checko ut
&token=
SetExpressCheckout
<token returned by
>
Displays login page and allows user to select
payment options and shipping address.
6Redirects buyer’s browser to returnURL passed to
SetExpressCheckout if buyer agrees to payment
description.
7Calls GetExpressCheckoutDetails to get
buyer information (optional).
Returns GetExpressCheckoutDetails
response.
Displays merchant review page for buyer.
8Calls DoExpressCheckoutPayment if the order
includes one-time purchases as well as a recurring
payment. Otherwise, skip this step.
Returns DoExpressCheckoutPayment response.
9Calls CreateRecurring PaymentsProfile one
time for each recurring payment item included in
the order. If the order includes a one-time digital
goods purchase, sets values for the required
payment details item parameters. Sets the item
category to Digital.
Returns ProfileID in
CreateRecurringPaymentsProfile response
for each profile successfully created.
11Fulfills the buyer’s order and displays a successful
transaction page.
Initiating the Processing Flow With SetExpressCheckout
As in the Express Checkout flow, the SetExpr essCheckout request notifies PayPal that you
are:
Initiating an order that can be either a one-time purchase, up to 10 recurring payments, or a
mixture of a one-time purchase and recurring payments
Initiating the processing flow to create one or more billing agreements for recurring
payments with no associated one-time purchase or recurring payment
NOTE: You can also initiate the processing flow using SetCustomerBillingAgreement
for orders that contain only a single recurring payment.
4
Typically, you set the amount of the payment for an Express Checkout transaction when you
call the SetExpressCheckout request. You confirm the amount in the
DoExpressCheckoutPayment request. If, however, you set the amount of the payment to 0
in the SetExpressCheckout request, you can create a billing agreement without initiating a
payment.
NOTE: To create a billing agreement without purchase, use Version 54.0 or higher, of the
PayPal API.
To set up one or more billing agreements for recurring payments, modify the
SetExpressCheckout request as follows:
1. Add an L_BILLINGTYPEn field for each billing agreement you want to create; n is a value
in the range of 0 to 9, inclusive. Set the value of each field to RecurringPayments.
L_BILLINGTYPE0=RecurringPayments
2. Add an L_BILLINGAGREEMENTDESCRIPTIONn field to correspond to each
L_BILLINGTYPEn field you pass; n is a value in the range of 0 to 9, inclusive. Set the
value of each field to the description of the goods or services associated with that billing
agreement, for example:
3. If there is no associated purchase, set PAYMENTREQUEST_0_AMT to 0.
PAYMENTREQUEST_0_AMT=0
Digital Goods Integration Guide - EC EditionJanuary 201241
Handling Recurring Payments
4
Recurring Payments With the Express Checkout API
4. (Optional) Set MAXAMT to the average expected transaction amount.
PayPal uses the value you pass to validate the buyer’s payment method for recurring
payments. If you do not specify a value, the default is 25.00.
The SetExpre ssCheckout response provides a token that uniquely identifies the transaction
for subsequent redirects and API calls.
Redirecting the Buyer to PayPal
After you receive a successful response from SetExpressCheckout, add the TOKEN from
the SetExpressCheckout respon se as a name/value pair to the following URL, and redirect
your buyer to it:
When redirecting the buyer to PayPal, PayPal recommends that you use the HTTPS response
302 “Object Moved” with the URL as the value of the Location header in the HTTPS
response. Make sure that you use an SSL-enabled server to prevent browser warnings about a
mix of secure and insecure graphics.
Getting Buyer Details Using GetExpressCheckoutDetails
The GetExpressCheckoutDetails method returns information about the buyer, including
name and email address stored on PayPal. You can optionally call this API after PayPal
redirects the buyer’s browser to the ReturnURL you specified in the SetExpressCheckout
request.
The GetExpressCheckoutDetails request has one required parameter, TOKEN, which is
the value returned in the SetExpressCheckout response.
PayPal does not return the values you specified for the following parameter fields in the
GetExpressCheckoutDetails response unless the transaction includes a purchase. PayPal
ignores the fields if you set up a billing agreement for a recurring payment that is not
immediately charged.
Creating the Profiles With CreateRecurringPaymentsProfile
After your buyer has agreed to the recurring payments billing agreement on your confirmation
page, you must call CreateRecurringPaymentsProfile to create the profile. If you are
creating multiple recurring payments profiles, you must call
CreateRecurringPaymentsProfile once for each profile you plan to create.
If the transaction includes a mixture of a one-time purchase and recurring payments profiles,
call DoExpressCheckou tPayment to complete the one-time purchase transaction. Then call
CreateRecurringPaymentsProfile for each recurring payment profile you plan to
create.
IMPORTANT:PayPal does not create the recurring payments profile until you receive a
success response from the CreateRecurringPaymentsProfile call.
T o obtain the best rates for digital goods, set values for the following required pay ment details
item fields:
L_PAYMENTREQUEST_0_NAMEn
L_PAYMENTREQUEST_0_AMTn
L_PAYMENTREQUEST_0_QTYn
L_PAYMENTREQUEST_0_ITEMCATEGORYn (you must set the value to Digital)
NOTE: The payment details item fields are available with version 69.0 and later of the
CreateRecurringPaymentsProfile API.
The CreateRecurringPaymentsProfile response contains a Profile ID, which is an
encoded string that uniquely identifies the recurring payments profile.
4
The following is a CreateRecurringPaymentsProfile example that enables you to
obtain the best rates for digital goods items.
Digital Goods Integration Guide - EC EditionJanuary 201243
Handling Recurring Payments
4
Recurring Payments Profile Status
Recurring Payments Profile Status
The recurring payments actions you may take depend on the status of the profile.
A recurring payments profile can have one of the following status values:
If PayPal successfully creates the profile, the profile has an ActiveProfile status. However,
if a non-recurring initial payment fails and you set FAILEDINITAMTA CTION to
CancelOnFailure in the CreateRecurringPayment sProfile request, PayPal creates
the profile with a status of PendingProfile. The profile remains in this status until the
initial payment either completes successfully or fails.
A profile has a status of ExpiredProfile when PayPal completes the total billing cycles for
the optional trial and the regular payment periods.
You can suspend or cancel a profile by using the
ManageRecurringPaymentsProfileStatus API. You can also reactivate a suspended
profile. If PayPal has already reached the maximum number of failed payments, however, you
must increase the number of failed payments before reactivating the profile.
NOTE: You can also suspend, cancel, or reactive a recurring payments profile through the
PayPal website.
For recurring payments profiles created with the Express Checkout API, the buyer receives an
email about the change in status of their recurring payment.
Getting Recurring Payments Profile Information
Use the GetRecurringPaymentsProfileDetails API to obtain information about a
profile.
NOTE: You can also get information about recurring payments profiles from the PayPal
website.
Along with the information that you specified in the CreateRecurringPaymentsProfile
request, GetRecurringPaymentsProfileDetails also returns the following summary
information about the profile:
Profile status
Next scheduled billing date
Number of billing cycles completed in the active subscription period
Number of billing cycles remaining in the active subscription period
Current outstanding balance
Total number of failed billing cycles
Date of the last successful payment received
Amount of the last successful payment received
Modifying a Recurring Payments Profile
Use the UpdateRecurringPaymentsProfile API to modify a recurring payments profile.
NOTE: You can also modify recurring payments profiles from the PayPal website.
You can modify only the following specific information about an active or suspended profile:
Subscriber name or address
Past due or outstanding amount
Handling Recurring Payments
Modifying a Recurring Payments Profile
4
Whether to bill the outstanding amount with the next billing cycle
Maximum number of failed payments allowed
Profile description and reference
Number of additional billing cycles
Billing amount, tax amount, or shipping amount
NOTE: You cannot modify the billing frequency or billing period of a profile. You can modify
the number of billing cycles in the profile.
You can modify the following profile information during the trial period or regular payment
period.
Billing amount
Number of billing cycles
NOTE: For recurring payments with the Express Checkout API, PayPal does not allow certain
updates, such as billing amount, within 3 days of the scheduled billing date.
The profile changes take effect with the next payment after the call to update the profile. Say,
for example, the buyer has made 1 trial payment out of a total of 3. You call
UpdateRecurringPaymentsProfile to increase the number of billing cycles to 5. This
provides the buyer with 4 additional trial payments. If you call
UpdateRecurringPaymentsProfile during the regular payment period, t he changes take
effect with the buyer’s next scheduled regular payment.
For complete details, see the Name-Value Pair Developer Guide and Reference or the SOAP API Reference.
Digital Goods Integration Guide - EC EditionJanuary 201245
Handling Recurring Payments
4
Billing the Outstanding Amount of a Profile
Updating Addresses
When you update the subscriber shipping address, you must enter all of address fields, not just
those that are changing:
To update the subscriber’s street address, for example, specify all the address fields listed in
the Name-Value Pair Developer Guide and Refer ence or SOAP API Reference. Do not specify
only the street address field.
Updating the Billing Amount
For profiles created using Express Checkout, you can increase the recurring payment total
amount by 20% maximum in a fixed 180-day interval after profile creation. The 20%
maximum is based on the total amount of the profile at the beginning of the 180-day interval,
including any shipping or tax amount.
If, for example, you create a profile on March 10 with a total amount of $100, during the 180day interval from March 10 to September 6, you can increase the amount to a maximum of
$120 (120% of $100).
Suppose that during the first 180-day interval, you increased the payment amount to $110.
During the next 180-day interval (starting September 7), you can only increase the amount of
the payment to a maximum of $132 (120% of $110).
Billing the Outstanding Amount of a Profile
Use the BillOutstandingAmount API to immediately bill the buyer for the current past
due or outstanding amount for a recurring payments profile.
NOTE: You can also bill the buyer for the current past due or outstanding amount for a
recurring payments profile from the PayPal website.
To bill the outstanding amount:
The profile status must be active or suspended.
NOTE: The BillOutstandingAm ount API does not reactivate a suspended profile. You
need to call ManageRecurringProfileStatus to do this.
The profile must have a non-zero outstanding balance.
The amount of the payment cannot exceed the outstanding amount for the profile.
The BillOutstandingAmount call cannot be within 24 hours of a regularly scheduled
payment for this profile.
NOTE: An error occurs when another outstanding balance payment is already queued.
PayPal informs you by IPN about the success or failure of the outstanding payment. For
profiles created using Express Checkout, the buyer receives an email notification of the
payment.
PayPal notifies you of recurring payments events through IPN and email. Typically, however,
you can call GetTransactionDetails to obtain the information you need.
PayPal notifies you of certain events through IPN. For recurring payments profiles created
using Express Checkout, PayPal also notifies buyers of specific events by email. The
following table indicates when PayPal generates IPN and emails:
Recurring payments IPN messages and email
EventIPNBuyer Email
Profile successfully createdYe sYes
Profile creation failedYesYes
Profile canceled from paypal.com interfaceYesYes
Profile status changed using APINoYes
Profile updated using APINoYes
4
Initial payment either succeeded or failedYesYes
Payment either succeeded or failed (during either trial
period or regular payment period)
Outstanding payment either succeeded or failedYesYes
Maximum number of failed payments reachedYesNo
NOTE: API transactions such as ManangeRecurringPaymentsProfileStatus do not
YesYes
trigger IPN notification. The API response immediately provides the success or failure
of the call.
Digital Goods Integration Guide - EC EditionJanuary 201247
The following options for closing the lightbox or mini-browser reload the parent page:
“Reloading Parent Page to a Specific URL” on page 49
“Reloading Parent Page by Removing Frames” on page 50
Reloading Parent Page to a Specific URL
This procedure for closing the lightbox or mini-browser reloads the parent page to a specific
URL:
1. Optionally, to obtain details about the buyer to display to your web page, call the
GetExpressCheckoutDetails API operation.
2. Call DoExpressCheckout to complete payment. See “Completing the Digital Goods
Transaction” on page 25.
3. Include JavaScript code, such as in the following example, on the return URL and cancel
URL pages:
<!-- Use result of DoEC to sen d the buyer to the correct page -->
<!DOCTYPE html>
<html>
<head>
<title></title>
<script>
top.location.href=’http://example.com/path_to_fulfillment_p age’;
</script>
</head>
<body>
If this page does not redir ect <a href="[page to deliver content
to non-JS customer]">Click Her e</a>
</body>
</html>
If the buyer cancels the order, close the lightbox or mini-browser without fulfilling the order.
The top window is the browser window. This code replaces the top window content with the
content of the page at the specified URL.
Digital Goods Integration Guide - EC EditionJanuary 201249
Options For Closing the Lightbox or Mini-browser
A
Reloading Parent Page by Removing Frames
Reloading Parent Page by Removing Frames
This procedure for closing the lightbox or mini-browser reloads the parent page by removing
frames:
1. Optionally, to obtain details about the buyer to display to your web page, call the
GetExpressCheckoutDetails API operation.
2. Call DoExpressCheckout to complete payment. See “Completing the Digital Goods
Transaction” on page 25.
NOTE: You perform the previous 2 steps while you are still in control of the lightbox.
3. Include JavaScript code, such as in the following example, on the return URL and cancel
URL pages:
<!-- Use result of DoEC to sen d the buyer to the correct page -->
<!DOCTYPE html>
<html>
<head>
<title></title>
<script>
if (window != top) {
top.location.replace(d ocument.location);
}
</script>
</head>
<body>
<!-- Include non-JavaScript c ontent here -->
If this page does not redirect <a href="[page to deliver content
to non-JS customer]">Click Her e</a>
</body>
</html>
If the buyer cancels the order, close the lightbox or mini-browser without fulfilling the order.
The top window is the browser window. This code replaces the top window content with the
You can integrate digital goods into a Flash file.
“Integrating Digital Goods With Flash - Third-Party Merchant” on page 51
“Integrating Digital Goods With Flash” on page 51
Integrating Digital Goods With Flash
The following is an example of how a first-party merchant can integrate digital goods with
Flash.
To integrate digital goods with Flash:
1. Include the digital goods JavaScript library in the HTML page game.html, which also
includes the Flash movie game.swf.
2. Include the following ActionScript in the Flash movie game.swf to initialize the digital
goods object:
dg_button.addEventListener(
MouseEvent.MOUSE_UP,
function(evt:MouseEvent):void {
var payment_URL:String = "<Mer chant URL to initi ate API call>";
// use ExternalInterface to call the JavaScrip t method dg.startFlow
var result:uint =
ExternalInterface.call("dg.sta rtFlow",payment_URL );
}
);
function paymentComplete(response Text):void {
// use responseText to do any customizations
}
// register the callback metho d so it can be cal led via JavaScript
ExternalInterface.addCallback( "paymentCompleteEx t", paymentComplete);
Integrating Digital Goods With Flash - Third-Party Merchant
The following is an example of how a third-party merchant can integrate digital goods with
Flash.
In the following example, use ActionScript 3.0’s LocalConnection in the Flash movie,
game.swf, to respond to the payment.
Digital Goods Integration Guide - EC EditionJanuary 201251
Methods For Integrating Digital Goods Into Flash
B
Integrating Digital Goods With Flash - Third-Party Merchant
1. Create the Flash movie, game.swf, with the following code. The code assumes the button
click on dg_button initiates payment.
// create local connection
var conn:LocalConnection;
conn = new LocalConnection();
// allow cross domain connecti on
conn.allowDomain('*');
// identify this movie as the receiver (i.e. cli ent)
conn.client = this;
dg_button.addEventListener(
MouseEvent.MOUSE_UP,
function(evt:MouseEvent):void {
// following URL will begin the DG API call
var payment_URL:String =
"<Merchant URL to initiate API call>";
// following JS opens a new wi ndow to the approp riate size
// for DG checkout
var jscommand:String = "windo w.open('"+payment_ URL+"','win',
var url:URLRequest = new URLRe quest("javascript: " +
jscommand + "
void(0);");
navigateToURL(url, "_self");
//initiate listening on connec tion
conn.connect('paymentConn');
});
function paymentComplete(response Text):void {
//use responseText to do any c ustomizations
//close the LocalConnection
conn.close();
}
2. Specify another Flash movie, return.swf, as the return URL in the API call.
3. Use FlashVars or ExternalInterface in return.swf to gather any required values
from the API response.
4. Use the LocalConnection from step 1 in return.swf to communicate with
game.swf, for example:
var sendingLC:LocalConnection = new Local Connection();
// do anything required to get API response para meters into
// the ‘response’ variable
// connect to game.swf and cal l paymentComplete
sendingLC.send('paymentConn', 'pa ymentComplete', respons e);
Revision history for PayPal Digital Goods Integration Guide - Express Checkout Edition.
Date Published Descr iption
01/30/12Updated to describe the use of the expType variable to achieve different DG
Flows. Split Chapter 1 into 2 chapters, in an effort to separate the bulk of the
conceptual info from the procedural info. Fixed doc b ugs, re-formatt ed API field
reference.
03/15/11Updated to include a note on setting item detail variables in
SetExpressCheckout and DoExpressCheckou tPayment to obtain the
digital goods discount rate.
03/08/11Updated information for V ersion 69.0: Describes how to obtain the best rates for
digital goods items for recurring payments and reference transactions.
01/26/11First publication.
Digital Goods Integration Guide - EC EditionJanuary 201263