Skip to content

Commit

Permalink
Properly handle Stripe refunds
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdenio committed Mar 21, 2024
1 parent 070256a commit 2223f15
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/components/transaction/types/CardChargeTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export default function CardChargeTransaction({
const navigation =
useNavigation<NativeStackNavigationProp<StackParamList, "Transaction">>();

const isRefund = transaction.amount_cents > 0;

const badge = transaction.pending ? (
<Badge icon="information-circle-outline" color={palette.info}>
Pending
Expand All @@ -39,7 +41,7 @@ export default function CardChargeTransaction({
<View style={{ flexDirection: "column", alignItems: "center" }}>
<TransactionTitle badge={badge}>
{renderMoney(Math.abs(transaction.amount_cents))}{" "}
<Muted>charge at</Muted>
<Muted>{isRefund ? "refund from" : "charge at"}</Muted>
{"\n"}
{merchant.smart_name}
</TransactionTitle>
Expand All @@ -51,9 +53,12 @@ export default function CardChargeTransaction({
value: merchant.name,
},
descriptionDetail(orgId, transaction, navigation),
{ label: "Spent on", value: renderDate(transaction.date) },
{
label: "Spent by",
label: isRefund ? "Refunded on" : "Spent on",
value: renderDate(transaction.date),
},
{
label: isRefund ? "Refunded to" : "Spent by",
value: <UserMention user={card_charge.card.user} />,
},
]}
Expand Down

0 comments on commit 2223f15

Please sign in to comment.