1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Omnipay\Yoomoney\Message; |
4
|
|
|
|
5
|
|
|
use Omnipay\Common\Exception\InvalidResponseException; |
6
|
|
|
|
7
|
|
|
class CompletePurchaseRequest extends AbstractRequest |
8
|
|
|
{ |
9
|
|
|
|
10
|
|
|
public function getData() |
11
|
|
|
{ |
12
|
|
|
$sign = $this->getSignature([ |
13
|
|
|
$this->httpRequest->get("notification_type"), |
14
|
|
|
$this->httpRequest->get("operation_id"), |
15
|
|
|
$this->httpRequest->get("amount"), |
16
|
|
|
$this->httpRequest->get("currency"), |
17
|
|
|
$this->httpRequest->get("datetime"), |
18
|
|
|
$this->httpRequest->get("sender"), |
19
|
|
|
$this->httpRequest->get("codepro"), |
20
|
|
|
$this->getSecret(), |
21
|
|
|
$this->httpRequest->get("label"), |
22
|
|
|
]); |
23
|
|
|
|
24
|
|
|
if ($this->httpRequest->get("sha1_hash") != $sign) { |
25
|
|
|
throw new InvalidResponseException("Callback hash does not match expected value"); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
return [ |
29
|
|
|
'notification_type' => $this->httpRequest->get("notification_type"), |
30
|
|
|
'bill_id' => $this->httpRequest->get("bill_id"), |
31
|
|
|
'amount' => $this->httpRequest->get("amount"), |
32
|
|
|
'codepro' => $this->httpRequest->get("codepro"), |
33
|
|
|
'withdraw_amount' => $this->httpRequest->get("withdraw_amount"), |
34
|
|
|
'unaccepted' => $this->httpRequest->get("unaccepted"), |
35
|
|
|
'operation_id' => $this->httpRequest->get("operation_id"), |
36
|
|
|
'currency' => $this->httpRequest->get("currency"), |
37
|
|
|
'datetime' => $this->httpRequest->get("datetime"), |
38
|
|
|
'sender' => $this->httpRequest->get("sender"), |
39
|
|
|
'label' => $this->httpRequest->get("label"), |
40
|
|
|
'sha1_hash' => $this->httpRequest->get("sha1_hash"), |
41
|
|
|
'operation_label' => $this->httpRequest->get("operation_label"), |
42
|
|
|
'test_notification' => $this->httpRequest->get("test_notification"), |
43
|
|
|
]; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function sendData($data) |
47
|
|
|
{ |
48
|
|
|
return $this->response = new CompletePurchaseResponse($this, $data); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
private function getSignature($params) |
52
|
|
|
{ |
53
|
|
|
return hash('sha1', implode("&", $params)); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|