Newer
Older
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
<?php
/**
* This file contains QUI\ERP\Payments\Amazon\Provider
*/
namespace QUI\ERP\Payments\Amazon;
use QUI;
use QUI\ERP\Accounting\Payments\Api\AbstractPaymentProvider;
/**
* Class Provider
*
* PaymentProvider class for Amazon Pay
*/
class Provider extends AbstractPaymentProvider
{
/**
* @return array
*/
public function getPaymentTypes()
{
return [
Payment::class
];
}
/**
* Get API setting
*
* @param string $setting - Setting name
* @return string|number|false
*/
public static function getApiSetting($setting)
{
try {
$Conf = QUI::getPackage('quiqqer/payment-amazon')->getConfig();
} catch (\Exception $Exception) {
QUI\System\Log::writeException($Exception);
return false;
}
return $Conf->get('api', $setting);
}
/**
* Get Payment setting
*
* @param string $setting - Setting name
* @return string|number|false
*/
public static function getPaymentSetting($setting)
{
try {
$Conf = QUI::getPackage('quiqqer/payment-amazon')->getConfig();
} catch (\Exception $Exception) {
QUI\System\Log::writeException($Exception);
return false;
}
return $Conf->get('payment', $setting);
}
/**
* Get Widgets setting
*
* @param string $setting - Setting name
* @return string|number|false
*/
public static function getWidgetsSetting($setting)
{
try {
$Conf = QUI::getPackage('quiqqer/payment-amazon')->getConfig();
} catch (\Exception $Exception) {
QUI\System\Log::writeException($Exception);
return false;
}
return $Conf->get('widgets', $setting);
}

Patrick Müller
committed
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
/**
* Check if the Amazon Pay API settings are correct
*
* @return bool
* @throws QUI\Exception
*/
public static function isApiSetUp()
{
$Conf = QUI::getPackage('quiqqer/payment-amazon')->getConfig();
$apiSettings = $Conf->getSection('api');
foreach ($apiSettings as $k => $v) {
switch ($k) {
case 'sandbox':
continue 2;
break;
}
if (empty($v)) {
QUI\System\Log::addError(
'Your Amazon Pay API credentials seem to be (partially) missing.'
. ' Amazon Pay CAN NOT be used at the moment. Please enter all your'
. ' API credentials. See https://dev.quiqqer.com/quiqqer/payment-amazon/wikis/api-configuration'
. ' for further instructions.'
);
return false;
}
}
return true;
}