Skip to content

Commit

Permalink
Merge pull request #3602 from kathuan/swgversion
Browse files Browse the repository at this point in the history
Add swgVersion URL param to Pay URLs
  • Loading branch information
kathuan authored Dec 19, 2024
2 parents 2584e46 + 3d7a73d commit c7369de
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 15 deletions.
15 changes: 8 additions & 7 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
Expand Up @@ -119,7 +119,7 @@
"@storybook/html": "7.6.19",
"@storybook/manager-webpack5": "6.5.16",
"cheerio": "1.0.0-rc.12",
"chromedriver": "129.0.0",
"chromedriver": "131.0.0",
"cookie-parser": "1.4.6",
"hogan-express": "0.5.2",
"is-running": "2.1.0",
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/pages/basicSubscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const commands = {
},
subscribe: function () {
return this.log('Clicking buy button')
.assert.textContains('@buyButton', 'Buy now')
.assert.textContains('@buyButton', 'Subscribe now')
.click('@buyButton');
},
};
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/pages/enterpriseSubscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const commands = {
},
subscribe: function () {
return this.log('Clicking buy button')
.assert.textContains('@buyButton', 'Buy now')
.assert.textContains('@buyButton', 'Subscribe now')
.click('@buyButton');
},
};
Expand Down
35 changes: 30 additions & 5 deletions third_party/gpay/src/payments_web_activity_delegate.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ class PaymentsWebActivityDelegate {
);
const opener = this.activities.open(
GPAY_ACTIVITY_REQUEST,
this.getHostingPageUrl_(),
this.getHostingPageUrl_(this.getSwgVersion_(paymentDataRequest)),
this.getRenderMode_(paymentDataRequest),
paymentDataRequest,
{'width': 600, 'height': 600}
Expand Down Expand Up @@ -436,13 +436,29 @@ class PaymentsWebActivityDelegate {
return url;
}

/**
* Returns the SwG version.
*
* @private
* @param {!PaymentDataRequest} paymentDataRequest
* @return {?string}
*/
getSwgVersion_(paymentDataRequest) {
const swgPaymentRequest = paymentDataRequest['swg'];
if (!swgPaymentRequest) {
return undefined;
}
return swgPaymentRequest['swgVersion'];
}

/**
* Returns the hosting page url.
*
* @private
* @param {?string=} swgVersion SwG version number
* @return {string} The hosting page url
*/
getHostingPageUrl_() {
getHostingPageUrl_(swgVersion) {
// In Tin tests, the hosting page is requested from
// /testing/buyflow/merchantdemo.html and is accessed relatively since the
// base path is unknown ahead of time.
Expand All @@ -451,17 +467,22 @@ class PaymentsWebActivityDelegate {
// http://yaqs/4912322941550592
return '/ui/pay';
}
return this.getBasePath_() + '/ui/pay?swg=true';
let hostingPageBase = this.getBasePath_() + '/ui/pay?swg=true';
if (swgVersion) {
hostingPageBase = hostingPageBase + '&swgVersion=' + swgVersion;
}
return hostingPageBase;
}

/**
* Returns the iframe pwg url to be used to be used for amp.
*
* @param {string} environment
* @param {string} origin
* @param {?string=} swgVersion SwG version number
* @return {string} The iframe url
*/
getIframeUrl(environment, origin) {
getIframeUrl(environment, origin, swgVersion) {
// TODO: These should be compile time constants and not dependent
// on the environment.
let iframeUrl = `https://pay.google.com/gp/p/ui/pay?origin=${origin}&swg=true`;
Expand All @@ -471,6 +492,9 @@ class PaymentsWebActivityDelegate {
) {
iframeUrl = `https://pay'+ (environment == Constants.Environment.PREPROD ? '-preprod' : '')+ '.sandbox.google.com/gp/p/ui/pay?origin=${origin}&swg=true`;
}
if (swgVersion) {
iframeUrl = iframeUrl + '&swgVersion=' + swgVersion;
}
return iframeUrl;
}

Expand Down Expand Up @@ -635,7 +659,8 @@ class PaymentsWebActivityDelegate {
let iframeLoadStartTime;
const trustedUrl = this.getIframeUrl(
this.environment_,
window.location.origin
window.location.origin,
this.getSwgVersion_(paymentDataRequest)
);
return this.activities
.openIframe(iframe, trustedUrl, paymentDataRequest)
Expand Down

0 comments on commit c7369de

Please sign in to comment.