File tree 2 files changed +28
-0
lines changed
2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -36,4 +36,14 @@ use Code4mk\LaraStripe\Lib\StripeCharge;
36
36
$stripeCharge = new StripeCharge();
37
37
38
38
$stripeCharge->lists();
39
+ ```
40
+
41
+ ### Refund Charge
42
+
43
+ ``` php
44
+ use Code4mk\LaraStripe\Lib\StripeCharge;
45
+
46
+ $stripeCharge = new StripeCharge();
47
+
48
+ $stripeCharge->refund('charge_id');
39
49
```
Original file line number Diff line number Diff line change @@ -206,4 +206,22 @@ public function lists()
206
206
return (object ) ['isError ' => 'true ' , 'message ' => $ e ->getMessage (), 'stripe ' => $ e ->getJsonBody ()['error ' ]];
207
207
}
208
208
}
209
+
210
+ public function refund ($ chargeId , $ amount = null )
211
+ {
212
+ $ refundData = [
213
+ 'charge ' => $ chargeId ,
214
+ ];
215
+
216
+ if ($ amount ) {
217
+ $ refundData ['amount ' ] = round ($ amount , 2 ) * 100 ;
218
+ }
219
+
220
+ try {
221
+ $ refund = $ this ->stripe ->refunds ->create ($ refundData );
222
+ return $ refund ;
223
+ } catch (\Exception $ e ) {
224
+ return (object ) ['isError ' => 'true ' , 'message ' => $ e ->getMessage (), 'stripe ' => $ e ->getJsonBody ()['error ' ]];
225
+ }
226
+ }
209
227
}
You can’t perform that action at this time.
0 commit comments