Пример #1
0
 public static function requireServiceId()
 {
     $serviceId = Config::getServiceId();
     if (empty($serviceId)) {
         throw new Error\Required\ServiceId();
     }
 }
Пример #2
0
 public function doRequest($endpoint = null)
 {
     if (isset(self::$cache[Config::getServiceId()])) {
         return self::$cache[Config::getServiceId()];
     } else {
         $result = parent::doRequest('transaction/getService');
         self::$cache[Config::getServiceId()] = $result;
         return $result;
     }
 }
Пример #3
0
 /**
  * Do the request
  *
  * @param null $endpoint
  * @param null $version
  * @return array The result
  */
 public function doRequest($endpoint = null, $version = null)
 {
     if (isset(self::$cache[Config::getServiceId()])) {
         Helper::requireApiToken();
         Helper::requireServiceId();
         return self::$cache[Config::getServiceId()];
     } else {
         $result = parent::doRequest('transaction/getService');
         self::$cache[Config::getServiceId()] = $result;
         return $result;
     }
 }
Пример #4
0
 protected function getData()
 {
     if ($this->isApiTokenRequired()) {
         Helper::requireApiToken();
         $this->data['token'] = Config::getApiToken();
     }
     if ($this->isServiceIdRequired()) {
         Helper::requireServiceId();
         $this->data['serviceId'] = Config::getServiceId();
     }
     return $this->data;
 }
Пример #5
0
 protected function getData()
 {
     // Checken of alle verplichte velden geset zijn
     Helper::requireServiceId();
     $data['serviceId'] = Config::getServiceId();
     if ($this->_testMode === true) {
         $data['testMode'] = '1';
     } else {
         $data['testMode'] = '0';
     }
     if (empty($this->_amount)) {
         throw new \ErrorRequired('Amount is niet geset', 1);
     } else {
         $data['amount'] = $this->_amount;
     }
     if (!empty($this->_paymentOptionId)) {
         $data['paymentOptionId'] = $this->_paymentOptionId;
     }
     if (empty($this->_finishUrl)) {
         throw new ErrorRequired('FinishUrl is niet geset', 1);
     } else {
         $data['finishUrl'] = $this->_finishUrl;
     }
     if (!empty($this->_exchangeUrl)) {
         $data['transaction']['orderExchangeUrl'] = $this->_exchangeUrl;
     }
     if (!empty($this->_description)) {
         $data['transaction']['description'] = $this->_description;
     }
     if (!empty($this->_paymentOptionSubId)) {
         $data['paymentOptionSubId'] = $this->_paymentOptionSubId;
     }
     //ip en browserdata setten browserdata set ik met dummydata
     $data['ipAddress'] = Helper::getIp();
     if (!empty($this->_products)) {
         //            $data['saleData']['invoiceDate'] = date('d-m-Y');
         //            $data['saleData']['deliveryDate'] = date('d-m-Y', strtotime('+1 day'));
         $data['saleData']['orderData'] = $this->_products;
     }
     if (!empty($this->_enduser)) {
         $data['enduser'] = $this->_enduser;
     }
     if (!empty($this->_extra1)) {
         $data['statsData']['extra1'] = $this->_extra1;
     }
     if (!empty($this->_extra2)) {
         $data['statsData']['extra2'] = $this->_extra2;
     }
     if (!empty($this->_extra3)) {
         $data['statsData']['extra3'] = $this->_extra3;
     }
     if (!empty($this->_promotorId)) {
         $data['statsData']['promotorId'] = $this->_promotorId;
     }
     if (!empty($this->_info)) {
         $data['statsData']['info'] = $this->_info;
     }
     if (!empty($this->_tool)) {
         $data['statsData']['tool'] = $this->_tool;
     }
     if (!empty($this->_object)) {
         $data['statsData']['object'] = $this->_object;
     }
     if (!empty($this->_domainId)) {
         $data['statsData']['domain_id'] = $this->_domainId;
     }
     if (!empty($this->_transferData)) {
         $data['statsData']['transferData'] = $this->_transferData;
     }
     $this->data = array_merge($data, $this->data);
     return parent::getData();
 }
Пример #6
0
Файл: Api.php Проект: ivodvb/sdk
 public function doRequest($endpoint, $version = null)
 {
     if (is_null($version)) {
         $version = $this->version;
     }
     $data = $this->getData();
     $uri = Config::getApiUrl($endpoint, $version);
     $curl = Config::getCurl();
     if (Config::getCAInfoLocation()) {
         // set a custom CAInfo file
         $curl->setOpt(CURLOPT_CAINFO, Config::getCAInfoLocation());
     }
     $result = $curl->post($uri, $data);
     if ($curl->error) {
         // todo handle 400 errors properly, the SDK user needs to know what
         // went wrong
         $error = new Error\Error($curl->errorMessage);
         $error->setAdditionalData($result)->setServiceId(Config::getServiceId())->setApiToken(Config::getApiToken())->setApiEndpoint($endpoint)->setApiEndpointVersion($version);
         throw $error;
     }
     $output = static::processResult($result);
     return $output;
 }
Пример #7
0
 public function testServiceId()
 {
     \Paynl\Config::setServiceId('my-service-id');
     $this->assertEquals('my-service-id', \Paynl\Config::getServiceId());
 }
Пример #8
0
Файл: Add.php Проект: ivodvb/sdk
 /**
  * Get data to send to the api
  *
  * @return array
  * @throws ErrorRequired
  */
 protected function getData()
 {
     Helper::requireServiceId();
     $this->data['serviceId'] = Config::getServiceId();
     if (empty($this->_amount)) {
         throw new ErrorRequired('Amount is not set', 1);
     }
     $this->data['amount'] = $this->_amount;
     if (empty($this->_bankAccountHolder)) {
         throw new ErrorRequired('bankAccountHolder is not set', 1);
     }
     $this->data['bankAccountHolder'] = $this->_bankAccountHolder;
     if (empty($this->_bankAccountNumber)) {
         throw new ErrorRequired('bankAccountNumber is not set', 1);
     }
     $this->data['bankAccountNumber'] = $this->_bankAccountNumber;
     if (!empty($this->_bankAccountBic)) {
         $this->data['bankAccountBic'] = $this->_bankAccountBic;
     }
     if (!empty($this->_description)) {
         $this->data['description'] = $this->_description;
     }
     if (!empty($this->_promotorId)) {
         $this->data['promotorId'] = $this->_promotorId;
     }
     if (!empty($this->_info)) {
         $this->data['info'] = $this->_info;
     }
     if (!empty($this->_tool)) {
         $this->data['tool'] = $this->_tool;
     }
     if (!empty($this->_object)) {
         $this->data['object'] = $this->_object;
     }
     if (!empty($this->_extra1)) {
         $this->data['extra1'] = $this->_extra1;
     }
     if (!empty($this->_extra2)) {
         $this->data['extra2'] = $this->_extra2;
     }
     if (!empty($this->_extra3)) {
         $this->data['extra3'] = $this->_extra3;
     }
     if (isset($this->_orderId)) {
         $this->data['orderId'] = $this->_orderId;
     }
     if (isset($this->_currency)) {
         $this->data['currency'] = $this->_currency;
     }
     if (!empty($this->_processDate)) {
         $this->data['processDate'] = $this->_processDate->format('d-m-Y');
     }
     return parent::getData();
 }
Пример #9
0
 protected function getData()
 {
     // Checken of alle verplichte velden geset zijn
     Helper::requireServiceId();
     $data['serviceId'] = Config::getServiceId();
     if ($this->_testMode === true) {
         $data['testMode'] = '1';
     } else {
         $data['testMode'] = '0';
     }
     if (empty($this->_amount)) {
         throw new ErrorRequired('Amount is niet geset', 1);
     } else {
         $data['amount'] = $this->_amount;
     }
     if (!empty($this->_paymentOptionId)) {
         $data['paymentOptionId'] = $this->_paymentOptionId;
     }
     if (empty($this->_finishUrl)) {
         throw new ErrorRequired('FinishUrl is niet geset', 1);
     } else {
         $data['finishUrl'] = $this->_finishUrl;
     }
     if (!empty($this->_exchangeUrl)) {
         $data['transaction']['orderExchangeUrl'] = $this->_exchangeUrl;
     }
     if (!empty($this->_description)) {
         $data['transaction']['description'] = $this->_description;
     }
     if (isset($this->_currency)) {
         $data['transaction']['currency'] = $this->_currency;
     }
     if (isset($this->_expireDate)) {
         $data['transaction']['expireDate'] = $this->_expireDate->format('d-m-Y H:i:s');
     }
     if (!empty($this->_paymentOptionSubId)) {
         $data['paymentOptionSubId'] = $this->_paymentOptionSubId;
     }
     if (isset($this->_ipaddress)) {
         $data['ipAddress'] = $this->_ipaddress;
     } else {
         $data['ipAddress'] = Helper::getIp();
     }
     if (!empty($this->_products)) {
         $data['saleData']['orderData'] = $this->_products;
     }
     if (!empty($this->_deliveryDate)) {
         $data['saleData']['deliveryDate'] = $this->_deliveryDate->format('d-m-Y');
     }
     if (!empty($this->_invoiceDate)) {
         $data['saleData']['invoiceDate'] = $this->_invoiceDate->format('d-m-Y');
     }
     if (!empty($this->_enduser)) {
         $data['enduser'] = $this->_enduser;
     }
     if (!empty($this->_extra1)) {
         $data['statsData']['extra1'] = $this->_extra1;
     }
     if (!empty($this->_extra2)) {
         $data['statsData']['extra2'] = $this->_extra2;
     }
     if (!empty($this->_extra3)) {
         $data['statsData']['extra3'] = $this->_extra3;
     }
     if (!empty($this->_promotorId)) {
         $data['statsData']['promotorId'] = $this->_promotorId;
     }
     if (!empty($this->_info)) {
         $data['statsData']['info'] = $this->_info;
     }
     if (!empty($this->_tool)) {
         $data['statsData']['tool'] = $this->_tool;
     }
     if (!empty($this->_object)) {
         $data['statsData']['object'] = $this->_object;
     }
     if (!empty($this->_domainId)) {
         $data['statsData']['domain_id'] = $this->_domainId;
     }
     if (!empty($this->_transferData)) {
         $data['statsData']['transferData'] = $this->_transferData;
     }
     if (!empty($this->_transferType)) {
         $data['transferType'] = $this->_transferType;
     }
     if (!empty($this->_transferValue)) {
         $data['transferValue'] = $this->_transferValue;
     }
     $this->data = array_merge($data, $this->data);
     return parent::getData();
 }