1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Luigel\Paymongo\Models; |
4
|
|
|
|
5
|
|
|
use Luigel\Paymongo\Paymongo; |
6
|
|
|
|
7
|
|
|
class PaymentIntent |
8
|
|
|
{ |
9
|
|
|
protected $data; |
10
|
|
|
protected $id; |
11
|
|
|
protected $type; |
12
|
|
|
protected $amount; |
13
|
|
|
protected $currency; |
14
|
|
|
protected $description; |
15
|
|
|
protected $statement_descriptor; |
16
|
|
|
protected $client_key; |
17
|
|
|
protected $last_payment_error; |
18
|
|
|
protected $payments; |
19
|
|
|
protected $next_action; |
20
|
|
|
protected $payment_method_options; |
21
|
|
|
protected $created_at; |
22
|
|
|
protected $updated_at; |
23
|
|
|
protected $metadata; |
24
|
|
|
protected $status; |
25
|
|
|
|
26
|
|
|
public function setData($data) |
27
|
|
|
{ |
28
|
|
|
$this->id = $data['id']; |
29
|
|
|
$this->type = $data['type']; |
30
|
|
|
$this->amount = $data['attributes']['amount']; |
31
|
|
|
$this->currency = $data['attributes']['currency']; |
32
|
|
|
$this->description = $data['attributes']['description']; |
33
|
|
|
$this->statement_descriptor = $data['attributes']['statement_descriptor']; |
34
|
|
|
$this->client_key = $data['attributes']['client_key']; |
35
|
|
|
$this->last_payment_error = $data['attributes']['last_payment_error']; |
36
|
|
|
$this->payments = $data['attributes']['payments']; |
37
|
|
|
$this->next_action = $data['attributes']['next_action']; |
38
|
|
|
$this->payment_method_options = $data['attributes']['payment_method_options']; |
39
|
|
|
$this->created_at = $data['attributes']['created_at']; |
40
|
|
|
$this->updated_at = $data['attributes']['updated_at']; |
41
|
|
|
$this->metadata = $data['attributes']['metadata']; |
42
|
|
|
$this->status = $data['attributes']['status']; |
43
|
|
|
|
44
|
|
|
$this->data = [ |
45
|
|
|
'id' => $this->id, |
46
|
|
|
'type' => $this->type, |
47
|
|
|
'amount' => $this->amount, |
48
|
|
|
'currency' => $this->currency, |
49
|
|
|
'description' => $this->amount, |
50
|
|
|
'statement_descriptor' => $this->statement_descriptor, |
51
|
|
|
'client_key' => $this->client_key, |
52
|
|
|
'last_payment_error' => $this->last_payment_error, |
53
|
|
|
'payments' => $this->payments, |
54
|
|
|
'next_action' => $this->next_action, |
55
|
|
|
'payment_method_options' => $this->payment_method_options, |
56
|
|
|
'created_at' => $this->created_at, |
57
|
|
|
'updated_at' => $this->updated_at, |
58
|
|
|
'metadata' => $this->metadata, |
59
|
|
|
'status' => $this->status, |
60
|
|
|
]; |
61
|
|
|
|
62
|
|
|
return $this; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function getData() |
66
|
|
|
{ |
67
|
|
|
return $this->data; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function getId() |
71
|
|
|
{ |
72
|
|
|
return $this->id; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function getType() |
76
|
|
|
{ |
77
|
|
|
return $this->type; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function getAmount() |
81
|
|
|
{ |
82
|
|
|
return $this->amount / 100; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function getCurrency() |
86
|
|
|
{ |
87
|
|
|
return $this->currency; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function getDescription() |
91
|
|
|
{ |
92
|
|
|
return $this->description; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function getStatementDescriptor() |
96
|
|
|
{ |
97
|
|
|
return $this->statement_descriptor; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function getClientKey() |
101
|
|
|
{ |
102
|
|
|
return $this->client_key; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function getLastPaymentError() |
106
|
|
|
{ |
107
|
|
|
return $this->last_payment_error; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function getPayments() |
111
|
|
|
{ |
112
|
|
|
return $this->payments; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function getNextAction() |
116
|
|
|
{ |
117
|
|
|
return $this->next_action; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function getPaymentMethodOptions() |
121
|
|
|
{ |
122
|
|
|
return $this->payment_method_options; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
public function getCreatedAt() |
126
|
|
|
{ |
127
|
|
|
return $this->created_at; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
public function getUpdatedDate() |
131
|
|
|
{ |
132
|
|
|
return $this->updated_at; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
public function getMetadata() |
136
|
|
|
{ |
137
|
|
|
return $this->metadata; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
public function getStatus() |
141
|
|
|
{ |
142
|
|
|
return $this->status; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
public function cancel() |
146
|
|
|
{ |
147
|
|
|
return (new Paymongo)->paymentIntent()->cancel($this); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
public function attach($paymentMethodId) |
151
|
|
|
{ |
152
|
|
|
return (new Paymongo)->paymentIntent()->attach($this, $paymentMethodId); |
153
|
|
|
} |
154
|
|
|
} |
155
|
|
|
|