예제 #1
0
 public ActionResult <IEnumerable <string> > Get()
 {
     try
     {
         var result = TokenService.Auth("dcaro", "1234");
         return(Ok(result));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex));
     }
 }
예제 #2
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 cardholder authentication verification value.</param>
        /// <param name="ECI">The electronic commerce international .</param>
        /// <param name="XID">The transaction ID.</param>
        /// <param name="AVSResult">The avsResult.</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 out.</param>
        /// <param name="transactionResponse">The transaction response.</param>
        /// <returns> Status of the transaction </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 transactionID, out string avsResult, out string authorizationResult, out string authorizationCode, out string authorizationTransID, out string transactionCommandOut, out string transactionResponse)
        {
            avsResult             = "N/A"; // not supported
            authorizationResult   = string.Empty;
            authorizationCode     = string.Empty;
            transactionCommandOut = string.Empty;
            transactionResponse   = string.Empty;
            authorizationTransID  = string.Empty;

            // Merchant account
            string token      = AppLogic.AppConfig("NETAXEPT.Merchant_Token");
            string merchantID = AppLogic.AppConfig("NETAXEPT.Merchant_Id");

            // get the transaction string that was created of calling setup in the GetHTMLTicket
            string transactionString = Customer.Current.ThisCustomerSession["Nextaxept_TransactionString"];

            TokenService service = new TokenService();

            // the server url
            string url = string.Empty;

            if (AppLogic.AppConfigBool("UseLiveTransactions"))
            {
                url = AppLogic.AppConfig("NETAXEPT.Live_Server"); // use live
            }
            else
            {
                url = AppLogic.AppConfig("NETAXEPT.Test_Server"); // use test
            }

            service.Url = url;

            Result result     = null;
            Result authResult = null;

            try
            {
                result = service.ProcessSetup(token, merchantID, transactionString);

                // We will use this for the transactionString that BBS provided to ProcessSetup
                transactionCommandOut = transactionString;

                // Response from BBS or issuer
                authorizationResult = result.ResponseCode;

                authorizationCode = result.AuthorizationCode;

                if (result.ResponseCode.Equals("OK", StringComparison.OrdinalIgnoreCase))
                {
                    if (transactionMode == TransactionModeEnum.auth)
                    {
                        // Auth - Allows you to authorize the availability of funds for a transaction
                        //        but delay the capture of funds until a later time.
                        //        This method has one additional parameter: batchReconRef (mandatory).
                        //        In standard implementation this should be empty.
                        authResult = service.Auth(token, merchantID, result.TransactionId, string.Empty);

                        // The value returned should be the same as passed in
                        authorizationTransID = authResult.TransactionId;

                        // Textual description of condition (usually available if an error occurs)
                        transactionResponse = authResult.ResponseText;
                    }
                    else
                    {
                        // sale - Allows you to authorize and capture at the same time.
                        //       This method has two additional parameters: transactionReconRef and batchReconRef
                        authResult = service.Sale(token, merchantID, result.TransactionId, string.Empty, string.Empty);

                        authorizationTransID = authResult.TransactionId;

                        // Textual description of condition (usually available if an error occurs)
                        transactionResponse = authResult.ResponseText;
                    }
                }
            }
            catch (Exception ex)
            {
                SoapException se = ex as SoapException;

                if (se != null)
                {
                    GetStatusCodeMessage(se, out transactionResponse, out authorizationResult);
                }

                return("Error:" + ex.Message);
            }

            return(AppLogic.ro_OK);
        }