/// <summary> /// Does the actual work of creating and processing the payment /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <param name="args">Any arguments required to process the payment.</param> /// <returns>The <see cref="IPaymentResult"/></returns> protected override IPaymentResult PerformAuthorizePayment(IInvoice invoice, ProcessorArgumentCollection args) { var po = args.AsPurchaseOrderFormData(); var payment = GatewayProviderService.CreatePayment(PaymentMethodType.PurchaseOrder, invoice.Total, PaymentMethod.Key); payment.CustomerKey = invoice.CustomerKey; payment.PaymentMethodName = PaymentMethod.Name; payment.ReferenceNumber = PaymentMethod.PaymentCode + "-" + invoice.PrefixedInvoiceNumber(); payment.Collected = false; payment.Authorized = true; if (string.IsNullOrEmpty(po.PurchaseOrderNumber)) { return new PaymentResult(Attempt<IPayment>.Fail(payment, new Exception("Error Purchase Order Number is empty")), invoice, false); } invoice.PoNumber = po.PurchaseOrderNumber; MerchelloContext.Current.Services.InvoiceService.Save(invoice); GatewayProviderService.Save(payment); // In this case, we want to do our own Apply Payment operation as the amount has not been collected - // so we create an applied payment with a 0 amount. Once the payment has been "collected", another Applied Payment record will // be created showing the full amount and the invoice status will be set to Paid. GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, string.Format("To show promise of a {0} payment", PaymentMethod.Name), 0); //// If this were using a service we might want to store some of the transaction data in the ExtendedData for record ////payment.ExtendData return new PaymentResult(Attempt.Succeed(payment), invoice, false); }
/// <summary> /// Builds the <see cref="PaymentDetailsItemType"/>. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="actionCode"> /// The <see cref="PaymentActionCodeType"/>. /// </param> /// <returns> /// The <see cref="PaymentDetailsType"/>. /// </returns> public PaymentDetailsType Build(IInvoice invoice, PaymentActionCodeType actionCode) { // Get the decimal configuration for the current currency var currencyCodeType = PayPalApiHelper.GetPayPalCurrencyCode(invoice.CurrencyCode); var basicAmountFactory = new PayPalBasicAmountTypeFactory(currencyCodeType); // Get the tax total var itemTotal = basicAmountFactory.Build(invoice.TotalItemPrice()); var shippingTotal = basicAmountFactory.Build(invoice.TotalShipping()); var taxTotal = basicAmountFactory.Build(invoice.TotalTax()); var invoiceTotal = basicAmountFactory.Build(invoice.Total); var items = BuildPaymentDetailsItemTypes(invoice.ProductLineItems(), basicAmountFactory); var paymentDetails = new PaymentDetailsType { PaymentDetailsItem = items.ToList(), ItemTotal = itemTotal, TaxTotal = taxTotal, ShippingTotal = shippingTotal, OrderTotal = invoiceTotal, PaymentAction = actionCode, InvoiceID = invoice.PrefixedInvoiceNumber() }; // ShipToAddress if (invoice.ShippingLineItems().Any()) { var addressTypeFactory = new PayPalAddressTypeFactory(); paymentDetails.ShipToAddress = addressTypeFactory.Build(invoice.GetShippingAddresses().FirstOrDefault()); } return paymentDetails; }
public int Delete(IInvoice entity) { if (entity == null) { throw new ArgumentException("Invoice entity provide is null."); } if (entity.Id < 0) { throw new ArgumentException("You must provide "); } try { using (_connection) { string sqlQuery = $"DELETE FROM {TableName} WHERE Id = {entity.Id}"; using (DbCommand deleteCommand = new SqlCommand(sqlQuery, _connection)) { return deleteCommand.ExecuteNonQuery(); } } } catch (Exception ex) { throw new Exception($"Unable to delete InvoiceHeader ID {entity.Id}", ex); } }
/// <summary> /// Adds billing information to the invoice /// </summary> /// <param name="value"> /// The <see cref="IInvoice"/> /// </param> /// <returns> /// The <see cref="Attempt"/>. /// </returns> public override Attempt<IInvoice> PerformTask(IInvoice value) { var noteDisplay = SalePreparation.Customer.ExtendedData.GetNote(); if (noteDisplay == null) return Attempt<IInvoice>.Succeed(value); var note = new Note { EntityKey = value.Key, EntityTfKey = EnumTypeFieldConverter.EntityType.GetTypeField(EntityType.Invoice).TypeKey, Message = noteDisplay.Message }; if (value.Notes != null) { if (value.Notes.All(x => x.Message != note.Message)) { value.Notes.Add(note); } } else { value.Notes = new System.Collections.Generic.List<Note> { note }; } return Attempt<IInvoice>.Succeed(value); }
/// <summary> /// Does the actual work of authorizing and capturing a payment /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <param name="amount">The amount to capture</param> /// <param name="args">Any arguments required to process the payment.</param> /// <returns>The <see cref="IPaymentResult"/></returns> protected override IPaymentResult PerformAuthorizeCapturePayment(IInvoice invoice, decimal amount, ProcessorArgumentCollection args) { var payment = GatewayProviderService.CreatePayment(PaymentMethodType.PurchaseOrder, amount, PaymentMethod.Key); payment.CustomerKey = invoice.CustomerKey; payment.PaymentMethodName = PaymentMethod.Name; payment.ReferenceNumber = PaymentMethod.PaymentCode + "-" + invoice.PrefixedInvoiceNumber(); payment.Collected = true; payment.Authorized = true; var po = args.AsPurchaseOrderFormData(); if (string.IsNullOrEmpty(po.PurchaseOrderNumber)) { return new PaymentResult(Attempt<IPayment>.Fail(payment, new Exception("Error Purchase Order Number is empty")), invoice, false); } invoice.PoNumber = po.PurchaseOrderNumber; MerchelloContext.Current.Services.InvoiceService.Save(invoice); GatewayProviderService.Save(payment); GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, "Cash payment", amount); return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, CalculateTotalOwed(invoice).CompareTo(amount) <= 0); }
/// <summary> /// Attempts to add the coupons discounts to the invoice /// </summary> /// <param name="value"> /// The value. /// </param> /// <returns> /// The <see cref="Attempt"/>. /// </returns> public override Attempt<IInvoice> PerformTask(IInvoice value) { // check if there are any coupon offers if (!SalePreparation.OfferCodes.Any()) return Attempt<IInvoice>.Succeed(value); if (!(SalePreparation is IBasketSalePreparation)) return Attempt<IInvoice>.Fail(value, new InvalidCastException("SalePreparation object is not IBasketSalePreparation")); _basketSalePreparation = SalePreparation as IBasketSalePreparation; foreach (var code in SalePreparation.OfferCodes) { var foundCoupon = CouponOfferManager.GetByOfferCode(code, SalePreparation.Customer); if (!foundCoupon.Success) { continue; } var coupon = foundCoupon.Result; var clone = LineItemExtensions.CreateNewItemCacheLineItemContainer(value.Items.Where(x => x.LineItemType != LineItemType.Tax)); var apply = coupon.TryApply(clone, this.SalePreparation.Customer).AsCouponRedemptionResult(coupon); if (apply.Success) { this.CouponOfferManager.SafeAddCouponAttemptContainer<InvoiceLineItem>(value, apply, true); } } return Attempt<IInvoice>.Succeed(value); }
protected override IPaymentResult PerformCapturePayment(IInvoice invoice, IPayment payment, decimal amount, ProcessorArgumentCollection args) { var payedTotalList = invoice.AppliedPayments().Select(item => item.Amount).ToList(); var payedTotal = (payedTotalList.Count == 0 ? 0 : payedTotalList.Aggregate((a, b) => a + b)); var isPartialPayment = amount + payedTotal < invoice.Total; var result = _processor.CapturePayment(invoice, payment, amount, isPartialPayment); //GatewayProviderService.Save(payment); if (!result.Payment.Success) { //payment.VoidPayment(invoice, payment.PaymentMethodKey.Value); GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Denied, "PayPal: request capture error: " + result.Payment.Exception.Message, 0); } else { GatewayProviderService.Save(payment); GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, "PayPal: captured", amount); //GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.CaptureTransactionResult), amount); } return result; }
/// <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> /// 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> /// Calculates tax for invoice. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="taxAddress"> /// The tax address. /// </param> /// <returns> /// The <see cref="ITaxCalculationResult"/>. /// </returns> public override ITaxCalculationResult CalculateTaxForInvoice(IInvoice invoice, IAddress taxAddress) { decimal amount = 0m; foreach (var item in invoice.Items) { // can I use?: https://github.com/Merchello/Merchello/blob/5706b8c9466f7417c41fdd29de7930b3e8c4dd2d/src/Merchello.Core/Models/ExtendedDataExtensions.cs#L287-L295 if (item.ExtendedData.GetTaxableValue()) amount = amount + item.TotalPrice; } TaxRequest taxRequest = new TaxRequest(); taxRequest.Amount = amount; taxRequest.Shipping = invoice.TotalShipping(); taxRequest.ToCity = taxAddress.Locality; taxRequest.ToCountry = taxAddress.CountryCode; taxRequest.ToState = taxAddress.Region; taxRequest.ToZip = taxAddress.PostalCode; Models.TaxResult taxResult = _taxjarService.GetTax(taxRequest); if (taxResult.Success) { var extendedData = new ExtendedDataCollection(); extendedData.SetValue(Core.Constants.ExtendedDataKeys.TaxTransactionResults, JsonConvert.SerializeObject(taxResult)); return new TaxCalculationResult(TaxMethod.Name, taxResult.Rate, taxResult.TotalTax, extendedData); } throw new Exception("TaxJar.com error"); }
/// <summary> /// Performs the task of asserting everything is billed in a common currency. /// </summary> /// <param name="value"> /// The value. /// </param> /// <returns> /// The <see cref="Attempt"/>. /// </returns> public override Attempt<IInvoice> PerformTask(IInvoice value) { var unTagged = value.Items.Where(x => !x.ExtendedData.ContainsKey(Constants.ExtendedDataKeys.CurrencyCode)).ToArray(); if (unTagged.Any()) { var defaultCurrency = this.CheckoutManager.Context.Services.StoreSettingService.GetByKey( Constants.StoreSettingKeys.CurrencyCodeKey); foreach (var item in unTagged) { item.ExtendedData.SetValue(Constants.ExtendedDataKeys.CurrencyCode, defaultCurrency.Value); } } var allCurrencyCodes = value.Items.Select(x => x.ExtendedData.GetValue(Constants.ExtendedDataKeys.CurrencyCode)).Distinct().ToArray(); //// Assign the currency code on the invoice if (allCurrencyCodes.Length == 1) value.CurrencyCode = allCurrencyCodes.First(); return 1 == allCurrencyCodes.Length ? Attempt<IInvoice>.Succeed(value) : Attempt<IInvoice>.Fail(new InvalidDataException("Invoice is being created with line items costed in different currencies.")); }
/// <summary> /// Captures a previously authorized payment /// </summary> /// <param name="invoice">The invoice associated with the <see cref="IPayment"/></param> /// <param name="payment">The <see cref="IPayment"/> to capture</param> /// <returns>The <see cref="IPaymentResult"/></returns> public IPaymentResult PriorAuthorizeCapturePayment(IInvoice invoice, IPayment payment) { if (!payment.Authorized) return new PaymentResult(Attempt<IPayment>.Fail(payment, new InvalidOperationException("Payment is not Authorized")), invoice, false); payment.Collected = true; return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, true); }
public IPaymentResult AuthorizePayment(IInvoice invoice, IPayment payment, string signature, string data) { MessageObject messageObject = VerifyResponse(data, signature); var id = messageObject.GetAttribute(SaferPayConstants.MessageAttributes.Id); var token = messageObject.GetAttribute(SaferPayConstants.MessageAttributes.Token); if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(token)) { return new PaymentResult(Attempt<IPayment>.Fail(payment), invoice, false); } // save this values to payment payment.ExtendedData.SetValue(SaferPayConstants.MessageAttributes.Id, id); payment.ExtendedData.SetValue(SaferPayConstants.MessageAttributes.Token, id); // Complete order for saferpay MessageObject payComplete = _messageFactory.CreateRequest(SaferPayConstants.PayCompleteKey); payComplete.SetAttribute(SaferPayConstants.MessageAttributes.AccountId, _settings.AccountId); payComplete.SetAttribute(SaferPayConstants.MessageAttributes.Id, id); payComplete.SetAttribute(SaferPayConstants.MessageAttributes.Token, token); MessageObject payCompleteResult = payComplete.Capture(); // authorize in merchello payment.Authorized = true; return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, true); }
public IPaymentResult InitializePayment(IInvoice invoice, IPayment payment, ProcessorArgumentCollection args) { string postUrl = GetPostUrl(invoice, payment); payment.ExtendedData.SetValue("RedirectUrl", postUrl); HttpContext.Current.Response.Redirect(postUrl); return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, true); }
/// <summary> /// Initializes a new instance of the <see cref="PaymentResult"/> class. /// </summary> /// <param name="payment"> /// The payment. /// </param> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="approveOrderCreation"> /// The approve order creation. /// </param> /// <param name="redirectUrl"> /// The redirect URL. /// </param> public PaymentResult(Attempt<IPayment> payment, IInvoice invoice, bool approveOrderCreation, string redirectUrl) { Payment = payment; Invoice = invoice; ApproveOrderCreation = approveOrderCreation; RedirectUrl = redirectUrl; }
/// <summary> /// Processes the Authorize and AuthorizeAndCapture transactions /// </summary> /// <param name="invoice">The <see cref="IInvoice"/> to be paid</param> /// <param name="payment">The <see cref="IPayment"/> record</param> /// <param name="args"></param> /// <returns>The <see cref="IPaymentResult"/></returns> public IPaymentResult ProcessPayment(IInvoice invoice, IPayment payment, ProcessorArgumentCollection args) { var setExpressCheckoutRequestDetails = new SetExpressCheckoutRequestDetailsType { ReturnURL = String.Format("{0}/App_Plugins/Merchello.PayPal/PayPalExpressCheckout.html?InvoiceKey={1}&PaymentKey={2}&PaymentMethodKey={3}", GetWebsiteUrl(), invoice.Key, payment.Key, payment.PaymentMethodKey), CancelURL = "http://localhost/cancel", PaymentDetails = new List<PaymentDetailsType> { GetPaymentDetails(invoice) } }; var setExpressCheckout = new SetExpressCheckoutReq(); var setExpressCheckoutRequest = new SetExpressCheckoutRequestType(setExpressCheckoutRequestDetails); setExpressCheckout.SetExpressCheckoutRequest = setExpressCheckoutRequest; var config = new Dictionary<string, string> { {"mode", "sandbox"}, {"account1.apiUsername", _settings.ApiUsername}, {"account1.apiPassword", _settings.ApiPassword}, {"account1.apiSignature", _settings.ApiSignature} }; var service = new PayPalAPIInterfaceServiceService(config); var responseSetExpressCheckoutResponseType = service.SetExpressCheckout(setExpressCheckout); // If this were using a service we might want to store some of the transaction data in the ExtendedData for record payment.ExtendedData.SetValue("RedirectUrl", "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=" + responseSetExpressCheckoutResponseType.Token); return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, false); }
/// <summary> /// Does the actual work capturing a payment /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <param name="payment">The previously Authorize payment to be captured</param> /// <param name="amount">The amount to capture</param> /// <param name="args">Any arguments required to process the payment.</param> /// <returns>The <see cref="IPaymentResult"/></returns> protected override IPaymentResult PerformCapturePayment(IInvoice invoice, IPayment payment, decimal amount, ProcessorArgumentCollection args) { var result = _processor.PriorAuthorizeCapturePayment(invoice, payment); GatewayProviderService.Save(payment); if (!result.Payment.Success) { GatewayProviderService.ApplyPaymentToInvoice( payment.Key, invoice.Key, AppliedPaymentType.Denied, result.Payment.Exception.Message, 0); } else { GatewayProviderService.ApplyPaymentToInvoice( payment.Key, invoice.Key, AppliedPaymentType.Debit, payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.CaptureTransactionResult), amount); } return result; }
protected override IPaymentResult PerformCapturePayment(IInvoice invoice, IPayment payment, decimal amount, ProcessorArgumentCollection args) { var token = args["token"]; var payerId = args["PayerID"]; var result = _processor.ComplitePayment(invoice, payment, token, payerId); GatewayProviderService.Save(payment); // TODO GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, "Cash payment", payment.Amount); /* if (!result.Payment.Success) { GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Denied, result.Payment.Exception.Message, 0); } else { GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.CaptureTransactionResult), amount); } */ return result; }
/// <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> /// Processes the Authorize and AuthorizeAndCapture transactions /// </summary> /// <param name="invoice">The <see cref="IInvoice" /> to be paid</param> /// <param name="payment">The <see cref="IPayment" /> record</param> /// <param name="transactionMode">Authorize or AuthorizeAndCapture</param> /// <param name="amount">The money amount to be processed</param> /// <returns>The <see cref="IPaymentResult" /></returns> public IPaymentResult ProcessPayment(IInvoice invoice, IPayment payment, TransactionMode transactionMode, decimal amount) { if (!IsValidCurrencyCode(invoice.CurrencyCode())) return new PaymentResult(Attempt<IPayment>.Fail(payment, new Exception(string.Format("Invalid currency. Invoice Currency: '{0}'", invoice.CurrencyCode()))), invoice, false); if (transactionMode == TransactionMode.Authorize) { //var paymentId = payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.QuickpayPaymentId); var currency = payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.PaymentCurrency); var amountAuthorizedMinorString = payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.PaymentAmount); var amountAuthorized = decimal.Parse(amountAuthorizedMinorString) / (IsZeroDecimalCurrency(currency) ? 100 : 1); if (invoice.CurrencyCode() != currency) { return new PaymentResult(Attempt<IPayment>.Fail(payment, new Exception(string.Format("Currency mismatch. Invoice Currency: {0}, Payment Currency: {1}", invoice.CurrencyCode(), currency))), invoice, false); } if (invoice.Total > amountAuthorized) { return new PaymentResult(Attempt<IPayment>.Fail(payment, new Exception(string.Format("Amount mismatch. Invoice Amount: {0}, Payment Amount: {1}", invoice.Total.ToString("F2"), amountAuthorized.ToString("F2")))), invoice, false); } payment.Authorized = true; return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, invoice.ShippingLineItems().Any()); } return new PaymentResult(Attempt<IPayment>.Fail(payment, new Exception(string.Format("{0}", "QuickPay Payment AuthorizeAndCapture Not Implemented Yet"))), invoice, false); }
private IPaymentResult ProcessPayment(IInvoice invoice, TransactionMode transactionMode, decimal amount, ProcessorArgumentCollection args) { var cc = args.AsCreditCardFormData(); var payment = GatewayProviderService.CreatePayment(PaymentMethodType.CreditCard, invoice.Total, PaymentMethod.Key); payment.CustomerKey = invoice.CustomerKey; payment.Authorized = false; payment.Collected = false; payment.PaymentMethodName = string.Format("{0} Stripe Credit Card", cc.CreditCardType); payment.ExtendedData.SetValue(Constants.ExtendedDataKeys.CcLastFour, cc.CardNumber.Substring(cc.CardNumber.Length - 4, 4).EncryptWithMachineKey()); var result = _processor.ProcessPayment(invoice, payment, transactionMode, amount, cc); GatewayProviderService.Save(payment); if (!result.Payment.Success) { GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Denied, result.Payment.Exception.Message, 0); } else { GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, //payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.AuthorizationTransactionResult) + (transactionMode == TransactionMode.AuthorizeAndCapture ? string.Empty : " to show record of Authorization"), transactionMode == TransactionMode.AuthorizeAndCapture ? invoice.Total : 0); } return result; }
/// <summary> /// Initializes a new instance of the <see cref="FixedRateTaxCalculationStrategy"/> class. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="taxAddress"> /// The tax address. /// </param> /// <param name="taxMethod"> /// The tax method. /// </param> public FixedRateTaxCalculationStrategy(IInvoice invoice, IAddress taxAddress, ITaxMethod taxMethod) : base(invoice, taxAddress) { Mandate.ParameterNotNull(taxMethod, "countryTaxRate"); _taxMethod = taxMethod; }
private IPaymentResult ProcessPayment(IInvoice invoice, TransactionMode transactionMode, decimal amount, ProcessorArgumentCollection args) { var po = args.AsPurchaseOrderFormData(); var payment = GatewayProviderService.CreatePayment(PaymentMethodType.PurchaseOrder, invoice.Total, PaymentMethod.Key); payment.CustomerKey = invoice.CustomerKey; payment.Authorized = false; payment.Collected = false; payment.PaymentMethodName = "Purchase Order"; var result = _processor.ProcessPayment(invoice, payment, amount, po); GatewayProviderService.Save(payment); if (!result.Payment.Success) { GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Denied, result.Payment.Exception.Message, 0); } else { MerchelloContext.Current.Services.InvoiceService.Save(invoice, false); GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, payment.ExtendedData.GetValue(Constants.ExtendedDataKeys.AuthorizationTransactionResult) + (transactionMode == TransactionMode.AuthorizeAndCapture ? string.Empty : " to show record of Authorization"), transactionMode == TransactionMode.AuthorizeAndCapture ? invoice.Total : 0); } return result; }
public void Bill() { invoiceId++; invoice = new Invoice() { Id = invoiceId, Date = DateTime.Now, Patient = patient, Receipt = prescription, Price = price,Status = false}; invoceList.Add(invoice); Console.WriteLine("Hospital billed the insurance company"); insurances.FootTheBill(invoice); }
/// <summary> /// Initializes a new instance of the <see cref="TaxCalculationStrategyBase"/> class. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="taxAddress"> /// The tax address. /// </param> protected TaxCalculationStrategyBase(IInvoice invoice, IAddress taxAddress) { Mandate.ParameterNotNull(invoice, "invoice"); Mandate.ParameterNotNull(taxAddress, "taxAddress"); _invoice = invoice; _taxAddress = taxAddress; }
public void Paying(IInvoice invoice) { invoice.Paid = true; if (onInvoicePaid != null) { onInvoicePaid(); } }
/// <summary> /// Adds billing information to the invoice /// </summary> /// <param name="value"> /// The <see cref="IInvoice"/> /// </param> /// <returns> /// The <see cref="Attempt"/>. /// </returns> public override Attempt<IInvoice> PerformTask(IInvoice value) { var address = this.SalePreparation.Customer.ExtendedData.GetAddress(Core.Constants.ExtendedDataKeys.BillingAddress); if (address == null) return Attempt<IInvoice>.Fail(new InvalidDataException("Billing information could not be retrieved from the Checkout")); value.SetBillingAddress(address); return Attempt<IInvoice>.Succeed(value); }
/// <summary> /// Adds the invoice number prefix to the invoice if it has been set. /// </summary> /// <param name="value"> /// The value. /// </param> /// <returns> /// The <see cref="Attempt"/>. /// </returns> public override Attempt<IInvoice> PerformTask(IInvoice value) { if (!string.IsNullOrWhiteSpace(CheckoutManager.Context.Settings.InvoiceNumberPrefix)) { value.InvoiceNumberPrefix = CheckoutManager.Context.Settings.InvoiceNumberPrefix; } return Attempt<IInvoice>.Succeed(value); }
/// <summary> /// Overrides the AuthorizePayment. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="args"> /// The args. /// </param> /// <returns> /// The <see cref="IPaymentResult"/>. /// </returns> /// <exception cref="InvalidOperationException"> /// Throws an exception if this method is called. /// </exception> public override IPaymentResult AuthorizePayment(IInvoice invoice, ProcessorArgumentCollection args) { var invalidOp = new InvalidOperationException( "Braintree PayPal authorize transaction is not supported. Use AuthorizeCapture Payment"); LogHelper.Error<PayPalVaultTransactionPaymentGatewayMethod>("Authorize method not supported.", invalidOp); throw invalidOp; }
/// <summary> /// Processes the Authorize and AuthorizeAndCapture transactions /// </summary> /// <param name="invoice">The <see cref="IInvoice"/> to be paid</param> /// <param name="payment">The <see cref="IPayment"/> record</param> /// <param name="transactionMode">Authorize or AuthorizeAndCapture</param> /// <param name="amount">The money amount to be processed</param> /// <param name="purchaseOrder">The <see cref="PurchaseOrderFormData"></see></param> /// <returns>The <see cref="IPaymentResult"/></returns> public IPaymentResult ProcessPayment(IInvoice invoice, IPayment payment, decimal amount, PurchaseOrderFormData purchaseOrder) { if (string.IsNullOrEmpty(purchaseOrder.PurchaseOrderNumber)) { return new PaymentResult(Attempt<IPayment>.Fail(payment, new Exception(string.Format("Error Purchase Order Number is empty"))), invoice, false); } invoice.PoNumber = purchaseOrder.PurchaseOrderNumber; payment.Authorized = true; return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, true); }
/// <summary> /// Voids a payment /// </summary> /// <param name="invoice">The invoice to be the payment was applied</param> /// <param name="payment">The payment to be voided</param> /// <param name="paymentGatewayMethod">The <see cref="IPaymentGatewayMethod"/></param> /// <param name="args">Additional arguements required by the payment processor</param> /// <returns>A <see cref="IPaymentResult"/></returns> public static IPaymentResult VoidPayment(this IInvoice invoice, IPayment payment, IPaymentGatewayMethod paymentGatewayMethod, ProcessorArgumentCollection args) { return(paymentGatewayMethod.VoidPayment(invoice, payment, args)); }
protected override IPaymentResult PerformAuthorizePayment(IInvoice invoice, ProcessorArgumentCollection args) { return(ProcessPayment(invoice, args)); }
protected override IPaymentResult PerformVoidPayment(IInvoice invoice, IPayment payment, ProcessorArgumentCollection args) { throw new System.NotImplementedException(); }
/// <summary> /// Renders the InvoiceSummary Partial View /// </summary> /// <param name="invoice">The <see cref="IInvoice"/> to be displayed</param> private ActionResult RenderInvoice(IInvoice invoice) { return(PartialView("InvoiceSummary", invoice)); }
/// <summary> /// Performs a Braintree sales transaction. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="paymentMethodNonce"> /// The payment method nonce. /// </param> /// <param name="customer"> /// The customer. /// </param> /// <param name="billingAddress"> /// The billing address. /// </param> /// <param name="option"> /// The transaction option. /// </param> /// <returns> /// The <see cref="Result{Transaction}"/>. /// </returns> public Result <Transaction> Sale(IInvoice invoice, string paymentMethodNonce, ICustomer customer, IAddress billingAddress, TransactionOption option = TransactionOption.SubmitForSettlement) { return(Sale(invoice, paymentMethodNonce, customer, billingAddress, null, option)); }
/// <summary> /// Returns a collection of <see cref="IAppliedPayment"/> for this <see cref="IInvoice"/> /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <param name="merchelloContext">The <see cref="IMerchelloContext"/></param> /// <returns>A collection of <see cref="IAppliedPayment"/></returns> internal static IEnumerable <IAppliedPayment> AppliedPayments(this IInvoice invoice, IMerchelloContext merchelloContext) { return(invoice.AppliedPayments(merchelloContext.Services.GatewayProviderService)); }
/// <summary> /// Gets a collection of <see cref="IPayment"/> applied to the invoice /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <returns>A collection of <see cref="IPayment"/></returns> public static IEnumerable <IPayment> Payments(this IInvoice invoice) { return(invoice.Payments(MerchelloContext.Current)); }
/// <summary> /// Calculates the tax amount for an invoice /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <returns>The <see cref="ITaxCalculationResult"/></returns> /// <remarks> /// /// Assumes the billing address of the invoice will be used for the taxation address /// /// </remarks> public virtual ITaxCalculationResult CalculateTaxForInvoice(IInvoice invoice) { return(CalculateTaxForInvoice(invoice, invoice.GetBillingAddress())); }
/// <summary> /// Sums the total tax amount for the invoice items /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> public static decimal TotalTax(this IInvoice invoice) { return(invoice.Items.Where(x => x.LineItemType == LineItemType.Tax).Sum(x => x.TotalPrice)); }
/// <summary> /// Calculates taxes for the invoice /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <param name="merchelloContext">The <see cref="IMerchelloContext"/></param> /// <param name="taxAddress">The address (generally country code and region) to be used to determine the taxation rates</param> /// <returns>The <see cref="ITaxCalculationResult"/> from the calculation</returns> internal static ITaxCalculationResult CalculateTaxes(this IInvoice invoice, IMerchelloContext merchelloContext, IAddress taxAddress) { // remove any other tax lines return(merchelloContext.Gateways.Taxation.CalculateTaxesForInvoice(invoice, taxAddress)); }
/// <summary> /// Calculates taxes for the invoice /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <param name="taxAddress">The address (generally country code and region) to be used to determine the taxation rates</param> /// <returns>The <see cref="ITaxCalculationResult"/> from the calculation</returns> public static ITaxCalculationResult CalculateTaxes(this IInvoice invoice, IAddress taxAddress) { return(invoice.CalculateTaxes(MerchelloContext.Current, taxAddress)); }
/// <summary> /// Refunds a payment /// </summary> /// <param name="invoice">The invoice to be the payment was applied</param> /// <param name="payment">The payment to be refunded</param> /// <param name="paymentGatewayMethod">The <see cref="IPaymentGatewayMethod"/></param> /// <param name="amount">The amount to be refunded</param> /// <param name="args">Additional arguements required by the payment processor</param> /// <returns>A <see cref="IPaymentResult"/></returns> public static IPaymentResult RefundPayment(this IInvoice invoice, IPayment payment, IPaymentGatewayMethod paymentGatewayMethod, decimal amount, ProcessorArgumentCollection args) { return(paymentGatewayMethod.RefundPayment(invoice, payment, amount, args)); }
/// <summary> /// Refunds a payment /// </summary> /// <param name="invoice">The invoice to be the payment was applied</param> /// <param name="payment">The payment to be refunded</param> /// <param name="paymentMethodKey">The key of the <see cref="IPaymentGatewayMethod"/></param> /// <param name="amount">The amount to be refunded</param> /// <returns>A <see cref="IPaymentResult"/></returns> public static IPaymentResult RefundPayment(this IInvoice invoice, IPayment payment, Guid paymentMethodKey, decimal amount) { return(invoice.RefundPayment(payment, paymentMethodKey, amount, new ProcessorArgumentCollection())); }
/// <summary> /// Returns a constructed invoice number (including it's invoice number prefix - if any) /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <returns>The prefixed invoice number</returns> public static string PrefixedInvoiceNumber(this IInvoice invoice) { return(string.IsNullOrEmpty(invoice.InvoiceNumberPrefix) ? invoice.InvoiceNumber.ToString(CultureInfo.InvariantCulture) : string.Format("{0}-{1}", invoice.InvoiceNumberPrefix, invoice.InvoiceNumber)); }
/// <summary> /// Gets a collection of <see cref="IPayment"/> applied to the invoice /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <param name="merchelloContext">The <see cref="IMerchelloContext"/></param> /// <returns>A collection of <see cref="IPayment"/></returns> internal static IEnumerable <IPayment> Payments(this IInvoice invoice, IMerchelloContext merchelloContext) { return(merchelloContext.Services.PaymentService.GetPaymentsByInvoiceKey(invoice.Key)); }
/// <summary> /// Calculates the tax amount for an invoice /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <param name="taxAddress">The <see cref="IAddress"/> to base taxation rates. Either origin or destination address.</param> /// <returns><see cref="ITaxCalculationResult"/></returns> public abstract ITaxCalculationResult CalculateTaxForInvoice(IInvoice invoice, IAddress taxAddress);
/// <summary> /// Returns a collection of <see cref="IAppliedPayment"/> for this <see cref="IInvoice"/> /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <param name="gatewayProviderService">The <see cref="IGatewayProviderService"/></param> /// <returns>A collection of <see cref="IAppliedPayment"/></returns> public static IEnumerable <IAppliedPayment> AppliedPayments(this IInvoice invoice, IGatewayProviderService gatewayProviderService) { return(gatewayProviderService.GetAppliedPaymentsByInvoiceKey(invoice.Key)); }
/// <summary> /// Get adoxio_Invoice from adoxio_contraventions /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='adoxioContraventionid'> /// key: adoxio_contraventionid of adoxio_contravention /// </param> /// <param name='select'> /// Select properties to be returned /// </param> /// <param name='expand'> /// Expand related entities /// </param> public static MicrosoftDynamicsCRMinvoice Get(this IInvoice operations, string adoxioContraventionid, IList <string> select = default(IList <string>), IList <string> expand = default(IList <string>)) { return(operations.GetAsync(adoxioContraventionid, select, expand).GetAwaiter().GetResult()); }
/// <summary> /// Prepares an <see cref="IOrder"/> without saving it to the database. /// </summary> /// <param name="invoice">The <see cref="IInvoice"/> to base the order on</param> /// <returns>The <see cref="IOrder"/></returns> public static IOrder PrepareOrder(this IInvoice invoice) { return(invoice.PrepareOrder(MerchelloContext.Current)); }
/// <summary> /// Captures a payment for the <see cref="IInvoice"/> /// </summary> /// <param name="invoice">The invoice to be payed</param> /// <param name="payment">The</param> /// <param name="paymentMethodKey">The <see cref="IPaymentMethod"/> key</param> /// <param name="amount">The amount to the payment to be captured</param> /// <param name="args">Additional arguements required by the payment processor</param> /// <returns>A <see cref="IPaymentResult"/></returns> public static IPaymentResult CapturePayment(this IInvoice invoice, IPayment payment, Guid paymentMethodKey, decimal amount, ProcessorArgumentCollection args) { return(invoice.CapturePayment(MerchelloContext.Current, payment, paymentMethodKey, amount, args)); }
/// <summary> /// Calculates taxes for the <see cref="IInvoice"/> /// </summary> /// <param name="invoice">The <see cref="IInvoice"/> to tax</param> /// <param name="quoteOnly"> /// An optional parameter indicating that the tax calculation should be an estimate. /// This is useful for some 3rd party tax APIs /// </param> /// <returns>The <see cref="ITaxCalculationResult"/></returns> /// <remarks> /// /// This assumes that the tax rate is associated with the invoice's billing address /// /// </remarks> public ITaxCalculationResult CalculateTaxesForInvoice(IInvoice invoice, bool quoteOnly = false) { return(CalculateTaxesForInvoice(invoice, invoice.GetBillingAddress())); }
/// <summary> /// Captures a payment for the <see cref="IInvoice"/> /// </summary> /// <param name="invoice">The invoice to be payed</param> /// <param name="payment">The</param> /// <param name="amount">The amount to the payment to be captured</param> /// <param name="paymentGatewayMethod"></param> /// <returns>A <see cref="IPaymentResult"/></returns> public static IPaymentResult CapturePayment(this IInvoice invoice, IPayment payment, IPaymentGatewayMethod paymentGatewayMethod, decimal amount) { return(invoice.CapturePayment(payment, paymentGatewayMethod, amount, new ProcessorArgumentCollection())); }
public string confirmPaymentDetail(ListInvoice inv) { Company _currentCompany = ((EInvoiceContext)FXContext.Current).CurrentCompany; int comID = _currentCompany.id; if (_currentCompany == null) { return("ERR:7"); //username khong phu hop - ko tim thay company phu hop voi [username] } List <IInvoice> invLst = new List <IInvoice>(); string[] invTokens = inv.lstInvToken.Split('_'); List <string> unPaid = new List <string>(); List <string> notFound = new List <string>(); List <string> paid = new List <string>(); string pattern; string serial; decimal invNo; string rv = ""; if (invTokens.Length < 1 || (!DataHelper.parseInvToken(invTokens[0], out pattern, out serial, out invNo).Equals("OK"))) { return(DataHelper.parseInvToken(invTokens[0], out pattern, out serial, out invNo)); } IInvoiceService _iInvoicSrv = InvServiceFactory.GetService(pattern, comID); foreach (string invToken in invTokens) { pattern = ""; serial = ""; invNo = 0; rv = DataHelper.parseInvToken(invToken, out pattern, out serial, out invNo); if (!rv.Equals("OK")) { return(rv); } IInvoice oInvoiceBase = _iInvoicSrv.GetByNo(comID, pattern, serial, invNo); if (oInvoiceBase == null) { //return "ERR:6"; //khong tim thay hoa don notFound.Add(invToken); } if (oInvoiceBase.PaymentStatus == Payment.Unpaid && (oInvoiceBase.Status == InvoiceStatus.AdjustedInv || oInvoiceBase.Status == InvoiceStatus.SignedInv)) { invLst.Add(oInvoiceBase); unPaid.Add(invToken); } else { paid.Add(invToken); } } rv = ""; StringBuilder sb = new StringBuilder("ERR:6#"); foreach (string s in notFound) { sb.AppendFormat("{0}_", s); } rv = sb.ToString(); rv = rv.Remove(rv.Length - 1, 1); sb = new StringBuilder("ERR:13#"); foreach (string s in paid) { sb.AppendFormat("{0}_", s); } rv = rv + "||" + sb.ToString(); rv = rv.Remove(rv.Length - 1, 1); if (invLst.Count == 0) { //return "ERR:13"; // hoa đơn đã gạch nợ/bỏ gạch nợ rồi return(rv); } ICompanyService _comSrv = IoC.Resolve <ICompanyService>(); Company com = _comSrv.Getbykey(comID); string strNote = "Thực hiện gạch nợ: Người gạch nợ: " + HttpContext.Current.User.Identity.Name + " Ngày gạch nợ: " + DateTime.Now.ToString(); if (_iInvoicSrv.ConfirmPayment(invLst, strNote)) { //thuc hien deliveriy IDeliver _deliver = _currentCompany.Config.Keys.Contains("IDeliver") ? IoC.Resolve(Type.GetType(_currentCompany.Config["IDeliver"])) as IDeliver : null; if (_deliver != null) { _deliver.Deliver(invLst.ToArray(), com); } //return "OK:"; sb = new StringBuilder("OK:#"); foreach (string s in unPaid) { sb.AppendFormat("{0}_", s); } rv = rv + "||" + sb.ToString(); rv = rv.Remove(rv.Length - 1, 1); return(rv); //ok } return("ERR:7"); //sao lai khong thanh toán được ? }
/// <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())); }
protected override IPaymentResult PerformAuthorizeCapturePayment(IInvoice invoice, decimal amount, ProcessorArgumentCollection args) { throw new System.NotImplementedException(); }
/// <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())); }
/// <summary> /// Calculates taxes for the invoice /// </summary> /// <param name="invoice">The <see cref="IInvoice"/></param> /// <returns>The <see cref="ITaxCalculationResult"/> from the calculation</returns> public static ITaxCalculationResult CalculateTaxes(this IInvoice invoice) { return(invoice.CalculateTaxes(invoice.GetBillingAddress())); }
/// <summary> /// Voids a payment /// </summary> /// <param name="invoice">The invoice to be the payment was applied</param> /// <param name="payment">The payment to be voided</param> /// <param name="paymentMethodKey">The <see cref="IPaymentGatewayMethod"/> key</param> /// <returns>A <see cref="IPaymentResult"/></returns> public static IPaymentResult VoidPayment(this IInvoice invoice, IPayment payment, Guid paymentMethodKey) { return(invoice.VoidPayment(payment, paymentMethodKey, new ProcessorArgumentCollection())); }
/// <summary> /// Voids a payment /// </summary> /// <param name="invoice">The invoice to be the payment was applied</param> /// <param name="payment">The payment to be voided</param> /// <param name="paymentMethodKey">The <see cref="IPaymentGatewayMethod"/> key</param> /// <param name="args">Additional arguements required by the payment processor</param> /// <returns>A <see cref="IPaymentResult"/></returns> public static IPaymentResult VoidPayment(this IInvoice invoice, IPayment payment, Guid paymentMethodKey, ProcessorArgumentCollection args) { return(invoice.VoidPayment(MerchelloContext.Current, payment, paymentMethodKey, args)); }
/// <summary> /// Voids a payment /// </summary> /// <param name="invoice">The invoice to be the payment was applied</param> /// <param name="merchelloContext">The <see cref="IMerchelloContext"/></param> /// <param name="payment">The payment to be voided</param> /// <param name="paymentMethodKey">The <see cref="IPaymentGatewayMethod"/> key</param> /// <param name="args">Additional arguements required by the payment processor</param> /// <returns>A <see cref="IPaymentResult"/></returns> internal static IPaymentResult VoidPayment(this IInvoice invoice, IMerchelloContext merchelloContext, IPayment payment, Guid paymentMethodKey, ProcessorArgumentCollection args) { var paymentGatewayMethod = merchelloContext.Gateways.Payment.GetPaymentGatewayMethodByKey(paymentMethodKey); return(paymentGatewayMethod.VoidPayment(invoice, payment, args)); }