|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Apache OSL-2 |
|
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace SprykerEco\Zed\AmazonPay\Business\Api\Adapter; |
|
9
|
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\AmazonpayCallTransfer; |
|
|
|
|
|
|
11
|
|
|
use Generated\Shared\Transfer\AmazonpayPaymentTransfer; |
|
|
|
|
|
|
12
|
|
|
use PayWithAmazon\ClientInterface; |
|
13
|
|
|
use SprykerEco\Shared\AmazonPay\AmazonPayConfigInterface; |
|
14
|
|
|
use SprykerEco\Zed\AmazonPay\Business\Api\Converter\ResponseParserConverterInterface; |
|
15
|
|
|
use SprykerEco\Zed\AmazonPay\Dependency\Facade\AmazonPayToMoneyInterface; |
|
16
|
|
|
|
|
17
|
|
|
class AuthorizeAdapter extends AbstractAdapter |
|
18
|
|
|
{ |
|
19
|
|
|
const AUTHORIZATION_AMOUNT = 'authorization_amount'; |
|
20
|
|
|
const AUTHORIZATION_REFERENCE_ID = 'authorization_reference_id'; |
|
21
|
|
|
const TRANSACTION_TIMEOUT = 'transaction_timeout'; |
|
22
|
|
|
const CAPTURE_NOW = 'capture_now'; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var bool |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $captureNow; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var int |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $transactionTimeout; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @param \PayWithAmazon\ClientInterface $client |
|
36
|
|
|
* @param \SprykerEco\Zed\AmazonPay\Business\Api\Converter\ResponseParserConverterInterface $converter |
|
37
|
|
|
* @param \SprykerEco\Zed\AmazonPay\Dependency\Facade\AmazonPayToMoneyInterface $moneyFacade |
|
38
|
|
|
* @param \SprykerEco\Shared\AmazonPay\AmazonPayConfigInterface $config |
|
39
|
|
|
* @param bool|null $captureNow |
|
40
|
|
|
*/ |
|
41
|
|
|
public function __construct( |
|
42
|
|
|
ClientInterface $client, |
|
43
|
|
|
ResponseParserConverterInterface $converter, |
|
44
|
|
|
AmazonPayToMoneyInterface $moneyFacade, |
|
45
|
|
|
AmazonPayConfigInterface $config, |
|
46
|
|
|
$captureNow = null |
|
47
|
|
|
) { |
|
48
|
|
|
parent::__construct($client, $converter, $moneyFacade); |
|
49
|
|
|
|
|
50
|
|
|
$this->captureNow = $this->getCaptureNow($config, $captureNow); |
|
51
|
|
|
$this->transactionTimeout = $config->getAuthTransactionTimeout(); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonpayCallTransfer |
|
56
|
|
|
* |
|
57
|
|
|
* @return \Generated\Shared\Transfer\AmazonpayResponseTransfer |
|
|
|
|
|
|
58
|
|
|
*/ |
|
59
|
|
|
public function call(AmazonpayCallTransfer $amazonpayCallTransfer) |
|
60
|
|
|
{ |
|
61
|
|
|
$result = $this->client->authorize( |
|
62
|
|
|
$this->getRequestArray($amazonpayCallTransfer->getAmazonpayPayment(), $this->getAmount($amazonpayCallTransfer)) |
|
63
|
|
|
); |
|
64
|
|
|
|
|
65
|
|
|
return $this->converter->convert($result); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @param \SprykerEco\Shared\AmazonPay\AmazonPayConfigInterface $config |
|
70
|
|
|
* @param bool|null $captureNow |
|
71
|
|
|
* |
|
72
|
|
|
* @return bool |
|
73
|
|
|
*/ |
|
74
|
|
|
protected function getCaptureNow(AmazonPayConfigInterface $config, $captureNow = null) |
|
75
|
|
|
{ |
|
76
|
|
|
return $captureNow ?? $config->getCaptureNow(); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @param \Generated\Shared\Transfer\AmazonpayPaymentTransfer $amazonpayPaymentTransfer |
|
81
|
|
|
* @param float $amount |
|
82
|
|
|
* |
|
83
|
|
|
* @return array |
|
84
|
|
|
*/ |
|
85
|
|
|
protected function getRequestArray(AmazonpayPaymentTransfer $amazonpayPaymentTransfer, $amount) |
|
86
|
|
|
{ |
|
87
|
|
|
return [ |
|
88
|
|
|
static::AMAZON_ORDER_REFERENCE_ID => $amazonpayPaymentTransfer->getOrderReferenceId(), |
|
89
|
|
|
static::AUTHORIZATION_AMOUNT => $amount, |
|
90
|
|
|
static::AUTHORIZATION_REFERENCE_ID => $amazonpayPaymentTransfer |
|
91
|
|
|
->getAuthorizationDetails() |
|
92
|
|
|
->getAuthorizationReferenceId(), |
|
93
|
|
|
static::TRANSACTION_TIMEOUT => $this->transactionTimeout, |
|
94
|
|
|
static::CAPTURE_NOW => $this->captureNow, |
|
95
|
|
|
]; |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths