1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ByTIC\Payments\Models\PurchaseSessions; |
4
|
|
|
|
5
|
|
|
use ByTIC\Payments\Gateways\Providers\AbstractGateway\Message\Traits\CompletePurchaseResponseTrait; |
6
|
|
|
use ByTIC\Payments\Models\Purchase\Traits\IsPurchasableModelTrait; |
7
|
|
|
use ByTIC\Payments\Models\PurchaseSessions\Traits\Cleanup\RecordsTrait as CleanupRecordsTrait; |
8
|
|
|
use Omnipay\Common\Message\ResponseInterface; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Trait PurchaseSessionsTrait |
12
|
|
|
* @package ByTIC\Payments\Models\PurchaseSessions |
13
|
|
|
* |
14
|
|
|
* @method PurchaseSessionTrait getNew |
15
|
|
|
*/ |
16
|
|
|
trait PurchaseSessionsTrait |
17
|
|
|
{ |
18
|
|
|
use CleanupRecordsTrait; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @param string $type |
22
|
|
|
* @param CompletePurchaseResponseTrait|ResponseInterface $response |
23
|
|
|
* @return PurchaseSessionTrait |
24
|
|
|
*/ |
25
|
|
|
public function createFromResponse($response, $type) |
26
|
|
|
{ |
27
|
|
|
/** @var IsPurchasableModelTrait $payment */ |
28
|
|
|
$payment = $response->getModel(); |
|
|
|
|
29
|
|
|
$session = $this->generateFromPurchaseType($payment, $type); |
30
|
|
|
$session->populateFromResponse($response); |
31
|
|
|
$session->insert(); |
32
|
|
|
|
33
|
|
|
return $session; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param string $type |
38
|
|
|
* @param IsPurchasableModelTrait $payment |
39
|
|
|
* @return PurchaseSessionTrait |
40
|
|
|
*/ |
41
|
|
|
public function createFromPurchase($payment, $type) |
42
|
|
|
{ |
43
|
|
|
$session = $this->generateFromPurchaseType($payment, $type); |
44
|
|
|
$session->insert(); |
45
|
|
|
|
46
|
|
|
return $session; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param array $params |
51
|
|
|
*/ |
52
|
|
|
protected function injectParams(&$params = []) |
53
|
|
|
{ |
54
|
|
|
$params['order'][] = ['created', 'desc']; |
55
|
|
|
|
56
|
|
|
parent::injectParams($params); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param IsPurchasableModelTrait $payment |
61
|
|
|
* @param string $type |
62
|
|
|
* @return PurchaseSessionTrait |
63
|
|
|
*/ |
64
|
|
|
protected function generateFromPurchaseType($payment, $type) |
65
|
|
|
{ |
66
|
|
|
$session = $this->generateFromPurchase($payment); |
67
|
|
|
$session->type = $type; |
68
|
|
|
return $session; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param IsPurchasableModelTrait $payment |
73
|
|
|
* @return PurchaseSessionTrait |
74
|
|
|
*/ |
75
|
|
|
protected function generateFromPurchase($payment) |
76
|
|
|
{ |
77
|
|
|
$session = $this->getNew(); |
78
|
|
|
$session->populateFromPayment($payment); |
79
|
|
|
$session->populateFromGateway($payment->getPaymentMethod()->getType()->getGateway()); |
|
|
|
|
80
|
|
|
$session->populateFromRequest(); |
81
|
|
|
|
82
|
|
|
return $session; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @return mixed|\Nip\Config\Config |
87
|
|
|
* @throws \Exception |
88
|
|
|
*/ |
89
|
|
|
protected function generateTable() |
90
|
|
|
{ |
91
|
|
|
return config('payments.tables.purchases_sessions','purchases_sessions'); |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.