Esempio n. 1
0
 public function testSetConfigPosAuthKeyEmpty()
 {
     $this->scopeConfig->expects($this->at(0))->method('getValue')->with($this->equalTo(Payupl::XML_PATH_POS_ID), $this->equalTo('store'))->willReturn('value');
     $this->scopeConfig->expects($this->at(1))->method('getValue')->with($this->equalTo(Payupl::XML_PATH_KEY_MD5), $this->equalTo('store'))->willReturn('value');
     $this->scopeConfig->expects($this->at(2))->method('getValue')->with($this->equalTo(Payupl::XML_PATH_SECOND_KEY_MD5), $this->equalTo('store'))->willReturn('value');
     $this->scopeConfig->expects($this->at(3))->method('getValue')->with($this->equalTo(Payupl::XML_PATH_POS_AUTH_KEY), $this->equalTo('store'))->willReturn('');
     $this->setExpectedException(LocalizedException::class, 'POS auth key is empty.');
     $this->model->setConfig();
 }
 /**
  * @return \Zend\Http\Client
  */
 public function getClient()
 {
     if (!$this->client) {
         $posId = $this->configHelper->getConfig('pos_id');
         $keyMd5 = $this->configHelper->getConfig('key_md5');
         $url = 'https://secure.payu.com/paygw/UTF/xml/' . $posId . '/' . substr($keyMd5, 0, 2) . '/paytype.xml';
         $this->client = new \Zend\Http\Client($url, ['adapter' => 'Zend\\Http\\Client\\Adapter\\Curl']);
     }
     return $this->client;
 }
Esempio n. 3
0
 public function getPayuplOrderId($request)
 {
     if (!$request->isPost()) {
         throw new LocalizedException(new Phrase('POST request is required.'));
     }
     $sig = $request->getParam('sig');
     $ts = $request->getParam('ts');
     $posId = $request->getParam('pos_id');
     $sessionId = $request->getParam('session_id');
     $secondKeyMd5 = $this->configHelper->getConfig('second_key_md5');
     if (md5($posId . $sessionId . $ts . $secondKeyMd5) === $sig) {
         return $sessionId;
     }
     throw new LocalizedException(new Phrase('Invalid SIG.'));
 }
Esempio n. 4
0
 /**
  * @param array $data
  * @return string
  */
 public function getSigForOrderRetrieve(array $data = [])
 {
     return md5($data['pos_id'] . $data['session_id'] . $data['ts'] . $this->configHelper->getConfig('key_md5'));
 }