FILTER BY TAG

Create a PayPal Order

This section describes how to create a
PayPal
order.
You must send a create order request to begin processing a new payment. Creating an order enables the customer to complete checkout using their PayPal account.
Itemization
Every unique item being purchased must be itemized in the request as a line item. For more information about how to format line items in a request, see Including Line Items in Requests.
Payment Processing Type
You must also set the
processingInformation.authorizationOptions.authType
request field to
AUTHORIZE
or
CAPTURE
to indicate which follow-on requests you will send to process the payment. Set the field value to
AUTHORIZE
if you want to process the payment using the authorization and capture requests. Set the field value to
CAPTURE
if you want to process the payment using the sale request.
Payment Method
To specify that the customer is paying with PayPal, set the
paymentInformation.paymentType.method.name
request field to
payPal
.
Saving Payment Credentials
You can save a customer's payment credentials in order to make future transactions fast and simple for the customer. To save the customer's credentials, you must include the optional
processingInformation.processingInstruction
request field and set its value to
ORDER_SAVED_EXPLICITLY
. After you successfully create the order and the customer completes the checkout, you must send a follow-on save payment credentials request. For more information, see Save an Order.
A successful request is indicated by a PayPal redirect URL in the
processorInformation.paymentUrl
response field and a request ID in the
id
response field. Redirect the customer to the PayPal URL where they can log in to their PayPal account to approve and complete the payment. Save the request ID in your system for the follow-on API requests.

Endpoints

Production:
POST
https://api.cybersource.com
/pts/v2/intents
Test:
POST
https://apitest.cybersource.com
/pts/v2/intents

Requesting to Create a PayPal Order

Follow these steps to successfully create an order.
  1. Send a
    POST
    request to the
    https://api.cybersource.com
    /v2/intents
    endpoint and include these required fields:
    orderInformation.amountDetails.taxDetails.taxId
    orderInformation.amountDetails.taxDetails.type
    orderInformation.invoiceDetails.invoiceNumber
    orderInformation.invoiceDetails.productDescription
    paymentInformation.customer.customerid
    Set to
    payPal
    .
    Set to
    eWallet
    .
    Set to
    AP_ORDER
    .
    processingInformation.authorizationOptions.authType
    Set to one of these values:
    • AUTHORIZE
      : The created order can be processed with an authorization and capture.
    • CAPTURE
      : The created order can be processed for a sale.
  2. Include any optional fields in the request:
    orderInformation.invoiceDetails.productDescription
    processingInformation.processingInstruction
    Set to
    ORDER_SAVED_EXPLICITLY
    to save the customer's payment credentials using the save an order follow-on request.
  3. Redirect the customer to the received URL in the
    processorInformation.paymentUrl
    response field.
    "processorInformation": { "transactionId": "1CE47930A46117822", "paymentUrl": "https://www.sandbox.paypal.com/checkoutnow?token=1CE47930A46117822" }
  4. When the customer completes checking out using their PayPal account, the customer is redirected to the URL you included in the
    merchantInformation.successUrl
    request field.

Example: Creating a PayPal Order

Request
{ "clientReferenceInformation": { "code": "123456" }, "buyerInformation": { "language": "en", "personalIdentification": [ { "id": "123", "type": "BR_CNPJ" } ], "dateOfBirth": "20210101" }, "orderInformation": { "shipTo": { "country": "PL", "postalCode": "CV-1012", "locality": "San" }, "billTo": { "firstName": "ab", "lastName": "c", "address1": "ABC city, XYZ street", "phoneNumber": "1234", "email": "test@enets.com", "locality": "San", "company": { "name": "abc" } }, "amountDetails": { "totalAmount": "150", "currency": "USD", "taxAmount": "50", "taxDetails": { "taxId": "123456", "type": "BR_CPF" } }, "invoiceDetails": { "invoiceNumber": "123", "productDescription": "1bc" }, "lineItems": [ { "productName": "test-product", "quantity": 5, "productDescription": "description-123", "unitPrice": "20", "taxAmount": "10", "totalAmount": "100", "typeOfSupply": "01" } ] }, "merchantInformation": { "successUrl": "https://developer.paypal.com/home", "merchantDescriptor": { "name": "Demo-Merchant" }, "returnUrl": "https://developer.paypal.com/home" }, "paymentInformation": { "customer": { "customerid": "12345" }, "paymentType": { "method": { "name": "payPal" }, "name": "eWallet" } }, "processingInformation": { "authorizationOptions": { "authType": "AUTHORIZE" }, "actionList": [ "AP_ORDER" ] } }
Response to a Successful Request
{ "processorInformation": { "transactionId": "1CE47930A46117822", "paymentUrl": "https://www.sandbox.paypal.com/checkoutnow?token=1CE47930A46117822" }, "message": "Successful", "status": "PAYER_ACTION_REQUIRE", "id": "7259726679396017501991", "submitTimeUtc": "2024-09-10T12:51:08Z" }

Response Statuses for Creating a PayPal Order

Cybersource
responds to your request with one of these statuses in the
status
field:
  • PAYER_ACTION_REQUIRE
    : The request was successful, and you must redirect the customer to the PayPal checkout URL in order for the customer to approve the payment.
  • INVALID_REQUEST
    : The request was not successful. Send a new request.
When you request a status update,
Cybersource
responds with one of these statuses in the
status
field:
  • COMPLETED
    : The order was approved by the customer. This status can also occur when the order is successfully used for an authorization or sale.

Follow-On Requests

After you create an order, you can send these follow-on API requests using the order ID from the response message.
Update Order
To update the order information, such as the payment amount or line items, send an update order request. For more information, see Update an Order.
Save Order
To save the customer's payment credentials in the order to make future check out experiences faster for the customer, send a save order request. For more information, see Save an Order.
Authorization
To authorize funds for a payment, send an authorization request. For more information, see Authorize a Payment.
Sale
To authorize and capture funds for a payment in the same request, send a sale request. For more information, see Process a Sale.