public function testSigForOrderRetrieve() { $data = ['pos_id' => '123456', 'session_id' => 'ABC', 'ts' => 12345678]; $keyMd5 = 'GHI'; $this->configHelper->expects($this->once())->method('getConfig')->with($this->equalTo('key_md5'))->willReturn($keyMd5); $sig = md5($data['pos_id'] . $data['session_id'] . $data['ts'] . $keyMd5); $this->assertEquals($sig, $this->model->getSigForOrderRetrieve($data)); }
/** * @inheritDoc */ public function create($orderId = '', $description = '', $amount = null) { $realPayuplOrderId = $this->transactionResource->getExtOrderIdByPayuplOrderId($orderId); if ($realPayuplOrderId) { $posId = $this->orderDataGetter->getPosId(); $ts = $this->orderDataGetter->getTs(); $sig = $this->orderDataGetter->getSigForOrderRetrieve(['pos_id' => $posId, 'session_id' => $realPayuplOrderId, 'ts' => $ts]); $authData = ['posId' => $posId, 'sessionId' => $realPayuplOrderId, 'ts' => $ts, 'sig' => $sig]; $getResult = $this->methodCaller->call('refundGet', [$authData]); if ($getResult) { $createResult = $this->methodCaller->call('refundAdd', [$authData, ['refundsHash' => $getResult->refsHash, 'amount' => $amount, 'desc' => $description, 'autoData' => true]]); if ($createResult < 0) { $this->logger->error('Refund error ' . $createResult . ' for transaction ' . $orderId); } return $createResult === 0; } } return false; }
/** * @inheritDoc */ public function retrieve($payuplOrderId) { $posId = $this->dataGetter->getPosId(); $ts = $this->dataGetter->getTs(); $sig = $this->dataGetter->getSigForOrderRetrieve(['pos_id' => $posId, 'session_id' => $payuplOrderId, 'ts' => $ts]); $result = $this->methodCaller->call('orderRetrieve', [$posId, $payuplOrderId, $ts, $sig]); if ($result) { return ['status' => $result->transStatus, 'amount' => $result->transAmount / 100]; } return false; }