$post_data = 'transid=' . $productId . '&status=Y&rkey=' . $rkey . '&checksum=' . $checksum . '&sellingamount=' . $price . '&accountingamount=' . $price; $find = $database['myorderbox']->findOne(['id' => $_GET['ref']], ['data']); if (isset($find['data'])) { $curl = ['code' => 200, 'data' => $find['data']]; } else { $curl = curlPost($post_data, $redirect_url); } $date = date('Y/m/d H:i:s') . ' +0000'; $mail = $_GET['email']; if (strstr($curl['data'], "transStatus=Success")) { $database['myorderbox']->insert(['id' => $_GET['ref'], 'data' => $curl['data']]); $success = true; } } else { if ($pingback->isCancelable()) { $checksum = generateChecksum($productId, $price, $price, 'N', $rkey, $private_var['myorderbox']); $post_data = 'transid=' . $productId . '&status=N&rkey=' . $rkey . '&checksum=' . $checksum . '&sellingamount=' . $price . '&accountingamount=' . $price; $curl = curlPost($post_data, $redirect_url); $curl['code'] = 1001; } } header('HTTP/1.1 ' . $curl['code']); $insert = apc_store('transid-' . $productId, $curl['data'], 3600); if ($success) { if ($insert) { echo 'OK'; } else { print_r($insert); } } elseif ($curl['code'] == 1001) { echo 'OK';
$post_data = 'transid=' . $productId . '&status=Y&rkey=' . $rkey . '&checksum=' . $checksum . '&sellingamount=' . $price . '&accountingamount=' . $price; $find = $database['myorderbox']->findOne(['id' => $_GET['ref']], ['data']); if (isset($find['data'])) { $curl = ['code' => 200, 'data' => $find['data']]; } else { $curl = curlPost($post_data, $redirect_url); } $date = date('Y/m/d H:i:s') . ' +0000'; $mail = $_GET['email']; if (strstr($curl['data'], "transStatus=Success")) { $database['myorderbox']->insert(['id' => $_GET['ref'], 'data' => $curl['data']]); $success = true; } } else { if ($pingback->isCancelable()) { $checksum = generateChecksum($productId, $price, $price, 'N', $rkey, $key); $post_data = 'transid=' . $productId . '&status=N&rkey=' . $rkey . '&checksum=' . $checksum . '&sellingamount=' . $price . '&accountingamount=' . $price; $curl = curlPost($post_data, $redirect_url); $curl['code'] = 1001; } } header('HTTP/1.1 ' . $curl['code']); $insert = apc_store('transid-' . $productId, $curl['data'], 3600); if ($curl['code'] == 200 && $success) { if ($insert) { echo 'OK'; } else { print_r($insert); } } elseif ($curl['code'] == 1001) { echo 'OK';
//logResult("3"); $redirectUrl = "https://www.foundationapi.com/servlet/CustomPaymentAuthCompletedServlet"; //logResult("4"); $transId = $_POST['out_trade_no']; //logResult("5"); $sellingCurrencyAmount = $_POST['total_fee']; //logResult("6"); $accountingCurrencyAmount = $_POST['total_fee']; //logResult("7"); $status = "Y"; //logResult("8"); srand((double) microtime() * 1000000); //logResult("9"); $rkey = rand(); //logResult("10"); $checksum = generateChecksum($transId, $sellingCurrencyAmount, $accountingCurrencyAmount, $status, $rkey, $rckey); //logResult("11"); $url = $redirectUrl . "?" . "transid=" . $transId . "&status=" . $status . "&rkey=" . $rkey . "&checksum=" . $checksum . "&sellingamount=" . $sellingCurrencyAmount . "&accountingamount=" . $accountingCurrencyAmount; logResult("12" . $url); //提交 $arr = parse_url($url); //logResult("13"); $fp = @fsockopen("ssl://" . $arr['host'], "443", $error, $errdesc, 60); //logResult("14"); if (!$fp) { //logResult("15"); die("this is error " . $error . " " . $errordesc); } else { //logResult("16"); $arr['query'] = isset($arr['query']) ? "?" . $arr['query'] : ""; fputs($fp, "GET " . $arr['path'] . "?" . $arr['query'] . " HTTP/1.1\r\n");