File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 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;
3636$stripeCharge = new StripeCharge();
3737
3838$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');
3949```
Original file line number Diff line number Diff line change @@ -206,4 +206,22 @@ public function lists()
206206 return (object ) ['isError ' => 'true ' , 'message ' => $ e ->getMessage (), 'stripe ' => $ e ->getJsonBody ()['error ' ]];
207207 }
208208 }
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+ }
209227}
You can’t perform that action at this time.
0 commit comments