/// <summary> /// Performs the actual work of authorizing and capturing the 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> protected override IPaymentResult PerformAuthorizeCapturePayment(IInvoice invoice, decimal amount, ProcessorArgumentCollection args) { var paymentMethodToken = args.GetTokenId(); if (string.IsNullOrEmpty(paymentMethodToken)) { var error = new InvalidOperationException("No payment method token was found in the ProcessorArgumentCollection"); LogHelper.Debug <StripePaymentGatewayMethod>(error.Message); return(new PaymentResult(Attempt <IPayment> .Fail(error), invoice, false)); } var attempt = this.ProcessPayment(invoice, TransactionOption.AuthorizeAndCapture, amount, paymentMethodToken, args.GetCustomerName(), args.GetCustomerEmail()); 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, "Stripe Payment - authorized and captured", amount); } return(attempt); }