Skip to content

Simple package to interact with Zarinpal-API in TypeScript

License

Notifications You must be signed in to change notification settings

sorooshme/zarinpal-typescript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Simple package to interact with Zarinpal-API in TypeScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages