LLMS_Payment_Gateway_Manual::handle_payment_source_switch( obj $order, array $form_data = array() )

Called when the Update Payment Method form is submitted from a single order view on the student dashboard


Description Description

Gateways should do whatever the gateway needs to do to validate the new payment method and save it to the order so that future payments on the order will use this new source


Top ↑

Parameters Parameters

$order

(obj) (Required) Instance of the LLMS_Order

$form_data

(array) (Optional) Additional data passed from the submitted form (EG $_POST)

Default value: array()


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/class.llms.gateway.manual.php

	public function handle_payment_source_switch( $order, $form_data = array() ) {

		$previous_gateway = $order->get( 'payment_gateway' );

		if ( $this->get_id() === $previous_gateway ) {
			return;
		}

		$order->set( 'payment_gateway', $this->get_id() );
		$order->set( 'gateway_customer_id', '' );
		$order->set( 'gateway_source_id', '' );
		$order->set( 'gateway_subscription_id', '' );

		$order->add_note( sprintf( __( 'Payment method switched from "%1$s" to "%2$s"', 'lifterlms' ), $previous_gateway, $this->get_admin_title() ) );

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.10.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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