Build with AI assistants
AI coding assistants can write most of a NogorPay integration for you if you give them the right facts. Copy the prompt below, adjust the framework, and paste it into your assistant.
Integrate NogorPay hosted checkout into my <framework> application.
API facts:- Base URL: https://api.nogorpay.com/api/v1- Auth: send the secret key in the NOGORPAY-API-KEY header. Read it from the NOGORPAY_API_KEY environment variable. Only call the API from the server.- GET /charge/methods?brand_id=... lists active payment methods. Each method has id, name, provider (bkash|nagad|rocket|upay), logo, min_amount, max_amount.- POST /charge/create with JSON: amount (required, BDT), at least one of customer_name / customer_phone / customer_email, plus optional order_id, payment_method (provider code), brand_id, expiry_minutes (1-1440), redirect_url, cancel_url, webhook_url, metadata. Returns 201 with invoice_id, session_id, payment_url, expires_at, expires_in_seconds. Redirect the customer to payment_url.- GET /charge/verify/{invoice_id} returns status: pending | verifying | completed | cancelled | expired, plus amount and trx_id when completed. Treat pending after expires_at as expired.- Webhooks: POST to webhook_url with events charge.completed and charge.cancelled. Header NOGORPAY-SIGNATURE = "sha256=" + hex HMAC-SHA256 of the raw body using the API key. Verify with a constant-time compare. Retries happen, so handle duplicates by invoice_id. Return 2xx within 10s.
Build:1. A server function to create a charge for an order and redirect to payment_url.2. A webhook endpoint that verifies the signature, checks amount, and marks the order paid idempotently.3. A return page that shows the order status, calling the verify API if the webhook hasn't arrived.Add types and error handling.For full details, point the assistant at the API reference and Webhook events pages.
