lianlianpay
LianLianPay SDK for Nodejs.
Install
$ npm i lianlianpay --save
Usage
const moment = require('moment-timezone')
const LianLianPay = require('lianlianpay')
const lianlianpayClient = new LianLianPay({
merchantId: 'xxx',
merchantSecretKey: `-----BEGIN PRIVATE KEY-----xxx-----END PRIVATE KEY-----`,
lianlianPublicKey: '-----BEGIN PUBLIC KEY-----xxx-----END PUBLIC KEY-----',
environment: 'sandbox'
})
;(async () => {
const createPaymentRes = await lianlianpayClient.execute({
method: 'post',
url: `/v3/merchants/${lianlianpayClient.merchantId}/payments`,
params: {
merchant_transaction_id: 'merchant_transaction_id_1',
merchant_id: lianlianpayClient.merchantId,
redirect_url: 'https://www.google.com/search?q=success',
cancel_url: 'https://www.google.com/search?q=cancel',
country: 'HK',
merchant_order: {
merchant_order_id: 'merchant_order_id_1',
merchant_user_no: 'merchant_user_no_1',
merchant_order_time: moment().format('yyyyMMDDHHmmss'),
order_description: 'order_description_1',
order_amount: 0.99,
order_currency_code: 'USD',
products: [
{
product_id: 'product_id_1',
name: 'name_1',
price: 0.99,
quantity: 1
}
]
}
}
})
console.log(createPaymentRes)
const getPaymentRes = await lianlianpayClient.execute({
method: 'get',
url: `/v3/merchants/${lianlianpayClient.merchantId}/payments/${createPaymentRes.order.merchant_transaction_id}`,
params: {
merchant_id: lianlianpayClient.merchantId,
merchant_transaction_id: createPaymentRes.order.merchant_transaction_id
}
})
console.log(getPaymentRes)
})().catch(console.error)
LianLianPay Docs