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 #24 from heidelpay/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Ryouzanpaku authored Feb 4, 2019
2 parents 622875d + ce35386 commit 9d56020
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 32 deletions.
37 changes: 29 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
# Release Notes - heidelpay Payment Gateway for WooCommerce

## 1.5.0
## [1.6.0][1.6.0]

### Added:
- Unique ID and Short ID now show up in Order Meta

### Change:
- Use different way to get the host url to ensure better compatibility
- Ensure that total price is only submitted with 2 decimal digits

### Fixed:
- Set the correct customer ip for payment request

## [1.5.0][1.5.0]

### Added:
- Payment method: Invoice
### Fixed:
- Date input for secured invoice not working on Safari browser.

## 1.4.0
## [1.4.0][1.4.0]

### Added:
#### Features:
- Supports WooCommerce Subscriptions
- Add Prepayment Payment Method

## 1.3.0
## [1.3.0][1.3.0]

### Fixed:
- Credit Card iFrame not working in Safari Browsers
Expand All @@ -23,7 +35,7 @@
#### Features:
- Add GiroPay Payment Method

## 1.2.0
## [1.2.0][1.2.0]

### Fixed:
- Missing payment information for secured invoice and direct debit on success page and notification mail.
Expand All @@ -35,12 +47,12 @@
- Support for push notifications
- A checkbox to decide whether payment information should be added to the notification mail or not.

## 1.1.1
## [1.1.1][1.1.1]

### Fixed:
- a bug that caused the payment requests to fail in some shops due to an invalid url.

## 1.1.0
## [1.1.0][1.1.0]

### Added

Expand All @@ -59,7 +71,16 @@
### Changed
- payment methods will be deactivated by default.

## 1.0.1
## [1.0.1][1.0.1]

### Fixed
- A bug which caused that the sandbox mode was activated regardless of the state of the switch.
- A bug which caused that the sandbox mode was activated regardless of the state of the switch.

[1.0.1]: https://github.com/heidelpay/woocommerce-heidelpay/compare/1.0.0..1.0.1
[1.1.0]: https://github.com/heidelpay/woocommerce-heidelpay/compare/1.0.1..1.1.0
[1.1.1]: https://github.com/heidelpay/woocommerce-heidelpay/compare/1.1.0..1.1.1
[1.2.0]: https://github.com/heidelpay/woocommerce-heidelpay/compare/1.1.1..1.2.0
[1.3.0]: https://github.com/heidelpay/woocommerce-heidelpay/compare/1.2.0..1.3.0
[1.4.0]: https://github.com/heidelpay/woocommerce-heidelpay/compare/1.3.0..1.4.0
[1.5.0]: https://github.com/heidelpay/woocommerce-heidelpay/compare/1.4.0..1.5.0
[1.6.0]: https://github.com/heidelpay/woocommerce-heidelpay/compare/1.5.0..1.6.0
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![PHP 7.0](https://img.shields.io/badge/php-7.0-blue.svg)](http://www.php.net)
[![PHP 7.1](https://img.shields.io/badge/php-7.1-blue.svg)](http://www.php.net)

![Logo](https://dev.heidelpay.de/devHeidelpay_400_180.jpg)
![Logo](https://dev.heidelpay.com/devHeidelpay_400_180.jpg)

# heidelpay WooCommerce plug-in
Payment extension for WooCommerce
Expand All @@ -20,6 +20,7 @@ To use this extension please paste the contents of the folder "woocommerce"" int
* iDEAL
* Paypal
* Sofort
* invoice b2c
* secured invoice b2c

### SYSTEM REQUIREMENTS
Expand All @@ -29,4 +30,19 @@ latest stable PHP version whenever possible.

## LICENSE

You can find a copy of the license in [LICENSE.txt](LICENSE.txt).
You can find a copy of the license in [LICENSE.txt](LICENSE.txt).

## Support
For any issues or questions please get in touch with our support.

### Web page
https://dev.heidelpay.com/

### Email
[email protected]

### Phone
+49 (0)6221/6471-100

### Twitter
@devHeidelpay
28 changes: 16 additions & 12 deletions includes/abstracts/abstract-wc-heidelpay-iframe-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ protected function getIFrame(WC_Order $order)
wp_enqueue_script('heidelpay-iFrame');

$this->prepareRequest($order);

// build host url and css path
$protocol = $_SERVER['HTTPS'] ? 'https' : 'http';
$host = $protocol . '://' . $_SERVER['SERVER_NAME'];
$urlArray = explode('/', get_home_url());
$host = $urlArray[0] . '//' . $urlArray[2];

$cssPath = WC_HEIDELPAY_PLUGIN_URL . '/assets/css/creditCardFrame.css';

$bookingAction = $this->getBookingAction();
Expand All @@ -152,17 +152,21 @@ protected function getIFrame(WC_Order $order)
$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 />';
$iFrame = '';

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

return $iFrame;
}
Expand Down
50 changes: 44 additions & 6 deletions includes/abstracts/abstract-wc-heidelpay-payment-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,24 @@

abstract class WC_Heidelpay_Payment_Gateway extends WC_Payment_Gateway
{
/**
* @var \Heidelpay\PhpPaymentApi\PaymentMethods\BasicPaymentMethodTrait $payMethod
*/
public $payMethod;

/**
* @var string $bookingAction
*/
public $bookingAction;

/**
* @var string $name
*/
protected $name;

/**
* @var MessageCodeMapper $messageMapper
*/
protected $messageMapper;

public function __construct()
Expand Down Expand Up @@ -208,7 +223,7 @@ public function enqueue_assets()
*
* @param int $order_id
* @return array|mixed
* @throws \Heidelpay\PhpPaymentApi\Exceptions\PaymentFormUrlException
* @throws Exception
*/
public function process_payment($order_id)
{
Expand All @@ -220,6 +235,7 @@ public function process_payment($order_id)

/**
* @param $order WC_Order
* @throws Exception
*/
public function prepareRequest(WC_Order $order)
{
Expand All @@ -228,6 +244,7 @@ public function prepareRequest(WC_Order $order)
$this->setCustomer($order);
$this->setBasket($order->get_id());
$this->setCriterions();
$this->payMethod->getRequest()->getContact()->setIp(WC_Geolocation::get_ip_address());
}

/**
Expand Down Expand Up @@ -262,7 +279,7 @@ protected function setAsync()
{
$this->payMethod->getRequest()->async(
$this->getLanguage(), // Language code for the Frame
get_home_url() . '/wc-api/' . strtolower(get_class($this))
$this->getResponeUrl()
);
}

Expand Down Expand Up @@ -300,22 +317,23 @@ protected function setCustomer(WC_Order $order)

/**
* @param $order_id
* @throws Exception
*/
protected function setBasket($order_id)
{
$order = wc_get_order($order_id);
$this->payMethod->getRequest()->basketData(
$order_id, //order id
$order->get_total(), //cart amount
'EUR', // Currency code of this request
round($order->get_total(), 2), //cart amount
$order->get_currency(), // Currency code of this request
$this->get_option('secret') // A secret passphrase from your application
);
}

/**
* @global string $wp_version
*/
protected function setCriterions()
protected function setCriterions($orderID = null)
{
global $wp_version;

Expand All @@ -339,7 +357,7 @@ protected function setCriterions()
public function performRequest($order, $uid = null)
{
if (!empty($_POST)) {
try{
try {
$this->handleFormPost($_POST);
} catch (\Exception $e) {
wc_get_logger()->log(WC_Log_Levels::DEBUG, htmlspecialchars(print_r($e->getMessage(), 1)));
Expand Down Expand Up @@ -461,6 +479,7 @@ protected function paymentLog($logData)
/**
* @param $order
* @param $uid
* @throws WC_Data_Exception
*/
public function performNoGuiRequest($order, $uid)
{
Expand All @@ -470,6 +489,7 @@ public function performNoGuiRequest($order, $uid)
/**
* @param WC_Order $order
* @param $uid
* @throws WC_Data_Exception
*/
public function performAfterRegistrationRequest($order, $uid)
{
Expand Down Expand Up @@ -512,6 +532,14 @@ public function callback_handler()
if (!empty($_POST)) {
$response = new WC_Heidelpay_Response();
$response->init($_POST, $this->get_option('secret'));
} else {
// Add Error Msg, debug log and redirect to cart.
$this->addPaymentError($this->getErrorMessage());
wc_get_logger()->log(WC_Log_Levels::DEBUG,
'heidelpay - Response: There has been an error fetching the RedirectURL by the payment. '
. 'Please make sure the ResponseURL (' . $this->getResponeUrl() .')is accessible from the internet.',
array('source' => 'heidelpay'));
wp_redirect(wc_get_cart_url());
}
exit();
}
Expand All @@ -532,6 +560,7 @@ public function setAvailability($available_gateways)
* payment.
* @param $orderReceivedText
* @return string
* @throws Exception
*/
public function addPayInfo($orderReceivedText)
{
Expand All @@ -556,6 +585,7 @@ public function addPayInfo($orderReceivedText)
/**
* Get the order using the Get parameter 'key'
* @return bool|WC_Order|WC_Refund
* @throws Exception
*/
public function getOrderFromKey()
{
Expand Down Expand Up @@ -614,4 +644,12 @@ protected function getBookingSelection()
'default' => 'DB'
);
}

/**
* @return string
*/
protected function getResponeUrl()
{
return get_home_url() . '/wc-api/' . strtolower(get_class($this));
}
}
7 changes: 5 additions & 2 deletions includes/class-wc-heidelpay-response.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function init(array $post_data, $secret)
public function handleResult($post_data, WC_Order $order)
{
$uid = self::$response->getIdentification()->getUniqueId();
$sid = self::$response->getIdentification()->getShortId();

if (self::$response->isSuccess()) {
$payCode = explode('.', strtoupper($post_data['PAYMENT_CODE']));
Expand Down Expand Up @@ -103,7 +104,9 @@ public function handleResult($post_data, WC_Order $order)
__('Awaiting payment.', 'woocommerce-heidelpay') . ' ' . $note
);
} else {
$order->payment_complete();
$order->add_meta_data('heidelpay-UniqueID', $uid);
$order->add_meta_data('heidelpay-ShortID', $sid);
$order->payment_complete($sid);
}
echo $order->get_checkout_order_received_url();

Expand All @@ -123,7 +126,7 @@ public function handleResult($post_data, WC_Order $order)
//empty cart
wc()->cart->empty_cart();

//show thank you page
//show thank you page
echo $order->get_checkout_order_received_url();
}
}
Expand Down
7 changes: 7 additions & 0 deletions includes/gateways/class-wc-heidelpay-gateway-va.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,11 @@ public function getBookingAction()
{
return (string)$this->bookingModes[$this->get_option('bookingmode')];
}

public function setCriterions($orderID = null)
{
parent::setCriterions();

$this->payMethod->getRequest()->getCriterion()->set('PAYPAL_PAYMENTREQUEST_0_INVNUM', $orderID);
}
}
4 changes: 2 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.5.0
* Version: 1.6.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.5.0');
define('WC_HEIDELPAY_VERSION', '1.6.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

0 comments on commit 9d56020

Please sign in to comment.