Skip to content
Docs
Get RestroPress

Filter

rpress_can_resume_payment

Updated
On this page

Filters whether checkout may resume a pending payment and overwrite it with the current checkout.

Runs in rpress_is_payment_resumable(), only after the payment passes is_recoverable() and no other owner holds a live claim. It can run twice in one checkout: with context 'purchase' while the purchase key is chosen, and with context 'insert' in rpress_insert_payment(), after core has claimed and re-read the payment. The second call is the authoritative one. Return false to leave the payment untouched, so checkout creates a new one with its own key.

Available since RestroPress 3.5.1.

Parameters#

ParameterTypeDescription
$canboolDefault true.
$payment_idintPending payment ID from the buyer's session.
$purchase_dataarrayPurchase data of the current checkout.
$contextstring'purchase' or 'insert'.

Return value#

bool. False to refuse the resume.

Example#

add_filter( 'rpress_can_resume_payment', 'my_can_resume_payment', 10, 4 );
function my_can_resume_payment( $can, $payment_id, $purchase_data, $context ) {
	if ( get_post_meta( $payment_id, '_my_gateway_charge_pending', true ) ) {
		return false;
	}
	return $can;
}

Notes#

A gateway can instead hold a claim with rpress_claim_payment() while a charge is in progress.

Source#

Applied in:

  • includes/payments/resume-claim.php (line 206), in rpress_is_payment_resumable()

See also#

Was this page helpful?