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

No redirect to status page if there is no action URL #167

Open
rvdsteege opened this issue Dec 21, 2023 · 0 comments
Open

No redirect to status page if there is no action URL #167

rvdsteege opened this issue Dec 21, 2023 · 0 comments
Assignees

Comments

@rvdsteege
Copy link
Member

It is possible that there is no action URL when starting a payment, e.g. Direct Debit via Mollie (for which we create the token). In this case the user will not be redirected:

wp-pay-core/src/Plugin.php

Lines 539 to 590 in c743a15

/**
* Maybe redirect.
*
* @return void
*/
public function maybe_redirect() {
// phpcs:disable WordPress.Security.NonceVerification.Recommended
if ( ! \array_key_exists( 'payment_redirect', $_GET ) || ! \array_key_exists( 'key', $_GET ) ) {
return;
}
// Get payment.
$payment_id = (int) $_GET['payment_redirect'];
$payment = get_pronamic_payment( $payment_id );
if ( null === $payment ) {
return;
}
// Validate key.
$key = \sanitize_text_field( \wp_unslash( $_GET['key'] ) );
if ( $key !== $payment->key || empty( $payment->key ) ) {
return;
}
// phpcs:enable WordPress.Security.NonceVerification.Recommended
Core_Util::no_cache();
$gateway = $payment->get_gateway();
if ( null !== $gateway ) {
// Give gateway a chance to handle redirect.
$gateway->payment_redirect( $payment );
// Handle HTML form redirect.
if ( $gateway->is_html_form() ) {
$gateway->redirect( $payment );
}
}
// Redirect to payment action URL.
$action_url = $payment->get_action_url();
if ( ! empty( $action_url ) ) {
wp_redirect( $action_url );
exit;
}
}

@remcotolsma should we add a fallback to redirect to the payment return redirect URL?

		// Redirect to payment return redirect URL.
		$return_redirect_url = $payment->get_return_redirect_url();

		if ( ! empty( $return_redirect_url ) ) {
			wp_redirect( $return_redirect_url );

			exit;
		}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Todo
Development

No branches or pull requests

2 participants