Ejemplo n.º 1
0
        /// <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));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 4
0
 /// <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()));
 }
Ejemplo n.º 5
0
 /// <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));
 }
Ejemplo n.º 6
0
 /// <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()));
 }