diff --git a/README.md b/README.md index f1452a3..6b66f26 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Requirements ------------ This extension requires at least wooCommerce 2.3 -It's tested up to wooCommerce 2.6.4 +It's tested up to wooCommerce 2.6.4 and woocommerce 3.x Author @@ -33,6 +33,9 @@ Payline is licensed under the LGPL-3.0+ License Changelog ------- +* 1.3.6 - 2018/01/02 + Feature - woocommerce 3.x compatibility + * 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 8c0908d..f374f0b 100644 --- a/class-wc-gateway-payline.php +++ b/class-wc-gateway-payline.php @@ -4,268 +4,268 @@ /** * Payline module for WooCommerce - * + * * @class WC_Payline * @package WooCommerce * @category Payment Gateways */ class WC_Gateway_Payline extends WC_Payment_Gateway { - private $extensionVersion = '1.3.5'; + private $extensionVersion = '1.3.6'; private $SDK; private $posData; private $disp_errors = ""; private $callGetMerchantSettings = true; - + const BAD_CONNECT_SETTINGS_ERR = "Unauthorized"; const BAD_PROXY_SETTINGS_ERR = "Could not connect to host"; - + var $_currencies = array( - 'EUR' => '978', // Euro - 'AFN' => '971', // Afghani - 'ALL' => '8', // Lek - 'DZD' => '12', // Algerian Dinar - 'USD' => '840', // US Dollar - 'AOA' => '973', // Kwanza - 'XCD' => '951', // East Caribbean Dollar - 'ARS' => '32', // Argentine Peso - 'AMD' => '51', // Armenian Dram - 'AWG' => '533', // Aruban Guilder - 'AUD' => '36', // Australian Dollar - 'AZN' => '944', // Azerbaijanian Manat - 'BSD' => '44', // Bahamian Dollar - 'BHD' => '48', // Bahraini Dinar - 'BDT' => '50', // Taka - 'BBD' => '52', // Barbados Dollar - 'BYR' => '974', // Belarussian Ruble - 'BZD' => '84', // Belize Dollar - 'XOF' => '952', // CFA Franc BCEAO � - 'BMD' => '60', // Bermudian Dollar (customarily known as Bermuda Dollar) - 'INR' => '356', // Indian Rupee - 'BTN' => '64', // Ngultrum - 'BOB' => '68', // Boliviano - 'BOV' => '984', // Mvdol - 'BAM' => '977', // Convertible Marks - 'BWP' => '72', // Pula - 'NOK' => '578', // Norwegian Krone - 'BRL' => '986', // Brazilian Real - 'BND' => '96', // Brunei Dollar - 'BGN' => '975', // Bulgarian Lev - 'BIF' => '108', // Burundi Franc - 'KHR' => '116', // Riel - 'XAF' => '950', // CFA Franc BEAC � - 'CAD' => '124', // Canadian Dollar - 'CVE' => '132', // Cape Verde Escudo - 'KYD' => '136', // Cayman Islands Dollar - 'CLP' => '152', // Chilean Peso - 'CLF' => '990', // Unidades de formento - 'CNY' => '156', // Yuan Renminbi - 'COP' => '170', // Colombian Peso - 'COU' => '970', // Unidad de Valor Real - 'KMF' => '174', // Comoro Franc - 'CDF' => '976', // Franc Congolais - 'NZD' => '554', // New Zealand Dollar - 'CRC' => '188', // Costa Rican Colon - 'HRK' => '191', // Croatian Kuna - 'CUP' => '192', // Cuban Peso - 'CYP' => '196', // Cyprus Pound - 'CZK' => '203', // Czech Koruna - 'DKK' => '208', // Danish Krone - 'DJF' => '262', // Djibouti Franc - 'DOP' => '214', // Dominican Peso - 'EGP' => '818', // Egyptian Pound - 'SVC' => '222', // El Salvador Colon - 'ERN' => '232', // Nakfa - 'EEK' => '233', // Kroon - 'ETB' => '230', // Ethiopian Birr - 'FKP' => '238', // Falkland Islands Pound - 'FJD' => '242', // Fiji Dollar - 'XPF' => '953', // CFP Franc - 'GMD' => '270', // Dalasi - 'GEL' => '981', // Lari - 'GHC' => '288', // Cedi - 'GIP' => '292', // Gibraltar Pound - 'GTQ' => '320', // Quetzal - 'GNF' => '324', // Guinea Franc - 'GWP' => '624', // Guinea-Bissau Peso - 'GYD' => '328', // Guyana Dollar - 'HTG' => '332', // Gourde - 'HNL' => '340', // Lempira - 'HKD' => '344', // Hong Kong Dollar - 'HUF' => '348', // Forint - 'ISK' => '352', // Iceland Krona - 'IDR' => '360', // Rupiah - 'XDR' => '960', // SDR - 'IRR' => '364', // Iranian Rial - 'IQD' => '368', // Iraqi Dinar - 'ILS' => '376', // New Israeli Sheqel - 'JMD' => '388', // Jamaican Dollar - 'JPY' => '392', // Yen - 'JOD' => '400', // Jordanian Dinar - 'KZT' => '398', // Tenge - 'KES' => '404', // Kenyan Shilling - 'KPW' => '408', // North Korean Won - 'KRW' => '410', // Won - 'KWD' => '414', // Kuwaiti Dinar - 'KGS' => '417', // Som - 'LAK' => '418', // Kip - 'LVL' => '428', // Latvian Lats - 'LBP' => '422', // Lebanese Pound - 'ZAR' => '710', // Rand - 'LSL' => '426', // Loti - 'LRD' => '430', // Liberian Dollar - 'LYD' => '434', // Libyan Dinar - 'CHF' => '756', // Swiss Franc - 'LTL' => '440', // Lithuanian Litas - 'MOP' => '446', // Pataca - 'MKD' => '807', // Denar - 'MGA' => '969', // Malagascy Ariary - 'MWK' => '454', // Kwacha - 'MYR' => '458', // Malaysian Ringgit - 'MVR' => '462', // Rufiyaa - 'MTL' => '470', // Maltese Lira - 'MRO' => '478', // Ouguiya - 'MUR' => '480', // Mauritius Rupee - 'MXN' => '484', // Mexican Peso - 'MXV' => '979', // Mexican Unidad de Inversion (UID) - 'MDL' => '498', // Moldovan Leu - 'MNT' => '496', // Tugrik - 'MAD' => '504', // Moroccan Dirham - 'MZN' => '943', // Metical - 'MMK' => '104', // Kyat - 'NAD' => '516', // Namibian Dollar - 'NPR' => '524', // Nepalese Rupee - 'ANG' => '532', // Netherlands Antillian Guilder - 'NIO' => '558', // Cordoba Oro - 'NGN' => '566', // Naira - 'OMR' => '512', // Rial Omani - 'PKR' => '586', // Pakistan Rupee - 'PAB' => '590', // Balboa - 'PGK' => '598', // Kina - 'PYG' => '600', // Guarani - 'PEN' => '604', // Nuevo Sol - 'PHP' => '608', // Philippine Peso - 'PLN' => '985', // Zloty - 'QAR' => '634', // Qatari Rial - 'ROL' => '642', // Old Leu - 'RON' => '946', // New Leu - 'RUB' => '643', // Russian Ruble - 'RWF' => '646', // Rwanda Franc - 'SHP' => '654', // Saint Helena Pound - 'WST' => '882', // Tala - 'STD' => '678', // Dobra - 'SAR' => '682', // Saudi Riyal - 'RSD' => '941', // Serbian Dinar - 'SCR' => '690', // Seychelles Rupee - 'SLL' => '694', // Leone - 'SGD' => '702', // Singapore Dollar - 'SKK' => '703', // Slovak Koruna - 'SIT' => '705', // Tolar - 'SBD' => '90', // Solomon Islands Dollar - 'SOS' => '706', // Somali Shilling - 'LKR' => '144', // Sri Lanka Rupee - 'SDG' => '938', // Sudanese Dinar - 'SRD' => '968', // Surinam Dollar - 'SZL' => '748', // Lilangeni - 'SEK' => '752', // Swedish Krona - 'CHW' => '948', // WIR Franc - 'CHE' => '947', // WIR Euro - 'SYP' => '760', // Syrian Pound - 'TWD' => '901', // New Taiwan Dollar - 'TJS' => '972', // Somoni - 'TZS' => '834', // Tanzanian Shilling - 'THB' => '764', // Baht - 'TOP' => '776', // Pa'anga - 'TTD' => '780', // Trinidad and Tobago Dollar - 'TND' => '788', // Tunisian Dinar - 'TRY' => '949', // New Turkish Lira - 'TMM' => '795', // Manat - 'UGX' => '800', // Uganda Shilling - 'UAH' => '980', // Hryvnia - 'AED' => '784', // UAE Dirham - 'GBP' => '826', // Pound Sterling - 'USS' => '998', // (Same day) - 'USN' => '997', // (Next day) - 'UYU' => '858', // Peso Uruguayo - 'UYI' => '940', // Uruguay Peso en Unidades Indexadas - 'UZS' => '860', // Uzbekistan Sum - 'VUV' => '548', // Vatu - 'VEB' => '862', // Bolivar - 'VND' => '704', // Dong - 'YER' => '886', // Yemeni Rial - 'ZMK' => '894', // Kwacha - 'ZWD' => '716', // Zimbabwe Dollar - 'XAU' => '959', // Gold - 'XBA' => '955', // Bond Markets Units European Composite Unit (EURCO) - 'XBB' => '956', // European Monetary Unit (E.M.U.-6) - 'XBC' => '957', // European Unit of Account 9(E.U.A.-9) - 'XBD' => '958', // European Unit of Account 17(E.U.A.-17) - 'XPD' => '964', // Palladium - 'XPT' => '962', // Platinum - 'XAG' => '961', // Silver - 'XTS' => '963', // Codes specifically reserved for testing purposes - 'XXX' => '999', // The codes assigned for transactions where no currency is involved + 'EUR' => '978', // Euro + 'AFN' => '971', // Afghani + 'ALL' => '8', // Lek + 'DZD' => '12', // Algerian Dinar + 'USD' => '840', // US Dollar + 'AOA' => '973', // Kwanza + 'XCD' => '951', // East Caribbean Dollar + 'ARS' => '32', // Argentine Peso + 'AMD' => '51', // Armenian Dram + 'AWG' => '533', // Aruban Guilder + 'AUD' => '36', // Australian Dollar + 'AZN' => '944', // Azerbaijanian Manat + 'BSD' => '44', // Bahamian Dollar + 'BHD' => '48', // Bahraini Dinar + 'BDT' => '50', // Taka + 'BBD' => '52', // Barbados Dollar + 'BYR' => '974', // Belarussian Ruble + 'BZD' => '84', // Belize Dollar + 'XOF' => '952', // CFA Franc BCEAO � + 'BMD' => '60', // Bermudian Dollar (customarily known as Bermuda Dollar) + 'INR' => '356', // Indian Rupee + 'BTN' => '64', // Ngultrum + 'BOB' => '68', // Boliviano + 'BOV' => '984', // Mvdol + 'BAM' => '977', // Convertible Marks + 'BWP' => '72', // Pula + 'NOK' => '578', // Norwegian Krone + 'BRL' => '986', // Brazilian Real + 'BND' => '96', // Brunei Dollar + 'BGN' => '975', // Bulgarian Lev + 'BIF' => '108', // Burundi Franc + 'KHR' => '116', // Riel + 'XAF' => '950', // CFA Franc BEAC � + 'CAD' => '124', // Canadian Dollar + 'CVE' => '132', // Cape Verde Escudo + 'KYD' => '136', // Cayman Islands Dollar + 'CLP' => '152', // Chilean Peso + 'CLF' => '990', // Unidades de formento + 'CNY' => '156', // Yuan Renminbi + 'COP' => '170', // Colombian Peso + 'COU' => '970', // Unidad de Valor Real + 'KMF' => '174', // Comoro Franc + 'CDF' => '976', // Franc Congolais + 'NZD' => '554', // New Zealand Dollar + 'CRC' => '188', // Costa Rican Colon + 'HRK' => '191', // Croatian Kuna + 'CUP' => '192', // Cuban Peso + 'CYP' => '196', // Cyprus Pound + 'CZK' => '203', // Czech Koruna + 'DKK' => '208', // Danish Krone + 'DJF' => '262', // Djibouti Franc + 'DOP' => '214', // Dominican Peso + 'EGP' => '818', // Egyptian Pound + 'SVC' => '222', // El Salvador Colon + 'ERN' => '232', // Nakfa + 'EEK' => '233', // Kroon + 'ETB' => '230', // Ethiopian Birr + 'FKP' => '238', // Falkland Islands Pound + 'FJD' => '242', // Fiji Dollar + 'XPF' => '953', // CFP Franc + 'GMD' => '270', // Dalasi + 'GEL' => '981', // Lari + 'GHC' => '288', // Cedi + 'GIP' => '292', // Gibraltar Pound + 'GTQ' => '320', // Quetzal + 'GNF' => '324', // Guinea Franc + 'GWP' => '624', // Guinea-Bissau Peso + 'GYD' => '328', // Guyana Dollar + 'HTG' => '332', // Gourde + 'HNL' => '340', // Lempira + 'HKD' => '344', // Hong Kong Dollar + 'HUF' => '348', // Forint + 'ISK' => '352', // Iceland Krona + 'IDR' => '360', // Rupiah + 'XDR' => '960', // SDR + 'IRR' => '364', // Iranian Rial + 'IQD' => '368', // Iraqi Dinar + 'ILS' => '376', // New Israeli Sheqel + 'JMD' => '388', // Jamaican Dollar + 'JPY' => '392', // Yen + 'JOD' => '400', // Jordanian Dinar + 'KZT' => '398', // Tenge + 'KES' => '404', // Kenyan Shilling + 'KPW' => '408', // North Korean Won + 'KRW' => '410', // Won + 'KWD' => '414', // Kuwaiti Dinar + 'KGS' => '417', // Som + 'LAK' => '418', // Kip + 'LVL' => '428', // Latvian Lats + 'LBP' => '422', // Lebanese Pound + 'ZAR' => '710', // Rand + 'LSL' => '426', // Loti + 'LRD' => '430', // Liberian Dollar + 'LYD' => '434', // Libyan Dinar + 'CHF' => '756', // Swiss Franc + 'LTL' => '440', // Lithuanian Litas + 'MOP' => '446', // Pataca + 'MKD' => '807', // Denar + 'MGA' => '969', // Malagascy Ariary + 'MWK' => '454', // Kwacha + 'MYR' => '458', // Malaysian Ringgit + 'MVR' => '462', // Rufiyaa + 'MTL' => '470', // Maltese Lira + 'MRO' => '478', // Ouguiya + 'MUR' => '480', // Mauritius Rupee + 'MXN' => '484', // Mexican Peso + 'MXV' => '979', // Mexican Unidad de Inversion (UID) + 'MDL' => '498', // Moldovan Leu + 'MNT' => '496', // Tugrik + 'MAD' => '504', // Moroccan Dirham + 'MZN' => '943', // Metical + 'MMK' => '104', // Kyat + 'NAD' => '516', // Namibian Dollar + 'NPR' => '524', // Nepalese Rupee + 'ANG' => '532', // Netherlands Antillian Guilder + 'NIO' => '558', // Cordoba Oro + 'NGN' => '566', // Naira + 'OMR' => '512', // Rial Omani + 'PKR' => '586', // Pakistan Rupee + 'PAB' => '590', // Balboa + 'PGK' => '598', // Kina + 'PYG' => '600', // Guarani + 'PEN' => '604', // Nuevo Sol + 'PHP' => '608', // Philippine Peso + 'PLN' => '985', // Zloty + 'QAR' => '634', // Qatari Rial + 'ROL' => '642', // Old Leu + 'RON' => '946', // New Leu + 'RUB' => '643', // Russian Ruble + 'RWF' => '646', // Rwanda Franc + 'SHP' => '654', // Saint Helena Pound + 'WST' => '882', // Tala + 'STD' => '678', // Dobra + 'SAR' => '682', // Saudi Riyal + 'RSD' => '941', // Serbian Dinar + 'SCR' => '690', // Seychelles Rupee + 'SLL' => '694', // Leone + 'SGD' => '702', // Singapore Dollar + 'SKK' => '703', // Slovak Koruna + 'SIT' => '705', // Tolar + 'SBD' => '90', // Solomon Islands Dollar + 'SOS' => '706', // Somali Shilling + 'LKR' => '144', // Sri Lanka Rupee + 'SDG' => '938', // Sudanese Dinar + 'SRD' => '968', // Surinam Dollar + 'SZL' => '748', // Lilangeni + 'SEK' => '752', // Swedish Krona + 'CHW' => '948', // WIR Franc + 'CHE' => '947', // WIR Euro + 'SYP' => '760', // Syrian Pound + 'TWD' => '901', // New Taiwan Dollar + 'TJS' => '972', // Somoni + 'TZS' => '834', // Tanzanian Shilling + 'THB' => '764', // Baht + 'TOP' => '776', // Pa'anga + 'TTD' => '780', // Trinidad and Tobago Dollar + 'TND' => '788', // Tunisian Dinar + 'TRY' => '949', // New Turkish Lira + 'TMM' => '795', // Manat + 'UGX' => '800', // Uganda Shilling + 'UAH' => '980', // Hryvnia + 'AED' => '784', // UAE Dirham + 'GBP' => '826', // Pound Sterling + 'USS' => '998', // (Same day) + 'USN' => '997', // (Next day) + 'UYU' => '858', // Peso Uruguayo + 'UYI' => '940', // Uruguay Peso en Unidades Indexadas + 'UZS' => '860', // Uzbekistan Sum + 'VUV' => '548', // Vatu + 'VEB' => '862', // Bolivar + 'VND' => '704', // Dong + 'YER' => '886', // Yemeni Rial + 'ZMK' => '894', // Kwacha + 'ZWD' => '716', // Zimbabwe Dollar + 'XAU' => '959', // Gold + 'XBA' => '955', // Bond Markets Units European Composite Unit (EURCO) + 'XBB' => '956', // European Monetary Unit (E.M.U.-6) + 'XBC' => '957', // European Unit of Account 9(E.U.A.-9) + 'XBD' => '958', // European Unit of Account 17(E.U.A.-17) + 'XPD' => '964', // Palladium + 'XPT' => '962', // Platinum + 'XAG' => '961', // Silver + 'XTS' => '963', // Codes specifically reserved for testing purposes + 'XXX' => '999', // The codes assigned for transactions where no currency is involved ); - + public function __construct() { - + $this->id = 'payline'; $this->icon = apply_filters('woocommerce_payline_icon', WCPAYLINE_PLUGIN_URL . 'assets/images/payline_front.png'); $this->has_fields = false; $this->method_title = 'Payline'; $this->order_button_text = __( 'Pay via Payline', 'payline' ); - + // Load the form fields. $this->init_form_fields(); - + // Load the settings. $this->init_settings(); - + // Define user set variables $this->title = $this->settings['title']; $this->description = $this->settings['description']; $this->testmode = (isset($this->settings['ctx_mode']) && $this->settings['ctx_mode'] === 'TEST'); - $this->debug = (isset($this->settings['debug']) && $this->settings['debug'] == 'yes') ? true : false; - + $this->debug = (isset($this->settings['debug']) && $this->settings['debug'] == 'yes') ? true : false; + // The module settings page URL $link = add_query_arg('page', 'wc-settings', admin_url('admin.php')); $link = add_query_arg('tab', 'checkout', $link); $link = add_query_arg('section', 'payline', $link); $this->admin_link = $link; - + // logger if ($this->debug) { $this->log = new WC_Logger(); } - + // Actions - + // Reset payline admin form action add_action('payline_reset_admin_options', array($this, 'reset_admin_options')); - + // Generate form action add_action('woocommerce_receipt_payline', array($this, 'generate_payline_form')); - + // Update admin form action add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); - + // Return from payment platform action add_action('woocommerce_api_wc_gateway_payline', array($this, 'payline_callback')); - } - + } + function get_icon() { $icon = $this->icon ? '' : ''; return apply_filters( 'woocommerce_gateway_icon', $icon, $this->id ); } - + public function admin_options() { global $woocommerce; - + if(key_exists('reset', $_REQUEST) && $_REQUEST['reset'] == 'true') { do_action('payline_reset_admin_options'); } - ?> - + ?> +
@@ -280,7 +280,7 @@ public function admin_options() { settings['merchant_id']; if(strcmp("PROD",$this->settings['environment'])==0){ - $mailSubject .= " in PRODUCTION"; + $mailSubject .= " in PRODUCTION"; }else{ $mailSubject .= " in HOMOLOGATION"; } @@ -290,15 +290,15 @@ public function admin_options() { |
".sprintf(__( 'Your %s configuration parameters are reset.', 'payline'), 'Payline')."
".sprintf(__( '%s is mandatory', 'payline'), __('Merchant ID', 'payline' ))."
"; @@ -307,13 +307,13 @@ public function admin_options() { $this->callGetMerchantSettings = false; $this->disp_errors .= "".sprintf(__( '%s is mandatory', 'payline'), __('Access Key', 'payline' ))."
"; } - + if($this->settings['main_contract'] == null || strlen($this->settings['main_contract']) == 0){ $this->callGetMerchantSettings = false; $this->disp_errors .= "".sprintf(__( '%s is mandatory', 'payline'), __('Main contract number', 'payline' ))."
"; } if($this->callGetMerchantSettings){ - + $this->SDK = new PaylineSDK( $this->settings['merchant_id'], $this->settings['access_key'], @@ -342,45 +342,45 @@ public function admin_options() { } } } - + if($this->disp_errors != ""){ echo "woocommerce/logs/%s.txt
', 'payline'), 'Payline', 'payline'),
);
-
+
/*
* Connexion
*/
@@ -440,14 +440,14 @@ function init_form_fields() {
'type' => 'title'
);
$this->form_fields['merchant_id'] = array(
- 'title' => __('Merchant ID', 'payline'),
- 'type' => 'text',
+ 'title' => __('Merchant ID', 'payline'),
+ 'type' => 'text',
'default' => '',
'description' => __('Your Payline account identifier', 'payline')
);
$this->form_fields['access_key'] = array(
- 'title' => __('Access key', 'payline'),
- 'type' => 'text',
+ 'title' => __('Access key', 'payline'),
+ 'type' => 'text',
'default' => '',
'description' => sprintf(__( 'Password used to call %s web services (available in the %s administration center)', 'payline'), 'Payline','Payline')
);
@@ -456,12 +456,12 @@ function init_form_fields() {
'type' => 'select',
'default' => 'Homologation',
'options' => array(
- PaylineSDK::ENV_HOMO => __('Homologation', 'payline'),
+ PaylineSDK::ENV_HOMO => __('Homologation', 'payline'),
PaylineSDK::ENV_PROD => __('Production', 'payline')
),
'description' => __('Payline destination environement of your requests', 'payline')
);
-
+
/*
* Proxy Settings
*/
@@ -470,22 +470,22 @@ function init_form_fields() {
'type' => 'title'
);
$this->form_fields['proxy_host'] = array(
- 'title' => __('Host', 'payline'),
- 'type' => 'text',
+ 'title' => __('Host', 'payline'),
+ 'type' => 'text',
);
$this->form_fields['proxy_port'] = array(
- 'title' => __('Port', 'payline'),
- 'type' => 'text',
+ 'title' => __('Port', 'payline'),
+ 'type' => 'text',
);
$this->form_fields['proxy_login'] = array(
- 'title' => __('Login', 'payline'),
- 'type' => 'text',
+ 'title' => __('Login', 'payline'),
+ 'type' => 'text',
);
$this->form_fields['proxy_password'] = array(
- 'title' => __('Password', 'payline'),
- 'type' => 'text',
+ 'title' => __('Password', 'payline'),
+ 'type' => 'text',
);
-
+
/*
* Payment Settings
*/
@@ -536,7 +536,7 @@ function init_form_fields() {
'description' => __('Contracts displayed for payment retry. Values must be separated by ;', 'payline')
);
}
-
+
function validate_multiselect_field ($key, $value) {
$newValue = $_POST[$this->plugin_id . $this->id . '_' . $key];
if(isset($newValue) && is_array($newValue) && in_array('', $newValue)) {
@@ -545,22 +545,22 @@ function validate_multiselect_field ($key, $value) {
return parent::validate_multiselect_field ($key);
}
}
-
+
function is_available() {
return parent::is_available();
}
-
+
function process_payment($order_id) {
$order = new WC_Order($order_id);
return array(
'result' => 'success',
- 'redirect' => add_query_arg('order', $order->id, add_query_arg('key', $order->order_key, get_permalink(woocommerce_get_page_id('pay'))))
+ 'redirect' => add_query_arg('order', $order->get_id(), add_query_arg('key', $order->get_order_key(), $order->get_checkout_order_received_url()/*get_permalink(woocommerce_get_page_id('pay'))*/))
);
}
-
+
function generate_payline_form($order_id) {
$order = new WC_Order($order_id);
-
+
$this->SDK = new PaylineSDK(
$this->settings['merchant_id'],
$this->settings['access_key'],
@@ -571,60 +571,60 @@ function generate_payline_form($order_id) {
$this->settings['environment']
);
$this->SDK->usedBy('wooComm '.$this->extensionVersion);
-
- $doWebPaymentRequest = array();
- $doWebPaymentRequest['version'] = '14';
+
+ $doWebPaymentRequest = array();
+ $doWebPaymentRequest['version'] = '14';
$doWebPaymentRequest['payment']['amount'] = round($order->get_total()*100);
- $doWebPaymentRequest['payment']['currency'] = $this->_currencies[$order->get_order_currency()];
+ $doWebPaymentRequest['payment']['currency'] = $this->_currencies[$order->get_currency()];
$doWebPaymentRequest['payment']['action'] = $this->settings['payment_action'];
$doWebPaymentRequest['payment']['mode'] = 'CPT';
$doWebPaymentRequest['payment']['contractNumber'] = $this->settings['main_contract'];
-
+
// ORDER
- $doWebPaymentRequest['order']['ref'] = $order->id;
- $doWebPaymentRequest['order']['country'] = $order->billing_country;
+ $doWebPaymentRequest['order']['ref'] = $order->get_id();
+ $doWebPaymentRequest['order']['country'] = $order->get_billing_country();
$doWebPaymentRequest['order']['taxes'] = round($order->get_total_tax());
$doWebPaymentRequest['order']['amount'] = $doWebPaymentRequest['payment']['amount'];
$doWebPaymentRequest['order']['date'] = date('d/m/Y H:i');
$doWebPaymentRequest['order']['currency'] = $doWebPaymentRequest['payment']['currency'];
-
+
// BUYER
$doWebPaymentRequest['buyer']['title'] = 'M';
- $doWebPaymentRequest['buyer']['lastName'] = $order->billing_last_name;
- $doWebPaymentRequest['buyer']['firstName'] = $order->billing_first_name;
- $doWebPaymentRequest['buyer']['customerId'] = $order->billing_email;
+ $doWebPaymentRequest['buyer']['lastName'] = $order->get_billing_last_name();
+ $doWebPaymentRequest['buyer']['firstName'] = $order->get_billing_first_name();
+ $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->billing_phone);
-
+ $doWebPaymentRequest['buyer']['mobilePhone'] = preg_replace("/[^0-9.]/", '', $order->get_billing_phone());
+
// BILLING ADDRESS
- $doWebPaymentRequest['billingAddress']['name'] = $order->billing_first_name." ".$order->billing_last_name;
- if($order->billing_company != null && strlen($order->billing_company) > 0){
- $doWebPaymentRequest['billingAddress']['name'] .= ' ('.$order->billing_company.')';
+ $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->billing_first_name;
- $doWebPaymentRequest['billingAddress']['lastName'] = $order->billing_last_name;
- $doWebPaymentRequest['billingAddress']['street1'] = $order->billing_address_1;
- $doWebPaymentRequest['billingAddress']['street2'] = $order->billing_address_2;
- $doWebPaymentRequest['billingAddress']['cityName'] = $order->billing_city;
- $doWebPaymentRequest['billingAddress']['zipCode'] = $order->billing_postcode;
- $doWebPaymentRequest['billingAddress']['country'] = $order->billing_country;
- $doWebPaymentRequest['billingAddress']['phone'] = preg_replace("/[^0-9.]/", '', $order->billing_phone);
-
+ $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']['country'] = $order->get_billing_country();
+ $doWebPaymentRequest['billingAddress']['phone'] = preg_replace("/[^0-9.]/", '', $order->get_billing_phone());
+
// SHIPPING ADDRESS
- $doWebPaymentRequest['shippingAddress']['name'] = $order->shipping_first_name ." ".$order->shipping_last_name;
- if($order->shipping_company != null && strlen($order->shipping_company) > 0){
- $doWebPaymentRequest['shippingAddress']['name'] .= ' ('.$order->shipping_company.')';
+ $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->shipping_first_name;
- $doWebPaymentRequest['shippingAddress']['lastName'] = $order->shipping_last_name;
- $doWebPaymentRequest['shippingAddress']['street1'] = $order->shipping_address_1;
- $doWebPaymentRequest['shippingAddress']['street2'] = $order->shipping_address_2;
- $doWebPaymentRequest['shippingAddress']['cityName'] = $order->shipping_city;
- $doWebPaymentRequest['shippingAddress']['zipCode'] = $order->shipping_postcode;
- $doWebPaymentRequest['shippingAddress']['country'] = $order->shipping_country;
+ $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']['country'] = $order->get_shipping_country();
$doWebPaymentRequest['shippingAddress']['phone'] = '';
-
+
// ORDER DETAILS
$items = $order->get_items();
foreach($items as $item){
@@ -635,26 +635,26 @@ function generate_payline_form($order_id) {
'comment' => ''
));
}
-
+
// TRANSACTION OPTIONS
$doWebPaymentRequest['notificationURL'] = add_query_arg('wc-api', 'WC_Gateway_Payline', home_url('/'));
$doWebPaymentRequest['returnURL'] = $doWebPaymentRequest['notificationURL'];
$doWebPaymentRequest['cancelURL'] = $doWebPaymentRequest['notificationURL'];
$doWebPaymentRequest['languageCode'] = $this->settings['language'];
$doWebPaymentRequest['customPaymentPageCode'] = $this->settings['custom_page_code'];
-
+
// PRIMARY CONTRACTS
if ($this->settings['primary_contracts'] != null && strlen($this->settings['primary_contracts']) > 0){
$contracts = explode(";",$this->settings['primary_contracts']);
$doWebPaymentRequest['contracts'] = $contracts;
}
-
+
// SECONDARY CONTRACTS
if ($this->settings['secondary_contracts'] != null && strlen($this->settings['secondary_contracts']) > 0){
$secondContracts = explode(";",$this->settings['secondary_contracts']);
$doWebPaymentRequest['secondContracts'] = $secondContracts;
}
-
+
// EXECUTE
$result = $this->SDK->doWebPayment($doWebPaymentRequest);
if($result['result']['code'] == '00000'){
@@ -665,13 +665,13 @@ function generate_payline_form($order_id) {
}
exit;
}
-
+
function payline_callback() {
if(isset($_GET['order_id'])){
$this->generate_payline_form($_GET['order_id']);
exit;
- }
-
+ }
+
$this->SDK = new PaylineSDK(
$this->settings['merchant_id'],
$this->settings['access_key'],
@@ -695,7 +695,7 @@ function payline_callback() {
$this->SDK->getLogger()->addError($message);
$order->add_order_note($message);
die($message);
- }
+ }
if($res['result']['code'] == '00000'){
// Store transaction details
update_post_meta((int) $orderId, 'Transaction ID', $res['transaction']['id']);