|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* PHP version 5.4 and 8 |
|
5
|
|
|
* |
|
6
|
|
|
* @category Payments |
|
7
|
|
|
* @package Payever\Payments |
|
8
|
|
|
* @author payever GmbH <[email protected]> |
|
9
|
|
|
* @copyright 2017-2021 payever GmbH |
|
10
|
|
|
* @license MIT <https://opensource.org/licenses/MIT> |
|
11
|
|
|
* @link https://docs.payever.org/shopsystems/api/getting-started |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Payever\ExternalIntegration\Payments; |
|
15
|
|
|
|
|
16
|
|
|
use Payever\ExternalIntegration\Core\Http\RequestBuilder; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Class represents Third Party Plugins Connector |
|
20
|
|
|
* @SuppressWarnings(PHPMD.CouplingBetweenObjects) |
|
21
|
|
|
* @SuppressWarnings(PHPMD.TooManyPublicMethods) |
|
22
|
|
|
*/ |
|
23
|
|
|
class ThirdPartyPluginsApiClient extends PaymentsApiClient |
|
24
|
|
|
{ |
|
25
|
|
|
const URL_SANDBOX = 'https://plugins-third-party.staging.devpayever.com/'; |
|
26
|
|
|
const URL_LIVE = 'https://plugins-third-party.payever.org/'; |
|
27
|
|
|
|
|
28
|
|
|
const SUB_URL_CREATE_PAYMENT = 'api/integration/%s/action/get-token'; |
|
29
|
|
|
const SUB_URL_CREATE_PAYMENT_SUBMIT = 'api/integration/%s/action/submit-payment'; |
|
30
|
|
|
const SUB_URL_RETRIEVE_PAYMENT = 'api/integration/%s/action/get-payment'; |
|
31
|
|
|
const SUB_URL_REFUND_PAYMENT = 'api/integration/%s/action/refund-payment'; |
|
32
|
|
|
const SUB_URL_SHIPPING_GOODS_PAYMENT = 'api/integration/%s/action/shipping-goods-payment'; |
|
33
|
|
|
const SUB_URL_CANCEL_PAYMENT = 'api/integration/%s/action/cancel-payment'; |
|
34
|
|
|
const SUB_URL_LIST_PAYMENT_OPTIONS = 'api/integration/%s/action/get-payment-options'; |
|
35
|
|
|
const SUB_URL_LIST_PAYMENT_OPTIONS_VARIANTS = 'api/integration/%s/action/get-payment-options-variants'; |
|
36
|
|
|
const SUB_URL_TRANSACTION = 'api/integration/%s/action/get-transaction'; |
|
37
|
|
|
const SUB_URL_TOKEN_VALIDATION = 'api/business/%s/token/validation'; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Token validation |
|
41
|
|
|
* |
|
42
|
|
|
* @return boolean |
|
43
|
|
|
*/ |
|
44
|
|
|
public function validateToken($businessUuid, $accessToken) |
|
45
|
|
|
{ |
|
46
|
|
|
$this->configuration->assertLoaded(); |
|
47
|
|
|
|
|
48
|
|
|
try { |
|
49
|
|
|
$request = RequestBuilder::post($this->getValidateTokenURL($businessUuid)) |
|
50
|
|
|
->addRawHeader( |
|
51
|
|
|
sprintf("Authorization: Bearer %s", $accessToken) |
|
52
|
|
|
) |
|
53
|
|
|
->build(); |
|
54
|
|
|
|
|
55
|
|
|
$this->executeRequest($request); |
|
56
|
|
|
|
|
57
|
|
|
return true; |
|
58
|
|
|
} catch (\Exception $exception) { |
|
59
|
|
|
return false; |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Returns URL to the token validation |
|
65
|
|
|
* |
|
66
|
|
|
* @param string $businessUuid |
|
67
|
|
|
* |
|
68
|
|
|
* @return string |
|
69
|
|
|
*/ |
|
70
|
|
|
protected function getValidateTokenURL($businessUuid) |
|
71
|
|
|
{ |
|
72
|
|
|
return $this->getBaseEntrypoint(true) . sprintf(self::SUB_URL_TOKEN_VALIDATION, $businessUuid); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|