diff --git a/.changeset/mighty-mugs-accept.md b/.changeset/mighty-mugs-accept.md new file mode 100644 index 0000000000..2063535d68 --- /dev/null +++ b/.changeset/mighty-mugs-accept.md @@ -0,0 +1,5 @@ +--- +"@adyen/adyen-web": patch +--- + +Correct the T&C links for Riverty, remove the B2B T&C link, and change the text from 'AfterPay' to 'Riverty'. diff --git a/packages/lib/.stylelintrc.json b/packages/lib/.stylelintrc.json index 146426140c..6bb7db0a0f 100644 --- a/packages/lib/.stylelintrc.json +++ b/packages/lib/.stylelintrc.json @@ -3,6 +3,7 @@ "rules": { "no-descending-specificity": null, "selector-class-pattern": null, - "scss/no-global-function-names": null + "scss/no-global-function-names": null, + "declaration-block-no-redundant-longhand-properties": null } } diff --git a/packages/lib/src/components/AfterPay/AfterPayB2B.tsx b/packages/lib/src/components/AfterPay/AfterPayB2B.tsx index a9d0bef3d5..0d8d0a1314 100644 --- a/packages/lib/src/components/AfterPay/AfterPayB2B.tsx +++ b/packages/lib/src/components/AfterPay/AfterPayB2B.tsx @@ -1,7 +1,5 @@ -import { h } from 'preact'; import OpenInvoiceContainer from '../helpers/OpenInvoiceContainer'; -import ConsentCheckboxLabel from './components/ConsentCheckboxLabel'; -import { AFTERPAY_B2B_CONSENT_URL, ALLOWED_COUNTRIES } from './config'; +import { ALLOWED_COUNTRIES } from './config'; import { OpenInvoiceContainerProps } from '../helpers/OpenInvoiceContainer/OpenInvoiceContainer'; export default class AfterPayB2B extends OpenInvoiceContainer { @@ -21,8 +19,7 @@ export default class AfterPayB2B extends OpenInvoiceContainer { formatProps(props) { return { ...super.formatProps(props), - allowedCountries: props.countryCode ? [props.countryCode] : ALLOWED_COUNTRIES, - consentCheckboxLabel: + allowedCountries: props.countryCode ? [props.countryCode] : ALLOWED_COUNTRIES }; } } diff --git a/packages/lib/src/components/AfterPay/config.ts b/packages/lib/src/components/AfterPay/config.ts index ffe4cacf9c..2b017e6d67 100644 --- a/packages/lib/src/components/AfterPay/config.ts +++ b/packages/lib/src/components/AfterPay/config.ts @@ -1,7 +1,13 @@ -const AFTERPAY_CONSENT_URL_EN = 'https://www.afterpay.nl/en/algemeen/pay-with-afterpay/payment-conditions'; -const AFTERPAY_CONSENT_URL_BE = 'https://www.afterpay.be/be/footer/betalen-met-afterpay/betalingsvoorwaarden'; -const AFTERPAY_CONSENT_URL_NL = 'https://www.afterpay.nl/nl/algemeen/betalen-met-afterpay/betalingsvoorwaarden'; -const AFTERPAY_B2B_CONSENT_URL = 'https://www.afterpay.nl/nl/algemeen/zakelijke-partners/betalingsvoorwaarden-zakelijk'; const ALLOWED_COUNTRIES = ['BE', 'NL']; - -export { AFTERPAY_CONSENT_URL_EN, AFTERPAY_CONSENT_URL_BE, AFTERPAY_CONSENT_URL_NL, AFTERPAY_B2B_CONSENT_URL, ALLOWED_COUNTRIES }; +const rivertyConsentUrlMap = { + be: { + en: 'https://documents.riverty.com/terms_conditions/payment_methods/invoice/be_en', + fr: 'https://documents.riverty.com/terms_conditions/payment_methods/invoice/be_fr', + nl: 'https://documents.riverty.com/terms_conditions/payment_methods/invoice/be_nl' + }, + nl: { + en: 'https://documents.riverty.com/terms_conditions/payment_methods/invoice/nl_en', + nl: 'https://documents.riverty.com/terms_conditions/payment_methods/invoice/nl_nl' + } +}; +export { ALLOWED_COUNTRIES, rivertyConsentUrlMap }; diff --git a/packages/lib/src/components/AfterPay/utils.test.ts b/packages/lib/src/components/AfterPay/utils.test.ts index 337b2405ad..698c569fe0 100644 --- a/packages/lib/src/components/AfterPay/utils.test.ts +++ b/packages/lib/src/components/AfterPay/utils.test.ts @@ -1,21 +1,41 @@ import { getConsentLinkUrl } from './utils'; -import { AFTERPAY_CONSENT_URL_BE, AFTERPAY_CONSENT_URL_EN, AFTERPAY_CONSENT_URL_NL } from './config'; +import { rivertyConsentUrlMap } from './config'; describe('getConsentLinkUrl', () => { - test('returns the english URL if the locale is "en"', () => { - expect(getConsentLinkUrl('', 'en')).toBe(AFTERPAY_CONSENT_URL_EN); - expect(getConsentLinkUrl('', 'EN')).toBe(AFTERPAY_CONSENT_URL_EN); - expect(getConsentLinkUrl('', 'en_US')).toBe(AFTERPAY_CONSENT_URL_EN); - expect(getConsentLinkUrl('', 'en_GB')).toBe(AFTERPAY_CONSENT_URL_EN); + describe('the country code is NL', () => { + test('returns the english URL if the shopper locale is "en"', () => { + expect(getConsentLinkUrl('nl', 'en')).toBe(rivertyConsentUrlMap.nl.en); + }); + test('returns the NL URL if the shopper locale is "nl"', () => { + expect(getConsentLinkUrl('nl', 'nl')).toBe(rivertyConsentUrlMap.nl.nl); + }); }); - - test('returns the english URL if the country code is "BE"', () => { - expect(getConsentLinkUrl('BE', '')).toBe(AFTERPAY_CONSENT_URL_BE); - expect(getConsentLinkUrl('be', '')).toBe(AFTERPAY_CONSENT_URL_BE); + describe('the country code is BE', () => { + test('returns the english URL if the shopper locale is "en"', () => { + expect(getConsentLinkUrl('be', 'en')).toBe(rivertyConsentUrlMap.be.en); + }); + test('returns the NL URL if the shopper locale is "nl"', () => { + expect(getConsentLinkUrl('be', 'nl')).toBe(rivertyConsentUrlMap.be.nl); + }); + test('returns the FR URL if the shopper locale is "fr"', () => { + expect(getConsentLinkUrl('be', 'fr')).toBe(rivertyConsentUrlMap.be.fr); + }); }); - - test('returns the URL for Netherlands otherwise', () => { - expect(getConsentLinkUrl('', '')).toBe(AFTERPAY_CONSENT_URL_NL); - expect(getConsentLinkUrl('es', 'ES')).toBe(AFTERPAY_CONSENT_URL_NL); + describe('no supported country code & locale', () => { + beforeEach(() => { + console.warn = jest.fn(); + }); + test('should give a warning if no country code is provided', () => { + getConsentLinkUrl(undefined, 'en'); + expect(console.warn).toBeCalled(); + }); + test('should give a warning if wrong country code is provided', () => { + getConsentLinkUrl('WRONG', 'en'); + expect(console.warn).toBeCalled(); + }); + test('should give a warning if wrong locale is provided', () => { + getConsentLinkUrl('nl', 'fr'); + expect(console.warn).toBeCalled(); + }); }); }); diff --git a/packages/lib/src/components/AfterPay/utils.ts b/packages/lib/src/components/AfterPay/utils.ts index 65f7fd35ef..3b37dc86b5 100644 --- a/packages/lib/src/components/AfterPay/utils.ts +++ b/packages/lib/src/components/AfterPay/utils.ts @@ -1,10 +1,13 @@ -import { AFTERPAY_CONSENT_URL_BE, AFTERPAY_CONSENT_URL_EN, AFTERPAY_CONSENT_URL_NL } from './config'; +import { rivertyConsentUrlMap } from './config'; function getConsentLinkUrl(countryCode: string, locale: string): string { const languageCode = locale?.toLowerCase().slice(0, 2); - if (languageCode === 'en') return AFTERPAY_CONSENT_URL_EN; - if (countryCode?.toLowerCase() === 'be') return AFTERPAY_CONSENT_URL_BE; - return AFTERPAY_CONSENT_URL_NL; + const consentLink = rivertyConsentUrlMap[countryCode?.toLowerCase()]?.[languageCode]; + if (!consentLink) { + console.warn(`Cannot find a consent url for the provided countryCode: ${countryCode} and locale: ${locale}`); + return; + } + return consentLink; } export { getConsentLinkUrl }; diff --git a/packages/lib/src/components/internal/CompanyDetails/CompanyDetails.tsx b/packages/lib/src/components/internal/CompanyDetails/CompanyDetails.tsx index 6ca8fa56aa..a82f937976 100644 --- a/packages/lib/src/components/internal/CompanyDetails/CompanyDetails.tsx +++ b/packages/lib/src/components/internal/CompanyDetails/CompanyDetails.tsx @@ -64,7 +64,7 @@ export default function CompanyDetails(props: CompanyDetailsProps) { name={generateFieldName('companyName')} >