FILTER BY TAG

Create a Session

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

Production:
POST
https://api.cybersource.com
/pts/v2/payment-references
Test:
POST
https://apitest.cybersource.com
/pts/v2/payment-references

Response Status

The session service responds with this status as the
status
field value:
  • PENDING
    : The Afterpay or Clearpay redirect URL is generated. Redirect the customer to the Afterpay or Clearpay URL.

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 fields, starting with , 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.

Creating a Session

Follow these steps to successfully complete a session request.
  1. Send a
    POST
    request to the
    https://apitest.cybersource.com/pts/v2/payment-references
    endpoint and include these required fields:

    ADDITIONAL INFORMATION

  2. Store the value in the
    processorInformation.token
    field from the session response. You must include this value in the follow-on authorization request.

    ADDITIONAL INFORMATION

    "token": "
    0d97aa1b-a9dd-4e9c-b60c-b1157470d034
    "
  3. Redirect the customer to the returned Afterpay or Clearpay URL contained in the
    processorInformation.paymentURL
    response field.

    ADDITIONAL INFORMATION

    "paymentUrl": "
    https://portal.sandbox.afterpay.com/us/checkout/?token=002.kfl0qoc9q5tarv41p34s1dvbrk62iflv382j1sd0ot7o5s82
    "
  4. 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.
  5. When you send the authorization request, set the
    processorInformation.preApprovalToken
    field to the
    processorInformation.token
    field value you stored from the session response.

REST API
Example: Create Session

Request
{ "clientReferenceInformation": { "code": "refnum-1234" }, "orderInformation": { "billTo": { "firstName": "John", "lastName": "Smith", "address1": "Happy St", "city": "Sunnyville", "administrativeArea": "TX", "postalCode": "55555", "country": "US", "email": "" }, "shipTo": { "firstName": "John", "lastName": "Smith", "address1": "Happy St", "city": "Sunnyville", "administrativeArea": "TX", "postalCode": "55555", "country": "US" }, "amountDetails": { "totalAmount": "102.21", "currency": "USD" } }, "paymentInformation": { "paymentType": { "name": "INVOICE", "method": { "name": "AFTERPAY" } } }, "processingInformation": { "actionList": "AP_SESSIONS" }, "merchantInformation": { "cancelURL": "https://www.test0.com", "successURL": "https://www.test1.com", "failureURL": "https://www.test2.com" } }
Response to a Successful Request
{ "_links": { "self": { "method": "GET", "href": "/pts/v2/payment-references" }, "updateSession": { "method": "PATCH", "href": "/pts/v2/payment-references/7117580946066126403954" }, "status": { "method": "POST", "href": "/pts/v2/status/7117580946066126403954/refresh" }, "order": { "method": "POST", "href": "/pts/v2/payments/7117580946066126403954/intents" } }, "clientReferenceInformation": { "code": "refnum-1234" }, "id": "7117580946066126403954", "orderInformation": { "amountDetails": { "totalAmount": "102.21", "currency": "USD" } }, "processorInformation": { "paymentUrl": "https://portal.sandbox.afterpay.com/us/checkout/?token=002.7uvnjm49feem2epsgandc6god33oprp32d6mla0ir036u181", "responseCode": "00001", "token": "3d331d44-a09c-4c25-9630-ed7193d52055" }, "reconciliationId": "XFZ55U75AF7X", "status": "PENDING", "submitTimeUtc": "2024-03-30T002135Z" }

REST API
Example: Create Session with Line Items

Request
{ "clientReferenceInformation": { "code": "refnum-1234" }, "orderInformation": { "billTo": { "firstName": "John", "lastName": "Smith", "street1": "Happy St", "city": "Sunnyville", "state": "TX", "postalCode": "55555", "country": "US", "email": "" }, "shipTo": { "firstName": "John", "lastName": "Smith", "street1": "Happy St", "city": "Sunnyville", "state": "TX", "postalCode": "55555", "country": "US" }, "amountDetails": { "currency": "USD" }, "lineItems": [ { "productCode": "4564", "productName": "TV", "quantity": "10", "unitPrice": "1", "productSku": "testI", "totalAmount": "10" }, { "productCode": "65432", "productName": "TV", "quantity": "1", "unitPrice": "15", "productSku": "testJ", "totalAmount": "15" } ] }, "paymentInformation": { "paymentType": { "name": "INVOICE", "method": { "name": "AFTERPAY" } } }, "processingInformation": { "actionList": "AP_SESSIONS" }, "merchantInformation": { "cancelURL": "https://www.test0.com", "successURL": "https://www.test1.com", "failureURL": "https://www.test2.com" } }
Response to a Successful Request
{ "_links": { "self": { "method": "POST", "href": "/pts/v2/payment-references" }, "updateSession": { "method": "PATCH", "href": "/pts/v2/payment-references/7138872813806339404953" }, "status": { "method": "POST", "href": "/pts/v2/refresh-payment-status/7138872813806339404953" }, "order": { "method": "POST", "href": "/pts/v2/payment-references/7138872813806339404953/intents" } }, "clientReferenceInformation": { "code": "refnum-1234" }, "id": "7138872813806339404953", "orderInformation": { "amountDetails": { "totalAmount": "25.00", "currency": "USD" } }, "processorInformation": { "responseDetails": "00001", "paymentUrl": "https://portal.sandbox.afterpay.com/us/checkout/?token=002.lu9cqikv022heqt1aq5o0ik5uu4g8encdhvvj6r5v68n4mgi", "responseCode": "00001", "token": "bcb5d37d-0043-46be-aa10-dc9858df99aa" }, "reconciliationId": "XFZ55VAJVS0I", "status": "PENDING", "submitTimeUtc": "2024-04-23T154801Z" }