# Creating External Purchases

**a.** This feature enables clients to integrate their login system, providing Conscent with only the user's unique user ID. Conscent will then optimize the user journey based on this information, enhancing the overall experience.

**b.** The client is responsible for managing the login and payment flow from their end, as Conscent does not have access to these details.

#### Steps to Enable External Purchase:

1. Navigate to global subscription settings on our dashboard \
   (**Visualise > Manage Subscriptions > Global Settings**)
2. Select ‘My Login’
3. Enter the redirect URL you want ConsCent to redirect the user to, along with the purchase token where you can handle the user’s purchase.

**Purchase Flow:**

<figure><img src="https://380225236-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcoDfVWiJBvgTq8DbifIH%2Fuploads%2FvwUlMBSqEiH9Z0BKuMKC%2FUntitled%20Diagram.drawio.png?alt=media&#x26;token=d921b947-016a-46bf-9e01-b2bd35187b21" alt=""><figcaption><p>Attached the screenshot for more clarity</p></figcaption></figure>

1. ConsCent redirects users from the <mark style="color:orange;">**Subscription Landing Page to your site**</mark> using the redirect URL set on the dashboard. The purchase token is passed as a query parameter during this redirection process.
2. Purchase information is transmitted to the client in the form of a JSON Web Token (JWT). Clients can easily extract and read purchase information from the JWT payload. The JWT is signed using the **RS256 algorithm** to ensure data integrity and authenticity.&#x20;

Additionally, clients can verify the **JWT using the public key provided by ConsCent.**

```
PUBLIC KEY:

-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDTRnZkcSXEZ/PUSlJDCXf1SHGS
GKTc1CaT6/BqgXO6aSjC3QVZ1WKzeKhfhksy6iNHld9w0BLTfgHTCzKuFzvfa1tH
wfyyd+00wYSLBsGtQb1G+sO8o96yPASYe8thlnIN2jnFxZ+W9M+pb+h5pAuifIcS
XUjz4sZ6Y4lHhLLHvQIDAQAB
-----END PUBLIC KEY-----
```

3. After successfully charging the user for the purchase, the client must create a purchase record on ConsCent using the create external purchase API. This step ensures the synchronization of purchase data between our system and ConsCent's platform.

**Step 1: Creating the Token:**

You can create the JWT token by using our create-external-purcase-token API.&#x20;

Attached is the Postman collection file for using the APIs.

> <mark style="color:orange;">**Postman documentation can be found below:**</mark>

> [Conscent Sandbox Env.postman\_environment.json](https://file.notion.so/f/f/0580a633-2770-412f-b280-f17ac138548a/4408e758-a4ef-497a-b53b-b89a0d536b7b/ConsCent_Sandbox_Env.postman_environment.json?id=3165c5e7-b629-4c8d-85f6-72fffa20ab69\&table=block\&spaceId=0580a633-2770-412f-b280-f17ac138548a\&expirationTimestamp=1714053600000\&signature=eVk19CGvg5-1aWF_2DOYEyeoSgKW4SiNzJdtZs0JbdA\&downloadName=ConsCent+Sandbox+Env.postman_environment.json)
>
> [External Purchase APIs.postman\_environmen](https://file.notion.so/f/f/0580a633-2770-412f-b280-f17ac138548a/7faa2163-b4d9-42c5-8a76-5f0ce146a0db/External_Purchase_APIs.postman_collection.json?id=fe118beb-7ffb-4e28-a267-4b2097b4fa09\&table=block\&spaceId=0580a633-2770-412f-b280-f17ac138548a\&expirationTimestamp=1714053600000\&signature=1YTp8wdrp2tOqOQiQwj5pZr1v1LV6b6M6sYBPOIlirk\&downloadName=External+Purchase+APIs.postman_collection.json)[t.json](https://file.notion.so/f/f/0580a633-2770-412f-b280-f17ac138548a/7faa2163-b4d9-42c5-8a76-5f0ce146a0db/External_Purchase_APIs.postman_collection.json?id=fe118beb-7ffb-4e28-a267-4b2097b4fa09\&table=block\&spaceId=0580a633-2770-412f-b280-f17ac138548a\&expirationTimestamp=1714053600000\&signature=1YTp8wdrp2tOqOQiQwj5pZr1v1LV6b6M6sYBPOIlirk\&downloadName=External+Purchase+APIs.postman_collection.json)

{% hint style="info" %}
Replace the URLs based on the environment [(SANDBOX/PRODUCTION)](https://docs.conscent.ai/using-conscent.ai)
{% endhint %}

**Step 2: Verify the JWT in your system and complete the purchase.**

You may refer to <https://jwt.io/introduction>

**Step 3: Pass the token in the create-purchase API (postman collection attached above)**

**SAMPLE JWT Payload details:**

<table><thead><tr><th width="177">PARAMETER </th><th width="144">DATATYPE</th><th>DESCRIPTION</th></tr></thead><tbody><tr><td>id</td><td>string</td><td>unique id assigned to each token to ensure consumability</td></tr><tr><td>iat</td><td>number</td><td>creation time in UTC timestamp format</td></tr><tr><td>subscriptionId</td><td>string</td><td>unique subscription ID for each subscription</td></tr><tr><td>tierId</td><td>string</td><td>unique tier ID for each subscription tier</td></tr><tr><td>amount</td><td>number</td><td>amount to be deducted to complete purchase</td></tr><tr><td>currency</td><td>string</td><td>currency in which amount is to be deducted</td></tr><tr><td>clientId</td><td>string</td><td>unique client ID for each client</td></tr><tr><td>consumeFreeTrial</td><td>boolean</td><td>Flag to avail of free trial</td></tr><tr><td>couponCode</td><td>string</td><td>coupon code applied by the user</td></tr><tr><td>ipAddress</td><td>string</td><td>IP address of the user</td></tr><tr><td>userAgent</td><td>string</td><td>user agent of the user</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.conscent.ai/version-1.0/creating-external-purchases.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
