Skip to content

Commit d56a401

Browse files
Feature/dtpayetwo 759 hw parity paypal account dev (#131)
* DTPAYETWO-759- Added field accountId for PayPal accounts * DTPAYETWO-759- Updated error message when accountId or email is missing for paypal accounts
1 parent ca336c8 commit d56a401

3 files changed

Lines changed: 24 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
Changelog
22
=========
3+
2.1.1
4+
-------------------
5+
- Added field 'accountId' to PayPal.
6+
- PayPal account creation allowed using field 'accountId' which accepts Email, Phone Number, PayPal PayerID.
7+
- Venmo account creation allowed using field 'accountId' which accepts Email, Phone Number, Venmo Handle, Venmo External ID.
38

49
2.1.0
510
-------------------

src/Hyperwallet.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,8 +1033,8 @@ export default class Hyperwallet {
10331033
if (!data.transferMethodCurrency) {
10341034
throw new Error("transferMethodCurrency is required");
10351035
}
1036-
if (!data.email) {
1037-
throw new Error("email is required");
1036+
if (!data.email && !data.accountId) {
1037+
throw new Error("email or accountId is required");
10381038
}
10391039
this.client.doPost(`users/${encodeURIComponent(userToken)}/paypal-accounts`, data, {}, callback);
10401040
}

test/Hyperwallet.spec.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1996,7 +1996,7 @@ describe("Hyperwallet", () => {
19961996
expect(() => client.createPayPalAccount("test-user-token", {
19971997
transferMethodCountry: "test-transferMethodCountry",
19981998
transferMethodCurrency: "test-transferMethodCurrency",
1999-
}, callback)).to.throw("email is required");
1999+
}, callback)).to.throw("email or accountId is required");
20002000
});
20012001

20022002
/** @test {Hyperwallet#createPayPalAccount} */
@@ -2015,6 +2015,22 @@ describe("Hyperwallet", () => {
20152015
email: "email",
20162016
}, {}, callback);
20172017
});
2018+
/** @test {Hyperwallet#createPayPalAccount} */
2019+
it("should do post call to PayPal account endpoint with accountId", () => {
2020+
const callback = () => null;
2021+
client.createPayPalAccount("test-user-token", {
2022+
transferMethodCountry: "test-transferMethodCountry",
2023+
transferMethodCurrency: "test-transferMethodCurrency",
2024+
accountId: "accountId",
2025+
}, callback);
2026+
2027+
apiClientSpy.should.have.been.calledOnce();
2028+
apiClientSpy.should.have.been.calledWith("users/test-user-token/paypal-accounts", {
2029+
transferMethodCountry: "test-transferMethodCountry",
2030+
transferMethodCurrency: "test-transferMethodCurrency",
2031+
accountId: "accountId",
2032+
}, {}, callback);
2033+
});
20182034
});
20192035

20202036
/** @test {Hyperwallet#getPayPalAccount} */

0 commit comments

Comments
 (0)