Version Notes
This extension adds CashCloud payment methods
Download this release
Release Info
Developer | cashcloud |
Extension | cashcloud_payments |
Version | 0.0.1 |
Comparing to | |
See all releases |
Version 0.0.1
- README.txt +11 -0
- app/code/local/Mage/CashCloud/Adminhtml/Model/Checks.php +49 -0
- app/code/local/Mage/CashCloud/Adminhtml/Model/Config.php +50 -0
- app/code/local/Mage/CashCloud/Adminhtml/Model/Expiration.php +34 -0
- app/code/local/Mage/CashCloud/Adminhtml/Model/Reason.php +24 -0
- app/code/local/Mage/CashCloud/Block/Form.php +71 -0
- app/code/local/Mage/CashCloud/Block/Info.php +39 -0
- app/code/local/Mage/CashCloud/Block/Process.php +18 -0
- app/code/local/Mage/CashCloud/Helper/Data.php +196 -0
- app/code/local/Mage/CashCloud/Model/Mysql4/Setup.php +9 -0
- app/code/local/Mage/CashCloud/Model/PaymentMethod.php +253 -0
- app/code/local/Mage/CashCloud/controllers/PayController.php +114 -0
- app/code/local/Mage/CashCloud/etc/config.xml +82 -0
- app/code/local/Mage/CashCloud/etc/system.xml +127 -0
- app/code/local/Mage/CashCloud/sql/cashcloud_setup/mysql4-install-0.0.1.php +20 -0
- app/design/adminhtml/default/default/template/cashcloud/checks.phtml +13 -0
- app/design/frontend/base/default/template/cashcloud/form.phtml +42 -0
- app/design/frontend/base/default/template/cashcloud/info.phtml +28 -0
- app/design/frontend/base/default/template/cashcloud/process.phtml +35 -0
- app/etc/modules/Mage_CashCloud.xml +12 -0
- app/locale/en_GB/Mage_CashCloud.csv +12 -0
- app/locale/en_US/Mage_CashCloud.csv +12 -0
- lib/CashCloudApi/README.md +1 -0
- lib/CashCloudApi/composer.json +25 -0
- lib/CashCloudApi/phpunit.xml +20 -0
- lib/CashCloudApi/samples/GetRate.php +14 -0
- lib/CashCloudApi/samples/GetReasons.php +13 -0
- lib/CashCloudApi/samples/GetSettings.php +11 -0
- lib/CashCloudApi/samples/RequestMoney.php +16 -0
- lib/CashCloudApi/samples/SaveSettings.php +15 -0
- lib/CashCloudApi/samples/credentials.php +10 -0
- lib/CashCloudApi/src/CashCloud/Api/Exception/AuthException.php +10 -0
- lib/CashCloudApi/src/CashCloud/Api/Exception/CashCloudException.php +10 -0
- lib/CashCloudApi/src/CashCloud/Api/Exception/ValidateException.php +74 -0
- lib/CashCloudApi/src/CashCloud/Api/Method/GetRates.php +63 -0
- lib/CashCloudApi/src/CashCloud/Api/Method/GetReasons.php +54 -0
- lib/CashCloudApi/src/CashCloud/Api/Method/GetSettings.php +59 -0
- lib/CashCloudApi/src/CashCloud/Api/Method/GetTransactions.php +65 -0
- lib/CashCloudApi/src/CashCloud/Api/Method/Method.php +96 -0
- lib/CashCloudApi/src/CashCloud/Api/Method/Refund.php +113 -0
- lib/CashCloudApi/src/CashCloud/Api/Method/RequestMoney.php +218 -0
- lib/CashCloudApi/src/CashCloud/Api/Method/SaveSettings.php +91 -0
- lib/CashCloudApi/src/CashCloud/Api/Rest/Auth.php +89 -0
- lib/CashCloudApi/src/CashCloud/Api/Rest/Client.php +122 -0
- lib/CashCloudApi/src/CashCloud/Api/Rest/CurlRequest.php +233 -0
- lib/CashCloudApi/src/CashCloud/Api/Rest/Request.php +79 -0
- lib/CashCloudApi/tests/CashCloud/Test/Api/Exception/ValidateExceptionTest.php +59 -0
- lib/CashCloudApi/tests/CashCloud/Test/Api/Method/GetRatesTest.php +17 -0
- lib/CashCloudApi/tests/CashCloud/Test/Api/Method/GetReasonsTest.php +57 -0
- lib/CashCloudApi/tests/CashCloud/Test/Api/Method/GetSettingsTest.php +17 -0
- lib/CashCloudApi/tests/CashCloud/Test/Api/Method/RequestMoneyTest.php +186 -0
- lib/CashCloudApi/tests/CashCloud/Test/Api/Method/SaveSettingsTest.php +17 -0
- lib/CashCloudApi/tests/CashCloud/Test/Api/Rest/AuthTest.php +41 -0
- lib/CashCloudApi/tests/CashCloud/Test/Api/Rest/ClientTest.php +61 -0
- lib/CashCloudApi/tests/CashCloud/Test/Api/Rest/CurlRequestTest.php +50 -0
- lib/CashCloudApi/tests/CashCloud/Test/TestCase.php +38 -0
- lib/CashCloudApi/tests/bootstrap.php +4 -0
- lib/CashCloudApi/vendor/autoload.php +7 -0
- lib/CashCloudApi/vendor/composer/ClassLoader.php +364 -0
- lib/CashCloudApi/vendor/composer/autoload_classmap.php +9 -0
- lib/CashCloudApi/vendor/composer/autoload_namespaces.php +10 -0
- lib/CashCloudApi/vendor/composer/autoload_psr4.php +9 -0
- lib/CashCloudApi/vendor/composer/autoload_real.php +53 -0
- package.xml +276 -0
- skin/frontend/base/default/css/cashcloud.css +5 -0
- skin/frontend/base/default/images/cashcloud/loader.gif +0 -0
- skin/frontend/base/default/images/cashcloud/logo.png +0 -0
- skin/frontend/base/default/js/cashcloud.js +0 -0
README.txt
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
==================================================
|
2 |
+
Installation
|
3 |
+
==================================================
|
4 |
+
|
5 |
+
1. Login to magento backend as administrator
|
6 |
+
2. Navigate to "System -> Magento Connect -> Magento Connect Manager"
|
7 |
+
3. Enter your username and password if needed
|
8 |
+
5. Click "Choose file" in "Direct package file upload"
|
9 |
+
6. Select ZIP and click upload
|
10 |
+
7. Plugin is now installed
|
11 |
+
8. Plugin configuration can be found in "System -> Configuration -> Payment methods"
|
app/code/local/Mage/CashCloud/Adminhtml/Model/Checks.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* File Checks.php
|
4 |
+
*
|
5 |
+
* @version GIT $Id$
|
6 |
+
*/
|
7 |
+
/**
|
8 |
+
* Class Mage_CashCloud_Adminhtml_Model_Checks
|
9 |
+
*/
|
10 |
+
class Mage_CashCloud_Adminhtml_Model_Checks extends Mage_Adminhtml_Block_System_Config_Form_Field
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Template path
|
14 |
+
*
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
protected $_template = 'cashcloud/checks.phtml';
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Render fieldset html
|
21 |
+
*
|
22 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
23 |
+
* @return string
|
24 |
+
*/
|
25 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
26 |
+
{
|
27 |
+
$columns = ($this->getRequest()->getParam('website') || $this->getRequest()->getParam('store')) ? 5 : 4;
|
28 |
+
return $this->_decorateRowHtml($element, "<td colspan='$columns'>" . $this->toHtml() . '</td>');
|
29 |
+
}
|
30 |
+
|
31 |
+
protected function _toHtml()
|
32 |
+
{
|
33 |
+
$this->setData(array(
|
34 |
+
'username'=>Mage::getStoreConfig('payment/cashcloud/api_username'),
|
35 |
+
'password'=>Mage::getStoreConfig('payment/cashcloud/api_password'),
|
36 |
+
'device_id'=>Mage::getStoreConfig('payment/cashcloud/device_id'),
|
37 |
+
'reason'=>Mage::getStoreConfig('payment/cashcloud/reason'),
|
38 |
+
));
|
39 |
+
return parent::_toHtml();
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* @return string
|
44 |
+
*/
|
45 |
+
public function getCallbackUrl()
|
46 |
+
{
|
47 |
+
return Mage::getUrl("cashcloud/pay/callback");
|
48 |
+
}
|
49 |
+
}
|
app/code/local/Mage/CashCloud/Adminhtml/Model/Config.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* File Config.php
|
4 |
+
*
|
5 |
+
* @version GIT $Id$
|
6 |
+
*/
|
7 |
+
/**
|
8 |
+
* Class Config
|
9 |
+
*/
|
10 |
+
class Mage_CashCloud_Adminhtml_Model_Config extends Mage_Core_Model_Config_Data
|
11 |
+
{
|
12 |
+
public function __construct()
|
13 |
+
{
|
14 |
+
$this->getHelper()->init();
|
15 |
+
parent::__construct();
|
16 |
+
}
|
17 |
+
|
18 |
+
|
19 |
+
protected function _afterSave()
|
20 |
+
{
|
21 |
+
if(!$this->getFieldsetDataValue("auto_set_settings")) {
|
22 |
+
return parent::_afterSave();
|
23 |
+
}
|
24 |
+
|
25 |
+
try {
|
26 |
+
$this->getHelper()->setCredentials(
|
27 |
+
$this->getFieldsetDataValue("api_username"),
|
28 |
+
$this->getFieldsetDataValue("api_password"),
|
29 |
+
$this->getFieldsetDataValue("device_id"),
|
30 |
+
$this->getFieldsetDataValue("enable_sandbox")
|
31 |
+
);
|
32 |
+
$this->getHelper()->setCallback(null, $this->getFieldsetDataValue("request_expiration"));
|
33 |
+
} catch (\CashCloud\Api\Exception\AuthException $e) {
|
34 |
+
Mage::throwException($this->getHelper()->__("Invalid cashcloud username or password"));
|
35 |
+
} catch (\CashCloud\Api\Exception\ValidateException $e) {
|
36 |
+
Mage::throwException($this->getHelper()->__($e->getFirstError()));
|
37 |
+
} catch (\CashCloud\Api\Exception\CashCloudException $e) {
|
38 |
+
Mage::throwException($this->getHelper()->__($e->getMessage()));
|
39 |
+
}
|
40 |
+
return parent::_afterSave();
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @return Mage_CashCloud_Helper_Data
|
45 |
+
*/
|
46 |
+
protected function getHelper()
|
47 |
+
{
|
48 |
+
return Mage::helper('cashcloud');
|
49 |
+
}
|
50 |
+
}
|
app/code/local/Mage/CashCloud/Adminhtml/Model/Expiration.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* File Reason.php
|
4 |
+
*
|
5 |
+
* @version GIT $Id$
|
6 |
+
*/
|
7 |
+
/**
|
8 |
+
* Class Reason
|
9 |
+
*/
|
10 |
+
class Mage_CashCloud_Adminhtml_Model_Expiration
|
11 |
+
{
|
12 |
+
public function toOptionArray()
|
13 |
+
{
|
14 |
+
return array(
|
15 |
+
array('value' => 60*2, 'label'=>Mage::helper('cashcloud')->__('2 minutes')),
|
16 |
+
array('value' => 60*3, 'label'=>Mage::helper('adminhtml')->__('30 minutes')),
|
17 |
+
array('value' => 60*60, 'label'=>Mage::helper('adminhtml')->__('1 hour')),
|
18 |
+
array('value' => 60*60*2, 'label'=>Mage::helper('adminhtml')->__('2 hour')),
|
19 |
+
array('value' => 60*60*6, 'label'=>Mage::helper('adminhtml')->__('6 hour')),
|
20 |
+
array('value' => 60*60*12, 'label'=>Mage::helper('adminhtml')->__('12 hours')),
|
21 |
+
array('value' => 60*60*24, 'label'=>Mage::helper('adminhtml')->__('24 hours')),
|
22 |
+
array('value' => 60*60*24*2, 'label'=>Mage::helper('adminhtml')->__('2 days')),
|
23 |
+
array('value' => 60*60*24*8, 'label'=>Mage::helper('adminhtml')->__('8 days')),
|
24 |
+
);
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @return Mage_CashCloud_Helper_Data
|
29 |
+
*/
|
30 |
+
public function getHelper()
|
31 |
+
{
|
32 |
+
return Mage::helper("cashcloud");
|
33 |
+
}
|
34 |
+
}
|
app/code/local/Mage/CashCloud/Adminhtml/Model/Reason.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* File Reason.php
|
4 |
+
*
|
5 |
+
* @version GIT $Id$
|
6 |
+
*/
|
7 |
+
/**
|
8 |
+
* Class Reason
|
9 |
+
*/
|
10 |
+
class Mage_CashCloud_Adminhtml_Model_Reason
|
11 |
+
{
|
12 |
+
public function toOptionArray()
|
13 |
+
{
|
14 |
+
return $this->getHelper()->getReasons();
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @return Mage_CashCloud_Helper_Data
|
19 |
+
*/
|
20 |
+
public function getHelper()
|
21 |
+
{
|
22 |
+
return Mage::helper("cashcloud");
|
23 |
+
}
|
24 |
+
}
|
app/code/local/Mage/CashCloud/Block/Form.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Mage_CashCloud_Block_Form
|
4 |
+
*
|
5 |
+
* @method Mage_CashCloud_Model_PaymentMethod getMethod()
|
6 |
+
*/
|
7 |
+
class Mage_CashCloud_Block_Form extends Mage_Payment_Block_Form
|
8 |
+
{
|
9 |
+
/**
|
10 |
+
* @return int
|
11 |
+
*/
|
12 |
+
public function getBasePrice()
|
13 |
+
{
|
14 |
+
return $this->getMethod()->getCart()->getQuote()->getGrandTotal();
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @return Mage_Core_Model_Abstract
|
19 |
+
*/
|
20 |
+
public function getEur()
|
21 |
+
{
|
22 |
+
return Mage::getModel('directory/currency')->load("EUR");
|
23 |
+
}
|
24 |
+
|
25 |
+
public function isReasonSelected()
|
26 |
+
{
|
27 |
+
return (bool) $this->getMethod()->getConfigData('reason');
|
28 |
+
}
|
29 |
+
|
30 |
+
protected function _construct()
|
31 |
+
{
|
32 |
+
$this->setTemplate('cashcloud/form.phtml');
|
33 |
+
parent::_construct();
|
34 |
+
}
|
35 |
+
|
36 |
+
public function isCCREnabled()
|
37 |
+
{
|
38 |
+
return (bool) $this->getMethod()->getConfigData('enable_ccr') && $this->getPriceInCCR() !== false;
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getPriceInEur()
|
42 |
+
{
|
43 |
+
$eur = $this->getMethod()->getEur();
|
44 |
+
$priceInEur = Mage::app()->getStore()->getCurrentCurrency()->convert($this->getBasePrice(), $eur);
|
45 |
+
return $eur->format($priceInEur);
|
46 |
+
}
|
47 |
+
|
48 |
+
public function getPriceInCCR()
|
49 |
+
{
|
50 |
+
return $this->getCashCloudHelper()->getAmountInCCR($this->getBasePrice());
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
public function getReasons()
|
55 |
+
{
|
56 |
+
return $this->getMethod()->getHelper()->getReasons();
|
57 |
+
}
|
58 |
+
|
59 |
+
public function getConversationRate()
|
60 |
+
{
|
61 |
+
return Mage::app()->getStore()->getCurrentCurrency()->getRate($this->getEur());
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* @return Mage_CashCloud_Helper_Data
|
66 |
+
*/
|
67 |
+
private function getCashCloudHelper()
|
68 |
+
{
|
69 |
+
return Mage::helper('cashcloud');
|
70 |
+
}
|
71 |
+
}
|
app/code/local/Mage/CashCloud/Block/Info.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Mage_CashCloud_Block_Form
|
4 |
+
*/
|
5 |
+
class Mage_CashCloud_Block_Info extends Mage_Payment_Block_Info
|
6 |
+
{
|
7 |
+
protected function _construct()
|
8 |
+
{
|
9 |
+
parent::_construct();
|
10 |
+
$this->setTemplate('cashcloud/info.phtml');
|
11 |
+
}
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @return Mage_CashCloud_Model_PaymentMethod
|
15 |
+
*/
|
16 |
+
public function getMethod()
|
17 |
+
{
|
18 |
+
return $this->getInfo()->getMethodInstance();
|
19 |
+
}
|
20 |
+
|
21 |
+
public function getFormattedPrice()
|
22 |
+
{
|
23 |
+
$grandTotalInEur = $this->getMethod()->getGrandTotalInEur(true);
|
24 |
+
if($this->getInfo()->getAdditionalInformation("cashcloud_currency") == "CCR") {
|
25 |
+
$amount = $this->getMethod()->getHelper()->getAmountInCCR($grandTotalInEur);
|
26 |
+
return number_format($amount, 2). " CCR";
|
27 |
+
} else {
|
28 |
+
return $grandTotalInEur;
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @return string
|
34 |
+
*/
|
35 |
+
public function getReason()
|
36 |
+
{
|
37 |
+
return $this->getInfo()->getAdditionalInformation('cashcloud_reason_id');
|
38 |
+
}
|
39 |
+
}
|
app/code/local/Mage/CashCloud/Block/Process.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* File Process.php
|
4 |
+
*
|
5 |
+
* @version GIT $Id$
|
6 |
+
*/
|
7 |
+
/**
|
8 |
+
* Class Process
|
9 |
+
*/
|
10 |
+
class Mage_CashCloud_Block_Process extends Mage_Core_Block_Template
|
11 |
+
{
|
12 |
+
public function __construct(array $args = array())
|
13 |
+
{
|
14 |
+
$this->setTemplate('cashcloud/process.phtml');
|
15 |
+
parent::__construct($args);
|
16 |
+
}
|
17 |
+
|
18 |
+
}
|
app/code/local/Mage/CashCloud/Helper/Data.php
ADDED
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
use CashCloud\Api\Exception\CashCloudException;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Class Api
|
6 |
+
*/
|
7 |
+
class Mage_CashCloud_Helper_Data extends Mage_Core_Helper_Data
|
8 |
+
{
|
9 |
+
protected $username;
|
10 |
+
protected $password;
|
11 |
+
protected $deviceId;
|
12 |
+
protected $sandboxMode = false;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @var \CashCloud\Api\Rest\Client
|
16 |
+
*/
|
17 |
+
private $client = null;
|
18 |
+
|
19 |
+
function __construct()
|
20 |
+
{
|
21 |
+
$this->init();
|
22 |
+
}
|
23 |
+
|
24 |
+
public function init()
|
25 |
+
{
|
26 |
+
// setup autoload
|
27 |
+
require_once Mage::getBaseDir("lib") . DS . "CashCloudApi" . DS . "vendor" . DS . "autoload.php";
|
28 |
+
|
29 |
+
/** @var Mage_CashCloud_Model_PaymentMethod $payment */
|
30 |
+
$payment = Mage::getSingleton("Mage_CashCloud_Model_PaymentMethod");
|
31 |
+
$this->username = $payment->getConfigData('api_username');
|
32 |
+
$this->password = $payment->getConfigData('api_password');
|
33 |
+
$this->deviceId = $payment->getConfigData('api_device_id');
|
34 |
+
$this->sandboxMode = $payment->getConfigData('enable_sandbox');
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @param string $username
|
39 |
+
* @param string $password
|
40 |
+
* @param string $deviceId
|
41 |
+
* @param bool $sandboxMode
|
42 |
+
*/
|
43 |
+
public function setCredentials($username, $password, $deviceId, $sandboxMode = false)
|
44 |
+
{
|
45 |
+
$this->username = $username;
|
46 |
+
$this->password = $password;
|
47 |
+
$this->deviceId = $deviceId;
|
48 |
+
$this->sandboxMode = $sandboxMode;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @return \CashCloud\Api\Rest\Client
|
53 |
+
*/
|
54 |
+
public function getClient()
|
55 |
+
{
|
56 |
+
if (is_null($this->client)) {
|
57 |
+
// create client
|
58 |
+
$this->client = new \CashCloud\Api\Rest\Client(
|
59 |
+
new \CashCloud\Api\Rest\Auth($this->username, $this->password, $this->deviceId), null, $this->sandboxMode
|
60 |
+
);
|
61 |
+
}
|
62 |
+
return $this->client;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* @return array
|
67 |
+
*/
|
68 |
+
public function getReasons()
|
69 |
+
{
|
70 |
+
$reasons = $this->getCached("cashcloud/reason_ids");
|
71 |
+
if ($reasons != false) {
|
72 |
+
return $reasons;
|
73 |
+
}
|
74 |
+
|
75 |
+
try {
|
76 |
+
$req = new \CashCloud\Api\Method\GetReasons();
|
77 |
+
$reasons = $req->perform($this->getClient());
|
78 |
+
} catch (CashCloudException $e) {
|
79 |
+
$reasons = array();
|
80 |
+
}
|
81 |
+
|
82 |
+
return $this->cache($reasons, "cashcloud/reason_ids");
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
87 |
+
* @return string order ID
|
88 |
+
*/
|
89 |
+
public function requestMoney($payment)
|
90 |
+
{
|
91 |
+
$order = $payment->getOrder();
|
92 |
+
$method = Mage::getSingleton("Mage_CashCloud_Model_PaymentMethod");
|
93 |
+
|
94 |
+
$request = new \CashCloud\Api\Method\RequestMoney();
|
95 |
+
$request->setEmail($order->getPayment()->getAdditionalInformation('cashcloud_username'));
|
96 |
+
$request->setAmount($order->getGrandTotal() * 100);
|
97 |
+
if($order->getPayment()->getAdditionalInformation('cashcloud_currency') == "CCR") {
|
98 |
+
$request->setCurrency(\CashCloud\Api\Rest\Client::CURRENCY_CCR);
|
99 |
+
} else {
|
100 |
+
$request->setCurrency(\CashCloud\Api\Rest\Client::CURRENCY_EUR);
|
101 |
+
}
|
102 |
+
$request->setExternalData($order->getId());
|
103 |
+
if ($method->getConfigData('reason') == "") {
|
104 |
+
Mage::throwException($this->__("Payments category not selected"));
|
105 |
+
}
|
106 |
+
$request->setReason($method->getConfigData('reason'));
|
107 |
+
|
108 |
+
$response = $request->perform($this->getClient());
|
109 |
+
return $response->hash;
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* @param float $amount
|
114 |
+
* @return false|float
|
115 |
+
*/
|
116 |
+
public function getAmountInCCR($amount)
|
117 |
+
{
|
118 |
+
try {
|
119 |
+
$request = new \CashCloud\Api\Method\GetRates();
|
120 |
+
$request->setAmount($amount * 100); //cents
|
121 |
+
$rate = $request->perform($this->getClient());
|
122 |
+
|
123 |
+
$currencyId = \CashCloud\Api\Rest\Client::CURRENCY_CCR;
|
124 |
+
$actionId = \CashCloud\Api\Rest\Client::CURRENCY_RECEIVE;
|
125 |
+
if(isset($rate->{$currencyId}->{$actionId})) {
|
126 |
+
// cents
|
127 |
+
return (float) ($rate->{$currencyId}->{$actionId} / 100);
|
128 |
+
}
|
129 |
+
} catch (CashCloudException $e) {
|
130 |
+
Mage::logException($e);
|
131 |
+
}
|
132 |
+
return false;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* @param $url
|
137 |
+
* @param $request_expiration
|
138 |
+
* @return bool|float
|
139 |
+
*/
|
140 |
+
public function setCallback($url = null, $request_expiration = null)
|
141 |
+
{
|
142 |
+
$url = is_null($url) ? $this->getCallbackUrl() : $url;
|
143 |
+
$request = new \CashCloud\Api\Method\SaveSettings();
|
144 |
+
$request->setCallbackUrl($url);
|
145 |
+
$request->setRequestExpiration($request_expiration);
|
146 |
+
$result = $request->perform($this->getClient()) / 100;
|
147 |
+
return $result;
|
148 |
+
}
|
149 |
+
|
150 |
+
public function refund($transactionId, $amount, $remark = "no remark")
|
151 |
+
{
|
152 |
+
try {
|
153 |
+
$refund = new \CashCloud\Api\Method\Refund();
|
154 |
+
$refund->setHash($transactionId);
|
155 |
+
$refund->setAmount($amount * 100);
|
156 |
+
$refund->setRemark($remark);
|
157 |
+
$refund->perform($this->getClient());
|
158 |
+
} catch (\CashCloud\Api\Exception\CashCloudException $e) {
|
159 |
+
Mage::throwException("Could not refund: " . $e->getMessage());
|
160 |
+
}
|
161 |
+
|
162 |
+
return $this;
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* @param string $key
|
167 |
+
* @return false|mixed
|
168 |
+
*/
|
169 |
+
private function getCached($key)
|
170 |
+
{
|
171 |
+
$data = Mage::app()->getCache()->load($key);
|
172 |
+
if ($data) {
|
173 |
+
return unserialize(base64_decode($data));
|
174 |
+
}
|
175 |
+
return false;
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* @param mixed $data
|
180 |
+
* @param string $key
|
181 |
+
* @return mixed
|
182 |
+
*/
|
183 |
+
private function cache($data, $key)
|
184 |
+
{
|
185 |
+
Mage::app()->getCache()->save(base64_encode(serialize($data)), $key, array('cashcloud'), 60 * 60 * 3);
|
186 |
+
return $data;
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* @return string
|
191 |
+
*/
|
192 |
+
public function getCallbackUrl()
|
193 |
+
{
|
194 |
+
return Mage::getUrl("cashcloud/pay/callback");
|
195 |
+
}
|
196 |
+
}
|
app/code/local/Mage/CashCloud/Model/Mysql4/Setup.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Mage_CashCloud_Model_Mysql4_Setup
|
5 |
+
*/
|
6 |
+
class Mage_CashCloud_Model_Mysql4_Setup extends Mage_Core_Model_Resource_Setup
|
7 |
+
{
|
8 |
+
|
9 |
+
}
|
app/code/local/Mage/CashCloud/Model/PaymentMethod.php
ADDED
@@ -0,0 +1,253 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Class PaymentMethod
|
6 |
+
*/
|
7 |
+
class Mage_CashCloud_Model_PaymentMethod extends Mage_Payment_Model_Method_Abstract
|
8 |
+
{
|
9 |
+
protected $_code = 'cashcloud';
|
10 |
+
protected $_formBlockType = 'cashCloud/form';
|
11 |
+
protected $_infoBlockType = 'cashCloud/info';
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var bool
|
15 |
+
*/
|
16 |
+
protected $_canRefund = true;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Availability options
|
20 |
+
*/
|
21 |
+
protected $_canCapture = true;
|
22 |
+
protected $_isGateway = false;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @param Varien_Object $payment
|
26 |
+
* @param float $amount
|
27 |
+
* @return $this
|
28 |
+
*/
|
29 |
+
public function capture(Varien_Object $payment, $amount)
|
30 |
+
{
|
31 |
+
$payment->setStatus(self::STATUS_APPROVED)
|
32 |
+
->setTransactionId($payment->getCashcloudId())->setIsTransactionClosed(0);
|
33 |
+
|
34 |
+
return $this;
|
35 |
+
}
|
36 |
+
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @param Varien_Object $payment
|
40 |
+
* @param float $amount
|
41 |
+
* @return $this
|
42 |
+
*/
|
43 |
+
public function refund(Varien_Object $payment, $amount)
|
44 |
+
{
|
45 |
+
$this->getHelper()->refund($payment->getParentTransactionId(), $amount);
|
46 |
+
return $this;
|
47 |
+
}
|
48 |
+
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @param null $quote
|
52 |
+
* @return bool
|
53 |
+
*/
|
54 |
+
public function isAvailable($quote = null)
|
55 |
+
{
|
56 |
+
if (Mage::app()->getStore()->getCurrentCurrencyCode() == "EUR") {
|
57 |
+
return parent::isAvailable($quote);
|
58 |
+
}
|
59 |
+
return false;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @return int
|
64 |
+
*/
|
65 |
+
public function getGrandTotal()
|
66 |
+
{
|
67 |
+
return $this->getCart()->getQuote()->getGrandTotal();
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* @return Mage_Directory_Model_Currency
|
72 |
+
*/
|
73 |
+
public function getEur()
|
74 |
+
{
|
75 |
+
return Mage::getModel('directory/currency')->load("EUR");
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* @param bool $raw
|
80 |
+
* @return int
|
81 |
+
*/
|
82 |
+
public function getGrandTotalInEur($raw = false)
|
83 |
+
{
|
84 |
+
$priceInEur = Mage::app()->getStore()->getCurrentCurrency()->convert($this->getGrandTotal(), $this->getEur());
|
85 |
+
return $raw ? $priceInEur : $this->getEur()->format($priceInEur);
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* @return $this
|
90 |
+
*/
|
91 |
+
public function validate()
|
92 |
+
{
|
93 |
+
$info = $this->getInfoInstance();
|
94 |
+
|
95 |
+
$username = $info->getAdditionalInformation("cashcloud_username");
|
96 |
+
if (!preg_match('/([\w-+\.]+)@((?:[\w]+\.)+)([a-zA-Z]{2,4})/', $username)) {
|
97 |
+
Mage::throwException(
|
98 |
+
$this->_getHelper()->__('Invalid CashCloud username')
|
99 |
+
);
|
100 |
+
}
|
101 |
+
|
102 |
+
$currency = $info->getAdditionalInformation("cashcloud_currency");
|
103 |
+
if ($this->getConfigData('enable_ccr') && $currency != "EUR" && $currency != "CCR") {
|
104 |
+
Mage::throwException(
|
105 |
+
$this->_getHelper()->__('Please select currency')
|
106 |
+
);
|
107 |
+
}
|
108 |
+
|
109 |
+
if (!$this->getConfigData('reason')) {
|
110 |
+
$reason = $info->getAdditionalInformation("cashcloud_reason_id");
|
111 |
+
if (empty($reason) || !array_key_exists($reason, $this->getHelper()->getReasons())) {
|
112 |
+
Mage::throwException(
|
113 |
+
$this->_getHelper()->__('Please select purchase reason')
|
114 |
+
);
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
return parent::validate();
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* @param mixed $data
|
123 |
+
* @return $this|Mage_Payment_Model_Info
|
124 |
+
*/
|
125 |
+
public function assignData($data)
|
126 |
+
{
|
127 |
+
parent::assignData($data);
|
128 |
+
|
129 |
+
$currency = isset($_POST['payment']['cashcloud_currency']) ? $_POST['payment']['cashcloud_currency'] : "EUR";
|
130 |
+
$username = isset($_POST['payment']['cashcloud_username']) ? $_POST['payment']['cashcloud_username'] : false;
|
131 |
+
$reason = isset($_POST['payment']['cashcloud_reason_id']) ? $_POST['payment']['cashcloud_reason_id'] : false;
|
132 |
+
|
133 |
+
$this->getInfoInstance()->setAdditionalInformation(array(
|
134 |
+
'cashcloud_username' => $username,
|
135 |
+
'cashcloud_currency' => $currency,
|
136 |
+
'cashcloud_reason_id' => $reason,
|
137 |
+
));
|
138 |
+
return $this;
|
139 |
+
}
|
140 |
+
|
141 |
+
|
142 |
+
/**
|
143 |
+
* @return Mage_Checkout_Model_Cart
|
144 |
+
*/
|
145 |
+
public function getCart()
|
146 |
+
{
|
147 |
+
return Mage::helper('checkout/cart');
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* @return Mage_CashCloud_Helper_Data
|
152 |
+
*/
|
153 |
+
public function getHelper()
|
154 |
+
{
|
155 |
+
return Mage::helper("cashcloud");
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Payment action getter compatible with payment model
|
160 |
+
*
|
161 |
+
* @see Mage_Sales_Model_Payment::place()
|
162 |
+
* @return string
|
163 |
+
*/
|
164 |
+
public function getConfigPaymentAction()
|
165 |
+
{
|
166 |
+
return "order";
|
167 |
+
}
|
168 |
+
|
169 |
+
|
170 |
+
public function order(Varien_Object $payment, $amount)
|
171 |
+
{
|
172 |
+
$this->getHelper()->init();
|
173 |
+
try {
|
174 |
+
$orderId = $this->getHelper()->requestMoney($payment);
|
175 |
+
$payment->setCashcloudId($orderId);
|
176 |
+
$payment->save();
|
177 |
+
} catch (\CashCloud\Api\Exception\ValidateException $e) {
|
178 |
+
Mage::throwException(
|
179 |
+
$this->_getHelper()->__("Validation failed").": ".$this->_getHelper()->__($e->getFirstError())
|
180 |
+
);
|
181 |
+
} catch (\CashCloud\Api\Exception\AuthException $e) {
|
182 |
+
Mage::throwException(
|
183 |
+
$this->_getHelper()->__("Error while authorizing payment. Please check CashCloud account details in configuration!")
|
184 |
+
);
|
185 |
+
} catch (\CashCloud\Api\Exception\CashCloudException $e) {
|
186 |
+
Mage::logException($e);
|
187 |
+
Mage::throwException(
|
188 |
+
$this->_getHelper()->__("Error while executing payment in CashCloud!")
|
189 |
+
);
|
190 |
+
}
|
191 |
+
|
192 |
+
return $this;
|
193 |
+
}
|
194 |
+
|
195 |
+
public function getOrderPlaceRedirectUrl()
|
196 |
+
{
|
197 |
+
return Mage::getUrl('cashcloud/pay/process');
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* @param Mage_Sales_Model_Order $order
|
202 |
+
* @param array $callbackData
|
203 |
+
*/
|
204 |
+
public function validateCallback($order, $callbackData)
|
205 |
+
{
|
206 |
+
$this->getHelper()->init();
|
207 |
+
$status = isset($callbackData['status']) ? $callbackData['status'] : null;
|
208 |
+
$unsuccessfulStatuses = array(
|
209 |
+
\CashCloud\Api\Rest\Client::STATUS_EXPIRED,
|
210 |
+
\CashCloud\Api\Rest\Client::STATUS_REFUNDED,
|
211 |
+
\CashCloud\Api\Rest\Client::STATUS_DECLINED,
|
212 |
+
\CashCloud\Api\Rest\Client::STATUS_MONEY_SERVICE_FAILED
|
213 |
+
);
|
214 |
+
|
215 |
+
if($status == \CashCloud\Api\Rest\Client::STATUS_COMPLETED) {
|
216 |
+
$orderState = Mage_Sales_Model_Order::STATE_PROCESSING;
|
217 |
+
$orderStatus = $this->getConfigData('order_status_after_payment');
|
218 |
+
$this->saveStatus($order, $orderState, $orderStatus, $this->getHelper()->__("Payment notification received"));
|
219 |
+
} elseif(in_array($status, $unsuccessfulStatuses)) {
|
220 |
+
$orderState = Mage_Sales_Model_Order::STATE_CANCELED;
|
221 |
+
$orderStatus = Mage_Sales_Model_Order::STATE_CANCELED;
|
222 |
+
$this->saveStatus($order, $orderState, $orderStatus, $this->getHelper()->__("Customer cancelled order"));
|
223 |
+
} else {
|
224 |
+
Mage::throwException("Invalid cashcloud status: $status");
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* @param Mage_Sales_Model_Order $order
|
230 |
+
* @param string $orderState
|
231 |
+
* @param string $orderStatus
|
232 |
+
* @param string $comment
|
233 |
+
*/
|
234 |
+
protected function saveStatus($order, $orderState, $orderStatus, $comment){
|
235 |
+
$order->setState($orderState, $orderStatus, $comment)->save();
|
236 |
+
|
237 |
+
/** @var Mage_Sales_Model_Order_Payment $payment */
|
238 |
+
$payment = $order->getPaymentsCollection()->getFirstItem();
|
239 |
+
|
240 |
+
if($orderStatus == Mage_Sales_Model_Order::STATE_PROCESSING) {
|
241 |
+
$order->addStatusHistoryComment($this->getHelper()->__("Payment received"), $orderStatus);
|
242 |
+
} else {
|
243 |
+
|
244 |
+
}
|
245 |
+
|
246 |
+
|
247 |
+
// var_dump($order->getData(), $payment->getData()); die();
|
248 |
+
/** @var Mage_Sales_Model_Order_Status_History $comment */
|
249 |
+
//
|
250 |
+
//
|
251 |
+
// $comment->save();
|
252 |
+
}
|
253 |
+
}
|
app/code/local/Mage/CashCloud/controllers/PayController.php
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Mage_CashCloud_PayController
|
4 |
+
*/
|
5 |
+
class Mage_CashCloud_PayController extends Mage_Core_Controller_Front_Action
|
6 |
+
{
|
7 |
+
/**
|
8 |
+
* @return Mage_Checkout_Model_Session
|
9 |
+
*/
|
10 |
+
public function getCheckout()
|
11 |
+
{
|
12 |
+
return Mage::getSingleton('checkout/session');
|
13 |
+
}
|
14 |
+
|
15 |
+
public function processAction()
|
16 |
+
{
|
17 |
+
$this->loadLayout();
|
18 |
+
|
19 |
+
$order = $this->getCheckout()->getLastRealOrder();
|
20 |
+
if(!$order) {
|
21 |
+
Mage::throwException("Cannot find order");
|
22 |
+
}
|
23 |
+
|
24 |
+
$success = null;
|
25 |
+
$orderStatus = $this->getMethodInstance()->getConfigData('order_status_after_payment');
|
26 |
+
if($order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING && $order->getStatus() == $orderStatus) {
|
27 |
+
$success = true;
|
28 |
+
} elseif ($order->getState() == Mage_Sales_Model_Order::STATE_CANCELED) {
|
29 |
+
$success = false;
|
30 |
+
}
|
31 |
+
|
32 |
+
if(!$this->getRequest()->isAjax() && !is_null($success)) {
|
33 |
+
$this->_redirect(
|
34 |
+
$success ? 'checkout/onepage/success' : 'checkout/onepage/failure'
|
35 |
+
);
|
36 |
+
}
|
37 |
+
|
38 |
+
if($this->getRequest()->isPost()) {
|
39 |
+
$this->getResponse()->setHeader('Content-type', 'application/x-json');
|
40 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array(
|
41 |
+
'action'=> is_null($success) ? "wait" : "reload",
|
42 |
+
)));
|
43 |
+
} else {
|
44 |
+
$this->getResponse()->setBody($this->getLayout()->createBlock('cashcloud/process')->toHtml());
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
public function callbackAction()
|
49 |
+
{
|
50 |
+
$method = isset($_POST['method']) ? $_POST['method'] : false;
|
51 |
+
$securityToken = isset($_POST['control']) ? $_POST['control'] : false;
|
52 |
+
$time = isset($_POST['time']) ? $_POST['time'] : false;
|
53 |
+
$status = isset($_POST['status']) ? $_POST['status'] : false;
|
54 |
+
|
55 |
+
$payment = Mage::getSingleton("Mage_CashCloud_Model_PaymentMethod");
|
56 |
+
|
57 |
+
$controlString = "$method|$status|$time|".md5(sha1($payment->getConfigData('api_password'), true), true);
|
58 |
+
$realToken = base64_encode( md5( sha1( $controlString, true), true));
|
59 |
+
|
60 |
+
if($securityToken != $realToken) {
|
61 |
+
Mage::throwException("Not found");
|
62 |
+
}
|
63 |
+
|
64 |
+
if($method == "refund") {
|
65 |
+
Mage::throwException("Method not supported");
|
66 |
+
}
|
67 |
+
|
68 |
+
$hash = isset($_POST['hash']) ? $_POST['hash'] : false;
|
69 |
+
$order = $this->loadOrder($hash);
|
70 |
+
|
71 |
+
if($order->getId()) {
|
72 |
+
$callbackData = $this->getRequest()->getPost();
|
73 |
+
$this->getMethodInstance()->validateCallback($order, $callbackData);
|
74 |
+
echo "OK";
|
75 |
+
} else {
|
76 |
+
Mage::throwException($this->getHelper()->__("Order not found!"));
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* @return Mage_CashCloud_Helper_Data
|
82 |
+
*/
|
83 |
+
public function getHelper()
|
84 |
+
{
|
85 |
+
return Mage::helper("cashcloud");
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* @param $hash
|
90 |
+
* @return Mage_Sales_Model_Order
|
91 |
+
*/
|
92 |
+
public function loadOrder($hash)
|
93 |
+
{
|
94 |
+
/** @var Mage_Sales_Model_Order_Payment $orderPayment */
|
95 |
+
$orderPayment = Mage::getSingleton("sales/order_payment")->load($hash, 'cashcloud_id');
|
96 |
+
/** @var Mage_Sales_Model_Order $order */
|
97 |
+
$order = Mage::getSingleton("sales/order")->load($orderPayment->getParentId());
|
98 |
+
if($order) {
|
99 |
+
$orderPayment->setOrder($order);
|
100 |
+
$order->setPayment($orderPayment);
|
101 |
+
} else {
|
102 |
+
Mage::throwException($this->getHelper()->__("Order not found!"));
|
103 |
+
}
|
104 |
+
return $order;
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* @return Mage_CashCloud_Model_PaymentMethod
|
109 |
+
*/
|
110 |
+
public function getMethodInstance()
|
111 |
+
{
|
112 |
+
return Mage::getSingleton("Mage_CashCloud_Model_PaymentMethod");
|
113 |
+
}
|
114 |
+
}
|
app/code/local/Mage/CashCloud/etc/config.xml
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Mage_CashCloud>
|
5 |
+
<version>0.0.1</version>
|
6 |
+
</Mage_CashCloud>
|
7 |
+
</modules>
|
8 |
+
|
9 |
+
<global>
|
10 |
+
<blocks>
|
11 |
+
<cashcloud>
|
12 |
+
<class>Mage_CashCloud_Block</class>
|
13 |
+
</cashcloud>
|
14 |
+
</blocks>
|
15 |
+
<models>
|
16 |
+
<CashCloud>
|
17 |
+
<class>Mage_CashCloud_Model</class>
|
18 |
+
</CashCloud>
|
19 |
+
</models>
|
20 |
+
<resources>
|
21 |
+
<cashcloud_setup>
|
22 |
+
<setup>
|
23 |
+
<module>Mage_CashCloud</module>
|
24 |
+
<class>Mage_CashCloud_Model_Mysql4_Setup</class>
|
25 |
+
</setup>
|
26 |
+
<connection>
|
27 |
+
<use>core_setup</use>
|
28 |
+
</connection>
|
29 |
+
</cashcloud_setup>
|
30 |
+
</resources>
|
31 |
+
<helpers>
|
32 |
+
<cashcloud>
|
33 |
+
<class>Mage_CashCloud_Helper</class>
|
34 |
+
</cashcloud>
|
35 |
+
</helpers>
|
36 |
+
</global>
|
37 |
+
<adminhtml>
|
38 |
+
<translate>
|
39 |
+
<modules>
|
40 |
+
<Mage_Epay>
|
41 |
+
<files>
|
42 |
+
<default>Mage_CashCloud.csv</default>
|
43 |
+
</files>
|
44 |
+
</Mage_Epay>
|
45 |
+
</modules>
|
46 |
+
</translate>
|
47 |
+
</adminhtml>
|
48 |
+
<frontend>
|
49 |
+
<routers>
|
50 |
+
<cashcloud>
|
51 |
+
<use>standard</use>
|
52 |
+
<args>
|
53 |
+
<module>Mage_CashCloud</module>
|
54 |
+
<frontName>cashcloud</frontName>
|
55 |
+
</args>
|
56 |
+
</cashcloud>
|
57 |
+
</routers>
|
58 |
+
<translate>
|
59 |
+
<modules>
|
60 |
+
<Mage_Epay>
|
61 |
+
<files>
|
62 |
+
<default>Mage_CashCloud.csv</default>
|
63 |
+
</files>
|
64 |
+
</Mage_Epay>
|
65 |
+
</modules>
|
66 |
+
</translate>
|
67 |
+
</frontend>
|
68 |
+
<default>
|
69 |
+
<payment>
|
70 |
+
<cashcloud>
|
71 |
+
<active>0</active>
|
72 |
+
<model>CashCloud/paymentMethod</model>
|
73 |
+
<request_expiration>691200</request_expiration>
|
74 |
+
<order_status>pending</order_status>
|
75 |
+
<order_status_after_payment>processing</order_status_after_payment>
|
76 |
+
<auto_set_settings>1</auto_set_settings>
|
77 |
+
<device_id>magento</device_id>
|
78 |
+
<title>CashCloud</title>
|
79 |
+
</cashcloud>
|
80 |
+
</payment>
|
81 |
+
</default>
|
82 |
+
</config>
|
app/code/local/Mage/CashCloud/etc/system.xml
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<payment>
|
5 |
+
<groups>
|
6 |
+
<cashcloud translate="label" module="paygate">
|
7 |
+
<label>CashCloud</label>
|
8 |
+
<sort_order>670</sort_order>
|
9 |
+
<show_in_default>1</show_in_default>
|
10 |
+
<show_in_website>1</show_in_website>
|
11 |
+
<show_in_store>0</show_in_store>
|
12 |
+
<comment>Please enter your CashCloud account details</comment>
|
13 |
+
<fields>
|
14 |
+
<active translate="label">
|
15 |
+
<label>Enabled</label>
|
16 |
+
<frontend_type>select</frontend_type>
|
17 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
18 |
+
<sort_order>1</sort_order>
|
19 |
+
<show_in_default>1</show_in_default>
|
20 |
+
<show_in_website>1</show_in_website>
|
21 |
+
<show_in_store>0</show_in_store>
|
22 |
+
</active>
|
23 |
+
<auto_set_settings translate="label">
|
24 |
+
<label>Save settings</label>
|
25 |
+
<comment><![CDATA[If yes, save callback and expiration to cashcloud account]]></comment>
|
26 |
+
<frontend_type>select</frontend_type>
|
27 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
28 |
+
<sort_order>2</sort_order>
|
29 |
+
<show_in_default>1</show_in_default>
|
30 |
+
<show_in_website>1</show_in_website>
|
31 |
+
<show_in_store>0</show_in_store>
|
32 |
+
</auto_set_settings>
|
33 |
+
<request_expiration translate="label">
|
34 |
+
<label>Payment expires in:</label>
|
35 |
+
<frontend_type>select</frontend_type>
|
36 |
+
<source_model>Mage_CashCloud_Adminhtml_Model_Expiration</source_model>
|
37 |
+
<sort_order>3</sort_order>
|
38 |
+
<validate>validate-number</validate>
|
39 |
+
<show_in_default>1</show_in_default>
|
40 |
+
<show_in_website>1</show_in_website>
|
41 |
+
<show_in_store>0</show_in_store>
|
42 |
+
</request_expiration>
|
43 |
+
<api_username translate="label">
|
44 |
+
<label>Username</label>
|
45 |
+
<frontend_type>text</frontend_type>
|
46 |
+
<sort_order>4</sort_order>
|
47 |
+
<validate>validate-email</validate>
|
48 |
+
<validate>validate-one-required</validate>
|
49 |
+
<show_in_default>1</show_in_default>
|
50 |
+
<show_in_website>1</show_in_website>
|
51 |
+
<show_in_store>0</show_in_store>
|
52 |
+
</api_username>
|
53 |
+
<api_password translate="label">
|
54 |
+
<label>Password</label>
|
55 |
+
<frontend_type>text</frontend_type>
|
56 |
+
<validate>validate-one-required</validate>
|
57 |
+
<backend_model>Mage_CashCloud_Adminhtml_Model_Config</backend_model>
|
58 |
+
<sort_order>5</sort_order>
|
59 |
+
<show_in_default>1</show_in_default>
|
60 |
+
<show_in_website>1</show_in_website>
|
61 |
+
<show_in_store>0</show_in_store>
|
62 |
+
</api_password>
|
63 |
+
<title translate="label">
|
64 |
+
<label>Title</label>
|
65 |
+
<frontend_type>text</frontend_type>
|
66 |
+
<sort_order>6</sort_order>
|
67 |
+
<show_in_default>1</show_in_default>
|
68 |
+
<show_in_website>1</show_in_website>
|
69 |
+
<show_in_store>0</show_in_store>
|
70 |
+
</title>
|
71 |
+
<reason translate="label">
|
72 |
+
<label>Category</label>
|
73 |
+
<frontend_type>select</frontend_type>
|
74 |
+
<source_model>Mage_CashCloud_Adminhtml_Model_Reason</source_model>
|
75 |
+
<sort_order>7</sort_order>
|
76 |
+
<show_in_default>1</show_in_default>
|
77 |
+
<show_in_website>1</show_in_website>
|
78 |
+
<show_in_store>0</show_in_store>
|
79 |
+
</reason>
|
80 |
+
<enable_ccr translate="label">
|
81 |
+
<label>Enable CCR</label>
|
82 |
+
<frontend_type>select</frontend_type>
|
83 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
84 |
+
<sort_order>8</sort_order>
|
85 |
+
<show_in_default>1</show_in_default>
|
86 |
+
<show_in_website>1</show_in_website>
|
87 |
+
<show_in_store>0</show_in_store>
|
88 |
+
</enable_ccr>
|
89 |
+
<device_id translate="label">
|
90 |
+
<label>Device ID</label>
|
91 |
+
<frontend_type>text</frontend_type>
|
92 |
+
<sort_order>9</sort_order>
|
93 |
+
<show_in_default>1</show_in_default>
|
94 |
+
<show_in_website>1</show_in_website>
|
95 |
+
<show_in_store>0</show_in_store>
|
96 |
+
</device_id>
|
97 |
+
<order_status translate="label">
|
98 |
+
<label><![CDATA[Order status (Before the payment)]]></label>
|
99 |
+
<comment><![CDATA[Set the status of the order <b>before</b> the payment is made.]]></comment>
|
100 |
+
<frontend_type>select</frontend_type>
|
101 |
+
<source_model>adminhtml/system_config_source_order_status</source_model>
|
102 |
+
<sort_order>10</sort_order>
|
103 |
+
<show_in_default>1</show_in_default>
|
104 |
+
</order_status>
|
105 |
+
<order_status_after_payment translate="label">
|
106 |
+
<label><![CDATA[Order status (When the payment is made):]]></label>
|
107 |
+
<comment><![CDATA[Set the status of the order <b>after</b> the payment is made. This is used to distinguish between paid and not paid orders!]]></comment>
|
108 |
+
<frontend_type>select</frontend_type>
|
109 |
+
<source_model>adminhtml/system_config_source_order_status</source_model>
|
110 |
+
<sort_order>11</sort_order>
|
111 |
+
<show_in_default>1</show_in_default>
|
112 |
+
</order_status_after_payment>
|
113 |
+
<enable_sandbox translate="label">
|
114 |
+
<label>Sandbox mode</label>
|
115 |
+
<frontend_type>select</frontend_type>
|
116 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
117 |
+
<sort_order>12</sort_order>
|
118 |
+
<show_in_default>1</show_in_default>
|
119 |
+
<show_in_website>1</show_in_website>
|
120 |
+
<show_in_store>0</show_in_store>
|
121 |
+
</enable_sandbox>
|
122 |
+
</fields>
|
123 |
+
</cashcloud>
|
124 |
+
</groups>
|
125 |
+
</payment>
|
126 |
+
</sections>
|
127 |
+
</config>
|
app/code/local/Mage/CashCloud/sql/cashcloud_setup/mysql4-install-0.0.1.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @var Mage_CashCloud_Model_Mysql4_Setup $this
|
4 |
+
*/
|
5 |
+
try {
|
6 |
+
$installer = $this;
|
7 |
+
$quotePaymentTable = $installer->getTable("sales/quote_payment");
|
8 |
+
$orderPaymentTable = $installer->getTable("sales/order_payment");
|
9 |
+
|
10 |
+
$installer->startSetup();
|
11 |
+
if (!$installer->getConnection()->tableColumnExists($quotePaymentTable, "cashcloud_id")) {
|
12 |
+
$installer->getConnection()->addColumn($quotePaymentTable, "cashcloud_id", "varchar(255)");
|
13 |
+
}
|
14 |
+
if (!$installer->getConnection()->tableColumnExists($orderPaymentTable, "cashcloud_id")) {
|
15 |
+
$installer->getConnection()->addColumn($orderPaymentTable, "cashcloud_id", "varchar(255)");
|
16 |
+
}
|
17 |
+
$installer->endSetup();
|
18 |
+
} catch (Exception $e) {
|
19 |
+
var_dump($e); die();
|
20 |
+
}
|
app/design/adminhtml/default/default/template/cashcloud/checks.phtml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @var Mage_CashCloud_Adminhtml_Model_Checks $this
|
4 |
+
*/
|
5 |
+
?>
|
6 |
+
<div class="payflow-settings-notice">
|
7 |
+
<strong class="important-label"><?php echo $this->__('Important: ') ?></strong>
|
8 |
+
<?php echo $this->__('To use CashCloud, you must configure your account on the CashCloud website.'); ?>
|
9 |
+
<?php echo $this->__('Once you log into your account, navigate to the Settings and set the options described below') ?>
|
10 |
+
<ul class="options-list">
|
11 |
+
<li><strong><?php echo $this->__('Callback URL') ?>:</strong> <?php echo $this->getCallbackUrl() ?></li>
|
12 |
+
</ul>
|
13 |
+
</div>
|
app/design/frontend/base/default/template/cashcloud/form.phtml
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @var Mage_CashCloud_Block_Form $this
|
4 |
+
*/
|
5 |
+
?>
|
6 |
+
<div id="payment_form_<?php echo $this->getMethodCode() ?>" style="display: none">
|
7 |
+
<ul class="form-list">
|
8 |
+
<li>
|
9 |
+
<label for="cashcloud_username" class="required"><em>*</em> Username</label>
|
10 |
+
|
11 |
+
<div class="input-box">
|
12 |
+
<input type="text" name="payment[cashcloud_username]" id="cashcloud_username" class="input-text required-entry"/>
|
13 |
+
</div>
|
14 |
+
</li>
|
15 |
+
<?php if (!$this->isReasonSelected()) { ?>
|
16 |
+
<li>
|
17 |
+
<label for="cashcloud_reason_id" class="required"><em>*</em> Reason</label>
|
18 |
+
|
19 |
+
<div class="input-box">
|
20 |
+
<select name="payment[cashcloud_reason_id]" id="cashcloud_reason_id">
|
21 |
+
<?php foreach ($this->getReasons() as $reasonId => $reasonName) {
|
22 |
+
echo "<option value='$reasonId'>$reasonName</option>";
|
23 |
+
} ?>
|
24 |
+
</select>
|
25 |
+
</div>
|
26 |
+
</li>
|
27 |
+
<?php } ?>
|
28 |
+
<?php if ($this->isCCREnabled()) { ?>
|
29 |
+
<li>
|
30 |
+
<label for="cashcloud_currency" class="required"><em>*</em> Currency</label>
|
31 |
+
</li>
|
32 |
+
<li class="control">
|
33 |
+
<input type="radio" name="payment[cashcloud_currency]" id="cashcloud_currency_eur" value="EUR" class="radio validation-passed" checked/>
|
34 |
+
<label for="cashcloud_currency_eur">EUR (<?php echo $this->getPriceInEur() ?>, <?php echo number_format($this->getConversationRate(), 4) ?>)</label>
|
35 |
+
</li>
|
36 |
+
<li class="control">
|
37 |
+
<input type="radio" name="payment[cashcloud_currency]" id="cashcloud_currency_ccr" value="CCR" class="radio validation-passed"/>
|
38 |
+
<label for="cashcloud_currency_ccr">CCR (<?php echo number_format($this->getPriceInCCR(), 2) ?> CCR)</label>
|
39 |
+
</li>
|
40 |
+
<?php } ?>
|
41 |
+
</ul>
|
42 |
+
</div>
|
app/design/frontend/base/default/template/cashcloud/info.phtml
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<table>
|
2 |
+
<tbody>
|
3 |
+
<?php
|
4 |
+
$username = $this->getInfo()->getAdditionalInformation("cashcloud_username");
|
5 |
+
$currency = $this->getInfo()->getAdditionalInformation("cashcloud_currency");
|
6 |
+
?>
|
7 |
+
<tr>
|
8 |
+
<th><strong>CashCloud <?php echo $this->__("user")?>:</strong></th>
|
9 |
+
</tr>
|
10 |
+
<tr>
|
11 |
+
<td><?php echo $this->escapeHtml($username)?></td>
|
12 |
+
</tr>
|
13 |
+
<tr>
|
14 |
+
<th><strong><?php echo $this->__("Amount")?>:</strong></th>
|
15 |
+
</tr>
|
16 |
+
<tr>
|
17 |
+
<td><?php echo $this->escapeHtml($currency)?>: <?php echo $this->getFormattedPrice() ?></td>
|
18 |
+
</tr>
|
19 |
+
<tr>
|
20 |
+
<th><strong><?php echo $this->__("Reason")?>:</strong></th>
|
21 |
+
</tr>
|
22 |
+
<tr>
|
23 |
+
<td><?php echo $this->escapeHtml($this->getReason()) ?></td>
|
24 |
+
</tr>
|
25 |
+
</tbody>
|
26 |
+
</table>
|
27 |
+
|
28 |
+
<?php echo $this->getChildHtml()?>
|
app/design/frontend/base/default/template/cashcloud/process.phtml
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE HTML>
|
2 |
+
<html>
|
3 |
+
<head>
|
4 |
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
5 |
+
<title>CashCloud</title>
|
6 |
+
<link href="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) ?>/skin/frontend/base/default/css/cashcloud.css" rel="stylesheet" />
|
7 |
+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
8 |
+
|
9 |
+
</head>
|
10 |
+
<body>
|
11 |
+
<div class="container">
|
12 |
+
<div class="logo">
|
13 |
+
<img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) ?>/skin/frontend/base/default/images/cashcloud/logo.png" alt="CashCloud"/>
|
14 |
+
</div>
|
15 |
+
<div class="desc">
|
16 |
+
Please approve payment in CashCloud app
|
17 |
+
</div>
|
18 |
+
<div class="loader">
|
19 |
+
<img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) ?>/skin/frontend/base/default/images/cashcloud/loader.gif" alt="CashCloud"/>
|
20 |
+
</div>
|
21 |
+
</div>
|
22 |
+
|
23 |
+
<div class="loader"></div>
|
24 |
+
<script>
|
25 |
+
setInterval(function(){
|
26 |
+
$.post(window.location.href, {action: "check"}, function(data){
|
27 |
+
if(data.action && data.action == "reload") {
|
28 |
+
location.reload();
|
29 |
+
}
|
30 |
+
});
|
31 |
+
return true;
|
32 |
+
}, 5000)
|
33 |
+
</script>
|
34 |
+
</body>
|
35 |
+
</html>
|
app/etc/modules/Mage_CashCloud.xml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<config>
|
2 |
+
<modules>
|
3 |
+
<Mage_CashCloud>
|
4 |
+
<active>true</active>
|
5 |
+
<codePool>local</codePool>
|
6 |
+
<depends>
|
7 |
+
<Mage_Payment />
|
8 |
+
</depends>
|
9 |
+
<version>0.0.1</version>
|
10 |
+
</Mage_CashCloud>
|
11 |
+
</modules>
|
12 |
+
</config>
|
app/locale/en_GB/Mage_CashCloud.csv
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"isNotCorporateUser","In order to use cashcloud payments, your account must be corporate"
|
2 |
+
"SendMoneyOptionBlocked","Sending money blocked"
|
3 |
+
"minAmountTransactionPerTradeLimit","Transaction amount too small"
|
4 |
+
"maxAmountTransactionPerTradeLimit","Maximum trade limit reached"
|
5 |
+
"blackList","User blacklisted"
|
6 |
+
"isBankAvailable","Bank not available"
|
7 |
+
"isCompanyApproved","Company not approved"
|
8 |
+
"isReasonAvailable","Reason not selected"
|
9 |
+
"email.emailDomain","Email is not correct"
|
10 |
+
"recipient.errorStatus","Incorrect recipient status"
|
11 |
+
"recipient.notFound","Recipient not found"
|
12 |
+
"Validation failed: email.emailDomain","Invalid email"
|
app/locale/en_US/Mage_CashCloud.csv
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"isNotCorporateUser","In order to use cashcloud payments, your account must be corporate"
|
2 |
+
"SendMoneyOptionBlocked","Sending money blocked"
|
3 |
+
"minAmountTransactionPerTradeLimit","Transaction amount too small"
|
4 |
+
"maxAmountTransactionPerTradeLimit","Maximum trade limit reached"
|
5 |
+
"blackList","User blacklisted"
|
6 |
+
"isBankAvailable","Bank not available"
|
7 |
+
"isCompanyApproved","Company not approved"
|
8 |
+
"isReasonAvailable","Reason not selected"
|
9 |
+
"email.emailDomain","Email is not correct"
|
10 |
+
"recipient.errorStatus","Incorrect recipient status"
|
11 |
+
"recipient.notFound","Recipient not found"
|
12 |
+
"Validation failed: email.emailDomain","Invalid email"
|
lib/CashCloudApi/README.md
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
# CashCloud API
|
lib/CashCloudApi/composer.json
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "CashCloud/api",
|
3 |
+
"description": "CashCloud api wrapper",
|
4 |
+
"minimum-stability": "dev",
|
5 |
+
"license": "proprietary",
|
6 |
+
"authors": [
|
7 |
+
{
|
8 |
+
"name": "DataDog",
|
9 |
+
"email": "info@datadog.lt"
|
10 |
+
}
|
11 |
+
],
|
12 |
+
"require-dev": {
|
13 |
+
"phpunit/phpunit": "3.7.*"
|
14 |
+
},
|
15 |
+
"require": {
|
16 |
+
"php": ">=5.3.0",
|
17 |
+
"ext-curl": "*",
|
18 |
+
"ext-json": "*"
|
19 |
+
},
|
20 |
+
"autoload": {
|
21 |
+
"psr-0": {
|
22 |
+
"CashCloud": "src/"
|
23 |
+
}
|
24 |
+
}
|
25 |
+
}
|
lib/CashCloudApi/phpunit.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<phpunit bootstrap="./tests/bootstrap.php" colors="true">
|
3 |
+
<testsuites>
|
4 |
+
<testsuite name="All">
|
5 |
+
<directory>tests</directory>
|
6 |
+
</testsuite>
|
7 |
+
</testsuites>
|
8 |
+
|
9 |
+
<logging>
|
10 |
+
<log type="junit" target="build/junit.xml" logIncompleteSkipped="false" />
|
11 |
+
</logging>
|
12 |
+
|
13 |
+
<filter>
|
14 |
+
<whitelist>
|
15 |
+
<directory suffix=".php">./lib</directory>
|
16 |
+
<exclude>
|
17 |
+
</exclude>
|
18 |
+
</whitelist>
|
19 |
+
</filter>
|
20 |
+
</phpunit>
|
lib/CashCloudApi/samples/GetRate.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// autoload
|
3 |
+
require_once __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
|
4 |
+
require_once __DIR__.DIRECTORY_SEPARATOR.'credentials.php';
|
5 |
+
|
6 |
+
use CashCloud\Api\Rest\Auth;
|
7 |
+
use CashCloud\Api\Rest\Client;
|
8 |
+
|
9 |
+
$api = new Client(new Auth(CASHCLOUD_USER, CASHCLOUD_PASSWORD, CASHCLOUD_DEVICEID), null, CASHCLOUD_SANDBOX);
|
10 |
+
$request = new \CashCloud\Api\Method\GetRates();
|
11 |
+
$request->setAmount(1000);
|
12 |
+
$result = $request->perform($api);
|
13 |
+
|
14 |
+
print_r($result);
|
lib/CashCloudApi/samples/GetReasons.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// autoload
|
3 |
+
require_once __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
|
4 |
+
require_once __DIR__.DIRECTORY_SEPARATOR.'credentials.php';
|
5 |
+
|
6 |
+
use CashCloud\Api\Rest\Auth;
|
7 |
+
use CashCloud\Api\Rest\Client;
|
8 |
+
|
9 |
+
$api = new Client(new Auth(CASHCLOUD_USER, CASHCLOUD_PASSWORD, CASHCLOUD_DEVICEID), null, CASHCLOUD_SANDBOX);
|
10 |
+
$request = new \CashCloud\Api\Method\GetReasons();
|
11 |
+
$result = $request->perform($api);
|
12 |
+
|
13 |
+
print_r($result);
|
lib/CashCloudApi/samples/GetSettings.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// autoload
|
3 |
+
require_once __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
|
4 |
+
require_once __DIR__.DIRECTORY_SEPARATOR.'credentials.php';
|
5 |
+
|
6 |
+
use CashCloud\Api\Rest\Auth;
|
7 |
+
use CashCloud\Api\Rest\Client;
|
8 |
+
|
9 |
+
$api = new Client(new Auth(CASHCLOUD_USER, CASHCLOUD_PASSWORD, CASHCLOUD_DEVICEID), null, CASHCLOUD_SANDBOX);
|
10 |
+
$request = new \CashCloud\Api\Method\GetSettings();
|
11 |
+
print_r($request->perform($api));
|
lib/CashCloudApi/samples/RequestMoney.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// autoload
|
3 |
+
require_once __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
|
4 |
+
require_once __DIR__.DIRECTORY_SEPARATOR.'credentials.php';
|
5 |
+
|
6 |
+
use CashCloud\Api\Rest\Auth;
|
7 |
+
use CashCloud\Api\Rest\Client;
|
8 |
+
|
9 |
+
$api = new Client(new Auth(CASHCLOUD_USER, CASHCLOUD_PASSWORD, CASHCLOUD_DEVICEID), null, CASHCLOUD_SANDBOX);
|
10 |
+
$request = new \CashCloud\Api\Method\RequestMoney(new \CashCloud\Api\Rest\CurlRequest());
|
11 |
+
$request->setEmail("customer@cashcloud.com");
|
12 |
+
$request->setAmount(100);
|
13 |
+
$request->setCurrency(Client::CURRENCY_CCR);
|
14 |
+
$request->setReason(1354);
|
15 |
+
$request->setRemark("123");
|
16 |
+
print_r($request->perform($api));
|
lib/CashCloudApi/samples/SaveSettings.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// autoload
|
3 |
+
require_once __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
|
4 |
+
require_once __DIR__.DIRECTORY_SEPARATOR.'credentials.php';
|
5 |
+
|
6 |
+
use CashCloud\Api\Rest\Auth;
|
7 |
+
use CashCloud\Api\Rest\Client;
|
8 |
+
|
9 |
+
$api = new Client(new Auth(CASHCLOUD_USER, CASHCLOUD_PASSWORD, CASHCLOUD_DEVICEID), null, CASHCLOUD_SANDBOX);
|
10 |
+
$request = new \CashCloud\Api\Method\SaveSettings();
|
11 |
+
$request->setCallbackUrl('https://www.example.com/callback?p');
|
12 |
+
$request->setRequestExpiration(3602);
|
13 |
+
print_r(
|
14 |
+
$request->perform($api)
|
15 |
+
);
|
lib/CashCloudApi/samples/credentials.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* File credentials.php
|
4 |
+
*
|
5 |
+
* @version GIT $Id$
|
6 |
+
*/
|
7 |
+
define("CASHCLOUD_USER", "");
|
8 |
+
define("CASHCLOUD_PASSWORD", "");
|
9 |
+
define("CASHCLOUD_SANDBOX", true);
|
10 |
+
define("CASHCLOUD_DEVICEID", "");
|
lib/CashCloudApi/src/CashCloud/Api/Exception/AuthException.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php namespace CashCloud\Api\Exception;
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class AuthException
|
5 |
+
* @package CashCloud\Api\Exception
|
6 |
+
*/
|
7 |
+
class AuthException extends CashCloudException
|
8 |
+
{
|
9 |
+
|
10 |
+
}
|
lib/CashCloudApi/src/CashCloud/Api/Exception/CashCloudException.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php namespace CashCloud\Api\Exception;
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class CashCloudException
|
5 |
+
* @package CashCloud\Api\Exception
|
6 |
+
*/
|
7 |
+
class CashCloudException extends \Exception
|
8 |
+
{
|
9 |
+
|
10 |
+
}
|
lib/CashCloudApi/src/CashCloud/Api/Exception/ValidateException.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php namespace CashCloud\Api\Exception;
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class ValidateException
|
5 |
+
* @package CashCloud\Api\Exception
|
6 |
+
*/
|
7 |
+
class ValidateException extends CashCloudException
|
8 |
+
{
|
9 |
+
/**
|
10 |
+
* @var array
|
11 |
+
*/
|
12 |
+
protected $errors = array();
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @param mixed $errors
|
16 |
+
*/
|
17 |
+
public function __construct($errors)
|
18 |
+
{
|
19 |
+
$this->errors = $this->parseErrors($errors);
|
20 |
+
parent::__construct($this->getFirstError(), 412, null);
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @return array|string
|
25 |
+
*/
|
26 |
+
public function getErrors()
|
27 |
+
{
|
28 |
+
return $this->errors;
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @return bool
|
33 |
+
*/
|
34 |
+
public function getFirstError()
|
35 |
+
{
|
36 |
+
foreach ($this->errors as $error) {
|
37 |
+
return $error;
|
38 |
+
}
|
39 |
+
return false;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* @param $errors
|
44 |
+
* @return mixed
|
45 |
+
*/
|
46 |
+
public function parseErrors($errors)
|
47 |
+
{
|
48 |
+
$formattedErrors = array();
|
49 |
+
|
50 |
+
foreach ($errors as $key=>$value) {
|
51 |
+
if(is_object($value)) {
|
52 |
+
$value = (array)$value;
|
53 |
+
}
|
54 |
+
|
55 |
+
if(is_int($key) && is_string($value)) {
|
56 |
+
$formattedErrors[] = $value;
|
57 |
+
} elseif(is_string($key) && is_bool($value)) {
|
58 |
+
$formattedErrors[] = $key;
|
59 |
+
} elseif(is_string($key) && is_string($value)) {
|
60 |
+
$formattedErrors[] = $key.'.'.$value;
|
61 |
+
} elseif(is_int($key) && is_array($value)) {
|
62 |
+
foreach ($value as $subKey => $subError) {
|
63 |
+
$formattedErrors[] = is_int($subKey) ? $subError : "{$subKey}.{$subError}";
|
64 |
+
}
|
65 |
+
} elseif( is_string($key) && is_array($value)) {
|
66 |
+
foreach ($value as $subError) {
|
67 |
+
$formattedErrors[] = $key.'.'.$subError;
|
68 |
+
}
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
return $formattedErrors;
|
73 |
+
}
|
74 |
+
}
|
lib/CashCloudApi/src/CashCloud/Api/Method/GetRates.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php namespace CashCloud\Api\Method;
|
2 |
+
|
3 |
+
use CashCloud\Api\Rest\Client;
|
4 |
+
use CashCloud\Api\Rest\Request;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Class GetRates
|
8 |
+
* @package CashCloud\Api\Method
|
9 |
+
*/
|
10 |
+
class GetRates extends Method
|
11 |
+
{
|
12 |
+
protected $amount = null;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Return method URL
|
16 |
+
* @param \CashCloud\Api\Rest\Client $api
|
17 |
+
* @return string
|
18 |
+
*/
|
19 |
+
public function getUrl(Client $api)
|
20 |
+
{
|
21 |
+
return $api->getMethodUrl("currency-rate");
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Return method data
|
26 |
+
* @return array
|
27 |
+
*/
|
28 |
+
public function getData()
|
29 |
+
{
|
30 |
+
return array(
|
31 |
+
'amount'=>$this->amount,
|
32 |
+
);
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @param Request $request
|
37 |
+
* @return array
|
38 |
+
*/
|
39 |
+
public function formatResponse(Request $request)
|
40 |
+
{
|
41 |
+
if(is_null($this->amount)) {
|
42 |
+
return $request->getJson("rate");
|
43 |
+
} else {
|
44 |
+
return $request->getJson("amount");
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @return float
|
50 |
+
*/
|
51 |
+
public function getAmount()
|
52 |
+
{
|
53 |
+
return $this->amount;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* @param float $amount
|
58 |
+
*/
|
59 |
+
public function setAmount($amount)
|
60 |
+
{
|
61 |
+
$this->amount = $amount;
|
62 |
+
}
|
63 |
+
}
|
lib/CashCloudApi/src/CashCloud/Api/Method/GetReasons.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php namespace CashCloud\Api\Method;
|
2 |
+
|
3 |
+
use CashCloud\Api\Exception\CashCloudException;
|
4 |
+
use CashCloud\Api\Rest\Client;
|
5 |
+
use CashCloud\Api\Rest\Request;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class GetReasons
|
9 |
+
* @package CashCloud\Api\Method
|
10 |
+
*/
|
11 |
+
class GetReasons extends Method
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Return method URL
|
16 |
+
* @param \CashCloud\Api\Rest\Client $api
|
17 |
+
* @return string
|
18 |
+
*/
|
19 |
+
public function getUrl(Client $api)
|
20 |
+
{
|
21 |
+
return $api->getMethodUrl('reasons');
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Return method data
|
26 |
+
* @return array
|
27 |
+
*/
|
28 |
+
public function getData()
|
29 |
+
{
|
30 |
+
return array();
|
31 |
+
}
|
32 |
+
|
33 |
+
public function getMethod()
|
34 |
+
{
|
35 |
+
return Request::GET;
|
36 |
+
}
|
37 |
+
|
38 |
+
|
39 |
+
/**
|
40 |
+
* @param Request $request
|
41 |
+
* @throws \CashCloud\Api\Exception\CashCloudException
|
42 |
+
* @return array
|
43 |
+
*/
|
44 |
+
public function formatResponse(Request $request)
|
45 |
+
{
|
46 |
+
$response = json_decode($request->getBody(), true);
|
47 |
+
|
48 |
+
if(isset($response['messages']) && is_array($response['messages'])) {
|
49 |
+
return $response['messages'];
|
50 |
+
}
|
51 |
+
|
52 |
+
throw new CashCloudException("Unexpected response from API:".$request->getBody());
|
53 |
+
}
|
54 |
+
}
|
lib/CashCloudApi/src/CashCloud/Api/Method/GetSettings.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php namespace CashCloud\Api\Method;
|
2 |
+
|
3 |
+
use CashCloud\Api\Rest\Client;
|
4 |
+
use CashCloud\Api\Rest\Request;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Class Settings
|
8 |
+
* @package CashCloud\Api\Method
|
9 |
+
*/
|
10 |
+
class GetSettings extends Method
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* @var string
|
14 |
+
*/
|
15 |
+
protected $callbackUrl;
|
16 |
+
/**
|
17 |
+
* @var string
|
18 |
+
*/
|
19 |
+
protected $requestExpiration;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Return method URL
|
23 |
+
* @param \CashCloud\Api\Rest\Client $api
|
24 |
+
* @return string
|
25 |
+
*/
|
26 |
+
public function getUrl(Client $api)
|
27 |
+
{
|
28 |
+
return $api->getMethodUrl("settings");
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @return string
|
33 |
+
*/
|
34 |
+
public function getMethod()
|
35 |
+
{
|
36 |
+
return Request::GET;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Return method data
|
41 |
+
* @return array
|
42 |
+
*/
|
43 |
+
public function getData()
|
44 |
+
{
|
45 |
+
return array();
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @param Request $request
|
50 |
+
* @return array
|
51 |
+
*/
|
52 |
+
public function formatResponse(Request $request)
|
53 |
+
{
|
54 |
+
return array(
|
55 |
+
$request->getJson('callback_url'),
|
56 |
+
$request->getJson('request_expiration'),
|
57 |
+
);
|
58 |
+
}
|
59 |
+
}
|
lib/CashCloudApi/src/CashCloud/Api/Method/GetTransactions.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php namespace CashCloud\Api\Method;
|
2 |
+
|
3 |
+
use CashCloud\Api\Rest\Client;
|
4 |
+
use CashCloud\Api\Rest\Request;
|
5 |
+
|
6 |
+
class GetTransactions extends Method
|
7 |
+
{
|
8 |
+
protected $hash = null;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Return method URL
|
12 |
+
* @param \CashCloud\Api\Rest\Client $api
|
13 |
+
* @return string
|
14 |
+
*/
|
15 |
+
public function getUrl(Client $api)
|
16 |
+
{
|
17 |
+
return $api->getMethodUrl("transactions");
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @return string
|
22 |
+
*/
|
23 |
+
public function getMethod()
|
24 |
+
{
|
25 |
+
return Request::GET;
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @return string
|
30 |
+
*/
|
31 |
+
public function getHash()
|
32 |
+
{
|
33 |
+
return $this->hash;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @param string $hash
|
38 |
+
*/
|
39 |
+
public function setHash($hash)
|
40 |
+
{
|
41 |
+
$this->hash = $hash;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Return method data
|
46 |
+
*
|
47 |
+
* @return array
|
48 |
+
*/
|
49 |
+
public function getData()
|
50 |
+
{
|
51 |
+
return array(
|
52 |
+
'hash' => $this->hash
|
53 |
+
);
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* @param Request $request
|
58 |
+
*
|
59 |
+
* @return array
|
60 |
+
*/
|
61 |
+
public function formatResponse(Request $request)
|
62 |
+
{
|
63 |
+
return $request->getJson();
|
64 |
+
}
|
65 |
+
}
|
lib/CashCloudApi/src/CashCloud/Api/Method/Method.php
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php namespace CashCloud\Api\Method;
|
2 |
+
|
3 |
+
use CashCloud\Api\Exception\AuthException;
|
4 |
+
use CashCloud\Api\Exception\CashCloudException;
|
5 |
+
use CashCloud\Api\Exception\ValidateException;
|
6 |
+
use CashCloud\Api\Rest\Client;
|
7 |
+
use CashCloud\Api\Rest\CurlRequest;
|
8 |
+
use CashCloud\Api\Rest\Request;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class Method
|
12 |
+
* @package CashCloud\Method
|
13 |
+
*/
|
14 |
+
abstract class Method
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* @var \CashCloud\Api\Rest\Request
|
18 |
+
*/
|
19 |
+
private $request;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Return method URL
|
23 |
+
* @param \CashCloud\Api\Rest\Client $api
|
24 |
+
* @return string
|
25 |
+
*/
|
26 |
+
abstract public function getUrl(Client $api);
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Return method data
|
30 |
+
* @return array
|
31 |
+
*/
|
32 |
+
abstract public function getData();
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @param Request $request
|
36 |
+
*/
|
37 |
+
function __construct(Request $request = null)
|
38 |
+
{
|
39 |
+
if(is_null($request)) {
|
40 |
+
$this->request = new CurlRequest();
|
41 |
+
} else {
|
42 |
+
$this->request = $request;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @return string
|
48 |
+
*/
|
49 |
+
public function getMethod()
|
50 |
+
{
|
51 |
+
return Request::GET;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @param Request $request
|
56 |
+
* @return array
|
57 |
+
*/
|
58 |
+
abstract public function formatResponse(Request $request);
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @param Client $api
|
62 |
+
* @return mixed
|
63 |
+
* @throws \CashCloud\Api\Exception\ValidateException
|
64 |
+
* @throws \CashCloud\Api\Exception\AuthException
|
65 |
+
* @throws \CashCloud\Api\Exception\CashCloudException
|
66 |
+
*/
|
67 |
+
public function perform(Client $api)
|
68 |
+
{
|
69 |
+
$this->request->setUrl($this->getUrl($api));
|
70 |
+
$this->request->setData($this->getData());
|
71 |
+
$this->request->setMethod($this->getMethod());
|
72 |
+
|
73 |
+
$api->authorizeRequest($this->request);
|
74 |
+
|
75 |
+
switch($this->request->execute()) {
|
76 |
+
case 200:
|
77 |
+
return $this->formatResponse($this->request);
|
78 |
+
case 201:
|
79 |
+
return $this->formatResponse($this->request);
|
80 |
+
case 403:
|
81 |
+
throw new AuthException();
|
82 |
+
case 404:
|
83 |
+
throw new CashCloudException("Invalid url", 404);
|
84 |
+
case 412:
|
85 |
+
throw new ValidateException($this->request->getJson("validationFailed"));
|
86 |
+
case 423:
|
87 |
+
throw new CashCloudException("API Locked!", 423);
|
88 |
+
case 500:
|
89 |
+
throw new CashCloudException("CashCloud server error", 500);
|
90 |
+
case 0:
|
91 |
+
throw new CashCloudException($this->request->getError(), $this->request->getErrorCode());
|
92 |
+
default:
|
93 |
+
throw new CashCloudException("Unknown exception", $this->request->getResponseCode());
|
94 |
+
}
|
95 |
+
}
|
96 |
+
}
|
lib/CashCloudApi/src/CashCloud/Api/Method/Refund.php
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php namespace CashCloud\Api\Method;
|
2 |
+
|
3 |
+
use CashCloud\Api\Rest\Client;
|
4 |
+
use CashCloud\Api\Rest\Request;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Class Settings
|
8 |
+
* @package CashCloud\Api\Method
|
9 |
+
*/
|
10 |
+
class Refund extends Method
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* @var string
|
14 |
+
*/
|
15 |
+
protected $hash;
|
16 |
+
/**
|
17 |
+
* @var int
|
18 |
+
*/
|
19 |
+
protected $amount;
|
20 |
+
/**
|
21 |
+
* @var string
|
22 |
+
*/
|
23 |
+
protected $remark;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Return method URL
|
27 |
+
* @param \CashCloud\Api\Rest\Client $api
|
28 |
+
* @return string
|
29 |
+
*/
|
30 |
+
public function getUrl(Client $api)
|
31 |
+
{
|
32 |
+
return $api->getMethodUrl("refund");
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @return string
|
37 |
+
*/
|
38 |
+
public function getMethod()
|
39 |
+
{
|
40 |
+
return Request::POST;
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Return method data
|
46 |
+
* @return array
|
47 |
+
*/
|
48 |
+
public function getData()
|
49 |
+
{
|
50 |
+
return array(
|
51 |
+
'hash'=>$this->hash,
|
52 |
+
'amount'=>$this->amount,
|
53 |
+
'remark'=>$this->remark,
|
54 |
+
);
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* @param Request $request
|
59 |
+
* @return array
|
60 |
+
*/
|
61 |
+
public function formatResponse(Request $request)
|
62 |
+
{
|
63 |
+
return $request->getJson();
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* @return string
|
68 |
+
*/
|
69 |
+
public function getHash()
|
70 |
+
{
|
71 |
+
return $this->hash;
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* @param string $hash
|
76 |
+
*/
|
77 |
+
public function setHash($hash)
|
78 |
+
{
|
79 |
+
$this->hash = $hash;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @return int
|
84 |
+
*/
|
85 |
+
public function getAmount()
|
86 |
+
{
|
87 |
+
return $this->amount;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* @param int $amount
|
92 |
+
*/
|
93 |
+
public function setAmount($amount)
|
94 |
+
{
|
95 |
+
$this->amount = $amount;
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* @return string
|
100 |
+
*/
|
101 |
+
public function getRemark()
|
102 |
+
{
|
103 |
+
return $this->remark;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* @param string $remark
|
108 |
+
*/
|
109 |
+
public function setRemark($remark)
|
110 |
+
{
|
111 |
+
$this->remark = $remark;
|
112 |
+
}
|
113 |
+
}
|
lib/CashCloudApi/src/CashCloud/Api/Method/RequestMoney.php
ADDED
@@ -0,0 +1,218 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php namespace CashCloud\Api\Method;
|
2 |
+
|
3 |
+
use CashCloud\Api\Exception\CashCloudException;
|
4 |
+
use CashCloud\Api\Rest\Client;
|
5 |
+
use CashCloud\Api\Rest\Request;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class RequestMoney
|
9 |
+
* @package CashCloud\Method
|
10 |
+
*/
|
11 |
+
class RequestMoney extends Method
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
protected $email;
|
17 |
+
/**
|
18 |
+
* @var int
|
19 |
+
*/
|
20 |
+
protected $amount;
|
21 |
+
/**
|
22 |
+
* @var int
|
23 |
+
*/
|
24 |
+
protected $currency;
|
25 |
+
/**
|
26 |
+
* @var int
|
27 |
+
*/
|
28 |
+
protected $reason;
|
29 |
+
/**
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
protected $remark;
|
33 |
+
/**
|
34 |
+
* @var string
|
35 |
+
*/
|
36 |
+
protected $externalId;
|
37 |
+
/**
|
38 |
+
* @var string
|
39 |
+
*/
|
40 |
+
protected $externalReference;
|
41 |
+
/**
|
42 |
+
* @var string
|
43 |
+
*/
|
44 |
+
protected $externalDescription;
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @return string
|
48 |
+
*/
|
49 |
+
public function getMethod()
|
50 |
+
{
|
51 |
+
return Request::POST;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @return mixed
|
56 |
+
*/
|
57 |
+
public function getEmail()
|
58 |
+
{
|
59 |
+
return $this->email;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @param mixed $email
|
64 |
+
*/
|
65 |
+
public function setEmail($email)
|
66 |
+
{
|
67 |
+
$this->email = $email;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* @return mixed
|
72 |
+
*/
|
73 |
+
public function getAmount()
|
74 |
+
{
|
75 |
+
return $this->amount;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* @param mixed $amount
|
80 |
+
*/
|
81 |
+
public function setAmount($amount)
|
82 |
+
{
|
83 |
+
$this->amount = $amount;
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* @return mixed
|
88 |
+
*/
|
89 |
+
public function getCurrency()
|
90 |
+
{
|
91 |
+
return $this->currency;
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* @param mixed $currency
|
96 |
+
* @throws \CashCloud\Api\Exception\CashCloudException
|
97 |
+
*/
|
98 |
+
public function setCurrency($currency)
|
99 |
+
{
|
100 |
+
if ($currency != Client::CURRENCY_EUR && $currency != Client::CURRENCY_CCR) {
|
101 |
+
throw new CashCloudException("Invalid currency!");
|
102 |
+
}
|
103 |
+
$this->currency = $currency;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* @param string $id
|
108 |
+
* @param string $reference
|
109 |
+
* @param string $description
|
110 |
+
* @internal param mixed $externalId
|
111 |
+
*/
|
112 |
+
public function setExternalData($id, $reference = null, $description = null)
|
113 |
+
{
|
114 |
+
$this->externalId = $id;
|
115 |
+
$this->externalReference = $reference;
|
116 |
+
$this->externalDescription = $description;
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Return method URL
|
121 |
+
* @param \CashCloud\Api\Rest\Client $api
|
122 |
+
* @return string
|
123 |
+
*/
|
124 |
+
public function getUrl(Client $api)
|
125 |
+
{
|
126 |
+
return $api->getMethodUrl('request');
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Return method data
|
131 |
+
* @return array
|
132 |
+
*/
|
133 |
+
public function getData()
|
134 |
+
{
|
135 |
+
return array(
|
136 |
+
'email'=>$this->getEmail(),
|
137 |
+
'amount'=>$this->getAmount(),
|
138 |
+
'currency_id'=>$this->getCurrency(),
|
139 |
+
'reason_id'=>$this->getReason(),
|
140 |
+
'remark'=>$this->getRemark(),
|
141 |
+
'extern.id'=>$this->externalId,
|
142 |
+
'extern.reference'=>$this->externalReference,
|
143 |
+
'extern.description'=>$this->externalDescription,
|
144 |
+
);
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* @param Client $api
|
149 |
+
* @return mixed
|
150 |
+
* @throws \CashCloud\Api\Exception\CashCloudException
|
151 |
+
*/
|
152 |
+
public function perform(Client $api)
|
153 |
+
{
|
154 |
+
if($this->getAmount() <= 0) {
|
155 |
+
throw new CashCloudException("Invalid amount!");
|
156 |
+
}
|
157 |
+
|
158 |
+
if(is_null($this->getCurrency())) {
|
159 |
+
throw new CashCloudException("Invalid currency!");
|
160 |
+
}
|
161 |
+
|
162 |
+
if(empty($this->email)) {
|
163 |
+
throw new CashCloudException("Invalid email!");
|
164 |
+
}
|
165 |
+
|
166 |
+
|
167 |
+
return parent::perform($api);
|
168 |
+
}
|
169 |
+
|
170 |
+
|
171 |
+
/**
|
172 |
+
* @return mixed
|
173 |
+
*/
|
174 |
+
public function getRemark()
|
175 |
+
{
|
176 |
+
return $this->remark;
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* @param mixed $remark
|
181 |
+
*/
|
182 |
+
public function setRemark($remark)
|
183 |
+
{
|
184 |
+
$this->remark = $remark;
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* @return mixed
|
189 |
+
*/
|
190 |
+
public function getReason()
|
191 |
+
{
|
192 |
+
return $this->reason;
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* @param mixed $reason
|
197 |
+
*/
|
198 |
+
public function setReason($reason)
|
199 |
+
{
|
200 |
+
$this->reason = $reason;
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* @param Request $request
|
205 |
+
* @throws \CashCloud\Api\Exception\CashCloudException
|
206 |
+
* @return array
|
207 |
+
*/
|
208 |
+
public function formatResponse(Request $request)
|
209 |
+
{
|
210 |
+
$json = $request->getJson();
|
211 |
+
|
212 |
+
if(!$json || empty($json->hash)) {
|
213 |
+
throw new CashCloudException("Unable to parse request body: ".$request->getBody());
|
214 |
+
}
|
215 |
+
|
216 |
+
return $json;
|
217 |
+
}
|
218 |
+
}
|
lib/CashCloudApi/src/CashCloud/Api/Method/SaveSettings.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php namespace CashCloud\Api\Method;
|
2 |
+
|
3 |
+
use CashCloud\Api\Rest\Client;
|
4 |
+
use CashCloud\Api\Rest\Request;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Class Settings
|
8 |
+
* @package CashCloud\Api\Method
|
9 |
+
*/
|
10 |
+
class SaveSettings extends Method
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* @var string
|
14 |
+
*/
|
15 |
+
protected $callbackUrl;
|
16 |
+
/**
|
17 |
+
* @var string
|
18 |
+
*/
|
19 |
+
protected $requestExpiration;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Return method URL
|
23 |
+
* @param \CashCloud\Api\Rest\Client $api
|
24 |
+
* @return string
|
25 |
+
*/
|
26 |
+
public function getUrl(Client $api)
|
27 |
+
{
|
28 |
+
return $api->getMethodUrl("settings");
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @return string
|
33 |
+
*/
|
34 |
+
public function getMethod()
|
35 |
+
{
|
36 |
+
return Request::POST;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Return method data
|
41 |
+
* @return array
|
42 |
+
*/
|
43 |
+
public function getData()
|
44 |
+
{
|
45 |
+
return array(
|
46 |
+
'callback_url'=>$this->callbackUrl,
|
47 |
+
'request_expiration'=>$this->requestExpiration,
|
48 |
+
);
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @param Request $request
|
53 |
+
* @return array
|
54 |
+
*/
|
55 |
+
public function formatResponse(Request $request)
|
56 |
+
{
|
57 |
+
return $request->getJson();
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @return string
|
62 |
+
*/
|
63 |
+
public function getCallbackUrl()
|
64 |
+
{
|
65 |
+
return $this->callbackUrl;
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* @param string $callbackUrl
|
70 |
+
*/
|
71 |
+
public function setCallbackUrl($callbackUrl)
|
72 |
+
{
|
73 |
+
$this->callbackUrl = $callbackUrl;
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* @return string
|
78 |
+
*/
|
79 |
+
public function getRequestExpiration()
|
80 |
+
{
|
81 |
+
return $this->requestExpiration;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* @param string $requestExpiration
|
86 |
+
*/
|
87 |
+
public function setRequestExpiration($requestExpiration)
|
88 |
+
{
|
89 |
+
$this->requestExpiration = $requestExpiration;
|
90 |
+
}
|
91 |
+
}
|
lib/CashCloudApi/src/CashCloud/Api/Rest/Auth.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php namespace CashCloud\Api\Rest;
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Auth
|
5 |
+
* @package CashCloud\Api
|
6 |
+
*/
|
7 |
+
class Auth
|
8 |
+
{
|
9 |
+
/**
|
10 |
+
* @var string
|
11 |
+
*/
|
12 |
+
private $email;
|
13 |
+
/**
|
14 |
+
* @var string
|
15 |
+
*/
|
16 |
+
private $password;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
private $deviceId = null;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @param string $email
|
25 |
+
* @param string $password
|
26 |
+
* @param string|null $deviceId
|
27 |
+
*/
|
28 |
+
function __construct($email, $password, $deviceId = null)
|
29 |
+
{
|
30 |
+
$this->email = $email;
|
31 |
+
$this->password = $password;
|
32 |
+
if(is_null($deviceId)) {
|
33 |
+
$this->deviceId = $this->generateDeviceId();
|
34 |
+
} else {
|
35 |
+
$this->deviceId = $deviceId;
|
36 |
+
}
|
37 |
+
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @throws \CashCloud\Api\Exception\AuthException
|
42 |
+
*/
|
43 |
+
public function authorizeRequest(Client $client, Request $request)
|
44 |
+
{
|
45 |
+
$request->setHeader("Authorization", $this->getAuthorizationToken($client));
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @param Client $client
|
50 |
+
* @throws \CashCloud\Api\Exception\AuthException
|
51 |
+
* @return string
|
52 |
+
*/
|
53 |
+
private function getAuthorizationToken(Client $client)
|
54 |
+
{
|
55 |
+
$deviceId = $this->getDeviceId();
|
56 |
+
$username = $this->getUsername();
|
57 |
+
$salt = $client->getSalt($client->createRequest());
|
58 |
+
|
59 |
+
$passwordHash = md5(sha1($this->password, true), true);
|
60 |
+
$hash = md5(sha1($username . $salt . $passwordHash, true));
|
61 |
+
$token = 'Token ' . base64_encode("{$username}|{$deviceId}|" . $hash);
|
62 |
+
|
63 |
+
return $token;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* @return string
|
68 |
+
*/
|
69 |
+
private function generateDeviceId()
|
70 |
+
{
|
71 |
+
return md5("cashcloud-api-".time());
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* @return string
|
76 |
+
*/
|
77 |
+
public function getUsername()
|
78 |
+
{
|
79 |
+
return $this->email;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @return string
|
84 |
+
*/
|
85 |
+
public function getDeviceId()
|
86 |
+
{
|
87 |
+
return $this->deviceId;
|
88 |
+
}
|
89 |
+
}
|
lib/CashCloudApi/src/CashCloud/Api/Rest/Client.php
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php namespace CashCloud\Api\Rest;
|
2 |
+
|
3 |
+
use CashCloud\Api\Exception\AuthException;
|
4 |
+
use CashCloud\Api\Exception\CashCloudException;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Class Client
|
8 |
+
*/
|
9 |
+
class Client
|
10 |
+
{
|
11 |
+
const STATUS_PENDING_ACCEPT = 1;
|
12 |
+
const STATUS_ACCEPTED = 2;
|
13 |
+
const STATUS_COMPLETED = 3;
|
14 |
+
const STATUS_DECLINED = 4;
|
15 |
+
const STATUS_EXPIRED = 6;
|
16 |
+
const STATUS_MONEY_SERVICE_FAILED = 7;
|
17 |
+
const STATUS_REFUNDED = 8;
|
18 |
+
|
19 |
+
const CURRENCY_EUR = 1;
|
20 |
+
const CURRENCY_CCR = 2;
|
21 |
+
|
22 |
+
const CURRENCY_BUY = 1;
|
23 |
+
const CURRENCY_SELL = 2;
|
24 |
+
const CURRENCY_RECEIVE = 3;
|
25 |
+
|
26 |
+
private $salt;
|
27 |
+
/**
|
28 |
+
* @var Auth
|
29 |
+
*/
|
30 |
+
private $auth;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @var string
|
34 |
+
*/
|
35 |
+
private $apiUrlSandbox = 'https://merchant-api.sandbox.cashcloud.com/';
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @var string
|
39 |
+
*/
|
40 |
+
private $apiUrl = 'https://merchant.api.cashcloud.com/';
|
41 |
+
|
42 |
+
/**
|
43 |
+
* @var bool
|
44 |
+
*/
|
45 |
+
private $sandbox = false;
|
46 |
+
|
47 |
+
/**
|
48 |
+
* @var string
|
49 |
+
*/
|
50 |
+
private $backend = '\CashCloud\Api\Rest\CurlRequest';
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @param Auth $authentication
|
54 |
+
* @param string|null $salt
|
55 |
+
* @param bool $sandbox
|
56 |
+
*/
|
57 |
+
function __construct(Auth $authentication, $salt = null, $sandbox = false)
|
58 |
+
{
|
59 |
+
$this->auth = $authentication;
|
60 |
+
$this->salt = $salt;
|
61 |
+
$this->sandbox = $sandbox;
|
62 |
+
}
|
63 |
+
|
64 |
+
|
65 |
+
/**
|
66 |
+
* @param Request $request
|
67 |
+
* @throws \CashCloud\Api\Exception\AuthException
|
68 |
+
* @throws \CashCloud\Api\Exception\CashCloudException
|
69 |
+
* @return mixed
|
70 |
+
*/
|
71 |
+
public function getSalt(Request $request)
|
72 |
+
{
|
73 |
+
if (is_null($this->salt)) {
|
74 |
+
$request->setUrl($this->getMethodUrl("salt"));
|
75 |
+
$request->setMethod(Request::POST);
|
76 |
+
$request->setData(array(
|
77 |
+
'username' => $this->auth->getUsername(),
|
78 |
+
'device_id' => $this->auth->getDeviceId(),
|
79 |
+
));
|
80 |
+
|
81 |
+
if ($request->execute() == 200) {
|
82 |
+
$response = $request->getJson();
|
83 |
+
if (isset($response->salt)) {
|
84 |
+
return $response->salt;
|
85 |
+
} else {
|
86 |
+
throw new CashCloudException("Invalid response from CashCloud: " . $request->getBody());
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
if ($request->getErrorCode() > 0) {
|
91 |
+
throw new CashCloudException($request->getError(), $request->getErrorCode());
|
92 |
+
}
|
93 |
+
|
94 |
+
if ($request->getResponseCode() != 200) {
|
95 |
+
throw new AuthException("Unable to retrieve salt from CashCloud", $request->getResponseCode());
|
96 |
+
}
|
97 |
+
}
|
98 |
+
return $this->salt;
|
99 |
+
}
|
100 |
+
|
101 |
+
public function authorizeRequest(Request $request)
|
102 |
+
{
|
103 |
+
$this->auth->authorizeRequest($this, $request);
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* @param string $method
|
108 |
+
* @return string
|
109 |
+
*/
|
110 |
+
public function getMethodUrl($method)
|
111 |
+
{
|
112 |
+
return ($this->sandbox ? $this->apiUrlSandbox : $this->apiUrl) . $method;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* @return Request
|
117 |
+
*/
|
118 |
+
public function createRequest()
|
119 |
+
{
|
120 |
+
return new $this->backend;
|
121 |
+
}
|
122 |
+
}
|
lib/CashCloudApi/src/CashCloud/Api/Rest/CurlRequest.php
ADDED
@@ -0,0 +1,233 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php namespace CashCloud\Api\Rest;
|
2 |
+
|
3 |
+
use CashCloud\Api\Exception\CashCloudException;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Class CurlRequest
|
7 |
+
* @package CashCloud\Api\Rest
|
8 |
+
*/
|
9 |
+
class CurlRequest implements Request
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* @var string
|
13 |
+
*/
|
14 |
+
private $agent = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5';
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @var array
|
18 |
+
*/
|
19 |
+
protected $headers = array();
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @var string
|
23 |
+
*/
|
24 |
+
protected $url = null;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @var string
|
28 |
+
*/
|
29 |
+
protected $method = self::GET;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @var array
|
33 |
+
*/
|
34 |
+
protected $data = array();
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @var array|null
|
38 |
+
*/
|
39 |
+
protected $response = null;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @var string|null
|
43 |
+
*/
|
44 |
+
private $error;
|
45 |
+
/**
|
46 |
+
* @var int|null
|
47 |
+
*/
|
48 |
+
private $errorCode;
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @param string|null $url
|
52 |
+
*/
|
53 |
+
function __construct($url = null)
|
54 |
+
{
|
55 |
+
$this->url = $url;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* @param string $url
|
60 |
+
*/
|
61 |
+
public function setUrl($url)
|
62 |
+
{
|
63 |
+
$this->url = $url;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* @param string $method
|
68 |
+
* @throws \CashCloud\Api\Exception\CashCloudException
|
69 |
+
* @return int response code
|
70 |
+
*/
|
71 |
+
public function execute($method = self::GET)
|
72 |
+
{
|
73 |
+
if($this->getResponseCode() > 0) {
|
74 |
+
// already executed
|
75 |
+
return $this->getResponseCode();
|
76 |
+
}
|
77 |
+
|
78 |
+
if(is_null($this->url)) {
|
79 |
+
throw new CashCloudException("Empty API URL!");
|
80 |
+
}
|
81 |
+
|
82 |
+
$ch = curl_init($this->url);
|
83 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
84 |
+
curl_setopt($ch, CURLOPT_USERAGENT, $this->agent);
|
85 |
+
|
86 |
+
if($this->getMethod() == Request::POST) {
|
87 |
+
curl_setopt($ch, CURLOPT_URL, $this->url);
|
88 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->getData());
|
89 |
+
} else {
|
90 |
+
curl_setopt($ch, CURLOPT_URL, $this->url . '?' . http_build_query($this->getData()));
|
91 |
+
}
|
92 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->getFormattedHeaders());
|
93 |
+
|
94 |
+
$responseBody = curl_exec($ch);
|
95 |
+
$responseCode = 0;
|
96 |
+
$this->errorCode = curl_errno($ch);
|
97 |
+
$this->error = curl_error($ch);
|
98 |
+
|
99 |
+
if($responseBody) {
|
100 |
+
$responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
101 |
+
}
|
102 |
+
|
103 |
+
curl_close($ch);
|
104 |
+
|
105 |
+
$this->response = array('code' => $responseCode, 'body' => $responseBody);
|
106 |
+
|
107 |
+
return $this->getResponseCode();
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* @return array
|
112 |
+
*/
|
113 |
+
public function getFormattedHeaders()
|
114 |
+
{
|
115 |
+
$headers = array();
|
116 |
+
foreach ($this->getHeaders() as $header => $value) {
|
117 |
+
$headers[] = "{$header}:{$value}";
|
118 |
+
}
|
119 |
+
return $headers;
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* @param array|string $name
|
124 |
+
* @return array
|
125 |
+
*/
|
126 |
+
public function getHeaders($name = null)
|
127 |
+
{
|
128 |
+
if (is_null($name)) {
|
129 |
+
return $this->headers;
|
130 |
+
} else {
|
131 |
+
return $this->headers[$name];
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* @param string $name
|
137 |
+
* @param string $value
|
138 |
+
*/
|
139 |
+
public function setHeader($name, $value)
|
140 |
+
{
|
141 |
+
$this->headers[$name] = $value;
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* @return array
|
146 |
+
*/
|
147 |
+
public function getData()
|
148 |
+
{
|
149 |
+
return $this->data;
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* @param array $data
|
154 |
+
*/
|
155 |
+
public function setData($data)
|
156 |
+
{
|
157 |
+
$this->data = $data;
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* @return int
|
162 |
+
*/
|
163 |
+
public function post()
|
164 |
+
{
|
165 |
+
return $this->execute(self::POST);
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* @return int
|
170 |
+
*/
|
171 |
+
public function get()
|
172 |
+
{
|
173 |
+
return $this->execute(self::GET);
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* @return string
|
178 |
+
*/
|
179 |
+
public function getMethod()
|
180 |
+
{
|
181 |
+
return $this->method;
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* @param string $method
|
186 |
+
*/
|
187 |
+
public function setMethod($method)
|
188 |
+
{
|
189 |
+
$this->method = $method;
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* @param null $field
|
194 |
+
* @return mixed|object
|
195 |
+
*/
|
196 |
+
public function getJson($field = null)
|
197 |
+
{
|
198 |
+
$decoded = json_decode($this->getBody());
|
199 |
+
return is_null($field) ? $decoded : $decoded->{$field};
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* @return null|string
|
204 |
+
*/
|
205 |
+
public function getBody()
|
206 |
+
{
|
207 |
+
return is_null($this->response) ? null : $this->response['body'];
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* @return int|null
|
212 |
+
*/
|
213 |
+
public function getResponseCode()
|
214 |
+
{
|
215 |
+
return is_null($this->response) ? null : $this->response['code'];
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* @return string|null
|
220 |
+
*/
|
221 |
+
public function getError()
|
222 |
+
{
|
223 |
+
return $this->error;
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* @return int|null
|
228 |
+
*/
|
229 |
+
public function getErrorCode()
|
230 |
+
{
|
231 |
+
return $this->errorCode;
|
232 |
+
}
|
233 |
+
}
|
lib/CashCloudApi/src/CashCloud/Api/Rest/Request.php
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php namespace CashCloud\Api\Rest;
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Interface Request
|
5 |
+
* @package CashCloud\Api\Rest
|
6 |
+
*/
|
7 |
+
interface Request
|
8 |
+
{
|
9 |
+
const POST = "post";
|
10 |
+
const GET = "get";
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @return string
|
14 |
+
*/
|
15 |
+
public function getBody();
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @param string $name
|
19 |
+
* @param string $value
|
20 |
+
*/
|
21 |
+
public function setHeader($name, $value);
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @param array|string $name
|
25 |
+
* @return array
|
26 |
+
*/
|
27 |
+
public function getHeaders($name = null);
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @return string
|
31 |
+
*/
|
32 |
+
public function getMethod();
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @param string $field
|
36 |
+
* @return object
|
37 |
+
*/
|
38 |
+
public function getJson($field = null);
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @param array $data
|
42 |
+
*/
|
43 |
+
public function setData($data);
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @param string $url
|
47 |
+
*/
|
48 |
+
public function setUrl($url);
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @param string $method
|
52 |
+
*/
|
53 |
+
public function setMethod($method);
|
54 |
+
|
55 |
+
/**
|
56 |
+
* @return array
|
57 |
+
*/
|
58 |
+
public function getData();
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @return int
|
62 |
+
*/
|
63 |
+
public function getResponseCode();
|
64 |
+
|
65 |
+
/**
|
66 |
+
* @return string|null
|
67 |
+
*/
|
68 |
+
public function getError();
|
69 |
+
/**
|
70 |
+
* @return int|null
|
71 |
+
*/
|
72 |
+
public function getErrorCode();
|
73 |
+
|
74 |
+
/**
|
75 |
+
* @param string $method
|
76 |
+
* @return int response code
|
77 |
+
*/
|
78 |
+
public function execute($method = self::GET);
|
79 |
+
}
|
lib/CashCloudApi/tests/CashCloud/Test/Api/Exception/ValidateExceptionTest.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php namespace CashCloud\Test\Api\Exception;
|
2 |
+
use CashCloud\Api\Exception\ValidateException;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Class ValidationExceptionTest
|
6 |
+
* @package CashCloud\Test\Api\Exception
|
7 |
+
*/
|
8 |
+
class ValidateExceptionTest extends \CashCloud\Test\TestCase
|
9 |
+
{
|
10 |
+
public function testNoErrors()
|
11 |
+
{
|
12 |
+
$exception = new ValidateException([]);
|
13 |
+
$this->assertFalse($exception->getFirstError());
|
14 |
+
$this->assertEquals([], $exception->getErrors());
|
15 |
+
}
|
16 |
+
|
17 |
+
public function testSimpleError()
|
18 |
+
{
|
19 |
+
$exception = new ValidateException(['sampleError']);
|
20 |
+
$this->assertEquals('sampleError', $exception->getFirstError());
|
21 |
+
}
|
22 |
+
|
23 |
+
public function testMultipleErrors()
|
24 |
+
{
|
25 |
+
$exception = new ValidateException(['sampleError', 'secondError']);
|
26 |
+
$this->assertEquals('sampleError', $exception->getFirstError());
|
27 |
+
$this->assertEquals(['sampleError', 'secondError'], $exception->getErrors());
|
28 |
+
}
|
29 |
+
|
30 |
+
public function testErrorWithParam()
|
31 |
+
{
|
32 |
+
$exception = new ValidateException(['sampleError'=>false]);
|
33 |
+
$this->assertEquals('sampleError', $exception->getFirstError());
|
34 |
+
}
|
35 |
+
|
36 |
+
public function testErrorWithNamedParam()
|
37 |
+
{
|
38 |
+
$exception = new ValidateException(['sampleError'=>'oneError']);
|
39 |
+
$this->assertEquals('sampleError.oneError', $exception->getFirstError());
|
40 |
+
}
|
41 |
+
|
42 |
+
public function testErrorWithErrorsArray()
|
43 |
+
{
|
44 |
+
$exception = new ValidateException([['oneError', 'twoErrors']]);
|
45 |
+
$this->assertEquals('oneError', $exception->getFirstError());
|
46 |
+
}
|
47 |
+
|
48 |
+
public function testErrorWithParamAndMultipleErrors()
|
49 |
+
{
|
50 |
+
$exception = new ValidateException(['sampleError'=>['oneError', 'twoErrors']]);
|
51 |
+
$this->assertEquals('sampleError.oneError', $exception->getFirstError());
|
52 |
+
}
|
53 |
+
|
54 |
+
public function testErrorWithObjectParam()
|
55 |
+
{
|
56 |
+
$exception = new ValidateException([(object)['sampleError'=>'oneError']]);
|
57 |
+
$this->assertEquals('sampleError.oneError', $exception->getFirstError());
|
58 |
+
}
|
59 |
+
}
|
lib/CashCloudApi/tests/CashCloud/Test/Api/Method/GetRatesTest.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php namespace CashCloud\Test\Api\Method;
|
2 |
+
|
3 |
+
use CashCloud\Api\Method\GetRates;
|
4 |
+
use CashCloud\Test\TestCase;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Class GetCurrencyRatesTest
|
8 |
+
* @package CashCloud\Test\Api\Method
|
9 |
+
*/
|
10 |
+
class GetCurrencyRatesTest extends TestCase
|
11 |
+
{
|
12 |
+
public function testIncomplete()
|
13 |
+
{
|
14 |
+
$request = new GetRates();
|
15 |
+
$this->markTestIncomplete('Implement');
|
16 |
+
}
|
17 |
+
}
|
lib/CashCloudApi/tests/CashCloud/Test/Api/Method/GetReasonsTest.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* File GetReasonsTest.php
|
4 |
+
*
|
5 |
+
* @version GIT $Id$
|
6 |
+
* @package CashCloud\Test\Api\Method
|
7 |
+
*/
|
8 |
+
namespace CashCloud\Test\Api\Method;
|
9 |
+
use CashCloud\Api\Method\GetReasons;
|
10 |
+
use CashCloud\Test\TestCase;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Class GetReasonsTest
|
14 |
+
* @package CashCloud\Test\Api\Method
|
15 |
+
*/
|
16 |
+
class GetReasonsTest extends TestCase
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* @expectedException \CashCloud\Api\Exception\CashCloudException
|
20 |
+
*/
|
21 |
+
public function testGetReasonsReturnsString()
|
22 |
+
{
|
23 |
+
$request = new GetReasons($this->mockRequest(200, "xxx"));
|
24 |
+
$request->perform($this->getClient());
|
25 |
+
}
|
26 |
+
|
27 |
+
|
28 |
+
public function testGetReasonsReturnsEmpty()
|
29 |
+
{
|
30 |
+
$request = new GetReasons($this->mockRequest(200, json_encode(array(
|
31 |
+
'error'=>false,
|
32 |
+
'messages'=> array(),
|
33 |
+
))));
|
34 |
+
|
35 |
+
$response = $request->perform($this->getClient());
|
36 |
+
$this->assertEquals(array(), $response);
|
37 |
+
}
|
38 |
+
|
39 |
+
public function testGetReasonsReturnsArray()
|
40 |
+
{
|
41 |
+
$reasons = array(
|
42 |
+
"314" => "Electronics",
|
43 |
+
"315" => "Computer",
|
44 |
+
"316" => "Home Appliances",
|
45 |
+
"317" => "Grocery",
|
46 |
+
"318" => "Beverages",
|
47 |
+
);
|
48 |
+
|
49 |
+
$request = new GetReasons($this->mockRequest(200, json_encode(array(
|
50 |
+
'error'=>false,
|
51 |
+
'messages'=> $reasons,
|
52 |
+
))));
|
53 |
+
|
54 |
+
$response = $request->perform($this->getClient());
|
55 |
+
$this->assertEquals($reasons, $response);
|
56 |
+
}
|
57 |
+
}
|
lib/CashCloudApi/tests/CashCloud/Test/Api/Method/GetSettingsTest.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php namespace CashCloud\Test\Api\Method;
|
2 |
+
|
3 |
+
use CashCloud\Api\Method\GetSettings;
|
4 |
+
use CashCloud\Test\TestCase;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Class GetSettingsTest
|
8 |
+
* @package CashCloud\Test\Api\Method
|
9 |
+
*/
|
10 |
+
class GetSettingsTest extends TestCase
|
11 |
+
{
|
12 |
+
public function testIncomplete()
|
13 |
+
{
|
14 |
+
$request = new GetSettings();
|
15 |
+
$this->markTestIncomplete('Implement');
|
16 |
+
}
|
17 |
+
}
|
lib/CashCloudApi/tests/CashCloud/Test/Api/Method/RequestMoneyTest.php
ADDED
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php namespace CashCloud\Test\Api\Method;
|
2 |
+
|
3 |
+
use CashCloud\Api\Method\RequestMoney;
|
4 |
+
use CashCloud\Test\TestCase;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Class RequestMoneyTest
|
8 |
+
* @package CashCloud\Method
|
9 |
+
*/
|
10 |
+
class RequestMoneyTest extends TestCase
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* @expectedException \CashCloud\Api\Exception\CashCloudException
|
14 |
+
* @expectedExceptionMessage Unknown exception
|
15 |
+
*/
|
16 |
+
public function testUnknownCode()
|
17 |
+
{
|
18 |
+
$request = new RequestMoney($this->mockRequest(800, ""));
|
19 |
+
$request->setEmail("email");
|
20 |
+
$request->setCurrency("EUR");
|
21 |
+
$request->setAmount(10);
|
22 |
+
$request->perform($this->getClient());
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @expectedException \CashCloud\Api\Exception\CashCloudException
|
27 |
+
* @expectedExceptionMessage Invalid url
|
28 |
+
*/
|
29 |
+
public function test404Error()
|
30 |
+
{
|
31 |
+
$request = new RequestMoney($this->mockRequest(404, ""));
|
32 |
+
$request->setEmail("email");
|
33 |
+
$request->setCurrency("EUR");
|
34 |
+
$request->setAmount(10);
|
35 |
+
$request->perform($this->getClient());
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @expectedException \CashCloud\Api\Exception\AuthException
|
40 |
+
*/
|
41 |
+
public function testAuthError()
|
42 |
+
{
|
43 |
+
$request = new RequestMoney($this->mockRequest(403, ""));
|
44 |
+
$request->setEmail("email");
|
45 |
+
$request->setCurrency("EUR");
|
46 |
+
$request->setAmount(10);
|
47 |
+
$request->perform($this->getClient());
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @expectedException \CashCloud\Api\Exception\CashCloudException
|
52 |
+
*/
|
53 |
+
public function testServerError()
|
54 |
+
{
|
55 |
+
$request = new RequestMoney($this->mockRequest(500, ""));
|
56 |
+
$request->setEmail("email");
|
57 |
+
$request->setCurrency("EUR");
|
58 |
+
$request->setAmount(10);
|
59 |
+
$request->perform($this->getClient());
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @expectedException \CashCloud\Api\Exception\ValidateException
|
64 |
+
* @expectedExceptionMessage SendMoneyOptionBlocked
|
65 |
+
*/
|
66 |
+
public function testValidateError()
|
67 |
+
{
|
68 |
+
$request = new RequestMoney($this->mockRequest(412, json_encode(array(
|
69 |
+
'validationFailed'=>array(
|
70 |
+
"SendMoneyOptionBlocked",
|
71 |
+
"minAmountTransactionPerTradeLimit",
|
72 |
+
)
|
73 |
+
))));
|
74 |
+
$request->setEmail("email");
|
75 |
+
$request->setCurrency("EUR");
|
76 |
+
$request->setAmount(10);
|
77 |
+
$request->perform($this->getClient());
|
78 |
+
$this->markTestIncomplete("validation messages is not covered");
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* @expectedException \CashCloud\Api\Exception\CashCloudException
|
83 |
+
*/
|
84 |
+
public function testInvalidJSON()
|
85 |
+
{
|
86 |
+
$request = new RequestMoney($this->mockRequest(201, "XXXXXX"));
|
87 |
+
$request->setEmail("email");
|
88 |
+
$request->setCurrency("EUR");
|
89 |
+
$request->setAmount(10);
|
90 |
+
$request->perform($this->getClient());
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* @expectedException \CashCloud\Api\Exception\CashCloudException
|
95 |
+
*/
|
96 |
+
public function testInvalidNoHash()
|
97 |
+
{
|
98 |
+
$request = new RequestMoney($this->mockRequest(201, json_encode(array('error'=>false))));
|
99 |
+
$request->setEmail("email");
|
100 |
+
$request->setCurrency("EUR");
|
101 |
+
$request->setAmount(10);
|
102 |
+
$request->perform($this->getClient());
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* @expectedException \CashCloud\Api\Exception\CashCloudException
|
107 |
+
* @expectedExceptionMessage Invalid email!
|
108 |
+
*/
|
109 |
+
public function testEmailMustBeSet()
|
110 |
+
{
|
111 |
+
$request = new RequestMoney();
|
112 |
+
$request->setAmount(10);
|
113 |
+
$request->setCurrency('EUR');
|
114 |
+
$response = $request->perform($this->getClient());
|
115 |
+
$this->assertEquals('1123456', $response->hash);
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* @expectedException \CashCloud\Api\Exception\CashCloudException
|
120 |
+
* @expectedExceptionMessage Invalid currency!
|
121 |
+
*/
|
122 |
+
public function testCurrencyMustBeSet()
|
123 |
+
{
|
124 |
+
$request = new RequestMoney();
|
125 |
+
$request->setEmail("email");
|
126 |
+
$request->setAmount(10);
|
127 |
+
$response = $request->perform($this->getClient());
|
128 |
+
$this->assertEquals('1123456', $response->hash);
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* @expectedException \CashCloud\Api\Exception\CashCloudException
|
133 |
+
* @expectedExceptionMessage Invalid currency!
|
134 |
+
*/
|
135 |
+
public function testCurrencyInvalid()
|
136 |
+
{
|
137 |
+
$request = new RequestMoney();
|
138 |
+
$request->setCurrency("USD");
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* @expectedException \CashCloud\Api\Exception\CashCloudException
|
143 |
+
* @expectedExceptionMessage Invalid amount!
|
144 |
+
*/
|
145 |
+
public function testAmountMustBeSet()
|
146 |
+
{
|
147 |
+
$request = new RequestMoney($this->mockRequest(201, json_encode(array('hash'=>'1123456'))));
|
148 |
+
$request->setEmail("email");
|
149 |
+
$request->setCurrency('EUR');
|
150 |
+
$response = $request->perform($this->getClient());
|
151 |
+
$this->assertEquals('1123456', $response->hash);
|
152 |
+
}
|
153 |
+
|
154 |
+
public function testGotHash()
|
155 |
+
{
|
156 |
+
$request = new RequestMoney($this->mockRequest(201, json_encode(array('hash'=>'1123456'))));
|
157 |
+
$request->setEmail("email");
|
158 |
+
$request->setCurrency("EUR");
|
159 |
+
$request->setAmount(10);
|
160 |
+
|
161 |
+
$response = $request->perform($this->getClient());
|
162 |
+
$this->assertEquals('1123456', $response->hash);
|
163 |
+
|
164 |
+
}
|
165 |
+
|
166 |
+
public function testAttribtuesAreSet()
|
167 |
+
{
|
168 |
+
$request = new RequestMoney($this->mockRequest(201, json_encode(array('hash'=>'1123456'))));
|
169 |
+
$request->setCurrency("EUR");
|
170 |
+
$request->setEmail("email");
|
171 |
+
$request->setAmount(10);
|
172 |
+
$request->setReason(12);
|
173 |
+
$request->setRemark("remark");
|
174 |
+
$request->setExternalData("xx", "xx", "desc");
|
175 |
+
$this->assertEquals(array (
|
176 |
+
'email' => "email",
|
177 |
+
'amount' => 10,
|
178 |
+
'currency' => 'EUR',
|
179 |
+
'reason_id' => 12,
|
180 |
+
'remark' => 'remark',
|
181 |
+
'extern.id' => 'xx',
|
182 |
+
'extern.reference' => 'xx',
|
183 |
+
'extern.description' => 'desc',
|
184 |
+
), $request->getData());
|
185 |
+
}
|
186 |
+
}
|
lib/CashCloudApi/tests/CashCloud/Test/Api/Method/SaveSettingsTest.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php namespace CashCloud\Test\Api\Method;
|
2 |
+
|
3 |
+
use CashCloud\Api\Method\SaveSettings;
|
4 |
+
use CashCloud\Test\TestCase;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Class SaveSettingsTest
|
8 |
+
* @package CashCloud\Test\Api\Method
|
9 |
+
*/
|
10 |
+
class SaveSettingsTest extends TestCase
|
11 |
+
{
|
12 |
+
public function testIncomplete()
|
13 |
+
{
|
14 |
+
$request = new SaveSettings();
|
15 |
+
$this->markTestIncomplete('Implement');
|
16 |
+
}
|
17 |
+
}
|
lib/CashCloudApi/tests/CashCloud/Test/Api/Rest/AuthTest.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php namespace CashCloud\Test\Api\Rest;
|
2 |
+
use CashCloud\Api\Rest\Auth;
|
3 |
+
use CashCloud\Api\Rest\CurlRequest;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Class AuthTest
|
7 |
+
* @package CashCloud\Test\Api\Rest
|
8 |
+
*/
|
9 |
+
class AuthTest extends \PHPUnit_Framework_TestCase
|
10 |
+
{
|
11 |
+
public function testHeaderIsSet()
|
12 |
+
{
|
13 |
+
/** @var \CashCloud\Api\Rest\CurlRequest $request */
|
14 |
+
$auth = new Auth("email", "pass", "devId");
|
15 |
+
$api = $this->getMock('CashCloud\Api\Rest\Client', ['getSalt'], [$auth]);
|
16 |
+
$api->expects($this->any())->method('getSalt')->will($this->returnValue('salt'));
|
17 |
+
$request = new CurlRequest();
|
18 |
+
$auth->authorizeRequest($api, $request);
|
19 |
+
$headers = $request->getHeaders();
|
20 |
+
$this->assertArrayHasKey('Authorization', $headers);
|
21 |
+
return $request;
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @depends testHeaderIsSet
|
26 |
+
* @param CurlRequest $request
|
27 |
+
*/
|
28 |
+
public function testAuthorizationToken(CurlRequest $request)
|
29 |
+
{
|
30 |
+
$hash = "Token ZW1haWx8ZGV2SWR8M2E0ZmZhOTE3NWE2OTJjMWZmNWVkZDNkOTAyYzdkMDY=";
|
31 |
+
$this->assertEquals($hash, $request->getHeaders('Authorization'));
|
32 |
+
}
|
33 |
+
|
34 |
+
public function testDeviceIdIsSetIfLeftEmpty()
|
35 |
+
{
|
36 |
+
$auth = new Auth("email", "password");
|
37 |
+
$deviceId = $auth->getDeviceId();
|
38 |
+
$this->assertNotEmpty($deviceId, "If left empty, device ID should be generated");
|
39 |
+
$this->assertEquals($deviceId, $auth->getDeviceId(), "Device ID regenerated when asking it second time");
|
40 |
+
}
|
41 |
+
}
|
lib/CashCloudApi/tests/CashCloud/Test/Api/Rest/ClientTest.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* File ClientTest.php
|
4 |
+
*
|
5 |
+
* @version GIT $Id$
|
6 |
+
* @package CashCloud\Test\Api\Rest
|
7 |
+
*/
|
8 |
+
namespace CashCloud\Test\Api\Rest;
|
9 |
+
use CashCloud\Api\Rest\Auth;
|
10 |
+
use CashCloud\Api\Rest\Client;
|
11 |
+
use CashCloud\Api\Rest\CurlRequest;
|
12 |
+
use CashCloud\Test\TestCase;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Class ClientTest
|
16 |
+
* @package CashCloud\Test\Api\Rest
|
17 |
+
*/
|
18 |
+
class ClientTest extends TestCase
|
19 |
+
{
|
20 |
+
/**
|
21 |
+
* @expectedException \CashCloud\Api\Exception\AuthException
|
22 |
+
*/
|
23 |
+
public function testGetSaltThrowsExceptionOnBadResponseCode()
|
24 |
+
{
|
25 |
+
$client = new Client(new Auth("email", "pass"));
|
26 |
+
$client->getSalt($this->mockRequest(403, ""));
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @expectedException \CashCloud\Api\Exception\AuthException
|
31 |
+
*/
|
32 |
+
public function testGetSaltThrowsExceptionOnMallformedJSON()
|
33 |
+
{
|
34 |
+
$client = new Client(new Auth("email", "pass"));
|
35 |
+
$client->getSalt($this->mockRequest(200, "xxx"));
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @expectedException \CashCloud\Api\Exception\AuthException
|
40 |
+
*/
|
41 |
+
public function testGetSaltThrowsExceptionOnIncorrectJSON()
|
42 |
+
{
|
43 |
+
$client = new Client(new Auth("email", "pass"));
|
44 |
+
$client->getSalt($this->mockRequest(200, '{"error":false, "nosalt": "xxxx"}'));
|
45 |
+
}
|
46 |
+
|
47 |
+
public function testGetSaltOk()
|
48 |
+
{
|
49 |
+
$client = new Client(new Auth("email", "pass"));
|
50 |
+
$salt = $client->getSalt($this->mockRequest(200, '{"error":false, "salt": "xxxx"}'));
|
51 |
+
$this->assertEquals('xxxx', $salt);
|
52 |
+
}
|
53 |
+
|
54 |
+
public function testRequestIsAuthorized()
|
55 |
+
{
|
56 |
+
$client = new Client(new Auth("email", "pass"), "salt");
|
57 |
+
$request = new CurlRequest();
|
58 |
+
$client->authorizeRequest($request);
|
59 |
+
$this->assertArrayHasKey("Authorization", $request->getHeaders());
|
60 |
+
}
|
61 |
+
}
|
lib/CashCloudApi/tests/CashCloud/Test/Api/Rest/CurlRequestTest.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php namespace CashCloud\Test\Api\Rest;
|
2 |
+
|
3 |
+
use CashCloud\Api\Rest\CurlRequest;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Class CurlRequest
|
7 |
+
* @package CashCloud\Test\Api\Rest
|
8 |
+
*/
|
9 |
+
class CurlRequestTest extends \CashCloud\Test\TestCase
|
10 |
+
{
|
11 |
+
public function testHeadersFormat()
|
12 |
+
{
|
13 |
+
$request = new CurlRequest();
|
14 |
+
$request->setHeader("Test", "*");
|
15 |
+
$this->assertEquals(['Test:*'], $request->getFormattedHeaders());
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @expectedException \CashCloud\Api\Exception\CashCloudException
|
20 |
+
*/
|
21 |
+
public function testEmptyUrl()
|
22 |
+
{
|
23 |
+
$request = new CurlRequest();
|
24 |
+
$request->execute();
|
25 |
+
}
|
26 |
+
|
27 |
+
public function testEmptyResponse()
|
28 |
+
{
|
29 |
+
$request = new CurlRequest();
|
30 |
+
$this->assertNull($request->getBody());
|
31 |
+
$this->assertNull($request->getResponseCode());
|
32 |
+
}
|
33 |
+
|
34 |
+
public function testDoNotExecuteSecondTime()
|
35 |
+
{
|
36 |
+
$request = $this->mockRequest(array('getResponseCode'));
|
37 |
+
$request->expects($this->any())->method('getResponseCode')->will($this->returnValue(200));
|
38 |
+
$this->assertEquals(200, $request->execute(), 'Mocking failed?');
|
39 |
+
$this->assertEquals(200, $request->execute(), 'Should not execute request');
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* @param array $methods
|
44 |
+
* @return CurlRequest|\PHPUnit_Framework_MockObject_MockObject
|
45 |
+
*/
|
46 |
+
public function mockRequest($methods = array())
|
47 |
+
{
|
48 |
+
return $this->getMock('CashCloud\Api\Rest\CurlRequest', $methods);
|
49 |
+
}
|
50 |
+
}
|
lib/CashCloudApi/tests/CashCloud/Test/TestCase.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* File TestCase.php
|
4 |
+
*
|
5 |
+
* @version GIT $Id$
|
6 |
+
* @package CashCloud\Test
|
7 |
+
*/
|
8 |
+
namespace CashCloud\Test;
|
9 |
+
use CashCloud\Api\Rest\Auth;
|
10 |
+
use CashCloud\Api\Rest\Client;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Class TestCase
|
14 |
+
* @package CashCloud\Test
|
15 |
+
*/
|
16 |
+
abstract class TestCase extends \PHPUnit_Framework_TestCase
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* @param integer $responseCode
|
20 |
+
* @param string $responseBody
|
21 |
+
* @return \PHPUnit_Framework_MockObject_MockObject|\CashCloud\Api\Rest\CurlRequest
|
22 |
+
*/
|
23 |
+
protected function mockRequest($responseCode, $responseBody)
|
24 |
+
{
|
25 |
+
$mock = $this->getMock('CashCloud\Api\Rest\CurlRequest', ['getResponseCode', 'getBody']);
|
26 |
+
$mock->expects($this->any())->method('getResponseCode')->will($this->returnValue($responseCode));
|
27 |
+
$mock->expects($this->any())->method('getBody')->will($this->returnValue($responseBody));
|
28 |
+
return $mock;
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @return Client
|
33 |
+
*/
|
34 |
+
public function getClient()
|
35 |
+
{
|
36 |
+
return new Client(new Auth("pass", "user"), "salt");
|
37 |
+
}
|
38 |
+
}
|
lib/CashCloudApi/tests/bootstrap.php
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Include the composer autoloader
|
3 |
+
$loader = require dirname(__DIR__) . '/vendor/autoload.php';
|
4 |
+
$loader->add('CashCloud\\Test', __DIR__);
|
lib/CashCloudApi/vendor/autoload.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload.php @generated by Composer
|
4 |
+
|
5 |
+
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
6 |
+
|
7 |
+
return ComposerAutoloaderInit454a2b2f06d5af3fb00888bd095cd4a6::getLoader();
|
lib/CashCloudApi/vendor/composer/ClassLoader.php
ADDED
@@ -0,0 +1,364 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* This file is part of Composer.
|
5 |
+
*
|
6 |
+
* (c) Nils Adermann <naderman@naderman.de>
|
7 |
+
* Jordi Boggiano <j.boggiano@seld.be>
|
8 |
+
*
|
9 |
+
* For the full copyright and license information, please view the LICENSE
|
10 |
+
* file that was distributed with this source code.
|
11 |
+
*/
|
12 |
+
|
13 |
+
namespace Composer\Autoload;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* ClassLoader implements a PSR-0 class loader
|
17 |
+
*
|
18 |
+
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
|
19 |
+
*
|
20 |
+
* $loader = new \Composer\Autoload\ClassLoader();
|
21 |
+
*
|
22 |
+
* // register classes with namespaces
|
23 |
+
* $loader->add('Symfony\Component', __DIR__.'/component');
|
24 |
+
* $loader->add('Symfony', __DIR__.'/framework');
|
25 |
+
*
|
26 |
+
* // activate the autoloader
|
27 |
+
* $loader->register();
|
28 |
+
*
|
29 |
+
* // to enable searching the include path (eg. for PEAR packages)
|
30 |
+
* $loader->setUseIncludePath(true);
|
31 |
+
*
|
32 |
+
* In this example, if you try to use a class in the Symfony\Component
|
33 |
+
* namespace or one of its children (Symfony\Component\Console for instance),
|
34 |
+
* the autoloader will first look for the class under the component/
|
35 |
+
* directory, and it will then fallback to the framework/ directory if not
|
36 |
+
* found before giving up.
|
37 |
+
*
|
38 |
+
* This class is loosely based on the Symfony UniversalClassLoader.
|
39 |
+
*
|
40 |
+
* @author Fabien Potencier <fabien@symfony.com>
|
41 |
+
* @author Jordi Boggiano <j.boggiano@seld.be>
|
42 |
+
*/
|
43 |
+
class ClassLoader
|
44 |
+
{
|
45 |
+
// PSR-4
|
46 |
+
private $prefixLengthsPsr4 = array();
|
47 |
+
private $prefixDirsPsr4 = array();
|
48 |
+
private $fallbackDirsPsr4 = array();
|
49 |
+
|
50 |
+
// PSR-0
|
51 |
+
private $prefixesPsr0 = array();
|
52 |
+
private $fallbackDirsPsr0 = array();
|
53 |
+
|
54 |
+
private $useIncludePath = false;
|
55 |
+
private $classMap = array();
|
56 |
+
|
57 |
+
public function getPrefixes()
|
58 |
+
{
|
59 |
+
return call_user_func_array('array_merge', $this->prefixesPsr0);
|
60 |
+
}
|
61 |
+
|
62 |
+
public function getPrefixesPsr4()
|
63 |
+
{
|
64 |
+
return $this->prefixDirsPsr4;
|
65 |
+
}
|
66 |
+
|
67 |
+
public function getFallbackDirs()
|
68 |
+
{
|
69 |
+
return $this->fallbackDirsPsr0;
|
70 |
+
}
|
71 |
+
|
72 |
+
public function getFallbackDirsPsr4()
|
73 |
+
{
|
74 |
+
return $this->fallbackDirsPsr4;
|
75 |
+
}
|
76 |
+
|
77 |
+
public function getClassMap()
|
78 |
+
{
|
79 |
+
return $this->classMap;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @param array $classMap Class to filename map
|
84 |
+
*/
|
85 |
+
public function addClassMap(array $classMap)
|
86 |
+
{
|
87 |
+
if ($this->classMap) {
|
88 |
+
$this->classMap = array_merge($this->classMap, $classMap);
|
89 |
+
} else {
|
90 |
+
$this->classMap = $classMap;
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Registers a set of PSR-0 directories for a given prefix, either
|
96 |
+
* appending or prepending to the ones previously set for this prefix.
|
97 |
+
*
|
98 |
+
* @param string $prefix The prefix
|
99 |
+
* @param array|string $paths The PSR-0 root directories
|
100 |
+
* @param bool $prepend Whether to prepend the directories
|
101 |
+
*/
|
102 |
+
public function add($prefix, $paths, $prepend = false)
|
103 |
+
{
|
104 |
+
if (!$prefix) {
|
105 |
+
if ($prepend) {
|
106 |
+
$this->fallbackDirsPsr0 = array_merge(
|
107 |
+
(array) $paths,
|
108 |
+
$this->fallbackDirsPsr0
|
109 |
+
);
|
110 |
+
} else {
|
111 |
+
$this->fallbackDirsPsr0 = array_merge(
|
112 |
+
$this->fallbackDirsPsr0,
|
113 |
+
(array) $paths
|
114 |
+
);
|
115 |
+
}
|
116 |
+
|
117 |
+
return;
|
118 |
+
}
|
119 |
+
|
120 |
+
$first = $prefix[0];
|
121 |
+
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
122 |
+
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
123 |
+
|
124 |
+
return;
|
125 |
+
}
|
126 |
+
if ($prepend) {
|
127 |
+
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
128 |
+
(array) $paths,
|
129 |
+
$this->prefixesPsr0[$first][$prefix]
|
130 |
+
);
|
131 |
+
} else {
|
132 |
+
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
133 |
+
$this->prefixesPsr0[$first][$prefix],
|
134 |
+
(array) $paths
|
135 |
+
);
|
136 |
+
}
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Registers a set of PSR-4 directories for a given namespace, either
|
141 |
+
* appending or prepending to the ones previously set for this namespace.
|
142 |
+
*
|
143 |
+
* @param string $prefix The prefix/namespace, with trailing '\\'
|
144 |
+
* @param array|string $paths The PSR-0 base directories
|
145 |
+
* @param bool $prepend Whether to prepend the directories
|
146 |
+
*/
|
147 |
+
public function addPsr4($prefix, $paths, $prepend = false)
|
148 |
+
{
|
149 |
+
if (!$prefix) {
|
150 |
+
// Register directories for the root namespace.
|
151 |
+
if ($prepend) {
|
152 |
+
$this->fallbackDirsPsr4 = array_merge(
|
153 |
+
(array) $paths,
|
154 |
+
$this->fallbackDirsPsr4
|
155 |
+
);
|
156 |
+
} else {
|
157 |
+
$this->fallbackDirsPsr4 = array_merge(
|
158 |
+
$this->fallbackDirsPsr4,
|
159 |
+
(array) $paths
|
160 |
+
);
|
161 |
+
}
|
162 |
+
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
163 |
+
// Register directories for a new namespace.
|
164 |
+
$length = strlen($prefix);
|
165 |
+
if ('\\' !== $prefix[$length - 1]) {
|
166 |
+
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
167 |
+
}
|
168 |
+
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
169 |
+
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
170 |
+
} elseif ($prepend) {
|
171 |
+
// Prepend directories for an already registered namespace.
|
172 |
+
$this->prefixDirsPsr4[$prefix] = array_merge(
|
173 |
+
(array) $paths,
|
174 |
+
$this->prefixDirsPsr4[$prefix]
|
175 |
+
);
|
176 |
+
} else {
|
177 |
+
// Append directories for an already registered namespace.
|
178 |
+
$this->prefixDirsPsr4[$prefix] = array_merge(
|
179 |
+
$this->prefixDirsPsr4[$prefix],
|
180 |
+
(array) $paths
|
181 |
+
);
|
182 |
+
}
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Registers a set of PSR-0 directories for a given prefix,
|
187 |
+
* replacing any others previously set for this prefix.
|
188 |
+
*
|
189 |
+
* @param string $prefix The prefix
|
190 |
+
* @param array|string $paths The PSR-0 base directories
|
191 |
+
*/
|
192 |
+
public function set($prefix, $paths)
|
193 |
+
{
|
194 |
+
if (!$prefix) {
|
195 |
+
$this->fallbackDirsPsr0 = (array) $paths;
|
196 |
+
} else {
|
197 |
+
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Registers a set of PSR-4 directories for a given namespace,
|
203 |
+
* replacing any others previously set for this namespace.
|
204 |
+
*
|
205 |
+
* @param string $prefix The prefix/namespace, with trailing '\\'
|
206 |
+
* @param array|string $paths The PSR-4 base directories
|
207 |
+
*/
|
208 |
+
public function setPsr4($prefix, $paths) {
|
209 |
+
if (!$prefix) {
|
210 |
+
$this->fallbackDirsPsr4 = (array) $paths;
|
211 |
+
} else {
|
212 |
+
$length = strlen($prefix);
|
213 |
+
if ('\\' !== $prefix[$length - 1]) {
|
214 |
+
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
215 |
+
}
|
216 |
+
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
217 |
+
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
218 |
+
}
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Turns on searching the include path for class files.
|
223 |
+
*
|
224 |
+
* @param bool $useIncludePath
|
225 |
+
*/
|
226 |
+
public function setUseIncludePath($useIncludePath)
|
227 |
+
{
|
228 |
+
$this->useIncludePath = $useIncludePath;
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Can be used to check if the autoloader uses the include path to check
|
233 |
+
* for classes.
|
234 |
+
*
|
235 |
+
* @return bool
|
236 |
+
*/
|
237 |
+
public function getUseIncludePath()
|
238 |
+
{
|
239 |
+
return $this->useIncludePath;
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Registers this instance as an autoloader.
|
244 |
+
*
|
245 |
+
* @param bool $prepend Whether to prepend the autoloader or not
|
246 |
+
*/
|
247 |
+
public function register($prepend = false)
|
248 |
+
{
|
249 |
+
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
250 |
+
}
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Unregisters this instance as an autoloader.
|
254 |
+
*/
|
255 |
+
public function unregister()
|
256 |
+
{
|
257 |
+
spl_autoload_unregister(array($this, 'loadClass'));
|
258 |
+
}
|
259 |
+
|
260 |
+
/**
|
261 |
+
* Loads the given class or interface.
|
262 |
+
*
|
263 |
+
* @param string $class The name of the class
|
264 |
+
* @return bool|null True if loaded, null otherwise
|
265 |
+
*/
|
266 |
+
public function loadClass($class)
|
267 |
+
{
|
268 |
+
if ($file = $this->findFile($class)) {
|
269 |
+
includeFile($file);
|
270 |
+
|
271 |
+
return true;
|
272 |
+
}
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* Finds the path to the file where the class is defined.
|
277 |
+
*
|
278 |
+
* @param string $class The name of the class
|
279 |
+
*
|
280 |
+
* @return string|false The path if found, false otherwise
|
281 |
+
*/
|
282 |
+
public function findFile($class)
|
283 |
+
{
|
284 |
+
// work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
|
285 |
+
if ('\\' == $class[0]) {
|
286 |
+
$class = substr($class, 1);
|
287 |
+
}
|
288 |
+
|
289 |
+
// class map lookup
|
290 |
+
if (isset($this->classMap[$class])) {
|
291 |
+
return $this->classMap[$class];
|
292 |
+
}
|
293 |
+
|
294 |
+
// PSR-4 lookup
|
295 |
+
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . '.php';
|
296 |
+
|
297 |
+
$first = $class[0];
|
298 |
+
if (isset($this->prefixLengthsPsr4[$first])) {
|
299 |
+
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
|
300 |
+
if (0 === strpos($class, $prefix)) {
|
301 |
+
foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
|
302 |
+
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
|
303 |
+
return $file;
|
304 |
+
}
|
305 |
+
}
|
306 |
+
}
|
307 |
+
}
|
308 |
+
}
|
309 |
+
|
310 |
+
// PSR-4 fallback dirs
|
311 |
+
foreach ($this->fallbackDirsPsr4 as $dir) {
|
312 |
+
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
313 |
+
return $file;
|
314 |
+
}
|
315 |
+
}
|
316 |
+
|
317 |
+
// PSR-0 lookup
|
318 |
+
if (false !== $pos = strrpos($class, '\\')) {
|
319 |
+
// namespaced class name
|
320 |
+
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
321 |
+
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
322 |
+
} else {
|
323 |
+
// PEAR-like class name
|
324 |
+
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . '.php';
|
325 |
+
}
|
326 |
+
|
327 |
+
if (isset($this->prefixesPsr0[$first])) {
|
328 |
+
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
329 |
+
if (0 === strpos($class, $prefix)) {
|
330 |
+
foreach ($dirs as $dir) {
|
331 |
+
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
332 |
+
return $file;
|
333 |
+
}
|
334 |
+
}
|
335 |
+
}
|
336 |
+
}
|
337 |
+
}
|
338 |
+
|
339 |
+
// PSR-0 fallback dirs
|
340 |
+
foreach ($this->fallbackDirsPsr0 as $dir) {
|
341 |
+
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
342 |
+
return $file;
|
343 |
+
}
|
344 |
+
}
|
345 |
+
|
346 |
+
// PSR-0 include paths.
|
347 |
+
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
348 |
+
return $file;
|
349 |
+
}
|
350 |
+
|
351 |
+
// Remember that this class does not exist.
|
352 |
+
return $this->classMap[$class] = false;
|
353 |
+
}
|
354 |
+
}
|
355 |
+
|
356 |
+
/**
|
357 |
+
* Scope isolated include.
|
358 |
+
*
|
359 |
+
* Prevents access to $this/self from included files.
|
360 |
+
*/
|
361 |
+
function includeFile($file)
|
362 |
+
{
|
363 |
+
include $file;
|
364 |
+
}
|
lib/CashCloudApi/vendor/composer/autoload_classmap.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload_classmap.php @generated by Composer
|
4 |
+
|
5 |
+
$vendorDir = dirname(dirname(__FILE__));
|
6 |
+
$baseDir = dirname($vendorDir);
|
7 |
+
|
8 |
+
return array(
|
9 |
+
);
|
lib/CashCloudApi/vendor/composer/autoload_namespaces.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload_namespaces.php @generated by Composer
|
4 |
+
|
5 |
+
$vendorDir = dirname(dirname(__FILE__));
|
6 |
+
$baseDir = dirname($vendorDir);
|
7 |
+
|
8 |
+
return array(
|
9 |
+
'CashCloud' => array($baseDir . '/src'),
|
10 |
+
);
|
lib/CashCloudApi/vendor/composer/autoload_psr4.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload_psr4.php @generated by Composer
|
4 |
+
|
5 |
+
$vendorDir = dirname(dirname(__FILE__));
|
6 |
+
$baseDir = dirname($vendorDir);
|
7 |
+
|
8 |
+
return array(
|
9 |
+
);
|
lib/CashCloudApi/vendor/composer/autoload_real.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// autoload_real.php @generated by Composer
|
4 |
+
|
5 |
+
class ComposerAutoloaderInit454a2b2f06d5af3fb00888bd095cd4a6
|
6 |
+
{
|
7 |
+
private static $loader;
|
8 |
+
|
9 |
+
public static function loadClassLoader($class)
|
10 |
+
{
|
11 |
+
if ('Composer\Autoload\ClassLoader' === $class) {
|
12 |
+
require __DIR__ . '/ClassLoader.php';
|
13 |
+
}
|
14 |
+
}
|
15 |
+
|
16 |
+
public static function getLoader()
|
17 |
+
{
|
18 |
+
if (null !== self::$loader) {
|
19 |
+
return self::$loader;
|
20 |
+
}
|
21 |
+
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInit454a2b2f06d5af3fb00888bd095cd4a6', 'loadClassLoader'), true, true);
|
23 |
+
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit454a2b2f06d5af3fb00888bd095cd4a6', 'loadClassLoader'));
|
25 |
+
|
26 |
+
$vendorDir = dirname(__DIR__);
|
27 |
+
$baseDir = dirname($vendorDir);
|
28 |
+
|
29 |
+
$map = require __DIR__ . '/autoload_namespaces.php';
|
30 |
+
foreach ($map as $namespace => $path) {
|
31 |
+
$loader->set($namespace, $path);
|
32 |
+
}
|
33 |
+
|
34 |
+
$map = require __DIR__ . '/autoload_psr4.php';
|
35 |
+
foreach ($map as $namespace => $path) {
|
36 |
+
$loader->setPsr4($namespace, $path);
|
37 |
+
}
|
38 |
+
|
39 |
+
$classMap = require __DIR__ . '/autoload_classmap.php';
|
40 |
+
if ($classMap) {
|
41 |
+
$loader->addClassMap($classMap);
|
42 |
+
}
|
43 |
+
|
44 |
+
$loader->register(true);
|
45 |
+
|
46 |
+
return $loader;
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
function composerRequire454a2b2f06d5af3fb00888bd095cd4a6($file)
|
51 |
+
{
|
52 |
+
require $file;
|
53 |
+
}
|
package.xml
ADDED
@@ -0,0 +1,276 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>cashcloud_payments</name>
|
4 |
+
<version>0.0.1</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://creativecommons.org/licenses/by/4.0/">
|
7 |
+
Creative Commons Attribution 4.0 International
|
8 |
+
License</license>
|
9 |
+
<channel>community</channel>
|
10 |
+
<extends />
|
11 |
+
<summary>CashCloud payments</summary>
|
12 |
+
<description>This extension adds CashCloud payment
|
13 |
+
methods</description>
|
14 |
+
<notes>This extension adds CashCloud payment methods</notes>
|
15 |
+
<authors>
|
16 |
+
<author>
|
17 |
+
<name>cashcloud</name>
|
18 |
+
<user>cashcloud</user>
|
19 |
+
<email>olaf.taupitz@cashcloud.com</email>
|
20 |
+
</author>
|
21 |
+
</authors>
|
22 |
+
<date>2014-04-08</date>
|
23 |
+
<time>11:04:01</time>
|
24 |
+
<contents>
|
25 |
+
<target name="magelocal">
|
26 |
+
<dir name="Mage">
|
27 |
+
<dir name="CashCloud">
|
28 |
+
<dir name="Block">
|
29 |
+
<file name="Form.php"
|
30 |
+
hash="d3ef5077816a2f508b3a7da7e80c3c6f" />
|
31 |
+
<file name="Process.php"
|
32 |
+
hash="1ddd06b620ce06c27510dfed0a7c477b" />
|
33 |
+
<file name="Info.php"
|
34 |
+
hash="4b22b99be40392e2adb7bdec86b7ad74" />
|
35 |
+
</dir>
|
36 |
+
<dir name="Model">
|
37 |
+
<dir name="Mysql4">
|
38 |
+
<file name="Setup.php"
|
39 |
+
hash="295e6757cc76c40fa261e2ddd3913cd3" />
|
40 |
+
</dir>
|
41 |
+
<file name="PaymentMethod.php"
|
42 |
+
hash="7f970fb0d25c4eb6d8cadc1b97525a1c" />
|
43 |
+
</dir>
|
44 |
+
<dir name="sql">
|
45 |
+
<dir name="cashcloud_setup">
|
46 |
+
<file name="mysql4-install-0.0.1.php"
|
47 |
+
hash="50b96b7c003ab0c754f1e128cdab04ad" />
|
48 |
+
</dir>
|
49 |
+
</dir>
|
50 |
+
<dir name="Adminhtml">
|
51 |
+
<dir name="Model">
|
52 |
+
<file name="Config.php"
|
53 |
+
hash="473fad0327a658612816993c22dc0614" />
|
54 |
+
<file name="Checks.php"
|
55 |
+
hash="0927945f60fd1b13f16b55156b8445de" />
|
56 |
+
<file name="Expiration.php"
|
57 |
+
hash="ee5862cd87523a727b91841364ddc41a" />
|
58 |
+
<file name="Reason.php"
|
59 |
+
hash="93265ecf40c4283b00d1eff9abfb09b6" />
|
60 |
+
</dir>
|
61 |
+
</dir>
|
62 |
+
<dir name="Helper">
|
63 |
+
<file name="Data.php"
|
64 |
+
hash="341c8d49beec9f37d97ae7433cad4726" />
|
65 |
+
</dir>
|
66 |
+
<dir name="controllers">
|
67 |
+
<file name="PayController.php"
|
68 |
+
hash="3cff4207fa9bd237dec13dda00a57c69" />
|
69 |
+
</dir>
|
70 |
+
<dir name="etc">
|
71 |
+
<file name="config.xml"
|
72 |
+
hash="e9c0749a5890f83dd7a4f69e56a36338" />
|
73 |
+
<file name="system.xml"
|
74 |
+
hash="67188821ef5177363deab0aa78c37237" />
|
75 |
+
</dir>
|
76 |
+
</dir>
|
77 |
+
</dir>
|
78 |
+
</target>
|
79 |
+
<target name="mageetc">
|
80 |
+
<dir name="modules">
|
81 |
+
<file name="Mage_CashCloud.xml"
|
82 |
+
hash="29b871aff1556810277f8a7b6048f20b" />
|
83 |
+
</dir>
|
84 |
+
</target>
|
85 |
+
<target name="magedesign">
|
86 |
+
<dir name="frontend">
|
87 |
+
<dir name="base">
|
88 |
+
<dir name="default">
|
89 |
+
<dir name="template">
|
90 |
+
<dir name="cashcloud">
|
91 |
+
<file name="form.phtml"
|
92 |
+
hash="f135a08dd235baba859990e95df3f22e" />
|
93 |
+
<file name="process.phtml"
|
94 |
+
hash="710854e31bb803b87624f0d837a9c2f7" />
|
95 |
+
<file name="info.phtml"
|
96 |
+
hash="d00f05fe6004a057beff737d7168d7e4" />
|
97 |
+
</dir>
|
98 |
+
</dir>
|
99 |
+
</dir>
|
100 |
+
</dir>
|
101 |
+
</dir>
|
102 |
+
<dir name="adminhtml">
|
103 |
+
<dir name="default">
|
104 |
+
<dir name="default">
|
105 |
+
<dir name="template">
|
106 |
+
<dir name="cashcloud">
|
107 |
+
<file name="checks.phtml"
|
108 |
+
hash="ce871438d50046b5bf01632287bb113a" />
|
109 |
+
</dir>
|
110 |
+
</dir>
|
111 |
+
</dir>
|
112 |
+
</dir>
|
113 |
+
</dir>
|
114 |
+
</target>
|
115 |
+
<target name="magelib">
|
116 |
+
<dir name="CashCloudApi">
|
117 |
+
<file name="README.md"
|
118 |
+
hash="aab32792745c5d2c37ab89b374dd4679" />
|
119 |
+
<file name="composer.json"
|
120 |
+
hash="f028b4aeea73abffc53d6b3537731848" />
|
121 |
+
<file name="phpunit.xml"
|
122 |
+
hash="84e70fe584254f6aa1377b0f5295cf73" />
|
123 |
+
<dir name="tests">
|
124 |
+
<file name="bootstrap.php"
|
125 |
+
hash="d9027f2b29bfb77e1962266d414648b1" />
|
126 |
+
<dir name="CashCloud">
|
127 |
+
<dir name="Test">
|
128 |
+
<file name="TestCase.php"
|
129 |
+
hash="cc78576f845fb0af58da9d15b59f301f" />
|
130 |
+
<dir name="Api">
|
131 |
+
<dir name="Rest">
|
132 |
+
<file name="AuthTest.php"
|
133 |
+
hash="de6f4af4bdf395b00ce843a825d38bdb" />
|
134 |
+
<file name="CurlRequestTest.php"
|
135 |
+
hash="a191b71e687b6aaf0a3384b37e2d64f7" />
|
136 |
+
<file name="ClientTest.php"
|
137 |
+
hash="e512fb59531809f65b77a4a8f034d690" />
|
138 |
+
</dir>
|
139 |
+
<dir name="Exception">
|
140 |
+
<file name="ValidateExceptionTest.php"
|
141 |
+
hash="e10c57f487b08bcae84c394bdf0c30d9" />
|
142 |
+
</dir>
|
143 |
+
<dir name="Method">
|
144 |
+
<file name="GetSettingsTest.php"
|
145 |
+
hash="62751c64dc3b383b1607aeff27e2e863" />
|
146 |
+
<file name="RequestMoneyTest.php"
|
147 |
+
hash="8b83522fc0c55ec19a5effe09c345bf8" />
|
148 |
+
<file name="GetRatesTest.php"
|
149 |
+
hash="221247ea77d858ee5743afded4f81ea1" />
|
150 |
+
<file name="SaveSettingsTest.php"
|
151 |
+
hash="f66782fba1fe916c8ec340c6a4e2e593" />
|
152 |
+
<file name="GetReasonsTest.php"
|
153 |
+
hash="1b5ad83bf87727c99783da70df3fb9ad" />
|
154 |
+
</dir>
|
155 |
+
</dir>
|
156 |
+
</dir>
|
157 |
+
</dir>
|
158 |
+
</dir>
|
159 |
+
<dir name="samples">
|
160 |
+
<file name="GetSettings.php"
|
161 |
+
hash="bc5890f26445fdc11524c779fa608cf6" />
|
162 |
+
<file name="GetReasons.php"
|
163 |
+
hash="f181a8f0c74e1127af87bea42151d6ff" />
|
164 |
+
<file name="SaveSettings.php"
|
165 |
+
hash="2628c36df7f07f3c4c02b73c3c2608d0" />
|
166 |
+
<file name="GetRate.php"
|
167 |
+
hash="2713be10db66ffd9048a134ae08e925e" />
|
168 |
+
<file name="credentials.php"
|
169 |
+
hash="5902bffeb7f9b1218e4b34653a9821e5" />
|
170 |
+
<file name="RequestMoney.php"
|
171 |
+
hash="6ce3c6b1f08e1fe7f86307dae449ce95" />
|
172 |
+
</dir>
|
173 |
+
<dir name="vendor">
|
174 |
+
<file name="autoload.php"
|
175 |
+
hash="23359eb0cd6c02298c82d094afe95338" />
|
176 |
+
<dir name="composer">
|
177 |
+
<file name="autoload_namespaces.php"
|
178 |
+
hash="6ad7d23d00d37b668c1c42aeb4334849" />
|
179 |
+
<file name="ClassLoader.php"
|
180 |
+
hash="6d55599d5476b3defbafbda79ae4abda" />
|
181 |
+
<file name="autoload_real.php"
|
182 |
+
hash="83ffbde0329875d86247f0781c83ee64" />
|
183 |
+
<file name="autoload_psr4.php"
|
184 |
+
hash="dd3a00f0d13eb29781edd8c77d4c5100" />
|
185 |
+
<file name="autoload_classmap.php"
|
186 |
+
hash="8645d3a4e3ad87e7cf4d88a46717aab4" />
|
187 |
+
</dir>
|
188 |
+
</dir>
|
189 |
+
<dir name="src">
|
190 |
+
<dir name="CashCloud">
|
191 |
+
<dir name="Api">
|
192 |
+
<dir name="Rest">
|
193 |
+
<file name="CurlRequest.php"
|
194 |
+
hash="6b26b31e77e7d4f5df91217bf6ba3af9" />
|
195 |
+
<file name="Request.php"
|
196 |
+
hash="3b55b826fcc2a4b7c143a03715f9b150" />
|
197 |
+
<file name="Auth.php"
|
198 |
+
hash="b823125f63372a0943a7289bd960633c" />
|
199 |
+
<file name="Client.php"
|
200 |
+
hash="4283bbeea546ba41d1d27011a3017783" />
|
201 |
+
</dir>
|
202 |
+
<dir name="Exception">
|
203 |
+
<file name="AuthException.php"
|
204 |
+
hash="2e908258e593142961c7f0475b161b03" />
|
205 |
+
<file name="CashCloudException.php"
|
206 |
+
hash="99efbf3eb2432500ea1741e546d4936f" />
|
207 |
+
<file name="ValidateException.php"
|
208 |
+
hash="ffa2cc1aadea92608e76a533bbd43d05" />
|
209 |
+
</dir>
|
210 |
+
<dir name="Method">
|
211 |
+
<file name="GetSettings.php"
|
212 |
+
hash="2f73322693e6856bbb278f1e7f4a9bc4" />
|
213 |
+
<file name="GetReasons.php"
|
214 |
+
hash="15b12947d116f979475d1d77292283bd" />
|
215 |
+
<file name="GetTransactions.php"
|
216 |
+
hash="09ac4cf83a4992470050c985e827e177" />
|
217 |
+
<file name="Refund.php"
|
218 |
+
hash="dea8056d0fb96ae55416801c67ad1f2c" />
|
219 |
+
<file name="SaveSettings.php"
|
220 |
+
hash="68aa90c3632d8abffd73f7ca8fa87a31" />
|
221 |
+
<file name="Method.php"
|
222 |
+
hash="489400a3c82e79970417de77917a2f3b" />
|
223 |
+
<file name="GetRates.php"
|
224 |
+
hash="e87a8595e22be353cbb4594ce32f685f" />
|
225 |
+
<file name="RequestMoney.php"
|
226 |
+
hash="300a72fb397bd3acff9097720b608eee" />
|
227 |
+
</dir>
|
228 |
+
</dir>
|
229 |
+
</dir>
|
230 |
+
</dir>
|
231 |
+
</dir>
|
232 |
+
</target>
|
233 |
+
<target name="mageskin">
|
234 |
+
<dir name="frontend">
|
235 |
+
<dir name="base">
|
236 |
+
<dir name="default">
|
237 |
+
<dir name="images">
|
238 |
+
<dir name="cashcloud">
|
239 |
+
<file name="logo.png"
|
240 |
+
hash="7b61cdf3b30ecfe0c14f0941748daac9" />
|
241 |
+
<file name="loader.gif"
|
242 |
+
hash="b78b8cd94c60b5a6515bfaf5ce974b75" />
|
243 |
+
</dir>
|
244 |
+
</dir>
|
245 |
+
<dir name="js">
|
246 |
+
<file name="cashcloud.js"
|
247 |
+
hash="d41d8cd98f00b204e9800998ecf8427e" />
|
248 |
+
</dir>
|
249 |
+
<dir name="css">
|
250 |
+
<file name="cashcloud.css"
|
251 |
+
hash="1d4ce0ed49ce6ebeb2bb2f3573bbf4ba" />
|
252 |
+
</dir>
|
253 |
+
</dir>
|
254 |
+
</dir>
|
255 |
+
</dir>
|
256 |
+
</target>
|
257 |
+
<target name="magelocale">
|
258 |
+
<dir name="en_US">
|
259 |
+
<file name="Mage_CashCloud.csv"
|
260 |
+
hash="81cc71f688fb48b92b955a7f05ff8a69" />
|
261 |
+
</dir>
|
262 |
+
<dir name="en_GB">
|
263 |
+
<file name="Mage_CashCloud.csv"
|
264 |
+
hash="81cc71f688fb48b92b955a7f05ff8a69" />
|
265 |
+
</dir>
|
266 |
+
</target>
|
267 |
+
</contents>
|
268 |
+
<dependencies>
|
269 |
+
<required>
|
270 |
+
<php>
|
271 |
+
<min>5.3.0</min>
|
272 |
+
<max>6.0.0</max>
|
273 |
+
</php>
|
274 |
+
</required>
|
275 |
+
</dependencies>
|
276 |
+
</package>
|
skin/frontend/base/default/css/cashcloud.css
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
div.container {
|
2 |
+
text-align: center;
|
3 |
+
margin: 10% auto 0 auto;
|
4 |
+
width:220px;
|
5 |
+
}
|
skin/frontend/base/default/images/cashcloud/loader.gif
ADDED
Binary file
|
skin/frontend/base/default/images/cashcloud/logo.png
ADDED
Binary file
|
skin/frontend/base/default/js/cashcloud.js
ADDED
File without changes
|