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/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 1080b67..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'), @@ -332,13 +332,19 @@ 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); + 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)) { @@ -529,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; } 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 '
'; 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..a6ab632 --- /dev/null +++ b/includes/gateways/class-wc-heidelpay-gateway-iv.php @@ -0,0 +1,67 @@ +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['transaction_channel']['default'] = '31HA07BC8142C5A171749A60D979B6E4'; + + $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() + { + $this->payMethod = new InvoicePaymentMethod(); + $this->id = 'hp_iv'; + $this->name = __('Invoice', 'woocommerce-heidelpay'); + $this->has_fields = false; + $this->bookingAction = 'authorize'; + } +} 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 da6920b..3dff71f 100644 Binary files a/languages/woocommerce-heidelpay-de_DE.mo and b/languages/woocommerce-heidelpay-de_DE.mo differ diff --git a/languages/woocommerce-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 9d3bbe7..3faa913 100644 Binary files a/languages/woocommerce-heidelpay-en_US.mo and b/languages/woocommerce-heidelpay-en_US.mo differ diff --git a/languages/woocommerce-heidelpay-en_US.po b/languages/woocommerce-heidelpay-en_US.po index 7cf39f6..9b2fac9 100644 --- a/languages/woocommerce-heidelpay-en_US.po +++ b/languages/woocommerce-heidelpay-en_US.po @@ -20,3 +20,12 @@ msgstr "The amount of {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 diff --git a/woocommerce-heidelpay.php b/woocommerce-heidelpay.php index 6edfe6b..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__); @@ -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';