Package Exports
- @jashine/unipay-poslink
- @jashine/unipay-poslink/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@jashine/unipay-poslink) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Install with:
npm i @jashine/unipay-poslink
Usage Example
const PosLink = require("@jashine/unipay-poslink");
//初始化实例
const posLink = new PosLink({
gateWay: "https://test-api-open.chinaums.com/v2/poslink/transaction/",
appid: "f0ec96ad2c3848b5b810e7aadf369e2f",
appkey: "775481e2556e4564985f5439a5e6a277",
});
//支付
const res = await posLink.pay({
merchantCode: "123456789900081",
terminalCode: "00810001",
transactionAmount: 1,
transactionCurrencyCode: 156,
merchantOrderId: "3235212201121929209721434193",
merchantRemark: "测试单",
payMode: "CODE_SCAN",
payCode: "用户手机上的付款码",
storeId: 128,
});
//交易查询
const res = await posLink.query({
merchantCode: "123456789900081",
terminalCode: "00810001",
// 银商订单号(微信支付里的商户单号,二选一)
// originalOrderId: "20220119173246100021724711",
// 商户订单号(商户系统生成的订单号,二选一)
merchantOrderId:'3235212201121929209721434193'
});
//支付撤销
const res = await posLink.voidpayment(
{
merchantCode: '123456789900081',
terminalCode: '00810001',
// 银商订单号(微信支付里的商户单号,二选一)
// originalOrderId: '20220119173246100021724711',
// 商户订单号(商户系统生成的订单号,二选一)
merchantOrderId:'3235212201121929209721434193'
}
);
//退款
const res = await posLink.refund({
merchantCode: "123456789900081",
terminalCode: "00810001",
// refundRequestId: uuidv4().replace(new RegExp('-','gm'), ""),
refundRequestId: "b73587b0cbed4991gf4530879f3ee643",
// originalOrderId: "20220119173246100021724711",
transactionAmount: 1,
merchantRemark: "我要退款",
// 商户订单号
merchantOrderId:'3625202201122919209721444193'
});
//退款查询
const res = await posLink.queryRefund({
merchantCode: "123456789900081",
terminalCode: "00810001",
// originalOrderId: "20220119173246100021724711",
merchantOrderId:'3625202201122919209721444193',
refundRequestId: "b73587b0cbed4991gf4530879f3ee643",
});
//统一请求方法,设置msgType的值请求相关的接口,包含所有请求功能,msgType的值根据文档填写,例:支付pay
const res = await posLink.request({
msgType: 'pay',
merchantCode: '123456789900081',
terminalCode: '00810001',
transactionAmount: 2,
transactionCurrencyCode: 156,
merchantOrderId: '3625202201122919209721444193',
merchantRemark: '测试单',
payMode: 'CODE_SCAN',
payCode: '用户手机上的付款码',
storeId: 1,
}
);