> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ecrypt.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Charge Customer Wallet

> Charge a customer's stored payment method using their customer ID or a specific wallet payment method.

## Overview

Once a customer has a payment method saved to their wallet, you can charge them through the standard
transaction endpoints using the `payment.stored` object. You can charge either the customer's default
payment method or a specific wallet entry.

***

## Charge the Default Payment Method

To charge a customer's default payment method, pass the customer `id` in `payment.stored.customer`.
ECRYPT will automatically use whichever wallet entry is marked as default.

```bash theme={null} theme={null}
POST /v1/transactions/sale
```

```json theme={null} theme={null}
{
  "payment": {
    "stored": {
      "customer": "00000000-0000-0000-0000-000000000000",
      "initiated_by": "MERCHANT"
    }
  },
  "amount": {
    "value": 99.00,
    "currency": "USD"
  }
}
```

***

## Charge a Specific Wallet Payment Method

To charge a specific payment method, pass the wallet entry `id` in `payment.stored.wallet` instead.
This is useful when a customer has multiple payment methods on file and you need to target a specific one.

```bash theme={null} theme={null}
POST /v1/transactions/sale
```

```json theme={null} theme={null}
{
  "payment": {
    "stored": {
      "wallet": "00000000-0000-0000-0000-000000000000",
      "initiated_by": "MERCHANT"
    }
  },
  "amount": {
    "value": 99.00,
    "currency": "USD"
  }
}
```

***

## initiatedBy

The `initiatedBy` field indicates who initiated the transaction. This is required for stored
payment method transactions and affects how the transaction is processed at the network level.

| Value | Meaning  | Description                                                                                                    |
| ----- | -------- | -------------------------------------------------------------------------------------------------------------- |
| `0`   | Merchant | The merchant initiated the transaction. Used for recurring payments, installments, and agent-assisted charges. |
| `1`   | Customer | The customer initiated the transaction. Used when the customer selects a stored card during checkout.          |

***

## Authorize and Capture

If you need to place a hold before capturing, use the authorize endpoint instead of sale. The same
`payment.stored` object applies.

```bash theme={null} theme={null}
POST /v1/transactions/authorize
```

Once ready to capture:

```bash theme={null} theme={null}
POST /v1/transactions/capture
```

```json theme={null} theme={null}
{
  "transaction_id": "123456789",
  "amount": 99.00
}
```

***

## Transaction Response

A successful charge returns a transaction ID, approval code, and the amount processed.

```json theme={null} theme={null}
{
  "transaction_id": "123456789",
  "auth_code": "TAS123",
  "response_code": "APPROVED",
  "response_text": "APPROVED",
  "amount": 99.00,
  "request_id": "000000000000000000000"
}
```

<Tip>
  Store the `transactionId` from every charge. It is required for voids, refunds, and captures.
</Tip>

***

## Recurring Payments

Customer wallets are also the foundation for automated recurring billing. ECRYPT supports two
models -- subscriptions for ongoing recurring charges, and installment plans for splitting a fixed
amount into scheduled payments.

<CardGroup cols={2}>
  <Card title="Subscriptions" icon="arrows-rotate" href="/docs/subscriptions">
    Automatically charge a customer's wallet on a recurring schedule -- daily, weekly, monthly, and more.
  </Card>

  <Card title="Installment Plans" icon="list-ol" href="/docs/installment-plans">
    Split a total amount into a defined number of scheduled charges against a customer's wallet.
  </Card>
</CardGroup>
