Hanzo
CommerceCommerce Modules

Payment Module

Payment providers, authorization, capture, refunds, and webhooks

The Payment module orchestrates payment processing across multiple providers with a unified interface for authorization, capture, and refunds.

Payment Flow

Authorize ──► Hold funds on customer's payment method

    ├── Capture ──► Collect the held funds

    ├── Cancel  ──► Release the hold

    └── (timeout) ──► Auto-void after configurable window

Supported Providers

ProviderMethodsFeatures
StripeCards, ACH, Apple Pay, Google Pay3D Secure, subscriptions
PayPalPayPal balance, cardsExpress checkout
Authorize.netCardsLegacy support
EthereumETH, ERC-20 tokensOn-chain verification
BitcoinBTC, LightningQR code payment

Data Model

{
  "id": "pay_xyz789",
  "orderId": "order_abc123",
  "provider": "stripe",
  "status": "captured",
  "amount": 6791,
  "currency": "USD",
  "providerPaymentId": "pi_1234567890",
  "capturedAt": "2025-01-15T10:35:00Z",
  "metadata": {
    "stripePaymentIntentId": "pi_1234567890"
  }
}

API Examples

Authorize a Payment

curl -X POST https://api.hanzo.ai/checkout/authorize \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "orderId": "order_abc123",
    "paymentMethod": "stripe",
    "paymentIntentId": "pi_1234567890"
  }'

Capture Payment

curl -X POST https://api.hanzo.ai/checkout/capture \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"orderId": "order_abc123", "paymentId": "pay_xyz789"}'

Issue a Refund

curl -X POST https://api.hanzo.ai/checkout/refund \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "orderId": "order_abc123",
    "paymentId": "pay_xyz789",
    "amount": 2999,
    "reason": "customer_request"
  }'

Webhook Events

Register for payment events to keep your systems in sync:

curl -X POST https://api.hanzo.ai/webhook \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://yourserver.com/webhooks",
    "events": [
      "payment.authorized",
      "payment.captured",
      "payment.refunded",
      "payment.failed"
    ]
  }'

Configuration

payment:
  providers:
    stripe:
      enabled: true
      secret_key: ${STRIPE_SECRET_KEY}
      webhook_secret: ${STRIPE_WEBHOOK_SECRET}
    paypal:
      enabled: true
      client_id: ${PAYPAL_CLIENT_ID}
      client_secret: ${PAYPAL_CLIENT_SECRET}
      mode: live  # sandbox | live
    ethereum:
      enabled: false
      rpc_url: ${ETH_RPC_URL}
  auto_capture: false         # capture immediately on authorize
  capture_deadline_days: 7    # void uncaptured after N days

Never log or store raw card numbers or CVVs. Always use tokenized payment methods provided by the payment processor.

How is this guide?

Last updated on

On this page