WC_Gateway_Paypal_Response::payment_completeprotectedWC 1.0

Complete order, add transaction ID and note.

Method of the class: WC_Gateway_Paypal_Response{}

No Hooks.

Returns

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->payment_complete( $order, $txn_id, $note );
$order(WC_Order) (required)
Order object.
$txn_id(string)
Transaction ID.
Default: ''
$note(string)
Payment note.
Default: ''

WC_Gateway_Paypal_Response::payment_complete() code WC 10.5.0

protected function payment_complete( $order, $txn_id = '', $note = '' ) {
	if ( ! $order->has_status( array( OrderStatus::PROCESSING, OrderStatus::COMPLETED ) ) ) {
		$order->add_order_note( $note );
		$order->payment_complete( $txn_id );

		if ( isset( WC()->cart ) ) {
			WC()->cart->empty_cart();
		}
	}
}