From 9bd15650b7f589b727f9107c12f91b270ace9fbd Mon Sep 17 00:00:00 2001 From: Yu Long Date: Mon, 27 Nov 2023 17:34:51 +0100 Subject: [PATCH 1/4] fix(redirect): collect browserInfo --- packages/lib/src/components/Redirect/Redirect.tsx | 8 +++++++- packages/playground/src/config/commonConfig.js | 2 +- packages/playground/src/pages/Dropin/manual.js | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/lib/src/components/Redirect/Redirect.tsx b/packages/lib/src/components/Redirect/Redirect.tsx index 05b74e93f9..c55d38a810 100644 --- a/packages/lib/src/components/Redirect/Redirect.tsx +++ b/packages/lib/src/components/Redirect/Redirect.tsx @@ -4,6 +4,7 @@ import UIElement from '../UIElement'; import CoreProvider from '../../core/Context/CoreProvider'; import RedirectShopper from './components/RedirectShopper'; import RedirectButton from '../internal/RedirectButton'; +import collectBrowserInfo from '../../utils/browserInfo'; /** * RedirectElement @@ -30,7 +31,8 @@ class RedirectElement extends UIElement { return { paymentMethod: { type: this.props.type - } + }, + browserInfo: this.browserInfo }; } @@ -45,6 +47,10 @@ class RedirectElement extends UIElement { return this.resources.getImage()(this.props.type); } + get browserInfo() { + return collectBrowserInfo(); + } + render() { if (this.props.url && this.props.method) { return ; diff --git a/packages/playground/src/config/commonConfig.js b/packages/playground/src/config/commonConfig.js index 8d452b0d51..322773934b 100644 --- a/packages/playground/src/config/commonConfig.js +++ b/packages/playground/src/config/commonConfig.js @@ -18,7 +18,7 @@ export const amount = { export const useSession = urlParams.session !== 'manual'; -export const returnUrl = 'http://localhost:3020/result'; +export const returnUrl = `${window.location.protocol}//localhost:3020/result`; export default { amount, diff --git a/packages/playground/src/pages/Dropin/manual.js b/packages/playground/src/pages/Dropin/manual.js index e9e5ecbf10..974efbca99 100644 --- a/packages/playground/src/pages/Dropin/manual.js +++ b/packages/playground/src/pages/Dropin/manual.js @@ -1,7 +1,7 @@ import AdyenCheckout from '@adyen/adyen-web'; import '@adyen/adyen-web/dist/es/adyen.css'; import { getPaymentMethods, makePayment, checkBalance, createOrder, cancelOrder, makeDetailsCall } from '../../services'; -import { amount, shopperLocale, countryCode, returnUrl } from '../../config/commonConfig'; +import { amount, shopperLocale, countryCode } from '../../config/commonConfig'; import { getSearchParameters } from '../../utils'; export async function initManual() { From b2f70393394ec2c6ee4dfa208079407aca9c74eb Mon Sep 17 00:00:00 2001 From: Yu Long Date: Tue, 28 Nov 2023 09:56:38 +0100 Subject: [PATCH 2/4] test: add unit test --- packages/lib/src/components/Redirect/Redirect.test.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/lib/src/components/Redirect/Redirect.test.tsx b/packages/lib/src/components/Redirect/Redirect.test.tsx index 2d65fcb4e9..d128c00de6 100644 --- a/packages/lib/src/components/Redirect/Redirect.test.tsx +++ b/packages/lib/src/components/Redirect/Redirect.test.tsx @@ -2,6 +2,7 @@ import { mount } from 'enzyme'; import { h } from 'preact'; import Redirect from './Redirect'; import RedirectShopper from './components/RedirectShopper'; +import RedirectElement from './Redirect'; jest.mock('../../utils/detectInIframe', () => { return jest.fn().mockImplementation(() => { @@ -21,6 +22,7 @@ describe('Redirect', () => { test('Accepts a POST redirect status', () => { window.HTMLFormElement.prototype.submit = jest.fn(); + // @ts-ignore ignore const wrapper = mount(); expect(wrapper.find('form')).toHaveLength(1); @@ -32,6 +34,7 @@ describe('Redirect', () => { test('Accepts a POST redirect status, setting target to _top, when the config prop tells it to', () => { window.HTMLFormElement.prototype.submit = jest.fn(); + // @ts-ignore ignore const wrapper = mount(); expect(wrapper.find('form')).toHaveLength(1); @@ -39,4 +42,11 @@ describe('Redirect', () => { setTimeout(() => expect(window.HTMLFormElement.prototype.submit).toHaveBeenCalled(), 0); }); }); + + describe('Redirect formatData', () => { + test('should send browserInfo in the data', () => { + const redirectElement = new RedirectElement({}); + expect(redirectElement.formatData().browserInfo).not.toBeNull(); + }); + }); }); From 4e325547ff017d2710e834be778a2b4831f9c8fb Mon Sep 17 00:00:00 2001 From: Yu Long Date: Tue, 28 Nov 2023 16:11:20 +0100 Subject: [PATCH 3/4] refactor(giropay-redirect): remove formatData override --- packages/lib/src/components/Giropay/Giropay.tsx | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/packages/lib/src/components/Giropay/Giropay.tsx b/packages/lib/src/components/Giropay/Giropay.tsx index bf6fe04f86..31094ae548 100644 --- a/packages/lib/src/components/Giropay/Giropay.tsx +++ b/packages/lib/src/components/Giropay/Giropay.tsx @@ -13,17 +13,6 @@ class GiropayElement extends RedirectElement { }; } - /** - * Formats the component data output - */ - formatData() { - return { - paymentMethod: { - type: GiropayElement.type - } - }; - } - get displayName() { return this.props.name || this.constructor['type']; } From 096ee8b583bf624e5b49b120cc4b9bdfe3192d7e Mon Sep 17 00:00:00 2001 From: Yu Long Date: Tue, 28 Nov 2023 16:27:29 +0100 Subject: [PATCH 4/4] chore: add the changeset --- .changeset/swift-rice-punch.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/swift-rice-punch.md diff --git a/.changeset/swift-rice-punch.md b/.changeset/swift-rice-punch.md new file mode 100644 index 0000000000..4cac281515 --- /dev/null +++ b/.changeset/swift-rice-punch.md @@ -0,0 +1,5 @@ +--- +'@adyen/adyen-web': patch +--- + +Pass the `browserInfo` in the `state.data` for the Redirect payments, in order to fix the mobile web integration for some redirect payments.