1 | <?php namespace Arcanedev\Stripe\Resources; |
||
45 | class Charge extends StripeResource implements ChargeContract |
||
46 | { |
||
47 | /* ----------------------------------------------------------------- |
||
48 | | Constants |
||
49 | | ----------------------------------------------------------------- |
||
50 | */ |
||
51 | |||
52 | const SAFE = 'safe'; |
||
53 | const FRAUDULENT = 'fraudulent'; |
||
54 | |||
55 | /* ----------------------------------------------------------------- |
||
56 | | Main Methods |
||
57 | | ----------------------------------------------------------------- |
||
58 | */ |
||
59 | |||
60 | /** |
||
61 | * List all Charges. |
||
62 | * @link https://stripe.com/docs/api/php#list_charges |
||
63 | * |
||
64 | * @param array|null $params |
||
65 | * @param array|string|null $options |
||
66 | * |
||
67 | * @return \Arcanedev\Stripe\Collection|array |
||
68 | */ |
||
69 | 4 | public static function all($params = [], $options = null) |
|
73 | |||
74 | /** |
||
75 | * Retrieve a Charge. |
||
76 | * @link https://stripe.com/docs/api/php#retrieve_charge |
||
77 | * |
||
78 | * @param string $id |
||
79 | * @param array|string|null $options |
||
80 | * |
||
81 | * @return self |
||
82 | */ |
||
83 | 20 | public static function retrieve($id, $options = null) |
|
87 | |||
88 | /** |
||
89 | * Create a new charge (charging a credit card). |
||
90 | * @link https://stripe.com/docs/api/php#create_charge |
||
91 | * |
||
92 | * @param array $params |
||
93 | * @param array|string|null $options |
||
94 | * |
||
95 | * @return self|array |
||
96 | */ |
||
97 | 62 | public static function create($params = [], $options = null) |
|
101 | |||
102 | /** |
||
103 | * Save/Update a Charge. |
||
104 | * @link https://stripe.com/docs/api/php#update_charge |
||
105 | * |
||
106 | * @param array|string|null $options |
||
107 | * |
||
108 | * @return self |
||
109 | */ |
||
110 | 4 | public function save($options = null) |
|
111 | { |
||
112 | 4 | return self::scopedSave($options); |
|
113 | } |
||
114 | |||
115 | /** |
||
116 | * Update a Charge. |
||
117 | * @link https://stripe.com/docs/api/php#update_charge |
||
118 | * |
||
119 | * @param string $id |
||
120 | * @param array|null $params |
||
121 | * @param array|string|null $options |
||
122 | * |
||
123 | * @return self |
||
124 | */ |
||
125 | 2 | public static function update($id, $params = [], $options = null) |
|
129 | |||
130 | /** |
||
131 | * Creating a new refund. |
||
132 | * @link https://stripe.com/docs/api/php#create_refund |
||
133 | * |
||
134 | * @param array|null $params |
||
135 | * @param array|string|null $options |
||
136 | * |
||
137 | * @return self |
||
138 | */ |
||
139 | 4 | public function refund($params = [], $options = null) |
|
140 | { |
||
141 | 4 | return self::scopedPostCall( |
|
142 | 4 | $this->instanceUrl().'/refund', $params, $options |
|
143 | ); |
||
144 | } |
||
145 | |||
146 | /** |
||
147 | * Capture a charge. |
||
148 | * @link https://stripe.com/docs/api/php#capture_charge |
||
149 | * |
||
150 | * @param array|null $params |
||
151 | * @param array|string|null $options |
||
152 | * |
||
153 | * @return self |
||
154 | */ |
||
155 | 2 | public function capture($params = [], $options = null) |
|
156 | { |
||
157 | 2 | return self::scopedPostCall( |
|
158 | 2 | $this->instanceUrl().'/capture', $params, $options |
|
159 | ); |
||
160 | } |
||
161 | |||
162 | /** |
||
163 | * Mark charge as Fraudulent. |
||
164 | * @param array|string|null $options |
||
165 | * |
||
166 | * @return self |
||
167 | */ |
||
168 | 2 | public function markAsFraudulent($options = null) |
|
172 | |||
173 | /** |
||
174 | * Mark charge as Safe. |
||
175 | * @param array|string|null $options |
||
176 | * |
||
177 | * @return self |
||
178 | */ |
||
179 | 2 | public function markAsSafe($options = null) |
|
183 | |||
184 | /* ----------------------------------------------------------------- |
||
185 | | Other Methods |
||
186 | | ----------------------------------------------------------------- |
||
187 | */ |
||
188 | |||
189 | /** |
||
190 | * Update charge's fraud details. |
||
191 | * |
||
192 | * @param bool $safe |
||
193 | * @param array|string|null $options |
||
194 | * |
||
195 | * @return self |
||
196 | */ |
||
197 | 4 | private function updateFraudDetails($safe = false, $options = null) |
|
205 | } |
||
206 |