Radial Integration | 2016

Payments, Tax & Fraud > Payments Processing > PayPal Processing > PayPal SetExpress

PayPal SetExpress

Overview

SetExpress is the first API call of the PayPal checkout flow. It is used to initiate the PayPal authorization process. PayPal supports Express Checkout, Express Checkout Easy Payments, and PayPal Standard Checkout payment method.

Express Checkout uses the shipping address on file at the buyer's PayPal account. Express Checkout Easy Payments leverages Express Checkout by allowing its customer to pay for a purchase with a specific amount over a specific number of months at a promotional APR. Currently Easy Payments are available to buyers with United Kingdom, Unites States, and Germany PayPal accounts only.

Standard Checkout uses the shipping address on file is overridden by the address entered by the user. The request element AddressOverride is used to distinguish between the two types of checkout. AddressOverride must be set to 0 for an Express checkout and to 1 for a Standard checkout.

The SetExpress response contains a Token element. The token value is used in the PayPal GetExpress request -- the next call in the PayPal checkout flow.

URI Description

Action URI Template URI Example Non-URI Request Response
POST /vM.m/stores/StoreId/payments/ paypal/setExpress.[format] /v1.0/stores/AStoreId/payments/ paypal/setExpress.xml XML 200 + XML Response containing PayPal Token

Request Elements

When preparing the request, consider the following data notes:

Element Required Description Type Restriction
StoreId Yes Store identifier used in the URL. String 20 Characters
OrderId Yes Order identifier. String 20 Characters
ReturnUrl Yes URL to which the customer's browser is returned after choosing to pay with PayPal. String Cannot be empty. (Minimum of 1 character)
CancelUrl Yes URL to which the customer is returned if the customer does not approve the use of PayPal. String Cannot be empty. (Minimum of 1 character)
LocaleCode Yes Locale code for the user's language in combination with a country. String Cannot be empty. (Minimum of 1 character)
Amount Yes The order total amount, which is the sum of LineItemsTotal + ShippingTotal + TaxTotal. Decimal 2 precision points. (123.34)
currencyCode Yes Code identifies the currency for the Amount. String IS-4217 three-letter code
AddressOverride No Identifies Express Checkout (set to 0) or Standard Checkout (set to 1). String 0, 1
NoShippingAddressDisplay No Hides shipping address on PayPal checkout review page when set to 1. Shows the shipping address when set to 0 or when not specified. String 0, 1
ShipToName No The name of the person shipped to String 32 Characters
ShippingAddress No Address the order will be shipped to. Complex Type Includes: Line1, Line2, Line3, Line4, City, MainDivision, CountryCode, PostalCode
Line1 Yes Line 1 of the address. String Between 1 and 70 Characters.
Line2 No Line 2 of the address. String Between 1 and 70 Characters.
Line3 No Line 3 of the address. String Between 1 and 70 Characters.
Line4 No Line 4 of the address. String Between 1 and 70 Characters.
City Yes City the order will be shipped to. String Between 1 and 40 Characters.
MainDivision No This is the State/Province name String Between 1 and 35 Characters. Use of the ISO 3166-2 code is recommended but not required.
CountryCode Yes Country the order will be shipped to. String Between 2 and 40 Characters. Use of the ISO 3166 alpha 2 code is recommended but not required.
PostalCode No Postal Code the order will be shipped to. String Between 1 and 15 Characters.
LineItems No Represents the items in the Order. Complex Type Includes: LineItemsTotal, ShippingTotal, TaxTotal and Multiple LineItem elements.
LineItemsTotal Yes Total amount for all line items excluding shipping and tax. Calculated as: LineItemsTotal = (First-LineItem-Quantity * First-LineItem-Amount) + other line items. Decimal 2 precision points. (123.34). Negative is allowed. However, LineItemsTotal + ShippingTotal + TaxTotal cannot be negative.
ShippingTotal Yes Total shipping amount for all line items. Decimal 2 precision points. (123.34).
TaxTotal Yes Total tax amount for all line items. Decimal 2 precision points. (123.34).
LineItem No Represents a single item on the order. Complex Type Includes: Name, SequenceNumber, Quantity, UnitAmount
Name Yes Line item name. String No Restrictions.
SequenceNumber No Sequence number of current line item in cart if available. String No Restrictions.
Quantity Yes Quantity for this line item. Int No Restrictions.
UnitAmount Yes Unit price amount for a line item. Decimal 2 precision points. (123.34). Negative is allowed.
Recurring No Set up billing agreement for recurring payment when Recurring is true. Boolean true/false
Installment No Indicates whether this payment will be made using PayPal's Credit installment payment. Boolean true/false
SchemaVersion Yes

Although marked as optional in the the schema, this element needs to be passed at all times with a value of 1.1 or greater in order to receive elements like 'ErrorMessage', ‘ShortErrorMessage’, ‘ErrorCode’ in the Response message.

String

pattern = "([0-9]+\.)*[0-9]+".
Value Example: 1.1, 1.2

Request Example

The request is a PayPalSetExpressCheckoutRequest message.

<?xml version="1.0" encoding="UTF-8"?>
  <PayPalSetExpressCheckoutRequest xmlns="http://api.gsicommerce.com/schema/checkout/1.0">
    <OrderId>12345</OrderId>
    <ReturnUrl>http://www.webstore.com/return?token=</ReturnUrl>
    <CancelUrl>http://www.webstore.com/cancel</CancelUrl>
    <LocaleCode>en_US</LocaleCode>
    <Amount currencyCode="USD">60.00</Amount>
    <AddressOverride>0</AddressOverride>
    <ShipToName>John Doe</ShipToName>
    <ShippingAddress>
      <Line1>630 Allendale Road</Line1>
      <Line2>Building A</Line2>
      <Line3>2nd Floor</Line3>
      <Line4>Appartment 17</Line4>
      <City>Philadelphia</City>
      <MainDivision>PA</MainDivision>
      <CountryCode>USA</CountryCode>
      <PostalCode>19001</PostalCode>
    </ShippingAddress>
    <LineItems>
      <LineItemsTotal currencyCode="USD">20.00</LineItemsTotal>
      <ShippingTotal currencyCode="USD">20.00</ShippingTotal>
      <TaxTotal currencyCode="USD">20.00</TaxTotal>
      <LineItem>
        <Name>Shirt</Name>
        <SequenceNumber>1</SequenceNumber>
        <Quantity>2</Quantity>
        <UnitAmount currencyCode="USD">10.00</UnitAmount>
      </LineItem>
    </LineItems>
    <Recurring>false</Recurring>
    <Installment>false</Installment>
    <SchemaVersion>1.1</SchemaVersion>
  </PayPalSetExpressCheckoutRequest>

Request Example with Multiple Line Items

The request is a PayPalSetExpressCheckoutRequest message.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PayPalSetExpressCheckoutRequest xmlns="http://api.gsicommerce.com/schema/checkout/1.0">
  <OrderId>11111123</OrderId>
  <ReturnUrl>http://webstore.com/return</ReturnUrl>
  <CancelUrl>http://webstore.com/cancel</CancelUrl>
  <LocaleCode>en_US</LocaleCode>
  <Amount currencyCode="USD">80.00</Amount>
  <ShipToName>John Doe</ShipToName>
  <ShippingAddress>
    <Line1>630 Allendale Road</Line1>
    <City>King of Prussia</City>
    <MainDivision>PA</MainDivision>
    <CountryCode>US</CountryCode>
    <PostalCode>19406</PostalCode>
  </ShippingAddress>
  <LineItems>
    <LineItemsTotal currencyCode="USD">40.00</LineItemsTotal>
    <ShippingTotal currencyCode="USD">25.00</ShippingTotal>
    <TaxTotal currencyCode="USD">15.00</TaxTotal>
    <LineItem>
      <Name>Hat</Name>
      <SequenceNumber>1</SequenceNumber>
      <Quantity>2</Quantity>
      <UnitAmount currencyCode="USD">-10.00</UnitAmount>
    </LineItem>
    <LineItem>
      <Name>Shirt</Name>
      <SequenceNumber>2</SequenceNumber>
      <Quantity>3</Quantity>
      <UnitAmount currencyCode="USD">30.00</UnitAmount>
    </LineItem>
  </LineItems>
  <SchemaVersion>1.1</SchemaVersion>
</PayPalSetExpressCheckoutRequest>

Request Example Negative Value for LineItemsTotal

The request is a PayPalSetExpressCheckoutRequest message.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PayPalSetExpressCheckoutRequest xmlns="http://api.gsicommerce.com/schema/checkout/1.0">
  <OrderId>11111123</OrderId>
  <ReturnUrl>http://webstore.com/return</ReturnUrl>
  <CancelUrl>http://webstore.com/cancel</CancelUrl>
  <LocaleCode>en_US</LocaleCode>
  <Amount currencyCode="USD">20.00</Amount>
  <ShippingAddress>
    <Line1>630 Allendale Road</Line1>
    <City>King of Prussia</City>
    <MainDivision>PA</MainDivision>
    <CountryCode>US</CountryCode>
    <PostalCode>19406</PostalCode>
  </ShippingAddress>
  <LineItems>
    <LineItemsTotal currencyCode="USD">-20.00</LineItemsTotal>
    <ShippingTotal currencyCode="USD">25.00</ShippingTotal>
    <TaxTotal currencyCode="USD">15.00</TaxTotal>
    <LineItem>
      <Name>Discount</Name>
      <SequenceNumber>1</SequenceNumber>
      <Quantity>2</Quantity>
      <UnitAmount currencyCode="USD">-10.00</UnitAmount>
    </LineItem>
  </LineItems>
  <SchemaVersion>1.1</SchemaVersion>
</PayPalSetExpressCheckoutRequest>

Response Elements

Element Required Description Type Restriction
OrderId Yes Order identifier. String 20 Characters
ResponseCode Yes Response Code returned from Payment Service. String Success, Failure
Token Yes The timestamped token value that was returned by PayPalSetExpressCheckoutReply and passed on PayPalGetExpressCheckoutRequest. String Generated by PayPal
ErrorMessage No Full Error Description. String Present only when the ResponseCode is Failure and SchemaVersion in the Request is equal to or greater than 1.1.
ShortErrorMessage No Short Error Description. String Present only when the ResponseCode is Failure and SchemaVersion in the Request is equal to or greater than 1.1.
ErrorCode No Error code coming from PayPal. String Present only when the ResponseCode is Failure and SchemaVersion in the Request is equal to or greater than 1.1.

Successful Response Example

The response is a PayPalSetExpressCheckoutReply message.

<?xml version="1.0" encoding="UTF-8"?>
<PayPalSetExpressCheckoutReply xmlns="http://api.gsicommerce.com/schema/checkout/1.0">
  <OrderId>12345</OrderId>
  <ResponseCode>Success</ResponseCode>
  <Token>EC-5YE59312K56892714</Token>
</PayPalSetExpressCheckoutReply>

Failure Response Example

The response is a PayPalSetExpressCheckoutReply message.

<?xml version="1.0" encoding="UTF-8"?>
<PayPalSetExpressCheckoutReply xmlns="http://api.gsicommerce.com/schema/checkout/1.0">
  <OrderId>12345</OrderId>
  <ResponseCode>Failure</ResponseCode>
  <ErrorMessage>Total Amount does not match line amounts.</ErrorMessage>
  <ShortErrorMessage>Total Amount does not match line amounts.</ShortErrorMessage>
  <ErrorCode>1234</ErrorCode>
</PayPalSetExpressCheckoutReply>

Timeout Response

The response is a XmlFaultReply message.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <XmlFaultReply xmlns="http://schema.gsicommerce.com/payments/services/1.0/"
    xmlns:payment="http://schema.gsicommerce.com/payments/types/1.0/">
    <payment:CreateTimestamp>2012-01-26T17:09:07.046Z</payment:CreateTimestamp>
    <payment:Code>SocketTimeoutException</payment:Code>
    <payment:Description>Read timed out</payment:Description>
  </XmlFaultReply>

Next Step

After a successful SetExpress call, the next step in the PayPal checkout flow is a GetExpress call.

 

Copyright © 2017 Radial. All rights reserved.