Create a Session
On This Page
Creating a session is mandatory for processing a payment. To create a session, you must
include shipping fields in your request. The shipping field values are included in the
invoice Afterpay and Clearpay send to the customer.
A successful session response includes an Afterpay or Clearpay redirect URL and a token.
Send the customer to the redirect URL to approve the payment using their Afterpay or
Clearpay account. Use the token in the authorization request to link the authorization
to the session.
Endpoints
Set the
apSessionsService_run
field to
true
, and send the request to one of these
endpoints:Production:
https://ics2ws.ic3.com/commerce/1.x/transactionProcessor
Test:
https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor
Response Status
The session service responds with this status as the
apSessionReply_status
field value:- PENDING: The Afterpay or Clearpay redirect URL is generated. Redirect the customer to the Afterpay or Clearpay URL.
The session service also responds with a reason code as the
apSessionReply_reasonCode
field value. For more information about reason
codes, see the Reason Codes for the Simple Order
API.Line Items
Afterpay and Clearpay use optional line item fields when you send a session
request.
Line items are used to include information about the goods that your customers purchase,
such as product name, quantity, and price.
Line items are represented as the
item_#_
fields,
starting with item_0_
, and increasing in numerical
order.These fields are required for each line item that you use:
Including Line Items
This example shows three valid line items.
<item id="0"> <unitPrice>20</unitPrice> <quantity>1</quantity> <productCode>98765</productCode> <productName>shirt</productName> <productSKU>testJ</productSKU> <totalAmount>20</totalAmount> </item> <item id="1"> <unitPrice>10</unitPrice> <quantity>3</quantity> <productCode>65432</productCode> <productName>pants</productName> <productSKU>testK</productSKU> <totalAmount>30</totalAmount> </item> <item id="2"> <unitPrice>5</unitPrice> <quantity>5</quantity> <productCode>12345</productCode> <productName>socks</productName> <productSKU>testX</productSKU> <totalAmount>25</totalAmount> </item>
Creating a Session
Follow these steps to successfully complete a session request.
- Send aPOSTrequest to thehttps://ics2ws.ic3.com/commerce/1.x/transactionProcessorendpoint and include these required fields:
ADDITIONAL INFORMATION
- Set toafp.
- Set totrue.
- Set toN.
- Include any of these optional fields in the request:
ADDITIONAL INFORMATION
- apSessionService_paymentMethod_name
- Set toN.
- billTo_street2
- Replace the#character with a sequential number starting from0.
- Replace the#character with a sequential number starting from0.
- Replace the#character with a sequential number starting from0.
- Replace the#character with a sequential number starting from0.
- Replace the#character with a sequential number starting from0.
- Replace the#character with a sequential number starting from0.
- When this field is included in the request, thepurchaseTotals_grandTotalAmountfield is no longer required.
- Replace the#character with a sequential number starting from0.
- Store the value in theprocessorTokenfield from the session response. You must include this value in the follow-on authorization request.
ADDITIONAL INFORMATION
<processorToken>5f97d636-85d1-486b-a1de-96111938ec61</processorToken> - Redirect the customer to the returned Afterpay or Clearpay URL contained in themerchantURLresponse field.
ADDITIONAL INFORMATION
<merchantURL>https://portal.afterpay.com/us/checkout/?token=002.suuh2tq1gfvthg0180il0928fjkhg1p4ufg4savhihcvm9uj</merchantURL> - When the customer completes the checkout using their Afterpay or Clearpay credentials, Afterpay or Clearpay redirects the customer to the success URL specified in the session request. You can now send an authorization request.
- When you send the authorization request, set theapAuthService_preapprovalTokenfield to theprocessorTokenfield value you stored from the session response.
Simple Order API Example: Create Session with
XML
Simple Order API
Example: Create Session with
XMLSimple Order API Example: Create Session Using
Line Items with XML
Simple Order API
Example: Create Session Using
Line Items with XMLRequest
1234567891011121314151617181920212223242526272829303132<="urn:schemas-cybersource-com:transaction-data-1.213"> <merchantID>test_merchant</merchantID> <merchantReferenceCode>refnum-1234</merchantReferenceCode> <billTo> <firstName>John</firstName> <lastName>Smith</lastName> <street1>Happy</street1> <city>Austin</city> <state>TX</state> <postalCode>78757</postalCode> <country>US</country> <email>test@cybs.com</email> </billTo> <shipTo> <firstName>John</firstName> <lastName>Smith</lastName> <street1>Happy</street1> <city>Austin</city> <state>TX</state> <postalCode>78757</postalCode> <country>US</country> </shipTo> <purchaseTotals> <currency>USD</currency> <grandTotalAmount>600</grandTotalAmount> </purchaseTotals> <apPaymentType>AFP</apPaymentType> <apSessionsService run="true"> <cancelURL>https://www.test0.com</cancelURL> <successURL>https://www.test1.com</successURL> </apSessionsService> </>
Response to a Successful Request
1234567891011121314151617181920<:c="urn:schemas-cybersource-com:transaction-data-1.213"> <merchantReferenceCode>refnum-1234</merchantReferenceCode> <requestID>6951825944986489403007</requestID> <decision>ACCEPT</decision> <reasonCode>100</reasonCode> <requestToken>AxjnrwSTeNv3IJzf8zZ/AAUZYjWmrWbQcsYsOgojmhl/H/SCHUwGX0MmkmXoxZaH/pN42/cgnN/zNn8A2VlF</requestToken> <purchaseTotals> <currency>USD</currency> </purchaseTotals> <apSessionsReply> <reasonCode>100</reasonCode> <responseCode>00000</responseCode> <merchantURL>https://portal.sandbox.afterpay.com/us/checkout/?token=002.suuh2tq1gfvthg0180il0928fjkhg1p4ufg4savhihcvm9uj</merchantURL> <processorToken>519ff272-d850-4c81-ab65-674f670063c7</processorToken> <amount>600.00</amount> <reconciliationID>XFZ55MP91ECP</reconciliationID> <status>COMPLETED</status> <dateTime>2023-09-20T04:03:14Z</dateTime> </apSessionsReply> </>
Request with Optional Line Items
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748<="urn:schemas-cybersource-com:transaction-data-1.213"> <merchantID>test_merchant</merchantID> <merchantReferenceCode>refnum-1234</merchantReferenceCode> <billTo> <firstName>John</firstName> <lastName>Smith</lastName> <street1>Peachtree St</street1> <city>Atlanta</city> <state>GA</state> <postalCode>33019</postalCode> <country>US</country> <email>test@cybs.com</email> </billTo> <shipTo> <firstName>John</firstName> <lastName>Smith</lastName> <street1>Peachtree St</street1> <city>Atlanta</city> <state>GA</state> <postalCode>30319</postalCode> <country>US</country> </shipTo> <item id="0"> <unitPrice>1</unitPrice> <quantity>10</quantity> <productCode>4564</productCode> <productName>TV</productName> <productSKU>testI</productSKU> <totalAmount>10</totalAmount> </item> <item id="1"> <unitPrice>15</unitPrice> <quantity>1</quantity> <productCode>65432</productCode> <productName>TV</productName> <productSKU>testJ</productSKU> <totalAmount>15</totalAmount> </item> <purchaseTotals> <currency>USD</currency> </purchaseTotals> <apPaymentType>AFP</apPaymentType> <apSessionsService run="true"> <cancelURL>https://www.test.com</cancelURL> <successURL>https://www.test1.com</successURL> <paymentMethod_name>afp</paymentMethod_name> </apSessionsService> </>
Response with Optional Line Items
1234567891011121314151617181920<:c="urn:schemas-cybersource-com:transaction-data-1.213"> <merchantReferenceCode>refnum-1234</merchantReferenceCode> <requestID>6977376246486503703007</requestID> <decision>ACCEPT</decision> <reasonCode>100</reasonCode> <requestToken>AxjnrwSTej6MCHSsbsHfAAUZYiy6ladJo2qFOEnkFtpem2kDJxDNyGTSTL0YwW2Lkm9H0YEOlY3YO+AAES2i</requestToken> <purchaseTotals> <currency>USD</currency> </purchaseTotals> <apSessionsReply> <reasonCode>100</reasonCode> <responseCode>00001</responseCode> <merchantURL>https://portal.sandbox.afterpay.com/us/checkout/?token=002.kfl0qoc9q5tarv41p34s1dvbrk62iflv382j1sd0ot7o5s82</merchantURL> <processorToken>0d97aa1b-a9dd-4e9c-b60c-b1157470d034</processorToken> <amount>25.00</amount> <reconciliationID>XEKTVNIQZPSB</reconciliationID> <status>PENDING</status> <dateTime>2023-10-19T17:47:05Z</dateTime> </apSessionsReply> </>