Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,25 @@ public virtual async Task ProcessRefundChangesAsync(RefundChangedJobArgument[] j
{ "IsUpdate", "true" },
};

var previousStatus = refund.Status;
Comment thread
OlegoO marked this conversation as resolved.
try
{
var result = await payment.PaymentMethod.RefundProcessPaymentAsync(refundRequest);
if (result.IsSuccess)
{
refund.Status = result.NewRefundStatus.ToString();
if (!string.IsNullOrEmpty(result.OuterId))
{
refund.OuterId = result.OuterId;
}
refund.RejectReasonMessage = null;
Comment thread
cursor[bot] marked this conversation as resolved.
}
else
{
refund.Status = nameof(RefundStatus.Rejected);
// A failed modification must not invalidate the underlying refund state.
// NewRefundStatus is non-nullable and defaults to Pending, so we cannot distinguish
// "provider didn't set it" from "provider explicitly reports Pending" -- preserve prior state.
refund.Status = previousStatus;
refund.RejectReasonMessage = result.ErrorMessage;
}

Expand Down Expand Up @@ -166,10 +175,14 @@ protected virtual RefundChangedJobArgument[] GetJobArgumentsForChangedEntry(Gene

protected virtual bool HasRefundFieldChanges(Refund oldRefund, Refund newRefund)
{
// Status and OuterId are intentionally NOT tracked here: both are written by the provider response
// (via PaymentFlowService.SaveResultToRefundDocument or this handler), so tracking them would
// re-trigger the handler from its own SaveChangesAsync and cause duplicate provider calls.
// Manual status edits on submitted refunds are blocked at the UI.
return oldRefund.Amount != newRefund.Amount
|| oldRefund.ReasonCode != newRefund.ReasonCode
|| oldRefund.ReasonMessage != newRefund.ReasonMessage
|| oldRefund.OuterId != newRefund.OuterId;
|| oldRefund.IsCancelled != newRefund.IsCancelled;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ protected virtual async Task<RefundOrderPaymentResult> SaveResultToRefundDocumen
if (refundResult.IsSuccess)
{
refund.Status = refundResult.NewRefundStatus.ToString();
if (!string.IsNullOrEmpty(refundResult.OuterId))
{
refund.OuterId = refundResult.OuterId;
}
Comment thread
OlegoO marked this conversation as resolved.
result.RefundStatus = refund.Status;
result.Succeeded = true;
}
Expand Down Expand Up @@ -343,6 +347,10 @@ public virtual async Task<CaptureOrderPaymentResult> SaveResultToCaptureDocument
if (captureResult.IsSuccess)
{
capture.Status = nameof(CaptureStatus.Processed);
if (!string.IsNullOrEmpty(captureResult.OuterId))
{
capture.OuterId = captureResult.OuterId;
}
paymentInfo.Payment.Status = captureResult.NewPaymentStatus.ToString();
result.PaymentStatus = paymentInfo.Payment.Status;
result.Succeeded = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@ angular.module('virtoCommerce.orderModule')
|| blade.currentEntity.cancelledState === 'Completed'
|| blade.currentEntity.cancelledState === 'Requested');
break;
case 'Refund':
result = !blade.currentEntity.isCancelled
&& blade.currentEntity.status !== 'Processed'
&& !blade.currentEntity.outerId;
break;
default:
result = !blade.currentEntity.isCancelled;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
placeholder="'orders.blades.refund-details.placeholders.status' | translate"
setting="'Refund.Status'"
ng-model="blade.currentEntity.status"
disabled="blade.isLocked"></va-setting-value-select>
disabled="blade.isLocked || blade.currentEntity.outerId || blade.currentEntity.status === 'Processed'"></va-setting-value-select>
</div>
<div class="form-group">
<label class="form-label">{{ 'orders.blades.refund-details.labels.amount' | translate }}</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="8.0.1">
<PackageReference Include="coverlet.collector" Version="10.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Loading