Esempio n. 1
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);
        }
Esempio n. 2
0
        public static void Test()
        {
            string store_id  = "store5";
            string api_token = "yesguy";
            string order_id  = "Test" + DateTime.Now.ToString("yyyyMMddhhmmss");
            string cust_id   = "Lance_Briggs_55";
            string amount    = "5.00";
            string track2    = "5268051119993326=0609AAAAAAAAAAAAA000";
            string processing_country_code = "CA";
            bool   status_check            = false;
            /********************* Billing/Shipping Variables ****************************/
            string first_name    = "Bob";
            string last_name     = "Smith";
            string company_name  = "ProLine Inc.";
            string address       = "623 Bears Ave";
            string city          = "Chicago";
            string province      = "Illinois";
            string postal_code   = "M1M2M1";
            string country       = "Canada";
            string phone         = "777-999-7777";
            string fax           = "777-999-7778";
            string tax1          = "10.00";
            string tax2          = "5.78";
            string tax3          = "4.56";
            string shipping_cost = "10.00";

            /********************* Order Line Item Variables *****************************/
            string[] item_description     = new string[] { "Chicago Bears Helmet", "Soldier Field Poster" };
            string[] item_quantity        = new string[] { "1", "1" };
            string[] item_product_code    = new string[] { "CB3450", "SF998S" };
            string[] item_extended_amount = new string[] { "150.00", "19.79" };
            /********************** Customer Information Object **************************/
            CustInfo customer = new CustInfo();

            /********************** Set Customer Billing Information **********************/
            customer.SetBilling(first_name, last_name, company_name, address, city,
                                province, postal_code, country, phone, fax, tax1, tax2,
                                tax3, shipping_cost);
            /******************** Set Customer Shipping Information ***********************/
            customer.SetShipping(first_name, last_name, company_name, address, city,
                                 province, postal_code, country, phone, fax, tax1, tax2,
                                 tax3, shipping_cost);
            /***************************** Order Line Items ******************************/
            customer.SetItem(item_description[0], item_quantity[0],
                             item_product_code[0], item_extended_amount[0]);
            customer.SetItem(item_description[1], item_quantity[1],
                             item_product_code[1], item_extended_amount[1]);
            /************************** Request *************************/
            IDebitPurchase IOP_Txn = new IDebitPurchase();

            IOP_Txn.SetOrderId(order_id);
            IOP_Txn.SetCustId(cust_id);
            IOP_Txn.SetAmount(amount);
            IOP_Txn.SetIdebitTrack2(track2);
            IOP_Txn.SetCustInfo(customer);
            //IOP_Txn.SetDynamicDescriptor("dynamicdescriptor1");
            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(IOP_Txn);
            mpgReq.SetStatusCheck(status_check);
            mpgReq.Send();
            try
            {
                Receipt receipt = mpgReq.GetReceipt();



                Console.WriteLine("CardType = " + receipt.GetCardType());
                Console.WriteLine("TransAmount = " + receipt.GetTransAmount());
                Console.WriteLine("TxnNumber = " + receipt.GetTxnNumber());
                Console.WriteLine("ReceiptId = " + receipt.GetReceiptId());
                Console.WriteLine("TransType = " + receipt.GetTransType());
                Console.WriteLine("ReferenceNum = " + receipt.GetReferenceNum());
                Console.WriteLine("ResponseCode = " + receipt.GetResponseCode());
                Console.WriteLine("ISO = " + receipt.GetISO());
                Console.WriteLine("BankTotals = " + receipt.GetBankTotals());
                Console.WriteLine("Message = " + receipt.GetMessage());
                Console.WriteLine("AuthCode = " + receipt.GetAuthCode());
                Console.WriteLine("Complete = " + receipt.GetComplete());
                Console.WriteLine("TransDate = " + receipt.GetTransDate());
                Console.WriteLine("TransTime = " + receipt.GetTransTime());
                Console.WriteLine("Ticket = " + receipt.GetTicket());
                Console.WriteLine("TimedOut = " + receipt.GetTimedOut());
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        public static void Main(string[] args)
        {
            string host = "esqa.moneris.com";
            string store_id = "store5";
            string api_token = "yesguy";
            string order_id = "Need_Unique_Order_ID_Cust_Info_005";
            string cust_id = "Lance_Briggs_55";
            string amount = "5.00";
            string track2 = "5268051119993326=0609AAAAAAAAAAAAA000";

              /********************* Billing/Shipping Variables ****************************/

              string first_name = "Bob";
              string last_name = "Smith";
              string company_name = "ProLine Inc.";
              string address = "623 Bears Ave";
              string city = "Chicago";
              string province = "Illinois";
              string postal_code = "M1M2M1";
              string country = "Canada";
              string phone = "777-999-7777";
              string fax = "777-999-7778";
              string tax1 = "10.00";
              string tax2 = "5.78";
              string tax3 = "4.56";
              string shipping_cost = "10.00";

              /********************* Order Line Item Variables *****************************/

              string[] item_description = new string[]{"Chicago Bears Helmet", "Soldier Field Poster"};
              string[] item_quantity = new string[]{"1", "1"};
              string[] item_product_code = new string[]{"CB3450", "SF998S"};
              string[] item_extended_amount = new string[]{"150.00", "19.79"};

              /********************** Customer Information Object **************************/

              CustInfo customer = new CustInfo();

              /********************** Set Customer Billing Information **********************/

              customer.SetBilling (first_name, last_name, company_name, address, city,
                               province, postal_code, country, phone, fax, tax1, tax2,
                               tax3, shipping_cost);

              /******************** Set Customer Shipping Information ***********************/

              customer.SetShipping (first_name, last_name, company_name, address, city,
                                province, postal_code, country, phone, fax, tax1, tax2,
                                tax3, shipping_cost);

              /***************************** Order Line Items  ******************************/

              customer.SetItem (item_description[0], item_quantity[0],
                            item_product_code[0], item_extended_amount[0]);

              customer.SetItem (item_description[1], item_quantity[1],
                            item_product_code[1], item_extended_amount[1]);

               	/************************** Request *************************/

            IDebitPurchase IOP_Txn = new IDebitPurchase (order_id, cust_id, amount, track2);

            IOP_Txn.SetCustInfo (customer);

            //IOP_Txn.SetDynamicDescriptor("dynamicdescriptor1");

            HttpsPostRequest mpgReq =
                new HttpsPostRequest(host, store_id, api_token, IOP_Txn);

            try
            {
               	Receipt receipt = mpgReq.GetReceipt();

                Console.WriteLine("CardType = " + receipt.GetCardType());
                Console.WriteLine("TransAmount = " + receipt.GetTransAmount());
                Console.WriteLine("TxnNumber = " + receipt.GetTxnNumber());
                Console.WriteLine("ReceiptId = " + receipt.GetReceiptId());
                Console.WriteLine("TransType = " + receipt.GetTransType());
                Console.WriteLine("ReferenceNum = " + receipt.GetReferenceNum());
                Console.WriteLine("ResponseCode = " + receipt.GetResponseCode());
                Console.WriteLine("ISO = " + receipt.GetISO());
                Console.WriteLine("BankTotals = " + receipt.GetBankTotals());
                Console.WriteLine("Message = " + receipt.GetMessage());
                Console.WriteLine("AuthCode = " + receipt.GetAuthCode());
                Console.WriteLine("Complete = " + receipt.GetComplete());
                Console.WriteLine("TransDate = " + receipt.GetTransDate());
                Console.WriteLine("TransTime = " + receipt.GetTransTime());
                Console.WriteLine("Ticket = " + receipt.GetTicket());
                Console.WriteLine("TimedOut = " + receipt.GetTimedOut());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }