/// <summary> /// Authorizes and Captures 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>A <see cref="IPaymentResult"/></returns> internal static IPaymentResult AuthorizeCapturePayment(this IInvoice invoice, IMerchelloContext merchelloContext, Guid paymentMethodKey, ProcessorArgumentCollection args) { var paymentMethod = merchelloContext.Gateways.Payment.GetPaymentGatewayMethodByKey(paymentMethodKey); return(invoice.AuthorizeCapturePayment(paymentMethod, args)); }
public void Can_Authorize_And_Capture_A_Payment_For_An_Invoice() { //// Arrange //// Act var authCapture = _invoice.AuthorizeCapturePayment(_merchelloContext, _paymentMethodKey, new ProcessorArgumentCollection()); //// Assert Assert.IsTrue(authCapture.Payment.Success); Assert.AreEqual(Constants.DefaultKeys.InvoiceStatus.Paid, _invoice.InvoiceStatusKey); }
/// <summary> /// Performs the work of processing the payment with Braintree. /// </summary> /// <param name="nonce"> /// The 'nonce' generated by Braintree that we use to bill against. /// </param> /// <param name="invoice"> /// The invoice. /// </param> /// <returns> /// The <see cref="IPaymentResult"/>. /// </returns> protected virtual IPaymentResult ProcessPayment(string nonce, IInvoice invoice = null) { // gets the payment method var paymentMethod = CheckoutManager.Payment.GetPaymentMethod(); // You need a ProcessorArgumentCollection for this transaction to store the payment method nonce // The braintree package includes an extension method off of the ProcessorArgumentCollection - SetPaymentMethodNonce([nonce]); var args = new ProcessorArgumentCollection(); args.SetPaymentMethodNonce(nonce); // We want this to be an AuthorizeCapture(paymentMethod.Key, args); return(invoice == null ? CheckoutManager.Payment.AuthorizeCapturePayment(paymentMethod.Key, args) : invoice.AuthorizeCapturePayment(paymentMethod.Key, args)); }
/// <summary> /// Authorizes and Captures a Payment /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <param name="paymentMethodKey">The <see cref="IPaymentMethod"/> key</param> /// <returns>A <see cref="IPaymentResult"/></returns> public static IPaymentResult AuthorizeCapturePayment(this IInvoice invoice, Guid paymentMethodKey) { return(invoice.AuthorizeCapturePayment(paymentMethodKey, new ProcessorArgumentCollection())); }
/// <summary> /// Authorizes and Captures a Payment /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <param name="paymentMethodKey">The <see cref="IPaymentMethod"/> key</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, Guid paymentMethodKey, ProcessorArgumentCollection args) { return(invoice.AuthorizeCapturePayment(MerchelloContext.Current, paymentMethodKey, args)); }
/// <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())); }