2.1.6 • Published 12 months ago

icadpay-sdk v2.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

IcadPay SDK

IcadPay SDK is a comprehensive and easy-to-use JavaScript SDK for integrating the IcadPay payment gateway into your web applications. It supports various payment methods, including card payments, USSD payments, QR codes, and bank transfers.

Features: Seamless integration with IcadPay's payment API. Support for multiple payment methods. Flexible configuration for custom integrations. Lightweight and optimized for performance. Built-in TypeScript support.

IcadPay SDK

IcadPay Logo
A simple and robust JavaScript SDK for integrating the IcadPay payment gateway.

šŸ“¦ Installation

Install the SDK via npm:

npm install icadpay-sdk

or via yarn:

yarn add icadpay-sdk

šŸ”§ Configuration

Using a .env File

To securely store your API keys and configurations, create a .env file in your project root and add:

ICADPAY_API_BASE_URL=https://icad-staging.icadpay.com/
MERCHANT_PUBLIC_KEY=your_public_key_here
DEBUG=true

Ensure you load the environment variables in your project:

import dotenv from "dotenv";
dotenv.config();

šŸš€ Usage

1ļøāƒ£ Initialize the SDK

import IcadPay from "icadpay-sdk";

const icadPay = IcadPay.initialize(process.env.MERCHANT_PUBLIC_KEY, { enableLogging: process.env.DEBUG === "true" });

šŸ›’ Payment Methods

2ļøāƒ£ Initiate Card Payment

const response = await icadPay.initiateCardPayment({
  customerId: "12345",
  amount: 1000,
  transactionRef: "txn_98765",
  deviceInformation: { userAgentBrowserValue: "Mozilla/5.0" },
  currency: "NGN",
  dataBlock: "cardData",
  callbackUrl: "https://your-website.com/callback",
  customerName: "John Doe",
  customerPhone: "555-1234",
  customerEmail: "john.doe@example.com",
});

console.log(response);

3ļøāƒ£ Initiate USSD Payment

const response = await icadPay.initiateUssdPayment({
  customerId: "12345",
  amount: 1000,
  transactionRef: "txn_98765",
  currency: "NGN",
  dataBlock: "ussdData",
  callbackUrl: "https://your-website.com/callback",
  customerName: "Jane Doe",
  customerPhone: "555-6789",
  customerEmail: "jane.doe@example.com",
});

4ļøāƒ£ Initiate Bank Transfer

const response = await icadPay.initiateBankTransfer({
  customerId: "12345",
  amount: 5000,
  transactionRef: "txn_56789",
  bankAccountNumber: "1234567890",
  bankCode: "XYZ",
  currency: "NGN",
  dataBlock: "bankTransferData",
  callbackUrl: "https://your-website.com/callback",
  customerName: "Mark Smith",
  customerPhone: "555-4321",
  customerEmail: "mark.smith@example.com",
});

5ļøāƒ£ Generate QR Code Payment

const response = await icadPay.generateQRCodePayment({
  customerId: "12345",
  amount: 2000,
  transactionRef: "txn_12345",
  currency: "NGN",
  dataBlock: "qrCodeData",
  callbackUrl: "https://your-website.com/callback",
  customerName: "Mike Johnson",
  customerPhone: "555-9876",
  customerEmail: "mike.johnson@example.com",
});

āœ… Verify Transactions

const response = await icadPay.verifyTransaction("txn_12345");
console.log(response);

ā— Error Handling

All API calls throw an error if something goes wrong:

try {
  const response = await icadPay.initiateCardPayment({...});
  console.log(response);
} catch (error) {
  console.error("Payment failed:", error.message);
}

šŸ“œ License

This SDK is licensed under the MIT License.


šŸ‘Øā€šŸ’» Contributing

We welcome contributions! To contribute:

  1. Fork the repository
  2. Create a new branch (git checkout -b feature-branch)
  3. Commit your changes (git commit -m "Added new feature")
  4. Push to the branch (git push origin feature-branch)
  5. Create a pull request

šŸ“ž Support

For any issues, feel free to open an issue or contact us at support@icadpay.com.


šŸš€ Happy Coding!

2.1.6

12 months ago

2.1.5

12 months ago

2.1.4

12 months ago

2.1.3

12 months ago

2.1.2

12 months ago

2.1.1

12 months ago

2.1.0

12 months ago

2.0.0

12 months ago

1.0.0

1 year ago