Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Created by stixlink.
- * E-mail: stixlink@gmail.com
- * Skype: stixlink
- * Date: 24.10.14
- * Time: 13:29
- */
- Yii::import('application.extensions.xcoin.SCurl');
- /**
- * Class XCoin
- *
- * @property SCurl $_curl
- */
- class XCoinProcessor {
- protected $apikey = '1ca8bd81a7e2dca83d5566fcc9f31a3c';
- protected $urlapi = 'https://xpay.pro/api';
- private $_curl;
- private $_data = array();
- public function __construct() {
- $this->_curl = new SCurl($this->urlapi);
- $this->_data = array('API_KEY' => $this->apikey);
- }
- /**
- * @param $data
- */
- public function setData(Array $data) {
- $this->_data = CMap::mergeArray($this->_data, $data);
- }
- public function unsetData() {
- $this->_data = array('API_KEY' => $this->apikey);
- }
- /**
- * @return string
- */
- public function getData() {
- return CJSON::encode($this->_data);
- }
- /**
- * @param $type
- *
- * @return mixed
- * @throws CException
- */
- public function execute($type, Array $data = array()) {
- if (!empty($data)) {
- $this->setData($data);
- }
- $this->setData(array('type' => $type));
- $sendData = $this->getData();
- $response = $this->_curl->execute($sendData);
- if ($response && !($response instanceof Exception)) {
- return CJSON::decode($response);
- } elseif ($response instanceof Exception) {
- throw new CException($response->getMessage());
- } else {
- return $response;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement