Skip to content

Commit

Permalink
feat: Refund enable for Partially Captured Payments (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
PritishBudhiraja authored Dec 13, 2023
1 parent 0e4b76f commit 5634990
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/screens/HyperSwitch/Order/HSwitchOrderUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type status =
| RequiresCustomerAction
| RequiresPaymentMethod
| RequiresConfirmation
| PartiallyCaptured
| None

type paymentAttemptStatus = [
Expand Down Expand Up @@ -44,6 +45,7 @@ let statusVariantMapper: string => status = statusLabel =>
| "REQUIRES_CUSTOMER_ACTION" => RequiresCustomerAction
| "REQUIRES_PAYMENT_METHOD" => RequiresPaymentMethod
| "REQUIRES_CONFIRMATION" => RequiresConfirmation
| "PARTIALLY_CAPTURED" => PartiallyCaptured
| _ => None
}

Expand Down
11 changes: 8 additions & 3 deletions src/screens/HyperSwitch/Order/OrderEntity.res
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 =>
<div className={`${fixedStatusCss} bg-hyperswitch_green dark:bg-opacity-50`}>
{orderStatusLabel->React.string}
</div>
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/screens/HyperSwitch/Order/ShowOrder.res
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module OrderInfo = {
~paymentId,
) => {
let hyperswitchMixPanel = HSMixPanel.useSendEvent()
let typedPaymentStatus = paymentStatus->statusVariantMapper
<Section
customCssClass={`border border-jp-gray-940 border-opacity-75 dark:border-jp-gray-960 ${bgColor} rounded-md p-5 h-full`}>
<UIUtils.RenderIf condition=isButtonEnabled>
Expand All @@ -46,7 +47,7 @@ module OrderInfo = {
}}
buttonType={Secondary}
buttonState={!isNonRefundConnector &&
paymentStatus->statusVariantMapper === Succeeded &&
(typedPaymentStatus === Succeeded || typedPaymentStatus === PartiallyCaptured) &&
!(paymentId->isTestPayment)
? Normal
: Disabled}
Expand Down

0 comments on commit 5634990

Please sign in to comment.