On This Page
Process a Sale
This service enables you to send both a payment authorization request and a capture
request as a single transaction using the sale service. You must include the token
received from the session response in the sale request to receive a successful response.
Endpoints
Production:
POST
https://api.cybersource.com
/pts/v2/paymentsTest:
POST
https://apitest.cybersource.com
/pts/v2/paymentsResponse Status
Cybersource
responds to your request with one of these statuses in the
status
. - FAILED: the sale request fails when there are invalid or missing fields.
- PENDING: the sale request is accepted but is not settled. To settle the payment, check out using the payment redirect URL that you received in the sale response.
IMPORTANT
When the sale status updates to
SETTLED
, the sale cannot be reversed using the
authorization-reversal request. You must send a refund request to refund the
settled amount. Required Fields for a Sale
Include these required fields in the sale request.
- This field becomes optional if theorderInformation.lineItems[].totalAmountfield is present.
- Set toAFTERPAY.
- Set toINVOICE.
- Set toAP_SALE.
- Set to theprocessorInformation.tokenreturned in the session response.
Optional Fields for a Sale
Choose from these optional fields to include in the sale request.
- If this field is present, theorderInformation.amountDetails.totalAmountfield is optional.
REST API Example: Processing a
Sale
REST API
Example: Processing a
SaleRequest
{ "clientReferenceInformation": { "code": "refnum-1234" }, "merchantInformation": { "successUrl": "https://www.test.com", "failureUrl": "https://www.test.com", "cancelUrl": "https://www.test.com" }, "processorInformation": { "preApprovalToken": "95820cec-1846-4f70-a5c4-c04b09e79e74" }, "paymentInformation": { "paymentType": { "name": "INVOICE", "method": { "name": "AFTERPAY" } } }, "processingInformation": { "actionList": "AP_SALE" }, "orderInformation": { "amountDetails": { "totalAmount": "102.21", "currency": "USD" }, "billTo": { "firstName": "John", "lastName": "Smith", "address1": "123 Happy St", "locality": "Happyville", "administrativeArea": "TX", "postalCode": "55555", "country": "US", "email": "" }, "shipTo": { "firstName": "John", "lastName": "Smith", "address1": "123 Happy", "locality": "Happyville", "administrativeArea": "TX", "postalCode": "55555", "country": "US" } } }
Response to a Successful Request
{ "_links": { "void": { "method": "POST", "href": "/pts/v2/payments/7138922745236263804951/voids" }, "billingAgreement": { "method": "POST", "href": "/pts/v2/billing-agreements/7138922745236263804951" }, "self": { "method": "POST", "href": "/pts/v2/payments/7138922745236263804951" }, "refund": { "method": "POST", "href": "/pts/v2/payments/7138922745236263804951/refunds" }, "status": { "method": "POST", "href": "/pts/v2/refresh-payment-status/7138922745236263804951" } }, "clientReferenceInformation": { "code": "refnum-1234" }, "id": "7138922745236263804951", "message": "Request was processed successfully.", "orderInformation": { "amountDetails": { "totalAmount": "102.21", "currency": "USD" } }, "processorInformation": { "responseDetails": "00004", "transactionId": "95820cec-1846-4f70-a5c4-c04b09e79e74", "responseCode": "00004" }, "reconciliationId": "XFZ55VAJVSL5", "status": "SETTLED", "submitTimeUtc": "2024-04-23T17:11:15Z" }
REST API Example: Processing a Sale with
Line Items
REST API
Example: Processing a Sale with
Line ItemsRequest
{ "clientReferenceInformation": { "code": "refnum-1234" }, "merchantInformation": { "successUrl": "https://www.test.com", "failureUrl": "https://www.test.com", "cancelUrl": "https://www.test.com" }, "processorInformation": { "preApprovalToken": "b35c3837-5e1b-4ed6-8494-b2a6744fcc58" }, "paymentInformation": { "paymentType": { "name": "INVOICE", "method": { "name": "AFTERPAY" } } }, "processingInformation": { "actionList": "AP_SALE" }, "orderInformation": { "amountDetails": { "totalAmount": "25.00", "currency": "USD" }, "billTo": { "firstName": "John", "lastName": "Smith", "address1": "123 Happy St", "locality": "Austin", "administrativeArea": "TX", "postalCode": "55555", "country": "US", "email": "" }, "shipTo": { "firstName": "John", "lastName": "Smith", "address1": "123 Happy", "locality": "Austin", "administrativeArea": "TX", "postalCode": "55555", "country": "US" }, "lineItems": [ { "unitPrice": "1.00", "quantity": "10", "productSKU": "testI", "productName": "TV", "productCode": "4564", "totalAmount": "10" }, { "unitPrice": "15.00", "quantity": "1", "productSKU": "testJ", "productName": "TV", "productCode": "65432", "totalAmount": "15" } ] } }
Response to a Successful Request
{ "_links": { "void": { "method": "POST", "href": "/pts/v2/payments/7139031022186616204951/voids" }, "billingAgreement": { "method": "POST", "href": "/pts/v2/billing-agreements/7139031022186616204951" }, "self": { "method": "POST", "href": "/pts/v2/payments/7139031022186616204951" }, "refund": { "method": "POST", "href": "/pts/v2/payments/7139031022186616204951/refunds" }, "status": { "method": "POST", "href": "/pts/v2/refresh-payment-status/7139031022186616204951" } }, "clientReferenceInformation": { "code": "refnum-1234" }, "id": "7139031022186616204951", "message": "Request was processed successfully.", "orderInformation": { "amountDetails": { "totalAmount": "25.00", "currency": "USD" } }, "processorInformation": { "responseDetails": "00004", "transactionId": "b35c3837-5e1b-4ed6-8494-b2a6744fcc58", "responseCode": "00004" }, "reconciliationId": "XFZ55VAJVTTZ", "status": "SETTLED", "submitTimeUtc": "2024-04-23T20:11:43Z" }