# Payment Reconciliation Mcp (`amirkhan_dev_crx/payment-reconciliation-mcp`) Actor

- **URL**: https://apify.com/amirkhan_dev_crx/payment-reconciliation-mcp.md
- **Developed by:** [Amir Khan](https://apify.com/amirkhan_dev_crx) (community)
- **Features:** Limited permissions, Single-tenant, Server interface
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Payment Reconciliation MCP

**Ask your AI where your money is.** A read-only MCP server that connects Claude, Cursor, VS Code Copilot and any MCP client to **Stripe, Razorpay and PayPal** at the same time, then answers finance questions across all of them:

> "What was our net revenue last month across all gateways?"
> "Why did sales drop this week?"
> "Did order #1042 actually get paid?"
> "Reconcile this WooCommerce export against our payments."
> "Which disputes need a response, and how many days are left?"
> "What's actually inside Friday's Stripe payout?"

- 🔒 **Read-only by design:** it never creates charges, refunds or payouts, and works with Stripe *restricted read-only* keys
- 🧾 **Order reconciliation:** paste a CSV/JSON order export and get missing payments, underpayments, double payments and refund mismatches
- 🌍 **Multi-currency, multi-gateway:** one normalized view, with JPY/KWD handled correctly and no accidental currency mixing
- 🕐 **Time-zone aware:** "today" and "this month" mean *your* day (e.g. `Asia/Kolkata`)
- 🛡️ **Resilient:** if one gateway fails, you still get data from the others, plus a clear error; secrets are never echoed
- ⚡ **Zero runtime dependencies:** pure Node.js, already compiled

***

### ⚡ Use it on Apify (no install)

This Actor runs in **Standby mode** as a remote MCP server. Connect your AI client to:

```
https://<APIFY_USERNAME>--payment-reconciliation-mcp.apify.actor/mcp
```

Authenticate with your **Apify API token** (Apify Console → Settings → API & Integrations), and pass your gateway keys as headers. You only need the gateways you use:

| Header | Value |
|---|---|
| `Authorization` | `Bearer <your Apify API token>` |
| `X-MCP-Stripe-Secret-Key` | Stripe restricted read-only key `rk_live_...` |
| `X-MCP-Razorpay-Key-Id` / `X-MCP-Razorpay-Key-Secret` | Razorpay key pair |
| `X-MCP-Paypal-Client-Id` / `X-MCP-Paypal-Client-Secret` | PayPal REST app (Transaction Search enabled) |
| `X-MCP-Paypal-Environment` | `sandbox` (optional, default `live`) |
| `X-MCP-Timezone` | e.g. `Asia/Kolkata` (optional, default `UTC`) |

**Cursor / Windsurf / VS Code** (remote server with headers):

```json
{
  "mcpServers": {
    "payments": {
      "url": "https://<APIFY_USERNAME>--payment-reconciliation-mcp.apify.actor/mcp",
      "headers": {
        "Authorization": "Bearer <APIFY_TOKEN>",
        "X-MCP-Stripe-Secret-Key": "rk_live_...",
        "X-MCP-Timezone": "Asia/Kolkata"
      }
    }
  }
}
```

**Claude Code**

```bash
claude mcp add --transport http payments https://<APIFY_USERNAME>--payment-reconciliation-mcp.apify.actor/mcp \
  --header "Authorization: Bearer <APIFY_TOKEN>" \
  --header "X-MCP-Stripe-Secret-Key: rk_live_..."
```

**Claude Desktop** (via `mcp-remote`):

```json
{
  "mcpServers": {
    "payments": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://<APIFY_USERNAME>--payment-reconciliation-mcp.apify.actor/mcp",
               "--header", "Authorization:Bearer <APIFY_TOKEN>",
               "--header", "X-MCP-Stripe-Secret-Key:rk_live_..."]
    }
  }
}
```

**Pricing:** pay per event, charged per successful tool call. Failed calls and the `list_gateways` setup check are free. Your keys are used only for the current session and are never stored or logged.

### 1. Requirements (self-hosted)

- Node.js **18.17+**
- Credentials for **at least one** gateway:

| Gateway | What you need | Where |
|---|---|---|
| **Stripe** | `STRIPE_SECRET_KEY`. Recommended: a **restricted key** with *Read* on Charges, Refunds, Disputes, Payouts, Balance and Balance transactions | Dashboard → Developers → API keys → *Create restricted key* |
| **Razorpay** | `RAZORPAY_KEY_ID` + `RAZORPAY_KEY_SECRET` | Dashboard → Account & Settings → API Keys |
| **PayPal** | `PAYPAL_CLIENT_ID` + `PAYPAL_CLIENT_SECRET` from a REST app with **Transaction Search** enabled (`PAYPAL_ENVIRONMENT=sandbox` for sandbox) | developer.paypal.com → Apps & Credentials |

Test-mode keys (`sk_test_`, `rzp_test_`, sandbox) work too, which makes them perfect for trying the server safely.

### 2. Install & verify

Unzip anywhere. It's already built, so you don't need `npm install`.

```bash
## macOS / Linux
STRIPE_SECRET_KEY=rk_live_... REPORT_TIMEZONE=Asia/Kolkata node dist/index.js --check
## Windows PowerShell
$env:STRIPE_SECRET_KEY="rk_live_..."; node dist/index.js --check
```

```
✔ stripe   connected: Acme Store (live)
· razorpay not configured
· paypal   not configured
All good: the server is ready to use.
```

### 3. Connect your AI client

**Claude Desktop** (*Settings → Developer → Edit Config*), **Cursor** (`~/.cursor/mcp.json`), **Windsurf**:

```json
{
  "mcpServers": {
    "payments": {
      "command": "node",
      "args": ["/ABSOLUTE/PATH/TO/payment-reconciliation-mcp/dist/index.js"],
      "env": {
        "STRIPE_SECRET_KEY": "rk_live_...",
        "RAZORPAY_KEY_ID": "rzp_live_...",
        "RAZORPAY_KEY_SECRET": "...",
        "PAYPAL_CLIENT_ID": "...",
        "PAYPAL_CLIENT_SECRET": "...",
        "REPORT_TIMEZONE": "Asia/Kolkata"
      }
    }
  }
}
```

**Claude Code**

```bash
claude mcp add payments -e STRIPE_SECRET_KEY=rk_live_... -e REPORT_TIMEZONE=Asia/Kolkata -- node /ABSOLUTE/PATH/TO/payment-reconciliation-mcp/dist/index.js
```

**VS Code** (`.vscode/mcp.json`): see `examples/vscode-mcp.json`. VS Code prompts for each key and stores it securely.

**Hosted (no install):** subscribe on MCPize and paste your keys there. See [MCPIZE.md](MCPIZE.md).

### 4. Tools (17, all read-only)

| Tool | What it answers |
|---|---|
| `list_gateways` | Which gateways are connected, live/test mode, and whether the credentials work |
| `get_balances` | Available and pending balance per gateway and currency |
| `list_transactions` | Unified payments and refunds, filtered by type, status, currency, amount or email |
| `get_transaction` | Full details for any `ch_`/`pi_`/`re_`/`po_`, `pay_`/`rfnd_`/`order_`/`setl_`, or PayPal id |
| `search_payments` | "Did order #1042 get paid?": search by email, name, order reference, id or amount |
| `customer_history` | Everything a customer paid, failed, refunded or disputed, across gateways |
| `revenue_summary` | Gross, refunds, fees, **net**, payments, average payment, failure rate, customers, daily series, method split |
| `compare_periods` | **Why revenue changed**: count vs basket size vs failures vs refunds vs method shifts |
| `failed_payments_report` | Decline reasons with fix suggestions, failures by method, revenue lost, customers to win back |
| `fee_analysis` | Effective fee % by gateway and method, plus savings from routing to the cheapest gateway |
| `find_duplicate_charges` | Same customer, same amount, within minutes: probable double charges to refund |
| `reconcile_orders` | Store orders (CSV/JSON) vs real payments: missing money, mismatches, duplicates, refund gaps |
| `payouts_report` | Stripe payouts, Razorpay settlements (UTR) and PayPal withdrawals, with failed payouts flagged |
| `payout_breakdown` | Every payment, refund and fee inside one Stripe payout or Razorpay settlement |
| `refunds_report` | Refund totals, refund rate, pending/failed refunds, repeat refunders |
| `disputes_report` | Chargebacks needing a response (days left), amount at risk, win rate |
| `generate_finance_report` | Ready-to-share Markdown report with period comparison and action items |

Common arguments: `gateways` (e.g. `["stripe","razorpay"]`), `period` (`today`, `yesterday`, `last_7_days`, `last_30_days`, `last_90_days`, `this_month`, `last_month`, `this_year`) or `from`/`to` dates, and `currency`.

#### Order reconciliation

Export orders from your store and pass the file content as `orders`:

- **WooCommerce:** *Orders → Export* (or any CSV export plugin)
- **Shopify:** *Orders → Export → CSV*
- **Laravel / custom:** any CSV or JSON with an order id and total

Columns are detected automatically. The id can be `order_id`, `order number`, `number`, `name` or `id`. The total can be `total`, `order total`, `amount` or `total_price`. Optional columns are currency, status, email and date. European number formats (`1.234,50`) work too.

Matching uses order references found in gateway metadata (Stripe `metadata.order_id`, Razorpay `notes.woocommerce_order_number`, PayPal `invoice_id`, and others), so `1042`, `#1042`, `WC-1042` and `Order 1042` all match. Orders without a reference fall back to amount + email + time.

### 5. Prompts

`daily_payments_check`, `month_end_close`, `investigate_revenue_drop`, `reconcile_store_orders` and `dispute_triage` are ready-made workflows. Open them from your client's prompt menu.

### 6. Configuration

| Variable | Default | Description |
|---|---|---|
| `REPORT_TIMEZONE` | `UTC` | IANA zone for periods and daily grouping, e.g. `Asia/Kolkata`, `America/New_York` |
| `PAYMENT_GATEWAYS` | all | Limit to `stripe,razorpay,paypal` |
| `MAX_TRANSACTIONS` | `5000` | Cap per gateway per call (results say when it's reached) |
| `MCP_TOOLSETS` | `all` | `gateways,transactions,analytics,reconciliation,reports` |
| `MCP_DISABLED_TOOLS` | — | Hide specific tools |
| `API_TIMEOUT_MS` / `API_MAX_RETRIES` | `30000` / `3` | Network behaviour |
| `PORT` / `MCP_HTTP_*` | — | HTTP mode (see below) |

### 7. HTTP / Docker / hosted mode

```bash
node dist/index.js --http --port 3000          # http://127.0.0.1:3000/mcp, health at /health
docker build -t payment-reconciliation-mcp . && docker run -p 3000:8080 --env-file .env payment-reconciliation-mcp
```

**Multi-tenant:** each request can carry its own keys in `X-MCP-Stripe-Secret-Key`, `X-MCP-Razorpay-Key-Id`, `X-MCP-Razorpay-Key-Secret`, `X-MCP-Paypal-Client-Id`, `X-MCP-Paypal-Client-Secret` and `X-MCP-Paypal-Environment`. When any of these headers is present, **only** those keys are used, and the server's own environment keys are never mixed in. Sessions are bound to a hash of the keys. Set `MCP_HTTP_AUTH_TOKEN` when exposing the server yourself.

### 8. Security

- Read-only: the code only performs `GET` requests, plus the PayPal OAuth token request.
- Use **restricted read-only Stripe keys**. Razorpay keys are full-access by design, so store them only in your MCP client's secret storage.
- Keys are never logged or included in tool output, and error messages are redacted (`sk_live_***`).
- No database and no telemetry: data flows only between your machine (or your MCPize session) and the gateways.

### 9. Accuracy notes

- **Net** = gross collected − refunds issued in the period − processing fees (cash basis). Razorpay fees include GST.
- Amounts are reported **per currency**. Different currencies are never added together.
- PayPal's Transaction Search covers completed, pending, denied and reversed transactions (no abandoned checkouts) and can lag up to ~3 hours. PayPal doesn't link bank withdrawals to individual transactions.
- Razorpay doesn't expose the gateway balance via its API.

### 10. Development

```bash
npm install && npm test     # 52 tests, fully mocked, no network needed
```

`src/gateways/*` holds one adapter per gateway behind a common interface. Adding Cashfree, PayU, Paddle or Square means writing one new file.

### Support

Contact the author through the marketplace where you bought the product. Include the output of `node dist/index.js --check`, which never prints keys.

# Changelog

This Actor's version history is a separate document: https://apify.com/amirkhan_dev_crx/payment-reconciliation-mcp/changelog.md

# Actor input Schema

## Actor input object example

```json
{}
```

# Actor output Schema

## `mcpServer` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("amirkhan_dev_crx/payment-reconciliation-mcp").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("amirkhan_dev_crx/payment-reconciliation-mcp").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call amirkhan_dev_crx/payment-reconciliation-mcp --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,amirkhan_dev_crx/payment-reconciliation-mcp"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/QMrxb1a9aq49nVr0Q/builds/gYNazQuzdQSX1cXKD/openapi.json
