示例#1
0
        /// <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);
        }
示例#2
0
        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();
        }
示例#3
0
        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);
            }
        }
示例#4
0
        /// <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();
        }