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/paymentsRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
amount | number | ✓ | Payment amount in the specified currency |
currency | string | ✓ | Three-letter ISO currency code (e.g., USD, EUR, GBP) |
customerEmail | string | ✓ | Customer's email address for receipts |
description | string | - | Description of the payment |
metadata | object | - | Custom key-value pairs for your reference |
successUrl | string | - | URL to redirect after successful payment |
cancelUrl | string | - | URL to redirect if payment is cancelled |
webhookUrl | string | - | 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
| Field | Description |
|---|---|
id | Unique identifier for the payment |
url | Hosted payment page URL - redirect your customer here |
status | Payment status: pending, processing, completed, failed, or cancelled |
expiresAt | Payment 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
Create Payment
Your server creates a payment using the Hedge Payments API
Redirect Customer
Redirect your customer to the hosted payment page URL
Customer Pays
Customer selects payment method and completes transaction
Webhook Notification
Hedge sends a webhook to your server with payment status
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.