PurchaseRequest::getIdentifier()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Paytic\Omnipay\Paylike\Message;
4
5
/**
6
 * Class PurchaseRequest
7
 * @package Paytic\Omnipay\Paylike\Message
8
 *
9
 * @method PurchaseResponse send()
10
 */
11
class PurchaseRequest extends AbstractRequest
12
{
13
    /**
14
     * @inheritdoc
15
     */
16
    public function initialize(array $parameters = [])
17
    {
18
        $parameters['identifier'] = isset($parameters['identifier']) ?
19
            $parameters['identifier'] : 'anonymous' . microtime(true);
20
21
        return parent::initialize($parameters);
22
    }
23
24
    /**
25
     * @return array
26
     * @throws \Omnipay\Common\Exception\InvalidRequestException
27
     */
28
    public function getData()
29
    {
30
        $this->validate(
31
            'publicKey',
32
            'amount',
33
            'currency',
34
            'description',
35
            'orderId',
36
            'returnUrl',
37
            'card'
38
        );
39
40
        $data = [
41
            'publicKey' => $this->getPublicKey(),
42
            'returnUrl' => $this->getReturnUrl(),
43
            'identifier' => $this->getIdentifier(),
44
            'orderId' => $this->getOrderId(),
45
            'amount' => $this->getAmount(),
46
            'currency' => $this->getCurrency(),
47
            'title' => $this->getTitle(),
48
            'description' => $this->getDescription(),
49
            'clientIp' => $this->getClientIp(),
50
        ];
51
52
        $card = $this->getCard();
53
54
        $data['firstName'] = $card->getBillingFirstName();
55
        $data['lastName'] = $card->getBillingLastName();
56
        $data['address'] = $card->getBillingAddress1();
57
        $data['phone'] = $card->getBillingPhone();
58
        $data['email'] = $card->getEmail();
59
60
        return $data;
61
    }
62
63
    /**
64
     * @return mixed
65
     */
66
    public function getIdentifier()
67
    {
68
        return $this->getParameter('identifier');
69
    }
70
71
    /**
72
     * @param $value
73
     * @return \Omnipay\Common\Message\AbstractRequest
74
     */
75
    public function setIdentifier($value)
76
    {
77
        return $this->setParameter('identifier', $value);
78
    }
79
80
    /**
81
     * @return mixed
82
     */
83
    public function getOrderId()
84
    {
85
        return $this->getParameter('orderId');
86
    }
87
88
    /**
89
     * @param $value
90
     * @return \Omnipay\Common\Message\AbstractRequest
91
     */
92
    public function setOrderId($value)
93
    {
94
        return $this->setParameter('orderId', $value);
95
    }
96
97
    /**
98
     * @return mixed
99
     */
100
    public function getTitle()
101
    {
102
        return $this->getParameter('title');
103
    }
104
105
    /**
106
     * @param $value
107
     * @return \Omnipay\Common\Message\AbstractRequest
108
     */
109
    public function setTitle($value)
110
    {
111
        return $this->setParameter('title', $value);
112
    }
113
}
114