fix: proper DeliveryStatus mapping + cancel delivery on failed payment
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m22s
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 8m22s
- Added MapDeliveryStatus() to correctly map Domain→Proto enum values - Domain Pending(1) was incorrectly cast to Proto PROCESSING(1) instead of PROCESSING - Set DeliveryStatus=Cancelled when payment fails (CompleteOrderPaymentCommandHandler) - Set DeliveryStatus=Cancelled when order expires (ExpirePendingOrdersService)
This commit is contained in:
@@ -93,7 +93,7 @@ public class DiscountOrderService : DiscountOrderContract.DiscountOrderContractB
|
||||
GatewayAmount = result.GatewayAmountPaid,
|
||||
PaymentCompleted = result.PaymentStatus == DomainEnums.PaymentStatus.Success,
|
||||
PaymentStatus = MapPaymentStatus(result.PaymentStatus),
|
||||
DeliveryStatus = (DeliveryStatus)(int)result.DeliveryStatus,
|
||||
DeliveryStatus = MapDeliveryStatus(result.DeliveryStatus),
|
||||
Created = Timestamp.FromDateTime(DateTime.SpecifyKind(result.Created, DateTimeKind.Utc)),
|
||||
};
|
||||
|
||||
@@ -153,7 +153,7 @@ public class DiscountOrderService : DiscountOrderContract.DiscountOrderContractB
|
||||
GatewayAmount = o.GatewayAmountPaid,
|
||||
PaymentCompleted = o.PaymentStatus == DomainEnums.PaymentStatus.Success,
|
||||
PaymentStatus = MapPaymentStatus(o.PaymentStatus),
|
||||
DeliveryStatus = (DeliveryStatus)(int)o.DeliveryStatus,
|
||||
DeliveryStatus = MapDeliveryStatus(o.DeliveryStatus),
|
||||
ItemsCount = o.ItemsCount,
|
||||
Created = Timestamp.FromDateTime(DateTime.SpecifyKind(o.Created, DateTimeKind.Utc)),
|
||||
};
|
||||
@@ -181,4 +181,15 @@ public class DiscountOrderService : DiscountOrderContract.DiscountOrderContractB
|
||||
DomainEnums.PaymentStatus.Pending => CMSMicroservice.Protobuf.Protos.DiscountOrder.PaymentStatus.PaymentPending,
|
||||
_ => CMSMicroservice.Protobuf.Protos.DiscountOrder.PaymentStatus.PaymentPending
|
||||
};
|
||||
|
||||
private static DeliveryStatus MapDeliveryStatus(DomainEnums.DeliveryStatus status) => status switch
|
||||
{
|
||||
DomainEnums.DeliveryStatus.None => DeliveryStatus.DeliveryPending,
|
||||
DomainEnums.DeliveryStatus.Pending => DeliveryStatus.DeliveryProcessing,
|
||||
DomainEnums.DeliveryStatus.InTransit => DeliveryStatus.DeliveryShipped,
|
||||
DomainEnums.DeliveryStatus.Delivered => DeliveryStatus.DeliveryDelivered,
|
||||
DomainEnums.DeliveryStatus.Returned => DeliveryStatus.DeliveryCancelled,
|
||||
DomainEnums.DeliveryStatus.Cancelled => DeliveryStatus.DeliveryCancelled,
|
||||
_ => DeliveryStatus.DeliveryPending
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user