Skip to content

Commit

Permalink
Merge pull request #13 from Ali-YousefiTelori/develop
Browse files Browse the repository at this point in the history
fix some service dependency
  • Loading branch information
Ali-YousefiTelori authored Oct 5, 2023
2 parents 904b17b + 8156d79 commit 0f0df89
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ public IConfiguration GetConfiguration()

public async Task<MessageContract<IPaymentProvider>> GetPayment()
{
var serviceId = await GetReadableOf<ServiceEntity>().Select(x => x.Id).FirstOrDefaultAsync();
return await GetPayment(serviceId);
var service = await GetReadableOf<ServiceEntity>().FirstOrDefaultAsync();
return await GetPayment((service?.Id).GetValueOrDefault());
}

public async Task<MessageContract<IPaymentProvider>> GetPayment(long serviceId)
{
var service = await GetReadableOf<ServiceEntity>().Include(x => x.Addresses).FirstOrDefaultAsync(x => x.Id == serviceId);
service.Validate();
Console.WriteLine($"{serviceId} {service == null}");
var validate = service.Validate();
if (!validate)
return validate.ToContract<IPaymentProvider>();
var address = service.Addresses.First();
return new StripeProvider(address.ApiKey, new StripeClient(address.ApiKey, apiBase: address.Address));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using EasyMicroservices.PaymentsMicroservice.Database.Entities;
using EasyMicroservices.ServiceContracts;
using Microsoft.IdentityModel.Tokens;
using System.Linq;
using System.Text;

namespace EasyMicroservices.PaymentsMicroservice.Validations
Expand All @@ -11,7 +12,7 @@ public static MessageContract Validate(this ServiceEntity service)
{
if (service == null)
return (FailedReasonType.NotFound, "No service provider found in ServiceEntity, Please add your service provider!");
else if (service.Addresses.IsNullOrEmpty())
else if (service.Addresses.IsEmpty())
return (FailedReasonType.Empty, $"No address found for service provider Id: {service.Id}");
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ await queryable.AddAsync(new ServiceEntity()
new ServiceAddressEntity()
{
//ApiKey = "your live session",
//Address = StripeClient.DefaultApiBase
//Address = Stripe.StripeClient.DefaultApiBase
ApiKey = "testapikey",
Address = $"http://localhost:{PaymentComponentPort}"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public async Task<MessageContract<CreateOrderResponseContract>> CreateOrderPorta
{
var orderContractLogic = _unitOfWork.GetLongContractLogic<OrderEntity, CreateOrderRequestContract, UpdateOrderRequestContract, OrderContract>();
var orderLogic = _unitOfWork.GetLogic<OrderEntity, long>();
request.ServiceId = 1;
var addedOrderId = await orderContractLogic.Add(request, cancellationToken).AsCheckedResult();
await OrderLogic.AddAndUpdateOrderStatus(addedOrderId, Payments.DataTypes.PaymentStatusType.Created, _unitOfWork);
var paymentOrderResponse = await OrderLogic.CreateOrder(request, _unitOfWork);
Expand Down

0 comments on commit 0f0df89

Please sign in to comment.