WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
функция не описана

WC_Gateway_Paypal_PDT_Handler::check_response() public WC 1.0

Check Response for PDT.

{} Это метод класса: WC_Gateway_Paypal_PDT_Handler{}

Хуков нет.

Возвращает

Null. Ничего.

Использование

$WC_Gateway_Paypal_PDT_Handler = new WC_Gateway_Paypal_PDT_Handler();
$WC_Gateway_Paypal_PDT_Handler->check_response();

Код WC_Gateway_Paypal_PDT_Handler::check_response() WC 5.0.0

<?php
public function check_response() {
	if ( empty( $_REQUEST['cm'] ) || empty( $_REQUEST['tx'] ) || empty( $_REQUEST['st'] ) ) { // WPCS: Input var ok, CSRF ok, sanitization ok.
		return;
	}

	$order_id    = wc_clean( wp_unslash( $_REQUEST['cm'] ) ); // WPCS: input var ok, CSRF ok, sanitization ok.
	$status      = wc_clean( strtolower( wp_unslash( $_REQUEST['st'] ) ) ); // WPCS: input var ok, CSRF ok, sanitization ok.
	$amount      = isset( $_REQUEST['amt'] ) ? wc_clean( wp_unslash( $_REQUEST['amt'] ) ) : 0; // WPCS: input var ok, CSRF ok, sanitization ok.
	$transaction = wc_clean( wp_unslash( $_REQUEST['tx'] ) ); // WPCS: input var ok, CSRF ok, sanitization ok.
	$order       = $this->get_paypal_order( $order_id );

	if ( ! $order || ! $order->needs_payment() ) {
		return false;
	}

	$transaction_result = $this->validate_transaction( $transaction );

	if ( $transaction_result ) {
		WC_Gateway_Paypal::log( 'PDT Transaction Status: ' . wc_print_r( $status, true ) );

		$order->add_meta_data( '_paypal_status', $status );
		$order->set_transaction_id( $transaction );

		if ( 'completed' === $status ) {
			if ( number_format( $order->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
				WC_Gateway_Paypal::log( 'Payment error: Amounts do not match (amt ' . $amount . ')', 'error' );
				/* translators: 1: Payment amount */
				$this->payment_on_hold( $order, sprintf( __( 'Validation error: PayPal amounts do not match (amt %s).', 'woocommerce' ), $amount ) );
			} else {
				// Log paypal transaction fee and payment type.
				if ( ! empty( $transaction_result['mc_fee'] ) ) {
					$order->add_meta_data( 'PayPal Transaction Fee', wc_clean( $transaction_result['mc_fee'] ) );
				}
				if ( ! empty( $transaction_result['payment_type'] ) ) {
					$order->add_meta_data( 'Payment type', wc_clean( $transaction_result['payment_type'] ) );
				}

				$this->payment_complete( $order, $transaction, __( 'PDT payment completed', 'woocommerce' ) );
			}
		} else {
			if ( 'authorization' === $transaction_result['pending_reason'] ) {
				$this->payment_on_hold( $order, __( 'Payment authorized. Change payment status to processing or complete to capture funds.', 'woocommerce' ) );
			} else {
				/* translators: 1: Pending reason */
				$this->payment_on_hold( $order, sprintf( __( 'Payment pending (%s).', 'woocommerce' ), $transaction_result['pending_reason'] ) );
			}
		}
	} else {
		WC_Gateway_Paypal::log( 'Received invalid response from PayPal PDT' );
	}
}