Praxis Wiki logo

Create Subscription

POST /api/v1.3/subscription method is your endpoint to create new customer subscription.

ENDPOINTS

Name URL
Sandbox https://pci-gw-test.praxispay.com/api/v1.3/subscription
Live https://gw.praxisgate.com/api/v1.3/subscription

REQUEST PARAMS

✓ - required value
? - optional, value or null
✕ - always appears as null

Variable Type Description
merchant_id varchar(50) Merchant API client account identifier
application_key varchar(32) Identifier of your application (website)
plan_id varchar(32) Subscription Plan ID
price_id varchar(32) Price ID
cid varchar(32) Customer ID
card_token varchar(32) Customer card token
activate varchar(5) ? Activate or not subscription immediately after creating. Possible values:
true - the subscription will be created with an active status.
false -the subscription will be created with an inactive status.
notification_url varchar(50) CRM endpoint for notifications from our system about subscription events
version varchar(4) API version. Default value - v1.3
timestamp int(11) Response time (unix timestamp, seconds)

RESPONSE PARAMS

Variable Type Description
status int API communication status -
- 0 if the request was successful
- Negative integer if internal server/network error occurs
- Positive integer if application/logical error occurs
description varchar(256) Accurate description of the result. Return the actual error for any exception as it helps to diagnose issues in production
subscription_id varchar(32) Subscription ID
plan_id varchar(32) Plan ID
cid varchar(32) Customer ID
price text Selected price(amount & currency) of subscription
subscription_status varchar(8) Status of subscription.
List of possible statuses:
Active - customer subscription in active status.
Inactive - customer subscription inactive.
Expired - customer subscription expired.
Canceled - customer subscription removed.
version varchar(3) API version
timestamp int(11) Response time (unix timestamp, seconds)

Signature

To execute the request, it is necessary to undergo the authentication process. The general authentication algorithm can be found in the Authentication section.

Request signature parameters

  1. merchant_id
  2. application_key
  3. timestamp

Response signature parameters

  1. status
  2. timestamp

Example

Request

{
  "merchant_id": "API-Merchant",
  "application_key": "test-application",
  "plan_id": "6lmzTS5SBc1ABD4h",
  "price_id": "KdGw29Fc",
  "cid": "user-1234",
  "card_token": "a52028efb6ccbedd65c066ce284c7dfb",
  "activate": true,
  "notification_url": "https://merchant-website.com/subscriptions/user-1234/callback"
  "version": 1.3,
  "timestamp": 1680712861
}

Response (successful scenario)

{
    "status": 0,
    "description": "Subscription plan 6lmzTS5SBc1ABD4h successfully assigned for customer user-1234",
    "subscription_id": "tvoS9vGKdDwfGLLvp0r8JJ5d",
    "plan_id": "6lmzTS5SBc1ABD4h",
    "cid": "user-1234",
    "price": {
        "price_id": "KdGw29Fc",
        "amount": 20000,
        "currency": "EUR",
    },
    "subscription_status": "active",
    "version": 1.3,
    "timestamp": 1680712861
}

Response (unsuccessful scenario)

{
  "status": -1,
  "description": "Subscription plan with ID 6lmzTS5SBc1ABD4h not found",
  "version": 1.3,
  "timestamp": 1680712861
}