1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Luigel\Paymongo\Models; |
4
|
|
|
|
5
|
|
|
class Payment |
6
|
|
|
{ |
7
|
|
|
protected $data; |
8
|
|
|
protected $id; |
9
|
|
|
protected $type; |
10
|
|
|
protected $amount; |
11
|
|
|
protected $billing_address; |
12
|
|
|
protected $billing_email; |
13
|
|
|
protected $billing_name; |
14
|
|
|
protected $billing_phone_number; |
15
|
|
|
protected $currency; |
16
|
|
|
protected $description; |
17
|
|
|
protected $fee; |
18
|
|
|
protected $livemode; |
19
|
|
|
protected $net_amount; |
20
|
|
|
protected $payout; |
21
|
|
|
protected $source; |
22
|
|
|
protected $statement_descriptor; |
23
|
|
|
protected $status; |
24
|
|
|
protected $created_at; |
25
|
|
|
protected $paid_at; |
26
|
|
|
protected $updated_at; |
27
|
|
|
|
28
|
|
|
public function setData($data) |
29
|
|
|
{ |
30
|
|
|
if (is_array($data) && isset($data['id'])) { |
31
|
|
|
return $this->setSingleData($data); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
$payments = collect(); |
35
|
|
|
|
36
|
|
|
foreach ($data as $item) { |
37
|
|
|
$payments->push($this->setSingleData($item)); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
return $payments; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
protected function setSingleData($data) |
44
|
|
|
{ |
45
|
|
|
$this->id = $data['id']; |
46
|
|
|
$this->type = $data['type']; |
47
|
|
|
$this->amount = floatval($data['attributes']['amount'] / 100); |
48
|
|
|
$this->billing_address = $data['attributes']['billing']['address']; |
49
|
|
|
$this->billing_email = $data['attributes']['billing']['email']; |
50
|
|
|
$this->billing_name = $data['attributes']['billing']['name']; |
51
|
|
|
$this->billing_phone_number = $data['attributes']['billing']['phone']; |
52
|
|
|
$this->currency = $data['attributes']['currency'] ?? 'PHP'; |
53
|
|
|
$this->description = $data['attributes']['description']; |
54
|
|
|
$this->fee = floatval($data['attributes']['fee'] / 100); |
55
|
|
|
$this->livemode = $data['attributes']['livemode']; |
56
|
|
|
$this->net_amount = floatval($data['attributes']['net_amount']); |
57
|
|
|
$this->payout = $data['attributes']['payout']; |
58
|
|
|
$this->source = $data['attributes']['source']; |
59
|
|
|
$this->statement_descriptor = $data['attributes']['statement_descriptor']; |
60
|
|
|
$this->status = $data['attributes']['status']; |
61
|
|
|
$this->created_at = $data['attributes']['created_at']; |
62
|
|
|
$this->paid_at = $data['attributes']['paid_at']; |
63
|
|
|
$this->updated_at = $data['attributes']['updated_at']; |
64
|
|
|
|
65
|
|
|
$this->data = [ |
66
|
|
|
'id' => $this->id, |
67
|
|
|
'type' => $this->type, |
68
|
|
|
'amount' => $this->amount, |
69
|
|
|
'billing_address' => $this->billing_address, |
70
|
|
|
'billing_email' => $this->billing_email, |
71
|
|
|
'billing_name' => $this->billing_name, |
72
|
|
|
'billing_phone_number' => $this->billing_phone_number, |
73
|
|
|
'currency' => $this->currency, |
74
|
|
|
'description' => $this->description, |
75
|
|
|
'fee' => $this->fee, |
76
|
|
|
'livemode' => $this->livemode, |
77
|
|
|
'net_amount' => $this->net_amount, |
78
|
|
|
'payout' => $this->payout, |
79
|
|
|
'source' => $this->source, |
80
|
|
|
'statement_descriptor' => $this->statement_descriptor, |
81
|
|
|
'status' => $this->status, |
82
|
|
|
'created_at' => $this->created_at, |
83
|
|
|
'paid_at' => $this->paid_at, |
84
|
|
|
'updated_at' => $this->updated_at, |
85
|
|
|
]; |
86
|
|
|
|
87
|
|
|
return $this; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function getId() |
91
|
|
|
{ |
92
|
|
|
return $this->id; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function getType() |
96
|
|
|
{ |
97
|
|
|
return $this->type; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function getAmount() |
101
|
|
|
{ |
102
|
|
|
return $this->amount; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function getBillingAddress() |
106
|
|
|
{ |
107
|
|
|
return $this->billing_address; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function getBillingEmail() |
111
|
|
|
{ |
112
|
|
|
return $this->billing_email; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function getBillingName() |
116
|
|
|
{ |
117
|
|
|
return $this->billing_name; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function getBillingPhoneNumber() |
121
|
|
|
{ |
122
|
|
|
return $this->billing_phone_number; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
public function getCurrency() |
126
|
|
|
{ |
127
|
|
|
return $this->currency; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
public function getDescription() |
131
|
|
|
{ |
132
|
|
|
return $this->description; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
public function getFee() |
136
|
|
|
{ |
137
|
|
|
return $this->fee; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
public function getLivemode() |
141
|
|
|
{ |
142
|
|
|
return $this->livemode; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
public function getNetAmount() |
146
|
|
|
{ |
147
|
|
|
return $this->net_amount; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
public function getPayout() |
151
|
|
|
{ |
152
|
|
|
return $this->payout; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
public function getSource() |
156
|
|
|
{ |
157
|
|
|
return $this->source; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
public function getStatementDescriptor() |
161
|
|
|
{ |
162
|
|
|
return $this->statement_descriptor; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
public function getStatus() |
166
|
|
|
{ |
167
|
|
|
return $this->status; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
public function getCreatedAt() |
171
|
|
|
{ |
172
|
|
|
return $this->created_at; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
public function getPaidAt() |
176
|
|
|
{ |
177
|
|
|
return $this->paid_at; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
public function getUpdatedAt() |
181
|
|
|
{ |
182
|
|
|
return $this->updated_at; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
public function getData() |
186
|
|
|
{ |
187
|
|
|
return $this->data; |
188
|
|
|
} |
189
|
|
|
} |
190
|
|
|
|