File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -202,14 +202,18 @@ public function retrieve($sessionToken)
202
202
* @param string $payment_intent get from database
203
203
* @return object
204
204
*/
205
- public function refund ($ payment_intent )
205
+ public function refund ($ payment_intent, $ amount = '' )
206
206
{
207
- try {
208
- $ paymentIntents = $ this ->stripe ->paymentIntents ->retrieve ($ payment_intent );
207
+ $ RefundData = [
208
+ 'payment_intent ' => $ payment_intent ,
209
+ ];
210
+
211
+ if ($ amount != '' ) {
212
+ $ RefundData ['amount ' ] = $ amount * 100 ;
213
+ }
209
214
210
- $ refund = $ this ->stripe ->refunds ->create ([
211
- 'charge ' => $ paymentIntents ->charges ->data [0 ]->id ,
212
- ]);
215
+ try {
216
+ $ refund = $ this ->stripe ->refunds ->create ($ RefundData );
213
217
214
218
return $ refund ;
215
219
} catch (\Exception $ e ) {
You can’t perform that action at this time.
0 commit comments