Welcome Guest, Not a member yet? Register   Sign In
Codeigniter and Ipay88
#1

[eluser]alexaaaaaaaaaa[/eluser]
Hi all, i was wondering if someone can help he or give an example how to integrate the ipay88 payment gateway into my codeingiter project.

Ok here's some code...

no matter what i put in it i still get the payment fail (Payment fail it's when the status is 0 and payment ok when the status is 1)

Code:
<head>
<title>Redirecting to ipay88.com. Please wait.</title>
</head>
<body>
Redirecting to ipay88.com. Please wait.
<form action="https://www.mobile88.com/ePayment/entry.asp" method="post" name="ipay88_payment">
<input type="hidden" name="MerchantCode" value="M03360">
<input type="hidden" name="PaymentId" value="2">
<input type="hidden" name="RefNo" value="1316816199">
<input type="hidden" name="Amount" value="4.90">
<input type="hidden" name="Currency" value="MYR">
<input type="hidden" name="ProdDesc" value="Japanese Snow Ice & French Fries @ Fun Ok Cafe">
<input type="hidden" name="UserName" value="marius alexandru">
<input type="hidden" name="UserEmail" value="[email protected]">

<input type="hidden" name="UserContact" value="0746506096">

<input type="hidden" name="Remark" value="">
<input type="hidden" name="Lang" value="UTF-8">
<input type="hidden" name="Signature" value="8XwZiM3TYoGt8FU4/0dQGfJFyNo=">
<input type="hidden" name="ResponseURL" value="http://localhost/payment/a/test">
<INPUT type="submit" value="Proceed with Payment" name="Submit">
</form>

</body>
</html>

and on my test page i've got this


Code:
$merchantkey  = "******"; (hidden)
$merchantcode = "M03360";
$paymentid    = $_REQUEST["PaymentId"];
$refno        = $_REQUEST["RefNo"];
$amount       = $_REQUEST["Amount"];
$ecurrency    = $_REQUEST["Currency"];
$remark       = $_REQUEST["Remark"];
$cctransid    = $_REQUEST["TransId"];
$authcode     = $_REQUEST["AuthCode"];
$estatus      = $_REQUEST["Status"];
$errdesc      = $_REQUEST["ErrDesc"];
$hashstring   = $_REQUEST["Signature"];
$status = $_POST['Status'];
$signature = $_REQUEST["Signature"];





function iPay88_signature($source)
{
  return base64_encode(hex2bin(sha1($source)));
}

function hex2bin($hexSource)
{
$bin = '';
    for ($i=0;$i<strlen($hexSource);$i=$i+2)
    {
      $bin .= chr(hexdec(substr($hexSource,$i,2)));
    }
  return $bin;
}
if ($status == "1" && Requery()=="00") {  // successful transaction

  
    echo "success";
}

else { // failure transaction

    
    echo "error";
}
echo "<strong>".Requery($merchantcode, $refno , $amount)."</strong>";

function Requery($MerchantCode, $RefNo, $Amount){

$buf = '';
$query = "http://www.mobile88.com/epayment/enquiry.asp?MerchantCode=" .
$MerchantCode . "&RefNo;=" . $RefNo . "&Amount;=" . $Amount;


$url = parse_url($query);
$host = $url["host"];
$path = $url["path"] . "?" . $url["query"];
$timeout = 1;
$fp = fsockopen ($host, 80, $errno, $errstr, $timeout);
if ($fp) {
  fputs ($fp, "GET $path HTTP/1.0\nHost: " . $host . "\n\n");
  while (!feof($fp)) {
    $buf .= fgets($fp, 128);
  }
  $lines = split("\n", $buf);
  $Result = $lines[count($lines)-1];
  fclose($fp);
} else {
  # enter error handing code here
}
return $Result;
echo $query;
}

Please help me.




Theme © iAndrew 2016 - Forum software by © MyBB