Registry / payments / safecharge

safecharge

JSON →
library1.0.1jsnpmunverified

SafeCharge REST API SDK for Node.js enabling merchants to process payments via SafeCharge's payment gateway. Supports payment cards, alternative payment methods, and multiple PCI levels. Current version 1.0.1, no recent updates (appears unmaintained). Key differentiator: direct REST API wrapper for SafeCharge's PSP. Alternative: use official REST API over HTTPS. Note: library uses callbacks, not promises; last release lacks TypeScript definitions and modern ESM support.

npm install safecharge
INSTALL
IMPORT
SIG · SAFECHARGE
S
safecharge
paymentsjavascriptv1.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

safecharge
const safecharge = require('safecharge');
import safecharge from 'safecharge';
CommonJS only; no default ESM export. Named import does not exist.
initiate
safecharge.initiate(merchantId, merchantSiteId, merchantSecretKey, env);
safecharge.initiate({merchantId, merchantSiteId, merchantSecretKey, env});
Parameters are positional, not an options object.
setAlgorithm
safecharge.setAlgorithm('md5');
safecharge.setAlgorithm('sha256');
Default is sha256; only set if account requires md5. No other algorithms supported.

Initializes the SafeCharge SDK with test credentials, then processes a credit card payment with error handling callback.

const safecharge = require('safecharge'); const merchantId = process.env.SAFECHARGE_MERCHANT_ID ?? ''; const merchantSiteId = process.env.SAFECHARGE_SITE_ID ?? ''; const secretKey = process.env.SAFECHARGE_SECRET_KEY ?? ''; safecharge.initiate(merchantId, merchantSiteId, secretKey, 'test'); const paymentParams = { currency: 'USD', amount: '9.99', paymentOption: { card: { cardNumber: '4111111111111111', cardHolderName: 'John Smith', expirationMonth: '12', expirationYear: '2025', CVV: '123' } } }; safecharge.payment(paymentParams, (error, response) => { if (error) { console.error('Payment failed:', error); } else { console.log('Payment success:', response); } });
Debug
Known issues
deprecatedLibrary uses callback pattern; no promise support.
fix
Wrap calls in new Promise((resolve, reject) => safecharge.payment(params, (err, res) => err ? reject(err) : resolve(res))); or migrate to a modern SDK.
affects: >=0.0.0
gotchaIncorrect algorithm throws silent errors or fails validation.
fix
Ensure setAlgorithm('md5') is called before any payment request if account uses MD5.
affects: >=0.0.0
gotchaMerchant ID and site ID are numbers but passed as strings; library does not validate types.
fix
Pass merchantId and siteId as strings; avoid leading zeros in numeric IDs.
affects: >=0.0.0
deprecatedNo official support for Node.js >=12; may break in newer versions.
fix
Test with your Node version; consider using http.request directly.
affects: >=0.0.0
Errors
Common errors & fixes
safecharge.initiate is not a function
Imported incorrectly (ESM import used with CommonJS only library).
fix
Use require('safecharge') instead of import.
Cannot read property 'payment' of undefined
forgot to call initiate() before using SDK methods.
fix
call safecharge.initiate(...) at the start of your application.
Invalid signature
Wrong secret key or hashing algorithm mismatch.
fix
Double-check merchantSecretKey and call setAlgorithm('md5') if using older account.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
39 hits · last 30 days
node
36
Resources
safecharge — npm install safecharge · libregistry