Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Checkout components and add telemetry info #1063

Merged
merged 4 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
};
Loading