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:
-
Details about the payment
referenceId
: The ID that references the ongoing payment, you probably want to store it in your database.
-
Details about how to send the user
url
: The url that you should send the user tomethod
: The method with which you should send the user with. Can beGET
orPOST
depending on the driverparams
: The data that you should send the user with