Prerequisites
Before creating a subscription, two things must be in place:- Stored Customer: The customer must exist in the Ecrypt system with a populated customer wallet containing at least one stored payment token (wallet payment method).
- Reusable Payment Token: When capturing the initial payment method (via iFrame or checkout page),
oneTimePaymentmust be set tofalse. This ensures the generated token can be stored to the customer wallet and used for future recurring charges. Setting this totruewill prevent the token from being reused.
API Flows
iFrame and Direct API
For a first-time customer using the iFrame or direct API integration, the typical sequence is:- Create Token — Tokenize the customer’s payment method via the iFrame or checkout page with
oneTimePayment: false. - Create Customer —
POST /v1/customers - Create Customer Wallet —
POST /v1/customers/{Customer}/wallet— Store the token to the customer’s wallet. - Create Subscription Plan —
POST /v1/subscriptions— Define the billing plan (cycle, amount, label). - Create Customer Subscription —
POST /v1/customers/{Customer}/subscriptions— Link the customer and their wallet to the subscription plan.
Dynamic Checkout Page
The Dynamic Checkout page simplifies this considerably. By including asubscription object in the POST /v1/dynamiccheckout request body, the checkout page handles the entire flow in a single session:
Tokenization > create customer > store payment method > subscription enrollment.You simply select a pre-defined billing cycle and a billing date (start date) within the pages subscription object, and the checkout page takes care of the rest.
Create a Subscription Plan
POST /v1/subscriptions This endpoint defines a reusable subscription plan that can then be assigned to one or more customers.
Required Fields
label (string, required) — A human-readable name for the subscription plan. Must be between 1 and 100 characters.
cycle (object, required) — Defines the billing frequency and timing.
amount (object, required) — The billing amount for each cycle occurrence.
Example Request
Enrolling a Customer in a Subscription
POST /v1/customers/{Customer}/subscriptions Once a subscription plan exists and the customer has a populated wallet, use this endpoint to activate the subscription for a specific customer.
Checkout Page Subscription Object
When using the Dynamic Checkout page (POST /v1/dynamiccheckout), include the subscription object to handle the full enrollment flow automatically. This is the simpler path for new customers.
Billing Cycle Values
Subscription Management
Once active, a customer subscription can be managed via the following endpoints. See the Customer Subscription section in the API reference.- Modify Price —
PUT /v1/customers/{Customer}/subscriptions/{Subscription} - Suspend —
PUT /v1/customers/{Customer}/subscriptions/{Subscription}/suspend - Resume —
PUT /v1/customers/{Customer}/subscriptions/{Subscription}/resume - Cancel —
DELETE /v1/customers/{Customer}/subscriptions/{Subscription} - Delete Plan —
DELETE /v1/subscriptions/{Subscription}