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

Deprecate Sofort #7480

Merged
merged 19 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
f957813
Removing Sofort from the WooPayments start Onboarding page.
dmallory42 Oct 13, 2023
13b69d9
Update changelog.
dmallory42 Oct 13, 2023
1e24d30
Adding PHP logic to prevent Sofort being passed to the Settings if it…
dmallory42 Oct 13, 2023
a2ec4eb
Adding Sofort notice on the Payments select list and payment disable …
dmallory42 Oct 16, 2023
65e0111
Merge branch 'develop' into dev/sofort-deprecation
dmallory42 Oct 16, 2023
5c4ff04
Update to use InlineNotice component instead of Notice.
dmallory42 Oct 17, 2023
c1f3b8f
Merge branch 'develop' into dev/sofort-deprecation
dmallory42 Oct 17, 2023
ece8d31
Merge branch 'dev/sofort-deprecation' of github.com:Automattic/woocom…
dmallory42 Oct 17, 2023
a73dba0
Update unit tests.
dmallory42 Oct 17, 2023
b5a944d
Remove remaining occurrence and update test snapshots
ismaeldcom Oct 17, 2023
99843b1
Removing code no longer needed after server update.
dmallory42 Oct 18, 2023
ddf113c
Merge branch 'dev/sofort-deprecation' of github.com:Automattic/woocom…
dmallory42 Oct 18, 2023
cb1f99d
Merge branch 'develop' into dev/sofort-deprecation
dmallory42 Oct 18, 2023
6493128
Update to unit tests.
dmallory42 Oct 18, 2023
5b035a2
Merge branch 'dev/sofort-deprecation' of github.com:Automattic/woocom…
dmallory42 Oct 18, 2023
4d0e8eb
Update the visual assets to remove Sofort.
dmallory42 Oct 19, 2023
5348010
Merge branch 'develop' into dev/sofort-deprecation
dmallory42 Oct 19, 2023
3993240
Remove unneeded comment.
dmallory42 Oct 19, 2023
6a94393
Merge branch 'dev/sofort-deprecation' of github.com:Automattic/woocom…
dmallory42 Oct 19, 2023
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
4 changes: 4 additions & 0 deletions changelog/dev-sofort-deprecation
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: update

Deprecate Sofort for any merchants who have not enabled it. Warn existing merchants about future deprecation.
19 changes: 14 additions & 5 deletions client/components/payment-methods-list/payment-method.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
.payment-method {
.payment-method__list-item {
display: flex;
flex-direction: column;
margin: 0;
padding: 24px;

&:not( :last-child ) {
box-shadow: inset 0 -1px 0 #e8eaeb;
}

& .sofort__notice {
margin-top: 20px;
}
}

.payment-method {
display: flex;
background: #fff;
justify-content: space-between;
align-items: center;
Expand All @@ -10,10 +23,6 @@
flex-wrap: nowrap;
}

&:not( :last-child ) {
box-shadow: inset 0 -1px 0 #e8eaeb;
}

&__text {
flex: 1 1 100%;
order: 1;
Expand Down
153 changes: 90 additions & 63 deletions client/components/payment-methods-list/payment-method.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import LoadableCheckboxControl from '../loadable-checkbox';
import { getDocumentationUrlForDisabledPaymentMethod } from '../payment-method-disabled-tooltip';
import Pill from '../pill';
import './payment-method.scss';
import { Notice } from '@wordpress/components';

interface PaymentMethodProps {
id: string;
Expand Down Expand Up @@ -127,6 +128,8 @@ const PaymentMethod = ( {
upeCapabilityStatuses.PENDING_VERIFICATION,
].includes( status );

const shouldDisplayNotice = id === 'sofort';

const needsOverlay =
( isManualCaptureEnabled && ! isAllowingManualCapture ) ||
isSetupRequired ||
Expand Down Expand Up @@ -209,83 +212,107 @@ const PaymentMethod = ( {
return (
<li
className={ classNames(
'payment-method',
'payment-method__list-item',
{ 'has-icon-border': id !== 'card' },
{ overlay: needsOverlay },
className
) }
>
<div className="payment-method__checkbox">
<LoadableCheckboxControl
label={ label }
checked={ checked }
disabled={ disabled || locked }
onChange={ handleChange }
delayMsOnCheck={ 1500 }
delayMsOnUncheck={ 0 }
hideLabel
isAllowingManualCapture={ isAllowingManualCapture }
isSetupRequired={ isSetupRequired }
setupTooltip={ getTooltipContent( id ) as any }
needsAttention={ needsAttention }
/>
</div>
<div className="payment-method__text-container">
<div className="payment-method__icon">
<Icon />
</div>
<div className="payment-method__label payment-method__label-mobile">
<PaymentMethodLabel
<div className="payment-method">
<div className="payment-method__checkbox">
<LoadableCheckboxControl
label={ label }
required={ required }
status={ status }
disabled={ disabled }
checked={ checked }
disabled={ disabled || locked }
onChange={ handleChange }
delayMsOnCheck={ 1500 }
delayMsOnUncheck={ 0 }
hideLabel
isAllowingManualCapture={ isAllowingManualCapture }
isSetupRequired={ isSetupRequired }
setupTooltip={ getTooltipContent( id ) as any }
needsAttention={ needsAttention }
/>
</div>
<div className="payment-method__text">
<div className="payment-method__label-container">
<div className="payment-method__label payment-method__label-desktop">
<PaymentMethodLabel
label={ label }
required={ required }
status={ status }
disabled={ disabled }
/>
</div>
<div className="payment-method__description">
{ description }
</div>
<div className="payment-method__text-container">
<div className="payment-method__icon">
<Icon />
</div>
<div className="payment-method__label payment-method__label-mobile">
<PaymentMethodLabel
label={ label }
required={ required }
status={ status }
disabled={ disabled }
/>
</div>
{ accountFees && accountFees[ id ] && (
<div className="payment-method__fees">
<HoverTooltip
maxWidth={ '300px' }
content={ formatMethodFeesTooltip(
accountFees[ id ]
) }
>
<Pill
aria-label={ sprintf(
__(
'Base transaction fees: %s',
'woocommerce-payments'
),
formatMethodFeesDescription(
accountFees[ id ]
)
<div className="payment-method__text">
<div className="payment-method__label-container">
<div className="payment-method__label payment-method__label-desktop">
<PaymentMethodLabel
label={ label }
required={ required }
status={ status }
disabled={ disabled }
/>
</div>
<div className="payment-method__description">
{ description }
</div>
</div>
{ accountFees && accountFees[ id ] && (
<div className="payment-method__fees">
<HoverTooltip
maxWidth={ '300px' }
content={ formatMethodFeesTooltip(
accountFees[ id ]
) }
>
<span>
{ formatMethodFeesDescription(
accountFees[ id ]
<Pill
aria-label={ sprintf(
__(
'Base transaction fees: %s',
'woocommerce-payments'
),
formatMethodFeesDescription(
accountFees[ id ]
)
) }
</span>
</Pill>
</HoverTooltip>
</div>
) }
>
<span>
{ formatMethodFeesDescription(
accountFees[ id ]
) }
</span>
</Pill>
</HoverTooltip>
</div>
) }
</div>
</div>
</div>
{ shouldDisplayNotice && (
<Notice
status="warning"
isDismissible={ false }
className="sofort__notice"
>
<span>
{ __(
'Support for Sofort is ending soon. ',
'woocommerce-payments'
) }
<a
// eslint-disable-next-line max-len
href="https://woocommerce.com/document/woopayments/payment-methods/additional-payment-methods/#sofort-deprecation"
target="_blank"
rel="external noreferrer noopener"
>
{ __( 'Learn more', 'woocommerce-payments' ) }
</a>
</span>
</Notice>
) }
</li>
);
};
Expand Down
2 changes: 0 additions & 2 deletions client/connect-account-page/payment-methods.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import DinersClub from 'assets/images/cards/diners.svg?asset';
import GooglePay from 'assets/images/cards/google-pay.svg?asset';
import JCB from 'assets/images/cards/jcb.svg?asset';
import MasterCard from 'assets/images/cards/mastercard.svg?asset';
import Sofort from 'assets/images/payment-methods/sofort.svg?asset';
import UnionPay from 'assets/images/cards/unionpay.svg?asset';
import Visa from 'assets/images/cards/visa.svg?asset';
import WooPay from 'assets/images/payment-methods/woopay.svg?asset';
Expand All @@ -37,7 +36,6 @@ const PaymentMethods: React.FC = () => {
<img src={ DinersClub } alt="DinersClub" />
<img src={ UnionPay } alt="UnionPay" />
<img src={ JCB } alt="JCB" />
<img src={ Sofort } alt="Sofort" />
<img src={ Affirm } alt="Affirm" />
<img src={ AfterPay } alt="AfterPay" />
<span>& more.</span>
Expand Down
28 changes: 26 additions & 2 deletions client/payment-methods/delete-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
import React from 'react';
import { __, sprintf } from '@wordpress/i18n';
import { Button } from '@wordpress/components';
import { Button, Notice } from '@wordpress/components';
import interpolateComponents from '@automattic/interpolate-components';

/**
Expand All @@ -20,6 +20,8 @@ const ConfirmPaymentMethodDeleteModal: React.FunctionComponent< {
onConfirm: () => void;
onCancel: () => void;
} > = ( { id, label, icon: Icon, onConfirm, onCancel } ): JSX.Element => {
const shouldDisplayNotice = id === 'sofort';

return (
<ConfirmationModal
title={ sprintf(
Expand Down Expand Up @@ -65,7 +67,7 @@ const ConfirmPaymentMethodDeleteModal: React.FunctionComponent< {
<p>
{ interpolateComponents( {
mixedString: __(
'You can add it again at any time in {{wooCommercePaymentsLink /}}',
'You can add it again at any time in {{wooCommercePaymentsLink /}}.',
'woocommerce-payments'
),
components: {
Expand All @@ -77,6 +79,28 @@ const ConfirmPaymentMethodDeleteModal: React.FunctionComponent< {
},
} ) }
</p>
{ shouldDisplayNotice && (
<Notice
status="warning"
isDismissible={ false }
className="sofort__notice"
>
<span>
{ __(
'As of October 20th 2023, Sofort is no longer supported for merchants who are not already using it. This means that if you disable Sofort, you will not be able to re-enable it later. ',
'woocommerce-payments'
) }
<a
// eslint-disable-next-line max-len
href="https://woocommerce.com/document/woopayments/payment-methods/additional-payment-methods/#sofort-deprecation"
target="_blank"
rel="external noreferrer noopener"
>
{ __( 'Learn more', 'woocommerce-payments' ) }
</a>
</span>
</Notice>
) }
</ConfirmationModal>
);
};
Expand Down
35 changes: 33 additions & 2 deletions includes/admin/class-wc-rest-payments-settings-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,10 @@ public function validate_business_support_address( array $value, WP_REST_Request
* @return WP_REST_Response
*/
public function get_settings(): WP_REST_Response {
$wcpay_form_fields = $this->wcpay_gateway->get_form_fields();
$wcpay_form_fields = $this->wcpay_gateway->get_form_fields();

$available_upe_payment_methods = $this->wcpay_gateway->get_upe_available_payment_methods();

/**
* It might be possible that enabled payment methods settings have an invalid state. As an example,
* if an account is switched to a new country and earlier country had PM's that are no longer valid; or if the PM is not available anymore.
Expand All @@ -448,6 +450,8 @@ public function get_settings(): WP_REST_Response {
)
);

$filtered_payment_methods = $this->possibly_filter_available_payment_methods( $available_upe_payment_methods, $enabled_payment_methods );

// Gather the status of the Stripe Billing migration for use on the settings page.
if ( class_exists( 'WC_Subscriptions' ) ) {
$stripe_billing_migrated_count = $this->wcpay_gateway->get_subscription_migrated_count();
Expand All @@ -465,7 +469,7 @@ public function get_settings(): WP_REST_Response {
return new WP_REST_Response(
[
'enabled_payment_method_ids' => $enabled_payment_methods,
'available_payment_method_ids' => $available_upe_payment_methods,
'available_payment_method_ids' => $filtered_payment_methods,
'payment_method_statuses' => $this->wcpay_gateway->get_upe_enabled_payment_method_statuses(),
'is_wcpay_enabled' => $this->wcpay_gateway->is_enabled(),
'is_manual_capture_enabled' => 'yes' === $this->wcpay_gateway->get_option( 'manual_capture' ),
Expand Down Expand Up @@ -1048,4 +1052,31 @@ private function get_avs_check_enabled( array $ruleset_config ) {

return $avs_check_enabled;
}

/**
* Because we still need to support payments made using Sofort until it is sunsetted at the end of the year,
* this is the most sensible place to prevent it getting shown on the frontend settings for new merchants.
* We will filter it from the array, but only if the user has not enabled it. If it is enabled, we show it with a warning (handled in the JS).
*
* @TODO: Remove this logic and tidy up once Sofort is officially deprecated for all users.
*
* @param array $available_payment_methods The available payment methods.
* @param array $enabled_payment_methods The enabled payment methods.
*
* @return array The filtered available payment methods.
*/
private function possibly_filter_available_payment_methods( array $available_payment_methods, array $enabled_payment_methods ): array {
if ( ! in_array( 'sofort', array_values( $enabled_payment_methods ), true ) ) {
return array_values(
array_filter(
$available_payment_methods,
function ( $payment_method ) {
return 'sofort' !== $payment_method;
}
)
);
}

return $available_payment_methods;
}
}
Loading