-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
C. Proske
committed
May 15, 2020
1 parent
36ab644
commit 27fe37c
Showing
42 changed files
with
3,101 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
use ws_mollie\Helper; | ||
|
||
require_once __DIR__ . '/../class/Helper.php'; | ||
try { | ||
Helper::init(); | ||
|
||
if (array_key_exists("action", $_REQUEST) && $_REQUEST['action'] === 'update-plugin') { | ||
Shop::Smarty()->assign('defaultTabbertab', Helper::getAdminmenu('Info')); | ||
Helper::selfupdate(); | ||
} | ||
|
||
$svgQuery = http_build_query([ | ||
'p' => Helper::oPlugin()->cPluginID, | ||
'v' => Helper::oPlugin()->nVersion, | ||
's' => defined('APPLICATION_VERSION') ? APPLICATION_VERSION : JTL_VERSION, | ||
'b' => defined('JTL_MINOR_VERSION') ? JTL_MINOR_VERSION : '0', | ||
'd' => Helper::getDomain(), | ||
'm' => base64_encode(Helper::getMasterMail(true)), | ||
'php' => PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION . PHP_EXTRA_VERSION, | ||
]); | ||
|
||
echo "<script type='application/javascript' src='//cdn.webstollen.com/plugin/js/ws.js?p=" . Helper::oPlugin()->cPluginID . '&v=' . Helper::oPlugin()->nVersion . "'></script>"; | ||
echo "<div id='ws-head-bar' class='row'>" . | ||
" <div class='col-md-4 text-center'>" . | ||
" <object data='//lic.dash.bar/info/licence?{$svgQuery}' type='image/svg+xml'>" . | ||
" <img src='//lic.dash.bar/info/licence.png?{$svgQuery}' width='370' height='20' alt='Lizenz Informationen'>" . | ||
' </object>' . | ||
' </div>' . | ||
" <div class='col-md-4 text-center'>" . | ||
" <object data='//lic.dash.bar/info/version?{$svgQuery}' type='image/svg+xml'>" . | ||
" <img src='//lic.dash.bar/info/version.png?{$svgQuery}' width='370' height='20' alt='Update Informationen'>" . | ||
' </object>' . | ||
' </div>' . | ||
" <div class='col-md-4 text-center'>" . | ||
" <object data='//lic.dash.bar/info/help?{$svgQuery}' type='image/svg+xml'>" . | ||
" <img src='//lic.dash.bar/info/help.png?{$svgQuery}' width='370' height='20' alt='Plugin informationen'>" . | ||
' </object>' . | ||
' </div>' . | ||
'</div>'; | ||
|
||
try { | ||
$latestRelease = Helper::getLatestRelease(array_key_exists('update', $_REQUEST)); | ||
if ((int)Helper::oPlugin()->nVersion < (int)$latestRelease->version) { | ||
Shop::Smarty()->assign('update', $latestRelease); | ||
} | ||
|
||
} catch (\Exception $e) { | ||
} | ||
|
||
Shop::Smarty()->display(Helper::oPlugin()->cAdminmenuPfad . '/tpl/info.tpl'); | ||
|
||
if (file_exists(__DIR__ . '/_addon.php')) { | ||
try { | ||
include __DIR__ . '/_addon.php'; | ||
} catch (Exception $e) { | ||
} | ||
} | ||
|
||
} catch (Exception $e) { | ||
echo "<div class='alert alert-danger'>Fehler: {$e->getMessage()}</div>"; | ||
Helper::logExc($e); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
<?php | ||
|
||
use Mollie\Api\Types\OrderStatus; | ||
use ws_mollie\Helper; | ||
use ws_mollie\Model\Payment; | ||
use ws_mollie\Mollie; | ||
|
||
require_once __DIR__ . '/../class/Helper.php'; | ||
try { | ||
if (!Helper::init()) { | ||
echo "Kein gültige Lizenz?"; | ||
return; | ||
} | ||
require_once __DIR__ . '/../paymentmethod/JTLMollie.php'; | ||
global $oPlugin; | ||
$ordersMsgs = []; | ||
if (array_key_exists('action', $_REQUEST)) { | ||
switch ($_REQUEST['action']) { | ||
case 'refund': | ||
if (!array_key_exists('id', $_REQUEST)) { | ||
$ordersMsgs[] = (object)['type' => 'danger', 'text' => 'Keine ID angeben!']; | ||
break; | ||
} | ||
$payment = Payment::getPaymentMollie($_REQUEST['id']); | ||
if (!$payment) { | ||
$ordersMsgs[] = (object)['type' => 'danger', 'text' => 'Order nicht gefunden!']; | ||
break; | ||
} | ||
|
||
$order = JTLMollie::API()->orders->get($_REQUEST['id']); | ||
if ($order->status == OrderStatus::STATUS_CANCELED) { | ||
$ordersMsgs[] = (object)['type' => 'danger', 'text' => 'Bestellung bereits storniert']; | ||
break; | ||
} | ||
$refund = JTLMollie::API()->orderRefunds->createFor($order, ['lines' => []]); | ||
Mollie::JTLMollie()->doLog("Order refunded: <br/><pre>" . print_r($refund, 1) . "</pre>", '$' . $payment->kID . '#' . $payment->kBestellung . '§' . $payment->cOrderNumber, LOGLEVEL_NOTICE); | ||
|
||
goto order; | ||
break; | ||
|
||
case 'cancel': | ||
if (!array_key_exists('id', $_REQUEST)) { | ||
$ordersMsgs[] = (object)['type' => 'danger', 'text' => 'Keine ID angeben!']; | ||
break; | ||
} | ||
$payment = Payment::getPaymentMollie($_REQUEST['id']); | ||
if (!$payment) { | ||
$ordersMsgs[] = (object)['type' => 'danger', 'text' => 'Order nicht gefunden!']; | ||
break; | ||
} | ||
$order = JTLMollie::API()->orders->get($_REQUEST['id']); | ||
if ($order->status == OrderStatus::STATUS_CANCELED) { | ||
$ordersMsgs[] = (object)['type' => 'danger', 'text' => 'Bestellung bereits storniert']; | ||
break; | ||
} | ||
$cancel = JTLMollie::API()->orders->cancel($order->id); | ||
Mollie::JTLMollie()->doLog("Order canceled: <br/><pre>" . print_r($cancel, 1) . "</pre>", '$' . $payment->kID . '#' . $payment->kBestellung . '§' . $payment->cOrderNumber, LOGLEVEL_NOTICE); | ||
goto order; | ||
break; | ||
|
||
case 'capture': | ||
if (!array_key_exists('id', $_REQUEST)) { | ||
$ordersMsgs[] = (object)['type' => 'danger', 'text' => 'Keine ID angeben!']; | ||
break; | ||
} | ||
$payment = Payment::getPaymentMollie($_REQUEST['id']); | ||
if (!$payment) { | ||
$ordersMsgs[] = (object)['type' => 'danger', 'text' => 'Order nicht gefunden!']; | ||
break; | ||
} | ||
$order = JTLMollie::API()->orders->get($_REQUEST['id']); | ||
if ($order->status !== OrderStatus::STATUS_AUTHORIZED && $order->status !== OrderStatus::STATUS_SHIPPING) { | ||
$ordersMsgs[] = (object)['type' => 'danger', 'text' => 'Nur autorisierte Zahlungen können erfasst werden!']; | ||
break; | ||
} | ||
|
||
$oBestellung = new Bestellung($payment->kBestellung, true); | ||
if (!$oBestellung->kBestellung) { | ||
$ordersMsgs[] = (object)['type' => 'danger', 'text' => 'Bestellung konnte nicht geladen werden!']; | ||
break; | ||
} | ||
|
||
$logData = '#' . $payment->kBestellung . '$' . $payment->kID . "§" . $oBestellung->cBestellNr; | ||
|
||
$options = ['lines' => []]; | ||
if ($oBestellung->cTracking) { | ||
$tracking = new stdClass(); | ||
$tracking->carrier = $oBestellung->cVersandartName; | ||
$tracking->url = $oBestellung->cTrackingURL; | ||
$tracking->code = $oBestellung->cTracking; | ||
$options['tracking'] = $tracking; | ||
} | ||
|
||
// CAPTURE ALL | ||
$shipment = JTLMollie::API()->shipments->createFor($order, $options); | ||
$ordersMsgs[] = (object)['type' => 'success', 'text' => 'Zahlung wurde erfolgreich erfasst!']; | ||
Mollie::JTLMollie()->doLog('Shipment created<br/><pre>' . print_r(['options' => $options, 'shipment' => $shipment], 1) . '</pre>', $logData); | ||
goto order; | ||
|
||
case 'order': | ||
order: | ||
if (!array_key_exists('id', $_REQUEST)) { | ||
$ordersMsgs[] = (object)['type' => 'danger', 'text' => 'Keine ID angeben!']; | ||
break; | ||
} | ||
|
||
$order = JTLMollie::API()->orders->get($_REQUEST['id'], ['embed' => 'payments,refunds']); | ||
$payment = Payment::getPaymentMollie($_REQUEST['id']); | ||
if ($payment) { | ||
$oBestellung = new Bestellung($payment->kBestellung, false); | ||
//\ws_mollie\Model\Payment::updateFromPayment($order, $oBestellung->kBestellung); | ||
if ($oBestellung->kBestellung && $oBestellung->cBestellNr !== $payment->cOrderNumber) { | ||
Shop::DB()->executeQueryPrepared("UPDATE xplugin_ws_mollie_payments SET cOrderNumber = :cBestellNr WHERE kID = :kID", [ | ||
':cBestellNr' => $oBestellung->cBestellNr, | ||
':kID' => $payment->kID, | ||
], 3); | ||
} | ||
} | ||
|
||
$logs = Shop::DB()->executeQueryPrepared("SELECT * FROM tzahlungslog WHERE cLogData LIKE :kBestellung OR cLogData LIKE :cBestellNr OR cLogData LIKE :MollieID ORDER BY dDatum DESC, cLog DESC", [ | ||
':kBestellung' => '%#' . ($payment->kBestellung ?: '##') . '%', | ||
':cBestellNr' => '%§' . ($payment->cOrderNumber ?: '§§') . '%', | ||
':MollieID' => '%$' . ($payment->kID ?: '$$') . '%', | ||
], 2); | ||
|
||
Shop::Smarty()->assign('payment', $payment) | ||
->assign('oBestellung', $oBestellung) | ||
->assign('order', $order) | ||
->assign('logs', $logs) | ||
->assign('ordersMsgs', $ordersMsgs); | ||
Shop::Smarty()->display($oPlugin->cAdminmenuPfad . '/tpl/order.tpl'); | ||
return; | ||
} | ||
} | ||
|
||
|
||
$payments = Shop::DB()->executeQueryPrepared("SELECT * FROM xplugin_ws_mollie_payments WHERE kBestellung IS NOT NULL AND cStatus != 'created' ORDER BY dCreatedAt DESC LIMIT 1000;", [], 2); | ||
foreach ($payments as $i => $payment) { | ||
$payments[$i]->oBestellung = new Bestellung($payment->kBestellung, false); | ||
} | ||
|
||
Shop::Smarty()->assign('payments', $payments) | ||
->assign('ordersMsgs', $ordersMsgs) | ||
->assign('admRoot', str_replace('http:', '', $oPlugin->cAdminmenuPfadURL)) | ||
->assign('hasAPIKey', trim(Helper::getSetting("api_key")) !== ''); | ||
|
||
Shop::Smarty()->display($oPlugin->cAdminmenuPfad . '/tpl/orders.tpl'); | ||
} catch (Exception $e) { | ||
echo "<div class='alert alert-danger'>" . | ||
"{$e->getMessage()}<br/>" . | ||
"<blockquote>{$e->getFile()}:{$e->getLine()}<br/><pre>{$e->getTraceAsString()}</pre></blockquote>" . | ||
"</div>"; | ||
Helper::logExc($e); | ||
} |
Oops, something went wrong.