pronamic / wp-pronamic-pay-restrict-content-pro

Restrict Content Pro driver for the WordPress payment processing library. http://www.wp-pay.org/extensions/restrict-content-pro/
3 stars 1 forks source link

Error when using 'Direct Debit (mandate via X)' payment method without auto renewal #3

Closed rvdsteege closed 2 years ago

rvdsteege commented 2 years ago

When using the Direct Debit (mandate via iDEAL/Bancontact/SOFORT) payment methods without auto renew, then the first payment will fail with this (Mollie) error:

Unprocessable Entity - The payment method is not activated on your account.

Instead, the regular iDEAL/Bancontact/SOFORT payment methods can be used both with and without auto renew:

Without auto renew, there is no subscription for the payment, so in the Mollie gateway the sequence type will not be set to first:

Thoughts, @remcotolsma?

Internal Help Scout ticket: https://secure.helpscout.net/conversation/1824903680/23725/

remcotolsma commented 2 years ago

For the pronamic_pay_direct_debit_bancontact, pronamic_pay_direct_debit_ideal and pronamic_pay_direct_debit_sofort gateways we should set mollie_sequence_type to first regardless of $gateway->auto_renew?

https://github.com/pronamic/wp-pronamic-pay-restrict-content-pro/blob/4332583bee2d4d9849294f562f7322afd414ddfe/src/Extension.php#L209-L211

https://github.com/pronamic/wp-pronamic-pay-restrict-content-pro/blob/4332583bee2d4d9849294f562f7322afd414ddfe/src/Gateway.php#L261-L265

In the Mollie library we need to convert the payment method to first with PaymentMethods::get_first_payment_method( $payment_method ) if 'first' === $payment->get_meta( 'mollie_sequence_type' );? That way, a mandate will be created as the gateway name suggests, but there will be no auto_renew.

Or am I missing something @rvdsteege?

remcotolsma commented 2 years ago

Or change in Mollie:

if ( \count( $subscriptions ) > 0 ) {

to

if (
    \count( $subscriptions ) > 0
        ||
    \in_array(
        $payment_method,
        array(
            PaymentMethods::DIRECT_DEBIT_BANCONTACT,
            PaymentMethods::DIRECT_DEBIT_IDEAL,
            PaymentMethods::DIRECT_DEBIT_SOFORT,
        ),
        true
    )
) {

}

https://github.com/pronamic/wp-pronamic-pay-mollie/blob/1c802b2cfeb493f9dc1a3b79b07fc42cfe112f68/src/Gateway.php#L343-L374

rvdsteege commented 2 years ago

Tested: issue has been resolved in https://github.com/pronamic/wp-pronamic-pay-mollie/pull/3 🎉