From a95cde84391a66679154a7818221f40cc2a45563 Mon Sep 17 00:00:00 2001 From: Florian Evertz Date: Wed, 20 Jun 2018 13:58:36 +0200 Subject: [PATCH 01/25] start Push integration --- includes/class-wc-heidelpay-response.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/includes/class-wc-heidelpay-response.php b/includes/class-wc-heidelpay-response.php index bdffd7a..52fec84 100644 --- a/includes/class-wc-heidelpay-response.php +++ b/includes/class-wc-heidelpay-response.php @@ -50,7 +50,8 @@ public function init(array $post_data, $secret) $order = wc_get_order($orderId); - $this->handleResult($post_data, $order); + //$this->handleResult($post_data, $order); + $this->handlePush($post_data); //TODO: if case for distinction between result and push } @@ -111,8 +112,8 @@ public function handleResult($post_data, WC_Order $order) * handle push post */ - public function handlePush() + public function handlePush($input) { - //TODO + wc_get_logger()->log(WC_Log_Levels::DEBUG, print_r($input, 1)); } -} \ No newline at end of file +} From 5ddd8e10e5dcf202ec20b0858babfdab6b4df7b3 Mon Sep 17 00:00:00 2001 From: Florian Evertz Date: Tue, 26 Jun 2018 11:24:47 +0200 Subject: [PATCH 02/25] add push class - add WC_Heidelpay_Push - change callback_handler in Abstract to catch Push - change default minimum amount value in ivpg from 100 to 10 - remove pushhandling in response class - add missing docs in response class --- .../abstract-wc-heidelpay-payment-gateway.php | 71 ++++++++++--------- includes/class-wc-heidelpay-push.php | 43 +++++++++++ includes/class-wc-heidelpay-response.php | 22 +++--- .../class-wc-heidelpay-gateway-ivpg.php | 2 +- woocommerce-heidelpay.php | 1 + 5 files changed, 91 insertions(+), 48 deletions(-) create mode 100644 includes/class-wc-heidelpay-push.php diff --git a/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php b/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php index 9b9a934..0e4b1a0 100644 --- a/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php +++ b/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php @@ -51,7 +51,7 @@ public function __construct() $this->title = $this->get_option('title'); $this->description = $this->get_option('description'); $this->instructions = $this->get_option('instructions'); - + // Actions add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); add_action('woocommerce_api_' . strtolower(get_class($this)), array($this, 'callback_handler')); @@ -67,29 +67,6 @@ public function __construct() */ abstract protected function setPayMethod(); - /** - * Validate the customer input coming from checkout. - * @return boolean - */ - public function checkoutValidation() - { - //return true; - } - - /** - * Check whether this paymethod was selected based on - * @return bool - */ - public function isGatewayActive() - { - if(!empty($_POST['payment_method'])) { - if($_POST['payment_method'] === $this->id) - return true; - } - - return false; - } - public function init_form_fields() { $this->form_fields = array( @@ -173,6 +150,29 @@ public function init_form_fields() ); } + /** + * Validate the customer input coming from checkout. + * @return boolean + */ + public function checkoutValidation() + { + //return true; + } + + /** + * Check whether this paymethod was selected based on + * @return bool + */ + public function isGatewayActive() + { + if (!empty($_POST['payment_method'])) { + if ($_POST['payment_method'] === $this->id) + return true; + } + + return false; + } + /** * register scripts and stylesheets for your payment gateway */ @@ -280,7 +280,7 @@ protected function setCriterions() global $wp_version; $shopType = 'WordPress: ' . $wp_version . ' - ' . 'WooCommerce: ' . wc()->version; - $this->payMethod->getRequest()->getCriterion()->set('PUSH_URL', 'push-url for testing'); //TODO insert URL + $this->payMethod->getRequest()->getCriterion()->set('PUSH_URL', get_permalink(wc_get_page_id('shop')) . 'wc-api/' . strtolower(get_class($this))); //TODO insert URL $this->payMethod->getRequest()->getCriterion()->set('SHOP.TYPE', $shopType); $this->payMethod->getRequest()->getCriterion()->set( 'SHOPMODULE.VERSION', @@ -336,6 +336,13 @@ protected function performRequest($order_id) } } + /** + * process the Form input from customer comimg from checkout. + */ + protected function handleFormPost() + { + } + /** * @return string */ @@ -355,13 +362,6 @@ public function addPaymentError(String $message) ); } - /** - * process the Form input from customer comimg from checkout. - */ - protected function handleFormPost() - { - } - /** * Get the mapped Errormessage from Respone wich is html escaped. * If a response is given as a parameter that will determine the message. Otherwise the Response from the payMethod @@ -401,8 +401,13 @@ public function admin_options() */ public function callback_handler() { - $response = new WC_Heidelpay_Response(); + if (array_key_exists('init(file_get_contents('php://input')); + exit; + } if (!empty($_POST)) { + $response = new WC_Heidelpay_Response(); $response->init($_POST, $this->get_option('secret')); } exit(); diff --git a/includes/class-wc-heidelpay-push.php b/includes/class-wc-heidelpay-push.php new file mode 100644 index 0000000..4b5cf24 --- /dev/null +++ b/includes/class-wc-heidelpay-push.php @@ -0,0 +1,43 @@ +handlePush(); + } + + public function handlePush() + { + wc_get_logger()->log(WC_Log_Levels::DEBUG, 'PaUSH'); + } +} diff --git a/includes/class-wc-heidelpay-response.php b/includes/class-wc-heidelpay-response.php index 52fec84..679e57d 100644 --- a/includes/class-wc-heidelpay-response.php +++ b/includes/class-wc-heidelpay-response.php @@ -27,6 +27,10 @@ class WC_Heidelpay_Response public static $response; + /** + * @param array $post_data + * @param $secret + */ public function init(array $post_data, $secret) { if (empty(self::$response)) { @@ -50,16 +54,15 @@ public function init(array $post_data, $secret) $order = wc_get_order($orderId); - //$this->handleResult($post_data, $order); - $this->handlePush($post_data); - - //TODO: if case for distinction between result and push + $this->handleResult($post_data, $order); } /** * handle result post + * + * @param $post_data + * @param WC_Order $order */ - public function handleResult($post_data, WC_Order $order) { $uid = self::$response->getIdentification()->getUniqueId(); @@ -107,13 +110,4 @@ public function handleResult($post_data, WC_Order $order) echo $order->get_checkout_order_received_url(); } } - - /* - * handle push post - */ - - public function handlePush($input) - { - wc_get_logger()->log(WC_Log_Levels::DEBUG, print_r($input, 1)); - } } diff --git a/includes/gateways/class-wc-heidelpay-gateway-ivpg.php b/includes/gateways/class-wc-heidelpay-gateway-ivpg.php index dc9a797..785c988 100644 --- a/includes/gateways/class-wc-heidelpay-gateway-ivpg.php +++ b/includes/gateways/class-wc-heidelpay-gateway-ivpg.php @@ -99,7 +99,7 @@ public function init_form_fields() $this->form_fields['min'] = array( 'title' => __('Minimum Amount', 'woocommerce-heidelpay'), 'type' => 'text', - 'default' => 100, + 'default' => 10, 'desc_tip' => true, ); diff --git a/woocommerce-heidelpay.php b/woocommerce-heidelpay.php index 8b73d40..90117e4 100644 --- a/woocommerce-heidelpay.php +++ b/woocommerce-heidelpay.php @@ -132,6 +132,7 @@ public function init() require_once(dirname(__FILE__) . '/includes/gateways/class-wc-heidelpay-gateway-so.php'); require_once(dirname(__FILE__) . '/includes/gateways/class-wc-heidelpay-gateway-va.php'); require_once(dirname(__FILE__) . '/includes/class-wc-heidelpay-response.php'); + require_once(dirname(__FILE__) . '/includes/class-wc-heidelpay-push.php'); add_filter('woocommerce_payment_gateways', array($this, 'add_gateways')); } From b7bb4030a835ac8011118123144f8b4455cd6445 Mon Sep 17 00:00:00 2001 From: Florian Evertz Date: Tue, 26 Jun 2018 11:29:08 +0200 Subject: [PATCH 03/25] Resolve phpstorm Error Notice --- woocommerce-heidelpay.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/woocommerce-heidelpay.php b/woocommerce-heidelpay.php index 90117e4..2d834ec 100644 --- a/woocommerce-heidelpay.php +++ b/woocommerce-heidelpay.php @@ -121,7 +121,11 @@ public function init() return; } - load_plugin_textdomain('woocommerce-heidelpay', false, plugin_basename(dirname(__FILE__)) . '/languages'); + load_plugin_textdomain( + 'woocommerce-heidelpay', + false, + plugin_basename(dirname(__FILE__)) . '/languages' + ); require_once(dirname(__FILE__) . '/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php'); require_once(dirname(__FILE__) . '/includes/gateways/class-wc-heidelpay-gateway-cc.php'); From 547045c008dbf955e88dfdf7a7c84fe1c2ddca9f Mon Sep 17 00:00:00 2001 From: Florian Evertz Date: Tue, 26 Jun 2018 11:40:59 +0200 Subject: [PATCH 04/25] Resolve phpstorm Error Notice - set visibility for get_environment_warning - remove parenthesis on requires --- woocommerce-heidelpay.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/woocommerce-heidelpay.php b/woocommerce-heidelpay.php index 2d834ec..898148b 100644 --- a/woocommerce-heidelpay.php +++ b/woocommerce-heidelpay.php @@ -127,16 +127,16 @@ public function init() plugin_basename(dirname(__FILE__)) . '/languages' ); - require_once(dirname(__FILE__) . '/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php'); - require_once(dirname(__FILE__) . '/includes/gateways/class-wc-heidelpay-gateway-cc.php'); - require_once(dirname(__FILE__) . '/includes/gateways/class-wc-heidelpay-gateway-dc.php'); - require_once(dirname(__FILE__) . '/includes/gateways/class-wc-heidelpay-gateway-idl.php'); - require_once(dirname(__FILE__) . '/includes/gateways/class-wc-heidelpay-gateway-dd.php'); - require_once(dirname(__FILE__) . '/includes/gateways/class-wc-heidelpay-gateway-ivpg.php'); - require_once(dirname(__FILE__) . '/includes/gateways/class-wc-heidelpay-gateway-so.php'); - require_once(dirname(__FILE__) . '/includes/gateways/class-wc-heidelpay-gateway-va.php'); - require_once(dirname(__FILE__) . '/includes/class-wc-heidelpay-response.php'); - require_once(dirname(__FILE__) . '/includes/class-wc-heidelpay-push.php'); + require_once dirname(__FILE__) . '/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php'; + require_once dirname(__FILE__) . '/includes/gateways/class-wc-heidelpay-gateway-cc.php'; + require_once dirname(__FILE__) . '/includes/gateways/class-wc-heidelpay-gateway-dc.php'; + require_once dirname(__FILE__) . '/includes/gateways/class-wc-heidelpay-gateway-idl.php'; + require_once dirname(__FILE__) . '/includes/gateways/class-wc-heidelpay-gateway-dd.php'; + require_once dirname(__FILE__) . '/includes/gateways/class-wc-heidelpay-gateway-ivpg.php'; + require_once dirname(__FILE__) . '/includes/gateways/class-wc-heidelpay-gateway-so.php'; + require_once dirname(__FILE__) . '/includes/gateways/class-wc-heidelpay-gateway-va.php'; + require_once dirname(__FILE__) . '/includes/class-wc-heidelpay-response.php'; + require_once dirname(__FILE__) . '/includes/class-wc-heidelpay-push.php'; add_filter('woocommerce_payment_gateways', array($this, 'add_gateways')); } @@ -217,7 +217,7 @@ public function install() * Checks the environment for compatibility problems. Returns a string with the first incompatibility * found or false if the environment has no problems. */ - static function get_environment_warning() + public static function get_environment_warning() { if (version_compare(phpversion(), WC_HEIDELPAY_MIN_PHP_VER, '<')) { $message = __('minimal PHP version error', 'woocommerce-heidelpay'); From 402c1eed5860d1949c7702c166c2cdb99c149cf5 Mon Sep 17 00:00:00 2001 From: Florian Evertz Date: Tue, 26 Jun 2018 11:51:33 +0200 Subject: [PATCH 05/25] Resolve phpstorm Error Notice without codesniffer --- woocommerce-heidelpay.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/woocommerce-heidelpay.php b/woocommerce-heidelpay.php index 898148b..70107b3 100644 --- a/woocommerce-heidelpay.php +++ b/woocommerce-heidelpay.php @@ -80,7 +80,7 @@ private function __clone() * * @return void */ - private function __wakeup() + public function __wakeup() { } @@ -143,6 +143,8 @@ public function init() /** * Add the gateways to WooCommerce. + * @param $methods + * @return array */ public function add_gateways($methods) { @@ -174,6 +176,9 @@ public function check_environment() /** * Allow this class and other classes to add slug keyed notices (to avoid duplication) + * @param $slug + * @param $class + * @param $message */ public function add_admin_notice($slug, $class, $message) { @@ -210,7 +215,7 @@ public function install() define('WC_HEIDELPAY_INSTALLING', true); } - $this->_update_plugin_version(); + static::_update_plugin_version(); } /** @@ -222,7 +227,7 @@ public static function get_environment_warning() if (version_compare(phpversion(), WC_HEIDELPAY_MIN_PHP_VER, '<')) { $message = __('minimal PHP version error', 'woocommerce-heidelpay'); - return sprintf($message, WC_HEIDELPAY_MIN_PHP_VER_MIN_PHP_VER, phpversion()); + return sprintf($message, WC_HEIDELPAY_MIN_PHP_VER, phpversion()); } if (!defined('WC_VERSION')) { @@ -251,7 +256,7 @@ public static function get_environment_warning() */ public function get_setting_link() { - $use_id_as_section = function_exists('WC') ? version_compare(WC()->version, '2.6', '>=') : false; + $use_id_as_section = function_exists('WC') ? version_compare(wc()->version, '2.6', '>=') : false; $section_slug = $use_id_as_section ? 'heidelpay' : strtolower('WC_Heidelpay'); @@ -272,6 +277,7 @@ public function admin_notices() /** * logging + * @param $message */ public static function log($message) { @@ -288,4 +294,3 @@ public static function log($message) endif; } - From a072f7261944fbcdec47129e94c5298925159aff Mon Sep 17 00:00:00 2001 From: Florian Evertz Date: Tue, 26 Jun 2018 12:00:32 +0200 Subject: [PATCH 06/25] Add Changelog entry & changed version --- CHANGELOG.md | 7 +++++++ woocommerce-heidelpay.php | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c1e861..4829451 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Release Notes - heidelpay Payment Gateway for WooCommerce +## 1.2.0 + +### Added + +#### Features: +- Support for push notifications + ## 1.1.0 ### Added diff --git a/woocommerce-heidelpay.php b/woocommerce-heidelpay.php index 70107b3..af4f2bc 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.1.0 + * Version: 1.2.0 * Author: heidelpay * Author URI: htts://www.heidelpay.com * Developer: heidelpay @@ -29,7 +29,7 @@ /** * Required minimums and constants */ - define('WC_HEIDELPAY_VERSION', '1.1.0'); + define('WC_HEIDELPAY_VERSION', '1.2.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__); @@ -192,7 +192,7 @@ public function add_admin_notice($slug, $class, $message) * Updates the plugin version in db * * @since 1.0.0 - * @version 1.0.1 + * @version 1.2.0 * @return bool */ private static function _update_plugin_version() @@ -207,7 +207,7 @@ private static function _update_plugin_version() * Handles upgrade routines. * * @since 1.0.0 - * @version 1.0.1 + * @version 1.2.0 */ public function install() { From 79fe6223640f20029af0ec82c59ef3306b8d27aa Mon Sep 17 00:00:00 2001 From: Florian Evertz Date: Tue, 10 Jul 2018 11:44:32 +0200 Subject: [PATCH 07/25] Add Hashcheck --- .../abstract-wc-heidelpay-payment-gateway.php | 2 +- includes/class-wc-heidelpay-push.php | 27 ++++++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php b/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php index 0e4b1a0..119eda3 100644 --- a/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php +++ b/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php @@ -403,7 +403,7 @@ public function callback_handler() { if (array_key_exists('init(file_get_contents('php://input')); + $push->init(file_get_contents('php://input'), $this->get_option('secret')); exit; } if (!empty($_POST)) { diff --git a/includes/class-wc-heidelpay-push.php b/includes/class-wc-heidelpay-push.php index 4b5cf24..aa53186 100644 --- a/includes/class-wc-heidelpay-push.php +++ b/includes/class-wc-heidelpay-push.php @@ -25,19 +25,38 @@ class WC_Heidelpay_Push { + /** @var Heidelpay\PhpPaymentApi\Push */ public static $push; - public function init($rawPayload) + public function init($rawPayload, $secret) { if (empty(self::$push)) { self::$push = new Push($rawPayload); } + $response = self::$push->getResponse(); - $this->handlePush(); + try { + $response->verifySecurityHash($secret, $response->getIdentification()->getTransactionId()); + } catch (\Exception $e) { + $callers = debug_backtrace(); + wc_get_logger()->log(WC_Log_Levels::NOTICE, print_r("Heidelpay - " . + $callers [0] ['function'] . ": Invalid push hash from " . + $_SERVER ['REMOTE_ADDR'] . ", suspecting manipulation", 1)); + exit(); //error + } + + $this->handlePush($response); } - public function handlePush() + public function handlePush($response) { - wc_get_logger()->log(WC_Log_Levels::DEBUG, 'PaUSH'); + //TODO: HashSecurityCheck + //TODO: Amount mit OrderAmount abgleichen + //TODO: Push in Datenbank schreiben? + + $orderID = $response->getIdentification()->getTransactionId(); + $order = wc_get_order($orderID); + + $order->update_status('processing', 'Bezahlung ist eingegangen'); } } From 5fe4e6864cbf148a621261f754dafd7895f0d2b6 Mon Sep 17 00:00:00 2001 From: Florian Evertz Date: Thu, 12 Jul 2018 16:25:08 +0200 Subject: [PATCH 08/25] extract Push to one URL --- .../abstract-wc-heidelpay-payment-gateway.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php b/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php index ee80c99..7a6a4cb 100644 --- a/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php +++ b/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php @@ -55,6 +55,7 @@ public function __construct() // Actions add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); add_action('woocommerce_api_' . strtolower(get_class($this)), array($this, 'callback_handler')); + add_action('woocommerce_api_push', array($this, 'pushHandler')); add_action('wp_enqueue_scripts', array($this, 'enqueue_assets')); add_action('woocommerce_after_checkout_validation', array($this, 'checkoutValidation')); @@ -67,6 +68,16 @@ public function __construct() */ abstract protected function setPayMethod(); + + public function pushHandler() + { + if (array_key_exists('init(file_get_contents('php://input'), $this->get_option('secret')); + } + exit; + } + public function init_form_fields() { $this->form_fields = array( @@ -280,7 +291,7 @@ protected function setCriterions() global $wp_version; $shopType = 'WordPress: ' . $wp_version . ' - ' . 'WooCommerce: ' . wc()->version; - $this->payMethod->getRequest()->getCriterion()->set('PUSH_URL', get_permalink(wc_get_page_id('shop')) . 'wc-api/' . strtolower(get_class($this))); //TODO insert URL + $this->payMethod->getRequest()->getCriterion()->set('PUSH_URL', get_home_url() . '/wc-api/push'); $this->payMethod->getRequest()->getCriterion()->set('SHOP.TYPE', $shopType); $this->payMethod->getRequest()->getCriterion()->set( 'SHOPMODULE.VERSION', @@ -401,11 +412,6 @@ public function admin_options() */ public function callback_handler() { - if (array_key_exists('init(file_get_contents('php://input'), $this->get_option('secret')); - exit; - } if (!empty($_POST)) { $response = new WC_Heidelpay_Response(); $response->init($_POST, $this->get_option('secret')); From 9bd9c57db272b8aea0ffe6f014757616cd4e491f Mon Sep 17 00:00:00 2001 From: "David.Owusu" Date: Fri, 13 Jul 2018 19:15:24 +0200 Subject: [PATCH 09/25] (WOO-20) Bugfix PaymentInfo: Add paymentInfo to invoice as a notice text on "order-received"-page and to the payment mail. Fixed email is sent in other payment methods. Fixed error of isAvailable hook if called in wrong context. --- .../abstract-wc-heidelpay-payment-gateway.php | 8 ++ includes/class-wc-heidelpay-response.php | 45 +++++++++++- .../class-wc-heidelpay-gateway-idl.php | 11 ++- .../class-wc-heidelpay-gateway-ivpg.php | 73 ++++++++++++++----- 4 files changed, 113 insertions(+), 24 deletions(-) diff --git a/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php b/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php index 15f1752..63feeed 100644 --- a/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php +++ b/includes/abstracts/abstract-wc-heidelpay-payment-gateway.php @@ -436,4 +436,12 @@ protected function getBookingSelection() 'default' => 'DB' ); } + + public function getOrderFromKey() + { + $order_id = wc_get_order_id_by_order_key($_GET['key']); + $order = wc_get_order($order_id); + + return $order; + } } diff --git a/includes/class-wc-heidelpay-response.php b/includes/class-wc-heidelpay-response.php index bdffd7a..ebe20d4 100644 --- a/includes/class-wc-heidelpay-response.php +++ b/includes/class-wc-heidelpay-response.php @@ -25,6 +25,9 @@ class WC_Heidelpay_Response { + /** + * @var Response + */ public static $response; public function init(array $post_data, $secret) @@ -68,14 +71,16 @@ public function handleResult($post_data, WC_Order $order) $note = ''; // If no money has been payed yet. - if (strtoupper($payCode[1]) === 'PA' or strtoupper($payCode[1]) === 'RG') { + if (strtoupper($payCode[1]) === 'PA' || strtoupper($payCode[1]) === 'RG') { // In not Prepayment and Invoice payment can be captured manually - if (strtoupper($payCode [0]) !== 'PP' and strtoupper($payCode [0]) !== 'IV') { + if (strtoupper($payCode [0]) !== 'PP' && strtoupper($payCode [0]) !== 'IV') { $note = __( 'Payment reservation successful. Please use the hiP to check the payment.', 'woocommerce-heidelpay.' ); $order->add_order_note($note, false); + } else { + $order->add_meta_data('heidelpay-paymentInfo', $this->setPaymentInfo(self::$response)); } $order->update_status('on-hold', __('Awaiting payment.', 'woocommerce-heidelpay') @@ -105,6 +110,42 @@ public function handleResult($post_data, WC_Order $order) //show thank you page echo $order->get_checkout_order_received_url(); } + + $info = $order->get_meta('heidelpay-paymentInfo', true); + wc_get_logger()->log( + WC_Log_Levels::DEBUG, + 'Payment - Meta ' . htmlspecialchars(print_r($info, 1)) + ); + } + + public function setPaymentInfo(Response $response) + { + $payinfo = $response->getConnector(); + $presentation = $response->getPresentation(); + + + $payInfoTemplate = 'Zahlungsinformationen
+Bitte überweisen Sie uns den Betrag von %1$s %2$s nach Erhalt der Ware auf folgendes Konto:
+
+Kontoinhaber: %3$s
+IBAN: %4$s
+BIC: %5$s
+
+Geben Sie als Verwendungszweck bitte ausschließlich diese Identifikationsnummer an:
+%6$s '; + + $infoText = sprintf( + $payInfoTemplate, + $presentation->getAmount(), + $presentation->getCurrency(), + $payinfo->getAccountHolder(), + $payinfo->getAccountIBan(), + $payinfo->getAccountBic(), + self::$response->getIdentification()->getShortId() + ); + + wc_get_logger()->log(WC_Log_Levels::DEBUG, 'Payment - info' . htmlspecialchars(print_r($infoText, 1))); + return $infoText; } /* diff --git a/includes/gateways/class-wc-heidelpay-gateway-idl.php b/includes/gateways/class-wc-heidelpay-gateway-idl.php index d5e2898..2af51f6 100644 --- a/includes/gateways/class-wc-heidelpay-gateway-idl.php +++ b/includes/gateways/class-wc-heidelpay-gateway-idl.php @@ -78,10 +78,10 @@ public function payment_fields() $accountHolder = wc()->customer->get_billing_first_name(). ' ' . wc()->customer->get_last_name(); - if(!empty($brands)) { + if (!empty($brands)) { echo '
'; echo ''; - echo ' '; + echo ' '; echo '
'; echo ''; echo '