WC_Gateway_Paypal_IPN_Handler::validate_amount
Check payment amount from IPN matches the order.
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->validate_amount( $order, $amount );
- $order(WC_Order) (required)
- Order object.
- $amount(int) (required)
- Amount to validate.
WC_Gateway_Paypal_IPN_Handler::validate_amount() WC Gateway Paypal IPN Handler::validate amount code WC 10.6.2
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( OrderStatus::ON_HOLD, sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'woocommerce' ), $amount ) );
exit;
}
}