Exemplo n.º 1
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // This file is only implemented for Authorize.net Automated Recurring Billing
            if (CommonLogic.FormCanBeDangerousContent("x_subscription_id").Length != 0)
            {
                String   TxSubID  = CommonLogic.FormCanBeDangerousContent("x_subscription_id");
                String   TxStatus = CommonLogic.FormCanBeDangerousContent("x_response_code");
                String   TxMsg    = CommonLogic.FormCanBeDangerousContent("x_response_reason_text");
                String   TxID     = CommonLogic.FormCanBeDangerousContent("x_trans_id");
                String   TxAmount = CommonLogic.FormCanBeDangerousContent("x_amount");
                DateTime dtTx     = System.DateTime.Now;

                String tmpStatus = String.Empty;

                int OrigOrdNumber = AppLogic.GetOriginalRecurringOrderNumberFromSubscriptionID(TxSubID);

                if (OrigOrdNumber == 0)
                {
                    tmpStatus = "Silent Post: No Original Order Found";
                    if (TxID.Length != 0)
                    {
                        tmpStatus += ", PNREF=" + TxID;
                    }
                    DB.ExecuteSQL("insert into FailedTransaction(CustomerID,OrderNumber,IPAddress,OrderDate,PaymentGateway,PaymentMethod,TransactionCommand,TransactionResult,CustomerEMailed,RecurringSubscriptionID) values(" +
                                  "0,0,'0.0.0.0'," + DB.DateQuote(dtTx) + "," + DB.SQuote("AUTHORIZENET") + "," +
                                  DB.SQuote(AppLogic.TransactionTypeEnum.RECURRING_AUTO.ToString()) + "," + DB.SQuote(AppLogic.ro_NotApplicable) + "," + DB.SQuote(tmpStatus) + ",0," + DB.SQuote(TxSubID) + ")");
                }
                else
                {
                    if (TxStatus == "1") // Approved
                    {
                        int NewOrderNumber     = 0;
                        RecurringOrderMgr rmgr = new RecurringOrderMgr(AppLogic.MakeEntityHelpers(), null);
                        tmpStatus = rmgr.ProcessAutoBillApproved(OrigOrdNumber, TxID, dtTx, out NewOrderNumber);
                    }
                    else
                    {
                        RecurringOrderMgr rmgr = new RecurringOrderMgr(AppLogic.MakeEntityHelpers(), null);
                        tmpStatus = rmgr.ProcessAutoBillDeclined(OrigOrdNumber, TxID, dtTx, TxSubID, TxMsg);
                    }

                    if (tmpStatus != AppLogic.ro_OK)
                    {
                        int      ProcessCustomerID = Order.GetOrderCustomerID(OrigOrdNumber);
                        Customer ProcessCustomer   = new Customer(ProcessCustomerID, true);

                        if (TxID.Length != 0)
                        {
                            tmpStatus += ", PNREF=" + TxID;
                        }
                        DB.ExecuteSQL("insert into FailedTransaction(CustomerID,OrderNumber,IPAddress,OrderDate,PaymentGateway,PaymentMethod,TransactionCommand,TransactionResult,CustomerEMailed,RecurringSubscriptionID) values(" +
                                      ProcessCustomer.CustomerID.ToString() + "," + OrigOrdNumber.ToString() + "," +
                                      DB.SQuote("0.0.0.0") + "," + DB.DateQuote(dtTx) + "," + DB.SQuote("AUTHORIZENET") + "," +
                                      DB.SQuote(AppLogic.TransactionTypeEnum.RECURRING_AUTO.ToString()) + "," + DB.SQuote(AppLogic.ro_NotApplicable) + "," + DB.SQuote(tmpStatus) + ",0," + DB.SQuote(TxSubID) + ")");
                    }
                }
            }
            Response.Write("OK");
        }
Exemplo n.º 2
0
        public ActionResult AuthorizeNetSilentPost(FormCollection collection)
        {
            var subscriptionId  = collection["x_subscription_id"] ?? string.Empty;
            var responseCode    = collection["x_response_code"] ?? string.Empty;
            var responseReason  = collection["x_response_reason_text"] ?? string.Empty;
            var transactionId   = collection["x_trans_id"] ?? string.Empty;
            var amount          = collection["x_amount"] ?? string.Empty;
            var transactionDate = DateTime.Now;

            if (string.IsNullOrEmpty(subscriptionId))
            {
                return(Content(string.Empty));
            }

            var originalOrderId = AppLogic.GetOriginalRecurringOrderNumberFromSubscriptionID(subscriptionId);
            var status          = string.Empty;

            if (originalOrderId == 0)
            {
                status = "Silent Post: No Original Order Found";
                if (!string.IsNullOrEmpty(transactionId))
                {
                    status += ", PNREF=" + transactionId;
                }

                DB.ExecuteSQL(@"INSERT INTO FailedTransaction(CustomerID, 
															OrderNumber, 
															IPAddress, 
															OrderDate, 
															PaymentGateway, 
															PaymentMethod, 
															TransactionCommand, 
															TransactionResult, 
															CustomerEMailed, 
															RecurringSubscriptionID) 
								VALUES(0, 0, @ipAddress, @transactionDate, @gateway, @paymentMethod, @command, @status, 0, @subscriptionId)"                                ,
                              new SqlParameter[]
                {
                    new SqlParameter("@ipAddress", "0.0.0.0"),
                    new SqlParameter("@transactionDate", transactionDate),
                    new SqlParameter("@gateway", "AUTHORIZENET"),
                    new SqlParameter("@paymentMethod", AppLogic.TransactionTypeEnum.RECURRING_AUTO.ToString()),
                    new SqlParameter("@command", AppLogic.ro_NotApplicable),
                    new SqlParameter("@status", status),
                    new SqlParameter("@subscriptionId", subscriptionId),
                }
                              );
            }
            else
            {
                if (responseCode.Equals("1"))                // Approved
                {
                    var newOrderNumber = 0;
                    var manager        = new RecurringOrderMgr();
                    status = manager.ProcessAutoBillApproved(originalOrderId, transactionId, transactionDate, out newOrderNumber);
                }
                else
                {
                    var manager = new RecurringOrderMgr();
                    status = manager.ProcessAutoBillDeclined(originalOrderId, transactionId, transactionDate, subscriptionId, responseReason);
                }

                if (status.Equals(AppLogic.ro_OK, StringComparison.InvariantCultureIgnoreCase))
                {
                    var customerId = Order.GetOrderCustomerID(originalOrderId);
                    var customer   = new Customer(customerId, true);

                    if (!string.IsNullOrEmpty(transactionId))
                    {
                        status += ", PNREF=" + transactionId;
                    }

                    DB.ExecuteSQL(@"INSERT INTO FailedTransaction(CustomerID, 
																	OrderNumber, 
																	IPAddress, 
																	OrderDate, 
																	PaymentGateway, 
																	PaymentMethod, 
																	TransactionCommand, 
																	TransactionResult, 
																	CustomerEMailed, 
																	RecurringSubscriptionID) 
									VALUES(@customerId, @orderId, @ipAddress, @transactionDate, @gateway, @paymentMethod, @command, @status, 0, @subscriptionId)"                                    ,
                                  new SqlParameter[]
                    {
                        new SqlParameter("@customerId", customer.CustomerID),
                        new SqlParameter("@orderId", originalOrderId),
                        new SqlParameter("@ipAddress", "0.0.0.0"),
                        new SqlParameter("@transactionDate", transactionDate),
                        new SqlParameter("@gateway", "AUTHORIZENET"),
                        new SqlParameter("@paymentMethod", AppLogic.TransactionTypeEnum.RECURRING_AUTO.ToString()),
                        new SqlParameter("@command", AppLogic.ro_NotApplicable),
                        new SqlParameter("@status", status),
                        new SqlParameter("@subscriptionId", subscriptionId),
                    }
                                  );
                }
            }

            return(Content(AppLogic.ro_OK));
        }
Exemplo n.º 3
0
        public ActionResult AuthorizeNetSilentPost(FormCollection collection)
        {
            SysLog.LogMessage(
                message: "Received a recurring payment notification from Authorize.Net.",
                details: Gateway.ListFormCollectionKeyValuePairs(collection),
                messageType: MessageTypeEnum.Informational,
                messageSeverity: MessageSeverityEnum.Alert);

            var subscriptionId  = collection["x_subscription_id"] ?? string.Empty;
            var responseCode    = collection["x_response_code"] ?? string.Empty;
            var responseReason  = collection["x_response_reason_text"] ?? string.Empty;
            var transactionId   = collection["x_trans_id"] ?? string.Empty;
            var amount          = collection["x_amount"] ?? string.Empty;
            var transactionDate = DateTime.Now;

            if (string.IsNullOrEmpty(subscriptionId))
            {
                return(Content(string.Empty));
            }

            var originalOrderId = AppLogic.GetOriginalRecurringOrderNumberFromSubscriptionID(subscriptionId);
            var status          = string.Empty;

            if (originalOrderId == 0)
            {
                status = "Silent Post: No Original Order Found";
                if (!string.IsNullOrEmpty(transactionId))
                {
                    status += ", PNREF=" + transactionId;
                }

                DB.ExecuteSQL(@"
					insert into FailedTransaction(CustomerID, 
						OrderNumber, 
						IPAddress, 
						OrderDate, 
						PaymentGateway, 
						PaymentMethod, 
						TransactionCommand, 
						TransactionResult, 
						CustomerEMailed, 
						RecurringSubscriptionID) 
					values(
						0, 
						0, 
						@ipAddress, 
						@transactionDate, 
						@gateway, 
						@paymentMethod, 
						@command, 
						@status, 
						0, 
						@subscriptionId)"                        ,
                              new SqlParameter[]
                {
                    new SqlParameter("@ipAddress", "0.0.0.0"),
                    new SqlParameter("@transactionDate", transactionDate),
                    new SqlParameter("@gateway", "AUTHORIZENET"),
                    new SqlParameter("@paymentMethod", AppLogic.TransactionTypeEnum.RECURRING_AUTO.ToString()),
                    new SqlParameter("@command", AppLogic.ro_NotApplicable),
                    new SqlParameter("@status", status),
                    new SqlParameter("@subscriptionId", subscriptionId),
                }
                              );
            }
            else
            {
                if (responseCode.Equals("1"))                // Approved
                {
                    var newOrderNumber = 0;
                    var manager        = new RecurringOrderMgr();
                    status = manager.ProcessAutoBillApproved(originalOrderId, transactionId, transactionDate, out newOrderNumber);
                }
                else
                {
                    var manager = new RecurringOrderMgr();
                    status = manager.ProcessAutoBillDeclined(originalOrderId, transactionId, transactionDate, subscriptionId, responseReason);
                }

                if (!StringComparer.OrdinalIgnoreCase.Equals(status, AppLogic.ro_OK))
                {
                    var customerId = Order.GetOrderCustomerID(originalOrderId);
                    var customer   = new Customer(customerId, true);

                    if (!string.IsNullOrEmpty(transactionId))
                    {
                        status += ", PNREF=" + transactionId;
                    }

                    DB.ExecuteSQL(@"
						insert into FailedTransaction(
							CustomerID, 
							OrderNumber, 
							IPAddress, 
							OrderDate, 
							PaymentGateway, 
							PaymentMethod, 
							TransactionCommand, 
							TransactionResult, 
							CustomerEMailed, 
							RecurringSubscriptionID)
						values(
							@customerId, 
							@orderId, 
							@ipAddress, 
							@transactionDate, 
							@gateway, 
							@paymentMethod, 
							@command, 
							@status, 
							0, 
							@subscriptionId)"                            ,
                                  new SqlParameter[]
                    {
                        new SqlParameter("@customerId", customer.CustomerID),
                        new SqlParameter("@orderId", originalOrderId),
                        new SqlParameter("@ipAddress", "0.0.0.0"),
                        new SqlParameter("@transactionDate", transactionDate),
                        new SqlParameter("@gateway", "AUTHORIZENET"),
                        new SqlParameter("@paymentMethod", AppLogic.TransactionTypeEnum.RECURRING_AUTO.ToString()),
                        new SqlParameter("@command", AppLogic.ro_NotApplicable),
                        new SqlParameter("@status", status),
                        new SqlParameter("@subscriptionId", subscriptionId),
                    }
                                  );
                }
            }

            return(Content(AppLogic.ro_OK));
        }