Filter
rpress_can_resume_payment
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#
| Parameter | Type | Description |
|---|---|---|
$can | bool | Default true. |
$payment_id | int | Pending payment ID from the buyer's session. |
$purchase_data | array | Purchase data of the current checkout. |
$context | string | '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), inrpress_is_payment_resumable()
