npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

paywize-merchant-sdk

v1.0.0

Published

PayWize SDK for merchant data encryption and decryption

Downloads

6

Readme

PayWize SDK

Official PayWize SDK for merchant data encryption and decryption using AES-256-CBC algorithm.

Installation

npm install paywize-merchant-sdk

Features

  • AES-256-CBC encryption and decryption
  • TypeScript support with full type definitions
  • Both class-based and functional API
  • Comprehensive error handling
  • Zero dependencies (uses Node.js built-in crypto module)

Usage

Class-Based API (Recommended)

Initialize the SDK once and reuse the instance:

import { PayWizeSDK } from 'paywize-merchant-sdk';

// Initialize SDK with your credentials
const sdk = new PayWizeSDK({
  key: 'your-32-character-encryption-key',
  iv: 'your-16-char-iv'
});

// Encrypt data
const encryptionResult = sdk.encrypt('Hello World');
if (encryptionResult.success) {
  console.log('Encrypted:', encryptionResult.data);
} else {
  console.error('Encryption failed:', encryptionResult.error);
}

// Decrypt data
const decryptionResult = sdk.decrypt(encryptionResult.data!);
if (decryptionResult.success) {
  console.log('Decrypted:', decryptionResult.data);
} else {
  console.error('Decryption failed:', decryptionResult.error);
}

// Update credentials if needed
sdk.updateCredentials({
  key: 'new-32-character-encryption-key',
  iv: 'new-16-char-iv'
});

Functional API

For one-off encryption/decryption operations:

import { encryptData, decryptData } from 'paywize-merchant-sdk';

const key = 'your-32-character-encryption-key';
const iv = 'your-16-char-iv';

try {
  // Encrypt
  const encrypted = encryptData('Hello World', key, iv);
  console.log('Encrypted:', encrypted);

  // Decrypt
  const decrypted = decryptData(encrypted, key, iv);
  console.log('Decrypted:', decrypted);
} catch (error) {
  console.error('Error:', error.message);
}

JavaScript (CommonJS)

const { PayWizeSDK, encryptData, decryptData } = require('paywize-merchant-sdk');

// Class-based API
const sdk = new PayWizeSDK({
  key: 'your-32-character-encryption-key',
  iv: 'your-16-char-iv'
});

const result = sdk.encrypt('Hello World');
console.log(result);

// Functional API
const encrypted = encryptData('Hello World',
  'your-32-character-encryption-key',
  'your-16-char-iv'
);
console.log(encrypted);

API Reference

Class: PayWizeSDK

Constructor

constructor(config: EncryptionConfig)

Initialize the SDK with encryption credentials.

Parameters:

  • config.key (string): Encryption key (minimum 32 characters)
  • config.iv (string): Initialization vector (minimum 16 characters)

Throws:

  • Error if key or iv is missing or too short

Methods

encrypt(data: string): EncryptionResult

Encrypts the provided data.

Parameters:

  • data (string): Plain text data to encrypt

Returns:

{
  success: boolean;
  data?: string;      // Base64 encoded encrypted data
  error?: string;     // Error message if failed
}
decrypt(encryptedData: string): DecryptionResult

Decrypts the provided encrypted data.

Parameters:

  • encryptedData (string): Base64 encoded encrypted data

Returns:

{
  success: boolean;
  data?: string;      // Decrypted plain text
  error?: string;     // Error message if failed
}
updateCredentials(config: EncryptionConfig): void

Updates the encryption credentials.

Parameters:

  • config.key (string): New encryption key
  • config.iv (string): New initialization vector

Functions

encryptData(data: string, key: string, iv: string): string

Standalone function to encrypt data.

Parameters:

  • data (string): Plain text to encrypt
  • key (string): Encryption key (minimum 32 characters)
  • iv (string): Initialization vector (minimum 16 characters)

Returns: Base64 encoded encrypted string

Throws: Error if encryption fails

decryptData(encryptedData: string, key: string, iv: string): string

Standalone function to decrypt data.

Parameters:

  • encryptedData (string): Base64 encoded encrypted data
  • key (string): Decryption key (minimum 32 characters)
  • iv (string): Initialization vector (minimum 16 characters)

Returns: Decrypted plain text string

Throws: Error if decryption fails

TypeScript Support

The SDK includes full TypeScript definitions. All types are exported:

import {
  PayWizeSDK,
  EncryptionConfig,
  EncryptionResult,
  DecryptionResult,
  encryptData,
  decryptData
} from 'paywize-merchant-sdk';

Error Handling

Class-Based API

The class-based API returns result objects with error information:

const result = sdk.encrypt('data');
if (!result.success) {
  console.error('Failed:', result.error);
}

Functional API

The functional API throws errors:

try {
  const encrypted = encryptData('data', key, iv);
} catch (error) {
  console.error('Failed:', error.message);
}

Requirements

  • Node.js >= 14.0.0

Security Notes

  • Keep your encryption keys and IVs secure
  • Never commit credentials to version control
  • Use environment variables for production deployments
  • The key must be at least 32 characters (AES-256 requirement)
  • The IV must be at least 16 characters (AES block size)

License

MIT

Support

For issues and questions, please contact PayWize support or open an issue on GitHub.