public static string WebTest()
        {
            string       store_id   = "store5";
            string       api_token  = "yesguy";
            string       order_id   = "Test20150625014816";
            string       amount     = "5.00";
            string       txn_number = "113524-0_10";
            string       processing_country_code = "CA";
            bool         status_check            = false;
            IDebitRefund refund = new IDebitRefund();

            refund.SetOrderId(order_id);
            refund.SetAmount(amount);
            refund.SetTxnNumber(txn_number);
            HttpsPostRequest mpgReq = new HttpsPostRequest();

            mpgReq.SetProcCountryCode(processing_country_code);
            mpgReq.SetTestMode(true); //false or comment out this line for production transactions
            mpgReq.SetStoreId(store_id);
            mpgReq.SetApiToken(api_token);
            mpgReq.SetTransaction(refund);
            mpgReq.SetStatusCheck(status_check);
            mpgReq.Send();

            StringBuilder stringBuilder = new StringBuilder();

            try
            {
                Receipt receipt = mpgReq.GetReceipt();
                stringBuilder.AppendLine("CardType = " + receipt.GetCardType() + "<br/>");
                stringBuilder.AppendLine("TransAmount = " + receipt.GetTransAmount() + "<br/>");
                stringBuilder.AppendLine("TxnNumber = " + receipt.GetTxnNumber() + "<br/>");
                stringBuilder.AppendLine("ReceiptId = " + receipt.GetReceiptId() + "<br/>");
                stringBuilder.AppendLine("TransType = " + receipt.GetTransType() + "<br/>");
                stringBuilder.AppendLine("ReferenceNum = " + receipt.GetReferenceNum() + "<br/>");
                stringBuilder.AppendLine("ResponseCode = " + receipt.GetResponseCode() + "<br/>");
                stringBuilder.AppendLine("ISO = " + receipt.GetISO() + "<br/>");
                stringBuilder.AppendLine("BankTotals = " + receipt.GetBankTotals() + "<br/>");
                stringBuilder.AppendLine("Message = " + receipt.GetMessage() + "<br/>");
                stringBuilder.AppendLine("AuthCode = " + receipt.GetAuthCode() + "<br/>");
                stringBuilder.AppendLine("Complete = " + receipt.GetComplete() + "<br/>");
                stringBuilder.AppendLine("TransDate = " + receipt.GetTransDate() + "<br/>");
                stringBuilder.AppendLine("TransTime = " + receipt.GetTransTime() + "<br/>");
                stringBuilder.AppendLine("Ticket = " + receipt.GetTicket() + "<br/>");
                stringBuilder.AppendLine("TimedOut = " + receipt.GetTimedOut() + "<br/>");
            }
            catch (Exception e)
            {
                stringBuilder.AppendLine(e.Message);
                stringBuilder.AppendLine(e.StackTrace);
            }

            return(stringBuilder.ToString());
        }
Exemple #2
0
        public TransactionResponse PerformTransaction(Transaction t)
        {
            HttpsPostRequest mpgReq = new HttpsPostRequest();

            mpgReq.SetProcCountryCode(t.Merchant.ProcessingCountry.ToString());
            mpgReq.SetTestMode(t.Merchant.Environment == Merchant.EnvironmentType.QA); //false or comment out this line for production transactions
            mpgReq.SetStoreId(t.Merchant.StoreId);
            mpgReq.SetApiToken(t.Merchant.ApiToken);
            mpgReq.SetStatusCheck(t.StatusCheck);


            TransactionResponse transactionResponse = new TransactionResponse
            {
                Exception = null
            };

            switch (t.CurrentTransactionType)
            {
            case Transaction.TransactionType.Purchase:
                break;

            case Transaction.TransactionType.InteracOnlinePurchase:
                IDebitPurchase IOP_Txn = new IDebitPurchase();
                IOP_Txn.SetOrderId(t.OrderId);
                IOP_Txn.SetCustId(t.CustId);
                IOP_Txn.SetAmount(t.Amount);
                IOP_Txn.SetIdebitTrack2(t.Track2);
                mpgReq.SetTransaction(IOP_Txn);

                break;

            case Transaction.TransactionType.Refund:
                Refund refund = new Refund();
                refund.SetOrderId(t.OrderId);
                refund.SetAmount(t.Amount);
                refund.SetTxnNumber(t.TxnNumber);
                refund.SetCryptType(t.CrtpyType);
                mpgReq.SetTransaction(refund);
                break;

            case Transaction.TransactionType.InteracOnlineRefund:

                IDebitRefund debitRefund = new IDebitRefund();
                debitRefund.SetOrderId(t.OrderId);
                debitRefund.SetAmount(t.Amount);
                debitRefund.SetTxnNumber(t.TxnNumber);
                mpgReq.SetTransaction(debitRefund);

                break;

            case Transaction.TransactionType.CardVerification:
                break;

            default:
                break;
            }

            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

            mpgReq.Send();

            try
            {
                Receipt receipt = mpgReq.GetReceipt();

                transactionResponse.CardType     = receipt.GetCardType();
                transactionResponse.TransAmount  = receipt.GetTransAmount();
                transactionResponse.TxnNumber    = receipt.GetTxnNumber();
                transactionResponse.ReceiptId    = receipt.GetReceiptId();
                transactionResponse.TransType    = receipt.GetTransType();
                transactionResponse.ReferenceNum = receipt.GetReferenceNum();
                transactionResponse.ResponseCode = receipt.GetResponseCode();
                transactionResponse.ISO          = receipt.GetISO();

                transactionResponse.BankTotals = receipt.GetBankTotals();
                transactionResponse.Message    = receipt.GetMessage();
                transactionResponse.AuthCode   = receipt.GetAuthCode();
                transactionResponse.CardType   = receipt.GetCardType();
                transactionResponse.Complete   = receipt.GetComplete();
                transactionResponse.TransDate  = receipt.GetTransDate();
                transactionResponse.TransTime  = receipt.GetTransTime();
                transactionResponse.Ticket     = receipt.GetTicket();
                transactionResponse.TimedOut   = receipt.GetTimedOut();
            }
            catch (Exception ex)
            {
                transactionResponse.Exception = ex;
            }


            return(transactionResponse);
        }