Browse Source

Add a simple zero price rule to DemoPaymentMethod

pull/63/head
enisn 5 years ago
parent
commit
a19196a6ad
  1. 6
      services/payment/src/EShopOnAbp.PaymentService.Application/PaymentMethods/DemoPaymentMethod.cs

6
services/payment/src/EShopOnAbp.PaymentService.Application/PaymentMethods/DemoPaymentMethod.cs

@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using EShopOnAbp.PaymentService.PaymentRequests;
using Volo.Abp.DependencyInjection;
@ -15,6 +16,11 @@ public class DemoPaymentMethod : IPaymentMethod
public Task<PaymentRequestStartResultDto> StartAsync(PaymentRequest paymentRequest, PaymentRequestStartDto input)
{
if (paymentRequest.Products.Sum(x => x.TotalPrice) <= 0)
{
throw new ArgumentException("Price can't be zero or less.");
}
return Task.FromResult(new PaymentRequestStartResultDto
{
CheckoutLink = input.ReturnUrl + "?token=" + input.PaymentRequestId

Loading…
Cancel
Save