0.0.3 • Published 11 months ago

@onepay-payment-sdk/server v0.0.3

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

A lightweight Node.js SDK to integrate payment gateway functionalities with zero dependencies and full TypeScript support.

This package provides various payment-related utilities such as generating payment URLs and other utility functions to assist with your payment gateway integration. Callback validation functionality is planned for a future release.

Features

  • Lightweight: Focused purely on generating payment links.
  • Zero dependencies: The package has no external dependencies.
  • TypeScript support: Built-in TypeScript types for a seamless experience.
  • Flexible payment URL generation: Easily generate payment URLs with custom parameters.
  • Callback validation (coming soon): Planned functionality to validate incoming callback data from the payment gateway.
  • Error handling: Catch and handle errors effectively during payment processing.

Installation

To install the package, run the following command:

npm install @onepay-payment-sdk/server

Usage

  • Require "@onepay-payment-sdk/server" in your file

    const { Onepay } = require("@onepay-payment-sdk/server");
  • Create onepay config option, with parameters.

    const onepay = new Onepay({
      appId: "Enter APP ID from merchant admin panel",
      salt: "Enter SALT value from merchant admin panel",
      token: "Enter APP TOKEN from merchant admin panel",
    });
  • Create a payment request to generate transaction information and url

    const paymentDetails = onepay.generatePaymentParams({
      amount: 100,
      email: "onepay@example.com",
      firstName: "john",
      lastName: "doe",
      phone: "+94701234567",
      reference: "581231123121311231",
      transactionRedirectUrl: "http://localhost:3000/checkout",
    });
    
    const response = await onepay.createPaymentRequest(data);
    
    console.log(response.data.gateway.redirect_url);

Configuration Parameters

ParameterDescriptionTypeRequired
appIdThe APP ID provided by the merchant's admin panel.stringYes
saltThe SALT value provided by the merchant's admin panel.stringYes
tokenThe APP TOKEN provided by the merchant's admin panel.stringYes

License

This package is licensed under the MIT License. See LICENSE for more information.

0.0.3

11 months ago

0.0.3-beta.0

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago