1.0.5 • Published 2 years ago

linkpay-api v1.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

LinkPay API


Documentation & Release Notes

Support

If you have any questions regarding the SDK, provided examples or our services, please refer to https://developer.evonetonline.com/reference.


Installation

npm install linkpay-api

Initialization

Node

Using ES6 import

import * as dotenv from 'dotenv'
import { Configuration, PaymentRequest, genUUIDWithoutDash, genYYYYMMDDThhmmsshh00 } from 'linkpay-api';
import LinkPayAPI  from 'linkpay-api';

dotenv.config()

async function main() {
    const returnUrl = `${process.env.LINKPAY_RETURNURL}`
    const currency = `${process.env.LINKPAY_CURRENCY}`
    const amount = `${process.env.LINKPAY_AMOUNT}`
    
    // Set configuration
    const configuration: Configuration = { baseUrl: `${process.env.LINKPAY_BASEURL}`, sid: `${process.env.LINKPAY_SID}`, signKey: `${process.env.LINKPAY_SIGNKEY}` }
    // Create a LinkPayAPI instance
    const linkpay = new LinkPayAPI(configuration)
    
    // Build a payment request
    const request = new PaymentRequest()
    request.returnUrl = returnUrl
    request.merchantOrderInfo = {
        merchantOrderID: genUUIDWithoutDash(),
        merchantOrderTime: genYYYYMMDDThhmmsshh00(),
    }

    request.transAmount = {
        currency,
        value: `${amount}`,
    }
    
    // Call the related LinkPay API method
    const response = await linkpay.payment(request)

    console.log(JSON.stringify(response))
}

// call
main()

With require

exports.__esModule = true;
const LinkpayApi = require('linkpay-api')["default"];

const linkpayApi = new LinkpayApi(configuration);

Browser

Use linkpay-api/dist/linkpay-api-sdk.browser.js or linkpay-api-sdk.browser.min.js for the minified version.

ES5 with Modules (CommonJS)

Import linkpay-api/dist/index.js.

Types

  • Typescript (linkpay-api/dist/index.d.ts)

Examples

You can find sample workflow scripts in the examples and test folder.