UNPKG

@jashine/unipay-poslink

Version:

银联: 扫码支付-被扫

156 lines (147 loc) 4.97 kB
const PosLink = require("@jashine/unipay-poslink"); const posLink = new PosLink({ gateWay: "https://test-api-open.chinaums.com/v2/poslink/transaction/", appid: "f0ec96ad2c3848b5b810e7aadf369e2f", appkey: "775481e2556e4564985f5439a5e6a277", }); // 测试 // (async function test(){ // let res = await posLink.test(); // console.log(res); // ;})() // 支付 // (async function pay() { // const res = await posLink.pay({ // merchantCode: "123456789900081", // terminalCode: "00810001", // transactionAmount: 1, // transactionCurrencyCode: 156, // merchantOrderId: "3235212201121929209721434193", // merchantRemark: "测试单", // payMode: "CODE_SCAN", // payCode: "", // storeId: 128, // }); // // console.log(res); // })(); // 支付2 // (async function request(){ // const res = await posLink.request( // { // msgType: 'pay', // merchantCode: '123456789900081', // terminalCode: '00810001', // transactionAmount: 2, // transactionCurrencyCode: 156, // merchantOrderId: '3625202201122919209721444193', // merchantRemark: '测试单', // payMode: 'CODE_SCAN', // payCode: '', // storeId: 128, // } // ); // console.log(res); // ;})() // 支付撤销 // (async function voidpayment(){ // const res = await posLink.voidpayment( // { // merchantCode: '123456789900081', // terminalCode: '00810001', // // 银商订单号(微信支付里的商户单号) // // originalOrderId: '20220119173246100021724711', // // 商户订单号(商户系统生成的订单号) // merchantOrderId:'3235212201121929209721434193' // } // ); // console.log(res); // ;})() // 交易退款 // (async function refund() { // try { // const res = await posLink.refund({ // merchantCode: "123456789900081", // terminalCode: "00810001", // // refundRequestId: uuidv4().replace(new RegExp('-','gm'), ""), // refundRequestId: "b73587b0cbed4991gf4530879f3ee643", // // 银商订单号(微信支付里的商户单号) // // originalOrderId: "20220119173246100021724711", // transactionAmount: 1, // merchantRemark: "我要退款", // // 商户订单号 // merchantOrderId:'3625202201122919209721444193' // }); // // console.log(res); // } catch (error) { // if (error.response) { // console.log('------error.response-----',error.response); // // html报错页面 // console.log('------error.response.data-----',error.response.data.errInfo); // console.log("------error.response.status-----", error.response.status); // // 错误信息 // // console.log( // // "------error.response.statusText-----", // // error.response.statusText // // ); // } else { // console.log("------error-----", error); // } // } // })(); // 交易状态查询 // (async function query() { // try { // const res = await posLink.query({ // merchantCode: "123456789900081", // terminalCode: "00810001", // // 银商订单号(微信支付里的商户单号) // // originalOrderId: "20220119173246100021724711", // // 商户订单号 // merchantOrderId:'3235212201121929209721434193' // }); // // console.log(res); // } catch (error) { // if (error.response) { // // console.log('------error.response-----',error.response); // // html报错页面 // // console.log('------error.response.data-----',error.response.data); // console.log("------error.response.status-----", error.response.status); // // 错误信息 // // console.log( // // "------error.response.statusText-----", // // error.response.statusText // // ); // } else { // console.log("------error-----", error); // } // } // })(); // 交易退款查询 // (async function queryRefund() { // try { // const res = await posLink.queryRefund({ // merchantCode: "123456789900081", // terminalCode: "00810001", // // 银商订单号(微信支付里的商户单号) // // originalOrderId: "20220119173246100021724711", // // 商户订单号 // merchantOrderId:'3625202201122919209721444193', // refundRequestId: "b73587b0cbed4991gf4530879f3ee643", // }); // // console.log(res); // } catch (error) { // if (error.response) { // // console.log('------error.response-----',error.response); // // html报错页面 // console.log('------error.response.data-----',error.response.data); // console.log("------error.response.status-----", error.response.status); // // 错误信息 // // console.log( // // "------error.response.statusText-----", // // error.response.statusText // // ); // } else { // console.log("------error-----", error); // } // } // })();