Skip to content

Instantly share code, notes, and snippets.

@thinkphp
Last active September 8, 2025 16:04
Show Gist options
  • Select an option

  • Save thinkphp/9ac3ed7b683bf1ffb65235b6fe66a6b8 to your computer and use it in GitHub Desktop.

Select an option

Save thinkphp/9ac3ed7b683bf1ffb65235b6fe66a6b8 to your computer and use it in GitHub Desktop.
refund.md

Refund Workflow for Roger Art Gallery

1. Client request

The client calls and says:

"I ordered 5 paintings, I want to return 3."

2. Identify the order

  • Ask for the order number (order_id) or the email address used for the purchase.
  • In the DB, find the order using order_id or email.
  • Identify the returned products.

3. Check purchased items

  • Go to the order_items table → see which paintings were purchased.
  • Manually mark the returned ones in the admin panel.

4. Calculate refund amount

  • Add up the prices of the paintings marked as returned.
  • This total is the amount to be refunded.

5. Process refund in Stripe

  • Run the PHP script with:
    • payment_intent_id saved in the DB
    • amount to refund
  • Stripe sends the corresponding amount back to the client’s card.

6. Update the database

  • In order_items, set refunded = 1 for the returned paintings.
  • Update the order status to partial_refund.
// 1. Client request 
// 2. Identify order
$order = findOrderByEmailOrId($emailOrId);


$orderItems = getOrderItems($order['id']);


$selectedItems = [45, 67]; // Admin selecteaza
$refundAmount = calculateRefundAmount($selectedItems);


$result = $refund->partialRefund($order['id'], $refundAmount, $selectedItems);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment