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 🙏

© 2024 – Pkg Stats / Ryan Hefner

cardknox-api-wrapper

v1.0.1

Published

A Node.js wrapper for the Cardknox Gateway API, simplifying the implementation and integration of secure payment processing.

Downloads

19

Readme

Cardknox API Wrapper for Node.js

A comprehensive Node.js wrapper for the Cardknox Payment Gateway, allowing you to securely process credit card and ACH transactions.

Socket Badge npm GitHub issues NPM npm bundle size

Features

  • Fast and easy integration: Get started quickly with a simple API.
  • Pre-built request classes: Simplified request classes for various transactions.

Installation

Install via npm:

npm install cardknox-api-wrapper

Quick Start

Setting Up

To get started, you'll need your Cardknox API key. This key will be added to all your requests.

Here’s how to generate an API key:

  1. Sign in to the Cardknox Merchant Portal.
  2. Go to Account Settings.
  3. Select Keys, and then click Create a Key.
  4. Choose API or iFields, set the necessary permissions, and save the key securely.

Now, initialize CardknoxService:

const { CardknoxService } = require('cardknox-api-wrapper');

const cardknox = new CardknoxService('your-api-key', 'your-software-name', 'your-software-version');

Example: Processing a Credit Card Sale

const { CCSaleRequest } = require('cardknox-api-wrapper');

const saleRequest = new CCSaleRequest();
saleRequest.xCardNum = '4111111111111111';  // Card number
saleRequest.xExp = '1225';  // Expiration date (MMYY)
saleRequest.xAmount = '50.00';  // Transaction amount

cardknox.Process(saleRequest)
  .then(response => {
    if (response.xResult === 'A') {
      console.log('Payment Approved:', response.xAuthCode);
    } else {
      console.log('Payment Failed:', response.xError || response.xErrorCode);
    }
  })
  .catch(error => console.error('Transaction Error:', error));

Example: Processing an ACH Payment

For ACH payments, make sure to include the xName field along with routing and account numbers.

const { CheckSaleRequest } = require('cardknox-api-wrapper');

const achRequest = new CheckSaleRequest();
achRequest.xRouting = '123456789';  // Routing number
achRequest.xAccount = '987654321';  // Account number
achRequest.xAmount = '100.00';  // Amount in USD
achRequest.xName = 'John Doe';  // Name of the account holder

cardknox.Process(achRequest)
  .then(response => {
    if (response.xResult === 'A') {
      console.log('ACH Payment Approved:', response.xAuthCode);
    } else {
      console.log('Payment Failed:', response.xError);
    }
  })
  .catch(error => console.error('Transaction Error:', error));

Available Requests

The wrapper provides multiple request classes to cover various types of transactions. Below are the key requests available:

Credit Card Requests

  • CCSaleRequest: Process a credit card sale.
  • CCRefundRequest: Issue a refund for a credit card transaction.
  • CCVoidRequest: Void a previously processed credit card transaction.
  • CCCaptureRequest: Capture a pre-authorized credit card payment.
  • CCAuthRequest: Authorize a credit card without immediate capture.
  • CCAdjustRequest: Adjust a previously processed transaction.
  • CCAvsOnlyRequest: Perform an AVS (Address Verification System) check only.
  • CCSaveRequest: Save credit card details for future use.
  • CCVoidRefundRequest: If a credit card transaction has not yet settled, it will void the transaction. If it has settled, it will issue a full refund.
  • CCVoidReleaseRequest: Release a pending authorization amount back to the cardholder’s credit limit without waiting for the standard authorization time frame to expire.

ACH Requests

  • CheckSaleRequest: Process an ACH (check) payment.
  • CheckRefundRequest: Refund an ACH transaction.
  • CheckVoidRequest: Void a pending ACH transaction before submission to the bank.
  • CheckSaveRequest: Save ACH details for future use.
  • CheckVoidRefundRequest: Void an ACH transaction that is pending bank submission, typically at the end of the day, and issue a refund. Partial refunds are also supported.

Each request class corresponds to a specific transaction type, ensuring that the right fields are included based on the transaction requirements.

Handling Responses

The Cardknox API returns a CardknoxResponse object that includes important fields like xResult to indicate the status of the transaction:

  • A: Approved
  • D: Declined
  • E: Error

Here's how to handle the transaction response:

if (response.xResult === 'A') {
  console.log('Transaction Approved');
} else {
  console.log('Transaction Failed:', response.xError);
}

Official Documentation

For full details on the fields, commands, and additional transaction types, check out the official Cardknox documentation:

License

This project is licensed under the MIT License.