From 5634990a6c0e5952f65e6c435f546314347acaac Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <77892330+PritishBudhiraja@users.noreply.github.com> Date: Wed, 13 Dec 2023 14:33:26 +0530 Subject: [PATCH] feat: Refund enable for Partially Captured Payments (#94) --- src/screens/HyperSwitch/Order/HSwitchOrderUtils.res | 2 ++ src/screens/HyperSwitch/Order/OrderEntity.res | 11 ++++++++--- src/screens/HyperSwitch/Order/ShowOrder.res | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/screens/HyperSwitch/Order/HSwitchOrderUtils.res b/src/screens/HyperSwitch/Order/HSwitchOrderUtils.res index 7d4194246..7b3c1294e 100644 --- a/src/screens/HyperSwitch/Order/HSwitchOrderUtils.res +++ b/src/screens/HyperSwitch/Order/HSwitchOrderUtils.res @@ -6,6 +6,7 @@ type status = | RequiresCustomerAction | RequiresPaymentMethod | RequiresConfirmation + | PartiallyCaptured | None type paymentAttemptStatus = [ @@ -44,6 +45,7 @@ let statusVariantMapper: string => status = statusLabel => | "REQUIRES_CUSTOMER_ACTION" => RequiresCustomerAction | "REQUIRES_PAYMENT_METHOD" => RequiresPaymentMethod | "REQUIRES_CONFIRMATION" => RequiresConfirmation + | "PARTIALLY_CAPTURED" => PartiallyCaptured | _ => None } diff --git a/src/screens/HyperSwitch/Order/OrderEntity.res b/src/screens/HyperSwitch/Order/OrderEntity.res index 8b8b24e33..348fe61a9 100644 --- a/src/screens/HyperSwitch/Order/OrderEntity.res +++ b/src/screens/HyperSwitch/Order/OrderEntity.res @@ -53,7 +53,9 @@ let getRefundCell = (refunds: refunds, refundsColType: refundsColType): Table.ce Label({ title: refunds.status->Js.String2.toUpperCase, color: switch refunds.status->HSwitchOrderUtils.statusVariantMapper { - | Succeeded => LabelGreen + | Succeeded + | PartiallyCaptured => + LabelGreen | Failed => LabelRed | Processing => LabelOrange | Cancelled => LabelRed @@ -488,7 +490,8 @@ let getStatus = order => { let orderStatusLabel = order.status->Js.String2.toUpperCase let fixedStatusCss = "text-sm text-white font-bold px-3 py-2 rounded-md" switch order.status->HSwitchOrderUtils.statusVariantMapper { - | Succeeded => + | Succeeded + | PartiallyCaptured =>
{orderStatusLabel->React.string}
@@ -706,7 +709,9 @@ let getCell = (order, colType: colType): Table.cell => { Label({ title: order.status->Js.String2.toUpperCase, color: switch orderStatus { - | Succeeded => LabelGreen + | Succeeded + | PartiallyCaptured => + LabelGreen | Failed | Cancelled => LabelRed diff --git a/src/screens/HyperSwitch/Order/ShowOrder.res b/src/screens/HyperSwitch/Order/ShowOrder.res index 444ea6366..a159f346f 100644 --- a/src/screens/HyperSwitch/Order/ShowOrder.res +++ b/src/screens/HyperSwitch/Order/ShowOrder.res @@ -25,6 +25,7 @@ module OrderInfo = { ~paymentId, ) => { let hyperswitchMixPanel = HSMixPanel.useSendEvent() + let typedPaymentStatus = paymentStatus->statusVariantMapper
@@ -46,7 +47,7 @@ module OrderInfo = { }} buttonType={Secondary} buttonState={!isNonRefundConnector && - paymentStatus->statusVariantMapper === Succeeded && + (typedPaymentStatus === Succeeded || typedPaymentStatus === PartiallyCaptured) && !(paymentId->isTestPayment) ? Normal : Disabled}