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
Choose API integration when you need full customization
- Custom branded checkout experience
- Non-React frameworks (Vue, Angular, vanilla JS, mobile)
- Complex subscription logic (trials, upgrades, prorations)
- Multi-step checkout with additional business logic
- Backend-only subscription management
- Custom payment method collection flows
- Teams with frontend development capacity
Integration time: 1-2 weeks for custom UI
These scenarios work better with the prebuilt component
- React/Next.js apps with standard subscription flows
- Quick validation of subscription business model (hours vs weeks)
- Limited resources for building custom payment UI
- Standard checkout without complex customization needs
- Faster time to market is critical priority
→ See Prebuilt Coinflow UI for fastest 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.
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.

