1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* FreeKassa driver for Omnipay PHP payment library |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/hiqdev/omnipay-freekassa |
6
|
|
|
* @package omnipay-freekassa |
7
|
|
|
* @license MIT |
8
|
|
|
* @copyright Copyright (c) 2017, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Omnipay\FreeKassa\Message; |
12
|
|
|
|
13
|
|
|
class PurchaseRequest extends AbstractRequest |
14
|
|
|
{ |
15
|
|
|
public function getLanguage() |
16
|
|
|
{ |
17
|
|
|
return $this->getParameter('language'); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
public function setLanguage($value) |
21
|
|
|
{ |
22
|
|
|
return $this->setParameter('language', $value); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function getClient() : string |
26
|
|
|
{ |
27
|
|
|
return (string) $this->getParameter('client'); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function setClient($value) |
31
|
|
|
{ |
32
|
|
|
return $this->setParameter('client', $value); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function getCurrency() |
36
|
|
|
{ |
37
|
|
|
return $this->getParameter('currency') ?? 'RUB'; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function setCurrency($value) |
41
|
|
|
{ |
42
|
|
|
$this->setParameter('currency', $value); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function getData() |
46
|
|
|
{ |
47
|
|
|
$this->validate( |
48
|
|
|
'purse', 'secretKey', |
49
|
|
|
'amount', 'currency', 'transactionId' |
50
|
|
|
); |
51
|
|
|
|
52
|
|
|
return array_filter([ |
53
|
|
|
'm' => $this->getPurse(), |
54
|
|
|
'oa' => $this->getAmount(), |
55
|
|
|
'o' => $this->getTransactionId(), |
56
|
|
|
'i' => strtolower($this->getCurrency()), |
57
|
|
|
's' => $this->calculateSignature(), |
58
|
|
|
'lang' => $this->getLanguage(), |
59
|
|
|
'us_client' => $this->getClient(), |
60
|
|
|
'us_system' => 'freekassa', |
61
|
|
|
'us_currency' => $this->getCurrency(), |
62
|
|
|
]); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function calculateSignature() |
66
|
|
|
{ |
67
|
|
|
return md5(implode(':', [ |
68
|
|
|
$this->getPurse(), |
69
|
|
|
$this->getAmount(), |
70
|
|
|
$this->getSecretKey(), |
71
|
|
|
$this->getTransactionId() |
72
|
|
|
])); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function sendData($data) |
76
|
|
|
{ |
77
|
|
|
return $this->response = new PurchaseResponse($this, $data); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|