This is my interface
public partial interface IPaymentMethod
{
void ProcessPayment(PaymentInfo paymentInfo, Customer customer,
Guid orderGuid, ref ProcessPaymentResult processPaymentResult);
void Capture(Order order, ref ProcessPaymentResult processPaymentResult);
void Refund(Order order, ref CancelPaymentResult cancelPaymentResult);
}
I want to implement this interface in PaypalPaymentProcessor.cs and AuthorizeNet.cs
public class PayPalExpressPaymentProcessor : IPaymentMethod
{
public void ProcessPayment(PaymentInfo paymentInfo, Customer customer, Guid orderGuid, ref ProcessPaymentResult processPaymentResult)
{
//Some code
}
void Capture(Order order, ref ProcessPaymentResult processPaymentResult)
{
// Some Code
}
void Refund(Order order, ref CancelPaymentResult cancelPaymentResult)
{
// Some Code
}
}
// Same For AuthorizNetPaymentProcessor class. Both this classes used for payment gateway. But i am confused do i put above interface and classes in App Service. Because both of this classes are not fit to be part of domain and not in domain service.
Is it ok to put them in App Service and create PaymentService class in application service from where i will call them. Can i do these?
Your question description is very brief but I will try to answer. Is your question where you want to put your gateway/Wrapper class that uses a payment web services, right?
If the scenario is that you have a Payment web service that you want to use in your application and to be more specific, in your application service layer. Then the approach should be to put your payment webservice gateway/wrapper in infrastructure layer (in another assembly/project) and using depencey injection for inserting the gateway in constructor. I’m not sure where PayPalExpressPaymentProcessor comes in the picture. But I guess thats the gateway class that talks to the payment service.
So you maybe have a CustomerService in your application layer that will get the IPaymentService (Gateway/wrapper) in constructor (Depency injection) and call IPaymentService.ProcessPayment(…) method. This service method is actually implemented in
infrastructure layer. Then your application service CustomerService also can call domain through ICustomerRepository which is also initiated through constructor (DI).
Maybe this is not your problem scenario? Hope I was able to help you…