コード例 #1
0
        /// <summary>
        /// Commits taxes after an order is placed
        /// </summary>
        /// <param name="order">The order that was placed</param>
        /// <remarks>This step is necessary for some providers such as CertiTAX for the purposes
        /// of tax reporting.  The native AbleCommerce provider does not require this step.</remarks>
        internal static void CommitTaxes(Order order)
        {
            TaxGatewayCollection taxGateways = Token.Instance.Store.TaxGateways;

            foreach (TaxGateway taxGateway in taxGateways)
            {
                ITaxProvider provider = taxGateway.GetProviderInstance();
                if (provider != null)
                {
                    provider.Commit(order);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets the configured avatax gateway
        /// </summary>
        /// <returns>The configured avatax gateway, or null if it is not configured</returns>
        private static TaxGateway LocateAvaTaxGateway()
        {
            TaxGatewayCollection taxGateways = Token.Instance.Store.TaxGateways;

            foreach (TaxGateway taxGateway in taxGateways)
            {
                if (taxGateway.Name == "Avalara AvaTax")
                {
                    return(taxGateway);
                }
            }
            return(null);
        }
コード例 #3
0
        /// <summary>
        /// Cancel this order.
        /// </summary>
        /// <param name="voidPayments">If true, any payments in a voidable state will have be voided.</param>
        public void Cancel(bool voidPayments)
        {
            //VOID ANY INCOMPLETED PAYMENTS
            if (voidPayments)
            {
                int paymentCount = this.Payments.Count;
                for (int i = 0; i < paymentCount; i++)
                {
                    Payment payment = this.Payments[i];
                    if (payment.IsVoidable)
                    {
                        payment.Void();
                    }
                }
            }
            // CANCEL ANY TAXES FROM INTEGRATED PROVIDERS
            TaxGatewayCollection taxGateways = Token.Instance.Store.TaxGateways;

            foreach (TaxGateway taxGateway in taxGateways)
            {
                ITaxProvider provider = taxGateway.GetProviderInstance();
                if (provider != null)
                {
                    try
                    {
                        provider.Cancel(this);
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("Could not cancel with the configured tax provider: " + taxGateway.ClassId, ex);
                    }
                }
                else
                {
                    Logger.Error("Could not load the configured tax provider: " + taxGateway.ClassId);
                }
            }
            //TRIGGER THE ORDER CANCELLED EVENT
            StoreEventEngine.OrderCancelled(this);
        }