Praxis Wiki logo

Create Subscription Plan

POST /api/v1.3/subscription-plan method is your endpoint for creating a Subscription Plan.

ENDPOINTS

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

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)
name varchar(32) Subscription plan name
description varchar(256) ? Description of the subscription plan
billing_cycle varchar(14) The frequency of charging within the subscription plan. List of possible values:
- Weekly (weekly)
- Monthly (monthly)
- Every 3 months (every_3_months)
- Every 6 months (every_6_months)
- Yearly (yearly)
prices varchar(256) Options with the amount/currency pairs in the subscription plan. Here is possible multiple pairs with different prices for different currencies. The currency parameter should be unique, meaning the record with two identical currencies cannot be created. The system should allow configuring only the currencies that exist in merchants gateway settings, considering only the gateways with MIT enabled.
trial_period int(2) ? Number of days/months without charging the client. List of possible values:
- null - meaning the trial period is not enabled
- [1, 2, 3, … N] - the number of days/months without charging
trial_period_cycle varchar(6) ? Cycle for attempts in the trial period without charging the client.List of possible values:
- null - meaning the trial period is not enabled
- days
- months
expiration_cycles int(2) ? Number of weeks after which billing cycle will be expired.
retries_number int(2) ? Number of retries in case of failure before disabling the plan for the customer. Default value - 3
retries_delay_days int(2) ? Delay between the retries in days. Default value - 1
subscription_plan_status varchar(8) ? Subscription Plan Status. Default value - active
subscription_status_failed_payments varchar(8) ? Status of subscriptions in case of failure after all the retries. List of possible value:
- inactive (that can be re-activated)
- canceled (that can not be re-activated)
inactive_subscription_lifetime int(2) ? Number of days before changing the subscription status from inactive to canceled.
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
plan_id varchar(32) Subscription Plan ID
prices varchar(256) Options with the amount/currency pairs in the subscription plan.
subscription_plan_status varchar(8) Subscription Plan Status
version varchar(4) 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",
  "name": "Plan 1",
  "description": "Basic plan for casino",
  "billing_cycle": "weekly",
  "prices": [
    {
      "amount": 20000,
      "currency": "EUR"
    },
    {
      "amount": 19800,
      "currency": "USD"
    },
    {
      "amount": 93500,
      "currency": "PLN"
    }
  ],
  "trial_period": 14,
  "trial_period_cycle": "days",
  "expiration_cycles": 12,
  "retries_number": 3,
  "retries_delay_days": 1,
  "subscription_status_failed_payments": "inactive",
  "inactive_subscription_lifetime": 14,
  "version": 1.3,
  "timestamp": 1680712861
}

Response (successful scenario)

{
  "status": 0,
  "description": "Subscription plan created successfully.",
  "plan_id": "i2VANeFxKR1aZGoH",
  "prices": [
    {
      "price_id": "1A8Nxpaf",
      "amount": 20000,
      "currency": "EUR"
    },
    {
      "price_id": "JWolofvu",
      "amount": 19800,
      "currency": "USD"
    },
    {
      "price_id": "0wvCJ1aU",
      "amount": 93500,
      "currency": "PLN"
    }
  ],
  "subscription_plan_status": "active",
  "version": 1.3,
  "timestamp": 1680712861
}

Response (unsuccessful scenario)

{
  "status": -1,
  "description": "Validation failed. Application Key cannot be empty."
}