BillTechPL / lms-billtech-plugin

Other
6 stars 7 forks source link

Nie działa BillTechPaymentCashImportHandler #20

Closed interduo closed 5 years ago

interduo commented 5 years ago

Mam zmienną: cashimport_enabled = true

Wydaje mi się, że w: https://github.com/BillTechPL/lms-billtech-plugin/blob/master/handlers/BillTechPaymentCashImportHandler.php#L18

Coś nie gra. Czy | nie powinien być escape'nięty?

Mam najnowszą wersję wtyczki.

Mam np wpłatę: Opłata za saldo-20190522 ID: 681 re|f:20190522-331308 dotpay: 355898 M1|278-88906 (Wpłata BS)

michal-kaciuba commented 5 years ago

Sprawdzisz proszę czy najnowsza zmiana na https://github.com/BillTechPL/lms-billtech-plugin/tree/cashimport rozwiązuje problem?

interduo commented 5 years ago

Ok - wrzuciłem sobie cherry-pickiem commita, dam znać jutro czy pomogło. W poniedziałek.

interduo commented 5 years ago

Nie działa.

2019/05/29 11:08 | Paweł | - | +112,00 zł | - | » | 0,00 zł | BillTech Payments |  
-- | -- | -- | -- | -- | -- | -- | -- | --
2019/05/30 00:00 |   | - | +112,00 zł | - | » | 112,00 zł | Opłata za saldo-20190529 ID: 527 re\|f:20190529-045156 dotpay: 355898 M2\|443-94603 (Wpłata BS)

lub

2019/05/29 09:58 |   | - | +100,00 zł | - | » | 0,00 zł | BillTech Payments |  
-- | -- | -- | -- | -- | -- | -- | -- | --
2019/05/30 00:00 |   | - | +100,00 zł | - | » | 100,00 zł | Opłata za saldo-20190529 ID: 2547 r\|ef:20190529-408486 dotpay: 355898 M\|1407-19203 (Wpłata BS)

lub

2019/05/29 08:53 | Paweł | - | +245,00 zł | - | » | 0,00 zł | BillTech Payments |  
-- | -- | -- | -- | -- | -- | -- | -- | --
2019/05/30 00:00 |   | - | +245,00 zł | - | » | 245,00 zł | Opłata za saldo-20190529 ID: 1867 r\|ef:20190529-073144 dotpay: 355898 M\|1407-19206 (Wpłata BS)

Cashimport wykonuję za pomocą skryptu https://github.com/lmsgit/lms/blob/master/bin/lms-cashimport.php.

interduo commented 5 years ago

@MKaciuba pomożesz z tym?

michal-kaciuba commented 5 years ago

@interduo jaka jest wartość w konfiguracji cashimport.autocommit? Czy możesz zweryfikować czy w ogóle ten hook jest wywoływany dodając np. jakiegoś loga do BillTechPaymentCashImportHandler->processCashImport?

interduo commented 5 years ago
SELECT * FROM uiconfig WHERE section='billtech' AND var='cashimport_enabled';
+-----+----------+--------------------+-------+-------------+----------+------+
| id  | section  | var                | value | description | disabled | type |
+-----+----------+--------------------+-------+-------------+----------+------+
| 367 | billtech | cashimport_enabled | true  |             |        0 |    7 |
+-----+----------+--------------------+-------+-------------+----------+------+
SELECT * FROM uiconfig WHERE var="autocommit";
+-----+------------+------------+-------+-------------+----------+------+
| id  | section    | var        | value | description | disabled | type |
+-----+------------+------------+-------+-------------+----------+------+
| 287 | cashimport | autocommit | true  |             |        0 |    7 |
+-----+------------+------------+-------+-------------+----------+------+
interduo commented 5 years ago

Aktualnie w systemie mam plugin zawierający commit: https://github.com/BillTechPL/lms-billtech-plugin/commit/7f3bf857f067baf30a664d4af2cb394c75ebc45b

Dodałem: w https://github.com/BillTechPL/lms-billtech-plugin/blob/master/handlers/BillTechPaymentCashImportHandler.php#L13

kod mail('jkl@interduo.pl','BillTechPaymentCashImportHandler.php - hook test','biltechowy handler w skrypcie billtechpaymentcashimporthandler dziala');

Zobaczymy czy jutro płatności się rozliczą.

interduo commented 5 years ago

Handler działa. Dostałem maila po imporcie za pomocą lms-cashimport.php który mam w crontabie.

Płatności billtechowe są nadal nierozliczone w https://lms/?m=billtechpaymentlist (oczywiście nie starsze niż $billtech.payment_expiration).

michal-kaciuba commented 5 years ago

Spróbujesz jeszcze ze zmianami z brancha cashimport?

interduo commented 5 years ago

Jak już napisałem ten commit (https://github.com/BillTechPL/lms-billtech-plugin/commit/7f3bf857f067baf30a664d4af2cb394c75ebc45b) mam u siebie w systemie. Branche różnią się tylko tym commitem.

michal-kaciuba commented 5 years ago

Ok, zmyliło mnie, że podlinkowałeś https://github.com/BillTechPL/lms-billtech-plugin/blob/master/handlers/BillTechPaymentCashImportHandler.php#L13. W takim razie czy mógłbyś do tego maila dodać jeszcze wartość var_dump($hookdata, true) i podesłać do mnie?

interduo commented 5 years ago

Teraz w https://github.com/BillTechPL/lms-billtech-plugin/blob/master/handlers/BillTechPaymentCashImportHandler.php#L13 dodałem kod:

$msg=var_dump($hookdata, true);
mail('jkl@interduo.pl','BillTechPaymentCashImportHandler.php',$msg);

Dam Ci tego maila jutro dopiero po 11.

interduo commented 5 years ago

Dostałem pustego maila, czyli $hookdata puste

interduo commented 5 years ago
array(1) {
  ["cashimports"]=>
  array(1) {
    [0]=>
    array(11) {
      ["id"]=>
      string(5) "98417"
      ["date"]=>
      string(10) "1562709600"
      ["value"]=>
      string(4) "1.00"
      ["customer"]=>
      string(21) "WYKASOWAŁEM BO RODO"
      ["description"]=>
      string(34) "WYKASOWAŁEM BO RODO"
      ["customerid"]=>
      string(3) "635"
      ["hash"]=>
      string(32) "a5e2e1c5fa56caaf617a9d0140cae4c8"
      ["closed"]=>
      string(1) "0"
      ["sourceid"]=>
      NULL
      ["sourcefileid"]=>
      string(4) "2534"
      ["idate"]=>
      string(10) "1562838349"
    }
  }
}
bool(true)
michal-kaciuba commented 5 years ago

@interduo sprawdź https://github.com/BillTechPL/lms-billtech-plugin/commit/5bbc8d64e1e17f5556561ebbba09dd7954219108

interduo commented 5 years ago

Niestety to jeszcze nie to. Płatność nadal nie jest rozliczona.

michal-kaciuba commented 5 years ago

Czy wartość pola description wygląda tak: Opłata za saldo-20190522 ID: 681 re|f:20190522-331308 dotpay: 355898 M1|278-88906 (Wpłata BS)? Separator to | czy \|?

interduo commented 5 years ago

Separator w polu description to pojedyńczy znak |.

interduo commented 5 years ago
Array
(
    [0] => Array
        (
            [id] => 98422
            [date] => 1562709600
            [value] => 126.00
            [customer] => RODOSRODO
            [description] => Opłata za saldo-20190709 ID: 361 re|f:20190709-338742 dotpay: 355898 M1|763-44428 (Wpłata BS)
            [customerid] => 361
            [hash] => dd346948825940f8ef3fdc03fd1cd109
            [closed] => 0
            [sourceid] => 
            [sourcefileid] => 2539
            [idate] => 1562844774
        )

)
interduo commented 5 years ago

https://github.com/BillTechPL/lms-billtech-plugin/blob/master/handlers/BillTechPaymentCashImportHandler.php#L18

to jest winne - prag_replace nie działa - kasuje wszystko

interduo commented 5 years ago
# git diff
diff --git a/handlers/BillTechPaymentCashImportHandler.php b/handlers/BillTechPaymentCashImportHandler.php
index bc363c6..74110d6 100644
--- a/handlers/BillTechPaymentCashImportHandler.php
+++ b/handlers/BillTechPaymentCashImportHandler.php
@@ -15,7 +15,7 @@ class BillTechPaymentCashImportHandler
                        $description = $import['description'];

                        if (ConfigHelper::getConfig('billtech.cashimport_enabled', false) && $description) {
-                               preg_match('/ref:(\d{8}-\d{6})/', preg_replace('[,|]', '', $description), $matches);
+                               preg_match('/ref:(\d{8}-\d{6})/', preg_replace('/[|]/', '', $description), $matches);
                                if (isset($matches[1])) {
                                        $reference_number = $matches[1];
                                        $payment = $DB->GetRow("SELECT id, amount, closed, cashid FROM billtech_payments WHERE reference_number=? AND closed=0", array($reference_number));
interduo commented 5 years ago

Naprawiłem i działa. Jak wrzucisz do repo zamknij zgłoszenie.