New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

zarinpal-typescript

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zarinpal-typescript

Simple Zarinpal package written in TypeScript.

  • 2.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-60%
Maintainers
1
Weekly downloads
 
Created
Source

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 invoiceResponse = await zp.requestPayment({
    amount: 1000, // Toman
    callbackUrl: 'https://example.com/my-call-back-url?custom-param=value',
    description: 'Invoice description', // This is required!
});

// Check for any errors
if (invoiceResponse.errorMessage) throw new Error(invoiceResponse.errorMessage);

// Get payment url
const paymentUrl = zp.startPayment(invoiceResponse.Authority);

// Redirect user to the paymentUrl

Verifying the payment (callback)

const amount = 1000;
const authority = 'invoice-authority';

const verificationResponse = await zp.verifyPayment({ amount: amount, authority: authority });

// Check for errors
if (verificationResponse.errorMessage) throw new Error(verificationResponse.errorMessage);

switch(verificationResponse.Status) {
    case 100:
        // Invoice paid
        break;
    case 101:
        // Invoice is already paid.
        break;
}

FAQs

Package last updated on 20 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc