zarinpal-typescript
v3.0.1
Published
Simple Zarinpal package written in TypeScript.
Downloads
7
Readme
Simple Zarinpal package written in TypeScript.
Installation
# Using npm
npm i zarinpal-typescript
# Using yarn
yarn add zarinpal-typescript
Configuration
import { Zarinpal } from "zarinpal-typescript";
const zp = new Zarinpal("merchant-code", {
/**
* Sandbox is for development only
* And should be turned off in production.
*/
sandbox: true,
});
Creating invoice
// Create invoice
const createdPayment = await zp.requestPayment({
amount: 1000, // Toman
callbackUrl: "https://example.com/my-call-back-url?custom-param=value",
description: "Invoice description", // This is required!
});
// Redirect user to the createdPayment.url
Verifying the payment (callback)
const amount = 1000;
const authority = "previously-created-authority";
const verifiedPayment = await zp.verifyPayment({ amount, authority });