> ## Documentation Index
> Fetch the complete documentation index at: https://docs.slm.m1amdocs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Enable Subscribers to Purchase a Subscription Using a PayPal Express Checkout Account

You can enable your subscribers to purchase a subscription using PayPal Express Checkout for payment. To enable this functionality, you must use the Subscribe APIs.

* **Use Case Number:** 2-2-03
* **Completed By:** Software Developer
* **Estimated Completion Time:** 1 day

## Basic Scenario

A subscriber purchases a subscription at the standard rate using PayPal Express Checkout for payment.

## Design Approach

1. Call the subscriptions create endpoint with the PayPal Express Checkout payment method.
2. Extract the redirect URL from the response.
3. Redirect the user to PayPal Express Checkout to authorize the subscription.
4. Upon success call the subscriptions endpoint to finalize the PayPal Express Checkout transaction.

<img src="https://mintcdn.com/amdocs-slm/ifa3y22T11JlqvtT/portal/vindiciaSubscribeAndNewRetain/subscribeUseCases/images/2203_payPalSubscriptionPurchase.png?fit=max&auto=format&n=ifa3y22T11JlqvtT&q=85&s=a9c13fe8998013575d5c41efcb26a42f" alt="" width="946" height="653" data-path="portal/vindiciaSubscribeAndNewRetain/subscribeUseCases/images/2203_payPalSubscriptionPurchase.png" />

For testing you can use a PayPal sandbox and set up a testing buyer and seller account (see [https://www.sandbox.paypal.com/](https://www.sandbox.paypal.com/)).

For additional developer information about PayPal, see: [https://developer.paypal.com](https://developer.paypal.com).

* **[Create a Subscription with Paypal Express Checkout Payment Method Using Subscribe APIs](../topics/2203_r_purchaseSubscriptionPayPal#)**

**Parent topic:**[Adding Additional Payment Methods](../topics/tp_additionalPaymentMethods)

## Create a Subscription with Paypal Express Checkout Payment Method Using Subscribe APIs

Establish a valid PayPal business account, authorize Vindicia to be a presenter on that account, and supply the required credentials to Vindicia. For implementation details, see [Using PayPal with Vindicia Subscribe](https://docs.vindicia.com/bundle/howTo/page/topics/r_usingPayPal.html).

To create a Subscription with Paypal Express Checkout as the Payment Method:

1. Capture the subscription information and begin the subscription create process by calling the subscriptions endpoint with the request JSON.

   For PayPal, the subscription create API call includes the PayPal payment method with the `return_url` (where to redirect the user after the PayPal credentials have been successfully captured), as well as a `cancel_url` (where to redirect the user in case of invalid PayPal credentials).

   ```

     "type": "PayPal",
       "paypal": {
         "return_url": "https://merchant.paypal.success.com",
         "cancel_url": "https://merchant.paypal.failure.com",
         "request_reference_id": true
      },
   ```

   Subscribe sends a redirection URL in the response to the API call. You then redirect the user using that URL to enable the user to login to PayPal and authorize the subscription. If the login is successful, Subscribe responds with the URL you provided for `return_url` and the PayPal transaction VID is returned in the URL string. If unsuccessful Subscribe responds with the `cancel_url`.

   PayPal Return URL contains the `vindicia_vid`:

   `http://merchant.success.paypal.com/? **vindicia\_vid=8d3900ef6f5b899b8883576101066de4131c30d3**&vin_validate=1&token=EC-6UY81576RU8018237`

2. After the PayPal credentials have been captured successfully, call the subscriptions endpoint to capture the initial PayPal transaction and set up the subscription for recurring billing.

   **Note:**

   The initial transaction VID is passed to the subscriptions endpoint with the finish action.

   `https://api.staging.us-west.vindicia.com/subscriptions/8d3900ef6f5b899b8883576101066de4131c30d3/actions/finish`

   **Sample Code:**

   * POST to the subscriptions endpoint to create the PayPal subscription:

     `https://api.staging.us-west.vindicia.com/subscriptions?dryrun=0`

     [Request JSON Payload](https://github.com/Vindicia/CashBoxRESTCodeSamples/blob/master/SubE-2-003/SubE-2-003-SubCreate-Request.json)

     [Sample Response JSON Payload](https://github.com/Vindicia/CashBoxRESTCodeSamples/blob/master/SubE-2-003/SubE-2-003-SubCreate-Response.json)

     [PayPal Express Checkout Payment Method attributes](https://docs.vindicia.com/bundle/Subscribe_REST_API_Guide/page/topics/PayPal_Attributes.html)

   * POST to the subscriptions endpoint to capture the initial transaction and authorize recurring billing with PayPal.

     `https://api.staging.us-west.vindicia.com/subscriptions/8d3900ef6f5b899b8883576101066de4131c30d3/actions/finish`

     [Postman Collection](https://github.com/Vindicia/CashBoxRESTCodeSamples/blob/master/SubE-2-003/SubE-2-003.postman_collection.json)

* A proper Subscription with Account and Payment Method objects are created in Subscribe.
* The initial Transaction is generated if applicable, including any applicable taxation.
* Future billings are correctly predicted.
* The Account has been granted appropriate Entitlements.

**Parent topic:**[Enable Subscribers to Purchase a Subscription Using a PayPal Express Checkout Account](../topics/2203_r_purchaseSubscriptionPayPal#)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.