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 #6 from heidelpay/develop
Browse files Browse the repository at this point in the history
Release 1.1.0
  • Loading branch information
bnoobbnoob authored Jun 20, 2018
2 parents 4ee588c + a143837 commit 47f5471
Show file tree
Hide file tree
Showing 20 changed files with 1,478 additions and 510 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Release Notes - heidelpay Payment Gateway for WooCommerce

## 1.1.0

### Added

#### New payment methods:
- iDeal
- PayPal
- Direct Debit

#### Features:
- Credit Card and Debit Card: Added css file to customize the appearance of the iFrame.
- Credit Card, Debit Card and Paypal: Added setting to chose between bookingmodes debit (default) and authorize.
- Secured Invoice: added settings for minimum and maximum Amount to accept for payment.
- Secured Invoice: added settings to enable payment for Germany and Austria.
- Secured Invoice: added validation on checkout.

### Changed


## 1.0.1

### Fixed
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ To use this extension please paste the contents of the folder "woocommerce"" int

* credit card
* debit card
* direct debit
* iDEAL
* Paypal
* Sofort
* secured invoice b2c

Expand Down
59 changes: 59 additions & 0 deletions assets/css/creditCardFrame.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#paymentFrameForm {
background: #fff;
}

.form-row {
margin: 0 0 1.5em;
padding: 0;
display: block;
}

.form-label {
color: #333;
margin-bottom: 0.5em;
position: relative;
word-wrap: break-word;
line-height: 1.66;
font: 800 15px Arial;

}

.form-input, .form-select{
border: 1px solid #bbb;
border-radius: 3px;
display: block;
width: 90%;
box-sizing: content-box;
padding: 0.7em;
font: 400 15px Arial;
color: #666;
}

.form-select {
width: 75%;
}

.verificationInlineHintWrapper {
width: 62%;
}

.form-input fullWidth {}

.form-select fullWidth {}

.creditCardSymbols {}

.creditCardImage {}

.fillWidth {}

.halfWidth{}

#verificationInlineHint {
right: -15px;
}





36 changes: 9 additions & 27 deletions includes/js/creditCardFrame.js → assets/js/creditCardFrame.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
/**
* SUMMARY
* Payment card script
*
* DESC
* Script to handle the communication with the iFrame in order to submit the form from outside the iFrame
*
* @license Use of this software requires acceptance of the License Agreement. See LICENSE file.
* @copyright Copyright © 2016-present heidelpay GmbH. All rights reserved.
* @link https://dev.heidelpay.de/JTL
* @link https://dev.heidelpay.de/woocommerce
* @author David Owusu
* @category WOOCOMMERCE
*/

/*var paymentFrameForm;
var targetOrigin;*/


/**
* Get hostname and protocol from paymentIframe
*/

jQuery(function () {
/**
* Get the form element
*/
paymentFrameForm = document.getElementById('paymentFrameForm');
if(paymentFrameForm != null) {
console.log(paymentFrameForm);

var paymentFrameIframe = document.getElementById('paymentFrameIframe');

/**
* Add an event listener to from submit, which will execute the sendMessage function
*/
if (paymentFrameForm.addEventListener) {// W3C DOM
paymentFrameForm.addEventListener('submit', sendMessage);
}
Expand All @@ -35,21 +32,6 @@ jQuery(function () {
}
)




/**
* Get the form element
*/




/**
* Add an event listener to from submit, which will execute the sendMessage function
*/


/**
* Define send Message function
* This function will collect each inpunt inside the form and then submit
Expand Down
24 changes: 24 additions & 0 deletions assets/js/securedInvoice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* SUMMARY
*
* DESC
*
* @license Use of this software requires acceptance of the License Agreement. See LICENSE file.
* @copyright Copyright © 2016-present heidelpay GmbH. All rights reserved.
* @author Florian Evertz
* @category WOOCOMMERCE
*/

/**
* This function checks if the billing_company is empty
*/
jQuery(function () {
jQuery('#billing_company').change(function () {
if (jQuery('#billing_company').val() !== '') {
jQuery('li.payment_method_hp_ivpg').hide();
} else {
jQuery('li.payment_method_hp_ivpg').show();
}
;
});
});
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
{
"name": "Florian Evertz",
"email": "[email protected]"
},
{
"name": "David Owusu"
}
]
}
180 changes: 180 additions & 0 deletions includes/abstracts/abstract-wc-heidelpay-iframe-gateway.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
<?php
/**
* Abstract iFrame gateway
*
* WooCommerce base class for iFrame based payment methods like Credit Card and Debit Card
*
* @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 Daniel Kraut, David Owusu, Florian Evertz
*
* @package woocommerce-heidelpay
* @category WooCommerce
*/
if (!defined('ABSPATH')) {
exit;
}

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

/**
* Class WC_Heidelpay_IFrame_Gateway
* Provide payment using an iFrame.
*/
abstract class WC_Heidelpay_IFrame_Gateway extends WC_Heidelpay_Payment_Gateway
{
protected $bookingModes;

public function __construct()
{
parent::__construct();
add_action('after_woocommerce_pay', array($this, 'after_pay'));

$this->bookingModes = array(
'PA' => 'authorize',
'DB' => 'debit'
);
}

public function process_payment($order_id)
{
return $this->toCheckoutPayment($order_id);
}

/**
* Redirect to an extra Checkout page.
* @param $order_id
* @return array
*/
public function toCheckoutPayment($order_id)
{
$order = wc_get_order($order_id);

$order->update_status('pending', __('Awaiting payment', 'woocommerce-heidelpay'));
return [
'result' => 'success',
'redirect' => $order->get_checkout_payment_url(true)
];
}

protected function performRequest($order_id)
{
$order = wc_get_order($order_id);
echo $this->getIFrame($order);
}

/**
* Initialise Gateway Settings Form Fields.
*/
public function init_form_fields()
{
parent::init_form_fields();

$this->form_fields['security_sender']['default'] = '31HA07BC8142C5A171745D00AD63D182';
$this->form_fields['user_login']['default'] = '31ha07bc8142c5a171744e5aef11ffd3';
$this->form_fields['user_password']['default'] = '93167DE7';
$this->form_fields['transaction_channel']['default'] = '31HA07BC8142C5A171744F3D6D155865';

$this->form_fields['description']['default'] = '';
$this->form_fields['bookingmode'] = $this->getBookingSelection();
}

/**
* register scripts and stylesheets for your payment gateway
*/
public function enqueue_assets()
{
wp_register_script('heidelpay-iFrame',
WC_HEIDELPAY_PLUGIN_URL . '/assets/js/creditCardFrame.js',
[],
false,
true
);
}

/**
* @throws \Heidelpay\PhpPaymentApi\Exceptions\PaymentFormUrlException
* @throws \Heidelpay\PhpPaymentApi\Exceptions\UndefinedTransactionModeException
*/
public function after_pay()
{
$order_id = wc_get_order_id_by_order_key($_GET['key']);
$order = wc_get_order($order_id);

if ($order->get_payment_method() === $this->id) {
$this->performRequest($order_id);
}
}

/**
* Build the Iframe and return the String
* @param $order
* @throws \Heidelpay\PhpPaymentApi\Exceptions\PaymentFormUrlException
* @throws \Heidelpay\PhpPaymentApi\Exceptions\UndefinedTransactionModeException
* @return String
*/
protected function getIFrame( WC_Order $order)
{
// Load script for payment cards
wp_enqueue_script('heidelpay-iFrame');

$this->prepareRequest($order);

// build host url and css path
$protocol = $_SERVER['HTTPS'] ? 'https' : 'http';
$host = $protocol . '://' . $_SERVER['SERVER_NAME'];
$cssPath = WC_HEIDELPAY_PLUGIN_URL . '/assets/css/creditCardFrame.css';

$bookingAction = $this->getBookingAction();

if (method_exists($this->payMethod, $bookingAction)) {
$this->payMethod->$bookingAction(
$host, // PaymentFrameOrigin - uri of your application like https://dev.heidelpay.com
'FALSE',
$cssPath
);

$iFrame = '<form method="post" class="formular" id="paymentFrameForm">';
if ($this->payMethod->getResponse()->isSuccess()) {
$iFrame .= '<iframe id="paymentFrameIframe" src="'
. $this->payMethod->getResponse()->getPaymentFormUrl()
. '" frameborder="0" scrolling="no" style="height:360px;"></iframe><br />';
} else {
$iFrame .= get_home_url() . '/wp-content/plugins/woocommerce-heidelpay/vendor/';
$iFrame .= '<pre>' . print_r($this->getErrorMessage(), 1) . '</pre>';
}
$iFrame .= '<button type="submit">' . __('Pay Now', 'woocommerce-heidelpay') . '</button>';
$iFrame .= '</form>';

return $iFrame;
}

$this->addPaymentError($this->getErrorMessage());
wc_print_notices();

wc_get_logger()->log(
WC_Log_Levels::ERROR,
htmlspecialchars(
print_r(
$this->plugin_id . ' - ' . $this->id . __(
' Error: Paymentmethod was not found: ', 'woocommerce-heidelpay'
) . $bookingAction,
1
)
)
);
return null;
}

public function getBookingAction()
{
if(!empty($this->bookingModes[$this->get_option('bookingmode')])) {
return $this->bookingModes[$this->get_option('bookingmode')];
}
return $this->bookingAction;
}
}
Loading

0 comments on commit 47f5471

Please sign in to comment.