From 1b9e9ab2669291353b35e457f006d7b2372a819e Mon Sep 17 00:00:00 2001 From: Eki Bagas Date: Wed, 17 Nov 2021 10:07:11 +0700 Subject: [PATCH] Adding qr_code metadata --- examples/with_async/qr_code.js | 3 +++ examples/with_promises/qr_code.js | 3 +++ integration_test/qr_code.test.js | 3 +++ src/qr_code/qr_code.d.ts | 1 + src/qr_code/qr_code.js | 1 + test/qr_code/constants.js | 2 ++ 6 files changed, 13 insertions(+) diff --git a/examples/with_async/qr_code.js b/examples/with_async/qr_code.js index 00478e6..5f7e5d9 100644 --- a/examples/with_async/qr_code.js +++ b/examples/with_async/qr_code.js @@ -10,6 +10,9 @@ const q = new QrCode({}); type: QrCode.Type.Dynamic, callbackURL: 'https://httpstat.us/200', amount: 10000, + metadata: { + meta2: 'data2', + }, }); console.log('created QR code', qrcode); // eslint-disable-line no-console diff --git a/examples/with_promises/qr_code.js b/examples/with_promises/qr_code.js index 633b1d4..ab8118e 100644 --- a/examples/with_promises/qr_code.js +++ b/examples/with_promises/qr_code.js @@ -8,6 +8,9 @@ q.createCode({ type: QrCode.Type.Dynamic, callbackURL: 'https://httpstat.us/200', amount: 10000, + metadata: { + meta2: 'data2', + }, }) .then(r => { console.log('created QR code', r); // eslint-disable-line no-console diff --git a/integration_test/qr_code.test.js b/integration_test/qr_code.test.js index 11c1002..50be4a3 100644 --- a/integration_test/qr_code.test.js +++ b/integration_test/qr_code.test.js @@ -10,6 +10,9 @@ module.exports = function() { type: QrCode.Type.Dynamic, callbackURL: 'https://httpstat.us/200', amount: 10000, + metadata: { + meta2: 'data2', + }, }) .then(r => q.getCode({ externalID: r.external_id })) .then(r => diff --git a/src/qr_code/qr_code.d.ts b/src/qr_code/qr_code.d.ts index fc171da..98f05be 100644 --- a/src/qr_code/qr_code.d.ts +++ b/src/qr_code/qr_code.d.ts @@ -19,6 +19,7 @@ export = class QrCode { type: QrCodeTypes; callbackURL: string; amount?: number; + metadata?: object; }): Promise; getCode(data: { externalID: string }): Promise; getPayments(data: { diff --git a/src/qr_code/qr_code.js b/src/qr_code/qr_code.js index 13b4443..3143fd7 100644 --- a/src/qr_code/qr_code.js +++ b/src/qr_code/qr_code.js @@ -41,6 +41,7 @@ QrCode.prototype.createCode = function(data) { type: data.type, callback_url: data.callbackURL, amount: data.amount, + metadata: data.metadata, }), }) .then(resolve) diff --git a/test/qr_code/constants.js b/test/qr_code/constants.js index 59c1660..e26cad7 100644 --- a/test/qr_code/constants.js +++ b/test/qr_code/constants.js @@ -14,6 +14,7 @@ const VALID_CREATE_CODE_RESPONSE = { merchant_callback_url: CALLBACK_URL, type: TYPE, status: 'ACTIVE', + metadata: null, created: '2020-01-08T18:18:18.661Z', updated: '2020-01-08T18:18:18.661Z', }; @@ -32,6 +33,7 @@ const VALID_PAYMENT = { type: TYPE, }, status: 'COMPLETED', + metadata: null, }; const VALID_PAYMENT_ARRAY = [VALID_PAYMENT, VALID_PAYMENT];