/// <summary> /// Performs the actual work of authorizing and capturing a payment. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="amount"> /// The amount. /// </param> /// <param name="args"> /// The args. /// </param> /// <returns> /// The <see cref="IPaymentResult"/>. /// </returns> /// <remarks> /// This is a transaction with SubmitForSettlement = true /// </remarks> protected override IPaymentResult PerformAuthorizeCapturePayment(IInvoice invoice, decimal amount, ProcessorArgumentCollection args) { var paymentMethodNonce = args.GetPaymentMethodNonce(); if (string.IsNullOrEmpty(paymentMethodNonce)) { var error = new InvalidOperationException("No payment method nonce was found in the ProcessorArgumentCollection"); LogHelper.Debug<BraintreeSimpleTransactionPaymentGatewayMethod>(error.Message); return new PaymentResult(Attempt<IPayment>.Fail(error), invoice, false); } var attempt = ProcessPayment(invoice, TransactionOption.Authorize, invoice.Total, paymentMethodNonce); var payment = attempt.Payment.Result; GatewayProviderService.Save(payment); if (!attempt.Payment.Success) { GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Denied, attempt.Payment.Exception.Message, 0); } else { GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, "Braintree transaction - authorized and captured", amount); } return attempt; }
/// <summary> /// Does the actual work of authorizing the payment /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="args"> /// The args. /// </param> /// <returns> /// The <see cref="IPaymentResult"/>. /// </returns> protected override IPaymentResult PerformAuthorizePayment(IInvoice invoice, ProcessorArgumentCollection args) { var paymentMethodNonce = args.GetPaymentMethodNonce(); if (string.IsNullOrEmpty(paymentMethodNonce)) { var error = new InvalidOperationException("No payment method nonce was found in the ProcessorArgumentCollection"); LogHelper.Debug <BraintreeStandardTransactionPaymentGatewayMethod>(error.Message); return(new PaymentResult(Attempt <IPayment> .Fail(error), invoice, false)); } var attempt = this.ProcessPayment(invoice, TransactionOption.Authorize, invoice.Total, paymentMethodNonce); var payment = attempt.Payment.Result; this.GatewayProviderService.Save(payment); if (!attempt.Payment.Success) { this.GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Denied, attempt.Payment.Exception.Message, 0); } else { this.GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, this.PaymentLineAuthorizeDescription, 0); } return(attempt); }
/// <summary> /// Does the actual work of authorizing the payment /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="args"> /// The args. /// </param> /// <returns> /// The <see cref="IPaymentResult"/>. /// </returns> protected override IPaymentResult PerformAuthorizePayment(IInvoice invoice, ProcessorArgumentCollection args) { // The Provider settings if (BraintreeApiService.BraintreeProviderSettings.DefaultTransactionOption == TransactionOption.SubmitForSettlement) { return(this.PerformAuthorizeCapturePayment(invoice, invoice.Total, args)); } var paymentMethodNonce = args.GetPaymentMethodNonce(); if (string.IsNullOrEmpty(paymentMethodNonce)) { var error = new InvalidOperationException("No payment method nonce was found in the ProcessorArgumentCollection"); LogHelper.Debug <BraintreeStandardTransactionPaymentGatewayMethod>(error.Message); return(new PaymentResult(Attempt <IPayment> .Fail(error), invoice, false)); } var attempt = ProcessPayment(invoice, TransactionOption.Authorize, invoice.Total, paymentMethodNonce); var payment = attempt.Payment.Result; GatewayProviderService.Save(payment); if (!attempt.Payment.Success) { GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Denied, attempt.Payment.Exception.Message, 0); } else { GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, "To show record of Braintree Authorization", 0); } return(attempt); }
/// <summary> /// Performs the actual work of authorizing and capturing a payment. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="amount"> /// The amount. /// </param> /// <param name="args"> /// The args. /// </param> /// <returns> /// The <see cref="IPaymentResult"/>. /// </returns> /// <remarks> /// This is a transaction with SubmitForSettlement = true /// </remarks> protected override IPaymentResult PerformAuthorizeCapturePayment(IInvoice invoice, decimal amount, ProcessorArgumentCollection args) { var paymentMethodNonce = args.GetPaymentMethodNonce(); if (string.IsNullOrEmpty(paymentMethodNonce)) { var error = new InvalidOperationException("No payment method nonce was found in the ProcessorArgumentCollection"); LogHelper.Debug<BraintreeStandardTransactionPaymentGatewayMethod>(error.Message); return new PaymentResult(Attempt<IPayment>.Fail(error), invoice, false); } // TODO this is a total last minute hack var email = string.Empty; if (args.ContainsKey("customerEmail")) email = args["customerEmail"]; var attempt = this.ProcessPayment(invoice, TransactionOption.SubmitForSettlement, invoice.Total, paymentMethodNonce, email); var payment = attempt.Payment.Result; this.GatewayProviderService.Save(payment); if (!attempt.Payment.Success) { this.GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Denied, attempt.Payment.Exception.Message, 0); } else { this.GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, "Braintree PayPal one time transaction - authorized and captured", amount); } return attempt; }
/// <summary> /// Does the actual work of authorizing the payment /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="args"> /// The args. /// </param> /// <returns> /// The <see cref="IPaymentResult"/>. /// </returns> protected override IPaymentResult PerformAuthorizePayment(IInvoice invoice, ProcessorArgumentCollection args) { // The Provider settings if (BraintreeApiService.BraintreeProviderSettings.DefaultTransactionOption == TransactionOption.SubmitForSettlement) { return this.PerformAuthorizeCapturePayment(invoice, invoice.Total, args); } var paymentMethodNonce = args.GetPaymentMethodNonce(); if (string.IsNullOrEmpty(paymentMethodNonce)) { var error = new InvalidOperationException("No payment method nonce was found in the ProcessorArgumentCollection"); LogHelper.Debug<BraintreeStandardTransactionPaymentGatewayMethod>(error.Message); return new PaymentResult(Attempt<IPayment>.Fail(error), invoice, false); } var attempt = ProcessPayment(invoice, TransactionOption.Authorize, invoice.Total, paymentMethodNonce); var payment = attempt.Payment.Result; GatewayProviderService.Save(payment); if (!attempt.Payment.Success) { GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Denied, attempt.Payment.Exception.Message, 0); } else { GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, "To show record of Braintree Authorization", 0); } return attempt; }
/// <summary> /// Performs the actual work of authorizing and capturing a payment. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="amount"> /// The amount. /// </param> /// <param name="args"> /// The args. /// </param> /// <returns> /// The <see cref="IPaymentResult"/>. /// </returns> /// <remarks> /// This is a transaction with SubmitForSettlement = true /// </remarks> protected override IPaymentResult PerformAuthorizeCapturePayment(IInvoice invoice, decimal amount, ProcessorArgumentCollection args) { var paymentMethodNonce = args.GetPaymentMethodNonce(); if (string.IsNullOrEmpty(paymentMethodNonce)) { var error = new InvalidOperationException("No payment method nonce was found in the ProcessorArgumentCollection"); LogHelper.Debug <BraintreeStandardTransactionPaymentGatewayMethod>(error.Message); return(new PaymentResult(Attempt <IPayment> .Fail(error), invoice, false)); } // TODO this is a total last minute hack var email = string.Empty; if (args.ContainsKey("customerEmail")) { email = args["customerEmail"]; } var merchantAccountId = string.Empty; if (args.ContainsKey("merchantAccountId")) { merchantAccountId = args["merchantAccountId"]; } var attempt = this.ProcessPayment(invoice, TransactionOption.SubmitForSettlement, amount, paymentMethodNonce, email, merchantAccountId); var payment = attempt.Payment.Result; this.GatewayProviderService.Save(payment); if (!attempt.Payment.Success) { this.GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Denied, attempt.Payment.Exception.Message, 0); } else { this.GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, "Braintree PayPal one time transaction - authorized and captured", amount); } return(attempt); }
/// <summary> /// Does the actual work of authorizing the payment /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="args"> /// The args. /// </param> /// <returns> /// The <see cref="IPaymentResult"/>. /// </returns> protected override IPaymentResult PerformAuthorizePayment(IInvoice invoice, ProcessorArgumentCollection args) { var authorizeAmount = invoice.Total; if (args.ContainsKey("authorizePaymentAmount")) { authorizeAmount = Convert.ToDecimal(args["authorizePaymentAmount"]); } var merchantAccountId = string.Empty; if (args.ContainsKey("merchantAccountId")) { merchantAccountId = args["merchantAccountId"]; } var paymentMethodNonce = args.GetPaymentMethodNonce(); if (string.IsNullOrEmpty(paymentMethodNonce)) { var error = new InvalidOperationException("No payment method nonce was found in the ProcessorArgumentCollection"); LogHelper.Debug <BraintreeStandardTransactionPaymentGatewayMethod>(error.Message); return(new PaymentResult(Attempt <IPayment> .Fail(error), invoice, false)); } var attempt = this.ProcessPayment(invoice, TransactionOption.Authorize, authorizeAmount, paymentMethodNonce, "", merchantAccountId); var payment = attempt.Payment.Result; this.GatewayProviderService.Save(payment); if (!attempt.Payment.Success) { this.GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Denied, attempt.Payment.Exception.Message, 0); } else { this.GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, "To show record of Braintree Authorization", 0); } return(attempt); }