Пример #1
0
        /// <summary>
        /// Refunds the order.
        /// </summary>
        /// <param name="OriginalOrderNumber">The original order number.</param>
        /// <param name="NewOrderNumber">The new order number.</param>
        /// <param name="RefundAmount">The refund amount. If 0.0M, refund ordertotal</param>
        /// <param name="RefundReason">The refund reason.</param>
        /// <param name="UseBillingAddress">The use billing address.</param>
        /// <returns>Status</returns>
        public override String RefundOrder(int OriginalOrderNumber, int NewOrderNumber, decimal RefundAmount, String RefundReason, Address UseBillingAddress)
        {
            String result = String.Empty;
            double amount;

            //set service configuration
            GatewayUSAePay.USAePaySOAP.ueSoapServerPortType client = GetServiceClient(UseSandBox);


            var token = GetSecurityToken();

            Order o = new Order(OriginalOrderNumber);

            // if RefundAmount == 0.0M, then then ENTIRE order amount will be refunded!
            amount = (RefundAmount == System.Decimal.Zero) ? Convert.ToDouble(o.Total()) : Convert.ToDouble(RefundAmount);
            var response = new GatewayUSAePay.USAePaySOAP.TransactionResponse();

            try
            {
                response = client.refundTransaction(token, o.AuthorizationPNREF, Convert.ToDouble(amount));

                if (response.ResultCode == "A")
                {
                    result            = AppLogic.ro_OK;
                    o.RefundTXCommand = response.RefNum;
                    o.RefundTXResult  = string.Format(CultureInfo.CurrentCulture, "{0} - Amount: {1}", response.Result, amount);
                }
                else
                {
                    result           = string.Format(CultureInfo.CurrentCulture, "Refund not processed: {0}", response.Error);
                    o.RefundTXResult = string.Format(CultureInfo.CurrentCulture, "{0} - {1}", response.Result, response.Error);
                }
            }
            catch (Exception err)
            {
                result = string.Format("Refund Not Processed - {0}", err.Message);
                //nothing is returned from this method so exceptions are not logged
                SysLog.LogMessage(String.Format(CultureInfo.CurrentCulture, "USAePay Refund Transaction Exception - {0}", OriginalOrderNumber.ToString(CultureInfo.InvariantCulture)),
                                  err.Message,
                                  MessageTypeEnum.GeneralException,
                                  MessageSeverityEnum.Message);
            }

            return(result);
        }
Пример #2
0
        /// <summary>
        /// Captures the order
        /// </summary>
        /// <param name="o">The sales order</param>
        /// <returns>Status</returns>
        public override String CaptureOrder(Order o)
        {
            String result = String.Empty;

            //set service configuration
            GatewayUSAePay.USAePaySOAP.ueSoapServerPortType client = GetServiceClient(UseSandBox);

            if (o == null)
            {
                return("Empty Order");
            }

            var token    = GetSecurityToken();
            var response = new GatewayUSAePay.USAePaySOAP.TransactionResponse();

            try
            {
                response = client.captureTransaction(token, o.AuthorizationPNREF, Convert.ToDouble(o.Total()));
                if (response.ResultCode == "A")
                {
                    result = AppLogic.ro_OK;
                }
                else
                {
                    result = string.Format(CultureInfo.CurrentCulture, "Capture Not Processed: {0}", response.Error);
                }
            }
            catch (Exception err)
            {
                result = string.Format("Capture Not Processed - {0}", err.Message);
                //nothing is returned from this method so exceptions are not logged
                SysLog.LogMessage(String.Format(CultureInfo.CurrentCulture, "USAePay Capture Transaction Exception - {0}", o.OrderNumber.ToString(CultureInfo.InvariantCulture)),
                                  err.Message,
                                  MessageTypeEnum.GeneralException,
                                  MessageSeverityEnum.Message);
            }

            return(result);
        }
Пример #3
0
        /// <summary>
        /// Processes the card.
        /// </summary>
        /// <param name="OrderNumber">The order number.</param>
        /// <param name="CustomerID">The customer ID.</param>
        /// <param name="OrderTotal">The order total.</param>
        /// <param name="useLiveTransactions">if set to <c>true</c> [use live transactions].</param>
        /// <param name="TransactionMode">The transaction mode.</param>
        /// <param name="UseBillingAddress">The use billing address.</param>
        /// <param name="CardExtraCode">The card extra code.</param>
        /// <param name="UseShippingAddress">The use shipping address.</param>
        /// <param name="CAVV">The CAVV.</param>
        /// <param name="ECI">The ECI.</param>
        /// <param name="XID">The XID.</param>
        /// <param name="AVSResult">The AVS result.</param>
        /// <param name="AuthorizationResult">The authorization result.</param>
        /// <param name="AuthorizationCode">The authorization code.</param>
        /// <param name="AuthorizationTransID">The authorization trans ID.</param>
        /// <param name="TransactionCommandOut">The transaction command sent to the gateway</param>
        /// <param name="TransactionResponse">The transaction response.</param>
        /// <returns>Status</returns>
        public override String ProcessCard(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)
        {
            String result = AppLogic.ro_OK;

            AuthorizationCode = AuthorizationResult = AuthorizationTransID = AVSResult = TransactionCommandOut = TransactionResponse = String.Empty;

            //set service configuration
            GatewayUSAePay.USAePaySOAP.ueSoapServerPortType client = GetServiceClient(UseSandBox);


            var token = GetSecurityToken();

            var tran = GetProcessCardTransactionRequestObject(OrderTotal, OrderNumber, UseBillingAddress, CardExtraCode, CAVV, ECI, XID, UseShippingAddress);

            var response = new GatewayUSAePay.USAePaySOAP.TransactionResponse();

            if (TransactionMode == TransactionModeEnum.auth)
            {
                try
                {
                    response = client.runAuthOnly(token, tran);
                    if (response.ResultCode == "A")
                    {
                        result = AppLogic.ro_OK;
                    }
                    else if (response.ResultCode == "D")
                    {
                        result = string.Format("{0}: {1}", AppLogic.AppConfig("USAePay.Declined"), response.Error);
                    }
                    else
                    {
                        result = string.Format("{0}: {1}", AppLogic.AppConfig("USAePay.TransactionError"), response.Error);
                    }
                }
                catch (Exception ex)
                {
                    result = string.Format("{0}: {1}", AppLogic.AppConfig("USAePay.ConnectionError"), ex.Message);
                }
            }
            else if (TransactionMode == TransactionModeEnum.authcapture)
            {
                try
                {
                    response = client.runSale(token, tran);
                    if (response.ResultCode == "A")
                    {
                        result = AppLogic.ro_OK;
                    }
                    else if (response.ResultCode == "D")
                    {
                        result = string.Format("{0}: {1}", AppLogic.AppConfig("USAePay.Declined"), response.Error);
                    }
                    else
                    {
                        result = string.Format("{0}: {1}", AppLogic.AppConfig("USAePay.TransactionError"), response.Error);
                    }
                }
                catch (Exception ex)
                {
                    result = string.Format("{0}: {1}", AppLogic.AppConfig("USAePay.ConnectionError"), ex.Message);
                }
            }

            AVSResult             = response.AvsResult ?? String.Empty;
            AuthorizationResult   = response.CardCodeResult ?? String.Empty;
            AuthorizationCode     = response.AuthCode ?? String.Empty;
            AuthorizationTransID  = response.RefNum ?? String.Empty;
            TransactionCommandOut = response.Error ?? String.Empty;            //Approved, etc
            TransactionResponse   = response.Result ?? String.Empty;

            return(result);
        }