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