> ## 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 With a Credit Card

You can enable subscribers to purchase a Subscription offer using a credit card for payment. To support this functionality, you must use the Subscribe APIs.

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

## Basic Scenario

A new subscriber purchases a Subscription at the standard rate using a credit card for payment. The Subscription does not include a free trial period.

## Design Approach

To allow subscribers to securely enter credit card information into Subscribe, you must use Subscribe Payment Method Tokenization (PMT). For more information about using PMT, please refer to [Payment Method Tokenization](https://docs.vindicia.com/bundle/SOAP-Programming-guide/page/topics/ProgGuide_PMT.html) in the Subscribe Programming Guide.

As shown in the following diagram, after the Credit Card Payment method is active in Subscribe, your storefront can reference the card and Account IDs when creating the Subscription. This attaches the new payment method to the subscriber's Account and Subscription in Subscribe.

<img src="https://mintcdn.com/amdocs-slm/ifa3y22T11JlqvtT/portal/vindiciaSubscribeAndNewRetain/subscribeUseCases/images/2202_subscriptionPurchaseFlow.png?fit=max&auto=format&n=ifa3y22T11JlqvtT&q=85&s=a760fb6545c8c93ba045619e088dd3ea" alt="" width="830" height="522" data-path="portal/vindiciaSubscribeAndNewRetain/subscribeUseCases/images/2202_subscriptionPurchaseFlow.png" />

* **[Initiate Payment Method Tokenization Using Subscribe APIs](../topics/2202_r_allowCustomersPurchase#)**

**Parent topic:**[Basic Subscription Setup](../topics/r_basicSubscriptionSetup)

## Initiate Payment Method Tokenization Using Subscribe APIs

* Set up an account with your payment processor of choice.
* Ensure Vindicia has been authorized as a presenter on the payment processor account.

1. [Use REST PMT](https://docs.vindicia.com/bundle/SOAP-Programming-guide/page/topics/Setting_up_Payment_Metho.html) to tokenize the card in Subscribe. This has the effect of vaulting the card without your server ever having to save or store the PCI components of the card number (primary account number \[PAN]), expiration date, or card verification number \[CVN]).

2. If you have a requirement to calculate and show taxes or campaign discounts before the subscriber commits to the purchase, you must make two calls to the subscription API. It is optional to use `dryrun` for this purpose as described here, but is very common among merchants.

   The first call uses the `dryrun` option that serves as a quote, which causes Subscribe to calculate taxes and discounts, and return them in the call response, but does not save the subscription, and no charges are sent to the processor. Since the subscription is not saved in this case, you cannot fetch it after the `dryrun` call.

   * To add the `dryrun` option to the POST, use the following sample code:

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

   * The second call does not set `dryrun`, and creates the subscription in Subscribe and sends any resulting billing charges to the processor, which will charge the subscriber's payment method.

3. If you are not using `dryrun` as described above, you can either set `dryrun` to `0` explicitly, or omit the option from the POST, as follows:

   `POST https://api.staging.us-west.vindicia.com/subscriptions`

   To initiate a dry run or create the subscription, you must include the following in the POST call at a minimum.

   | Name | Value |
   | - | - |
   | subscription: id | Unique ID for this subscription. |
   | account: id | ID for the account that this subscription will be attached to. |
   | account: payment\_method : id | ID for the payment method which was returned from the PMT tokenization process.  |
   | billing\_plan: id | ID for the billing plan that this subscription will use. |
   | items | Array of product objects for each product being purchased as part of this subscription.   |
   | items: product: id | ID for the product defined in the product catalog in Subscribe. |
   | policy | The policy object incorporates fraud screening and authorization directives as indicated below. |
   | policy:ignore\_avs\_policy | Indicates whether Subscribe cancels this autobill if the initial authorization shows a `No Match` for AVS validation. Recommended value is `0` for US and CA addresses. |
   | policy:ignore\_cvn\_policy | Indicates whether Subscribe cancels this autobill (subscription) if the initial authorization shows a `No Match` for CVN validation. Recommended value is `0`. |
   | policy:immediate\_auth\_failure\_policy | Indicates whether to create the autobill (subscription) if the initial authorization is declined by the processor.  Recommended value is `doNotSaveAutoBill.` |
   | policy:validate\_for\_future\_payment | Indicates whether Subscribe should send an auth request to the processor if there is no immediate billing. Recommended value is `1` so that Subscribe validates when the billing plan includes a free trial period. |

   **Sample Code**

   For examples of subscription related REST calls, see: [Github REST examples for subscription](https://github.com/Vindicia/CashBoxRESTCodeSamples/tree/master/Autobill).

   The following is an example of the JSON REST payload used to create the subscription:

   `POST https://api.staging.us-west.vindicia.com/subscriptions`

   ```

   {
      "object": "Subscription",
      "id": "rmmtest_ab_20190219_001",
      "account": {
         "object": "Account",
         "id": "rmmtest_20181204_001"
      },
      "billing_plan": {
         "object": "BillingPlan",
         "id": "monthly_noprice"
      },
      "payment_method": {
         "object": "PaymentMethod",
         "id": "pm-rmmtest_20181204_001"
      },
      "description": "dryrun Testing AB rmmtest_ab_20190219_001",
      "currency" : "USD",
      "items": [
         {
            "object": "SubscriptionItem",
            "id": "MyItemID_RMMTEST002",
            "campaign_code": "10P",
            "product": {
               "object": "Product",
               "id": "RMMTEST002"
            }
         }
      ],
      "minimum_commitment": 0,
      "policy": {
         "ignore_cvn_policy": 1,
         "ignore_avs_policy": 1,
         "min_chargeback_probability": 100,
         "immediate_auth_failure_policy": "doNotSaveAutoBill",
         "validate_for_future_payment": 0
      }
   }
   ```

* A proper Subscription with Account and PaymentMethod 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 With a Credit Card](../topics/2202_r_allowCustomersPurchase#)


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