|
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
|
|
|
return $payments; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
protected function setSingleData($data) |
|
43
|
|
|
{ |
|
44
|
|
|
$this->id = $data['id']; |
|
45
|
|
|
$this->type = $data['type']; |
|
46
|
|
|
$this->amount = doubleval($data['attributes']['amount'] / 100); |
|
47
|
|
|
$this->billing_address = $data['attributes']['billing']['address']; |
|
48
|
|
|
$this->billing_email = $data['attributes']['billing']['email']; |
|
49
|
|
|
$this->billing_name = $data['attributes']['billing']['name']; |
|
50
|
|
|
$this->billing_phone_number = $data['attributes']['billing']['phone']; |
|
51
|
|
|
$this->currency = $data['attributes']['currency'] ?? 'PHP'; |
|
52
|
|
|
$this->description = $data['attributes']['description']; |
|
53
|
|
|
$this->fee = doubleval($data['attributes']['fee'] / 100); |
|
54
|
|
|
$this->livemode = $data['attributes']['livemode']; |
|
55
|
|
|
$this->net_amount = doubleval($data['attributes']['net_amount']); |
|
56
|
|
|
$this->payout = $data['attributes']['payout']; |
|
57
|
|
|
$this->source = $data['attributes']['source']; |
|
58
|
|
|
$this->statement_descriptor = $data['attributes']['statement_descriptor']; |
|
59
|
|
|
$this->status = $data['attributes']['status']; |
|
60
|
|
|
$this->created_at = $data['attributes']['created_at']; |
|
61
|
|
|
$this->paid_at = $data['attributes']['paid_at']; |
|
62
|
|
|
$this->updated_at = $data['attributes']['updated_at']; |
|
63
|
|
|
|
|
64
|
|
|
$this->data = [ |
|
65
|
|
|
'id' => $this->id, |
|
66
|
|
|
'type' => $this->type, |
|
67
|
|
|
'amount' => $this->amount, |
|
68
|
|
|
'billing_address' => $this->billing_address, |
|
69
|
|
|
'billing_email' => $this->billing_email, |
|
70
|
|
|
'billing_name' => $this->billing_name, |
|
71
|
|
|
'billing_phone_number' => $this->billing_phone_number, |
|
72
|
|
|
'currency' => $this->currency, |
|
73
|
|
|
'description' => $this->description, |
|
74
|
|
|
'fee' => $this->fee, |
|
75
|
|
|
'livemode' => $this->livemode, |
|
76
|
|
|
'net_amount' => $this->net_amount, |
|
77
|
|
|
'payout' => $this->payout, |
|
78
|
|
|
'source' => $this->source, |
|
79
|
|
|
'statement_descriptor' => $this->statement_descriptor, |
|
80
|
|
|
'status' => $this->status, |
|
81
|
|
|
'created_at' => $this->created_at, |
|
82
|
|
|
'paid_at' => $this->paid_at, |
|
83
|
|
|
'updated_at' => $this->updated_at, |
|
84
|
|
|
]; |
|
85
|
|
|
|
|
86
|
|
|
return $this; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
public function getId() |
|
90
|
|
|
{ |
|
91
|
|
|
return $this->id; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
public function getType() |
|
95
|
|
|
{ |
|
96
|
|
|
return $this->type; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
public function getAmount() |
|
100
|
|
|
{ |
|
101
|
|
|
return $this->amount; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
public function getBillingAddress() |
|
105
|
|
|
{ |
|
106
|
|
|
return $this->billing_address; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
public function getBillingEmail() |
|
110
|
|
|
{ |
|
111
|
|
|
return $this->billing_email; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
public function getBillingName() |
|
115
|
|
|
{ |
|
116
|
|
|
return $this->billing_name; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
public function getBillingPhoneNumber() |
|
120
|
|
|
{ |
|
121
|
|
|
return $this->billing_phone_number; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
public function getCurrency() |
|
125
|
|
|
{ |
|
126
|
|
|
return $this->currency; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
public function getDescription() |
|
130
|
|
|
{ |
|
131
|
|
|
return $this->description; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
public function getFee() |
|
135
|
|
|
{ |
|
136
|
|
|
return $this->fee; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
public function getLivemode() |
|
140
|
|
|
{ |
|
141
|
|
|
return $this->livemode; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
public function getNetAmount() |
|
145
|
|
|
{ |
|
146
|
|
|
return $this->net_amount; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
public function getPayout() |
|
150
|
|
|
{ |
|
151
|
|
|
return $this->payout; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
public function getSource() |
|
155
|
|
|
{ |
|
156
|
|
|
return $this->source; |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
public function getStatementDescriptor() |
|
160
|
|
|
{ |
|
161
|
|
|
return $this->statement_descriptor; |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
public function getStatus() |
|
165
|
|
|
{ |
|
166
|
|
|
return $this->status; |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
public function getCreatedAt() |
|
170
|
|
|
{ |
|
171
|
|
|
return $this->created_at; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
public function getPaidAt() |
|
175
|
|
|
{ |
|
176
|
|
|
return $this->paid_at; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
public function getUpdatedAt() |
|
180
|
|
|
{ |
|
181
|
|
|
return $this->updated_at; |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
public function getData() |
|
185
|
|
|
{ |
|
186
|
|
|
return $this->data; |
|
187
|
|
|
} |
|
188
|
|
|
} |
|
189
|
|
|
|