From e68f72022c6339eb5411e596f663b3447efeeffd Mon Sep 17 00:00:00 2001 From: ChangChao-Tang Date: Wed, 1 Nov 2017 23:44:02 +0800 Subject: [PATCH 1/8] add gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a2e1919 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +Doc/ +ECPAY_Payment_node_js/.idea/ +ECPAY_Payment_node_js/node_modules/ +.idea/ \ No newline at end of file From 6e963b31c013a21f03a289384e20e50dea92ed52 Mon Sep 17 00:00:00 2001 From: ChangChao-Tang Date: Wed, 1 Nov 2017 23:58:06 +0800 Subject: [PATCH 2/8] modify main field --- ECPAY_Payment_node_js/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ECPAY_Payment_node_js/package.json b/ECPAY_Payment_node_js/package.json index 9a746a6..abfa39b 100644 --- a/ECPAY_Payment_node_js/package.json +++ b/ECPAY_Payment_node_js/package.json @@ -2,7 +2,7 @@ "name": "ecpay_payment_nodejs", "version": "1.0.0", "description": "綠界全方位金流串接用SDK", - "main": "ecpay_payment.js", + "main": "index.js", "dependencies": { "elementtree": "^0.1.7", "iconv-lite": "^0.4.18", From 47653b893f23a4698b6299317bf6124be32db435 Mon Sep 17 00:00:00 2001 From: ChangChao-Tang Date: Thu, 2 Nov 2017 00:04:50 +0800 Subject: [PATCH 3/8] add example config --- ECPAY_Payment_node_js/conf/config-example.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 ECPAY_Payment_node_js/conf/config-example.js diff --git a/ECPAY_Payment_node_js/conf/config-example.js b/ECPAY_Payment_node_js/conf/config-example.js new file mode 100644 index 0000000..a6c3b96 --- /dev/null +++ b/ECPAY_Payment_node_js/conf/config-example.js @@ -0,0 +1,19 @@ +const options = { + "OperationMode": "Test", //Test or Production + "MercProfile": { + "MerchantID": "2000132", + "HashKey": "5294y06JbISpM5x9", + "HashIV": "v77hoKGq4kWxNNIS" + }, + "IgnorePayment": [ +// "Credit", +// "WebATM", +// "ATM", +// "CVS", +// "BARCODE", +// "AndroidPay" + ], + "IsProjectContractor": false +} + +module.exports = options \ No newline at end of file From 12003caeb8c8ee3ef1adad3299ba1ea719877299 Mon Sep 17 00:00:00 2001 From: ChangChao-Tang Date: Thu, 2 Nov 2017 00:16:29 +0800 Subject: [PATCH 4/8] accept options instead of parsing xml --- .../lib/ecpay_payment/helper.js | 36 ++++++------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/ECPAY_Payment_node_js/lib/ecpay_payment/helper.js b/ECPAY_Payment_node_js/lib/ecpay_payment/helper.js index c906ee8..3f22551 100644 --- a/ECPAY_Payment_node_js/lib/ecpay_payment/helper.js +++ b/ECPAY_Payment_node_js/lib/ecpay_payment/helper.js @@ -12,25 +12,17 @@ const https = require('https'); // const EventEmitter = require('events').EventEmitter; class APIHelper { - constructor(){ - this.cont = fs.readFileSync(__dirname + '/../../conf/payment_conf.xml').toString(); - this.cont_xml = et.parse(this.cont); - this.active_merc_info = this.cont_xml.findtext('./MercProfile'); - this.op_mode = this.cont_xml.findtext('./OperatingMode'); - this.contractor_stat = this.cont_xml.findtext('./IsProjectContractor'); - this.merc_info = this.cont_xml.findall(`./MerchantInfo/MInfo/[@name="${this.active_merc_info}"]`); - this.ignore_payment = []; - this.ignore_info = this.cont_xml.findall('./IgnorePayment//Method'); - for(let t = 0, l = this.ignore_info.length; t < l; t++) { - this.ignore_payment.push(this.ignore_info[t].text); - } - if (this.merc_info !== []) { - this.merc_id = this.merc_info[0].findtext('./MerchantID'); - this.hkey = this.merc_info[0].findtext('./HashKey'); - this.hiv = this.merc_info[0].findtext('./HashIV'); - } else { - throw new Error(`Specified merchant setting name (${this.active_merc_info}) not found.`); + constructor(options){ + this.op_mode = options.OperationMode + this.contractor_stat = options.IsProjectContractor + if (!options.MercProfile || !options.MercProfile.MerchantID || !options.MercProfile.HashIV || !options.MercProfile.HashKey){ + throw new Error('Please specify the MercProfile') } + this.merc_info = options.MercProfile + this.ignore_payment = options.IgnorePayment + this.merc_id = this.merc_info.MerchantID + this.hkey = this.merc_info.HashKey + this.hiv = this.merc_info.HashIV this.date = new Date(); } get_mercid(){ @@ -46,13 +38,7 @@ class APIHelper { return this.date.getTime().toString().slice(0, 10); } is_contractor(){ - if (this.contractor_stat === 'N') { - return false - } else if (this.contractor_stat === 'Y') { - return true - } else { - throw new Error("Unknown [IsProjectContractor] configuration."); - } + return this.contractor_stat } urlencode_dot_net(raw_data, case_tr='DOWN'){ if (typeof raw_data === 'string') { From f8327d19bf2a59fe05dc933217a01df8cf015564 Mon Sep 17 00:00:00 2001 From: ChangChao-Tang Date: Thu, 2 Nov 2017 00:22:11 +0800 Subject: [PATCH 5/8] clean the code --- .../lib/ecpay_payment/helper.js | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/ECPAY_Payment_node_js/lib/ecpay_payment/helper.js b/ECPAY_Payment_node_js/lib/ecpay_payment/helper.js index 3f22551..6803bc2 100644 --- a/ECPAY_Payment_node_js/lib/ecpay_payment/helper.js +++ b/ECPAY_Payment_node_js/lib/ecpay_payment/helper.js @@ -1,15 +1,12 @@ /** * Created by ying.wu on 2017/6/12. */ -const fs = require('fs'); -const et = require('elementtree'); const crypto = require('crypto'); const url = require('url'); const querystring = require('querystring'); const http = require('http'); const https = require('https'); -// const EventEmitter = require('events').EventEmitter; class APIHelper { constructor(options){ @@ -133,9 +130,9 @@ class APIHelper { throw new Error("Only GET & POST method are available."); } - var target_url = url.parse(api_url); - var postData = querystring.stringify(payload); - var http_op; + const target_url = url.parse(api_url), + postData = querystring.stringify(payload) + let http_op; if (target_url.protocol === 'https:'){ http_op = https; @@ -145,7 +142,7 @@ class APIHelper { throw new Error("Only http & https protocol are available."); } - var options = { + const options = { protocol: target_url['protocol'], hostname: target_url['hostname'], path: target_url['path'], @@ -154,7 +151,7 @@ class APIHelper { 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': Buffer.byteLength(postData), } - }; + } return new Promise((resolve, reject) => { @@ -183,7 +180,7 @@ class APIHelper { }); }; gen_html_post_form(act, id, parameters, input_typ='hidden', submit=true){ - var html = "
"; + let html = ""; Object.keys(parameters).forEach(function (key) { html += ""; }); @@ -209,12 +206,7 @@ class APIHelper { } else if (chkmac.length === 32) { val = this.gen_chk_mac_value(rtn_obj, 0); } - if (chkmac === val){ - return true - } else { - return false - } - + return chkmac === val } } From fbc3c1a5630e6b1499f5074fb0172da67ce4d7be Mon Sep 17 00:00:00 2001 From: ChangChao-Tang Date: Thu, 2 Nov 2017 00:33:59 +0800 Subject: [PATCH 6/8] options injection --- ECPAY_Payment_node_js/lib/ecpay_payment.js | 8 ++++---- .../lib/ecpay_payment/exec_grant_refund.js | 4 ++-- ECPAY_Payment_node_js/lib/ecpay_payment/payment_client.js | 4 ++-- ECPAY_Payment_node_js/lib/ecpay_payment/query_client.js | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ECPAY_Payment_node_js/lib/ecpay_payment.js b/ECPAY_Payment_node_js/lib/ecpay_payment.js index b67d813..8e791f4 100644 --- a/ECPAY_Payment_node_js/lib/ecpay_payment.js +++ b/ECPAY_Payment_node_js/lib/ecpay_payment.js @@ -7,11 +7,11 @@ const query_client = require('./ecpay_payment/query_client.js'); const exec_grant_refund = require('./ecpay_payment/exec_grant_refund.js'); class ECPayPayment { - constructor(){ + constructor(options){ this.version = new version(); - this.payment_client = new payment_client(); - this.query_client = new query_client(); - this.exec_grant_refund = new exec_grant_refund(); + this.payment_client = new payment_client(options); + this.query_client = new query_client(options); + this.exec_grant_refund = new exec_grant_refund(options); } } module.exports = ECPayPayment; \ No newline at end of file diff --git a/ECPAY_Payment_node_js/lib/ecpay_payment/exec_grant_refund.js b/ECPAY_Payment_node_js/lib/ecpay_payment/exec_grant_refund.js index 8de093a..93416cb 100644 --- a/ECPAY_Payment_node_js/lib/ecpay_payment/exec_grant_refund.js +++ b/ECPAY_Payment_node_js/lib/ecpay_payment/exec_grant_refund.js @@ -12,8 +12,8 @@ const http = require('http'); const https = require('https'); class ECpayExecRefundAndGrant{ - constructor(){ - this.helper = new helper(); + constructor(options){ + this.helper = new helper(options); // this.verify_act_api = new verify.ActParamVerify(); } diff --git a/ECPAY_Payment_node_js/lib/ecpay_payment/payment_client.js b/ECPAY_Payment_node_js/lib/ecpay_payment/payment_client.js index 1682922..c215387 100644 --- a/ECPAY_Payment_node_js/lib/ecpay_payment/payment_client.js +++ b/ECPAY_Payment_node_js/lib/ecpay_payment/payment_client.js @@ -11,8 +11,8 @@ const http = require('http'); const https = require('https'); class ECpayPaymentClient{ - constructor(){ - this.helper = new helper(); + constructor(options){ + this.helper = new helper(options); this.verify_aiochkout = new verify.AioCheckOutParamVerify(); } diff --git a/ECPAY_Payment_node_js/lib/ecpay_payment/query_client.js b/ECPAY_Payment_node_js/lib/ecpay_payment/query_client.js index c50ff3a..7715988 100644 --- a/ECPAY_Payment_node_js/lib/ecpay_payment/query_client.js +++ b/ECPAY_Payment_node_js/lib/ecpay_payment/query_client.js @@ -12,8 +12,8 @@ const http = require('http'); const https = require('https'); class ECpayQueryClient{ - constructor(){ - this.helper = new helper(); + constructor(options){ + this.helper = new helper(options); // this.verify_query_api = new verify.QueryParamVerify(); } From a6c939d863a556d3a8df35cd523408395f9ab719 Mon Sep 17 00:00:00 2001 From: ChangChao-Tang Date: Thu, 2 Nov 2017 00:51:42 +0800 Subject: [PATCH 7/8] update examples --- ECPAY_Payment_node_js/example/aio_capture.js | 26 ++--- .../example/aio_check_out_all.js | 94 ++++++++-------- .../example/aio_check_out_atm.js | 100 ++++++++--------- .../example/aio_check_out_barcode.js | 101 +++++++++--------- .../example/aio_check_out_credit_divide.js | 98 ++++++++--------- .../example/aio_check_out_credit_onetime.js | 94 ++++++++-------- .../example/aio_check_out_credit_period.js | 10 +- .../example/aio_check_out_cvs.js | 101 +++++++++--------- .../example/aio_check_out_webatm.js | 94 ++++++++-------- .../example/create_server_order.js | 34 +++--- .../example/credit_do_act.js | 24 ++--- .../example/query_credit_csv.js | 22 ++-- .../example/query_credit_period.js | 17 +-- .../example/query_credit_single.js | 22 ++-- .../example/query_trade_info.js | 18 ++-- .../example/query_transac_csv.js | 32 +++--- 16 files changed, 443 insertions(+), 444 deletions(-) diff --git a/ECPAY_Payment_node_js/example/aio_capture.js b/ECPAY_Payment_node_js/example/aio_capture.js index b82676a..1ef13e4 100644 --- a/ECPAY_Payment_node_js/example/aio_capture.js +++ b/ECPAY_Payment_node_js/example/aio_capture.js @@ -1,21 +1,21 @@ /** * Created by ying.wu on 2017/6/27. */ -const ecpay_payment = require('../lib/ecpay_payment.js'); +const ecpay_payment = require('../lib/ecpay_payment.js') //參數值為[PLEASE MODIFY]者,請在每次測試時給予獨特值 //若要測試非必帶參數請將base_param內註解的參數依需求取消註解 // let base_param = { - MerchantTradeNo: 'PLEASE MODIFY', //請帶20碼uid, ex: f0a0d7e9fae1bb72bc93 - CaptureAMT: '70', - UserRefundAMT: '30', - // MerchantID: '', - // Remark: '撥款備註' -}; - -let create = new ecpay_payment(); -let res = create.exec_grant_refund.aio_capture(parameters = base_param); + MerchantTradeNo: 'PLEASE MODIFY', //請帶20碼uid, ex: f0a0d7e9fae1bb72bc93 + CaptureAMT: '70', + UserRefundAMT: '30', + // MerchantID: '', + // Remark: '撥款備註' +} +const options = require('../conf/config-example'), + create = new ecpay_payment(options), + res = create.exec_grant_refund.aio_capture(parameters = base_param) res.then(function (result) { - console.log(result); + console.log(result) }).catch(function (err) { - console.log(err); -}); \ No newline at end of file + console.log(err) +}) \ No newline at end of file diff --git a/ECPAY_Payment_node_js/example/aio_check_out_all.js b/ECPAY_Payment_node_js/example/aio_check_out_all.js index ff37c14..d085ad7 100644 --- a/ECPAY_Payment_node_js/example/aio_check_out_all.js +++ b/ECPAY_Payment_node_js/example/aio_check_out_all.js @@ -1,56 +1,56 @@ /** * Created by ying.wu on 2017/6/27. */ -const ecpay_payment = require('../lib/ecpay_payment.js'); +const ecpay_payment = require('../lib/ecpay_payment.js') //參數值為[PLEASE MODIFY]者,請在每次測試時給予獨特值 //若要測試非必帶參數請將base_param內註解的參數依需求取消註解 // let base_param = { - MerchantTradeNo: 'PLEASE MODIFY', //請帶20碼uid, ex: f0a0d7e9fae1bb72bc93 - MerchantTradeDate: 'PLEASE MODIFY', //ex: 2017/02/13 15:45:30 - TotalAmount: '100', - TradeDesc: '測試交易描述', - ItemName: '測試商品等', - ReturnURL: 'http://192.168.0.1', - // ChooseSubPayment: '', - // OrderResultURL: 'http://192.168.0.1/payment_result', - // NeedExtraPaidInfo: '1', - // ClientBackURL: 'https://www.google.com', - // ItemURL: 'http://item.test.tw', - // Remark: '交易備註', - // HoldTradeAMT: '1', - // StoreID: '', - // CustomField1: '', - // CustomField2: '', - // CustomField3: '', - // CustomField4: '' -}; + MerchantTradeNo: 'PLEASE MODIFY', //請帶20碼uid, ex: f0a0d7e9fae1bb72bc93 + MerchantTradeDate: 'PLEASE MODIFY', //ex: 2017/02/13 15:45:30 + TotalAmount: '100', + TradeDesc: '測試交易描述', + ItemName: '測試商品等', + ReturnURL: 'http://192.168.0.1', + // ChooseSubPayment: '', + // OrderResultURL: 'http://192.168.0.1/payment_result', + // NeedExtraPaidInfo: '1', + // ClientBackURL: 'https://www.google.com', + // ItemURL: 'http://item.test.tw', + // Remark: '交易備註', + // HoldTradeAMT: '1', + // StoreID: '', + // CustomField1: '', + // CustomField2: '', + // CustomField3: '', + // CustomField4: '' +} // 若要測試開立電子發票,請將inv_params內的"所有"參數取消註解 // let inv_params = { - // RelateNumber: 'PLEASE MODIFY', //請帶30碼uid ex: SJDFJGH24FJIL97G73653XM0VOMS4K - // CustomerID: 'MEM_0000001', //會員編號 - // CustomerIdentifier: '', //統一編號 - // CustomerName: '測試買家', - // CustomerAddr: '測試用地址', - // CustomerPhone: '0123456789', - // CustomerEmail: 'johndoe@test.com', - // ClearanceMark: '2', - // TaxType: '1', - // CarruerType: '', - // CarruerNum: '', - // Donation: '2', - // LoveCode: '', - // Print: '1', - // InvoiceItemName: '測試商品1|測試商品2', - // InvoiceItemCount: '2|3', - // InvoiceItemWord: '個|包', - // InvoiceItemPrice: '35|10', - // InvoiceItemTaxType: '1|1', - // InvoiceRemark: '測試商品1的說明|測試商品2的說明', - // DelayDay: '0', - // InvType: '07' -}; - -let create = new ecpay_payment(); -let htm = create.payment_client.aio_check_out_all(parameters = base_param, invoice = inv_params); -console.log(htm); \ No newline at end of file + // RelateNumber: 'PLEASE MODIFY', //請帶30碼uid ex: SJDFJGH24FJIL97G73653XM0VOMS4K + // CustomerID: 'MEM_0000001', //會員編號 + // CustomerIdentifier: '', //統一編號 + // CustomerName: '測試買家', + // CustomerAddr: '測試用地址', + // CustomerPhone: '0123456789', + // CustomerEmail: 'johndoe@test.com', + // ClearanceMark: '2', + // TaxType: '1', + // CarruerType: '', + // CarruerNum: '', + // Donation: '2', + // LoveCode: '', + // Print: '1', + // InvoiceItemName: '測試商品1|測試商品2', + // InvoiceItemCount: '2|3', + // InvoiceItemWord: '個|包', + // InvoiceItemPrice: '35|10', + // InvoiceItemTaxType: '1|1', + // InvoiceRemark: '測試商品1的說明|測試商品2的說明', + // DelayDay: '0', + // InvType: '07' +} +const options = require('../conf/config-example'), + create = new ecpay_payment(options), + htm = create.payment_client.aio_check_out_all(parameters = base_param, invoice = inv_params) +console.log(htm) \ No newline at end of file diff --git a/ECPAY_Payment_node_js/example/aio_check_out_atm.js b/ECPAY_Payment_node_js/example/aio_check_out_atm.js index 1c926b7..aab61df 100644 --- a/ECPAY_Payment_node_js/example/aio_check_out_atm.js +++ b/ECPAY_Payment_node_js/example/aio_check_out_atm.js @@ -1,60 +1,60 @@ /** * Created by ying.wu on 2017/6/27. */ -const ecpay_payment = require('../lib/ecpay_payment.js'); +const ecpay_payment = require('../lib/ecpay_payment.js') //參數值為[PLEASE MODIFY]者,請在每次測試時給予獨特值 //若要測試非必帶參數請將base_param內註解的參數依需求取消註解 // let base_param = { - MerchantTradeNo: 'PLEASE MODIFY', //請帶20碼uid, ex: f0a0d7e9fae1bb72bc93 - MerchantTradeDate: 'PLEASE MODIFY', //ex: 2017/02/13 15:45:30 - TotalAmount: '100', - TradeDesc: '測試交易描述', - ItemName: '測試商品等', - ReturnURL: 'http://192.168.0.1', - // ChooseSubPayment: '', - // OrderResultURL: 'http://192.168.0.1/payment_result', - // NeedExtraPaidInfo: '1', - // ClientBackURL: 'https://www.google.com', - // ItemURL: 'http://item.test.tw', - // Remark: '交易備註', - // HoldTradeAMT: '1', - // StoreID: '', - // CustomField1: '', - // CustomField2: '', - // CustomField3: '', - // CustomField4: '' -}; + MerchantTradeNo: 'PLEASE MODIFY', //請帶20碼uid, ex: f0a0d7e9fae1bb72bc93 + MerchantTradeDate: 'PLEASE MODIFY', //ex: 2017/02/13 15:45:30 + TotalAmount: '100', + TradeDesc: '測試交易描述', + ItemName: '測試商品等', + ReturnURL: 'http://192.168.0.1', + // ChooseSubPayment: '', + // OrderResultURL: 'http://192.168.0.1/payment_result', + // NeedExtraPaidInfo: '1', + // ClientBackURL: 'https://www.google.com', + // ItemURL: 'http://item.test.tw', + // Remark: '交易備註', + // HoldTradeAMT: '1', + // StoreID: '', + // CustomField1: '', + // CustomField2: '', + // CustomField3: '', + // CustomField4: '' +} // 若要測試開立電子發票,請將inv_params內的"所有"參數取消註解 // let inv_params = { - // RelateNumber: 'PLEASE MODIFY', //請帶30碼uid ex: SJDFJGH24FJIL97G73653XM0VOMS4K - // CustomerID: 'MEM_0000001', //會員編號 - // CustomerIdentifier: '', //統一編號 - // CustomerName: '測試買家', - // CustomerAddr: '測試用地址', - // CustomerPhone: '0123456789', - // CustomerEmail: 'johndoe@test.com', - // ClearanceMark: '2', - // TaxType: '1', - // CarruerType: '', - // CarruerNum: '', - // Donation: '2', - // LoveCode: '', - // Print: '1', - // InvoiceItemName: '測試商品1|測試商品2', - // InvoiceItemCount: '2|3', - // InvoiceItemWord: '個|包', - // InvoiceItemPrice: '35|10', - // InvoiceItemTaxType: '1|1', - // InvoiceRemark: '測試商品1的說明|測試商品2的說明', - // DelayDay: '0', - // InvType: '07' -}; + // RelateNumber: 'PLEASE MODIFY', //請帶30碼uid ex: SJDFJGH24FJIL97G73653XM0VOMS4K + // CustomerID: 'MEM_0000001', //會員編號 + // CustomerIdentifier: '', //統一編號 + // CustomerName: '測試買家', + // CustomerAddr: '測試用地址', + // CustomerPhone: '0123456789', + // CustomerEmail: 'johndoe@test.com', + // ClearanceMark: '2', + // TaxType: '1', + // CarruerType: '', + // CarruerNum: '', + // Donation: '2', + // LoveCode: '', + // Print: '1', + // InvoiceItemName: '測試商品1|測試商品2', + // InvoiceItemCount: '2|3', + // InvoiceItemWord: '個|包', + // InvoiceItemPrice: '35|10', + // InvoiceItemTaxType: '1|1', + // InvoiceRemark: '測試商品1的說明|測試商品2的說明', + // DelayDay: '0', + // InvType: '07' +} -let pay_info_url = 'http://192.168.0.1'; -let exp = '7'; -let cli_redir_url = 'http://192.168.0.1/payment_result'; - -let create = new ecpay_payment(); -let htm = create.payment_client.aio_check_out_atm(parameters = base_param, url_return_payinfo = pay_info_url, exp_period = exp, client_redirect = cli_redir_url, invoice = inv_params); -console.log(htm); \ No newline at end of file +const pay_info_url = 'http://192.168.0.1', + exp = '7', + cli_redir_url = 'http://192.168.0.1/payment_result', + options = require('../conf/config-example'), + create = new ecpay_payment(options), + htm = create.payment_client.aio_check_out_atm(parameters = base_param, url_return_payinfo = pay_info_url, exp_period = exp, client_redirect = cli_redir_url, invoice = inv_params) +console.log(htm) \ No newline at end of file diff --git a/ECPAY_Payment_node_js/example/aio_check_out_barcode.js b/ECPAY_Payment_node_js/example/aio_check_out_barcode.js index af35d60..31c76cf 100644 --- a/ECPAY_Payment_node_js/example/aio_check_out_barcode.js +++ b/ECPAY_Payment_node_js/example/aio_check_out_barcode.js @@ -1,67 +1,66 @@ /** * Created by ying.wu on 2017/6/27. */ -const ecpay_payment = require('../lib/ecpay_payment.js'); +const ecpay_payment = require('../lib/ecpay_payment.js') //參數值為[PLEASE MODIFY]者,請在每次測試時給予獨特值 //若要測試非必帶參數請將base_param內註解的參數依需求取消註解 // let base_param = { - MerchantTradeNo: 'PLEASE MODIFY', //請帶20碼uid, ex: f0a0d7e9fae1bb72bc93 - MerchantTradeDate: 'PLEASE MODIFY', //ex: 2017/02/13 15:45:30 - TotalAmount: '100', - TradeDesc: '測試交易描述', - ItemName: '測試商品等', - ReturnURL: 'http://192.168.0.1', - // ChooseSubPayment: '', - // OrderResultURL: 'http://192.168.0.1/payment_result', - // NeedExtraPaidInfo: '1', - // ClientBackURL: 'https://www.google.com', - // ItemURL: 'http://item.test.tw', - // Remark: '交易備註', - // HoldTradeAMT: '1', - // StoreID: '', - // CustomField1: '', - // CustomField2: '', - // CustomField3: '', - // CustomField4: '' -}; + MerchantTradeNo: 'PLEASE MODIFY', //請帶20碼uid, ex: f0a0d7e9fae1bb72bc93 + MerchantTradeDate: 'PLEASE MODIFY', //ex: 2017/02/13 15:45:30 + TotalAmount: '100', + TradeDesc: '測試交易描述', + ItemName: '測試商品等', + ReturnURL: 'http://192.168.0.1', + // ChooseSubPayment: '', + // OrderResultURL: 'http://192.168.0.1/payment_result', + // NeedExtraPaidInfo: '1', + // ClientBackURL: 'https://www.google.com', + // ItemURL: 'http://item.test.tw', + // Remark: '交易備註', + // HoldTradeAMT: '1', + // StoreID: '', + // CustomField1: '', + // CustomField2: '', + // CustomField3: '', + // CustomField4: '' +} // 若要測試開立電子發票,請將inv_params內的"所有"參數取消註解 // let inv_params = { - // RelateNumber: 'PLEASE MODIFY', //請帶30碼uid ex: SJDFJGH24FJIL97G73653XM0VOMS4K - // CustomerID: 'MEM_0000001', //會員編號 - // CustomerIdentifier: '', //統一編號 - // CustomerName: '測試買家', - // CustomerAddr: '測試用地址', - // CustomerPhone: '0123456789', - // CustomerEmail: 'johndoe@test.com', - // ClearanceMark: '2', - // TaxType: '1', - // CarruerType: '', - // CarruerNum: '', - // Donation: '2', - // LoveCode: '', - // Print: '1', - // InvoiceItemName: '測試商品1|測試商品2', - // InvoiceItemCount: '2|3', - // InvoiceItemWord: '個|包', - // InvoiceItemPrice: '35|10', - // InvoiceItemTaxType: '1|1', - // InvoiceRemark: '測試商品1的說明|測試商品2的說明', - // DelayDay: '0', - // InvType: '07' -}; + // RelateNumber: 'PLEASE MODIFY', //請帶30碼uid ex: SJDFJGH24FJIL97G73653XM0VOMS4K + // CustomerID: 'MEM_0000001', //會員編號 + // CustomerIdentifier: '', //統一編號 + // CustomerName: '測試買家', + // CustomerAddr: '測試用地址', + // CustomerPhone: '0123456789', + // CustomerEmail: 'johndoe@test.com', + // ClearanceMark: '2', + // TaxType: '1', + // CarruerType: '', + // CarruerNum: '', + // Donation: '2', + // LoveCode: '', + // Print: '1', + // InvoiceItemName: '測試商品1|測試商品2', + // InvoiceItemCount: '2|3', + // InvoiceItemWord: '個|包', + // InvoiceItemPrice: '35|10', + // InvoiceItemTaxType: '1|1', + // InvoiceRemark: '測試商品1的說明|測試商品2的說明', + // DelayDay: '0', + // InvType: '07' +} -let barcode_params = { +const barcode_params = { StoreExpireDate: '7', Desc_1: '超商螢幕描述A', Desc_2: '超商螢幕描述B', Desc_3: '超商螢幕描述C', Desc_4: '超商螢幕描述D', PaymentInfoURL: 'http://192.168.0.1' -}; - -let client_redirect = 'http://192.168.0.1/payment_result'; - -let create = new ecpay_payment(); -let htm = create.payment_client.aio_check_out_barcode(barcode_info = barcode_params, parameters = base_param, invoice = inv_params, client_redirect_url = client_redirect); -console.log(htm); \ No newline at end of file + }, + client_redirect = 'http://192.168.0.1/payment_result', + options = require('../conf/config-example'), + create = new ecpay_payment(options), + htm = create.payment_client.aio_check_out_barcode(barcode_info = barcode_params, parameters = base_param, invoice = inv_params, client_redirect_url = client_redirect) +console.log(htm) \ No newline at end of file diff --git a/ECPAY_Payment_node_js/example/aio_check_out_credit_divide.js b/ECPAY_Payment_node_js/example/aio_check_out_credit_divide.js index fa30a6f..c04dd44 100644 --- a/ECPAY_Payment_node_js/example/aio_check_out_credit_divide.js +++ b/ECPAY_Payment_node_js/example/aio_check_out_credit_divide.js @@ -1,59 +1,59 @@ /** * Created by ying.wu on 2017/6/27. */ -const ecpay_payment = require('../lib/ecpay_payment.js'); +const ecpay_payment = require('../lib/ecpay_payment.js') //參數值為[PLEASE MODIFY]者,請在每次測試時給予獨特值 //若要測試非必帶參數請將base_param內註解的參數依需求取消註解 // let base_param = { - MerchantTradeNo: 'PLEASE MODIFY', //請帶20碼uid, ex: f0a0d7e9fae1bb72bc93 - MerchantTradeDate: 'PLEASE MODIFY', //ex: 2017/02/13 15:45:30 - TotalAmount: '100', - TradeDesc: '測試交易描述', - ItemName: '測試商品等', - ReturnURL: 'http://192.168.0.1', - // ChooseSubPayment: '', - // OrderResultURL: 'http://192.168.0.1/payment_result', - // NeedExtraPaidInfo: '1', - // ClientBackURL: 'https://www.google.com', - // ItemURL: 'http://item.test.tw', - // Remark: '交易備註', - // HoldTradeAMT: '1', - // StoreID: '', - // CustomField1: '', - // CustomField2: '', - // CustomField3: '', - // CustomField4: '' -}; + MerchantTradeNo: 'PLEASE MODIFY', //請帶20碼uid, ex: f0a0d7e9fae1bb72bc93 + MerchantTradeDate: 'PLEASE MODIFY', //ex: 2017/02/13 15:45:30 + TotalAmount: '100', + TradeDesc: '測試交易描述', + ItemName: '測試商品等', + ReturnURL: 'http://192.168.0.1', + // ChooseSubPayment: '', + // OrderResultURL: 'http://192.168.0.1/payment_result', + // NeedExtraPaidInfo: '1', + // ClientBackURL: 'https://www.google.com', + // ItemURL: 'http://item.test.tw', + // Remark: '交易備註', + // HoldTradeAMT: '1', + // StoreID: '', + // CustomField1: '', + // CustomField2: '', + // CustomField3: '', + // CustomField4: '' +} // 若要測試開立電子發票,請將inv_params內的"所有"參數取消註解 // let inv_params = { - // RelateNumber: 'PLEASE MODIFY', //請帶30碼uid ex: SJDFJGH24FJIL97G73653XM0VOMS4K - // CustomerID: 'MEM_0000001', //會員編號 - // CustomerIdentifier: '', //統一編號 - // CustomerName: '測試買家', - // CustomerAddr: '測試用地址', - // CustomerPhone: '0123456789', - // CustomerEmail: 'johndoe@test.com', - // ClearanceMark: '2', - // TaxType: '1', - // CarruerType: '', - // CarruerNum: '', - // Donation: '2', - // LoveCode: '', - // Print: '1', - // InvoiceItemName: '測試商品1|測試商品2', - // InvoiceItemCount: '2|3', - // InvoiceItemWord: '個|包', - // InvoiceItemPrice: '35|10', - // InvoiceItemTaxType: '1|1', - // InvoiceRemark: '測試商品1的說明|測試商品2的說明', - // DelayDay: '0', - // InvType: '07' -}; + // RelateNumber: 'PLEASE MODIFY', //請帶30碼uid ex: SJDFJGH24FJIL97G73653XM0VOMS4K + // CustomerID: 'MEM_0000001', //會員編號 + // CustomerIdentifier: '', //統一編號 + // CustomerName: '測試買家', + // CustomerAddr: '測試用地址', + // CustomerPhone: '0123456789', + // CustomerEmail: 'johndoe@test.com', + // ClearanceMark: '2', + // TaxType: '1', + // CarruerType: '', + // CarruerNum: '', + // Donation: '2', + // LoveCode: '', + // Print: '1', + // InvoiceItemName: '測試商品1|測試商品2', + // InvoiceItemCount: '2|3', + // InvoiceItemWord: '個|包', + // InvoiceItemPrice: '35|10', + // InvoiceItemTaxType: '1|1', + // InvoiceRemark: '測試商品1的說明|測試商品2的說明', + // DelayDay: '0', + // InvType: '07' +} -let inst = '12'; //分期期數 -let amt = 100; //分期總金額 - -let create = new ecpay_payment(); -let htm = create.payment_client.aio_check_out_credit_divide(parameters = base_param, invoice = inv_params, installment = inst, amount = amt); -console.log(htm); \ No newline at end of file +const inst = '12', //分期期數 + amt = 100, //分期總金額 + options = require('../conf/config-example') +create = new ecpay_payment(options), + htm = create.payment_client.aio_check_out_credit_divide(parameters = base_param, invoice = inv_params, installment = inst, amount = amt) +console.log(htm) \ No newline at end of file diff --git a/ECPAY_Payment_node_js/example/aio_check_out_credit_onetime.js b/ECPAY_Payment_node_js/example/aio_check_out_credit_onetime.js index 41e4305..47fff1a 100644 --- a/ECPAY_Payment_node_js/example/aio_check_out_credit_onetime.js +++ b/ECPAY_Payment_node_js/example/aio_check_out_credit_onetime.js @@ -1,56 +1,56 @@ /** * Created by ying.wu on 2017/6/27. */ -const ecpay_payment = require('../lib/ecpay_payment.js'); +const ecpay_payment = require('../lib/ecpay_payment.js') //參數值為[PLEASE MODIFY]者,請在每次測試時給予獨特值 //若要測試非必帶參數請將base_param內註解的參數依需求取消註解 // let base_param = { - MerchantTradeNo: 'PLEASE MODIFY', //請帶20碼uid, ex: f0a0d7e9fae1bb72bc93 - MerchantTradeDate: 'PLEASE MODIFY', //ex: 2017/02/13 15:45:30 - TotalAmount: '100', - TradeDesc: '測試交易描述', - ItemName: '測試商品等', - ReturnURL: 'http://192.168.0.1', - // ChooseSubPayment: '', - // OrderResultURL: 'http://192.168.0.1/payment_result', - // NeedExtraPaidInfo: '1', - // ClientBackURL: 'https://www.google.com', - // ItemURL: 'http://item.test.tw', - // Remark: '交易備註', - // HoldTradeAMT: '1', - // StoreID: '', - // CustomField1: '', - // CustomField2: '', - // CustomField3: '', - // CustomField4: '' -}; + MerchantTradeNo: 'PLEASE MODIFY', //請帶20碼uid, ex: f0a0d7e9fae1bb72bc93 + MerchantTradeDate: 'PLEASE MODIFY', //ex: 2017/02/13 15:45:30 + TotalAmount: '100', + TradeDesc: '測試交易描述', + ItemName: '測試商品等', + ReturnURL: 'http://192.168.0.1', + // ChooseSubPayment: '', + // OrderResultURL: 'http://192.168.0.1/payment_result', + // NeedExtraPaidInfo: '1', + // ClientBackURL: 'https://www.google.com', + // ItemURL: 'http://item.test.tw', + // Remark: '交易備註', + // HoldTradeAMT: '1', + // StoreID: '', + // CustomField1: '', + // CustomField2: '', + // CustomField3: '', + // CustomField4: '' +} // 若要測試開立電子發票,請將inv_params內的"所有"參數取消註解 // let inv_params = { - // RelateNumber: 'PLEASE MODIFY', //請帶30碼uid ex: SJDFJGH24FJIL97G73653XM0VOMS4K - // CustomerID: 'MEM_0000001', //會員編號 - // CustomerIdentifier: '', //統一編號 - // CustomerName: '測試買家', - // CustomerAddr: '測試用地址', - // CustomerPhone: '0123456789', - // CustomerEmail: 'johndoe@test.com', - // ClearanceMark: '2', - // TaxType: '1', - // CarruerType: '', - // CarruerNum: '', - // Donation: '2', - // LoveCode: '', - // Print: '1', - // InvoiceItemName: '測試商品1|測試商品2', - // InvoiceItemCount: '2|3', - // InvoiceItemWord: '個|包', - // InvoiceItemPrice: '35|10', - // InvoiceItemTaxType: '1|1', - // InvoiceRemark: '測試商品1的說明|測試商品2的說明', - // DelayDay: '0', - // InvType: '07' -}; - -let create = new ecpay_payment(); -let htm = create.payment_client.aio_check_out_credit_onetime(parameters = base_param, invoice = inv_params); -console.log(htm); \ No newline at end of file + // RelateNumber: 'PLEASE MODIFY', //請帶30碼uid ex: SJDFJGH24FJIL97G73653XM0VOMS4K + // CustomerID: 'MEM_0000001', //會員編號 + // CustomerIdentifier: '', //統一編號 + // CustomerName: '測試買家', + // CustomerAddr: '測試用地址', + // CustomerPhone: '0123456789', + // CustomerEmail: 'johndoe@test.com', + // ClearanceMark: '2', + // TaxType: '1', + // CarruerType: '', + // CarruerNum: '', + // Donation: '2', + // LoveCode: '', + // Print: '1', + // InvoiceItemName: '測試商品1|測試商品2', + // InvoiceItemCount: '2|3', + // InvoiceItemWord: '個|包', + // InvoiceItemPrice: '35|10', + // InvoiceItemTaxType: '1|1', + // InvoiceRemark: '測試商品1的說明|測試商品2的說明', + // DelayDay: '0', + // InvType: '07' +} +const options = require('../conf/config-example'), + create = new ecpay_payment(options), + htm = create.payment_client.aio_check_out_credit_onetime(parameters = base_param, invoice = inv_params) +console.log(htm) \ No newline at end of file diff --git a/ECPAY_Payment_node_js/example/aio_check_out_credit_period.js b/ECPAY_Payment_node_js/example/aio_check_out_credit_period.js index 8648cf6..c60ba0c 100644 --- a/ECPAY_Payment_node_js/example/aio_check_out_credit_period.js +++ b/ECPAY_Payment_node_js/example/aio_check_out_credit_period.js @@ -52,14 +52,14 @@ let inv_params = { }; // 定期定額相關參數 -let period_params = { +const period_params = { PeriodAmount: '50', PeriodType: 'M', Frequency: '1', ExecTimes: '2', PeriodReturnURL: 'http://192.168.0.1' -}; - -let create = new ecpay_payment(); -let htm = create.payment_client.aio_check_out_credit_period(period_info = period_params, parameters = base_param, invoice = inv_params); +}, + options = require('../conf/config-example'), + create = new ecpay_payment(options), + htm = create.payment_client.aio_check_out_credit_period(period_info = period_params, parameters = base_param, invoice = inv_params); console.log(htm); \ No newline at end of file diff --git a/ECPAY_Payment_node_js/example/aio_check_out_cvs.js b/ECPAY_Payment_node_js/example/aio_check_out_cvs.js index 143c443..7a6da43 100644 --- a/ECPAY_Payment_node_js/example/aio_check_out_cvs.js +++ b/ECPAY_Payment_node_js/example/aio_check_out_cvs.js @@ -1,67 +1,66 @@ /** * Created by ying.wu on 2017/6/27. */ -const ecpay_payment = require('../lib/ecpay_payment.js'); +const ecpay_payment = require('../lib/ecpay_payment.js') //參數值為[PLEASE MODIFY]者,請在每次測試時給予獨特值 //若要測試非必帶參數請將base_param內註解的參數依需求取消註解 // let base_param = { - MerchantTradeNo: 'PLEASE MODIFY', //請帶20碼uid, ex: f0a0d7e9fae1bb72bc93 - MerchantTradeDate: 'PLEASE MODIFY', //ex: 2017/02/13 15:45:30 - TotalAmount: '100', - TradeDesc: '測試交易描述', - ItemName: '測試商品等', - ReturnURL: 'http://192.168.0.1', - // ChooseSubPayment: '', - // OrderResultURL: 'http://192.168.0.1/payment_result', - // NeedExtraPaidInfo: '1', - // ClientBackURL: 'https://www.google.com', - // ItemURL: 'http://item.test.tw', - // Remark: '交易備註', - // HoldTradeAMT: '1', - // StoreID: '', - // CustomField1: '', - // CustomField2: '', - // CustomField3: '', - // CustomField4: '' -}; + MerchantTradeNo: 'PLEASE MODIFY', //請帶20碼uid, ex: f0a0d7e9fae1bb72bc93 + MerchantTradeDate: 'PLEASE MODIFY', //ex: 2017/02/13 15:45:30 + TotalAmount: '100', + TradeDesc: '測試交易描述', + ItemName: '測試商品等', + ReturnURL: 'http://192.168.0.1', + // ChooseSubPayment: '', + // OrderResultURL: 'http://192.168.0.1/payment_result', + // NeedExtraPaidInfo: '1', + // ClientBackURL: 'https://www.google.com', + // ItemURL: 'http://item.test.tw', + // Remark: '交易備註', + // HoldTradeAMT: '1', + // StoreID: '', + // CustomField1: '', + // CustomField2: '', + // CustomField3: '', + // CustomField4: '' +} // 若要測試開立電子發票,請將inv_params內的"所有"參數取消註解 // let inv_params = { - // RelateNumber: 'PLEASE MODIFY', //請帶30碼uid ex: SJDFJGH24FJIL97G73653XM0VOMS4K - // CustomerID: 'MEM_0000001', //會員編號 - // CustomerIdentifier: '', //統一編號 - // CustomerName: '測試買家', - // CustomerAddr: '測試用地址', - // CustomerPhone: '0123456789', - // CustomerEmail: 'johndoe@test.com', - // ClearanceMark: '2', - // TaxType: '1', - // CarruerType: '', - // CarruerNum: '', - // Donation: '2', - // LoveCode: '', - // Print: '1', - // InvoiceItemName: '測試商品1|測試商品2', - // InvoiceItemCount: '2|3', - // InvoiceItemWord: '個|包', - // InvoiceItemPrice: '35|10', - // InvoiceItemTaxType: '1|1', - // InvoiceRemark: '測試商品1的說明|測試商品2的說明', - // DelayDay: '0', - // InvType: '07' -}; + // RelateNumber: 'PLEASE MODIFY', //請帶30碼uid ex: SJDFJGH24FJIL97G73653XM0VOMS4K + // CustomerID: 'MEM_0000001', //會員編號 + // CustomerIdentifier: '', //統一編號 + // CustomerName: '測試買家', + // CustomerAddr: '測試用地址', + // CustomerPhone: '0123456789', + // CustomerEmail: 'johndoe@test.com', + // ClearanceMark: '2', + // TaxType: '1', + // CarruerType: '', + // CarruerNum: '', + // Donation: '2', + // LoveCode: '', + // Print: '1', + // InvoiceItemName: '測試商品1|測試商品2', + // InvoiceItemCount: '2|3', + // InvoiceItemWord: '個|包', + // InvoiceItemPrice: '35|10', + // InvoiceItemTaxType: '1|1', + // InvoiceRemark: '測試商品1的說明|測試商品2的說明', + // DelayDay: '0', + // InvType: '07' +} -let cvs_params = { +const cvs_params = { StoreExpireDate: '7', Desc_1: '超商螢幕描述A', Desc_2: '超商螢幕描述B', Desc_3: '超商螢幕描述C', Desc_4: '超商螢幕描述D', PaymentInfoURL: 'http://192.168.0.1' -}; - -let client_redirect = 'http://192.168.0.1/payment_result'; - -let create = new ecpay_payment(); -let htm = create.payment_client.aio_check_out_cvs(cvs_info = cvs_params, parameters = base_param, invoice = inv_params, client_redirect_url = client_redirect); -console.log(htm); \ No newline at end of file + }, + client_redirect = 'http://192.168.0.1/payment_result', + options = require('../conf/config-example'), + create = new ecpay_payment(options), + htm = create.payment_client.aio_check_out_cvs(cvs_info = cvs_params, parameters = base_param, invoice = inv_params, client_redirect_url = client_redirect) +console.log(htm) \ No newline at end of file diff --git a/ECPAY_Payment_node_js/example/aio_check_out_webatm.js b/ECPAY_Payment_node_js/example/aio_check_out_webatm.js index b2f3c94..285e25e 100644 --- a/ECPAY_Payment_node_js/example/aio_check_out_webatm.js +++ b/ECPAY_Payment_node_js/example/aio_check_out_webatm.js @@ -1,56 +1,56 @@ /** * Created by ying.wu on 2017/6/27. */ -const ecpay_payment = require('../lib/ecpay_payment.js'); +const ecpay_payment = require('../lib/ecpay_payment.js') //參數值為[PLEASE MODIFY]者,請在每次測試時給予獨特值 //若要測試非必帶參數請將base_param內註解的參數依需求取消註解 // let base_param = { - MerchantTradeNo: 'PLEASE MODIFY', //請帶20碼uid, ex: f0a0d7e9fae1bb72bc93 - MerchantTradeDate: 'PLEASE MODIFY', //ex: 2017/02/13 15:45:30 - TotalAmount: '100', - TradeDesc: '測試交易描述', - ItemName: '測試商品等', - ReturnURL: 'http://192.168.0.1', - // ChooseSubPayment: '', - // OrderResultURL: 'http://192.168.0.1/payment_result', - // NeedExtraPaidInfo: '1', - // ClientBackURL: 'https://www.google.com', - // ItemURL: 'http://item.test.tw', - // Remark: '交易備註', - // HoldTradeAMT: '1', - // StoreID: '', - // CustomField1: '', - // CustomField2: '', - // CustomField3: '', - // CustomField4: '' -}; + MerchantTradeNo: 'PLEASE MODIFY', //請帶20碼uid, ex: f0a0d7e9fae1bb72bc93 + MerchantTradeDate: 'PLEASE MODIFY', //ex: 2017/02/13 15:45:30 + TotalAmount: '100', + TradeDesc: '測試交易描述', + ItemName: '測試商品等', + ReturnURL: 'http://192.168.0.1', + // ChooseSubPayment: '', + // OrderResultURL: 'http://192.168.0.1/payment_result', + // NeedExtraPaidInfo: '1', + // ClientBackURL: 'https://www.google.com', + // ItemURL: 'http://item.test.tw', + // Remark: '交易備註', + // HoldTradeAMT: '1', + // StoreID: '', + // CustomField1: '', + // CustomField2: '', + // CustomField3: '', + // CustomField4: '' +} // 若要測試開立電子發票,請將inv_params內的"所有"參數取消註解 // let inv_params = { - // RelateNumber: 'PLEASE MODIFY', //請帶30碼uid ex: SJDFJGH24FJIL97G73653XM0VOMS4K - // CustomerID: 'MEM_0000001', //會員編號 - // CustomerIdentifier: '', //統一編號 - // CustomerName: '測試買家', - // CustomerAddr: '測試用地址', - // CustomerPhone: '0123456789', - // CustomerEmail: 'johndoe@test.com', - // ClearanceMark: '2', - // TaxType: '1', - // CarruerType: '', - // CarruerNum: '', - // Donation: '2', - // LoveCode: '', - // Print: '1', - // InvoiceItemName: '測試商品1|測試商品2', - // InvoiceItemCount: '2|3', - // InvoiceItemWord: '個|包', - // InvoiceItemPrice: '35|10', - // InvoiceItemTaxType: '1|1', - // InvoiceRemark: '測試商品1的說明|測試商品2的說明', - // DelayDay: '0', - // InvType: '07' -}; - -let create = new ecpay_payment(); -let htm = create.payment_client.aio_check_out_webatm(parameters = base_param, invoice = inv_params); -console.log(htm); \ No newline at end of file + // RelateNumber: 'PLEASE MODIFY', //請帶30碼uid ex: SJDFJGH24FJIL97G73653XM0VOMS4K + // CustomerID: 'MEM_0000001', //會員編號 + // CustomerIdentifier: '', //統一編號 + // CustomerName: '測試買家', + // CustomerAddr: '測試用地址', + // CustomerPhone: '0123456789', + // CustomerEmail: 'johndoe@test.com', + // ClearanceMark: '2', + // TaxType: '1', + // CarruerType: '', + // CarruerNum: '', + // Donation: '2', + // LoveCode: '', + // Print: '1', + // InvoiceItemName: '測試商品1|測試商品2', + // InvoiceItemCount: '2|3', + // InvoiceItemWord: '個|包', + // InvoiceItemPrice: '35|10', + // InvoiceItemTaxType: '1|1', + // InvoiceRemark: '測試商品1的說明|測試商品2的說明', + // DelayDay: '0', + // InvType: '07' +} +const options = require('../conf/config-example'), + create = new ecpay_payment(options) +htm = create.payment_client.aio_check_out_webatm(parameters = base_param, invoice = inv_params) +console.log(htm) \ No newline at end of file diff --git a/ECPAY_Payment_node_js/example/create_server_order.js b/ECPAY_Payment_node_js/example/create_server_order.js index 1d6c59d..f80fd18 100644 --- a/ECPAY_Payment_node_js/example/create_server_order.js +++ b/ECPAY_Payment_node_js/example/create_server_order.js @@ -1,25 +1,25 @@ /** * Created by ying.wu on 2017/6/27. */ -const ecpay_payment = require('../lib/ecpay_payment.js'); +const ecpay_payment = require('../lib/ecpay_payment.js') //參數值為[PLEASE MODIFY]者,請在每次測試時給予獨特值 //若要測試非必帶參數請將base_param內註解的參數依需求取消註解 // let base_param = { - MerchantTradeNo: 'PLEASE MODIFY', // 唯一值,不可重覆 - MerchantTradeDate: 'PLEASE MODIFY', // 交易時間格式為「yyyy/MM/dd HH:mm:ss」, ex: 2017/02/12 10:20:20 - TotalAmount: '100', - CurrencyCode: 'TWD', - ItemName: '手機2萬元', - PlatformID: '', - TradeDesc: 'Test TradeDesc', - TradeType: '2', // 1: In APP 2: On the Web - PaymentToken: '' // 請將Apple Server做商店驗證完回傳的Merchant Session物件中的Payment物件的JSON,轉成字串放入 -}; - -let query = new ecpay_payment(); -let res = query.query_client.create_server_order(parameters = base_param); + MerchantTradeNo: 'PLEASE MODIFY', // 唯一值,不可重覆 + MerchantTradeDate: 'PLEASE MODIFY', // 交易時間格式為「yyyy/MM/dd HH:mm:ss」, ex: 2017/02/12 10:20:20 + TotalAmount: '100', + CurrencyCode: 'TWD', + ItemName: '手機2萬元', + PlatformID: '', + TradeDesc: 'Test TradeDesc', + TradeType: '2', // 1: In APP 2: On the Web + PaymentToken: '' // 請將Apple Server做商店驗證完回傳的Merchant Session物件中的Payment物件的JSON,轉成字串放入 +} +const options = require('../conf/config-example'), + query = new ecpay_payment(options), + res = query.query_client.create_server_order(parameters = base_param) res.then(function (result) { - console.log(result); + console.log(result) }).catch(function (err) { - console.log(err); -}); \ No newline at end of file + console.log(err) +}) \ No newline at end of file diff --git a/ECPAY_Payment_node_js/example/credit_do_act.js b/ECPAY_Payment_node_js/example/credit_do_act.js index 8c92ec2..f815316 100644 --- a/ECPAY_Payment_node_js/example/credit_do_act.js +++ b/ECPAY_Payment_node_js/example/credit_do_act.js @@ -1,20 +1,20 @@ /** * Created by ying.wu on 2017/6/27. */ -const ecpay_payment = require('../lib/ecpay_payment.js'); +const ecpay_payment = require('../lib/ecpay_payment.js') //參數值為[PLEASE MODIFY]者,請在每次測試時給予獨特值 //若要測試非必帶參數請將base_param內註解的參數依需求取消註解 // let base_param = { - MerchantTradeNo: 'PLEASE MODIFY', //請帶20碼uid, ex: f0a0d7e9fae1bb72bc93 - TradeNo: 'PLEASE MODIFY', //ECpay的交易編號 - Action: 'C', - TotalAmount: '100' -}; - -let query = new ecpay_payment(); -let res = query.exec_grant_refund.credit_do_act(parameters = base_param); + MerchantTradeNo: 'PLEASE MODIFY', //請帶20碼uid, ex: f0a0d7e9fae1bb72bc93 + TradeNo: 'PLEASE MODIFY', //ECpay的交易編號 + Action: 'C', + TotalAmount: '100' +} +const options = require('../conf/config-example'), + query = new ecpay_payment(options), + res = query.exec_grant_refund.credit_do_act(parameters = base_param) res.then(function (result) { - console.log(result); + console.log(result) }).catch(function (err) { - console.log(err); -}); \ No newline at end of file + console.log(err) +}) \ No newline at end of file diff --git a/ECPAY_Payment_node_js/example/query_credit_csv.js b/ECPAY_Payment_node_js/example/query_credit_csv.js index bcc0d9f..76dbc37 100644 --- a/ECPAY_Payment_node_js/example/query_credit_csv.js +++ b/ECPAY_Payment_node_js/example/query_credit_csv.js @@ -1,19 +1,19 @@ /** * Created by ying.wu on 2017/6/27. */ -const ecpay_payment = require('../lib/ecpay_payment.js'); +const ecpay_payment = require('../lib/ecpay_payment.js') //參數值為[PLEASE MODIFY]者,請在每次測試時給予獨特值 //若要測試非必帶參數請將base_param內註解的參數依需求取消註解 // let base_param = { - PayDateType: 'close', - StartDate: 'PLEASE MODIFY', //日期格式為「yyyy-MM-dd」, ex: 2017-02-12 - EndDate: 'PLEASE MODIFY' //日期格式為「yyyy-MM-dd」, ex: 2017-02-12 -}; - -let query = new ecpay_payment(); -let res = query.query_client.query_credit_csv(parameters = base_param); + PayDateType: 'close', + StartDate: 'PLEASE MODIFY', //日期格式為「yyyy-MM-dd」, ex: 2017-02-12 + EndDate: 'PLEASE MODIFY' //日期格式為「yyyy-MM-dd」, ex: 2017-02-12 +} +const options = require('../conf/config-example'), + query = new ecpay_payment(options), + res = query.query_client.query_credit_csv(parameters = base_param) res.then(function (result) { - console.log(result); + console.log(result) }).catch(function (err) { - console.log(err); -}); \ No newline at end of file + console.log(err) +}) \ No newline at end of file diff --git a/ECPAY_Payment_node_js/example/query_credit_period.js b/ECPAY_Payment_node_js/example/query_credit_period.js index dd81327..90e296c 100644 --- a/ECPAY_Payment_node_js/example/query_credit_period.js +++ b/ECPAY_Payment_node_js/example/query_credit_period.js @@ -1,17 +1,18 @@ /** * Created by ying.wu on 2017/6/27. */ -const ecpay_payment = require('../lib/ecpay_payment.js'); +const ecpay_payment = require('../lib/ecpay_payment.js') //參數值為[PLEASE MODIFY]者,請在每次測試時給予獨特值 //若要測試非必帶參數請將base_param內註解的參數依需求取消註解 // let base_param = { - MerchantTradeNo: 'PLEASE MODIFY', //請帶20碼uid, ex: f0a0d7e9fae1bb72bc93 -}; + MerchantTradeNo: 'PLEASE MODIFY', //請帶20碼uid, ex: f0a0d7e9fae1bb72bc93 +} -let query = new ecpay_payment(); -let res = query.query_client.query_credit_period(parameters = base_param); +const options = require('../conf/config-example'), + query = new ecpay_payment(options), + res = query.query_client.query_credit_period(parameters = base_param) res.then(function (result) { - console.log(result); + console.log(result) }).catch(function (err) { - console.log(err); -}); \ No newline at end of file + console.log(err) +}) \ No newline at end of file diff --git a/ECPAY_Payment_node_js/example/query_credit_single.js b/ECPAY_Payment_node_js/example/query_credit_single.js index 55808f6..c6f1828 100644 --- a/ECPAY_Payment_node_js/example/query_credit_single.js +++ b/ECPAY_Payment_node_js/example/query_credit_single.js @@ -1,20 +1,20 @@ /** * Created by ying.wu on 2017/6/27. */ -const ecpay_payment = require('../lib/ecpay_payment.js'); +const ecpay_payment = require('../lib/ecpay_payment.js') //參數值為[PLEASE MODIFY]者,請在每次測試時給予獨特值 //若要測試非必帶參數請將base_param內註解的參數依需求取消註解 // //在測試環境因為沒有實際授權,此API僅會回傳{"RtnMsg":"","RtnValue":null},但代表API連線正常 let base_param = { - CreditRefundId: '10123456', - CreditAmount: '100', - CreditCheckCode: '59997889' -}; - -let query = new ecpay_payment(); -let res = query.query_client.query_credit_single(parameters = base_param); + CreditRefundId: '10123456', + CreditAmount: '100', + CreditCheckCode: '59997889' +} +const options = require('../conf/config-example'), + query = new ecpay_payment(options), + res = query.query_client.query_credit_single(parameters = base_param) res.then(function (result) { - console.log(result); + console.log(result) }).catch(function (err) { - console.log(err); -}); \ No newline at end of file + console.log(err) +}) \ No newline at end of file diff --git a/ECPAY_Payment_node_js/example/query_trade_info.js b/ECPAY_Payment_node_js/example/query_trade_info.js index 434c90d..c5747e4 100644 --- a/ECPAY_Payment_node_js/example/query_trade_info.js +++ b/ECPAY_Payment_node_js/example/query_trade_info.js @@ -1,17 +1,17 @@ /** * Created by ying.wu on 2017/6/27. */ -const ecpay_payment = require('../lib/ecpay_payment.js'); +const ecpay_payment = require('../lib/ecpay_payment.js') //參數值為[PLEASE MODIFY]者,請在每次測試時給予獨特值 //若要測試非必帶參數請將base_param內註解的參數依需求取消註解 // let base_param = { - MerchantTradeNo: 'PLEASE MODIFY', //請帶20碼uid, ex: f0a0d7e9fae1bb72bc93 -}; - -let query = new ecpay_payment(); -let res = query.query_client.query_trade_info(parameters = base_param); + MerchantTradeNo: 'PLEASE MODIFY', //請帶20碼uid, ex: f0a0d7e9fae1bb72bc93 +} +const options = require('../conf/config-example'), + query = new ecpay_payment(options), + res = query.query_client.query_trade_info(parameters = base_param) res.then(function (result) { - console.log(result); + console.log(result) }).catch(function (err) { - console.log(err); -}); \ No newline at end of file + console.log(err) +}) \ No newline at end of file diff --git a/ECPAY_Payment_node_js/example/query_transac_csv.js b/ECPAY_Payment_node_js/example/query_transac_csv.js index def5c5c..77db27c 100644 --- a/ECPAY_Payment_node_js/example/query_transac_csv.js +++ b/ECPAY_Payment_node_js/example/query_transac_csv.js @@ -1,24 +1,24 @@ /** * Created by ying.wu on 2017/6/27. */ -const ecpay_payment = require('../lib/ecpay_payment.js'); +const ecpay_payment = require('../lib/ecpay_payment.js') //參數值為[PLEASE MODIFY]者,請在每次測試時給予獨特值 //若要測試非必帶參數請將base_param內註解的參數依需求取消註解 // let base_param = { - DateType: '6', - BeginDate: 'PLEASE MODIFY', //日期格式為「yyyy-MM-dd」, ex: 2017-02-12 - EndDate: 'PLEASE MODIFY', //日期格式為「yyyy-MM-dd」, ex: 2017-02-12 - MediaFormated: '1', - // PaymentType: '01', - // PlatformStatus: '1', - // PaymentStatus: '0', - // AllocateStauts: '0' -}; - -let query = new ecpay_payment(); -let res = query.query_client.query_transac_csv(parameters = base_param); + DateType: '6', + BeginDate: 'PLEASE MODIFY', //日期格式為「yyyy-MM-dd」, ex: 2017-02-12 + EndDate: 'PLEASE MODIFY', //日期格式為「yyyy-MM-dd」, ex: 2017-02-12 + MediaFormated: '1', + // PaymentType: '01', + // PlatformStatus: '1', + // PaymentStatus: '0', + // AllocateStauts: '0' +} +const options = require('../conf/config-example'), + query = new ecpay_payment(options), + res = query.query_client.query_transac_csv(parameters = base_param) res.then(function (result) { - console.log(result); + console.log(result) }).catch(function (err) { - console.log(err); -}); \ No newline at end of file + console.log(err) +}) \ No newline at end of file From 0dec9ea662d6ce3f9545d670386919562f5b84fb Mon Sep 17 00:00:00 2001 From: adelachang0418 <53203322+adelachang0418@users.noreply.github.com> Date: Thu, 20 Feb 2020 11:23:07 +0800 Subject: [PATCH 8/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c4f105c..bd85901 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ ## 4. 聯絡我們 - - 綠界技術客服信箱: techsupport@ecpay.com.tw + - 綠界技術服務工程師信箱: techsupport@ecpay.com.tw