/// <summary> /// Authorizes and Captures a Payment /// </summary> /// <param name="paymentGatewayMethod">The <see cref="IPaymentMethod"/></param> /// <param name="args">Additional arguments required by the payment processor</param> /// <returns>A <see cref="IPaymentResult"/></returns> public override IPaymentResult AuthorizeCapturePayment(IPaymentGatewayMethod paymentGatewayMethod, ProcessorArgumentCollection args) { Mandate.ParameterNotNull(paymentGatewayMethod, "paymentGatewayMethod"); if (!this.IsReadyToInvoice()) { return(new PaymentResult(Attempt <IPayment> .Fail(new InvalidOperationException("SalesPreparation is not ready to invoice")), null, false)); } // invoice var invoice = this.PrepareInvoice(this.InvoiceBuilder); this.Context.Services.InvoiceService.Save(invoice); var result = invoice.AuthorizeCapturePayment(paymentGatewayMethod, args); if (result.Payment.Success && this.Context.Settings.EmptyBasketOnPaymentSuccess) { this.Context.Customer.Basket().Empty(); } this.OnFinalizing(result); return(result); }
/// <summary> /// Authorizes and Captures a Payment /// </summary> /// <param name="paymentGatewayMethod">The <see cref="IPaymentMethod"/></param> /// <param name="args">Additional arguments required by the payment processor</param> /// <returns>A <see cref="IPaymentResult"/></returns> public virtual IPaymentResult AuthorizeCapturePayment(IPaymentGatewayMethod paymentGatewayMethod, ProcessorArgumentCollection args) { Mandate.ParameterNotNull(paymentGatewayMethod, "paymentGatewayMethod"); if (!IsReadyToInvoice()) { return(new PaymentResult(Attempt <IPayment> .Fail(new InvalidOperationException("SalesPreparation is not ready to invoice")), null, false)); } // invoice var invoice = PrepareInvoice(new InvoiceBuilderChain(this)); MerchelloContext.Services.InvoiceService.Save(invoice); ////TODO ////Announce.Broadcast.InvoicedCustomer(_customer, invoice); var result = invoice.AuthorizeCapturePayment(paymentGatewayMethod, args); ////if(result.Payment.Success) //// Announce.Broadcast.PaymentWasCaptured(_customer, result); if (!result.ApproveOrderCreation) { return(result); } // order var order = result.Invoice.PrepareOrder(MerchelloContext); MerchelloContext.Services.OrderService.Save(order); return(result); }
/// <summary> /// Authorizes and Captures a Payment /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <param name="paymentGatewayMethod">The <see cref="IPaymentMethod"/></param> /// <param name="args">Additional arguements required by the payment processor</param> /// <returns>A <see cref="IPaymentResult"/></returns> public static IPaymentResult AuthorizeCapturePayment(this IInvoice invoice, IPaymentGatewayMethod paymentGatewayMethod, ProcessorArgumentCollection args) { Mandate.ParameterNotNull(paymentGatewayMethod, "paymentGatewayMethod"); return(paymentGatewayMethod.AuthorizeCapturePayment(invoice, invoice.Total, args)); }
/// <summary> /// Authorizes and Captures a Payment /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <param name="paymentGatewayMethod">The <see cref="IPaymentMethod"/></param> /// <param name="args">Additional arguements required by the payment processor</param> /// <returns>A <see cref="IPaymentResult"/></returns> public static IPaymentResult AuthorizeCapturePayment(this IInvoice invoice, IPaymentGatewayMethod paymentGatewayMethod, ProcessorArgumentCollection args) { Mandate.ParameterNotNull(paymentGatewayMethod, "paymentGatewayMethod"); return paymentGatewayMethod.AuthorizeCapturePayment(invoice, invoice.Total, args); }
/// <summary> /// Authorizes and Captures a Payment /// </summary> /// <param name="paymentGatewayMethod">The <see cref="IPaymentMethod"/></param> /// <param name="args">Additional arguements required by the payment processor</param> /// <returns>A <see cref="IPaymentResult"/></returns> public override IPaymentResult AuthorizeCapturePayment(IPaymentGatewayMethod paymentGatewayMethod, ProcessorArgumentCollection args) { var result = base.AuthorizeCapturePayment(paymentGatewayMethod, args); Customer.Basket().Empty(); return(result); }
/// <summary> /// Attempts to authorize a payment /// </summary> /// <param name="paymentGatewayMethod">The <see cref="IPaymentGatewayMethod"/> to use in processing the payment</param> /// <param name="args">Additional arguments required by the payment processor</param> /// <returns>The <see cref="IPaymentResult"/></returns> public override IPaymentResult AuthorizePayment(IPaymentGatewayMethod paymentGatewayMethod, ProcessorArgumentCollection args) { var result = base.AuthorizePayment(paymentGatewayMethod, args); if (result.Payment.Success) Customer.Basket().Empty(); return result; }
/// <summary> /// Attempts to process a payment /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <param name="paymentGatewayMethod">The <see cref="IPaymentGatewayMethod"/> to use in processing the payment</param> /// <returns>The <see cref="IPaymentResult"/></returns> public static IPaymentResult AuthorizePayment(this IInvoice invoice, IPaymentGatewayMethod paymentGatewayMethod) { Mandate.ParameterCondition(invoice.HasIdentity, "The invoice must be saved before a payment can be authorized."); Mandate.ParameterNotNull(paymentGatewayMethod, "paymentGatewayMethod"); return(invoice.AuthorizePayment(paymentGatewayMethod, new ProcessorArgumentCollection())); }
/// <summary> /// Authorizes and Captures a Payment /// </summary> /// <param name="paymentGatewayMethod">The <see cref="IPaymentMethod"/></param> /// <param name="args">Additional arguments required by the payment processor</param> /// <returns>A <see cref="IPaymentResult"/></returns> public override IPaymentResult AuthorizeCapturePayment(IPaymentGatewayMethod paymentGatewayMethod, ProcessorArgumentCollection args) { Mandate.ParameterNotNull(paymentGatewayMethod, "paymentGatewayMethod"); if (!this.IsReadyToInvoice()) return new PaymentResult(Attempt<IPayment>.Fail(new InvalidOperationException("SalesPreparation is not ready to invoice")), null, false); // invoice var invoice = this.PrepareInvoice(this.InvoiceBuilder); this.Context.Services.InvoiceService.Save(invoice); var result = invoice.AuthorizeCapturePayment(paymentGatewayMethod, args); if (result.Payment.Success && this.Context.Settings.EmptyBasketOnPaymentSuccess) this.Context.Customer.Basket().Empty(); this.OnFinalizing(result); return result; }
/// <summary> /// Initializes "this" object /// </summary> /// <param name="request"> /// The incoming <see cref="PaymentRequestDisplay"/> /// </param> private void Initialize(PaymentRequestDisplay request) { this._invoice = this._merchelloContext.Services.InvoiceService.GetByKey(request.InvoiceKey); if (request.PaymentKey != null) { this._payment = this._merchelloContext.Services.PaymentService.GetByKey(request.PaymentKey.Value); } this._paymentGatewayMethod = this._merchelloContext.Gateways.Payment.GetPaymentGatewayMethodByKey(request.PaymentMethodKey); this._amount = request.Amount; foreach (var arg in request.ProcessorArgs) { this._args.Add(arg.Key, arg.Value); } }
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> /// Authorizes and Captures a Payment /// </summary> /// <param name="paymentGatewayMethod">The <see cref="IPaymentMethod"/></param> /// <param name="args">Additional arguments required by the payment processor</param> /// <returns>A <see cref="IPaymentResult"/></returns> public virtual IPaymentResult AuthorizeCapturePayment(IPaymentGatewayMethod paymentGatewayMethod, ProcessorArgumentCollection args) { Mandate.ParameterNotNull(paymentGatewayMethod, "paymentGatewayMethod"); if (!IsReadyToInvoice()) { return(new PaymentResult(Attempt <IPayment> .Fail(new InvalidOperationException("SalesPreparation is not ready to invoice")), null, false)); } // invoice var invoice = PrepareInvoice(new InvoiceBuilderChain(this)); MerchelloContext.Services.InvoiceService.Save(invoice); var result = invoice.AuthorizeCapturePayment(paymentGatewayMethod, args); Finalizing.RaiseEvent(new SalesPreparationEventArgs <IPaymentResult>(result), this); return(result); }
public void Init() { var billTo = new Address() { Organization = "Proworks", Address1 = "777 NE 2nd St.", Locality = "Corvallis", Region = "OR", PostalCode = "97330", CountryCode = "US", Email = "*****@*****.**", Phone = "555-555-5555" }; // create an invoice var invoiceService = new InvoiceService(); _invoice = invoiceService.CreateInvoice(Core.Constants.DefaultKeys.InvoiceStatus.Unpaid); var extendedData = new ExtendedDataCollection(); // this is typically added automatically in the checkout workflow extendedData.SetValue(Core.Constants.ExtendedDataKeys.CurrencyCode, "USD"); var processorSettings = new ChaseProcessorSettings { MerchantId = ConfigurationManager.AppSettings["merchantId"], Bin = ConfigurationManager.AppSettings["bin"], Username = ConfigurationManager.AppSettings["username"], Password = ConfigurationManager.AppSettings["password"] }; Provider.GatewayProviderSettings.ExtendedData.SaveProcessorSettings(processorSettings); if (Provider.PaymentMethods.Any()) return; var resource = new GatewayResource("CreditCard", "Credit Card"); _payment = Provider.CreatePaymentMethod(resource, "Credit Card", "Credit Card"); }
/// <summary> /// Refunds a payment /// </summary> /// <param name="invoice">The invoice to be the payment was applied</param> /// <param name="payment">The payment to be refunded</param> /// <param name="paymentGatewayMethod">The <see cref="IPaymentGatewayMethod"/></param> /// <param name="amount">The amount to be refunded</param> /// <param name="args">Additional arguements required by the payment processor</param> /// <returns>A <see cref="IPaymentResult"/></returns> public static IPaymentResult RefundPayment(this IPayment payment, IInvoice invoice, IPaymentGatewayMethod paymentGatewayMethod, decimal amount, ProcessorArgumentCollection args) { return paymentGatewayMethod.RefundPayment(invoice, payment, amount, args); }
internal static PaymentMethodDisplay ToPaymentMethodDisplay(this IPaymentGatewayMethod paymentGatewayMethod) { return(AutoMapper.Mapper.Map <PaymentMethodDisplay>(paymentGatewayMethod)); }
/// <summary> /// Authorizes and Captures a Payment /// </summary> /// <param name="paymentGatewayMethod">The <see cref="IPaymentMethod"/></param> /// <returns>A <see cref="IPaymentResult"/></returns> public abstract IPaymentResult AuthorizeCapturePayment(IPaymentGatewayMethod paymentGatewayMethod);
/// <summary> /// Captures a payment for the <see cref="IInvoice"/> /// </summary> /// <param name="invoice">The invoice to be payed</param> /// <param name="payment">The</param> /// <param name="amount">The amount to the payment to be captured</param> /// <param name="paymentGatewayMethod"></param> /// <returns>A <see cref="IPaymentResult"/></returns> internal static IPaymentResult CapturePayment(this IInvoice invoice, IPayment payment, IPaymentGatewayMethod paymentGatewayMethod, decimal amount) { return invoice.CapturePayment(payment, paymentGatewayMethod, amount, new ProcessorArgumentCollection()); }
/// <summary> /// Deletes a <see cref="IPaymentGatewayMethod"/> /// </summary> /// <param name="method">The <see cref="IPaymentGatewayMethod"/> to delete</param> public virtual void DeletePaymentMethod(IPaymentGatewayMethod method) { GatewayProviderService.Save(method.PaymentMethod); }
/// <summary> /// Refunds a payment /// </summary> /// <param name="invoice">The invoice to be the payment was applied</param> /// <param name="payment">The payment to be refunded</param> /// <param name="paymentGatewayMethod">The <see cref="IPaymentGatewayMethod"/></param> /// <param name="args">Additional arguements required by the payment processor</param> /// <returns>A <see cref="IPaymentResult"/></returns> internal static IPaymentResult RefundPayment(this IInvoice invoice, IPayment payment, IPaymentGatewayMethod paymentGatewayMethod, ProcessorArgumentCollection args) { return paymentGatewayMethod.RefundPayment(invoice, payment, args); }
/// <summary> /// Deletes a <see cref="IPaymentGatewayMethod"/> /// </summary> /// <param name="method">The <see cref="IPaymentGatewayMethod"/> to delete</param> public virtual void DeletePaymentMethod(IPaymentGatewayMethod method) { GatewayProviderService.Delete(method.PaymentMethod); PaymentMethods = null; }
/// <summary> /// Attempts to process a payment /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <param name="paymentGatewayMethod">The <see cref="IPaymentGatewayMethod"/> to use in processing the payment</param> /// <returns>The <see cref="IPaymentResult"/></returns> public static IPaymentResult AuthorizePayment(this IInvoice invoice, IPaymentGatewayMethod paymentGatewayMethod) { Mandate.ParameterCondition(invoice.HasIdentity, "The invoice must be saved before a payment can be authorized."); Mandate.ParameterNotNull(paymentGatewayMethod, "paymentGatewayMethod"); return invoice.AuthorizePayment(paymentGatewayMethod, new ProcessorArgumentCollection()); }
/// <summary> /// Authorizes and Captures a Payment /// </summary> /// <param name="paymentGatewayMethod">The <see cref="IPaymentMethod"/></param> /// <returns>A <see cref="IPaymentResult"/></returns> public override IPaymentResult AuthorizeCapturePayment(IPaymentGatewayMethod paymentGatewayMethod) { return(this.AuthorizeCapturePayment(paymentGatewayMethod, new ProcessorArgumentCollection())); }
/// <summary> /// Refunds a payment /// </summary> /// <param name="invoice">The invoice to be the payment was applied</param> /// <param name="payment">The payment to be refunded</param> /// <param name="paymentGatewayMethod">The <see cref="IPaymentGatewayMethod"/></param> /// <returns>A <see cref="IPaymentResult"/></returns> internal static IPaymentResult RefundPayment(this IInvoice invoice, IPayment payment, IPaymentGatewayMethod paymentGatewayMethod) { return invoice.RefundPayment(payment, paymentGatewayMethod, new ProcessorArgumentCollection()); }
/// <summary> /// Authorizes and Captures a Payment /// </summary> /// <param name="paymentGatewayMethod">The <see cref="IPaymentMethod"/></param> /// <param name="args">Additional arguements required by the payment processor</param> /// <returns>A <see cref="IPaymentResult"/></returns> public virtual IPaymentResult AuthorizeCapturePayment(IPaymentGatewayMethod paymentGatewayMethod, ProcessorArgumentCollection args) { Mandate.ParameterNotNull(paymentGatewayMethod, "paymentGatewayMethod"); if (!IsReadyToInvoice()) return new PaymentResult(Attempt<IPayment>.Fail(new InvalidOperationException("SalesPreparation is not ready to invoice")), null, false); // invoice var invoice = PrepareInvoice(new InvoiceBuilderChain(this)); MerchelloContext.Services.InvoiceService.Save(invoice); var result = invoice.AuthorizeCapturePayment(paymentGatewayMethod, args); if (!result.ApproveOrderCreation) return result; // order var order = result.Invoice.PrepareOrder(MerchelloContext); MerchelloContext.Services.OrderService.Save(order); return result; }
/// <summary> /// Authorizes and Captures a Payment /// </summary> /// <param name="paymentGatewayMethod">The <see cref="IPaymentMethod"/></param> /// <returns>A <see cref="IPaymentResult"/></returns> public override IPaymentResult AuthorizeCapturePayment(IPaymentGatewayMethod paymentGatewayMethod) { return this.AuthorizeCapturePayment(paymentGatewayMethod, new ProcessorArgumentCollection()); }
/// <summary> /// Saves a <see cref="IPaymentGatewayMethod"/> /// </summary> /// <param name="method">The <see cref="IPaymentGatewayMethod"/> to be saved</param> public virtual void SavePaymentMethod(IPaymentGatewayMethod method) { GatewayProviderService.Save(method.PaymentMethod); PaymentMethods = null; }
/// <summary> /// Voids a payment /// </summary> /// <param name="invoice">The invoice to be the payment was applied</param> /// <param name="payment">The payment to be voided</param> /// <param name="paymentGatewayMethod">The <see cref="IPaymentGatewayMethod"/></param> /// <param name="args">Additional arguements required by the payment processor</param> /// <returns>A <see cref="IPaymentResult"/></returns> public static IPaymentResult VoidPayment(this IPayment payment, IInvoice invoice, IPaymentGatewayMethod paymentGatewayMethod, ProcessorArgumentCollection args) { return paymentGatewayMethod.VoidPayment(invoice, payment, args); }
/// <summary> /// Captures a payment for the <see cref="IInvoice"/> /// </summary> /// <param name="invoice">The invoice to be payed</param> /// <param name="payment">The</param> /// <param name="amount">The amount to the payment to be captured</param> /// <param name="paymentGatewayMethod">The <see cref="IPaymentGatewayMethod"/> to process the payment</param> /// <returns>A <see cref="IPaymentResult"/></returns> public static IPaymentResult CapturePayment(this IPayment payment, IInvoice invoice, IPaymentGatewayMethod paymentGatewayMethod, decimal amount) { return payment.CapturePayment(invoice, paymentGatewayMethod, amount, new ProcessorArgumentCollection()); }
/// <summary> /// Refunds a payment /// </summary> /// <param name="invoice">The invoice to be the payment was applied</param> /// <param name="payment">The payment to be refunded</param> /// <param name="paymentGatewayMethod">The <see cref="IPaymentGatewayMethod"/></param> /// <param name="amount">The amount to be refunded</param> /// <param name="args">Additional arguements required by the payment processor</param> /// <returns>A <see cref="IPaymentResult"/></returns> public static IPaymentResult RefundPayment(this IInvoice invoice, IPayment payment, IPaymentGatewayMethod paymentGatewayMethod, decimal amount, ProcessorArgumentCollection args) { return(paymentGatewayMethod.RefundPayment(invoice, payment, amount, args)); }
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> /// Voids a payment /// </summary> /// <param name="invoice">The invoice to be the payment was applied</param> /// <param name="payment">The payment to be voided</param> /// <param name="paymentGatewayMethod">The <see cref="IPaymentGatewayMethod"/></param> /// <param name="args">Additional arguements required by the payment processor</param> /// <returns>A <see cref="IPaymentResult"/></returns> public static IPaymentResult VoidPayment(this IInvoice invoice, IPayment payment, IPaymentGatewayMethod paymentGatewayMethod, ProcessorArgumentCollection args) { return(paymentGatewayMethod.VoidPayment(invoice, payment, args)); }
/// <summary> /// Refunds a payment /// </summary> /// <param name="invoice">The invoice to be the payment was applied</param> /// <param name="payment">The payment to be refunded</param> /// <param name="paymentGatewayMethod">The <see cref="IPaymentGatewayMethod"/></param> /// <param name="amount">The amount to be refunded</param> /// <returns>A <see cref="IPaymentResult"/></returns> public static IPaymentResult RefundPayment(this IInvoice invoice, IPayment payment, IPaymentGatewayMethod paymentGatewayMethod, decimal amount) { return invoice.RefundPayment(payment, paymentGatewayMethod, amount, new ProcessorArgumentCollection()); }
/// <summary> /// Attempts to process a payment /// </summary> /// <param name="paymentGatewayMethod">The <see cref="IPaymentGatewayMethod"/> to use in processing the payment</param> /// <returns>The <see cref="IPaymentResult"/></returns> public virtual IPaymentResult AuthorizePayment(IPaymentGatewayMethod paymentGatewayMethod) { return AuthorizePayment(paymentGatewayMethod, new ProcessorArgumentCollection()); }
/// <summary> /// Authorizes and Captures a Payment /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <param name="paymentGatewayMethod">The <see cref="IPaymentMethod"/></param> /// <returns>A <see cref="IPaymentResult"/></returns> public static IPaymentResult AuthorizeCapturePayment(this IInvoice invoice, IPaymentGatewayMethod paymentGatewayMethod) { return(invoice.AuthorizeCapturePayment(paymentGatewayMethod, new ProcessorArgumentCollection())); }
/// <summary> /// Authorizes and Captures a Payment /// </summary> /// <param name="paymentGatewayMethod">The <see cref="IPaymentMethod"/></param> /// <param name="args">Additional arguments required by the payment processor</param> /// <returns>A <see cref="IPaymentResult"/></returns> public abstract IPaymentResult AuthorizeCapturePayment(IPaymentGatewayMethod paymentGatewayMethod, ProcessorArgumentCollection args);
/// <summary> /// Refunds a payment /// </summary> /// <param name="invoice">The invoice to be the payment was applied</param> /// <param name="payment">The payment to be refunded</param> /// <param name="paymentGatewayMethod">The <see cref="IPaymentGatewayMethod"/></param> /// <param name="amount">The amount to be refunded</param> /// <returns>A <see cref="IPaymentResult"/></returns> public static IPaymentResult RefundPayment(this IInvoice invoice, IPayment payment, IPaymentGatewayMethod paymentGatewayMethod, decimal amount) { return(invoice.RefundPayment(payment, paymentGatewayMethod, amount, new ProcessorArgumentCollection())); }
/// <summary> /// Initializes "this" object /// </summary> /// <param name="request"> /// The incoming <see cref="PaymentRequestDisplay"/> /// </param> private void Initialize(PaymentRequestDisplay request) { this._invoice = this._merchelloContext.Services.InvoiceService.GetByKey(request.InvoiceKey); if (request.PaymentKey != null) this._payment = this._merchelloContext.Services.PaymentService.GetByKey(request.PaymentKey.Value); this._paymentGatewayMethod = this._merchelloContext.Gateways.Payment.GetPaymentGatewayMethodByKey(request.PaymentMethodKey); this._amount = request.Amount; foreach (var arg in request.ProcessorArgs) { this._args.Add(arg.Key, arg.Value); } }
/// <summary> /// Attempts to process a payment /// </summary> /// <param name="paymentGatewayMethod">The <see cref="IPaymentGatewayMethod"/> to use in processing the payment</param> /// <param name="args">Additional arguments required by the payment processor</param> /// <returns>The <see cref="IPaymentResult"/></returns> public virtual IPaymentResult AuthorizePayment(IPaymentGatewayMethod paymentGatewayMethod, ProcessorArgumentCollection args) { Mandate.ParameterNotNull(paymentGatewayMethod, "paymentGatewayMethod"); if (!IsReadyToInvoice()) return new PaymentResult(Attempt<IPayment>.Fail(new InvalidOperationException("SalesPreparation is not ready to invoice")), null, false); // invoice var invoice = PrepareInvoice(new InvoiceBuilderChain(this)); MerchelloContext.Services.InvoiceService.Save(invoice); ////TODO //// Raise the notification event //// Announce.Broadcast.InvoicedCustomer(_customer, invoice); var result = invoice.AuthorizePayment(paymentGatewayMethod, args); ////if(result.Payment.Success) //// Announce.Broadcast.PaymentWasAuthorized(_customer, result); if (!result.ApproveOrderCreation) return result; // order var order = result.Invoice.PrepareOrder(MerchelloContext); MerchelloContext.Services.OrderService.Save(order); return result; }
/// <summary> /// Authorizes and Captures a Payment /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <param name="paymentGatewayMethod">The <see cref="IPaymentMethod"/></param> /// <returns>A <see cref="IPaymentResult"/></returns> public static IPaymentResult AuthorizeCapturePayment(this IInvoice invoice, IPaymentGatewayMethod paymentGatewayMethod) { return invoice.AuthorizeCapturePayment(paymentGatewayMethod, new ProcessorArgumentCollection()); }
/// <summary> /// Captures a payment for the <see cref="IInvoice"/> /// </summary> /// <param name="invoice">The invoice to be payed</param> /// <param name="payment">The</param> /// <param name="amount">The amount to the payment to be captured</param> /// <param name="paymentGatewayMethod"></param> /// <param name="args">Additional arguements required by the payment processor</param> /// <returns>A <see cref="IPaymentResult"/></returns> internal static IPaymentResult CapturePayment(this IInvoice invoice, IPayment payment, IPaymentGatewayMethod paymentGatewayMethod, decimal amount, ProcessorArgumentCollection args) { return paymentGatewayMethod.CapturePayment(invoice, payment, amount, args); }
/// <summary> /// Authorizes and Captures a Payment /// </summary> /// <param name="paymentGatewayMethod">The <see cref="IPaymentMethod"/></param> /// <returns>A <see cref="IPaymentResult"/></returns> public virtual IPaymentResult AuthorizeCapturePayment(IPaymentGatewayMethod paymentGatewayMethod) { return(AuthorizeCapturePayment(paymentGatewayMethod, new ProcessorArgumentCollection())); }
/// <summary> /// Attempts to process a payment /// </summary> /// <param name="paymentGatewayMethod">The <see cref="IPaymentGatewayMethod"/> to use in processing the payment</param> /// <param name="args">Additional arguments required by the payment processor</param> /// <returns>The <see cref="IPaymentResult"/></returns> public virtual IPaymentResult AuthorizePayment(IPaymentGatewayMethod paymentGatewayMethod, ProcessorArgumentCollection args) { Mandate.ParameterNotNull(paymentGatewayMethod, "paymentGatewayMethod"); if (!IsReadyToInvoice()) return new PaymentResult(Attempt<IPayment>.Fail(new InvalidOperationException("SalesPreparation is not ready to invoice")), null, false); // invoice var invoice = PrepareInvoice(new InvoiceBuilderChain(this)); MerchelloContext.Services.InvoiceService.Save(invoice); var result = invoice.AuthorizePayment(paymentGatewayMethod, args); Finalizing.RaiseEvent(new SalesPreparationEventArgs<IPaymentResult>(result), this); return result; }