API Integration for Subscriptions
This guide shows you how to implement subscriptions using either the prebuilt UI component or direct API integration.
When to Use API Integration
Trade-offs: Speed vs Control
The prebuilt UI gets you live in hours with minimal code, while API integration takes 1-2 weeks but gives you complete control over the user experience. Both support the same payment methods, currencies, and business logic.
UI Implementation
Installation
Install the latest Coinflow packages:
Configuration
To use the provided purchase page for subscriptions:
- Supply the
merchantIdandplanCodein theCoinflowPurchasecomponent - The subscription cost and information will automatically populate the form
Example Implementation
Component Display
How the Subscription Purchase Works
When a customer subscribes:
- Payment Method: Customer provides a payment method (card or bank account)
- Initial Payment: The first payment is processed immediately
- Subscription Creation: If payment succeeds, the subscription is created with
Activestatus - Recurring Billing: Future payments are automatically processed according to the plan schedule
Note: If the first payment fails, the subscription is not created. The customer must retry the entire subscription purchase.
API Implementation
Follow these steps to implement subscriptions via direct API integration.
Step 1: Create a Subscription Plan
Create a subscription plan using the merchant API. This is a one-time setup for each plan you want to offer.
Note: Use
USDCorEUROeforsettlementTypeif you want stablecoin settlement; see Settlement Types.
Response:
Step 2: Get Available Subscription Plans
Get all available subscription plans that customers can purchase. Use this endpoint in your application to display plan options.
Response:
Step 3: Create Subscription with Credit Card
Enable customers to subscribe to a plan with a credit card. This processes the first payment and creates the subscription.
Important: You must tokenize the card before making this request. See the card tokenization guide for details.
Response:
Step 4: Enable Customer to Cancel Subscription
Allow customers to cancel their subscription when needed.
Get Customer Subscriptions
First, retrieve all subscriptions for the customer:
Response:
Cancel the Subscription
Use the subscription ID from the previous response to cancel:
Testing
To test credit card purchases for a subscription, please see our testing credit card purchase documentation. For bank-account testing, see the ACH testing guide.

