Skip to content

Commit

Permalink
Upgrade Checkout components and add telemetry info (#1063)
Browse files Browse the repository at this point in the history
  • Loading branch information
zenit2001 committed Apr 5, 2024
1 parent d809507 commit cc5d044
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ const AMAZON_PAY = 'amazonpay';
async function mountAmazonPayComponent() {
try {
const data = await getPaymentMethods();
const paymentMethodsResponse = data.AdyenPaymentMethods;

const paymentMethodsResponse = data?.AdyenPaymentMethods;
const applicationInfo = data?.applicationInfo;
const checkout = await AdyenCheckout({
environment: window.environment,
clientKey: window.clientKey,
locale: window.locale,
analytics: {
analyticsData: { applicationInfo },
},
});

const amazonPayConfig = paymentMethodsResponse?.paymentMethods.find(
Expand All @@ -27,6 +30,7 @@ async function mountAmazonPayComponent() {
productType: 'PayAndShip',
configuration: amazonPayConfig,
returnUrl: window.returnUrl,
isExpress: true,
};

const amazonPayButton = checkout.create(AMAZON_PAY, amazonPayButtonConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,19 @@ function showAddressDetails(shopperDetails) {
}

async function mountAmazonPayComponent() {
const amazonPayNode = document.getElementById('amazon-container');
const checkout = await AdyenCheckout(window.Configuration);

try {
const amazonPayNode = document.getElementById('amazon-container');
const data = await getPaymentMethods();
const paymentMethodsResponse = data.AdyenPaymentMethods;
const paymentMethodsResponse = data?.AdyenPaymentMethods;
const applicationInfo = data?.applicationInfo;
const checkout = await AdyenCheckout({
environment: window.Configuration.environment,
clientKey: window.Configuration.clientKey,
locale: window.Configuration.locale,
analytics: {
analyticsData: { applicationInfo },
},
});
const amazonPayConfig = paymentMethodsResponse?.paymentMethods.find(
(pm) => pm.type === 'amazonpay',
)?.configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ async function initializeCheckout() {
paymentMethodsResponse = await getPaymentMethods();
const shippingMethods = await fetch(window.shippingMethodsUrl);
shippingMethodsData = await shippingMethods.json();
const applicationInfo = paymentMethodsResponse?.applicationInfo;
checkout = await AdyenCheckout({
environment: window.environment,
clientKey: window.clientKey,
locale: window.locale,
analytics: {
analyticsData: { applicationInfo },
},
});
}

Expand Down Expand Up @@ -137,6 +141,7 @@ initializeCheckout()

const applePayButtonConfig = {
showPayButton: true,
isExpress: true,
configuration: applePayConfig,
amount: JSON.parse(window.basketAmount),
requiredShippingContactFields: ['postalAddress', 'email', 'phone'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ describe('getCheckoutPaymentMethods', () => {
},
imagePath: "mocked_loading_contextimages/logos/medium/",
countryCode: "NL",
applicationInfo: {
externalPlatform: {
"version" : "SFRA",
}
}
});
expect(next).toHaveBeenCalled();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function getCheckoutPaymentMethods(req, res, next) {
adyenConnectedTerminals: connectedTerminals,
amount: { value: paymentAmount.value, currency },
countryCode,
applicationInfo: AdyenHelper.getApplicationInfo(),
});
} catch (err) {
AdyenLogs.fatal_log(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ module.exports = {
EXTERNAL_PLATFORM_NAME : 'SalesforceCommerceCloud',
EXTERNAL_PLATFORM_VERSION : 'SFRA',

CHECKOUT_COMPONENT_VERSION: '5.56.0',
CHECKOUT_COMPONENT_VERSION: '5.61.0',
VERSION: '24.1.0',
};

0 comments on commit cc5d044

Please sign in to comment.