LLMS_Order::maybe_schedule_retry()
Handles scheduling recurring payment retries when the gateway supports them
Description Description
Return Return
(void)
Source Source
File: includes/models/model.llms.order.php
public function maybe_schedule_retry() { if ( ! $this->can_be_retried() ) { return; } $current_rule = $this->get( 'last_retry_rule' ); if ( '' === $current_rule ) { $current_rule = 0; } else { $current_rule = $current_rule + 1; } $rules = $this->get_retry_rules(); if ( isset( $rules[ $current_rule ] ) ) { $rule = $rules[ $current_rule ]; $next_payment_time = current_time( 'timestamp' ) + $rule['delay']; // update the status $this->set_status( $rule['status'] ); // set the next payment date based on the rule's delay $this->set_date( 'next_payment', date_i18n( 'Y-m-d H:i:s', $next_payment_time ) ); // save the rule for reference on potential future retries $this->set( 'last_retry_rule', $current_rule ); // if notifications should be sent, trigger them if ( $rule['notifications'] ) { do_action( 'llms_send_automatic_payment_retry_notification', $this ); } $this->add_note( sprintf( esc_html__( 'Automatic retry attempt scheduled for %s', 'lifterlms' ), date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $next_payment_time ) ) ); // generic action do_action( 'llms_automatic_payment_retry_scheduled', $this ); // we are out of rules, fail the order, move on with our lives } else { $this->set_status( 'failed' ); $this->set( 'last_retry_rule', '' ); $this->add_note( esc_html__( 'Maximum retry attempts reached.', 'lifterlms' ) ); do_action( 'llms_automatic_payment_maximum_retries_reached', $this ); }// End if(). }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.10.0 | Introduced. |
User Contributed Notes User Contributed Notes
Permalink: