WC_Gateway_Paypal_Response::payment_complete()protectedWC 1.0

Complete order, add transaction ID and note.

Method of the class: WC_Gateway_Paypal_Response{}

No Hooks.

Return

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 8.6.1

protected function payment_complete( $order, $txn_id = '', $note = '' ) {
	if ( ! $order->has_status( array( 'processing', 'completed' ) ) ) {
		$order->add_order_note( $note );
		$order->payment_complete( $txn_id );

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