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

Ignore non-existing customers when determining customer ID #47

Open
rvdsteege opened this issue Mar 22, 2024 · 0 comments
Open

Ignore non-existing customers when determining customer ID #47

rvdsteege opened this issue Mar 22, 2024 · 0 comments

Comments

@rvdsteege
Copy link
Member

On payment start, we try to use the first existing Mollie customer ID:

public function get_customer_id_for_payment( Payment $payment ) {
$customer_ids = $this->get_customer_ids_for_payment( $payment );
$customer_id = $this->get_first_existing_customer_id( $customer_ids );
return $customer_id;
}

private function get_first_existing_customer_id( $customer_ids ) {
$customer_ids = \array_filter( $customer_ids );
$customer_ids = \array_unique( $customer_ids );
foreach ( $customer_ids as $customer_id ) {
try {
$customer = $this->client->get_customer( $customer_id );
} catch ( Error $error ) {
// Check for status 410 ("Gone - The customer is no longer available").
if ( 410 === $error->get_status() ) {
continue;
}
throw $error;
}
if ( null !== $customer ) {
return $customer_id;
}
}

Mollie returns the HTTP 410 'Gone' status if a customer does not exist anymore and we then ignore this customer ID. However, we do not store this permanent status and next time we test again for the existence of this customer ID.

I just ran into timeout issues in a development environment because of this. Manually truncating the wp_pronamic_pay_mollie_* database tables resolved the issue.

CC @remcotolsma

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

No branches or pull requests

1 participant