Skip to content

Commit

Permalink
Added errors processing for payment generation call
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Nesterov committed Apr 29, 2020
1 parent ec14471 commit 5d4be4e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ public enum ProcessingVoucherErrorCodes
NoAvailableVouchers,
/// <summary>Voucher not found</summary>
VoucherNotFound,
/// <summary>Invalid partner payment configuration</summary>
InvalidPartnerPaymentConfiguration,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ public enum ProcessingVoucherError
VoucherCampaignNotActive,
NoAvailableVouchers,
VoucherNotFound,
InvalidPartnerPaymentConfiguration,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ItemGroup>
<PackageReference Include="AutoMapper" Version="9.0.0" />
<PackageReference Include="Lykke.RabbitMqBroker" Version="7.13.1" />
<PackageReference Include="MAVN.Service.PaymentManagement.Client" Version="1.9.0" />
<PackageReference Include="MAVN.Service.PaymentManagement.Client" Version="1.10.1" />
<PackageReference Include="StackExchange.Redis" Version="2.1.30" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Lykke.Common.Log;
using MAVN.Service.PaymentManagement.Client;
using MAVN.Service.PaymentManagement.Client.Models.Requests;
using MAVN.Service.PaymentManagement.Client.Models.Responses;
using MAVN.Service.SmartVouchers.Domain.Enums;
using MAVN.Service.SmartVouchers.Domain.Models;
using MAVN.Service.SmartVouchers.Domain.Repositories;
Expand Down Expand Up @@ -136,6 +137,14 @@ public async Task<VoucherReservationResult> ReserveVoucherAsync(Guid voucherCamp
Currency = campaign.Currency,
PartnerId = campaign.PartnerId,
});
if (paymentRequestResult.ErrorCode != PaymentGenerationErrorCode.Success)
{
await CancelReservationAsync(voucher.ShortCode);
return new VoucherReservationResult
{
ErrorCode = ProcessingVoucherError.InvalidPartnerPaymentConfiguration,
};
}

await _paymentRequestsRepository.CreatePaymentRequestAsync(paymentRequestResult.PaymentRequestId, voucher.ShortCode);

Expand Down

0 comments on commit 5d4be4e

Please sign in to comment.