internal static IPaymentMethod ToPaymentMethod(this PaymentMethodDisplay paymentMethodDisplay, IPaymentMethod destination) { if (paymentMethodDisplay.Key != Guid.Empty) { destination.Key = paymentMethodDisplay.Key; } destination.Name = paymentMethodDisplay.Name; destination.PaymentCode = paymentMethodDisplay.PaymentCode; destination.Description = paymentMethodDisplay.Description; return(destination); }
public HttpResponseMessage AddPaymentMethod(PaymentMethodDisplay method) { var response = Request.CreateResponse(HttpStatusCode.OK); try { var provider = _paymentContext.ResolveByKey(method.ProviderKey); var paymentGatewayMethod = provider.CreatePaymentMethod(method.Name, method.Description); provider.SavePaymentMethod(paymentGatewayMethod); } catch (Exception ex) { response = Request.CreateResponse(HttpStatusCode.InternalServerError, String.Format("{0}", ex.Message)); } return response; }
public HttpResponseMessage AddPaymentMethod(PaymentMethodDisplay method) { var response = Request.CreateResponse(HttpStatusCode.OK); try { var provider = _paymentContext.CreateInstance(method.ProviderKey); var gatewayResource = provider.ListResourcesOffered().FirstOrDefault(x => x.ServiceCode == method.PaymentCode); var paymentGatewayMethod = provider.CreatePaymentMethod(gatewayResource, method.Name, method.Description); provider.SavePaymentMethod(paymentGatewayMethod); } catch (Exception ex) { response = Request.CreateResponse(HttpStatusCode.InternalServerError, String.Format("{0}", ex.Message)); } return response; }
public HttpResponseMessage PutPaymentMethod(PaymentMethodDisplay method) { var response = Request.CreateResponse(HttpStatusCode.OK); try { var provider = _paymentContext.ResolveByKey(method.ProviderKey); var paymentMethod = provider.PaymentMethods.FirstOrDefault(x => x.Key == method.Key); paymentMethod = method.ToPaymentMethod(paymentMethod); provider.GatewayProviderService.Save(paymentMethod); } catch (Exception ex) { response = Request.CreateResponse(HttpStatusCode.InternalServerError, String.Format("{0}", ex.Message)); } return response; }