diff --git a/assets/css/admin.css b/assets/css/admin.css index dc8c6be7e0a..66865b0a54d 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -81,6 +81,11 @@ background-size: contain; } +.payment-method__brand--ideal { + background: no-repeat url( '../images/payment-methods/ideal.svg' ); + background-size: contain; +} + .payment-method__brand--google-pay { background: no-repeat url( '../images/cards/google-pay.svg' ); background-size: contain; diff --git a/assets/images/payment-methods/ideal.svg b/assets/images/payment-methods/ideal.svg new file mode 100644 index 00000000000..d382023438d --- /dev/null +++ b/assets/images/payment-methods/ideal.svg @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/changelog.txt b/changelog.txt index 22b79b82c9b..becf90f6f86 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,7 @@ *** WooCommerce Payments Changelog *** = 2.9.0 - 2021-xx-xx = +* Add - *Early access*: allow your store to collect payments with iDEAL. Enable the feature in settings! = 2.8.2 - 2021-08-05 = * Fix - If account is disconnected or not set up do not display onboarding task and UPE inbox note. diff --git a/client/additional-methods-setup/methods-selector/add-payment-methods-task.js b/client/additional-methods-setup/methods-selector/add-payment-methods-task.js index e6ec65861e1..4567e96f3aa 100644 --- a/client/additional-methods-setup/methods-selector/add-payment-methods-task.js +++ b/client/additional-methods-setup/methods-selector/add-payment-methods-task.js @@ -231,6 +231,13 @@ const AddPaymentMethodsTask = () => { name="sepa_debit" /> ) } + { availablePaymentMethods.includes( 'ideal' ) && ( + + ) } diff --git a/client/additional-methods-setup/upe-preview-methods-selector/add-payment-methods-task.js b/client/additional-methods-setup/upe-preview-methods-selector/add-payment-methods-task.js index 4df3231a069..c821a84b074 100644 --- a/client/additional-methods-setup/upe-preview-methods-selector/add-payment-methods-task.js +++ b/client/additional-methods-setup/upe-preview-methods-selector/add-payment-methods-task.js @@ -38,7 +38,9 @@ const usePaymentMethodsCheckboxState = () => { // by default, all the checkboxes should be "checked" availablePaymentMethods .filter( ( method ) => - [ 'giropay', 'sofort', 'sepa_debit' ].includes( method ) + [ 'giropay', 'sofort', 'sepa_debit', 'ideal' ].includes( + method + ) ) .reduce( ( map, paymentMethod ) => ( { @@ -234,6 +236,19 @@ const AddPaymentMethodsTask = () => { name="sepa_debit" /> ) } + { availablePaymentMethods.includes( + 'ideal' + ) && ( + + ) } diff --git a/client/additional-methods-setup/upe-preview-methods-selector/test/add-payment-methods-task.test.js b/client/additional-methods-setup/upe-preview-methods-selector/test/add-payment-methods-task.test.js index bf91b2daa3f..c12c9b19b4b 100644 --- a/client/additional-methods-setup/upe-preview-methods-selector/test/add-payment-methods-task.test.js +++ b/client/additional-methods-setup/upe-preview-methods-selector/test/add-payment-methods-task.test.js @@ -47,6 +47,7 @@ describe( 'AddPaymentMethodsTask', () => { 'card', 'giropay', 'sepa_debit', + 'ideal', ] ); useSettings.mockReturnValue( { saveSettings: () => Promise.resolve( true ), @@ -108,6 +109,9 @@ describe( 'AddPaymentMethodsTask', () => { expect( screen.getByRole( 'checkbox', { name: 'giropay' } ) ).toBeChecked(); + expect( + screen.getByRole( 'checkbox', { name: 'iDEAL' } ) + ).toBeChecked(); expect( screen.getByRole( 'checkbox', { name: 'Direct debit payment' } ) ).toBeChecked(); @@ -120,6 +124,7 @@ describe( 'AddPaymentMethodsTask', () => { userEvent.click( screen.getByRole( 'checkbox', { name: 'Direct debit payment' } ) ); + userEvent.click( screen.getByRole( 'checkbox', { name: 'iDEAL' } ) ); // no "euro" text when no elements are checked expect( @@ -157,6 +162,9 @@ describe( 'AddPaymentMethodsTask', () => { expect( screen.getByRole( 'checkbox', { name: 'Direct debit payment' } ) ).toBeChecked(); + expect( + screen.getByRole( 'checkbox', { name: 'iDEAL' } ) + ).toBeChecked(); expect( screen.queryByRole( 'checkbox', { name: /Credit/ } ) ).not.toBeInTheDocument(); @@ -167,6 +175,7 @@ describe( 'AddPaymentMethodsTask', () => { 'card', 'giropay', 'sepa_debit', + 'ideal', ] ); await waitFor( () => expect( setCompletedMock ).toHaveBeenCalledWith( @@ -180,7 +189,7 @@ describe( 'AddPaymentMethodsTask', () => { const setCompletedMock = jest.fn(); const updateEnabledPaymentMethodsMock = jest.fn(); useEnabledPaymentMethodIds.mockReturnValue( [ - [ 'card', 'giropay' ], + [ 'card', 'giropay', 'ideal' ], updateEnabledPaymentMethodsMock, ] ); render( @@ -200,19 +209,24 @@ describe( 'AddPaymentMethodsTask', () => { expect( screen.getByRole( 'checkbox', { name: 'Direct debit payment' } ) ).toBeChecked(); + expect( + screen.getByRole( 'checkbox', { name: 'iDEAL' } ) + ).toBeChecked(); // un-check giropay userEvent.click( screen.getByRole( 'checkbox', { name: 'giropay' } ) ); + // un-check iDEAL + userEvent.click( screen.getByRole( 'checkbox', { name: 'iDEAL' } ) ); userEvent.click( screen.getByText( 'Add payment methods' ) ); - // giropay is removed + // giropay and iDEAL are removed expect( updateEnabledPaymentMethodsMock ).toHaveBeenCalledWith( [ 'card', 'sepa_debit', ] ); await waitFor( () => expect( setCompletedMock ).toHaveBeenCalledWith( - { initialMethods: [ 'card', 'giropay' ] }, + { initialMethods: [ 'card', 'giropay', 'ideal' ] }, 'setup-complete' ) ); diff --git a/client/additional-methods-setup/upe-preview-methods-selector/test/setup-complete-task.test.js b/client/additional-methods-setup/upe-preview-methods-selector/test/setup-complete-task.test.js index bac14ef647a..6dd7c3bd252 100644 --- a/client/additional-methods-setup/upe-preview-methods-selector/test/setup-complete-task.test.js +++ b/client/additional-methods-setup/upe-preview-methods-selector/test/setup-complete-task.test.js @@ -28,7 +28,7 @@ describe( 'SetupComplete', () => { }; useEnabledPaymentMethodIds.mockReturnValue( [ - [ 'card', 'giropay', 'sofort' ], + [ 'card', 'giropay', 'sofort', 'ideal' ], () => null, ] ); } ); @@ -99,7 +99,12 @@ describe( 'SetupComplete', () => { value={ { completedTasks: { 'add-payment-methods': { - initialMethods: [ 'card', 'giropay', 'sofort' ], + initialMethods: [ + 'card', + 'giropay', + 'sofort', + 'ideal', + ], }, }, } } @@ -125,7 +130,12 @@ describe( 'SetupComplete', () => { value={ { completedTasks: { 'add-payment-methods': { - initialMethods: [ 'card', 'giropay', 'sofort' ], + initialMethods: [ + 'card', + 'giropay', + 'sofort', + 'ideal', + ], }, }, } } @@ -169,7 +179,7 @@ describe( 'SetupComplete', () => { it( 'renders setup complete messaging when context value says that more than one payment method has been added', () => { useEnabledPaymentMethodIds.mockReturnValue( [ - [ 'card', 'giropay', 'sofort', 'sepa_debit' ], + [ 'card', 'giropay', 'sofort', 'sepa_debit', 'ideal' ], () => null, ] ); render( @@ -189,7 +199,7 @@ describe( 'SetupComplete', () => { ); expect( screen.getByText( /Setup complete/ ) ).toHaveTextContent( - 'Setup complete! 3 new payment methods are now live on your store!' + 'Setup complete! 4 new payment methods are now live on your store!' ); } ); } ); diff --git a/client/components/currency-information-for-methods/index.js b/client/components/currency-information-for-methods/index.js index be20cf98674..12d4d77c92b 100644 --- a/client/components/currency-information-for-methods/index.js +++ b/client/components/currency-information-for-methods/index.js @@ -29,7 +29,7 @@ const CurrencyInformationForMethods = ( { selectedMethods } ) => { } const enabledMethodsRequiringEuros = selectedMethods.filter( ( method ) => - [ 'giropay', 'sepa_debit', 'sofort' ].includes( method ) + [ 'giropay', 'sepa_debit', 'sofort', 'ideal' ].includes( method ) ); if ( 0 === enabledMethodsRequiringEuros.length ) { diff --git a/client/components/currency-information-for-methods/test/index.test.js b/client/components/currency-information-for-methods/test/index.test.js index f80a6e09a60..12af5dcba98 100644 --- a/client/components/currency-information-for-methods/test/index.test.js +++ b/client/components/currency-information-for-methods/test/index.test.js @@ -46,7 +46,7 @@ describe( 'CurrencyInformationForMethods', () => { const { container } = render( ); @@ -61,7 +61,7 @@ describe( 'CurrencyInformationForMethods', () => { const { container } = render( ); @@ -84,7 +84,7 @@ describe( 'CurrencyInformationForMethods', () => { const { container } = render( ); @@ -118,7 +118,7 @@ describe( 'CurrencyInformationForMethods', () => { render( ); diff --git a/client/components/payment-method-details/index.js b/client/components/payment-method-details/index.js index ba0ed085280..38c218d258c 100755 --- a/client/components/payment-method-details/index.js +++ b/client/components/payment-method-details/index.js @@ -24,6 +24,7 @@ const formatDetails = ( payment ) => { case 'giropay': return { paymentMethod.bank_code }; case 'sofort': + case 'ideal': return (  ••••  diff --git a/client/components/payment-methods-checkboxes/test/index.js b/client/components/payment-methods-checkboxes/test/index.js index f9ee771dd56..e9fa99b5f9c 100644 --- a/client/components/payment-methods-checkboxes/test/index.js +++ b/client/components/payment-methods-checkboxes/test/index.js @@ -33,6 +33,11 @@ describe( 'PaymentMethodsCheckboxes', () => { checked={ false } name="giropay" /> + ); @@ -40,20 +45,24 @@ describe( 'PaymentMethodsCheckboxes', () => { const sepa = within( paymentMethods[ 0 ] ); const sofort = within( paymentMethods[ 1 ] ); const giropay = within( paymentMethods[ 2 ] ); + const ideal = within( paymentMethods[ 3 ] ); expect( sepa.getByRole( 'checkbox' ) ).toBeChecked(); expect( sofort.getByRole( 'checkbox' ) ).not.toBeChecked(); expect( giropay.getByRole( 'checkbox' ) ).not.toBeChecked(); + expect( ideal.getByRole( 'checkbox' ) ).not.toBeChecked(); userEvent.click( sepa.getByRole( 'checkbox' ) ); userEvent.click( giropay.getByRole( 'checkbox' ) ); + userEvent.click( ideal.getByRole( 'checkbox' ) ); - expect( handleChange ).toHaveBeenCalledTimes( 2 ); + expect( handleChange ).toHaveBeenCalledTimes( 3 ); expect( handleChange ).toHaveBeenNthCalledWith( 1, 'sepa_debit', false ); expect( handleChange ).toHaveBeenNthCalledWith( 2, 'giropay', true ); + expect( handleChange ).toHaveBeenNthCalledWith( 3, 'ideal', true ); } ); } ); diff --git a/client/gateway-icons/ideal.js b/client/gateway-icons/ideal.js new file mode 100644 index 00000000000..370fc1ed4c8 --- /dev/null +++ b/client/gateway-icons/ideal.js @@ -0,0 +1,36 @@ +/* eslint-disable max-len */ +/** + * External dependencies + */ +import React from 'react'; + +export default ( props ) => ( + + + + + + + + + + + +); diff --git a/client/payment-details/payment-method/ideal/index.js b/client/payment-details/payment-method/ideal/index.js new file mode 100644 index 00000000000..0d29cac811b --- /dev/null +++ b/client/payment-details/payment-method/ideal/index.js @@ -0,0 +1,150 @@ +/** @format **/ + +/** + * External dependencies + */ +import { __ } from '@wordpress/i18n'; + +/** + * Internal dependencies. + */ +import PaymentDetailsPaymentMethodDetail from '../detail'; + +/** + * Extracts and formats payment method details from a charge. + * + * @param {Object} charge The charge object. + * @return {Object} A flat hash of all necessary values. + */ +const formatPaymentMethodDetails = ( charge ) => { + const { billing_details: billingDetails, payment_method: id } = charge; + + const { + bank: bankName, + bic, + country: countryCode, + iban_last4: last4, + verified_name: verifiedName, + } = charge.payment_method_details.ideal; + + const { name, email, formatted_address: formattedAddress } = billingDetails; + // Use the full country name. + const country = wcSettings.countries[ countryCode ]; + + return { + bankName, + bic, + last4, + verifiedName, + id, + name, + email, + country, + formattedAddress, + }; +}; + +/** + * Placeholders to display while loading. + */ +const paymentMethodPlaceholders = { + id: 'id placeholder', + bankName: 'bank name placeholder', + bic: 'bic placeholder', + last4: '0000', + verifiedName: 'verified name placeholder', + name: 'name placeholder', + email: 'email placeholder', + formattedAddress: 'address placeholder', + country: 'country placeholder', +}; + +const IdealDetails = ( { charge = {}, isLoading } ) => { + const details = charge.payment_method_details + ? formatPaymentMethodDetails( charge ) + : paymentMethodPlaceholders; + + const { + bankName, + bic, + last4, + verifiedName, + id, + name, + email, + formattedAddress, + } = details; + + // Shorthand for more readable code. + const Detail = PaymentDetailsPaymentMethodDetail; + + return ( +
+
+ + { id } + + + + { bankName } + + + + { bic } + + + + •••• { last4 } + +
+ +
+ + { verifiedName } + + + + { name } + + + + { email } + + + + + +
+
+ ); +}; + +export default IdealDetails; diff --git a/client/payment-details/payment-method/index.js b/client/payment-details/payment-method/index.js index 831dda046fe..f392c53dff3 100644 --- a/client/payment-details/payment-method/index.js +++ b/client/payment-details/payment-method/index.js @@ -15,6 +15,7 @@ import CardPresentDetails from './card-present'; import GiropayDetails from './giropay'; import SepaDetails from './sepa'; import SofortDetails from './sofort'; +import IdealDetails from './ideal'; const detailsComponentMap = { card: CardDetails, @@ -22,6 +23,7 @@ const detailsComponentMap = { giropay: GiropayDetails, sepa_debit: SepaDetails, sofort: SofortDetails, + ideal: IdealDetails, }; const PaymentDetailsPaymentMethod = ( { charge = {}, isLoading } ) => { diff --git a/client/payment-methods-map.js b/client/payment-methods-map.js index 996874d4d12..72241277af3 100644 --- a/client/payment-methods-map.js +++ b/client/payment-methods-map.js @@ -10,6 +10,7 @@ import CreditCardIcon from './gateway-icons/credit-card'; import GiropayIcon from './gateway-icons/giropay'; import SofortIcon from './gateway-icons/sofort'; import SepaIcon from './gateway-icons/sepa'; +import IdealIcon from './gateway-icons/ideal'; export default { card: { @@ -48,4 +49,13 @@ export default { ), Icon: SepaIcon, }, + ideal: { + id: 'ideal', + label: __( 'iDEAL', 'woocommerce-payments' ), + description: __( + 'Expand your business with iDEAL — Netherlands’s most popular payment method.', + 'woocommerce-payments' + ), + Icon: IdealIcon, + }, }; diff --git a/client/payment-methods/test/index.js b/client/payment-methods/test/index.js index 6f003a5c697..3dc5231f76c 100644 --- a/client/payment-methods/test/index.js +++ b/client/payment-methods/test/index.js @@ -34,6 +34,7 @@ describe( 'PaymentMethods', () => { 'giropay', 'sofort', 'sepa_debit', + 'ideal', ] ); } ); @@ -106,7 +107,8 @@ describe( 'PaymentMethods', () => { const giropay = screen.getByLabelText( 'giropay' ); const sofort = screen.getByLabelText( 'Sofort' ); - [ giropay, sofort ].forEach( ( method ) => { + const ideal = screen.getByLabelText( 'iDEAL' ); + [ giropay, sofort, ideal ].forEach( ( method ) => { expect( method.closest( 'ul' ) ).toHaveClass( 'payment-methods__available-methods' ); @@ -150,7 +152,7 @@ describe( 'PaymentMethods', () => { test( 'clicking delete updates enabled method IDs', () => { const updateEnabledMethodsMock = jest.fn( () => {} ); useEnabledPaymentMethodIds.mockReturnValue( [ - [ 'card', 'sepa_debit', 'giropay', 'sofort' ], + [ 'card', 'sepa_debit', 'giropay', 'sofort', 'ideal' ], updateEnabledMethodsMock, ] ); @@ -174,6 +176,7 @@ describe( 'PaymentMethods', () => { 'sepa_debit', 'giropay', 'sofort', + 'ideal', ] ); } ); diff --git a/client/settings/payment-method-icon/test/index.js b/client/settings/payment-method-icon/test/index.js index ae51fdd08aa..7b1505bf941 100644 --- a/client/settings/payment-method-icon/test/index.js +++ b/client/settings/payment-method-icon/test/index.js @@ -21,11 +21,16 @@ describe( 'PaymentMethodIcon', () => { expect( container.querySelector( 'svg' ) ).toBeInTheDocument(); } ); - test( 'renders giropay payment method icon', () => { + test( 'renders sofort payment method icon', () => { const { container } = render( ); expect( container.querySelector( 'svg' ) ).toBeInTheDocument(); } ); + test( 'renders iDEAL payment method icon', () => { + const { container } = render( ); + expect( container.querySelector( 'svg' ) ).toBeInTheDocument(); + } ); + test( 'renders giropay payment method icon and label', () => { render( ); @@ -40,12 +45,20 @@ describe( 'PaymentMethodIcon', () => { expect( label ).toBeInTheDocument(); } ); - test( 'renders giropay payment method icon and label', () => { + test( 'renders sofort payment method icon and label', () => { render( ); const label = screen.queryByText( 'Sofort' ); expect( label ).toBeInTheDocument(); } ); + + test( 'renders iDEAL payment method icon and label', () => { + render( ); + + const label = screen.queryByText( 'iDEAL' ); + expect( label ).toBeInTheDocument(); + } ); + test( 'renders nothing when using an invalid icon name', () => { const { container } = render( ); diff --git a/client/settings/payment-methods-selector/test/index.js b/client/settings/payment-methods-selector/test/index.js index 934ac41a43e..4caa3f287d1 100644 --- a/client/settings/payment-methods-selector/test/index.js +++ b/client/settings/payment-methods-selector/test/index.js @@ -30,6 +30,7 @@ describe( 'PaymentMethodsSelector', () => { 'giropay', 'sofort', 'sepa_debit', + 'ideal', ] ); } ); @@ -74,7 +75,7 @@ describe( 'PaymentMethodsSelector', () => { ).toBeInTheDocument(); const paymentMethods = screen.getAllByRole( 'listitem' ); - expect( paymentMethods ).toHaveLength( 3 ); + expect( paymentMethods ).toHaveLength( 4 ); const giroPayCheckbox = screen.getByRole( 'checkbox', { name: 'giropay', @@ -91,6 +92,11 @@ describe( 'PaymentMethodsSelector', () => { } ); expect( sepaCheckbox ).not.toBeChecked(); + const idealCheckbox = screen.getByRole( 'checkbox', { + name: 'iDEAL', + } ); + expect( idealCheckbox ).not.toBeChecked(); + expect( screen.getByRole( 'button', { name: 'Add selected', @@ -136,10 +142,13 @@ describe( 'PaymentMethodsSelector', () => { user.click( addPaymentMethodButton ); const paymentMethods = screen.getAllByRole( 'listitem' ); - expect( paymentMethods ).toHaveLength( 2 ); + expect( paymentMethods ).toHaveLength( 3 ); expect( screen.queryByRole( 'checkbox', { name: 'Sofort' } ) ).toBeNull(); + expect( + screen.queryByRole( 'checkbox', { name: 'iDEAL' } ) + ).not.toBeNull(); } ); test( 'Selecting payment methods does not update enabled payment methods', () => { @@ -224,6 +233,11 @@ describe( 'PaymentMethodsSelector', () => { } ); user.click( giroPayCheckbox ); + const idealCheckbox = screen.getByRole( 'checkbox', { + name: 'iDEAL', + } ); + user.click( idealCheckbox ); + const addSelectedButton = screen.getByRole( 'button', { name: 'Add selected', } ); @@ -232,6 +246,7 @@ describe( 'PaymentMethodsSelector', () => { 'card', 'sepa_debit', 'giropay', + 'ideal', ] ); expect( screen.queryByRole( 'button', { diff --git a/includes/class-wc-payments.php b/includes/class-wc-payments.php index 9310565268f..a4c9c0dec2e 100644 --- a/includes/class-wc-payments.php +++ b/includes/class-wc-payments.php @@ -20,6 +20,7 @@ use WCPay\Payment_Methods\Sofort_Payment_Gateway; use WCPay\Payment_Methods\Sofort_Payment_Method; use WCPay\Payment_Methods\UPE_Payment_Gateway; +use WCPay\Payment_Methods\Ideal_Payment_Method; /** * Main class for the WooCommerce Payments extension. Its responsibility is to initialize the extension. @@ -182,6 +183,7 @@ public static function init() { include_once __DIR__ . '/payment-methods/class-cc-payment-method.php'; include_once __DIR__ . '/payment-methods/class-giropay-payment-method.php'; include_once __DIR__ . '/payment-methods/class-sofort-payment-method.php'; + include_once __DIR__ . '/payment-methods/class-ideal-payment-method.php'; include_once __DIR__ . '/class-wc-payment-token-wcpay-sepa.php'; include_once __DIR__ . '/class-wc-payments-token-service.php'; include_once __DIR__ . '/class-wc-payments-payment-request-button-handler.php'; @@ -230,6 +232,7 @@ public static function init() { CC_Payment_Method::class, Giropay_Payment_Method::class, Sofort_Payment_Method::class, + Ideal_Payment_Method::class, ]; foreach ( $payment_method_classes as $payment_method_class ) { $payment_method = new $payment_method_class( self::$token_service ); diff --git a/includes/multi-currency/PaymentMethodsCompatibility.php b/includes/multi-currency/PaymentMethodsCompatibility.php index 64e324a5414..0b3753f6fa7 100644 --- a/includes/multi-currency/PaymentMethodsCompatibility.php +++ b/includes/multi-currency/PaymentMethodsCompatibility.php @@ -38,6 +38,7 @@ class PaymentMethodsCompatibility { 'giropay' => 'EUR', 'sepa_debit' => 'EUR', 'sofort' => 'EUR', + 'ideal' => 'EUR', ]; /** diff --git a/includes/payment-methods/class-ideal-payment-method.php b/includes/payment-methods/class-ideal-payment-method.php new file mode 100644 index 00000000000..33149d6c0cf --- /dev/null +++ b/includes/payment-methods/class-ideal-payment-method.php @@ -0,0 +1,29 @@ +stripe_id = 'ideal'; + $this->title = 'iDEAL'; + $this->is_reusable = false; + $this->currencies = [ 'EUR' ]; + } +} diff --git a/includes/payment-methods/class-upe-payment-gateway.php b/includes/payment-methods/class-upe-payment-gateway.php index ec28f4cd8bf..3e18b52e07a 100644 --- a/includes/payment-methods/class-upe-payment-gateway.php +++ b/includes/payment-methods/class-upe-payment-gateway.php @@ -737,6 +737,7 @@ public function get_upe_available_payment_methods() { $methods[] = 'giropay'; $methods[] = 'sofort'; + $methods[] = 'ideal'; return array_values( apply_filters( diff --git a/readme.txt b/readme.txt index 3f6085dbf8b..30c309f37ed 100644 --- a/readme.txt +++ b/readme.txt @@ -99,6 +99,7 @@ Please note that our support for the checkout block is still experimental and th == Changelog == = 2.9.0 - 2021-xx-xx = +* Add - *Early access*: allow your store to collect payments with iDEAL. Enable the feature in settings! = 2.8.2 - 2021-08-05 = * Fix - If account is disconnected or not set up do not display onboarding task and UPE inbox note. diff --git a/tests/unit/admin/test-class-wc-rest-payments-settings-controller.php b/tests/unit/admin/test-class-wc-rest-payments-settings-controller.php index c09c2e6e726..4ee9444650e 100644 --- a/tests/unit/admin/test-class-wc-rest-payments-settings-controller.php +++ b/tests/unit/admin/test-class-wc-rest-payments-settings-controller.php @@ -11,6 +11,7 @@ use WCPay\Payment_Methods\CC_Payment_Method; use WCPay\Payment_Methods\Giropay_Payment_Method; use WCPay\Payment_Methods\Sofort_Payment_Method; +use WCPay\Payment_Methods\Ideal_Payment_Method; /** * WC_REST_Payments_Settings_Controller_Test unit tests. @@ -85,6 +86,7 @@ public function setUp() { CC_Payment_Method::class, Giropay_Payment_Method::class, Sofort_Payment_Method::class, + Ideal_Payment_Method::class, ]; foreach ( $payment_method_classes as $payment_method_class ) { $mock_payment_method = $this->getMockBuilder( $payment_method_class ) @@ -125,7 +127,7 @@ public function test_get_settings_returns_available_payment_method_ids() { $enabled_method_ids = $response->get_data()['available_payment_method_ids']; $this->assertEquals( - [ 'card', 'giropay', 'sofort' ], + [ 'card', 'giropay', 'sofort', 'ideal' ], $enabled_method_ids ); } diff --git a/tests/unit/payment-methods/test-class-upe-payment-gateway.php b/tests/unit/payment-methods/test-class-upe-payment-gateway.php index 3cf24b26ee4..e43d4f6522b 100644 --- a/tests/unit/payment-methods/test-class-upe-payment-gateway.php +++ b/tests/unit/payment-methods/test-class-upe-payment-gateway.php @@ -168,6 +168,7 @@ public function setUp() { CC_Payment_Method::class, Giropay_Payment_Method::class, Sofort_Payment_Method::class, + Ideal_Payment_Method::class, ]; foreach ( $payment_method_classes as $payment_method_class ) { $mock_payment_method = $this->getMockBuilder( $payment_method_class ) @@ -779,6 +780,9 @@ public function test_correct_payment_method_title_for_order() { $sofort_details = [ 'type' => 'sofort', ]; + $ideal_details = [ + 'type' => 'ideal', + ]; $charge_payment_method_details = [ $visa_credit_details, @@ -786,6 +790,7 @@ public function test_correct_payment_method_title_for_order() { $mastercard_credit_details, $giropay_details, $sofort_details, + $ideal_details, ]; $expected_payment_method_titles = [ 'Visa credit card', @@ -793,6 +798,7 @@ public function test_correct_payment_method_title_for_order() { 'Mastercard credit card', 'giropay', 'Sofort', + 'iDEAL', ]; foreach ( $charge_payment_method_details as $i => $payment_method_details ) { @@ -832,11 +838,15 @@ public function test_payment_methods_show_correct_default_outputs() { $mock_sofort_details = [ 'type' => 'sofort', ]; + $mock_ideal_details = [ + 'type' => 'ideal', + ]; $this->set_cart_contains_subscription_items( false ); $card_method = $this->mock_payment_methods['card']; $giropay_method = $this->mock_payment_methods['giropay']; $sofort_method = $this->mock_payment_methods['sofort']; + $ideal_method = $this->mock_payment_methods['ideal']; $this->assertEquals( 'card', $card_method->get_id() ); $this->assertEquals( 'Credit card / debit card', $card_method->get_title() ); @@ -857,6 +867,12 @@ public function test_payment_methods_show_correct_default_outputs() { $this->assertEquals( 'Sofort', $sofort_method->get_title( $mock_sofort_details ) ); $this->assertTrue( $sofort_method->is_enabled_at_checkout() ); $this->assertFalse( $sofort_method->is_reusable() ); + + $this->assertEquals( 'ideal', $ideal_method->get_id() ); + $this->assertEquals( 'iDEAL', $ideal_method->get_title() ); + $this->assertEquals( 'iDEAL', $ideal_method->get_title( $mock_ideal_details ) ); + $this->assertTrue( $ideal_method->is_enabled_at_checkout() ); + $this->assertFalse( $ideal_method->is_reusable() ); } public function test_only_reusabled_payment_methods_enabled_with_subscription_item_present() { @@ -864,28 +880,33 @@ public function test_only_reusabled_payment_methods_enabled_with_subscription_it $card_method = $this->mock_payment_methods['card']; $giropay_method = $this->mock_payment_methods['giropay']; $sofort_method = $this->mock_payment_methods['sofort']; + $ideal_method = $this->mock_payment_methods['ideal']; $this->assertTrue( $card_method->is_enabled_at_checkout() ); $this->assertFalse( $giropay_method->is_enabled_at_checkout() ); $this->assertFalse( $sofort_method->is_enabled_at_checkout() ); + $this->assertFalse( $ideal_method->is_enabled_at_checkout() ); } public function test_only_valid_payment_methods_returned_for_currency() { $card_method = $this->mock_payment_methods['card']; $giropay_method = $this->mock_payment_methods['giropay']; $sofort_method = $this->mock_payment_methods['sofort']; + $ideal_method = $this->mock_payment_methods['ideal']; self::$mock_site_currency = 'EUR'; $this->assertTrue( $card_method->is_currency_valid() ); $this->assertTrue( $giropay_method->is_currency_valid() ); $this->assertTrue( $sofort_method->is_currency_valid() ); + $this->assertTrue( $ideal_method->is_currency_valid() ); self::$mock_site_currency = 'USD'; $this->assertTrue( $card_method->is_currency_valid() ); $this->assertFalse( $giropay_method->is_currency_valid() ); $this->assertFalse( $sofort_method->is_currency_valid() ); + $this->assertFalse( $ideal_method->is_currency_valid() ); self::$mock_site_currency = ''; }