diff --git a/src/Lib/StripeCheckout.php b/src/Lib/StripeCheckout.php index 2898c81..0e1f51e 100644 --- a/src/Lib/StripeCheckout.php +++ b/src/Lib/StripeCheckout.php @@ -202,14 +202,18 @@ public function retrieve($sessionToken) * @param string $payment_intent get from database * @return object */ - public function refund($payment_intent) + public function refund($payment_intent, $amount = '') { - try { - $paymentIntents = $this->stripe->paymentIntents->retrieve($payment_intent); + $RefundData = [ + 'payment_intent' => $payment_intent, + ]; + + if ($amount != '') { + $RefundData['amount'] = $amount * 100; + } - $refund = $this->stripe->refunds->create([ - 'charge' => $paymentIntents->charges->data[0]->id, - ]); + try { + $refund = $this->stripe->refunds->create($RefundData); return $refund; } catch (\Exception $e) {