CreatePaymentV2CallEntity   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 129
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
eloc 36
c 1
b 0
f 0
dl 0
loc 129
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setCreatedAt() 0 7 2
A setAddress() 0 5 1
A setCart() 0 13 5
A setShippingAddress() 0 5 1
1
<?php
2
3
/**
4
 * PHP version 5.4 and 8
5
 *
6
 * @category  MessageEntity
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\Http\MessageEntity;
15
16
use Payever\ExternalIntegration\Core\Helper\StringHelper;
17
use Payever\ExternalIntegration\Core\Http\MessageEntity\CallEntity;
18
19
/**
20
 * This class represents Create Payment Call Entity
21
 *
22
 * @method string           getStatus()
23
 * @method string           getId()
24
 * @method \DateTime|false      getCreatedAt()
25
 * @method string           getChannel()
26
 * @method float            getAmount()
27
 * @method float            getPaymentFee()
28
 * @method float            getDeliveryFee()
29
 * @method string           getReference()
30
 * @method string           getCurrency()
31
 * @method CartItemEntity[] getCart()
32
 * @method AddressEntity    getAddress()
33
 * @method AddressEntity    getShippingAddress()
34
 * @method string           getCustomerEmail()
35
 * @method float            getTotal()
36
 * @method float            getDownPayment()
37
 * @method string           getSuccessUrl()
38
 * @method string           getFailureUrl()
39
 * @method string           getCancelUrl()
40
 * @method string           getNoticeUrl()
41
 * @method string           getPendingUrl()
42
 * @method string           getCustomerRedirectUrl()
43
 * @method string           getPaymentType()
44
 * @method self             setStatus(string $status)
45
 * @method self             setId(string $id)
46
 * @method self             setChannel(string $name)
47
 * @method self             setAmount(float $amount)
48
 * @method self             setPaymentFee(float $paymentFee)
49
 * @method self             setDeliveryFee(float $deliveryFee)
50
 * @method self             setReference(string $reference)
51
 * @method self             setCurrency(string $currency)
52
 * @method self             setCustomerEmail(string $email)
53
 * @method self             setTotal(float $total)
54
 * @method self             setDownPayment(float $downPayment)
55
 * @method self             setSuccessUrl(string $successUrl)
56
 * @method self             setFailureUrl(string $failureUrl)
57
 * @method self             setCancelUrl(string $cancelUrl)
58
 * @method self             setNoticeUrl(string $noticeUrl)
59
 * @method self             setPendingUrl(string $pendingUrl)
60
 * @method self             setCustomerRedirectUrl(string $url)
61
 * @method self             setPaymentType(string $paymentType)
62
 *
63
 * @SuppressWarnings(PHPMD.StaticAccess)
64
 * @SuppressWarnings(PHPMD.TooManyFields)
65
 */
66
class CreatePaymentV2CallEntity extends CallEntity
67
{
68
    /** @var string $status */
69
    protected $status;
70
71
    /** @var string $id */
72
    protected $id;
73
74
    /** @var \DateTime|bool $createdAt */
75
    protected $createdAt;
76
77
    /** @var string $channel */
78
    protected $channel;
79
80
    /** @var float $amount */
81
    protected $amount;
82
83
    /** @var float $paymentFee */
84
    protected $paymentFee;
85
86
    /** @var float $fee */
87
    protected $deliveryFee;
88
89
    /** @var string $reference */
90
    protected $reference;
91
92
    /** @var string $currency */
93
    protected $currency;
94
95
    /** @var CartItemEntity[] $cart */
96
    protected $cart;
97
98
    /** @var AddressEntity $address */
99
    protected $address;
100
101
    /** @var AddressEntity $shippingAddress */
102
    protected $shippingAddress;
103
104
    /** @var string $customerEmail */
105
    protected $customerEmail;
106
107
    /** @var float $total */
108
    protected $total;
109
110
    /** @var float $downPayment */
111
    protected $downPayment;
112
113
    /** @var string $successUrl */
114
    protected $successUrl;
115
116
    /** @var string $failureUrl */
117
    protected $failureUrl;
118
119
    /** @var string $cancelUrl */
120
    protected $cancelUrl;
121
122
    /** @var string $noticeUrl */
123
    protected $noticeUrl;
124
125
    /** @var string $pendingUrl */
126
    protected $pendingUrl;
127
128
    /** @var string $customerRedirectUrl */
129
    protected $customerRedirectUrl;
130
131
    /** @var string $paymentType */
132
    protected $paymentType;
133
134
    /**
135
     * Sets Cart
136
     *
137
     * @param array|string $cart
138
     * @return self
139
     * @throws \Exception
140
     */
141
    public function setCart($cart)
142
    {
143
        if (is_string($cart)) {
144
            $cart = StringHelper::jsonDecode($cart);
145
        }
146
147
        if ($cart && is_array($cart)) {
148
            foreach ($cart as $item) {
149
                $this->cart[] = new CartItemEntity($item);
150
            }
151
        }
152
153
        return $this;
154
    }
155
156
    /**
157
     * Sets Address
158
     *
159
     * @param array $address
160
     * @return self
161
     */
162
    public function setAddress($address)
163
    {
164
        $this->address = new AddressEntity($address);
165
166
        return $this;
167
    }
168
169
    /**
170
     * Sets Shipping Address
171
     *
172
     * @param array $shippingAddress
173
     * @return self
174
     */
175
    public function setShippingAddress($shippingAddress)
176
    {
177
        $this->shippingAddress = new AddressEntity($shippingAddress);
178
179
        return $this;
180
    }
181
182
    /**
183
     * Sets Created At
184
     *
185
     * @param string $createdAt
186
     * @return self
187
     */
188
    public function setCreatedAt($createdAt)
189
    {
190
        if ($createdAt) {
191
            $this->createdAt = date_create($createdAt);
192
        }
193
194
        return $this;
195
    }
196
}
197