Ejemplo n.º 1
0
        public string ProcessTransaction(int OrderNumber, int CustomerID, decimal OrderTotal, bool useLiveTransactions, TransactionModeEnum TransactionMode, Address UseBillingAddress, string CardExtraCode, Address UseShippingAddress, string CAVV, string ECI, string XID, out string AVSResult, out string AuthorizationResult, out string AuthorizationCode, out string AuthorizationTransID, out string TransactionCommandOut, out string TransactionResponse)
        {
            Processors.GatewayProcessor sn = GatewayLoader.GetProcessor("SecureNetV4");
            if (sn == null)
            {
                throw new ArgumentException("Gateway processor \"SecureNetV4\" must be present to process vault transactions.");
            }

            UseBillingAddress.CardNumber = "";//set card to empty to trigger vault transaction

            return(sn.ProcessCard(OrderNumber, CustomerID, OrderTotal, useLiveTransactions, TransactionMode, UseBillingAddress, CardExtraCode, UseShippingAddress, CAVV, ECI, XID, out AVSResult, out AuthorizationResult, out AuthorizationCode, out AuthorizationTransID, out TransactionCommandOut, out TransactionResponse));
        }
Ejemplo n.º 2
0
        public String ProcessAutoBillStatusFile(String GW, String StatusFile, out String Results)
        {
            String Status = AppLogic.ro_OK;

            Results = String.Empty;
            StringBuilder tmpS = new StringBuilder(4096);

            GatewayProcessor GWActual = GatewayLoader.GetProcessor(GW);

            if (GWActual != null)
            {
                string gwresults;
                Status = GWActual.ProcessAutoBillStatusFile(GW, StatusFile, out gwresults, this);
                tmpS.Append(gwresults);
            }

            tmpS.Append("\nEND_OF_FILE");
            Results = tmpS.ToString();
            return(Status);
        }
Ejemplo n.º 3
0
        public String ProcessAutoBillAddressUpdate(int OriginalRecurringOrderNumber, Address UseNewBillingInfo)
        {
            // update subscription to use new billing info
            String Status = AppLogic.ro_OK;
            String GW     = AppLogic.ActivePaymentGatewayCleaned();
            String RecurringSubscriptionID = AppLogic.GetRecurringSubscriptionIDFromOrder(OriginalRecurringOrderNumber);

            if (RecurringSubscriptionID.Length != 0)
            {
                // dynamically load the gateway processor class via the name
                GatewayProcessor processor = GatewayLoader.GetProcessor(GW);
                if (processor != null)
                {
                    Status = processor.RecurringBillingAddressUpdate(RecurringSubscriptionID,
                                                                     OriginalRecurringOrderNumber,
                                                                     UseNewBillingInfo);
                }
                else
                {
                    if (GW == Gateway.ro_GWPAYFLOWPRO)
                    {
                        GatewayProcessor pfp = GatewayLoader.GetProcessor(Gateway.ro_GWPAYFLOWPRO);

                        Status = pfp.RecurringBillingAddressUpdate(RecurringSubscriptionID, OriginalRecurringOrderNumber, UseNewBillingInfo);
                    }
                    else
                    {
                        Status = "Invalid Gateway";
                    }
                }
            }

            if (AppLogic.AppConfigBool("AuditLog.Enabled"))
            {
                StringBuilder sbDetails = new StringBuilder("Result=" + Status);
                sbDetails.Append(", RecurringSubscriptionID=" + RecurringSubscriptionID);
                sbDetails.Append(", New Address=" + UseNewBillingInfo.DisplayHTML(true));
                AppLogic.AuditLogInsert(0, 0, OriginalRecurringOrderNumber, "ProcessAutoBillAddressUpdate", sbDetails.ToString(), CommonLogic.GetThisPageName(true), "RecurringOrderMgr");
            }
            return(Status);
        }
Ejemplo n.º 4
0
        public String GetAutoBillStatusFile(String GW, out String StatusFile)
        {
            String Status = AppLogic.ro_OK;

            StatusFile = String.Empty;

            if (GW == Gateway.ro_GWPAYFLOWPRO)
            {
                StatusFile = GatewayLoader.GetProcessor(Gateway.ro_GWPAYFLOWPRO).RecurringBillingGetStatusFile();
                return(Status);
            }

            GatewayProcessor GWActual = GatewayLoader.GetProcessor(GW);

            if (GW != null)
            {
                StatusFile = GWActual.RecurringBillingGetStatusFile();
            }

            return(Status);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// This will check for an existing AutoBill order for the CustomerID and
        /// return the number of days left on that order's subscription, if any.
        /// The existing AutoBill order will be canceled and the items deleted
        /// from the cart.
        /// This should only be used with AppConfig Recurring.LimitCustomerToOneOrder=TRUE
        /// </summary>
        /// <param name="CustomerID"></param>
        /// <returns>Number of subscription days to migrate from existing order. If not a subscription we return zero.</returns>
        public static int ProcessAutoBillMigrateExisting(int CustomerID)
        {
            // This should only be used with AppConfig Recurring.LimitCustomerToOneOrder=TRUE

            int    MigrateDays = 0;
            int    OriginalRecurringOrderNumber = 0;
            bool   IsSubscription          = false;
            String Status                  = AppLogic.ro_OK;
            String RecurringSubscriptionID = String.Empty;

            using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
            {
                dbconn.Open();
                using (IDataReader rs = DB.GetRS("Select top 1 OriginalRecurringOrderNumber, RecurringInterval from ShoppingCart  with (NOLOCK)  where RecurringSubscriptionID<>'' and CustomerID=" + CustomerID.ToString() + " order by OriginalRecurringOrderNumber desc", dbconn))
                {
                    if (rs.Read())
                    {
                        OriginalRecurringOrderNumber = DB.RSFieldInt(rs, "OriginalRecurringOrderNumber");
                        IsSubscription = (DB.RSFieldInt(rs, "RecurringInterval") > 0);
                    }
                }
            }

            if (OriginalRecurringOrderNumber != 0)
            {
                if (IsSubscription && !AppLogic.AppConfigBool("SubscriptionExtensionOccursFromOrderDate"))
                {
                    // get customer's current subscription expiration and compute days remaining
                    using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
                    {
                        dbconn.Open();
                        using (IDataReader rsCust = DB.GetRS("Select SubscriptionExpiresOn from customer  with (NOLOCK)  where CustomerID=" + CustomerID.ToString(), dbconn))
                        {
                            if (rsCust.Read())
                            {
                                TimeSpan TimeRemaining = DB.RSFieldDateTime(rsCust, "SubscriptionExpiresOn").Subtract(DateTime.Today);
                                // Only carry forward if Expires in future
                                if (TimeRemaining.Days > 0)
                                {
                                    MigrateDays = TimeRemaining.Days;
                                }
                            }
                        }
                    }
                }

                RecurringSubscriptionID = AppLogic.GetRecurringSubscriptionIDFromOrder(OriginalRecurringOrderNumber);

                if (RecurringSubscriptionID.Length != 0)
                {
                    // cancel the existing gateway billing
                    String GW = AppLogic.ActivePaymentGatewayCleaned();
                    if (RecurringSubscriptionID.Length != 0)
                    {
                        if (GW == Gateway.ro_GWPAYFLOWPRO)
                        {
                            GatewayProcessor             pfp = GatewayLoader.GetProcessor(Gateway.ro_GWPAYFLOWPRO);
                            IDictionary <string, string> transactionContext = new Dictionary <string, string>();

                            if (RecurringSubscriptionID.ToUpper().StartsWith("B-"))
                            {
                                transactionContext.Add("TENDER", "P");
                            }

                            Status = pfp.RecurringBillingCancelSubscription(RecurringSubscriptionID, OriginalRecurringOrderNumber, transactionContext);
                        }
                        else
                        {
                            Status = "Invalid Gateway";
                        }
                    }
                }

                // now clean up the original order from the cart
                DB.ExecuteSQL(String.Format("delete from kitcart where OriginalRecurringOrderNumber={0}", OriginalRecurringOrderNumber.ToString()));
                DB.ExecuteSQL(String.Format("delete from ShoppingCart where OriginalRecurringOrderNumber={0}", OriginalRecurringOrderNumber.ToString()));
            }
            else
            {
                Status = "OriginalRecurringOrderNumber Not Found.";
            }

            if (AppLogic.AppConfigBool("AuditLog.Enabled"))
            {
                StringBuilder sbDetails = new StringBuilder("Result=" + Status);
                sbDetails.Append(", RecurringSubscriptionID=" + RecurringSubscriptionID);
                sbDetails.Append(", MigrateDays=" + MigrateDays.ToString());
                AppLogic.AuditLogInsert(0, CustomerID, OriginalRecurringOrderNumber, "ProcessAutoBillMigrateExisting", sbDetails.ToString(), CommonLogic.GetThisPageName(true), "RecurringOrderMgr");
            }
            return(MigrateDays);
        }
Ejemplo n.º 6
0
        // main routine to cancel any active recurring order (can be subscription autobill or in-cart):
        public String CancelRecurringOrder(int OriginalRecurringOrderNumber)
        {
            String Status = AppLogic.ro_OK;

            if (OriginalRecurringOrderNumber != 0)
            {
                String RecurringSubscriptionID = AppLogic.GetRecurringSubscriptionIDFromOrder(OriginalRecurringOrderNumber);

                if (RecurringSubscriptionID.Length != 0)
                {
                    // a Gateway AutoBill order, so cancel the gateway billing first:
                    String GW = AppLogic.ActivePaymentGatewayCleaned();
                    if (RecurringSubscriptionID.Length != 0)
                    {
                        // dynamically load the gateway processor class via the name
                        GatewayProcessor processor = GatewayLoader.GetProcessor(GW);

                        IDictionary <string, string> transactionContext = new Dictionary <string, string>();

                        if (RecurringSubscriptionID.ToUpper().StartsWith("B-"))
                        {
                            transactionContext.Add("TENDER", "P");
                        }

                        if (processor != null)
                        {
                            Status = processor.RecurringBillingCancelSubscription(RecurringSubscriptionID, OriginalRecurringOrderNumber, transactionContext);
                        }
                        else
                        {
                            if (GW == Gateway.ro_GWPAYFLOWPRO)
                            {
                                GatewayProcessor pfp = GatewayLoader.GetProcessor(Gateway.ro_GWPAYFLOWPRO);

                                Status = pfp.RecurringBillingCancelSubscription(RecurringSubscriptionID, OriginalRecurringOrderNumber, transactionContext);
                            }
                            else
                            {
                                Status = "Invalid Gateway";
                            }
                        }
                    }
                }

                int ProcessCustomerID = Order.GetOrderCustomerID(OriginalRecurringOrderNumber);

                if (Status == AppLogic.ro_OK)
                {
                    // now clean it up in the cart only if it cannot be restarted/reactivated
                    DB.ExecuteSQL(String.Format("delete from kitcart where OriginalRecurringOrderNumber={0}", OriginalRecurringOrderNumber.ToString()));
                    DB.ExecuteSQL(String.Format("delete from ShoppingCart where OriginalRecurringOrderNumber={0}", OriginalRecurringOrderNumber.ToString()));

                    // now notify customer of cancellation:
                    Customer ProcessCustomer = new Customer(ProcessCustomerID, true);

                    try
                    {
                        // send email notification to customer
                        string emailSubject = String.Format("{0} - Recurring Order Canceled", AppLogic.AppConfig("StoreName"));
                        string emailBody    = String.Format("Your recurring order has been canceled. The original order number was: {0}", OriginalRecurringOrderNumber.ToString());
                        AppLogic.SendMail(subject: emailSubject,
                                          body: emailBody + AppLogic.AppConfig("MailFooter"),
                                          useHtml: true,
                                          fromAddress: AppLogic.AppConfig("ReceiptEMailFrom"),
                                          fromName: AppLogic.AppConfig("ReceiptEMailFromName"),
                                          toAddress: ProcessCustomer.EMail,
                                          toName: ProcessCustomer.EMail,
                                          bccAddresses: String.Empty,
                                          server: AppLogic.MailServer());


                        // send email notification to admin
                        if (AppLogic.AppConfig("GotOrderEMailTo").Length != 0 && !AppLogic.AppConfigBool("TurnOffStoreAdminEMailNotifications"))
                        {
                            String SendToList = AppLogic.AppConfig("GotOrderEMailTo").Replace(",", ";");
                            if (SendToList.IndexOf(';') != -1)
                            {
                                foreach (String s in SendToList.Split(';'))
                                {
                                    AppLogic.SendMail(subject: emailSubject,
                                                      body: emailBody + AppLogic.AppConfig("MailFooter"),
                                                      useHtml: true,
                                                      fromAddress: AppLogic.AppConfig("GotOrderEMailFrom"),
                                                      fromName: AppLogic.AppConfig("GotOrderEMailFromName"),
                                                      toAddress: s.Trim(),
                                                      toName: s.Trim(),
                                                      bccAddresses: String.Empty,
                                                      server: AppLogic.MailServer());
                                }
                            }
                            else
                            {
                                AppLogic.SendMail(subject: emailSubject,
                                                  body: emailBody + AppLogic.AppConfig("MailFooter"),
                                                  useHtml: true,
                                                  fromAddress: AppLogic.AppConfig("GotOrderEMailFrom"),
                                                  fromName: AppLogic.AppConfig("GotOrderEMailFromName"),
                                                  toAddress: SendToList,
                                                  toName: SendToList,
                                                  bccAddresses: String.Empty,
                                                  server: AppLogic.MailServer());
                            }
                        }
                    }
                    catch { }
                }

                if (AppLogic.AppConfigBool("AuditLog.Enabled"))
                {
                    StringBuilder sbDetails = new StringBuilder("Result=" + Status);
                    sbDetails.Append(", RecurringSubscriptionID=" + RecurringSubscriptionID);
                    AppLogic.AuditLogInsert(0, ProcessCustomerID, OriginalRecurringOrderNumber, "CancelRecurringOrder", sbDetails.ToString(), CommonLogic.GetThisPageName(true), "RecurringOrderMgr");
                }
            }
            return(Status);
        }