subscriptions

Subscriptions Management

Show subscription details

This sample request shows subscription details:

curl -v -X GET https://api.sandbox.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer Access-Token"

A successful request returns the HTTP 200 OK status code and a JSON response body.

{
  "id": "I-BW452GLLEP1G",
  "plan_id": "P-5ML4271244454362WXNWU5NQ",
  "start_time": "2019-04-10T07:00:00Z",
  "quantity": "20",
  "shipping_amount": {
    "currency_code": "USD",
    "value": "10.00"
  },
  "subscriber": {
    "shipping_address": {
      "name": {
        "full_name": "John Doe"
      },
      "address": {
        "address_line_1": "2211 N First Street",
        "address_line_2": "Building 17",
        "admin_area_2": "San Jose",
        "admin_area_1": "CA",
        "postal_code": "95131",
        "country_code": "US"
      }
    },
    "name": {
      "given_name": "John",
      "surname": "Doe"
    },
    "email_address": "customer@example.com"
  },
  "billing_info": {
    "outstanding_balance": {
      "currency_code": "USD",
      "value": "1.00"
    },
    "cycle_executions": [{
      "tenure_type": "TRIAL",
      "sequence": 1,
      "cycles_completed": 0,
      "cycles_remaining": 1
    }, {
      "tenure_type": "REGULAR",
      "sequence": 2,
      "cycles_completed": 0,
      "cycles_remaining": 12
    }],
    "last_payment": {
      "amount": {
        "currency_code": "USD",
        "value": "1.15"
      },
      "time": "2019-04-09T10:27:20Z"
    },
    "next_billing_time": "2019-04-10T10:00:00Z",
    "failed_payments_count": 0
  },
  "auto_renewal": true,
  "create_time": "2019-04-09T10:26:04Z",
  "update_time": "2019-04-09T10:27:27Z",
  "links": [{
    "href": "https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/cancel",
    "rel": "cancel",
    "method": "POST"
  }, {
    "href": "https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G",
    "rel": "edit",
    "method": "PATCH"
  }, {
    "href": "https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G",
    "rel": "self",
    "method": "GET"
  }, {
    "href": "https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/suspend",
    "rel": "suspend",
    "method": "POST"
  }, {
    "href": "https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/capture",
    "rel": "capture",
    "method": "POST"
  }]
}

Update subscription

This sample request updates a subscription:

curl -v -X PATCH https://api.sandbox.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Access-Token" \
-d '[
  {
    "op": "replace",
    "path": "/billing_info/outstanding_balance",
    "value": {
      "currency_code": "USD",
      "value": "50.00"
    }
  }
]'

You can update the following fields:

  • subscriber.shipping_address
  • shipping_amount
  • billing_info.outstanding_balance

A successful request returns the HTTP 204 No Content status code.

If subscription update succeeds, it triggers the BILLING.SUBSCRIPTION.UPDATED webhook.

Suspend subscription

This sample request suspends a subscription:

curl -v -X POST https://api.sandbox.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/suspend \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer Access-Token"

A successful request returns the HTTP 204 No Content status code with no JSON response body.

If subscription suspension succeeds, it triggers the BILLING.SUBSCRIPTION.SUSPENDED webhook.

Cancel subscription

This sample request cancels a subscription:

curl -v -X POST https://api.sandbox.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/cancel \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer Access-Token"

A successful request returns the HTTP 204 No Content status code with no JSON response body.

If subscription cancellation succeeds, it triggers the BILLING.SUBSCRIPTION.CANCELLED webhook.

Activate subscription

The sample request activates a subscription:

curl -v -X POST https://api.sandbox.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/activate \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer Access-Token"

A successful request returns the HTTP 204 No Content status code with no JSON response body.

If activate subscription succeeds, it triggers the BILLING.SUBSCRIPTION.ACTIVATED webhook.

Capture amount on subscription

This sample request captures any outstanding amount for a subscription:

Note: You can capture up to the maximum outstanding balance for only active or suspended subscriptions.

curl -v -X POST https://api.sandbox.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/capture \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer Access-Token"
 -d '{
   "note": "Charging as the balance reached the limit",
   "capture_type": "OUTSTANDING_BALANCE",
   "amount": {
     "value": "100",
     "currency_code": "USD"
   }
 }'

A successful request returns the HTTP 202 Accepted status code without a JSON response body and an idempotent request returns 200 OK with a JSON response body.

If the capture of the outstanding balance succeeds, it triggers the PAYMENT.SALE.COMPLETED webhook.

List transactions for a subscription

This sample request lists the transactions for a subscription:

By default, the response lists 150 transactions.

curl -v -X GET https://api.sandbox.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/transactions?start_time=2018-01-21T07:50:20.940Z&end_time=2018-08-21T07:50:20.940Z" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer Access-Token"

A successful request returns the HTTP 200 OK status code and a JSON response body.

{
    "id": "TRFGHNJKOIIOJKL",
    "status": "COMPLETED",
    "payer_email": "customer@example.com",
    "payer_name": {
        "given_name": "John",
        "surname": "Doe"
    },
    "amount_with_breakdown": {
        "gross_amount": {
            "currency_code": "USD",
            "value": "10.00"
        },
        "fee_amount": {
            "currency_code": "USD",
            "value": "1.00"
        },
        "net_amount": {
            "currency_code": "USD",
            "value": "9.00"
        }
    },
    "time": "2018-03-16T07:40:20.940Z"
}, {
    "id": "VDFG45345FFGS",
    "status": "COMPLETED",
    "payer_email": "customer2@example.com",
    "payer_name": {
        "given_name": "Johnny",
        "surname": "Cat"
    },
    "amount_with_breakdown": {
        "gross_amount": {
            "currency_code": "USD",
            "value": "15.00"
        },
        "fee_amount": {
            "currency_code": "USD",
            "value": "1.00"
        },
        "net_amount": {
            "currency_code": "USD",
            "value": "14.00"
        }
    },
    "time": "2018-08-21T07:50:20.940Z"
}],
"links": [{
    "href": "https://api.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/transactions?start_time=2018-01-21T07:50:20.940Z&end_time=2018-08-21T07:50:20.940Z",
    "rel": "self",
    "method": "GET"
}]

Revise subscription

You can upgrade or downgrade a subscription by changing the plan and/or quantity of the subscription. Changing from one plan to another is allowed only across plans within the same product.

For example, you can revise a subscription from a $10 basic plan to a $14 premium plan, or revise a five software licenses monthly subscription to 10 licenses per month.

Subscription revisions require the buyer's consent. If the buyer doesn't consent, they continue to be billed according to their current subscription. All successful revisions are effective in the next billing cycle.

Revise a subscription using the Subscriptions API

To revise a subscription for a plan in active status, call /subscriptions/{subscription_id}/revise. The buyer must consent to the subscription change to activate it.

curl -v -X POST https://api.sandbox.paypal.com/v1/billing/subscriptions/I-BW452GLLEP1G/revise \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Access-Token" \
-d '{
  "plan_id": "P-5ML4271244454362WXNWU5NQ",
  "shipping_amount": {
    "currency_code": "USD",
    "value": "10.00"
  },
  "shipping_address": {
    "name": {
      "full_name": "John Doe"
    },
    "address": {
      "address_line_1": "2211 N First Street",
      "address_line_2": "Building 17",
      "admin_area_2": "San Jose",
      "admin_area_1": "CA",
      "postal_code": "95131",
      "country_code": "US"
    }
  },
  "application_context": {
    "brand_name": "Video Streaming Service",
    "locale": "en-US",
    "shipping_preference": "SET_PROVIDED_ADDRESS",
    "payment_method": {
      "payer_selected": "PAYPAL",
      "payee_preferred": "IMMEDIATE_PAYMENT_REQUIRED"
    },
    "return_url": "https://example.com/returnUrl",
    "cancel_url": "https://example.com/cancelUrl"
  }
}'

A successful request returns the HTTP 200 OK status code and a JSON response body that shows subscription details.

{
  "plan_id": "P-5ML4271244454362WXNWU5NQ",
  "effective_time": "2018-11-01T00:00:00Z",
  "shipping_amount": {
    "currency_code": "USD",
    "value": "10.00"
  },
  "shipping_address": {
    "name": {
      "full_name": "John Doe"
    },
    "address": {
      "address_line_1": "2211 N First Street",
      "address_line_2": "Building 17",
      "admin_area_2": "San Jose",
      "admin_area_1": "CA",
      "postal_code": "95131",
      "country_code": "US"
    }
  },
  "links": [
    {
      "href": "https://www.paypal.com/webapps/billing/subscriptions?ba_token=BA-2M539689T3856352J",
      "rel": "approve",
      "method": "GET"
    }
  ]
}

If revising the subscription succeeds, it triggers the BILLING.SUBSCRIPTION.UPDATED webhook.

Feedback