> For the complete documentation index, see [llms.txt](https://docs.hyperswitch.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hyperswitch.io/integrations/prism/node/recurring-payment-service/charge.md).

# Charge

## Overview

The `charge` method processes a recurring payment using an existing mandate. Once a customer has authorized recurring billing, use this 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.

## Purpose

| Scenario             | Benefit                                  |
| -------------------- | ---------------------------------------- |
| Subscription billing | Automate monthly/yearly charges          |
| Membership dues      | Process club/organization fees           |
| Installment plans    | Collect scheduled payments automatically |

## Request Fields

| Field                   | Type   | Required | Description                         |
| ----------------------- | ------ | -------- | ----------------------------------- |
| `merchantTransactionId` | string | Yes      | Your unique transaction reference   |
| `amount`                | Money  | Yes      | Amount to charge (minor units)      |
| `mandateId`             | string | Yes      | The mandate ID from setupRecurring  |
| `description`           | string | No       | Description on customer's statement |
| `metadata`              | object | No       | Additional data (max 20 keys)       |

## Response Fields

| Field                    | Type          | Description                |
| ------------------------ | ------------- | -------------------------- |
| `merchantTransactionId`  | string        | Your transaction reference |
| `connectorTransactionId` | string        | Connector's transaction ID |
| `status`                 | PaymentStatus | SUCCEEDED, PENDING, FAILED |
| `error`                  | ErrorInfo     | Error details if failed    |
| `statusCode`             | number        | HTTP status code           |

## Example

### SDK Setup

```javascript
const { RecurringPaymentClient } = require('hyperswitch-prism');

const recurringClient = new RecurringPaymentClient({
    connector: 'stripe',
    apiKey: 'YOUR_API_KEY',
    environment: 'SANDBOX'
});
```

### Request

```javascript
const request = {
    merchantTransactionId: "txn_sub_monthly_001",
    amount: {
        minorAmount: 2900,
        currency: "USD"
    },
    mandateId: "mandate_xxx",
    description: "Monthly Pro Plan Subscription"
};

const response = await recurringClient.charge(request);
```

### Response

```javascript
{
    merchantTransactionId: "txn_sub_monthly_001",
    connectorTransactionId: "pi_3Oxxx...",
    status: "SUCCEEDED",
    statusCode: 200
}
```

## Subscription Renewal Flow

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

    Note over App: Renewal date reached
    App->>CS: charge with mandateId
    CS->>PP: Process recurring payment
    PP-->>CS: Return: SUCCEEDED
    CS-->>App: Return status
```

## Error Handling

| Error Code | Meaning           | Action                           |
| ---------- | ----------------- | -------------------------------- |
| `402`      | Payment failed    | Insufficient funds, expired card |
| `404`      | Mandate not found | Verify mandateId                 |
| `409`      | Duplicate         | Use unique merchantTransactionId |

## Next Steps

* [setupRecurring](/integrations/prism/node/payment-service/setup-recurring.md) - Create initial mandate
* [revoke](/integrations/prism/node/recurring-payment-service/revoke.md) - Cancel recurring payments


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.hyperswitch.io/integrations/prism/node/recurring-payment-service/charge.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
