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\Models\AbstractModels\HasGateway\HasGatewayRecordTrait; |
9
|
|
|
use ByTIC\Payments\Models\AbstractModels\HasPurchaseParent; |
10
|
|
|
use Omnipay\Common\Message\AbstractResponse; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Trait TransactionTrait |
14
|
|
|
* @package ByTIC\Payments\Models\Transactions |
15
|
|
|
* |
16
|
|
|
* @property int $id_purchase |
17
|
|
|
* @property int $id_token |
18
|
|
|
* @property string $gateway |
19
|
|
|
* @property string $currency |
20
|
|
|
* |
21
|
|
|
* @property string $card |
22
|
|
|
* @property string $code A response code from the payment gateway |
23
|
|
|
* @property string $reference A reference provided by the gateway to represent this transaction |
24
|
|
|
* @property string $metadata |
25
|
|
|
* |
26
|
|
|
* @property string $modified |
27
|
|
|
* @property string $created |
28
|
|
|
* |
29
|
|
|
* @method TransactionsTrait getManager |
30
|
|
|
*/ |
31
|
|
|
trait TransactionTrait |
32
|
|
|
{ |
33
|
|
|
use HasPurchaseParent; |
34
|
|
|
use HasGatewayRecordTrait; |
35
|
|
|
use TimestampableTrait; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
static protected $createTimestamps = ['created']; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var string |
44
|
|
|
*/ |
45
|
|
|
static protected $updateTimestamps = ['modified']; |
46
|
|
|
|
47
|
|
|
public function bootTransactionTrait() |
48
|
|
|
{ |
49
|
|
|
$this->addCast('metadata', AsArrayObject::class . ':json'); |
|
|
|
|
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return mixed |
54
|
|
|
*/ |
55
|
|
|
public function getMetadata() |
56
|
|
|
{ |
57
|
|
|
return $this->getPropertyValue('metadata'); |
|
|
|
|
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function setMedata($value) |
61
|
|
|
{ |
62
|
|
|
return $this->setPropertyValue('metadata', $value); |
|
|
|
|
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param $key |
67
|
|
|
* @param $value |
68
|
|
|
*/ |
69
|
|
|
public function addMedata($key, $value) |
70
|
|
|
{ |
71
|
|
|
$metadata = $this->metadata; |
72
|
|
|
$metadata[$key] = $value; |
73
|
|
|
$this->setMedata($metadata); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @param AbstractResponse|HasModelProcessedResponse $response |
78
|
|
|
*/ |
79
|
|
|
public function updateFromResponse($response, $type) |
|
|
|
|
80
|
|
|
{ |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|