pronamic / wp-pronamic-pay-adyen

Adyen driver for the WordPress payment processing library.
https://www.wp-pay.org/gateways/adyen/
6 stars 2 forks source link

Backward compatibility from version `3` to `4` #10

Closed remcotolsma closed 2 years ago

remcotolsma commented 2 years ago

The https://github.com/pronamic/wp-pronamic-pay-adyen/releases/tag/4.0.0-RC-1 release is breaking backward compatibility since the Adyen Web Drop-in version 5.14.0 configuration requires a clientKey and environment parameter.

Schermafbeelding 2022-05-17 om 16 35 21

https://docs.adyen.com/online-payments/web-drop-in#configure

I've already set it up to throw an exception when these parameters are empty:

https://github.com/pronamic/wp-pronamic-pay-adyen/blob/756d1b632682cb0dde299c3f55b25c5b249dcd30/src/Gateway.php#L296-L306

However, it is not very friendly for site owners that the Adyen gateway no longer works after an update.

We can inform site owners about this in different ways:

  1. Send an email notice.
  2. Show an admin notice.
  3. Add upgrade_notice in https://api.pronamic.nl/plugins/update-check/1.2/ response.
  4. Use https://wordpress.org/plugins/woocommerce-gateway-paypal-express-checkout/https://wordpress.org/plugins/woocommerce-paypal-payments/ tactics.

The upgrade_notice option is only shown on the /wp-admin/update-core.php page and not on /wp-admin/plugins.php:

Schermafbeelding 2022-05-17 om 16 31 52
remcotolsma commented 2 years ago

Another point of attention is that if Adyen users update the Pronamic Pay plugin and not the Pronamic Pay Adyen Add-On, they will still run on the new Adyen code. This has to do with the way we want to avoid Composer dependencies problems. In that regard, the https://wordpress.org/plugins/woocommerce-gateway-paypal-express-checkout/https://wordpress.org/plugins/woocommerce-paypal-payments/ approach is also interesting.

remcotolsma commented 2 years ago

Admin notice implementation:

add_action(
    'admin_notices',
    function() {
        if ( ! current_user_can( 'manage_options' ) ) {
            return;
        }

        $query = new WP_Query(
            [
                'post_type'      => 'pronamic_gateway',
                'posts_per_page' => 10,
                'meta_query'     => [
                    'relation' => 'AND',
                    [
                        'key'     => '_pronamic_gateway_id',
                        'compare' => 'IN',
                        'value'   => [
                            'adyen',
                            'adyen-test',
                        ],
                    ],
                    [
                        'relation' => 'OR',
                        [
                            'key'     => '_pronamic_gateway_adyen_client_key',
                            'compare' => '=',
                            'value'   => '',
                        ],
                        [
                            'key'     => '_pronamic_gateway_adyen_client_key',
                            'compare' => 'NOT EXISTS',
                        ],
                    ],
                ]
            ]
        );

        if ( empty( $query->posts ) ) {
            return;
        }

        ?>
        <div class="error notice">
            <p>
                <strong><?php esc_html_e( 'Pronamic Pay', 'pronamic_ideal' ); ?></strong> —
                <?php \esc_html_e( 'The following Ayden configurations must be migrated to a client key:', 'pronamic_ideal' ); ?>
            </p>

            <ul>

                <?php foreach ( $query->posts as $adyen_config_post ) : ?>

                    <li>
                        <?php

                        printf(
                            '<a href="%s">%s</a>',
                            esc_url( get_edit_post_link( $adyen_config_post ) ),
                            esc_html( get_the_title( $adyen_config_post ) )
                        );

                        ?>
                    </li>

                <?php endforeach; ?>

            </ul>
        </div>
        <?php
    }
);
Schermafbeelding 2022-05-18 om 09 58 23
remcotolsma commented 2 years ago

Implemented in https://github.com/pronamic/wp-pronamic-pay-adyen/commit/3c18ecd9568f28ab0b27b84b8c0ad00f6b264dcb.

remcotolsma commented 2 years ago
  1. Use https://wordpress.org/plugins/woocommerce-gateway-paypal-express-checkout/https://wordpress.org/plugins/woocommerce-paypal-payments/ tactics.

Another point of attention is that if Adyen users update the Pronamic Pay plugin and not the Pronamic Pay Adyen Add-On, they will still run on the new Adyen code. This has to do with the way we want to avoid Composer dependencies problems. In that regard, the https://wordpress.org/plugins/woocommerce-gateway-paypal-express-checkout/https://wordpress.org/plugins/woocommerce-paypal-payments/ approach is also interesting.

For the Rabobank OmniKassa version '1' to '2' upgrade we did something similar:

https://github.com/wp-pay-gateways/omnikassahttps://github.com/pronamic/wp-pronamic-pay-omnikassa-2

This might not be a bad approach for gateway integrations that cannot be kept backwards compatible.