Tuesday, January 31, 2017

Hosted Payment

Monaris

function PaymentMoneris(insertdata) {
        TsMessage.Show("Redirect to Moneris hosted payment", TsMessage.MessageType.Success);
 
        var url = "https://esqa.moneris.com/HPPDP/index.php"; // sand box
        if (settingsI.MonerisIsTestServer == false) {
            url = "https://www3.moneris.com/HPPDP/index.php"; // original
        }
 
        var postValues = {
            "ps_store_id": settingsI.MonerisID,
            "hpp_key": settingsI.MonerisKey,
            "charge_total": settingsI.TotalAmount.toFixed(2),
            "cust_id""custcode:" + settingsI.Customers + "-id:" + settingsI.userid,
            "order_id""oid" + insertdata.TransId,
            "lang""en-ca",
            "email": settingsI.email,
            "bill_first_name": insertdata.FirstName,
            "bill_last_name": insertdata.LastName,
            "bill_address_one": insertdata.Address1,
            "bill_city": insertdata.City,
            "bill_state_or_province": insertdata.StateProvince,
            "bill_postal_code": insertdata.PostalCodeZIP,
            "bill_country": insertdata.Country,
            "bill_phone": insertdata.Phone,
            "rvar_mode": settingsI.CheckOutType
        };
 
        for (var i = 0; i < insertdata.InvoiceDetails.length; i++) {
            var breakoutdata = insertdata.InvoiceDetails[i];
            var quantity = 1;
            var pos = i + 1;
 
            postValues["id" + pos] = breakoutdata.EventCode;
            postValues["description" + pos] = breakoutdata.EventName;
            postValues["quantity" + pos] = quantity;
            postValues["price" + pos] = breakoutdata.EventAmount;
            postValues["subtotal" + pos] = breakoutdata.EventAmount * quantity;
        }
 
        PostRedirect.redirect(url,
            postValues,
            "POST");
    }
 
parameter description 

settingsI.MonerisID //public key
"ATNEQtore3"
settingsI.MonerisKey // private key
"hpFGG67Q5VJJ"
settingsI.TotalAmount.toFixed(2) // amount
"500.00"
"custcode:" + settingsI.Customers + "-id:" + settingsI.userid // customer id
"custcode:ADAMM002-id:123456789c"
 "oid" + insertdata.TransId // order id (when rederect the page this will pass from gate way to our site)
"oid1149"
settingsI.email
"admintestuser@townsuite.com"
settingsI.CheckOutType
1

payment interface

// sandbox configuration

If you do not have the moneris key and id login at https://esqa.moneris.com/mpg/index.php (Only store 3 supports interac).

Valid credit cards for testing

  • MasterCard 5454545454545454
  • Visa 4242424242424242
  • Amex 373599005095005
  • Diners 36462462742008

Valid debit cards for testing

INTERAC Online Select test bank
Valdid IDEBIT_TRACK2 values
  • 3728024906540591206=01121122334455000
  • 5268051119993326=01121122334455000000
  • 453781122255=011211223344550000000000

Configuration Url

Accept

http://localhost:52469/monerishostedreceipt

accept function C#

public void monerishostedreceipt{
try
           {
               Card = GlobalMethods.RequestParam("card");
 
               if (Card == "P")
               {
                   // interac online
                   IssName = GlobalMethods.RequestParam("ISSNAME");
                   Invoice = GlobalMethods.RequestParam("INVOICE");
                   IssConf = GlobalMethods.RequestParam("ISSCONF");
               }
               else
               {
                   IssName = "";
                   Invoice = "";
                   IssConf = "";
               }
 
               ResponseOrderId = GlobalMethods.RequestParam("response_order_id");
               DateStamp = GlobalMethods.RequestParam("date_stamp");
               TimeStamp = GlobalMethods.RequestParam("time_stamp");
               BankTransactionId = GlobalMethods.RequestParam("bank_transaction_id");
               ChargeTotal = decimal.Parse(GlobalMethods.RequestParam("charge_total"));
               BankApprovalCode = GlobalMethods.RequestParam("bank_approval_code");
               IsoCode = GlobalMethods.RequestParam("iso_code");
               Message = GlobalMethods.RequestParam("message");
               TransName = GlobalMethods.RequestParam("trans_name");
               CardHolder = GlobalMethods.RequestParam("cardholder");
               F4l4 = GlobalMethods.RequestParam("f4l4");
               CardUserFriendly = GetHumanReadableCardType(Card);
               ExpiryDate = GlobalMethods.RequestParam("expiry_date");
               Result = GlobalMethods.RequestParam("result");
               ResponseCode = GlobalMethods.RequestParam("response_code");
               Mode = GlobalMethods.RequestParam("rvar_mode");
 
               ProcessData();
           }
           catch (Exception ex)
           {
               TownSuiteWebPortals.Trace.TrapErrors(ex);
               TownSuiteWebPortals.Messages.Show(this"An unknown error occurred."Messages.MessageType.Error);
           }
}

Reject

http://localhost:65299/monerishosteddeclined

rejected function

public void monerishosteddeclined ()
       {
 
           try
           {
 
               Card = MonerisHostedReceipt.GetHumanReadableCardType(GlobalMethods.RequestParam("card"));
 
               if (Card == "P")
               {
                   // interac online
                   IssName = GlobalMethods.RequestParam("ISSNAME");
                   Invoice = GlobalMethods.RequestParam("INVOICE");
                   IssConf = GlobalMethods.RequestParam("ISSCONF");
               }
               else
               {
                   IssName = "";
                   Invoice = "";
                   IssConf = "";
               }
 
               ResponseOrderId = GlobalMethods.RequestParam("response_order_id");
               DateStamp = GlobalMethods.RequestParam("date_stamp");
               TimeStamp = GlobalMethods.RequestParam("time_stamp");
               BankTransactionId = GlobalMethods.RequestParam("bank_transaction_id");
 
               // On a cancel request this will be an empty string
               decimal cTotal = 0m;
               decimal.TryParse(GlobalMethods.RequestParam("charge_total"), out cTotal);
               ChargeTotal = cTotal;
 
               BankApprovalCode = GlobalMethods.RequestParam("bank_approval_code");
               IsoCode = GlobalMethods.RequestParam("iso_code");
               Message = GlobalMethods.RequestParam("message");
               TransName = GlobalMethods.RequestParam("trans_name");
               CardHolder = GlobalMethods.RequestParam("cardholder");
               F4l4 = GlobalMethods.RequestParam("f4l4");
               ExpiryDate = GlobalMethods.RequestParam("expiry_date");
               Result = GlobalMethods.RequestParam("result");
               ResponseCode = GlobalMethods.RequestParam("response_code");
 
               ProcessData();
           }
           catch (Exception ex)
           {
               TownSuiteWebPortals.Trace.TrapErrors(ex);
               TownSuiteWebPortals.Messages.Show(this"An unknown error occurred."Messages.MessageType.Error);
           }
       }

Configuration page
https://esqa.moneris.com/mpg/admin/hppv3_config/index.php







No comments:

Post a Comment

CS Events