Hi DW.
I am able to purchase from my online store but I don't seem to be able to get the pass through data which whould be sent to my notify_url. Payfast is my payment gateway and now it does call my notify_url because two files are created after I try to purchase but the files are blank and what I want is to get the posted variables and their values, but I'm not sure if the variables are posted on call or because even if I try to trap the $_POST
I don't get any data.
Here is my notify_url script which should write file with posted data but the files are empty. The files created are the first two files not the failed file.
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 = $pfData;
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;
}
Here is my purchase button:
<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&merchant_key=cdfgwzzwudp39&item_name=test&item_description=test&payment_method=cc&amount=5.00&email_address=<?php echo $_SESSION['qwertp'];?>&custom_str1=first&custom_str2=xx&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;}?>&custom_str4=p-nn&custom_int1=5&custom_int2=1&custom_str5=<?php echo $_SESSION['xxfs'];?>&notify_url=http://www.mydomain.com/pass.php?&cancel_url=http://www.mydomain.com/cancelled.html&return_url=http://www.mydomain.com/thankyou.html';">Buy Airtime</button>