How to Integrate ZinariPay with Your Application Using the NPM Package

Integrating cryptocurrency payments into your web application has never been easier. ZinariPay offers a robust NPM package that allows developers to seamlessly add USDT and USDC payment functionalities. In this guide, we will walk you through the steps…


This content originally appeared on DEV Community and was authored by Christopher Akanmu

Integrating cryptocurrency payments into your web application has never been easier. ZinariPay offers a robust NPM package that allows developers to seamlessly add USDT and USDC payment functionalities. In this guide, we will walk you through the steps to integrate ZinariPay into your application using the NPM package.

Step 1: Installation

First, you'll need to install the ZinariPay package. This can be done using either npm or yarn, depending on your preference.

Using npm
To install using npm, run the following command in your terminal:

npm install zinari-pay

Using yarn
Alternatively, you can use yarn to install the package:

yarn add zinari-pay

Step 2: Configuration

Once the package is installed, you need to configure it for your application. The configuration involves creating an instance of ZinariPay with your specific settings.

Example Configuration
Here's a basic configuration example using vanilla JavaScript:

import ZinariPay from 'zinari-pay';

const zinariPay = new ZinariPay({
  appId: 'your-app-id',
  publicKey: 'your-public-key',
  log: process.env.NODE_ENV === 'development', /** Recommendation: Only 
use for development to avoid exposing sensitive data to end users
   */
});

You can get you appId and publicKey from you dashboard

Step 3: Initiate a Transaction

With your configuration set up, you can now initiate a transaction. This can be done using the initiateTransaction method.

Vanilla JavaScript Example
Here's how you would initiate a transaction:

import ZinariPay from 'zinari-pay';

const zinariPay = new ZinariPay({...})

const payWithCryptoButton = document.getElementById("your-payment-button");

payWithCryptoButton.addEventListener("click", () => {
  zinariPay.initiateTransaction({
    amount: 10000,
    notificationEmailAddress: 'users@email.com',
    details: {
      /** Add all the extra details you need here,
       * we  call your webhook url with all this data included */
    },
    onConfirmed: (transactionDetails) => {
      /** Do something when the transaction is confirmed */
    }
  });
});

React Example
If you're using React, you can integrate ZinariPay as follows:

import ZinariPay from 'zinari-pay';

const zinariPay = new ZinariPay({
  appId: 'your-app-id',
  publicKey: 'your-public-key',
  log: process.env.NODE_ENV === 'development',
});

const App = () => {
  const handleClick = useCallback(({price, email}) => {
    zinariPay.initiateTransaction({
      amount: price,
      notificationEmailAddress: email,
      onConfirmed: (transactionDetails) => {
        /** Do something when the transaction is confirmed */
      },
      details: {
        /** Add all the extra details you need here,
         * we  call your webhook url with all this data included */
      },
    });
  }, []);

  return <button onClick={handleClick}>
    Pay with Cryptocurrency
  </button>
}

Conclusion
Integrating ZinariPay into your application using the NPM package is straightforward and efficient. With support for USDT and USDC, encrypted transactions, and easy-to-use methods, ZinariPay is the perfect solution for adding cryptocurrency payments to your web application.
For more detailed information, visit the official documentation and start building today!

ZinariPay Customer Payment Flow
ZinariPay Customer Payment Flow
ZinariPay Customer Payment Flow
ZinariPay Customer Payment Flow
ZinariPay Customer Payment Flow


This content originally appeared on DEV Community and was authored by Christopher Akanmu


Print Share Comment Cite Upload Translate Updates
APA

Christopher Akanmu | Sciencx (2024-09-04T11:35:12+00:00) How to Integrate ZinariPay with Your Application Using the NPM Package. Retrieved from https://www.scien.cx/2024/09/04/how-to-integrate-zinaripay-with-your-application-using-the-npm-package/

MLA
" » How to Integrate ZinariPay with Your Application Using the NPM Package." Christopher Akanmu | Sciencx - Wednesday September 4, 2024, https://www.scien.cx/2024/09/04/how-to-integrate-zinaripay-with-your-application-using-the-npm-package/
HARVARD
Christopher Akanmu | Sciencx Wednesday September 4, 2024 » How to Integrate ZinariPay with Your Application Using the NPM Package., viewed ,<https://www.scien.cx/2024/09/04/how-to-integrate-zinaripay-with-your-application-using-the-npm-package/>
VANCOUVER
Christopher Akanmu | Sciencx - » How to Integrate ZinariPay with Your Application Using the NPM Package. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/09/04/how-to-integrate-zinaripay-with-your-application-using-the-npm-package/
CHICAGO
" » How to Integrate ZinariPay with Your Application Using the NPM Package." Christopher Akanmu | Sciencx - Accessed . https://www.scien.cx/2024/09/04/how-to-integrate-zinaripay-with-your-application-using-the-npm-package/
IEEE
" » How to Integrate ZinariPay with Your Application Using the NPM Package." Christopher Akanmu | Sciencx [Online]. Available: https://www.scien.cx/2024/09/04/how-to-integrate-zinaripay-with-your-application-using-the-npm-package/. [Accessed: ]
rf:citation
» How to Integrate ZinariPay with Your Application Using the NPM Package | Christopher Akanmu | Sciencx | https://www.scien.cx/2024/09/04/how-to-integrate-zinaripay-with-your-application-using-the-npm-package/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.