summaryrefslogtreecommitdiff
path: root/views/mods/mod_paypal/settings_edit.phtml
blob: 41bd9bd15795013e8c05d4733756a618dcf60800 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php

	/**
	 * Templatedatei für die Einstellungen des PayPal Moduls
	 */

	if (!defined('ABSPATH')) exit;

	$arView = $this->view['wpsg_mod_paypal'];
	$arStatus = (array)($arView['arStatus']??[]);
	$bSandbox = (bool)$arView['bSandbox'];

	$arStornoStatus = (array)$this->get_option('wpsg_mod_paypal_stornostate');
	$strDeveloperURL = 'https://developer.paypal.com/dashboard/applications/'.(($bSandbox)?'sandbox':'live');

	// Das gespeicherte Prüfergebnis gilt nur für den aktuell eingestellten Modus
	$bChecked = (isset($arStatus['time']) && (bool)($arStatus['sandbox']??false) === $bSandbox);

	$strBadge = '<span class="label label-%s" style="font-size:12px;">%s</span>';

	if ($bSandbox) {

		$strMode = sprintf($strBadge, 'warning', esc_html__('Sandbox (Testbetrieb)', 'wpsg'));

	} else {

		$strMode = sprintf($strBadge, 'success', esc_html__('Live', 'wpsg'));

	}

	if (!$arView['bCredentials']) {

		$strConnection = sprintf($strBadge, 'default', esc_html__('Keine Zugangsdaten hinterlegt', 'wpsg'));

	} else if (!$bChecked) {

		$strConnection = sprintf($strBadge, 'default', esc_html__('Noch nicht geprüft, bitte speichern', 'wpsg'));

	} else if ($arStatus['connected'] === true) {

		$strConnection = sprintf($strBadge, 'success', esc_html__('Verbindung erfolgreich', 'wpsg'));

	} else {

		$strConnection = sprintf($strBadge, 'danger', esc_html__('Anmeldung fehlgeschlagen', 'wpsg'));

		if ((string)($arStatus['message']??'') !== '') $strConnection .= '<br /><small class="text-danger">'.esc_html($arStatus['message']).'</small>';

	}

	if ($bChecked && $arStatus['connected'] === true) {

		$strWebHook = sprintf($strBadge, (($arStatus['webhook'] === true)?'success':'warning'), (($arStatus['webhook'] === true)?esc_html__('Angemeldet', 'wpsg'):esc_html__('Nicht angemeldet', 'wpsg')));

	} else {

		$strWebHook = sprintf($strBadge, 'default', esc_html__('Unbekannt', 'wpsg'));

	}

?>

<?php wpsg_drawForm_AdminboxStart(__('Verbindung zu PayPal', 'wpsg'), 'wpsg_mod_paypal_status'); ?>

	<?php echo wpsg_drawForm_Text(__('Umgebung', 'wpsg'), $strMode); ?>
	<?php echo wpsg_drawForm_Text(__('Zugangsdaten', 'wpsg'), $strConnection); ?>
	<?php echo wpsg_drawForm_Text(__('WebHook', 'wpsg'), $strWebHook); ?>

	<?php if ($bChecked) { ?>

		<?php echo wpsg_drawForm_Text(__('Zuletzt geprüft', 'wpsg'), esc_html(wpsg_formatTimestamp($arStatus['time']))); ?>

	<?php } ?>

	<?php if ($bChecked && $arStatus['connected'] === true && $arStatus['webhook'] !== true) { ?>

		<div class="wpsg_hinweis"><?php echo esc_html__('Der WebHook ist bei PayPal noch nicht angemeldet. Aktivieren Sie unten "WebHook beim Speichern anmelden" und speichern Sie die Einstellungen.', 'wpsg'); ?></div>

	<?php } ?>

<?php wpsg_drawForm_AdminboxEnd(); ?>

<?php wpsg_drawForm_AdminboxStart(__('Zahlungsart im Shop', 'wpsg'), 'wpsg_mod_paypal_payment'); ?>

	<?php echo wpsg_drawForm_Input('wpsg_mod_paypal_bezeichnung', __('Bezeichnung', 'wpsg'), $this->get_option('wpsg_mod_paypal_bezeichnung'), ['help' => 'wpsg_shippay_name']); ?>
	<?php echo wpsg_drawForm_Checkbox('wpsg_mod_paypal_aktiv', __('Aktiv', 'wpsg'), $this->get_option('wpsg_mod_paypal_aktiv'), ['help' => 'wpsg_shippay_activ']); ?>
	<?php echo wpsg_drawForm_Textarea('wpsg_mod_paypal_hint', __('Hinweistext', 'wpsg'), $this->get_option('wpsg_mod_paypal_hint'), ['help' => 'wpsg_shippay_hint']); ?>
	<?php echo wpsg_drawForm_Input('wpsg_mod_paypal_gebuehr', __('Gebühr/Rabatt', 'wpsg'), wpsg_ff($this->get_option('wpsg_mod_paypal_gebuehr'), true), ['help' => 'wpsg_shippay_gebuehr', 'unit' => $this->get_option('wpsg_currency').' / %']); ?>
	<?php echo wpsg_drawForm_Select('wpsg_mod_paypal_mwst', __('Mehrwertsteuersatz', 'wpsg'), wpsg_tax_groups(), $this->get_option('wpsg_mod_paypal_mwst'), ['help' => 'wpsg_shippay_mwst']); ?>

<?php wpsg_drawForm_AdminboxEnd(); ?>

<?php wpsg_drawForm_AdminboxStart(__('Zugangsdaten', 'wpsg'), 'wpsg_mod_paypal_credentials'); ?>

	<?php echo wpsg_drawForm_Checkbox('wpsg_mod_paypal_sandbox', __('Sandbox Modus', 'wpsg'), $this->get_option('wpsg_mod_paypal_sandbox'), ['help' => 'wpsg_mod_paypal_sandbox', 'hint' => esc_html__('Im Sandbox Modus werden keine echten Zahlungen ausgeführt. Sandbox und Live haben eigene Zugangsdaten.', 'wpsg')]); ?>
	<?php echo wpsg_drawForm_Input('wpsg_mod_paypal_clientid', __('Client ID', 'wpsg'), $this->get_option('wpsg_mod_paypal_clientid'), ['help' => 'wpsg_mod_paypal_clientid']); ?>
	<?php echo wpsg_drawForm_Input('wpsg_mod_paypal_secret', __('Secret', 'wpsg'), $this->get_option('wpsg_mod_paypal_secret'), ['help' => 'wpsg_mod_paypal_secret', 'hint' => wpsg_translate(__('Client ID und Secret erhalten Sie im <a target="_blank" href="#1#">PayPal Developer Dashboard</a> unter "Apps & Credentials".', 'wpsg'), esc_url($strDeveloperURL))]); ?>

<?php wpsg_drawForm_AdminboxEnd(); ?>

<?php wpsg_drawForm_AdminboxStart(__('WebHook', 'wpsg'), 'wpsg_mod_paypal_webhook'); ?>

	<?php echo wpsg_drawForm_Input('', __('WebHook URL', 'wpsg'), $arView['webhookURL'], ['readonly' => true, 'help' => 'wpsg_mod_paypal_webhook_url', 'hint' => esc_html__('Über den WebHook meldet PayPal den Zahlungseingang an den Shop. Die URL muss per HTTPS von außen erreichbar sein.', 'wpsg')]); ?>
	<?php echo wpsg_drawForm_Checkbox('wpsg_mod_paypal_createwebhook', __('WebHook beim Speichern anmelden', 'wpsg'), 0, ['help' => 'wpsg_mod_paypal_createwebhook']); ?>

<?php wpsg_drawForm_AdminboxEnd(); ?>

<?php wpsg_drawForm_AdminboxStart(__('Zahlungsablauf', 'wpsg'), 'wpsg_mod_paypal_process'); ?>

	<?php echo wpsg_drawForm_Input('wpsg_mod_paypal_subject', __('Betreff der Überweisung', 'wpsg'), $this->get_option('wpsg_mod_paypal_subject'), ['help' => 'wpsg_mod_paypal_subject']); ?>
	<?php echo wpsg_drawForm_Input('wpsg_mod_paypal_invoicenumber', __('Formatierung InvoiceNumber', 'wpsg'), $this->get_option('wpsg_mod_paypal_invoicenumber'), ['help' => 'wpsg_mod_paypal_invoicenumber']); ?>
	<?php echo wpsg_drawForm_Input('wpsg_mod_paypal_currency', __('Währungscode (Standard: EUR)', 'wpsg'), $this->get_option('wpsg_mod_paypal_currency'), ['help' => 'wpsg_mod_paypal_currency']); ?>
	<?php echo wpsg_drawForm_Select('wpsg_mod_paypal_language', __('Sprache im PayPal Interface', 'wpsg'), ['DE' => __('Deutsch', 'wpsg'), 'US' => __('Englisch', 'wpsg'), 'FR' => __('Französisch', 'wpsg')], $this->get_option('wpsg_mod_paypal_language'), ['help' => 'wpsg_mod_paypal_language']); ?>
	<?php echo wpsg_drawForm_Checkbox('wpsg_mod_paypal_autostart', __('Zahlung sofort starten', 'wpsg'), $this->get_option('wpsg_mod_paypal_autostart'), ['help' => 'wpsg_shippay_paystart']); ?>
	<?php echo wpsg_drawForm_Select('wpsg_page_mod_paypal_success', __('Erfolgsseite', 'wpsg'), $this->view['pages'], $this->get_option('wpsg_page_mod_paypal_success'), ['help' => 'wpsg_page_mod_paypal_success']); ?>
	<?php echo wpsg_drawForm_Select('wpsg_page_mod_paypal_error', __('Fehlerseite', 'wpsg'), $this->view['pages'], $this->get_option('wpsg_page_mod_paypal_error'), ['help' => 'wpsg_page_mod_paypal_error']); ?>

<?php wpsg_drawForm_AdminboxEnd(); ?>

<?php wpsg_drawForm_AdminboxStart(__('Stornierung bei Statuswechsel', 'wpsg'), 'wpsg_mod_paypal_storno'); ?>

	<p class="text-muted"><?php echo esc_html__('Wechselt eine mit PayPal bezahlte Bestellung in einen der markierten Status, wird der Betrag automatisch über PayPal erstattet.', 'wpsg'); ?></p>

	<?php foreach ($this->arStatus as $status_id => $status_label) { ?>

		<?php echo wpsg_drawForm_Checkbox('wpsg_mod_paypal_stornostate['.$status_id.']', __($status_label, 'wpsg'), ($arStornoStatus[$status_id]??'0')); ?>

	<?php } ?>

<?php wpsg_drawForm_AdminboxEnd(); ?>