Skip to content

Commit

Permalink
Release braintree-web 3.112.1 source
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed Nov 19, 2024
1 parent fdbcd5d commit fd61c46
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 3 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.112.1

- Venmo
- Fix a bug where, after redirecting in the mobile web flow, we were passing in a null context ID to a graphql API call. The fix is to set the Venmo instance's venmoPaymentContextId based on resource_id in url.

## 3.112.0

- Local Payment
Expand Down
4 changes: 2 additions & 2 deletions 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.112.0",
"version": "3.112.1",
"license": "MIT",
"main": "src/index.js",
"private": true,
Expand Down
11 changes: 11 additions & 0 deletions src/lib/url-params.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"use strict";

var querystring = require("./querystring");

function getUrlParams() {
return querystring.parse(window.location.href);
}

module.exports = {
getUrlParams: getUrlParams,
};
6 changes: 6 additions & 0 deletions src/venmo/venmo.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var ExtendedPromise = require("@braintree/extended-promise");
var getVenmoUrl = require("./shared/get-venmo-url");
var desktopWebLogin = require("./shared/web-login-backdrop");
var snakeCaseToCamelCase = require("../lib/snake-case-to-camel-case");
var urlParams = require("../lib/url-params");

// NEXT_MAJOR_VERSION the source code for this is actually in a
// typescript repo called venmo-desktop, once the SDK is migrated
Expand Down Expand Up @@ -503,6 +504,11 @@ Venmo.prototype.hasTokenizationResult = function () {
// when listening on a hashchange event
Venmo.prototype._hasTokenizationResult = function (hash) {
var params = getFragmentParameters(hash);
var paramsFromUrl = urlParams.getUrlParams();

if (paramsFromUrl.resource_id) {
this._venmoPaymentContextId = paramsFromUrl.resource_id;
}

return (
typeof (params.venmoSuccess || params.venmoError || params.venmoCancel) !==
Expand Down
13 changes: 13 additions & 0 deletions test/venmo/unit/venmo.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ jest.mock("../../../src/venmo/shared/supports-venmo");
jest.mock("../../../src/venmo/external");
jest.mock("../../../src/lib/in-iframe");
jest.mock("../../../src/venmo/shared/web-login-backdrop");
jest.mock("../../../src/lib/url-params");

const analytics = require("../../../src/lib/analytics");
const { fake } = require("../../helpers");
Expand All @@ -23,6 +24,7 @@ const {
setupDesktopWebLogin,
} = require("../../../src/venmo/shared/web-login-backdrop");
const venmoConstants = require("../../../src/venmo/shared/constants");
const urlParams = require("../../../src/lib/url-params");

function triggerVisibilityHandler(instance, runAllTimers = true) {
// TODO we should have it trigger the actual
Expand Down Expand Up @@ -55,6 +57,7 @@ describe("Venmo", () => {
beforeAll(() => {
window.open = jest.fn();
originalLocationHref = window.location.href;
urlParams.getUrlParams.mockReturnValue({});
});

beforeEach(() => {
Expand Down Expand Up @@ -2008,6 +2011,16 @@ describe("Venmo", () => {
it("returns false when URL has no Venmo payload", () => {
expect(venmo.hasTokenizationResult()).toBe(false);
});

it("sets the _venmoPaymentContextId from the resource_id", () => {
urlParams.getUrlParams.mockReturnValue({
resource_id: "test-resource-id", // eslint-disable-line camelcase
});

venmo.hasTokenizationResult();

expect(venmo._venmoPaymentContextId).toBe("test-resource-id");
});
});

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

0 comments on commit fd61c46

Please sign in to comment.