|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ByTIC\Payments\Models\Subscriptions; |
|
4
|
|
|
|
|
5
|
|
|
use ByTIC\DataObjects\Behaviors\Timestampable\TimestampableTrait; |
|
6
|
|
|
use ByTIC\DataObjects\Casts\Metadata\AsMetadataObject; |
|
7
|
|
|
use ByTIC\Omnipay\Common\Models\SubscriptionInterface; |
|
|
|
|
|
|
8
|
|
|
use ByTIC\Payments\Models\AbstractModels\HasCustomer\HasCustomerRecord; |
|
9
|
|
|
use ByTIC\Payments\Models\AbstractModels\HasPaymentMethod\HasPaymentMethodRecord; |
|
10
|
|
|
use ByTIC\Payments\Models\AbstractModels\HasPaymentMethod\HasPaymentMethodRecordTrait; |
|
|
|
|
|
|
11
|
|
|
use ByTIC\Payments\Models\AbstractModels\HasToken\HasTokenRecord; |
|
12
|
|
|
use ByTIC\Payments\Models\Tokens\Token; |
|
13
|
|
|
use ByTIC\Payments\Models\Transactions\Transaction; |
|
14
|
|
|
use ByTIC\Payments\Models\Transactions\TransactionTrait; |
|
15
|
|
|
use ByTIC\Payments\Subscriptions\ChargeMethods\AbstractMethod; |
|
16
|
|
|
use DateTime; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Trait SubscriptionTrait |
|
20
|
|
|
* @package ByTIC\Payments\Models\Subscriptions |
|
21
|
|
|
* |
|
22
|
|
|
* @property int $id_method |
|
23
|
|
|
* @property int $id_token |
|
24
|
|
|
* @property int $id_last_transaction |
|
25
|
|
|
* @property int $id_billing_record |
|
26
|
|
|
* |
|
27
|
|
|
* @property string $billing_period |
|
28
|
|
|
* @property int $billing_interval |
|
29
|
|
|
* @property int $billing_count |
|
30
|
|
|
* |
|
31
|
|
|
* @property string|DateTime $start_at |
|
32
|
|
|
* @property string|DateTime $cancel_at |
|
33
|
|
|
* @property string|DateTime $ended_at |
|
34
|
|
|
* @property string|DateTime $charge_at |
|
35
|
|
|
* |
|
36
|
|
|
* @property int $charge_attempts |
|
37
|
|
|
* @property int $charge_count |
|
38
|
|
|
* @property int $charge_method |
|
39
|
|
|
* |
|
40
|
|
|
* @property string $modified |
|
41
|
|
|
* @property string $created |
|
42
|
|
|
* |
|
43
|
|
|
* @method Transaction getLastTransaction |
|
44
|
|
|
* @method SubscriptionsTrait getManager |
|
45
|
|
|
*/ |
|
46
|
|
|
trait SubscriptionTrait |
|
47
|
|
|
{ |
|
48
|
|
|
use \ByTIC\Models\SmartProperties\RecordsTraits\HasStatus\RecordTrait; |
|
49
|
|
|
use HasPaymentMethodRecord; |
|
50
|
|
|
use HasCustomerRecord; |
|
51
|
|
|
use HasTokenRecord; |
|
52
|
|
|
use TimestampableTrait; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @var string |
|
56
|
|
|
*/ |
|
57
|
|
|
static protected $createTimestamps = ['created']; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @var string |
|
61
|
|
|
*/ |
|
62
|
|
|
static protected $updateTimestamps = ['modified']; |
|
63
|
|
|
|
|
64
|
|
|
public function bootSubscriptionTrait() |
|
65
|
|
|
{ |
|
66
|
|
|
$fields = [ |
|
67
|
|
|
'start_at' => 'date', |
|
68
|
|
|
'cancel_at' => 'date', |
|
69
|
|
|
'ended_at' => 'date', |
|
70
|
|
|
'charge_at' => 'datetime' |
|
71
|
|
|
]; |
|
72
|
|
|
foreach ($fields as $field => $cast) { |
|
73
|
|
|
if ($this->hasCast($field)) { |
|
|
|
|
|
|
74
|
|
|
continue; |
|
75
|
|
|
} |
|
76
|
|
|
$this->addCast($field, $cast); |
|
|
|
|
|
|
77
|
|
|
} |
|
78
|
|
|
$this->addCast('metadata', AsMetadataObject::class . ':json'); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @param $key |
|
83
|
|
|
* @param $value |
|
84
|
|
|
*/ |
|
85
|
|
|
public function addMedata($key, $value) |
|
86
|
|
|
{ |
|
87
|
|
|
$this->metadata->set($key, $value); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @return \ByTIC\Models\SmartProperties\Properties\AbstractProperty\Generic|AbstractMethod |
|
92
|
|
|
*/ |
|
93
|
|
|
public function getChargeMethod() |
|
94
|
|
|
{ |
|
95
|
|
|
return $this->getSmartProperty('ChargeMethods'); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @param Transaction|TransactionTrait $transaction |
|
100
|
|
|
*/ |
|
101
|
|
|
public function populateFromLastTransaction($transaction) |
|
102
|
|
|
{ |
|
103
|
|
|
$this->id_last_transaction = $transaction->id; |
|
104
|
|
|
$this->getRelation('LastTransaction')->setResults($transaction); |
|
|
|
|
|
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @param Token $token |
|
109
|
|
|
*/ |
|
110
|
|
|
public function populateFromToken($token) |
|
111
|
|
|
{ |
|
112
|
|
|
$this->id_token = $token->id; |
|
113
|
|
|
$this->getRelation('Token')->setResults($token); |
|
114
|
|
|
} |
|
115
|
|
|
} |
|
116
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths