Skip to content

Commit

Permalink
Release braintree-web 3.108.0 source
Browse files Browse the repository at this point in the history
Co-authored-by: Iris Booker <[email protected]>
  • Loading branch information
braintreeps and Iris Booker committed Sep 19, 2024
1 parent 7fad75a commit d14f5a2
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 7 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# CHANGELOG

## 3.107.1
## 3.108.0

- PayPal
- Support Checkout with Vault on v2 orders API

## 3.107.1

- Hosted Fields
- Fix passing through a sessionId value

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "braintree-web",
"version": "3.107.1",
"version": "3.108.0",
"license": "MIT",
"main": "src/index.js",
"private": true,
Expand Down
6 changes: 2 additions & 4 deletions src/paypal-checkout/paypal-checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ PayPalCheckout.prototype._createPaymentResource = function (options, config) {
var self = this;
var endpoint = "paypal_hermes/" + constants.FLOW_ENDPOINTS[options.flow];

this._flow = options.flow;
delete this.intentFromCreatePayment;

config = config || {};
Expand Down Expand Up @@ -1127,10 +1128,7 @@ PayPalCheckout.prototype.tokenizePayment = function (tokenizeOptions) {
var shouldVault = true;
var payload;
var options = {
flow:
tokenizeOptions.billingToken && !tokenizeOptions.paymentID
? "vault"
: "checkout",
flow: this._flow,
intent: tokenizeOptions.intent || this.intentFromCreatePayment,
};
var params = {
Expand Down
66 changes: 66 additions & 0 deletions test/paypal-checkout/unit/paypal-checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2473,6 +2473,7 @@ describe("PayPalCheckout", () => {

it("validates if flow is vault and auth is not tokenization key", () => {
testContext.configuration.authorizationType = "CLIENT_TOKEN";
testContext.paypalCheckout._flow = "vault";

return testContext.paypalCheckout
.tokenizePayment({ billingToken: "token" })
Expand All @@ -2492,6 +2493,7 @@ describe("PayPalCheckout", () => {

it("does not validate if merchant opts out even when flow is vault and auth is not tokenization key", () => {
testContext.configuration.authorizationType = "CLIENT_TOKEN";
testContext.paypalCheckout._flow = "vault";

return testContext.paypalCheckout
.tokenizePayment({
Expand All @@ -2514,6 +2516,7 @@ describe("PayPalCheckout", () => {

it("does not validate if merchant is using the pay later flow", () => {
testContext.configuration.authorizationType = "CLIENT_TOKEN";
testContext.paypalCheckout._flow = "checkout";

return testContext.paypalCheckout
.tokenizePayment({
Expand All @@ -2536,6 +2539,7 @@ describe("PayPalCheckout", () => {

it("does not validate if flow is vault and auth is tokenization key", () => {
testContext.configuration.authorizationType = "TOKENIZATION_KEY";
testContext.paypalCheckout._flow = "vault";

return testContext.paypalCheckout
.tokenizePayment({ billingToken: "token" })
Expand Down Expand Up @@ -2571,6 +2575,68 @@ describe("PayPalCheckout", () => {
});
}));

it("passes along paymentID as paymentToken when paymentID and billingToken are present and flow is checkout", () => {
testContext.paypalCheckout._flow = "checkout";
testContext.paypalCheckout
.tokenizePayment({
payerID: "payer id",
paymentID: "payment id",
billingToken: "ba token",
})
.then(() => {
expect(testContext.client.request).toHaveBeenCalledTimes(1);
expect(testContext.client.request.mock.calls[0][0]).toMatchObject({
data: {
paypalAccount: {
paymentToken: "payment id",
payerId: "payer id",
},
},
});
});
});

it("passes along orderId as payemntToken when orderId and billingToken are present and flow is checkout", () => {
testContext.paypalCheckout._flow = "checkout";
testContext.paypalCheckout
.tokenizePayment({
payerID: "payer id",
orderID: "order id",
billingToken: "ba token",
})
.then(() => {
expect(testContext.client.request).toHaveBeenCalledTimes(1);
expect(testContext.client.request.mock.calls[0][0]).toMatchObject({
data: {
paypalAccount: {
paymentToken: "order id",
payerId: "payer id",
},
},
});
});
});

it("passes along billingAgreementToken when orderId and billingToken are present and flow is vault", () => {
testContext.paypalCheckout._flow = "vault";
testContext.paypalCheckout
.tokenizePayment({
payerID: "payer id",
orderID: "order id",
billingToken: "ba token",
})
.then(() => {
expect(testContext.client.request).toHaveBeenCalledTimes(1);
expect(testContext.client.request.mock.calls[0][0]).toMatchObject({
data: {
paypalAccount: {
billingAgreementToken: "ba token",
},
},
});
});
});

it("passes along orderId as payemntToken when orderId is present and paymentID is not present", () =>
testContext.paypalCheckout
.tokenizePayment({
Expand Down

0 comments on commit d14f5a2

Please sign in to comment.