Create a charge
POSThttps://api.nogorpay.com/api/v1/charge/create
Creates a payment session and returns a payment_url for the NogorPay hosted checkout. Redirect your customer to that URL to pay.
Request body
Section titled “Request body”| Field | Type | Required | Description |
|---|---|---|---|
amount |
number | Yes | Amount in BDT. Must be greater than 0, for example 1500. |
customer_name |
string | One of three | Customer’s full name. |
customer_phone |
string | One of three | Customer’s phone number, for example 01712345678. |
customer_email |
string | One of three | Customer’s email address. |
order_id |
string | No | Your own order reference. You can use it later to verify the charge. |
invoice_id |
string | No | Your own invoice ID. If you leave it out, NogorPay generates one like INV-7K9X2P8M. |
payment_method |
string | No | Provider code to pre-select: bkash, nagad, rocket or upay. The customer skips the method selection screen. |
brand_id |
string | No | 6-character brand ID to charge under, for example B9X7K2. Defaults to your default brand. |
expiry_minutes |
integer | No | How long the checkout stays open, from 1 to 1440. See Checkout expiry. |
redirect_url |
string | No | Where to send the customer after a successful payment. |
cancel_url |
string | No | Where to send the customer if they cancel. |
webhook_url |
string | No | Where NogorPay sends webhook events for this charge. The domain must be in your Allowed Webhook Domains. |
metadata |
object | No | Any JSON object you want back in webhooks, for example { "cart_id": "c_981" }. |
You must send at least one of customer_name, customer_phone or customer_email.
Request
Section titled “Request”curl -X POST https://api.nogorpay.com/api/v1/charge/create \ -H "NOGORPAY-API-KEY: $NOGORPAY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "amount": 1500, "customer_name": "Rahim Ahmed", "customer_phone": "01712345678", "customer_email": "customer@example.com", "order_id": "ORDER-1042", "payment_method": "bkash", "expiry_minutes": 15, "redirect_url": "https://yourstore.com/checkout/success", "cancel_url": "https://yourstore.com/checkout/cancel", "webhook_url": "https://yourstore.com/api/nogorpay/webhook", "metadata": { "cart_id": "c_981" } }'async function createCharge(order) { const res = await fetch('https://api.nogorpay.com/api/v1/charge/create', { method: 'POST', headers: { 'NOGORPAY-API-KEY': process.env.NOGORPAY_API_KEY, 'Content-Type': 'application/json', }, body: JSON.stringify({ amount: order.total, customer_name: order.customerName, customer_phone: order.customerPhone, order_id: order.id, payment_method: 'bkash', expiry_minutes: 15, redirect_url: 'https://yourstore.com/checkout/success', cancel_url: 'https://yourstore.com/checkout/cancel', webhook_url: 'https://yourstore.com/api/nogorpay/webhook', }), });
const data = await res.json(); if (!data.success) throw new Error(data.message); return data; // redirect the customer to data.payment_url}<?phpfunction create_nogorpay_charge(array $order): array{ $ch = curl_init('https://api.nogorpay.com/api/v1/charge/create'); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ 'NOGORPAY-API-KEY: ' . getenv('NOGORPAY_API_KEY'), 'Content-Type: application/json', ], CURLOPT_POSTFIELDS => json_encode([ 'amount' => $order['total'], 'customer_name' => $order['customer_name'], 'customer_phone' => $order['customer_phone'], 'order_id' => $order['id'], 'payment_method' => 'bkash', 'expiry_minutes' => 15, 'redirect_url' => 'https://yourstore.com/checkout/success', 'cancel_url' => 'https://yourstore.com/checkout/cancel', 'webhook_url' => 'https://yourstore.com/api/nogorpay/webhook', ]), ]); $data = json_decode(curl_exec($ch), true); curl_close($ch);
if (empty($data['success'])) { throw new RuntimeException($data['message'] ?? 'NogorPay request failed'); } return $data; // header('Location: ' . $data['payment_url']);}import osimport requests
def create_charge(order): res = requests.post( "https://api.nogorpay.com/api/v1/charge/create", headers={"NOGORPAY-API-KEY": os.environ["NOGORPAY_API_KEY"]}, json={ "amount": order["total"], "customer_name": order["customer_name"], "customer_phone": order["customer_phone"], "order_id": order["id"], "payment_method": "bkash", "expiry_minutes": 15, "redirect_url": "https://yourstore.com/checkout/success", "cancel_url": "https://yourstore.com/checkout/cancel", "webhook_url": "https://yourstore.com/api/nogorpay/webhook", }, timeout=15, ) data = res.json() if not data.get("success"): raise RuntimeError(data.get("message")) return data # redirect the customer to data["payment_url"]Response
Section titled “Response”A successful request returns 201 Created:
{ "success": true, "invoice_id": "INV-7K9X2P8M", "order_id": "ORDER-1042", "session_id": "cs_live_3f2a9c0e8b7d4e1fa6c5b4d3e2f1a0b9", "payment_method": "bkash", "payment_url": "https://pay.nogorpay.com/checkout/cs_live_3f2a9c0e8b7d4e1fa6c5b4d3e2f1a0b9?method=bkash", "expires_at": "2026-08-07T12:15:00.000Z", "server_time": "2026-08-07T12:00:00.000Z", "expires_in_seconds": 900}Response fields
Section titled “Response fields”| Field | Type | Description |
|---|---|---|
success |
boolean | true when the charge was created. |
invoice_id |
string | NogorPay invoice ID. Store it with your order. |
order_id |
string or null |
The order_id you sent. |
session_id |
string | Checkout session ID. |
payment_method |
string or null |
Pre-selected provider code, if you sent payment_method. |
payment_url |
string | Hosted checkout URL. Redirect the customer here. |
expires_at |
string | When the checkout closes (ISO 8601, UTC). |
server_time |
string | NogorPay server time when the charge was created. Use it with expires_in_seconds to show a countdown that doesn’t depend on the customer’s clock. |
expires_in_seconds |
integer | Seconds until the checkout closes. |
Errors
Section titled “Errors”| Status | message |
Cause |
|---|---|---|
400 |
Invalid request payload. Please provide a JSON request body ... |
The request body is empty. Check that you send JSON with Content-Type: application/json. |
400 |
amount is required in request body |
No amount. |
400 |
amount must be a valid positive number |
amount is 0, negative or not a number. |
400 |
At least one customer field (customer_name, customer_phone, or customer_email) is required |
No customer details. |
400 |
NogorPay Webhook URL is restricted. You must configure your authorized domain(s) ... |
You sent webhook_url but have no allowed webhook domains. |
400 |
Webhook domain 'example.com' is not authorized. ... |
The webhook_url domain isn’t in your allowed list. |
400 |
No brand configured for this merchant account. ... |
Your account has no brand, or brand_id doesn’t match one of your brands. |
403 |
Plan limit message, with "limitExceeded": true |
You’ve reached your plan’s monthly transaction limit ("resource": "transactions") or website limit ("resource": "websites"). |
{ "success": false, "message": "NogorPay Monthly transaction limit reached. Please upgrade your subscription on the Billing page to continue receiving payments.", "limitExceeded": true, "resource": "transactions"}