$alipayapi = new AlipayApi($credentials); $alipay_notify->setParamList('notify_verify'); $alipayapi->prepareRequest($alipay_notify, false); $url = $alipayapi->createUrl(); $alipay_notify->setParamList('compare_sign'); $params = $alipayapi->getProtocolParams(); unset($params['partner']); unset($params['service']); $alipayapi->setProtocolParams($params); $alipayapi->setSecreteKey(Configuration::get('ALIPAY_SECRETE_KEY')); $alipayapi->prepareRequest($alipay_notify); if ($alipayapi->getResponse($url) != 'true' || !$alipay_notify->verifyDupplicates() || $alipayapi->getSign() != Tools::getValue('sign')) { return; } if ($alipay_notify->saveNotify()) { $alipay = new Alipay(); $extra_vars = array(); $extra_vars['transaction_id'] = $alipay_notify->getTradeNo(); $alipay->validateOrder((int) $alipay_notify->getIdCart(), Configuration::get('PS_OS_PAYMENT'), $alipay_notify->getTotalFee(), 'Alipay', null, $extra_vars, null, false, $alipay_notify->getSecureKey()); $id_order = (int) Order::getOrderByCartId($alipay_notify->getIdCart()); if ($id_order) { $alipay_notify->saveOrder($id_order); header('HTTP/1.1 200 OK'); echo "success"; exit; } } header('HTTP/1.1 200 OK'); echo "fail"; exit; default:
/** * This method is called when the customer goes back to shop, after he made a payment. * The customer will redirected either to the order confirmation page or to an error page * @return mixed */ public function postProcess() { require_once dirname(__FILE__) . '/../../api/loader.php'; $alipay = new Alipay(); $payment_response = new PaymentResponse(); $payment_response->getPostData(); if ($payment_response->getTradeStatus() == 'TRADE_FINISHED') { $payment_response->setIdModule($this->module->id); if (!$payment_response->processResponse()) { $errors = $payment_response->getErrors(); if ($errors) { foreach ($errors as $error) { $this->errors[] = $error; } return $this->setTemplate('error.tpl'); } } if ($payment_response->getIdOrder()) { $params = array('id_cart' => $payment_response->getIdCart(), 'id_module' => $payment_response->getIdModule(), 'id_order' => $payment_response->getIdOrder(), 'key' => $payment_response->getSecureKey()); $s = $this->context->link->getModuleLink('alipay', 'confirmation', $params); Tools::redirect($s); } else { $this->context->smarty->assign($payment_response->getTplVars()); return $this->setTemplate('check_order.tpl'); } } $this->errors[] = $alipay->l('An error occured. Please contact the merchant to have more informations'); return $this->setTemplate('error.tpl'); }
/** * Registers swiftMailer autoloader and includes the required files */ public function registerScripts() { if (self::$registeredScripts) { return; } self::$registeredScripts = true; require dirname(__FILE__) . '/lib/alipay_submit.class.php'; }
/** * This method checks Alipay's response regarding the refund * @param bool|true $response * @param bool|true $params * @return int */ public function processResponse($response = true, $params = true) { $alipay = new Alipay(); if (!$response) { $this->errors[] = $alipay->l('An error occurred during the process.'); return -1; } $xmlObj = new SimpleXMLElement($response); if ($xmlObj && $xmlObj->is_success == 'T') { $this->insertRefund($params); } elseif ($xmlObj && $xmlObj->is_success == 'F') { $this->errors[] = sprintf($alipay->l('An error occured during the process: %s'), $xmlObj->error); return -1; } else { $this->errors[] = $alipay->l('An error occurred during the process.'); return -1; } }
/** * This method get useful payment details and assign them into the Order back-office template * @param bool|true $response * @param bool|true $params * @return int */ public function processResponse($response = true, $params = true) { $alipay = new Alipay(); if (!$response) { $this->errors[] = $alipay->l('Impossible to retrieve transaction information'); return -1; } $xmlObj = new SimpleXMLElement($response); if ($xmlObj && $xmlObj->is_success == 'T') { $this->tplVars = get_object_vars($xmlObj->response->trade); $this->tplVars['currency'] = Currency::getIdByIsoCode($params['currency']); $this->tplVars['iso_code'] = $params['currency']; $this->tplVars['amount_in_currency'] = $params['total_fee']; } else { $this->errors[] = $alipay->l('Impossible to retrieve transaction information'); return -1; } }
<?php include dirname(__FILE__) . '/../../config/config.inc.php'; include dirname(__FILE__) . '/../../header.php'; include dirname(__FILE__) . '/alipay.php'; $currency = new Currency(intval(isset($_POST['currency_payement']) ? $_POST['currency_payement'] : $cookie->id_currency)); $total = floatval(number_format($cart->getOrderTotal(true, 3), 2, '.', '')); $alipay = new Alipay(); $alipay->validateOrder($cart->id, _PS_OS_PAYMENT_, $total, $alipay->displayName); $order = new Order($alipay->currentOrder); Tools::redirectLink($_POST['hiddenlink']);
private function getAlipayForm4FollowupOrder(FollowupOrder $order) { $callbackUrl = BeanFinder::get('configs')->alipay_callback_url; $frontUrl = BeanFinder::get('configs')->alipay_callback_returnurl; $price = $order->price;//原价 //dodo::zhb 创建充值单 $depositeOrder = OrderClient::getInstance()->createDepositeOrder($this->user, $price, DepositeOrder::RECHARGE_TYPE_ALIPAY, array($order)); $description = ''; $form = Alipay::getInstance()->getPayForm($depositeOrder->id, Pay::TYPE_FOLLOWUPORDER, $price, $callbackUrl, $order->product->title, $order->product->title, $frontUrl); return $form; }
<?php /* SSL Management */ $useSSL = true; include dirname(__FILE__) . '/../../config/config.inc.php'; include dirname(__FILE__) . '/../../header.php'; include dirname(__FILE__) . '/alipay.php'; include dirname(__FILE__) . '/alipay_notify.php'; $_html = ''; $alipay_class = new Alipay(); $alipay = new alipay_notify($alipay_class->partner, $alipay_class->security_code, $alipay_class->sign_type, $alipay_class->_input_charset, $alipay_class->transport); $verify_result = $alipay->notify_verify(); if ($verify_result) { //获取支付宝的反馈参数 $dingdan = $_POST['out_trade_no']; //获取支付宝传递过来的订单号 $total = $_POST['total_fee']; //获取支付宝传递过来的总价格 $receive_name = $_POST['receive_name']; //获取收货人姓名 $receive_address = $_POST['receive_address']; //获取收货人地址 $receive_zip = $_POST['receive_zip']; //获取收货人邮编 $receive_phone = $_POST['receive_phone']; //获取收货人电话 $receive_mobile = $_POST['receive_mobile']; //获取收货人手机 $trade_status = $_POST['trade_status']; //获取支付宝反馈过来的状态,根据不同的状态来更新数据库 WAIT_BUYER_PAY(表示等待买家付款);WAIT_SELLER_SEND_GOODS(表示买家付款成功,等待卖家发货);WAIT_BUYER_CONFIRM_GOODS(卖家已经发货等待买家确认);TRADE_FINISHED(表示交易已经成功结束) if ($_POST['trade_status'] == 'WAIT_SELLER_SEND_GOODS' and $_POST['trade_status'] == 'TRADE_FINISHED') {
<?php /* SSL Management */ $useSSL = true; include dirname(__FILE__) . '/../../config/config.inc.php'; include dirname(__FILE__) . '/../../header.php'; include dirname(__FILE__) . '/alipay.php'; if (!$cookie->isLogged()) { Tools::redirect('authentication.php?back=order.php'); } if ($_POST['hiddenlink'] != "") { $hiddenlink = $_POST['hiddenlink']; } $alipay = new Alipay(); echo $alipay->execPayment($cart, $hiddenlink); include_once dirname(__FILE__) . '/../../footer.php';
} exit(); } if (!$sustc->user->islogin()) { dredirect('/user/signin?redirect=/user/deposit'); } if (is_post()) { $err['code'] = -1; $err['success'] = false; $depo = isset($_POST['deposit']) ? $_POST['deposit'] : false; if ($depo && isset($_POST['formhash']) && $sustc->security->check_formhash($_POST['formhash'])) { $price = isset($depo['price']) ? intval($depo['price']) : 0; if (isset($depo['method']) && $depo['method'] == 'alipay' && in_array($price, array(500, 1000, 2000, 5000))) { $trade = new Alipay(); //echo '<!DOCTYPE html><html><head></head><body>'; $trade_html = $trade->create_trade($price); //echo '</body></html>'; include template('user/deposit_call'); exit(); } } } $err['disabled'] = isset($_GET['disabled']) ? (intval($_GET['disabled']) != 0 ? TRUE : FALSE) : FALSE; include template('user/deposit'); } else { echo 'WIP'; }
public function pay($request, $response) {/*{{{*/ $this->validLogin(); $user = $this->_newUser; $onlinePayType = $request->onlinePayType; $order = DAL::get()->find('TelOrder', $request->sId); if (false == $order->isNull() && $order->isPayed()) { $response->setRedirect($response->router->urlfor('payment/paymessage', array('orderId'=>$order->id))); return ; } DBC::requireTrue($user->id == $order->getUser()->id, '请患者重新登陆,或者重新下单!'); $ownerDoctor = $order->getExecuterBySpace()->host; $hospitalfaculty = $ownerDoctor->hospitalfaculty; $hospital = $hospitalfaculty->hospital; $description = $hospital->name.$hospitalfaculty->name.$ownerDoctor->name; $buyerCashAccount = $order->owner->relatedObject->getCashAccount(); $balance = 0; if($buyerCashAccount != null && $buyerCashAccount->isNull() == false) { $balance = $order->owner->relatedObject->getCashAccount()->amount; } $amount = number_format($order->getAmount()-$balance, 2, '.', ''); TelOrderClient::getInstance()->updatePayType($order->id, $onlinePayType); //dodo::zhb 创建充值单 $depositeOrder = OrderClient::getInstance()->createDepositeOrder($user, $user->getCashAccount(), $amount, $onlinePayType == 'alipay'?DepositeOrder::RECHARGE_TYPE_ALIPAY:DepositeOrder::RECHARGE_TYPE_QPAY, $order->id, get_class($order)); if($onlinePayType == 'alipay') { //创建支付url $callBackUrl = BeanFinder::get('configs')->alipay_callback_url; $frontUrl = BeanFinder::get('configs')->alipay_callback_returnurl; $payUrl = Alipay::getInstance()->getPayUrl($depositeOrder->id, Pay::TYPE_PAY, $amount, $callBackUrl, TelService::$serviceType[TelService::APPOINTMENT_SERVICE], $description, $frontUrl); header("Location: $payUrl"); exit(); } else { $orders = array(); $orders['orderId'] = $depositeOrder->id; $orders['productName'] = TelService::$serviceType[TelService::APPOINTMENT_SERVICE]; if($onlinePayType == '00') { $orders['bankId'] = ''; $orders['bankType'] = '00'; }else{ $orders['bankId'] = $onlinePayType; $orders['payType'] = 10; } $orders['orderTimestamp'] = Qpay::getInstance()->getQpayOrderTimestamp(); $orders['payerIP'] = XIpLocation::getIp(); $orders['bgUrl'] = BeanFinder::get('configs')->qpay_callback_url; $orders['orderAmount'] = $amount; $qpay = new Qpay(); $qpay->setOrderInfo($orders, Pay::TYPE_PAY); $form = $qpay->getSubmitForm(); $response->form = $form; } }/*}}}*/
public function alipay_return() { $order_id_arr = explode('_', $_GET['out_trade_no']); $order_type = $order_id_arr[0]; $order_id = $order_id_arr[1]; switch ($order_type) { case 'group': $now_order = D('Group_order')->where(array('order_id' => $order_id))->find(); break; case 'meal': $now_order = D('Meal_order')->where(array('order_id' => $order_id))->find(); break; default: $this->error('非法的订单'); } if ($now_order['paid']) { switch ($order_type) { case 'group': $redirctUrl = C('config.site_url') . '/index.php?g=User&c=Index&a=group_order_view&order_id=' . $now_order['order_id']; break; case 'meal': $redirctUrl = C('config.site_url') . '/index.php?g=User&c=Index&a=meal_order_view&order_id=' . $now_order['order_id']; break; } redirect($redirctUrl); exit; } $pay_method = D('Config')->get_pay_method(); if (empty($pay_method)) { $this->error_tips('系统管理员没开启任一一种支付方式!'); } $import_result = import('@.ORG.pay.Alipay'); $pay_class = new Alipay('', '', $pay_type, $pay_method['alipay']['config'], $this->user_session, 0); $go_query_param = $pay_class->query_order(); if ($go_query_param['error'] === 0) { switch ($order_type) { case 'group': D('Group_order')->after_pay($go_query_param['order_param']); break; case 'meal': D('Meal_order')->after_pay($go_query_param['order_param']); break; } } switch ($order_type) { case 'group': $redirctUrl = C('config.site_url') . '/index.php?g=User&c=Index&a=group_order_view&order_id=' . $now_order['order_id']; break; case 'meal': $redirctUrl = C('config.site_url') . '/index.php?g=User&c=Index&a=meal_order_view&order_id=' . $now_order['order_id']; break; } redirect($redirctUrl); }
/** * 获取远程服务器ATN结果,验证返回URL * @param $notify_id 通知校验ID * @return 服务器ATN结果 * 验证结果集: * invalid命令参数不对 出现这个错误,请检测返回处理中partner和key是否为空 * true 返回正确信息 * false 请检查防火墙或者是服务器阻止端口问题以及验证时间是否超过一分钟 */ public function getResponse($notify_id) { $transport = strtolower(trim($this->Config['transport'])); $partner = trim($this->Config['partner']); $veryfy_url = ''; if ($transport == 'https') { $veryfy_url = $this->httpsVerifyUrl; } else { $veryfy_url = $this->httpVerifyUrl; } $veryfy_url = $veryfy_url . "partner=" . $partner . "¬ify_id=" . $notify_id; $responseTxt = Alipay::getHttpResponseGET($veryfy_url, $this->Config['cacert']); return $responseTxt; }
<?php use alipay\WebPay; function __autoload($class) { static $classLib = []; $path = dirname(__FILE__) . DIRECTORY_SEPARATOR; $file = $path . str_replace('\\', '/', $class) . '.php'; $md5file = md5($file); if (in_array($md5file, $classLib)) { return true; } $classLib[] = $md5file; include $file; } $alipay = new Alipay(); $alipay->setKey(''); // 填写 $webPay = new WebPay(); $webPay->setPartner(''); // 填写 $webPay->setSeller_email(''); // 填写 $webPay->setGateway('https://mapi.alipay.com/gateway.do'); $webPay->setOut_trade_no(2015092900010001.0); $webPay->setSubject('支付测试商品,不声成实际购买订单'); $webPay->setBody('支付测试商品,不声成实际购买订单'); $webPay->setTotal_fee(30.55); $webPay->setNotify_url("http://www.nogi.com/notify.php"); $webPay->setReturn_url("http://www.nogi.com/notify.php"); $url = $alipay->toWebPayed($webPay);
/** * 功能号:12081 * 支付宝支付订单 * */ public function order_alipay() { require_once ROOT . "class/plus/alipay/alipay.config.php"; COMFilter::$_jump = false; // $paymentid = Core::$_dataFilter->valueCheck( Core::get("payment") , "Integer" , "数据非法"); /* $payment_name = $this->_payment[$paymentid]; if(empty($payment_name)){ Core::json_error('支付方式不合法'); }*/ $host = $this->_host; //支付类型 $payment_type = "1"; //必填,不能修改 //服务器异步通知页面路径 $notify_url = "http://{$host}/tvmv/notify_url.php"; //需http://格式的完整路径,不能加?id=123这类自定义参数 //页面跳转同步通知页面路径 $return_url = "http://{$host}/tvmv/return_url.php"; //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/ //商户订单号 $out_trade_no = $_COOKIE['CLIENTORDERSN']; if (!self::checkcode($out_trade_no)) { Core::json_error('订单号不合法'); } //商户网站订单系统中唯一订单号,必填 //订单名称 $subject = "TVM-手机电影服务"; //必填 //付款金额 $total_fee = 0.01; //必填 //商品展示地址 $show_url = $_POST['WIDshow_url']; //必填,需以http://开头的完整路径,例如:http://www.商户网址.com/myorder.html //订单描述 $body = " TVM-手机电影服务"; //选填 //构造要请求的参数数组,无需改动 $parameter = array("service" => "alipay.wap.create.direct.pay.by.user", "partner" => trim($alipay_config['partner']), "seller_id" => trim($alipay_config['seller_id']), "payment_type" => $payment_type, "notify_url" => $notify_url, "return_url" => $return_url, "out_trade_no" => $out_trade_no, "subject" => $subject, "total_fee" => $total_fee, "show_url" => $show_url, "body" => $body, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $alipaySubmit = new Alipay($alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter, "get", "确认"); echo $html_text; }
public function callbackAlipay() { $order_no = Input::get('out_trade_no', 0); $ali_trade_no = Input::get('trade_no', ''); $ali_trade_status = Input::get('trade_status', ''); $amount = Input::get('total_fee', 0); $via_id = Input::get('buyer_id', ''); $refund_account = Input::get('buyer_email', ''); DB::beginTransaction(); try { $alipay = new Alipay(); $alipay->verifyNotify(); $transaction_id = $ali_trade_no; $orders = Order::getGroupOrdersByNo($order_no); if ($ali_trade_status == 'TRADE_FINISHED' || $ali_trade_status == 'TRADE_SUCCESS') { $u_id = 0; foreach ($orders as $key => $order) { $u_id = $order->u_id; $o_id = $order->o_id; $order->pay(Alipay::PAYMENT_TAG); $order->checkoutCarts(); } $cart = Cart::where('o_id', '=', $o_id)->where('c_status', '<>', 0)->first(); if ($cart->c_type == Cart::$TYPE_REGULAR_PRODUCT || $cart->c_type == Cart::$TYPE_FLEA_PRODUCT) { $log_cate = LogTransaction::$CATE_PRODUCT; } elseif ($cart->c_type == Cart::$TYPE_CROWD_FUNDING) { $log_cate = LogTransaction::$CATE_CROWDFUNDING; } elseif ($cart->c_type == Cart::$TYPE_AUCTION) { $log_cate = LogTransaction::$CATE_AUCTION; } else { $log_cate = 0; } //add transaction log $log = new LogTransaction(); $log->l_type = LogTransaction::$TYPE_TRADE; $log->l_cate = $log_cate; $log->l_amt = $amount; $log->from_type = LogTransaction::$OPERATOR_USER; $log->from_id = $u_id; $log->to_type = LogTransaction::$OPERATOR_QNCK; $log->to_id = 1; $log->via_type = LogTransaction::$PAYMENT_ALIPAY; $log->via_id = $via_id; $log->transaction_id = $transaction_id; $log->addLog(); if (empty($log->l_id)) { throw new Exception("添加交易记录失败", 2001); } $log_order = new LogTransactionOrders(); $log_order->l_id = $log->l_id; $log_order->o_group_number = $order_no; $log_order->refund_account = $refund_account; $log_order->save(); } DB::commit(); echo "success"; die; } catch (Exception $e) { DB::rollback(); echo "fail"; die; } exit; }
public function actionAlipayReturn() { //ali验证不允许有多余参数 if (isset($_GET['r'])) { unset($_GET['r']); } $out_trade_no = $_GET['out_trade_no']; $trade_no = $_GET['trade_no']; $trade_status = $_GET['trade_status']; global $sysSettings; $alipay = new Alipay($sysSettings['payment']['aliPartner'], $sysSettings['payment']['aliKey']); if ($alipay->verifyReturn()) { $order = Order::model()->findByPk($out_trade_no); $course = Course::model()->findByAttributes(array('entityId' => $order->produceEntityId)); // modified by wzh if ($order->status == Order::ORDER_PAID) { Yii::app()->user->setFlash('success', '购买成功!你已经成功选上课程'); } $this->redirect(array('view', 'id' => $course->id)); } else { throw new CHttpException(404, '验证错误!'); } }
$subject = $_POST['WIDsubject']; //必填 //付款金额 $total_fee = $_POST['WIDtotal_fee']; //必填 //订单描述 $body = $_POST['WIDbody']; //商品展示地址 $show_url = $_POST['WIDshow_url']; //需以http://开头的完整路径,例如:http://www.xxx.com/myorder.html //防钓鱼时间戳 $anti_phishing_key = ""; //若要使用请调用类文件submit中的query_timestamp函数 //客户端的IP地址 $exter_invoke_ip = ""; //非局域网的外网IP地址,如:221.0.0.1 /************************************************************/ $detector = new Mobile_Detect(); $is_mobile = $detector->isMobile(); //建立请求 $alipay = new Alipay($alipay_config, $is_mobile); if ($is_mobile) { $params = $alipay->prepareMobileTradeData(array('out_trade_no' => $out_trade_no, 'subject' => $subject, 'body' => $body, 'total_fee' => $total_fee, 'merchant_url' => 'http://' . $_SERVER['HTTP_HOST'], 'req_id' => date('Ymdhis-'))); echo $alipay->buildRequestFormHTML($params, 'get'); } else { echo $alipay->buildRequestFormHTML(array("service" => "create_direct_pay_by_user", "partner" => trim($alipay_config['partner']), "payment_type" => $payment_type, "notify_url" => $notify_url, "return_url" => $return_url, "seller_id" => $alipay_config['partner'], "out_trade_no" => $out_trade_no, "subject" => $subject, "total_fee" => $total_fee, "body" => $body, "show_url" => $show_url, "anti_phishing_key" => $anti_phishing_key, "exter_invoke_ip" => $exter_invoke_ip, "_input_charset" => trim(strtolower($alipay_config['input_charset']))), "post"); } ?> </body> </html>
public function alipayCallBack4notify() {/*{{{*/ $content = $_POST; $payable = Alipay::getInstance()->initCallBackData($content,Pay::NAME_TYPE_ALIPAY_NOTIFY); //参数检查,如果无效,直接退出 $this->_checkPayable($payable,Pay::NAME_TYPE_ALIPAY_NOTIFY); //notify $ret = $this->_callbackImp4notify(); if($ret){ //返回回调成功 echo "success"; }else { echo "fail"; } exit; }/*}}}*/
<?php require_once "../Alipay.php"; $sale_id = uniqid(); $amount = 10.25; $description = "A pair of shoes"; $uuid = uuid(); // Associate the sale id with uuid in your database for a look up once Alipay // pings your notify_url $return_url = "http://localhost/site?action=return&sale_id={$sale_id}"; $notify_url = "http://localhost/site?action=notify&id={$uuid}"; function uuid() { $data = openssl_random_pseudo_bytes(16); $data[6] = chr(ord($data[6]) & 0xf | 0x40); // set version to 0010 $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10 return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); } $alipay = new Alipay(); // Generates a one-time URL to redirect the Buyer to $approve = $alipay->createPayment($sale_id, $amount, $description, $return_url, $notify_url); echo "<a href='{$approve}'>Test Transaction Link</a>";
public function getAliPayItemList($request, $response) {/*{{{*/ //第一次查询列表 $isFirstQuery = $request->query; $depositeId = $request->depositeId; $failDepositeOrderIds = array(); $page = $request->page ? $request->page : 1; $pageSize = 100; $startMinute = $request->startMinute; $endMinute = $request->endMinute; $startNormalTime = $request->getRequest('startTime', XDateTime::now()->toShortString()); $startTime = $startNormalTime.' '.$request->getRequest('startHour', '00').':'.$request->getRequest('startMinute', '00').':00'; $endTime = $startNormalTime.' '.$request->getRequest('endHour', '23').':'.$request->getRequest('endMinute', '00').':59'; DBC::requireTrue(XDateTime::secondDiff(XDateTime::valueOf($endTime), XDateTime::valueOf($startTime)) <= 0 , "结束时间不能大于开始时间"); $isSuccess = false; $returnItems = array(); //第一次查询isFirstQuery有值 if(empty($isFirstQuery)) {/*{{{*/ $itemUrl = Alipay::getInstance()->getPayItemList($page, $pageSize, $startTime, $endTime); $xml = file_get_contents($itemUrl); $itemValues = simplexml_load_string($xml); if($itemValues->is_success == 'T') { $i = 0; $isSuccess = true; $xmlResponse = $itemValues->response; $account_page_query_result = $xmlResponse->account_page_query_result; $response->hasNextPage = $account_page_query_result->has_next_page && $account_page_query_result->has_next_page == 'T'; $account_log_list = $account_page_query_result->account_log_list; $AccountQueryAccountLogVO = $account_log_list->AccountQueryAccountLogVO; foreach($AccountQueryAccountLogVO as $item) { $i++; $items = array(); $depositeOrderId = strstr($item->merchant_out_order_no,'_', true); if($item->income > 0 && $item->outcome == 0 ) { $items = $this->getAllAliPayList($item, $depositeOrderId, $items); //查询全部 if(empty($depositeId)) { $returnItems[$i] = $items; } else if ($depositeId == $depositeOrderId) { $returnItems[$i] = $items; } //区间内最多50条status为fail的记录 $failDepositeId = $this->getFailDepositeOrderIds($items, $depositeOrderId); $failDepositeOrderIds[] = $failDepositeId; } } } else { $response->errorMsg = $itemValues->error; } }/*}}}*/ //充值失败充值单 $failDepositeOrders = DAL::get()->find('depositeorder', $failDepositeOrderIds); $response->failDepositeOrders = $failDepositeOrders; $response->items = $returnItems; $response->isSuccess = $isSuccess; $response->startHour = $request->startHour; $response->endHour = $request->endHour; $response->startTime = $request->startTime; $response->startMinute = $request->startMinute; $response->endMinute = $request->endMinute; $response->page = $page; $response->depositeId = $depositeId; }/*}}}*/
<?php require_once dirname(__FILE__) . '/Lib/Alipay.php'; $alipay = new Alipay(['cookie' => '', 'notify' => '', 'token' => 'please_input_your_token']); while (true) { echo date('Y-m-d H:i:s') . "\n"; $alipay->run(); usleep(5000000); }
* 该页面可以使用PHP开发工具调试,也可以使用写文本函数logResult,该函数已被默认关闭,见alipay_notify_class.php中的函数verifyReturn */ require_once "config.php"; require_once "lib/Alipay.class.php"; ?> <!DOCTYPE HTML> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" /> <title>支付宝即时到账交易接口</title> </head> <body> <?php //计算得出通知验证结果 $alipay = new Alipay($alipay_config); $verify_result = $alipay->verifyCallback(); if ($verify_result) { //验证成功 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //请在这里加上商户的业务逻辑程序代码 //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表 //商户订单号 $out_trade_no = $_GET['out_trade_no']; //支付宝交易号 $trade_no = $_GET['trade_no']; //交易状态 $trade_status = $_GET['trade_status']; if ($_GET['trade_status'] == 'TRADE_FINISHED' || $_GET['trade_status'] == 'TRADE_SUCCESS') { //判断该笔订单是否在商户网站中已经做过处理
private function _alipayForOrder($amount, $order, DepositeOrder $depositeOrder) {/*{{{*/ $callBackUrl = BeanFinder::get('configs')->alipay_callback_url; $frontUrl = BeanFinder::get('configs')->alipay_callback_returnurl; if($order instanceof ScoreOrder) { $description = $this->user->name."充值兑换积分"; $type = Pay::TYPE_SCOREORDER; } else if($order instanceof ServiceOrder) { $description = $this->user->name."充值购买咨询"; $type = Pay::TYPE_FLOWORDER; } else if($order instanceof DepositeOrder) { $type = Pay::TYPE_RECHARGE; $description = $this->user->name."充值"; } else { return false; } return Alipay::getInstance()->getPayUrl($depositeOrder->id, $type, $amount, $callBackUrl, ServiceDef::getServiceSpec(ServiceDef::TYPE_TELORDER)->text, $description, $frontUrl); }/*}}}*/
/** * This method checks data integrity * @param bool $response * @param bool $params * @return bool */ public function processResponse($response = true, $params = true) { $alipay = new Alipay(); if (!$response || !$params) { $this->errors[] = $alipay->l('An error occured. Please contact the merchant to have more informations'); return false; } $cart = new Cart((int) $this->id_cart); if (!Validate::isLoadedObject($cart)) { $this->errors[] = $alipay->l('Cannot load Cart object.'); return false; } $customer = new Customer((int) $cart->id_customer); if (!Validate::isLoadedObject($customer)) { $this->errors[] = $alipay->l('Cannot load Customer object.'); return false; } if ($customer->secure_key != $this->secure_key || !$this->compareSign()) { $this->errors[] = $alipay->l('An error occured. Please contact the merchant to have more informations'); return false; } $this->tplVars = array('id_cart' => $this->id_cart, 'id_module' => $this->id_module, 'secure_key' => $this->secure_key); return true; }
public function pay($request, $response) { /*{{{*/ $this->validLogin($response); $source = $this->getSource($request); if ($source->isNull()) { $response->setRedirect($this->space->getPhoneServiceUrl4Order()); return parent::DIRECT_OUTPUT; } $this->checkIsMySource($source); if ($source->isPaid()) { $response->setRedirect($source->successUrl()); return parent::DIRECT_OUTPUT; } $account = $source->user->getCashAccount(); if ($account->amount >= $source->getSalePrice()) { $response->setRedirect($response->router->urlfor('payment/showpaytype', array('sourceId' => $source->id, 'sourceType' => $request->sourceType))); return parent::DIRECT_OUTPUT; } $amount = XString::calculateBalancePrice($source->getSalePrice(), $account->amount); $doctor = $this->space->host; $hospitalfaculty = $doctor->hospitalfaculty; $hospital = $hospitalfaculty->hospital; $description = $hospital->name . $hospitalfaculty->name . $doctor->name; $onlinePayType = $request->onlinePayType; $depositeOrder = OrderClient::getInstance()->createDepositeOrder($this->user, $amount, $onlinePayType == 'alipay' ? DepositeOrder::RECHARGE_TYPE_ALIPAY : DepositeOrder::RECHARGE_TYPE_QPAY, array($source)); if ($onlinePayType == 'alipay') { //创建支付url $callBackUrl = BeanFinder::get('configs')->alipay_callback_url; $frontUrl = BeanFinder::get('configs')->alipay_callback_returnurl; $payUrl = Alipay::getInstance()->getPayUrl($depositeOrder->id, Pay::TYPE_PAY, $depositeOrder->amount, $callBackUrl, ServiceDef::getServiceSpec(ServiceDef::TYPE_TELORDER)->text, $description, $frontUrl); $response->exitJump($payUrl); } else { if ($onlinePayType == '00') { $orders = array(); $orders['orderId'] = $depositeOrder->id; $orders['productName'] = ServiceDef::getServiceSpec(ServiceDef::TYPE_TELORDER)->text; $orders['bankId'] = ''; $orders['bankType'] = '00'; $orders['orderTimestamp'] = Qpay::getInstance()->getQpayOrderTimestamp(); $orders['payerIP'] = XIpLocation::getIp(); $orders['bgUrl'] = BeanFinder::get('configs')->qpay_callback_url; $orders['orderAmount'] = $amount; $qpay = new Qpay(); $qpay->setOrderInfo($orders, Pay::TYPE_PAY); $form = $qpay->getSubmitForm(); $response->form = $form; } else { //创建支付url $callBackUrl = BeanFinder::get('configs')->alipay_gateway_callback_url; $frontUrl = BeanFinder::get('configs')->alipay_gateway_callback_returnurl; $payUrl = GatewayAlipay::getInstance()->getPayUrl($depositeOrder->id, Pay::TYPE_PAY, $amount, $callBackUrl, ServiceDef::getServiceSpec(ServiceDef::TYPE_TELORDER)->text, $description, $frontUrl, $onlinePayType); $response->form = $payUrl; } } }
/** * 建立请求,以模拟远程HTTP的POST请求方式构造并获取支付宝的处理结果,带文件上传功能 * @param $para_temp 请求参数数组 * @param $file_para_name 文件类型的参数名 * @param $file_name 文件完整绝对路径 * @return 支付宝返回处理结果 */ function buildRequestHttpInFile($para_temp, $file_para_name, $file_name) { //待请求参数数组 $para = $this->buildRequestPara($para_temp); $para[$file_para_name] = "@" . $file_name; //远程获取数据 $sResult = Alipay::getHttpResponsePOST($this->gatewayNew, $this->config['cacert'], $para, trim(strtolower($this->config['input_charset']))); return $sResult; }