Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/dtpayetwo 759 hw parity paypal account dev #131

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions 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
-------------------
Expand Down
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 or 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 or 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