Skip to content

Commit

Permalink
checkout refund
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa6765 committed Aug 9, 2023
1 parent aadff2b commit 943c37c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/Lib/StripeCheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 943c37c

Please sign in to comment.