Ejemplo n.º 1
0
 /**
  * Set test data.
  */
 public function setUp()
 {
     $this->sellerId = 'id2000';
     $this->sellerName = 'Ülo Pääsuke';
     $this->sellerAccount = '1010342342354345435';
     $this->senderName = 'Toomas Jäär';
     $this->orderId = 100;
     $this->amount = 10.0;
     $this->message = 'First payment';
     $this->language = 'EST';
     $this->currency = 'EUR';
     $this->timezone = 'Europe/Tallinn';
     // From ENV variable
     $this->datetime = getenv('TEST_DATETIME');
     $this->customRequestUrl = 'http://example.com';
     $this->expectedData = array('VK_SERVICE' => '1012', 'VK_VERSION' => '008', 'VK_SND_ID' => $this->sellerId, 'VK_STAMP' => $this->orderId, 'VK_AMOUNT' => $this->amount, 'VK_CURR' => $this->currency, 'VK_REF' => ProtocolHelper::calculateReference($this->orderId), 'VK_MSG' => $this->message, 'VK_RETURN' => $this->customRequestUrl, 'VK_CANCEL' => $this->customRequestUrl, 'VK_LANG' => $this->language, 'VK_MAC' => 'PmAB256IR1FzTKZHNn5LBPso/KyLAhNcTOMq82lhpYn0mXKYtVtpNkolQxyETnTcIn1TcYOmekJEATe86Bz2MRljEQqllkaIl7bNuLCtuBPtAOYWNLmQHoop+5QSiguJEmEV+JJU3w4BApjWcsHA5HYlYze+3L09UO6na0lB/Zs=', 'VK_DATETIME' => $this->datetime, 'VK_ENCODING' => 'UTF-8');
     // Set up banklink
     $this->setUpBanklink();
 }
Ejemplo n.º 2
0
 /**
  * Get payment object.
  *
  * @param string $orderId  Order ID
  * @param float  $sum      Sum of order
  * @param string $message  Transaction description
  * @param string $encoding Encoding
  * @param string $language Language
  * @param string $currency Currency. Default: EUR
  * @param string $timezone Timezone. Default: Europe/Tallinn
  *
  * @return array Payment request data
  */
 public function getPaymentRequest($orderId, $sum, $message, $encoding = 'UTF-8', $language = 'EST', $currency = 'EUR', $timezone = 'Europe/Tallinn')
 {
     $time = getenv('CI') ? getenv('TEST_DATETIME') : 'now';
     $datetime = new \Datetime($time, new \DateTimeZone($timezone));
     $data = array('VK_SERVICE' => $this->serviceId, 'VK_VERSION' => $this->version, 'VK_SND_ID' => $this->sellerId, 'VK_STAMP' => $orderId, 'VK_AMOUNT' => $sum, 'VK_CURR' => $currency, 'VK_REF' => ProtocolHelper::calculateReference($orderId), 'VK_MSG' => $message, 'VK_RETURN' => $this->requestUrl, 'VK_CANCEL' => $this->requestUrl, 'VK_DATETIME' => $datetime->format('Y-m-d\\TH:i:sO'), 'VK_LANG' => $language);
     if (Services::PAYMENT_REQUEST_1011 === $this->serviceId) {
         $data['VK_NAME'] = $this->sellerName;
         $data['VK_ACC'] = $this->sellerAccount;
     }
     // Generate signature
     $data['VK_MAC'] = $this->getSignature($data, $encoding);
     return $data;
 }
Ejemplo n.º 3
0
 /**
  * Test exception for too short order id.
  *
  * @expectedException InvalidArgumentException
  */
 public function testReferenceTooShortNotInteger()
 {
     ProtocolHelper::calculateReference('');
 }