Skip to content

Commit

Permalink
Release braintree-web 3.102.0 source
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed May 2, 2024
1 parent f3df759 commit 44bf796
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

# 3.102.0

- PayPal
- Support new `amountBreakdown` and its subfields in the `updatePayment` method

# 3.101.3

- FrameService
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.101.3",
"version": "3.102.0",
"license": "MIT",
"main": "src/index.js",
"private": true,
Expand Down
12 changes: 12 additions & 0 deletions src/paypal-checkout/paypal-checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,14 @@ PayPalCheckout.prototype._createPaymentResource = function (options, config) {
* @param {string} options.currency The currency code of the amount, such as 'USD'. Required when using the Checkout flow.
* @param {shippingOption[]} [options.shippingOptions] List of {@link PayPalCheckout~shippingOption|shipping options} offered by the payee or merchant to the payer to ship or pick up their items.
* @param {lineItem[]} [options.lineItems] The {@link PayPalCheckout~lineItem|line items} for this transaction. It can include up to 249 line items.
* @param {object} [options.amountBreakdown] Optional collection of amounts that break down the total into individual pieces.
* @param {string} [options.amountBreakdown.itemTotal] Optional, item amount
* @param {string} [options.amountBreakdown.shipping] Optional, shipping amount
* @param {string} [options.amountBreakdown.handling] Optional, handling amount
* @param {string} [options.amountBreakdown.taxTotal] Optional, tax amount
* @param {string} [options.amountBreakdown.insurance] Optional, insurance amount
* @param {string} [options.amountBreakdown.shippingDiscount] Optional, shipping discount amount
* @param {string} [options.amountBreakdown.discount] Optional, discount amount
* @param {callback} [callback] The second argument is a PayPal `paymentId` or `billingToken` string, depending on whether `options.flow` is `checkout` or `vault`. This is also what is resolved by the promise if no callback is provided.
* @example
* // this paypal object is created by the PayPal JS SDK
Expand Down Expand Up @@ -1469,6 +1477,10 @@ PayPalCheckout.prototype._formatUpdatePaymentData = function (options) {
paymentResource.shippingOptions = options.shippingOptions;
}

if (options.hasOwnProperty("amountBreakdown")) {
paymentResource.amountBreakdown = options.amountBreakdown;
}

/* shippingAddress not supported yet */
if (options.hasOwnProperty("shippingAddress")) {
analytics.sendEvent(
Expand Down
26 changes: 26 additions & 0 deletions test/paypal-checkout/unit/paypal-checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,32 @@ describe("PayPalCheckout", () => {
expect(formattedData).not.toHaveProperty("recipientName");
});
});

it("propagates amountBreakdown when passed", () => {
const amountBreakdown = {
itemTotal: "12.34",
shipping: "2.99",
handling: "0",
taxTotal: "1.99",
insurance: "0",
shippingDiscount: "0",
discount: "0",
};
const options = {
paymentId: "abc123",
currency: "USD",
amountBreakdown: amountBreakdown,
};
const actual = PayPalCheckout.prototype._formatUpdatePaymentData(options);

expect(actual).toStrictEqual({
paymentId: "abc123",
// eslint-disable-next-line no-undefined
merchantAccountId: undefined,
currencyIsoCode: "USD",
amountBreakdown: amountBreakdown,
});
});
});

describe("startVaultInitiatedCheckout", () => {
Expand Down

0 comments on commit 44bf796

Please sign in to comment.