Return URL

Permalink Browser Info Environment
I am trying to activate auto return and Paypal PDF on my account. I have specified a return url and also the following code on the return page.

<?php

function showOrderDetails() {
//echo order details
}

function sendEmailToBuyer($emailAddress) {
//send a thank you email to buyer
}

function checkIfTransactionHasAlreadyBeenProcessed($tx) {
//check if transaction with this id has already been process
}

function checkThatPaymentIsReceivedAtYourEmailAddress($email) {
//check $email againt the email address which was suppose receive the payment
}

function checkPaymentAmountAndCurrency($amount, $currency) {
//verify that the amount and currency code are as required.
}

function processOrder() {
// process the order
}

function exitCode() {
die("Error");
//exit with error message
}
//look if the parameter 'tx' is set in the GET request and that it does not have a null or empty value
if(isset($_GET['tx']) && ($_GET['tx'])!=null && ($_GET['tx'])!= "") {
$tx = $_GET['tx'];
verifyWithPayPal($tx);
}
else {
exitCode();
}
function verifyWithPayPal($tx) {
$req = 'cmd=_notify-synch';
$tx_token = $tx;
$auth_token = "2QX1msCOg3cYrSE7-wJIGkEdC46OJ8ljEH_X7S8-DPIBqJdb1IaWGudEL4O";
$req .= "&tx=$tx_token&at=$auth_token";

// post back to PayPal system to validate
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";

// url for paypal sandbox
//$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);

// url for payal
// $fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
// If possible, securely post back to paypal using HTTPS
// Your PHP server will need to be SSL enabled
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

if (!$fp) {
exitCode();
} else {
fputs ($fp, $header . $req);
// read the body data
$res = '';
$headerdone = false;
while (!feof($fp)) {
$line = fgets ($fp, 1024);
if (strcmp($line, "\r\n") == 0) {
// read the header
$headerdone = true;
}
else if ($headerdone) {
// header has been read. now read the contents
$res .= $line;
}
}

// parse the data
$lines = explode("\n", $res);

$response = array();

if (strcmp ($lines[0], "SUCCESS") == 0) {

for ($i=1; $i<count($lines);$i++){
list($key,$val) = explode("=", $lines[$i]);
$response[urldecode($key)] = urldecode($val);
}

$itemName = $response["item_name"];
$amount = $response["payment_gross"];
$myEmail = $response["receiver_email"];
$userEmailPaypalId = $response["payer_email"];
$paymentStatus = $response["payment_status"];
$paypalTxId = $response["txn_id"];
$currency = $response["mc_currency"];

// check the payment_status is Completed
if($paymentStatus!="Completed") {
paymentNotComplete($paymentStatus);
}

// check that txn_id has not been previously processed
checkIfTransactionHasAlreadyBeenProcessed($paypalTxId);
// check that receiver_email is your Primary PayPal email
checkThatPaymentIsReceivedAtYourEmailAddress($myEmail);
// check that payment_amount/payment_currency are correct
checkPaymentAmountAndCurrency($amount, $currency);
// process the order
processOrder();
} else {
exitCode();
}
}
fclose ($fp);
}
?>

When I am redirected after payment, it is back to the page from which I came.

Can you please help asap?

Thanks

Type: Pre-Sale
Status: New
cebabbage
View Replies:

concrete5 Environment Information

# concrete5 Version
5.6.3.1

# concrete5 Packages
Advanced Forms (1.13.1), Best Suite - Core (1.2.6), Dynamic Iframe (1.7), Oembed (1.2.0.1), Quick Links (2.0.1), Wufoo Forms (1.0.1).

# concrete5 Overrides
blocks/autonav, languages/vi_VN, languages/sv_SE, languages/ar, languages/it_IT, languages/cs_CZ, languages/nl_NL, languages/el_GR, languages/pt_PT, languages/es_AR, languages/es_MX, languages/de_DE, languages/fi_FI, languages/fr_FR, languages/sl_SI, languages/sk_SK, languages/ro_RO, languages/da_DK, languages/es_ES, languages/nb_NO, languages/he_IL, languages/zh_CN, languages/es_PE, languages/fa_IR, languages/ru_RU, languages/ja_JP, languages/tr_TR, languages/zh_TW, themes/sweet_umami

# concrete5 Cache Settings
Block Cache - On
Overrides Cache - On
Full Page Caching - Off

# Server Software
Apache

# Server API
cgi-fcgi

# PHP Version
5.4.34

# PHP Extensions
bcmath, bz2, calendar, cgi-fcgi, Core, ctype, curl, date, dba, dom, enchant, ereg, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, imagick, imap, intl, json, ldap, libxml, mbstring, mcrypt, mhash, mysql, mysqli, odbc, openssl, pcntl, pcre, PDO, pdo_dblib, pdo_mysql, PDO_ODBC, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, pspell, readline, recode, Reflection, session, shmop, SimpleXML, soap, sockets, SPL, sqlite3, standard, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, wddx, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend Guard Loader, zip, zlib.

# PHP Settings
max_execution_time - 30
log_errors_max_len - 1024
max_file_uploads - 20
max_input_nesting_level - 64
max_input_time - 60
max_input_vars - 1000
memory_limit - 128M
post_max_size - 50M
sql.safe_mode - Off
upload_max_filesize - 50M
ldap.max_links - Unlimited
mysql.max_links - Unlimited
mysql.max_persistent - Unlimited
mysqli.max_links - Unlimited
mysqli.max_persistent - Unlimited
odbc.max_links - Unlimited
odbc.max_persistent - Unlimited
pcre.backtrack_limit - 1000000
pcre.recursion_limit - 100000
pgsql.max_links - Unlimited
pgsql.max_persistent - Unlimited
session.cache_limiter - nocache
session.gc_maxlifetime - 7200
soap.wsdl_cache_limit - 5

Browser User-Agent String

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/600.2.5 (KHTML, like Gecko) Version/8.0.2 Safari/600.2.5

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You may not request a refund that is not currently owned by you.