|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ByTIC\Payments\Gateways\Providers\Payu\Message; |
|
4
|
|
|
|
|
5
|
|
|
use ByTIC\Omnipay\Payu\Message\CompletePurchaseRequest as AbstractCompletePurchaseRequest; |
|
6
|
|
|
use ByTIC\Payments\Gateways\Providers\AbstractGateway\Message\Traits\HasModelRequest; |
|
7
|
|
|
use ByTIC\Payments\Gateways\Providers\Payu\Gateway; |
|
8
|
|
|
use ByTIC\Payments\Models\Purchase\Traits\IsPurchasableModelTrait; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class PurchaseResponse |
|
12
|
|
|
* @package ByTIC\Omnipay\Payu\Message |
|
13
|
|
|
*/ |
|
14
|
|
|
class CompletePurchaseRequest extends AbstractCompletePurchaseRequest |
|
15
|
|
|
{ |
|
16
|
|
|
use Traits\CompletePurchaseRequestTrait; |
|
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @inheritdoc |
|
20
|
|
|
*/ |
|
21
|
8 |
|
public function isValidNotification() |
|
22
|
|
|
{ |
|
23
|
8 |
|
if ($this->hasGet('ctrl')) { |
|
24
|
2 |
|
if ($this->validateModel()) { |
|
25
|
2 |
|
return parent::isValidNotification(); |
|
26
|
|
|
} |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
6 |
|
return false; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @return string |
|
34
|
|
|
*/ |
|
35
|
2 |
|
public function getModelIdFromRequest() |
|
36
|
|
|
{ |
|
37
|
2 |
|
if ($this->httpRequest->query->has('hash')) { |
|
38
|
2 |
|
return $this->httpRequest->query->get('hash'); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
return $this->httpRequest->query->get('id'); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @inheritDoc |
|
46
|
|
|
*/ |
|
47
|
2 |
|
protected function parseNotification() |
|
48
|
|
|
{ |
|
49
|
2 |
|
$model = $this->getModel(); |
|
50
|
2 |
|
$this->updateParametersFromPurchase($model); |
|
51
|
|
|
|
|
52
|
2 |
|
return parent::parseNotification(); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @inheritdoc |
|
58
|
|
|
*/ |
|
59
|
2 |
|
protected function generateCtrl() |
|
60
|
|
|
{ |
|
61
|
2 |
|
return $this->getModelCtrl(); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @return string |
|
66
|
|
|
*/ |
|
67
|
2 |
|
public function getModelCtrl() |
|
68
|
|
|
{ |
|
69
|
|
|
/** @var IsPurchasableModelTrait $model */ |
|
70
|
2 |
|
$model = $this->getModel(); |
|
71
|
|
|
/** @var Gateway $gateway */ |
|
72
|
2 |
|
$gateway = $model->getPaymentMethod()->getType()->getGateway(); |
|
|
|
|
|
|
73
|
2 |
|
$purchaseRequest = $gateway->purchaseFromModel($model); |
|
74
|
|
|
|
|
75
|
2 |
|
return $purchaseRequest->getCtrl(); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|