Welcome to Anyway! We are currently in Early Access, check out our website at Anyway for more info!
https://api.mor.dev.anyway.shTBDPOST /api/v1/subscriptions/setup{
"productId": "your_product_id",
"setupSuccessUrl": "https://yoursite.com/subscription/success",
"setupCancelUrl": "https://yoursite.com/subscription/cancel",
"webhookUrl": "https://yoursite.com/webhooks/subscription",
"customerEmail": "customer@example.com",
"customerFirstName": "John",
"customerLastName": "Doe",
"customerCountry": "USA",
"productName": "Premium Membership",
"description": "Monthly premium subscription",
"firstPaymentAmount": 0.00
}| Parameter | Type | Required | Description |
|---|---|---|---|
productId | string | Yes | Your product identifier. If it doesn't contain "ORG", your org ID will be prepended automatically |
setupSuccessUrl | string | Yes | URL to redirect customer after successful payment setup |
setupCancelUrl | string | Yes | URL to redirect customer if they cancel the setup |
webhookUrl | string | Yes | URL to receive webhook notifications |
customerEmail | string | Yes | Customer's email address |
customerFirstName | string | Yes | Customer's first name |
customerLastName | string | Yes | Customer's last name |
customerCountry | string | Yes | 3-letter ISO country code (e.g., "USA", "GBR") |
productName | string | No | Display name for the product/service |
description | string | No | Description of the subscription |
firstPaymentAmount | decimal | No | Amount for first payment. Set to 0 for setup-only (no immediate charge), or specify amount for immediate charge |
amount, currency, and interval are automatically fetched from the product pricing configuration in the database.{
"success": true,
"message": "Subscription setup created successfully. Redirect customer to setup_url.",
"data": {
"paymentUrl": "https://payment.dev.anyway.sh/pay?token=eyJhbGc...",
"orderId": "PI_538854c3f217645d3b30b7a2ce00d362",
"subscriptionId": "sub_d749f000e08344e58b37230216e516c9",
"status": "PAYMENT_PENDING",
"expiresIn": 3600000
}
}| Field | Description |
|---|---|
paymentUrl | Redirect URL for customer to complete payment setup |
orderId | Unique order identifier for this subscription |
subscriptionId | Unique subscription identifier |
status | Current status (PAYMENT_PENDING) |
expiresIn | JWT token expiration time in milliseconds (1 hour) |
paymentUrl returned in the response. The customer will:setupSuccessUrlsetupCancelUrlsubscription_setup_complete{
"event": "subscription_setup_complete",
"subscriptionId": "sub_d749f000e08344e58b37230216e516c9",
"orderId": "PI_538854c3f217645d3b30b7a2ce00d362",
"status": "ACTIVE",
"activatedAt": "2025-10-14T10:30:00Z",
"nextBillingDate": "2025-11-14T10:30:00Z",
"amount": 29.99,
"currency": "USD",
"interval": "monthly"
}subscription_payment_succeeded{
"event": "subscription_payment_succeeded",
"subscriptionId": "sub_d749f000e08344e58b37230216e516c9",
"orderId": "PI_new_order_id",
"amount": 29.99,
"currency": "USD",
"lastBilledAt": "2025-11-14T10:30:00Z",
"nextBillingDate": "2025-12-14T10:30:00Z",
"paymentStatus": "paid"
}subscription_payment_failed{
"event": "subscription_payment_failed",
"subscriptionId": "sub_d749f000e08344e58b37230216e516c9",
"failureReason": "card_declined",
"retryCount": 1,
"nextRetryDate": "2025-11-17T10:30:00Z",
"paymentStatus": "failed"
}subscription_payment_failed{
"event": "subscription_payment_failed",
"subscriptionId": "sub_d749f000e08344e58b37230216e516c9",
"failureReason": "multiple_failures",
"retryCount": 3,
"status": "past_due",
"paymentStatus": "failed"
}past_due or cancelled, and the customer receives an email to update their payment method.GET /api/v1/subscriptions/{subscriptionId}{
"success": true,
"data": {
"subscriptionId": "sub_d749f000e08344e58b37230216e516c9",
"amount": 29.99,
"currency": "USD",
"interval": "monthly",
"status": "ACTIVE",
"description": "Monthly premium subscription",
"productName": "Premium Membership",
"customerEmail": "customer@example.com",
"customerName": "John Doe",
"customerId": "cust_123",
"paymentMethodId": "pm_xyz789",
"createdAt": "2025-10-14T10:30:00Z",
"activatedAt": "2025-10-14T10:35:00Z",
"nextBillingDate": "2025-11-14T10:30:00Z",
"firstPaymentAmount": 0.00
}
}POST /api/v1/subscriptions/{subscriptionId}/cancel{
"success": true,
"message": "Subscription cancelled successfully"
}subscription_cancelled{
"event": "subscription_cancelled",
"subscriptionId": "sub_d749f000e08344e58b37230216e516c9",
"canceledAt": "2025-10-14T15:00:00Z",
"cancelAtPeriodEnd": true
}POST /api/v1/subscriptions/{subscriptionId}/update_payment_methodorderId or subscriptionId| Status | Description |
|---|---|
PENDING | Subscription created, awaiting customer payment setup |
ACTIVE | Subscription is active and billing normally |
PAST_DUE | Payment failed multiple times, awaiting resolution |
CANCELED | Subscription has been cancelled |
PAUSED | Subscription is paused (billing cycles skipped) |
| Interval | Description |
|---|---|
WEEKLY | Billed every 7 days |
MONTHLY | Billed once per month |
YEARLY | Billed once per year |
test_premium_monthlyPOST /api/v1/subscriptions/setup with test customer datapaymentUrl to complete test payment setupwebhookUrlGET /api/v1/subscriptions/{subscriptionId}4242 4242 4242 42424000 0000 0000 00024000 0000 0000 9995{
"success": false,
"message": "Invalid request parameters",
"errors": [
"customerEmail must be a valid email address"
]
}{
"success": false,
"message": "Invalid or missing authentication token"
}{
"success": false,
"message": "Subscription not found"
}{
"success": false,
"message": "Unable to process subscription setup",
"error": "Payment processing failed"
}