Skip to content

Request Payment

Get the driver using getPaymentDriver and use the requestPayment method. This method accepts an object with callbackUrl, amount, and driver-specific fields.

import { getPaymentDriver } from "monopay";

const driver = getPaymentDriver("zarinpal")({
  merchantId: "zarinpal-merchant",
});

const paymentInfo = await driver.requestPayment({
  amount: 50000,
  callbackUrl: "https://my-site.com/callback",
  description: "Description about the transaction",
});

The returned value of requestPayment, is a class containing the following:

  1. Details about the payment

    • referenceId: The ID that references the ongoing payment, you probably want to store it in your database.
  2. Details about how to send the user

    • url: The url that you should send the user to
    • method: The method with which you should send the user with. Can be GET or POST depending on the driver
    • params: The data that you should send the user with