From 0047f98e710a02d1bc102bed2094cc3abe6a8dfc Mon Sep 17 00:00:00 2001 From: Florian Evertz Date: Thu, 25 Oct 2018 11:20:56 +0200 Subject: [PATCH 1/7] Create IV Gateway Class --- .../abstract-wc-heidelpay-payment-gateway.php | 5 ++- .../class-wc-heidelpay-gateway-iv.php | 38 +++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 includes/gateways/class-wc-heidelpay-gateway-iv.php diff --git a/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php b/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php index 1080b67..962a8e8 100644 --- a/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php +++ b/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php @@ -332,10 +332,11 @@ protected function setCriterions() * Send payment request. * Validation happens before this in the checkoutValidation() function. * + * @param $order + * @param null $uid * @return mixed - * @throws \Heidelpay\PhpPaymentApi\Exceptions\PaymentFormUrlException */ - public function performRequest($order, $uid) + public function performRequest($order, $uid = null) { if (!empty($_POST)) { $this->handleFormPost($_POST); diff --git a/includes/gateways/class-wc-heidelpay-gateway-iv.php b/includes/gateways/class-wc-heidelpay-gateway-iv.php new file mode 100644 index 0000000..15f046b --- /dev/null +++ b/includes/gateways/class-wc-heidelpay-gateway-iv.php @@ -0,0 +1,38 @@ + Date: Tue, 30 Oct 2018 11:14:44 +0100 Subject: [PATCH 2/7] Create IV Gateway Class --- .../class-wc-heidelpay-gateway-iv.php | 38 ++++++++++++++++++- woocommerce-heidelpay.php | 2 + 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/includes/gateways/class-wc-heidelpay-gateway-iv.php b/includes/gateways/class-wc-heidelpay-gateway-iv.php index 15f046b..c2ec903 100644 --- a/includes/gateways/class-wc-heidelpay-gateway-iv.php +++ b/includes/gateways/class-wc-heidelpay-gateway-iv.php @@ -25,14 +25,48 @@ use Heidelpay\PhpPaymentApi\PaymentMethods\InvoicePaymentMethod; -class WC_Heidelpay_HP_IV extends WC_Heidelpay_Payment_Gateway +class WC_Gateway_HP_IV extends WC_Heidelpay_Payment_Gateway { + public function init_form_fields() + { + parent::init_form_fields(); + + $this->form_fields['title']['default'] = sprintf(__('%s', 'woocommerce-heidelpay'), $this->name); + $this->form_fields['description']['default'] = sprintf( + __('Insert payment data for %s', 'woocommerce-heidelpay'), + $this->name + ); + $this->form_fields['instructions']['default'] = __( + 'please send the money to IBAN BIC ', + 'woocommerce-heidelpay' + ); + $this->form_fields['enabled']['label'] = sprintf(__('Enable %s', 'woocommerce-heidelpay'), $this->name); + $this->form_fields['security_sender']['default'] = '31HA07BC8181E8CCFDAD64E8A4B3B766'; + $this->form_fields['user_login']['default'] = '31ha07bc8181e8ccfdad73fd513d2a53'; + $this->form_fields['user_password']['default'] = '4B2D4BE3'; + $this->form_fields['transaction_channel']['default'] = '31HA07BC8181E8CCFDAD0419C1D13E84'; + + $this->form_fields['send_payment_info'] = array( + 'title' => __('Payment information mail', 'woocommerce-heidelpay'), + 'type' => 'checkbox', + 'description' => __( + 'Add payment information to e-mail', + 'woocommerce-heidelpay' + ), + 'default' => 'yes', + 'desc_tip' => true, + ); + } /** * Set the id and PaymentMethod */ protected function setPayMethod() { - // TODO: Implement setPayMethod() method. + $this->payMethod = new InvoicePaymentMethod(); + $this->id = 'hp_iv'; + $this->name = __('Invoice', 'woocommerce-heidelpay'); + $this->has_fields = false; + $this->bookingAction = 'authorize'; } } diff --git a/woocommerce-heidelpay.php b/woocommerce-heidelpay.php index 6edfe6b..9aada32 100644 --- a/woocommerce-heidelpay.php +++ b/woocommerce-heidelpay.php @@ -134,6 +134,7 @@ public function init() require_once __DIR__ . '/includes/gateways/class-wc-heidelpay-gateway-idl.php'; require_once __DIR__ . '/includes/gateways/class-wc-heidelpay-gateway-dd.php'; require_once __DIR__ . '/includes/gateways/class-wc-heidelpay-gateway-gp.php'; + require_once __DIR__ . '/includes/gateways/class-wc-heidelpay-gateway-iv.php'; require_once __DIR__ . '/includes/gateways/class-wc-heidelpay-gateway-ivpg.php'; require_once __DIR__ . '/includes/gateways/class-wc-heidelpay-gateway-so.php'; require_once __DIR__ . '/includes/gateways/class-wc-heidelpay-gateway-va.php'; @@ -155,6 +156,7 @@ public function add_gateways($methods) $methods[] = 'WC_Gateway_HP_IDL'; $methods[] = 'WC_Gateway_HP_DD'; $methods[] = 'WC_Gateway_HP_GP'; + $methods[] = 'WC_Gateway_HP_IV'; $methods[] = 'WC_Gateway_HP_IVPG'; $methods[] = 'WC_Gateway_HP_SO'; $methods[] = 'WC_Gateway_HP_VA'; From ae47b6f63498fb518db54c1a6c30d6d865e900a5 Mon Sep 17 00:00:00 2001 From: "David.Owusu" Date: Fri, 2 Nov 2018 14:07:57 +0100 Subject: [PATCH 3/7] (Woo) Bugfix Safari-iFrame: make iFrame work in safari browser. --- assets/css/datepicker.css | 31 ++++++++ assets/js/securedInvoice.js | 8 +++ .../abstract-wc-heidelpay-payment-gateway.php | 7 +- .../class-wc-heidelpay-gateway-ivpg.php | 68 ++++++++++++------ languages/woocommerce-heidelpay-de_DE.mo | Bin 6373 -> 6514 bytes languages/woocommerce-heidelpay-de_DE.po | 9 +++ languages/woocommerce-heidelpay-en_US.mo | Bin 1144 -> 1304 bytes languages/woocommerce-heidelpay-en_US.po | 9 +++ 8 files changed, 109 insertions(+), 23 deletions(-) create mode 100644 assets/css/datepicker.css diff --git a/assets/css/datepicker.css b/assets/css/datepicker.css new file mode 100644 index 0000000..a322e79 --- /dev/null +++ b/assets/css/datepicker.css @@ -0,0 +1,31 @@ +.ui-datepicker { + background: #fff; + font-size:11px; + padding:10px; + border:1px solid #ccc; +} + +.ui-datepicker table { + width:278px; +} + +.ui-datepicker table td { + text-align:center; +} + +.ui-datepicker a { + cursor:pointer; + text-decoration:none; +} + +.ui-datepicker-prev { +} + +.ui-datepicker-next { + float:right; +} + +.ui-datepicker-title { + text-align: center; + font-weight:bold; +} diff --git a/assets/js/securedInvoice.js b/assets/js/securedInvoice.js index f0a744e..5596369 100644 --- a/assets/js/securedInvoice.js +++ b/assets/js/securedInvoice.js @@ -20,5 +20,13 @@ jQuery(function () { jQuery('li.payment_method_hp_ivpg').show(); } ; + + var date_input = document.getElementById("hp_date"); + + date_input.reportValidity = function() { + var inputDate = this.valueAsDate; + var currentDate = new Date(); + return new Date(currentDate-inputDate).getFullYear() - new Date(0).getFullYear() < 18 + }; }); }); \ No newline at end of file diff --git a/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php b/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php index 962a8e8..3ea0ab0 100644 --- a/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php +++ b/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php @@ -339,7 +339,12 @@ protected function setCriterions() public function performRequest($order, $uid = null) { if (!empty($_POST)) { - $this->handleFormPost($_POST); + try{ + $this->handleFormPost($_POST); + } catch (\Exception $e) { + wc_get_logger()->log(WC_Log_Levels::DEBUG, htmlspecialchars(print_r($e->getMessage(), 1))); + return null; + } } if (!empty($this->bookingAction) && method_exists($this->payMethod, $this->bookingAction)) { diff --git a/includes/gateways/class-wc-heidelpay-gateway-ivpg.php b/includes/gateways/class-wc-heidelpay-gateway-ivpg.php index 6daea0d..48742b9 100644 --- a/includes/gateways/class-wc-heidelpay-gateway-ivpg.php +++ b/includes/gateways/class-wc-heidelpay-gateway-ivpg.php @@ -222,6 +222,17 @@ public function payment_fields() $salutationMText = __('Mr', 'woocommerce-heidelpay'); $salutationWText = __('Mrs', 'woocommerce-heidelpay'); $birthdateText = __('Birthdate', 'woocommerce-heidelpay'); + $dateFormatPlaceholder = __('datePlaceholder', 'woocommerce-heidelpay'); + $dateFormat = __('dateFormat', 'woocommerce-heidelpay'); + + wp_enqueue_script('jquery'); + wp_enqueue_script('jquery-ui-core'); + wp_enqueue_script('jquery-ui-datepicker'); + wp_enqueue_style( + 'jquery-ui-css', + WC_HEIDELPAY_PLUGIN_URL . '/assets/css/datepicker.css' + ); + echo '
'; @@ -234,33 +245,34 @@ public function payment_fields() '' . '
' . '' . - '' . + '' . '
'; - echo '
'; - echo ''; +'; } public function ErrorHtml() @@ -286,12 +298,24 @@ protected function setPayMethod() $this->bookingAction = 'authorize'; } + + /** + * @throws Exception + */ protected function handleFormPost() { parent::handleFormPost(); if (!empty($_POST['salutation']) && !empty($_POST['birthdate'])) { - $this->payMethod->getRequest()->b2cSecured($_POST['salutation'], $_POST['birthdate']); + $input = $_POST; + try { + $date = new DateTime(htmlspecialchars($input['birthdate'])); + } catch (\Exception $exception) { + wc_add_notice(__('Birthdate', 'woocommerce-heidelpay') . ': ' + . __('invalid date format', 'woocommerce-heidelpay'), 'error'); + throw $exception; + } + $this->payMethod->getRequest()->b2cSecured(htmlspecialchars($input['salutation']), $date->format('Y-m-d')); } } } diff --git a/languages/woocommerce-heidelpay-de_DE.mo b/languages/woocommerce-heidelpay-de_DE.mo index da6920b5fc566a43d114550478f756a421f074b6..3dff71fa27aabe3b8966d8f726b0bdd1e6633ffa 100644 GIT binary patch delta 1510 zcmXZce`rl%9LMqRoqJ{&_JjQ}vpd`{jG6g08=D!6Nq(eIy6s+!JNDyBliY|RO*jdm zlqi}e*FTznSo=fr2l0hL~Ij`rO^PJ~-zTfAZ`>y26toW-8{~4py zQO8olNoFDJ^mCxhOg0N*33AIe;0WA^h1iH`cpQi0MVy2;yz5Ufo%6S-A-~}e{Ds5J z;^rT0Hi`>roEkFlraVW0zu5Z9p&KpnzHKP`^&+`~&a(>P`@5C<7yHN|+nPN5u zn=zI7?Kq7pJ%A(e1!}+#sEB{!ApDJt@o!f3OJVjL%)w`DMh>m6+r|wP&)^u_AmzUG*)5)Yw!yyqPe7PBCbJg&0fsH^GFxF zg<3#2YD*qroVo2K4W;xwj>fMz9fxu;7w4fOU4vTSPSgThke?mlpnj)O{W@_x_M#^2 z$74RT9~j{L5b0HBuZ$r7T(fIjn1Kn@z;BVCedjP6lNlug%RN`2_A-Qeek&?NZKwba zVm6*dVzDmoem5!;4^huO8%h4v;f>ef6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-heidelpay-de_DE.po b/languages/woocommerce-heidelpay-de_DE.po index 2118f91..259684b 100644 --- a/languages/woocommerce-heidelpay-de_DE.po +++ b/languages/woocommerce-heidelpay-de_DE.po @@ -36,6 +36,15 @@ msgstr "Der Betrag von {AMOUNT} {CURRENCY} wird in den näc "
" "Bitte sorgen Sie für ausreichende Deckung auf dem entsprechenden Konto." +msgid "datePlaceholder" +msgstr "tt.mm.jjjj" + +msgid "dateFormat" +msgstr "dd.mm.yy" + +msgid "invalid date format" +msgstr "Ungültiges Datumsformat." + #: includes/abstracts/abstract-wc-heidelpay-iframe-gateway.php:57 msgid "Awaiting payment" msgstr "Auf Zahlung warten" diff --git a/languages/woocommerce-heidelpay-en_US.mo b/languages/woocommerce-heidelpay-en_US.mo index 9d3bbe754ffef34c00dff337822fa67ca4ffeca2..3faa9136dcf65d0733a327524343b0aa735a81ba 100644 GIT binary patch delta 271 zcmeytF@vlAo)F7a1|VPqVi_Rz0b*_-t^r~$AYK8){6M@Jhy{W8Fc1p^@l_z^0pgcH z43hr_#2i4(#t6~J52S;ESPFea^34wzXD|T({c|w* delta 151 zcmbQi^@F4So)F7a1|VPtVi_Pd0b*7l_5or+AWi^c9w06PVtyd52jXBx28Mnhodu*H z1F{AMOUNT} {CURRENCY} will be debited from "and the creditor identifier: {CreditorId}
" "
" "Please ensure that there will be sufficient funds on the corresponding account." + +msgid "datePlaceholder" +msgstr "yyyy-mm-dd" + +msgid "dateFormat" +msgstr "yy-mm-dd" + +msgid "invalid date format" +msgstr "Invalid date format." \ No newline at end of file From 9e497d3f6a72e05e3fcbf548754411bc201b5c9c Mon Sep 17 00:00:00 2001 From: "David.Owusu" Date: Fri, 2 Nov 2018 15:59:19 +0100 Subject: [PATCH 4/7] (Woo) update Version --- CHANGELOG.md | 7 +++++++ woocommerce-heidelpay.php | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7284a9..b314e7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Release Notes - heidelpay Payment Gateway for WooCommerce +## 1.5.0 + +### Added: +- Payment method: Invoice +### Fixed: +- Date input for secured invoice not working on Safari browser. + ## 1.4.0 ### Added: diff --git a/woocommerce-heidelpay.php b/woocommerce-heidelpay.php index 9aada32..f66d3cc 100644 --- a/woocommerce-heidelpay.php +++ b/woocommerce-heidelpay.php @@ -10,7 +10,7 @@ * Plugin Name: heidelpay WooCommerce * Plugin URI: https://dev.heidelpay.com * Description: heidelpay payment integration for WooCommerce - * Version: 1.4.0 + * Version: 1.5.0 * Author: heidelpay * Author URI: htts://www.heidelpay.com * Developer: heidelpay @@ -29,7 +29,7 @@ /** * Required minimums and constants */ - define('WC_HEIDELPAY_VERSION', '1.4.0'); + define('WC_HEIDELPAY_VERSION', '1.5.0'); define('WC_HEIDELPAY_MIN_PHP_VER', '5.6.0'); define('WC_HEIDELPAY_MIN_WC_VER', '3.0.0'); define('WC_HEIDELPAY_MAIN_FILE', __FILE__); From 2f37f3bd607e0e4209011ea563db60ba1c4b9ccd Mon Sep 17 00:00:00 2001 From: "David.Owusu" Date: Mon, 5 Nov 2018 17:04:17 +0100 Subject: [PATCH 5/7] (Woo) Fix: Check for correct class instead of null. - in WC_Heidelpay_Payment_Gateway::addPayInfo() --- includes/abstracts/abstract-wc-heidelpay-payment-gateway.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php b/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php index 3ea0ab0..473b61f 100644 --- a/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php +++ b/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php @@ -535,9 +535,12 @@ public function setAvailability($available_gateways) */ public function addPayInfo($orderReceivedText) { + /** + * @var WC_Order $order + */ $order = $this->getOrderFromKey(); - if ($order === null || $order->get_payment_method() !== $this->id) { + if (!$order instanceof WC_Order || $order->get_payment_method() !== $this->id) { return $orderReceivedText; } From e3f69a3ad6852d1026e63129e7fbe3574daf082d Mon Sep 17 00:00:00 2001 From: "David.Owusu" Date: Wed, 7 Nov 2018 14:42:36 +0100 Subject: [PATCH 6/7] (Woo-4) Invoice: set default configuration for default merchant. --- .../abstracts/abstract-wc-heidelpay-payment-gateway.php | 4 ++-- includes/gateways/class-wc-heidelpay-gateway-iv.php | 7 +------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php b/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php index 473b61f..0dd7152 100644 --- a/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php +++ b/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php @@ -114,14 +114,14 @@ public function init_form_fields() 'type' => 'text', 'id' => $this->id . '_security_sender', 'description' => 'Security Sender', - 'default' => '' + 'default' => '31HA07BC8142C5A171745D00AD63D182' ), 'user_login' => array( 'title' => __('User Login', 'woocommerce-heidelpay'), 'type' => 'text', 'id' => $this->id . '_user_login', 'description' => 'User Login', - 'default' => '' + 'default' => '31ha07bc8142c5a171744e5aef11ffd3' ), 'user_password' => array( 'title' => __('User Password', 'woocommerce-heidelpay'), diff --git a/includes/gateways/class-wc-heidelpay-gateway-iv.php b/includes/gateways/class-wc-heidelpay-gateway-iv.php index c2ec903..a6ab632 100644 --- a/includes/gateways/class-wc-heidelpay-gateway-iv.php +++ b/includes/gateways/class-wc-heidelpay-gateway-iv.php @@ -31,7 +31,6 @@ public function init_form_fields() { parent::init_form_fields(); - $this->form_fields['title']['default'] = sprintf(__('%s', 'woocommerce-heidelpay'), $this->name); $this->form_fields['description']['default'] = sprintf( __('Insert payment data for %s', 'woocommerce-heidelpay'), $this->name @@ -40,11 +39,7 @@ public function init_form_fields() 'please send the money to IBAN BIC ', 'woocommerce-heidelpay' ); - $this->form_fields['enabled']['label'] = sprintf(__('Enable %s', 'woocommerce-heidelpay'), $this->name); - $this->form_fields['security_sender']['default'] = '31HA07BC8181E8CCFDAD64E8A4B3B766'; - $this->form_fields['user_login']['default'] = '31ha07bc8181e8ccfdad73fd513d2a53'; - $this->form_fields['user_password']['default'] = '4B2D4BE3'; - $this->form_fields['transaction_channel']['default'] = '31HA07BC8181E8CCFDAD0419C1D13E84'; + $this->form_fields['transaction_channel']['default'] = '31HA07BC8142C5A171749A60D979B6E4'; $this->form_fields['send_payment_info'] = array( 'title' => __('Payment information mail', 'woocommerce-heidelpay'), From 1afb015598a40534c327eca36f7f49a9d39c889d Mon Sep 17 00:00:00 2001 From: "David.Owusu" Date: Wed, 7 Nov 2018 15:07:36 +0100 Subject: [PATCH 7/7] (Woo) direct debit: Use acccount holder from billing data of customer. --- includes/gateways/class-wc-heidelpay-gateway-dd.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/gateways/class-wc-heidelpay-gateway-dd.php b/includes/gateways/class-wc-heidelpay-gateway-dd.php index 089adf2..df58ea2 100644 --- a/includes/gateways/class-wc-heidelpay-gateway-dd.php +++ b/includes/gateways/class-wc-heidelpay-gateway-dd.php @@ -103,7 +103,7 @@ public function payment_fields() $accountHolderLabel = __('Account Holder', 'woocommerce-heidelpay'); $accountIbanLabel = __('IBAN', 'woocommerce-heidelpay'); - $accountHolder = wc()->customer->get_billing_first_name() . ' ' . wc()->customer->get_last_name(); + $accountHolder = wc()->customer->get_billing_first_name() . ' ' . wc()->customer->get_billing_last_name(); echo '
';