Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Refund enable for Partially Captured Payments #94

Merged
merged 3 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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