Skip to main content

NPM Library - Echezona Pop

A framework-agnostic JavaScript library for integrating with the Echezona API, a payment solution for seamless online transactions.

Installation

npm install echezona-pop

Usage

import EchezonaPayPop from "echezona-pop";

const payPop = new EchezonaPayPop();

payPop.newTransaction({
onSuccess: (transaction) => {
// Payment complete! transactionId: transaction.transactionId
},
onError: (error) => {
// Payment failed! Error message: error.message
},
onCancel: () => {
// user closed the popup
},
request: {
amount: "2000.00",
transactionId: Math.floor(Math.random() * 1000000),
email: "sample@mail.com",
publicKey: "xxxxxxxxxxxxxxxxxxxxxxxxxx",
currency: "NGN",
mode: "Live",
productId: "1001",
applyConviniencyCharge: true,
productDescription: "MTN",
bodyColor: "#0000",
buttonColor: "#0000",
footerText: "Powered by Echezona Ltd",
footerLink: "http://my-site.com",
footerLogo: "http://my-site.com/logo.png",
metadata: [
{
name: "sample",
value: "test",
},
],
},
});

Request Parameters for Initializing Payment

To initiate the transaction, you'll need to pass details like email, amount, transaction ID, public key, etc. Email and amount are required fields. Other optional details can be added to the metadata object. Below is a list of parameters you can use:

ParameterTypeDefaultRequiredDescription
amountstringundefinedtrueThe amount you want to debit from the customer, e.g., 1000.00, 10.00...
transactionIdstringundefinedtrueUnique, case-sensitive transaction ID
emailstringundefinedtrueCustomer's email address
publicKeystringundefinedtrueYour public key from EchezonaPay
currencystringNGNtrueCurrency for the transaction. Only NGN is supported
productIdstringundefinedfalseUnique ID for the product your customer is paying for
applyConviniencyChargebooleanfalsefalseWhether to apply a convenience fee for the transaction
productDescriptionstringundefinedfalseDescription of the product being purchased
modestringDebugtrueMode of operation: Test or Live
callBackUrlstringcurrent URLfalseURL to redirect the customer to upon successful payment
bodyColorstringnullfalseCustom color for the payment page body
buttonColorstringnullfalseCustom color for the payment page buttons
footerTextstringnullfalseCustom text for the payment page footer
footerLogostringnullfalseCustom logo for the payment page footer
metadataobject{}falseExtra metadata to attach to the transaction (can be any key-value pairs)

Example Callback

const payPop = new EchezonaPayPop();
payPop.newTransaction({
onSuccess: (transaction) => {
console.log("Payment successful:", transaction.transactionId);
},
onError: (transaction) => {
console.log("Payment failed:", transaction.transactionId);
},
onCancel: () => {
console.log("User closed the popup");
},
request: {
amount: "1000.00",
transactionId: Math.floor(Math.random() * 99999999) + "", // generate Trxn ID
email: "customer@mail.com",
publicKey: "public-key-here",
currency: "NGN",
mode: "Live",
productId: "1001",
applyConviniencyCharge: true,
productDescription: "Sample Product",
footerText: "Powered by Echezona Ltd",
footerLogo: "https://paybridge.africa/logo.png",
},
});