-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding the google pay express enable/disable option and rendering it …
…in cart and minicart (#1190) * feat: adding the google pay express enable/disable option for cart,minicart and pdp * feat: enabling google pay on cart/minicart * chore: linting * chore: css fix * chore: skipping klarna success test due to flakiness * chore: skipping ideal flaky test * chore: testing force:true if it solves flakiness * chore: reverting the force:true and skipping the other klarna,ideal flaky tests
- Loading branch information
Showing
14 changed files
with
135 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/cartridges/app_adyen_SFRA/cartridge/client/default/js/googlePayExpress.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
const { | ||
checkIfExpressMethodsAreReady, | ||
updateLoadedExpressMethods, | ||
getPaymentMethods, | ||
} = require('./commons'); | ||
const { GOOGLE_PAY } = require('./constants'); | ||
|
||
let checkout; | ||
let paymentMethodsResponse; | ||
|
||
async function initializeCheckout() { | ||
const paymentMethods = await getPaymentMethods(); | ||
paymentMethodsResponse = await paymentMethods.json(); | ||
const applicationInfo = paymentMethodsResponse?.applicationInfo; | ||
checkout = await AdyenCheckout({ | ||
environment: window.environment, | ||
clientKey: window.clientKey, | ||
locale: window.locale, | ||
analytics: { | ||
analyticsData: { applicationInfo }, | ||
}, | ||
}); | ||
} | ||
|
||
async function init() { | ||
initializeCheckout() | ||
.then(async () => { | ||
const googlePayPaymentMethod = | ||
paymentMethodsResponse?.AdyenPaymentMethods?.paymentMethods.find( | ||
(pm) => pm.type === GOOGLE_PAY, | ||
); | ||
if (!googlePayPaymentMethod) { | ||
updateLoadedExpressMethods(GOOGLE_PAY); | ||
checkIfExpressMethodsAreReady(); | ||
return; | ||
} | ||
|
||
const googlePayConfig = googlePayPaymentMethod.configuration; | ||
const googlePayButtonConfig = { | ||
showPayButton: true, | ||
buttonType: 'buy', | ||
configuration: googlePayConfig, | ||
returnUrl: window.returnUrl, | ||
isExpress: true, | ||
}; | ||
|
||
const googlePayButton = checkout.create( | ||
GOOGLE_PAY, | ||
googlePayButtonConfig, | ||
); | ||
googlePayButton.mount('#googlepay-container'); | ||
updateLoadedExpressMethods(GOOGLE_PAY); | ||
checkIfExpressMethodsAreReady(); | ||
}) | ||
.catch(() => { | ||
updateLoadedExpressMethods(GOOGLE_PAY); | ||
checkIfExpressMethodsAreReady(); | ||
}); | ||
} | ||
|
||
init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/cartridges/bm_adyen/cartridge/static/default/icons/googlepay.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters