コード例 #1
0
        static void Main(string[] args)
        {
            String initParams =
                "certificateFile=CERT_FILE" + "&" +
                "logDirectory=LOG_DIR";
            PayWayAPI payWayAPI = new PayWayAPI();

            payWayAPI.Initialise(initParams);

            Hashtable requestParameters = new Hashtable();

            requestParameters.Add("customer.username", "USER");
            requestParameters.Add("customer.password", "PASS");
            requestParameters.Add("customer.merchant", "TEST");
            requestParameters.Add("order.type", "capture");
            requestParameters.Add("card.PAN", "4564710000000004");
            requestParameters.Add("card.CVN", "847");
            requestParameters.Add("card.expiryYear", "09");
            requestParameters.Add("card.expiryMonth", "02");
            requestParameters.Add("order.amount", "1008");
            requestParameters.Add("customer.orderNumber", "" + DateTime.Now.Ticks);
            requestParameters.Add("card.currency", "AUD");
            requestParameters.Add("order.ECI", "SSL");

            string requestText = payWayAPI.FormatRequestParameters(requestParameters);

            string responseText = payWayAPI.ProcessCreditCard(requestText);

            Console.Out.WriteLine("\r\nRequest: " + requestText);
            Console.Out.WriteLine("\r\nResponse: " + responseText);
            Console.Out.WriteLine("");

            // Break the response string into its component parameters
            IDictionary responseParameters = payWayAPI.ParseResponseParameters(responseText);

            // Print out the parameters:
            IDictionaryEnumerator enumerator = responseParameters.GetEnumerator();

            while (enumerator.MoveNext())
            {
                string name = (string)enumerator.Key;
                string val  = (string)enumerator.Value;

                Console.Write(name + ": ");
                for (int i = name.Length; i < 25; i++)
                {
                    Console.Write(' ');
                }
                Console.WriteLine(val);
            }
        }
コード例 #2
0
ファイル: Default.aspx.cs プロジェクト: blendev/Trumans
        protected void btnCCPayment_Click(object sender, EventArgs e)
        {
            PayWayAPI payWayAPI = (PayWayAPI)Application["PayWayAPI"];

            //----------------------------------------------------------------------------
            // SET CONNECTION DEFAULTS
            //----------------------------------------------------------------------------
            string orderECI  = "SSL";
            string orderType = "capture";

            cardNumber             = ccNo.Value.ToString();
            cardVerificationNumber = CVV.Value.ToString();
            cardExpiryYear         = txtYear.Value.ToString();
            cardExpiryMonth        = ExpiryMonth.Value.ToString();

            StreamWriter File2 = File.AppendText(HttpContext.Current.Server.MapPath("~/Logs/file.txt"));

            File2.WriteLine("Year and month  : " + cardExpiryYear + " - " + cardExpiryMonth);
            File2.Close();

            string card_currency = "AUD";
            var    ActualAmount  = amount.Value;
            var    Surcharge     = Math.Round((Convert.ToDouble(amount.Value) * 2) / 100, 2);

            orderAmountCents =
                Convert.ToString(Convert.ToUInt64(Math.Round(
                                                      Convert.ToDouble(amount.Value.ToString()) * 100) + Surcharge * 100));

            string customerUsername = System.Configuration.ConfigurationManager.AppSettings["CCUserName"].ToString();
            string customerPassword = System.Configuration.ConfigurationManager.AppSettings["CCPassword"].ToString();
            string customerMerchant = System.Configuration.ConfigurationManager.AppSettings["CCMerchant"].ToString();

            // Note: you must supply a unique order number for each transaction request.
            // We recommend that you store each transaction request in your database and
            // that the order number is the primary key for the transaction record in that
            // database.
            Guid   guid = Guid.NewGuid();
            string str  = guid.ToString();

            string orderNumber = Convert.ToString(accountNum.Value.ToString() + '-' + str.Substring(0, 8));
            //"01";

            //----------------------------------------------------------------------------
            //INITIALISE CONNECTION VARIABLES
            //----------------------------------------------------------------------------
            Hashtable requestParameters = new Hashtable();

            requestParameters.Add("customer.username", customerUsername);
            requestParameters.Add("customer.password", customerPassword);
            requestParameters.Add("customer.merchant", customerMerchant);
            requestParameters.Add("order.type", orderType);
            requestParameters.Add("card.PAN", cardNumber);
            requestParameters.Add("card.CVN", cardVerificationNumber);
            requestParameters.Add("card.expiryYear", cardExpiryYear);
            requestParameters.Add("card.expiryMonth", cardExpiryMonth);
            requestParameters.Add("order.amount", orderAmountCents);
            requestParameters.Add("customer.orderNumber", orderNumber);
            requestParameters.Add("card.currency", card_currency);
            requestParameters.Add("order.ECI", orderECI);

            string requestText = payWayAPI.FormatRequestParameters(requestParameters);

            string responseText = payWayAPI.ProcessCreditCard(requestText);

            // Break the response string into its component parameters
            IDictionary responseParameters = payWayAPI.ParseResponseParameters(responseText);

            // Get the required parameters from the response
            summaryCode    = (string)responseParameters["response.summaryCode"];
            responseCode   = (string)responseParameters["response.responseCode"];
            description    = (string)responseParameters["response.text"];
            receiptNo      = (string)responseParameters["response.receiptNo"];
            settlementDate = (string)responseParameters["response.settlementDate"];
            creditGroup    = (string)responseParameters["response.creditGroup"];
            previousTxn    = (string)responseParameters["response.previousTxn"];
            cardSchemeName = (string)responseParameters["response.cardSchemeName"];
            try
            {
                //Read the connection string from Web.Config file
                string ConnectionString = ConfigurationManager.ConnectionStrings["DefaultConnectionsql"].ConnectionString;
                using (SqlConnection con = new SqlConnection(ConnectionString))
                {
                    //Create the SqlCommand object
                    SqlCommand cmd = new SqlCommand("sp_InsertCCPaymentDetails", con);

                    //Specify that the SqlCommand is a stored procedure
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;


                    //Add the input parameters to the command object
                    cmd.Parameters.AddWithValue("@AccNum", accountNum.Value);
                    cmd.Parameters.AddWithValue("@Amount", (Convert.ToDouble(orderAmountCents) / 100).ToString());
                    cmd.Parameters.AddWithValue("@CCsummaryCode", summaryCode);
                    cmd.Parameters.AddWithValue("@CCresponseCode", responseCode);
                    cmd.Parameters.AddWithValue("@CCdescription", description);
                    if (receiptNo == null)
                    {
                        receiptNo = "";
                    }
                    cmd.Parameters.AddWithValue("@CCreceiptNo", receiptNo);
                    if (settlementDate == null)
                    {
                        settlementDate = "";
                    }
                    cmd.Parameters.AddWithValue("@CCsettlementDate", settlementDate);
                    if (creditGroup == null)
                    {
                        creditGroup = "";
                    }
                    cmd.Parameters.AddWithValue("@CCcreditGroup", creditGroup);
                    if (previousTxn == null)
                    {
                        previousTxn = "";
                    }
                    cmd.Parameters.AddWithValue("@CCpreviousTxn", previousTxn);
                    if (cardSchemeName == null)
                    {
                        cardSchemeName = "";
                    }
                    cmd.Parameters.AddWithValue("@CCcardSchemeName", cardSchemeName);


                    //Open the connection and execute the query
                    con.Open();
                    try
                    {
                        cmd.ExecuteScalar();
                    }
                    catch (Exception ex)
                    {
                        StreamWriter File1 = File.AppendText(HttpContext.Current.Server.MapPath("~/Logs/file.txt"));
                        File1.WriteLine("Error : " + ex.Message);
                        File1.Close();
                    }
                }
            }
            catch (Exception ex)
            {
            }
            if (summaryCode == "0")
            {
                Session["TNo"]         = receiptNo;
                Session["Description"] = description + summaryCode;
                Response.Redirect("SuccessfulPayment.aspx", false);
            }
            else
            {
                message.Visible   = true;
                message.InnerHtml = description;
                CVV.Value         = "";
                ccNo.Value        = "";
                ExpiryMonth.Value = "";
                ExpiryYear.Value  = "";
            }
        }
コード例 #3
0
ファイル: processCard.aspx.cs プロジェクト: blendev/Trumans
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // Put user code to initialize the page here
            PayWayAPI payWayAPI = (PayWayAPI)Application["PayWayAPI"];

            //----------------------------------------------------------------------------
            // SET CONNECTION DEFAULTS
            //----------------------------------------------------------------------------
            string orderECI  = "SSL";
            string orderType = "capture";

            cardNumber             = Request.Form["cardNumber"];
            cardVerificationNumber = Request.Form["cardVerificationNumber"];
            cardExpiryYear         = Request.Form["cardExpiryYear"];
            cardExpiryMonth        = Request.Form["cardExpiryMonth"];

            string card_currency = "AUD";

            orderAmountCents =
                Convert.ToString(Convert.ToUInt64(Math.Round(
                                                      Convert.ToDouble(Request.Form["orderAmount"]) * 100)));

            string customerUsername = "******";
            string customerPassword = "******";
            string customerMerchant = "Q21322";

            // Note: you must supply a unique order number for each transaction request.
            // We recommend that you store each transaction request in your database and
            // that the order number is the primary key for the transaction record in that
            // database.
            string orderNumber = "01";

            //----------------------------------------------------------------------------
            //INITIALISE CONNECTION VARIABLES
            //----------------------------------------------------------------------------
            Hashtable requestParameters = new Hashtable();

            requestParameters.Add("customer.username", customerUsername);
            requestParameters.Add("customer.password", customerPassword);
            requestParameters.Add("customer.merchant", customerMerchant);
            requestParameters.Add("order.type", orderType);
            requestParameters.Add("card.PAN", cardNumber);
            requestParameters.Add("card.CVN", cardVerificationNumber);
            requestParameters.Add("card.expiryYear", cardExpiryYear);
            requestParameters.Add("card.expiryMonth", cardExpiryMonth);
            requestParameters.Add("order.amount", orderAmountCents);
            requestParameters.Add("customer.orderNumber", orderNumber);
            requestParameters.Add("card.currency", card_currency);
            requestParameters.Add("order.ECI", orderECI);

            string requestText = payWayAPI.FormatRequestParameters(requestParameters);

            string responseText = payWayAPI.ProcessCreditCard(requestText);

            // Break the response string into its component parameters
            IDictionary responseParameters = payWayAPI.ParseResponseParameters(responseText);

            // Get the required parameters from the response
            summaryCode    = (string)responseParameters["response.summaryCode"];
            responseCode   = (string)responseParameters["response.responseCode"];
            description    = (string)responseParameters["response.text"];
            receiptNo      = (string)responseParameters["response.receiptNo"];
            settlementDate = (string)responseParameters["response.settlementDate"];
            creditGroup    = (string)responseParameters["response.creditGroup"];
            previousTxn    = (string)responseParameters["response.previousTxn"];
            cardSchemeName = (string)responseParameters["response.cardSchemeName"];
        }