LLMS_Controller_Orders::recurring_charge( int $order_id )

Trigger a recurring payment


Description Description

Called by action scheduler.


Parameters Parameters

$order_id

(int) (Required) WP Post ID of the order.


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/controllers/class.llms.controller.orders.php

	public function recurring_charge( $order_id ) {

		$order = new LLMS_Order( $order_id );
		$gateway = $order->get_gateway();

		// ensure the gateway is still installed & available
		if ( ! is_wp_error( $gateway ) ) {

			if ( ! $gateway->supports( 'recurring_payments' ) ) {

				do_action( 'llms_order_recurring_charge_gateway_payments_disabled', $order_id, $gateway, $this );

				llms_log( 'Recurring charge for order # ' . $order_id . ' could not be processed because the gateway no longer supports recurring payments', 'recurring-payments' );

				$order->add_note( __( 'Recurring charge skipped because recurring payments are disabled in for the payment gateway.', 'lifterlms' ) );

			} elseif ( ! LLMS_Site::get_feature( 'recurring_payments' ) ) {

				do_action( 'llms_order_recurring_charge_skipped', $order_id, $gateway, $this );
				$order->add_note( __( 'Recurring charge skipped because recurring payments are disabled in staging mode.', 'lifterlms' ) );

			} else {

				$gateway->handle_recurring_transaction( $order );

			}
		} else {

			do_action( 'llms_order_recurring_charge_gateway_error', $order_id, $gateway, $this );

			llms_log( 'Recurring charge for order # ' . $order_id . ' could not be processed', 'recurring-payments' );
			llms_log( $gateway->get_error_message(), 'recurring-payments' );

			$order->add_note(
				sprintf(
					__( 'A recurring charge was not processed due to an error encountered while loading the payment gateway: "%s"', 'lifterlms' ),
					$gateway->get_error_message()
				)
			);

		}// End if().

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.32.0 Record order notes and trigger actions during errors.
3.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.





Permalink: