1.0.0 • Published 7 years ago

coinpayments-ipn v1.0.0

Weekly downloads
346
License
ISC
Repository
github
Last release
7 years ago

Coinpayments-IPN

alt text

Module for verifing Coinpaymets Instant Payment notifications.

Installation

npm install coinpayments-ipn

Usage

/**
 *
 * @param {String} hmac
 * @param {String} ipnSecret
 * @param {Object} payload
 * @returns {Boolean}
 * @throws {CoinpaymentsIPNError}
 */
const { verify } = require('coinpaments-ipn');
const CoinpaymentsIPNError = require('coinpaments-ipn/lib/error');

let IsValid, error;

try {
  isValid = verify(hmac, ipnSecret, payload);
} catch (e) {
  error = e;
}
if (error) {
  if (error instanceof CoinpaymentsIPNError) {
    // handle invalid payload
  }
  // make bug report
}

if (isValid) {
  // valid
} else {
  // invalid
}

Example

A simple docker image can be found here.

1.0.0

7 years ago