API Examples

These are just a few examples. Check out the API documentation for all capabilities.


Single Transaction

RevCent creates everything in one transaction.

All product sales, subscriptions, trials, shipping, etc. are created and provided immediately. No need for web hooks or endpoints.

Example

A customer makes a purchase that contains three products. Product 1 is a one time product. Product 2 is a subscription product. Product 3 is a trial product.

You send the sale request to RevCent for the three products. RevCent processes the transaction and at the same time creates the subscription for product 2 and the trial for product 3.

The API response will contain the product sales for each product, as well as the subscription ID for product 2 and the trial ID for product 3.

The entire process takes seconds. You processed the sale and have all of the related items available.

    {
       "request": {
         "type": "sale",
         "method": "create",
         "gateway": "Stripe",
         "customer_id": "my_customer_id",
         "product": [
           {
             "id": "My Trial Product"
           },
           {
             "id": "My Subscription Product"
           },
           {
             "id": "My One Time Product"
           }
         ]
       }
     }
                
    // Redacted for brevity

      "product_sale_created": [
        "5rwrazKL8LtMvGKPbbgM",
        "8rdrjzq8E8t6YQvJBB7m",
        "l4z4bg9J6JT7oQlwggW9"
      ],
      "subscription_created": [
        "d9k9KWLGBGi6L0zYQQgl"
      ],
      "trial_created": [
        "ajWj9Na0M0F5aY1Lllgp"
      ]

    //
                

Save The Sale

Don't lose a sale due to declines.

Payment profiles within RevCent allow you to set rules to achieve a sale.

If a sale is declined, process the sale or partial transaction later.

Example

You attempt to charge a customer, but the transaction gets declined.

Instead of killing the sale, you may wish to try the transaction again at another gateway or at a lower price.

If the transaction succeeds at a lower price we record the difference and save as a partial salvage transaction.

If the entire process fails, we still save the customer and card. We also create a full salvage transaction so you can try the entire sale later.

    {
       "request": {
         "type": "salvage_transaction",
         "method": "process",
         "salvage_transaction_id": "the_salvage_transaction_id",
         "gateway": "Braintree"
       }
    }
                
      // Redacted for brevity

        "amount": 13.31,
        "code": 1,
        "customer_id": "l4zkPvjk4pc2Jo98mlv5",
        "gateway": "Braintree",
        "result": "Approved",
        "salvage_transaction_id": "P6okvJN7oZUWp4n58Gz5",
        "transaction_id": "rmk1vj64oLFP60zoA29R"

      //
                

Retrieve in Seconds

Retrieve up to date information on trials, subscriptions, shipping and more in seconds.

Display the information to your customers and implement within your app without latency issues.

Example

You have an app that restricts access based upon subscription status. If a customers' subscription is overdue, you refuse access to your particular service.

Create an API account with retrieve only permissions. When the customer logs in, you retrieve the customers' subscription.

In the API response you will see whether the subscription is overdue, when the last bill occurred, the next bill date and more.

Use the API response to restrict access or to simply let the customer know their next bill date.

    {
       "request": {
         "type": "subscription",
         "method": "retrieve",
         "subscription_id": "the_subscription_id"
       }
    }
                
      // Redacted for brevity

        "active": true,
        "amount": 29.99,
        "billing": {
          "next_renewal_unix": 1501039835,
          "last_renewal_amount": 29.99,
          "last_renewal_id": "5rwngZo7ywh8YvpdrEkd",
          "last_renewal_unix": 1500953435
        },
        "customer": {
          "internal_id": "cus_5299",
          "id": "YaYZ6l1ZzQuRyZ0ojlap"
        },
        "is_cancelled": false,
        "is_overdue": false,
        "is_suspended": false,
        "is_void": false,
        "status": "Active",
        "subscription_id": "nbK6XoLNrViPo0Lvl2kN",
        "subscription_profile": {
          "id": "BvOBj5nmloUXbmw1R19Y",
          "name": "Daily",
          "description": "",
          "frequency_unit": "days",
          "frequency_value": 1,
          "occurrences": "indefinite",
          "occurrences_value": null
        }

      //
                

Metadata Within

We integrated metadata within the sale, not just the entire sale.

Store metadata for an entire sale, an individual product, a shipping entry or specific tax.

Example

You want to track an affiliate ID for a sale and the specific version of a software product the affiliate sold.

When creating the sale, include the affiliate ID in the sale metadata, and the version in the product metadata.

This metadata will be stored and can be used to analyze data on versions of software sold and linked to specific affiliates.

    {
       "request": {
         "type": "sale",
         "method": "create",
         "gateway": "Stripe",
         "customer_id": "my_customer_id",
         "product": [
           {
             "id": "My Product",
             "metadata": [
               {
                 "name": "version",
                 "value": "1.4"
               }
             ]
           }
         ],
         "metadata": [
           {
             "name": "affiliate_id",
             "value": "1234567890"
           }
         ]
       }
     }