Skip to main content

Introduction

The Subscriptions Module provides merchants with a robust API-driven platform to orchestrate recurring payments. At the core of this service is the Subscription Billing Engine, which autonomously manages the entire agreement lifecycle from customer enrollment to recurring billing, status transitions, and dunning management.

The Role of Schemes The engine is designed with a modular architecture driven by Payment Schemes. While the engine handles the high-level orchestration, the Scheme dictates the specific execution rules required to process that charge compliant with local regulations and provider capabilities.

A Scheme defines parameters such as:

  • Execution Windows: Mandatory scheduling times (e.g., PIX Automático's 8-day window vs. Credit Card's real-time capture).
  • Orchestration Logic: Whether the charge is triggered by the merchant or the engine.
  • Retry Policies: Scheme-specific rules for recovering failed payments (Dunning).
  • Enrollment Flows: Whether a setup requires synchronous payment or asynchronous authorization.

Supported Schemes:

Subscription Flow

Orchestration Models & Responsibility

The Subscriptions Module offers two distinct orchestration models, configured via the merchant_initiation flag. This parameter serves as the fundamental architectural decision for your integration, defining not only which party is responsible for driving the subscription lifecycle, but also governing the behavior of critical financial parameters:

  1. Amount Strategy (FIXED vs. VARIABLE): This setting dictates whether the Engine has the autonomy to schedule and execute payments based on a known constant value, or if it must remain passive, waiting for the Merchant to calculate and submit usage-based values for each cycle.

  2. Currency & FX Logic: This defines how the system handles multi-currency scenarios. Regardless of the initiation model, the Engine provides native support for Cross-Currency transactions (e.g., defining a price in USD to charge a payer in BRL), automatically handling the foreign exchange (FX) conversion at the moment of execution without requiring manual calculation by the merchant.

1. Merchant-Driven (merchant_initiation: true)

  • Responsibility: The Merchant must explicitly trigger each payment attempt via the API. You are responsible for tracking due dates and calculating the amount to be charged for each cycle.
  • Engine Role: The Billing Engine operates strictly as a System of Record. It records the transaction history and updates the subscription status based on the outcome of your requests, but it will not automatically generate cycles or attempt charges on its own.
  • Primary Use Case: Mandatory for subscriptions with VARIABLE amounts (e.g., usage-based billing) or irregular billing intervals.
  • Specific Constraints: For PIX Automático, you must strict adherence to regulatory windows when triggering payments. See Merchant-Initiated Rules.

2. Engine-Driven (merchant_initiation: false)

This model leverages the full power of our automation infrastructure. Once the subscription is created, the Engine takes over the operational burden.

  • Responsibility: Our Subscription Billing Engine assumes full ownership of the lifecycle orchestration.
  • Engine Role (Active): The system acts autonomously to:
    • Calculate precise due dates based on the schedule.
    • Create billing cycles automatically.
    • Orchestrate scheduling: Interact with the Financial Institution (PSP) within mandatory windows (e.g., PIX Automático 8-day window).
    • Execute charges and manage the Retry Logic (Dunning) in case of failures.
  • Primary Use Case: Ideal for standard recurring plans with FIXED amounts (e.g., SaaS fees, memberships).

Capabilities & Constraints Matrix

The following table outlines the logical availability of features based on the initiation model chosen.

Feature / ScenarioEngine-Driven (false)Merchant-Driven (true)Notes
Fixed AmountAvailableAvailableStandard recurring model.
Variable AmountNot AvailableAvailableThe Engine cannot automate unknown values; the Merchant must provide them per cycle.
Local Currency (Order = Destination)AvailableAvailableE.g., Charging BRL to a Brazilian payer.
Cross-Currency (FX) (Order ≠ Destination)AvailableAvailableE.g., Charging USD to a Brazilian payer. The Engine handles the conversion automatically.

Data Model: Subscription Entity

The Subscription entity is the central component representing the recurring agreement.

FieldTypeDescription
subscriptionIdUUIDUnique identifier generated by the system.
referenceIdStringMerchant's unique identifier for reconciliation.
personObjectCustomer/Payer information.
scheduleObjectDefines timing (startDate, endDate, periodicity).
schedule.billingCycleEnumWEEKLY, MONTHLY, QUARTERLY, HALF_YEARLY, YEARLY.
schedule.forceWorkDayBooleanIf true, non-business due dates are adjusted to the next business day.
amountObjectFinancial value (orderAmount, currency).
typeEnumFIXED or VARIABLE.
subscriptionSchemeEnumThe payment method (e.g., PIX_AUTOMATICO).
statusEnumCREATED, PENDING, DECLINED, ERROR, ACTIVE, REJECTED, EXPIRED, PAST_DUE, UNPAID, SUSPENDED, FINISHED, CANCELED, REVOKED
retryPolicyStringIdentifier code for the dunning policy (e.g., 002).

Subscription Status Map

The Subscription entity functions as a state machine. Its status transitions are driven by three primary factors:

  1. Enrollment Events: The authorization process with the Financial Institution (PSP).
  2. Billing Results: Success or failure of recurring charges (including retries).
  3. Manual Interventions: Actions triggered by the merchant (e.g., suspension, cancellation) or the payer (e.g., revocation).

State Transition Diagram

The following flowchart illustrates all valid transitions within the subscription lifecycle.

1. Onboarding & Enrollment Phase

Statuses related to the setup of the subscription and the initial authorization with the PSP.

StatusDescription
CREATEDThe subscription object has been initialized in our system but the enrollment request has not yet been sent to the PSP.
PENDINGThe enrollment request has been sent and is awaiting Payer authorization (e.g., via Bank App) or PSP confirmation.
ACTIVEThe Goal State. The enrollment is authorized, and the subscription is healthy, valid, and ready to process charges according to the schedule.
DECLINEDThe enrollment request was immediately declined by the PSP (e.g., invalid data or business rules).
REJECTEDThe payer actively rejected the enrollment request in their banking app, or the PSP rejected it after analysis.
EXPIREDThe time window for the payer to authorize the enrollment (QR Code) has elapsed without action.
ERRORA technical error occurred during the setup process preventing the enrollment.

2. Operational & Billing Phase

Statuses indicating the ongoing health of an active subscription based on payment performance.

StatusDescription
PAST_DUEA scheduled payment failed, but the Retry Policy is still active. The system will attempt to charge again within the defined window.
UNPAIDAll retry attempts defined in the policy have failed. The subscription remains valid but is in default.
SUSPENDEDThe merchant has manually paused the subscription. No new charges will be generated until it is reactivated.

3. Terminal States

Final states from which a subscription typically cannot return to ACTIVE (unless a new enrollment is created).

StatusDescription
FINISHEDThe subscription has reached its natural endDate as defined in the schedule.
CANCELEDThe subscription was manually terminated by the merchant or the system (e.g., due to long-term default).
REVOKEDCritical State. The underlying authorization was revoked by the Payer directly at their bank or by the Financial Institution. No further charges are possible.