Skip to content

Commit de99cea

Browse files
author
Samuel Kmita
committed
v2.1.4
1 parent eece0bb commit de99cea

12 files changed

Lines changed: 1514 additions & 151 deletions

Gateway/Base.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,12 @@ public function process_payment($order_id)
241241

242242
if (!$method) {
243243
wc_add_notice(__('Unsupported payment method', 'wc-gateway-paylane'), 'error');
244+
WCPL_Logger::log("[process_payment]\nUnsupported payment method\norder_id: ".$order_id,'error');
244245
return array('success' => false);
245246
}
246247

247248
if (!$this->validate_fields()) {
249+
WCPL_Logger::log("[process_payment]\nNOT valid fields\norder_id: ".$order_id,'error');
248250
return array('success' => false);
249251
}
250252

@@ -276,6 +278,7 @@ public function process_payment($order_id)
276278

277279
if (is_null($payload) || !$this->isCorrectpayload($payload)) {
278280
wc_add_notice(__('Incorrect Apple Pay payload', 'wc-gateway-paylane'), 'error');
281+
WCPL_Logger::log("[process_payment]\nIncorrect Apple Pay payload\norder_id: ".$order_id,'error');
279282
return array('success' => false);
280283
}
281284

@@ -362,6 +365,7 @@ public function process_payment($order_id)
362365
}
363366

364367
$this->set_order_paylane_type($order_id, $method);
368+
WCPL_Logger::log("[process_payment]\nWoocommerce process finished\norder_id: ".$order_id."\ntype: ".$method);
365369
return array(
366370
'result' => 'success',
367371
'redirect' => add_query_arg(array('order_id' => $order_id, 'type' => $method), $this->notify_link),
@@ -448,6 +452,7 @@ public function handle_notification($data, $token, $communication_id)
448452
$this->checkBasicAuth();
449453
}
450454
if (empty($_POST['communication_id'])) {
455+
WCPL_Logger::log("[handle_notification]\nEmpty communication id",'error');
451456
die('Empty communication id');
452457
}
453458

@@ -472,22 +477,27 @@ private function parseNotification($notification, $order)
472477

473478
if ($notification['type'] === 'S') {
474479
$order->add_order_note('PayLane: ' . __('Transaction complete', 'wc-gateway-paylane'));
480+
WCPL_Logger::log("[handle_notification]\nTransaction complete\nsale_id: ".$id_sale);
475481
}
476482

477483
if ($notification['type'] === 'R') {
478484
$order->add_order_note('PayLane: ' . __('Refund complete', 'wc-gateway-paylane'));
485+
WCPL_Logger::log("[handle_notification]\nRefund complete\nsale_id: ".$id_sale);
479486
}
480487

481488
if ($notification['type'] === 'RV') {
482489
$order->update_status('on-hold', __('Reversal received', 'wc-gateway-paylane'));
490+
WCPL_Logger::log("[handle_notification]\nReversal received\nsale_id: ".$id_sale);
483491
}
484492

485493
if ($notification['type'] === 'RRO') {
486494
$order->update_status('on-hold', __('Retrieval request / chargeback opened', 'wc-gateway-paylane'));
495+
WCPL_Logger::log("[handle_notification]\nRetrieval request / chargeback opened (RRO)\nsale_id: ".$id_sale);
487496
}
488497

489498
if ($notification['type'] === 'CAD') {
490499
$order->update_status('on-hold', __('Retrieval request / chargeback opened', 'wc-gateway-paylane'));
500+
WCPL_Logger::log("[handle_notification]\nRetrieval request / chargeback opened (CAD)\nsale_id: ".$id_sale);
491501
}
492502

493503
update_post_meta($order->get_id(), 'paylane-notification-timestamp', time());

changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Changelog by Mind Joker Marcin Musiak <marcin@musiak.pl>
22
=========================================================
33

4+
= 2.1.4 - 2019-08-07 =
5+
* Fix the 3-D Secure flow when 3DS is required
6+
* Add descriptions in the admin section
7+
* Improved the non successful payments. From now client will be able to retry it using different payment method or different payment data
8+
* Add debug logs feature
9+
* Add new translations of payment errors
10+
411
= 2.1.3 - 2019-07-24 =
512
* Improve display payment methods names
613
* Add option to display/hide payment methods logo

forms/basic/transfer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php if ( !defined( 'ABSPATH' ) ) exit;
22

33
require_once __DIR__ . '/../../includes/paylane-banks.php';
4-
$paymentTypes = getBankTransferPaymentTypes();
4+
$paymentTypes = wcpl_getBankTransferPaymentTypes();
55

66
?>
77
<div class="paylane-payment-form paylane-payment-form--polish-bank-transfers">

forms/paylane/transfer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php if ( !defined( 'ABSPATH' ) ) exit;
22

33
require_once __DIR__ . '/../../includes/paylane-banks.php';
4-
$paymentTypes = getBankTransferPaymentTypes();
4+
$paymentTypes = wcpl_getBankTransferPaymentTypes();
55

66
?>
77
<div class="paylane-payment-form paylane-payment-form--polish-bank-transfers">

includes/logger.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
if (!defined('ABSPATH')) {
3+
exit;
4+
}
5+
6+
class WCPL_Logger
7+
{
8+
public static $logger;
9+
const LOG_FILENAME = 'woocommerce-gateway-paylane';
10+
11+
public static function log($message, $type = null)
12+
{
13+
if (!class_exists('WC_Logger')) {
14+
return;
15+
}
16+
17+
if (empty(self::$logger)) {
18+
if (version_compare(WC_VERSION, '3.0', '<')) {
19+
self::$logger = new WC_Logger();
20+
} else {
21+
self::$logger = wc_get_logger();
22+
}
23+
}
24+
25+
$settings = get_option('woocommerce_paylane_settings');
26+
27+
if (empty($settings) || isset($settings['logging']) && $settings['logging'] !== 'yes') {
28+
return;
29+
}
30+
31+
if(is_null($type)){
32+
$type = 'info';
33+
}
34+
35+
$txt = "\n" . '======= ['.strtoupper($type).'] =======' . "\n" . $message . "\n" . '======= End Log =======' . "\n\n";
36+
37+
if (version_compare(WC_VERSION, '3.0', '<')) {
38+
self::$logger->add(self::LOG_FILENAME, $txt);
39+
} else {
40+
self::$logger->debug($txt, array('source' => self::LOG_FILENAME));
41+
}
42+
}
43+
44+
public static function secure(array $data){
45+
if(isset($data['hash'])){
46+
$data['hash'] = '===SECRET===';
47+
}
48+
49+
return $data;
50+
}
51+
}

includes/paylane-banks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php if ( !defined( 'ABSPATH' ) ) exit;
22

3-
function getBankTransferPaymentTypes()
3+
function wcpl_getBankTransferPaymentTypes()
44
{
55
$result = array(
66
'AB' => array(

0 commit comments

Comments
 (0)