示例#1
0
 public function alipay($amount, $callback, $data = array())
 {
     $config = \Eva\Api::_()->getModuleConfig('Payment');
     $options = $config['payment']['alipay'];
     $orderId = time();
     $config = $this->getServiceLocator()->get('config');
     $helper = $this->getEvent()->getApplication()->getServiceManager()->get('viewhelpermanager')->get('serverurl');
     $notify = $helper() . $config['payment']['return_url_path'] . '?' . http_build_query(array('callback' => 'notify'));
     $pay = new \Payment\Service\Payment('AlipayEc', false, $options);
     $pay->setServiceLocator($this->getServiceLocator());
     if (isset($data['title'])) {
         $pay->setOrderTitle($data['title']);
     }
     $link = $pay->setAmount($amount)->setOrderId($orderId)->setNotify($notify)->setCallback($callback)->setLogData($data)->sendRequest();
     return $this->redirect()->toUrl($link);
 }
示例#2
0
 public function authenticate($params)
 {
     $adapter = $params['adapter'];
     $callback = $params['callback'];
     $amount = $params['amount'];
     $secretKey = $params['secretKey'];
     $requestTime = $params['time'];
     $signed = $params['signed'];
     $itemModel = \Eva\Api::_()->getModel('Payment\\Model\\Log');
     $log = $itemModel->getLog($secretKey, array('self' => array('*', 'unserializeRequestData()', 'unserializeResponseData()')));
     if (!$log) {
         return false;
     }
     $adapter = $adapter == 'paypalec' ? 'PaypalEc' : 'AlipayEc';
     $pay = new \Payment\Service\Payment($adapter);
     $pay->setServiceLocator($this->getServiceLocator());
     $authenticate = $pay->setAmount($amount)->setRequestTime($requestTime)->setlogData($log['requestData'])->setStep('cancel')->getSigned();
     if ($authenticate !== $signed) {
         return false;
     }
     return true;
 }
 public function alipayResponse()
 {
     $callback = $this->params()->fromQuery('callback');
     $responseData = $this->params()->fromQuery();
     if (!isset($responseData['notify_id'])) {
         $responseData = $this->params()->fromPost();
         $method = 'notify';
     }
     $config = \Eva\Api::_()->getModuleConfig('Payment');
     $options = $config['payment']['alipay'];
     $pay = new \Payment\Service\Payment('AlipayEc', false, $options);
     $verify_result = $pay->verify();
     if ($verify_result) {
         $pay->setStep('response');
         $pay->saveResponseLog($responseData['out_trade_no'], $responseData);
     }
     if ($callback == 'notify') {
         return;
     }
     if ($callback) {
         return $this->redirect()->toUrl($callback);
     }
 }