Back to Practice

Practice · Payments · Card 5

A user returns one of three items. Where does the data go?

The order was $150. The refund is $50. The order isn't "refunded" but it's not "paid in full" either. How should the schema represent that?

The setup

Existing schema:

class Order < ApplicationRecord
  has_one :payment

  enum status: { pending: 0, paid: 1, refunded: 2 }
end

class Payment < ApplicationRecord
  belongs_to :order
  enum status: { pending: 0, succeeded: 3, refunded: 7 }
end

# A user paid $150. They return one $50 item. You need to refund $50.

The question

Where should the partial refund live, and how should "how much was refunded so far?" be answered?

Take a moment. Pick the best answer. Wrong picks reveal why they're wrong, which is half the point.