$postVals = rtrim(implode($arrPostVals), "&");
            $response = parseString(runCurl(URLBASE, $postVals));
            $custom = explode("%2c", $response["CUSTOM"]);
            if (getUserId() == $custom[0] && $itemId == $custom[1]) {
                // ADDED LINE TO GET KS SESSION
                $ks = getSession($itemId, $userId);
                // ADD KS to ARRAY
                $returnObj = array('success' => true, 'error' => "", 'transactionId' => $response["TRANSACTIONID"], 'orderTime' => $response["ORDERTIME"], 'paymentStatus' => $response["PAYMENTSTATUS"], 'itemId' => $itemId, 'userId' => $userId, 'ks' => $ks);
            }
        } else {
            $returnObj = array('success' => false, 'error' => "Item not found in transaction history");
        }
        echo json_encode($returnObj);
    }
}
$transact = new pptransact();
if (array_key_exists("method", $_GET)) {
    switch ($_GET["method"]) {
        case "init":
            $connect->init();
            break;
        case "getToken":
            $transact->getToken($_GET["userId"], $_GET["itemId"], $_GET["qty"], $_GET["mobile"]);
            break;
        case "commitPayment":
            $transact->commitPayment($_GET["userId"], $_GET["payerId"], $_GET["token"], $_GET["amt"], $_GET["itemId"]);
            break;
        case "verifyPayment":
            $transact->verifyPurchase($_GET["userId"], $_GET["itemId"], $_GET["transactions"]);
            break;
    }
Beispiel #2
0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Thank you</title>
<script src="https://www.paypalobjects.com/js/external/dg.js"></script>
<script src="../../client/jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="../../client/pptransact.js"></script>

<?php 
require_once "pptransact.php";
$transact = new pptransact();
$data = explode("|", $_GET["data"]);
$returnObj = $transact->commitPayment($data[1], $_GET["PayerID"], $_GET["token"], $data[0], $data[2]);
?>

<script>

function parentExists() {
 	return (parent.location == window.location)? false : true;
}

function closeFlow(param) {
	
	pptransact.init('cf',true);
	
	if(!parentExists()) {
		var jsonData = $.parseJSON('<?php 
echo $returnObj;
?>
');