VNIT

Too lazy to think of a slogan

Trang chủ » Diễn Đàn » Lập trình và Phát triển Web » Phát triển web » sử dụng WEBSERVICE của ngân lượng

Chủ đề đã bị khóa, bạn không thể xóa, sửa hay trả lời trong chủ đề này!

First Page Previous Page  1  Next Page Last Page
Locked sử dụng WEBSERVICE của ngân lượng
0
question Gởi bởi lodenvutru (20:30 18-11-2011)
Bài: 4 / Điểm VCS: 6 /

Mình muốn nhờ các bạn giúp đỡ chút về hàm UpdateOrder của Ngân Lượng để cập nhật thông tin giỏ hàng.Mình làm để lấy dữ liệu email đăng nhập trên web để khi thanh toán thành công thì WEBSERVICE tự động gửi mail về email đó.Nhưng không cách nào lấy được dữ liệu từ câu sql.Không biết có sai chỗ nào không:

require_once('nusoap.php');

$conn=mysql_connect("localhost","test","test") or die ("Ko the connect toi MySQL Database. Vui long kiem tra lai username & password");
    mysql_select_db("db_test",$conn);

$secure_pass = '123456'; // Mật khẩu giao tiếp API của Merchant với NgânLượng.vn

function UpdateOrder($transaction_info,$order_code,$payment_id,$payment_type,$secure_code)
{
    global $secure_pass;

    // Kiểm tra chuỗi bảo mật
      $secure_code_new = md5($transaction_info.' '.$order_code.' '.$payment_id.' '.$payment_type.' '.$secure_pass);
    if($secure_code_new != $secure_code)
    {
        return -1; // Sai mã bảo mật
    }
    else // Thanh toán thành công
    {
        // Trường hợp là thanh toán tạm giữ. Hãy đưa thông báo thành công và cập nhật hóa đơn phù hợp
        if($payment_type == 2)
        {
                $sql="select email,id from tbl_member_registry_payment where status=0 and active=1 and session='".$_SESSION['session']."'";

                $result = mysql_query($sql,$conn);

                while($row = mysql_fetch_row($result))
                {
                    $to      = "".$row['email']."";

                }
                $subject = 'Thông báo từ website name.com';
                $mail_body  = "Thông báo từ name.com
                Bạn đã thanh toán thành công tại website name.com!
                Bạn vui lòng bấm vào link sau để về trang download sản phẩm:
                <a href=\"http://www.name.com/?ac...load&session=".$_SESSION['session']."\">Link Download</a>

                ";
                $headers = 'From: name@gmail.com' . "\r\n" .
                    'Reply-To: name@gmail.com' . "\r\n" .
                    'X-Mailer: PHP/' . phpversion();

                mail($to, $subject, $mail_body, $headers);


        }
        // Trường hợp thanh toán ngay. Hãy đưa thông báo thành công và cập nhật hóa đơn phù hợp
        elseif($payment_type == 1)
        {
                    $sql="select email,id from tbl_member_registry_payment where status=0 and active=1 and session='".$_SESSION['session'[."'";

                $result = mysql_query($sql,$conn);

                while($row = mysql_fetch_row($result))
                {
                    $to      = "".$row['email']."";

                }
                $subject = 'Thông báo từ website name.com';
                $mail_body  = "Thông báo từ name.com
                Bạn đã thanh toán thành công tại website name.com!
                Bạn vui lòng bấm vào link sau để về trang download sản phẩm:
                <a href=\"http://www.name.com/?ac...load&session=".$_SESSION['session']."\">Link Download</a>

                ";
                $headers = 'From: name@gmail.com' . "\r\n" .
                    'Reply-To: name@gmail.com' . "\r\n" .
                    'X-Mailer: PHP/' . phpversion();

                mail($to, $subject, $mail_body, $headers);

        }
    }
}

function RefundOrder($transaction_info,$order_code,$payment_id,$refund_payment_id,$payment_type,$secure_code)
{
    global $secure_pass;
    // Kiểm tra chuỗi bảo mật
      $secure_code_new = md5($transaction_info.' '.$order_code.' '.$payment_id.' '.$refund_payment_id.' '.$secure_pass);
    if($secure_code_new != $secure_code)
    {
        return -1; // Sai mã bảo mật
    }
    else // Trường hợp hòan trả thành công
    {
        // Lập trình thông báo hoàn trả thành công và cập nhật hóa đơn
    }
}


// Khai bao chung WebService
$server = new nusoap_server();
$server->configureWSDL('WS_WITH_SMS',NS);
$server->wsdl->schemaTargetNamespace=NS;
// Khai bao cac Function
$server->register('UpdateOrder',array('transaction_info'=>'xsd:string','order_code'=>'xsd:string','payment_id'=>'xsd:int','payment_type'=>'xsd:int','secure_code'=>'xsd:string'),array('result'=>'xsd:int'),NS);
$server->register('RefundOrder',array('transaction_info'=>'xsd:string','order_code'=>'xsd:string','payment_id'=>'xsd:int','refund_payment_id'=>'xsd:int','payment_type'=>'xsd:int','secure_code'=>'xsd:string'),array('result'=>'xsd:int'),NS);
// Khoi tao Webservice
$HTTP_RAW_POST_DATA = (isset($HTTP_RAW_POST_DATA)) ? $HTTP_RAW_POST_DATA :'';
$server->service($HTTP_RAW_POST_DATA);

?>
Locked Re: sử dụng WEBSERVICE của ngân lượng
0
answer Gởi bởi Thành Bá Nguyễn (21:46 18-11-2011)
Bài: 18,319 / Điểm VCS: 17,795 /

Cái này do lỗi PHP thuần tuý của bạn thôi. Biến $conn bạn khai báo ở ngoài hàm UpdateOrder nên bên trong hàm bạn sẽ không còn refer tới nó được nữa. Do vậy có thể có 2 trường hợp:
- Ở bên trong hàm này bạn không connect được tới MySQL
- Hoặc PHP nó sẽ tạo 1 connection mặc định, mà connection này connect tới 1 db khác không có dữ liệu mà bạn cần.
First Page Previous Page  1  Next Page Last Page

Thống kê

Hiện tại web site có 85,806 thành viên. Xin chào đón thành viên mới nhất nightt.

Các thành viên đã tạo 62,822 chủ đề và 241,950 bài viết trong 30 box.

Hiện có 0 thành viên và 1 khách đang trực tuyến.

Template by styleshout / Icons by Tango Icon Library and FamFamFam.