Skip to main content

charge Method

Overview​

The charge method processes a recurring payment using an existing mandate. Once a customer has authorized recurring billing, use this method to charge their stored payment method without requiring their interaction.

Business Use Case: Your SaaS subscription renews monthly. The customer already authorized recurring payments during signup. On the renewal date, you call charge to process their subscription payment automatically.

Purpose​

Why use recurring payment charges?

ScenarioBenefit
Subscription billingAutomate monthly/yearly recurring charges
Membership duesProcess club/organization membership fees
Installment plansCollect scheduled payments automatically
Utility billingAutomate recurring service payments

Key outcomes:

  • No customer interaction required for repeat payments
  • Consistent cash flow for subscription businesses
  • Reduced payment friction improves retention

Request Fields​

FieldTypeRequiredDescription
merchant_transaction_idstringYesYour unique transaction reference
amountMoneyYesAmount to charge in minor units (e.g., 1000 = $10.00)
mandate_idstringYesThe mandate ID from setup_recurring
descriptionstringNoDescription shown on customer's statement
metadatadictNoAdditional data (max 20 keys)
webhook_urlstringNoURL for async webhook notifications

Response Fields​

FieldTypeDescription
merchant_transaction_idstringYour transaction reference (echoed back)
connector_transaction_idstringConnector's transaction ID
statusPaymentStatusCurrent status: SUCCEEDED, PENDING, FAILED
errorErrorInfoError details if status is FAILED
status_codeintHTTP-style status code (200, 402, etc.)

Example​

SDK Setup​

from orchestratorx_prism import RecurringPaymentClient

recurring_client = RecurringPaymentClient(
connector='stripe',
api_key='YOUR_API_KEY',
environment='SANDBOX'
)

Request​

request = {
"merchant_transaction_id": "txn_sub_monthly_001",
"amount": {
"minor_amount": 2900,
"currency": "USD"
},
"mandate_id": "mandate_xxx",
"description": "Monthly Pro Plan Subscription"
}

response = await recurring_client.charge(request)

Response​

{
"merchant_transaction_id": "txn_sub_monthly_001",
"connector_transaction_id": "pi_3Oxxx...",
"status": "SUCCEEDED",
"status_code": 200
}

Common Patterns​

Subscription Renewal Flow​

sequenceDiagram
participant App as Your App
participant CS as Prism
participant PP as Payment Provider

Note over App: Renewal date reached
App->>CS: 1. charge with mandate_id
CS->>PP: Process recurring payment
PP-->>CS: Return result: SUCCEEDED
CS-->>App: Return status: SUCCEEDED
Note over App: Subscription renewed

Flow Explanation:

  1. Check renewal - On the scheduled date, call charge with the stored mandate_id.

  2. Process payment - The charge is processed using the customer's stored payment method.

  3. Handle result - If successful, extend the subscription period. If failed, initiate dunning workflow.

Error Handling​

Error CodeMeaningAction
402Payment failedInsufficient funds, expired card, etc.
404Mandate not foundVerify mandate_id is correct
409Duplicate transactionUse unique merchant_transaction_id

Best Practices​

  • Call charge on the expected renewal date
  • Handle failures gracefully with retry logic
  • Notify customers of failed payments with update payment method link
  • Store successful transaction IDs for reporting

Next Steps​