如何从payfast获取数据

时间:2018-02-15 10:47:48

标签: javascript php html

我有一个网上商店我遇到的问题是,payfast确实调用了我的notify_url,但似乎没有发布数据或者我应该说我没有得到任何数据。这是我使用的代码。

购买:

 <button id="cCart" type="submit"  class="btn btn-danger my-cart-btn my-cart-b" onClick="Javascript:window.location.href = 'https://sandbox.payfast.co.za/eng/process?merchant_id=10007327&amp;merchant_key=rnbmwzzwudp39&amp;item_name=Cell+C+R5+Airtime&amp;item_description=Cell+C+R5+Airtime&amp;payment_method=cc&amp;amount=5.00&amp;email_address=<?php echo $_SESSION['qwertp'];?>&amp;custom_str1=pinless&amp;custom_str2=xx&amp;custom_str3=<?php function Licenseuu() {$alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789"; $pass = array();$alphaLength = strlen($alphabet) - 1;for ($i = 0; $i < 12; $i++) {$n = rand(0, $alphaLength);$pass[] = $alphabet[$n];}return implode($pass);echo $pass;}?>&amp;custom_str4=p-cellc&amp;custom_int1=5&amp;custom_int2=1&amp;custom_str5=<?php echo $_SESSION['xxfs'];?>&amp;notify_url=http://www.luqratemobile.co.za/pass.php?&amp;cancel_url=http://www.luqratemobile.co.za/cancelled.html&amp;return_url=http://www.luqratemobile.co.za/thankyou.html';">Buy Airtime</button>

我收到的代码是:

$custuser = $_GET["custom_str1"];
header( 'HTTP/1.0 200 OK' );
flush();
// Posted variables from ITN
$pfData = $_POST;
$myfile = fopen("payfastPost.txt", "w") or die("Unable to open file!");
$txt = $custuser;
fwrite($myfile, $txt);
fclose($myfile);
//update db
switch( $pfData['payment_status'] )
{
    case 'COMPLETE':
        // If complete, update your application, email the buyer and process the transaction as paid     
        $myfile = fopen("payfastComplete.txt", "w") or die("Unable to open file!");
        $txt = $pfData;
        fwrite($myfile, $txt);
        fclose($myfile);
        break;
    case 'FAILED':                    
        // There was an error, update your application
        $myfile = fopen("payfastFailed.txt", "w") or die("Unable to open file!");
        $txt = $pfData;
        fwrite($myfile, $txt);
        fclose($myfile);
        break;
    default:
        // If unknown status, do nothing (safest course of action)
    break;
}

1 个答案:

答案 0 :(得分:0)

Full match  798-866 `case 'courseDifferences'  : $page='admin/p-events/diff.php`
Group 1.    804-821 `courseDifferences`
Group 2.    843-866 `admin/p-events/diff.php`
Match 7
Full match  2036-2110   `case 'course_program' : $page='admin/p-program/courseProgram.php`
Group 1.    2042-2056   `course_program`
Group 2.    2077-2110   `admin/p-program/courseProgram.php`

解决了我的问题。