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\Converter; |
9
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\AmazonpayPriceTransfer; |
|
|
|
|
11
|
|
|
use Generated\Shared\Transfer\AmazonpayStatusTransfer; |
|
|
|
|
12
|
|
|
use SprykerEco\Shared\Amazonpay\AmazonpayConstants; |
13
|
|
|
use Spryker\Shared\Kernel\Transfer\AbstractTransfer; |
14
|
|
|
|
15
|
|
|
abstract class AbstractConverter |
16
|
|
|
{ |
17
|
|
|
|
18
|
|
|
const STATUS_DECLINED = 'Declined'; |
19
|
|
|
const STATUS_PENDING = 'Pending'; |
20
|
|
|
const STATUS_OPEN = 'Open'; |
21
|
|
|
const STATUS_CLOSED = 'Closed'; |
22
|
|
|
const STATUS_COMPLETED = 'Completed'; |
23
|
|
|
const STATUS_SUSPENDED = 'Suspended'; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @param array $priceData |
27
|
|
|
* |
28
|
|
|
* @return \Generated\Shared\Transfer\AmazonpayPriceTransfer |
29
|
|
|
*/ |
30
|
|
|
protected function convertPriceToTransfer(array $priceData) |
31
|
|
|
{ |
32
|
|
|
$priceTransfer = new AmazonpayPriceTransfer(); |
33
|
|
|
|
34
|
|
|
$priceTransfer->setAmount($priceData['Amount']); |
35
|
|
|
$priceTransfer->setCurrencyCode($priceData['CurrencyCode']); |
36
|
|
|
|
37
|
|
|
return $priceTransfer; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param array $statusData |
42
|
|
|
* |
43
|
|
|
* @return \Generated\Shared\Transfer\AmazonpayStatusTransfer |
44
|
|
|
*/ |
45
|
|
|
protected function convertStatusToTransfer(array $statusData) |
46
|
|
|
{ |
47
|
|
|
$status = new AmazonpayStatusTransfer(); |
48
|
|
|
|
49
|
|
|
if (!empty($statusData['LastUpdateTimestamp'])) { |
50
|
|
|
$status->setLastUpdateTimestamp($statusData['LastUpdateTimestamp']); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$status->setState($statusData['State']); |
54
|
|
|
|
55
|
|
|
if (!empty($statusData['ReasonCode'])) { |
56
|
|
|
$status->setReasonCode($statusData['ReasonCode']); |
57
|
|
|
$status->setIsReauthorizable( |
58
|
|
|
$statusData['ReasonCode'] === AmazonpayConstants::REASON_CODE_SELLER_CLOSED |
59
|
|
|
|| $statusData['ReasonCode'] === AmazonpayConstants::REASON_CODE_EXPIRED_UNUSED |
60
|
|
|
); |
61
|
|
|
|
62
|
|
|
$status->setIsPaymentMethodInvalid( |
63
|
|
|
$statusData['ReasonCode'] === AmazonpayConstants::REASON_CODE_PAYMENT_METHOD_INVALID |
64
|
|
|
); |
65
|
|
|
|
66
|
|
|
$status->setIsClosedByAmazon( |
67
|
|
|
$statusData['ReasonCode'] === AmazonpayConstants::REASON_CODE_AMAZON_CLOSED |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
if ($statusData['State'] === static::STATUS_DECLINED) { |
72
|
|
|
$status->setIsSuspended($status->getIsPaymentMethodInvalid()); |
73
|
|
|
$status->setIsDeclined(true); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
if ($statusData['State'] === static::STATUS_SUSPENDED) { |
77
|
|
|
$status->setIsSuspended(true); |
78
|
|
|
$status->setIsDeclined(true); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
$status->setIsPending( |
82
|
|
|
$statusData['State'] === static::STATUS_PENDING |
83
|
|
|
); |
84
|
|
|
|
85
|
|
|
$status->setIsOpen( |
86
|
|
|
$statusData['State'] === static::STATUS_OPEN |
87
|
|
|
); |
88
|
|
|
|
89
|
|
|
$status->setIsClosed( |
90
|
|
|
$statusData['State'] === static::STATUS_CLOSED |
91
|
|
|
); |
92
|
|
|
|
93
|
|
|
$status->setIsCompleted( |
94
|
|
|
$statusData['State'] === static::STATUS_COMPLETED |
95
|
|
|
); |
96
|
|
|
|
97
|
|
|
return $status; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @param \Spryker\Shared\Kernel\Transfer\AbstractTransfer $transfer |
102
|
|
|
* @param string $name |
103
|
|
|
* |
104
|
|
|
* @return \Spryker\Shared\Kernel\Transfer\AbstractTransfer |
105
|
|
|
*/ |
106
|
|
|
protected function updateNameData(AbstractTransfer $transfer, $name) |
107
|
|
|
{ |
108
|
|
|
$names = explode(' ', $name, 2); |
109
|
|
|
|
110
|
|
|
if (count($names) >= 2) { |
111
|
|
|
$transfer->setFirstName($names[0]); |
|
|
|
|
112
|
|
|
$transfer->setLastName($names[1]); |
|
|
|
|
113
|
|
|
} else { |
114
|
|
|
$transfer->setFirstName($name); |
115
|
|
|
$transfer->setLastName($name); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
return $transfer; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
} |
122
|
|
|
|
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