1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ByTIC\Payments\Models\Transactions; |
4
|
|
|
|
5
|
|
|
use ByTIC\DataObjects\Behaviors\Timestampable\TimestampableTrait; |
6
|
|
|
use ByTIC\DataObjects\Casts\AsArrayObject; |
7
|
|
|
use ByTIC\Payments\Gateways\Providers\AbstractGateway\Message\Traits\HasModelProcessedResponse; |
8
|
|
|
use ByTIC\Payments\Gateways\Providers\AbstractGateway\Traits\GatewayTrait as AbstractGateway; |
9
|
|
|
use ByTIC\Payments\Models\AbstractModels\HasPurchaseParent; |
10
|
|
|
use Nip\MailModule\Models\EmailsTable\EmailTrait; |
11
|
|
|
use Nip\Records\AbstractModels\RecordManager; |
12
|
|
|
use Nip\Records\EventManager\Events\Event; |
13
|
|
|
use Nip\Records\Record; |
14
|
|
|
use Omnipay\Common\Message\AbstractResponse; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Trait TransactionTrait |
18
|
|
|
* @package ByTIC\Payments\Models\Transactions |
19
|
|
|
* |
20
|
|
|
* @property int $id_purchase |
21
|
|
|
* @property int $id_token |
22
|
|
|
* @property string $gateway |
23
|
|
|
* @property string $currency |
24
|
|
|
* |
25
|
|
|
* @property string $card |
26
|
|
|
* @property string $code A response code from the payment gateway |
27
|
|
|
* @property string $reference A reference provided by the gateway to represent this transaction |
28
|
|
|
* @property string $metadata |
29
|
|
|
* |
30
|
|
|
* @property string $modified |
31
|
|
|
* @property string $created |
32
|
|
|
* |
33
|
|
|
* @method TransactionsTrait getManager |
34
|
|
|
*/ |
35
|
|
|
trait TransactionTrait |
36
|
|
|
{ |
37
|
|
|
use HasPurchaseParent; |
38
|
|
|
use TimestampableTrait; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var string |
42
|
|
|
*/ |
43
|
|
|
static protected $createTimestamps = ['created']; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var string |
47
|
|
|
*/ |
48
|
|
|
static protected $updateTimestamps = ['modified']; |
49
|
|
|
|
50
|
|
|
public function bootTransactionTrait() |
51
|
|
|
{ |
52
|
|
|
$this->addCast('metadata', AsArrayObject::class . ':json'); |
|
|
|
|
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return mixed |
57
|
|
|
*/ |
58
|
|
|
public function getMetadata() |
59
|
|
|
{ |
60
|
|
|
return $this->getPropertyValue('metadata'); |
|
|
|
|
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function setMedata($value) |
64
|
|
|
{ |
65
|
|
|
return $this->setPropertyValue('metadata', $value); |
|
|
|
|
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param $key |
70
|
|
|
* @param $value |
71
|
|
|
*/ |
72
|
|
|
public function addMedata($key, $value) |
73
|
|
|
{ |
74
|
|
|
$metadata = $this->metadata; |
75
|
|
|
$metadata[$key] = $value; |
76
|
|
|
$this->setMedata($metadata); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param AbstractResponse|HasModelProcessedResponse $response |
81
|
|
|
*/ |
82
|
|
|
public function updateFromResponse($response, $type) |
|
|
|
|
83
|
|
|
{ |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @param AbstractGateway $gateway |
88
|
|
|
*/ |
89
|
|
|
public function populateFromGateway($gateway) |
90
|
|
|
{ |
91
|
|
|
$this->gateway = $gateway->getName(); |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|