From c5faa28a0d3579ba6b79538a4757a50b00749426 Mon Sep 17 00:00:00 2001 From: bootpay Date: Tue, 16 Jan 2018 14:02:14 +0900 Subject: [PATCH 001/109] Update README.md --- README.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 799d850..2eb654b 100644 --- a/README.md +++ b/README.md @@ -1 +1,28 @@ -# server_nodejs + +## PG Analytics - 결제데이터 분석서비스 +* 기존 PG 사를 이용 중이신 사업자도 별도의 계약없이 부트페이를 통해 결제 연동과 통계를 무료로 이용하실 수 있습니다. +* 한줄의 소스코드로 인사이트를 얻어 매출을 극대화하세요. + + + +## 결제 검증 및 취소 - 서버사이드용 +* 보안상의 이유로 결제검증과 취소는 서버사이드에서 이루어집니다. +* 부트페이 서버와 통신시 Rest용 Application Id, Private Key 값을 보내주셔야 하며, 보내실 서버의 IP는 미리 등록하셔야 합니다. + +## npm을 통해 restler를 설치합니다 +``` +npm install restler +``` + +## 샘플 코드 +```nodejs +var Bootpay = require('./bootpay'); + +var bootpay = new Bootpay('application_id_value_1234', '593f8febe13f332431a8ddaw'); +// +bootpay.confirm('593f8febe13f332431a8ddae', function(data) { + console.log(data); +}); +``` + +### 더 자세한 정보는 [Docs](https://docs.bootpay.co.kr/api/validate?languageCurrentIndex=2)를 참조해주세요.  From 733b6303faf0456635ade4a2b1e866cbd083ffb8 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Tue, 29 May 2018 11:22:58 +0900 Subject: [PATCH 002/109] =?UTF-8?q?=EC=A0=95=EA=B8=B0=20=EA=B2=B0=EC=A0=9C?= =?UTF-8?q?=EA=B9=8C=EC=A7=80=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 5 ++ bootpay.js | 58 ----------------------- lib/bootpay.js | 98 +++++++++++++++++++++++++++++++++++++++ package.json | 32 +++++++++++++ test/access_token.js | 12 +++++ test/cancel.js | 14 ++++++ test/subscribe_billing.js | 14 ++++++ test/verify.js | 14 ++++++ 8 files changed, 189 insertions(+), 58 deletions(-) delete mode 100644 bootpay.js create mode 100644 lib/bootpay.js create mode 100644 package.json create mode 100644 test/access_token.js create mode 100644 test/cancel.js create mode 100644 test/subscribe_billing.js create mode 100644 test/verify.js diff --git a/.gitignore b/.gitignore index 9a439fc..ee0b027 100644 --- a/.gitignore +++ b/.gitignore @@ -45,4 +45,9 @@ jspm_packages # Yarn Integrity file .yarn-integrity +*.iml +*.idea +node_modules/* +package-lock.json +yarn.lock diff --git a/bootpay.js b/bootpay.js deleted file mode 100644 index e7926b6..0000000 --- a/bootpay.js +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Created by ehowlsla on 2017. 8. 3.. - */ -// npm install restler - -var rest = require('restler'); - -const BASE_URL = 'https://api.bootpay.co.kr/'; -const CONFIRM_URL = BASE_URL + 'receipt/'; -const CANCEL_URL = BASE_URL + 'cancel'; - - -var BootpayApi = function(application_id, private_key) { - if(application_id == undefined) throw 'application_id 값이 비어있습니다.'; - if(private_key == undefined) throw 'private_key 값이 비어있습니다.'; - - this.application_id = application_id; - this.private_key = private_key; -} - -BootpayApi.prototype.confirm = function (receipt_id, res) { - if(receipt_id == undefined) throw 'receipt_id 값이 비어있습니다.'; - - rest.get(CONFIRM_URL + receipt_id, { - query: { - application_id: this.application_id, - private_key: this.private_key - } - }).on('complete', function(data, response) { - res(data); - }); -} - - -BootpayApi.prototype.cancel = function (receipt_id, name, reason, res) { - if(receipt_id == undefined) throw 'receipt_id 값이 비어있습니다.'; - if(name == undefined) throw 'name 값이 비어있습니다.'; - if(reason == undefined) throw 'reason 값이 비어있습니다.'; - - var args = { - data: { - application_id: this.application_id, - private_key: this.private_key, - receipt_id: receipt_id, - name: name, - reason: reason, - format: 'json' - }, - headers: {'Accept': 'application/json', 'Content-Type': 'application/json'} - }; - - rest.post(CANCEL_URL, args).on('complete', function(data, response) { - res(data); - }); -} - - -module.exports = BootpayApi; \ No newline at end of file diff --git a/lib/bootpay.js b/lib/bootpay.js new file mode 100644 index 0000000..6e032ea --- /dev/null +++ b/lib/bootpay.js @@ -0,0 +1,98 @@ +/** + * Created by ehowlsla on 2017. 8. 3.. + */ +// npm install restler +var rest = require('restler'); + +module.exports = { + BASE_URL: { + development: 'https://dev-api.bootpay.co.kr', + production: 'https://api.bootpay.co.kr' + }, + applicationId: undefined, + privateKey: undefined, + mode: 'production', + token: undefined, + getUrl: function (uri = []) { + return [].concat([this.BASE_URL[this.mode]]).concat(uri).join('/'); + }, + setConfig: function (applicationId, privateKey, mode = 'production') { + this.applicationId = applicationId; + this.privateKey = privateKey; + this.mode = mode; + }, + getAccessToken: function (res) { + var _this = this; + rest.post( + this.getUrl(['request', 'token.json']), + { + data: { + application_id: this.applicationId, + private_key: this.privateKey + }, + headers: {'Accept': 'application/json', 'Content-Type': 'application/json'} + } + ).on('complete', function (data, response) { + if (data.status === 200) { + _this.token = data.data.token; + } + res(data); + }); + }, + verify: function (receiptId, res) { + if (receiptId === undefined) throw 'receiptId 값을 입력해주세요.'; + if (this.token === undefined || !this.token.length) throw 'Access Token을 발급 받은 후 진행해주세요.'; + rest.get( + this.getUrl(['receipt', receiptId + '.json']), + { + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': this.token + } + } + ).on('complete', function (data, response) { + res(data); + }); + }, + cancel: function (receiptId, name, reason, res) { + rest.post( + this.getUrl(['cancel.json']), + { + data: { + receipt_id: receiptId, + name: name, + reason: reason + }, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': this.token + } + } + ).on('complete', function (data, response) { + res(data); + }); + }, + subscribeBilling: function (billingKey, itemName, price, orderId, items = [], res) { + rest.post( + this.getUrl(['subscribe', 'billing.json']), + { + data: { + billing_key: billingKey, + item_name: itemName, + price: price, + order_id: orderId, + items: items + }, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': this.token + } + } + ).on('complete', function (data, response) { + res(data); + }); + } +}; \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..087d83d --- /dev/null +++ b/package.json @@ -0,0 +1,32 @@ +{ + "name": "bootpay-rest-client", + "version": "1.0.0", + "description": "Bootpay Rest Client Javasrcipt Library", + "main": "lib/bootpay.js", + "dependencies": { + "restler": "^3.4.0", + "babel-cli": "^6.26.0" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/bootpay/server_nodejs" + }, + "keywords": [ + "결제", + "payment", + "결제연동", + "PG연동", + "PG", + "부트페이", + "bootpay" + ], + "author": "Bootpay", + "license": "ISC", + "bugs": { + "url": "https://github.com/bootpay/server_nodejs/issues" + }, + "homepage": "https://docs.bootpay.co.kr" +} diff --git a/test/access_token.js b/test/access_token.js new file mode 100644 index 0000000..f435bce --- /dev/null +++ b/test/access_token.js @@ -0,0 +1,12 @@ +var BootpayRest = require('../lib/bootpay'); + +BootpayRest.setConfig( + '59bfc738e13f337dbd6ca48a', + 'FQj3jOvQYp053nxzWxHSuw+cq3zUlSWZV2ec/8fkiyA=', + 'development' +); + + +BootpayRest.getAccessToken(function (data) { + console.log(data); +}); \ No newline at end of file diff --git a/test/cancel.js b/test/cancel.js new file mode 100644 index 0000000..6e43ebb --- /dev/null +++ b/test/cancel.js @@ -0,0 +1,14 @@ +var BootpayRest = require('../lib/bootpay'); + +BootpayRest.setConfig( + '59bfc738e13f337dbd6ca48a', + 'FQj3jOvQYp053nxzWxHSuw+cq3zUlSWZV2ec/8fkiyA=', + 'development' +); + + +BootpayRest.getAccessToken(function (data) { + BootpayRest.cancel('1234', '테스트', '테스트입니다.', function (data) { + console.log(data); + }); +}); \ No newline at end of file diff --git a/test/subscribe_billing.js b/test/subscribe_billing.js new file mode 100644 index 0000000..86121ee --- /dev/null +++ b/test/subscribe_billing.js @@ -0,0 +1,14 @@ +var BootpayRest = require('../lib/bootpay'); + +BootpayRest.setConfig( + '59bfc738e13f337dbd6ca48a', + 'FQj3jOvQYp053nxzWxHSuw+cq3zUlSWZV2ec/8fkiyA=', + 'development' +); + + +BootpayRest.getAccessToken(function (data) { + BootpayRest.subscribeBilling('5b025b33e13f33310ce560fb', '정기결제입니다.', 1000, (new Date()).getTime(), [], function (data) { + console.log(data); + }); +}); \ No newline at end of file diff --git a/test/verify.js b/test/verify.js new file mode 100644 index 0000000..e6a91b0 --- /dev/null +++ b/test/verify.js @@ -0,0 +1,14 @@ +var BootpayRest = require('../lib/bootpay'); + +BootpayRest.setConfig( + '59bfc738e13f337dbd6ca48a', + 'FQj3jOvQYp053nxzWxHSuw+cq3zUlSWZV2ec/8fkiyA=', + 'development' +); + + +BootpayRest.getAccessToken(function (data) { + BootpayRest.verify('1234', function (data) { + console.log(data); + }); +}); \ No newline at end of file From 5c7d3673401492668affd9d877ac9f55b2c90098 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Tue, 29 May 2018 22:45:30 +0900 Subject: [PATCH 003/109] =?UTF-8?q?promise=20=EB=A1=9C=EC=A7=81=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=AA=A8=EB=91=90=20=EB=B3=80=EA=B2=BD=20=EC=98=88?= =?UTF-8?q?=EC=A0=9C=EB=8F=84=20=EB=AA=A8=EB=91=90=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 134 +++++++++++++++++++++----------------- test/access_token.js | 5 +- test/cancel.js | 5 +- test/subscribe_billing.js | 6 +- test/verify.js | 12 ++-- 5 files changed, 91 insertions(+), 71 deletions(-) diff --git a/lib/bootpay.js b/lib/bootpay.js index 6e032ea..b4d5e22 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -21,78 +21,90 @@ module.exports = { this.privateKey = privateKey; this.mode = mode; }, - getAccessToken: function (res) { - var _this = this; - rest.post( - this.getUrl(['request', 'token.json']), - { - data: { - application_id: this.applicationId, - private_key: this.privateKey - }, - headers: {'Accept': 'application/json', 'Content-Type': 'application/json'} - } - ).on('complete', function (data, response) { - if (data.status === 200) { - _this.token = data.data.token; - } - res(data); + getAccessToken: function () { + let _this = this; + return new Promise(function (resolve, reject) { + rest.post( + _this.getUrl(['request', 'token.json']), + { + data: { + application_id: _this.applicationId, + private_key: _this.privateKey + }, + headers: {'Accept': 'application/json', 'Content-Type': 'application/json'} + } + ).on('complete', function (data, response) { + if (data.status === 200) { + _this.token = data.data.token; + } + resolve(data); + }); }); }, - verify: function (receiptId, res) { + verify: function (receiptId) { if (receiptId === undefined) throw 'receiptId 값을 입력해주세요.'; if (this.token === undefined || !this.token.length) throw 'Access Token을 발급 받은 후 진행해주세요.'; - rest.get( - this.getUrl(['receipt', receiptId + '.json']), - { - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': this.token + let _this = this; + return new Promise(function (resolve, reject) { + rest.get( + _this.getUrl(['receipt', receiptId + '.json']), + { + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': _this.token + } } - } - ).on('complete', function (data, response) { - res(data); + ).on('complete', function (data, response) { + resolve(data); + }); }); }, - cancel: function (receiptId, name, reason, res) { - rest.post( - this.getUrl(['cancel.json']), - { - data: { - receipt_id: receiptId, - name: name, - reason: reason - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': this.token + cancel: function (receiptId, price = undefined, name = undefined, reason = undefined) { + let _this = this; + return new Promise(function (resolve, reject) { + rest.post( + _this.getUrl(['cancel.json']), + { + data: { + receipt_id: receiptId, + price: price, + name: name, + reason: reason + }, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': _this.token + } } - } - ).on('complete', function (data, response) { - res(data); + ).on('complete', function (data, response) { + resolve(data); + }); }); }, - subscribeBilling: function (billingKey, itemName, price, orderId, items = [], res) { - rest.post( - this.getUrl(['subscribe', 'billing.json']), - { - data: { - billing_key: billingKey, - item_name: itemName, - price: price, - order_id: orderId, - items: items - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': this.token + subscribeBilling: function (billingKey, itemName, price, orderId, items = []) { + let _this = this; + return new Promise(function(resolve, reject) { + rest.post( + _this.getUrl(['subscribe', 'billing.json']), + { + data: { + billing_key: billingKey, + item_name: itemName, + price: price, + order_id: orderId, + items: items + }, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': _this.token + } } - } - ).on('complete', function (data, response) { - res(data); + ).on('complete', function (data, response) { + resolve(data); + }); }); } }; \ No newline at end of file diff --git a/test/access_token.js b/test/access_token.js index f435bce..ad0fa31 100644 --- a/test/access_token.js +++ b/test/access_token.js @@ -7,6 +7,7 @@ BootpayRest.setConfig( ); -BootpayRest.getAccessToken(function (data) { - console.log(data); +BootpayRest.getAccessToken() +.then(function(data) { + console.log(data); }); \ No newline at end of file diff --git a/test/cancel.js b/test/cancel.js index 6e43ebb..b14ad23 100644 --- a/test/cancel.js +++ b/test/cancel.js @@ -8,7 +8,8 @@ BootpayRest.setConfig( BootpayRest.getAccessToken(function (data) { - BootpayRest.cancel('1234', '테스트', '테스트입니다.', function (data) { - console.log(data); + BootpayRest.cancel('1234') + .then(function(data) { + console.log(data); }); }); \ No newline at end of file diff --git a/test/subscribe_billing.js b/test/subscribe_billing.js index 86121ee..81b2ccf 100644 --- a/test/subscribe_billing.js +++ b/test/subscribe_billing.js @@ -7,8 +7,10 @@ BootpayRest.setConfig( ); -BootpayRest.getAccessToken(function (data) { - BootpayRest.subscribeBilling('5b025b33e13f33310ce560fb', '정기결제입니다.', 1000, (new Date()).getTime(), [], function (data) { +BootpayRest.getAccessToken() +.then(function(data) { + BootpayRest.subscribeBilling('5b025b33e13f33310ce560fb', '정기결제입니다.', 1000, (new Date()).getTime(), []) + .then(function(data) { console.log(data); }); }); \ No newline at end of file diff --git a/test/verify.js b/test/verify.js index e6a91b0..18cbf86 100644 --- a/test/verify.js +++ b/test/verify.js @@ -7,8 +7,12 @@ BootpayRest.setConfig( ); -BootpayRest.getAccessToken(function (data) { - BootpayRest.verify('1234', function (data) { - console.log(data); - }); +BootpayRest.getAccessToken() +.then(function(tokenData) { + if (tokenData.status === 200) { + BootpayRest.verify('1234') + .then(function (data) { + console.log(data); + }); + } }); \ No newline at end of file From 740762171401f66d652c25a77d1836b25493e22d Mon Sep 17 00:00:00 2001 From: Gosomi Date: Thu, 21 Jun 2018 21:14:48 +0900 Subject: [PATCH 004/109] =?UTF-8?q?=EC=B7=A8=EC=86=8C=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/cancel.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/cancel.js b/test/cancel.js index b14ad23..1fc43ac 100644 --- a/test/cancel.js +++ b/test/cancel.js @@ -7,9 +7,8 @@ BootpayRest.setConfig( ); -BootpayRest.getAccessToken(function (data) { - BootpayRest.cancel('1234') - .then(function(data) { - console.log(data); +BootpayRest.getAccessToken().then(function (data) { + BootpayRest.cancel('5b0df1b8e13f332c6c83df6a', 1000, '취소함', '취소합니다').then(function (data) { + console.log(data); }); }); \ No newline at end of file From abbdc38393790242122abfbde36b9f0a834c2e8e Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 27 Jun 2018 15:26:19 +0900 Subject: [PATCH 005/109] =?UTF-8?q?=EC=A0=95=EA=B8=B0=20=EA=B2=B0=EC=A0=9C?= =?UTF-8?q?=20=EC=98=88=EC=95=BD=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 29 ++++++++++++++++++++++++++++- test/cancel.js | 2 +- test/subscribe_billing.js | 2 +- test/subscribe_billing_reserve.js | 22 ++++++++++++++++++++++ 4 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 test/subscribe_billing_reserve.js diff --git a/lib/bootpay.js b/lib/bootpay.js index b4d5e22..8d91688 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -85,7 +85,7 @@ module.exports = { }, subscribeBilling: function (billingKey, itemName, price, orderId, items = []) { let _this = this; - return new Promise(function(resolve, reject) { + return new Promise(function (resolve, reject) { rest.post( _this.getUrl(['subscribe', 'billing.json']), { @@ -106,5 +106,32 @@ module.exports = { resolve(data); }); }); + }, + subscribeBillingReserve: function (billingKey, itemName, price, orderId, execute_at, feedback_url, items = []) { + let _this = this; + return new Promise(function (resolve, reject) { + rest.post( + _this.getUrl(['subscribe', 'billing', 'reserve.json']), + { + data: { + billing_key: billingKey, + item_name: itemName, + price: price, + order_id: orderId, + items: items, + scheduler_type: 'oneshot', + execute_at: execute_at, + feedback_url: feedback_url + }, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': _this.token + } + } + ).on('complete', function (data, response) { + resolve(data); + }); + }); } }; \ No newline at end of file diff --git a/test/cancel.js b/test/cancel.js index 1fc43ac..f063b3d 100644 --- a/test/cancel.js +++ b/test/cancel.js @@ -2,7 +2,7 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'FQj3jOvQYp053nxzWxHSuw+cq3zUlSWZV2ec/8fkiyA=', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', 'development' ); diff --git a/test/subscribe_billing.js b/test/subscribe_billing.js index 81b2ccf..a6e16ec 100644 --- a/test/subscribe_billing.js +++ b/test/subscribe_billing.js @@ -2,7 +2,7 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'FQj3jOvQYp053nxzWxHSuw+cq3zUlSWZV2ec/8fkiyA=', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', 'development' ); diff --git a/test/subscribe_billing_reserve.js b/test/subscribe_billing_reserve.js new file mode 100644 index 0000000..e263085 --- /dev/null +++ b/test/subscribe_billing_reserve.js @@ -0,0 +1,22 @@ +var BootpayRest = require('../lib/bootpay'); + +BootpayRest.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' +); + + +BootpayRest.getAccessToken() + .then(function (data) { + BootpayRest.subscribeBillingReserve( + '5b025b33e13f33310ce560fb', + '정기결제입니다.', + 1000, + (new Date()).getTime(), + ((new Date()).getTime() + 10000) / 1000, + "https://dev-api.bootpay.co.kr/callback" + ).then(function (data) { + console.log(data); + }); + }); \ No newline at end of file From 7448aa18957aa4f62f1031a0b0726ce257e6ec40 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Thu, 18 Oct 2018 16:22:47 +0900 Subject: [PATCH 006/109] =?UTF-8?q?es5=20=EB=8C=80=EC=9D=91=20throw=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 4 ++-- test/subscribe_billing_reserve.js | 2 +- test/verify.js | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/bootpay.js b/lib/bootpay.js index 8d91688..def4e86 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -42,8 +42,8 @@ module.exports = { }); }, verify: function (receiptId) { - if (receiptId === undefined) throw 'receiptId 값을 입력해주세요.'; - if (this.token === undefined || !this.token.length) throw 'Access Token을 발급 받은 후 진행해주세요.'; + if (receiptId === undefined) throw new Error('receiptId 값을 입력해주세요.'); + if (this.token === undefined || !this.token.length) throw new Error('Access Token을 발급 받은 후 진행해주세요.'); let _this = this; return new Promise(function (resolve, reject) { rest.get( diff --git a/test/subscribe_billing_reserve.js b/test/subscribe_billing_reserve.js index e263085..970752f 100644 --- a/test/subscribe_billing_reserve.js +++ b/test/subscribe_billing_reserve.js @@ -14,7 +14,7 @@ BootpayRest.getAccessToken() '정기결제입니다.', 1000, (new Date()).getTime(), - ((new Date()).getTime() + 10000) / 1000, + parseInt(new Date().getTime() / 1000) + 3600, // 1시간 뒤 실행 "https://dev-api.bootpay.co.kr/callback" ).then(function (data) { console.log(data); diff --git a/test/verify.js b/test/verify.js index 18cbf86..a203e13 100644 --- a/test/verify.js +++ b/test/verify.js @@ -2,7 +2,7 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'FQj3jOvQYp053nxzWxHSuw+cq3zUlSWZV2ec/8fkiyA=', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', 'development' ); @@ -14,5 +14,7 @@ BootpayRest.getAccessToken() .then(function (data) { console.log(data); }); + } else { + console.log('error!') } }); \ No newline at end of file From e06353de75bdd1ed440d4dc2f908e3b6926f3e46 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 16 Jan 2019 14:55:38 +0900 Subject: [PATCH 007/109] =?UTF-8?q?=EC=A0=95=EA=B8=B0=EA=B2=B0=EC=A0=9C=20?= =?UTF-8?q?=EC=B9=B4=EB=93=9C=20=EC=9A=94=EC=B2=AD=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/bootpay.js b/lib/bootpay.js index def4e86..dbec932 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -133,5 +133,33 @@ module.exports = { resolve(data); }); }); + }, + getSubscribeBillingKey: function (data) { + let _this = this; + return new Promise(function (resolve, reject) { + rest.post( + _this.getUrl(['request', 'card_rebill.json']), + { + data: { + order_id: data.orderId, + pg: data.pg, + item_name: data.name, + card_no: data.cardNo, + card_pw: data.cardPw, + expire_year: data.expireYear, + expire_month: data.expireMonth, + identify_number: data.identifyNumber, + user_info: data.userInfo + }, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': _this.token + } + } + ).on('complete', function (data, response) { + resolve(data); + }); + }); } }; \ No newline at end of file From 3474678b7ce5531eb5bacf9f5659ba16bd641541 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Mon, 18 Feb 2019 17:09:01 +0900 Subject: [PATCH 008/109] =?UTF-8?q?form=20=EA=B2=B0=EC=A0=9C=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20=ED=85=8C=EC=8A=A4=ED=8A=B8=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20submit=20rest=20api=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 20 ++++++++++++++++ test/form_payment_progress.js | 45 +++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 test/form_payment_progress.js diff --git a/lib/bootpay.js b/lib/bootpay.js index dbec932..7c05ff6 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -60,6 +60,26 @@ module.exports = { }); }); }, + submit: function(receiptId) { + let _this = this; + return new Promise(function(resolve, reject) { + rest.post( + _this.getUrl(['submit.json']), + { + data: { + receipt_id: receiptId, + }, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': _this.token + } + } + ).on('complete', function (data, response) { + resolve(data); + }); + }); + }, cancel: function (receiptId, price = undefined, name = undefined, reason = undefined) { let _this = this; return new Promise(function (resolve, reject) { diff --git a/test/form_payment_progress.js b/test/form_payment_progress.js new file mode 100644 index 0000000..a7a184a --- /dev/null +++ b/test/form_payment_progress.js @@ -0,0 +1,45 @@ +var BootpayRest = require('../lib/bootpay'); + +BootpayRest.setConfig( + "[[ REST용 Application ID]]", + "[[ Private Key ]]" +); + +// POST로 Params를 받아서 처리 +// params가 POST로 전달된 Object라고 가정하면 + +switch (params.act) { + case 'cancel': + // 결제창 닫을 때 이벤트 + break; + case 'error': + // 결제 진행중 에러가 났을 때 + // params.message로 데이터 전달 + break; + case 'confirm': + BootpayRest.getAccessToken().then(function (tokenData) { + // 부트페이 서버에서 토큰값을 제대로 가져온 경우 + if (tokenData.status === 200) { + BootpayRest.verify(params.receipt_id).then( + function (verify) { + // 원래 요청했던 금액과 일치하거나 + // 결제 승인 전 상태라면 결제 승인 요청을 한다. ( 승인전 상태는 status 값이 2 입니다. ) + if (verify.status === 200 && verify.price == originPrice && verify.data.status === 2) { + // 결제 승인한다. + BootpayRest.submit(params.receipt_id).then( + function (response) { + // 서버에서 REST API로 승인 후 200 OK를 받았다면 + // 결제가 완료 처리를 한다. + if (response.status === 200) { + console.log(response.data); + } + } + ) + } + } + ); + } + }); + + break; +} \ No newline at end of file From 8677dd93ad0de0d76fa75eefdccdea7b40da7638 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Tue, 19 Mar 2019 17:42:20 +0900 Subject: [PATCH 009/109] =?UTF-8?q?=EB=B9=8C=EB=A7=81=ED=82=A4=20=EC=B7=A8?= =?UTF-8?q?=EC=86=8C=ED=95=98=EB=8A=94=20=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/bootpay.js b/lib/bootpay.js index 7c05ff6..c068d7c 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -60,9 +60,9 @@ module.exports = { }); }); }, - submit: function(receiptId) { + submit: function (receiptId) { let _this = this; - return new Promise(function(resolve, reject) { + return new Promise(function (resolve, reject) { rest.post( _this.getUrl(['submit.json']), { @@ -181,5 +181,22 @@ module.exports = { resolve(data); }); }); + }, + destroySubscribeBillingKey: function (billingKey) { + let _this = this; + return new Promise(function (resolve, reject) { + rest.del( + _this.getUrl(['subscribe', 'billing', billingKey]), + { + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': _this.token + } + } + ).on('complete', function (data, response) { + resolve(data); + }); + }); } }; \ No newline at end of file From 25c04f0574831f7d25b0856a0ed5a6f1024be73c Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 17 Apr 2019 16:48:15 +0900 Subject: [PATCH 010/109] =?UTF-8?q?=EC=A0=95=EA=B8=B0=EA=B2=B0=EC=A0=9C=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=EC=9E=90=20=EC=A0=95=EB=B3=B4=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EC=9E=85=EB=A0=A5=20=ED=95=98=EB=8A=94=20field=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 7 +++++-- test/subscribe_billing.js | 23 +++++++++++++++++------ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/lib/bootpay.js b/lib/bootpay.js index c068d7c..cec3f31 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -103,7 +103,7 @@ module.exports = { }); }); }, - subscribeBilling: function (billingKey, itemName, price, orderId, items = []) { + subscribeBilling: function (billingKey, itemName, price, orderId, items = [], user_info = {}) { let _this = this; return new Promise(function (resolve, reject) { rest.post( @@ -114,7 +114,10 @@ module.exports = { item_name: itemName, price: price, order_id: orderId, - items: items + items: items, + username: user_info.username, + phone: user_info.phone, + address: user_info.address }, headers: { 'Accept': 'application/json', diff --git a/test/subscribe_billing.js b/test/subscribe_billing.js index a6e16ec..03b9c7e 100644 --- a/test/subscribe_billing.js +++ b/test/subscribe_billing.js @@ -8,9 +8,20 @@ BootpayRest.setConfig( BootpayRest.getAccessToken() -.then(function(data) { - BootpayRest.subscribeBilling('5b025b33e13f33310ce560fb', '정기결제입니다.', 1000, (new Date()).getTime(), []) - .then(function(data) { - console.log(data); - }); -}); \ No newline at end of file + .then( + // Access Token을 가져왔을 때 처리 + function (data) { + BootpayRest.subscribeBilling('5b025b33e13f33310ce560fb', '정기결제입니다.', 1000, (new Date()).getTime(), [], { + username: '홍길동', + phone: '010-0000-0000', + address: '서울특별시 구로구' + }) + .then(function (data) { + console.log(data); + }); + }, + // Access Token을 가져오는데 실패한 경우 + function (data) { + console.log(data); + } + ); \ No newline at end of file From 8f6dc3f50bf36d533dacc0fc6d5d8c66dd0bc982 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 17 Apr 2019 16:50:00 +0900 Subject: [PATCH 011/109] =?UTF-8?q?=EC=86=8C=EC=8A=A4=20=EA=B3=B5=EB=B0=B1?= =?UTF-8?q?=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/subscribe_billing.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/subscribe_billing.js b/test/subscribe_billing.js index 03b9c7e..3ff07dc 100644 --- a/test/subscribe_billing.js +++ b/test/subscribe_billing.js @@ -15,10 +15,9 @@ BootpayRest.getAccessToken() username: '홍길동', phone: '010-0000-0000', address: '서울특별시 구로구' - }) - .then(function (data) { - console.log(data); - }); + }).then(function (data) { + console.log(data); + }); }, // Access Token을 가져오는데 실패한 경우 function (data) { From 9e4e20be38a42d32e718f1b90702c8b549bbc4a7 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Tue, 23 Apr 2019 13:26:59 +0900 Subject: [PATCH 012/109] =?UTF-8?q?readme=20=EC=98=88=EC=A0=9C=20=EB=AC=B8?= =?UTF-8?q?=EC=84=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 19 ++++++++++++++----- test/verify.js | 9 ++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2eb654b..1ed00ed 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,20 @@ npm install restler ```nodejs var Bootpay = require('./bootpay'); -var bootpay = new Bootpay('application_id_value_1234', '593f8febe13f332431a8ddaw'); -// -bootpay.confirm('593f8febe13f332431a8ddae', function(data) { - console.log(data); +BootpayRest.setConfig( + '[[ REST용 application id ]]', + '[[ Private Key ]]' +); + +BootpayRest.getAccessToken().then(function (tokenData) { + if (tokenData.status === 200) { + BootpayRest.verify('1234') + .then(function (data) { + console.log(data); + }); + } else { + console.log('error!') + } }); -``` ### 더 자세한 정보는 [Docs](https://docs.bootpay.co.kr/api/validate?languageCurrentIndex=2)를 참조해주세요.  diff --git a/test/verify.js b/test/verify.js index a203e13..3884444 100644 --- a/test/verify.js +++ b/test/verify.js @@ -7,13 +7,12 @@ BootpayRest.setConfig( ); -BootpayRest.getAccessToken() -.then(function(tokenData) { +BootpayRest.getAccessToken().then(function (tokenData) { if (tokenData.status === 200) { BootpayRest.verify('1234') - .then(function (data) { - console.log(data); - }); + .then(function (data) { + console.log(data); + }); } else { console.log('error!') } From 589e1b3b100d7160d5d45ffa223295de04142422 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Fri, 19 Jul 2019 13:48:23 +0900 Subject: [PATCH 013/109] =?UTF-8?q?development=20=EC=98=B5=EC=85=98=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/access_token.js | 3 +-- test/cancel.js | 3 +-- test/subscribe_billing.js | 3 +-- test/subscribe_billing_reserve.js | 3 +-- test/verify.js | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/test/access_token.js b/test/access_token.js index ad0fa31..f45a0ea 100644 --- a/test/access_token.js +++ b/test/access_token.js @@ -2,8 +2,7 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'FQj3jOvQYp053nxzWxHSuw+cq3zUlSWZV2ec/8fkiyA=', - 'development' + 'FQj3jOvQYp053nxzWxHSuw+cq3zUlSWZV2ec/8fkiyA=' ); diff --git a/test/cancel.js b/test/cancel.js index f063b3d..80383b3 100644 --- a/test/cancel.js +++ b/test/cancel.js @@ -2,8 +2,7 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' ); diff --git a/test/subscribe_billing.js b/test/subscribe_billing.js index 3ff07dc..6e6de8f 100644 --- a/test/subscribe_billing.js +++ b/test/subscribe_billing.js @@ -2,8 +2,7 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' ); diff --git a/test/subscribe_billing_reserve.js b/test/subscribe_billing_reserve.js index 970752f..19091b1 100644 --- a/test/subscribe_billing_reserve.js +++ b/test/subscribe_billing_reserve.js @@ -2,8 +2,7 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' ); diff --git a/test/verify.js b/test/verify.js index 3884444..9f13e6a 100644 --- a/test/verify.js +++ b/test/verify.js @@ -2,8 +2,7 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' ); From 02a5eb223d2ac26c080c5e81a17e1d8cd97f8ebd Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 7 Aug 2019 17:30:09 +0900 Subject: [PATCH 014/109] =?UTF-8?q?stage=20=EC=98=B5=EC=85=98=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/bootpay.js b/lib/bootpay.js index cec3f31..19b79d0 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -7,6 +7,7 @@ var rest = require('restler'); module.exports = { BASE_URL: { development: 'https://dev-api.bootpay.co.kr', + stage: 'https://stage-api.bootpay.co.kr', production: 'https://api.bootpay.co.kr' }, applicationId: undefined, From 8e94476eb6860e26e9840065cdae41caae2d5ac4 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 7 Aug 2019 17:32:30 +0900 Subject: [PATCH 015/109] =?UTF-8?q?=EB=B2=84=EC=A0=84=201.0.1=20=EC=97=85?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=8A=B8=20subscribe=5Ftest=5Fpayment=20?= =?UTF-8?q?=EC=98=88=EC=A0=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 3 ++- package.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/bootpay.js b/lib/bootpay.js index 19b79d0..2e22368 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -173,7 +173,8 @@ module.exports = { expire_year: data.expireYear, expire_month: data.expireMonth, identify_number: data.identifyNumber, - user_info: data.userInfo + user_info: data.userInfo, + extra: data.extra }, headers: { 'Accept': 'application/json', diff --git a/package.json b/package.json index 087d83d..a4f25cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootpay-rest-client", - "version": "1.0.0", + "version": "1.0.1", "description": "Bootpay Rest Client Javasrcipt Library", "main": "lib/bootpay.js", "dependencies": { From dc6faeb8f41331b594f0befe1da558a2af043706 Mon Sep 17 00:00:00 2001 From: ehowlsla Date: Mon, 26 Aug 2019 10:45:54 +0900 Subject: [PATCH 016/109] remote form added --- lib/bootpay.js | 71 +++++++++++++++++++++++++++++++++++++++++++++ test/remote_form.js | 36 +++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 test/remote_form.js diff --git a/lib/bootpay.js b/lib/bootpay.js index 2e22368..6de6b4f 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -203,5 +203,76 @@ module.exports = { resolve(data); }); }); + }, + remoteForm: function (remoteForm, smsPayload = {}) { + let _this = this; + return new Promise(function (resolve, reject) { + rest.post( + _this.getUrl(['app', 'rest', 'remote_form.json']), + { + data: { + application_id: _this.applicationId, + remote_form: remoteForm, + sms_payload: smsPayload + }, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': _this.token + } + } + ).on('complete', function (data, response) { + resolve(data); + }); + }); + }, + sendSms: function (receiveNumbers, message, sendNumber = undefined, extra = {}) { + let _this = this; + return new Promise(function (resolve, reject) { + rest.post( + _this.getUrl(['push', 'sms.json']), + { + data: { + sp: sendNumber, + rps: receiveNumbers, + msg: message, + m_id: extra.m_id, + o_id: extra.o_id + }, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': _this.token + } + } + ).on('complete', function (data, response) { + resolve(data); + }); + }); + }, + sendLms: function (receiveNumbers, message, subject, sendNumber = undefined, extra = {}) { + let _this = this; + return new Promise(function (resolve, reject) { + rest.post( + _this.getUrl(['push', 'lms.json']), + { + data: { + sp: sendNumber, + rps: receiveNumbers, + msg: message, + sj: subject, + m_id: extra.m_id, + o_id: extra.o_id + }, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': _this.token + } + } + ).on('complete', function (data, response) { + resolve(data); + }); + }); } }; \ No newline at end of file diff --git a/test/remote_form.js b/test/remote_form.js new file mode 100644 index 0000000..1f55aae --- /dev/null +++ b/test/remote_form.js @@ -0,0 +1,36 @@ +var BootpayRest = require('../lib/bootpay'); + +BootpayRest.setConfig( + '5b9f51264457636ab9a07cde', + 'sfilSOSVakw+PZA+PRux4Iuwm7a//9CXXudCq9TMDHk=', + 'development' +); + +BootpayRest.remoteForm( + { + pg: 'danal', + fm: ['card', 'phone'], + n: '테스트 결제', //상품명 + o_key: 'unique_value_1234', //가맹점의 상품 고유 키 + is_r_n: false, //구매자가 상품명 입력 허용할지 말지 + is_r_p: false, //구매자가 가격 입력 허용할지 말지 + is_addr: false, //주소창 추가 할지 말지 + is_da: false, //배송비 추가 할지 말지 + is_memo: false, //구매자로부터 메모를 받을 지 + tfp: 0, //비과세 금액 + ip: 10000, //아이템 판매금액 + dp: 0, //디스플레이용 가격, 할인전 가격을 의미함, 쿠폰이나 프로모션에 의한 가격 디스카운트 개념 필요 - 페이코 때문에 생긴 개념 + dap: 0, //기본배송비 + dap_jj: 0, //제주 배송비 + dap_njj: 0 //제주 외 지역 도서산간 추가비용 + }, + { +// # st: 1, #1: sms, 2:lms, 3:mms, 4:알림톡, 5:친구톡 +// # rps: ['010-1234-5678', '010-1111-2222'], # 받는 사람 전화번호 +// # sp: '010-1234-1111', # 보내는 사람 전화번호 +// # msg: '테스트 문자입니다' + } +).then(function (data) { + console.log(data); +}); + From 39f2d7bfdd78a7db455a891d497e8e73a00f3410 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Thu, 19 Dec 2019 10:54:05 +0900 Subject: [PATCH 017/109] =?UTF-8?q?1.0.2=20=EB=B2=84=EC=A0=84=20=EB=B0=B0?= =?UTF-8?q?=ED=8F=AC=20=EB=B3=B8=EC=9D=B8=EC=9D=B8=EC=A6=9D=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8=20REST=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 20 ++++++++++++++++++++ package.json | 2 +- test/certificate.js | 18 ++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 test/certificate.js diff --git a/lib/bootpay.js b/lib/bootpay.js index 2e22368..47f4ace 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -203,5 +203,25 @@ module.exports = { resolve(data); }); }); + }, + certificate: function (receiptId) { + let _this = this; + return new Promise(function (resolve, reject) { + rest.post( + _this.getUrl(['certificate.json']), + { + data: { + receipt_id: receiptId + }, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': _this.token + } + } + ).on('complete', function (data, response) { + resolve(data); + }); + }); } }; \ No newline at end of file diff --git a/package.json b/package.json index a4f25cf..8669358 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootpay-rest-client", - "version": "1.0.1", + "version": "1.0.2", "description": "Bootpay Rest Client Javasrcipt Library", "main": "lib/bootpay.js", "dependencies": { diff --git a/test/certificate.js b/test/certificate.js new file mode 100644 index 0000000..6837919 --- /dev/null +++ b/test/certificate.js @@ -0,0 +1,18 @@ +var BootpayRest = require('../lib/bootpay'); + +BootpayRest.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' +); + + +BootpayRest.getAccessToken().then(function (tokenData) { + if (tokenData.status === 200) { + BootpayRest.certificate('1234') + .then(function (data) { + console.log(data); + }); + } else { + console.log('error!') + } +}); \ No newline at end of file From b55bb8e16791f7549919fdbd43ed4cf6ad3fb45e Mon Sep 17 00:00:00 2001 From: Gosomi Date: Fri, 20 Dec 2019 15:11:26 +0900 Subject: [PATCH 018/109] =?UTF-8?q?certificate=20GET=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/bootpay.js b/lib/bootpay.js index 501558b..d2426e6 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -207,12 +207,9 @@ module.exports = { certificate: function (receiptId) { let _this = this; return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['certificate.json']), + rest.get( + _this.getUrl(['certificate', receiptId]), { - data: { - receipt_id: receiptId - }, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json; charset=utf-8"', From 4d506ae7bb0f05143f6c8df84d5275b69741ac2c Mon Sep 17 00:00:00 2001 From: Gosomi Date: Tue, 21 Jan 2020 09:30:03 +0900 Subject: [PATCH 019/109] =?UTF-8?q?rest=20api=20=EA=B2=B0=EC=A0=9C=20?= =?UTF-8?q?=EB=A7=81=ED=81=AC=20=EC=83=9D=EC=84=B1=ED=95=98=EA=B8=B0=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 18 ++++++++++++++++++ test/request_payment.js | 27 +++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 test/request_payment.js diff --git a/lib/bootpay.js b/lib/bootpay.js index d2426e6..122414b 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -243,6 +243,24 @@ module.exports = { }); }); }, + requestPayment: function (data) { + let _this = this; + return new Promise(function (resolve, reject) { + rest.post( + _this.getUrl(['request', 'payment.json']), + { + data: data, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': _this.token + } + } + ).on('complete', function (data, response) { + resolve(data); + }); + }); + }, sendSms: function (receiveNumbers, message, sendNumber = undefined, extra = {}) { let _this = this; return new Promise(function (resolve, reject) { diff --git a/test/request_payment.js b/test/request_payment.js new file mode 100644 index 0000000..f03ea52 --- /dev/null +++ b/test/request_payment.js @@ -0,0 +1,27 @@ +var BootpayRest = require('../lib/bootpay'); + +BootpayRest.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' +); + + +BootpayRest.getAccessToken().then(function (tokenData) { + if (tokenData.status === 200) { + BootpayRest.requestPayment({ + pg: 'kcp', + method: 'card', + order_id: (new Date).getTime(), + price: 1000, + name: '테스트 부트페이 상품', + return_url: 'https://dev-api.bootpay.co.kr/callback', + extra: { + expire: 30 + } + }).then(function (data) { + console.log(data); + }); + } else { + console.log('error!') + } +}); \ No newline at end of file From 9d9eb54f099f054ac68687f775c1ee6ef66d53ae Mon Sep 17 00:00:00 2001 From: Gosomi Date: Thu, 30 Jan 2020 11:18:31 +0900 Subject: [PATCH 020/109] =?UTF-8?q?bootpay-rest-client=201.0.3=20=EB=B0=B0?= =?UTF-8?q?=ED=8F=AC=20=EC=A4=80=EB=B9=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8669358..27ef1a8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootpay-rest-client", - "version": "1.0.2", + "version": "1.0.3", "description": "Bootpay Rest Client Javasrcipt Library", "main": "lib/bootpay.js", "dependencies": { From 8df45945e5dbd016d6cf83665871bee74fcc40c7 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Mon, 10 Feb 2020 14:47:25 +0900 Subject: [PATCH 021/109] =?UTF-8?q?-=20access=20token=20=EB=B0=9C=EA=B8=89?= =?UTF-8?q?=20=EC=8B=A4=ED=8C=A8=EC=8B=9C=20reject=20=EC=B2=98=EB=A6=AC=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=201.0.4=20=EB=B2=84=EC=A0=84=20=EB=B0=B0?= =?UTF-8?q?=ED=8F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 4 +++- package.json | 2 +- test/subscribe_billing.js | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/bootpay.js b/lib/bootpay.js index 122414b..f5784c2 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -37,8 +37,10 @@ module.exports = { ).on('complete', function (data, response) { if (data.status === 200) { _this.token = data.data.token; + resolve(data); + } else { + reject(data); } - resolve(data); }); }); }, diff --git a/package.json b/package.json index 27ef1a8..47c2014 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootpay-rest-client", - "version": "1.0.3", + "version": "1.0.4", "description": "Bootpay Rest Client Javasrcipt Library", "main": "lib/bootpay.js", "dependencies": { diff --git a/test/subscribe_billing.js b/test/subscribe_billing.js index 6e6de8f..05948f3 100644 --- a/test/subscribe_billing.js +++ b/test/subscribe_billing.js @@ -16,6 +16,8 @@ BootpayRest.getAccessToken() address: '서울특별시 구로구' }).then(function (data) { console.log(data); + }, function (data) { + console.log(data); }); }, // Access Token을 가져오는데 실패한 경우 From 28a11eb54c7662f5e2f102d52337e870a0e4bc97 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Mon, 30 Mar 2020 17:54:10 +0900 Subject: [PATCH 022/109] =?UTF-8?q?user=20token=20=EA=B0=80=EC=A0=B8?= =?UTF-8?q?=EC=98=A4=EA=B8=B0=20=EB=B0=B0=ED=8F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 18 ++++++++++++++++++ package.json | 2 +- test/get_user_token.js | 23 +++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 test/get_user_token.js diff --git a/lib/bootpay.js b/lib/bootpay.js index f5784c2..b2e29bf 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -311,5 +311,23 @@ module.exports = { resolve(data); }); }); + }, + getUserToken: function (data) { + let _this = this; + return new Promise(function (resolve, reject) { + rest.post( + _this.getUrl(['request', 'user', 'token.json']), + { + data: data, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': _this.token + } + } + ).on('complete', function (data, response) { + resolve(data); + }); + }); } }; \ No newline at end of file diff --git a/package.json b/package.json index 47c2014..3a43f23 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootpay-rest-client", - "version": "1.0.4", + "version": "1.0.5", "description": "Bootpay Rest Client Javasrcipt Library", "main": "lib/bootpay.js", "dependencies": { diff --git a/test/get_user_token.js b/test/get_user_token.js new file mode 100644 index 0000000..276c082 --- /dev/null +++ b/test/get_user_token.js @@ -0,0 +1,23 @@ +var BootpayRest = require('../lib/bootpay'); + +BootpayRest.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' +); + +BootpayRest.getAccessToken().then(function (tokenData) { + if (tokenData.status === 200) { + BootpayRest.getUserToken({ + user_id: '[[ user_id ]] ( 필수 )', + email: 'bootpay@bootpay.co.kr', // 필수 + name: '[[ 사용자 명 ]] ( 선택 )', + gender: '[[ 0 - 여자, 1 - 남자 ]] ( 선택 )', + birth: ' [[ 생년월일 ( 6자리) ]] ( 선택 )', + phone: ' [[ 전화번호 ]] ( 페이앱의 경우 필수 )' + }).then(function (data) { + console.log(data); + }); + } else { + console.log('error!') + } +}); \ No newline at end of file From 550419c4903435854310d19f79b1d23a7371c33b Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 29 Apr 2020 13:00:01 +0900 Subject: [PATCH 023/109] =?UTF-8?q?=EB=B9=8C=EB=A7=81=ED=82=A4=20=EC=98=88?= =?UTF-8?q?=EC=95=BD=20=EC=B7=A8=EC=86=8C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/subscribe_billing_reserve_cancel.js | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/subscribe_billing_reserve_cancel.js diff --git a/test/subscribe_billing_reserve_cancel.js b/test/subscribe_billing_reserve_cancel.js new file mode 100644 index 0000000..d4f4814 --- /dev/null +++ b/test/subscribe_billing_reserve_cancel.js @@ -0,0 +1,27 @@ +var BootpayRest = require('../lib/bootpay'); + +BootpayRest.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' +); + + +BootpayRest.getAccessToken() + .then(function (data) { + BootpayRest.subscribeBillingReserve( + '5b025b33e13f33310ce560fb', + '정기결제입니다.', + 1000, + (new Date()).getTime(), + parseInt(new Date().getTime() / 1000) + 3600, // 1시간 뒤 실행 + "https://dev-api.bootpay.co.kr/callback" + ).then(function (data) { + console.log(data); + // 예약된 빌링키 취소 + BootpayRest.destroySubscribeBillingKey(data.reserve_id).then( + function(data) { + console.log(data) + } + ) + }); + }); \ No newline at end of file From 2ec69a7f84598489d1bd3481fe9670caca9a1a47 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 29 Apr 2020 13:18:59 +0900 Subject: [PATCH 024/109] =?UTF-8?q?=EC=98=88=EC=95=BD=EB=90=9C=20=EB=B9=8C?= =?UTF-8?q?=EB=A7=81=ED=82=A4=20=EC=B7=A8=EC=86=8C=20test=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=B0=8F=20=EB=A9=94=EC=9D=B8=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=20merge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 17 +++++++++++++++++ test/subscribe_billing_reserve_cancel.js | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/bootpay.js b/lib/bootpay.js index b2e29bf..4d47c33 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -206,6 +206,23 @@ module.exports = { }); }); }, + destroySubscribeBillingReserveCancel: function (billingKey) { + let _this = this; + return new Promise(function (resolve, reject) { + rest.del( + _this.getUrl(['subscribe', 'billing', 'reserve', billingKey]), + { + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': _this.token + } + } + ).on('complete', function (data, response) { + resolve(data); + }); + }); + }, certificate: function (receiptId) { let _this = this; return new Promise(function (resolve, reject) { diff --git a/test/subscribe_billing_reserve_cancel.js b/test/subscribe_billing_reserve_cancel.js index d4f4814..087a223 100644 --- a/test/subscribe_billing_reserve_cancel.js +++ b/test/subscribe_billing_reserve_cancel.js @@ -18,7 +18,7 @@ BootpayRest.getAccessToken() ).then(function (data) { console.log(data); // 예약된 빌링키 취소 - BootpayRest.destroySubscribeBillingKey(data.reserve_id).then( + BootpayRest.destroySubscribeBillingReserveCancel(data.reserve_id).then( function(data) { console.log(data) } From 20e65099dbdf7f7d0cc8751aaed6875d83ac14f2 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Mon, 22 Jun 2020 17:16:37 +0900 Subject: [PATCH 025/109] =?UTF-8?q?2.0.0=20=EB=B2=84=EC=A0=84=20=EB=B8=8C?= =?UTF-8?q?=EB=9F=B0=EC=B9=98=20=EB=B3=84=EB=8F=84=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 590 ++++++++++++----------- package.json | 6 +- test/access_token.js | 12 +- test/cancel.js | 21 +- test/certificate.js | 24 +- test/get_user_token.js | 3 +- test/request_payment.js | 43 +- test/request_subscribe_rest.js | 46 +- test/subscribe_billing.js | 3 +- test/subscribe_billing_reserve.js | 36 +- test/subscribe_billing_reserve_cancel.js | 44 +- test/verify.js | 24 +- 12 files changed, 444 insertions(+), 408 deletions(-) diff --git a/lib/bootpay.js b/lib/bootpay.js index 4d47c33..1cc3417 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -1,8 +1,7 @@ /** * Created by ehowlsla on 2017. 8. 3.. */ -// npm install restler -var rest = require('restler'); +var request = require('request-promise-native'); module.exports = { BASE_URL: { @@ -22,329 +21,336 @@ module.exports = { this.privateKey = privateKey; this.mode = mode; }, - getAccessToken: function () { - let _this = this; - return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['request', 'token.json']), - { - data: { - application_id: _this.applicationId, - private_key: _this.privateKey + getAccessToken: async function () { + let response + try { + response = await request({ + method: 'POST', + url: this.getUrl(['request', 'token.json']), + body: { + application_id: this.applicationId, + private_key: this.privateKey }, - headers: {'Accept': 'application/json', 'Content-Type': 'application/json'} - } - ).on('complete', function (data, response) { - if (data.status === 200) { - _this.token = data.data.token; - resolve(data); - } else { - reject(data); + json: true } - }); - }); + ) + } catch (e) { + return Promise.reject(e) + } + this.token = response.data.token + return Promise.resolve(response) }, - verify: function (receiptId) { + verify: async function (receiptId) { if (receiptId === undefined) throw new Error('receiptId 값을 입력해주세요.'); if (this.token === undefined || !this.token.length) throw new Error('Access Token을 발급 받은 후 진행해주세요.'); - let _this = this; - return new Promise(function (resolve, reject) { - rest.get( - _this.getUrl(['receipt', receiptId + '.json']), - { - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': _this.token - } + let response = undefined + try { + response = await request({ + method: 'GET', + url: this.getUrl(['receipt', receiptId + '.json']), + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': this.token } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + }) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - submit: function (receiptId) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['submit.json']), + submit: async function (receiptId) { + let response + try { + response = request( { - data: { + method: 'POST', + url: this.getUrl(['submit.json']), + body: { receipt_id: receiptId, }, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', - 'Authorization': _this.token - } - } - ).on('complete', function (data, response) { - resolve(data); - }); - }); - }, - cancel: function (receiptId, price = undefined, name = undefined, reason = undefined) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['cancel.json']), - { - data: { - receipt_id: receiptId, - price: price, - name: name, - reason: reason + 'Authorization': this.token }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': _this.token - } + json: true } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - subscribeBilling: function (billingKey, itemName, price, orderId, items = [], user_info = {}) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['subscribe', 'billing.json']), - { - data: { - billing_key: billingKey, - item_name: itemName, - price: price, - order_id: orderId, - items: items, - username: user_info.username, - phone: user_info.phone, - address: user_info.address - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': _this.token - } - } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + cancel: async function (receiptId, price = undefined, name = undefined, reason = undefined) { + let response + try { + response = await request({ + method: 'POST', + url: this.getUrl(['cancel.json']), + body: { + receipt_id: receiptId, + price: price, + name: name, + reason: reason + }, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': this.token + }, + json: true + }) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - subscribeBillingReserve: function (billingKey, itemName, price, orderId, execute_at, feedback_url, items = []) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['subscribe', 'billing', 'reserve.json']), - { - data: { - billing_key: billingKey, - item_name: itemName, - price: price, - order_id: orderId, - items: items, - scheduler_type: 'oneshot', - execute_at: execute_at, - feedback_url: feedback_url - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': _this.token - } + subscribeBilling: async function (billingKey, itemName, price, orderId, items = [], user_info = {}) { + let response + try { + response = await request({ + method: 'POST', + url: this.getUrl(['subscribe', 'billing.json']), + body: { + billing_key: billingKey, + item_name: itemName, + price: price, + order_id: orderId, + items: items, + username: user_info.username, + phone: user_info.phone, + address: user_info.address + }, + json: true, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': _this.token } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + }) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - getSubscribeBillingKey: function (data) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['request', 'card_rebill.json']), - { - data: { - order_id: data.orderId, - pg: data.pg, - item_name: data.name, - card_no: data.cardNo, - card_pw: data.cardPw, - expire_year: data.expireYear, - expire_month: data.expireMonth, - identify_number: data.identifyNumber, - user_info: data.userInfo, - extra: data.extra - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': _this.token - } + subscribeBillingReserve: async function (billingKey, itemName, price, orderId, execute_at, feedback_url, items = []) { + let response + try { + response = await request({ + method: 'POST', + url: this.getUrl(['subscribe', 'billing', 'reserve.json']), + body: { + billing_key: billingKey, + item_name: itemName, + price: price, + order_id: orderId, + items: items, + scheduler_type: 'oneshot', + execute_at: execute_at, + feedback_url: feedback_url + }, + json: true, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': this.token } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + }) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - destroySubscribeBillingKey: function (billingKey) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.del( - _this.getUrl(['subscribe', 'billing', billingKey]), - { - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': _this.token - } + getSubscribeBillingKey: async function (data) { + let response + try { + response = await request({ + method: 'POST', + url: this.getUrl(['request', 'card_rebill.json']), + body: { + order_id: data.orderId, + pg: data.pg, + item_name: data.name, + card_no: data.cardNo, + card_pw: data.cardPw, + expire_year: data.expireYear, + expire_month: data.expireMonth, + identify_number: data.identifyNumber, + user_info: data.userInfo, + extra: data.extra + }, + json: true, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': this.token } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + }) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - destroySubscribeBillingReserveCancel: function (billingKey) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.del( - _this.getUrl(['subscribe', 'billing', 'reserve', billingKey]), - { - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': _this.token - } + destroySubscribeBillingKey: async function (billingKey) { + let response + try { + response = await request({ + method: 'DELETE', + url: this.getUrl(['subscribe', 'billing', billingKey]), + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': this.token } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + }) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - certificate: function (receiptId) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.get( - _this.getUrl(['certificate', receiptId]), - { - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': _this.token - } + destroySubscribeBillingReserveCancel: async function (billingKey) { + let response + try { + response = await request({ + method: 'DELETE', + url: this.getUrl(['subscribe', 'billing', 'reserve', billingKey]), + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': this.token } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + }) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - remoteForm: function (remoteForm, smsPayload = {}) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['app', 'rest', 'remote_form.json']), - { - data: { - application_id: _this.applicationId, - remote_form: remoteForm, - sms_payload: smsPayload - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': _this.token - } + certificate: async function (receiptId) { + let response + try { + response = await request({ + method: 'GET', + url: this.getUrl(['certificate', receiptId]), + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': this.token } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + }) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - requestPayment: function (data) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['request', 'payment.json']), - { - data: data, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': _this.token - } + remoteForm: async function (remoteForm, smsPayload = {}) { + let response + try { + response = await request({ + method: 'POST', + url: this.getUrl(['app', 'rest', 'remote_form.json']), + body: { + application_id: _this.applicationId, + remote_form: remoteForm, + sms_payload: smsPayload + }, + json: true, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': this.token } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + }) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - sendSms: function (receiveNumbers, message, sendNumber = undefined, extra = {}) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['push', 'sms.json']), - { - data: { - sp: sendNumber, - rps: receiveNumbers, - msg: message, - m_id: extra.m_id, - o_id: extra.o_id - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': _this.token - } + requestPayment: async function (data) { + let response + try { + response = await request({ + method: 'POST', + url: this.getUrl(['request', 'payment.json']), + body: data, + json: true, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': this.token } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + }) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - sendLms: function (receiveNumbers, message, subject, sendNumber = undefined, extra = {}) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['push', 'lms.json']), - { - data: { - sp: sendNumber, - rps: receiveNumbers, - msg: message, - sj: subject, - m_id: extra.m_id, - o_id: extra.o_id - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': _this.token - } + getUserToken: async function (data) { + let response + try { + response = await request({ + method: 'POST', + url: this.getUrl(['request', 'user', 'token.json']), + body: data, + json: true, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': this.token } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + }) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - getUserToken: function (data) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['request', 'user', 'token.json']), - { - data: data, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': _this.token - } - } - ).on('complete', function (data, response) { - resolve(data); - }); - }); - } + // sendSms: function (receiveNumbers, message, sendNumber = undefined, extra = {}) { + // let _this = this; + // return new Promise(function (resolve, reject) { + // request.post( + // _this.getUrl(['push', 'sms.json']), + // { + // data: { + // sp: sendNumber, + // rps: receiveNumbers, + // msg: message, + // m_id: extra.m_id, + // o_id: extra.o_id + // }, + // headers: { + // 'Accept': 'application/json', + // 'Content-Type': 'application/json; charset=utf-8"', + // 'Authorization': _this.token + // } + // } + // ).on('response', function (data, response) { + // resolve(data); + // }); + // }); + // }, + // sendLms: function (receiveNumbers, message, subject, sendNumber = undefined, extra = {}) { + // let _this = this; + // return new Promise(function (resolve, reject) { + // request.post( + // _this.getUrl(['push', 'lms.json']), + // { + // data: { + // sp: sendNumber, + // rps: receiveNumbers, + // msg: message, + // sj: subject, + // m_id: extra.m_id, + // o_id: extra.o_id + // }, + // headers: { + // 'Accept': 'application/json', + // 'Content-Type': 'application/json; charset=utf-8"', + // 'Authorization': _this.token + // } + // } + // ).on('response', function (data, response) { + // resolve(data); + // }); + // }); + // }, }; \ No newline at end of file diff --git a/package.json b/package.json index 3a43f23..2be67ba 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "bootpay-rest-client", - "version": "1.0.5", + "version": "2.0.0", "description": "Bootpay Rest Client Javasrcipt Library", "main": "lib/bootpay.js", "dependencies": { - "restler": "^3.4.0", - "babel-cli": "^6.26.0" + "request": "^2.88.2", + "request-promise-native": "^1.0.8" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" diff --git a/test/access_token.js b/test/access_token.js index f45a0ea..3287584 100644 --- a/test/access_token.js +++ b/test/access_token.js @@ -2,11 +2,11 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'FQj3jOvQYp053nxzWxHSuw+cq3zUlSWZV2ec/8fkiyA=' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' ); - -BootpayRest.getAccessToken() -.then(function(data) { - console.log(data); -}); \ No newline at end of file +(async () => { + let response = await BootpayRest.getAccessToken(); + console.log(response); +})() diff --git a/test/cancel.js b/test/cancel.js index 80383b3..949feb5 100644 --- a/test/cancel.js +++ b/test/cancel.js @@ -2,12 +2,19 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' ); - -BootpayRest.getAccessToken().then(function (data) { - BootpayRest.cancel('5b0df1b8e13f332c6c83df6a', 1000, '취소함', '취소합니다').then(function (data) { - console.log(data); - }); -}); \ No newline at end of file +(async () => { + let token = await BootpayRest.getAccessToken() + if (token.status === 200) { + let response + try { + response = await BootpayRest.cancel('5b0df1b8e13f332c6c83df6a', 1000, '취소함', '취소합니다') + } catch (e) { + return console.log(e.error) + } + console.log(response) + } +})() \ No newline at end of file diff --git a/test/certificate.js b/test/certificate.js index 6837919..535f0c3 100644 --- a/test/certificate.js +++ b/test/certificate.js @@ -2,17 +2,19 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' ); - -BootpayRest.getAccessToken().then(function (tokenData) { - if (tokenData.status === 200) { - BootpayRest.certificate('1234') - .then(function (data) { - console.log(data); - }); - } else { - console.log('error!') +(async () => { + let token = await BootpayRest.getAccessToken() + if (token.status === 200) { + let response + try { + response = await BootpayRest.certificate('1234') + } catch (e) { + return console.log(e.error) + } + console.log(response) } -}); \ No newline at end of file +})() \ No newline at end of file diff --git a/test/get_user_token.js b/test/get_user_token.js index 276c082..72a7da3 100644 --- a/test/get_user_token.js +++ b/test/get_user_token.js @@ -2,7 +2,8 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' ); BootpayRest.getAccessToken().then(function (tokenData) { diff --git a/test/request_payment.js b/test/request_payment.js index f03ea52..44af4e5 100644 --- a/test/request_payment.js +++ b/test/request_payment.js @@ -2,26 +2,29 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' ); - -BootpayRest.getAccessToken().then(function (tokenData) { - if (tokenData.status === 200) { - BootpayRest.requestPayment({ - pg: 'kcp', - method: 'card', - order_id: (new Date).getTime(), - price: 1000, - name: '테스트 부트페이 상품', - return_url: 'https://dev-api.bootpay.co.kr/callback', - extra: { - expire: 30 - } - }).then(function (data) { - console.log(data); - }); - } else { - console.log('error!') +(async () => { + let token = await BootpayRest.getAccessToken() + if (token.status === 200) { + let response + try { + response = await BootpayRest.requestPayment({ + pg: 'kcp', + method: 'card', + order_id: (new Date).getTime(), + price: 1000, + name: '테스트 부트페이 상품', + return_url: 'https://dev-api.bootpay.co.kr/callback', + extra: { + expire: 30 + } + }) + } catch (e) { + response = e.error + } + console.log(response) } -}); \ No newline at end of file +})() \ No newline at end of file diff --git a/test/request_subscribe_rest.js b/test/request_subscribe_rest.js index b18c82f..7baeee6 100644 --- a/test/request_subscribe_rest.js +++ b/test/request_subscribe_rest.js @@ -2,27 +2,31 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' ); - -BootpayRest.getAccessToken().then(function (data) { - BootpayRest.getSubscribeBillingKey({ - orderId: (new Date()).getTime(), - pg: 'nicepay', - name: '정기결제 30일권', - cardNo: '[ 카드 번호 ]', - cardPw: '[ 카드 비밀번호 앞 2자리 ]', - expireYear: '[ 카드 만료 연도 ]', - expireMonth: '[ 카드 만료 월 ]', - identifyNumber: '[ 카드 소유주 생년월일 혹은 법인 번호 ]', - extra: { - subscribe_test_payment: 1 // 100원 결제 후 결제가 되면 billing key를 발행, 결제가 실패하면 에러 +(async () => { + let token = await BootpayRest.getAccessToken() + if (token.status === 200) { + let response + try { + response = await BootpayRest.getSubscribeBillingKey({ + orderId: (new Date()).getTime(), + pg: 'nicepay', + name: '정기결제 30일권', + cardNo: '[ 카드 번호 ]', + cardPw: '[ 카드 비밀번호 앞 2자리 ]', + expireYear: '[ 카드 만료 연도 ]', + expireMonth: '[ 카드 만료 월 ]', + identifyNumber: '[ 카드 소유주 생년월일 혹은 법인 번호 ]', + extra: { + subscribe_test_payment: 1 // 100원 결제 후 결제가 되면 billing key를 발행, 결제가 실패하면 에러 + } + }) + } catch (e) { + return console.log(e.error) } - }).then(function (response) { - console.log(response); - // 발급 받은 키를 삭제하는 로직입니다. - BootpayRest.destroySubscribeBillingKey(response.data.billing_key); - }); - -}); \ No newline at end of file + console.log(response) + } +})() \ No newline at end of file diff --git a/test/subscribe_billing.js b/test/subscribe_billing.js index 05948f3..99be22b 100644 --- a/test/subscribe_billing.js +++ b/test/subscribe_billing.js @@ -2,7 +2,8 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' ); diff --git a/test/subscribe_billing_reserve.js b/test/subscribe_billing_reserve.js index 19091b1..c73b08c 100644 --- a/test/subscribe_billing_reserve.js +++ b/test/subscribe_billing_reserve.js @@ -2,20 +2,26 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' ); - -BootpayRest.getAccessToken() - .then(function (data) { - BootpayRest.subscribeBillingReserve( - '5b025b33e13f33310ce560fb', - '정기결제입니다.', - 1000, - (new Date()).getTime(), - parseInt(new Date().getTime() / 1000) + 3600, // 1시간 뒤 실행 - "https://dev-api.bootpay.co.kr/callback" - ).then(function (data) { - console.log(data); - }); - }); \ No newline at end of file +(async () =>{ + let token = await BootpayRest.getAccessToken() + if(token.status === 200) { + let response + try { + response = await BootpayRest.subscribeBillingReserve( + '5b025b33e13f33310ce560fb', + '정기결제입니다.', + 1000, + (new Date()).getTime(), + parseInt(new Date().getTime() / 1000) + 3600, // 1시간 뒤 실행 + "https://dev-api.bootpay.co.kr/callback" + ) + } catch (e) { + console.log(e.error) + } + console.log(response) + } +})() \ No newline at end of file diff --git a/test/subscribe_billing_reserve_cancel.js b/test/subscribe_billing_reserve_cancel.js index 087a223..09be7f0 100644 --- a/test/subscribe_billing_reserve_cancel.js +++ b/test/subscribe_billing_reserve_cancel.js @@ -2,26 +2,30 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' ); - -BootpayRest.getAccessToken() - .then(function (data) { - BootpayRest.subscribeBillingReserve( - '5b025b33e13f33310ce560fb', - '정기결제입니다.', - 1000, - (new Date()).getTime(), - parseInt(new Date().getTime() / 1000) + 3600, // 1시간 뒤 실행 - "https://dev-api.bootpay.co.kr/callback" - ).then(function (data) { - console.log(data); - // 예약된 빌링키 취소 - BootpayRest.destroySubscribeBillingReserveCancel(data.reserve_id).then( - function(data) { - console.log(data) - } +(async () => { + let token = await BootpayRest.getAccessToken() + if (token.status === 200) { + let response + try { + response = await BootpayRest.subscribeBillingReserve( + '5b025b33e13f33310ce560fb', + '정기결제입니다.', + 1000, + (new Date()).getTime(), + parseInt(new Date().getTime() / 1000) + 3600, // 1시간 뒤 실행 + "https://dev-api.bootpay.co.kr/callback" ) - }); - }); \ No newline at end of file + } catch (e) { + response = e.error + } + console.log(response) + if (response.status === 200) { + let cancelled_response = await BootpayRest.destroySubscribeBillingReserveCancel(response.data.reserve_id) + console.log(cancelled_response) + } + } +})() \ No newline at end of file diff --git a/test/verify.js b/test/verify.js index 9f13e6a..b812335 100644 --- a/test/verify.js +++ b/test/verify.js @@ -2,17 +2,19 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' ); - -BootpayRest.getAccessToken().then(function (tokenData) { - if (tokenData.status === 200) { - BootpayRest.verify('1234') - .then(function (data) { - console.log(data); - }); - } else { - console.log('error!') +(async () => { + let response = await BootpayRest.getAccessToken() + if (response.status === 200) { + let result + try { + result = await BootpayRest.verify('1234') + } catch (e) { + return console.log(e.error) + } + console.log(result) } -}); \ No newline at end of file +})() \ No newline at end of file From 20520303f9d01341e36f15f7a465ce78230d6a86 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Mon, 22 Jun 2020 17:16:37 +0900 Subject: [PATCH 026/109] =?UTF-8?q?2.0.0=20=EB=B2=84=EC=A0=84=20=EB=B8=8C?= =?UTF-8?q?=EB=9F=B0=EC=B9=98=20=EB=B3=84=EB=8F=84=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 590 ++++++++++++----------- package.json | 6 +- test/access_token.js | 12 +- test/cancel.js | 21 +- test/certificate.js | 24 +- test/get_user_token.js | 3 +- test/request_payment.js | 43 +- test/subscribe_billing.js | 3 +- test/subscribe_billing_reserve.js | 36 +- test/subscribe_billing_reserve_cancel.js | 44 +- test/verify.js | 24 +- 11 files changed, 419 insertions(+), 387 deletions(-) diff --git a/lib/bootpay.js b/lib/bootpay.js index 4d47c33..1cc3417 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -1,8 +1,7 @@ /** * Created by ehowlsla on 2017. 8. 3.. */ -// npm install restler -var rest = require('restler'); +var request = require('request-promise-native'); module.exports = { BASE_URL: { @@ -22,329 +21,336 @@ module.exports = { this.privateKey = privateKey; this.mode = mode; }, - getAccessToken: function () { - let _this = this; - return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['request', 'token.json']), - { - data: { - application_id: _this.applicationId, - private_key: _this.privateKey + getAccessToken: async function () { + let response + try { + response = await request({ + method: 'POST', + url: this.getUrl(['request', 'token.json']), + body: { + application_id: this.applicationId, + private_key: this.privateKey }, - headers: {'Accept': 'application/json', 'Content-Type': 'application/json'} - } - ).on('complete', function (data, response) { - if (data.status === 200) { - _this.token = data.data.token; - resolve(data); - } else { - reject(data); + json: true } - }); - }); + ) + } catch (e) { + return Promise.reject(e) + } + this.token = response.data.token + return Promise.resolve(response) }, - verify: function (receiptId) { + verify: async function (receiptId) { if (receiptId === undefined) throw new Error('receiptId 값을 입력해주세요.'); if (this.token === undefined || !this.token.length) throw new Error('Access Token을 발급 받은 후 진행해주세요.'); - let _this = this; - return new Promise(function (resolve, reject) { - rest.get( - _this.getUrl(['receipt', receiptId + '.json']), - { - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': _this.token - } + let response = undefined + try { + response = await request({ + method: 'GET', + url: this.getUrl(['receipt', receiptId + '.json']), + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': this.token } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + }) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - submit: function (receiptId) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['submit.json']), + submit: async function (receiptId) { + let response + try { + response = request( { - data: { + method: 'POST', + url: this.getUrl(['submit.json']), + body: { receipt_id: receiptId, }, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', - 'Authorization': _this.token - } - } - ).on('complete', function (data, response) { - resolve(data); - }); - }); - }, - cancel: function (receiptId, price = undefined, name = undefined, reason = undefined) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['cancel.json']), - { - data: { - receipt_id: receiptId, - price: price, - name: name, - reason: reason + 'Authorization': this.token }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': _this.token - } + json: true } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - subscribeBilling: function (billingKey, itemName, price, orderId, items = [], user_info = {}) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['subscribe', 'billing.json']), - { - data: { - billing_key: billingKey, - item_name: itemName, - price: price, - order_id: orderId, - items: items, - username: user_info.username, - phone: user_info.phone, - address: user_info.address - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': _this.token - } - } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + cancel: async function (receiptId, price = undefined, name = undefined, reason = undefined) { + let response + try { + response = await request({ + method: 'POST', + url: this.getUrl(['cancel.json']), + body: { + receipt_id: receiptId, + price: price, + name: name, + reason: reason + }, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': this.token + }, + json: true + }) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - subscribeBillingReserve: function (billingKey, itemName, price, orderId, execute_at, feedback_url, items = []) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['subscribe', 'billing', 'reserve.json']), - { - data: { - billing_key: billingKey, - item_name: itemName, - price: price, - order_id: orderId, - items: items, - scheduler_type: 'oneshot', - execute_at: execute_at, - feedback_url: feedback_url - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': _this.token - } + subscribeBilling: async function (billingKey, itemName, price, orderId, items = [], user_info = {}) { + let response + try { + response = await request({ + method: 'POST', + url: this.getUrl(['subscribe', 'billing.json']), + body: { + billing_key: billingKey, + item_name: itemName, + price: price, + order_id: orderId, + items: items, + username: user_info.username, + phone: user_info.phone, + address: user_info.address + }, + json: true, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': _this.token } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + }) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - getSubscribeBillingKey: function (data) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['request', 'card_rebill.json']), - { - data: { - order_id: data.orderId, - pg: data.pg, - item_name: data.name, - card_no: data.cardNo, - card_pw: data.cardPw, - expire_year: data.expireYear, - expire_month: data.expireMonth, - identify_number: data.identifyNumber, - user_info: data.userInfo, - extra: data.extra - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': _this.token - } + subscribeBillingReserve: async function (billingKey, itemName, price, orderId, execute_at, feedback_url, items = []) { + let response + try { + response = await request({ + method: 'POST', + url: this.getUrl(['subscribe', 'billing', 'reserve.json']), + body: { + billing_key: billingKey, + item_name: itemName, + price: price, + order_id: orderId, + items: items, + scheduler_type: 'oneshot', + execute_at: execute_at, + feedback_url: feedback_url + }, + json: true, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + 'Authorization': this.token } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + }) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - destroySubscribeBillingKey: function (billingKey) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.del( - _this.getUrl(['subscribe', 'billing', billingKey]), - { - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': _this.token - } + getSubscribeBillingKey: async function (data) { + let response + try { + response = await request({ + method: 'POST', + url: this.getUrl(['request', 'card_rebill.json']), + body: { + order_id: data.orderId, + pg: data.pg, + item_name: data.name, + card_no: data.cardNo, + card_pw: data.cardPw, + expire_year: data.expireYear, + expire_month: data.expireMonth, + identify_number: data.identifyNumber, + user_info: data.userInfo, + extra: data.extra + }, + json: true, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': this.token } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + }) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - destroySubscribeBillingReserveCancel: function (billingKey) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.del( - _this.getUrl(['subscribe', 'billing', 'reserve', billingKey]), - { - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': _this.token - } + destroySubscribeBillingKey: async function (billingKey) { + let response + try { + response = await request({ + method: 'DELETE', + url: this.getUrl(['subscribe', 'billing', billingKey]), + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': this.token } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + }) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - certificate: function (receiptId) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.get( - _this.getUrl(['certificate', receiptId]), - { - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': _this.token - } + destroySubscribeBillingReserveCancel: async function (billingKey) { + let response + try { + response = await request({ + method: 'DELETE', + url: this.getUrl(['subscribe', 'billing', 'reserve', billingKey]), + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': this.token } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + }) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - remoteForm: function (remoteForm, smsPayload = {}) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['app', 'rest', 'remote_form.json']), - { - data: { - application_id: _this.applicationId, - remote_form: remoteForm, - sms_payload: smsPayload - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': _this.token - } + certificate: async function (receiptId) { + let response + try { + response = await request({ + method: 'GET', + url: this.getUrl(['certificate', receiptId]), + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': this.token } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + }) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - requestPayment: function (data) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['request', 'payment.json']), - { - data: data, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': _this.token - } + remoteForm: async function (remoteForm, smsPayload = {}) { + let response + try { + response = await request({ + method: 'POST', + url: this.getUrl(['app', 'rest', 'remote_form.json']), + body: { + application_id: _this.applicationId, + remote_form: remoteForm, + sms_payload: smsPayload + }, + json: true, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': this.token } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + }) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - sendSms: function (receiveNumbers, message, sendNumber = undefined, extra = {}) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['push', 'sms.json']), - { - data: { - sp: sendNumber, - rps: receiveNumbers, - msg: message, - m_id: extra.m_id, - o_id: extra.o_id - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': _this.token - } + requestPayment: async function (data) { + let response + try { + response = await request({ + method: 'POST', + url: this.getUrl(['request', 'payment.json']), + body: data, + json: true, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': this.token } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + }) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - sendLms: function (receiveNumbers, message, subject, sendNumber = undefined, extra = {}) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['push', 'lms.json']), - { - data: { - sp: sendNumber, - rps: receiveNumbers, - msg: message, - sj: subject, - m_id: extra.m_id, - o_id: extra.o_id - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': _this.token - } + getUserToken: async function (data) { + let response + try { + response = await request({ + method: 'POST', + url: this.getUrl(['request', 'user', 'token.json']), + body: data, + json: true, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json; charset=utf-8"', + 'Authorization': this.token } - ).on('complete', function (data, response) { - resolve(data); - }); - }); + }) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) }, - getUserToken: function (data) { - let _this = this; - return new Promise(function (resolve, reject) { - rest.post( - _this.getUrl(['request', 'user', 'token.json']), - { - data: data, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': _this.token - } - } - ).on('complete', function (data, response) { - resolve(data); - }); - }); - } + // sendSms: function (receiveNumbers, message, sendNumber = undefined, extra = {}) { + // let _this = this; + // return new Promise(function (resolve, reject) { + // request.post( + // _this.getUrl(['push', 'sms.json']), + // { + // data: { + // sp: sendNumber, + // rps: receiveNumbers, + // msg: message, + // m_id: extra.m_id, + // o_id: extra.o_id + // }, + // headers: { + // 'Accept': 'application/json', + // 'Content-Type': 'application/json; charset=utf-8"', + // 'Authorization': _this.token + // } + // } + // ).on('response', function (data, response) { + // resolve(data); + // }); + // }); + // }, + // sendLms: function (receiveNumbers, message, subject, sendNumber = undefined, extra = {}) { + // let _this = this; + // return new Promise(function (resolve, reject) { + // request.post( + // _this.getUrl(['push', 'lms.json']), + // { + // data: { + // sp: sendNumber, + // rps: receiveNumbers, + // msg: message, + // sj: subject, + // m_id: extra.m_id, + // o_id: extra.o_id + // }, + // headers: { + // 'Accept': 'application/json', + // 'Content-Type': 'application/json; charset=utf-8"', + // 'Authorization': _this.token + // } + // } + // ).on('response', function (data, response) { + // resolve(data); + // }); + // }); + // }, }; \ No newline at end of file diff --git a/package.json b/package.json index 3a43f23..2be67ba 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "bootpay-rest-client", - "version": "1.0.5", + "version": "2.0.0", "description": "Bootpay Rest Client Javasrcipt Library", "main": "lib/bootpay.js", "dependencies": { - "restler": "^3.4.0", - "babel-cli": "^6.26.0" + "request": "^2.88.2", + "request-promise-native": "^1.0.8" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" diff --git a/test/access_token.js b/test/access_token.js index f45a0ea..3287584 100644 --- a/test/access_token.js +++ b/test/access_token.js @@ -2,11 +2,11 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'FQj3jOvQYp053nxzWxHSuw+cq3zUlSWZV2ec/8fkiyA=' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' ); - -BootpayRest.getAccessToken() -.then(function(data) { - console.log(data); -}); \ No newline at end of file +(async () => { + let response = await BootpayRest.getAccessToken(); + console.log(response); +})() diff --git a/test/cancel.js b/test/cancel.js index 80383b3..949feb5 100644 --- a/test/cancel.js +++ b/test/cancel.js @@ -2,12 +2,19 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' ); - -BootpayRest.getAccessToken().then(function (data) { - BootpayRest.cancel('5b0df1b8e13f332c6c83df6a', 1000, '취소함', '취소합니다').then(function (data) { - console.log(data); - }); -}); \ No newline at end of file +(async () => { + let token = await BootpayRest.getAccessToken() + if (token.status === 200) { + let response + try { + response = await BootpayRest.cancel('5b0df1b8e13f332c6c83df6a', 1000, '취소함', '취소합니다') + } catch (e) { + return console.log(e.error) + } + console.log(response) + } +})() \ No newline at end of file diff --git a/test/certificate.js b/test/certificate.js index 6837919..535f0c3 100644 --- a/test/certificate.js +++ b/test/certificate.js @@ -2,17 +2,19 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' ); - -BootpayRest.getAccessToken().then(function (tokenData) { - if (tokenData.status === 200) { - BootpayRest.certificate('1234') - .then(function (data) { - console.log(data); - }); - } else { - console.log('error!') +(async () => { + let token = await BootpayRest.getAccessToken() + if (token.status === 200) { + let response + try { + response = await BootpayRest.certificate('1234') + } catch (e) { + return console.log(e.error) + } + console.log(response) } -}); \ No newline at end of file +})() \ No newline at end of file diff --git a/test/get_user_token.js b/test/get_user_token.js index 276c082..72a7da3 100644 --- a/test/get_user_token.js +++ b/test/get_user_token.js @@ -2,7 +2,8 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' ); BootpayRest.getAccessToken().then(function (tokenData) { diff --git a/test/request_payment.js b/test/request_payment.js index f03ea52..44af4e5 100644 --- a/test/request_payment.js +++ b/test/request_payment.js @@ -2,26 +2,29 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' ); - -BootpayRest.getAccessToken().then(function (tokenData) { - if (tokenData.status === 200) { - BootpayRest.requestPayment({ - pg: 'kcp', - method: 'card', - order_id: (new Date).getTime(), - price: 1000, - name: '테스트 부트페이 상품', - return_url: 'https://dev-api.bootpay.co.kr/callback', - extra: { - expire: 30 - } - }).then(function (data) { - console.log(data); - }); - } else { - console.log('error!') +(async () => { + let token = await BootpayRest.getAccessToken() + if (token.status === 200) { + let response + try { + response = await BootpayRest.requestPayment({ + pg: 'kcp', + method: 'card', + order_id: (new Date).getTime(), + price: 1000, + name: '테스트 부트페이 상품', + return_url: 'https://dev-api.bootpay.co.kr/callback', + extra: { + expire: 30 + } + }) + } catch (e) { + response = e.error + } + console.log(response) } -}); \ No newline at end of file +})() \ No newline at end of file diff --git a/test/subscribe_billing.js b/test/subscribe_billing.js index 05948f3..99be22b 100644 --- a/test/subscribe_billing.js +++ b/test/subscribe_billing.js @@ -2,7 +2,8 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' ); diff --git a/test/subscribe_billing_reserve.js b/test/subscribe_billing_reserve.js index 19091b1..c73b08c 100644 --- a/test/subscribe_billing_reserve.js +++ b/test/subscribe_billing_reserve.js @@ -2,20 +2,26 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' ); - -BootpayRest.getAccessToken() - .then(function (data) { - BootpayRest.subscribeBillingReserve( - '5b025b33e13f33310ce560fb', - '정기결제입니다.', - 1000, - (new Date()).getTime(), - parseInt(new Date().getTime() / 1000) + 3600, // 1시간 뒤 실행 - "https://dev-api.bootpay.co.kr/callback" - ).then(function (data) { - console.log(data); - }); - }); \ No newline at end of file +(async () =>{ + let token = await BootpayRest.getAccessToken() + if(token.status === 200) { + let response + try { + response = await BootpayRest.subscribeBillingReserve( + '5b025b33e13f33310ce560fb', + '정기결제입니다.', + 1000, + (new Date()).getTime(), + parseInt(new Date().getTime() / 1000) + 3600, // 1시간 뒤 실행 + "https://dev-api.bootpay.co.kr/callback" + ) + } catch (e) { + console.log(e.error) + } + console.log(response) + } +})() \ No newline at end of file diff --git a/test/subscribe_billing_reserve_cancel.js b/test/subscribe_billing_reserve_cancel.js index 087a223..09be7f0 100644 --- a/test/subscribe_billing_reserve_cancel.js +++ b/test/subscribe_billing_reserve_cancel.js @@ -2,26 +2,30 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' ); - -BootpayRest.getAccessToken() - .then(function (data) { - BootpayRest.subscribeBillingReserve( - '5b025b33e13f33310ce560fb', - '정기결제입니다.', - 1000, - (new Date()).getTime(), - parseInt(new Date().getTime() / 1000) + 3600, // 1시간 뒤 실행 - "https://dev-api.bootpay.co.kr/callback" - ).then(function (data) { - console.log(data); - // 예약된 빌링키 취소 - BootpayRest.destroySubscribeBillingReserveCancel(data.reserve_id).then( - function(data) { - console.log(data) - } +(async () => { + let token = await BootpayRest.getAccessToken() + if (token.status === 200) { + let response + try { + response = await BootpayRest.subscribeBillingReserve( + '5b025b33e13f33310ce560fb', + '정기결제입니다.', + 1000, + (new Date()).getTime(), + parseInt(new Date().getTime() / 1000) + 3600, // 1시간 뒤 실행 + "https://dev-api.bootpay.co.kr/callback" ) - }); - }); \ No newline at end of file + } catch (e) { + response = e.error + } + console.log(response) + if (response.status === 200) { + let cancelled_response = await BootpayRest.destroySubscribeBillingReserveCancel(response.data.reserve_id) + console.log(cancelled_response) + } + } +})() \ No newline at end of file diff --git a/test/verify.js b/test/verify.js index 9f13e6a..b812335 100644 --- a/test/verify.js +++ b/test/verify.js @@ -2,17 +2,19 @@ var BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' ); - -BootpayRest.getAccessToken().then(function (tokenData) { - if (tokenData.status === 200) { - BootpayRest.verify('1234') - .then(function (data) { - console.log(data); - }); - } else { - console.log('error!') +(async () => { + let response = await BootpayRest.getAccessToken() + if (response.status === 200) { + let result + try { + result = await BootpayRest.verify('1234') + } catch (e) { + return console.log(e.error) + } + console.log(result) } -}); \ No newline at end of file +})() \ No newline at end of file From 348bd8e2af55d9c8088a033e7cbdfe6a16518fb4 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Mon, 22 Jun 2020 17:21:29 +0900 Subject: [PATCH 027/109] 2.0.0 readme add changelog --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1ed00ed..a7fa41f 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,13 @@ +# 2.0.0 Release +### 변경된 점 +* 보안취약점 노출된 Restler -> request-promise-native 로 변경하였습니다. +* ES6 Syntax로 변경되었습니다. +* Error 처리를 유연하게 할 수 있도록 예제가 변경되었습니다. ## PG Analytics - 결제데이터 분석서비스 * 기존 PG 사를 이용 중이신 사업자도 별도의 계약없이 부트페이를 통해 결제 연동과 통계를 무료로 이용하실 수 있습니다. * 한줄의 소스코드로 인사이트를 얻어 매출을 극대화하세요. - - ## 결제 검증 및 취소 - 서버사이드용 * 보안상의 이유로 결제검증과 취소는 서버사이드에서 이루어집니다. * 부트페이 서버와 통신시 Rest용 Application Id, Private Key 값을 보내주셔야 하며, 보내실 서버의 IP는 미리 등록하셔야 합니다. From c799b02df7ee194e0be6ed153dad8eee42c34812 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Mon, 22 Jun 2020 17:21:29 +0900 Subject: [PATCH 028/109] 2.0.0 readme add changelog --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1ed00ed..a7fa41f 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,13 @@ +# 2.0.0 Release +### 변경된 점 +* 보안취약점 노출된 Restler -> request-promise-native 로 변경하였습니다. +* ES6 Syntax로 변경되었습니다. +* Error 처리를 유연하게 할 수 있도록 예제가 변경되었습니다. ## PG Analytics - 결제데이터 분석서비스 * 기존 PG 사를 이용 중이신 사업자도 별도의 계약없이 부트페이를 통해 결제 연동과 통계를 무료로 이용하실 수 있습니다. * 한줄의 소스코드로 인사이트를 얻어 매출을 극대화하세요. - - ## 결제 검증 및 취소 - 서버사이드용 * 보안상의 이유로 결제검증과 취소는 서버사이드에서 이루어집니다. * 부트페이 서버와 통신시 Rest용 Application Id, Private Key 값을 보내주셔야 하며, 보내실 서버의 IP는 미리 등록하셔야 합니다. From df9afeff240519ab5fcd57985cb6fec70f9ed786 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 24 Jun 2020 17:29:12 +0900 Subject: [PATCH 029/109] =?UTF-8?q?=EB=B9=8C=EB=A7=81=ED=82=A4=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/destroy_subscribe_billing_key.js | 20 ++++++++++++++++++++ test/subscribe_billing_reserve_cancel.js | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 test/destroy_subscribe_billing_key.js diff --git a/test/destroy_subscribe_billing_key.js b/test/destroy_subscribe_billing_key.js new file mode 100644 index 0000000..a4791ce --- /dev/null +++ b/test/destroy_subscribe_billing_key.js @@ -0,0 +1,20 @@ +var BootpayRest = require('../lib/bootpay'); + +BootpayRest.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' +); + +(async () => { + let token = await BootpayRest.getAccessToken() + if (token.status === 200) { + let response + try { + response = await BootpayRest.destroySubscribeBillingKey('5ef30dd58a1a350391ecdce3') + } catch (e) { + response = e.error + } + console.log(response) + } +})() \ No newline at end of file diff --git a/test/subscribe_billing_reserve_cancel.js b/test/subscribe_billing_reserve_cancel.js index 09be7f0..524e6a1 100644 --- a/test/subscribe_billing_reserve_cancel.js +++ b/test/subscribe_billing_reserve_cancel.js @@ -12,7 +12,7 @@ BootpayRest.setConfig( let response try { response = await BootpayRest.subscribeBillingReserve( - '5b025b33e13f33310ce560fb', + '5ef30dd58a1a350391ecdce3', '정기결제입니다.', 1000, (new Date()).getTime(), From d0e25e6ebdbbe3b696a4363b7837454013c66240 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 24 Jun 2020 17:29:12 +0900 Subject: [PATCH 030/109] =?UTF-8?q?=EB=B9=8C=EB=A7=81=ED=82=A4=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/destroy_subscribe_billing_key.js | 20 ++++++++++++++++++++ test/subscribe_billing_reserve_cancel.js | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 test/destroy_subscribe_billing_key.js diff --git a/test/destroy_subscribe_billing_key.js b/test/destroy_subscribe_billing_key.js new file mode 100644 index 0000000..a4791ce --- /dev/null +++ b/test/destroy_subscribe_billing_key.js @@ -0,0 +1,20 @@ +var BootpayRest = require('../lib/bootpay'); + +BootpayRest.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' +); + +(async () => { + let token = await BootpayRest.getAccessToken() + if (token.status === 200) { + let response + try { + response = await BootpayRest.destroySubscribeBillingKey('5ef30dd58a1a350391ecdce3') + } catch (e) { + response = e.error + } + console.log(response) + } +})() \ No newline at end of file diff --git a/test/subscribe_billing_reserve_cancel.js b/test/subscribe_billing_reserve_cancel.js index 09be7f0..524e6a1 100644 --- a/test/subscribe_billing_reserve_cancel.js +++ b/test/subscribe_billing_reserve_cancel.js @@ -12,7 +12,7 @@ BootpayRest.setConfig( let response try { response = await BootpayRest.subscribeBillingReserve( - '5b025b33e13f33310ce560fb', + '5ef30dd58a1a350391ecdce3', '정기결제입니다.', 1000, (new Date()).getTime(), From 1468f380676c93457ae1cb9534cf9f51db02d982 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 24 Jun 2020 17:48:05 +0900 Subject: [PATCH 031/109] =?UTF-8?q?subscribe=20=EC=97=90=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=EB=90=9C=5Fthis=20=EB=B2=84=EA=B7=B8=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bootpay.js b/lib/bootpay.js index 1cc3417..2a68111 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -126,7 +126,7 @@ module.exports = { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', - 'Authorization': _this.token + 'Authorization': this.token } }) } catch (e) { @@ -250,7 +250,7 @@ module.exports = { method: 'POST', url: this.getUrl(['app', 'rest', 'remote_form.json']), body: { - application_id: _this.applicationId, + application_id: this.applicationId, remote_form: remoteForm, sms_payload: smsPayload }, From 851b316298ef172fb7c418db98574d57b1cf1b16 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 24 Jun 2020 17:48:05 +0900 Subject: [PATCH 032/109] =?UTF-8?q?subscribe=20=EC=97=90=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=EB=90=9C=5Fthis=20=EB=B2=84=EA=B7=B8=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bootpay.js b/lib/bootpay.js index 1cc3417..2a68111 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -126,7 +126,7 @@ module.exports = { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', - 'Authorization': _this.token + 'Authorization': this.token } }) } catch (e) { @@ -250,7 +250,7 @@ module.exports = { method: 'POST', url: this.getUrl(['app', 'rest', 'remote_form.json']), body: { - application_id: _this.applicationId, + application_id: this.applicationId, remote_form: remoteForm, sms_payload: smsPayload }, From 3343f541da9813e4274c97e61b65092c61c722a5 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 24 Jun 2020 17:48:15 +0900 Subject: [PATCH 033/109] =?UTF-8?q?package=20=EB=B2=84=EC=A0=84=202.0.1=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2be67ba..ed32934 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootpay-rest-client", - "version": "2.0.0", + "version": "2.0.1", "description": "Bootpay Rest Client Javasrcipt Library", "main": "lib/bootpay.js", "dependencies": { From adfbc45ab8d038d64b386601beeec35c4cc58e3d Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 24 Jun 2020 17:48:15 +0900 Subject: [PATCH 034/109] =?UTF-8?q?package=20=EB=B2=84=EC=A0=84=202.0.1=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2be67ba..ed32934 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootpay-rest-client", - "version": "2.0.0", + "version": "2.0.1", "description": "Bootpay Rest Client Javasrcipt Library", "main": "lib/bootpay.js", "dependencies": { From 7793d63124baa29010ba76be2e1ef7b4ec97684e Mon Sep 17 00:00:00 2001 From: Gosomi Date: Tue, 14 Jul 2020 16:57:08 +0900 Subject: [PATCH 035/109] =?UTF-8?q?verify=EC=8B=9C=20json=20=EC=A0=95?= =?UTF-8?q?=EC=9D=98=EB=A5=BC=20=ED=95=98=EC=A7=80=20=EC=95=8A=EC=95=84=20?= =?UTF-8?q?string=EC=9C=BC=EB=A1=9C=20=EB=A6=AC=ED=84=B4=EB=90=98=EB=8A=94?= =?UTF-8?q?=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 3 ++- package.json | 2 +- test/verify.js | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/bootpay.js b/lib/bootpay.js index 2a68111..db385b3 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -52,7 +52,8 @@ module.exports = { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': this.token - } + }, + json: true }) } catch (e) { return Promise.reject(e) diff --git a/package.json b/package.json index ed32934..0fc2306 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootpay-rest-client", - "version": "2.0.1", + "version": "2.0.2", "description": "Bootpay Rest Client Javasrcipt Library", "main": "lib/bootpay.js", "dependencies": { diff --git a/test/verify.js b/test/verify.js index b812335..59feaaa 100644 --- a/test/verify.js +++ b/test/verify.js @@ -1,4 +1,4 @@ -var BootpayRest = require('../lib/bootpay'); +let BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', @@ -11,7 +11,7 @@ BootpayRest.setConfig( if (response.status === 200) { let result try { - result = await BootpayRest.verify('1234') + result = await BootpayRest.verify('5f0d42a7d111902931bea5ff') } catch (e) { return console.log(e.error) } From 545479368d74d54ef3c24b7e12bd78f9f1fce6c0 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Tue, 14 Jul 2020 16:57:08 +0900 Subject: [PATCH 036/109] =?UTF-8?q?verify=EC=8B=9C=20json=20=EC=A0=95?= =?UTF-8?q?=EC=9D=98=EB=A5=BC=20=ED=95=98=EC=A7=80=20=EC=95=8A=EC=95=84=20?= =?UTF-8?q?string=EC=9C=BC=EB=A1=9C=20=EB=A6=AC=ED=84=B4=EB=90=98=EB=8A=94?= =?UTF-8?q?=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 3 ++- package.json | 2 +- test/verify.js | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/bootpay.js b/lib/bootpay.js index 2a68111..db385b3 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -52,7 +52,8 @@ module.exports = { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': this.token - } + }, + json: true }) } catch (e) { return Promise.reject(e) diff --git a/package.json b/package.json index ed32934..0fc2306 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootpay-rest-client", - "version": "2.0.1", + "version": "2.0.2", "description": "Bootpay Rest Client Javasrcipt Library", "main": "lib/bootpay.js", "dependencies": { diff --git a/test/verify.js b/test/verify.js index b812335..59feaaa 100644 --- a/test/verify.js +++ b/test/verify.js @@ -1,4 +1,4 @@ -var BootpayRest = require('../lib/bootpay'); +let BootpayRest = require('../lib/bootpay'); BootpayRest.setConfig( '59bfc738e13f337dbd6ca48a', @@ -11,7 +11,7 @@ BootpayRest.setConfig( if (response.status === 200) { let result try { - result = await BootpayRest.verify('1234') + result = await BootpayRest.verify('5f0d42a7d111902931bea5ff') } catch (e) { return console.log(e.error) } From bc270b046f3387cd7bc6e41e401169737643a600 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Tue, 14 Jul 2020 17:00:04 +0900 Subject: [PATCH 037/109] =?UTF-8?q?json=20object=EB=A1=9C=20=EB=A6=AC?= =?UTF-8?q?=ED=84=B4=EB=90=98=EC=A7=80=20=EC=95=8A=EC=9D=80=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 9 ++++++--- package.json | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/bootpay.js b/lib/bootpay.js index db385b3..2803ebd 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -203,7 +203,8 @@ module.exports = { 'Accept': 'application/json', 'Content-Type': 'application/json; charset=utf-8"', 'Authorization': this.token - } + }, + json: true }) } catch (e) { return Promise.reject(e) @@ -220,7 +221,8 @@ module.exports = { 'Accept': 'application/json', 'Content-Type': 'application/json; charset=utf-8"', 'Authorization': this.token - } + }, + json: true }) } catch (e) { return Promise.reject(e) @@ -237,7 +239,8 @@ module.exports = { 'Accept': 'application/json', 'Content-Type': 'application/json; charset=utf-8"', 'Authorization': this.token - } + }, + json: true }) } catch (e) { return Promise.reject(e) diff --git a/package.json b/package.json index 0fc2306..bcfd3e5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootpay-rest-client", - "version": "2.0.2", + "version": "2.0.3", "description": "Bootpay Rest Client Javasrcipt Library", "main": "lib/bootpay.js", "dependencies": { From e4cb3cb4c11d2f8bd5562abf3f08918448a24c87 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Tue, 14 Jul 2020 17:00:04 +0900 Subject: [PATCH 038/109] =?UTF-8?q?json=20object=EB=A1=9C=20=EB=A6=AC?= =?UTF-8?q?=ED=84=B4=EB=90=98=EC=A7=80=20=EC=95=8A=EC=9D=80=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 9 ++++++--- package.json | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/bootpay.js b/lib/bootpay.js index db385b3..2803ebd 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -203,7 +203,8 @@ module.exports = { 'Accept': 'application/json', 'Content-Type': 'application/json; charset=utf-8"', 'Authorization': this.token - } + }, + json: true }) } catch (e) { return Promise.reject(e) @@ -220,7 +221,8 @@ module.exports = { 'Accept': 'application/json', 'Content-Type': 'application/json; charset=utf-8"', 'Authorization': this.token - } + }, + json: true }) } catch (e) { return Promise.reject(e) @@ -237,7 +239,8 @@ module.exports = { 'Accept': 'application/json', 'Content-Type': 'application/json; charset=utf-8"', 'Authorization': this.token - } + }, + json: true }) } catch (e) { return Promise.reject(e) diff --git a/package.json b/package.json index 0fc2306..bcfd3e5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootpay-rest-client", - "version": "2.0.2", + "version": "2.0.3", "description": "Bootpay Rest Client Javasrcipt Library", "main": "lib/bootpay.js", "dependencies": { From d6af8c9b37a35d71e775fa664969fc364e3ec716 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Fri, 21 Aug 2020 15:29:34 +0900 Subject: [PATCH 039/109] =?UTF-8?q?refund=20params=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/bootpay.js b/lib/bootpay.js index 2803ebd..8111f3e 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -83,7 +83,7 @@ module.exports = { } return Promise.resolve(response) }, - cancel: async function (receiptId, price = undefined, name = undefined, reason = undefined) { + cancel: async function (receiptId, price = undefined, name = undefined, reason = undefined, refund = undefined) { let response try { response = await request({ @@ -93,7 +93,8 @@ module.exports = { receipt_id: receiptId, price: price, name: name, - reason: reason + reason: reason, + refund: refund }, headers: { 'Accept': 'application/json', From 927034a1330c34efe0af402f6ac00ace238f095b Mon Sep 17 00:00:00 2001 From: Gosomi Date: Fri, 21 Aug 2020 15:29:34 +0900 Subject: [PATCH 040/109] =?UTF-8?q?refund=20params=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/bootpay.js b/lib/bootpay.js index 2803ebd..8111f3e 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -83,7 +83,7 @@ module.exports = { } return Promise.resolve(response) }, - cancel: async function (receiptId, price = undefined, name = undefined, reason = undefined) { + cancel: async function (receiptId, price = undefined, name = undefined, reason = undefined, refund = undefined) { let response try { response = await request({ @@ -93,7 +93,8 @@ module.exports = { receipt_id: receiptId, price: price, name: name, - reason: reason + reason: reason, + refund: refund }, headers: { 'Accept': 'application/json', From 66649a0bbb46148003c8425af1de8b628b637b19 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Fri, 21 Aug 2020 15:29:47 +0900 Subject: [PATCH 041/109] =?UTF-8?q?2.0.4=20=EB=B2=84=EC=A0=84=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bcfd3e5..9502f27 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootpay-rest-client", - "version": "2.0.3", + "version": "2.0.4", "description": "Bootpay Rest Client Javasrcipt Library", "main": "lib/bootpay.js", "dependencies": { From 579be50f68c7c31e7f280e7dfa7395bea7afeee1 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Fri, 21 Aug 2020 15:29:47 +0900 Subject: [PATCH 042/109] =?UTF-8?q?2.0.4=20=EB=B2=84=EC=A0=84=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bcfd3e5..9502f27 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootpay-rest-client", - "version": "2.0.3", + "version": "2.0.4", "description": "Bootpay Rest Client Javasrcipt Library", "main": "lib/bootpay.js", "dependencies": { From 45664f90c897fbd7365bc7058e1157cd457754d6 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Mon, 26 Oct 2020 11:51:35 +0900 Subject: [PATCH 043/109] =?UTF-8?q?request.js=20->=20axios=20=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=203.0.0=20beta1=20next=20publish=20=EB=8C=80?= =?UTF-8?q?=EA=B8=B0=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 131 +++++++++++------------ package.json | 5 +- test/cancel.js | 2 +- test/certificate.js | 2 +- test/destroy_subscribe_billing_key.js | 2 +- test/request_payment.js | 2 +- test/request_subscribe_rest.js | 2 +- test/subscribe_billing_reserve.js | 2 +- test/subscribe_billing_reserve_cancel.js | 2 +- 9 files changed, 70 insertions(+), 80 deletions(-) diff --git a/lib/bootpay.js b/lib/bootpay.js index 8111f3e..61cc35b 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -1,7 +1,7 @@ /** * Created by ehowlsla on 2017. 8. 3.. */ -var request = require('request-promise-native'); +var axios = require('axios') module.exports = { BASE_URL: { @@ -24,72 +24,73 @@ module.exports = { getAccessToken: async function () { let response try { - response = await request({ + response = await axios({ method: 'POST', url: this.getUrl(['request', 'token.json']), - body: { + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + }, + data: { application_id: this.applicationId, private_key: this.privateKey - }, - json: true + } } ) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - this.token = response.data.token - return Promise.resolve(response) + this.token = response.data.data.token + return Promise.resolve(response.data) }, verify: async function (receiptId) { if (receiptId === undefined) throw new Error('receiptId 값을 입력해주세요.'); if (this.token === undefined || !this.token.length) throw new Error('Access Token을 발급 받은 후 진행해주세요.'); let response = undefined try { - response = await request({ + response = await axios({ method: 'GET', url: this.getUrl(['receipt', receiptId + '.json']), headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': this.token - }, - json: true + } }) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, submit: async function (receiptId) { let response try { - response = request( + response = axios( { method: 'POST', url: this.getUrl(['submit.json']), - body: { + data: { receipt_id: receiptId, }, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': this.token - }, - json: true + } } ) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, cancel: async function (receiptId, price = undefined, name = undefined, reason = undefined, refund = undefined) { let response try { - response = await request({ + response = await axios({ method: 'POST', url: this.getUrl(['cancel.json']), - body: { + data: { receipt_id: receiptId, price: price, name: name, @@ -100,21 +101,20 @@ module.exports = { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': this.token - }, - json: true + } }) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, subscribeBilling: async function (billingKey, itemName, price, orderId, items = [], user_info = {}) { let response try { - response = await request({ + response = await axios({ method: 'POST', url: this.getUrl(['subscribe', 'billing.json']), - body: { + data: { billing_key: billingKey, item_name: itemName, price: price, @@ -124,7 +124,6 @@ module.exports = { phone: user_info.phone, address: user_info.address }, - json: true, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -132,17 +131,17 @@ module.exports = { } }) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, subscribeBillingReserve: async function (billingKey, itemName, price, orderId, execute_at, feedback_url, items = []) { let response try { - response = await request({ + response = await axios({ method: 'POST', url: this.getUrl(['subscribe', 'billing', 'reserve.json']), - body: { + data: { billing_key: billingKey, item_name: itemName, price: price, @@ -152,7 +151,6 @@ module.exports = { execute_at: execute_at, feedback_url: feedback_url }, - json: true, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -160,17 +158,17 @@ module.exports = { } }) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, getSubscribeBillingKey: async function (data) { let response try { - response = await request({ + response = await axios({ method: 'POST', url: this.getUrl(['request', 'card_rebill.json']), - body: { + data: { order_id: data.orderId, pg: data.pg, item_name: data.name, @@ -182,7 +180,6 @@ module.exports = { user_info: data.userInfo, extra: data.extra }, - json: true, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json; charset=utf-8"', @@ -190,76 +187,72 @@ module.exports = { } }) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, destroySubscribeBillingKey: async function (billingKey) { let response try { - response = await request({ + response = await axios({ method: 'DELETE', url: this.getUrl(['subscribe', 'billing', billingKey]), headers: { 'Accept': 'application/json', 'Content-Type': 'application/json; charset=utf-8"', 'Authorization': this.token - }, - json: true + } }) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, destroySubscribeBillingReserveCancel: async function (billingKey) { let response try { - response = await request({ + response = await axios({ method: 'DELETE', url: this.getUrl(['subscribe', 'billing', 'reserve', billingKey]), headers: { 'Accept': 'application/json', 'Content-Type': 'application/json; charset=utf-8"', 'Authorization': this.token - }, - json: true + } }) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, certificate: async function (receiptId) { let response try { - response = await request({ + response = await axios({ method: 'GET', url: this.getUrl(['certificate', receiptId]), headers: { 'Accept': 'application/json', 'Content-Type': 'application/json; charset=utf-8"', 'Authorization': this.token - }, - json: true + } }) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, remoteForm: async function (remoteForm, smsPayload = {}) { let response try { - response = await request({ + response = await axios({ method: 'POST', url: this.getUrl(['app', 'rest', 'remote_form.json']), - body: { + data: { application_id: this.applicationId, remote_form: remoteForm, sms_payload: smsPayload }, - json: true, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json; charset=utf-8"', @@ -267,18 +260,17 @@ module.exports = { } }) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, requestPayment: async function (data) { let response try { - response = await request({ + response = await axios({ method: 'POST', url: this.getUrl(['request', 'payment.json']), - body: data, - json: true, + data: data, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json; charset=utf-8"', @@ -286,18 +278,17 @@ module.exports = { } }) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, getUserToken: async function (data) { let response try { - response = await request({ + response = await axios({ method: 'POST', url: this.getUrl(['request', 'user', 'token.json']), - body: data, - json: true, + data: data, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json; charset=utf-8"', @@ -305,9 +296,9 @@ module.exports = { } }) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, // sendSms: function (receiveNumbers, message, sendNumber = undefined, extra = {}) { // let _this = this; diff --git a/package.json b/package.json index 9502f27..6323e15 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,10 @@ { "name": "bootpay-rest-client", - "version": "2.0.4", + "version": "3.0.0-beta1@next", "description": "Bootpay Rest Client Javasrcipt Library", "main": "lib/bootpay.js", "dependencies": { - "request": "^2.88.2", - "request-promise-native": "^1.0.8" + "axios": "^0.21.0" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" diff --git a/test/cancel.js b/test/cancel.js index 949feb5..f489507 100644 --- a/test/cancel.js +++ b/test/cancel.js @@ -13,7 +13,7 @@ BootpayRest.setConfig( try { response = await BootpayRest.cancel('5b0df1b8e13f332c6c83df6a', 1000, '취소함', '취소합니다') } catch (e) { - return console.log(e.error) + return console.log(e.data) } console.log(response) } diff --git a/test/certificate.js b/test/certificate.js index 535f0c3..565b5f3 100644 --- a/test/certificate.js +++ b/test/certificate.js @@ -13,7 +13,7 @@ BootpayRest.setConfig( try { response = await BootpayRest.certificate('1234') } catch (e) { - return console.log(e.error) + return console.log(e.data) } console.log(response) } diff --git a/test/destroy_subscribe_billing_key.js b/test/destroy_subscribe_billing_key.js index a4791ce..6f4b849 100644 --- a/test/destroy_subscribe_billing_key.js +++ b/test/destroy_subscribe_billing_key.js @@ -13,7 +13,7 @@ BootpayRest.setConfig( try { response = await BootpayRest.destroySubscribeBillingKey('5ef30dd58a1a350391ecdce3') } catch (e) { - response = e.error + response = e.data } console.log(response) } diff --git a/test/request_payment.js b/test/request_payment.js index 44af4e5..544f854 100644 --- a/test/request_payment.js +++ b/test/request_payment.js @@ -23,7 +23,7 @@ BootpayRest.setConfig( } }) } catch (e) { - response = e.error + response = e.data } console.log(response) } diff --git a/test/request_subscribe_rest.js b/test/request_subscribe_rest.js index 7baeee6..200f7b6 100644 --- a/test/request_subscribe_rest.js +++ b/test/request_subscribe_rest.js @@ -25,7 +25,7 @@ BootpayRest.setConfig( } }) } catch (e) { - return console.log(e.error) + return console.log(e.data) } console.log(response) } diff --git a/test/subscribe_billing_reserve.js b/test/subscribe_billing_reserve.js index c73b08c..3ccf3fc 100644 --- a/test/subscribe_billing_reserve.js +++ b/test/subscribe_billing_reserve.js @@ -20,7 +20,7 @@ BootpayRest.setConfig( "https://dev-api.bootpay.co.kr/callback" ) } catch (e) { - console.log(e.error) + console.log(e.data) } console.log(response) } diff --git a/test/subscribe_billing_reserve_cancel.js b/test/subscribe_billing_reserve_cancel.js index 524e6a1..3d5c0a3 100644 --- a/test/subscribe_billing_reserve_cancel.js +++ b/test/subscribe_billing_reserve_cancel.js @@ -20,7 +20,7 @@ BootpayRest.setConfig( "https://dev-api.bootpay.co.kr/callback" ) } catch (e) { - response = e.error + response = e.data } console.log(response) if (response.status === 200) { From 207a9da69c9848680db47c3a5cf45deb661b1a02 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Mon, 26 Oct 2020 11:51:35 +0900 Subject: [PATCH 044/109] =?UTF-8?q?request.js=20->=20axios=20=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=203.0.0=20beta1=20next=20publish=20=EB=8C=80?= =?UTF-8?q?=EA=B8=B0=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bootpay.js | 131 +++++++++++------------ package.json | 5 +- test/cancel.js | 2 +- test/certificate.js | 2 +- test/destroy_subscribe_billing_key.js | 2 +- test/request_payment.js | 2 +- test/subscribe_billing_reserve.js | 2 +- test/subscribe_billing_reserve_cancel.js | 2 +- 8 files changed, 69 insertions(+), 79 deletions(-) diff --git a/lib/bootpay.js b/lib/bootpay.js index 8111f3e..61cc35b 100644 --- a/lib/bootpay.js +++ b/lib/bootpay.js @@ -1,7 +1,7 @@ /** * Created by ehowlsla on 2017. 8. 3.. */ -var request = require('request-promise-native'); +var axios = require('axios') module.exports = { BASE_URL: { @@ -24,72 +24,73 @@ module.exports = { getAccessToken: async function () { let response try { - response = await request({ + response = await axios({ method: 'POST', url: this.getUrl(['request', 'token.json']), - body: { + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + }, + data: { application_id: this.applicationId, private_key: this.privateKey - }, - json: true + } } ) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - this.token = response.data.token - return Promise.resolve(response) + this.token = response.data.data.token + return Promise.resolve(response.data) }, verify: async function (receiptId) { if (receiptId === undefined) throw new Error('receiptId 값을 입력해주세요.'); if (this.token === undefined || !this.token.length) throw new Error('Access Token을 발급 받은 후 진행해주세요.'); let response = undefined try { - response = await request({ + response = await axios({ method: 'GET', url: this.getUrl(['receipt', receiptId + '.json']), headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': this.token - }, - json: true + } }) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, submit: async function (receiptId) { let response try { - response = request( + response = axios( { method: 'POST', url: this.getUrl(['submit.json']), - body: { + data: { receipt_id: receiptId, }, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': this.token - }, - json: true + } } ) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, cancel: async function (receiptId, price = undefined, name = undefined, reason = undefined, refund = undefined) { let response try { - response = await request({ + response = await axios({ method: 'POST', url: this.getUrl(['cancel.json']), - body: { + data: { receipt_id: receiptId, price: price, name: name, @@ -100,21 +101,20 @@ module.exports = { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': this.token - }, - json: true + } }) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, subscribeBilling: async function (billingKey, itemName, price, orderId, items = [], user_info = {}) { let response try { - response = await request({ + response = await axios({ method: 'POST', url: this.getUrl(['subscribe', 'billing.json']), - body: { + data: { billing_key: billingKey, item_name: itemName, price: price, @@ -124,7 +124,6 @@ module.exports = { phone: user_info.phone, address: user_info.address }, - json: true, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -132,17 +131,17 @@ module.exports = { } }) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, subscribeBillingReserve: async function (billingKey, itemName, price, orderId, execute_at, feedback_url, items = []) { let response try { - response = await request({ + response = await axios({ method: 'POST', url: this.getUrl(['subscribe', 'billing', 'reserve.json']), - body: { + data: { billing_key: billingKey, item_name: itemName, price: price, @@ -152,7 +151,6 @@ module.exports = { execute_at: execute_at, feedback_url: feedback_url }, - json: true, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', @@ -160,17 +158,17 @@ module.exports = { } }) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, getSubscribeBillingKey: async function (data) { let response try { - response = await request({ + response = await axios({ method: 'POST', url: this.getUrl(['request', 'card_rebill.json']), - body: { + data: { order_id: data.orderId, pg: data.pg, item_name: data.name, @@ -182,7 +180,6 @@ module.exports = { user_info: data.userInfo, extra: data.extra }, - json: true, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json; charset=utf-8"', @@ -190,76 +187,72 @@ module.exports = { } }) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, destroySubscribeBillingKey: async function (billingKey) { let response try { - response = await request({ + response = await axios({ method: 'DELETE', url: this.getUrl(['subscribe', 'billing', billingKey]), headers: { 'Accept': 'application/json', 'Content-Type': 'application/json; charset=utf-8"', 'Authorization': this.token - }, - json: true + } }) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, destroySubscribeBillingReserveCancel: async function (billingKey) { let response try { - response = await request({ + response = await axios({ method: 'DELETE', url: this.getUrl(['subscribe', 'billing', 'reserve', billingKey]), headers: { 'Accept': 'application/json', 'Content-Type': 'application/json; charset=utf-8"', 'Authorization': this.token - }, - json: true + } }) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, certificate: async function (receiptId) { let response try { - response = await request({ + response = await axios({ method: 'GET', url: this.getUrl(['certificate', receiptId]), headers: { 'Accept': 'application/json', 'Content-Type': 'application/json; charset=utf-8"', 'Authorization': this.token - }, - json: true + } }) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, remoteForm: async function (remoteForm, smsPayload = {}) { let response try { - response = await request({ + response = await axios({ method: 'POST', url: this.getUrl(['app', 'rest', 'remote_form.json']), - body: { + data: { application_id: this.applicationId, remote_form: remoteForm, sms_payload: smsPayload }, - json: true, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json; charset=utf-8"', @@ -267,18 +260,17 @@ module.exports = { } }) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, requestPayment: async function (data) { let response try { - response = await request({ + response = await axios({ method: 'POST', url: this.getUrl(['request', 'payment.json']), - body: data, - json: true, + data: data, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json; charset=utf-8"', @@ -286,18 +278,17 @@ module.exports = { } }) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, getUserToken: async function (data) { let response try { - response = await request({ + response = await axios({ method: 'POST', url: this.getUrl(['request', 'user', 'token.json']), - body: data, - json: true, + data: data, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json; charset=utf-8"', @@ -305,9 +296,9 @@ module.exports = { } }) } catch (e) { - return Promise.reject(e) + return Promise.reject(e.response) } - return Promise.resolve(response) + return Promise.resolve(response.data) }, // sendSms: function (receiveNumbers, message, sendNumber = undefined, extra = {}) { // let _this = this; diff --git a/package.json b/package.json index 9502f27..6323e15 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,10 @@ { "name": "bootpay-rest-client", - "version": "2.0.4", + "version": "3.0.0-beta1@next", "description": "Bootpay Rest Client Javasrcipt Library", "main": "lib/bootpay.js", "dependencies": { - "request": "^2.88.2", - "request-promise-native": "^1.0.8" + "axios": "^0.21.0" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" diff --git a/test/cancel.js b/test/cancel.js index 949feb5..f489507 100644 --- a/test/cancel.js +++ b/test/cancel.js @@ -13,7 +13,7 @@ BootpayRest.setConfig( try { response = await BootpayRest.cancel('5b0df1b8e13f332c6c83df6a', 1000, '취소함', '취소합니다') } catch (e) { - return console.log(e.error) + return console.log(e.data) } console.log(response) } diff --git a/test/certificate.js b/test/certificate.js index 535f0c3..565b5f3 100644 --- a/test/certificate.js +++ b/test/certificate.js @@ -13,7 +13,7 @@ BootpayRest.setConfig( try { response = await BootpayRest.certificate('1234') } catch (e) { - return console.log(e.error) + return console.log(e.data) } console.log(response) } diff --git a/test/destroy_subscribe_billing_key.js b/test/destroy_subscribe_billing_key.js index a4791ce..6f4b849 100644 --- a/test/destroy_subscribe_billing_key.js +++ b/test/destroy_subscribe_billing_key.js @@ -13,7 +13,7 @@ BootpayRest.setConfig( try { response = await BootpayRest.destroySubscribeBillingKey('5ef30dd58a1a350391ecdce3') } catch (e) { - response = e.error + response = e.data } console.log(response) } diff --git a/test/request_payment.js b/test/request_payment.js index 44af4e5..544f854 100644 --- a/test/request_payment.js +++ b/test/request_payment.js @@ -23,7 +23,7 @@ BootpayRest.setConfig( } }) } catch (e) { - response = e.error + response = e.data } console.log(response) } diff --git a/test/subscribe_billing_reserve.js b/test/subscribe_billing_reserve.js index c73b08c..3ccf3fc 100644 --- a/test/subscribe_billing_reserve.js +++ b/test/subscribe_billing_reserve.js @@ -20,7 +20,7 @@ BootpayRest.setConfig( "https://dev-api.bootpay.co.kr/callback" ) } catch (e) { - console.log(e.error) + console.log(e.data) } console.log(response) } diff --git a/test/subscribe_billing_reserve_cancel.js b/test/subscribe_billing_reserve_cancel.js index 524e6a1..3d5c0a3 100644 --- a/test/subscribe_billing_reserve_cancel.js +++ b/test/subscribe_billing_reserve_cancel.js @@ -20,7 +20,7 @@ BootpayRest.setConfig( "https://dev-api.bootpay.co.kr/callback" ) } catch (e) { - response = e.error + response = e.data } console.log(response) if (response.status === 200) { From 9cb614b52fe0c37f6a0390b8dc86d49e64f1bf58 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Mon, 26 Oct 2020 11:52:58 +0900 Subject: [PATCH 045/109] =?UTF-8?q?readme=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a7fa41f..a2b64d1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ -# 2.0.0 Release -### 변경된 점 +# 3.0.0 ( next ) - Nightly Version + +### 3.0.0 변경된 점 +* request.js -> axios로 변경 되었습니다. + + +### 2.0.0 변경된 점 * 보안취약점 노출된 Restler -> request-promise-native 로 변경하였습니다. * ES6 Syntax로 변경되었습니다. * Error 처리를 유연하게 할 수 있도록 예제가 변경되었습니다. From 740fbcdead4649a08f549526fc4b7e449c0da4f2 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Mon, 26 Oct 2020 11:52:58 +0900 Subject: [PATCH 046/109] =?UTF-8?q?readme=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a7fa41f..a2b64d1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ -# 2.0.0 Release -### 변경된 점 +# 3.0.0 ( next ) - Nightly Version + +### 3.0.0 변경된 점 +* request.js -> axios로 변경 되었습니다. + + +### 2.0.0 변경된 점 * 보안취약점 노출된 Restler -> request-promise-native 로 변경하였습니다. * ES6 Syntax로 변경되었습니다. * Error 처리를 유연하게 할 수 있도록 예제가 변경되었습니다. From 0453268ebc6644bea6a10a2c6874d9e4ae933156 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Mon, 26 Oct 2020 11:54:17 +0900 Subject: [PATCH 047/109] =?UTF-8?q?package.json=20beta1=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EB=AA=85=EC=B9=AD=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6323e15..dbd2fe2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootpay-rest-client", - "version": "3.0.0-beta1@next", + "version": "3.0.0-beta1", "description": "Bootpay Rest Client Javasrcipt Library", "main": "lib/bootpay.js", "dependencies": { From d8ed1f4296c1d21cad5883bd22f935815b63b594 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Mon, 26 Oct 2020 11:54:17 +0900 Subject: [PATCH 048/109] =?UTF-8?q?package.json=20beta1=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EB=AA=85=EC=B9=AD=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6323e15..dbd2fe2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootpay-rest-client", - "version": "3.0.0-beta1@next", + "version": "3.0.0-beta1", "description": "Bootpay Rest Client Javasrcipt Library", "main": "lib/bootpay.js", "dependencies": { From e9e220bc75edc9db4dd90bcb492d9d93daeb0c0b Mon Sep 17 00:00:00 2001 From: Gosomi Date: Tue, 27 Oct 2020 17:23:42 +0900 Subject: [PATCH 049/109] =?UTF-8?q?typescript=20=EB=B2=84=EC=A0=84=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- lib/bootpay.js | 352 ---------------- package.json | 19 +- src/bootpay.ts | 489 +++++++++++++++++++++++ src/lib/bootpay/singleton.ts | 17 + src/lib/bootpay/support.ts | 43 ++ test/access_token.js | 18 +- test/cancel.js | 26 +- test/certificate.js | 20 +- test/destroy_subscribe_billing_key.js | 20 +- test/get_user_token.js | 42 +- test/request_payment.js | 30 +- test/request_subscribe_rest.js | 46 ++- test/subscribe_billing.js | 57 +-- test/subscribe_billing_reserve.js | 44 +- test/subscribe_billing_reserve_cancel.js | 50 +-- test/verify.js | 22 +- tsconfig.json | 26 ++ 18 files changed, 783 insertions(+), 540 deletions(-) delete mode 100644 lib/bootpay.js create mode 100644 src/bootpay.ts create mode 100644 src/lib/bootpay/singleton.ts create mode 100644 src/lib/bootpay/support.ts create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore index ee0b027..4304d78 100644 --- a/.gitignore +++ b/.gitignore @@ -50,4 +50,4 @@ jspm_packages node_modules/* package-lock.json yarn.lock - +dist diff --git a/lib/bootpay.js b/lib/bootpay.js deleted file mode 100644 index 61cc35b..0000000 --- a/lib/bootpay.js +++ /dev/null @@ -1,352 +0,0 @@ -/** - * Created by ehowlsla on 2017. 8. 3.. - */ -var axios = require('axios') - -module.exports = { - BASE_URL: { - development: 'https://dev-api.bootpay.co.kr', - stage: 'https://stage-api.bootpay.co.kr', - production: 'https://api.bootpay.co.kr' - }, - applicationId: undefined, - privateKey: undefined, - mode: 'production', - token: undefined, - getUrl: function (uri = []) { - return [].concat([this.BASE_URL[this.mode]]).concat(uri).join('/'); - }, - setConfig: function (applicationId, privateKey, mode = 'production') { - this.applicationId = applicationId; - this.privateKey = privateKey; - this.mode = mode; - }, - getAccessToken: async function () { - let response - try { - response = await axios({ - method: 'POST', - url: this.getUrl(['request', 'token.json']), - headers: { - 'Content-Type': 'application/json', - 'Accept': 'application/json' - }, - data: { - application_id: this.applicationId, - private_key: this.privateKey - } - } - ) - } catch (e) { - return Promise.reject(e.response) - } - this.token = response.data.data.token - return Promise.resolve(response.data) - }, - verify: async function (receiptId) { - if (receiptId === undefined) throw new Error('receiptId 값을 입력해주세요.'); - if (this.token === undefined || !this.token.length) throw new Error('Access Token을 발급 받은 후 진행해주세요.'); - let response = undefined - try { - response = await axios({ - method: 'GET', - url: this.getUrl(['receipt', receiptId + '.json']), - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': this.token - } - }) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - submit: async function (receiptId) { - let response - try { - response = axios( - { - method: 'POST', - url: this.getUrl(['submit.json']), - data: { - receipt_id: receiptId, - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': this.token - } - } - ) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - cancel: async function (receiptId, price = undefined, name = undefined, reason = undefined, refund = undefined) { - let response - try { - response = await axios({ - method: 'POST', - url: this.getUrl(['cancel.json']), - data: { - receipt_id: receiptId, - price: price, - name: name, - reason: reason, - refund: refund - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': this.token - } - }) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - subscribeBilling: async function (billingKey, itemName, price, orderId, items = [], user_info = {}) { - let response - try { - response = await axios({ - method: 'POST', - url: this.getUrl(['subscribe', 'billing.json']), - data: { - billing_key: billingKey, - item_name: itemName, - price: price, - order_id: orderId, - items: items, - username: user_info.username, - phone: user_info.phone, - address: user_info.address - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': this.token - } - }) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - subscribeBillingReserve: async function (billingKey, itemName, price, orderId, execute_at, feedback_url, items = []) { - let response - try { - response = await axios({ - method: 'POST', - url: this.getUrl(['subscribe', 'billing', 'reserve.json']), - data: { - billing_key: billingKey, - item_name: itemName, - price: price, - order_id: orderId, - items: items, - scheduler_type: 'oneshot', - execute_at: execute_at, - feedback_url: feedback_url - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': this.token - } - }) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - getSubscribeBillingKey: async function (data) { - let response - try { - response = await axios({ - method: 'POST', - url: this.getUrl(['request', 'card_rebill.json']), - data: { - order_id: data.orderId, - pg: data.pg, - item_name: data.name, - card_no: data.cardNo, - card_pw: data.cardPw, - expire_year: data.expireYear, - expire_month: data.expireMonth, - identify_number: data.identifyNumber, - user_info: data.userInfo, - extra: data.extra - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': this.token - } - }) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - destroySubscribeBillingKey: async function (billingKey) { - let response - try { - response = await axios({ - method: 'DELETE', - url: this.getUrl(['subscribe', 'billing', billingKey]), - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': this.token - } - }) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - destroySubscribeBillingReserveCancel: async function (billingKey) { - let response - try { - response = await axios({ - method: 'DELETE', - url: this.getUrl(['subscribe', 'billing', 'reserve', billingKey]), - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': this.token - } - }) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - certificate: async function (receiptId) { - let response - try { - response = await axios({ - method: 'GET', - url: this.getUrl(['certificate', receiptId]), - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': this.token - } - }) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - remoteForm: async function (remoteForm, smsPayload = {}) { - let response - try { - response = await axios({ - method: 'POST', - url: this.getUrl(['app', 'rest', 'remote_form.json']), - data: { - application_id: this.applicationId, - remote_form: remoteForm, - sms_payload: smsPayload - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': this.token - } - }) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - requestPayment: async function (data) { - let response - try { - response = await axios({ - method: 'POST', - url: this.getUrl(['request', 'payment.json']), - data: data, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': this.token - } - }) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - getUserToken: async function (data) { - let response - try { - response = await axios({ - method: 'POST', - url: this.getUrl(['request', 'user', 'token.json']), - data: data, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': this.token - } - }) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - // sendSms: function (receiveNumbers, message, sendNumber = undefined, extra = {}) { - // let _this = this; - // return new Promise(function (resolve, reject) { - // request.post( - // _this.getUrl(['push', 'sms.json']), - // { - // data: { - // sp: sendNumber, - // rps: receiveNumbers, - // msg: message, - // m_id: extra.m_id, - // o_id: extra.o_id - // }, - // headers: { - // 'Accept': 'application/json', - // 'Content-Type': 'application/json; charset=utf-8"', - // 'Authorization': _this.token - // } - // } - // ).on('response', function (data, response) { - // resolve(data); - // }); - // }); - // }, - // sendLms: function (receiveNumbers, message, subject, sendNumber = undefined, extra = {}) { - // let _this = this; - // return new Promise(function (resolve, reject) { - // request.post( - // _this.getUrl(['push', 'lms.json']), - // { - // data: { - // sp: sendNumber, - // rps: receiveNumbers, - // msg: message, - // sj: subject, - // m_id: extra.m_id, - // o_id: extra.o_id - // }, - // headers: { - // 'Accept': 'application/json', - // 'Content-Type': 'application/json; charset=utf-8"', - // 'Authorization': _this.token - // } - // } - // ).on('response', function (data, response) { - // resolve(data); - // }); - // }); - // }, -}; \ No newline at end of file diff --git a/package.json b/package.json index dbd2fe2..48b8a3e 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,20 @@ { - "name": "bootpay-rest-client", - "version": "3.0.0-beta1", - "description": "Bootpay Rest Client Javasrcipt Library", - "main": "lib/bootpay.js", + "name": "@bootpay/server-rest-client", + "version": "1.0.0-beta1", + "description": "Bootpay Server Rest Client Javasrcipt Library", + "main": "dist/bootpay.js", + "types": "dist/bootpay.d.ts", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "build": "tsc --build", + "clear": "tsc --build --clean" + }, "dependencies": { "axios": "^0.21.0" }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "devDependencies": { + "ts-node": "^9.0.0", + "typescript": "^4.0.5" }, "repository": { "type": "git", diff --git a/src/bootpay.ts b/src/bootpay.ts new file mode 100644 index 0000000..2771fef --- /dev/null +++ b/src/bootpay.ts @@ -0,0 +1,489 @@ +import { BootpaySingleton } from "./lib/bootpay/singleton" +import axios, { AxiosInstance, AxiosResponse, AxiosRequestConfig } from "axios" +import { isBlank, isPresent } from "./lib/bootpay/support" + +const API_URL: any = { + development: 'https://dev-api.bootpay.co.kr', + stage: 'https://stage-api.bootpay.co.kr', + production: 'https://api.bootpay.co.kr' +} + +export interface BootpayCommonResponse { + status: Number + code: Number + message?: String + data?: T +} + +export interface BootpayCancelData { + receiptId: string, + price?: number, + name?: string, + reason?: string, + refund?: BootpayRefundData +} + +export interface BootpayRefundData { + account: string + accountholder: string + bankcode: string +} + +export interface BootpaySubscribeBillingData { + orderId: string, + pg: string, + itemName: string, + cardNo: string, + cardPw: string + expireYear: string + expireMonth: string, + identifyNumber: string, + userInfo?: BootpayUserInfoData, + extra?: BootpaySubscribeExtraData +} + +export interface BootpayRequestSubscribeBillingPaymentData { + billingKey: string, + itemName: string, + price: number, + taxFree?: number, // 면세금액 + orderId: string, + quota?: number, // 할부 개월수 + interest?: number, // 무이자 여부 ( 웰컴 페이먼츠만 가능 ) + userInfo?: BootpayUserInfoData, + items?: Array, + feedbackUrl?: string, // 결제 완료 후 피드백 받을 URL + feedbackContentType?: string // Feedback 받을 경우 content-type - json, urlencoded +} + +export interface BootpayReserveSubscribeBillingData { + billingKey: string, + itemName: string, + price: number, + taxFree: number, + orderId: string, + quota?: number, + interest?: number, + schedulerType: string, // 실행 방법 - oneshot + executeAt: number, // 실행시간 + userInfo?: BootpayUserInfoData, + items?: Array, + feedbackUrl: string, + feedbackContentType: string // content-type - json, urlencoded +} + +export interface BootpayRequestPaymentData { + pg?: string, + method?: string, + methods?: Array, + orderId: string, + price: number, + taxFree: number, + itemName: string, + returnUrl?: string, + userInfo?: BootpayUserInfoData, + items?: Array, + extra?: any +} + +export interface BootpayRequestUserTokenData { + userId: string + email?: string + name?: string, + gender?: number // 0 - 여자, 1 - 남자 + birth?: string + phone?: string +} + +export interface BootpayItemData { + unique: string, + qty: number, + itemName: string, + price: number +} + +export interface BootpaySubscribeExtraData { + subscribeTestPayment: number +} + +export interface BootpayUserInfoData { + id: string, + username: string, + email: string, + phone: string, + gender: number, + area: string +} + + +class BootpayRestClient extends BootpaySingleton { + + $http: AxiosInstance + $token?: string + applicationId?: string + privateKey?: string + mode: string + + constructor() { + super() + let _this = this + this.mode = 'production' + this.$token = undefined + this.$http = axios + this.$http.interceptors.response.use((response: AxiosResponse): any => { + if (isPresent(response.request) && isPresent(response.headers)) { + return response.data as BootpayCommonResponse + } else { + return { + code: -100, + status: 500, + message: `오류가 발생했습니다. ${response}`, + data: response + } as BootpayCommonResponse + } + }, function (error) { + if (isPresent(error.response)) { + return Promise.reject(error.response.data) + } else { + return Promise.reject({ + code: -100, + message: `통신오류가 발생하였습니다. ${error.message}`, + status: 500 + }) + } + }) + this.$http.interceptors.request.use((config: AxiosRequestConfig) => { + if (isPresent(_this.$token)) { + config.headers.authorization = _this.$token + } + return config + }, (error) => { + return Promise.reject(error) + }) + this.$http.defaults.headers.common['Content-Type'] = 'application/json' + this.$http.defaults.headers.common['Accept'] = 'application/json' + } + + /** + * rest api configure + * Comment by rumi + * @date: 2020-10-27 + * @param (applicationId, privateKey, mode) + * @returns void + */ + setConfig(applicationId: string, privateKey: string, mode: string = 'production') { + this.applicationId = applicationId + this.privateKey = privateKey + this.mode = isPresent(mode) ? mode : 'production' + if (isBlank(API_URL[this.mode])) { + throw new Error(`환경설정 설정이 잘못되었습니다. 현재 설정된 모드: ${this.mode}, 가능한 모드: development, stage, production`) + } + return + } + + /** + * getting access token + * Comment by rumi + * @date: 2020-10-27 + * @param void + * @returns Promise + */ + async getAccessToken(): Promise { + let response: BootpayCommonResponse + try { + response = await this.$http.post( + this.getApiUrl('request/token'), + { + application_id: this.applicationId, + private_key: this.privateKey + } + ) + } catch (e) { + return Promise.reject(e) + } + this.$token = response.data.token + return Promise.resolve(response) + } + + /** + * receipt verify + * Comment by rumi + * @date: 2020-10-27 + * @param receiptId + * @returns Promise + */ + async verify(receiptId: string): Promise { + let response: BootpayCommonResponse + try { + response = await this.$http.get( + this.getApiUrl(`receipt/${receiptId}`) + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) + } + + /** + * Server Submit method + * Comment by rumi + * @date: 2020-10-27 + * @param receiptId + * @returns Promise + */ + async submit(receiptId: string): Promise { + let response: BootpayCommonResponse + try { + response = await this.$http.post( + this.getApiUrl('submit'), + { receipt_id: receiptId } + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) + } + + /** + * Payment Cancel + * Comment by rumi + * @date: 2020-10-27 + * @param data: BootpayCancelData + * @returns Promise + */ + async cancel(data: BootpayCancelData) { + let response: BootpayCommonResponse + try { + response = await this.$http.post( + this.getApiUrl('cancel'), + { + receipt_id: data.receiptId, + price: data.price, + name: data.name, + reason: data.reason, + refund: data.refund + } + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) + } + + /** + * Request Subscribe Card Billing Key + * Comment by rumi + * @date: 2020-10-27 + * @param data: BootpaySubscribeBillingData + * @returns Promise + */ + async requestSubscribeBillingKey(data: BootpaySubscribeBillingData) { + let response: BootpayCommonResponse + try { + response = await this.$http.post( + this.getApiUrl('request/card_rebill'), + { + order_id: data.orderId, + pg: data.pg, + item_name: data.itemName, + card_no: data.cardNo, + card_pw: data.cardPw, + expire_year: data.expireYear, + expire_month: data.expireMonth, + identify_number: data.identifyNumber, + user_info: data.userInfo, + extra: data.extra + } + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) + } + + /** + * destroy billing key + * Comment by rumi + * @date: 2020-10-27 + * @param billingKey: string + * @returns Promise + */ + async destroySubscribeBillingKey(billingKey: string) { + let response: BootpayCommonResponse + try { + response = await this.$http.delete( + this.getApiUrl(`subscribe/billing/${billingKey}`) + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) + } + + /** + * subscribe payment by billing key + * Comment by rumi + * @date: 2020-10-27 + * @param data: BootpayRequestSubscribeBillingPaymentData + * @returns Promise + */ + async requestSubscribeBillingPayment(data: BootpayRequestSubscribeBillingPaymentData) { + let response: BootpayCommonResponse + try { + response = await this.$http.post( + this.getApiUrl('subscribe/billing'), + { + billing_key: data.billingKey, + order_id: data.orderId, + item_name: data.itemName, + price: data.price, + tax_free: data.taxFree, + interest: data.interest, + quota: data.quota, + items: data.items, + user_info: data.userInfo, + feedback_url: data.feedbackUrl, + feedback_content_type: data.feedbackContentType + } + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) + } + + /** + * reserve payment by billing key + * Comment by rumi + * @date: 2020-10-27 + * @param data: BootpayReserveSubscribeBillingData + * @returns Promise + */ + async reserveSubscribeBilling(data: BootpayReserveSubscribeBillingData) { + let response: BootpayCommonResponse + try { + response = await this.$http.post( + this.getApiUrl('subscribe/billing/reserve'), + { + billing_key: data.billingKey, + order_id: data.orderId, + price: data.price, + tax_free: data.taxFree, + user_info: data.userInfo, + item_info: data.items, + item_name: data.itemName, + feedback_url: data.feedbackUrl, + feedback_content_type: data.feedbackContentType, + scheduler_type: data.schedulerType, + execute_at: data.executeAt + } + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) + } + + /** + * Cancel Reserve Subscribe Billing + * Comment by rumi + * @date: 2020-10-27 + * @param reserveId: string + * @returns Promise + */ + async destroyReserveSubscribeBilling(reserveId: string) { + let response: BootpayCommonResponse + try { + response = await this.$http.delete( + this.getApiUrl(`subscribe/billing/reserve/${reserveId}`) + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) + } + + /** + * Certificate Data + * Comment by rumi + * @date: 2020-10-27 + * @param receiptId: string + * @returns Promise + */ + async certificate(receiptId: string) { + let response: BootpayCommonResponse + try { + response = await this.$http.get( + this.getApiUrl(`certificate/${receiptId}`) + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) + } + + /** + * REST API로 결제 요청을 합니다 + * Comment by rumi + * @date: 2020-10-27 + * @param data: any + * @returns Promise + */ + async requestPayment(data: BootpayRequestPaymentData) { + let response: BootpayCommonResponse + try { + response = await this.$http.post( + this.getApiUrl('request/payment'), + { + pg: data.pg, + method: data.method, + methods: data.methods, + order_id: data.orderId, + price: data.price, + tax_free: data.taxFree, + name: data.itemName, + user_info: data.userInfo, + items: data.items, + return_url: data.returnUrl, + extra: data.extra + } + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) + } + + /** + * get user token + * Comment by rumi + * @date: 2020-10-27 + * @param data: BootpayRequestUserTokenData + * @returns Promise + */ + async requestUserToken(data: BootpayRequestUserTokenData) { + let response: BootpayCommonResponse + try { + response = await this.$http.post( + this.getApiUrl('request/user/token'), + { + user_id: data.userId, + email: data.email, + name: data.name, + gender: data.gender, + birth: data.birth, + phone: data.phone + } + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) + } + + private getApiUrl(uri: string) { + return [API_URL[this.mode], uri].join('/') + } +} + +export const RestClient = BootpayRestClient.currentInstance() \ No newline at end of file diff --git a/src/lib/bootpay/singleton.ts b/src/lib/bootpay/singleton.ts new file mode 100644 index 0000000..eb14325 --- /dev/null +++ b/src/lib/bootpay/singleton.ts @@ -0,0 +1,17 @@ +export class BootpaySingleton { + private static __instance: any + + /** + * Singleton Instance Return + * Comment by rumi + * @date: 2020-10-20 + * @param + * @returns + */ + static currentInstance() { + if (!this.__instance) { + this.__instance = new this() + } + return this.__instance as T + } +} \ No newline at end of file diff --git a/src/lib/bootpay/support.ts b/src/lib/bootpay/support.ts new file mode 100644 index 0000000..84ae5a3 --- /dev/null +++ b/src/lib/bootpay/support.ts @@ -0,0 +1,43 @@ +import { BootpaySingleton } from "./singleton" + +export interface Validate { + isBlank(value: any): Boolean + + isPresent(value: any): Boolean + + presence(value: any, defaultValue: any): any +} + +class ValidateMethod extends BootpaySingleton implements Validate { + isBlank(value: any): Boolean { + let valid: Boolean = false + if (typeof value === 'string') { + valid = value.length === 0 + } else if (Array.isArray(value)) { + valid = value.length === 0 + } else if (typeof value === 'object') { + valid = Object.keys(value).length === 0 + } else { + valid = value === undefined || value === null + } + return valid + } + + isPresent(value: any): Boolean { + return !this.isBlank(value) + } + + presence(value: any, defaultValue: any): any { + if (this.isBlank(value)) { + return defaultValue + } else { + return value + } + } +} + +const ValidClass: ValidateMethod = ValidateMethod.currentInstance() + +export const isPresent = (value: any) => ValidClass.isPresent(value) +export const isBlank = (value: any) => ValidClass.isBlank(value) +export const presence = (value: any, defaultValue: any) => ValidClass.presence(value, defaultValue) \ No newline at end of file diff --git a/test/access_token.js b/test/access_token.js index 3287584..b2ab4b2 100644 --- a/test/access_token.js +++ b/test/access_token.js @@ -1,12 +1,10 @@ -var BootpayRest = require('../lib/bootpay'); - -BootpayRest.setConfig( - '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' -); - (async () => { - let response = await BootpayRest.getAccessToken(); - console.log(response); + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + let response = await RestClient.getAccessToken() + console.log(response) })() diff --git a/test/cancel.js b/test/cancel.js index f489507..a38647d 100644 --- a/test/cancel.js +++ b/test/cancel.js @@ -1,19 +1,23 @@ -var BootpayRest = require('../lib/bootpay'); - -BootpayRest.setConfig( - '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' -); - (async () => { - let token = await BootpayRest.getAccessToken() + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + let token = await RestClient.getAccessToken() if (token.status === 200) { let response try { - response = await BootpayRest.cancel('5b0df1b8e13f332c6c83df6a', 1000, '취소함', '취소합니다') + response = await RestClient.cancel({ + receiptId: '5b0df1b8e13f332c6c83df6a', + price: 1000, + name: '취소자명', + reason: '취소합니다' + }) } catch (e) { - return console.log(e.data) + console.log(e) + return } console.log(response) } diff --git a/test/certificate.js b/test/certificate.js index 565b5f3..8e3dee5 100644 --- a/test/certificate.js +++ b/test/certificate.js @@ -1,19 +1,17 @@ -var BootpayRest = require('../lib/bootpay'); - -BootpayRest.setConfig( - '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' -); - (async () => { - let token = await BootpayRest.getAccessToken() + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + let token = await RestClient.getAccessToken() if (token.status === 200) { let response try { - response = await BootpayRest.certificate('1234') + response = await RestClient.certificate('1234') } catch (e) { - return console.log(e.data) + return console.log(e) } console.log(response) } diff --git a/test/destroy_subscribe_billing_key.js b/test/destroy_subscribe_billing_key.js index 6f4b849..cb4e82d 100644 --- a/test/destroy_subscribe_billing_key.js +++ b/test/destroy_subscribe_billing_key.js @@ -1,19 +1,17 @@ -var BootpayRest = require('../lib/bootpay'); - -BootpayRest.setConfig( - '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' -); - (async () => { - let token = await BootpayRest.getAccessToken() + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + let token = await RestClient.getAccessToken() if (token.status === 200) { let response try { - response = await BootpayRest.destroySubscribeBillingKey('5ef30dd58a1a350391ecdce3') + response = await RestClient.destroySubscribeBillingKey('5f97b8a40f606f03e8ab32a0') } catch (e) { - response = e.data + return console.log(e) } console.log(response) } diff --git a/test/get_user_token.js b/test/get_user_token.js index 72a7da3..12e3371 100644 --- a/test/get_user_token.js +++ b/test/get_user_token.js @@ -1,24 +1,20 @@ -var BootpayRest = require('../lib/bootpay'); - -BootpayRest.setConfig( - '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' -); - -BootpayRest.getAccessToken().then(function (tokenData) { - if (tokenData.status === 200) { - BootpayRest.getUserToken({ - user_id: '[[ user_id ]] ( 필수 )', - email: 'bootpay@bootpay.co.kr', // 필수 - name: '[[ 사용자 명 ]] ( 선택 )', - gender: '[[ 0 - 여자, 1 - 남자 ]] ( 선택 )', - birth: ' [[ 생년월일 ( 6자리) ]] ( 선택 )', - phone: ' [[ 전화번호 ]] ( 페이앱의 경우 필수 )' - }).then(function (data) { - console.log(data); - }); - } else { - console.log('error!') +(async () => { + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + const token = await RestClient.getAccessToken() + if (token.status === 200) { + let result + try { + result = await RestClient.requestUserToken({ + userId: 'gosomi' + }) + } catch (e) { + return console.log(e) + } + console.log(result) } -}); \ No newline at end of file +})() \ No newline at end of file diff --git a/test/request_payment.js b/test/request_payment.js index 544f854..083868e 100644 --- a/test/request_payment.js +++ b/test/request_payment.js @@ -1,30 +1,28 @@ -var BootpayRest = require('../lib/bootpay'); - -BootpayRest.setConfig( - '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' -); - (async () => { - let token = await BootpayRest.getAccessToken() + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + const token = await RestClient.getAccessToken() if (token.status === 200) { - let response + let result try { - response = await BootpayRest.requestPayment({ + result = await RestClient.requestPayment({ pg: 'kcp', method: 'card', - order_id: (new Date).getTime(), + orderId: (new Date).getTime(), price: 1000, - name: '테스트 부트페이 상품', - return_url: 'https://dev-api.bootpay.co.kr/callback', + itemName: '테스트 부트페이 상품', + returnUrl: 'https://dev-api.bootpay.co.kr/callback', extra: { expire: 30 } }) } catch (e) { - response = e.data + return console.log(e) } - console.log(response) + console.log(result) } })() \ No newline at end of file diff --git a/test/request_subscribe_rest.js b/test/request_subscribe_rest.js index 200f7b6..aaac663 100644 --- a/test/request_subscribe_rest.js +++ b/test/request_subscribe_rest.js @@ -1,31 +1,43 @@ -var BootpayRest = require('../lib/bootpay'); - -BootpayRest.setConfig( - '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' -); - (async () => { - let token = await BootpayRest.getAccessToken() + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + let token = await RestClient.getAccessToken() if (token.status === 200) { let response try { - response = await BootpayRest.getSubscribeBillingKey({ + // response = await RestClient.requestSubscribeBillingKey({ + // orderId: (new Date()).getTime(), + // pg: 'nicepay', + // name: '정기결제 30일권', + // cardNo: '[ 카드 번호 ]', + // cardPw: '[ 카드 비밀번호 앞 2자리 ]', + // expireYear: '[ 카드 만료 연도 ]', + // expireMonth: '[ 카드 만료 월 ]', + // identifyNumber: '[ 카드 소유주 생년월일 혹은 법인 번호 ]', + // extra: { + // subscribe_test_payment: 1 // 100원 결제 후 결제가 되면 billing key를 발행, 결제가 실패하면 에러 + // } + // }) + + response = await RestClient.requestSubscribeBillingKey({ orderId: (new Date()).getTime(), pg: 'nicepay', - name: '정기결제 30일권', - cardNo: '[ 카드 번호 ]', - cardPw: '[ 카드 비밀번호 앞 2자리 ]', - expireYear: '[ 카드 만료 연도 ]', - expireMonth: '[ 카드 만료 월 ]', - identifyNumber: '[ 카드 소유주 생년월일 혹은 법인 번호 ]', + itemName: '정기결제 30일권', + cardNo: '9430810003624569', + cardPw: '89', + expireYear: '21', + expireMonth: '09', + identifyNumber: '841025', extra: { subscribe_test_payment: 1 // 100원 결제 후 결제가 되면 billing key를 발행, 결제가 실패하면 에러 } }) } catch (e) { - return console.log(e.data) + return console.log(e) } console.log(response) } diff --git a/test/subscribe_billing.js b/test/subscribe_billing.js index 99be22b..d7295ff 100644 --- a/test/subscribe_billing.js +++ b/test/subscribe_billing.js @@ -1,28 +1,31 @@ -var BootpayRest = require('../lib/bootpay'); - -BootpayRest.setConfig( - '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' -); - - -BootpayRest.getAccessToken() - .then( - // Access Token을 가져왔을 때 처리 - function (data) { - BootpayRest.subscribeBilling('5b025b33e13f33310ce560fb', '정기결제입니다.', 1000, (new Date()).getTime(), [], { - username: '홍길동', - phone: '010-0000-0000', - address: '서울특별시 구로구' - }).then(function (data) { - console.log(data); - }, function (data) { - console.log(data); - }); - }, - // Access Token을 가져오는데 실패한 경우 - function (data) { - console.log(data); +(async () => { + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + let token = await RestClient.getAccessToken() + if (token.status === 200) { + let response + try { + response = await RestClient.requestSubscribeBillingPayment({ + billingKey: '5f97b8a40f606f03e8ab32a0', + itemName: '테스트', + price: 1000, + orderId: (new Date()).getTime(), + userInfo: { + username: 'test', + email: 'test@bootpay.co.kr', + phone: '01000000000', + address: '테스트 지역' + }, + feedbackUrl: 'https://dev-api.bootpay.co.kr/callback', + feedbackContentType: 'json' + }) + } catch (e) { + return console.log(e) } - ); \ No newline at end of file + console.log(response) + } +})() \ No newline at end of file diff --git a/test/subscribe_billing_reserve.js b/test/subscribe_billing_reserve.js index 3ccf3fc..099b1d8 100644 --- a/test/subscribe_billing_reserve.js +++ b/test/subscribe_billing_reserve.js @@ -1,26 +1,30 @@ -var BootpayRest = require('../lib/bootpay'); - -BootpayRest.setConfig( - '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' -); - -(async () =>{ - let token = await BootpayRest.getAccessToken() - if(token.status === 200) { +(async () => { + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + let token = await RestClient.getAccessToken() + if (token.status === 200) { let response try { - response = await BootpayRest.subscribeBillingReserve( - '5b025b33e13f33310ce560fb', - '정기결제입니다.', - 1000, - (new Date()).getTime(), - parseInt(new Date().getTime() / 1000) + 3600, // 1시간 뒤 실행 - "https://dev-api.bootpay.co.kr/callback" - ) + response = await RestClient.reserveSubscribeBilling({ + billingKey: '5f97b8a40f606f03e8ab32a0', + itemName: '테스트', + price: 1000, + orderId: (new Date()).getTime(), + userInfo: { + username: '테스트', + phone: '01000000000' + }, + feedbackUrl: 'https://dev-api.bootpay.co.kr/callback', + feedbackContentType: 'json', + schedulerType: 'oneshot', + executeAt: ((new Date()).getTime() / 1000) + 5 + }) } catch (e) { - console.log(e.data) + return console.log(e) } console.log(response) } diff --git a/test/subscribe_billing_reserve_cancel.js b/test/subscribe_billing_reserve_cancel.js index 3d5c0a3..150338e 100644 --- a/test/subscribe_billing_reserve_cancel.js +++ b/test/subscribe_billing_reserve_cancel.js @@ -1,31 +1,35 @@ -var BootpayRest = require('../lib/bootpay'); - -BootpayRest.setConfig( - '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' -); - (async () => { - let token = await BootpayRest.getAccessToken() + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + let token = await RestClient.getAccessToken() if (token.status === 200) { let response try { - response = await BootpayRest.subscribeBillingReserve( - '5ef30dd58a1a350391ecdce3', - '정기결제입니다.', - 1000, - (new Date()).getTime(), - parseInt(new Date().getTime() / 1000) + 3600, // 1시간 뒤 실행 - "https://dev-api.bootpay.co.kr/callback" - ) + response = await RestClient.reserveSubscribeBilling({ + billingKey: '5f97b8a40f606f03e8ab32a0', + itemName: '테스트', + price: 1000, + orderId: (new Date()).getTime(), + userInfo: { + username: '테스트', + phone: '01000000000' + }, + feedbackUrl: 'https://dev-api.bootpay.co.kr/callback', + feedbackContentType: 'json', + schedulerType: 'oneshot', + executeAt: ((new Date()).getTime() / 1000) + 60 + }) + if (response.status === 200) { + response = await RestClient.destroyReserveSubscribeBilling(response.data.reserve_id) + console.log(response) + } } catch (e) { - response = e.data - } - console.log(response) - if (response.status === 200) { - let cancelled_response = await BootpayRest.destroySubscribeBillingReserveCancel(response.data.reserve_id) - console.log(cancelled_response) + return console.log(e) } + // console.log(response) } })() \ No newline at end of file diff --git a/test/verify.js b/test/verify.js index 59feaaa..3946af6 100644 --- a/test/verify.js +++ b/test/verify.js @@ -1,19 +1,17 @@ -let BootpayRest = require('../lib/bootpay'); - -BootpayRest.setConfig( - '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' -); - (async () => { - let response = await BootpayRest.getAccessToken() - if (response.status === 200) { + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + const token = await RestClient.getAccessToken() + if (token.status === 200) { let result try { - result = await BootpayRest.verify('5f0d42a7d111902931bea5ff') + result = await RestClient.verify('5f0d42a7d111902931bea5ff') } catch (e) { - return console.log(e.error) + return console.log(e) } console.log(result) } diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..bf25cbc --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": [ + "es6" + ], + "module": "commonjs", + "moduleResolution": "node", + "declaration": true, + "outDir": "./dist", + "strict": true, + "baseUrl": "./src", + "paths": { + "*": [ + "../node_modules/*", + "./*" + ] + } + }, + "exclude": [ + "**/*.spec.ts", + "node_modules", + "dist" + ], + "compileOnSave": false +} \ No newline at end of file From 6483f0ee8fbe6b7a20d1e62a93401e96d2dcc771 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Tue, 27 Oct 2020 17:23:42 +0900 Subject: [PATCH 050/109] =?UTF-8?q?typescript=20=EB=B2=84=EC=A0=84=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- lib/bootpay.js | 352 ---------------- package.json | 19 +- src/bootpay.ts | 489 +++++++++++++++++++++++ src/lib/bootpay/singleton.ts | 17 + src/lib/bootpay/support.ts | 43 ++ test/access_token.js | 18 +- test/cancel.js | 26 +- test/certificate.js | 20 +- test/destroy_subscribe_billing_key.js | 20 +- test/get_user_token.js | 42 +- test/request_payment.js | 30 +- test/subscribe_billing.js | 57 +-- test/subscribe_billing_reserve.js | 44 +- test/subscribe_billing_reserve_cancel.js | 50 +-- test/verify.js | 22 +- tsconfig.json | 26 ++ 17 files changed, 754 insertions(+), 523 deletions(-) delete mode 100644 lib/bootpay.js create mode 100644 src/bootpay.ts create mode 100644 src/lib/bootpay/singleton.ts create mode 100644 src/lib/bootpay/support.ts create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore index ee0b027..4304d78 100644 --- a/.gitignore +++ b/.gitignore @@ -50,4 +50,4 @@ jspm_packages node_modules/* package-lock.json yarn.lock - +dist diff --git a/lib/bootpay.js b/lib/bootpay.js deleted file mode 100644 index 61cc35b..0000000 --- a/lib/bootpay.js +++ /dev/null @@ -1,352 +0,0 @@ -/** - * Created by ehowlsla on 2017. 8. 3.. - */ -var axios = require('axios') - -module.exports = { - BASE_URL: { - development: 'https://dev-api.bootpay.co.kr', - stage: 'https://stage-api.bootpay.co.kr', - production: 'https://api.bootpay.co.kr' - }, - applicationId: undefined, - privateKey: undefined, - mode: 'production', - token: undefined, - getUrl: function (uri = []) { - return [].concat([this.BASE_URL[this.mode]]).concat(uri).join('/'); - }, - setConfig: function (applicationId, privateKey, mode = 'production') { - this.applicationId = applicationId; - this.privateKey = privateKey; - this.mode = mode; - }, - getAccessToken: async function () { - let response - try { - response = await axios({ - method: 'POST', - url: this.getUrl(['request', 'token.json']), - headers: { - 'Content-Type': 'application/json', - 'Accept': 'application/json' - }, - data: { - application_id: this.applicationId, - private_key: this.privateKey - } - } - ) - } catch (e) { - return Promise.reject(e.response) - } - this.token = response.data.data.token - return Promise.resolve(response.data) - }, - verify: async function (receiptId) { - if (receiptId === undefined) throw new Error('receiptId 값을 입력해주세요.'); - if (this.token === undefined || !this.token.length) throw new Error('Access Token을 발급 받은 후 진행해주세요.'); - let response = undefined - try { - response = await axios({ - method: 'GET', - url: this.getUrl(['receipt', receiptId + '.json']), - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': this.token - } - }) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - submit: async function (receiptId) { - let response - try { - response = axios( - { - method: 'POST', - url: this.getUrl(['submit.json']), - data: { - receipt_id: receiptId, - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': this.token - } - } - ) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - cancel: async function (receiptId, price = undefined, name = undefined, reason = undefined, refund = undefined) { - let response - try { - response = await axios({ - method: 'POST', - url: this.getUrl(['cancel.json']), - data: { - receipt_id: receiptId, - price: price, - name: name, - reason: reason, - refund: refund - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': this.token - } - }) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - subscribeBilling: async function (billingKey, itemName, price, orderId, items = [], user_info = {}) { - let response - try { - response = await axios({ - method: 'POST', - url: this.getUrl(['subscribe', 'billing.json']), - data: { - billing_key: billingKey, - item_name: itemName, - price: price, - order_id: orderId, - items: items, - username: user_info.username, - phone: user_info.phone, - address: user_info.address - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': this.token - } - }) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - subscribeBillingReserve: async function (billingKey, itemName, price, orderId, execute_at, feedback_url, items = []) { - let response - try { - response = await axios({ - method: 'POST', - url: this.getUrl(['subscribe', 'billing', 'reserve.json']), - data: { - billing_key: billingKey, - item_name: itemName, - price: price, - order_id: orderId, - items: items, - scheduler_type: 'oneshot', - execute_at: execute_at, - feedback_url: feedback_url - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'Authorization': this.token - } - }) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - getSubscribeBillingKey: async function (data) { - let response - try { - response = await axios({ - method: 'POST', - url: this.getUrl(['request', 'card_rebill.json']), - data: { - order_id: data.orderId, - pg: data.pg, - item_name: data.name, - card_no: data.cardNo, - card_pw: data.cardPw, - expire_year: data.expireYear, - expire_month: data.expireMonth, - identify_number: data.identifyNumber, - user_info: data.userInfo, - extra: data.extra - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': this.token - } - }) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - destroySubscribeBillingKey: async function (billingKey) { - let response - try { - response = await axios({ - method: 'DELETE', - url: this.getUrl(['subscribe', 'billing', billingKey]), - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': this.token - } - }) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - destroySubscribeBillingReserveCancel: async function (billingKey) { - let response - try { - response = await axios({ - method: 'DELETE', - url: this.getUrl(['subscribe', 'billing', 'reserve', billingKey]), - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': this.token - } - }) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - certificate: async function (receiptId) { - let response - try { - response = await axios({ - method: 'GET', - url: this.getUrl(['certificate', receiptId]), - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': this.token - } - }) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - remoteForm: async function (remoteForm, smsPayload = {}) { - let response - try { - response = await axios({ - method: 'POST', - url: this.getUrl(['app', 'rest', 'remote_form.json']), - data: { - application_id: this.applicationId, - remote_form: remoteForm, - sms_payload: smsPayload - }, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': this.token - } - }) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - requestPayment: async function (data) { - let response - try { - response = await axios({ - method: 'POST', - url: this.getUrl(['request', 'payment.json']), - data: data, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': this.token - } - }) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - getUserToken: async function (data) { - let response - try { - response = await axios({ - method: 'POST', - url: this.getUrl(['request', 'user', 'token.json']), - data: data, - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json; charset=utf-8"', - 'Authorization': this.token - } - }) - } catch (e) { - return Promise.reject(e.response) - } - return Promise.resolve(response.data) - }, - // sendSms: function (receiveNumbers, message, sendNumber = undefined, extra = {}) { - // let _this = this; - // return new Promise(function (resolve, reject) { - // request.post( - // _this.getUrl(['push', 'sms.json']), - // { - // data: { - // sp: sendNumber, - // rps: receiveNumbers, - // msg: message, - // m_id: extra.m_id, - // o_id: extra.o_id - // }, - // headers: { - // 'Accept': 'application/json', - // 'Content-Type': 'application/json; charset=utf-8"', - // 'Authorization': _this.token - // } - // } - // ).on('response', function (data, response) { - // resolve(data); - // }); - // }); - // }, - // sendLms: function (receiveNumbers, message, subject, sendNumber = undefined, extra = {}) { - // let _this = this; - // return new Promise(function (resolve, reject) { - // request.post( - // _this.getUrl(['push', 'lms.json']), - // { - // data: { - // sp: sendNumber, - // rps: receiveNumbers, - // msg: message, - // sj: subject, - // m_id: extra.m_id, - // o_id: extra.o_id - // }, - // headers: { - // 'Accept': 'application/json', - // 'Content-Type': 'application/json; charset=utf-8"', - // 'Authorization': _this.token - // } - // } - // ).on('response', function (data, response) { - // resolve(data); - // }); - // }); - // }, -}; \ No newline at end of file diff --git a/package.json b/package.json index dbd2fe2..48b8a3e 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,20 @@ { - "name": "bootpay-rest-client", - "version": "3.0.0-beta1", - "description": "Bootpay Rest Client Javasrcipt Library", - "main": "lib/bootpay.js", + "name": "@bootpay/server-rest-client", + "version": "1.0.0-beta1", + "description": "Bootpay Server Rest Client Javasrcipt Library", + "main": "dist/bootpay.js", + "types": "dist/bootpay.d.ts", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "build": "tsc --build", + "clear": "tsc --build --clean" + }, "dependencies": { "axios": "^0.21.0" }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "devDependencies": { + "ts-node": "^9.0.0", + "typescript": "^4.0.5" }, "repository": { "type": "git", diff --git a/src/bootpay.ts b/src/bootpay.ts new file mode 100644 index 0000000..2771fef --- /dev/null +++ b/src/bootpay.ts @@ -0,0 +1,489 @@ +import { BootpaySingleton } from "./lib/bootpay/singleton" +import axios, { AxiosInstance, AxiosResponse, AxiosRequestConfig } from "axios" +import { isBlank, isPresent } from "./lib/bootpay/support" + +const API_URL: any = { + development: 'https://dev-api.bootpay.co.kr', + stage: 'https://stage-api.bootpay.co.kr', + production: 'https://api.bootpay.co.kr' +} + +export interface BootpayCommonResponse { + status: Number + code: Number + message?: String + data?: T +} + +export interface BootpayCancelData { + receiptId: string, + price?: number, + name?: string, + reason?: string, + refund?: BootpayRefundData +} + +export interface BootpayRefundData { + account: string + accountholder: string + bankcode: string +} + +export interface BootpaySubscribeBillingData { + orderId: string, + pg: string, + itemName: string, + cardNo: string, + cardPw: string + expireYear: string + expireMonth: string, + identifyNumber: string, + userInfo?: BootpayUserInfoData, + extra?: BootpaySubscribeExtraData +} + +export interface BootpayRequestSubscribeBillingPaymentData { + billingKey: string, + itemName: string, + price: number, + taxFree?: number, // 면세금액 + orderId: string, + quota?: number, // 할부 개월수 + interest?: number, // 무이자 여부 ( 웰컴 페이먼츠만 가능 ) + userInfo?: BootpayUserInfoData, + items?: Array, + feedbackUrl?: string, // 결제 완료 후 피드백 받을 URL + feedbackContentType?: string // Feedback 받을 경우 content-type - json, urlencoded +} + +export interface BootpayReserveSubscribeBillingData { + billingKey: string, + itemName: string, + price: number, + taxFree: number, + orderId: string, + quota?: number, + interest?: number, + schedulerType: string, // 실행 방법 - oneshot + executeAt: number, // 실행시간 + userInfo?: BootpayUserInfoData, + items?: Array, + feedbackUrl: string, + feedbackContentType: string // content-type - json, urlencoded +} + +export interface BootpayRequestPaymentData { + pg?: string, + method?: string, + methods?: Array, + orderId: string, + price: number, + taxFree: number, + itemName: string, + returnUrl?: string, + userInfo?: BootpayUserInfoData, + items?: Array, + extra?: any +} + +export interface BootpayRequestUserTokenData { + userId: string + email?: string + name?: string, + gender?: number // 0 - 여자, 1 - 남자 + birth?: string + phone?: string +} + +export interface BootpayItemData { + unique: string, + qty: number, + itemName: string, + price: number +} + +export interface BootpaySubscribeExtraData { + subscribeTestPayment: number +} + +export interface BootpayUserInfoData { + id: string, + username: string, + email: string, + phone: string, + gender: number, + area: string +} + + +class BootpayRestClient extends BootpaySingleton { + + $http: AxiosInstance + $token?: string + applicationId?: string + privateKey?: string + mode: string + + constructor() { + super() + let _this = this + this.mode = 'production' + this.$token = undefined + this.$http = axios + this.$http.interceptors.response.use((response: AxiosResponse): any => { + if (isPresent(response.request) && isPresent(response.headers)) { + return response.data as BootpayCommonResponse + } else { + return { + code: -100, + status: 500, + message: `오류가 발생했습니다. ${response}`, + data: response + } as BootpayCommonResponse + } + }, function (error) { + if (isPresent(error.response)) { + return Promise.reject(error.response.data) + } else { + return Promise.reject({ + code: -100, + message: `통신오류가 발생하였습니다. ${error.message}`, + status: 500 + }) + } + }) + this.$http.interceptors.request.use((config: AxiosRequestConfig) => { + if (isPresent(_this.$token)) { + config.headers.authorization = _this.$token + } + return config + }, (error) => { + return Promise.reject(error) + }) + this.$http.defaults.headers.common['Content-Type'] = 'application/json' + this.$http.defaults.headers.common['Accept'] = 'application/json' + } + + /** + * rest api configure + * Comment by rumi + * @date: 2020-10-27 + * @param (applicationId, privateKey, mode) + * @returns void + */ + setConfig(applicationId: string, privateKey: string, mode: string = 'production') { + this.applicationId = applicationId + this.privateKey = privateKey + this.mode = isPresent(mode) ? mode : 'production' + if (isBlank(API_URL[this.mode])) { + throw new Error(`환경설정 설정이 잘못되었습니다. 현재 설정된 모드: ${this.mode}, 가능한 모드: development, stage, production`) + } + return + } + + /** + * getting access token + * Comment by rumi + * @date: 2020-10-27 + * @param void + * @returns Promise + */ + async getAccessToken(): Promise { + let response: BootpayCommonResponse + try { + response = await this.$http.post( + this.getApiUrl('request/token'), + { + application_id: this.applicationId, + private_key: this.privateKey + } + ) + } catch (e) { + return Promise.reject(e) + } + this.$token = response.data.token + return Promise.resolve(response) + } + + /** + * receipt verify + * Comment by rumi + * @date: 2020-10-27 + * @param receiptId + * @returns Promise + */ + async verify(receiptId: string): Promise { + let response: BootpayCommonResponse + try { + response = await this.$http.get( + this.getApiUrl(`receipt/${receiptId}`) + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) + } + + /** + * Server Submit method + * Comment by rumi + * @date: 2020-10-27 + * @param receiptId + * @returns Promise + */ + async submit(receiptId: string): Promise { + let response: BootpayCommonResponse + try { + response = await this.$http.post( + this.getApiUrl('submit'), + { receipt_id: receiptId } + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) + } + + /** + * Payment Cancel + * Comment by rumi + * @date: 2020-10-27 + * @param data: BootpayCancelData + * @returns Promise + */ + async cancel(data: BootpayCancelData) { + let response: BootpayCommonResponse + try { + response = await this.$http.post( + this.getApiUrl('cancel'), + { + receipt_id: data.receiptId, + price: data.price, + name: data.name, + reason: data.reason, + refund: data.refund + } + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) + } + + /** + * Request Subscribe Card Billing Key + * Comment by rumi + * @date: 2020-10-27 + * @param data: BootpaySubscribeBillingData + * @returns Promise + */ + async requestSubscribeBillingKey(data: BootpaySubscribeBillingData) { + let response: BootpayCommonResponse + try { + response = await this.$http.post( + this.getApiUrl('request/card_rebill'), + { + order_id: data.orderId, + pg: data.pg, + item_name: data.itemName, + card_no: data.cardNo, + card_pw: data.cardPw, + expire_year: data.expireYear, + expire_month: data.expireMonth, + identify_number: data.identifyNumber, + user_info: data.userInfo, + extra: data.extra + } + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) + } + + /** + * destroy billing key + * Comment by rumi + * @date: 2020-10-27 + * @param billingKey: string + * @returns Promise + */ + async destroySubscribeBillingKey(billingKey: string) { + let response: BootpayCommonResponse + try { + response = await this.$http.delete( + this.getApiUrl(`subscribe/billing/${billingKey}`) + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) + } + + /** + * subscribe payment by billing key + * Comment by rumi + * @date: 2020-10-27 + * @param data: BootpayRequestSubscribeBillingPaymentData + * @returns Promise + */ + async requestSubscribeBillingPayment(data: BootpayRequestSubscribeBillingPaymentData) { + let response: BootpayCommonResponse + try { + response = await this.$http.post( + this.getApiUrl('subscribe/billing'), + { + billing_key: data.billingKey, + order_id: data.orderId, + item_name: data.itemName, + price: data.price, + tax_free: data.taxFree, + interest: data.interest, + quota: data.quota, + items: data.items, + user_info: data.userInfo, + feedback_url: data.feedbackUrl, + feedback_content_type: data.feedbackContentType + } + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) + } + + /** + * reserve payment by billing key + * Comment by rumi + * @date: 2020-10-27 + * @param data: BootpayReserveSubscribeBillingData + * @returns Promise + */ + async reserveSubscribeBilling(data: BootpayReserveSubscribeBillingData) { + let response: BootpayCommonResponse + try { + response = await this.$http.post( + this.getApiUrl('subscribe/billing/reserve'), + { + billing_key: data.billingKey, + order_id: data.orderId, + price: data.price, + tax_free: data.taxFree, + user_info: data.userInfo, + item_info: data.items, + item_name: data.itemName, + feedback_url: data.feedbackUrl, + feedback_content_type: data.feedbackContentType, + scheduler_type: data.schedulerType, + execute_at: data.executeAt + } + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) + } + + /** + * Cancel Reserve Subscribe Billing + * Comment by rumi + * @date: 2020-10-27 + * @param reserveId: string + * @returns Promise + */ + async destroyReserveSubscribeBilling(reserveId: string) { + let response: BootpayCommonResponse + try { + response = await this.$http.delete( + this.getApiUrl(`subscribe/billing/reserve/${reserveId}`) + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) + } + + /** + * Certificate Data + * Comment by rumi + * @date: 2020-10-27 + * @param receiptId: string + * @returns Promise + */ + async certificate(receiptId: string) { + let response: BootpayCommonResponse + try { + response = await this.$http.get( + this.getApiUrl(`certificate/${receiptId}`) + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) + } + + /** + * REST API로 결제 요청을 합니다 + * Comment by rumi + * @date: 2020-10-27 + * @param data: any + * @returns Promise + */ + async requestPayment(data: BootpayRequestPaymentData) { + let response: BootpayCommonResponse + try { + response = await this.$http.post( + this.getApiUrl('request/payment'), + { + pg: data.pg, + method: data.method, + methods: data.methods, + order_id: data.orderId, + price: data.price, + tax_free: data.taxFree, + name: data.itemName, + user_info: data.userInfo, + items: data.items, + return_url: data.returnUrl, + extra: data.extra + } + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) + } + + /** + * get user token + * Comment by rumi + * @date: 2020-10-27 + * @param data: BootpayRequestUserTokenData + * @returns Promise + */ + async requestUserToken(data: BootpayRequestUserTokenData) { + let response: BootpayCommonResponse + try { + response = await this.$http.post( + this.getApiUrl('request/user/token'), + { + user_id: data.userId, + email: data.email, + name: data.name, + gender: data.gender, + birth: data.birth, + phone: data.phone + } + ) + } catch (e) { + return Promise.reject(e) + } + return Promise.resolve(response) + } + + private getApiUrl(uri: string) { + return [API_URL[this.mode], uri].join('/') + } +} + +export const RestClient = BootpayRestClient.currentInstance() \ No newline at end of file diff --git a/src/lib/bootpay/singleton.ts b/src/lib/bootpay/singleton.ts new file mode 100644 index 0000000..eb14325 --- /dev/null +++ b/src/lib/bootpay/singleton.ts @@ -0,0 +1,17 @@ +export class BootpaySingleton { + private static __instance: any + + /** + * Singleton Instance Return + * Comment by rumi + * @date: 2020-10-20 + * @param + * @returns + */ + static currentInstance() { + if (!this.__instance) { + this.__instance = new this() + } + return this.__instance as T + } +} \ No newline at end of file diff --git a/src/lib/bootpay/support.ts b/src/lib/bootpay/support.ts new file mode 100644 index 0000000..84ae5a3 --- /dev/null +++ b/src/lib/bootpay/support.ts @@ -0,0 +1,43 @@ +import { BootpaySingleton } from "./singleton" + +export interface Validate { + isBlank(value: any): Boolean + + isPresent(value: any): Boolean + + presence(value: any, defaultValue: any): any +} + +class ValidateMethod extends BootpaySingleton implements Validate { + isBlank(value: any): Boolean { + let valid: Boolean = false + if (typeof value === 'string') { + valid = value.length === 0 + } else if (Array.isArray(value)) { + valid = value.length === 0 + } else if (typeof value === 'object') { + valid = Object.keys(value).length === 0 + } else { + valid = value === undefined || value === null + } + return valid + } + + isPresent(value: any): Boolean { + return !this.isBlank(value) + } + + presence(value: any, defaultValue: any): any { + if (this.isBlank(value)) { + return defaultValue + } else { + return value + } + } +} + +const ValidClass: ValidateMethod = ValidateMethod.currentInstance() + +export const isPresent = (value: any) => ValidClass.isPresent(value) +export const isBlank = (value: any) => ValidClass.isBlank(value) +export const presence = (value: any, defaultValue: any) => ValidClass.presence(value, defaultValue) \ No newline at end of file diff --git a/test/access_token.js b/test/access_token.js index 3287584..b2ab4b2 100644 --- a/test/access_token.js +++ b/test/access_token.js @@ -1,12 +1,10 @@ -var BootpayRest = require('../lib/bootpay'); - -BootpayRest.setConfig( - '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' -); - (async () => { - let response = await BootpayRest.getAccessToken(); - console.log(response); + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + let response = await RestClient.getAccessToken() + console.log(response) })() diff --git a/test/cancel.js b/test/cancel.js index f489507..a38647d 100644 --- a/test/cancel.js +++ b/test/cancel.js @@ -1,19 +1,23 @@ -var BootpayRest = require('../lib/bootpay'); - -BootpayRest.setConfig( - '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' -); - (async () => { - let token = await BootpayRest.getAccessToken() + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + let token = await RestClient.getAccessToken() if (token.status === 200) { let response try { - response = await BootpayRest.cancel('5b0df1b8e13f332c6c83df6a', 1000, '취소함', '취소합니다') + response = await RestClient.cancel({ + receiptId: '5b0df1b8e13f332c6c83df6a', + price: 1000, + name: '취소자명', + reason: '취소합니다' + }) } catch (e) { - return console.log(e.data) + console.log(e) + return } console.log(response) } diff --git a/test/certificate.js b/test/certificate.js index 565b5f3..8e3dee5 100644 --- a/test/certificate.js +++ b/test/certificate.js @@ -1,19 +1,17 @@ -var BootpayRest = require('../lib/bootpay'); - -BootpayRest.setConfig( - '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' -); - (async () => { - let token = await BootpayRest.getAccessToken() + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + let token = await RestClient.getAccessToken() if (token.status === 200) { let response try { - response = await BootpayRest.certificate('1234') + response = await RestClient.certificate('1234') } catch (e) { - return console.log(e.data) + return console.log(e) } console.log(response) } diff --git a/test/destroy_subscribe_billing_key.js b/test/destroy_subscribe_billing_key.js index 6f4b849..cb4e82d 100644 --- a/test/destroy_subscribe_billing_key.js +++ b/test/destroy_subscribe_billing_key.js @@ -1,19 +1,17 @@ -var BootpayRest = require('../lib/bootpay'); - -BootpayRest.setConfig( - '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' -); - (async () => { - let token = await BootpayRest.getAccessToken() + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + let token = await RestClient.getAccessToken() if (token.status === 200) { let response try { - response = await BootpayRest.destroySubscribeBillingKey('5ef30dd58a1a350391ecdce3') + response = await RestClient.destroySubscribeBillingKey('5f97b8a40f606f03e8ab32a0') } catch (e) { - response = e.data + return console.log(e) } console.log(response) } diff --git a/test/get_user_token.js b/test/get_user_token.js index 72a7da3..12e3371 100644 --- a/test/get_user_token.js +++ b/test/get_user_token.js @@ -1,24 +1,20 @@ -var BootpayRest = require('../lib/bootpay'); - -BootpayRest.setConfig( - '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' -); - -BootpayRest.getAccessToken().then(function (tokenData) { - if (tokenData.status === 200) { - BootpayRest.getUserToken({ - user_id: '[[ user_id ]] ( 필수 )', - email: 'bootpay@bootpay.co.kr', // 필수 - name: '[[ 사용자 명 ]] ( 선택 )', - gender: '[[ 0 - 여자, 1 - 남자 ]] ( 선택 )', - birth: ' [[ 생년월일 ( 6자리) ]] ( 선택 )', - phone: ' [[ 전화번호 ]] ( 페이앱의 경우 필수 )' - }).then(function (data) { - console.log(data); - }); - } else { - console.log('error!') +(async () => { + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + const token = await RestClient.getAccessToken() + if (token.status === 200) { + let result + try { + result = await RestClient.requestUserToken({ + userId: 'gosomi' + }) + } catch (e) { + return console.log(e) + } + console.log(result) } -}); \ No newline at end of file +})() \ No newline at end of file diff --git a/test/request_payment.js b/test/request_payment.js index 544f854..083868e 100644 --- a/test/request_payment.js +++ b/test/request_payment.js @@ -1,30 +1,28 @@ -var BootpayRest = require('../lib/bootpay'); - -BootpayRest.setConfig( - '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' -); - (async () => { - let token = await BootpayRest.getAccessToken() + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + const token = await RestClient.getAccessToken() if (token.status === 200) { - let response + let result try { - response = await BootpayRest.requestPayment({ + result = await RestClient.requestPayment({ pg: 'kcp', method: 'card', - order_id: (new Date).getTime(), + orderId: (new Date).getTime(), price: 1000, - name: '테스트 부트페이 상품', - return_url: 'https://dev-api.bootpay.co.kr/callback', + itemName: '테스트 부트페이 상품', + returnUrl: 'https://dev-api.bootpay.co.kr/callback', extra: { expire: 30 } }) } catch (e) { - response = e.data + return console.log(e) } - console.log(response) + console.log(result) } })() \ No newline at end of file diff --git a/test/subscribe_billing.js b/test/subscribe_billing.js index 99be22b..d7295ff 100644 --- a/test/subscribe_billing.js +++ b/test/subscribe_billing.js @@ -1,28 +1,31 @@ -var BootpayRest = require('../lib/bootpay'); - -BootpayRest.setConfig( - '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' -); - - -BootpayRest.getAccessToken() - .then( - // Access Token을 가져왔을 때 처리 - function (data) { - BootpayRest.subscribeBilling('5b025b33e13f33310ce560fb', '정기결제입니다.', 1000, (new Date()).getTime(), [], { - username: '홍길동', - phone: '010-0000-0000', - address: '서울특별시 구로구' - }).then(function (data) { - console.log(data); - }, function (data) { - console.log(data); - }); - }, - // Access Token을 가져오는데 실패한 경우 - function (data) { - console.log(data); +(async () => { + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + let token = await RestClient.getAccessToken() + if (token.status === 200) { + let response + try { + response = await RestClient.requestSubscribeBillingPayment({ + billingKey: '5f97b8a40f606f03e8ab32a0', + itemName: '테스트', + price: 1000, + orderId: (new Date()).getTime(), + userInfo: { + username: 'test', + email: 'test@bootpay.co.kr', + phone: '01000000000', + address: '테스트 지역' + }, + feedbackUrl: 'https://dev-api.bootpay.co.kr/callback', + feedbackContentType: 'json' + }) + } catch (e) { + return console.log(e) } - ); \ No newline at end of file + console.log(response) + } +})() \ No newline at end of file diff --git a/test/subscribe_billing_reserve.js b/test/subscribe_billing_reserve.js index 3ccf3fc..099b1d8 100644 --- a/test/subscribe_billing_reserve.js +++ b/test/subscribe_billing_reserve.js @@ -1,26 +1,30 @@ -var BootpayRest = require('../lib/bootpay'); - -BootpayRest.setConfig( - '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' -); - -(async () =>{ - let token = await BootpayRest.getAccessToken() - if(token.status === 200) { +(async () => { + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + let token = await RestClient.getAccessToken() + if (token.status === 200) { let response try { - response = await BootpayRest.subscribeBillingReserve( - '5b025b33e13f33310ce560fb', - '정기결제입니다.', - 1000, - (new Date()).getTime(), - parseInt(new Date().getTime() / 1000) + 3600, // 1시간 뒤 실행 - "https://dev-api.bootpay.co.kr/callback" - ) + response = await RestClient.reserveSubscribeBilling({ + billingKey: '5f97b8a40f606f03e8ab32a0', + itemName: '테스트', + price: 1000, + orderId: (new Date()).getTime(), + userInfo: { + username: '테스트', + phone: '01000000000' + }, + feedbackUrl: 'https://dev-api.bootpay.co.kr/callback', + feedbackContentType: 'json', + schedulerType: 'oneshot', + executeAt: ((new Date()).getTime() / 1000) + 5 + }) } catch (e) { - console.log(e.data) + return console.log(e) } console.log(response) } diff --git a/test/subscribe_billing_reserve_cancel.js b/test/subscribe_billing_reserve_cancel.js index 3d5c0a3..150338e 100644 --- a/test/subscribe_billing_reserve_cancel.js +++ b/test/subscribe_billing_reserve_cancel.js @@ -1,31 +1,35 @@ -var BootpayRest = require('../lib/bootpay'); - -BootpayRest.setConfig( - '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' -); - (async () => { - let token = await BootpayRest.getAccessToken() + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + let token = await RestClient.getAccessToken() if (token.status === 200) { let response try { - response = await BootpayRest.subscribeBillingReserve( - '5ef30dd58a1a350391ecdce3', - '정기결제입니다.', - 1000, - (new Date()).getTime(), - parseInt(new Date().getTime() / 1000) + 3600, // 1시간 뒤 실행 - "https://dev-api.bootpay.co.kr/callback" - ) + response = await RestClient.reserveSubscribeBilling({ + billingKey: '5f97b8a40f606f03e8ab32a0', + itemName: '테스트', + price: 1000, + orderId: (new Date()).getTime(), + userInfo: { + username: '테스트', + phone: '01000000000' + }, + feedbackUrl: 'https://dev-api.bootpay.co.kr/callback', + feedbackContentType: 'json', + schedulerType: 'oneshot', + executeAt: ((new Date()).getTime() / 1000) + 60 + }) + if (response.status === 200) { + response = await RestClient.destroyReserveSubscribeBilling(response.data.reserve_id) + console.log(response) + } } catch (e) { - response = e.data - } - console.log(response) - if (response.status === 200) { - let cancelled_response = await BootpayRest.destroySubscribeBillingReserveCancel(response.data.reserve_id) - console.log(cancelled_response) + return console.log(e) } + // console.log(response) } })() \ No newline at end of file diff --git a/test/verify.js b/test/verify.js index 59feaaa..3946af6 100644 --- a/test/verify.js +++ b/test/verify.js @@ -1,19 +1,17 @@ -let BootpayRest = require('../lib/bootpay'); - -BootpayRest.setConfig( - '59bfc738e13f337dbd6ca48a', - 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', - 'development' -); - (async () => { - let response = await BootpayRest.getAccessToken() - if (response.status === 200) { + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + const token = await RestClient.getAccessToken() + if (token.status === 200) { let result try { - result = await BootpayRest.verify('5f0d42a7d111902931bea5ff') + result = await RestClient.verify('5f0d42a7d111902931bea5ff') } catch (e) { - return console.log(e.error) + return console.log(e) } console.log(result) } diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..bf25cbc --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": [ + "es6" + ], + "module": "commonjs", + "moduleResolution": "node", + "declaration": true, + "outDir": "./dist", + "strict": true, + "baseUrl": "./src", + "paths": { + "*": [ + "../node_modules/*", + "./*" + ] + } + }, + "exclude": [ + "**/*.spec.ts", + "node_modules", + "dist" + ], + "compileOnSave": false +} \ No newline at end of file From 8f82459111ef4a307664124cb3ecb0829f4683ce Mon Sep 17 00:00:00 2001 From: Gosomi Date: Tue, 27 Oct 2020 17:43:18 +0900 Subject: [PATCH 051/109] =?UTF-8?q?npm=20ignore=20=EC=B6=94=EA=B0=80=20typ?= =?UTF-8?q?escript=20package=20=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .npmignore | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .npmignore diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..749bfc1 --- /dev/null +++ b/.npmignore @@ -0,0 +1,7 @@ +src/* +.gitattributes +.gitignore +package-lock.json +*.iml +*.idea +yarn.lock \ No newline at end of file diff --git a/package.json b/package.json index 48b8a3e..474e029 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@bootpay/server-rest-client", + "name": "bootpay-server-client", "version": "1.0.0-beta1", "description": "Bootpay Server Rest Client Javasrcipt Library", "main": "dist/bootpay.js", From de77446576cc0723366a2492f96618ef73af0f2c Mon Sep 17 00:00:00 2001 From: Gosomi Date: Tue, 27 Oct 2020 17:43:18 +0900 Subject: [PATCH 052/109] =?UTF-8?q?npm=20ignore=20=EC=B6=94=EA=B0=80=20typ?= =?UTF-8?q?escript=20package=20=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .npmignore | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .npmignore diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..749bfc1 --- /dev/null +++ b/.npmignore @@ -0,0 +1,7 @@ +src/* +.gitattributes +.gitignore +package-lock.json +*.iml +*.idea +yarn.lock \ No newline at end of file diff --git a/package.json b/package.json index 48b8a3e..474e029 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@bootpay/server-rest-client", + "name": "bootpay-server-client", "version": "1.0.0-beta1", "description": "Bootpay Server Rest Client Javasrcipt Library", "main": "dist/bootpay.js", From 57a6b4cea3bedb5642251c22074d3b2d28cd82ef Mon Sep 17 00:00:00 2001 From: Gosomi Date: Tue, 27 Oct 2020 17:55:58 +0900 Subject: [PATCH 053/109] =?UTF-8?q?readme=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .npmignore | 3 ++- README.md | 75 ++++++++++++++++++++++++++-------------------------- package.json | 2 +- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/.npmignore b/.npmignore index 749bfc1..82f4082 100644 --- a/.npmignore +++ b/.npmignore @@ -4,4 +4,5 @@ src/* package-lock.json *.iml *.idea -yarn.lock \ No newline at end of file +yarn.lock +tsconfig.json \ No newline at end of file diff --git a/README.md b/README.md index a2b64d1..e9114b9 100644 --- a/README.md +++ b/README.md @@ -1,45 +1,44 @@ -# 3.0.0 ( next ) - Nightly Version +# 1.0.0-beta2 ( next ) - Nightly Version -### 3.0.0 변경된 점 -* request.js -> axios로 변경 되었습니다. +### 1.0.0 +* typescript로 코딩이 되어있습니다 +* d.ts 파일이 첨부되어 typescript로도 코딩이 가능합니다. - -### 2.0.0 변경된 점 -* 보안취약점 노출된 Restler -> request-promise-native 로 변경하였습니다. -* ES6 Syntax로 변경되었습니다. -* Error 처리를 유연하게 할 수 있도록 예제가 변경되었습니다. - -## PG Analytics - 결제데이터 분석서비스 -* 기존 PG 사를 이용 중이신 사업자도 별도의 계약없이 부트페이를 통해 결제 연동과 통계를 무료로 이용하실 수 있습니다. -* 한줄의 소스코드로 인사이트를 얻어 매출을 극대화하세요. - -## 결제 검증 및 취소 - 서버사이드용 -* 보안상의 이유로 결제검증과 취소는 서버사이드에서 이루어집니다. -* 부트페이 서버와 통신시 Rest용 Application Id, Private Key 값을 보내주셔야 하며, 보내실 서버의 IP는 미리 등록하셔야 합니다. - -## npm을 통해 restler를 설치합니다 -``` -npm install restler -``` - -## 샘플 코드 +## 샘플 코드 +### NPM으로 다운 받은 경우 ```nodejs -var Bootpay = require('./bootpay'); - -BootpayRest.setConfig( - '[[ REST용 application id ]]', - '[[ Private Key ]]' -); - -BootpayRest.getAccessToken().then(function (tokenData) { - if (tokenData.status === 200) { - BootpayRest.verify('1234') - .then(function (data) { - console.log(data); - }); - } else { - console.log('error!') +const RestClient = require('bootpay-rest-client') + +RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' +) +RestClient.getAccessToken().then( + function(response) { + console.log(response) + }, function(e) { + console.log(e) } +) }); ### 더 자세한 정보는 [Docs](https://docs.bootpay.co.kr/api/validate?languageCurrentIndex=2)를 참조해주세요.  +``` +### github으로 바로 다운 받은 경우 +```nodejs +const RestClient = require('./dist/bootpay') + +RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' +) +RestClient.getAccessToken().then( + function(response) { + console.log(response) + }, function(e) { + console.log(e) + } +) +}); \ No newline at end of file diff --git a/package.json b/package.json index 474e029..de16d0a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootpay-server-client", - "version": "1.0.0-beta1", + "version": "1.0.0-beta2", "description": "Bootpay Server Rest Client Javasrcipt Library", "main": "dist/bootpay.js", "types": "dist/bootpay.d.ts", From f2a5330ec7dfb6dabaacc1b25746451403dbf427 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Tue, 27 Oct 2020 17:55:58 +0900 Subject: [PATCH 054/109] =?UTF-8?q?readme=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .npmignore | 3 ++- README.md | 75 ++++++++++++++++++++++++++-------------------------- package.json | 2 +- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/.npmignore b/.npmignore index 749bfc1..82f4082 100644 --- a/.npmignore +++ b/.npmignore @@ -4,4 +4,5 @@ src/* package-lock.json *.iml *.idea -yarn.lock \ No newline at end of file +yarn.lock +tsconfig.json \ No newline at end of file diff --git a/README.md b/README.md index a2b64d1..e9114b9 100644 --- a/README.md +++ b/README.md @@ -1,45 +1,44 @@ -# 3.0.0 ( next ) - Nightly Version +# 1.0.0-beta2 ( next ) - Nightly Version -### 3.0.0 변경된 점 -* request.js -> axios로 변경 되었습니다. +### 1.0.0 +* typescript로 코딩이 되어있습니다 +* d.ts 파일이 첨부되어 typescript로도 코딩이 가능합니다. - -### 2.0.0 변경된 점 -* 보안취약점 노출된 Restler -> request-promise-native 로 변경하였습니다. -* ES6 Syntax로 변경되었습니다. -* Error 처리를 유연하게 할 수 있도록 예제가 변경되었습니다. - -## PG Analytics - 결제데이터 분석서비스 -* 기존 PG 사를 이용 중이신 사업자도 별도의 계약없이 부트페이를 통해 결제 연동과 통계를 무료로 이용하실 수 있습니다. -* 한줄의 소스코드로 인사이트를 얻어 매출을 극대화하세요. - -## 결제 검증 및 취소 - 서버사이드용 -* 보안상의 이유로 결제검증과 취소는 서버사이드에서 이루어집니다. -* 부트페이 서버와 통신시 Rest용 Application Id, Private Key 값을 보내주셔야 하며, 보내실 서버의 IP는 미리 등록하셔야 합니다. - -## npm을 통해 restler를 설치합니다 -``` -npm install restler -``` - -## 샘플 코드 +## 샘플 코드 +### NPM으로 다운 받은 경우 ```nodejs -var Bootpay = require('./bootpay'); - -BootpayRest.setConfig( - '[[ REST용 application id ]]', - '[[ Private Key ]]' -); - -BootpayRest.getAccessToken().then(function (tokenData) { - if (tokenData.status === 200) { - BootpayRest.verify('1234') - .then(function (data) { - console.log(data); - }); - } else { - console.log('error!') +const RestClient = require('bootpay-rest-client') + +RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' +) +RestClient.getAccessToken().then( + function(response) { + console.log(response) + }, function(e) { + console.log(e) } +) }); ### 더 자세한 정보는 [Docs](https://docs.bootpay.co.kr/api/validate?languageCurrentIndex=2)를 참조해주세요.  +``` +### github으로 바로 다운 받은 경우 +```nodejs +const RestClient = require('./dist/bootpay') + +RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' +) +RestClient.getAccessToken().then( + function(response) { + console.log(response) + }, function(e) { + console.log(e) + } +) +}); \ No newline at end of file diff --git a/package.json b/package.json index 474e029..de16d0a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootpay-server-client", - "version": "1.0.0-beta1", + "version": "1.0.0-beta2", "description": "Bootpay Server Rest Client Javasrcipt Library", "main": "dist/bootpay.js", "types": "dist/bootpay.d.ts", From 9db4be2499fb36215685be477f368c674c8d5fde Mon Sep 17 00:00:00 2001 From: Gosomi Date: Tue, 27 Oct 2020 20:06:01 +0900 Subject: [PATCH 055/109] =?UTF-8?q?readme=20=EC=88=98=EC=A0=95=201.0.0=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 ++--- package.json | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e9114b9..aed2f95 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ -# 1.0.0-beta2 ( next ) - Nightly Version - -### 1.0.0 +# Bootpay Server Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg?[Digest::md5])](https://www.npmjs.com/package/bootpay-server-client) +### 1.0.0 ( Stable ) * typescript로 코딩이 되어있습니다 * d.ts 파일이 첨부되어 typescript로도 코딩이 가능합니다. diff --git a/package.json b/package.json index de16d0a..cc2e592 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootpay-server-client", - "version": "1.0.0-beta2", + "version": "1.0.0", "description": "Bootpay Server Rest Client Javasrcipt Library", "main": "dist/bootpay.js", "types": "dist/bootpay.d.ts", From ff5bdf318a952f17ab6512a7b77568cc54b5cced Mon Sep 17 00:00:00 2001 From: Gosomi Date: Tue, 27 Oct 2020 20:06:01 +0900 Subject: [PATCH 056/109] =?UTF-8?q?readme=20=EC=88=98=EC=A0=95=201.0.0=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 ++--- package.json | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e9114b9..aed2f95 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ -# 1.0.0-beta2 ( next ) - Nightly Version - -### 1.0.0 +# Bootpay Server Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg?[Digest::md5])](https://www.npmjs.com/package/bootpay-server-client) +### 1.0.0 ( Stable ) * typescript로 코딩이 되어있습니다 * d.ts 파일이 첨부되어 typescript로도 코딩이 가능합니다. diff --git a/package.json b/package.json index de16d0a..cc2e592 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootpay-server-client", - "version": "1.0.0-beta2", + "version": "1.0.0", "description": "Bootpay Server Rest Client Javasrcipt Library", "main": "dist/bootpay.js", "types": "dist/bootpay.d.ts", From ecc10d864694f4248fcff27978b3bb24381c7c49 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Tue, 27 Oct 2020 20:16:57 +0900 Subject: [PATCH 057/109] =?UTF-8?q?readme=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aed2f95..462fa73 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ## 샘플 코드 ### NPM으로 다운 받은 경우 ```nodejs -const RestClient = require('bootpay-rest-client') +const RestClient = require('bootpay-server-client') RestClient.setConfig( '59bfc738e13f337dbd6ca48a', @@ -26,7 +26,7 @@ RestClient.getAccessToken().then( ``` ### github으로 바로 다운 받은 경우 ```nodejs -const RestClient = require('./dist/bootpay') +const RestClient = require('./dist/bootpay').RestClient RestClient.setConfig( '59bfc738e13f337dbd6ca48a', From 13079d968ce630b1068e3621259fb11826d9d15d Mon Sep 17 00:00:00 2001 From: Gosomi Date: Tue, 27 Oct 2020 20:16:57 +0900 Subject: [PATCH 058/109] =?UTF-8?q?readme=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aed2f95..462fa73 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ## 샘플 코드 ### NPM으로 다운 받은 경우 ```nodejs -const RestClient = require('bootpay-rest-client') +const RestClient = require('bootpay-server-client') RestClient.setConfig( '59bfc738e13f337dbd6ca48a', @@ -26,7 +26,7 @@ RestClient.getAccessToken().then( ``` ### github으로 바로 다운 받은 경우 ```nodejs -const RestClient = require('./dist/bootpay') +const RestClient = require('./dist/bootpay').RestClient RestClient.setConfig( '59bfc738e13f337dbd6ca48a', From b5c6a034af358b75232c4396a806b4ea959e842c Mon Sep 17 00:00:00 2001 From: Gosomi Date: Tue, 27 Oct 2020 20:30:51 +0900 Subject: [PATCH 059/109] =?UTF-8?q?readme=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 462fa73..ba8436d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ -# Bootpay Server Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg?[Digest::md5])](https://www.npmjs.com/package/bootpay-server-client) +# Bootpay Server Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg)](https://www.npmjs.com/package/bootpay-server-client) ### 1.0.0 ( Stable ) * typescript로 코딩이 되어있습니다 * d.ts 파일이 첨부되어 typescript로도 코딩이 가능합니다. +date: '`r paste("First created on Oct 01, 2018. Updated on", Sys.Date())`' ## 샘플 코드 ### NPM으로 다운 받은 경우 ```nodejs From 679acab12b6025ebff22c4b5e335bf6d1608de13 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Tue, 27 Oct 2020 20:30:51 +0900 Subject: [PATCH 060/109] =?UTF-8?q?readme=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 462fa73..ba8436d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ -# Bootpay Server Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg?[Digest::md5])](https://www.npmjs.com/package/bootpay-server-client) +# Bootpay Server Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg)](https://www.npmjs.com/package/bootpay-server-client) ### 1.0.0 ( Stable ) * typescript로 코딩이 되어있습니다 * d.ts 파일이 첨부되어 typescript로도 코딩이 가능합니다. +date: '`r paste("First created on Oct 01, 2018. Updated on", Sys.Date())`' ## 샘플 코드 ### NPM으로 다운 받은 경우 ```nodejs From e0e01ed2aa36aa95f0f9a4e25c1758ddc8dee212 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 08:56:28 +0900 Subject: [PATCH 061/109] =?UTF-8?q?package=20name=20scope=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cc2e592..3ff0053 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "bootpay-server-client", + "name": "@bootpay/server-rest-client", "version": "1.0.0", "description": "Bootpay Server Rest Client Javasrcipt Library", "main": "dist/bootpay.js", From c75c434e3652b66e8723affcc2f4c277093b6145 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 08:56:28 +0900 Subject: [PATCH 062/109] =?UTF-8?q?package=20name=20scope=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cc2e592..3ff0053 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "bootpay-server-client", + "name": "@bootpay/server-rest-client", "version": "1.0.0", "description": "Bootpay Server Rest Client Javasrcipt Library", "main": "dist/bootpay.js", From 00c8d6ae70c7d3da1655f0274a21c17251d6aa2b Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 08:58:57 +0900 Subject: [PATCH 063/109] =?UTF-8?q?readme=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index ba8436d..7517345 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ * typescript로 코딩이 되어있습니다 * d.ts 파일이 첨부되어 typescript로도 코딩이 가능합니다. -date: '`r paste("First created on Oct 01, 2018. Updated on", Sys.Date())`' ## 샘플 코드 ### NPM으로 다운 받은 경우 ```nodejs From fdd247ec91d8624cc89e860375d16b1867e54796 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 08:58:57 +0900 Subject: [PATCH 064/109] =?UTF-8?q?readme=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index ba8436d..7517345 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ * typescript로 코딩이 되어있습니다 * d.ts 파일이 첨부되어 typescript로도 코딩이 가능합니다. -date: '`r paste("First created on Oct 01, 2018. Updated on", Sys.Date())`' ## 샘플 코드 ### NPM으로 다운 받은 경우 ```nodejs From 9870ea65f576749742055e8e920d2432b6785da7 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 08:59:22 +0900 Subject: [PATCH 065/109] =?UTF-8?q?=EB=A7=81=ED=81=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7517345..b718fee 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Bootpay Server Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg)](https://www.npmjs.com/package/bootpay-server-client) +# Bootpay Server Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg)](https://www.npmjs.com/package/@bootpay/server-rest-client) ### 1.0.0 ( Stable ) * typescript로 코딩이 되어있습니다 * d.ts 파일이 첨부되어 typescript로도 코딩이 가능합니다. From ee34fcb652960f4cc071e3e42d8ce53ea37f5e93 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 08:59:22 +0900 Subject: [PATCH 066/109] =?UTF-8?q?=EB=A7=81=ED=81=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7517345..b718fee 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Bootpay Server Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg)](https://www.npmjs.com/package/bootpay-server-client) +# Bootpay Server Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg)](https://www.npmjs.com/package/@bootpay/server-rest-client) ### 1.0.0 ( Stable ) * typescript로 코딩이 되어있습니다 * d.ts 파일이 첨부되어 typescript로도 코딩이 가능합니다. From 748773127956e4ea39632ba80597f23955a14cf7 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 09:00:10 +0900 Subject: [PATCH 067/109] =?UTF-8?q?require=20package=20=EB=AA=85=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b718fee..4935412 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ## 샘플 코드 ### NPM으로 다운 받은 경우 ```nodejs -const RestClient = require('bootpay-server-client') +const RestClient = require('@bootpay/server-rest-client') RestClient.setConfig( '59bfc738e13f337dbd6ca48a', From ac1df52c2a85c1b156647f56303d54738b1c4102 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 09:00:10 +0900 Subject: [PATCH 068/109] =?UTF-8?q?require=20package=20=EB=AA=85=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b718fee..4935412 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ## 샘플 코드 ### NPM으로 다운 받은 경우 ```nodejs -const RestClient = require('bootpay-server-client') +const RestClient = require('@bootpay/server-rest-client') RestClient.setConfig( '59bfc738e13f337dbd6ca48a', From 418144dac5b7833da2913e7673c10734ff90d46e Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 09:24:01 +0900 Subject: [PATCH 069/109] =?UTF-8?q?readme=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4935412..cd933ce 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,11 @@ ## 샘플 코드 ### NPM으로 다운 받은 경우 ```nodejs -const RestClient = require('@bootpay/server-rest-client') +const RestClient = require('@bootpay/server-rest-client').RestClient + +// or + +import { RestClient } from '@bootpay/server-rest-client' RestClient.setConfig( '59bfc738e13f337dbd6ca48a', @@ -28,6 +32,10 @@ RestClient.getAccessToken().then( ```nodejs const RestClient = require('./dist/bootpay').RestClient +// or + +import { RestClient } from './dist/bootpay' + RestClient.setConfig( '59bfc738e13f337dbd6ca48a', 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', From 489b8e9815907e0a6fb6ef48fdee743b708e6483 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 09:24:01 +0900 Subject: [PATCH 070/109] =?UTF-8?q?readme=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4935412..cd933ce 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,11 @@ ## 샘플 코드 ### NPM으로 다운 받은 경우 ```nodejs -const RestClient = require('@bootpay/server-rest-client') +const RestClient = require('@bootpay/server-rest-client').RestClient + +// or + +import { RestClient } from '@bootpay/server-rest-client' RestClient.setConfig( '59bfc738e13f337dbd6ca48a', @@ -28,6 +32,10 @@ RestClient.getAccessToken().then( ```nodejs const RestClient = require('./dist/bootpay').RestClient +// or + +import { RestClient } from './dist/bootpay' + RestClient.setConfig( '59bfc738e13f337dbd6ca48a', 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', From 7c69496d2a34608becb88c52586934de24f08cfe Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 09:25:37 +0900 Subject: [PATCH 071/109] delete hello.js --- hello.js | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 hello.js diff --git a/hello.js b/hello.js deleted file mode 100644 index 2788991..0000000 --- a/hello.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Created by ehowlsla on 2017. 8. 3.. - */ -var Bootpay = require('./bootpay'); - -var bootpay = new Bootpay('application_id_value_1234', '593f8febe13f332431a8ddaw'); -// -bootpay.confirm('593f8febe13f332431a8ddae', function(data) { - console.log(data); -}); - -bootpay.cancel('593f8febe13f332431a8ddae', '관리자 홍길동', '구매자 단순변심', function(data) { - console.log(data); -}); From d9dcd6354762531a2e3a8cd78917d14626ea7e6f Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 09:25:37 +0900 Subject: [PATCH 072/109] delete hello.js --- hello.js | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 hello.js diff --git a/hello.js b/hello.js deleted file mode 100644 index 2788991..0000000 --- a/hello.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Created by ehowlsla on 2017. 8. 3.. - */ -var Bootpay = require('./bootpay'); - -var bootpay = new Bootpay('application_id_value_1234', '593f8febe13f332431a8ddaw'); -// -bootpay.confirm('593f8febe13f332431a8ddae', function(data) { - console.log(data); -}); - -bootpay.cancel('593f8febe13f332431a8ddae', '관리자 홍길동', '구매자 단순변심', function(data) { - console.log(data); -}); From b2309f49d42e342ea2a2f1b8c8377259518fc946 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 09:33:42 +0900 Subject: [PATCH 073/109] =?UTF-8?q?readme=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cd933ce..d3a7b3f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Bootpay Server Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg)](https://www.npmjs.com/package/@bootpay/server-rest-client) +# Bootpay Server Rest Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg)](https://www.npmjs.com/package/@bootpay/server-rest-client) ### 1.0.0 ( Stable ) * typescript로 코딩이 되어있습니다 * d.ts 파일이 첨부되어 typescript로도 코딩이 가능합니다. From a4abdca19025f1e45cbccbdeba6b74f4b60d68f2 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 09:33:42 +0900 Subject: [PATCH 074/109] =?UTF-8?q?readme=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cd933ce..d3a7b3f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Bootpay Server Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg)](https://www.npmjs.com/package/@bootpay/server-rest-client) +# Bootpay Server Rest Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg)](https://www.npmjs.com/package/@bootpay/server-rest-client) ### 1.0.0 ( Stable ) * typescript로 코딩이 되어있습니다 * d.ts 파일이 첨부되어 typescript로도 코딩이 가능합니다. From 2f303e297bdfa599db9d2d2d262efe207a4e234e Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 09:35:04 +0900 Subject: [PATCH 075/109] =?UTF-8?q?=EB=9D=BC=EC=9D=B4=EC=84=BC=EC=8A=A4=20?= =?UTF-8?q?=EB=AA=85=EC=8B=9C=20=EB=B3=80=EA=B2=BD=20=EB=B2=84=EC=A0=84=20?= =?UTF-8?q?=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3ff0053..3677865 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bootpay/server-rest-client", - "version": "1.0.0", + "version": "1.0.1", "description": "Bootpay Server Rest Client Javasrcipt Library", "main": "dist/bootpay.js", "types": "dist/bootpay.d.ts", @@ -30,7 +30,7 @@ "bootpay" ], "author": "Bootpay", - "license": "ISC", + "license": "MIT", "bugs": { "url": "https://github.com/bootpay/server_nodejs/issues" }, From 5918ad05c3319f269f6b25cf9839b2c066290cb6 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 09:35:04 +0900 Subject: [PATCH 076/109] =?UTF-8?q?=EB=9D=BC=EC=9D=B4=EC=84=BC=EC=8A=A4=20?= =?UTF-8?q?=EB=AA=85=EC=8B=9C=20=EB=B3=80=EA=B2=BD=20=EB=B2=84=EC=A0=84=20?= =?UTF-8?q?=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3ff0053..3677865 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bootpay/server-rest-client", - "version": "1.0.0", + "version": "1.0.1", "description": "Bootpay Server Rest Client Javasrcipt Library", "main": "dist/bootpay.js", "types": "dist/bootpay.d.ts", @@ -30,7 +30,7 @@ "bootpay" ], "author": "Bootpay", - "license": "ISC", + "license": "MIT", "bugs": { "url": "https://github.com/bootpay/server_nodejs/issues" }, From f846e39087863243ea8a2e2845ab766075edeedc Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 10:18:01 +0900 Subject: [PATCH 077/109] =?UTF-8?q?items,=20user=5Finfo=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20underscore=20key=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bootpay.ts | 17 ++++++++++------- src/lib/bootpay/support.ts | 35 ++++++++++++++++++++++++++++++++++- test/subscribe_billing.js | 6 ------ 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/src/bootpay.ts b/src/bootpay.ts index 2771fef..97f0619 100644 --- a/src/bootpay.ts +++ b/src/bootpay.ts @@ -1,6 +1,6 @@ import { BootpaySingleton } from "./lib/bootpay/singleton" import axios, { AxiosInstance, AxiosResponse, AxiosRequestConfig } from "axios" -import { isBlank, isPresent } from "./lib/bootpay/support" +import { isBlank, isPresent, objectKeyToUnderscore } from "./lib/bootpay/support" const API_URL: any = { development: 'https://dev-api.bootpay.co.kr', @@ -100,6 +100,9 @@ export interface BootpayItemData { qty: number, itemName: string, price: number + cat1?: string + cat2?: string + cat3?: string } export interface BootpaySubscribeExtraData { @@ -340,8 +343,8 @@ class BootpayRestClient extends BootpaySingleton { tax_free: data.taxFree, interest: data.interest, quota: data.quota, - items: data.items, - user_info: data.userInfo, + items: objectKeyToUnderscore(data.items), + user_info: objectKeyToUnderscore(data.userInfo), feedback_url: data.feedbackUrl, feedback_content_type: data.feedbackContentType } @@ -369,8 +372,8 @@ class BootpayRestClient extends BootpaySingleton { order_id: data.orderId, price: data.price, tax_free: data.taxFree, - user_info: data.userInfo, - item_info: data.items, + user_info: objectKeyToUnderscore(data.userInfo), + item_info: objectKeyToUnderscore(data.items), item_name: data.itemName, feedback_url: data.feedbackUrl, feedback_content_type: data.feedbackContentType, @@ -442,8 +445,8 @@ class BootpayRestClient extends BootpaySingleton { price: data.price, tax_free: data.taxFree, name: data.itemName, - user_info: data.userInfo, - items: data.items, + user_info: objectKeyToUnderscore(data.userInfo), + items: objectKeyToUnderscore(data.items), return_url: data.returnUrl, extra: data.extra } diff --git a/src/lib/bootpay/support.ts b/src/lib/bootpay/support.ts index 84ae5a3..9290cf4 100644 --- a/src/lib/bootpay/support.ts +++ b/src/lib/bootpay/support.ts @@ -6,6 +6,10 @@ export interface Validate { isPresent(value: any): Boolean presence(value: any, defaultValue: any): any + + toUnderscore(value: any): any + + objectKeyToUnderscore(value: any): any } class ValidateMethod extends BootpaySingleton implements Validate { @@ -34,10 +38,39 @@ class ValidateMethod extends BootpaySingleton implements Validate { return value } } + + objectKeyToUnderscore(value: any): any { + let cloneObject: any = undefined + if (isPresent(value)) { + const _this = this + if (Array.isArray(value)) { + cloneObject = [] + value.forEach((_value) => { + let childObject: any = {} + Object.keys(_value).forEach((key) => { + childObject[_this.toUnderscore(key)] = _value[key] + }) + cloneObject.push(childObject) + }) + } else { + cloneObject = {} + Object.keys(value).forEach((key) => { + cloneObject[_this.toUnderscore(key)] = value[key] + }) + } + } + return cloneObject + } + + toUnderscore(value: any): any { + return value.split(/(?=[A-Z])/).join('_').toLowerCase() + } } const ValidClass: ValidateMethod = ValidateMethod.currentInstance() export const isPresent = (value: any) => ValidClass.isPresent(value) export const isBlank = (value: any) => ValidClass.isBlank(value) -export const presence = (value: any, defaultValue: any) => ValidClass.presence(value, defaultValue) \ No newline at end of file +export const presence = (value: any, defaultValue: any) => ValidClass.presence(value, defaultValue) +export const toUnderscore = (value: any) => ValidClass.toUnderscore(value) +export const objectKeyToUnderscore = (value: any) => ValidClass.objectKeyToUnderscore(value) \ No newline at end of file diff --git a/test/subscribe_billing.js b/test/subscribe_billing.js index d7295ff..3660fb2 100644 --- a/test/subscribe_billing.js +++ b/test/subscribe_billing.js @@ -14,12 +14,6 @@ itemName: '테스트', price: 1000, orderId: (new Date()).getTime(), - userInfo: { - username: 'test', - email: 'test@bootpay.co.kr', - phone: '01000000000', - address: '테스트 지역' - }, feedbackUrl: 'https://dev-api.bootpay.co.kr/callback', feedbackContentType: 'json' }) From 78cee3960fcaca33b7b085af2a810d25ff4dabd7 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 10:18:01 +0900 Subject: [PATCH 078/109] =?UTF-8?q?items,=20user=5Finfo=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20underscore=20key=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bootpay.ts | 17 ++++++++++------- src/lib/bootpay/support.ts | 35 ++++++++++++++++++++++++++++++++++- test/subscribe_billing.js | 6 ------ 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/src/bootpay.ts b/src/bootpay.ts index 2771fef..97f0619 100644 --- a/src/bootpay.ts +++ b/src/bootpay.ts @@ -1,6 +1,6 @@ import { BootpaySingleton } from "./lib/bootpay/singleton" import axios, { AxiosInstance, AxiosResponse, AxiosRequestConfig } from "axios" -import { isBlank, isPresent } from "./lib/bootpay/support" +import { isBlank, isPresent, objectKeyToUnderscore } from "./lib/bootpay/support" const API_URL: any = { development: 'https://dev-api.bootpay.co.kr', @@ -100,6 +100,9 @@ export interface BootpayItemData { qty: number, itemName: string, price: number + cat1?: string + cat2?: string + cat3?: string } export interface BootpaySubscribeExtraData { @@ -340,8 +343,8 @@ class BootpayRestClient extends BootpaySingleton { tax_free: data.taxFree, interest: data.interest, quota: data.quota, - items: data.items, - user_info: data.userInfo, + items: objectKeyToUnderscore(data.items), + user_info: objectKeyToUnderscore(data.userInfo), feedback_url: data.feedbackUrl, feedback_content_type: data.feedbackContentType } @@ -369,8 +372,8 @@ class BootpayRestClient extends BootpaySingleton { order_id: data.orderId, price: data.price, tax_free: data.taxFree, - user_info: data.userInfo, - item_info: data.items, + user_info: objectKeyToUnderscore(data.userInfo), + item_info: objectKeyToUnderscore(data.items), item_name: data.itemName, feedback_url: data.feedbackUrl, feedback_content_type: data.feedbackContentType, @@ -442,8 +445,8 @@ class BootpayRestClient extends BootpaySingleton { price: data.price, tax_free: data.taxFree, name: data.itemName, - user_info: data.userInfo, - items: data.items, + user_info: objectKeyToUnderscore(data.userInfo), + items: objectKeyToUnderscore(data.items), return_url: data.returnUrl, extra: data.extra } diff --git a/src/lib/bootpay/support.ts b/src/lib/bootpay/support.ts index 84ae5a3..9290cf4 100644 --- a/src/lib/bootpay/support.ts +++ b/src/lib/bootpay/support.ts @@ -6,6 +6,10 @@ export interface Validate { isPresent(value: any): Boolean presence(value: any, defaultValue: any): any + + toUnderscore(value: any): any + + objectKeyToUnderscore(value: any): any } class ValidateMethod extends BootpaySingleton implements Validate { @@ -34,10 +38,39 @@ class ValidateMethod extends BootpaySingleton implements Validate { return value } } + + objectKeyToUnderscore(value: any): any { + let cloneObject: any = undefined + if (isPresent(value)) { + const _this = this + if (Array.isArray(value)) { + cloneObject = [] + value.forEach((_value) => { + let childObject: any = {} + Object.keys(_value).forEach((key) => { + childObject[_this.toUnderscore(key)] = _value[key] + }) + cloneObject.push(childObject) + }) + } else { + cloneObject = {} + Object.keys(value).forEach((key) => { + cloneObject[_this.toUnderscore(key)] = value[key] + }) + } + } + return cloneObject + } + + toUnderscore(value: any): any { + return value.split(/(?=[A-Z])/).join('_').toLowerCase() + } } const ValidClass: ValidateMethod = ValidateMethod.currentInstance() export const isPresent = (value: any) => ValidClass.isPresent(value) export const isBlank = (value: any) => ValidClass.isBlank(value) -export const presence = (value: any, defaultValue: any) => ValidClass.presence(value, defaultValue) \ No newline at end of file +export const presence = (value: any, defaultValue: any) => ValidClass.presence(value, defaultValue) +export const toUnderscore = (value: any) => ValidClass.toUnderscore(value) +export const objectKeyToUnderscore = (value: any) => ValidClass.objectKeyToUnderscore(value) \ No newline at end of file diff --git a/test/subscribe_billing.js b/test/subscribe_billing.js index d7295ff..3660fb2 100644 --- a/test/subscribe_billing.js +++ b/test/subscribe_billing.js @@ -14,12 +14,6 @@ itemName: '테스트', price: 1000, orderId: (new Date()).getTime(), - userInfo: { - username: 'test', - email: 'test@bootpay.co.kr', - phone: '01000000000', - address: '테스트 지역' - }, feedbackUrl: 'https://dev-api.bootpay.co.kr/callback', feedbackContentType: 'json' }) From 46d82fb126519b60e104fa5890f0e2960815bd02 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 10:18:57 +0900 Subject: [PATCH 079/109] =?UTF-8?q?1.0.2=20=ED=8D=BC=EB=B8=94=EB=A6=AC?= =?UTF-8?q?=EC=8B=B1=20=EC=A4=80=EB=B9=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 7 ++++++- package.json | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d3a7b3f..dddb127 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # Bootpay Server Rest Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg)](https://www.npmjs.com/package/@bootpay/server-rest-client) -### 1.0.0 ( Stable ) + +### 1.0.2 ( Stable ) +* item 정보를 underscore로 보내는 로직 추가 +* user_info 정보를 underscore로 보내는 로직 추가 + +### 1.0.0 * typescript로 코딩이 되어있습니다 * d.ts 파일이 첨부되어 typescript로도 코딩이 가능합니다. diff --git a/package.json b/package.json index 3677865..9a05741 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bootpay/server-rest-client", - "version": "1.0.1", + "version": "1.0.2", "description": "Bootpay Server Rest Client Javasrcipt Library", "main": "dist/bootpay.js", "types": "dist/bootpay.d.ts", From b5ef5604e083207fcb1d9bd4411306a7aaf9b146 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 10:18:57 +0900 Subject: [PATCH 080/109] =?UTF-8?q?1.0.2=20=ED=8D=BC=EB=B8=94=EB=A6=AC?= =?UTF-8?q?=EC=8B=B1=20=EC=A4=80=EB=B9=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 7 ++++++- package.json | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d3a7b3f..dddb127 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # Bootpay Server Rest Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg)](https://www.npmjs.com/package/@bootpay/server-rest-client) -### 1.0.0 ( Stable ) + +### 1.0.2 ( Stable ) +* item 정보를 underscore로 보내는 로직 추가 +* user_info 정보를 underscore로 보내는 로직 추가 + +### 1.0.0 * typescript로 코딩이 되어있습니다 * d.ts 파일이 첨부되어 typescript로도 코딩이 가능합니다. diff --git a/package.json b/package.json index 3677865..9a05741 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bootpay/server-rest-client", - "version": "1.0.1", + "version": "1.0.2", "description": "Bootpay Server Rest Client Javasrcipt Library", "main": "dist/bootpay.js", "types": "dist/bootpay.d.ts", From 51562a381aa25284ee47aafd8a6db8b1623d730d Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 10:30:11 +0900 Subject: [PATCH 081/109] =?UTF-8?q?=EC=B9=B4=EB=93=9C=20=EB=B2=88=ED=98=B8?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/request_subscribe_rest.js | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/test/request_subscribe_rest.js b/test/request_subscribe_rest.js index aaac663..8ba11d0 100644 --- a/test/request_subscribe_rest.js +++ b/test/request_subscribe_rest.js @@ -9,29 +9,15 @@ if (token.status === 200) { let response try { - // response = await RestClient.requestSubscribeBillingKey({ - // orderId: (new Date()).getTime(), - // pg: 'nicepay', - // name: '정기결제 30일권', - // cardNo: '[ 카드 번호 ]', - // cardPw: '[ 카드 비밀번호 앞 2자리 ]', - // expireYear: '[ 카드 만료 연도 ]', - // expireMonth: '[ 카드 만료 월 ]', - // identifyNumber: '[ 카드 소유주 생년월일 혹은 법인 번호 ]', - // extra: { - // subscribe_test_payment: 1 // 100원 결제 후 결제가 되면 billing key를 발행, 결제가 실패하면 에러 - // } - // }) - response = await RestClient.requestSubscribeBillingKey({ orderId: (new Date()).getTime(), pg: 'nicepay', - itemName: '정기결제 30일권', - cardNo: '9430810003624569', - cardPw: '89', - expireYear: '21', - expireMonth: '09', - identifyNumber: '841025', + name: '정기결제 30일권', + cardNo: '[ 카드 번호 ]', + cardPw: '[ 카드 비밀번호 앞 2자리 ]', + expireYear: '[ 카드 만료 연도 ]', + expireMonth: '[ 카드 만료 월 ]', + identifyNumber: '[ 카드 소유주 생년월일 혹은 법인 번호 ]', extra: { subscribe_test_payment: 1 // 100원 결제 후 결제가 되면 billing key를 발행, 결제가 실패하면 에러 } From efd690a3817cf27b4a10810b023c422aa1fe1b09 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 10:32:51 +0900 Subject: [PATCH 082/109] =?UTF-8?q?subscribe=20rest=20=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/request_subscribe_rest.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/request_subscribe_rest.js diff --git a/test/request_subscribe_rest.js b/test/request_subscribe_rest.js new file mode 100644 index 0000000..8ba11d0 --- /dev/null +++ b/test/request_subscribe_rest.js @@ -0,0 +1,30 @@ +(async () => { + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + let token = await RestClient.getAccessToken() + if (token.status === 200) { + let response + try { + response = await RestClient.requestSubscribeBillingKey({ + orderId: (new Date()).getTime(), + pg: 'nicepay', + name: '정기결제 30일권', + cardNo: '[ 카드 번호 ]', + cardPw: '[ 카드 비밀번호 앞 2자리 ]', + expireYear: '[ 카드 만료 연도 ]', + expireMonth: '[ 카드 만료 월 ]', + identifyNumber: '[ 카드 소유주 생년월일 혹은 법인 번호 ]', + extra: { + subscribe_test_payment: 1 // 100원 결제 후 결제가 되면 billing key를 발행, 결제가 실패하면 에러 + } + }) + } catch (e) { + return console.log(e) + } + console.log(response) + } +})() \ No newline at end of file From 287901a70e74e3e8664aa4a7a5737c309fc1fc5b Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 10:34:05 +0900 Subject: [PATCH 083/109] =?UTF-8?q?=EA=B2=B0=EC=A0=9C=20=EA=B2=80=EC=A6=9D?= =?UTF-8?q?=20extra=20key=20=EB=B3=80=EA=B2=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/request_subscribe_rest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/request_subscribe_rest.js b/test/request_subscribe_rest.js index 8ba11d0..9c53e09 100644 --- a/test/request_subscribe_rest.js +++ b/test/request_subscribe_rest.js @@ -19,7 +19,7 @@ expireMonth: '[ 카드 만료 월 ]', identifyNumber: '[ 카드 소유주 생년월일 혹은 법인 번호 ]', extra: { - subscribe_test_payment: 1 // 100원 결제 후 결제가 되면 billing key를 발행, 결제가 실패하면 에러 + subscribeTestPayment: 1 // 100원 결제 후 결제가 되면 billing key를 발행, 결제가 실패하면 에러 } }) } catch (e) { From 280eab296d0bf3351ab8d09e8d7c3a33a1add0e6 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 10:35:11 +0900 Subject: [PATCH 084/109] =?UTF-8?q?extra=20=EA=B0=92=20underscore=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bootpay.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootpay.ts b/src/bootpay.ts index 97f0619..f00d368 100644 --- a/src/bootpay.ts +++ b/src/bootpay.ts @@ -295,7 +295,7 @@ class BootpayRestClient extends BootpaySingleton { expire_month: data.expireMonth, identify_number: data.identifyNumber, user_info: data.userInfo, - extra: data.extra + extra: objectKeyToUnderscore(data.extra) } ) } catch (e) { From 158cea463738c5b49620c6a58a99c3602324fac1 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 10:35:31 +0900 Subject: [PATCH 085/109] =?UTF-8?q?extra=20=EA=B0=92=20underscore=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bootpay.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootpay.ts b/src/bootpay.ts index f00d368..169f421 100644 --- a/src/bootpay.ts +++ b/src/bootpay.ts @@ -448,7 +448,7 @@ class BootpayRestClient extends BootpaySingleton { user_info: objectKeyToUnderscore(data.userInfo), items: objectKeyToUnderscore(data.items), return_url: data.returnUrl, - extra: data.extra + extra: objectKeyToUnderscore(data.extra) } ) } catch (e) { From 0a6b7f311438965b564a1dc700669e2c5e72caf0 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 11:12:50 +0900 Subject: [PATCH 086/109] readme add github directly case --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index dddb127..2794651 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,18 @@ RestClient.getAccessToken().then( ### 더 자세한 정보는 [Docs](https://docs.bootpay.co.kr/api/validate?languageCurrentIndex=2)를 참조해주세요.  ``` ### github으로 바로 다운 받은 경우 + +먼저 패키지를 모두 설치합니다 +```bash +yarn install +``` + +이후 빌드를 해서 dist로 js로 컴파일 합니다. +```bash +npm run build +``` + +그리고 dist로 output 된 패키지를 상대 경로로 가져와서 사용합니다. ```nodejs const RestClient = require('./dist/bootpay').RestClient From 4a76a1ffec0b7c40f43b1d82e6da68efb10a6dfa Mon Sep 17 00:00:00 2001 From: Gosomi Date: Wed, 28 Oct 2020 11:13:30 +0900 Subject: [PATCH 087/109] =?UTF-8?q?docs=20=EA=B2=BD=EB=A1=9C=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 2794651..73a24d9 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,6 @@ RestClient.getAccessToken().then( } ) }); - -### 더 자세한 정보는 [Docs](https://docs.bootpay.co.kr/api/validate?languageCurrentIndex=2)를 참조해주세요.  ``` ### github으로 바로 다운 받은 경우 From 4dc8579a625fa0a3018e9c15913583fedf3489b5 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Fri, 30 Oct 2020 08:24:57 +0900 Subject: [PATCH 088/109] =?UTF-8?q?version=201.0.3=20=ED=8D=BC=EB=B8=94?= =?UTF-8?q?=EB=A6=AC=EC=8B=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9a05741..478bcb0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bootpay/server-rest-client", - "version": "1.0.2", + "version": "1.0.3", "description": "Bootpay Server Rest Client Javasrcipt Library", "main": "dist/bootpay.js", "types": "dist/bootpay.d.ts", From b333f5745a896370f525a169dcfe344f306bd6aa Mon Sep 17 00:00:00 2001 From: Gosomi Date: Fri, 30 Oct 2020 08:26:03 +0900 Subject: [PATCH 089/109] =?UTF-8?q?readme=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 73a24d9..0f7bd47 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # Bootpay Server Rest Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg)](https://www.npmjs.com/package/@bootpay/server-rest-client) -### 1.0.2 ( Stable ) +### 1.0.3 ( Stable ) +* extra를 undeerscore로 보내는 로직 추가 + +### 1.0.2 * item 정보를 underscore로 보내는 로직 추가 * user_info 정보를 underscore로 보내는 로직 추가 From a3a42b77230c7c7bda6c3011f57414ed8023e0ef Mon Sep 17 00:00:00 2001 From: Gosomi Date: Fri, 30 Oct 2020 09:51:22 +0900 Subject: [PATCH 090/109] =?UTF-8?q?isBlank=20object=20=EC=9D=BC=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20=EB=B2=84=EA=B7=B8=20{}=20=EC=B2=B4?= =?UTF-8?q?=ED=81=AC=20=EB=AA=BB=ED=95=98=EB=8A=94=20=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/bootpay/support.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/lib/bootpay/support.ts b/src/lib/bootpay/support.ts index 9290cf4..b803a8a 100644 --- a/src/lib/bootpay/support.ts +++ b/src/lib/bootpay/support.ts @@ -3,6 +3,8 @@ import { BootpaySingleton } from "./singleton" export interface Validate { isBlank(value: any): Boolean + isType(value: any, type: string): Boolean + isPresent(value: any): Boolean presence(value: any, defaultValue: any): any @@ -19,14 +21,18 @@ class ValidateMethod extends BootpaySingleton implements Validate { valid = value.length === 0 } else if (Array.isArray(value)) { valid = value.length === 0 - } else if (typeof value === 'object') { - valid = Object.keys(value).length === 0 } else { - valid = value === undefined || value === null + valid = value === undefined || + value === null || + (this.isType(value, 'object') && value.constructor === Object && Object.keys(value).length === 0) } return valid } + isType(value: any, type: string) { + return (typeof value === type) + } + isPresent(value: any): Boolean { return !this.isBlank(value) } @@ -73,4 +79,5 @@ export const isPresent = (value: any) => ValidClass.isPresent(value) export const isBlank = (value: any) => ValidClass.isBlank(value) export const presence = (value: any, defaultValue: any) => ValidClass.presence(value, defaultValue) export const toUnderscore = (value: any) => ValidClass.toUnderscore(value) -export const objectKeyToUnderscore = (value: any) => ValidClass.objectKeyToUnderscore(value) \ No newline at end of file +export const objectKeyToUnderscore = (value: any) => ValidClass.objectKeyToUnderscore(value) +export const isType = (value: any, type: string) => ValidClass.isType(value, type) \ No newline at end of file From ec0686234adf6b543f3b10844a644ecabb49586b Mon Sep 17 00:00:00 2001 From: Gosomi Date: Fri, 30 Oct 2020 10:12:01 +0900 Subject: [PATCH 091/109] =?UTF-8?q?export=20default=20RestClient=EB=A1=9C?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bootpay.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bootpay.ts b/src/bootpay.ts index 169f421..95fc4d8 100644 --- a/src/bootpay.ts +++ b/src/bootpay.ts @@ -489,4 +489,6 @@ class BootpayRestClient extends BootpaySingleton { } } -export const RestClient = BootpayRestClient.currentInstance() \ No newline at end of file +export const RestClient = BootpayRestClient.currentInstance() + +export default RestClient \ No newline at end of file From c729ee43635a689a02029750a9bd834d39686f37 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Fri, 30 Oct 2020 10:16:28 +0900 Subject: [PATCH 092/109] =?UTF-8?q?1.0.4=20=EB=B0=B0=ED=8F=AC=20=EC=A4=80?= =?UTF-8?q?=EB=B9=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/bootpay.ts | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 478bcb0..3bd231e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bootpay/server-rest-client", - "version": "1.0.3", + "version": "1.0.4", "description": "Bootpay Server Rest Client Javasrcipt Library", "main": "dist/bootpay.js", "types": "dist/bootpay.d.ts", diff --git a/src/bootpay.ts b/src/bootpay.ts index 95fc4d8..169f421 100644 --- a/src/bootpay.ts +++ b/src/bootpay.ts @@ -489,6 +489,4 @@ class BootpayRestClient extends BootpaySingleton { } } -export const RestClient = BootpayRestClient.currentInstance() - -export default RestClient \ No newline at end of file +export const RestClient = BootpayRestClient.currentInstance() \ No newline at end of file From 5eee7726640fc42153541446af8db4c1a4c25bd9 Mon Sep 17 00:00:00 2001 From: Gosomi Date: Fri, 30 Oct 2020 10:17:08 +0900 Subject: [PATCH 093/109] =?UTF-8?q?readme=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f7bd47..63e314d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ # Bootpay Server Rest Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg)](https://www.npmjs.com/package/@bootpay/server-rest-client) +### 1.0.4 ( Nightly ) +isBlank {} 체크 못하는 버그 수정 + ### 1.0.3 ( Stable ) -* extra를 undeerscore로 보내는 로직 추가 +* extra를 underscore로 보내는 로직 추가 ### 1.0.2 * item 정보를 underscore로 보내는 로직 추가 From e0dd4a7678c62b0780ee45005970e6ffb357cb7f Mon Sep 17 00:00:00 2001 From: gosomi Date: Mon, 21 Dec 2020 15:29:40 +0900 Subject: [PATCH 094/109] =?UTF-8?q?name=20->=20itemName=20=EC=98=88?= =?UTF-8?q?=EC=A0=9C=20=EC=BD=94=EB=93=9C=20=EC=98=A4=ED=83=80=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/request_subscribe_rest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/request_subscribe_rest.js b/test/request_subscribe_rest.js index 9c53e09..73ad434 100644 --- a/test/request_subscribe_rest.js +++ b/test/request_subscribe_rest.js @@ -12,7 +12,7 @@ response = await RestClient.requestSubscribeBillingKey({ orderId: (new Date()).getTime(), pg: 'nicepay', - name: '정기결제 30일권', + itemName: '정기결제 30일권', cardNo: '[ 카드 번호 ]', cardPw: '[ 카드 비밀번호 앞 2자리 ]', expireYear: '[ 카드 만료 연도 ]', From 0a5508e04af1917c969a7111ef2465debeb8d0c4 Mon Sep 17 00:00:00 2001 From: gosomi Date: Tue, 19 Jan 2021 12:00:04 +0900 Subject: [PATCH 095/109] =?UTF-8?q?rawData=20=EB=A6=AC=ED=84=B4=20?= =?UTF-8?q?=EB=90=98=EB=8F=84=EB=A1=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bootpay.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bootpay.ts b/src/bootpay.ts index 169f421..dcf75b3 100644 --- a/src/bootpay.ts +++ b/src/bootpay.ts @@ -54,6 +54,7 @@ export interface BootpayRequestSubscribeBillingPaymentData { items?: Array, feedbackUrl?: string, // 결제 완료 후 피드백 받을 URL feedbackContentType?: string // Feedback 받을 경우 content-type - json, urlencoded + extra?: BootpaySubscribeExtraData } export interface BootpayReserveSubscribeBillingData { @@ -107,6 +108,7 @@ export interface BootpayItemData { export interface BootpaySubscribeExtraData { subscribeTestPayment: number + rawData: number } export interface BootpayUserInfoData { @@ -346,7 +348,8 @@ class BootpayRestClient extends BootpaySingleton { items: objectKeyToUnderscore(data.items), user_info: objectKeyToUnderscore(data.userInfo), feedback_url: data.feedbackUrl, - feedback_content_type: data.feedbackContentType + feedback_content_type: data.feedbackContentType, + extra: data.extra } ) } catch (e) { From eb29886e4497a55e66415e17a6365c9070afcc41 Mon Sep 17 00:00:00 2001 From: gosomi Date: Tue, 19 Jan 2021 12:27:04 +0900 Subject: [PATCH 096/109] readme update --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 63e314d..ddd3909 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # Bootpay Server Rest Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg)](https://www.npmjs.com/package/@bootpay/server-rest-client) -### 1.0.4 ( Nightly ) -isBlank {} 체크 못하는 버그 수정 +### 1.0.4 +* isBlank {} 체크 못하는 버그 수정 +* subscribe payment ( 정기결제 ) extra 추가 ### 1.0.3 ( Stable ) * extra를 underscore로 보내는 로직 추가 From d994065125e5b8976fd28201473bd692b7484a59 Mon Sep 17 00:00:00 2001 From: gosomi Date: Tue, 19 Jan 2021 12:32:27 +0900 Subject: [PATCH 097/109] =?UTF-8?q?stable=20version=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- package.json | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ddd3909..efb2d59 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # Bootpay Server Rest Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg)](https://www.npmjs.com/package/@bootpay/server-rest-client) -### 1.0.4 +### 1.0.4 ( Stable ) * isBlank {} 체크 못하는 버그 수정 * subscribe payment ( 정기결제 ) extra 추가 -### 1.0.3 ( Stable ) +### 1.0.3 * extra를 underscore로 보내는 로직 추가 ### 1.0.2 diff --git a/package.json b/package.json index 3bd231e..73d9f5d 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "clear": "tsc --build --clean" }, "dependencies": { - "axios": "^0.21.0" + "axios": "^0.21.0", + "tsc": "^1.20150623.0" }, "devDependencies": { "ts-node": "^9.0.0", From c79c28240836618acf9929d26cf9acb257271d4d Mon Sep 17 00:00:00 2001 From: gosomi Date: Tue, 19 Jan 2021 12:32:54 +0900 Subject: [PATCH 098/109] =?UTF-8?q?tsc=20=EC=9D=98=EC=A1=B4=EC=84=B1=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 73d9f5d..3bd231e 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,7 @@ "clear": "tsc --build --clean" }, "dependencies": { - "axios": "^0.21.0", - "tsc": "^1.20150623.0" + "axios": "^0.21.0" }, "devDependencies": { "ts-node": "^9.0.0", From 6acfd8ee049d4c08679b22789a36546f65b18460 Mon Sep 17 00:00:00 2001 From: gosomi Date: Fri, 7 May 2021 17:18:52 +0900 Subject: [PATCH 099/109] =?UTF-8?q?extra=20rawData=3F=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=20=EA=B8=B0=EB=B3=B8=20undefined=20=ED=97=88=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bootpay.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootpay.ts b/src/bootpay.ts index dcf75b3..67bbc1e 100644 --- a/src/bootpay.ts +++ b/src/bootpay.ts @@ -108,7 +108,7 @@ export interface BootpayItemData { export interface BootpaySubscribeExtraData { subscribeTestPayment: number - rawData: number + rawData?: number } export interface BootpayUserInfoData { From b3ead1796f76ad13530184bb6e569024a57bccb9 Mon Sep 17 00:00:00 2001 From: gosomi Date: Mon, 17 May 2021 14:36:02 +0900 Subject: [PATCH 100/109] =?UTF-8?q?axios=20clone=20interceptor=20=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD=20axios=20clone=20inter?= =?UTF-8?q?ceptor=20test=20code=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 6 ++++-- src/bootpay.ts | 17 +++++++++-------- test/axios_test.js | 22 ++++++++++++++++++++++ 3 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 test/axios_test.js diff --git a/package.json b/package.json index 3bd231e..76fb381 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bootpay/server-rest-client", - "version": "1.0.4", + "version": "1.0.5", "description": "Bootpay Server Rest Client Javasrcipt Library", "main": "dist/bootpay.js", "types": "dist/bootpay.d.ts", @@ -10,7 +10,9 @@ "clear": "tsc --build --clean" }, "dependencies": { - "axios": "^0.21.0" + "axios": "^0.21.0", + "lodash": "^4.17.21", + "@types/lodash": "^4.14.169" }, "devDependencies": { "ts-node": "^9.0.0", diff --git a/src/bootpay.ts b/src/bootpay.ts index 67bbc1e..daaef13 100644 --- a/src/bootpay.ts +++ b/src/bootpay.ts @@ -1,6 +1,7 @@ import { BootpaySingleton } from "./lib/bootpay/singleton" import axios, { AxiosInstance, AxiosResponse, AxiosRequestConfig } from "axios" import { isBlank, isPresent, objectKeyToUnderscore } from "./lib/bootpay/support" +import * as _ from 'lodash' const API_URL: any = { development: 'https://dev-api.bootpay.co.kr', @@ -134,7 +135,7 @@ class BootpayRestClient extends BootpaySingleton { let _this = this this.mode = 'production' this.$token = undefined - this.$http = axios + this.$http = _.cloneDeep(axios) this.$http.interceptors.response.use((response: AxiosResponse): any => { if (isPresent(response.request) && isPresent(response.headers)) { return response.data as BootpayCommonResponse @@ -142,7 +143,7 @@ class BootpayRestClient extends BootpaySingleton { return { code: -100, status: 500, - message: `오류가 발생했습니다. ${response}`, + message: `오류가 발생했습니다. ${ response }`, data: response } as BootpayCommonResponse } @@ -152,7 +153,7 @@ class BootpayRestClient extends BootpaySingleton { } else { return Promise.reject({ code: -100, - message: `통신오류가 발생하였습니다. ${error.message}`, + message: `통신오류가 발생하였습니다. ${ error.message }`, status: 500 }) } @@ -181,7 +182,7 @@ class BootpayRestClient extends BootpaySingleton { this.privateKey = privateKey this.mode = isPresent(mode) ? mode : 'production' if (isBlank(API_URL[this.mode])) { - throw new Error(`환경설정 설정이 잘못되었습니다. 현재 설정된 모드: ${this.mode}, 가능한 모드: development, stage, production`) + throw new Error(`환경설정 설정이 잘못되었습니다. 현재 설정된 모드: ${ this.mode }, 가능한 모드: development, stage, production`) } return } @@ -221,7 +222,7 @@ class BootpayRestClient extends BootpaySingleton { let response: BootpayCommonResponse try { response = await this.$http.get( - this.getApiUrl(`receipt/${receiptId}`) + this.getApiUrl(`receipt/${ receiptId }`) ) } catch (e) { return Promise.reject(e) @@ -317,7 +318,7 @@ class BootpayRestClient extends BootpaySingleton { let response: BootpayCommonResponse try { response = await this.$http.delete( - this.getApiUrl(`subscribe/billing/${billingKey}`) + this.getApiUrl(`subscribe/billing/${ billingKey }`) ) } catch (e) { return Promise.reject(e) @@ -401,7 +402,7 @@ class BootpayRestClient extends BootpaySingleton { let response: BootpayCommonResponse try { response = await this.$http.delete( - this.getApiUrl(`subscribe/billing/reserve/${reserveId}`) + this.getApiUrl(`subscribe/billing/reserve/${ reserveId }`) ) } catch (e) { return Promise.reject(e) @@ -420,7 +421,7 @@ class BootpayRestClient extends BootpaySingleton { let response: BootpayCommonResponse try { response = await this.$http.get( - this.getApiUrl(`certificate/${receiptId}`) + this.getApiUrl(`certificate/${ receiptId }`) ) } catch (e) { return Promise.reject(e) diff --git a/test/axios_test.js b/test/axios_test.js new file mode 100644 index 0000000..d6e4b4a --- /dev/null +++ b/test/axios_test.js @@ -0,0 +1,22 @@ +// import axios from "axios" + +(async () => { + const RestClient = require('../dist/bootpay').RestClient + RestClient.setConfig( + '59bfc738e13f337dbd6ca48a', + 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=', + 'development' + ) + let response = await RestClient.getAccessToken() + // console.log(response) + const axios = require('axios') + try { + response = await axios.post("https://dev-api.bootpay.co.kr/request/token.json", { + application_id: '59bfc738e13f337dbd6ca48a', + private_key: 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' + }) + console.log(response.data) + } catch(e) { + console.log(e.response.data) + } +})() \ No newline at end of file From fb4e21295d9914987d44971cfb7fcec431b01151 Mon Sep 17 00:00:00 2001 From: gosomi Date: Mon, 17 May 2021 15:11:12 +0900 Subject: [PATCH 101/109] =?UTF-8?q?axios=20instance=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=20=ED=9B=84=20interceptor=20=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20=EA=B8=B0=EC=A1=B4=20clone=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=EB=8A=94=20=EB=AA=A8=EB=91=90=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 +--- src/bootpay.ts | 14 +++++++------- test/axios_test.js | 3 +-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 76fb381..d16127b 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,7 @@ "clear": "tsc --build --clean" }, "dependencies": { - "axios": "^0.21.0", - "lodash": "^4.17.21", - "@types/lodash": "^4.14.169" + "axios": "^0.21.1" }, "devDependencies": { "ts-node": "^9.0.0", diff --git a/src/bootpay.ts b/src/bootpay.ts index daaef13..664893c 100644 --- a/src/bootpay.ts +++ b/src/bootpay.ts @@ -1,7 +1,6 @@ import { BootpaySingleton } from "./lib/bootpay/singleton" import axios, { AxiosInstance, AxiosResponse, AxiosRequestConfig } from "axios" import { isBlank, isPresent, objectKeyToUnderscore } from "./lib/bootpay/support" -import * as _ from 'lodash' const API_URL: any = { development: 'https://dev-api.bootpay.co.kr', @@ -132,10 +131,11 @@ class BootpayRestClient extends BootpaySingleton { constructor() { super() - let _this = this this.mode = 'production' this.$token = undefined - this.$http = _.cloneDeep(axios) + this.$http = axios.create({ + timeout: 60000 + }) this.$http.interceptors.response.use((response: AxiosResponse): any => { if (isPresent(response.request) && isPresent(response.headers)) { return response.data as BootpayCommonResponse @@ -159,15 +159,15 @@ class BootpayRestClient extends BootpaySingleton { } }) this.$http.interceptors.request.use((config: AxiosRequestConfig) => { - if (isPresent(_this.$token)) { - config.headers.authorization = _this.$token + if (isPresent(this.$token)) { + config.headers.authorization = this.$token } + config.headers['Content-Type'] = 'application/json' + config.headers['Accept'] = 'application/json' return config }, (error) => { return Promise.reject(error) }) - this.$http.defaults.headers.common['Content-Type'] = 'application/json' - this.$http.defaults.headers.common['Accept'] = 'application/json' } /** diff --git a/test/axios_test.js b/test/axios_test.js index d6e4b4a..52880d4 100644 --- a/test/axios_test.js +++ b/test/axios_test.js @@ -1,4 +1,3 @@ -// import axios from "axios" (async () => { const RestClient = require('../dist/bootpay').RestClient @@ -15,7 +14,7 @@ application_id: '59bfc738e13f337dbd6ca48a', private_key: 'pDc0NwlkEX3aSaHTp/PPL/i8vn5E/CqRChgyEp/gHD0=' }) - console.log(response.data) + console.log(response) } catch(e) { console.log(e.response.data) } From b306bfc27bf3bebb86ad376bf4c95cfc6c17539f Mon Sep 17 00:00:00 2001 From: gosomi Date: Mon, 17 May 2021 15:11:40 +0900 Subject: [PATCH 102/109] =?UTF-8?q?1.0.6=20axios=20instance=20=EB=B0=B0?= =?UTF-8?q?=ED=8F=AC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d16127b..f7b80a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bootpay/server-rest-client", - "version": "1.0.5", + "version": "1.0.6", "description": "Bootpay Server Rest Client Javasrcipt Library", "main": "dist/bootpay.js", "types": "dist/bootpay.d.ts", From 45b8cae502393681e2b507ff82f0ab256cc847a5 Mon Sep 17 00:00:00 2001 From: gosomi Date: Mon, 17 May 2021 15:14:36 +0900 Subject: [PATCH 103/109] =?UTF-8?q?readme=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index efb2d59..c9f4cfa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # Bootpay Server Rest Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg)](https://www.npmjs.com/package/@bootpay/server-rest-client) -### 1.0.4 ( Stable ) +### 1.0.6 ( Stable ) +* axios instance로 생성, interceptor가 global 영향을 받지 않도록 수정 + +### 1.0.4 * isBlank {} 체크 못하는 버그 수정 * subscribe payment ( 정기결제 ) extra 추가 From 96c299bb2e7696ebafb2bc4d03f2e602f67451aa Mon Sep 17 00:00:00 2001 From: gosomi Date: Wed, 9 Jun 2021 14:30:56 +0900 Subject: [PATCH 104/109] =?UTF-8?q?requestPayment=20rest=20api=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=EC=8B=9C=20params=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EC=A0=84=EB=8B=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/bootpay.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index f7b80a1..9f44111 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bootpay/server-rest-client", - "version": "1.0.6", + "version": "1.0.7", "description": "Bootpay Server Rest Client Javasrcipt Library", "main": "dist/bootpay.js", "types": "dist/bootpay.d.ts", diff --git a/src/bootpay.ts b/src/bootpay.ts index 664893c..7d42736 100644 --- a/src/bootpay.ts +++ b/src/bootpay.ts @@ -82,6 +82,7 @@ export interface BootpayRequestPaymentData { taxFree: number, itemName: string, returnUrl?: string, + params: any userInfo?: BootpayUserInfoData, items?: Array, extra?: any @@ -447,6 +448,7 @@ class BootpayRestClient extends BootpaySingleton { methods: data.methods, order_id: data.orderId, price: data.price, + params: data.params, tax_free: data.taxFree, name: data.itemName, user_info: objectKeyToUnderscore(data.userInfo), From 63b4fb707d96219f4ba3ca51ef5d6e493e42984d Mon Sep 17 00:00:00 2001 From: gosomi Date: Wed, 9 Jun 2021 14:33:31 +0900 Subject: [PATCH 105/109] =?UTF-8?q?readme=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index c9f4cfa..4a5b092 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Bootpay Server Rest Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg)](https://www.npmjs.com/package/@bootpay/server-rest-client) +### 1.0.7 ( Stable ) +requestPayment params 데이터를 전달되도록 변경 + ### 1.0.6 ( Stable ) * axios instance로 생성, interceptor가 global 영향을 받지 않도록 수정 From 22e3327e48efa95b812a196b59b342f0d8a2c606 Mon Sep 17 00:00:00 2001 From: gosomi Date: Wed, 9 Jun 2021 14:33:38 +0900 Subject: [PATCH 106/109] =?UTF-8?q?stable=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4a5b092..25d552c 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ### 1.0.7 ( Stable ) requestPayment params 데이터를 전달되도록 변경 -### 1.0.6 ( Stable ) +### 1.0.6 * axios instance로 생성, interceptor가 global 영향을 받지 않도록 수정 ### 1.0.4 From f22d8be5444cc8304d0b2c4a973f86c98d09f763 Mon Sep 17 00:00:00 2001 From: gosomi Date: Wed, 9 Jun 2021 16:12:27 +0900 Subject: [PATCH 107/109] =?UTF-8?q?=EB=B2=84=EC=A0=84=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +++++- package.json | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 25d552c..8607603 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # Bootpay Server Rest Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg)](https://www.npmjs.com/package/@bootpay/server-rest-client) -### 1.0.7 ( Stable ) +### 1.0.8 ( Stable ) +readme 업데이트 +precompile 옵션 변경 + +### 1.0.7 requestPayment params 데이터를 전달되도록 변경 ### 1.0.6 diff --git a/package.json b/package.json index 9f44111..de4673d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bootpay/server-rest-client", - "version": "1.0.7", + "version": "1.0.8", "description": "Bootpay Server Rest Client Javasrcipt Library", "main": "dist/bootpay.js", "types": "dist/bootpay.d.ts", From afce7d4ee1e365f9182f1e56af07b73b0379451c Mon Sep 17 00:00:00 2001 From: gosomi Date: Wed, 8 Jun 2022 13:14:03 +0900 Subject: [PATCH 108/109] =?UTF-8?q?cancel=20tax=20free=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bootpay.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/bootpay.ts b/src/bootpay.ts index 7d42736..60e222d 100644 --- a/src/bootpay.ts +++ b/src/bootpay.ts @@ -16,10 +16,11 @@ export interface BootpayCommonResponse { } export interface BootpayCancelData { - receiptId: string, - price?: number, - name?: string, - reason?: string, + receiptId: string + price?: number + taxFree?: number + name?: string + reason?: string refund?: BootpayRefundData } @@ -266,6 +267,7 @@ class BootpayRestClient extends BootpaySingleton { { receipt_id: data.receiptId, price: data.price, + tax_free: data.taxFree, name: data.name, reason: data.reason, refund: data.refund From 9892c3802cf0525084f673bb97b5524cff4d3ab5 Mon Sep 17 00:00:00 2001 From: gosomi Date: Wed, 8 Jun 2022 13:14:46 +0900 Subject: [PATCH 109/109] =?UTF-8?q?readme=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 35 ++++++++++++++++++++++++++--------- package.json | 2 +- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 8607603..e9601a7 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,45 @@ # Bootpay Server Rest Client [![alt text](https://cdn.bootpay.co.kr/icon/npm.svg)](https://www.npmjs.com/package/@bootpay/server-rest-client) -### 1.0.8 ( Stable ) -readme 업데이트 +### 1.0.9 ( Stable ) + +* 결제 취소시 taxFree 값 추가 + +### 1.0.8 + +readme 업데이트 precompile 옵션 변경 -### 1.0.7 +### 1.0.7 + requestPayment params 데이터를 전달되도록 변경 ### 1.0.6 + * axios instance로 생성, interceptor가 global 영향을 받지 않도록 수정 -### 1.0.4 +### 1.0.4 + * isBlank {} 체크 못하는 버그 수정 * subscribe payment ( 정기결제 ) extra 추가 -### 1.0.3 +### 1.0.3 + * extra를 underscore로 보내는 로직 추가 -### 1.0.2 +### 1.0.2 + * item 정보를 underscore로 보내는 로직 추가 -* user_info 정보를 underscore로 보내는 로직 추가 +* user_info 정보를 underscore로 보내는 로직 추가 + +### 1.0.0 -### 1.0.0 * typescript로 코딩이 되어있습니다 * d.ts 파일이 첨부되어 typescript로도 코딩이 가능합니다. -## 샘플 코드 +## 샘플 코드 + ### NPM으로 다운 받은 경우 + ```nodejs const RestClient = require('@bootpay/server-rest-client').RestClient @@ -48,19 +61,23 @@ RestClient.getAccessToken().then( ) }); ``` + ### github으로 바로 다운 받은 경우 먼저 패키지를 모두 설치합니다 + ```bash yarn install ``` 이후 빌드를 해서 dist로 js로 컴파일 합니다. + ```bash npm run build ``` 그리고 dist로 output 된 패키지를 상대 경로로 가져와서 사용합니다. + ```nodejs const RestClient = require('./dist/bootpay').RestClient diff --git a/package.json b/package.json index de4673d..03c8bc0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bootpay/server-rest-client", - "version": "1.0.8", + "version": "1.0.9", "description": "Bootpay Server Rest Client Javasrcipt Library", "main": "dist/bootpay.js", "types": "dist/bootpay.d.ts",