Commit 662cd782 authored by Andy J's avatar Andy J

ecs

parent cab54819
This diff is collapsed.
<?php
/**
* @copyright (c) JTL-Software-GmbH
* @license http://jtl-url.de/jtlshoplicense
*/
$results = null;
$type = isset($_REQUEST['validate']) ? $_REQUEST['validate'] : null;
$security = isset($_REQUEST['security']) ? $_REQUEST['security'] : null;
$module = "kPlugin_{$oPlugin->kPlugin}_paypal";
$method = "/" . str_replace('frontend', 'paymentmethod', $oPlugin->cFrontendPfad);
if ($type) {
switch ($type) {
case 'basic':
$module = "{$module}{$type}";
require_once $method . 'class/PayPalBasic.class.php';
$payPal = new PayPalBasic($oPlugin->oPluginZahlungsmethodeAssoc_arr[$module]->cModulId);
$results = $payPal->test();
break;
case 'express':
$module = "{$module}{$type}";
require_once $method . 'class/PayPalExpress.class.php';
$payPal = new PayPalExpress($oPlugin->oPluginZahlungsmethodeAssoc_arr[$module]->cModulId);
$results = $payPal->test();
break;
case 'plus':
$module = "{$module}{$type}";
require_once $method . 'class/PayPalPlus.class.php';
$payPal = new PayPalPlus($oPlugin->oPluginZahlungsmethodeAssoc_arr[$module]->cModulId);
$results = ['status' => $payPal->isConfigured(true) ? 'success' : 'error'];
break;
case 'finance':
$module = "{$module}{$type}";
require_once $method . 'class/PayPalFinance.class.php';
$payPal = new PayPalFinance($oPlugin->oPluginZahlungsmethodeAssoc_arr[$module]->cModulId);
$results = ['status' => $payPal->isConfigured(true) ? 'success' : 'error'];
break;
}
if ($payPal) {
$results['modus'] = $payPal->getModus();
$results['linked'] = PayPalHelper::isLinked($payPal->getPaymentId());
}
$results['type'] = $type;
die(json_encode($results));
} elseif (isset($security)) {
require_once dirname(__FILE__) . '/tlscheck.php';
$smarty->assign('tlsResponse', paypal_tlstest());
} else {
require_once $method . 'class/PayPal.helper.class.php';
PayPalHelper::copyCredentials($oPlugin->oPluginEinstellungAssoc_arr, $module, 'basic', 'express',
['api_live_sandbox', 'api_user', 'api_pass', 'api_signatur', 'api_sandbox_user', 'api_sandbox_pass', 'api_sandbox_signatur']
);
PayPalHelper::copyCredentials($oPlugin->oPluginEinstellungAssoc_arr, $module, 'plus', 'finance',
['api_live_sandbox', 'api_live_client_id', 'api_live_secret', 'api_sandbox_client_id', 'api_sandbox_secret']
);
}
$smarty->assign('results', $results)
->assign('post_url', Shop::getURL(true) . '/' . PFAD_ADMIN . 'plugin.php?kPlugin=' . $oPlugin->kPlugin . '')
->display($oPlugin->cAdminmenuPfad . 'templates/infos.tpl');
<?php
/**
* @copyright (c) JTL-Software-GmbH
* @license http://jtl-url.de/jtlshoplicense
*/
require_once PFAD_ROOT . PFAD_ADMIN . PFAD_INCLUDES . 'blaetternavi.php';
require_once str_replace('frontend', 'paymentmethod', $oPlugin->cFrontendPfad) . '/class/PayPalFinance.class.php';
$message = null;
$ordersPerPage = 10;
$ids = array_map(function($method) {
return (int)$method->kZahlungsart;
}, $oPlugin->oPluginZahlungsmethodeAssoc_arr);
$sqlFilter = sprintf('IN(%s)', implode(', ', array_values($ids)));
$res = Shop::DB()->query("SELECT COUNT(*) AS cnt FROM tbestellung WHERE kZahlungsart {$sqlFilter}", 1);
$config = baueBlaetterNaviGetterSetter(1, $ordersPerPage);
$pagination = baueBlaetterNavi($config->nAktuelleSeite1, $res->cnt, $ordersPerPage);
$orderKeys = Shop::DB()->query(
"SELECT kBestellung as id FROM tbestellung WHERE kZahlungsart {$sqlFilter} ORDER BY dErstellt DESC {$config->cSQL1}", 2);
$receivedPaymentSql = <<<SQL
SELECT
SUM(fBetrag) AS fBetrag,
SUM(fZahlungsgebuehr) AS fZahlungsgebuehr,
cISO, cZahler, dZeit, cHinweis, cAbgeholt
FROM
tzahlungseingang
WHERE
kBestellung = :id
GROUP BY
kBestellung
SQL;
$orders = [];
$payments = [];
foreach ($orderKeys as $key) {
$order = new Bestellung($key->id);
$order->fuelleBestellung(1, 0, false);
if ((int)$order->kBestellung === 0)
continue;
$orders[$key->id] = $order;
$payment = Shop::DB()->executeQueryPrepared(
$receivedPaymentSql, ['id' => $key->id], 1);
if ($payment) {
$payments[$key->id] = $payment;
}
}
$smarty->assign('orders', $orders)
->assign('payments', $payments)
->assign('message', $message)
->assign('pagination', $pagination)
->assign('hash', '#plugin-tab-' . ($_adminMenu ? $_adminMenu->kPluginAdminMenu : '0'))
->display($oPlugin->cAdminmenuPfad . 'templates/orders.tpl');
\ No newline at end of file
<?php
/**
* @copyright (c) JTL-Software-GmbH
* @license http://jtl-url.de/jtlshoplicense
*/
$table = 'xplugin_jtl_paypal_additional_payment';
if (isset($_POST['save'])) {
Shop::DB()->query("truncate {$table}", 4);
$items = array_slice($_POST['payment'], 0, 5);
foreach ($items as $i => $id) {
$item = [
'paymentId' => $id,
'sort' => $i,
];
Shop::DB()->insert($table, (object) $item);
}
}
$payments = Shop::DB()->query("SELECT * FROM tzahlungsart WHERE nActive = 1 ORDER BY cAnbieter, cName, nSort, kZahlungsart", 2);
$selectedPayments = Shop::DB()->query("SELECT * FROM {$table}", 2);
$selectedPaymentKeys = array_map(function ($o) {
return intval($o->paymentId);
}, $selectedPayments);
$payments = array_map(function ($o) use ($selectedPayments) {
$o->sort = 999;
$o->checked = false;
foreach ($selectedPayments as $p) {
if ($p->paymentId == $o->kZahlungsart) {
$o->sort = $p->sort;
$o->checked = true;
break;
}
}
return $o;
}, $payments);
usort($payments, function ($a, $b) {
if ($a->sort > $b->sort) {
return 1;
} elseif ($a->sort < $b->sort) {
return -1;
}
return 0;
});
$pspType = isset($oPlugin->oPluginEinstellungAssoc_arr['jtl_paypal_psp_type']) ?
(int)$oPlugin->oPluginEinstellungAssoc_arr['jtl_paypal_psp_type'] : 0;
$smarty
->assign('pspType', $pspType)
->assign('payments', $payments)
->assign('saved', isset($_POST['save']))
->assign('selectedPayments', $selectedPayments)
->assign('selectedPaymentKeys', $selectedPaymentKeys)
->assign('postUrl', Shop::getURL(true) . '/' . PFAD_ADMIN . 'plugin.php?kPlugin=' . $oPlugin->kPlugin . '#payment')
->display($oPlugin->cAdminmenuPfad . 'templates/payment.tpl');
<div class="container-fluid">
{if isset($errorMessage) && $errorMessage|@count_characters > 0}
<div class="alert alert-danger">
<i class="fa fa-exclamation-triangle"></i> {$errorMessage}
</div>
{/if}
<h2>Konfiguration</h2>
<table class="table" id="paypal-test-credentials">
<thead>
<th>Zahlungsart</th>
<th class="text-center">Modus</th>
<th class="text-center">Zugangsdaten</th>
<th class="text-center">Verknüpft</th>
</thead>
<tbody>
<tr class="basic">
<td>Basic</td>
<td class="payment-modus text-center"><i class="fa fa-spinner fa-spin"></i></td>
<td class="payment-state text-center">
<i class="fa fa-spinner fa-spin"></i>
</td>
<td class="payment-linked text-center"><i class="fa fa-spinner fa-spin"></i></td>
</tr>
<tr class="express">
<td>Express</td>
<td class="payment-modus text-center"><i class="fa fa-spinner fa-spin"></i></td>
<td class="payment-state text-center">
<i class="fa fa-spinner fa-spin"></i>
</td>
<td class="payment-linked text-center"><i class="fa fa-spinner fa-spin"></i></td>
</tr>
<tr class="plus">
<td>PLUS</td>
<td class="payment-modus text-center"><i class="fa fa-spinner fa-spin"></i></td>
<td class="payment-state text-center"><i class="fa fa-spinner fa-spin"></i></td>
<td class="payment-linked text-center"><i class="fa fa-spinner fa-spin"></i></td>
</tr>
<tr class="finance">
<td>Ratenzahlung</td>
<td class="payment-modus text-center"><i class="fa fa-spinner fa-spin"></i></td>
<td class="payment-state text-center"><i class="fa fa-spinner fa-spin"></i></td>
<td class="payment-linked text-center"><i class="fa fa-spinner fa-spin"></i></td>
</tr>
</tbody>
</table>
<h2>TLS 1.2 Unterst&uuml;tzung pr&uuml;fen</h2>
<p>
Pr&uuml;fen Sie, ob Ihr System eine mit TLS 1.2 verschl&uuml;sselte Verbindung &uuml;ber HTTP/1.1 zu PayPal aufbauen kann.
</p>
<form id="paypal-test-credentials" method="post" action="{$post_url}">
<div class="btn-group" role="group">
<button class="btn btn-default" name="security" value="basic">Jetzt pr&uuml;fen</button>
<a href="https://www.paypal-knowledge.com/infocenter/index?page=content&id=FAQ1913&expand=true&locale=de_DE" target="_blank" class="btn btn-default">Weitere Informationen</a>
</div>
</form>
{if isset($tlsResponse)}
<br />
<div id="paypal2-security">
{if empty($tlsResponse)}
<div class="alert alert-success" role="alert"><i class="fa fa-check"></i> Verbindung wurde efolgreich hergestellt.</div>
{else}
<div class="alert alert-danger" role="alert">
<h4> Fehlerhaft - bitte setzen Sie sich mit Ihrem Hoster in Verbindung.</h4>
<p>{$tlsResponse}</p>
</div>
{/if}
</div>
{/if}
<br />
<p>
<a href="http://jtl-url.de/paypaldocs" class="btn btn-primary" target="_blank"><i class="fa fa-file-pdf-o"></i> Integrationshandbuch zu diesem Plugin lesen</a>
</p>
</div>
<script type="text/javascript">
var kPlugin = '{$smarty.get.kPlugin}';
var payments = ['basic', 'express', 'plus', 'finance'];
$(payments).each(function(i, item) {
check_payment(item);
});
function check_payment(type) {
$.ajax({
dataType: "json",
url: '/admin/plugin.php?kPlugin='+kPlugin+'&validate=' + type,
success: function(data) {
var label_type = data['status'] == 'success' ? 'Gültig' : 'Ungültig';
var class_state = data['status'] == 'success' ? 'success' : 'danger';
var state = '<small class="label label-'+class_state+'">'+label_type+'</small>';
var label_linked = data['linked'] ? 'Ja' : 'Nein';
var class_linked = data['linked'] ? 'success' : 'danger';
var linked = '<small class="label label-'+class_linked+'">'+label_linked+'</small>';
var modus = '<small class="label label-info">'+data['modus'].toUpperCase()+'</small>';
$('tr.' + data['type'] + ' td.payment-state').html(state);
$('tr.' + data['type'] + ' td.payment-linked').html(linked);
$('tr.' + data['type'] + ' td.payment-modus').html(modus);
}
});
}
</script>
\ No newline at end of file
{config_load file="$lang.conf" section="bestellungen"}
<div class="container-full">
{if $message}
<div class="alert alert-{key($message)}" role="alert">
{reset($message)}
</div>
{/if}
{if $orders|@count > 0 && $orders}
{include file='pagination.tpl' cSite='1' cUrl='plugin.php' cParams='&kPlugin='|cat:$oPlugin->kPlugin oBlaetterNavi=$pagination hash=$hash}
<form method="post" action="{$post_url}">
{$jtl_token}
<div class="panel panel-default">
<table class="list table table-hover">
<thead>
<tr>
<th class="tleft">{#orderNumber#}</th>
<th class="tleft">{#orderCostumer#}</th>
<th class="tleft">{#orderPaymentName#}</th>
<th class="text-center">{#orderSum#}</th>
<th class="text-center">Status</th>
<th class="text-right"></th>
</tr>
</thead>
<tbody>
{foreach $orders as $order}
{$payment = null}
{if isset($payments[$order->kBestellung])}
{$payment = $payments[$order->kBestellung]}
{/if}
<tr class="text-vcenter">
<td>
<div>{$order->cBestellNr}</div>
<small class="text-muted" title="{$order->dErstelldatum_de}" data-toggle="tooltip" data-placement="left"><i class="fa fa-clock-o" aria-hidden="true"></i> {$order->dErstelldatum_de|date_format:"%d.%m.%Y"}</small>
</td>
<td>
{if isset($order->oKunde->cVorname) || isset($order->oKunde->cNachname) || isset($order->oKunde->cFirma)}
<div>
{$order->oKunde->cVorname} {$order->oKunde->cNachname}
{if isset($order->oKunde->cFirma) && $order->oKunde->cFirma|strlen > 0} ({$order->oKunde->cFirma}){/if}
</div>
<small class="text-muted"><i class="fa fa-user" aria-hidden="true"></i> {$order->oKunde->cMail}</small>
{else}
<i class="fa fa-user-secret" aria-hidden="true"></i> {#noAccount#}
{/if}
</td>
<td>
<div>{$order->cZahlungsartName}</div>
{if $payment}
<small class="text-muted"><i class="fa fa-paypal text-info" aria-hidden="true"></i> {$payment->cHinweis}</small>
{/if}
</td>
<td class="text-center">{$order->WarensummeLocalized[0]}</td>
<td class="text-center">
<small class="{if $order->cStatus < 0}label label-danger{elseif $order->cStatus > 0 && $order->cStatus < 3}text-muted{else}label label-success{/if}">{$order->Status}</small>
</td>
<th class="text-right no-flow">
{if $payment}
<div class="btn-group btn-group-xs" role="group" aria-label="Extra-small button group">
<a href="https://www.sandbox.paypal.com/activity/payment/{$payment->cHinweis}" target="_blank" class="btn btn-default">Sandbox</a>
<a href="https://www.paypal.com/activity/payment/{$payment->cHinweis}" target="_blank" class="btn btn-default active">Live</a>
</div>
{/if}
</th>
</tr>
{/foreach}
</tbody>
</table>
</div>
</form>
{else}
<div class="alert alert-info"><i class="fa fa-info-circle"></i> Keine Daten vorhanden.</div>
{/if}
</div>
\ No newline at end of file
{config_load file="$lang.conf" section='zahlungsarten'}
{if $pspType > 0}
<div class="alert alert-warning">
<i class="fa fa-info-circle"></i> Nur in Variante <a href="#" id="goto_psp_type">Integriert</a> konfigurierbar.
</div>
{else}
{if isset($saved) && $saved}
<div class="alert alert-success">
<i class="fa fa-info-circle"></i> Einstellungen wurden erfolgreich gespeichert
</div>
{else}
<div class="alert alert-info">
<i class="fa fa-info-circle"></i> W&auml;hlen Sie bis zu 5 zus&auml;tzliche Zahlungsarten aus, die in der Payment Wall unter den Standard-Bezahlmethoden von PayPal PLUS angeboten werden.
</div>
{/if}
<div class="panel panel-default">
<div class="panel-heading" style="border-bottom:0">
<h3 class="panel-title">Verf&uuml;gbare Zahlungsarten</h3>
</div>
<form method="post" action="{$postUrl}">
<input type="hidden" name="save" value="1">
<div class="table-responsive">
<table class="list table" id="payments">
<tbody>
{foreach name=p from=$payments item=payment}
<tr class="text-vcenter">
<td class="text-center" width="40"><input type="checkbox" name="payment[]" value="{$payment->kZahlungsart}" {if $payment->checked}checked="checked"{/if} /></td>
<td class="ui-drag-visible">
<h4>{$payment->cName}{if $payment->cAnbieter|@count_characters > 0} <small class="text-muted">{$payment->cAnbieter}</small>{/if}</h4>
</td>
<td class="text-center" width="40">
<a href="zahlungsarten.php?kZahlungsart={$payment->kZahlungsart}&token={$smarty.session.jtl_token}" class="btn btn-default btn-sm" title="Anzeigen"><i class="fa fa-bars"></i></a>
</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
<div class="panel-footer">
<div class="save btn-group">
<button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> Speichern</button>
</div>
</div>
</form>
</div>
{/if}
<script type="text/javascript">
{literal}
$(function() {
$('#goto_psp_type').click(function() {
$('a[data-toggle=tab].tab-link-settings-2').tab('show');
$('label[for="jtl_paypal_psp_type"]')
.closest('.input-group')
.addClass('highlight');
});
$("#payments tbody").sortable({
placeholder: "ui-state-highlight"
});
$("#payments tbody").disableSelection();
$('#payments input[name="payment[]"]').tooltip({
trigger: 'manual',
placement: 'right',
title: 'Maximal 5 weitere Zahlungsarten'
});
$('#payments input[name="payment[]"]').change(function(e) {
var count = $('input[name="payment[]"]:checked').length;
if (count > 5) {
$(e.target).attr('checked', false);
$(e.target).tooltip('show');
}
});
$('#payments input[name="payment[]"]').focusout(function(e) {
$(e.target).tooltip('hide');
});
});
{/literal}
</script>
\ No newline at end of file
{if isset($reset) && $reset}
<div class="alert alert-success">
<i class="fa fa-info-circle"></i> Webhooks wurden wiederhergestellt
</div>
{/if}
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Webhooks</h3>
</div>
{if $fetched}
<form method="post" action="{$postUrl}">
<input type="hidden" name="reset" value="1">
<div class="panel-body">
{if !empty($webhooks) && $webhooks|@count > 0}
<div class="table-responsive">
<table class="list table">
<thead>
<th>Zahlungsart</th>
<th>Url</th>
<th></th>
</thead>
<tbody>
{foreach $webhooks as $webhook}
<tr>
<td class="v-center">{$webhook->name}</td>
<td class="v-center">{$webhook->url}</td>
<td class="v-center text-right">
{if $webhook->configured}
{if $webhook->hook}
<span class="label label-success">installiert</span>
{else}
<span class="label label-danger">nicht installiert</span>
{/if}
{else}
<span class="label label-warning">nicht konfiguriert</span>
{/if}
</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
{else}
<div class="alert alert-danger">
<i class="fa fa-exclamation-triangle"></i> Zur Zeit sind keine Webhooks installiert.
</div>
{/if}
</div>
<div class="panel-footer">
<div class="save btn-group">
<button type="submit" class="btn btn-primary">{if !empty($webhooks)}Aktualisieren{else}Installieren{/if}</button>
</div>
</div>
</form>
{else}
<div class="panel-body">
<a href="{$fetchUrl}" class="btn btn-primary">Webhooks anzeigen</a>
</div>
{/if}
</div>
\ No newline at end of file
<?php
if (!function_exists('paypal_tlstest')) {
function paypal_tlstest()
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://tlstest.paypal.com/");
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Some environments may be capable of TLS 1.2 but it is not in their
// list of defaults so need the SSL version option to be set.
curl_setopt($ch, CURLOPT_SSLVERSION, 1);
curl_exec($ch);
$res = curl_error($ch);
curl_close($ch);
return $res;
}
}
if (PHP_SAPI == 'cli') {
$error = paypal_tlstest();
if (!$error) {
echo "OK";
} else {
echo $error . PHP_EOL . PHP_EOL;
echo "------------------------------" . PHP_EOL;
echo json_encode(curl_version(), JSON_PRETTY_PRINT);
}
echo PHP_EOL;
}
<?php
/**
* @copyright (c) JTL-Software-GmbH
* @license http://jtl-url.de/jtlshoplicense
*/
require_once str_replace('frontend', 'paymentmethod', $oPlugin->cFrontendPfad) . 'class/PayPal.helper.class.php';
require_once str_replace('frontend', 'paymentmethod', $oPlugin->cFrontendPfad) . 'class/PayPalPlus.class.php';
require_once str_replace('frontend', 'paymentmethod', $oPlugin->cFrontendPfad) . 'class/PayPalFinance.class.php';
$fetched = false;
$webhooks = array();
$restPaymentMethods = array(new PayPalPlus(), new PayPalFinance());
if (isset($_POST['reset'])) {
foreach ($restPaymentMethods as $paymentMethod) {
PayPalHelper::deleteWebhook($paymentMethod);
PayPalHelper::setWebhook($paymentMethod);
}
}
if (isset($_GET['fetch']) && $_GET['fetch'] == 'webhooks') {
$fetched = true;
foreach ($restPaymentMethods as $paymentMethod) {
$webhooks[] = (object)[
'name' => $paymentMethod->name,
'configured' => $paymentMethod->isConfigured(false),
'url' => PayPalHelper::getWebhookUrl($paymentMethod),
'hook' => PayPalHelper::getWebhook($paymentMethod),
];
}
}
$postUrl = Shop::getURL(true) . '/' . PFAD_ADMIN .
'plugin.php?kPlugin=' . $oPlugin->kPlugin . '#plugin-tab-' . ($_adminMenu ? $_adminMenu->kPluginAdminMenu : '0');
$fetchUrl = Shop::getURL(true) . '/' . PFAD_ADMIN .
'plugin.php?kPlugin=' . $oPlugin->kPlugin . '&fetch=webhooks' . '#plugin-tab-' . ($_adminMenu ? $_adminMenu->kPluginAdminMenu : '0');
$smarty->assign('reset', isset($_POST['reset']))
->assign('postUrl', $postUrl)
->assign('fetchUrl', $fetchUrl)
->assign('webhooks', $webhooks)
->assign('fetched', $fetched)
->display($oPlugin->cAdminmenuPfad . 'templates/webhooks.tpl');
<Files notify.php>
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
Order Allow,Deny
Allow from all
</IfModule>
</Files>
<Files presentment.php>
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
Order Allow,Deny
Allow from all
</IfModule>
</Files>
\ No newline at end of file