Skip to content

Commit

Permalink
Sanitize phone number field
Browse files Browse the repository at this point in the history
To avoid this error:

You can't be redirected to payment page (error code 02305 : Invalid field format : MobilePhone : Must be composed from 1 to 14 numeric, ex : +00334916666666 or 00334916666666). Please contact us.

If the user phone number contains spaces, commas or other non numeric characters.
  • Loading branch information
nicomollet authored May 11, 2017
1 parent dff1836 commit 6975b26
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions class-wc-gateway-payline.php
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ function generate_payline_form($order_id) {
$doWebPaymentRequest['buyer']['customerId'] = $order->billing_email;
$doWebPaymentRequest['buyer']['email'] = $doWebPaymentRequest['buyer']['customerId'];
$doWebPaymentRequest['buyer']['ip'] = $_SERVER['REMOTE_ADDR'];
$doWebPaymentRequest['buyer']['mobilePhone'] = $order->billing_phone;
$doWebPaymentRequest['buyer']['mobilePhone'] = preg_replace("/[^0-9.]/", '', $order->billing_phone);

// BILLING ADDRESS
$doWebPaymentRequest['billingAddress']['name'] = $order->billing_first_name." ".$order->billing_last_name;
Expand All @@ -609,7 +609,7 @@ function generate_payline_form($order_id) {
$doWebPaymentRequest['billingAddress']['cityName'] = $order->billing_city;
$doWebPaymentRequest['billingAddress']['zipCode'] = $order->billing_postcode;
$doWebPaymentRequest['billingAddress']['country'] = $order->billing_country;
$doWebPaymentRequest['billingAddress']['phone'] = $order->billing_phone;
$doWebPaymentRequest['billingAddress']['phone'] = preg_replace("/[^0-9.]/", '', $order->billing_phone);

// SHIPPING ADDRESS
$doWebPaymentRequest['shippingAddress']['name'] = $order->shipping_first_name ." ".$order->shipping_last_name;
Expand Down Expand Up @@ -738,4 +738,4 @@ function payline_callback() {
}
}
}
}
}

0 comments on commit 6975b26

Please sign in to comment.