Purchase API Guide

Overview

This guide shows you how to retrieve the full details of a purchase using the Get Purchase endpoint.

Use case

Cloudify sells cloud backup subscriptions through Cleverbridge. A customer contacts Cloudify support because they can't find their license key.

  1. The support agent enters the purchase ID in Cloudify's internal support tool.
  2. The support tool sends a request to the Get Purchase endpoint.
  3. Cleverbridge returns the purchase details, including the purchase status, the license key, and the subscription status.
  4. The support tool shows the license key and the subscription status to the agent.

Result

The agent sends the license key to the customer without a manual lookup.

Implement Get Purchase endpoint

Before you start

To retrieve a purchase, send one GET request with the purchase ID. The response contains the purchase details as a JSON string, which you parse a second time.

Before you start

Make sure that:

  • Your Cleverbridge user has the API User privilege. For more information, see Authentication.
  • You replace YOUR_BASE64_ENCODED_CREDENTIALS with your base64-encoded username:password.
  • You have the ID of an existing purchase. Cleverbridge sends the purchase ID in its purchase notifications, for example PaidOrderNotification.
  • You test with a test user. The endpoint returns production data. To get a test user, contact your Client Experience Manager.
  • You run the Node.js sample on Node.js 18 or later and the Java sample on Java 11 or later. These versions include the built-in HTTP clients that the samples use.

The endpoint is read-only. It doesn't change the purchase or send notifications.

Parameters

The request uses these query parameters:

ParameterTypeRequiredExample
purchaseIdstringYes115515453
reimbursementIdstringNo1

Request

Send a GET request to the following endpoint:

GET https://rest.cleverbridge.com/purchase/getpurchase/v2?purchaseId={purchaseId}&reimbursementId={reimbursementId}

The following samples retrieve purchase 115515453 as a paid order notification:

curl --request GET \
  --url 'https://rest.cleverbridge.com/purchase/getpurchase/v2?purchaseId=115515453&reimbursementId=-1' \
  --header 'Accept: application/json' \
  --header 'Authorization: Basic YOUR_BASE64_ENCODED_CREDENTIALS'
import urllib.parse
import urllib.request

params = urllib.parse.urlencode({"purchaseId": "115515453", "reimbursementId": "-1"})
url = f"https://rest.cleverbridge.com/purchase/getpurchase/v2?{params}"

request = urllib.request.Request(
    url,
    method="GET",
    headers={
        "Accept": "application/json",
        "Authorization": "Basic YOUR_BASE64_ENCODED_CREDENTIALS",
    },
)

with urllib.request.urlopen(request) as response:
    print(response.status)
    print(response.read().decode("utf-8"))
const params = new URLSearchParams({ purchaseId: "115515453", reimbursementId: "-1" });
const url = `https://rest.cleverbridge.com/purchase/getpurchase/v2?${params}`;

async function getPurchase() {
  const response = await fetch(url, {
    method: "GET",
    headers: {
      Accept: "application/json",
      Authorization: "Basic YOUR_BASE64_ENCODED_CREDENTIALS",
    },
  });

  console.log(response.status);
  console.log(await response.text());
}

getPurchase();
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class GetPurchase {
    public static void main(String[] args) throws Exception {
        String url = "https://rest.cleverbridge.com/purchase/getpurchase/v2"
                + "?purchaseId=115515453&reimbursementId=-1";

        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Accept", "application/json")
                .header("Authorization", "Basic YOUR_BASE64_ENCODED_CREDENTIALS")
                .GET()
                .build();

        HttpResponse<String> response = HttpClient.newHttpClient()
                .send(request, HttpResponse.BodyHandlers.ofString());

        System.out.println(response.statusCode());
        System.out.println(response.body());
    }
}

GET /purchase/getpurchase/v2?purchaseId={PurchaseID}

The Get Purchase endpoint retrieves all information about a particular purchase. When you make a call, you get a PurchaseNotification string that contains general purchase information, purchase item information, and other customized data (for example, x-parameters and license keys).

Response

A successful call returns HTTP status 200 OK. The following example is shortened:

Example response

{
  "PurchaseNotification": "{\n\t\"meta\": {\n\t\t\"type\": \"PaidOrderNotification\",\n\t\t\"date\": \"2019-03-19T14:47:34.857671\",\n\t\t\"schemaUrl\": \"https://www.cleverbridge.com/JsonNotificationSchemas/PaidOrderNotification\"\n\t},\n\t\"purchaseId\": 168377690,\n\t\"status\": \"Paid\",\n\t\"statusId\": \"PAY\",\n\t\"billingContact\": {\n\t\t\"language\": \"English\",\n\t\t\"languageId\": \"en\",\n\t\t\"locale\": \"en-US\",\n\t\t\"company\": \"Your Company Name\",\n\t\t\"firstname\": \"John\",\n\t\t\"lastname\": \"Doe\",\n\t\t\"companyRomanized\": \"Your Company Name\",\n\t\t\"firstnameRomanized\": \"John\",\n\t\t\"lastnameRomanized\": \"Doe\",\n\t\t\"country\": \"Germany\",\n\t\t\"countryId\": \"DE\",\n\t\t\"email\": \"[email protected]\"\n\t},\n\t\"deliveryContact\": {\n\t\t\"language\": \"English\",\n\t\t\"languageId\": \"en\",\n\t\t\"locale\": \"en-US\",\n\t\t\"company\": \"Your Company Name\",\n\t\t\"firstname\": \"John\",\n\t\t\"lastname\": \"Doe\",\n\t\t\"companyRomanized\": \"Your Company Name\",\n\t\t\"firstnameRomanized\": \"John\",\n\t\t\"lastnameRomanized\": \"Doe\",\n\t\t\"country\": \"Germany\",\n\t\t\"countryId\": \"DE\",\n\t\t\"email\": \"[email protected]\"\n\t},\n\t\"licenseeContact\": {\n\t\t\"language\": \"English\",\n\t\t\"languageId\": \"en\",\n\t\t\"locale\": \"en-US\",\n\t\t\"company\": \"Your Company Name\",\n\t\t\"firstname\": \"John\",\n\t\t\"lastname\": \"Doe\",\n\t\t\"companyRomanized\": \"Your Company Name\",\n\t\t\"firstnameRomanized\": \"John\",\n\t\t\"lastnameRomanized\": \"Doe\",\n\t\t\"country\": \"Germany\",\n\t\t\"countryId\": \"DE\",\n\t\t\"email\": \"[email protected]\"\n\t},\n\t\"paymentInfo\": {\n\t\t\"currency\": \"Euro\",\n\t\t\"currencyId\": \"EUR\",\n\t\t\"paymentType\": \"Visa\",\n\t\t\"paymentTypeId\": \"CCA_VIS\",\n\t\t\"isPurchaseOrder\": false,\n\t\t\"cardLastFourDigits\": \"142T\",\n\t\t\"cardExpirationDate\": {\n\t\t\t\"month\": 3,\n\t\t\t\"year\": 2023\n\t\t}\n\t},\n\t\"creationTime\": \"2019-03-19T14:47:34.360177\",\n\t\"paymentArriveTime\": \"2019-03-19T14:47:34.857671\",\n\t\"lastModificationTime\": \"2019-03-19T14:47:35.084112\",\n\t\"subscriptionRevenueCategoryId\": \"Signup\",\n\t\"remoteAddress\": \"89.1.3.0\",\n\t\"httpUserAgent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36\",\n\t\"httpEntryUrl\": \"https://shop.yourcustomdomain.com/1584/?scope=checkout\\u0026cart=219783,219788,%20\\u0026x-source=christmas%20newsletter\\u0026x-reference=A5434A\",\n\t\"httpReferer\": \"https://shop.yourcustomdomain.com/1584/?scope=checkout\\u0026cart=219783,219788,%20\\u0026x-source=christmas%20newsletter\\u0026x-reference=A5434A\",\n\t\"httpAcceptLanguage\": \"de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7\",\n\t\"internalCustomer\": \"UUID-YOUR-UNIQUE-ID-1234-5678\",\n\t\"customerConfirmationPageUrl\": \"https://shop.yourcustomdomain.com/1584/p/168377690-PshC04s31zTWdIFn1234\",\n\t\"customerPdfDocumentUrl\": \"https://shop.yourcustomdomain.com/invoice/4U719A24QWH5ER7N1234/168377690.pdf\",\n\t\"merchantOfRecord\": \"AG\",\n\t\"items\": [{\n\t\t\"runningNumber\": 1,\n\t\t\"productId\": 219783,\n\t\t\"productName\": \"Film Now\",\n\t\t\"productNameExtension\": \"Film Now for 12 months\",\n\t\t\"yourProductId\": \"internal_id_219783\",\n\t\t\"yourProductName\": \"Film Now\",\n\t\t\"internalCategory\": \"Film\",\n\t\t\"clientId\": 1584,\n\t\t\"quantity\": 1,\n\t\t\"yourCurrency\": \"Euro\",\n\t\t\"yourCurrencyId\": \"EUR\",\n\t\t\"profitCalculation\": {\n\t\t\t\"grossRevenue\": 9.99,\n\t\t\t\"collectedVat\": 1.60,\n\t\t\t\"netRevenue\": 8.39,\n\t\t\t\"cbMarginPercentage\": 0.0,\n\t\t\t\"cbMarginFix\": 0.0,\n\t\t\t\"yourNetProfit\": 8.39,\n\t\t\t\"yourVat\": 1.60,\n\t\t\t\"yourGrossProfit\": 9.99\n\t\t},\n\t\t\"yourPrice\": {\n\t\t\t\"productSinglePrice\": {\n\t\t\t\t\"netPrice\": 8.39,\n\t\t\t\t\"vatPrice\": 1.60,\n\t\t\t\t\"grossPrice\": 9.99,\n\t\t\t\t\"vatPercentage\": 19.0\n\t\t\t},\n\t\t\t\"productTotalPrice\": {\n\t\t\t\t\"netPrice\": 8.39,\n\t\t\t\t\"vatPrice\": 1.60,\n\t\t\t\t\"grossPrice\": 9.99,\n\t\t\t\t\"vatPercentage\": 19.0\n\t\t\t},\n\t\t\t\"totalSinglePrice\": {\n\t\t\t\t\"netPrice\": 8.39,\n\t\t\t\t\"vatPrice\": 1.60,\n\t\t\t\t\"grossPrice\": 9.99,\n\t\t\t\t\"vatPercentage\": 19.0\n\t\t\t},\n\t\t\t\"totalTotalPrice\": {\n\t\t\t\t\"netPrice\": 8.39,\n\t\t\t\t\"vatPrice\": 1.60,\n\t\t\t\t\"grossPrice\": 9.99,\n\t\t\t\t\"vatPercentage\": 19.0\n\t\t\t}\n\t\t},\n\t\t\"customerPrice\": {\n\t\t\t\"productSinglePrice\": {\n\t\t\t\t\"netPrice\": 8.39,\n\t\t\t\t\"vatPrice\": 1.60,\n\t\t\t\t\"grossPrice\": 9.99,\n\t\t\t\t\"vatPercentage\": 19.0\n\t\t\t},\n\t\t\t\"productTotalPrice\": {\n\t\t\t\t\"netPrice\": 8.39,\n\t\t\t\t\"vatPrice\": 1.60,\n\t\t\t\t\"grossPrice\": 9.99,\n\t\t\t\t\"vatPercentage\": 19.0\n\t\t\t},\n\t\t\t\"totalSinglePrice\": {\n\t\t\t\t\"netPrice\": 8.39,\n\t\t\t\t\"vatPrice\": 1.60,\n\t\t\t\t\"grossPrice\": 9.99,\n\t\t\t\t\"vatPercentage\": 19.0\n\t\t\t},\n\t\t\t\"totalTotalPrice\": {\n\t\t\t\t\"netPrice\": 8.39,\n\t\t\t\t\"vatPrice\": 1.60,\n\t\t\t\t\"grossPrice\": 9.99,\n\t\t\t\t\"vatPercentage\": 19.0\n\t\t\t}\n\t\t},\n\t\t\"deliveries\": [{\n\t\t\t\"key\": {\n\t\t\t\t\"key\": \"your-key-13455-xxx\",\n\t\t\t\t\"keyRaw\": \"your-key-13455-xxx\",\n\t\t\t\t\"deliveryType\": \"cleverbridge delivers key\",\n\t\t\t\t\"deliveryTypeId\": \"cleverbridgeDeliversKey\"\n\t\t\t}\n\t\t}],\n\t\t\"recurringBilling\": {\n\t\t\t\"subscriptionId\": \"S29327383\",\n\t\t\t\"subscriptionItemRunningNo\": 1,\n\t\t\t\"subscriptionEventtypeId\": \"new\",\n\t\t\t\"originalPurchaseId\": 168377690,\n\t\t\t\"originalPurchaseItemRunningNumber\": 1,\n\t\t\t\"intervalNumber\": 0,\n\t\t\t\"intervalLengthInDays\": 0,\n\t\t\t\"intervalLengthInMonths\": 12,\n\t\t\t\"gracePeriodDays\": 15,\n\t\t\t\"statusId\": \"ACT\",\n\t\t\t\"status\": \"Active\",\n\t\t\t\"itemStatusId\": \"ACT\",\n\t\t\t\"itemStatus\": \"Active\",\n\t\t\t\"nextBillingDate\": \"2020-03-19T14:47:34.857671\",\n\t\t\t\"cancellationUrl\": \"https://shop.yourcustomdomain.com/1584/crb/168377690-PshC04s31zTZdIRn1234-1\",\n\t\t\t\"changePaymentSubscriptionUrl\": \"https://shop.yourcustomdomain.com/1584/scp/S29327383-05RlfQwTnDRP1234\",\n\t\t\t\"nextBillingProfit\": {\n\t\t\t\t\"grossRevenue\": 9.99,\n\t\t\t\t\"collectedVat\": 1.60,\n\t\t\t\t\"netRevenue\": 8.39,\n\t\t\t\t\"cbMarginPercentage\": 0.0,\n\t\t\t\t\"cbMarginFix\": 0.0,\n\t\t\t\t\"yourNetProfit\": 8.39,\n\t\t\t\t\"yourVat\": 1.60,\n\t\t\t\t\"yourGrossProfit\": 9.99\n\t\t\t},\n\t\t\t\"renewalType\": \"Automatic\"\n\t\t}\n\t},\n\t{\n\t\t\"runningNumber\": 2,\n\t\t\"productId\": 219788,\n\t\t\"productName\": \"New Tunes\",\n\t\t\"productNameExtension\": \"New Tunes\",\n\t\t\"yourProductId\": \"internal_id_219788\",\n\t\t\"yourProductName\": \"New Tunes\",\n\t\t\"clientId\": 1584,\n\t\t\"quantity\": 1,\n\t\t\"yourCurrency\": \"Euro\",\n\t\t\"yourCurrencyId\": \"EUR\",\n\t\t\"profitCalculation\": {\n\t\t\t\"grossRevenue\": 5.99,\n\t\t\t\"collectedVat\": 0.96,\n\t\t\t\"netRevenue\": 5.03,\n\t\t\t\"cbMarginPercentage\": 0.0,\n\t\t\t\"cbMarginFix\": 0.0,\n\t\t\t\"yourNetProfit\": 5.03,\n\t\t\t\"yourVat\": 0.96,\n\t\t\t\"yourGrossProfit\": 5.99\n\t\t},\n\t\t\"yourPrice\": {\n\t\t\t\"productSinglePrice\": {\n\t\t\t\t\"netPrice\": 5.03,\n\t\t\t\t\"vatPrice\": 0.96,\n\t\t\t\t\"grossPrice\": 5.99,\n\t\t\t\t\"vatPercentage\": 19.0\n\t\t\t},\n\t\t\t\"productTotalPrice\": {\n\t\t\t\t\"netPrice\": 5.03,\n\t\t\t\t\"vatPrice\": 0.96,\n\t\t\t\t\"grossPrice\": 5.99,\n\t\t\t\t\"vatPercentage\": 19.0\n\t\t\t},\n\t\t\t\"totalSinglePrice\": {\n\t\t\t\t\"netPrice\": 5.03,\n\t\t\t\t\"vatPrice\": 0.96,\n\t\t\t\t\"grossPrice\": 5.99,\n\t\t\t\t\"vatPercentage\": 19.0\n\t\t\t},\n\t\t\t\"totalTotalPrice\": {\n\t\t\t\t\"netPrice\": 5.03,\n\t\t\t\t\"vatPrice\": 0.96,\n\t\t\t\t\"grossPrice\": 5.99,\n\t\t\t\t\"vatPercentage\": 19.0\n\t\t\t}\n\t\t},\n\t\t\"customerPrice\": {\n\t\t\t\"productSinglePrice\": {\n\t\t\t\t\"netPrice\": 5.03,\n\t\t\t\t\"vatPrice\": 0.96,\n\t\t\t\t\"grossPrice\": 5.99,\n\t\t\t\t\"vatPercentage\": 19.0\n\t\t\t},\n\t\t\t\"productTotalPrice\": {\n\t\t\t\t\"netPrice\": 5.03,\n\t\t\t\t\"vatPrice\": 0.96,\n\t\t\t\t\"grossPrice\": 5.99,\n\t\t\t\t\"vatPercentage\": 19.0\n\t\t\t},\n\t\t\t\"totalSinglePrice\": {\n\t\t\t\t\"netPrice\": 5.03,\n\t\t\t\t\"vatPrice\": 0.96,\n\t\t\t\t\"grossPrice\": 5.99,\n\t\t\t\t\"vatPercentage\": 19.0\n\t\t\t},\n\t\t\t\"totalTotalPrice\": {\n\t\t\t\t\"netPrice\": 5.03,\n\t\t\t\t\"vatPrice\": 0.96,\n\t\t\t\t\"grossPrice\": 5.99,\n\t\t\t\t\"vatPercentage\": 19.0\n\t\t\t}\n\t\t},\n\t\t\"deliveries\": [{\n\t\t\t\"service\": {\n\t\t\t\t\"deliveryType\": \"cleverbridge delivers trial version by download\",\n\t\t\t\t\"deliveryTypeId\": \"cleverbridgeLinksToTrialDownload\"\n\t\t\t}\n\t\t}]\n\t}],\n\t\"extraParameters\": {\n\t\t\"x-reference\": \"A5434A\",\n\t\t\"x-source\": \"christmas newsletter\"\n\t}\n}",
  "ResultMessage": "OK"
}

Response fields

FieldDescription
meta.typeThe notification type. It depends on the purchase status and on reimbursementId.
statusIdThe purchase status code, for example PAY for a paid purchase. For all codes, see Purchase Status.
items[].deliveries[].key.keyThe license key with the delivery text that the customer sees.
items[].deliveries[].key.keyRawThe license key only. Use this value in your systems.
items[].recurringBillingThe subscription data. This object appears only for subscription items.
extraParametersThe x-parameters of the purchase as key-value pairs.

For all fields, see Purchase Model.

Errors

If the purchase ID doesn't exist, the endpoint returns HTTP status 404 Not Found. Check the purchase ID and send the request again.

{
  "Id": null,
  "Message": "Not found",
  "Status": 404
}

If Cleverbridge can't process the request, the endpoint returns HTTP status 500 Internal Server Error. Send the request again later.

{
  "Id": null,
  "Message": "An error has occured processing your request.",
  "Status": 500
}

Status IDs

List of subscription statusIds and abbreviations

3-letter codeStatus
ACTActive
DEADeactivated
FINFinished
GRAGrace
HLDHold
NEWNew
HBCHandled by Client
WNOAwaiting New Order

Did this page help you?