コード例 #1
0
 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;
         }
     }
 }
コード例 #2
0
    public function getCaseRechargeOrderString4ali($caseId, $caseType, $os)
    {/*{{{*/
        $infos = array();
        if ($caseType != 'flow' && $caseType != 'Flow') {
            $this->setErrorCode(335);
            return false; 
        }
        $flow = DAL::get()->find('DoctorPatientRef', $caseId);
        if ($flow->isNull()) {
            $this->setErrorCode(335);
            return false; 
        }
        $product = ProductClient::getInstance()->getDoctorChargeFlowProduct($flow->space);
        $needPay = XString::calculateBalancePrice($product->salePrice, $flow->user->getCashAccount()->amount);
        if ($needPay <= 0) {
            return false;
        }
        $serviceOrder = ServiceOrderClient::getInstance()->create($flow, $product, $flow->user);
        if ($serviceOrder->isNull()) {
            $this->setErrorCode(307);
            return false;
        }
        //dodo::zhb 创建充值单
        $depositeOrder = OrderClient::getInstance()->createDepositeOrder($flow->user, $needPay, 
            DepositeOrder::RECHARGE_TYPE_ALIPAYWAP, array($serviceOrder)); 
        if ($depositeOrder->isNull()) {
            $this->setErrorCode(3071);
            return false;
        }

        $userName = $flow->user->name;
        $callBackUrl = WapAlipay::getDefaultNotifyUrl();
        $description = $userName."充值购买咨询";
        $type = Pay::TYPE_FLOWORDER;
        $orderString = WapAlipay::getInstance()->encryptOrderInfo($depositeOrder->id, $type, $needPay, $callBackUrl,
                                                                  ServiceDef::getServiceSpec(ServiceDef::TYPE_FLOW)->text,
                                                                  $description);
        $infos['orderString'] = $orderString;
        $infos['wapPayUrl'] = WaperAlipay::getPayUrl4rechargeableCase($caseId, $os, $serviceOrder->id, $depositeOrder->id);
        $infos['wapPayReturnUrl'] = WaperAlipay::getDefaultReturnUrl();
        $infos['wapPaySellerUrl'] = WaperAlipay::getDefaultSellerUrl();
        $this->content = $infos;
    }/*}}}*/
コード例 #3
0
 public function _prepareUnionPayForScoreOrder($request, $response)
 {/*{{{*/
     $scoreOrder = ScoreClient::getInstance()->createScoreOrder($this->user->id, Account::money2Integral($request->price), 
         $request->price, ScoreOrder::EVENT_TYPE_MONEY_CONVERT_SCORE, $request->orderId);    
     $this->checkPriceVaild4PresentOrder($this->user->id, $request->price, $request->orderId);
     //dodo::zhb 创建充值单
     $depositeOrder = OrderClient::getInstance()->createDepositeOrder($this->user, $request->price, 
         DepositeOrder::RECHARGE_TYPE_UNION, array($scoreOrder)); 
     $response->html = $this->_unionPayOrder(UnionPayConnector::TYPE_SCORE.$depositeOrder->id, $request->price, $request->defaultPayType);
 }/*}}}*/
コード例 #4
0
 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;
 }
コード例 #5
0
    public function getPhoneOrderPayStringByOrderId($orderId)
    {/*{{{*/
		$source = DAL::get()->find('intention', $orderId);
        if ($source->isNull())
        {
          //  $proposal = DAL::get()->find('proposal', $orderId);
            $proposal = $this->getRightObj($orderId);
            if($proposal->isNull())
            {
                $this->setErrorCode(313);
                return 0;
            }
            $source = DAL::get()->find_by_source('serviceorder', $proposal);
            if($source->isNull())
            {
                $this->setErrorCode(313);
                return 0;
            }
        }

		$hospitalfaculty = $source->space->host->hospitalfaculty;
		$hospital = $hospitalfaculty->hospital;
		$description = $hospital->commonName.$hospitalfaculty->name.$source->space->name;
        $amount = XString::calculateBalancePrice($source->getSalePrice(), $source->user->getCashAccount()->amount);
        if (0 >= $amount)
        {
            $this->setErrorCode(338);
            return 0;
        }

        //dodo::zhb 创建充值单
        $depositeOrder = OrderClient::getInstance()->createDepositeOrder($source->user, $amount, 
            DepositeOrder::RECHARGE_TYPE_ALIPAYWAP, array($source)); 
        //创建支付url
        $callBackUrl = WapAlipay::getDefaultNotifyUrl();
        $string = WapAlipay::getInstance()->encryptOrderInfo($depositeOrder->id, Pay::TYPE_PAY, $depositeOrder->amount, $callBackUrl, 
                                            ServiceDef::getServiceSpec(ServiceDef::TYPE_TELORDER)->text, $description);
        $infos = array();
        $infos['string'] = $string;
        $infos['wapPayUrl'] = WaperAlipay::getPayUrl4telorder($source->id);
        $infos['wapPayReturnUrl'] = WaperAlipay::getDefaultReturnUrl();
        $infos['wapPaySellerUrl'] = WaperAlipay::getDefaultSellerUrl();
        $this->content = $infos;
    }/*}}}*/
コード例 #6
0
ファイル: test_Orders.php プロジェクト: moodboom/Reusable
 * E*TRADE PHP SDK
 *
 * @package    	PHP-SDK
 * @version		1.1
 * @copyright  	Copyright (c) 2012 E*TRADE FINANCIAL Corp.
 *
 */
require_once "config.php";
require_once dirname(__FILE__) . '/../Common/Common.php';
require_once 'Orders/OrderClient.class.php';
$consumer = new etOAuthConsumer(ETWS_APP_KEY, ETWS_APP_SECRET);
$consumer->oauth_token = OAUTH_ACCESS_TOKEN;
$consumer->oauth_token_secret = OAUTH_ACCESS_TOKEN_SECRET;
// MDM update as desired!
$accountno = 35383656;
$ac_obj = new OrderClient($consumer);
echo "-------------------------------------------------\n";
echo "Welcome to Accounts SDK test utility.\n";
echo "-------------------------------------------------\n";
$valid_choice = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$choice = '1';
while (in_array($choice, $valid_choice)) {
    $choice = show_menu();
    try {
        switch ($choice) {
            //1. Get Order List
            case 1:
                // $out 	= $ac_obj->getOrderList(83310032);
                $out = $ac_obj->getOrderList($accountno);
                break;
                //2. Preview Equity Order
コード例 #7
0
    private function _checkPayable(PayAble $payable,$payType)
    {/*{{{*/
    	$this->payable = $payable;
    	$this->payType = $payType;
    	
    	try{
            $this->paylog = AccountClient::getInstance()->addPayLog($payable->getOrderId(), $this->payType, 
                Pay::$typeDescs[Pay::TYPE_DEPOSITEORDER], $payable->getPayAmount(), $payable->data);
    	}catch(Exception $ex){
    	}
    	
        if(false == $payable->isValid())                                                                                   
        {
            echo '无效访问';
            exit;
        }
        
        try{
        	AccountClient::getInstance()->doPayLogVerifySuccess($this->paylog);
        }catch(Exception $ex)
        {}
        
        $this->depositeOrder = DAL::get()->find('DepositeOrder', $payable->getOrderId(), true);
        if($this->depositeOrder->isNull())
        {
        	echo "充值记录[".$payable->getOrderId()."]不存在";
        	exit;
        }

        if($payable instanceof QPayCardConnector && $payable->getPayAmount() > 0 && 
            (false == $this->equals($payable->getPayAmount(),$this->depositeOrder->amount)))
        {
            $this->depositeOrder = OrderClient::getInstance()->modifyDepositeOrderAmount($this->depositeOrder->id, 
                $payable->getPayAmount());
        }
        else if(false == $payable instanceof QPayCardConnector && 
            (false == $this->equals($payable->getPayAmount(),$this->depositeOrder->amount)))
        {
        	echo "充值记录[".$payable->getOrderId()."]金额有误";
        	exit;
        }
        
    }/*}}}*/
コード例 #8
0
	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;
		}
	}/*}}}*/
コード例 #9
0
 public function alipayChannel4Zixun($request, $response)
 {
     /*{{{*/
     $flow = DAL::get()->find('DoctorPatientRef', $request->refid);
     DBC::requireFalse($flow->isNull(), '无效订单');
     $product = ProductClient::getInstance()->getDoctorChargeFlowProduct($flow->space);
     $needPay = XString::calculateBalancePrice($product->salePrice, $flow->user->getCashAccount()->amount);
     DBC::requireTrue($needPay > 0, '价格有错误 或 余额可够支付');
     $serviceOrder = ServiceOrderClient::getInstance()->create($flow, $product, $flow->user);
     DBC::requireFalse($serviceOrder->isNull(), '无效订单');
     $depositeOrder = OrderClient::getInstance()->createDepositeOrder($flow->user, $needPay, DepositeOrder::RECHARGE_TYPE_ALIPAYWAP, array($serviceOrder));
     DBC::requireFalse($depositeOrder->isNull(), '无效订单!');
     $userName = $flow->user->name;
     $returnUrl = WaperAlipay::getDefaultReturnUrl4TouchZixun();
     $notifyUrl = WaperAlipay::getDefaultNotifyUrl();
     $sellerUrl = WaperAlipay::getDefaultSellerUrl4TouchZixun($serviceOrder->id);
     $aliPayUrl = WaperAlipay::getAliWapPayUrl($depositeOrder->id, $this->getPayTypeByOrder($serviceOrder), $needPay, $notifyUrl, $returnUrl, $sellerUrl, ServiceDef::getServiceSpec(ServiceDef::TYPE_FLOW)->text, $this->getPayDescriptionByOrder($serviceOrder, $userName));
     $response->setRedirect($aliPayUrl);
 }