Initiate future transactions

DocsCurrent

Last updated: Sept 16th, 5:47pm

Website Payments Pro merchants can initiate future transactions using a transaction ID

Use your payer's original transaction ID to charge them later with reference transactions. A reference transaction is a transaction you initiate through an established contract with the payer and from which you can derive subsequent payments.

Know before you code

Required
Get Started

This server-side integration uses Orders REST API. To complete this integration, you require:

Reference transactions are also available if you have previously integrated with the DoReferenceTransaction  NVP or SOAP API operation.

Optional
Explore PayPal APIs with Postman

Use Postman to explore and test PayPal APIs. Learn more in our Postman guide

How it works

  1. The payer generates a transaction ID when they purchase an item on your site.
  2. The payer agrees to a reference transaction.
  3. Use the transaction ID in future reference transactions using the same payment method.

Use cases

Use reference transactions to:

  • Save payers' card details for a future payer-initiated transaction.
  • Initiate transactions to charge the payment method based on a previously agreed contract.
1

Create an order

Provide an order ID from a previous transaction or generate a new one.

API endpoint used: Create order

    1curl -v -X POST https://api-m.sandbox.paypal.com/v2/checkout/orders
    2-H "Content-Type: application/json"
    3-H "Authorization: Bearer Access-Token"
    4-H "PayPal-Auth-Assertion: PAYPAL-AUTH-ASSERTION"
    5-H "PayPal-Partner-Attribution-Id: BN-CODE"
    6-d '{
    7 "intent": "CAPTURE",
    8 "purchase_units": [
    9 {
    10 "amount": {
    11 "currency_code": "USD",
    12 "value": "100.00"
    13 }
    14 }
    15 ]
    16}'

    Modify the code

    After you copy the code in the sample request, modify the following:

    Step result

    A successful request results in the following:

    • A return status code of HTTP 201 Created.
    • A JSON response body that contains an order ID, for example, 5O190127TN364715T.
      1{
      2 "id": "5O190127TN364715T",
      3 "status": "CREATED",
      4 "links": [
      5 {
      6 "href": "https://api-m.paypal.com/v2/checkout/orders/5O190127TN364715T",
      7 "rel": "self",
      8 "method": "GET"
      9 },
      10 {
      11 "href": "https://www.paypal.com/checkoutnow?token=5O190127TN364715T",
      12 "rel": "approve",
      13 "method": "GET"
      14 },
      15 {
      16 "href": "https://api-m.paypal.com/v2/checkout/orders/5O190127TN364715T",
      17 "rel": "update",
      18 "method": "PATCH"
      19 },
      20 {
      21 "href": "https://api-m.paypal.com/v2/checkout/orders/5O190127TN364715T/capture",
      22 "rel": "capture",
      23 "method": "POST"
      24 }
      25 ]
      26 }
      2

      Authorize payment

      Authorize payment for an order using a previous transaction ID and order ID. Ensure you have an original transaction ID from a previous transaction made by the same buyer.

      API endpoint used: Authorize payment for order

      1. PayPal transaction ID
      2. PNREF
      1curl -X POST https://api-m.sandbox.paypal.com/v2/checkout/orders/5O190127TN364715T/authorize
      2 -H 'Content-Type: application/json'
      3 -H 'Authorization: Bearer Access-Token'
      4 -H 'Accept-Language: en_US'
      5 -H 'PayPal-Auth-Assertion: PAYPAL-AUTH-ASSERTION'
      6 -H 'PayPal-Partner-Attribution-Id: BN-CODE'
      7 -d '{
      8 "payment_source": {
      9 "token": {
      10 "id": "67N9717781765035V",
      11 "type": "PAYPAL_TRANSACTION_ID"
      12 }
      13 }
      14 }'

      Modify the code

      After you copy the code in the sample request, modify the following:

      • Access-Token: Your access token.
      • PAYPAL-AUTH-ASSERTION: Your PayPal-Auth-Assertion token.
      • BN-CODE: Your PayPal Attribution ID to receive revenue attribution. To find your BN code, see Code and Credential Reference.
      • Order ID: In the URI for the API call, replace the sample ID with your order ID. In the example, the order ID is 5O190127TN364715T.
      • payment_source: Replace the payment_source sample ID with your transaction ID. In the example, the transaction ID is 67N9717781765035V.

      Step result

      A successful request results in the following:

      • A return status code of HTTP 201 Created.
      • A JSON response body that contains the order ID and a status of COMPLETED.
      3

      Capture payment

      Capture payment for an order using a previous transaction ID and an order ID.

      API endpoint used: Capture payment for order

      1. PayPal transaction ID
      2. PNREF
      1curl -X POST https://api-m.sandbox.paypal.com/v2/checkout/orders/5O190127TN364715T/capture
      2 -H 'Content-Type: application/json'
      3 -H 'PayPal-Request-ID: 7b92603e-77ed-4896-8e78-5dea2050476a'
      4 -H 'Authorization: Bearer Access-Token'
      5 -H 'Accept-Language: en_US'
      6 -H 'PayPal-Auth-Assertion: PAYPAL-AUTH-ASSERTION'
      7 -H 'PayPal-Partner-Attribution-Id: BN-CODE'
      8 -d '{
      9 "payment_source": {
      10 "token": {
      11 "id": "67N9717781765035V",
      12 "type": "PAYPAL_TRANSACTION_ID"
      13 }
      14 }
      15 }'

      Modify the code

      After you copy the code in the sample request, modify the following:

      • Access-Token: Your access token.
      • PAYPAL-AUTH-ASSERTION: Your PayPal-Auth-Assertion token.
      • BN-CODE: Your PayPal Attribution ID to receive revenue attribution. To find your BN code, see Code and Credential Reference.
      • Order ID: In the URI for the API call, replace the sample ID with your order ID. In the example, the order ID is 5O190127TN364715T.
      • PayPal-Request-ID: Replace the sample ID with a unique ID you generate. This ID helps prevent duplicate authorizations if the API call gets disrupted. For more information, see API idempotency.
      • payment_source: Replace the payment_source sample ID with your transaction ID. In the example, the transaction ID is 67N9717781765035V.

      Step result

      A successful request results in the following:

      • A return status code of HTTP 201 Created.
      • A JSON response body that contains the order ID and a status of COMPLETED.

      We use cookies to improve your experience on our site. May we use marketing cookies to show you personalized ads? Manage all cookies