Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #20 from heidelpay/develop_gitlab
Browse files Browse the repository at this point in the history
Release 1.5.0
  • Loading branch information
bnoobbnoob authored Nov 13, 2018
2 parents 28baec2 + 78c0bab commit 968e785
Show file tree
Hide file tree
Showing 12 changed files with 197 additions and 31 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
31 changes: 31 additions & 0 deletions assets/css/datepicker.css
Original file line number Diff line number Diff line change
@@ -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;
}
8 changes: 8 additions & 0 deletions assets/js/securedInvoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
});
});
21 changes: 15 additions & 6 deletions includes/abstracts/abstract-wc-heidelpay-payment-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion includes/gateways/class-wc-heidelpay-gateway-dd.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<div>';

Expand Down
67 changes: 67 additions & 0 deletions includes/gateways/class-wc-heidelpay-gateway-iv.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

/**
* Invoice
*
* WooCommerce payment gateway for Invoice
*
* @license Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
* @copyright Copyright © 2018-present heidelpay GmbH. All rights reserved.
*
* @link http://dev.heidelpay.com/
*
* @author Florian Evertz
*
* @package woocommerce-heidelpay
* @category WooCommerce
*/

if (!defined('ABSPATH')){
exit; // Exit if accessed directly
}

require_once WC_HEIDELPAY_PLUGIN_PATH . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'abstracts' .
DIRECTORY_SEPARATOR . 'abstract-wc-heidelpay-payment-gateway.php';

use Heidelpay\PhpPaymentApi\PaymentMethods\InvoicePaymentMethod;

class WC_Gateway_HP_IV extends WC_Heidelpay_Payment_Gateway
{
public function init_form_fields()
{
parent::init_form_fields();

$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['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';
}
}
68 changes: 46 additions & 22 deletions includes/gateways/class-wc-heidelpay-gateway-ivpg.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<div>';

Expand All @@ -234,33 +245,34 @@ public function payment_fields()
'</select>' .
'<br/>' .
'<label for="hp_date">' . $birthdateText . ':</label>' .
'<input type="date" name="birthdate" id="hp_date" value="" class="form-row-wide validate-required"/>' .
'<input type="date" name="birthdate" id="hp_date" value="" class="form-row-wide validate-required"
placeholder="' . $dateFormatPlaceholder . '"/>' .
'<br/>';

echo '</div>';
echo '<script>
var date_input = document.getElementById("hp_date");
date_input.reportValidity = function() {
var inputDate = this.valueAsDate;
var currentDate = new Date();
if(new Date(currentDate-inputDate).getFullYear() - new Date(0).getFullYear() < 18){
return false;
echo '<script type="text/javascript">
if ( jQuery(\'[type="date"]\').prop(\'type\') != \'date\' ) {
jQuery(document).ready(function(){
jQuery(\'#hp_date\').datepicker({
dateFormat: \'' . $dateFormat . '\',
changeYear: true,
changeMonth: true,
yearRange: \'-100:-18\',
defaultDate: "-17y -364d"
});
});
}
return true;
};
date_input.onchange = function () {
if(!this.reportValidity() && jQuery("ul[class=woocommerce-error]")[0] == undefined){
jQuery("form[name=checkout]").prepend(\'' . $this->ErrorHtml() . '\');
jQuery("ul[class=woocommerce-error]")[0].scrollIntoView({behavior : "smooth"})
}else{
if(this.reportValidity() && jQuery("ul[class=woocommerce-error]")[0] !== undefined){
jQuery("ul[class=woocommerce-error]").remove();
date_input.onchange = function () {
if(!this.reportValidity() && jQuery("ul[class=woocommerce-error]")[0] == undefined){
jQuery("form[name=checkout]").prepend(\'' . $this->ErrorHtml() . '\');
jQuery("ul[class=woocommerce-error]")[0].scrollIntoView({behavior : "smooth"})
}else{
if(this.reportValidity() && jQuery("ul[class=woocommerce-error]")[0] !== undefined){
jQuery("ul[class=woocommerce-error]").remove();
}
}
};
</script>';
</script>';
}

public function ErrorHtml()
Expand All @@ -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'));
}
}
}
Binary file modified languages/woocommerce-heidelpay-de_DE.mo
Binary file not shown.
9 changes: 9 additions & 0 deletions languages/woocommerce-heidelpay-de_DE.po
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ msgstr "Der Betrag von <strong>{AMOUNT} {CURRENCY}</strong> wird in den n&auml;c
"<br />"
"Bitte sorgen Sie f&uuml;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"
Expand Down
Binary file modified languages/woocommerce-heidelpay-en_US.mo
Binary file not shown.
9 changes: 9 additions & 0 deletions languages/woocommerce-heidelpay-en_US.po
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,12 @@ msgstr "The amount of <strong>{AMOUNT} {CURRENCY}</strong> will be debited from
"and the creditor identifier: {CreditorId}</i><br />"
"<br />"
"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."
6 changes: 4 additions & 2 deletions woocommerce-heidelpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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__);
Expand Down Expand Up @@ -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';
Expand All @@ -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';
Expand Down

0 comments on commit 968e785

Please sign in to comment.