/** * initialize page elements * */ function init($get = '') { global $config, $locate; $objResponse = new xajaxResponse(); if ($get != '') { $get = rtrim($get, ','); $get = split(',', $get); foreach ($get as $item_tmp) { $item = split(':', $item_tmp); $get_item[$item[0]] = $item[1]; } } $rechargeEable = true; if ($_SESSION['curuser']['usertype'] == 'reseller') { $paymentinfoHtml = paymentInfoHtml(); $objResponse->addAssign("paymentInfo", "innerHTML", $paymentinfoHtml); if ($config['epayment']['epayment_status'] != 'enable' || $config['epayment']['paypal_payment_url'] == '' || $config['epayment']['paypal_account'] == '' || $config['epayment']['pdt_identity_token'] == '' || $config['epayment']['asterbilling_url'] == '' || $config['epayment']['amount'] == '' || $config['epayment']['currency_code'] == '') { $rechargeEable = false; } else { $identity_token = $config['epayment']['pdt_identity_token']; $receiver_email = $config['epayment']['paypal_account']; $currency_code = $config['epayment']['currency_code']; } } elseif ($_SESSION['curuser']['usertype'] == 'groupadmin') { $reseller_row = astercrm::getRecordByID($_SESSION['curuser']['resellerid'], 'resellergroup'); if ($reseller_row['epayment_status'] != 'enable') { $rechargeEable = false; } else { $identity_token = $reseller_row['epayment_identity_token']; $receiver_email = $reseller_row['epayment_account']; $currency_code = $config['epayment']['currency_code']; } } $objResponse->addAssign("divNav", "innerHTML", common::generateManageNav($skin, $_SESSION['curuser']['country'], $_SESSION['curuser']['language'])); $objResponse->addAssign("divCopyright", "innerHTML", common::generateCopyright($skin)); $infoHtml = InfomationHtml(); $objResponse->addAssign("info", "innerHTML", $infoHtml); if ($rechargeEable) { $rechargeInfoHtml = '<table border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#F0F0F0" width="600"> <tr> <td width="26%" height="39" class="td font" align="center">' . $locate->Translate('Recharge By Paypal') . ' </td> <td width="74%" class="td font" align="center"> </td> </tr> <tr><td height="10" class="td"></td> <td class="td font" align="center"> </td> </tr> </table> <table border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#F0F0F0" id="menu" width="600"> <tr bgcolor="#F7F7F7"> <td align="center" valign="top"><b>'; if ($get_item["action"] == 'success') { if ($get_item['tx'] != '') { $txn_res = astercrm::getRecordByField('epayment_txn_id', $get_item['tx'], 'credithistory'); // check that txn_id has not been previously processed if ($txn_res['id'] > 0) { $rechargeInfoHtml .= $locate->Translate('payment_success'); } else { if ($identity_token != '') { $p = new paypal_class(); $p->verify_url = $config['epayment']['paypal_verify_url']; if ($config['epayment']['pdt_log']) { $return = $p->paypal_pdt_return($get_item['tx'], $identity_token, true); } else { $return = $p->paypal_pdt_return($get_item['tx'], $identity_token); } if ($return['flag'] == 'SUCCESS') { $errorFlag = 0; // check that receiver_email is your Primary PayPal email if ($return['pdt']['receiver_email'] != $receiver_email) { $rechargeInfoHtml .= $locate->Translate('payment_receiver_error') . '</br>'; $errorFlag += 1; } // check that payment_amount/payment_currency are correct if ($return['pdt']['mc_currency'] != $currency_code) { $rechargeInfoHtml .= $locate->Translate('payment_currency_error') . '</br>'; $errorFlag += 1; } if ($return['pdt']['payment_status'] == "Completed") { if ($errorFlag > 0) { $rechargeInfoHtml .= $locate->Translate('payment_order_error') . "</br>" . $locate->Translate('payment_may_completed'); } else { // process Order 不再用pdt处理订单,等待ipn处理 //$process_res = processOrder($return['pdt']); sleep(1); $infoHtml = InfomationHtml(); $objResponse->addAssign("info", "innerHTML", $infoHtml); $rechargeInfoHtml .= $locate->Translate('payment_success'); } } else { $rechargeInfoHtml .= $locate->Translate('payment_failed'); } } else { //PDT return failed $rechargeInfoHtml .= $locate->Translate('payment_return_failed'); } } } } else { $rechargeInfoHtml = rechargeHtml(); $objResponse->addAssign("rechargeInfo", "innerHTML", $rechargeInfoHtml); return $objResponse; } } elseif ($get_item["action"] == 'cancel') { $rechargeInfoHtml .= $locate->Translate('payment_canceled'); } else { $rechargeInfoHtml = rechargeHtml(); $objResponse->addAssign("rechargeInfo", "innerHTML", $rechargeInfoHtml); return $objResponse; } $rechargeInfoHtml .= '</b> <a href="profile.php" >' . $locate->Translate('Return') . '</a></td></tr></table>'; $objResponse->addAssign("rechargeInfo", "innerHTML", $rechargeInfoHtml); } return $objResponse; }