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

Retrieving iDEAL issuers from transient catches exceptions #69

Closed
remcotolsma opened this issue Jul 7, 2022 · 3 comments
Closed

Retrieving iDEAL issuers from transient catches exceptions #69

remcotolsma opened this issue Jul 7, 2022 · 3 comments
Assignees

Comments

@remcotolsma
Copy link
Member

I believe this has been discussed before, the Gateway->get_transient_issuers() method catches exceptions. As a result, as an administrator you will not always see error messages that occur when retrieving the iDEAL issuers.

/**
* Get the iDEAL issuers transient.
*
* @return array|null
*/
public function get_transient_issuers() {
$issuers = null;
// Transient name.
$transient = 'pronamic_pay_issuers_' . md5( serialize( $this ) );
$result = get_transient( $transient );
if ( is_wp_error( $result ) || false === $result ) {
try {
$issuers = $this->get_issuers();
} catch ( \Exception $e ) {
$issuers = null;
}
if ( ! empty( $issuers ) ) {
// 60 * 60 * 24 = 24 hours = 1 day
set_transient( $transient, $issuers, 60 * 60 * 24 );
}
} elseif ( is_array( $result ) ) {
$issuers = $result;
}
return $issuers;
}

This catch was added in 2c9a6bf on March 31, 2022. Probably also necessary because the switch from errors to exceptions has not yet been made properly / completely.

This can be seen, for example, in the Gravity Forms integration:

We should remove the catch from the Gateway->get_transient_issuers() method and handle the exceptions downstream.

@remcotolsma
Copy link
Member Author

remcotolsma commented Jul 7, 2022

This issue was brought to our attention again via internal HelpScout ticket: https://secure.helpscout.net/conversation/1942250530/24187?folderId=1425710. The customer probably made a mistake while setting up the iDEAL Advanced certificate, but didn't see the underlying error message:

Invalid electronic signature. System generating error: Acquirer

@remcotolsma
Copy link
Member Author

remcotolsma commented Jul 7, 2022

I think we should also combine this directly with the following issue:

The following Gateway class methods have become somewhat complex over time:

  • get_issuer_field()
  • get_transient_issuers()
  • get_credit_card_issuers()
  • get_gender_field()
  • get_birth_date_field()
  • get_consumer_bank_details_name_field()
  • get_payment_method()
  • set_payment_method( $payment_method )
  • get_input_fields()
  • get_input_html()
  • get_form_html()
  • get_output_fields( Payment $payment )
  • get_output_html( Payment $payment )
  • payment_method_is_required()
  • get_payment_method_field_options( $other_first = false )
  • get_transient_available_payment_methods( $update_active_methods = true )
  • get_available_payment_methods()
  • get_supported_payment_methods()
  • get_transient_credit_card_issuers()
  • get_issuers()

I believe we should als abstract the way we use the WordPress https://developer.wordpress.org/apis/handbook/transients/ API.

We know from the iDEAL Advanced integration guide that it is not allowed to request the iDEAL issuers for each transaction:

It is not allowed to perform the Directory protocol for each transaction. Since the list of Issuers only changes occasionally, it is sufficient to execute the Directory protocol on a daily basis and check if the list has changed based on the directoryDateTimestamp. If the Issuer list has changed, the latest version has to be saved and used for any subsequent transaction. Acquirers will normally also inform all Merchants (e.g. by email) about changes in their Issuer list. The Directory protocol should at least be executed once a month.

https://github.com/pronamic/wp-pronamic-pay-ideal-advanced-v3/blob/master/documentation/iDEAL-Merchant-Integration-Guide_29696264_931138689.pdf

I think this is less important with, for example, the Mollie API:
https://docs.mollie.com/reference/v2/methods-api/list-methods

@remcotolsma remcotolsma self-assigned this Jul 13, 2022
@remcotolsma
Copy link
Member Author

This has been improved in

<td>
<?php
try {
$field->output();
} catch ( \Exception $exception ) {
echo '<em>';
printf(
__( 'This field could not be displayed due to the following error message: "%s".', 'pronamic_ideal' ),
\esc_html( $exception->getMessage() )
);
echo '</em>';
?>
<div class="error">
<dl>
<dt><?php esc_html_e( 'Message', 'pronamic_ideal' ); ?></dt>
<dd><?php echo esc_html( $exception->getMessage() ); ?></dd>
<?php if ( 0 !== $exception->getCode() ) : ?>
<dt><?php esc_html_e( 'Code', 'pronamic_ideal' ); ?></dt>
<dd><?php echo esc_html( $exception->getCode() ); ?></dd>
<?php endif; ?>
</dl>
</div>
<?php
}
?>
</td>
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

1 participant