Skip to content

Commit

Permalink
DTPAYETWO-759- Added field accountId for PayPal accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
akswaminathan-pp-dev committed Dec 1, 2022
1 parent 389b782 commit 7d7bd2a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Hyperwallet.js
Expand Up @@ -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);
}
Expand Down
18 changes: 17 additions & 1 deletion test/Hyperwallet.spec.js
Expand Up @@ -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} */
Expand All @@ -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} */
Expand Down

0 comments on commit 7d7bd2a

Please sign in to comment.