Skip to content

Latest commit

 

History

History
47 lines (35 loc) · 913 Bytes

README.md

File metadata and controls

47 lines (35 loc) · 913 Bytes

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 });