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

HeaderRequiredDescription
x-api-keyYesYour API key
Content-TypeYesapplication/json

Request body

FieldTypeRequiredDescription
amountnumberYesPayment amount in BDT
descriptionstringYesDescription of the payment (e.g., order ID)
paymentMethodIdstringYesID of the payment method (from GET /payment/methods)
redirect_urlstringYesURL to redirect the customer after payment
callback_urlstringYesURL for server-to-server status callbacks
suggestedPayerNumberstringNoPre-fill the customer's phone number
gatewayTypestringNoGateway type identifier
notestringNoInternal 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

FieldDescription
transactionIdUnique identifier for this payment. Use it to retrieve status later.
payment_urlRedirect your customer to this URL to complete payment.
amountThe payment amount.
statusCurrent 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

  1. Redirect your customer to the payment_url. They will complete the payment on the Payzava hosted page.
  2. After redirect, verify the payment status via the retrieve endpoint.
  3. Callbacks will be sent to your callback_url when 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.