Create a Payment Resource

Create a payment resource to render the required payment wall.

Important: You cannot send any user specific data in this initial payment call as the payment resource is not an actual payment. After you configure your payment button, use the PATCH call to update your payment resource with customer data to complete the payment.

Along with your access token, pass intent and payment_method as parameters in the request body to /v1/payments/payment.

Parameter Value
intent sale
payment_method paypal

Sample request

curl -v https://api.sandbox.paypal.com/v1/payments/payment \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {accessToken}' \
{
  "intent": "sale",
  "payer": {
    "payment_method": "paypal"
  },
  "transactions": [{
    "amount": {
      "total": "21.50",
      "currency": "EUR",
      "details": {
        "subtotal": "15.00",
        "tax": "2.00",
        "shipping": "2.50",
        "handling_fee": "1.00",
        "shipping_discount": "-1.00",
        "insurance": "2.00"
      }
    },

    "description": "This is the payment transaction description.",
    "custom": "This is a hidden value",
    "invoice_number": "unique_invoice_number",

    "soft_descriptor": "your order description",
    "item_list": {
      "items": [{
          "name": "Item 1",
          "description": "add description here",
          "quantity": "2",
          "price": "10.00",
          "sku": "1",
          "currency": "EUR"
        },
        {
          "name": "Voucher",
          "description": "discount on your order",
          "quantity": "1",
          "price": "-5.00",
          "sku": "vouch1",
          "currency": "EUR"
        }
      ]
    }
  }],
  "note_to_payer": "Contact us for any questions on your order.",
  "redirect_urls": {
    "return_url": "http://example.com/success",
    "cancel_url": "http://example.com/cancel"
  }
}

Note: To avoid rounding errors, do not submit value-added tax amounts on a line-item basis. You can submit calculated tax amounts for an entire shopping basket in amount objects. The item amounts exclude tax. In a business to consumer (B2C) scenario that include taxes, do not submit taxes to PayPal.

Sample response

{
    "id": "PAY-0W5897135C7963359LNZPE4A",
    "intent": "sale",
    "state": "created",
    "payer": {
        "payment_method": "paypal"
    },
    "transactions": [
        {
            "amount": {
                "total": "21.50",
                "currency": "EUR",
                "details": {
                    "subtotal": "15.00",
                    "tax": "2.00",
                    "shipping": "2.50",
                    "insurance": "2.00",
                    "handling_fee": "1.00",
                    "shipping_discount": "-1.00"
                }
            },
            "description": "This is the payment transaction description.",
            "custom": "This is a hidden value",
            "invoice_number": "unique_invoice_number",
            "soft_descriptor": "your order description",
            "item_list": {
                "items": [
                    {
                        "name": "Item 1",
                        "sku": "1",
                        "description": "add description here",
                        "price": "10.00",
                        "currency": "EUR",
                        "quantity": 2
                    },
                    {
                        "name": "Voucher",
                        "sku": "vouch1",
                        "description": "discount on your order",
                        "price": "-5.00",
                        "currency": "EUR",
                        "quantity": 1
                    }
                ]
            },
            "related_resources": []
        }
    ],
    "note_to_payer": "Contact us for any questions on your order.",
    "create_time": "2018-08-14T15:17:03Z",
    "links": [
        {
            "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-0W5897135C7963359LNZPE4A",
            "rel": "self",
            "method": "GET"
        },
        {
            "href": "https://api.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-8AT72418NV353182U",
            "rel": "approval_url",
            "method": "REDIRECT"
        },
        {
            "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAY-0W5897135C7963359LNZPE4A/execute",
            "rel": "execute",
            "method": "POST"
        }
    ]
}

When you integrate a payment wall, you need the approval_url link from the HATEOAS links in the previous response.

Next

Integrate a payment wall.