/// <summary> /// Attempts to process a payment /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <param name="merchelloContext">The <see cref="IMerchelloContext"/></param> /// <param name="paymentMethodKey">The <see cref="IPaymentMethod"/> key</param> /// <param name="args">Additional arguements required by the payment processor</param> /// <returns>The <see cref="IPaymentResult"/></returns> internal static IPaymentResult AuthorizePayment(this IInvoice invoice, IMerchelloContext merchelloContext, Guid paymentMethodKey, ProcessorArgumentCollection args) { var paymentMethod = merchelloContext.Gateways.Payment.GetPaymentGatewayMethodByKey(paymentMethodKey); return(invoice.AuthorizePayment(paymentMethod, args)); }
/// <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())); }
public void Can_Authorize_Payment_On_Invoice() { //// Arrange //// Act var authorized = _invoice.AuthorizePayment(_merchelloContext, _paymentMethodKey, new ProcessorArgumentCollection()); //// Assert Assert.IsTrue(authorized.Payment.Success); Assert.IsTrue(authorized.Payment.Result.HasIdentity); Assert.IsTrue(authorized.Payment.Result.AppliedPayments(_merchelloContext).Any()); Assert.AreEqual(Constants.DefaultKeys.InvoiceStatus.Unpaid, _invoice.InvoiceStatusKey); }
/// <summary> /// Attempts to process a payment /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <param name="paymentMethodKey">The <see cref="IPaymentMethod"/> key</param> /// <returns>The <see cref="IPaymentResult"/></returns> public static IPaymentResult AuthorizePayment(this IInvoice invoice, Guid paymentMethodKey) { return(invoice.AuthorizePayment(paymentMethodKey, new ProcessorArgumentCollection())); }
/// <summary> /// Attempts to process a payment /// </summary> /// <param name="invoice"></param> /// <param name="paymentMethodKey">The <see cref="IPaymentMethod"/> key</param> /// <param name="args">Additional arguements required by the payment processor</param> /// <returns>The <see cref="IPaymentResult"/></returns> public static IPaymentResult AuthorizePayment(this IInvoice invoice, Guid paymentMethodKey, ProcessorArgumentCollection args) { return(invoice.AuthorizePayment(MerchelloContext.Current, paymentMethodKey, args)); }