node.js wrapper for Safecharge API

npm install safecharge
6 downloads in the last week
16 downloads in the last month


This module generates URL-s for the Safecharge PPP, and validates responses.


$ npm install safecharge


getPPPURL(items, options, [secret])


  name: 'Foo',
  amount: 19.95
}], {
  merchant_id: 'XXX',
  merchant_site_id: 'YYY',
}, 'ZZZ');

The following default values are used:

secret: process.env.SAFECHARGE_SECRET
merchant_id: process.env.SAFECHARGE_MERCHANT_ID
merchant_site_id: process.env.SAFECHARGE_MERCHANT_SITE_ID
curreny: 'USD'
version: '3.0.0'
handling: 0 (globally, and for each individual item)
shipping: 0 (globally, and for each individual item)
discount: 0 (globally, and for each individual item)
item.quantity: 1
total_tax: 0
time_stamp: the current time
total_amount: calculated according to the safecharge docs:
  total = shipping + handling - discount
  for each item
    total += (item.amount - + item.shipping + item.handling)*item.quantity
  total *= (1 + total_tax/100)

validate(checksum, data, [secret])

Validates Safecharges response against checksum.

data is an object, containing totalAmount, currency, responseTimeStamp, PPP_TransactionID, Status, productId fields.

secret defaults to process.env.SAFECHARGE_SECRET.

npm loves you