Subscriptions
Create recurring payment schedules for subscription billing, membership fees, loan repayments, and other periodic charges.
Overview
The Subscriptions API enables automatic recurring payments at configurable intervals. Features include:
- Flexible billing frequencies (daily, weekly, monthly, quarterly, yearly)
- Configurable anchor day for monthly+ frequencies
- Automatic retry on failed charges
- Pause and resume capabilities
- Charge history tracking
- Webhook notifications for all subscription events
Billing Frequencies
| Frequency | Description | Anchor Day |
|---|---|---|
DAILY | Charges every day | N/A |
WEEKLY | Charges every 7 days | N/A |
BIWEEKLY | Charges every 14 days | N/A |
MONTHLY | Charges once per month | 1-28 |
QUARTERLY | Charges every 3 months | 1-28 |
YEARLY | Charges once per year | 1-28 |
Subscription Lifecycle
| Status | Description |
|---|---|
ACTIVE | Subscription is active and charges will be processed |
PAUSED | Temporarily paused, no charges will be made |
CANCELLED | Permanently cancelled by user/merchant |
EXPIRED | End date reached, subscription completed |
FAILED | Max retries exceeded, requires attention |
API Reference
Create Subscription
Create a new recurring payment subscription.
Get Subscription
Retrieve details of a specific subscription.
GET
/partner/subscriptions/:subscriptionIdList Subscriptions
List all subscriptions with optional filters.
GET
/partner/subscriptionsUpdate Subscription
Update subscription details. Only active or paused subscriptions can be updated.
PATCH
/partner/subscriptions/:subscriptionIdPause Subscription
Temporarily pause a subscription. No charges will be made while paused.
POST
/partner/subscriptions/:subscriptionId/pauseResume Subscription
Resume a paused subscription.
POST
/partner/subscriptions/:subscriptionId/resumeCancel Subscription
Permanently cancel a subscription.
POST
/partner/subscriptions/:subscriptionId/cancelGet Subscription Charges
Retrieve the charge history for a subscription.
GET
/partner/subscriptions/:subscriptionId/chargesCode Examples
Create Monthly Membership (JavaScript)
create-subscription.js
1async function createMembershipSubscription(userWalletId, merchantWalletId, plan) {2 const API_KEY = process.env.WASAAPAY_API_KEY;3 const BASE_URL = 'https://api.wasaapay.com/api/v1/partner';45 const plans = {6 basic: { name: 'Basic Membership', amount: 499 },7 premium: { name: 'Premium Membership', amount: 999 },8 enterprise: { name: 'Enterprise Membership', amount: 2999 },9 };1011 const selectedPlan = plans[plan];12 if (!selectedPlan) {13 throw new Error('Invalid plan');14 }1516 // Start on the 1st of next month17 const startDate = new Date();18 startDate.setMonth(startDate.getMonth() + 1);19 startDate.setDate(1);20 startDate.setHours(0, 0, 0, 0);2122 const response = await fetch(`${BASE_URL}/subscriptions`, {23 method: 'POST',24 headers: {25 'Content-Type': 'application/json',26 'X-API-Key': API_KEY,27 'X-Idempotency-Key': `sub_${userWalletId}_${plan}_${Date.now()}`,28 },29 body: JSON.stringify({30 sourceWalletId: userWalletId,31 destinationWalletId: merchantWalletId,32 name: selectedPlan.name,33 amount: selectedPlan.amount,34 frequency: 'MONTHLY',35 startDate: startDate.toISOString(),36 anchorDay: 1, // Charge on 1st of each month37 externalReference: `MEMBER-${userWalletId}`,38 metadata: { plan, signupDate: new Date().toISOString() }39 }),40 });4142 const result = await response.json();4344 if (!result.success) {45 throw new Error(result.message);46 }4748 console.log(`Subscription created: ${result.data.reference}`);49 console.log(`First charge: ${result.data.nextChargeAt}`);5051 return result.data;52}5354// Create premium subscription55createMembershipSubscription('wallet_user123', 'wallet_merchant456', 'premium')56 .then(sub => console.log('Subscription ID:', sub.id))57 .catch(console.error);
Webhooks
Subscribe to events to track subscription lifecycle changes. See Webhooks documentation for setup.
Subscription Events
| Event | Description |
|---|---|
subscription.created | New subscription created |
subscription.charge.completed | Recurring charge was successful |
subscription.charge.failed | Recurring charge failed |
subscription.paused | Subscription was paused |
subscription.resumed | Subscription was resumed |
subscription.cancelled | Subscription was cancelled |
subscription.expired | Subscription reached end date |
Best Practices
- Set anchor days wisely: For monthly subscriptions, use anchor days between 1-28 to avoid end-of-month issues
- Handle charge failures: Monitor webhook events and notify users about failed charges
- Grace periods: Consider pausing instead of immediately cancelling on failed charges
- Proration: When upgrading plans mid-cycle, consider creating a new subscription with the difference
- Track charges: Use the charges endpoint to build billing history for your users