From 213b8968de1f3610ec5b6169173ded8a35cb240d Mon Sep 17 00:00:00 2001 From: PaylineGitHub Date: Tue, 2 Jan 2018 15:14:43 +0100 Subject: [PATCH] Truncate buyer data before send it to Payline --- README.md | 1 + class-wc-gateway-payline.php | 34 ++++++++++++++++++---------------- woocommerce-payline.php | 2 +- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 6b66f26..4442e9e 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ Changelog * 1.3.6 - 2018/01/02 Feature - woocommerce 3.x compatibility + Fix - Truncate buyer data before send it to Payline. * 1.3.5 - 2017/04/04 Feature - send buyer info mandatoty for Cetelem 3x / 4x diff --git a/class-wc-gateway-payline.php b/class-wc-gateway-payline.php index f374f0b..f5e4659 100644 --- a/class-wc-gateway-payline.php +++ b/class-wc-gateway-payline.php @@ -590,38 +590,40 @@ function generate_payline_form($order_id) { // BUYER $doWebPaymentRequest['buyer']['title'] = 'M'; - $doWebPaymentRequest['buyer']['lastName'] = $order->get_billing_last_name(); - $doWebPaymentRequest['buyer']['firstName'] = $order->get_billing_first_name(); + $doWebPaymentRequest['buyer']['lastName'] = substr($order->get_billing_last_name(), 0, 100); + $doWebPaymentRequest['buyer']['firstName'] = substr($order->get_billing_first_name(), 0, 100); $doWebPaymentRequest['buyer']['customerId'] = $order->get_billing_email(); $doWebPaymentRequest['buyer']['email'] = $doWebPaymentRequest['buyer']['customerId']; $doWebPaymentRequest['buyer']['ip'] = $_SERVER['REMOTE_ADDR']; - $doWebPaymentRequest['buyer']['mobilePhone'] = preg_replace("/[^0-9.]/", '', $order->get_billing_phone()); + $doWebPaymentRequest['buyer']['mobilePhone'] = substr(preg_replace("/[^0-9.]/", '', $order->get_billing_phone()), 0, 15); // BILLING ADDRESS $doWebPaymentRequest['billingAddress']['name'] = $order->get_billing_first_name()." ".$order->get_billing_last_name(); if($order->get_billing_company() != null && strlen($order->get_billing_company()) > 0){ $doWebPaymentRequest['billingAddress']['name'] .= ' ('.$order->get_billing_company().')'; } - $doWebPaymentRequest['billingAddress']['firstName'] = $order->get_billing_first_name(); - $doWebPaymentRequest['billingAddress']['lastName'] = $order->get_billing_last_name(); - $doWebPaymentRequest['billingAddress']['street1'] = $order->get_billing_address_1(); - $doWebPaymentRequest['billingAddress']['street2'] = $order->get_billing_address_2(); - $doWebPaymentRequest['billingAddress']['cityName'] = $order->get_billing_city(); - $doWebPaymentRequest['billingAddress']['zipCode'] = $order->get_billing_postcode(); + $doWebPaymentRequest['billingAddress']['name'] = substr($doWebPaymentRequest['billingAddress']['name'], 0, 100); + $doWebPaymentRequest['billingAddress']['firstName'] = substr($order->get_billing_first_name(), 0, 100); + $doWebPaymentRequest['billingAddress']['lastName'] = substr($order->get_billing_last_name(), 0, 100); + $doWebPaymentRequest['billingAddress']['street1'] = substr($order->get_billing_address_1(), 0, 100); + $doWebPaymentRequest['billingAddress']['street2'] = substr($order->get_billing_address_2(), 0, 100); + $doWebPaymentRequest['billingAddress']['cityName'] = substr($order->get_billing_city(), 0, 40); + $doWebPaymentRequest['billingAddress']['zipCode'] = substr($order->get_billing_postcode(), 0, 20); $doWebPaymentRequest['billingAddress']['country'] = $order->get_billing_country(); - $doWebPaymentRequest['billingAddress']['phone'] = preg_replace("/[^0-9.]/", '', $order->get_billing_phone()); + $doWebPaymentRequest['billingAddress']['phone'] = substr(preg_replace("/[^0-9.]/", '', $order->get_billing_phone()), 0, 15); // SHIPPING ADDRESS $doWebPaymentRequest['shippingAddress']['name'] = $order->get_shipping_first_name() ." ".$order->get_shipping_last_name(); if($order->get_shipping_company() != null && strlen($order->get_shipping_company()) > 0){ $doWebPaymentRequest['shippingAddress']['name'] .= ' ('.$order->get_shipping_company().')'; } - $doWebPaymentRequest['shippingAddress']['firstName'] = $order->get_shipping_first_name(); - $doWebPaymentRequest['shippingAddress']['lastName'] = $order->get_shipping_last_name(); - $doWebPaymentRequest['shippingAddress']['street1'] = $order->get_shipping_address_1(); - $doWebPaymentRequest['shippingAddress']['street2'] = $order->get_shipping_address_2(); - $doWebPaymentRequest['shippingAddress']['cityName'] = $order->get_shipping_city(); - $doWebPaymentRequest['shippingAddress']['zipCode'] = $order->get_shipping_postcode(); + $doWebPaymentRequest['shippingAddress']['name'] = substr($doWebPaymentRequest['shippingAddress']['name'], 0, 100); + $doWebPaymentRequest['shippingAddress']['firstName'] = substr($order->get_shipping_first_name(), 0, 100); + $doWebPaymentRequest['shippingAddress']['lastName'] = substr($order->get_shipping_last_name(), 0, 100); + $doWebPaymentRequest['shippingAddress']['street1'] = substr($order->get_shipping_address_1(), 0, 100); + $doWebPaymentRequest['shippingAddress']['street2'] = substr($order->get_shipping_address_2(), 0, 100); + $doWebPaymentRequest['shippingAddress']['cityName'] = substr($order->get_shipping_city(), 0, 40); + $doWebPaymentRequest['shippingAddress']['zipCode'] = substr($order->get_shipping_postcode(), 0, 20); $doWebPaymentRequest['shippingAddress']['country'] = $order->get_shipping_country(); $doWebPaymentRequest['shippingAddress']['phone'] = ''; diff --git a/woocommerce-payline.php b/woocommerce-payline.php index 5a7fb9c..c932d72 100644 --- a/woocommerce-payline.php +++ b/woocommerce-payline.php @@ -3,7 +3,7 @@ * Plugin Name: Payline * Plugin URI: http://www.payline.com * Description: integrations of Payline payment solution in your WooCommerce store - * Version: 1.3.5 + * Version: 1.3.6 * Author: Monext * Author URI: http://www.monext.fr * License: LGPL-3.0+