WC_Gateway_Paypal_IPN_Handler::validate_amount()protectedWC 1.0

Check payment amount from IPN matches the order.

Method of the class: WC_Gateway_Paypal_IPN_Handler{}

No Hooks.

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->validate_amount( $order, $amount );
$order(WC_Order) (required)
Order object.
$amount(int) (required)
Amount to validate.

WC_Gateway_Paypal_IPN_Handler::validate_amount() code WC 8.7.0

protected function validate_amount( $order, $amount ) {
	if ( number_format( $order->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
		WC_Gateway_Paypal::log( 'Payment error: Amounts do not match (gross ' . $amount . ')' );

		/* translators: %s: Amount. */
		$order->update_status( 'on-hold', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'woocommerce' ), $amount ) );
		exit;
	}
}