All requests need to set
api-key
to their peanut api key in their headers:Header | Value |
api-key | YOUR_PEANUT_API_KEY |
Create a New Payment
POST
https://api.peanut.to/charges
Request Body Parameters
Parameter | Type | Description | Example |
pricing_type | enum | Options: fixed_price, no_price | "fixed_price" |
local_price | object | Price information | {
"amount": "13.37",
"currency": "USD"
} |
metadata | [Optional] object | Arbitrary additional data. Returned in webhook call | { "item": "devcon_ticket" } |
redirect_url | [Optional] string | URL to redirect user to after successful payment. | "https://shopify.com/success" |
cancel_url | [Optional] string | URL to redirect user to if they cancel the payment | "https://shopify.com/failure" |
Example Request
javascriptconst res = await fetch('https://api.peanut.to/charges', { method: 'POST', headers: { "Content-Type": "application/json", 'api-key': "YOUR_API_KEY" }, body: JSON.stringify({ pricing_type: "fixed_price", local_price: { amount: "13.37", currency: "USD" }, redirect_url: "https://shopify.com/success", cancel_url: "https://shopify.com/cancel" }) }); const data = await res.json();
Example Response
json{ "data": { "id": "4f77223g-f5be-5e6d-bcb3-443f29gf5f5g", "hosted_url": "https://peanut.to/pay/4f77223g-f5be-5e6d-bcb3-443f29gf5f5g", "created_at": "2024-11-28T06:45:23.034Z", "metadata": { "userId": "0x742d35" }, "pricing_type": "fixed_price" } }
Fetch a single charge
GET
https://api.peanut.to/charges/{payment_id}
Example Request
javascriptconst response = await fetch('https://api.peanut.to/charges/4f77223g-f5be-5e6d-bcb3-443f29gf5f5g', { method: 'GET', headers: { 'api-key': 'YOUR_API_KEY' } }); const data = await response.json();
Fetch all your charges
GET
https://api.peanut.to/charges
Example Request
javascriptconst response = await fetch('https://api.peanut.to/charges', { method: 'GET', headers: { 'api-key': 'YOUR_API_KEY' } }); const data = await response.json();
Configure Payment Destination
POST
https://api.peanut.to/api-keys/receiving-wallet
Parameter | Type | Description |
walletAddress | string | Destination wallet address |
chainId | number | Blockchain network ID |
tokenAddress | string | Token contract address |
Example Request
javascriptconst res = await fetch('https://api.peanut.to/api-keys/receiving-wallet', { method: 'POST', headers: { 'Content-Type': 'application/json', 'api-key': 'YOUR_API_KEY' }, body: JSON.stringify({ walletAddress: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e', chainId: 10, tokenAddress: '0xdAC17F958D2ee523a2206206994597C13D831ec7' }) });
Configure Webhook
POST
https://api.peanut.to/api-keys/charge-webhook
Endpoint | Type | Description |
url | string | your receiving webhook URL |
Example Request
javascriptconst res = await fetch('https://api.peanut.to/api-keys/charge-webhook', { method: 'POST', headers: { 'Content-Type': 'application/json', 'api-key': 'YOUR_API_KEY' }, body: JSON.stringify({ url: 'https://shopify.com/webhook' }) });