Skip to content

Commit 943c37c

Browse files
committed
checkout refund
1 parent aadff2b commit 943c37c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/Lib/StripeCheckout.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,18 @@ public function retrieve($sessionToken)
202202
* @param string $payment_intent get from database
203203
* @return object
204204
*/
205-
public function refund($payment_intent)
205+
public function refund($payment_intent, $amount = '')
206206
{
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+
}
209214

210-
$refund = $this->stripe->refunds->create([
211-
'charge' => $paymentIntents->charges->data[0]->id,
212-
]);
215+
try {
216+
$refund = $this->stripe->refunds->create($RefundData);
213217

214218
return $refund;
215219
} catch (\Exception $e) {

0 commit comments

Comments
 (0)