BPCSharp.BluePayPayment_BP10Emu.Process C# (CSharp) Method

Process() public method

public Process ( ) : string
return string
        public string Process()
        {
            string postData = "MODE=" + HttpUtility.UrlEncode(this.mode);
            if (this.transType != "SET" && this.transType != "GET")
            {
                calcTPS();
                this.URL = "https://secure.bluepay.com/interfaces/bp10emu";
                postData = postData + "&MERCHANT=" + HttpUtility.UrlEncode(this.accountID) +
                "&TRANSACTION_TYPE=" + HttpUtility.UrlEncode(this.transType) +
                "&TAMPER_PROOF_SEAL=" + HttpUtility.UrlEncode(this.TPS) +
                "&NAME1=" + HttpUtility.UrlEncode(this.name1) +
                "&NAME2=" + HttpUtility.UrlEncode(this.name2) +
                "&AMOUNT=" + HttpUtility.UrlEncode(this.amount) +
                "&ADDR1=" + HttpUtility.UrlEncode(this.addr1) +
                "&ADDR2=" + HttpUtility.UrlEncode(this.addr2) +
                "&CITY=" + HttpUtility.UrlEncode(this.city) +
                "&STATE=" + HttpUtility.UrlEncode(this.state) +
                "&ZIPCODE=" + HttpUtility.UrlEncode(this.zip) +
                "&COMMENT=" + HttpUtility.UrlEncode(this.memo) +
                "&PHONE=" + HttpUtility.UrlEncode(this.phone) +
                "&EMAIL=" + HttpUtility.UrlEncode(this.email) +
                "&REBILLING=" + HttpUtility.UrlEncode(this.doRebill) +
                "&REB_FIRST_DATE=" + HttpUtility.UrlEncode(this.rebillFirstDate) +
                "&REB_EXPR=" + HttpUtility.UrlEncode(this.rebillExpr) +
                "&REB_CYCLES=" + HttpUtility.UrlEncode(this.rebillCycles) +
                "&REB_AMOUNT=" + HttpUtility.UrlEncode(this.rebillAmount) +
                "&RRNO=" + HttpUtility.UrlEncode(this.masterID) +
                "&PAYMENT_TYPE=" + HttpUtility.UrlEncode(this.paymentType) +
                "&INVOICE_ID=" + HttpUtility.UrlEncode(this.invoiceID) +
                "&ORDER_ID=" + HttpUtility.UrlEncode(this.orderID) +
                "&AMOUNT_TIP=" + HttpUtility.UrlEncode(this.amountTip) +
                "&AMOUNT_TAX=" + HttpUtility.UrlEncode(this.amountTax) +
                "&AMOUNT_FOOD=" + HttpUtility.UrlEncode(this.amountFood) +
                "&AMOUNT_MISC=" + HttpUtility.UrlEncode(this.amountMisc);
                if (this.paymentType == "CREDIT") {
                    postData = postData + "&CC_NUM=" + HttpUtility.UrlEncode(this.paymentAccount) +
                    "&CC_EXPIRES=" + HttpUtility.UrlEncode(this.cardExpire) +
                    "&CVCVV2=" + HttpUtility.UrlEncode(this.cvv2);
                } else {
                    postData = postData + "&ACH_ROUTING=" + HttpUtility.UrlEncode(this.routingNum) +
                    "&ACH_ACCOUNT=" + HttpUtility.UrlEncode(this.accountNum) +
                    "&ACH_ACCOUNT_TYPE=" + HttpUtility.UrlEncode(this.accountType) +
                    "&DOC_TYPE=" + HttpUtility.UrlEncode(this.docType);
                }
            } else {
                calcRebillTPS();
                this.URL = "https://secure.bluepay.com/interfaces/bp20rebadmin";
                postData = postData + "&ACCOUNT_ID=" + HttpUtility.UrlEncode(this.accountID) +
                "&TAMPER_PROOF_SEAL=" + HttpUtility.UrlEncode(this.TPS) +
                "&TRANS_TYPE=" + HttpUtility.UrlEncode(this.transType) +
                "&REBILL_ID=" + HttpUtility.UrlEncode(this.rebillID) +
                "&TEMPLATE_ID=" + HttpUtility.UrlEncode(this.templateID) +
                "&REB_EXPR=" + HttpUtility.UrlEncode(this.rebillExpr) +
                "&REB_CYCLES=" + HttpUtility.UrlEncode(this.rebillCycles) +
                "&REB_AMOUNT=" + HttpUtility.UrlEncode(this.rebillAmount) +
                "&NEXT_AMOUNT=" + HttpUtility.UrlEncode(this.rebillNextAmount) +
                "&STATUS=" + HttpUtility.UrlEncode(this.rebillStatus);
            }

            //Create HTTPS POST object and send to BluePay
            ASCIIEncoding encoding = new ASCIIEncoding();
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(this.URL));
            request.AllowAutoRedirect = false;

            byte[] data = encoding.GetBytes(postData);

            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = data.Length;

            Stream postdata = request.GetRequestStream();
            postdata.Write(data, 0, data.Length);
            postdata.Close();

            //get response
            try
            {
                HttpWebResponse httpResponse = (HttpWebResponse)request.GetResponse();
                getResponse(request);
                httpResponse.Close();
            }
            catch (WebException e)
            {
                HttpWebResponse httpResponse = (HttpWebResponse)e.Response;
                getResponse(e);
                httpResponse.Close();
            }
            return getStatus();
        }

Usage Example

        public static void Main()
        {
            string accountID = "MERCHANT'S ACCOUNT ID HERE";
            string secretKey = "MERCHANT'S SECRET KEY HERE";
            string mode = "TEST";

            // Merchant's Account ID
            // Merchant's Secret Key
            // Transaction Mode: TEST (can also be LIVE)
            BluePayPayment_BP10Emu stq = new BluePayPayment_BP10Emu(
                accountID,
                secretKey,
                mode);

            // Search Date Start: Jan. 1, 2013
            // Search Date End: Jan 15, 2013
            // Do not include errored transactions in search? Yes
            stq.getSingleTransQuery(
                "2013-01-01",
                "2013-01-15",
                "1");
            stq.queryByTransactionID("ENTER A TRANSACTION ID HERE");
            stq.Process();

            // Outputs response from BluePay gateway
            Console.Write(stq.response);
        }
All Usage Examples Of BPCSharp.BluePayPayment_BP10Emu::Process