<?php
// ------ Requires the actual API file. This can be placed anywhere as long as you indicate
// ------ the proper path
require "../mpgClasses.php";
// ------ Define all the required variables. These can be passed by whatever means you wish
$store_id = ‘store1’;
$api_token = ‘yesguy’;
$crypttype = ‘7’;
$orderid = Request.Cookies("invoice_no");
$amount = Request.Cookies("invoice_total");
$pan = Request.Cookies("creditcard_no");
$expirydate = Request.Cookies("creditcard_expiry");
// ------ step 1) create transaction hash
$txnArray=array(‘type’=>'purchase',
‘order_id’=>$orderid,
‘cust_id’=>$customerid,
‘amount’=>$amount,
‘pan’=>$pan,
‘expdate’=>$expirydate,
‘crypt_type’=>$crypttype
);
// ------ step 2) create a transaction object passing the hash created in step 1.
$mpgTxn = new mpgTransaction($txnArray);
// ------ step 3) create a mpgRequest object passing the transaction object created in step 2
$mpgRequest = new mpgRequest($mpgTxn);
// ------ step 4) create mpgHttpsPost object which does an https post
$mpgHttpPost =new mpgHttpsPost($store_id,$api_token,$mpgRequest);
// ------ step 5) get an mpgResponse object
$mpgResponse=$mpgHttpPost->getMpgResponse();
// ------ step 6) retrieve data using get methods. Using these methods you can retrieve the
// ------ appropriate variables (getResponseCode) to check if the transactions is approved
// ------ (=>0 or <50) or declined (>49) or incomplete (NULL)
Response.Cookies("CardType") = $mpgResponse->getCardType();
Response.Cookies("TransAmount") = $mpgResponse->getTransAmount();
Response.Cookies("TxnNumber") = $mpgResponse->getTxnNumber();
Response.Cookies("ReceiptId") = $mpgResponse->getReceiptId();
Response.Cookies("TransType") = $mpgResponse->getTransType();
Response.Cookies("ReferenceNum") = $mpgResponse->getReferenceNum();
Response.Cookies("ResponseCode") = $mpgResponse->getResponseCode();
Response.Cookies("ISO") = $mpgResponse->getISO();
Response.Cookies("Message") = $mpgResponse->getMessage();
Response.Cookies("AuthCode") = $mpgResponse->getAuthCode();
Response.Cookies("Complete") = $mpgResponse->getComplete();
Response.Cookies("TransDate") = $mpgResponse->getTransDate();
Response.Cookies("TransTime") = $mpgResponse->getTransTime();
Response.Cookies("Ticket") = $mpgResponse->getTicket();
Response.Cookies("TimedOut") = $mpgResponse->getTimedOut();
Response.Redirect(finalStep.asp")
|