public static function getSoapClient() { //$wsdl = CodaUtil::airtimeWSDLURL(); $wsdl = CodaUtil::airtimeURL(); $client = new SoapClient($wsdl, array('typemap' => array(array('type_ns' => 'http://www.w3.org/2001/XMLSchema', 'type_name' => 'long', 'to_xml' => 'CodaUtil::to_long_xml', 'from_xml' => 'CodaUtil::from_long_xml')))); return $client; }
<?php include 'coda/CodaUtil.php'; $airtimeRoot = CodaUtil::airtimeURL(); //log_message('info', 'The purpose of some variable is to provide some value.'); ?> <!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>Welcome To Security Company</title> <link href="css/style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" language="javascript" src="script/jquery-1.3.2.min.js"></script> <link rel="stylesheet" type="text/css" href="<?php echo $airtimeRoot; ?> css/airtime_v1.0.css"> <script type="text/javascript" src="<?php echo $airtimeRoot; ?> js/airtime_v1.0.js"></script> <script type="text/javascript"> function processPayment (obj) { if (validate ()) { initTxn (obj, $('input[name=PayType]:radio:checked').val()); } } function initTxn (obj, payType) {
<?php include 'coda/CodaUtil.php'; include 'coda/InitTxnRequest.php'; $request = new InitTxnRequest(); $request->country = CodaUtil::country(); $request->currency = CodaUtil::currency(); $request->orderId = (string) round(microtime(true) * 1000); $request->apiKey = CodaUtil::apiKey(); $request->payType = CodaUtil::payType(); //log_message('info', 'The purpose of some variable is to provide some value.'); $request->items = CodaUtil::getItems($_REQUEST); $result = CodaUtil::initTxn($request); //r_dump(json_encode($result)); die(); echo $result->txnId;
* Optional: for double check the transaction result */ $txnId = $_REQUEST['TxnId']; $result = CodaUtil::inquiryPayment($txnId); $errorCode = $result->resultCode; $errMsg = $result->resultDesc; $orderId = $result->orderId; $totalPrice = $result->totalPrice; } if ($errorCode > 0) { $url = "error.php"; $qryStr = "?errorCode=" . $errorCode . "&txnId=" . $txnId . "&orderId=" . $orderId . "&errMsg=" . $errMsg; header('Location: ' . $url . $qryStr); return; } if (!CodaUtil::validateChecksum($_REQUEST)) { // Handle Error } ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Purchase Completed</title> <link href="css/style.css" rel="stylesheet" type="text/css" /> <style type="text/css"> .container {width:100%;float:left;} .leftCol {width:170px; float:left;} .rightCol {width:550px; float:right} .rightCol div {float:left; clear:left;} </style>
public function transaction_completion_notification() { foreach ($_GET as $key => $item) { $parames_ret[$key] = $item; } $temp_order = $this->pay_model->get_recharge_order($parames_ret['OrderId']); $res = $this->pay_model->get_merchant_data_by_pay_type($temp_order->pay_type_id, $temp_order->method_id); $apiKey = $res['merchant_key']; log_message('gash', 'codapay transaction notification parameters : ' . json_encode($parames_ret)); if (CodaUtil::validateChecksum2($parames_ret, $apiKey) == true && $parames_ret['ResultCode'] == 0) { $order_sn = $parames_ret['OrderId']; $temp_order = $this->pay_model->get_recharge_order($order_sn); if (empty($temp_order) == false && $temp_order->tradeseq == $parames_ret['TxnId']) { //不是在我们收到钱后返回 ResultCode = 0 $this->_update_order_without_reminder($order_sn, $parames_ret['TotalPrice']); //修改订单状态, 发送元宝TotalPrice log_message('gash', 'codapay notification success'); echo 'ResultCode=0'; exit; } else { if (empty($temp_order)) { log_message('gash', 'codapay notification failed does not exist order ' . $order_sn); } else { log_message('gash', 'codapay notification failed tradeseq ' . $temp_order->tradeseq . ' != ' . 'TxnId ' . $parames_ret['TxnId']); } echo 'ResultCode=1'; exit; } } else { if ($parames_ret['ResultCode'] != 0) { log_message('gash', "codapay notification failed invalid resultCode = " . $parames_ret['ResultCode']); } else { log_message('gash', "codapay notification invalide Checksum = " . $parames_ret['Checksum']); } echo 'ResultCode=1'; exit; } }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php include '../CodaUtil.php'; $result = null; $errorCode = 0; $errMsg = null; $txnId = null; $orderId = null; $totalPrice = 0.0; if (strlen($_REQUEST['TxnId']) == 0) { $errMsg = "Incomplete transaction error."; } else { $txnId = $_REQUEST['TxnId']; $result = CodaUtil::inquiryPayment($txnId); $errorCode = $result->resultCode; $errMsg = $result->resultDesc; $orderId = $result->orderId; $totalPrice = $result->totalPrice; } if ($errorCode > 0) { $url = "error.php"; $qryStr = "?errorCode=" . $errorCode . "&txnId=" . $txnId . "&orderId=" . $orderId . "&errMsg=" . $errMsg; header('Location: ' . $url . $qryStr); return; } ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Purchase Completed</title>