Skip to content

Commit

Permalink
Release braintree-web 3.105.0 source
Browse files Browse the repository at this point in the history
Co-authored-by: corydavis <[email protected]>
  • Loading branch information
braintreeps and CJGlitter committed Jul 30, 2024
1 parent 9df42af commit 0bb5d5c
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG

# 3.105.0

- PayPal Checkout
- Add client-metadata-id as a data attribute when loading the PayPal SDK
- Google Pay
- Add string conversion for totalPrice

# 3.104.0

- Fastlane
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.104.0",
"version": "3.105.0",
"license": "MIT",
"main": "src/index.js",
"private": true,
Expand Down
6 changes: 6 additions & 0 deletions scripts/release
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ join() {
release_source() {
set +e

local CP_CMD="cp"
if [[ "$(uname)"="Darwin" ]]; then
# Coreutils version of cp supports --parents, mac default one doesn't
CP_CMD="gcp"
fi

git ls-files | egrep -v "$(join '|' $SOURCE_IGNORES)" | xargs cp --parents -t "$BRAINTREE_JS_SOURCE_DEST"
echo -e "Applied source changes in ${BLUE}$BRAINTREE_JS_SOURCE_DEST${RESET}."
exit 0
Expand Down
8 changes: 8 additions & 0 deletions src/google-payment/google-payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@ GooglePayment.prototype._createPaymentDataRequestSyncronously = function (
var createPaymentDataRequestMethod =
CREATE_PAYMENT_DATA_REQUEST_METHODS[version];

if (
paymentDataRequest.transactionInfo &&
paymentDataRequest.transactionInfo.totalPrice
) {
paymentDataRequest.transactionInfo.totalPrice =
paymentDataRequest.transactionInfo.totalPrice.toString();
}

analytics.sendEvent(
this._createPromise,
"google-payment.v" + version + ".createPaymentDataRequest"
Expand Down
5 changes: 5 additions & 0 deletions src/paypal-checkout/paypal-checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,11 @@ PayPalCheckout.prototype.loadPayPalSDK = function (options) {
var userIdToken =
dataAttributes["user-id-token"] || dataAttributes["data-user-id-token"];

if (this._configuration) {
dataAttributes["client-metadata-id"] =
this._configuration.analyticsMetadata.sessionId;
}

if (!userIdToken) {
userIdToken =
this._authorizationInformation.fingerprint &&
Expand Down
25 changes: 25 additions & 0 deletions test/google-payment/unit/google-payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,31 @@ describe("GooglePayment", () => {
});
});

describe("when passing totalPrice values", () => {
it("converts numbers to strings", () => {
return testContext.googlePayment
.createPaymentDataRequest({
transactionInfo: {
totalPrice: 15,
},
})
.then((paymentDataRequest) => {
expect(paymentDataRequest.transactionInfo.totalPrice).toBe("15");
});
});
it("leaves strings unchanged", () => {
return testContext.googlePayment
.createPaymentDataRequest({
transactionInfo: {
totalPrice: "15.00",
},
})
.then((paymentDataRequest) => {
expect(paymentDataRequest.transactionInfo.totalPrice).toBe("15.00");
});
});
});

describe("when using options during instance construction", () => {
it("preserves options in a GooglePayment instance", () => {
const googlePayment = new GooglePayment({
Expand Down
13 changes: 13 additions & 0 deletions test/paypal-checkout/unit/paypal-checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2775,6 +2775,19 @@ describe("PayPalCheckout", () => {
});
});

it("always adds the client-metadata-id data attribute", () => {
const instance = testContext.paypalCheckout;
const promise = instance.loadPayPalSDK();

fakeScript.onload();

return promise.then(() => {
expect(fakeScript.getAttribute("data-client-metadata-id")).toEqual(
expect.any(String)
);
});
});

it("can pass data attributes", () => {
const instance = testContext.paypalCheckout;

Expand Down

0 comments on commit 0bb5d5c

Please sign in to comment.