Create Payment

Accept crypto and fiat payments from your customers

Overview

The Create Payment endpoint generates a payment request that redirects your customer to a hosted payment page. Hedge Payments handles the entire payment flow, including currency selection, payment processing, and confirmations.

Endpoint

POST /api/payments

Request Parameters

ParameterTypeRequiredDescription
amountnumberPayment amount in the specified currency
currencystringThree-letter ISO currency code (e.g., USD, EUR, GBP)
customerEmailstringCustomer's email address for receipts
descriptionstring-Description of the payment
metadataobject-Custom key-value pairs for your reference
successUrlstring-URL to redirect after successful payment
cancelUrlstring-URL to redirect if payment is cancelled
webhookUrlstring-URL to receive payment status updates

Example Request

cURL

curl -X POST https://api.hedgepayments.com/api/payments \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 100.00,
    "currency": "USD",
    "customerEmail": "customer@example.com",
    "description": "Premium subscription - Monthly",
    "metadata": {
      "orderId": "order_12345",
      "customerId": "cust_67890"
    },
    "successUrl": "https://yourapp.com/success",
    "cancelUrl": "https://yourapp.com/cancel",
    "webhookUrl": "https://yourapp.com/webhooks/hedge"
  }'

Node.js

const payment = await hedge.payments.create({
  amount: 100.00,
  currency: 'USD',
  customerEmail: 'customer@example.com',
  description: 'Premium subscription - Monthly',
  metadata: {
    orderId: 'order_12345',
    customerId: 'cust_67890'
  },
  successUrl: 'https://yourapp.com/success',
  cancelUrl: 'https://yourapp.com/cancel',
  webhookUrl: 'https://yourapp.com/webhooks/hedge'
})

Python

payment = hedge.payments.create(
    amount=100.00,
    currency='USD',
    customer_email='customer@example.com',
    description='Premium subscription - Monthly',
    metadata={
        'order_id': 'order_12345',
        'customer_id': 'cust_67890'
    },
    success_url='https://yourapp.com/success',
    cancel_url='https://yourapp.com/cancel',
    webhook_url='https://yourapp.com/webhooks/hedge'
)

Response

A successful request returns a payment object with a unique ID and hosted payment page URL:

{
  "id": "pay_1234567890abcdef",
  "object": "payment",
  "amount": 100.00,
  "currency": "USD",
  "status": "pending",
  "customerEmail": "customer@example.com",
  "description": "Premium subscription - Monthly",
  "url": "https://pay.hedgepayments.com/pay_1234567890abcdef",
  "metadata": {
    "orderId": "order_12345",
    "customerId": "cust_67890"
  },
  "successUrl": "https://yourapp.com/success",
  "cancelUrl": "https://yourapp.com/cancel",
  "webhookUrl": "https://yourapp.com/webhooks/hedge",
  "createdAt": "2025-01-10T12:00:00Z",
  "expiresAt": "2025-01-10T13:00:00Z"
}

Response Fields

FieldDescription
idUnique identifier for the payment
urlHosted payment page URL - redirect your customer here
statusPayment status: pending, processing, completed, failed, or cancelled
expiresAtPayment link expiration time (1 hour from creation)

Supported Currencies

Hedge Payments supports 50+ cryptocurrencies and all major fiat currencies:

🪙 Cryptocurrencies

  • Bitcoin (BTC)
  • Ethereum (ETH)
  • USDC, USDT (Stablecoins)
  • Solana (SOL)
  • Polygon (MATIC)
  • And 45+ more...

💵 Fiat Currencies

  • USD - US Dollar
  • EUR - Euro
  • GBP - British Pound
  • JPY - Japanese Yen
  • CAD - Canadian Dollar
  • And 180+ more...

Payment Flow

1

Create Payment

Your server creates a payment using the Hedge Payments API

2

Redirect Customer

Redirect your customer to the hosted payment page URL

3

Customer Pays

Customer selects payment method and completes transaction

4

Webhook Notification

Hedge sends a webhook to your server with payment status

5

Customer Returns

Customer is redirected back to your successUrl or cancelUrl

💡 Best Practice:
Always rely on webhook notifications to confirm payment status. Don't trust the redirect alone, as customers may not complete the redirect flow.