/// <summary> /// Initializes a new instance of the <see cref="PaymentProcessor"/> class. /// </summary> /// <param name="merchelloContext"> /// The merchello context. /// </param> /// <param name="request"> /// The request. /// </param> public PaymentProcessor(IMerchelloContext merchelloContext, PaymentRequest request) { Mandate.ParameterNotNull(merchelloContext, "merchelloContext"); _merchelloContext = merchelloContext; Build(request); }
public PaymentDisplay AuthorizeCapturePayment(PaymentRequest request) { var processor = new PaymentProcessor(MerchelloContext, request); var authorizeCapture = processor.AuthorizeCapture(); if(!authorizeCapture.Payment.Success) throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); return authorizeCapture.Payment.Result.ToPaymentDisplay(); }
private void Build(PaymentRequest request) { _invoice = _merchelloContext.Services.InvoiceService.GetByKey(request.InvoiceKey); if (request.PaymentKey != null) _payment = _merchelloContext.Services.PaymentService.GetByKey(request.PaymentKey.Value); _paymentGatewayMethod = _merchelloContext.Gateways.Payment.GetPaymentGatewayMethodByKey(request.PaymentMethodKey); _amount = request.Amount; foreach (var arg in request.ProcessorArgs) { _args.Add(arg.Key, arg.Value); } }
/// <summary> /// Returns a payment for an CapturePayment for a PaymentRequest /// /// GET /umbraco/Merchello/PaymentApi/RefundPayment/ /// </summary> public PaymentDisplay RefundPayment(PaymentRequest request) { var processor = new PaymentProcessor(MerchelloContext, request); var refund = processor.Refund(); if(!refund.Payment.Success) throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); return refund.Payment.Result.ToPaymentDisplay(); }