Create Payment
Create a new payment request via the Payzava API
Create a payment request to accept payments from your customers.
Endpoint
POST /payment/create
Request headers
| Header | Required | Description |
|---|---|---|
x-api-key | Yes | Your API key |
Content-Type | Yes | application/json |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
amount | number | Yes | Payment amount in BDT |
description | string | Yes | Description of the payment (e.g., order ID) |
paymentMethodId | string | Yes | ID of the payment method (from GET /payment/methods) |
redirect_url | string | Yes | URL to redirect the customer after payment |
callback_url | string | Yes | URL for server-to-server status callbacks |
suggestedPayerNumber | string | No | Pre-fill the customer's phone number |
gatewayType | string | No | Gateway type identifier |
note | string | No | Internal note for your reference |
Response
{
"success": true,
"data": {
"transactionId": "txn_abc123def456",
"payment_url": "https://sandbox.payzava.com/pay/txn_abc123def456",
"amount": 100,
"status": "Processing"
}
}
Response fields
| Field | Description |
|---|---|
transactionId | Unique identifier for this payment. Use it to retrieve status later. |
payment_url | Redirect your customer to this URL to complete payment. |
amount | The payment amount. |
status | Current status: Processing. |
Example
const axios = require("axios");
const response = await axios.post(
"https://sandbox.payzava.com/cp/api/v1/payment/create",
{
amount: 500,
description: "Order #67890",
paymentMethodId: "your_payment_method_id",
redirect_url: "https://yoursite.com/payment/complete",
callback_url: "https://yourserver.com/webhooks/payzava",
suggestedPayerNumber: "01712345678",
note: "Premium plan subscription",
},
{
headers: {
"Content-Type": "application/json",
"x-api-key": "sk_sandbox_your_api_key",
},
}
);
const { transactionId, payment_url } = response.data.data;
// Redirect the user to complete payment
// In a web app: res.redirect(payment_url)
console.log("Payment URL:", payment_url);
console.log("Transaction ID:", transactionId);
After creating a payment
- Redirect your customer to the
payment_url. They will complete the payment on the Payzava hosted page. - After redirect, verify the payment status via the retrieve endpoint.
- Callbacks will be sent to your
callback_urlwhen status changes. Always verify via the retrieve endpoint.
Note:
Always call the retrieve endpoint to verify payment status. Never rely solely on redirect parameters or callback data.