Skip to content

Commit

Permalink
version 106
Browse files Browse the repository at this point in the history
  • Loading branch information
C. Proske committed May 15, 2020
1 parent 36ab644 commit 27fe37c
Show file tree
Hide file tree
Showing 42 changed files with 3,101 additions and 22 deletions.
44 changes: 23 additions & 21 deletions info.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="ISO-8859-1"?><jtlshop3plugin>
<Name>mollie</Name>
<Description>Zahlungsartplugin für mollie.com</Description>
<Description>Zahlungsartplugin für mollie.com</Description>
<Author>WebStollen</Author>
<URL>http://www.webstollen.de/</URL>
<URL>https://www.webstollen.de/</URL>
<XMLVersion>102</XMLVersion>
<PluginID>ws_mollie</PluginID>
<Shop4Version>405</Shop4Version>
Expand All @@ -26,6 +26,9 @@
<Version nr="105">
<CreateDate>2019-11-26</CreateDate>
</Version>
<Version nr="106">
<CreateDate>2019-12-18</CreateDate>
</Version>
<Hooks>
<Hook id="131">131_globalinclude.php</Hook>
<Hook id="144">144_notify.php</Hook>
Expand All @@ -49,12 +52,12 @@
<Name>Einstellungen</Name>
<Setting type="text" initialValue="" sort="10" conf="Y">
<Name>API Key:</Name>
<Description>Füge hier deinen mollie API Key ein</Description>
<Description>Füge hier deinen mollie API Key ein</Description>
<ValueName>api_key</ValueName>
</Setting>
<Setting type="text" initialValue="" sort="15" conf="Y">
<Name>Profile ID:</Name>
<Description>Füge hier deinen mollie Profil ID ein. Wird benötigt um mollie Components zu aktivieren</Description>
<Description>Füge hier deinen mollie Profil ID (pfl_) ein. Wird benötigt um mollie Components zu aktivieren</Description>
<ValueName>profileId</ValueName>
</Setting>
<Setting type="selectbox" initialValue="Y" sort="19" conf="Y">
Expand All @@ -68,18 +71,18 @@
</Setting>
<Setting type="selectbox" initialValue="S" sort="20" conf="Y">
<Name>Zahlungsart Daten syncronisiernen</Name>
<Description>Lädt Name / Bild für die jeweilige Sprache automatisch von mollie, und speichert diese&#xA; in der Datenbank&#xA; </Description>
<Description>Lädt Name / Bild für die jeweilige Sprache automatisch von mollie, und speichert diese&#xA; in der Datenbank&#xA; </Description>
<ValueName>paymentmethod_sync</ValueName>
<SelectboxOptions>
<Option value="N" sort="1"><![CDATA[Nein]]></Option>
<Option value="size1x" sort="2"><![CDATA[Ja, Bildgröße 1x]]></Option>
<Option value="size2x" sort="3"><![CDATA[Ja, Bildgröße 2x]]></Option>
<Option value="size1x" sort="2"><![CDATA[Ja, Bildgröße 1x]]></Option>
<Option value="size2x" sort="3"><![CDATA[Ja, Bildgröße 2x]]></Option>
<Option value="svg" sort="4"><![CDATA[Ja, Bild SVG]]></Option>
</SelectboxOptions>
</Setting>
<Setting type="selectbox" initialValue="N" sort="30" conf="Y">
<Name>Checkout Styles laden</Name>
<Description>Lädt Stylesheets für das Evo Template, um den Checkout zu verschönern.</Description>
<Description>Lädt Stylesheets für das Evo Template, um den Checkout zu verschönern.</Description>
<ValueName>load_styles</ValueName>
<SelectboxOptions>
<Option value="N" sort="1"><![CDATA[Nein]]></Option>
Expand All @@ -89,7 +92,7 @@
</Setting>
<Setting type="selectbox" initialValue="ord_tr" sort="100" conf="Y">
<Name>TransaktionsID des Zahlungseingangs:</Name>
<Description>Welche ID soll an die WAWI übetragen werden?</Description>
<Description>Welche ID soll an die WAWI übetragen werden?</Description>
<ValueName>wawiPaymentID</ValueName>
<SelectboxOptions>
<Option value="ord" sort="1"><![CDATA[Order ID]]></Option>
Expand All @@ -99,7 +102,7 @@
</Setting>
<Setting type="text" initialValue="" sort="110" conf="Y">
<Name>Workflow-Secret:</Name>
<Description>Schlüssel, um die WAWI Workflow-Requests zu authentifizieren.</Description>
<Description>Schlüssel, um die WAWI Workflow-Requests zu authentifizieren.</Description>
<ValueName>workflowSecret</ValueName>
</Setting>
</Settingslink>
Expand All @@ -114,7 +117,7 @@
<Variable>
<Name>error_canceled</Name>
<Description></Description>
<VariableLocalized iso="GER"><![CDATA[Die Zahlung wurde von Ihnen abgebrochen. Wählen Sie ggf. eine andere
<VariableLocalized iso="GER"><![CDATA[Die Zahlung wurde von Ihnen abgebrochen. Wählen Sie ggf. eine andere
Zahlart aus.
]]></VariableLocalized>
<VariableLocalized iso="ENG"><![CDATA[You canceled the payment. Please select a different payment method if
Expand All @@ -132,7 +135,7 @@
<Name>error_open</Name>
<Description></Description>
<VariableLocalized iso="GER"><![CDATA[Bei der Zahlung ist ein Fehler aufgetreten. Bitte versuchen Sie es erneut,
oder wählen Sie eine andere Zahlungsart.
oder whälen Sie eine andere Zahlungsart.
]]></VariableLocalized>
<VariableLocalized iso="ENG"><![CDATA[The payment process failed. Please try again or choose a different payment
method.
Expand All @@ -142,7 +145,7 @@
<Name>error_failed</Name>
<Description></Description>
<VariableLocalized iso="GER"><![CDATA[Bei der Zahlung ist ein Fehler aufgetreten. Bitte versuchen Sie es erneut,
oder wählen Sie eine andere Zahlungsart.
oder wählen Sie eine andere Zahlungsart.
]]></VariableLocalized>
<VariableLocalized iso="ENG"><![CDATA[The payment process failed. Please try again or choose a different payment
method.
Expand Down Expand Up @@ -175,16 +178,16 @@
<Variable>
<Name>cvchint_1</Name>
<Description></Description>
<VariableLocalized iso="GER"><![CDATA[So findet man die CVV Nummer]]></VariableLocalized>
<VariableLocalized iso="ENG"><![CDATA[How to find the CVV number]]></VariableLocalized>
<VariableLocalized iso="GER"><![CDATA[So findet man die CVV/CVC Nummer]]></VariableLocalized>
<VariableLocalized iso="ENG"><![CDATA[How to find the CVV/CVC number]]></VariableLocalized>
</Variable>
<Variable>
<Name>cvchint_2</Name>
<Description></Description>
<VariableLocalized iso="GER"><![CDATA[Die dreistellige CVV Nummer wird bei Visa und Mastercard auf der Rückseite,
<VariableLocalized iso="GER"><![CDATA[Die dreistellige CVV/CVC Nummer wird bei Visa und Mastercard auf der Rückseite,
bei American Express auf der Vorderseite der Karte abgebildet.
]]></VariableLocalized>
<VariableLocalized iso="ENG"><![CDATA[The three-digit CVV number is shown on the reverse for Visa and Mastercard,
<VariableLocalized iso="ENG"><![CDATA[The three-digit CVV/CVC number is shown on the reverse for Visa and Mastercard,
and on the front of the card for American Express.
]]></VariableLocalized>
</Variable>
Expand Down Expand Up @@ -214,7 +217,6 @@
<Name>mollie Kreditkarte</Name>
<PictureURL></PictureURL>
<Sort>3</Sort>
<AdditionalTemplateFile>tpl/mollieComponents.tpl</AdditionalTemplateFile>
<SendMail>0</SendMail>
<Provider>mollie.com</Provider>
<TSCode>CREDIT_CARD</TSCode>
Expand Down Expand Up @@ -286,9 +288,9 @@
<ClassName>JTLMollieBanktransfer</ClassName>
<TemplateFile>tpl/bestellabschluss.tpl</TemplateFile>
<MethodLanguage iso="GER">
<Name>SEPA Überweisung</Name>
<Name>SEPA Überweisung</Name>
<ChargeName>mollie</ChargeName>
<InfoText>Bezahlen Sie bequem mit SEPA Überweisung.</InfoText>
<InfoText>Bezahlen Sie bequem mit SEPA Überweisung.</InfoText>
</MethodLanguage>
</Method>
<Method>
Expand Down Expand Up @@ -553,4 +555,4 @@
</Method>
</PaymentMethod>
</Install>
</jtlshop3plugin>
</jtlshop3plugin>
2 changes: 1 addition & 1 deletion version/103/paymentmethod/JTLMollie.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function preparePaymentProcess($order)
}
$logData .= '$' . $oMolliePayment->id;
$this->doLog('Mollie Create Payment Redirect: ' . $oMolliePayment->getCheckoutUrl() . "<br/><pre>" . print_r($oMolliePayment, 1) . "</pre>", $logData, LOGLEVEL_DEBUG);
Payment::updateFromPayment($oMolliePayment, $order->kBestellung, md5($hash));
Payment::updateFromPayment($oMolliePayment, $order->kBestellung, md5(trim($hash, '_')));
Shop::Smarty()->assign('oMolliePayment', $oMolliePayment);
if (!$this->duringCheckout) {
Session::getInstance()->cleanUp();
Expand Down
64 changes: 64 additions & 0 deletions version/106/adminmenu/info.php
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);
}
154 changes: 154 additions & 0 deletions version/106/adminmenu/orders.php
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);
}
Loading

0 comments on commit 27fe37c

Please sign in to comment.