KuvarPay API
Home
Home
  1. Home
  • Overview
  • SDK Integration Guide
  • Webhooks Integration Guide
  • Subscriptions Guide
  • Transactions
    • Calculate Payment Amount
      POST
    • Create Transaction
      POST
    • Get Transactions Details
      GET
    • Get Transactions
      GET
  • Checkout Sessions
    • Create Checkout Session
      POST
    • Get Checkout Session
      GET
  • Transfer Fees
    • /api/v1/optimal-transfer-fee
      GET
  • Sandbox Simulator
    • Force Simulator Scenario
      POST
    • Force Transaction Status
      POST
  • Invoices
    • Create a new invoice
      POST
    • Send invoice email to customer
      POST
  • Payment Links
    • Create a new payment link
      POST
  • Server-Sent Events (SSE)
    • Get Transaction Details
      GET
    • Get Session Details
      GET
  • Subscriptions
    • Create Plans
      POST
    • Get Plans
      GET
    • Get Plans Details
      GET
    • Update Plans Details
      PATCH
    • Create Prices
      POST
    • Get Prices
      GET
    • Update Prices Details
      PATCH
    • Create Checkout Sessions
      POST
    • Get Checkout Sessions Details
      GET
    • Confirm Subscription Checkout
      POST
    • Create Subscriptions
      POST
    • Get Subscriptions
      GET
    • Get Subscriptions Details
      GET
    • Update Subscriptions Details
      PATCH
    • Delete Subscriptions Details
      DELETE
    • Renew Subscription
      POST
    • Confirm Subscription Cancellation
      POST
    • Create Subscription Invoices
      POST
    • Upgrade Subscription
      POST
    • Get Subscription Invoices
      GET
    • Downgrade Subscription
      POST
    • Renew Subscription Authorization
      POST
    • Create Metered Invoices
      POST
    • Get Subscription Invoices Details
      GET
    • Get Charge Attempts
      GET
    • Create Authorizations
      POST
    • Revoke Relay Authorization
      POST
    • Get Relay Authorization Status
      GET
  • Currencies
    • Get Subscription Currencies
    • Get Supported Currencies
    • Get networks supported for subscription payments
    • Get Currencies
    • Get all supported networks
  • Schemas
    • ErrorResponse
    • CreateInvoiceRequest
    • CreatePaymentLinkRequest
    • InvoiceResponse
    • PaymentLinkResponse
    • CreateInvoiceResponse
    • CreatePaymentLinkResponse
    • SendInvoiceEmailRequest
    • SendInvoiceEmailResponse
    • SubscriptionInvoice
Home
Home
  1. Home

Subscriptions Guide

KuvarPay Subscriptions Guide#

This guide explains how to implement and manage subscriptions using the KuvarPay Business Platform. KuvarPay supports both FIXED (recurring) and METERED (usage-based) billing models to accommodate different business needs.

Overview#

KuvarPay's subscription system enables businesses to:
Create recurring payment plans with fixed pricing
Implement usage-based billing for metered services
Manage customer subscriptions and invoices
Handle payment authorization and collection automatically
Receive real-time webhook notifications for subscription events

Billing Modes#

FIXED Billing Mode#

FIXED billing is for traditional recurring subscriptions where customers pay a predetermined amount at regular intervals (monthly, yearly, etc.).
Use Cases:
SaaS software licenses
Membership fees
Monthly service plans
Subscription boxes
Key Features:
Predictable recurring revenue
Automatic invoice generation
Trial period support
Proration handling

METERED Billing Mode#

METERED billing is for usage-based pricing where customers pay based on their actual consumption of services or resources.
Use Cases:
API usage billing
Cloud storage consumption
Utility services
Pay-per-use features
Key Features:
Flexible pricing based on usage
Custom invoice creation
Real-time usage tracking
Consumption-based charging

Implementation Guide#

1. Setting Up Subscription Plans and Prices#

For FIXED Billing Mode#

Before creating FIXED billing subscriptions, you need to define your plans and pricing structure.
Create a Subscription Plan
Endpoint: POST /subscription-plans
{
  "name": "Premium Plan",
  "description": "Full access to all premium features",
  "metadata": {
    "features": ["unlimited_api_calls", "priority_support"]
  }
}
Create Prices for FIXED Billing
Endpoint: POST /subscription-plans/{planUid}/prices
{
  "amount": "2999",
  "currency": "NGN",
  "interval": "month",
  "intervalCount": 1,
  "trialPeriodDays": 14
}

For METERED Billing Mode#

METERED billing does not require pre-created subscription plans or prices. Instead, you work directly with target pricing and create usage-based invoices as needed.
Metered subscriptions use:
Target Price: Specified during checkout session creation
Usage-based Invoices: Created when you need to charge for actual usage
Flexible Pricing: No fixed recurring schedule

2. Creating Subscription Checkout Sessions#

FIXED Billing Checkout Session#

Endpoint: POST /subscription-checkout-sessions
{
  "priceUid": "price_abc123",
  "billingMode": "FIXED",
  "customer": {
    "email": "customer@example.com",
    "firstName": "John",
    "lastName": "Doe"
  },
  "successUrl": "https://yourapp.com/success",
  "cancelUrl": "https://yourapp.com/cancel"
}

METERED Billing Checkout Session#

Endpoint: POST /subscription-checkout-sessions
{
  "billingMode": "METERED",
  "targetPrice": {
    "targetCurrency": "NGN",
    "targetAmount": "5000.00"
  },
  "customer": {
    "email": "customer@example.com",
    "firstName": "Jane",
    "lastName": "Smith"
  },
  "successUrl": "https://yourapp.com/success",
  "cancelUrl": "https://yourapp.com/cancel"
}

3. Customer Approval Flow#

After creating a checkout session, you'll receive an approvalUrl in the response. Direct your customer to this URL where they will:
1.
Approve the Smart Contract: The customer approves KuvarPay's smart contract to handle their subscription payments
2.
Sign Authorization: The customer signs the EIP-712 authorization for the subscription
3.
Automatic Confirmation: KuvarPay's frontend automatically confirms the session and redirects to your successUrl
Note: Businesses do not need to call the confirm endpoint directly. The KuvarPay frontend handles the confirmation process automatically after the customer completes the approval flow.
Checkout Session Response Example:
{
  "sessionUid": "session_abc123",
  "approvalUrl": "https://checkout.kuvarpay.com/approve/session_abc123",
  "status": "pending"
}

4. Managing Subscriptions#

Retrieve Subscription Details#

Endpoint: GET /subscriptions/{subscriptionUid}

Update Subscription#

Endpoint: PATCH /subscriptions/{subscriptionUid}
{
  "status": "PAUSED",
  "cancel_at_period_end": true,
  "metadata": {
    "reason": "Customer requested pause"
  }
}

Cancel Subscription#

Endpoint: DELETE /subscriptions/{subscriptionUid}
{
  "cancel_at_period_end": false,
  "reason": "Customer cancellation"
}

5. Invoice Management#

FIXED Billing Invoices#

For FIXED billing, invoices are automatically generated based on the subscription schedule. You can retrieve them using:
Endpoint: GET /subscriptions/{subscriptionUid}/invoices

METERED Billing Invoices#

For METERED billing, you create invoices based on actual usage:
Endpoint: POST /subscriptions/{subscriptionUid}/invoices/metered
{
  "amount": "150.00",
  "currency": "NGN",
  "usage_description": "API calls for January 2024",
  "due_date": "2024-02-15T10:00:00Z",
  "charge_schedule": "scheduled",
  "metadata": {
    "period": "2024-01",
    "service": "api"
  }
}
Charge Scheduling Options:
immediate: Charge the invoice immediately upon creation
scheduled: Charge at the specified due_date (or 24 hours if not provided)
Examples:
Immediate Charging:
{
  "amount": "750.00",
  "currency": "NGN",
  "usage_description": "Premium API usage - urgent billing",
  "charge_schedule": "immediate"
}
Scheduled Charging:
{
  "amount": "2000.00",
  "currency": "NGN",
  "usage_description": "Monthly data processing usage",
  "due_date": "2024-02-01T09:00:00Z",
  "charge_schedule": "scheduled"
}

Charge Invoice#

Endpoint: POST /subscription-invoices/{invoiceUid}/charge
{
  "amount": "15000",
  "currency": "NGN"
}

Webhook Events#

KuvarPay sends webhook notifications for subscription events. Configure your webhook endpoint to handle these events:

Subscription Events#

subscription.created - New subscription created
subscription.updated - Subscription details changed
subscription.cancelled - Subscription cancelled
subscription.activated - Subscription became active
subscription.trial_ended - Trial period ended
subscription.payment_failed - Payment attempt failed

Invoice Events#

subscription_invoice.created - New invoice generated
subscription_invoice.paid - Invoice successfully paid
subscription_invoice.payment_failed - Invoice payment failed

Best Practices#

For FIXED Billing#

1.
Trial Periods: Offer trial periods to reduce friction
2.
Proration: Handle mid-cycle plan changes gracefully
3.
Grace Periods: Implement grace periods for failed payments
4.
Dunning Management: Set up retry logic for failed payments

For METERED Billing#

1.
Usage Tracking: Implement accurate usage measurement
2.
Billing Cycles: Define clear billing periods
3.
Usage Limits: Set reasonable usage caps to prevent bill shock
4.
Real-time Monitoring: Provide usage dashboards for customers

General Best Practices#

1.
Webhook Handling: Implement idempotent webhook processing
2.
Error Handling: Handle API errors gracefully
3.
Security: Verify webhook signatures
4.
Monitoring: Track subscription metrics and health
5.
Customer Communication: Send clear notifications about billing events

Error Handling#

Common error scenarios and how to handle them:

Payment Failures#

Implement retry logic with exponential backoff
Send customer notifications
Provide payment method update flows

Subscription State Issues#

Validate subscription status before operations
Handle concurrent modifications
Implement proper state transitions

Usage Tracking Errors (Metered)#

Implement usage event deduplication
Handle late-arriving usage data
Provide usage correction mechanisms

Testing#

Sandbox Mode#

Use sandbox mode for testing:
All subscription operations work in sandbox
No real payments are processed
Use test webhook endpoints

Test Scenarios#

1.
Successful Subscription Flow
2.
Payment Failures and Retries
3.
Subscription Cancellations
4.
Usage-based Billing (Metered)
5.
Webhook Delivery and Processing

API Reference#

For complete API documentation, refer to the OpenAPI specification at /openapi.yaml.

Key Endpoints#

EndpointMethodDescription
/subscription-plansPOSTCreate subscription plan
/subscription-plans/{planUid}GETGet plan details
/subscription-plans/{planUid}/pricesPOSTCreate price for plan
/subscription-checkout-sessionsPOSTCreate checkout session
/subscriptions/{subscriptionUid}GETGet subscription
/subscriptions/{subscriptionUid}PATCHUpdate subscription
/subscriptions/{subscriptionUid}DELETECancel subscription
/subscriptions/{subscriptionUid}/invoicesGETList invoices
/subscriptions/{subscriptionUid}/invoices/meteredPOSTCreate metered invoice
/subscription-invoices/{invoiceUid}/chargePOSTCharge invoice
/subscription-currenciesGETList supported currencies

Support#

For additional support:
Review the webhook documentation in webhooks.mdc
Check the OpenAPI specification for detailed endpoint documentation
Contact KuvarPay support for implementation assistance
Modified at 2025-09-15 21:14:10
Previous
Webhooks Integration Guide
Next
Calculate Payment Amount
Built with