|
 |
|
ปัญหาสร้างหน้า notify payment กับระบบ Mpay ช่วยทีค่ะ |
|
 |
|
|
 |
 |
|
เวลาลูกค้าซื้อสินค้ากับ mpay ทางมือถือ มันก็จะส่งค่ามาที่เว็บเรา เค้าให้สร้างหน้า notify รับ
โดยให้ parameter มา แล้วก็ให้ตัวอย่าง code มาเป็น asp
รบกวนผู้รู้ช่วยแปลงเป็น php ด้วยเถอะค่ะ จะบ้าอยู่แล้ว
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
'on error goto errhandle
logheader=now & " -- " & session.SessionID & " >>> "
set db=server.CreateObject("adodb.connection")
chiiori=application("chiiori")
db.Open chiiori
CMD=request.QueryString("CMD")
PAYRESULT=request.QueryString("PAYRESULT")
BASKETID=request.QueryString("BASKETID")
OFFERID=request.QueryString("OFFERID")
TXID=request.QueryString("TXID")
DESC=request.QueryString("DESCRIPTION")
AMOUNT=request.QueryString("AMOUNT")
pTYPE=request.QueryString("TYPE")
ERRCODE=request.QueryString("ERRCODE")
ERRMSG=request.QueryString("ERRMSG")
Set fs = Server.CreateObject("Scripting.FileSystemObject")
MsgFile = "c:\sites\Premium6\nikomart\webroot\notifylog.txt"
Set f= fs.OpenTextFile (MSGFile, 8, true)
f.WriteLine(logheader & "notify request >>> " & request.QueryString)
if cmd="NotifyPayment" and PAYRESULT="OK" then
sql="insert into INMCTX (basketid,offerid,txid,result,[desc],amount,ptype,errcode,errmsg,smsstatus) values ('" & basketid & "','" & offerid & "','" & txid & "','" & PAYRESULT & "','" & desc & "'," & amount & ",'" & ptype & "','" & errcode & "','" & errmsg & "','')"
' response.Write(sql & "<BR>")
db.Execute sql
f.WriteLine(logheader & "sql >>> " & sql)
smstext=server.URLEncode("test sms delivery for txid=" & txid & " basketid=" & basketid)
INMCurl="http://saichon-beauty.ais.co.th:8001/AISMPAYWeb/MerchantInterface?" ' dev server
' INMCurl="http://www.mpay.co.th/inmc/INMCServlet?" ' production server
para="CMD=SMSDelivery&USER=Hatari&PASSWORD=Hatari&TXID=" & txid & "&TEXT=" & smstext
smsurl=inmcurl & para
set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "GET",smsurl,false
f.WriteLine(logheader & "smsdelivery >>> " & smsurl)
xmlhttp.Send
xmlresponse=xmlhttp.responsetext
f.WriteLine(logheader & "sms response >>> " & xmlresponse)
sql="update inmctx set smsstatus='" & xmlresponse & "' where txid='" & txid & "'"
db.Execute sql
f.WriteLine(logheader & "sql >>> " & sql)
notifyres="STATUS=OK"
response.Write(notifyres)
f.WriteLine(logheader & "notify response >>> " & notifyres)
else
notifyres="STATUS=ERR&SHOP_ERRCODE=" & Err.Number & "&SHOP_ERRMSG=" & server.URLEncode(err.Description)
response.Write(notifyres)
f.WriteLine(logheader & "notify response >>> " & notifyres)
end if
f.close
Set f=Nothing
set fs=nothing
db.close
set db=nothing
%>
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-06-07 23:10:47 |
By :
patfanfeye |
View :
1373 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอนอกเรื่องนิดนึง ใช่พี่ฝ้ายรึป่าวคะที่ตั้งคำถามอ่ะ
|
 |
 |
 |
 |
Date :
2009-06-08 10:00:52 |
By :
ชะเอม |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (ASP)
<%
CMD=request.QueryString("CMD")
PAYRESULT=request.QueryString("PAYRESULT")
BASKETID=request.QueryString("BASKETID")
OFFERID=request.QueryString("OFFERID")
TXID=request.QueryString("TXID")
DESC=request.QueryString("DESCRIPTION")
AMOUNT=request.QueryString("AMOUNT")
pTYPE=request.QueryString("TYPE")
ERRCODE=request.QueryString("ERRCODE")
ERRMSG=request.QueryString("ERRMSG")
%>
Code (PHP)
<?php
$CMD=$_REQUEST["CMD"];
$PAYRESULT=$_REQUEST["PAYRESULT"];
$BASKETID=$_REQUEST["BASKETID"];
$OFFERID=$_REQUEST["OFFERID"];
$TXID=$_REQUEST["TXID"];
$DESC=$_REQUEST["DESCRIPTION"];
$AMOUNT=$_REQUEST["AMOUNT"];
$pTYPE=$_REQUEST["TYPE"];
$ERRCODE=$_REQUEST["ERRCODE"];
$ERRMSG=$_REQUEST["ERRMSG"];
?>
ที่เหลือ มันก็ขึ้นอยู่กับว่า จะเอาข้อมูลพวกนี้ไปทำอะไร
เช่น เก็บเป็น log ไฟล์ หรือ บันทึกลงฐานข้อมูล
ก็สามารถทำตามวิธีของ php ได้เลย
|
 |
 |
 |
 |
Date :
2009-06-08 10:29:23 |
By :
lozomac |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|