From 7d7bd2a4844725f9375e5bc7c67b9c293bf9ce46 Mon Sep 17 00:00:00 2001 From: akswaminathan-pp-dev Date: Thu, 1 Dec 2022 11:15:13 +0530 Subject: [PATCH 1/2] DTPAYETWO-759- Added field accountId for PayPal accounts --- src/Hyperwallet.js | 4 ++-- test/Hyperwallet.spec.js | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Hyperwallet.js b/src/Hyperwallet.js index 8add7bf..16c2d5e 100644 --- a/src/Hyperwallet.js +++ b/src/Hyperwallet.js @@ -1033,8 +1033,8 @@ export default class Hyperwallet { if (!data.transferMethodCurrency) { throw new Error("transferMethodCurrency is required"); } - if (!data.email) { - throw new Error("email is required"); + if (!data.email && !data.accountId) { + throw new Error("email/accountId is required"); } this.client.doPost(`users/${encodeURIComponent(userToken)}/paypal-accounts`, data, {}, callback); } diff --git a/test/Hyperwallet.spec.js b/test/Hyperwallet.spec.js index c46d92b..0770ecc 100644 --- a/test/Hyperwallet.spec.js +++ b/test/Hyperwallet.spec.js @@ -1996,7 +1996,7 @@ describe("Hyperwallet", () => { expect(() => client.createPayPalAccount("test-user-token", { transferMethodCountry: "test-transferMethodCountry", transferMethodCurrency: "test-transferMethodCurrency", - }, callback)).to.throw("email is required"); + }, callback)).to.throw("email/accountId is required"); }); /** @test {Hyperwallet#createPayPalAccount} */ @@ -2015,6 +2015,22 @@ describe("Hyperwallet", () => { email: "email", }, {}, callback); }); + /** @test {Hyperwallet#createPayPalAccount} */ + it("should do post call to PayPal account endpoint with accountId", () => { + const callback = () => null; + client.createPayPalAccount("test-user-token", { + transferMethodCountry: "test-transferMethodCountry", + transferMethodCurrency: "test-transferMethodCurrency", + accountId: "accountId", + }, callback); + + apiClientSpy.should.have.been.calledOnce(); + apiClientSpy.should.have.been.calledWith("users/test-user-token/paypal-accounts", { + transferMethodCountry: "test-transferMethodCountry", + transferMethodCurrency: "test-transferMethodCurrency", + accountId: "accountId", + }, {}, callback); + }); }); /** @test {Hyperwallet#getPayPalAccount} */ From 7a97915447bbfe9cc0833d8092435be6c1b30d92 Mon Sep 17 00:00:00 2001 From: akswaminathan-pp-dev Date: Thu, 1 Dec 2022 11:49:11 +0530 Subject: [PATCH 2/2] DTPAYETWO-759- Updated error message when accountId or email is missing for paypal accounts --- CHANGELOG.md | 5 +++++ src/Hyperwallet.js | 2 +- test/Hyperwallet.spec.js | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4e216b..6a382b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ Changelog ========= +2.1.1 +------------------- +- Added field 'accountId' to PayPal. +- PayPal account creation allowed using field 'accountId' which accepts Email, Phone Number, PayPal PayerID. +- Venmo account creation allowed using field 'accountId' which accepts Email, Phone Number, Venmo Handle, Venmo External ID. 2.1.0 ------------------- diff --git a/src/Hyperwallet.js b/src/Hyperwallet.js index 16c2d5e..998e375 100644 --- a/src/Hyperwallet.js +++ b/src/Hyperwallet.js @@ -1034,7 +1034,7 @@ export default class Hyperwallet { throw new Error("transferMethodCurrency is required"); } if (!data.email && !data.accountId) { - throw new Error("email/accountId is required"); + throw new Error("email or accountId is required"); } this.client.doPost(`users/${encodeURIComponent(userToken)}/paypal-accounts`, data, {}, callback); } diff --git a/test/Hyperwallet.spec.js b/test/Hyperwallet.spec.js index 0770ecc..6c7f23a 100644 --- a/test/Hyperwallet.spec.js +++ b/test/Hyperwallet.spec.js @@ -1996,7 +1996,7 @@ describe("Hyperwallet", () => { expect(() => client.createPayPalAccount("test-user-token", { transferMethodCountry: "test-transferMethodCountry", transferMethodCurrency: "test-transferMethodCurrency", - }, callback)).to.throw("email/accountId is required"); + }, callback)).to.throw("email or accountId is required"); }); /** @test {Hyperwallet#createPayPalAccount} */