예제 #1
0
 /**
  * Get a formatted string containing all data according to the OmniKassa requirement
  *
  * @return string
  *
  * @throws \BadMethodCallException if no currency is specified
  * @throws \BadMethodCallException if no amount is specified
  * @throws \BadMethodCallException if no merchantId is specified
  * @throws \BadMethodCallException if no orderId is specified
  * @throws \BadMethodCallException if no normalReturnUrl is specified
  * @throws \BadMethodCallException if no automaticResponseUrl is specified
  * @throws \BadMethodCallException if no transactionReference is specified
  * @throws \BadMethodCallException if no keyVersion is specified
  *
  */
 public function getData()
 {
     if (defined('OMNIKASSA_TEST_MODE')) {
         $this->enableTestMode();
     }
     $orderData = $this->order->getData();
     // Required fields
     $requestData = array('normalReturnUrl' => $this->normalReturnUrl, 'automaticResponseUrl' => $this->automaticResponseUrl, 'keyVersion' => $this->keyVersion);
     if ($this->customerLanguage !== null) {
         $requestData['customerLanguage'] = $this->customerLanguage;
     }
     if ($this->expirationDate !== null) {
         $requestData['expirationDate'] = $this->expirationDate;
     }
     if (sizeof($this->paymentMeanBrandList) > 0) {
         $requestData['paymentMeanBrandList'] = implode(',', $this->paymentMeanBrandList);
     }
     $data = array_merge($requestData, $orderData);
     //quick dirty validation on null values
     foreach ($data as $key => $value) {
         if (null == $value) {
             throw new \BadMethodCallException(sprintf('No %s specified', $key));
         }
     }
     return implode('|', array_map(function ($v, $k) {
         return sprintf('%s=%s', $k, $v);
     }, $data, array_keys($data)));
 }