WC_Gateway_Paypal_IPN_Handler::payment_status_completed
Handle a completed payment.
Method of the class: WC_Gateway_Paypal_IPN_Handler{}
No Hooks.
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->payment_status_completed( $order, $posted );
- $order(WC_Order) (required)
- Order object.
- $posted(array) (required)
- Posted data.
WC_Gateway_Paypal_IPN_Handler::payment_status_completed() WC Gateway Paypal IPN Handler::payment status completed code WC 10.5.0
protected function payment_status_completed( $order, $posted ) {
if ( $order->has_status( wc_get_is_paid_statuses() ) ) {
WC_Gateway_Paypal::log( 'Aborting, Order #' . $order->get_id() . ' is already complete.' );
exit;
}
$this->validate_transaction_type( $posted['txn_type'] );
$this->validate_currency( $order, $posted['mc_currency'] );
$this->validate_amount( $order, $posted['mc_gross'] );
$this->validate_receiver_email( $order, $posted['receiver_email'] );
$this->save_paypal_meta_data( $order, $posted );
if ( OrderStatus::COMPLETED === $posted['payment_status'] ) {
if ( $order->has_status( OrderStatus::CANCELLED ) ) {
$this->payment_status_paid_cancelled_order( $order, $posted );
}
if ( ! empty( $posted['mc_fee'] ) ) {
$order->add_meta_data( 'PayPal Transaction Fee', wc_clean( $posted['mc_fee'] ) );
}
$this->payment_complete( $order, ( ! empty( $posted['txn_id'] ) ? wc_clean( $posted['txn_id'] ) : '' ), __( 'IPN payment completed', 'woocommerce' ) );
} else {
if ( 'authorization' === $posted['pending_reason'] ) {
$this->payment_on_hold( $order, __( 'Payment authorized. Change payment status to processing or complete to capture funds.', 'woocommerce' ) );
} else {
/* translators: %s: pending reason. */
$this->payment_on_hold( $order, sprintf( __( 'Payment pending (%s).', 'woocommerce' ), $posted['pending_reason'] ) );
}
}
}