yapital - Version 1.1.0

Version Notes

Yapital, the first Pan-European, cross-channel payment solution, is the fast, easy and secure way for your customers to pay. All payments and transactions immediately show up in your Yapital business account and all payments are guaranteed.

Download this release

Release Info

Developer code-x GmbH
Extension yapital
Version 1.1.0
Comparing to
See all releases


Code changes from version 1.0.0 to 1.1.0

Files changed (68) hide show
  1. app/code/community/Codex/Yapital/Block/Config/Credentials/Sandbox.php +0 -75
  2. app/code/community/Codex/Yapital/Block/Config/Notification/Sandbox.php +0 -75
  3. app/code/community/Codex/Yapital/Block/Standard/Iframe.php +1 -1
  4. app/code/community/Codex/Yapital/Block/System/Config/Form/Field/Html.php +28 -0
  5. app/code/community/Codex/Yapital/Block/System/Config/Head.php +12 -0
  6. app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Abstract.php +13 -0
  7. app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Notification.php +39 -7
  8. app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Sandbox.php +0 -75
  9. app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Sandbox/Notification.php +18 -0
  10. app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Sandbox/Secret.php +2 -46
  11. app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Sandbox/Update.php +13 -0
  12. app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Sandbox/Validate.php +14 -0
  13. app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/{Live/Secret.php → Secret.php} +14 -6
  14. app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Update.php +40 -0
  15. app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Validate.php +36 -19
  16. app/code/community/Codex/Yapital/Helper/Config.php +9 -0
  17. app/code/community/Codex/Yapital/Model/Api/Abstract.php +11 -1
  18. app/code/community/Codex/Yapital/Model/Api/Basket/Transaction.php +2 -1
  19. app/code/community/Codex/Yapital/Model/Api/BasketCollection.php +43 -0
  20. app/code/community/Codex/Yapital/Model/Api/Client.php +223 -0
  21. app/code/community/Codex/Yapital/Model/Api/Connection.php +256 -0
  22. app/code/community/Codex/Yapital/Model/Api/ErrorMessage.php +32 -0
  23. app/code/community/Codex/Yapital/Model/Api/Notification.php +13 -5
  24. app/code/community/Codex/Yapital/Model/Api/Restclient.php +31 -3
  25. app/code/community/Codex/Yapital/Model/Api/Token.php +19 -6
  26. app/code/community/Codex/Yapital/Model/Config.php +33 -33
  27. app/code/community/Codex/Yapital/Model/Datatype/ISOLanguage.php +41 -0
  28. app/code/community/Codex/Yapital/Model/Datatype/Transaction.php +0 -1
  29. app/code/community/Codex/Yapital/Model/Datatype/{Transactionstatus.php → TransactionStatus.php} +0 -0
  30. app/code/community/Codex/Yapital/Model/Datatype/Transactions.php +340 -0
  31. app/code/community/Codex/Yapital/Model/Notification.php +24 -0
  32. app/code/community/Codex/Yapital/Model/Observer.php +4 -3
  33. app/code/community/Codex/Yapital/Model/Payment/Standard.php +10 -0
  34. app/code/community/Codex/Yapital/Model/Resource/Report/Paymentmethod.php +3 -1
  35. app/code/community/Codex/Yapital/controllers/Adminhtml/Yapital/ConfigController.php +112 -59
  36. app/code/community/Codex/Yapital/controllers/Adminhtml/Yapital/DocumentationController.php +34 -0
  37. app/code/community/Codex/Yapital/controllers/Adminhtml/Yapital/NotificationController.php +72 -3
  38. app/code/community/Codex/Yapital/controllers/Adminhtml/Yapital/SandboxController.php +0 -105
  39. app/code/community/Codex/Yapital/controllers/NotificationController.php +17 -5
  40. app/code/community/Codex/Yapital/controllers/StandardController.php +8 -6
  41. app/code/community/Codex/Yapital/etc/config.xml +31 -13
  42. app/code/community/Codex/Yapital/etc/system.xml +55 -17
  43. app/code/community/Codex/Yapital/sql/yapital_setup/mysql4-upgrade-0.2.0-0.3.0.php +1 -1
  44. app/design/adminhtml/default/default/layout/yapital.xml +17 -4
  45. app/design/adminhtml/default/default/template/yapital/.gitignore +0 -0
  46. app/design/adminhtml/default/default/template/yapital/config/credentials/notification.phtml +10 -0
  47. app/design/adminhtml/default/default/template/yapital/config/credentials/sandbox.phtml +0 -152
  48. app/design/adminhtml/default/default/template/yapital/config/credentials/secret.phtml +2 -0
  49. app/design/adminhtml/default/default/template/yapital/config/credentials/update.phtml +8 -0
  50. app/design/adminhtml/default/default/template/yapital/config/credentials/validate.phtml +10 -0
  51. app/design/adminhtml/default/default/template/yapital/config/head.phtml +12 -0
  52. app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/live/secret.phtml +0 -21
  53. app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/notification.phtml +0 -145
  54. app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/sandbox.phtml +0 -144
  55. app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/sandbox/notification.phtml +0 -144
  56. app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/sandbox/secret.phtml +0 -11
  57. app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/validate.phtml +0 -148
  58. app/design/frontend/base/default/layout/yapital.xml +6 -0
  59. app/design/frontend/base/default/template/yapital/.gitignore +0 -0
  60. app/design/frontend/base/default/template/yapital/standard/accessdenied.phtml +1 -1
  61. app/design/frontend/base/default/template/yapital/standard/documentation.phtml +26 -0
  62. app/design/frontend/base/default/template/yapital/standard/error.phtml +1 -6
  63. app/design/frontend/base/default/template/yapital/standard/iframe.phtml +47 -2
  64. app/locale/en_US/Codex_Yapital.csv +70 -0
  65. package.xml +5 -5
  66. skin/adminhtml/default/default/images/codex/yapital/yapital150x39.png +0 -0
  67. skin/adminhtml/default/default/yapital.js +227 -0
  68. skin/frontend/base/default/css/yapital/.gitignore +0 -0
app/code/community/Codex/Yapital/Block/Config/Credentials/Sandbox.php DELETED
@@ -1,75 +0,0 @@
1
- <?php
2
-
3
- class Codex_Yapital_Block_Config_Credentials_Sandbox
4
- extends Mage_Adminhtml_Block_System_Config_Form_Field
5
- {
6
- /*
7
- * Set template
8
- */
9
- protected function _construct()
10
- {
11
- parent::_construct();
12
- $this->setTemplate('yapital/config/credentials/sandbox.phtml');
13
- }
14
-
15
- /**
16
- * Remove scope label
17
- *
18
- * @param Varien_Data_Form_Element_Abstract $element
19
- * @return string
20
- */
21
- public function render(Varien_Data_Form_Element_Abstract $element)
22
- {
23
- $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
24
- return parent::render($element);
25
- }
26
-
27
- /**
28
- * Return element html
29
- *
30
- * @param Varien_Data_Form_Element_Abstract $element
31
- * @return string
32
- */
33
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
34
- {
35
- return $this->_toHtml();
36
- }
37
-
38
- /**
39
- * Return ajax url for synchronize button
40
- *
41
- * @return string
42
- */
43
- public function getAjaxValidateUpdateUrl()
44
- {
45
- // @todo yapital_system_config_system_storage/validate
46
- return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_config/validateSandbox');
47
- }
48
-
49
- /**
50
- * Return ajax url for synchronize button
51
- *
52
- * @return string
53
- */
54
- public function getAjaxStatusUpdateUrl()
55
- {
56
- // @todo yapital_system_config_system_storage/status
57
- return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_config/statusSandbox');
58
- }
59
-
60
- /**
61
- * Generate synchronize button html
62
- *
63
- * @return string
64
- */
65
- public function getButtonHtml()
66
- {
67
- $button = $this->getLayout()->createBlock('adminhtml/widget_button')
68
- ->setData(array(
69
- 'id' => 'validate_button',
70
- 'label' => $this->helper('yapital/data')->__('Validate sandbox credentials'),
71
- 'onclick' => 'javascript:validateSandboxYapital(); return false;'
72
- ));
73
- return $button->toHtml();
74
- }
75
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Codex/Yapital/Block/Config/Notification/Sandbox.php DELETED
@@ -1,75 +0,0 @@
1
- <?php
2
-
3
- class Codex_Yapital_Block_Config_Notification_Sandbox
4
- extends Mage_Adminhtml_Block_System_Config_Form_Field
5
- {
6
- /*
7
- * Set template
8
- */
9
- protected function _construct()
10
- {
11
- parent::_construct();
12
- $this->setTemplate('yapital/system/config/storage/credentials/sandbox/notification.phtml');
13
- }
14
-
15
- /**
16
- * Remove scope label
17
- *
18
- * @param Varien_Data_Form_Element_Abstract $element
19
- * @return string
20
- */
21
- public function render(Varien_Data_Form_Element_Abstract $element)
22
- {
23
- $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
24
- return parent::render($element);
25
- }
26
-
27
- /**
28
- * Return ajax url for synchronize button
29
- *
30
- * @return string
31
- */
32
- public function getAjaxRegisterUrl()
33
- {
34
- // @todo yapital_system_config_system_storage/validate
35
- return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_sandbox/register');
36
- }
37
-
38
- /**
39
- * Return ajax url for synchronize button
40
- *
41
- * @return string
42
- */
43
- public function getAjaxStatusUpdateUrl()
44
- {
45
- // @todo yapital_system_config_system_storage/status
46
- return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_sandbox/status');
47
- }
48
-
49
- /**
50
- * Return element html
51
- *
52
- * @param Varien_Data_Form_Element_Abstract $element
53
- * @return string
54
- */
55
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
56
- {
57
- return $this->_toHtml();
58
- }
59
-
60
- /**
61
- * Generate synchronize button html
62
- *
63
- * @return string
64
- */
65
- public function getButtonHtml()
66
- {
67
- $button = $this->getLayout()->createBlock('adminhtml/widget_button')
68
- ->setData(array(
69
- 'id' => 'notification_button',
70
- 'label' => $this->helper('yapital/data')->__('Register sandbox notification'),
71
- 'onclick' => 'javascript:yapitalSandboxNotificationRegister(); return false;'
72
- ));
73
- return $button->toHtml();
74
- }
75
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Codex/Yapital/Block/Standard/Iframe.php CHANGED
@@ -19,7 +19,7 @@ class Codex_Yapital_Block_Standard_Iframe extends Codex_Yapital_Block_AbstractBl
19
  }
20
 
21
  public function getApiUrl() {
22
- return $this->_getConfig()->getApiUrl();
23
  }
24
 
25
  public function getApiIFrameScript()
19
  }
20
 
21
  public function getApiUrl() {
22
+ return rtrim( $this->_getConfig()->getApiUrl() , '/') .'/';
23
  }
24
 
25
  public function getApiIFrameScript()
app/code/community/Codex/Yapital/Block/System/Config/Form/Field/Html.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Block_System_Config_Form_Field_Html
4
+ extends Mage_Adminhtml_Block_System_Config_Form_Field
5
+ {
6
+ /**
7
+ * Remove scope label
8
+ *
9
+ * @param Varien_Data_Form_Element_Abstract $element
10
+ * @return string
11
+ */
12
+ public function render(Varien_Data_Form_Element_Abstract $element)
13
+ {
14
+ $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
15
+ return parent::render($element);
16
+ }
17
+
18
+ /**
19
+ * Return element html
20
+ *
21
+ * @param Varien_Data_Form_Element_Abstract $element
22
+ * @return string
23
+ */
24
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
25
+ {
26
+ return $this->_toHtml();
27
+ }
28
+ }
app/code/community/Codex/Yapital/Block/System/Config/Head.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Block_System_Config_Head
4
+ extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface
5
+ {
6
+ protected $_template = 'yapital/config/head.phtml';
7
+
8
+ public function render(Varien_Data_Form_Element_Abstract $element)
9
+ {
10
+ return $this->toHtml();
11
+ }
12
+ }
app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Abstract.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Block_System_Config_Storage_Credentials_Abstract extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+
6
+ protected $is_sandbox = false;
7
+
8
+ public function getConfigPath()
9
+ {
10
+ return ( $this->is_sandbox ? 'standard_sandbox' : 'standard') ;
11
+ }
12
+
13
+ }
app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Notification.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  class Codex_Yapital_Block_System_Config_Storage_Credentials_Notification
4
- extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
  /*
7
  * Set template
@@ -9,7 +9,7 @@ extends Mage_Adminhtml_Block_System_Config_Form_Field
9
  protected function _construct()
10
  {
11
  parent::_construct();
12
- $this->setTemplate('yapital/system/config/storage/credentials/notification.phtml');
13
  }
14
 
15
  /**
@@ -32,7 +32,17 @@ extends Mage_Adminhtml_Block_System_Config_Form_Field
32
  public function getAjaxRegisterUrl()
33
  {
34
  // @todo yapital_system_config_system_storage/validate
35
- return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_notification/register');
 
 
 
 
 
 
 
 
 
 
36
  }
37
 
38
  /**
@@ -43,7 +53,7 @@ extends Mage_Adminhtml_Block_System_Config_Form_Field
43
  public function getAjaxStatusUpdateUrl()
44
  {
45
  // @todo yapital_system_config_system_storage/status
46
- return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_notification/status');
47
  }
48
 
49
  /**
@@ -66,10 +76,32 @@ extends Mage_Adminhtml_Block_System_Config_Form_Field
66
  {
67
  $button = $this->getLayout()->createBlock('adminhtml/widget_button')
68
  ->setData(array(
69
- 'id' => 'notification_button',
70
- 'label' => $this->helper('yapital/data')->__('Register live notification'),
71
- 'onclick' => 'javascript:yapitalNotificationRegister(); return false;'
72
  ));
73
  return $button->toHtml();
74
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  }
1
  <?php
2
 
3
  class Codex_Yapital_Block_System_Config_Storage_Credentials_Notification
4
+ extends Codex_Yapital_Block_System_Config_Storage_Credentials_Abstract
5
  {
6
  /*
7
  * Set template
9
  protected function _construct()
10
  {
11
  parent::_construct();
12
+ $this->setTemplate('yapital/config/credentials/notification.phtml');
13
  }
14
 
15
  /**
32
  public function getAjaxRegisterUrl()
33
  {
34
  // @todo yapital_system_config_system_storage/validate
35
+ return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_notification/register', array( 'sandbox' => $this->is_sandbox ) );
36
+ }
37
+
38
+ /**
39
+ * Return ajax url for unregister button
40
+ *
41
+ * @return string
42
+ */
43
+ public function getAjaxUnregisterUrl()
44
+ {
45
+ return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_notification/unregister', array( 'sandbox' => $this->is_sandbox ) );
46
  }
47
 
48
  /**
53
  public function getAjaxStatusUpdateUrl()
54
  {
55
  // @todo yapital_system_config_system_storage/status
56
+ return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_notification/status', array( 'sandbox' => $this->is_sandbox ) );
57
  }
58
 
59
  /**
76
  {
77
  $button = $this->getLayout()->createBlock('adminhtml/widget_button')
78
  ->setData(array(
79
+ 'id' => $this->getConfigPath(). '_notification_button',
80
+ 'label' => $this->getButtonLabel(),
81
+ 'onclick' => $this->getConfigPath().'_yapitalConfig.register(\''.$this->getAjaxRegisterUrl().'\'); return false;'
82
  ));
83
  return $button->toHtml();
84
  }
85
+
86
+ public function getButtonLabel()
87
+ {
88
+ return $this->helper('yapital/data')->__('Register live notification');
89
+ }
90
+
91
+ public function getButtonUnregisterLabel()
92
+ {
93
+ return $this->helper('yapital/data')->__('Unregister all live notifications');
94
+ }
95
+
96
+ public function getButtonUnregisterHtml()
97
+ {
98
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
99
+ ->setData(array(
100
+ 'id' => $this->getConfigPath(). '_notification_unregister_button',
101
+ 'label' => $this->getButtonUnregisterLabel(),
102
+ 'onclick' => $this->getConfigPath().'_yapitalConfig.unregister(\''.$this->getAjaxUnregisterUrl().'\'); return false;'
103
+ ));
104
+ return $button->toHtml();
105
+ }
106
+
107
  }
app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Sandbox.php DELETED
@@ -1,75 +0,0 @@
1
- <?php
2
-
3
- class Codex_Yapital_Block_System_Config_Storage_Credentials_Sandbox
4
- extends Mage_Adminhtml_Block_System_Config_Form_Field
5
- {
6
- /*
7
- * Set template
8
- */
9
- protected function _construct()
10
- {
11
- parent::_construct();
12
- $this->setTemplate('yapital/system/config/storage/credentials/sandbox/notification.phtml');
13
- }
14
-
15
- /**
16
- * Remove scope label
17
- *
18
- * @param Varien_Data_Form_Element_Abstract $element
19
- * @return string
20
- */
21
- public function render(Varien_Data_Form_Element_Abstract $element)
22
- {
23
- $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
24
- return parent::render($element);
25
- }
26
-
27
- /**
28
- * Return ajax url for synchronize button
29
- *
30
- * @return string
31
- */
32
- public function getAjaxRegisterUrl()
33
- {
34
- // @todo yapital_system_config_system_storage/validate
35
- return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_sandbox/register');
36
- }
37
-
38
- /**
39
- * Return ajax url for synchronize button
40
- *
41
- * @return string
42
- */
43
- public function getAjaxStatusUpdateUrl()
44
- {
45
- // @todo yapital_system_config_system_storage/status
46
- return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_sandbox/status');
47
- }
48
-
49
- /**
50
- * Return element html
51
- *
52
- * @param Varien_Data_Form_Element_Abstract $element
53
- * @return string
54
- */
55
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
56
- {
57
- return $this->_toHtml();
58
- }
59
-
60
- /**
61
- * Generate synchronize button html
62
- *
63
- * @return string
64
- */
65
- public function getButtonHtml()
66
- {
67
- $button = $this->getLayout()->createBlock('adminhtml/widget_button')
68
- ->setData(array(
69
- 'id' => 'notification_button',
70
- 'label' => $this->helper('yapital/data')->__('Register sandbox notification'),
71
- 'onclick' => 'javascript:yapitalSandboxNotificationRegister(); return false;'
72
- ));
73
- return $button->toHtml();
74
- }
75
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Sandbox/Notification.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Block_System_Config_Storage_Credentials_Sandbox_Notification
4
+ extends Codex_Yapital_Block_System_Config_Storage_Credentials_Notification
5
+ {
6
+ protected $is_sandbox = true;
7
+
8
+ public function getButtonLabel()
9
+ {
10
+ return $this->helper('yapital/data')->__('Register sandbox notification');
11
+ }
12
+
13
+ public function getButtonUnregisterLabel()
14
+ {
15
+ return $this->helper('yapital/data')->__('Unregister all sandbox notifications');
16
+ }
17
+
18
+ }
app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Sandbox/Secret.php CHANGED
@@ -1,53 +1,9 @@
1
  <?php
2
 
3
  class Codex_Yapital_Block_System_Config_Storage_Credentials_Sandbox_Secret
4
- extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
6
- /*
7
- * Set template
8
- */
9
- protected function _construct()
10
- {
11
- parent::_construct();
12
- $this->setTemplate('yapital/system/config/storage/credentials/sandbox/secret.phtml');
13
- }
14
 
15
- /**
16
- * Remove scope label
17
- *
18
- * @param Varien_Data_Form_Element_Abstract $element
19
- * @return string
20
- */
21
- public function render(Varien_Data_Form_Element_Abstract $element)
22
- {
23
- $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
24
- return parent::render($element);
25
- }
26
 
27
- /**
28
- * Return element html
29
- *
30
- * @param Varien_Data_Form_Element_Abstract $element
31
- * @return string
32
- */
33
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
34
- {
35
- return $this->_toHtml();
36
- }
37
-
38
- /**
39
- * Generate synchronize button html
40
- *
41
- * @return string
42
- */
43
- public function getButtonHtml()
44
- {
45
- $button = $this->getLayout()->createBlock('adminhtml/widget_button')
46
- ->setData(array(
47
- 'id' => 'notification_generate_secret_button',
48
- 'label' => $this->helper('yapital/data')->__('Generate a new notification secret'),
49
- 'onclick' => 'javascript:yapitalSandboxGenerateNotificationSecret(); return false;'
50
- ));
51
- return $button->toHtml();
52
- }
53
  }
1
  <?php
2
 
3
  class Codex_Yapital_Block_System_Config_Storage_Credentials_Sandbox_Secret
4
+ extends Codex_Yapital_Block_System_Config_Storage_Credentials_Secret
5
  {
 
 
 
 
 
 
 
 
6
 
7
+ protected $is_sandbox = true;
 
 
 
 
 
 
 
 
 
 
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  }
app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Sandbox/Update.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Block_System_Config_Storage_Credentials_Sandbox_Update
4
+ extends Codex_Yapital_Block_System_Config_Storage_Credentials_Update
5
+ {
6
+ protected $is_sandbox = true;
7
+
8
+ public function getButtonLabel()
9
+ {
10
+ return $this->helper('yapital/data')->__('Update sandbox orders');
11
+ }
12
+
13
+ }
app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Sandbox/Validate.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Block_System_Config_Storage_Credentials_Sandbox_Validate
4
+ extends Codex_Yapital_Block_System_Config_Storage_Credentials_Validate
5
+ {
6
+
7
+ protected $is_sandbox = true;
8
+
9
+ public function getButtonLabel()
10
+ {
11
+ return $this->helper('yapital/data')->__('Validate sandbox credentials');
12
+ }
13
+
14
+ }
app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/{Live/Secret.php → Secret.php} RENAMED
@@ -1,15 +1,17 @@
1
  <?php
2
 
3
- class Codex_Yapital_Block_System_Config_Storage_Credentials_Live_Secret
4
- extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
 
 
6
  /*
7
  * Set template
8
  */
9
  protected function _construct()
10
  {
11
  parent::_construct();
12
- $this->setTemplate('yapital/system/config/storage/credentials/live/secret.phtml');
13
  }
14
 
15
  /**
@@ -44,10 +46,16 @@ extends Mage_Adminhtml_Block_System_Config_Form_Field
44
  {
45
  $button = $this->getLayout()->createBlock('adminhtml/widget_button')
46
  ->setData(array(
47
- 'id' => 'notification_generate_secret_button',
48
- 'label' => $this->helper('yapital/data')->__('Generate a new notification secret'),
49
- 'onclick' => 'javascript:yapitalLiveGenerateNotificationSecret(); return false;'
50
  ));
51
  return $button->toHtml();
52
  }
 
 
 
 
 
 
53
  }
1
  <?php
2
 
3
+ class Codex_Yapital_Block_System_Config_Storage_Credentials_Secret
4
+ extends Codex_Yapital_Block_System_Config_Storage_Credentials_Abstract
5
  {
6
+
7
+
8
  /*
9
  * Set template
10
  */
11
  protected function _construct()
12
  {
13
  parent::_construct();
14
+ $this->setTemplate('yapital/config/credentials/secret.phtml');
15
  }
16
 
17
  /**
46
  {
47
  $button = $this->getLayout()->createBlock('adminhtml/widget_button')
48
  ->setData(array(
49
+ 'id' => $this->getConfigPath().'_notification_generate_secret_button',
50
+ 'label' => $this->getButtonLabel(),
51
+ 'onclick' => $this->getConfigPath().'_yapitalConfig.generateNotificationSecret(); return false;'
52
  ));
53
  return $button->toHtml();
54
  }
55
+
56
+ public function getButtonLabel()
57
+ {
58
+ return $this->helper('yapital/data')->__('Generate a new notification secret');
59
+ }
60
+
61
  }
app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Update.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Block_System_Config_Storage_Credentials_Update
4
+ extends Codex_Yapital_Block_System_Config_Storage_Credentials_Abstract
5
+ {
6
+ protected $_template = 'yapital/config/credentials/update.phtml';
7
+
8
+
9
+ public function getButtonLabel()
10
+ {
11
+ return $this->helper('yapital/data')->__('Update orders');
12
+ }
13
+
14
+ /**
15
+ * Return element html
16
+ *
17
+ * @param Varien_Data_Form_Element_Abstract $element
18
+ * @return string
19
+ */
20
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
21
+ {
22
+ return $this->_toHtml();
23
+ }
24
+
25
+ /**
26
+ * Generate synchronize button html
27
+ *
28
+ * @return string
29
+ */
30
+ public function getButtonHtml()
31
+ {
32
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
33
+ ->setData(array(
34
+ 'id' => 'validate_button',
35
+ 'label' => $this->getButtonLabel(),
36
+ 'onclick' => $this->getConfigPath().'_yapitalConfig.updateTransactions(); return false;'
37
+ ));
38
+ return $button->toHtml();
39
+ }
40
+ }
app/code/community/Codex/Yapital/Block/System/Config/Storage/Credentials/Validate.php CHANGED
@@ -1,15 +1,17 @@
1
  <?php
2
 
3
  class Codex_Yapital_Block_System_Config_Storage_Credentials_Validate
4
- extends Mage_Adminhtml_Block_System_Config_Form_Field
5
  {
 
 
6
  /*
7
  * Set template
8
  */
9
  protected function _construct()
10
  {
11
  parent::_construct();
12
- $this->setTemplate('yapital/system/config/storage/credentials/validate.phtml');
13
  }
14
 
15
  /**
@@ -43,7 +45,7 @@ extends Mage_Adminhtml_Block_System_Config_Form_Field
43
  public function getAjaxValidateUpdateUrl()
44
  {
45
  // @todo yapital_system_config_system_storage/validate
46
- return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_config/validate');
47
  }
48
 
49
  /**
@@ -54,38 +56,53 @@ extends Mage_Adminhtml_Block_System_Config_Form_Field
54
  public function getAjaxStatusUpdateUrl()
55
  {
56
  // @todo yapital_system_config_system_storage/status
57
- return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_config/status');
58
  }
59
 
60
  /**
61
- * Generate synchronize button html
62
  *
63
  * @return string
64
  */
65
- public function getButtonHtml()
66
  {
67
- $button = $this->getLayout()->createBlock('adminhtml/widget_button')
68
- ->setData(array(
69
- 'id' => 'validate_button',
70
- 'label' => $this->helper('yapital/data')->__('Validate live credentials'),
71
- 'onclick' => 'javascript:validateYapital(); return false;'
72
- ));
73
- return $button->toHtml();
74
  }
75
 
76
  /**
77
- * Generate switch button html
78
  *
79
  * @return string
80
  */
81
- public function getSwitchButtonHtml()
82
  {
83
  $button = $this->getLayout()->createBlock('adminhtml/widget_button')
84
  ->setData(array(
85
- 'id' => 'validate_button',
86
- 'label' => $this->helper('yapital/data')->__('Switch'),
87
- 'onclick' => 'javascript:yapitalSwitch(); return false;'
88
- ));
89
  return $button->toHtml();
90
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  }
1
  <?php
2
 
3
  class Codex_Yapital_Block_System_Config_Storage_Credentials_Validate
4
+ extends Codex_Yapital_Block_System_Config_Storage_Credentials_Abstract
5
  {
6
+ protected $is_sandbox = false;
7
+
8
  /*
9
  * Set template
10
  */
11
  protected function _construct()
12
  {
13
  parent::_construct();
14
+ $this->setTemplate('yapital/config/credentials/validate.phtml');
15
  }
16
 
17
  /**
45
  public function getAjaxValidateUpdateUrl()
46
  {
47
  // @todo yapital_system_config_system_storage/validate
48
+ return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_config/validate', array( 'sandbox' => $this->is_sandbox ) );
49
  }
50
 
51
  /**
56
  public function getAjaxStatusUpdateUrl()
57
  {
58
  // @todo yapital_system_config_system_storage/status
59
+ return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_config/status', array( 'sandbox' => $this->is_sandbox ));
60
  }
61
 
62
  /**
63
+ * Return ajax url for update button
64
  *
65
  * @return string
66
  */
67
+ public function getAjaxTransactionUpdateUrl()
68
  {
69
+ return Mage::getSingleton('adminhtml/url')->getUrl('*/yapital_config/update', array( 'sandbox' => $this->is_sandbox ));
 
 
 
 
 
 
70
  }
71
 
72
  /**
73
+ * Generate synchronize button html
74
  *
75
  * @return string
76
  */
77
+ public function getButtonHtml()
78
  {
79
  $button = $this->getLayout()->createBlock('adminhtml/widget_button')
80
  ->setData(array(
81
+ 'id' => $this->getConfigPath() . '_validate_button',
82
+ 'label' => $this->getButtonLabel(),
83
+ 'onclick' => $this->getConfigPath().'_yapitalConfig.validate(); return false;'
84
+ ));
85
  return $button->toHtml();
86
  }
87
+
88
+ public function getButtonLabel()
89
+ {
90
+ return $this->helper('yapital/data')->__('Validate live credentials');
91
+ }
92
+
93
+ public function getJSConfig()
94
+ {
95
+ return Zend_Json::encode(
96
+ array(
97
+ 'is_sandbox' => $this->is_sandbox,
98
+ 'config_path' => $this->getConfigPath(),
99
+ 'validate_url' => $this->getAjaxValidateUpdateUrl(),
100
+ 'status_url' => $this->getAjaxStatusUpdateUrl(),
101
+ 'update_url' => $this->getAjaxTransactionUpdateUrl()
102
+ )
103
+ );
104
+ }
105
+
106
+
107
+
108
  }
app/code/community/Codex/Yapital/Helper/Config.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Helper_Config extends Mage_Core_Helper_Abstract
4
+ {
5
+ public function getConfigModel()
6
+ {
7
+ return Mage::getSingleton('yapital/config');
8
+ }
9
+ }
app/code/community/Codex/Yapital/Model/Api/Abstract.php CHANGED
@@ -47,6 +47,8 @@ class Codex_Yapital_Model_Api_Abstract
47
 
48
  protected function _getQuery($data = array())
49
  {
 
 
50
  /** @var $tokenModel Codex_Yapital_Model_Api_Token */
51
  $tokenModel = Mage::getModel("yapital/api_token");
52
 
@@ -55,7 +57,11 @@ class Codex_Yapital_Model_Api_Abstract
55
  $this->_getConfig()->getApiSecret()
56
  );
57
 
58
- $data['access_token'] = $token->getAccessToken();
 
 
 
 
59
 
60
  return $data;
61
  }
@@ -83,6 +89,8 @@ class Codex_Yapital_Model_Api_Abstract
83
  */
84
  protected function _send($path, $data)
85
  {
 
 
86
  $querydata = $this->_getQuery();
87
 
88
  $path = $this->_getConfig()->getApiUrlPath() . $path;
@@ -94,4 +102,6 @@ class Codex_Yapital_Model_Api_Abstract
94
 
95
  return $response;
96
  }
 
 
97
  }
47
 
48
  protected function _getQuery($data = array())
49
  {
50
+ Codex_Yapital_Model_Log::debug("Adding token to query");
51
+
52
  /** @var $tokenModel Codex_Yapital_Model_Api_Token */
53
  $tokenModel = Mage::getModel("yapital/api_token");
54
 
57
  $this->_getConfig()->getApiSecret()
58
  );
59
 
60
+ if ($token)
61
+ { // token received: add the query
62
+ $data['access_token'] = $token->getAccessToken();
63
+ }
64
+
65
 
66
  return $data;
67
  }
89
  */
90
  protected function _send($path, $data)
91
  {
92
+ Codex_Yapital_Model_Log::debug("Prepare sending data to API...");
93
+
94
  $querydata = $this->_getQuery();
95
 
96
  $path = $this->_getConfig()->getApiUrlPath() . $path;
102
 
103
  return $response;
104
  }
105
+
106
+
107
  }
app/code/community/Codex/Yapital/Model/Api/Basket/Transaction.php CHANGED
@@ -13,12 +13,13 @@ class Codex_Yapital_Model_Api_Basket_Transaction extends Codex_Yapital_Model_Api
13
  */
14
  public function sendOrder ( Mage_Sales_Model_Order $order )
15
  {
16
- Codex_Yapital_Model_Log::log("Sending BasketTransaction");
17
 
18
  /* @var $basketTransaction Codex_Yapital_Model_DataType_BasketsTransaction */
19
  $basketTransaction = Mage::getModel('yapital/datatype_basketstransaction');
20
  $basketTransaction->importOrder($order);
21
 
 
22
 
23
  $url = '/shops/' . $this->_getConfig()->getYapitalShopId() . '/basket_transaction';
24
  $response = $this->_send($url, $basketTransaction);
13
  */
14
  public function sendOrder ( Mage_Sales_Model_Order $order )
15
  {
16
+ Codex_Yapital_Model_Log::debug("Prepare BasketTransaction");
17
 
18
  /* @var $basketTransaction Codex_Yapital_Model_DataType_BasketsTransaction */
19
  $basketTransaction = Mage::getModel('yapital/datatype_basketstransaction');
20
  $basketTransaction->importOrder($order);
21
 
22
+ Codex_Yapital_Model_Log::log("Sending BasketTransaction");
23
 
24
  $url = '/shops/' . $this->_getConfig()->getYapitalShopId() . '/basket_transaction';
25
  $response = $this->_send($url, $basketTransaction);
app/code/community/Codex/Yapital/Model/Api/BasketCollection.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: mike
5
+ * Date: 2/20/14
6
+ * Time: 3:14 PM
7
+ */
8
+
9
+ class Codex_Yapital_Model_Api_BasketCollection extends Varien_Data_Collection
10
+ {
11
+ public function api()
12
+ {
13
+ Codex_Yapital_Model_Log::log("Sending BasketTransaction");
14
+
15
+ /* @var $basketTransaction Codex_Yapital_Model_DataType_BasketsTransaction */
16
+ $basketTransaction = Mage::getModel('yapital/datatype_basketstransaction');
17
+ $basketTransaction->importOrder($order);
18
+
19
+
20
+ $url = '/shops/' . $this->_getConfig()->getYapitalShopId() . '/basket_transaction';
21
+ $response = $this->_send($url, $basketTransaction);
22
+
23
+ /**
24
+ * @var $shopRestResponse Codex_Yapital_Model_Datatype_Shoprestresponse
25
+ */
26
+ $shopRestResponse = Mage::getModel("yapital/datatype_shoprestresponse");
27
+ $shopRestResponse->importRawResponse($response);
28
+
29
+ $order_transaction = $this->getOrderTransaction();
30
+ $order_transaction->importShopRestResponse($order, $shopRestResponse);
31
+
32
+ $order_transaction->save();
33
+
34
+ return $shopRestResponse;
35
+ }
36
+
37
+ public function loadData($printQuery = false, $logQuery = false)
38
+ {
39
+
40
+ return parent::loadData($printQuery, $logQuery); // TODO: Change the autogenerated stub
41
+ }
42
+
43
+ }
app/code/community/Codex/Yapital/Model/Api/Client.php ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Model_Api_Client extends Zend_Service_Abstract
4
+ {
5
+
6
+ /**
7
+ * Data for the query
8
+ * @var array
9
+ */
10
+ protected $_data = array();
11
+
12
+ protected $_token;
13
+
14
+ /**
15
+ * Zend_Uri of this web service
16
+ * @var Zend_Uri_Http
17
+ */
18
+ protected $_uri = null;
19
+
20
+ public function __construct()
21
+ {
22
+ $adapter = new Zend_Http_Client_Adapter_Curl();
23
+
24
+ $adapter->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0);
25
+ $adapter->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0);
26
+
27
+ $configModel = Mage::getSingleton('yapital/config');
28
+
29
+
30
+ $uri = $configModel->getApiUrl() . $configModel->getApiUrlPath();
31
+ $this->_uri = Zend_Uri::factory($uri);
32
+
33
+ self::getHttpClient()->setAdapter($adapter);
34
+
35
+ }
36
+
37
+ public function getToken()
38
+ {
39
+
40
+ if (null == $this->_token)
41
+ {
42
+ /* @var Codex_Yapital_Model_Api_Token $tokenModel */
43
+ $tokenApi = Mage::getModel('yapital/api_token');
44
+
45
+ /** @var Codex_Yapital_Model_Datatype_Token $tokenModel */
46
+ $tokenModel = $tokenApi->getTokenByStoreConfig();
47
+
48
+ $this->_token = $tokenModel->getAccessToken();
49
+ }
50
+
51
+ return $this->_token;
52
+ }
53
+
54
+
55
+ /**
56
+ * Send a REST POST Query.
57
+ *
58
+ * @param $path
59
+ * @param array $query
60
+ * @param string $data
61
+ *
62
+ * @return Zend_Http_Response
63
+ */
64
+ public function restPostQuery($path, $query = array(), $data = '')
65
+ {
66
+ $this->_prepareRest($path);
67
+ $client = self::getHttpClient();
68
+ $client->setParameterGet($query);
69
+ $client->setRawData($data);
70
+
71
+ self::getHttpClient()->setEncType(false);
72
+
73
+ return $client->request('POST');
74
+ }
75
+
76
+ /**
77
+ * Call a remote REST web service URI and return the Zend_Http_Response object
78
+ *
79
+ * @param string $path The path to append to the URI
80
+ * @throws Zend_Rest_Client_Exception
81
+ * @return void
82
+ */
83
+ private function _prepareRest($path)
84
+ {
85
+ // Get the URI object and configure it
86
+ if (!$this->_uri instanceof Zend_Uri_Http) {
87
+ #require_once 'Zend/Rest/Client/Exception.php';
88
+ throw new Zend_Rest_Client_Exception('URI object must be set before performing call');
89
+ }
90
+
91
+ $uri = $this->_uri->getUri();
92
+
93
+ if ($path[0] != '/' && $uri[strlen($uri) - 1] != '/') {
94
+ $path = '/' . $path;
95
+ }
96
+
97
+ $this->_uri->setPath($path);
98
+
99
+ $this->getHttpClient()->setUri($this->_uri);
100
+ }
101
+
102
+ public function restDeleteQuery($path, $query)
103
+ {
104
+ $this->_prepareRest($path);
105
+ $client = self::getHttpClient();
106
+ $client->setParameterGet($query);
107
+ return $client->request('DELETE');
108
+ }
109
+
110
+ public function resetHttpClient()
111
+ {
112
+ /**
113
+ * Get the HTTP client and configure it for the endpoint URI. Do this each time
114
+ * because the Zend_Http_Client instance is shared among all Zend_Service_Abstract subclasses.
115
+ */
116
+ self::getHttpClient()->resetParameters(true);
117
+
118
+ //
119
+ // Only Accept JSON
120
+ self::getHttpClient()->setHeaders('Accept', 'application/json');
121
+
122
+ //
123
+ // Only send json
124
+ self::getHttpClient()->setHeaders('Content-Type', 'application/json');
125
+
126
+ }
127
+
128
+ /**
129
+ * Performs an HTTP GET request to the $path.
130
+ *
131
+ * @param string $path
132
+ * @param array $query Array of GET parameters
133
+ * @throws Zend_Http_Client_Exception
134
+ * @return Zend_Http_Response
135
+ */
136
+ public function restGet($path, array $query = null)
137
+ {
138
+ $this->_prepareRest($path);
139
+ $client = self::getHttpClient();
140
+ $client->setParameterGet($query);
141
+ return $client->request('GET');
142
+ }
143
+
144
+ public function request($type = 'GET', $path = null, $query = null)
145
+ {
146
+ $this->_prepareRest($path);
147
+ $client = self::getHttpClient();
148
+ $client->setParameterGet($query);
149
+ return $client->request($type);
150
+ }
151
+
152
+ /**
153
+ * Performs an HTTP POST request to $path.
154
+ *
155
+ * @param string $path
156
+ * @param mixed $data Raw data to send
157
+ * @throws Zend_Http_Client_Exception
158
+ * @return Zend_Http_Response
159
+ */
160
+ final public function restPost($path, $data = null)
161
+ {
162
+ $this->_prepareRest($path);
163
+ return $this->_performPost('POST', $data);
164
+ }
165
+
166
+ /**
167
+ * Perform a POST or PUT
168
+ *
169
+ * Performs a POST or PUT request. Any data provided is set in the HTTP
170
+ * client. String data is pushed in as raw POST data; array or object data
171
+ * is pushed in as POST parameters.
172
+ *
173
+ * @param mixed $method
174
+ * @param mixed $data
175
+ * @return Zend_Http_Response
176
+ */
177
+ function _performPost($method, $data = null)
178
+ {
179
+ $client = self::getHttpClient();
180
+ if (is_string($data)) {
181
+ $client->setRawData($data);
182
+ } elseif (is_array($data) || is_object($data)) {
183
+ $client->setParameterPost((array)$data);
184
+ }
185
+
186
+ $_performPost = $client->request($method);
187
+ $status = $_performPost->getStatus();
188
+
189
+ if (substr($status, 0, 1) != 2) {
190
+ Codex_Yapital_Model_Log::error("Unable to communicate with api. " . $_performPost->getMessage());
191
+ }
192
+ return $_performPost;
193
+ }
194
+
195
+ /**
196
+ * Performs an HTTP PUT request to $path.
197
+ *
198
+ * @param string $path
199
+ * @param mixed $data Raw data to send in request
200
+ * @throws Zend_Http_Client_Exception
201
+ * @return Zend_Http_Response
202
+ */
203
+ public function restPut($path, $data = null)
204
+ {
205
+ $this->_prepareRest($path);
206
+ return $this->_performPost('PUT', $data);
207
+ }
208
+
209
+ /**
210
+ * Performs an HTTP DELETE request to $path.
211
+ *
212
+ * @param string $path
213
+ * @throws Zend_Http_Client_Exception
214
+ * @return Zend_Http_Response
215
+ */
216
+ public function restDelete($path)
217
+ {
218
+ $this->_prepareRest($path);
219
+ return self::getHttpClient()->request('DELETE');
220
+ }
221
+
222
+
223
+ }
app/code/community/Codex/Yapital/Model/Api/Connection.php ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Model_Api_Connection extends Zend_Service_Abstract
4
+ {
5
+
6
+ /**
7
+ * Data for the query
8
+ * @var array
9
+ */
10
+ protected $_data = array();
11
+
12
+ /**
13
+ * Zend_Uri of this web service
14
+ * @var Zend_Uri_Http
15
+ */
16
+ protected $_uri = null;
17
+
18
+ public function __construct ( $uri = null )
19
+ {
20
+ if (!empty($uri)) {
21
+ $this->setUri($uri);
22
+ }
23
+
24
+ $adapter = new Zend_Http_Client_Adapter_Curl();
25
+
26
+ $adapter->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0);
27
+ $adapter->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0);
28
+ $adapter->setCurlOption(CURLOPT_SSLVERSION, 3);
29
+
30
+ self::getHttpClient()->setAdapter($adapter);
31
+
32
+ }
33
+
34
+ protected function _getQuery($data = array())
35
+ {
36
+ /** @var $tokenModel Codex_Yapital_Model_Api_Token */
37
+ $tokenModel = Mage::getModel("yapital/api_token");
38
+
39
+ $config = Mage::getSingleton('yapital/config');
40
+ $token = $tokenModel->getTokenByCredentials(
41
+ $config->getApiClientId(),
42
+ $config->getApiSecret()
43
+ );
44
+
45
+ $data['access_token'] = $token->getAccessToken();
46
+
47
+ return $data;
48
+ }
49
+
50
+ public function getToken()
51
+ {
52
+
53
+ if (null == $this->_token)
54
+ {
55
+ /* @var Codex_Yapital_Model_Api_Token $tokenModel */
56
+ $tokenApi = Mage::getModel('yapital/api_token');
57
+
58
+ /** @var Codex_Yapital_Model_Datatype_Token $tokenModel */
59
+ $tokenModel = $tokenApi->getTokenByStoreConfig();
60
+
61
+ $this->_token = $tokenModel->getAccessToken();
62
+ }
63
+
64
+ return $this->_token;
65
+ }
66
+
67
+
68
+
69
+ /**
70
+ * Send a REST POST Query.
71
+ *
72
+ * @param $path
73
+ * @param array $query
74
+ * @param string $data
75
+ *
76
+ * @return Zend_Http_Response
77
+ */
78
+ public function restPostQuery( $path, $query = array(), $data = '' )
79
+ {
80
+ $this->_prepareRest($path);
81
+ $client = self::getHttpClient();
82
+ $client->setParameterGet($query);
83
+ $client->setRawData($data);
84
+
85
+ self::getHttpClient()->setEncType(false);
86
+
87
+ return $client->request('POST');
88
+ }
89
+
90
+ public function restDeleteQuery($path, $query)
91
+ {
92
+ $this->_prepareRest($path);
93
+ $client = self::getHttpClient();
94
+ $client->setParameterGet($query);
95
+ return $client->request('DELETE');
96
+ }
97
+
98
+ public function resetHttpClient()
99
+ {
100
+ /**
101
+ * Get the HTTP client and configure it for the endpoint URI. Do this each time
102
+ * because the Zend_Http_Client instance is shared among all Zend_Service_Abstract subclasses.
103
+ */
104
+ self::getHttpClient()->resetParameters(true);
105
+
106
+ //
107
+ // Only Accept JSON
108
+ self::getHttpClient()->setHeaders('Accept','application/json');
109
+
110
+ //
111
+ // Only send json
112
+ self::getHttpClient()->setHeaders('Content-Type','application/json');
113
+
114
+ }
115
+
116
+ /**
117
+ * Set the URI to use in the request
118
+ *
119
+ * @param string|Zend_Uri_Http $uri URI for the web service
120
+ * @return Zend_Rest_Client
121
+ */
122
+ public function setUri($uri)
123
+ {
124
+ if ($uri instanceof Zend_Uri_Http) {
125
+ $this->_uri = $uri;
126
+ } else {
127
+ $this->_uri = Zend_Uri::factory($uri);
128
+ }
129
+
130
+ return $this;
131
+ }
132
+
133
+ /**
134
+ * Retrieve the current request URI object
135
+ *
136
+ * @return Zend_Uri_Http
137
+ */
138
+ public function getUri()
139
+ {
140
+ return $this->_uri;
141
+ }
142
+
143
+ /**
144
+ * Call a remote REST web service URI and return the Zend_Http_Response object
145
+ *
146
+ * @param string $path The path to append to the URI
147
+ * @throws Zend_Rest_Client_Exception
148
+ * @return void
149
+ */
150
+ private function _prepareRest($path)
151
+ {
152
+ // Get the URI object and configure it
153
+ if (!$this->_uri instanceof Zend_Uri_Http) {
154
+ #require_once 'Zend/Rest/Client/Exception.php';
155
+ throw new Zend_Rest_Client_Exception('URI object must be set before performing call');
156
+ }
157
+
158
+ $uri = $this->_uri->getUri();
159
+
160
+ if ($path[0] != '/' && $uri[strlen($uri)-1] != '/') {
161
+ $path = '/' . $path;
162
+ }
163
+
164
+ $this->_uri->setPath($path);
165
+
166
+ $this->getHttpClient()->setUri($this->_uri);
167
+ }
168
+
169
+ /**
170
+ * Performs an HTTP GET request to the $path.
171
+ *
172
+ * @param string $path
173
+ * @param array $query Array of GET parameters
174
+ * @throws Zend_Http_Client_Exception
175
+ * @return Zend_Http_Response
176
+ */
177
+ public function restGet($path, array $query = null)
178
+ {
179
+ $client = self::getHttpClient();
180
+ $client->setParameterGet($this->_getQuery($query));
181
+ $this->_prepareRest($path);
182
+ return $client->request('GET');
183
+ }
184
+
185
+ /**
186
+ * Perform a POST or PUT
187
+ *
188
+ * Performs a POST or PUT request. Any data provided is set in the HTTP
189
+ * client. String data is pushed in as raw POST data; array or object data
190
+ * is pushed in as POST parameters.
191
+ *
192
+ * @param mixed $method
193
+ * @param mixed $data
194
+ * @return Zend_Http_Response
195
+ */
196
+ function _performPost($method, $data = null)
197
+ {
198
+ $client = self::getHttpClient();
199
+ if (is_string($data)) {
200
+ $client->setRawData($data);
201
+ } elseif (is_array($data) || is_object($data)) {
202
+ $client->setParameterPost((array) $data);
203
+ }
204
+
205
+ $_performPost = $client->request($method);
206
+ $status = $_performPost->getStatus();
207
+
208
+ if (substr($status, 0, 1) != 2) {
209
+ Codex_Yapital_Model_Log::error("Unable to communicate with api. " . $_performPost->getMessage());
210
+ }
211
+ return $_performPost;
212
+ }
213
+
214
+ /**
215
+ * Performs an HTTP POST request to $path.
216
+ *
217
+ * @param string $path
218
+ * @param mixed $data Raw data to send
219
+ * @throws Zend_Http_Client_Exception
220
+ * @return Zend_Http_Response
221
+ */
222
+ final public function restPost($path, $data = null)
223
+ {
224
+ $this->_prepareRest($path);
225
+ return $this->_performPost('POST', $data);
226
+ }
227
+
228
+ /**
229
+ * Performs an HTTP PUT request to $path.
230
+ *
231
+ * @param string $path
232
+ * @param mixed $data Raw data to send in request
233
+ * @throws Zend_Http_Client_Exception
234
+ * @return Zend_Http_Response
235
+ */
236
+ public function restPut($path, $data = null)
237
+ {
238
+ $this->_prepareRest($path);
239
+ return $this->_performPost('PUT', $data);
240
+ }
241
+
242
+ /**
243
+ * Performs an HTTP DELETE request to $path.
244
+ *
245
+ * @param string $path
246
+ * @throws Zend_Http_Client_Exception
247
+ * @return Zend_Http_Response
248
+ */
249
+ public function restDelete($path)
250
+ {
251
+ $this->_prepareRest($path);
252
+ return self::getHttpClient()->request('DELETE');
253
+ }
254
+
255
+
256
+ }
app/code/community/Codex/Yapital/Model/Api/ErrorMessage.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: mike
6
+ * Date: 2/19/14
7
+ * Time: 12:09 AM
8
+ */
9
+ class Codex_Yapital_Model_Api_ErrorMessage extends Varien_Object
10
+ {
11
+ public function __construct()
12
+ {
13
+ $this->setData(
14
+ array(
15
+ // HTTP 400s
16
+ 400102 => "Request not readable.",
17
+ 400004 => "Invalid item price.",
18
+
19
+ // HTTP 403
20
+ 403001 => "Access denied.",
21
+ 403009 => "Duplicate entry found.",
22
+ 403999 => "Operation not allowed. Please contact the Yapital Customer Service Center at 00800-927 927 10.",
23
+
24
+ // HTTP 404
25
+ 432100 => "The requested resource is not available.",
26
+
27
+ // HTTP 500
28
+ // 432100 =>
29
+ )
30
+ );
31
+ }
32
+ }
app/code/community/Codex/Yapital/Model/Api/Notification.php CHANGED
@@ -43,6 +43,11 @@ class Codex_Yapital_Model_Api_Notification extends Codex_Yapital_Model_Api_Abstr
43
  return $this;
44
  }
45
 
 
 
 
 
 
46
  public function getAll()
47
  {
48
  $result = array();
@@ -56,13 +61,16 @@ class Codex_Yapital_Model_Api_Notification extends Codex_Yapital_Model_Api_Abstr
56
  if ( $data = json_decode($response,1) )
57
  {
58
 
59
- foreach( $data['payload'] AS $payload ) {
60
- $notification = Mage::getModel('yapital/datatype_notification');
61
- /* @var $notification Codex_Yapital_Model_Datatype_Notification */
 
 
62
 
63
- $notification->importPayload( $payload );
64
 
65
- $result[] = $notification;
 
66
  }
67
 
68
  }
43
  return $this;
44
  }
45
 
46
+ /**
47
+ * This method serves to get all notifications to which the shop is subscribed.
48
+ *
49
+ * @return Codex_Yapital_Model_Datatype_Notification[]
50
+ */
51
  public function getAll()
52
  {
53
  $result = array();
61
  if ( $data = json_decode($response,1) )
62
  {
63
 
64
+ if( isset( $data['payload'] ) && is_array( $data['payload']['notification'] ) )
65
+ {
66
+ foreach( $data['payload']['notification'] AS $payload ) {
67
+ $notification = Mage::getModel('yapital/datatype_notification');
68
+ /* @var $notification Codex_Yapital_Model_Datatype_Notification */
69
 
70
+ $notification->importPayload( $payload );
71
 
72
+ $result[] = $notification;
73
+ }
74
  }
75
 
76
  }
app/code/community/Codex/Yapital/Model/Api/Restclient.php CHANGED
@@ -25,7 +25,6 @@ class Codex_Yapital_Model_Api_Restclient extends Zend_Service_Abstract
25
 
26
  $adapter->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0);
27
  $adapter->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0);
28
- $adapter->setCurlOption(CURLOPT_SSLVERSION, 3);
29
 
30
  self::getHttpClient()->setAdapter($adapter);
31
 
@@ -50,7 +49,29 @@ class Codex_Yapital_Model_Api_Restclient extends Zend_Service_Abstract
50
 
51
  self::getHttpClient()->setEncType(false);
52
 
53
- return $client->request('POST');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  }
55
 
56
  public function restDeleteQuery($path, $query)
@@ -145,7 +166,11 @@ class Codex_Yapital_Model_Api_Restclient extends Zend_Service_Abstract
145
  $this->_prepareRest($path);
146
  $client = self::getHttpClient();
147
  $client->setParameterGet($query);
148
- return $client->request('GET');
 
 
 
 
149
  }
150
 
151
  /**
@@ -174,6 +199,9 @@ class Codex_Yapital_Model_Api_Restclient extends Zend_Service_Abstract
174
  if (substr($status, 0, 1) != 2) {
175
  Codex_Yapital_Model_Log::error("Unable to communicate with api. " . $_performPost->getMessage());
176
  }
 
 
 
177
  return $_performPost;
178
  }
179
 
25
 
26
  $adapter->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0);
27
  $adapter->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0);
 
28
 
29
  self::getHttpClient()->setAdapter($adapter);
30
 
49
 
50
  self::getHttpClient()->setEncType(false);
51
 
52
+ \Codex_Yapital_Model_Log::verbose(
53
+ sprintf('Send post to %s', $path)
54
+ );
55
+
56
+ $response = $client->request('POST');
57
+
58
+ $this->_logResponse($response);
59
+
60
+ return $response;
61
+ }
62
+
63
+ /**
64
+ * @param Zend_Http_Response $response
65
+ */
66
+ protected function _logResponse($response)
67
+ {
68
+ \Codex_Yapital_Model_Log::verbose(
69
+ sprintf('Status %d: %d B body received', $response->getStatus(), strlen($response->getBody()))
70
+ );
71
+
72
+ \Codex_Yapital_Model_Log::debug(
73
+ sprintf("<<<BODYBEGIN\n\n%s\n\nBODYEND;", $response->getBody())
74
+ );
75
  }
76
 
77
  public function restDeleteQuery($path, $query)
166
  $this->_prepareRest($path);
167
  $client = self::getHttpClient();
168
  $client->setParameterGet($query);
169
+ $response = $client->request('GET');
170
+
171
+ $this->_logResponse($response);
172
+
173
+ return $response;
174
  }
175
 
176
  /**
199
  if (substr($status, 0, 1) != 2) {
200
  Codex_Yapital_Model_Log::error("Unable to communicate with api. " . $_performPost->getMessage());
201
  }
202
+
203
+ $this->_logResponse($_performPost);
204
+
205
  return $_performPost;
206
  }
207
 
app/code/community/Codex/Yapital/Model/Api/Token.php CHANGED
@@ -9,7 +9,7 @@ class Codex_Yapital_Model_Api_Token extends Codex_Yapital_Model_Api_Abstract
9
  * @param string $client_id
10
  * @param string $secret
11
  *
12
- * @return Codex_Yapital_Model_Datatype_Token
13
  */
14
  public function getTokenByCredentials($client_id, $secret)
15
  {
@@ -33,14 +33,22 @@ class Codex_Yapital_Model_Api_Token extends Codex_Yapital_Model_Api_Abstract
33
  'Accept-Encoding' => 'gzip,deflate',
34
  'Authorization' => $auth,
35
  'Content-Type' => 'application/x-www-form-urlencoded',
36
- 'Connection' => 'keepalive',
37
  )
38
  );
39
 
40
- $response = $client->restPost(
41
- $config->getApiUrlPath() . '/oauth/token',
42
- 'grant_type=client_credentials'
43
- );
 
 
 
 
 
 
 
 
 
44
 
45
  /** @var $token Codex_Yapital_Model_Datatype_Token */
46
  $token = Mage::getModel("yapital/datatype_token");
@@ -83,6 +91,11 @@ class Codex_Yapital_Model_Api_Token extends Codex_Yapital_Model_Api_Abstract
83
  }
84
 
85
 
 
 
 
 
 
86
  public function getTokenByStoreConfig($store_id = null)
87
  {
88
  $config = $this->_getConfig();
9
  * @param string $client_id
10
  * @param string $secret
11
  *
12
+ * @return Codex_Yapital_Model_Datatype_Token|false The token as received or `false` if something went wrong.
13
  */
14
  public function getTokenByCredentials($client_id, $secret)
15
  {
33
  'Accept-Encoding' => 'gzip,deflate',
34
  'Authorization' => $auth,
35
  'Content-Type' => 'application/x-www-form-urlencoded',
 
36
  )
37
  );
38
 
39
+ try
40
+ {
41
+ $path = $config->getApiUrlPath() . '/oauth/token';
42
+ $response = $client->restPost($path, 'grant_type=client_credentials');
43
+
44
+ $client->resetHttpClient();
45
+ } catch (Zend_Http_Client_Exception $e) {
46
+
47
+ Codex_Yapital_Model_Log::error(
48
+ sprintf('Connection failure (on %s): %s', $client->getUri(), $e->getMessage())
49
+ );
50
+ return false;
51
+ }
52
 
53
  /** @var $token Codex_Yapital_Model_Datatype_Token */
54
  $token = Mage::getModel("yapital/datatype_token");
91
  }
92
 
93
 
94
+ /**
95
+ * @param mixed$store_id
96
+ *
97
+ * @return Codex_Yapital_Model_Datatype_Token
98
+ */
99
  public function getTokenByStoreConfig($store_id = null)
100
  {
101
  $config = $this->_getConfig();
app/code/community/Codex/Yapital/Model/Config.php CHANGED
@@ -4,13 +4,13 @@ class Codex_Yapital_Model_Config
4
  {
5
 
6
  protected $_storeId = null;
7
- protected $_force_sandbox = false;
8
 
9
  /**
10
  * Helps forcing Sandbox Settings
11
  * @param $bool
12
  */
13
- public function setSandbox( $bool )
14
  {
15
  $this->_force_sandbox = $bool;
16
  }
@@ -25,8 +25,7 @@ class Codex_Yapital_Model_Config
25
  */
26
  public function getApiIFrameScript()
27
  {
28
- if ($this->getCredentialsSwitch() == Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX)
29
- {
30
  // sandbox
31
  return Mage::getConfig()->getNode('default/yapital_sandbox/url/iframe_script');
32
  } else {
@@ -43,9 +42,12 @@ class Codex_Yapital_Model_Config
43
  */
44
  public function getApiUrl()
45
  {
46
- if ($this->getCredentialsSwitch() == Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX)
47
- {
48
  // sandbox
 
 
 
 
49
  return Mage::getConfig()->getNode('default/yapital_sandbox/url/base');
50
  } else {
51
  // live
@@ -56,12 +58,10 @@ class Codex_Yapital_Model_Config
56
 
57
  public function getApiClientId()
58
  {
59
- if ($this->getCredentialsSwitch() == Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX)
60
- { // sandbox is selected: return sandbox setting
61
  $clientId = Mage::getStoreConfig('payment/yapital_standard/sandbox_client_id', $this->getStoreId());
62
- }
63
- else
64
- { // default: live
65
  $clientId = Mage::getStoreConfig('payment/yapital_standard/client_id', $this->getStoreId());
66
  }
67
 
@@ -71,12 +71,10 @@ class Codex_Yapital_Model_Config
71
 
72
  public function getApiSecret()
73
  {
74
- if ($this->getCredentialsSwitch() == Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX)
75
- { // sandbox is selected: return sandbox setting
76
  $apiSecret = Mage::getStoreConfig('payment/yapital_standard/sandbox_secret_key', $this->getStoreId());
77
- }
78
- else
79
- { // default: live
80
  $apiSecret = Mage::getStoreConfig('payment/yapital_standard/secret_key', $this->getStoreId());
81
  }
82
 
@@ -91,9 +89,12 @@ class Codex_Yapital_Model_Config
91
  */
92
  public function getApiUrlPath()
93
  {
94
- if ($this->getCredentialsSwitch() == Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX)
95
- {
96
  // sandbox
 
 
 
 
97
  return Mage::getConfig()->getNode('default/yapital_sandbox/url/api');
98
  } else {
99
  // live
@@ -104,25 +105,27 @@ class Codex_Yapital_Model_Config
104
 
105
  public function getCredentialsSwitch()
106
  {
107
- if( $this->_force_sandbox )
108
- {
109
- return Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX;
 
 
 
110
  }
 
111
  return Mage::getStoreConfig('payment/yapital_standard/credentials_switch', $this->getStoreId());
112
  }
113
 
114
 
115
  public function getNotificationSecret()
116
  {
117
- if ($this->getCredentialsSwitch() == Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX)
118
- { // sandbox is selected: return sandbox setting
119
  $notificationSecret = Mage::getStoreConfig(
120
  'payment/yapital_standard/sandbox_notification_secret',
121
  $this->getStoreId()
122
  );
123
- }
124
- else
125
- {
126
  $notificationSecret = Mage::getStoreConfig(
127
  'payment/yapital_standard/notification_secret',
128
  $this->getStoreId()
@@ -141,8 +144,7 @@ class Codex_Yapital_Model_Config
141
 
142
  public function getStoreId()
143
  {
144
- if (null === $this->_storeId)
145
- {
146
  $this->_storeId = Mage::app()->getStore()->getStoreId();
147
  }
148
 
@@ -152,12 +154,10 @@ class Codex_Yapital_Model_Config
152
 
153
  public function getYapitalShopId()
154
  {
155
- if ($this->getCredentialsSwitch() == Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX)
156
- { // sandbox is selected: use sandbox setting
157
  $shopId = Mage::getStoreConfig('payment/yapital_standard/sandbox_shop_id', $this->getStoreId());
158
- }
159
- else
160
- { // default: live
161
  $shopId = Mage::getStoreConfig('payment/yapital_standard/shop_id', $this->getStoreId());
162
  }
163
 
4
  {
5
 
6
  protected $_storeId = null;
7
+ protected $_force_sandbox = null;
8
 
9
  /**
10
  * Helps forcing Sandbox Settings
11
  * @param $bool
12
  */
13
+ public function setSandbox($bool)
14
  {
15
  $this->_force_sandbox = $bool;
16
  }
25
  */
26
  public function getApiIFrameScript()
27
  {
28
+ if ($this->getCredentialsSwitch() == Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX) {
 
29
  // sandbox
30
  return Mage::getConfig()->getNode('default/yapital_sandbox/url/iframe_script');
31
  } else {
42
  */
43
  public function getApiUrl()
44
  {
45
+ if ($this->getCredentialsSwitch() == Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX) {
 
46
  // sandbox
47
+ if ($sandboxUri = Mage::getStoreConfig('payment/yapital_standard/sandbox_apiuri', $this->getStoreId())) {
48
+ return $sandboxUri;
49
+ }
50
+
51
  return Mage::getConfig()->getNode('default/yapital_sandbox/url/base');
52
  } else {
53
  // live
58
 
59
  public function getApiClientId()
60
  {
61
+ if ($this->getCredentialsSwitch() == Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX
62
+ ) { // sandbox is selected: return sandbox setting
63
  $clientId = Mage::getStoreConfig('payment/yapital_standard/sandbox_client_id', $this->getStoreId());
64
+ } else { // default: live
 
 
65
  $clientId = Mage::getStoreConfig('payment/yapital_standard/client_id', $this->getStoreId());
66
  }
67
 
71
 
72
  public function getApiSecret()
73
  {
74
+ if ($this->getCredentialsSwitch() == Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX
75
+ ) { // sandbox is selected: return sandbox setting
76
  $apiSecret = Mage::getStoreConfig('payment/yapital_standard/sandbox_secret_key', $this->getStoreId());
77
+ } else { // default: live
 
 
78
  $apiSecret = Mage::getStoreConfig('payment/yapital_standard/secret_key', $this->getStoreId());
79
  }
80
 
89
  */
90
  public function getApiUrlPath()
91
  {
92
+ if ($this->getCredentialsSwitch() == Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX) {
 
93
  // sandbox
94
+ if ($sandboxUri = Mage::getStoreConfig('payment/yapital_standard/sandbox_apipath', $this->getStoreId())) {
95
+ return $sandboxUri;
96
+ }
97
+
98
  return Mage::getConfig()->getNode('default/yapital_sandbox/url/api');
99
  } else {
100
  // live
105
 
106
  public function getCredentialsSwitch()
107
  {
108
+ if (!is_null($this->_force_sandbox)) {
109
+ if ($this->_force_sandbox) {
110
+ return Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX;
111
+ } else {
112
+ return Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::LIVE;
113
+ }
114
  }
115
+
116
  return Mage::getStoreConfig('payment/yapital_standard/credentials_switch', $this->getStoreId());
117
  }
118
 
119
 
120
  public function getNotificationSecret()
121
  {
122
+ if ($this->getCredentialsSwitch() == Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX
123
+ ) { // sandbox is selected: return sandbox setting
124
  $notificationSecret = Mage::getStoreConfig(
125
  'payment/yapital_standard/sandbox_notification_secret',
126
  $this->getStoreId()
127
  );
128
+ } else {
 
 
129
  $notificationSecret = Mage::getStoreConfig(
130
  'payment/yapital_standard/notification_secret',
131
  $this->getStoreId()
144
 
145
  public function getStoreId()
146
  {
147
+ if (null === $this->_storeId) {
 
148
  $this->_storeId = Mage::app()->getStore()->getStoreId();
149
  }
150
 
154
 
155
  public function getYapitalShopId()
156
  {
157
+ if ($this->getCredentialsSwitch() == Codex_Yapital_Model_System_Config_Payment_Credentials_Switch::SANDBOX
158
+ ) { // sandbox is selected: use sandbox setting
159
  $shopId = Mage::getStoreConfig('payment/yapital_standard/sandbox_shop_id', $this->getStoreId());
160
+ } else { // default: live
 
 
161
  $shopId = Mage::getStoreConfig('payment/yapital_standard/shop_id', $this->getStoreId());
162
  }
163
 
app/code/community/Codex/Yapital/Model/Datatype/ISOLanguage.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Model_Datatype_ISOLanguage extends Varien_Object
4
+ {
5
+
6
+ protected $_defaultLanguage = 'en_GB';
7
+
8
+ protected function _construct()
9
+ {
10
+ parent::_construct();
11
+
12
+ $this->setData(
13
+ array(
14
+ 'de_DE' => 'de',
15
+ 'en_GB' => 'en',
16
+ 'en_US' => 'en',
17
+ )
18
+ );
19
+ }
20
+
21
+ public function getYapitalLanguage()
22
+ {
23
+ $language = $this->getData($this->getStoreLanguage());
24
+ if (!$language)
25
+ {
26
+ $language = $this->getDefault();
27
+ }
28
+
29
+ return $language;
30
+ }
31
+
32
+ public function getStoreLanguage()
33
+ {
34
+ return Mage::app()->getLocale()->getLocaleCode();
35
+ }
36
+
37
+ public function getDefault()
38
+ {
39
+ return $this->getData($this->_defaultLanguage);
40
+ }
41
+ }
app/code/community/Codex/Yapital/Model/Datatype/Transaction.php CHANGED
@@ -323,7 +323,6 @@ class Codex_Yapital_Model_Datatype_Transaction extends Codex_Yapital_Model_Datat
323
 
324
  function getData ()
325
  {
326
-
327
  return array(
328
  // "transaction_id" => $this->getTransactionId(),
329
  "qr_code_url" => $this->getQrCodeUrl(),
323
 
324
  function getData ()
325
  {
 
326
  return array(
327
  // "transaction_id" => $this->getTransactionId(),
328
  "qr_code_url" => $this->getQrCodeUrl(),
app/code/community/Codex/Yapital/Model/Datatype/{Transactionstatus.php → TransactionStatus.php} RENAMED
File without changes
app/code/community/Codex/Yapital/Model/Datatype/Transactions.php ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Defines the Transaction datatype for the Yapital API
4
+ *
5
+ *
6
+ * PHP version 5
7
+ *
8
+ *
9
+ * @category Datatype
10
+ * @package Codex_Yapital_Model_Datatype
11
+ * @copyright 2013 Code-X GmbH
12
+ * @link http://code-x.de
13
+ * @since File available since Release 0.1.0
14
+ */
15
+
16
+ /**
17
+ * The Transaction type specifies the details of a transaction.
18
+ *
19
+ * Used by methods
20
+ *
21
+ * Request:
22
+ * - POST shops/{id}/baskets/{id}/transaction
23
+ * Response:
24
+ * - GET shops/{shopId}/baskets/{basketId}/transaction
25
+ *
26
+ *
27
+ * @category Datatype
28
+ * @package Codex_Yapital_Model_Datatype
29
+ * @copyright 2013 Code-X GmbH
30
+ * @link http://code-x.de
31
+ * @since Class available since Release 0.1.0
32
+ */
33
+ class Codex_Yapital_Model_Datatype_Transaction extends Codex_Yapital_Model_Datatype_Abstract
34
+ implements Codex_Yapital_Model_Datatype_Interface
35
+ {
36
+
37
+ /**
38
+ * @var Codex_Yapital_Model_Datatype_YapitalPublicId
39
+ */
40
+ protected $_transactionId;
41
+
42
+ /**
43
+ * @var string
44
+ */
45
+ protected $_qrCodeUrl;
46
+
47
+ /**
48
+ * @var Codex_Yapital_Model_Datatype_QRCodeBinary
49
+ */
50
+ protected $_qrCodeBin;
51
+
52
+ /**
53
+ * @var string
54
+ */
55
+ protected $_transactionStatus;
56
+
57
+ /**
58
+ * @var string
59
+ */
60
+ protected $_transactionDate;
61
+
62
+ /**
63
+ * @var string
64
+ */
65
+ protected $_orderNumber;
66
+
67
+ /**
68
+ * @var string
69
+ */
70
+ protected $_invoiceNumber;
71
+
72
+ /**
73
+ * @var string
74
+ */
75
+ protected $_returnUrl;
76
+
77
+ /**
78
+ * @var string
79
+ */
80
+ protected $_cancelUrl;
81
+
82
+ /**
83
+ * @var string
84
+ */
85
+ protected $_errorUrl;
86
+
87
+ /**
88
+ * @param string $cancelUrl
89
+ */
90
+ public function setCancelUrl ( $cancelUrl )
91
+ {
92
+
93
+ $this->_cancelUrl = $cancelUrl;
94
+
95
+ return $this;
96
+ }
97
+
98
+ /**
99
+ * @return string
100
+ */
101
+ public function getCancelUrl ()
102
+ {
103
+
104
+ return (string) $this->_cancelUrl;
105
+ }
106
+
107
+ /**
108
+ * @param string $errorUrl
109
+ */
110
+ public function setErrorUrl ( $errorUrl )
111
+ {
112
+
113
+ $this->_errorUrl = $errorUrl;
114
+
115
+ return $this;
116
+ }
117
+
118
+ /**
119
+ * @return string
120
+ */
121
+ public function getErrorUrl ()
122
+ {
123
+
124
+ return (string) $this->_errorUrl;
125
+ }
126
+
127
+ /**
128
+ * @param string $invoiceNumber
129
+ */
130
+ public function setInvoiceNumber ( $invoiceNumber )
131
+ {
132
+
133
+ $this->_invoiceNumber = $invoiceNumber;
134
+
135
+ return $this;
136
+ }
137
+
138
+ /**
139
+ * @return string
140
+ */
141
+ public function getInvoiceNumber ()
142
+ {
143
+
144
+ return (string) $this->_invoiceNumber;
145
+ }
146
+
147
+ /**
148
+ * @param string $orderNumber
149
+ */
150
+ public function setOrderNumber ( $orderNumber )
151
+ {
152
+
153
+ $this->_orderNumber = $orderNumber;
154
+
155
+ return $this;
156
+ }
157
+
158
+ /**
159
+ * @return string
160
+ */
161
+ public function getOrderNumber ()
162
+ {
163
+
164
+ return (string) $this->_orderNumber;
165
+ }
166
+
167
+ /**
168
+ * @param \Codex_Yapital_Model_Datatype_QRCodeBinary $qrCodeBin
169
+ */
170
+ public function setQrCodeBin ( $qrCodeBin )
171
+ {
172
+
173
+ $this->_qrCodeBin = $qrCodeBin;
174
+
175
+ return $this;
176
+ }
177
+
178
+ /**
179
+ * @return \Codex_Yapital_Model_Datatype_QRCodeBinary
180
+ */
181
+ public function getQrCodeBin ()
182
+ {
183
+
184
+ return $this->_qrCodeBin;
185
+ }
186
+
187
+ /**
188
+ * @param string $qrCodeUrl
189
+ */
190
+ public function setQrCodeUrl ( $qrCodeUrl )
191
+ {
192
+
193
+ $this->_qrCodeUrl = $qrCodeUrl;
194
+
195
+ return $this;
196
+ }
197
+
198
+ /**
199
+ * @return string
200
+ */
201
+ public function getQrCodeUrl ()
202
+ {
203
+
204
+ return (string) $this->_qrCodeUrl;
205
+ }
206
+
207
+ /**
208
+ * @param string $returnUrl
209
+ */
210
+ public function setReturnUrl ( $returnUrl )
211
+ {
212
+
213
+ $this->_returnUrl = $returnUrl;
214
+
215
+ return $this;
216
+ }
217
+
218
+ /**
219
+ * @return string
220
+ */
221
+ public function getReturnUrl ()
222
+ {
223
+
224
+ return (string) $this->_returnUrl;
225
+ }
226
+
227
+ /**
228
+ * @param \Codex_Yapital_Model_Datatype_YapitalPublicId $transactionId
229
+ */
230
+ public function setTransactionId ( $transactionId )
231
+ {
232
+
233
+ $this->_transactionId = $transactionId;
234
+
235
+ return $this;
236
+ }
237
+
238
+ /**
239
+ * @return \Codex_Yapital_Model_Datatype_YapitalPublicId
240
+ */
241
+ public function getTransactionId ()
242
+ {
243
+
244
+ return $this->_transactionId;
245
+ }
246
+
247
+ /**
248
+ * @param string $transactionStatus
249
+ */
250
+ public function setTransactionStatus ( $transactionStatus )
251
+ {
252
+
253
+ $this->_transactionStatus = $transactionStatus;
254
+
255
+ return $this;
256
+ }
257
+
258
+ /**
259
+ * @return \Codex_Yapital_Model_Datatype_TransactionStatus
260
+ */
261
+ public function getTransactionStatus ()
262
+ {
263
+
264
+ return $this->_transactionStatus;
265
+ }
266
+
267
+ /**
268
+ * @param string $transationDate
269
+ */
270
+ public function setTransactionDate ( $transationDate )
271
+ {
272
+
273
+ $this->_transactionDate = $transationDate;
274
+
275
+ return $this;
276
+ }
277
+
278
+ /**
279
+ * @return string
280
+ */
281
+ public function getTransactionDate ()
282
+ {
283
+
284
+ return $this->_transactionDate;
285
+ }
286
+
287
+ /**
288
+ * Imports an order into this transaction
289
+ *
290
+ * @todo import correct?
291
+ *
292
+ * @param Mage_Sales_Model_Order $order
293
+ *
294
+ * @return Codex_Yapital_Model_Datatype_Transaction
295
+ */
296
+ public function importOrder ( Mage_Sales_Model_Order $order )
297
+ {
298
+ $this->_getConfig()->setStoreId( $order->getStoreId() );
299
+
300
+ $this->setOrderNumber($order->getRealOrderId());
301
+ $this->setInvoiceNumber($order->getQuoteId());
302
+
303
+ $this->setReturnUrl( $this->_getUrl('success', $order) );
304
+ $this->setCancelUrl( $this->_getUrl('cancel', $order) );
305
+ $this->setErrorUrl( $this->_getUrl('error', $order) );
306
+
307
+ return $this;
308
+ }
309
+
310
+ protected function _getUrl( $action, Mage_Sales_Model_Order $order )
311
+ {
312
+ $this->_getConfig()->setStoreId( $order->getStoreId() );
313
+
314
+ $helper = Mage::helper('yapital');
315
+ /* @var $helper Codex_Yapital_Helper_Data */
316
+
317
+ return Mage::getUrl ('yapital/standard/'.$action,
318
+ array( 'order_id' => $order->getId(),
319
+ 'secret' => $helper->getOrderHash( $order )
320
+ )
321
+ );
322
+ }
323
+
324
+ function getData ()
325
+ {
326
+
327
+ return array(
328
+ // "transaction_id" => $this->getTransactionId(),
329
+ "qr_code_url" => $this->getQrCodeUrl(),
330
+ // "qr_code_bin" => $this->getQrCodeBin(),
331
+ // "transaction_status" => $this->getTransactionStatus(),
332
+ // "transaction_date" => $this->getTransactionDate(),
333
+ "order_number" => $this->getOrderNumber(),
334
+ "invoice_number" => $this->getInvoiceNumber(),
335
+ "return_url" => $this->getReturnUrl(),
336
+ "cancel_url" => $this->getCancelUrl(),
337
+ "error_url" => $this->getErrorUrl(),
338
+ );
339
+ }
340
+ }
app/code/community/Codex/Yapital/Model/Notification.php CHANGED
@@ -53,6 +53,14 @@ class Codex_Yapital_Model_Notification extends Mage_Core_Model_Abstract
53
  $this->setData('event_id', $data['event_id']);
54
  $this->setData('event_timestamp', $data['event_timestamp']);
55
 
 
 
 
 
 
 
 
 
56
  return $this;
57
  }
58
 
@@ -95,6 +103,22 @@ class Codex_Yapital_Model_Notification extends Mage_Core_Model_Abstract
95
  return $this;
96
  }
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  public function getCallbackUrl() {
99
  return Mage::getUrl('yapital/notification/receive', array('_forced_secure' => true, 'secret' => $this->getSecret() ) );
100
  }
53
  $this->setData('event_id', $data['event_id']);
54
  $this->setData('event_timestamp', $data['event_timestamp']);
55
 
56
+ Codex_Yapital_Model_Log::log(
57
+ sprintf("Processing Notification-Id #%s, Transaction-Id #%s, Magento-Order-Id %s",
58
+ $this->getData('notification_id'),
59
+ $this->getData('transaction_id'),
60
+ $this->getTransaction()->getOrder()->getIncrementId()
61
+ )
62
+ );
63
+
64
  return $this;
65
  }
66
 
103
  return $this;
104
  }
105
 
106
+ /**
107
+ * This method serves to get all notifications to which the shop is subscribed.
108
+ *
109
+ * @return Codex_Yapital_Model_Datatype_Notification[]
110
+ */
111
+ public function getRegistered()
112
+ {
113
+ /* @var $notification Codex_Yapital_Model_Datatype_Notification */
114
+ $notification = Mage::getModel("yapital/datatype_notification");
115
+
116
+ $api = Mage::getModel("yapital/api_notification");
117
+ /* @var $api Codex_Yapital_Model_Api_Notification */
118
+
119
+ return $api->getAll();
120
+ }
121
+
122
  public function getCallbackUrl() {
123
  return Mage::getUrl('yapital/notification/receive', array('_forced_secure' => true, 'secret' => $this->getSecret() ) );
124
  }
app/code/community/Codex/Yapital/Model/Observer.php CHANGED
@@ -1,5 +1,6 @@
1
  <?php
2
 
 
3
  class Codex_Yapital_Model_Observer
4
  {
5
  public function aggregateYapitalReportOrderPaymentData($schedule)
@@ -7,8 +8,8 @@ class Codex_Yapital_Model_Observer
7
  Mage::app()->getLocale()->emulate(0);
8
  $currentDate = Mage::app()->getLocale()->date();
9
  $date = $currentDate->subHour(25);
10
- Mage::getResourceModel('yapital/report_paymentmethod')->aggregate($date);
 
11
  Mage::app()->getLocale()->revert();
12
- return $this;
13
  }
14
- }
1
  <?php
2
 
3
+ // Mage::getModel('yapital/observer')->aggregateYapitalReportOrderPaymentData('')
4
  class Codex_Yapital_Model_Observer
5
  {
6
  public function aggregateYapitalReportOrderPaymentData($schedule)
8
  Mage::app()->getLocale()->emulate(0);
9
  $currentDate = Mage::app()->getLocale()->date();
10
  $date = $currentDate->subHour(25);
11
+ $paymentMethod = Mage::getResourceModel('yapital/report_paymentmethod');
12
+ $paymentMethod->aggregate($date);
13
  Mage::app()->getLocale()->revert();
 
14
  }
15
+ }
app/code/community/Codex/Yapital/Model/Payment/Standard.php CHANGED
@@ -29,6 +29,8 @@ class Codex_Yapital_Model_Payment_Standard extends Mage_Payment_Model_Method_Abs
29
 
30
  public function initialize($paymentAction, $stateObject)
31
  {
 
 
32
  $state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
33
  $stateObject->setState($state);
34
  $stateObject->setStatus('pending_payment');
@@ -57,6 +59,14 @@ class Codex_Yapital_Model_Payment_Standard extends Mage_Payment_Model_Method_Abs
57
  $amountModel->setCurrency(Codex_Yapital_Model_Datatype_Currency::EUR);
58
  $amountModel->setValue($amount);
59
 
 
 
 
 
 
 
 
 
60
  $basket->setAmountToCredit($amountModel);
61
 
62
  /** @var $config Codex_Yapital_Model_Config */
29
 
30
  public function initialize($paymentAction, $stateObject)
31
  {
32
+ Codex_Yapital_Model_Log::debug('Payment_Standard::initialize()');
33
+
34
  $state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
35
  $stateObject->setState($state);
36
  $stateObject->setStatus('pending_payment');
59
  $amountModel->setCurrency(Codex_Yapital_Model_Datatype_Currency::EUR);
60
  $amountModel->setValue($amount);
61
 
62
+ Codex_Yapital_Model_Log::verbose(
63
+ sprintf(
64
+ 'Refunding cash (%d %s)',
65
+ $amountModel->getValue(),
66
+ $amountModel->getCurrency()
67
+ )
68
+ );
69
+
70
  $basket->setAmountToCredit($amountModel);
71
 
72
  /** @var $config Codex_Yapital_Model_Config */
app/code/community/Codex/Yapital/Model/Resource/Report/Paymentmethod.php CHANGED
@@ -190,8 +190,9 @@ class Codex_Yapital_Model_Resource_Report_Paymentmethod extends Mage_Sales_Model
190
  Mage_Sales_Model_Order::STATE_NEW
191
  ));
192
 
 
193
  if ($subSelect !== null) {
194
- $select->having($this->_makeConditionFromDateRangeSelect($subSelect, 'period'));
195
  }
196
 
197
  $select->group(array(
@@ -201,6 +202,7 @@ class Codex_Yapital_Model_Resource_Report_Paymentmethod extends Mage_Sales_Model
201
  'o.status',
202
  ));
203
 
 
204
  $adapter->query($select->insertFromSelect($this->getMainTable(), array_keys($columns)));
205
 
206
  // setup all columns to select SUM() except period, store_id and order_status
190
  Mage_Sales_Model_Order::STATE_NEW
191
  ));
192
 
193
+
194
  if ($subSelect !== null) {
195
+ // $select->having($this->_makeConditionFromDateRangeSelect($subSelect, 'period'));
196
  }
197
 
198
  $select->group(array(
202
  'o.status',
203
  ));
204
 
205
+
206
  $adapter->query($select->insertFromSelect($this->getMainTable(), array_keys($columns)));
207
 
208
  // setup all columns to select SUM() except period, store_id and order_status
app/code/community/Codex/Yapital/controllers/Adminhtml/Yapital/ConfigController.php CHANGED
@@ -3,72 +3,125 @@
3
  class Codex_Yapital_Adminhtml_Yapital_ConfigController extends Mage_Adminhtml_Controller_Action
4
  {
5
 
6
- public function validateAction ()
7
  {
8
- session_write_close();
 
9
 
10
- Codex_Yapital_Model_Log::log("Validating user given credentials");
 
 
 
 
 
 
 
11
 
12
- $dataHelper = Mage::helper('yapital/data');
13
- $result = array();
14
- $result["message"] = $dataHelper->__('We are sorry! Something went wrong.');
15
- $result["has_errors"] = true;
16
 
17
- try
18
- {
 
19
 
20
- if ( isset( $_REQUEST['shop_id'] ) )
21
- {
22
- /**
23
- * @var $tokenModel Codex_Yapital_Model_Api_Token
24
- */
25
- $tokenModel = Mage::getModel("yapital/api_token");
26
- $token = $tokenModel->getTokenByFullCredentials(
27
- $_REQUEST['shop_id'],
28
- $_REQUEST['client_id'],
29
- $_REQUEST['secret_key']
30
- );
31
 
32
- if ( "" != $token->getAccessToken() )
33
- {
34
- $result["message"] = $dataHelper->__(
35
- 'Congratulations! Store this config to let your customer pay easily with yapital.'
36
- );
37
- $result["has_errors"] = false;
38
- }
39
- else
40
- {
41
- $result["message"] = $dataHelper->__('No access token received');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  }
43
  }
44
 
45
- }
46
- catch ( Exception $e )
47
- {
48
- $result["message"] = "Error: " . $e->getMessage();
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
- if (true == $result["has_errors"]) {
52
- Codex_Yapital_Model_Log::log("Unable to validate user given credentials.");
53
  }
54
 
55
- $resultJSON = Mage::helper('core')->jsonEncode($result);
56
-
57
- $this->getResponse()->setBody($resultJSON);
58
-
59
  }
60
 
61
- public function validateSandboxAction ()
62
  {
63
  session_write_close();
64
 
65
- /** @var $config Codex_Yapital_Model_Config */
66
- $config = Mage::getSingleton('yapital/config');
67
- $config->setSandbox( true );
68
-
69
  Codex_Yapital_Model_Log::log("Validating user given credentials");
70
 
71
- $dataHelper = Mage::helper('yapital/data');
72
  $result = array();
73
  $result["message"] = $dataHelper->__('We are sorry! Something went wrong.');
74
  $result["has_errors"] = true;
@@ -76,7 +129,7 @@ class Codex_Yapital_Adminhtml_Yapital_ConfigController extends Mage_Adminhtml_Co
76
  try
77
  {
78
 
79
- if ( isset( $_REQUEST['shop_id'] ) )
80
  {
81
  /**
82
  * @var $tokenModel Codex_Yapital_Model_Api_Token
@@ -88,22 +141,29 @@ class Codex_Yapital_Adminhtml_Yapital_ConfigController extends Mage_Adminhtml_Co
88
  $_REQUEST['secret_key']
89
  );
90
 
91
- if ( "" != $token->getAccessToken() )
92
  {
93
  $result["message"] = $dataHelper->__(
94
  'Congratulations! Store this config to let your customer pay easily with yapital.'
95
  );
96
  $result["has_errors"] = false;
97
  }
 
 
 
 
 
 
98
  }
99
 
100
- }
101
- catch ( Exception $e )
102
  {
103
  $result["message"] = "Error: " . $e->getMessage();
104
  }
105
 
106
- if (true == $result["has_errors"]) {
 
 
107
  Codex_Yapital_Model_Log::log("Unable to validate user given credentials.");
108
  }
109
 
@@ -113,11 +173,4 @@ class Codex_Yapital_Adminhtml_Yapital_ConfigController extends Mage_Adminhtml_Co
113
 
114
  }
115
 
116
- public function statusAction ()
117
- {
118
- $result = array();
119
-
120
- $result = Mage::helper('core')->jsonEncode($result);
121
- Mage::app()->getResponse()->setBody($result);
122
- }
123
  }
3
  class Codex_Yapital_Adminhtml_Yapital_ConfigController extends Mage_Adminhtml_Controller_Action
4
  {
5
 
6
+ public function preDispatch()
7
  {
8
+ /** @var $config Codex_Yapital_Model_Config */
9
+ $config = Mage::getSingleton('yapital/config');
10
 
11
+ if ($this->getRequest()->getParam('sandbox', false))
12
+ {
13
+ $config->setSandbox(true);
14
+ } else {
15
+ $config->setSandbox(false);
16
+ }
17
+ parent::preDispatch();
18
+ }
19
 
20
+ public function statusAction()
21
+ {
22
+ $result = array();
 
23
 
24
+ $result = Mage::helper('core')->jsonEncode($result);
25
+ Mage::app()->getResponse()->setBody($result);
26
+ }
27
 
28
+ public function updateAction()
29
+ {
30
+ Codex_Yapital_Model_Log::log("Updating transactions");
 
 
 
 
 
 
 
 
31
 
32
+ /** @var Mage_Captcha_Helper_Data $coreHelper */
33
+ $coreHelper = Mage::helper('core');
34
+
35
+ $config = Mage::getModel('yapital/config');
36
+
37
+ $refreshFrom = date('Y-m-d', strtotime("today -1 week"));
38
+
39
+ try {
40
+ /** @var $restClient Codex_Yapital_Model_Api_Connection */
41
+ $restClient = Mage::getModel('yapital/api_connection', $config->getApiUrl());
42
+ $result = $restClient->restGet(
43
+ $config->getApiUrlPath() .
44
+ sprintf('/shops/%s/transactions', $config->getYapitalShopId()),
45
+ array(
46
+ 'from' => $refreshFrom,
47
+ 'until' => date("Y-m-d", strtotime("today +1 day"))
48
+ )
49
+ );
50
+
51
+ $updatedTransactions = 0;
52
+ $transactions = $coreHelper->jsonDecode($result->getBody(), Zend_Json::TYPE_OBJECT);
53
+
54
+ if (!empty($transactions->error)) {
55
+ throw new Exception('API Exception: '.$transactions->error_description);
56
+ }
57
+
58
+ $order = Mage::getModel('sales/order');
59
+ foreach ($transactions->payload->transaction as $transaction) {
60
+ if ($transaction->transaction_status == Codex_Yapital_Model_Datatype_TransactionStatus::PAID) {
61
+ $order->load($transaction->order_number, 'increment_id');
62
+
63
+ if ($order->getId() && $config->getOrderPaidState() != $order->getStatus()) {
64
+
65
+ /** @var $orderTransaction Codex_Yapital_Model_Order_Transaction */
66
+ $orderTransaction = Mage::getModel('yapital/order_transaction');
67
+ $orderTransaction->load($transaction->transaction_id, 'transaction_id');
68
+ if ($orderTransaction->getId() && $orderTransaction->getOrderId() == $order->getId()) {
69
+
70
+ /* @var $notification Codex_Yapital_Model_Notification */
71
+ $notification = Mage::getModel('yapital/notification');
72
+ $notification->setData( array(
73
+ 'notification_id' => null,
74
+ 'transaction_id' => $transaction->transaction_id,
75
+ 'status_code' => $transaction->transaction_status,
76
+ 'status_information' => null,
77
+ 'customer_data' => null,
78
+ 'amount' => $transaction->total_amount,
79
+ 'currency' => $transaction->currency,
80
+ ));
81
+
82
+ $notification->processOrder();
83
+
84
+ $updatedTransactions++;
85
+ Codex_Yapital_Model_Log::log("Order #".$order->getId() ." updated.");
86
+ }
87
+ }
88
  }
89
  }
90
 
91
+ $this->getResponse()->setBody(
92
+ $coreHelper->jsonEncode(
93
+ array(
94
+ 'success' => true,
95
+ 'updated' => $updatedTransactions,
96
+ 'from' => $refreshFrom,
97
+ 'message' => Mage::helper('yapital')->__('%s transaction successfully updated.', $updatedTransactions)
98
+ ))
99
+ );
100
+ } catch (Exception $e) {
101
+
102
+ Codex_Yapital_Model_Log::log('Exception '.$e->getMessage());
103
+
104
+ $this->getResponse()->setBody(
105
+ $coreHelper->jsonEncode(
106
+ array(
107
+ 'success' => false,
108
+ 'from' => $refreshFrom,
109
+ 'message' => Mage::helper('yapital')->__('We are sorry! Something went wrong.')
110
+ ))
111
+ );
112
 
 
 
113
  }
114
 
115
+ return;
 
 
 
116
  }
117
 
118
+ public function validateAction()
119
  {
120
  session_write_close();
121
 
 
 
 
 
122
  Codex_Yapital_Model_Log::log("Validating user given credentials");
123
 
124
+ $dataHelper = Mage::helper('yapital');
125
  $result = array();
126
  $result["message"] = $dataHelper->__('We are sorry! Something went wrong.');
127
  $result["has_errors"] = true;
129
  try
130
  {
131
 
132
+ if (isset($_REQUEST['shop_id']))
133
  {
134
  /**
135
  * @var $tokenModel Codex_Yapital_Model_Api_Token
141
  $_REQUEST['secret_key']
142
  );
143
 
144
+ if ("" != $token->getAccessToken())
145
  {
146
  $result["message"] = $dataHelper->__(
147
  'Congratulations! Store this config to let your customer pay easily with yapital.'
148
  );
149
  $result["has_errors"] = false;
150
  }
151
+ else
152
+ {
153
+ $result["message"] = $dataHelper->__(
154
+ 'No access token received. Please check your credentials'
155
+ );
156
+ }
157
  }
158
 
159
+ } catch (Exception $e)
 
160
  {
161
  $result["message"] = "Error: " . $e->getMessage();
162
  }
163
 
164
+ if (true == $result["has_errors"])
165
+ {
166
+ Codex_Yapital_Model_Log::debug( $result['message'] );
167
  Codex_Yapital_Model_Log::log("Unable to validate user given credentials.");
168
  }
169
 
173
 
174
  }
175
 
 
 
 
 
 
 
 
176
  }
app/code/community/Codex/Yapital/controllers/Adminhtml/Yapital/DocumentationController.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Codex_Yapital_Adminhtml_Yapital_DocumentationController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ /**
6
+ * Add report/sales breadcrumbs
7
+ *
8
+ * @return Mage_Adminhtml_Report_SalesController
9
+ */
10
+ public function _initAction()
11
+ {
12
+ parent::_initAction();
13
+ $helper = Mage::helper('yapital');
14
+ $this->_addBreadcrumb($helper->__('Yapital'), $helper->__('Yapital'));
15
+ return $this;
16
+ }
17
+
18
+ public function mainAction()
19
+ {
20
+ echo "foo";
21
+ }
22
+
23
+ protected function _isAllowed()
24
+ {
25
+ switch ($this->getRequest()->getActionName()) {
26
+ case 'payment':
27
+ return $this->_getSession()->isAllowed('report/yapital/payment');
28
+ break;
29
+ default:
30
+ return $this->_getSession()->isAllowed('report/yapital');
31
+ break;
32
+ }
33
+ }
34
+ }
app/code/community/Codex/Yapital/controllers/Adminhtml/Yapital/NotificationController.php CHANGED
@@ -24,11 +24,21 @@ class Codex_Yapital_Adminhtml_Yapital_NotificationController extends Mage_Adminh
24
  );
25
  }
26
 
 
 
 
 
 
 
 
 
 
 
 
27
  public function registerAction ()
28
  {
29
  session_write_close();
30
 
31
- $dataHelper = Mage::helper('yapital/data');
32
  $result = $this->_getStandardResult();
33
 
34
  if ( isset( $_REQUEST['notification_secret'] ) )
@@ -49,8 +59,6 @@ class Codex_Yapital_Adminhtml_Yapital_NotificationController extends Mage_Adminh
49
  }
50
  catch ( Codex_Yapital_ErrorException $e )
51
  {
52
- $config = Mage::getModel('yapital/config');
53
-
54
  if ( $e->getMessage() == "Rest-Request failed: Duplicate entry found." )
55
  {
56
  $result["has_errors"] = false;
@@ -98,4 +106,65 @@ class Codex_Yapital_Adminhtml_Yapital_NotificationController extends Mage_Adminh
98
  $result = Mage::helper('core')->jsonEncode($result);
99
  Mage::app()->getResponse()->setBody($result);
100
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  }
24
  );
25
  }
26
 
27
+ public function preDispatch()
28
+ {
29
+ if( $this->getRequest()->getParam('sandbox', false) )
30
+ {
31
+ /** @var $config Codex_Yapital_Model_Config */
32
+ $config = Mage::getSingleton('yapital/config');
33
+ $config->setSandbox( true );
34
+ }
35
+ parent::preDispatch();
36
+ }
37
+
38
  public function registerAction ()
39
  {
40
  session_write_close();
41
 
 
42
  $result = $this->_getStandardResult();
43
 
44
  if ( isset( $_REQUEST['notification_secret'] ) )
59
  }
60
  catch ( Codex_Yapital_ErrorException $e )
61
  {
 
 
62
  if ( $e->getMessage() == "Rest-Request failed: Duplicate entry found." )
63
  {
64
  $result["has_errors"] = false;
106
  $result = Mage::helper('core')->jsonEncode($result);
107
  Mage::app()->getResponse()->setBody($result);
108
  }
109
+
110
+ public function unregisterAction()
111
+ {
112
+ session_write_close();
113
+
114
+ $result = $this->_getStandardResult();
115
+
116
+ /** @var $notification Codex_Yapital_Model_Notification */
117
+ $notification = Mage::getModel('yapital/notification');
118
+
119
+ $api = Mage::getModel("yapital/api_notification");
120
+ /* @var $api Codex_Yapital_Model_Api_Notification */
121
+
122
+ $error_cnt = 0;
123
+ $delete_cnt = 0;
124
+
125
+ foreach( $notification->getRegistered() AS $_notification )
126
+ {
127
+ try {
128
+ $api->delete( $_notification->getNotificationId() );
129
+ $delete_cnt++;
130
+ } catch( Exception $e )
131
+ {
132
+ $error_cnt++;
133
+ }
134
+ }
135
+
136
+ if( $error_cnt )
137
+ {
138
+ $result['has_errors'] = true;
139
+ $result['message'] =
140
+ $this->__('Sorry, but your notifications could not be deleted. Please try again later or <a onclick="window.open(this.href); return false;" href="https://www.yapital.com/consumer/index.html#customersupport">contact Yapital.</a>');
141
+ } else {
142
+ $result['has_errors'] = false;
143
+ $result['message'] = $this->__('%s notification(s) have been deleted.', $delete_cnt );
144
+ }
145
+
146
+ $result = Mage::helper('core')->jsonEncode($result);
147
+ Mage::app()->getResponse()->setBody($result);
148
+ }
149
+
150
+ public function showAction()
151
+ {
152
+ session_write_close();
153
+
154
+ $result = array();
155
+
156
+ /** @var $notification Codex_Yapital_Model_Notification */
157
+ $notification = Mage::getModel('yapital/notification');
158
+
159
+ $api = Mage::getModel("yapital/api_notification");
160
+ /* @var $api Codex_Yapital_Model_Api_Notification */
161
+
162
+ foreach( $notification->getRegistered() AS $_notification )
163
+ {
164
+ $result[] = $_notification->getData();
165
+ }
166
+
167
+ $result = Mage::helper('core')->jsonEncode($result);
168
+ Mage::app()->getResponse()->setBody($result);
169
+ }
170
  }
app/code/community/Codex/Yapital/controllers/Adminhtml/Yapital/SandboxController.php DELETED
@@ -1,105 +0,0 @@
1
- <?php
2
-
3
- class Codex_Yapital_Adminhtml_Yapital_SandboxController extends Mage_Adminhtml_Controller_Action
4
- {
5
-
6
- /**
7
- * @return Codex_Yapital_Model_Notification
8
- */
9
- protected function _getNotificationModel ()
10
- {
11
- return Mage::getModel('yapital/notification');
12
- }
13
-
14
- protected function _getDataHelper ()
15
- {
16
- return Mage::helper('yapital/data');
17
- }
18
-
19
- protected function _getStandardResult ()
20
- {
21
- return array(
22
- "message" => $this->_getDataHelper()->__('We are sorry! Something went wrong.'),
23
- "has_errors" => true,
24
- );
25
- }
26
-
27
- public function preDispatch()
28
- {
29
- /** @var $config Codex_Yapital_Model_Config */
30
- $config = Mage::getSingleton('yapital/config');
31
- $config->setSandbox( true );
32
- }
33
-
34
- public function registerAction ()
35
- {
36
- session_write_close();
37
-
38
- $dataHelper = Mage::helper('yapital/data');
39
- $result = $this->_getStandardResult();
40
-
41
- if ( isset( $_REQUEST['notification_secret'] ) )
42
- {
43
- $notificationModel = $this->_getNotificationModel();
44
-
45
- try
46
- {
47
- $notificationModel->register();
48
-
49
- $result["has_errors"] = false;
50
- $result["message"] = $this->_getDataHelper()->__('Notification has been registered.');
51
-
52
- }
53
- catch ( Codex_Yapital_ErrorException $e )
54
- {
55
- $config = Mage::getModel('yapital/config');
56
-
57
- if ( $e->getMessage() == "Rest-Request failed: Duplicate entry found." )
58
- {
59
- $result["has_errors"] = false;
60
- $result["message"] = $this->_getDataHelper()->__('Notification was already registered.');
61
- }
62
- else
63
- {
64
- throw $e;
65
- $result["message"] = $this->__("Internal error [%d]: ", $e->getCode()) . $e->getMessage();
66
- }
67
- }
68
-
69
- }
70
-
71
- $resultJSON = Mage::helper('core')->jsonEncode($result);
72
-
73
- $this->getResponse()->setBody($resultJSON);
74
-
75
- }
76
-
77
- public function statusAction ()
78
- {
79
- $dataHelper = Mage::helper('yapital/data');
80
- $result = $this->_getStandardResult();
81
-
82
- $api = Mage::getModel('yapital/api_notification');
83
- /* @var $api Codex_Yapital_Model_Api_Notification */
84
-
85
- /* @var $notification Codex_Yapital_Model_Datatype_Notification */
86
- $tmpNotification = current($api->getAll());
87
-
88
- $notificationId = $tmpNotification->getNotificationId();
89
-
90
- if ( null !== $notificationId )
91
- {
92
- $notification = $api->get($notificationId);
93
-
94
- if ( $notification instanceof Codex_Yapital_Model_Datatype_Notification
95
- && $notificationId == $notification->getNotificationId()
96
- )
97
- {
98
- $result["message"] = $dataHelper->__('Valid.');
99
- }
100
- }
101
-
102
- $result = Mage::helper('core')->jsonEncode($result);
103
- Mage::app()->getResponse()->setBody($result);
104
- }
105
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Codex/Yapital/controllers/NotificationController.php CHANGED
@@ -2,7 +2,9 @@
2
 
3
  class Codex_Yapital_NotificationController extends Mage_Core_Controller_Front_Action {
4
 
5
- public function receiveAction() {
 
 
6
 
7
  $notification = Mage::getModel('yapital/notification');
8
  /* @var $notification Codex_Yapital_Model_Notification */
@@ -13,29 +15,39 @@ class Codex_Yapital_NotificationController extends Mage_Core_Controller_Front_Ac
13
  }
14
 
15
  $data = json_decode( $json , true );
16
- if ( is_array( $data ) || true ) {
17
  $notification->import( $data );
18
 
 
 
 
 
 
 
 
 
 
19
  if ( $notification->getSecret() != '' && $notification->getSecret() == $this->getRequest()->getParam('secret') )
20
  {
21
  try {
22
  $notification->save();
23
  $notification->processOrder();
 
24
  $this->getResponse()->setHttpResponseCode(200); // OK
25
  } catch ( Exception $e ) {
26
- Codex_Yapital_Model_Log::error( "notification:" .$e->getMessage() );
27
  $this->getResponse()->setHttpResponseCode(500); // Internal Server Error (Exception)
28
  }
29
 
30
  } else {
31
- Codex_Yapital_Model_Log::error('notification: invalid secret');
32
  $this->getResponse()->setHttpResponseCode(403); // Invalid Secret, Forbidden
33
  }
34
 
35
 
36
  } else {
37
  Codex_Yapital_Model_Log::error('notification: empty request');
38
- $this->getResponse()->setHttpResponseCode(200); // To validate Notifications
39
  }
40
 
41
  $this->getResponse()->setBody('fin');
2
 
3
  class Codex_Yapital_NotificationController extends Mage_Core_Controller_Front_Action {
4
 
5
+ public function receiveAction()
6
+ {
7
+ Codex_Yapital_Model_Log::log("notification: processing");
8
 
9
  $notification = Mage::getModel('yapital/notification');
10
  /* @var $notification Codex_Yapital_Model_Notification */
15
  }
16
 
17
  $data = json_decode( $json , true );
18
+ if ( is_array( $data ) ) {
19
  $notification->import( $data );
20
 
21
+ $notificationPrefix = "notification";
22
+
23
+ if ($notification->getId())
24
+ {
25
+ $notificationPrefix .= " (" . $notification->getId() . ")";
26
+ }
27
+
28
+ $notificationPrefix .= ": ";
29
+
30
  if ( $notification->getSecret() != '' && $notification->getSecret() == $this->getRequest()->getParam('secret') )
31
  {
32
  try {
33
  $notification->save();
34
  $notification->processOrder();
35
+ Codex_Yapital_Model_Log::log($notificationPrefix . "success");
36
  $this->getResponse()->setHttpResponseCode(200); // OK
37
  } catch ( Exception $e ) {
38
+ Codex_Yapital_Model_Log::error($notificationPrefix . $e->getMessage());
39
  $this->getResponse()->setHttpResponseCode(500); // Internal Server Error (Exception)
40
  }
41
 
42
  } else {
43
+ Codex_Yapital_Model_Log::error($notificationPrefix . 'invalid secret');
44
  $this->getResponse()->setHttpResponseCode(403); // Invalid Secret, Forbidden
45
  }
46
 
47
 
48
  } else {
49
  Codex_Yapital_Model_Log::error('notification: empty request');
50
+ $this->getResponse()->setHttpResponseCode(200); // Incase of not sending 200 everything breaks!
51
  }
52
 
53
  $this->getResponse()->setBody('fin');
app/code/community/Codex/Yapital/controllers/StandardController.php CHANGED
@@ -79,13 +79,15 @@ class Codex_Yapital_StandardController extends Mage_Core_Controller_Front_Action
79
  */
80
  public function errorAction ()
81
  {
82
- if ( $order = $this->_getOrder() ) {
83
- if ($order->getId()) {
84
- $order->addStatusHistoryComment('Error during checkout with yapital');
85
- $order->cancel()->save();
86
- }
87
- }
88
 
 
 
 
 
 
89
  $this->loadLayout();
90
  $this->renderLayout();
91
  }
79
  */
80
  public function errorAction ()
81
  {
82
+ $this->loadLayout();
83
+ $this->renderLayout();
84
+ }
 
 
 
85
 
86
+ /**
87
+ * wenn yapital-customer got an error
88
+ */
89
+ public function documentationAction ()
90
+ {
91
  $this->loadLayout();
92
  $this->renderLayout();
93
  }
app/code/community/Codex/Yapital/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Codex_Yapital>
5
- <version>1.0.0.0</version>
6
  </Codex_Yapital>
7
  </modules>
8
 
@@ -57,6 +57,16 @@
57
  </yapital_setup>
58
  </resources>
59
 
 
 
 
 
 
 
 
 
 
 
60
  </global>
61
 
62
  <phpunit>
@@ -84,15 +94,6 @@
84
  </yapital>
85
  </updates>
86
  </layout>
87
- <translate>
88
- <modules>
89
- <Codex_Yapital>
90
- <files>
91
- <default>Codex_Yapital.csv</default>
92
- </files>
93
- </Codex_Yapital>
94
- </modules>
95
- </translate>
96
  </frontend>
97
 
98
  <adminhtml>
@@ -134,7 +135,7 @@
134
  <yapital>
135
  <url>
136
  <base>https://secure.yapital.com</base>
137
- <api>api/v0.1</api>
138
  <iframe_script>/beta/js/widget/script.js</iframe_script>
139
  </url>
140
  </yapital>
@@ -142,8 +143,8 @@
142
  <yapital_sandbox>
143
  <url>
144
  <base>https://demo.dev.yapital.com</base>
145
- <api>/3pnext/api/v0.1</api>
146
- <iframe_script>/3pnext/web-ui/js/widget/script.js</iframe_script>
147
  </url>
148
  </yapital_sandbox>
149
 
@@ -158,4 +159,21 @@
158
  </yapital_standard>
159
  </payment>
160
  </default>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  </config>
2
  <config>
3
  <modules>
4
  <Codex_Yapital>
5
+ <version>1.1.0</version>
6
  </Codex_Yapital>
7
  </modules>
8
 
57
  </yapital_setup>
58
  </resources>
59
 
60
+ <translate>
61
+ <modules>
62
+ <Codex_Yapital>
63
+ <files>
64
+ <default>Codex_Yapital.csv</default>
65
+ </files>
66
+ </Codex_Yapital>
67
+ </modules>
68
+ </translate>
69
+
70
  </global>
71
 
72
  <phpunit>
94
  </yapital>
95
  </updates>
96
  </layout>
 
 
 
 
 
 
 
 
 
97
  </frontend>
98
 
99
  <adminhtml>
135
  <yapital>
136
  <url>
137
  <base>https://secure.yapital.com</base>
138
+ <api>/api/v0.1</api>
139
  <iframe_script>/beta/js/widget/script.js</iframe_script>
140
  </url>
141
  </yapital>
143
  <yapital_sandbox>
144
  <url>
145
  <base>https://demo.dev.yapital.com</base>
146
+ <api>/api/v0.1</api>
147
+ <iframe_script>/web-ui/js/widget/script.js</iframe_script>
148
  </url>
149
  </yapital_sandbox>
150
 
159
  </yapital_standard>
160
  </payment>
161
  </default>
162
+
163
+ <behat>
164
+ <contexts>
165
+ <Codex_Yapital_Test_FeatureContext>
166
+ <active>1</active>
167
+ </Codex_Yapital_Test_FeatureContext>
168
+ </contexts>
169
+ <tests>
170
+ <Codex_Yapital>
171
+ <active>1</active>
172
+ <features>
173
+ <backend_config><active>1</active></backend_config>
174
+ <checkout><active>1</active></checkout>
175
+ </features>
176
+ </Codex_Yapital>
177
+ </tests>
178
+ </behat>
179
  </config>
app/code/community/Codex/Yapital/etc/system.xml CHANGED
@@ -10,11 +10,15 @@
10
  <show_in_default>1</show_in_default>
11
  <show_in_website>1</show_in_website>
12
  <show_in_store>0</show_in_store>
13
- <comment><![CDATA[
14
- Please fill out the information below. Read this documentation of
15
- tests you need to run before going online: <a href="http://code-x.de">Documentation</a>
16
- ]]></comment>
17
  <fields>
 
 
 
 
 
 
 
 
18
  <active translate="label">
19
  <label>Enabled</label>
20
  <frontend_type>select</frontend_type>
@@ -65,7 +69,7 @@
65
  </heading_credentials>
66
 
67
  <shop_id translate="label">
68
- <label>Shop-Id</label>
69
  <frontend_type>text</frontend_type>
70
  <sort_order>610</sort_order>
71
  <show_in_default>1</show_in_default>
@@ -73,7 +77,7 @@
73
  </shop_id>
74
 
75
  <client_id translate="label">
76
- <label>Client-Id</label>
77
  <frontend_type>text</frontend_type>
78
  <sort_order>630</sort_order>
79
  <show_in_default>1</show_in_default>
@@ -81,7 +85,7 @@
81
  </client_id>
82
 
83
  <secret_key translate="label">
84
- <label>Secret key</label>
85
  <frontend_type>text</frontend_type>
86
  <sort_order>660</sort_order>
87
  <show_in_default>1</show_in_default>
@@ -90,7 +94,7 @@
90
 
91
  <check_credentials translate="comment">
92
  <label>Test credentials</label>
93
- <frontend_type>button</frontend_type>
94
  <frontend_model>yapital/system_config_storage_credentials_validate</frontend_model>
95
  <sort_order>690</sort_order>
96
  <show_in_default>1</show_in_default>
@@ -104,6 +108,7 @@
104
 
105
  <notification_secret translate="label">
106
  <label>Secret</label>
 
107
  <frontend_type>text</frontend_type>
108
  <sort_order>692</sort_order>
109
  <show_in_default>1</show_in_default>
@@ -115,16 +120,15 @@
115
  <!-- "Generate a new secret"-Button -->
116
  <label></label>
117
  <frontend_type>button</frontend_type>
118
- <frontend_model>yapital/system_config_storage_credentials_live_secret</frontend_model>
119
  <sort_order>694</sort_order>
120
  <show_in_default>1</show_in_default>
121
  <show_in_website>1</show_in_website>
122
  </notifcation_secret_button>
123
 
124
  <notification_id translate="label">
125
- <label>Yapital Notification Id</label>
126
  <!-- TDOO readonly -->
127
- <frontend_type>text</frontend_type>
128
  <sort_order>696</sort_order>
129
  <show_in_default>1</show_in_default>
130
  <show_in_website>0</show_in_website>
@@ -150,7 +154,7 @@
150
  </heading_sandbox>
151
 
152
  <sandbox_shop_id translate="label">
153
- <label>Shop-Id</label>
154
  <frontend_type>text</frontend_type>
155
  <sort_order>810</sort_order>
156
  <show_in_default>1</show_in_default>
@@ -158,7 +162,7 @@
158
  </sandbox_shop_id>
159
 
160
  <sandbox_client_id translate="label">
161
- <label>Client-Id</label>
162
  <frontend_type>text</frontend_type>
163
  <sort_order>830</sort_order>
164
  <show_in_default>1</show_in_default>
@@ -166,7 +170,7 @@
166
  </sandbox_client_id>
167
 
168
  <sandbox_secret_key translate="label">
169
- <label>Secret key</label>
170
  <frontend_type>text</frontend_type>
171
  <sort_order>860</sort_order>
172
  <show_in_default>1</show_in_default>
@@ -177,7 +181,7 @@
177
  <!--"validate sandbox"-button-->
178
  <label>Test credentials</label>
179
  <frontend_type>button</frontend_type>
180
- <frontend_model>yapital/config_credentials_sandbox</frontend_model>
181
  <sort_order>865</sort_order>
182
  <show_in_default>1</show_in_default>
183
  <show_in_website>1</show_in_website>
@@ -188,6 +192,28 @@
188
  ]]></comment>
189
  </sandbox_check_credentials>
190
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  <sandbox_notification_secret translate="label">
192
  <label>Notification Secret</label>
193
  <frontend_type>text</frontend_type>
@@ -220,15 +246,27 @@
220
  <label></label>
221
  <frontend_type>button</frontend_type>
222
  <!-- "Register sandbox notification"-Button -->
223
- <frontend_model>yapital/config_notification_sandbox</frontend_model>
224
  <sort_order>890</sort_order>
225
  <show_in_default>1</show_in_default>
226
  <show_in_website>1</show_in_website>
227
  </sandbox_button>
228
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  </fields>
230
  </yapital_standard>
231
  </groups>
232
  </payment>
233
  </sections>
234
- </config>
10
  <show_in_default>1</show_in_default>
11
  <show_in_website>1</show_in_website>
12
  <show_in_store>0</show_in_store>
 
 
 
 
13
  <fields>
14
+ <head translate="label">
15
+ <label>Yapital</label>
16
+ <frontend_model>yapital/system_config_head</frontend_model>
17
+ <sort_order>10</sort_order>
18
+ <show_in_default>1</show_in_default>
19
+ <show_in_website>1</show_in_website>
20
+ </head>
21
+
22
  <active translate="label">
23
  <label>Enabled</label>
24
  <frontend_type>select</frontend_type>
69
  </heading_credentials>
70
 
71
  <shop_id translate="label">
72
+ <label>Shop ID</label>
73
  <frontend_type>text</frontend_type>
74
  <sort_order>610</sort_order>
75
  <show_in_default>1</show_in_default>
77
  </shop_id>
78
 
79
  <client_id translate="label">
80
+ <label>Public ID</label>
81
  <frontend_type>text</frontend_type>
82
  <sort_order>630</sort_order>
83
  <show_in_default>1</show_in_default>
85
  </client_id>
86
 
87
  <secret_key translate="label">
88
+ <label>Secret ID</label>
89
  <frontend_type>text</frontend_type>
90
  <sort_order>660</sort_order>
91
  <show_in_default>1</show_in_default>
94
 
95
  <check_credentials translate="comment">
96
  <label>Test credentials</label>
97
+ <frontend_class>button</frontend_class>
98
  <frontend_model>yapital/system_config_storage_credentials_validate</frontend_model>
99
  <sort_order>690</sort_order>
100
  <show_in_default>1</show_in_default>
108
 
109
  <notification_secret translate="label">
110
  <label>Secret</label>
111
+ <tooltip>Insert your secret here.</tooltip>
112
  <frontend_type>text</frontend_type>
113
  <sort_order>692</sort_order>
114
  <show_in_default>1</show_in_default>
120
  <!-- "Generate a new secret"-Button -->
121
  <label></label>
122
  <frontend_type>button</frontend_type>
123
+ <frontend_model>yapital/system_config_storage_credentials_secret</frontend_model>
124
  <sort_order>694</sort_order>
125
  <show_in_default>1</show_in_default>
126
  <show_in_website>1</show_in_website>
127
  </notifcation_secret_button>
128
 
129
  <notification_id translate="label">
 
130
  <!-- TDOO readonly -->
131
+ <frontend_type>hidden</frontend_type>
132
  <sort_order>696</sort_order>
133
  <show_in_default>1</show_in_default>
134
  <show_in_website>0</show_in_website>
154
  </heading_sandbox>
155
 
156
  <sandbox_shop_id translate="label">
157
+ <label>Shop ID</label>
158
  <frontend_type>text</frontend_type>
159
  <sort_order>810</sort_order>
160
  <show_in_default>1</show_in_default>
162
  </sandbox_shop_id>
163
 
164
  <sandbox_client_id translate="label">
165
+ <label>Public ID</label>
166
  <frontend_type>text</frontend_type>
167
  <sort_order>830</sort_order>
168
  <show_in_default>1</show_in_default>
170
  </sandbox_client_id>
171
 
172
  <sandbox_secret_key translate="label">
173
+ <label>Secret ID</label>
174
  <frontend_type>text</frontend_type>
175
  <sort_order>860</sort_order>
176
  <show_in_default>1</show_in_default>
181
  <!--"validate sandbox"-button-->
182
  <label>Test credentials</label>
183
  <frontend_type>button</frontend_type>
184
+ <frontend_model>yapital/system_config_storage_credentials_sandbox_validate</frontend_model>
185
  <sort_order>865</sort_order>
186
  <show_in_default>1</show_in_default>
187
  <show_in_website>1</show_in_website>
192
  ]]></comment>
193
  </sandbox_check_credentials>
194
 
195
+ <sandbox_apiuri translate="label">
196
+ <label>Sandbox API-URI</label>
197
+ <frontend_type>text</frontend_type>
198
+ <sort_order>866</sort_order>
199
+ <show_in_default>1</show_in_default>
200
+ <show_in_website>1</show_in_website>
201
+ <comment><![CDATA[
202
+ Providing a value here allows you to override the API-URI that was set in the XML config.
203
+ ]]></comment>
204
+ </sandbox_apiuri>
205
+
206
+ <sandbox_apipath translate="label">
207
+ <label>Sandbox API-Path</label>
208
+ <frontend_type>text</frontend_type>
209
+ <sort_order>867</sort_order>
210
+ <show_in_default>1</show_in_default>
211
+ <show_in_website>1</show_in_website>
212
+ <comment><![CDATA[
213
+ Providing a value here allows you to override the API path that was set in the XML config.
214
+ ]]></comment>
215
+ </sandbox_apipath>
216
+
217
  <sandbox_notification_secret translate="label">
218
  <label>Notification Secret</label>
219
  <frontend_type>text</frontend_type>
246
  <label></label>
247
  <frontend_type>button</frontend_type>
248
  <!-- "Register sandbox notification"-Button -->
249
+ <frontend_model>yapital/system_config_storage_credentials_sandbox_notification</frontend_model>
250
  <sort_order>890</sort_order>
251
  <show_in_default>1</show_in_default>
252
  <show_in_website>1</show_in_website>
253
  </sandbox_button>
254
 
255
+ <sandbox_update_status translate="comment">
256
+ <label>Fetch pending payments</label>
257
+ <frontend_class>button</frontend_class>
258
+ <frontend_model>yapital/system_config_storage_credentials_sandbox_update</frontend_model>
259
+ <sort_order>900</sort_order>
260
+ <show_in_default>1</show_in_default>
261
+ <show_in_website>1</show_in_website>
262
+ <comment><![CDATA[
263
+ Check once again if your pending payments has been paid yet.
264
+ ]]></comment>
265
+ </sandbox_update_status>
266
+
267
  </fields>
268
  </yapital_standard>
269
  </groups>
270
  </payment>
271
  </sections>
272
+ </config>
app/code/community/Codex/Yapital/sql/yapital_setup/mysql4-upgrade-0.2.0-0.3.0.php CHANGED
@@ -4,7 +4,7 @@
4
  $installer = $this;
5
  $installer->startSetup();
6
 
7
- Mage::log('codex_yapital update to 0.3.0', null, '', true);
8
 
9
  /**
10
  * Create table 'sales/order_aggregated_payment'
4
  $installer = $this;
5
  $installer->startSetup();
6
 
7
+ Codex_Yapital_Model_Log::log('codex_yapital update to 0.3.0', null, '', true);
8
 
9
  /**
10
  * Create table 'sales/order_aggregated_payment'
app/design/adminhtml/default/default/layout/yapital.xml CHANGED
@@ -1,6 +1,15 @@
1
  <?xml version="1.0"?>
2
  <layout version="0.1.0">
3
 
 
 
 
 
 
 
 
 
 
4
  <report_yapital>
5
  <reference name="messages">
6
  <action method="addNotice" translate="message">
@@ -12,9 +21,13 @@
12
  <adminhtml_report_yapital_payment>
13
  <update handle="report_yapital"/>
14
  <reference name="content">
15
- <block type="yapital/adminhtml_report_yapital_payment" template="report/grid/container.phtml" name="yapital.report.grid.container">
16
- <block type="adminhtml/store_switcher" template="report/store/switcher/enhanced.phtml" name="store.switcher">
17
- <action method="setStoreVarName"><var_name>store_ids</var_name></action>
 
 
 
 
18
  </block>
19
  <block type="sales/adminhtml_report_filter_form_order" name="grid.filter.form">
20
  <action method="addReportTypeOption" translate="value">
@@ -34,4 +47,4 @@
34
  </block>
35
  </reference>
36
  </adminhtml_report_yapital_payment>
37
- </layout>
1
  <?xml version="1.0"?>
2
  <layout version="0.1.0">
3
 
4
+ <default>
5
+ <reference name="head">
6
+ <action method="addItem">
7
+ <type>skin_js</type>
8
+ <name>yapital.js</name>
9
+ </action>
10
+ </reference>
11
+ </default>
12
+
13
  <report_yapital>
14
  <reference name="messages">
15
  <action method="addNotice" translate="message">
21
  <adminhtml_report_yapital_payment>
22
  <update handle="report_yapital"/>
23
  <reference name="content">
24
+ <block type="yapital/adminhtml_report_yapital_payment" template="report/grid/container.phtml"
25
+ name="yapital.report.grid.container">
26
+ <block type="adminhtml/store_switcher" template="report/store/switcher/enhanced.phtml"
27
+ name="store.switcher">
28
+ <action method="setStoreVarName">
29
+ <var_name>store_ids</var_name>
30
+ </action>
31
  </block>
32
  <block type="sales/adminhtml_report_filter_form_order" name="grid.filter.form">
33
  <action method="addReportTypeOption" translate="value">
47
  </block>
48
  </reference>
49
  </adminhtml_report_yapital_payment>
50
+ </layout>
app/design/adminhtml/default/default/template/yapital/.gitignore DELETED
File without changes
app/design/adminhtml/default/default/template/yapital/config/credentials/notification.phtml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php /* @var $this Codex_Yapital_Block_System_Config_Storage_Credentials_Notification */ ?>
2
+
3
+ <?php echo $this->getButtonHtml() ?><span class="validation-indicator no-display" id="<?php echo $this->getConfigPath(); ?>_notification_span"><img
4
+ alt="Synchronize" style="margin:0 5px" src="<?php echo $this->getSkinUrl('images/process_spinner.gif')
5
+ ?>"/></span><span id="<?php echo $this->getConfigPath(); ?>_notification_message_span"></span>
6
+ <input type="hidden" id="<?php echo $this->getConfigPath(); ?>_validation-input" class="required-validation no-display"/>
7
+
8
+ <div style="margin-top: 6px">
9
+ <?php echo $this->getButtonUnregisterHtml(); ?>
10
+ </div>
app/design/adminhtml/default/default/template/yapital/config/credentials/sandbox.phtml DELETED
@@ -1,152 +0,0 @@
1
- <?php /* var $this Codex_Yapital_Block_System_Config_Storage_Credentials_Validate */ ?>
2
-
3
- <script type="text/javascript">
4
- //<![CDATA[
5
- <!-- Validation.add('required-validation', '--><?php //echo $this->__('Validation is required.') ?><!--', function () {-->
6
- <!-- storage = getConnectionName(-->
7
- <!-- $('payment_yapital_standard_sandbox_client_id').value,-->
8
- <!-- $('payment_yapital_standard_sandbox_secret_key').value-->
9
- <!-- );-->
10
- <!---->
11
- <!-- console.log(allowedNotifications);-->
12
- <!---->
13
- <!-- return allowedNotifications.include(storage);-->
14
- <!-- });-->
15
-
16
- defaultValues = [];
17
- defaultValues['payment_yapital_standard_sandbox_client_id'] = $('payment_yapital_standard_sandbox_client_id').value;
18
- defaultValues['system_media_storage_configuration_media_database'] = $('payment_yapital_standard_sandbox_secret_key').value;
19
-
20
- allowedNotifications = [];
21
- addAllowedStorage(
22
- $('payment_yapital_standard_sandbox_client_id').value,
23
- $('payment_yapital_standard_sandbox_secret_key').value
24
- );
25
-
26
- function getConnectionName(storageType, connection) {
27
- return storageType + '_' + connection;
28
- }
29
-
30
- function addAllowedStorage(storageType, connection) {
31
- var storage = getConnectionName(storageType, connection);
32
-
33
- if (storage != getConnectionName('', '') && !allowedNotifications.include(storage)) {
34
- allowedNotifications.push(storage);
35
- }
36
- }
37
-
38
- function checkButtonState(event) {
39
- var element = Event.element(event);
40
-
41
- var defaultStorage = getConnectionName(
42
- defaultValues['payment_yapital_standard_sandbox_client_id'],
43
- defaultValues['payment_yapital_standard_sandbox_secret_key']
44
- );
45
-
46
- storage = getConnectionName(
47
- $('payment_yapital_standard_sandbox_client_id').value,
48
- $('payment_yapital_standard_sandbox_secret_key').value
49
- );
50
-
51
- if (defaultStorage != storage) {
52
- enableValidateButton();
53
- } else {
54
- disableValidateButton();
55
- }
56
- }
57
-
58
- function enableStorageSelection() {
59
- $('payment_yapital_standard_sandbox_client_id').enable('enabled');
60
- $('payment_yapital_standard_sandbox_secret_key').enable('enabled');
61
- }
62
-
63
- function disableStorageSelection() {
64
- $('payment_yapital_standard_sandbox_client_id').disable('disabled');
65
- $('payment_yapital_standard_sandbox_secret_key').disable('disabled');
66
- }
67
-
68
- function enableValidateButton() {
69
- Form.Element.enable('validate_button');
70
- $('validate_button').removeClassName('disabled');
71
- }
72
-
73
- function disableValidateButton() {
74
- Form.Element.disable('validate_button');
75
- $('validate_button').addClassName('disabled');
76
- }
77
-
78
- Event.observe(window, 'load', function () {
79
- //disableStorageSelection();
80
- //disableValidateButton();
81
- //checkStatus();
82
- });
83
- $('payment_yapital_standard_sandbox_client_id').observe('change', checkButtonState);
84
- $('payment_yapital_standard_sandbox_secret_key').observe('change', checkButtonState);
85
-
86
- function yapitalCheckStatus() {
87
-
88
- }
89
-
90
- function validateSandboxYapital() {
91
- //var advice = Validation.getAdvice('required-validation', $('synchronize-validation-input'));
92
- //if (advice) {
93
- // advice.hide();
94
- //}
95
- console.log("validateYapital()");
96
-
97
- params = {
98
- shop_id : 1,
99
- client_id :$('payment_yapital_standard_sandbox_client_id').value,
100
- secret_key:$('payment_yapital_standard_sandbox_secret_key').value
101
- };
102
-
103
- $('credentials_sandbox_message_span').addClassName('no-display');
104
- $('credentials_sandbox_span').removeClassName('no-display');
105
-
106
- new Ajax.Request('<?php echo $this->getAjaxValidateUpdateUrl() ?>', {
107
- parameters :params,
108
- loaderArea :false,
109
- asynchronous:false,
110
- onSuccess :function (transport) {
111
- var response;
112
-
113
- response = eval('(' + transport.responseText + ')');
114
- console.log(response);
115
- if (false == response.has_errors) {
116
- // no errors: it works!
117
- disableValidateButton();
118
- } else {
119
- // TODO ERROR
120
- }
121
-
122
- allowedNotifications.push(getConnectionName(
123
- $('payment_yapital_standard_sandbox_client_id').value,
124
- $('payment_yapital_standard_sandbox_secret_key').value
125
- ));
126
-
127
- $('credentials_sandbox_span').addClassName('no-display');
128
- $('credentials_sandbox_message_span').removeClassName('no-display');
129
- $('credentials_sandbox_message_span').update(response.message);
130
- },
131
-
132
- onFailure:function (transport) {
133
- $('credentials_sandbox_span').addClassName('no-display');
134
- $('credentials_sandbox_message_span').removeClassName('no-display');
135
- $('credentials_sandbox_message_span').update('<?php echo $this->__('Internal error during validation.') ?>');
136
- }
137
-
138
- });
139
-
140
- //window.setTimeout('yapitalCheckStatus()', 2011);
141
-
142
- //disableStorageSelection();
143
- //disableValidateButton();
144
- enableValidateButton();
145
- }
146
- //]]>
147
- </script>
148
-
149
- <?php echo $this->getButtonHtml() ?><span class="validation-indicator no-display" id="credentials_sandbox_span"><img
150
- alt="Synchronize" style="margin:0 5px" src="<?php echo $this->getSkinUrl('images/process_spinner.gif')
151
- ?>"/></span><span id="credentials_sandbox_message_span"></span>
152
- <input type="hidden" id="validation-input" class="required-validation no-display"/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/template/yapital/config/credentials/secret.phtml ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php /* var $this Codex_Yapital_Block_System_Config_Storage_Credentials_Validate */ ?>
2
+ <?php echo $this->getButtonHtml() ?>
app/design/adminhtml/default/default/template/yapital/config/credentials/update.phtml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php /** @var Codex_Yapital_Block_System_Config_Storage_Credentials_Update $this */ ?>
2
+
3
+ <?php echo $this->getButtonHtml() ?>
4
+ <span class="update-indicator no-display" id="<?php echo $this->getConfigPath(); ?>_update_span"><img
5
+ alt="Synchronize" style="margin:0 5px" src="<?php echo $this->getSkinUrl('images/process_spinner.gif')
6
+ ?>"/></span><span id="<?php echo $this->getConfigPath(); ?>_update_message_span"></span>
7
+ <input type="hidden" id="<?php echo $this->getConfigPath(); ?>_update-input"
8
+ class="required-update no-display"/>
app/design/adminhtml/default/default/template/yapital/config/credentials/validate.phtml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php /* @var $this Codex_Yapital_Block_System_Config_Storage_Credentials_Validate */ ?>
2
+
3
+ <script type="text/javascript">
4
+ var <?php echo $this->getConfigPath(); ?>_yapitalConfig = new YapitalConfig( <?php echo $this->getJSConfig() ?> );
5
+ </script>
6
+
7
+ <?php echo $this->getButtonHtml() ?><span class="validation-indicator no-display" id="<?php echo $this->getConfigPath(); ?>_validation_span"><img
8
+ alt="Synchronize" style="margin:0 5px" src="<?php echo $this->getSkinUrl('images/process_spinner.gif')
9
+ ?>"/></span><span id="<?php echo $this->getConfigPath(); ?>_validation_message_span"></span>
10
+ <input type="hidden" id="<?php echo $this->getConfigPath(); ?>_validation-input" class="required-validation no-display"/>
app/design/adminhtml/default/default/template/yapital/config/head.phtml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /** @var Codex_Yapital_Block_System_Config_Head $this */ ?>
2
+ <img src="<?php echo $this->getSkinUrl('images/codex/yapital/yapital150x39.png') ?>" />
3
+
4
+ <p>
5
+ <?php echo $this->helper('yapital')->__('Please fill out the information below.') ?>
6
+ <?php echo $this->helper('yapital')->__(
7
+ 'Read this documentation of tests you need to run before going online:'
8
+ ) ?>
9
+ <a href="<?php echo Mage::getUrl('yapital/standard/documentation') ?>">
10
+ <?php echo $this->helper('yapital')->__('Documentation') ?>
11
+ </a>
12
+ </p>
app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/live/secret.phtml DELETED
@@ -1,21 +0,0 @@
1
- <?php /* var $this Codex_Yapital_Block_System_Config_Storage_Credentials_Validate */ ?>
2
-
3
- <script type="text/javascript">
4
- //<![CDATA[
5
- function yapitalGenerateNotificationSecret() {
6
- var uniq = Math.floor(Math.random() * 0xF + 10).toString(36);
7
- uniq += Math.floor(Math.random() * 0x100000000).toString(36);
8
- uniq += Math.floor(Math.random() * 0x1000).toString(36);
9
- uniq += Math.floor(Math.random() * 0x1000).toString(36);
10
- uniq += Math.floor(Math.random() * 0x1000).toString(36);
11
-
12
- return uniq;
13
- }
14
-
15
- function yapitalLiveGenerateNotificationSecret() {
16
- $('payment_yapital_standard_notification_secret').value = yapitalGenerateNotificationSecret();
17
- }
18
- //]]>
19
- </script>
20
-
21
- <?php echo $this->getButtonHtml() ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/notification.phtml DELETED
@@ -1,145 +0,0 @@
1
- <?php /* var $this Codex_Yapital_Block_System_Config_Storage_Credentials_Notification */ ?>
2
-
3
- <script type="text/javascript">
4
- //<![CDATA[
5
- /* Validation.add('required-validation', '<?php echo $this->__('Validation is required.') ?>', function(){
6
- storage = yapitalGetNotificationName(
7
- $('payment_yapital_standard_notification_secret').value,
8
- $('payment_yapital_standard_notification_id').value
9
- );
10
-
11
- return allowedNotifications.include(storage);
12
- }); */
13
-
14
- defaultValues = [];
15
- defaultValues['payment_yapital_standard_notification_secret'] = $('payment_yapital_standard_notification_secret').value;
16
- defaultValues['payment_yapital_standard_notification_id'] = $('payment_yapital_standard_notification_id').value;
17
-
18
- allowedNotifications = [];
19
- yapitalAddAllowedNotification(
20
- $('payment_yapital_standard_notification_secret').value,
21
- $('payment_yapital_standard_notification_id').value
22
- );
23
-
24
- function yapitalGetNotificationName(storageType, connection) {
25
- return storageType + '_' + connection;
26
- }
27
-
28
- function yapitalAddAllowedNotification(storageType, connection) {
29
- var storage = yapitalGetNotificationName(storageType, connection);
30
-
31
- if (storage != '' && !allowedNotifications.include(storage)) {
32
- allowedNotifications.push(storage);
33
- }
34
- }
35
-
36
- function yapitalNotificationsCheckButtonState(event) {
37
- var element = Event.element(event);
38
-
39
- var defaultStorage = yapitalGetNotificationName(
40
- defaultValues['payment_yapital_standard_notification_secret'],
41
- defaultValues['payment_yapital_standard_notification_id']
42
- );
43
-
44
- var storage = yapitalGetNotificationName(
45
- $('payment_yapital_standard_notification_secret').value,
46
- $('payment_yapital_standard_notification_id').value
47
- );
48
-
49
- if (defaultStorage != storage) {
50
- enableValidateButton();
51
- } else {
52
- disableValidateButton();
53
- }
54
- }
55
-
56
- function enableStorageSelection() {
57
- $('payment_yapital_standard_notification_secret').enable('enabled');
58
- $('payment_yapital_standard_notification_id').enable('enabled');
59
- }
60
-
61
- function disableStorageSelection() {
62
- $('payment_yapital_standard_notification_secret').disable('disabled');
63
- $('payment_yapital_standard_notification_id').disable('disabled');
64
- }
65
-
66
- function enableValidateButton() {
67
- Form.Element.enable('validate_button');
68
- $('validate_button').removeClassName('disabled');
69
- }
70
-
71
- function disableValidateButton() {
72
- Form.Element.disable('validate_button');
73
- $('validate_button').addClassName('disabled');
74
- }
75
-
76
- Event.observe(window, 'load', function () {
77
- //disableStorageSelection();
78
- //disableValidateButton();
79
- //checkStatus();
80
- });
81
- $('payment_yapital_standard_notification_secret').observe('change', yapitalNotificationsCheckButtonState);
82
- $('payment_yapital_standard_notification_id').observe('change', yapitalNotificationsCheckButtonState);
83
-
84
- function yapitalCheckNotificationStatus() {
85
-
86
- }
87
-
88
- function yapitalNotificationRegister() {
89
- //var advice = Validation.getAdvice('required-validation', $('synchronize-validation-input'));
90
- //if (advice) {
91
- // advice.hide();
92
- //}
93
-
94
- params = {
95
- store_id :1,
96
- notification_secret :$('payment_yapital_standard_notification_secret').value,
97
- notification_id:$('payment_yapital_standard_notification_id').value
98
- };
99
-
100
- $('notification_message_span').addClassName('no-display');
101
- $('notification_span').removeClassName('no-display');
102
-
103
- new Ajax.Request('<?php echo $this->getAjaxRegisterUrl() ?>', {
104
- parameters :params,
105
- loaderArea :false,
106
- asynchronous:false,
107
- onSuccess :function (transport) {
108
- var response;
109
-
110
- response = eval('(' + transport.responseText + ')');
111
- console.log(response);
112
- if (false == response.has_errors) {
113
- // no errors: it works!
114
- disableValidateButton();
115
- } else {
116
- // TODO ERROR
117
- }
118
-
119
- allowedNotifications.push(yapitalGetNotificationName(
120
- $('payment_yapital_standard_notification_secret').value,
121
- $('payment_yapital_standard_notification_id').value
122
- ));
123
-
124
- $('notification_span').addClassName('no-display');
125
- $('notification_message_span').removeClassName('no-display');
126
- $('notification_message_span').update(response.message);
127
- },
128
-
129
- onFailure:function (transport) {
130
- $('validation_span').addClassName('no-display');
131
- $('validation_message_span').removeClassName('no-display');
132
- $('validation_message_span').update('<?php echo $this->__('Internal error during validation.') ?>');
133
- }
134
-
135
- });
136
-
137
- enableValidateButton();
138
- }
139
- //]]>
140
- </script>
141
-
142
- <?php echo $this->getButtonHtml() ?><span class="validation-indicator no-display" id="notification_span"><img
143
- alt="Synchronize" style="margin:0 5px" src="<?php echo $this->getSkinUrl('images/process_spinner.gif')
144
- ?>"/></span><span id="notification_message_span"></span>
145
- <input type="hidden" id="validation-input" class="required-validation no-display"/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/sandbox.phtml DELETED
@@ -1,144 +0,0 @@
1
- <?php /* var $this Codex_Yapital_Block_System_Config_Storage_Credentials_Notification */ ?>
2
-
3
- <script type="text/javascript">
4
- //<![CDATA[
5
- /* Validation.add('required-validation', '<?php echo $this->__('Validation is required.') ?>', function(){
6
- storage = yapitalGetSandboxName(
7
- $('payment_yapital_standard_sandbox_notification_secret').value,
8
- $('payment_yapital_standard_sandbox_id').value
9
- );
10
-
11
- return allowedSandboxs.include(storage);
12
- }); */
13
-
14
- defaultValues = [];
15
- defaultValues['payment_yapital_standard_sandbox_notification_secret'] = $('payment_yapital_standard_sandbox_notification_secret').value;
16
- defaultValues['payment_yapital_standard_sandbox_id'] = $('payment_yapital_standard_sandbox_id').value;
17
-
18
- allowedSandboxs = [];
19
- yapitalAddAllowedSandbox(
20
- $('payment_yapital_standard_sandbox_notification_secret').value,
21
- $('payment_yapital_standard_sandbox_id').value
22
- );
23
-
24
- function yapitalGetSandboxName(storageType, connection) {
25
- return storageType + '_' + connection;
26
- }
27
-
28
- function yapitalAddAllowedSandbox(storageType, connection) {
29
- var storage = yapitalGetSandboxName(storageType, connection);
30
-
31
- if (storage != '' && !allowedSandboxs.include(storage)) {
32
- allowedSandboxs.push(storage);
33
- }
34
- }
35
-
36
- function yapitalSandboxsCheckButtonState(event) {
37
- var element = Event.element(event);
38
-
39
- var defaultStorage = yapitalGetSandboxName(
40
- defaultValues['payment_yapital_standard_sandbox_notification_secret'],
41
- defaultValues['payment_yapital_standard_sandbox_id']
42
- );
43
-
44
- storage = yapitalGetSandboxName(
45
- $('payment_yapital_standard_sandbox_notification_secret').value,
46
- $('payment_yapital_standard_sandbox_id').value
47
- );
48
-
49
- if (defaultStorage != storage) {
50
- enableValidateButton();
51
- } else {
52
- disableValidateButton();
53
- }
54
- }
55
-
56
- function enableStorageSelection() {
57
- $('payment_yapital_standard_sandbox_notification_secret').enable('enabled');
58
- $('payment_yapital_standard_sandbox_id').enable('enabled');
59
- }
60
-
61
- function disableStorageSelection() {
62
- $('payment_yapital_standard_sandbox_notification_secret').disable('disabled');
63
- $('payment_yapital_standard_sandbox_id').disable('disabled');
64
- }
65
-
66
- function enableValidateButton() {
67
- Form.Element.enable('validate_button');
68
- $('validate_button').removeClassName('disabled');
69
- }
70
-
71
- function disableValidateButton() {
72
- Form.Element.disable('validate_button');
73
- $('validate_button').addClassName('disabled');
74
- }
75
-
76
- Event.observe(window, 'load', function () {
77
- //disableStorageSelection();
78
- //disableValidateButton();
79
- //checkStatus();
80
- });
81
- $('payment_yapital_standard_sandbox_notification_secret').observe('change', yapitalSandboxsCheckButtonState);
82
- $('payment_yapital_standard_sandbox_id').observe('change', yapitalSandboxsCheckButtonState);
83
-
84
- function yapitalCheckSandboxStatus() {
85
-
86
- }
87
-
88
- function yapitalSandboxRegister() {
89
- //var advice = Validation.getAdvice('required-validation', $('synchronize-validation-input'));
90
- //if (advice) {
91
- // advice.hide();
92
- //}
93
-
94
- params = {
95
- store_id :1,
96
- notification_secret :$('payment_yapital_standard_sandbox_notification_secret').value,
97
- notification_id:$('payment_yapital_standard_sandbox_id').value
98
- };
99
-
100
- $('sandbox_message_span').addClassName('no-display');
101
- $('sandbox_span').removeClassName('no-display');
102
-
103
- new Ajax.Request('<?php echo $this->getAjaxRegisterUrl() ?>', {
104
- parameters :params,
105
- loaderArea :false,
106
- asynchronous:false,
107
- onSuccess :function (transport) {
108
- var response;
109
-
110
- response = eval('(' + transport.responseText + ')');
111
- if (false == response.has_errors) {
112
- // no errors: it works!
113
- disableValidateButton();
114
- } else {
115
- // TODO ERROR
116
- }
117
-
118
- allowedSandboxs.push(yapitalGetSandboxName(
119
- $('payment_yapital_standard_sandbox_notification_secret').value,
120
- $('payment_yapital_standard_sandbox_id').value
121
- ));
122
-
123
- $('sandbox_span').addClassName('no-display');
124
- $('sandbox_message_span').removeClassName('no-display');
125
- $('sandbox_message_span').update(response.message);
126
- },
127
-
128
- onFailure:function (transport) {
129
- $('validation_span').addClassName('no-display');
130
- $('validation_message_span').removeClassName('no-display');
131
- $('validation_message_span').update('<?php echo $this->__('Internal error during validation.') ?>');
132
- }
133
-
134
- });
135
-
136
- enableValidateButton();
137
- }
138
- //]]>
139
- </script>
140
-
141
- <?php echo $this->getButtonHtml() ?><span class="validation-indicator no-display" id="sandbox_span"><img
142
- alt="Synchronize" style="margin:0 5px" src="<?php echo $this->getSkinUrl('images/process_spinner.gif')
143
- ?>"/></span><span id="sandbox_message_span"></span>
144
- <input type="hidden" id="validation-input" class="required-validation no-display"/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/sandbox/notification.phtml DELETED
@@ -1,144 +0,0 @@
1
- <?php /* var $this Codex_Yapital_Block_System_Config_Storage_Credentials_Notification */ ?>
2
-
3
- <script type="text/javascript">
4
- //<![CDATA[
5
- /* Validation.add('required-validation', '<?php echo $this->__('Validation is required.') ?>', function(){
6
- storage = yapitalGetNotificationName(
7
- $('payment_yapital_standard_sandbox_notification_secret').value,
8
- $('payment_yapital_standard_sandbox_notification_id').value
9
- );
10
-
11
- return allowedNotifications.include(storage);
12
- }); */
13
-
14
- defaultValues = [];
15
- defaultValues['payment_yapital_standard_sandbox_notification_secret'] = $('payment_yapital_standard_sandbox_notification_secret').value;
16
- defaultValues['payment_yapital_standard_sandbox_notification_id'] = $('payment_yapital_standard_sandbox_notification_id').value;
17
-
18
- allowedSandboxNotifications = [];
19
- yapitalSandboxAddAllowedNotification(
20
- $('payment_yapital_standard_sandbox_notification_secret').value,
21
- $('payment_yapital_standard_sandbox_notification_id').value
22
- );
23
-
24
- function yapitalSandboxGetNotificationName(notificationSecret, notificationId) {
25
- return notificationSecret + '_' + notificationId;
26
- }
27
-
28
- function yapitalSandboxAddAllowedNotification(storageType, connection) {
29
- var storage = yapitalSandboxGetNotificationName(storageType, connection);
30
-
31
- if (storage != '' && !allowedNotifications.include(storage)) {
32
- allowedSandboxNotifications.push(storage);
33
- }
34
- }
35
-
36
- function yapitalSandboxNotificationsCheckButtonState(event) {
37
- var element = Event.element(event);
38
-
39
- var defaultStorage = yapitalGetSandboxNotificationName(
40
- defaultValues['payment_yapital_standard_sandbox_notification_secret'],
41
- defaultValues['payment_yapital_standard_sandbox_notification_id']
42
- );
43
-
44
- storage = yapitalGetSandboxNotificationName(
45
- $('payment_yapital_standard_sandbox_notification_secret').value,
46
- $('payment_yapital_standard_sandbox_notification_id').value
47
- );
48
-
49
- if (defaultStorage != storage) {
50
- enableValidateButton();
51
- } else {
52
- disableValidateButton();
53
- }
54
- }
55
-
56
- function enableStorageSelection() {
57
- $('payment_yapital_standard_sandbox_notification_secret').enable('enabled');
58
- $('payment_yapital_standard_sandbox_notification_id').enable('enabled');
59
- }
60
-
61
- function disableStorageSelection() {
62
- $('payment_yapital_standard_sandbox_notification_secret').disable('disabled');
63
- $('payment_yapital_standard_sandbox_notification_id').disable('disabled');
64
- }
65
-
66
- function enableValidateButton() {
67
- Form.Element.enable('validate_button');
68
- $('validate_button').removeClassName('disabled');
69
- }
70
-
71
- function disableValidateButton() {
72
- Form.Element.disable('validate_button');
73
- $('validate_button').addClassName('disabled');
74
- }
75
-
76
- Event.observe(window, 'load', function () {
77
- //disableStorageSelection();
78
- //disableValidateButton();
79
- //checkStatus();
80
- });
81
- $('payment_yapital_standard_sandbox_notification_secret').observe('change', yapitalSandboxNotificationsCheckButtonState);
82
- $('payment_yapital_standard_sandbox_notification_id').observe('change', yapitalSandboxNotificationsCheckButtonState);
83
-
84
- function yapitalCheckSandboxNotificationStatus() {
85
-
86
- }
87
-
88
- function yapitalSandboxNotificationRegister() {
89
- //var advice = Validation.getAdvice('required-validation', $('synchronize-validation-input'));
90
- //if (advice) {
91
- // advice.hide();
92
- //}
93
-
94
- params = {
95
- store_id :1,
96
- notification_secret :$('payment_yapital_standard_sandbox_notification_secret').value,
97
- notification_id:$('payment_yapital_standard_sandbox_notification_id').value
98
- };
99
-
100
- $('sandbox_notification_message_span').addClassName('no-display');
101
- $('sandbox_notification_span').removeClassName('no-display');
102
-
103
- new Ajax.Request('<?php echo $this->getAjaxRegisterUrl() ?>', {
104
- parameters :params,
105
- loaderArea :false,
106
- asynchronous:false,
107
- onSuccess :function (transport) {
108
- var response;
109
-
110
- response = eval('(' + transport.responseText + ')');
111
- if (false == response.has_errors) {
112
- // no errors: it works!
113
- disableValidateButton();
114
- } else {
115
- // TODO ERROR
116
- }
117
-
118
- yapitalSandboxAddAllowedNotification(
119
- $('payment_yapital_standard_sandbox_notification_secret').value,
120
- $('payment_yapital_standard_sandbox_notification_id').value
121
- );
122
-
123
- $('sandbox_notification_span').addClassName('no-display');
124
- $('sandbox_notification_message_span').removeClassName('no-display');
125
- $('sandbox_notification_message_span').update(response.message);
126
- },
127
-
128
- onFailure:function (transport) {
129
- $('validation_span').addClassName('no-display');
130
- $('validation_message_span').removeClassName('no-display');
131
- $('validation_message_span').update('<?php echo $this->__('Internal error during validation.') ?>');
132
- }
133
-
134
- });
135
-
136
- enableValidateButton();
137
- }
138
- //]]>
139
- </script>
140
-
141
- <?php echo $this->getButtonHtml() ?><span class="validation-indicator no-display" id="sandbox_notification_span"><img
142
- alt="Synchronize" style="margin:0 5px" src="<?php echo $this->getSkinUrl('images/process_spinner.gif')
143
- ?>"/></span><span id="sandbox_notification_message_span"></span>
144
- <input type="hidden" id="validation-input" class="required-validation no-display"/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/sandbox/secret.phtml DELETED
@@ -1,11 +0,0 @@
1
- <?php /** @var $this Codex_Yapital_Block_System_Config_Storage_Credentials_Sandbox_Secret */ ?>
2
-
3
- <script type="text/javascript">
4
- //<![CDATA[
5
- function yapitalSandboxGenerateNotificationSecret() {
6
- $('payment_yapital_standard_sandbox_notification_secret').value = yapitalGenerateNotificationSecret();
7
- }
8
- //]]>
9
- </script>
10
-
11
- <?php echo $this->getButtonHtml() ?>
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/template/yapital/system/config/storage/credentials/validate.phtml DELETED
@@ -1,148 +0,0 @@
1
- <?php /* var $this Codex_Yapital_Block_System_Config_Storage_Credentials_Validate */ ?>
2
-
3
- <script type="text/javascript">
4
- //<![CDATA[
5
- Validation.add('required-validation', '<?php echo $this->__('Validation is required.') ?>', function () {
6
- var storage = getConnectionName(
7
- $('payment_yapital_standard_client_id').value,
8
- $('payment_yapital_standard_secret_key').value
9
- );
10
-
11
- return allowedNotifications.include(storage);
12
- });
13
-
14
- defaultValues = [];
15
- defaultValues['payment_yapital_standard_client_id'] = $('payment_yapital_standard_client_id').value;
16
- defaultValues['system_media_storage_configuration_media_database'] = $('payment_yapital_standard_secret_key').value;
17
-
18
- allowedNotifications = [];
19
- addAllowedStorage(
20
- $('payment_yapital_standard_client_id').value,
21
- $('payment_yapital_standard_secret_key').value
22
- );
23
-
24
- function getConnectionName(storageType, connection) {
25
- return storageType + '_' + connection;
26
- }
27
-
28
- function addAllowedStorage(storageType, connection) {
29
- var storage = getConnectionName(storageType, connection);
30
-
31
- if (storage != getConnectionName('', '') && !allowedNotifications.include(storage)) {
32
- allowedNotifications.push(storage);
33
- }
34
- }
35
-
36
- function checkButtonState(event) {
37
- var element = Event.element(event);
38
-
39
- var defaultStorage = getConnectionName(
40
- defaultValues['payment_yapital_standard_client_id'],
41
- defaultValues['payment_yapital_standard_secret_key']
42
- );
43
-
44
- storage = getConnectionName(
45
- $('payment_yapital_standard_client_id').value,
46
- $('payment_yapital_standard_secret_key').value
47
- );
48
-
49
- if (defaultStorage != storage) {
50
- enableValidateButton();
51
- } else {
52
- disableValidateButton();
53
- }
54
- }
55
-
56
- function enableStorageSelection() {
57
- $('payment_yapital_standard_client_id').enable('enabled');
58
- $('payment_yapital_standard_secret_key').enable('enabled');
59
- }
60
-
61
- function disableStorageSelection() {
62
- $('payment_yapital_standard_client_id').disable('disabled');
63
- $('payment_yapital_standard_secret_key').disable('disabled');
64
- }
65
-
66
- function enableValidateButton() {
67
- Form.Element.enable('validate_button');
68
- $('validate_button').removeClassName('disabled');
69
- }
70
-
71
- function disableValidateButton() {
72
- Form.Element.disable('validate_button');
73
- $('validate_button').addClassName('disabled');
74
- }
75
-
76
- Event.observe(window, 'load', function () {
77
- //disableStorageSelection();
78
- //disableValidateButton();
79
- //checkStatus();
80
- });
81
- $('payment_yapital_standard_client_id').observe('change', checkButtonState);
82
- $('payment_yapital_standard_secret_key').observe('change', checkButtonState);
83
-
84
- function yapitalCheckStatus() {
85
-
86
- }
87
-
88
- function validateYapital() {
89
- //var advice = Validation.getAdvice('required-validation', $('synchronize-validation-input'));
90
- //if (advice) {
91
- // advice.hide();
92
- //}
93
-
94
- params = {
95
- shop_id : 1,
96
- client_id :$('payment_yapital_standard_client_id').value,
97
- secret_key:$('payment_yapital_standard_secret_key').value
98
- };
99
-
100
- $('validation_message_span').addClassName('no-display');
101
- $('validation_span').removeClassName('no-display');
102
-
103
- new Ajax.Request('<?php echo $this->getAjaxValidateUpdateUrl() ?>', {
104
- parameters :params,
105
- loaderArea :false,
106
- asynchronous:false,
107
- onSuccess :function (transport) {
108
- var response;
109
-
110
- response = eval('(' + transport.responseText + ')');
111
- if (false == response.has_errors) {
112
- // no errors: it works!
113
- disableValidateButton();
114
- } else {
115
- // TODO ERROR
116
- }
117
-
118
- allowedNotifications.push(getConnectionName(
119
- $('payment_yapital_standard_client_id').value,
120
- $('payment_yapital_standard_secret_key').value
121
- ));
122
-
123
- $('validation_span').addClassName('no-display');
124
- $('validation_message_span').removeClassName('no-display');
125
- $('validation_message_span').update(response.message);
126
- },
127
-
128
- onFailure:function (transport) {
129
- $('validation_span').addClassName('no-display');
130
- $('validation_message_span').removeClassName('no-display');
131
- $('validation_message_span').update('<?php echo $this->__('Internal error during validation.') ?>');
132
- }
133
-
134
- });
135
-
136
- //window.setTimeout('yapitalCheckStatus()', 2011);
137
-
138
- //disableStorageSelection();
139
- //disableValidateButton();
140
- enableValidateButton();
141
- }
142
- //]]>
143
- </script>
144
-
145
- <?php echo $this->getButtonHtml() ?><span class="validation-indicator no-display" id="validation_span"><img
146
- alt="Synchronize" style="margin:0 5px" src="<?php echo $this->getSkinUrl('images/process_spinner.gif')
147
- ?>"/></span><span id="validation_message_span"></span>
148
- <input type="hidden" id="validation-input" class="required-validation no-display"/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/layout/yapital.xml CHANGED
@@ -29,6 +29,12 @@
29
  </reference>
30
  </yapital_standard_error>
31
 
 
 
 
 
 
 
32
  <yapital_standard_accessdenied>
33
  <reference name="root">
34
  <action method="setTemplate"><template>page/3columns.phtml</template></action>
29
  </reference>
30
  </yapital_standard_error>
31
 
32
+ <yapital_standard_documentation>
33
+ <reference name="content">
34
+ <block type="yapital/base" template="yapital/standard/documentation.phtml" name="yapital.standard.error" />
35
+ </reference>
36
+ </yapital_standard_documentation>
37
+
38
  <yapital_standard_accessdenied>
39
  <reference name="root">
40
  <action method="setTemplate"><template>page/3columns.phtml</template></action>
app/design/frontend/base/default/template/yapital/.gitignore DELETED
File without changes
app/design/frontend/base/default/template/yapital/standard/accessdenied.phtml CHANGED
@@ -1 +1 @@
1
- Oh snap! Wasn't able to authorize at the yapital API.
1
+ <?php echo $this->__('Oh snap! Was not able to authorize at the yapital API.'); ?>
app/design/frontend/base/default/template/yapital/standard/documentation.phtml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p>
2
+ <?php echo $this->__('In this section you could edit all Yapital related configuration parameter and you could enable the Yapital payment. In order to activate Yapital please do as follows:')?>
3
+ </p>
4
+
5
+ <ol style="list-style: lower-roman; margin-left: 2em;">
6
+ <li><?php echo $this->__('Set enabled to "YES"'); ?></li>
7
+ <li><?php echo $this->__('Enter a Title (will appear on the customer facing Web-site) and should contain "Yapital payment"'); ?></li>
8
+ <li><?php echo $this->__('Paid order status has to be set to "processing". This will be the internal status after the customer paid with Yapital'); ?></li>
9
+ <li><?php echo $this->__('Set "Use this credentials" to "Live"'); ?></li>
10
+ <li><?php echo $this->__('Next copy/paste your Shop-ID, Client-Id and your Secret Key'); ?></li>
11
+ <li><?php echo $this->__('Click on "Validate" to check the credentials given'); ?></li>
12
+ <li><?php echo $this->__('Click on "Generate a new secret", a new secret will appear in the field'); ?></li>
13
+ <li><?php echo $this->__('Enter some random chars into the "Yapital Notification Id" and press "Register notification"'); ?></li>
14
+ <li><?php echo $this->__('Click on "Register notification" to register the notification'); ?></li>
15
+ <li><?php echo $this->__('Click on "Save Config" on top of the screen'); ?></li>
16
+ </ol>
17
+
18
+ <hr />
19
+
20
+ <p>
21
+ <?php echo $this->__('Checks: Please open your shop and go shopping. Choose the payment method "Yapital" and pay with your Yapital account. In the backend you should see your transaction with the Paid order status "processing" now.'); ?>
22
+ </p>
23
+
24
+ <p>
25
+ <?php echo $this->__('More information (including the setup of a test-connection to a Yapital test-system) could be found in the delivered plugin-documentation.'); ?>
26
+ </p>
app/design/frontend/base/default/template/yapital/standard/error.phtml CHANGED
@@ -1,11 +1,6 @@
1
  <h2><?php echo $this->__('A problem occurred') ?></h2>
2
 
3
- <?php echo $this->__(
4
- 'We are sorry!
5
- It was not possible to receive your payment from yapital.
6
- Therefor we canceled your order.
7
- You can try it again or choose another payment method.'
8
- ) ?>
9
 
10
  <div class="a-center">
11
  <a href="<? echo Mage::getUrl('checkout/cart') ?>">
1
  <h2><?php echo $this->__('A problem occurred') ?></h2>
2
 
3
+ <?php echo $this->__('We are sorry! It was not possible to receive your payment from yapital. Therefor we canceled your order. You can try it again or choose another payment method.') ?>
 
 
 
 
 
4
 
5
  <div class="a-center">
6
  <a href="<? echo Mage::getUrl('checkout/cart') ?>">
app/design/frontend/base/default/template/yapital/standard/iframe.phtml CHANGED
@@ -1,10 +1,55 @@
1
  <?php /* @var $this Codex_Yapital_Block_Standard_Iframe */ ?>
2
  <div id="yapital-widget-container-id"></div>
 
 
 
 
 
 
 
 
 
 
3
  <script src="<?php echo $this->getApiIFrameScript(); ?>"></script>
4
- <script>
5
  (function (window) {
6
  var transactionId = "<?php echo $this->getTransactionId(); ?>";
7
- window.__yapital_init_widget(transactionId, "<?php echo $this->getApiIFrameScript(); ?>",
8
  "yapital-widget-container-id");
9
  })(window);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  </script>
1
  <?php /* @var $this Codex_Yapital_Block_Standard_Iframe */ ?>
2
  <div id="yapital-widget-container-id"></div>
3
+ <p id="yapital-error-notice" style="display: none; font-weight: bold;">
4
+ <?php echo $this->__('Problems connecting with Yapital'); ?>
5
+ <br />
6
+ <?php echo $this->__('Please contact us at <a href="mailto:%s?subject=%s">%s</a>',
7
+ Mage::getStoreConfig('trans_email/ident_support/email'),
8
+ htmlentities($this->__('Yapital Payment Failed: %s', $this->getOrderTransaction()->getOrder()->getIncrementId())),
9
+ Mage::getStoreConfig('trans_email/ident_support/email')
10
+ ); ?>
11
+ </p>
12
+
13
  <script src="<?php echo $this->getApiIFrameScript(); ?>"></script>
14
+ <script type="text/javascript">
15
  (function (window) {
16
  var transactionId = "<?php echo $this->getTransactionId(); ?>";
17
+ window.__yapital_init_widget(transactionId, "<?php echo $this->getApiUrl(); ?>/web-ui/",
18
  "yapital-widget-container-id");
19
  })(window);
20
+
21
+ (function (window) {
22
+
23
+ function showFailed(errors)
24
+ {
25
+ if (errors == 3) {
26
+ $('yapital-error-notice').show();
27
+ }
28
+ }
29
+
30
+ setTimeout(function() {
31
+ var iframeSource = $$('#yapital-widget-container-id iframe').first().src;
32
+
33
+ if (iframeSource) {
34
+
35
+ var failedRequests = 0;
36
+
37
+ for(var i = 1; i <= 3; i++) {
38
+ new Ajax.Request(iframeSource, {
39
+ method: 'head',
40
+ onSuccess: function(response) {
41
+ if (response.readyState < 3) {
42
+ showFailed(++failedRequests);
43
+ }
44
+ },
45
+ onFailure: function() {
46
+ showFailed(++failedRequests);
47
+ }
48
+ });
49
+ }
50
+
51
+ }
52
+
53
+ }, 5000);
54
+ })(window);
55
  </script>
app/locale/en_US/Codex_Yapital.csv ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "%s notification(s) have been deleted.","%s notification(s) have been deleted."
2
+ "%s transaction successfully updated.","%s transaction successfully updated."
3
+ "A problem occurred","A problem occurred"
4
+ "Back to cart","Back to cart"
5
+ "CSV","CSV"
6
+ "Canceled","Canceled"
7
+ "Checks: Please open your shop and go shopping. Choose the payment method ""Yapital"" and pay with your Yapital account. In the backend you should see your transaction with the Paid order status ""processing"" now.","Checks: Please open your shop and go shopping. Choose the payment method ""Yapital"" and pay with your Yapital account. In the backend you should see your transaction with the Paid order status ""processing"" now."
8
+ "Click on ""Generate a new secret"", a new secret will appear in the field","Click on ""Generate a new secret"", a new secret will appear in the field"
9
+ "Click on ""Register notification"" to register the notification","Click on ""Register notification"" to register the notification"
10
+ "Click on ""Save Config"" on top of the screen","Click on ""Save Config"" on top of the screen"
11
+ "Click on ""Validate"" to check the credentials given","Click on ""Validate"" to check the credentials given"
12
+ "Discount","Discount"
13
+ "Documentation","Documentation"
14
+ "Enter a Title (will appear on the customer facing Web-site) and should contain ""Yapital payment""","Enter a Title (will appear on the customer facing Web-site) and should contain ""Yapital payment"""
15
+ "Enter some random chars into the ""Yapital Notification Id"" and press ""Register notification""","Enter some random chars into the ""Yapital Notification Id"" and press ""Register notification"""
16
+ "Excel XML","Excel XML"
17
+ "Generate a new notification secret","Generate a new notification secret"
18
+ "In this section you could edit all Yapital related configuration parameter and you could enable the Yapital payment. In order to activate Yapital please do as follows:","In this section you could edit all Yapital related configuration parameter and you could enable the Yapital payment. In order to activate Yapital please do as follows:"
19
+ "Invoiced","Invoiced"
20
+ "Items","Items"
21
+ "Lifetime statistics have been updated.","Lifetime statistics have been updated."
22
+ "Live","Live"
23
+ "More information (including the setup of a test-connection to a Yapital test-system) could be found in the delivered plugin-documentation.","More information (including the setup of a test-connection to a Yapital test-system) could be found in the delivered plugin-documentation."
24
+ "Next copy/paste your Shop-ID, Client-Id and your Secret Key","Next copy/paste your Shop-ID, Client-Id and your Secret Key"
25
+ "Notification has been registered.","Notification has been registered."
26
+ "Notification was already registered.","Notification was already registered."
27
+ "Oh snap! Was not able to authorize at the yapital API.","Oh snap! Was not able to authorize at the yapital API."
28
+ "Order cancelled","Order cancelled"
29
+ "Order paid","Order paid"
30
+ "Orders","Orders"
31
+ "Paid","Paid"
32
+ "Paid order status has to be set to ""processing"". This will be the internal status after the customer paid with Yapital","Paid order status has to be set to ""processing"". This will be the internal status after the customer paid with Yapital"
33
+ "Payment","Payment"
34
+ "Payment Method","Payment Method"
35
+ "Period","Period"
36
+ "Please contact us at <a href=""mailto:%s?subject=%s"">%s</a>","Please contact us at <a href=""mailto:%s?subject=%s"">%s</a>"
37
+ "Please fill out the information below.","Please fill out the information below."
38
+ "Problems connecting with Yapital","Problems connecting with Yapital"
39
+ "Profit","Profit"
40
+ "Refunded","Refunded"
41
+ "Register live notification","Register live notification"
42
+ "Register sandbox notification","Register sandbox notification"
43
+ "Reports","Reports"
44
+ "Revenue","Revenue"
45
+ "Sales Discount","Sales Discount"
46
+ "Sales Items","Sales Items"
47
+ "Sales Shipping","Sales Shipping"
48
+ "Sales Tax","Sales Tax"
49
+ "Sales Total","Sales Total"
50
+ "Sandbox","Sandbox"
51
+ "Set ""Use this credentials"" to ""Live""","Set ""Use this credentials"" to ""Live"""
52
+ "Set enabled to ""YES""","Set enabled to ""YES"""
53
+ "Shipping","Shipping"
54
+ "Show Report","Show Report"
55
+ "Sorry, but your notifications could not be deleted. Please try again later or <a onclick=""window.open(this.href); return false;"" href=""https://www.yapital.com/consumer/index.html#customersupport"">contact Yapital.</a>","Sorry, but your notifications could not be deleted. Please try again later or <a onclick=""window.open(this.href); return false;"" href=""https://www.yapital.com/consumer/index.html#customersupport"">contact Yapital.</a>"
56
+ "Tax","Tax"
57
+ "Total","Total"
58
+ "Unable to refresh lifetime statistics.","Unable to refresh lifetime statistics."
59
+ "Unregister all live notifications","Unregister all live notifications"
60
+ "Unregister all sandbox notifications","Unregister all sandbox notifications"
61
+ "Update orders","Update orders"
62
+ "Update sandbox orders","Update sandbox orders"
63
+ "Valid.","Valid."
64
+ "Validate live credentials","Validate live credentials"
65
+ "Validate sandbox credentials","Validate sandbox credentials"
66
+ "We are sorry! It was not possible to receive your payment from yapital. Therefor we canceled your order. You can try it again or choose another payment method.","We are sorry! It was not possible to receive your payment from yapital. Therefor we canceled your order. You can try it again or choose another payment method."
67
+ "We are sorry! Something went wrong.","We are sorry! Something went wrong."
68
+ "Yapital","Yapital"
69
+ "Yapital Payment Failed: %s","Yapital Payment Failed: %s"
70
+ "Yapital Payment Method Report","Yapital Payment Method Report"
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>yapital</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/apachepl.php">APL</license>
7
  <channel>community</channel>
@@ -10,9 +10,9 @@
10
  <description>Yapital, the first Pan-European, cross-channel payment solution, is the fast, easy and secure way for your customers to pay. All payments and transactions immediately show up in your Yapital business account and all payments are guaranteed.</description>
11
  <notes>Yapital, the first Pan-European, cross-channel payment solution, is the fast, easy and secure way for your customers to pay. All payments and transactions immediately show up in your Yapital business account and all payments are guaranteed.</notes>
12
  <authors><author><name>code-x GmbH</name><user>Yapital</user><email>yapital@code-x.de</email></author></authors>
13
- <date>2013-10-29</date>
14
- <time>14:06:17</time>
15
- <contents><target name="magecommunity"><dir name="Codex"><dir name="Yapital"><dir name="Block"><file name="AbstractBlock.php" hash="5c615255446d077cee069bf7d5d21322"/><dir name="Adminhtml"><dir name="Report"><dir name="Yapital"><dir name="Payment"><file name="Grid.php" hash="a0344b462ed361f7d57acfda0ba10798"/></dir><file name="Payment.php" hash="aea486be982bc8741d1eedd221802758"/></dir></dir></dir><file name="Base.php" hash="791be5703ba25b221a7321abec8c0f45"/><dir name="Config"><dir name="Credentials"><file name="Sandbox.php" hash="d59b058fcd135de6048c0a9e3d9fcebb"/></dir><dir name="Notification"><file name="Sandbox.php" hash="112035622ba9f81f4753a0f461bdb01d"/></dir></dir><dir name="Standard"><file name="Iframe.php" hash="93acbf9e7d373bf9f75dfc4c27ff6d6a"/></dir><dir name="System"><dir name="Config"><dir name="Storage"><dir name="Credentials"><dir name="Live"><file name="Secret.php" hash="14684928a2a51942e0aaa02cc55497db"/></dir><file name="Notification.php" hash="bbed86882e6192843acf75247d4cf585"/><dir name="Sandbox"><file name="Secret.php" hash="f80470cf08d702187e453cc1113963b1"/></dir><file name="Sandbox.php" hash="83d525ac976c538243f38c35399f77b5"/><file name="Validate.php" hash="0c20bd7c1db1967bd0a9e3a629713a92"/></dir></dir></dir></dir></dir><file name="ErrorException.php" hash="fe1b4ff685300385200970d7d0f25571"/><file name="Exception.php" hash="b0de3f506d7247d17807f2582cef47a7"/><dir name="Helper"><file name="Data.php" hash="818a367f6504849a355e099597ed6d16"/></dir><dir name="Model"><file name="Abstract.php" hash="7d8d5535aa68914342ac867ee90e44cf"/><dir name="Api"><file name="Abstract.php" hash="de49b71ba967f62427107860b0bd2c25"/><dir name="Basket"><file name="Transaction.php" hash="381eeb3b0adf030adb2458270994e926"/></dir><file name="Notification.php" hash="3fea7c8f75d07ae25824d622fce99e42"/><file name="Restclient.php" hash="f161a48ea789206e000a972e080020f6"/><file name="ReturnBasket.php" hash="64b28c01b7cf3404e633bb78c4207feb"/><file name="Token.php" hash="ffe35d52b03af4913b1978b6d1ea88ae"/></dir><file name="Config.php" hash="dfeb91696cf5897cc8fcf356a2b3b40d"/><dir name="Datatype"><file name="Abstract.php" hash="f6cfcdba68d0680cae215fc396453ddc"/><file name="AbstractSimpleType.php" hash="cb14f8247e7e5c501cad829e566e62e8"/><file name="Airlinedata.php" hash="23fb1b88201c6813b9a9f59ac6da8968"/><file name="Amount.php" hash="70688876d82c81886f707d539c026d9b"/><file name="Basket.php" hash="5b3c687efec18bfe955819b1973591f3"/><file name="Basketstransaction.php" hash="96af52e5b7a8ec7d5f19b8f640109d4a"/><file name="Baskettransactioncreated.php" hash="d0123197d7391957eded7a27a249f9d1"/><file name="Currency.php" hash="bfd417f13b4e591086cdd8344908e30c"/><file name="EventType.php" hash="766ca5f6ff202501a2c91ea7c38b387c"/><file name="Interface.php" hash="ee2a4b504cf88f52dd732b485bb6f200"/><file name="Item.php" hash="9863da0b4b7c8fdb71ef9e40d204b8a6"/><file name="Merchantitem.php" hash="6de991ba501f6c8e0262fc178274e490"/><file name="Notification.php" hash="68403d19e03e029b87ae9f0c222bd9a5"/><file name="Postaladdress.php" hash="fb82d24751a956bac07fe93c541fef50"/><file name="Qrcodebinary.php" hash="d3a11746ea034234feaacf9f9a34c997"/><file name="Returnbasket.php" hash="b94285c70113ce402fc6d8a18fcf942f"/><file name="Shoprestresponse.php" hash="eb24834c14e622c8ac8679a8b14e5b5d"/><file name="Token.php" hash="c88ba481935bace3c72f661fe7ace803"/><file name="Transaction.php" hash="56ab62845ec4fefc29ba89c518af5058"/><file name="Transactionstatus.php" hash="b0bb4364938c6978f29540008b6d4932"/><file name="Yapitalpublicid.php" hash="6484f8852560106eb9237d354ca2f7a6"/></dir><file name="Log.php" hash="c31d1f06231b7397cb39d01cee19d5d2"/><file name="Notification.php" hash="ad25abfed8a840139ff33b534920a617"/><file name="Observer.php" hash="ad02a74d3cc02bdec9b8bc6a58c3615d"/><dir name="Order"><file name="Transaction.php" hash="7408eb705773c2ad499219a4677babf1"/></dir><dir name="Payment"><file name="Standard.php" hash="acfea2ae40055cf56cd736abdd4d252d"/></dir><dir name="Resource"><dir name="Notification"><file name="Collection.php" hash="e1b79fbcec50d81d1c4174c89b8f1148"/></dir><file name="Notification.php" hash="b0068110480422a9e1b6f2449efba433"/><dir name="Order"><dir name="Transaction"><file name="Collection.php" hash="027427bd2322fd73683ea3c60c61ef04"/></dir><file name="Transaction.php" hash="2c0bac5ca37f822da93b49971458f5d0"/></dir><dir name="Report"><dir name="Paymentmethod"><file name="Collection.php" hash="cc5b60ed4de7e958a0fc79707dd36482"/></dir><file name="Paymentmethod.php" hash="456b9e3d6b7d621257e4d51b36d64395"/></dir></dir><dir name="System"><dir name="Config"><dir name="Payment"><dir name="Credentials"><file name="Switch.php" hash="348cda17f3003ea434d27457aadf3064"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Report"><file name="YapitalController.php" hash="683e407a92e7c136cee9ec2380368823"/></dir><dir name="Yapital"><file name="ConfigController.php" hash="f6625e999ff97d6846cfd2e0ace7cf84"/><file name="NotificationController.php" hash="f28571bee8c4503d6328d0b6abb4c6ea"/><file name="SandboxController.php" hash="964c254652930d0e0bfe1fb633f01b82"/></dir></dir><file name="NotificationController.php" hash="e40e6e973be86e5b98c4cb05615ec448"/><file name="StandardController.php" hash="4624e119ecb77c16115190ba4a804056"/></dir><dir name="doc"><file name="phpdoc.xml" hash="2f00609a356a86ae5563d2aab9f18267"/></dir><dir name="etc"><file name="adminhtml.xml" hash="1ff06e4291227e1206db001e2d22d788"/><file name="config.xml" hash="d021ab919b1b24197b52c2fc40e3ccab"/><file name="system.xml" hash="bfb429e766f59c42d09de337a2520661"/></dir><dir name="sql"><dir name="yapital_setup"><file name="mysql4-install-0.1.0.php" hash="4152644ea01d36e2e3e1b57fec1994ef"/><file name="mysql4-upgrade-0.1.0-0.2.0.php" hash="1293127dc8ed191d4d33de7190e872e6"/><file name="mysql4-upgrade-0.2.0-0.3.0.php" hash="b1e1a52496abe325f21bbc3bfce79243"/><file name="mysql4-upgrade-0.3.0-1.0.0.php" hash="6d9e464fbb62007982d3ce4e2d82f8f9"/><file name="mysql4-upgrade-1.0.0-1.1.0.php" hash="45f5bf22bb6ef4d414bcc9a2281300d3"/></dir></dir><file name=".gitignore" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></target><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Codex_Yapital.xml" hash="a6a24ae1ce947aa47c778521b1f481a0"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="yapital.xml" hash="63a92065cdcf2ec2afde43ec2a784865"/></dir><dir name="template"><dir name="yapital"><dir><dir name="config"><dir name="credentials"><file name="sandbox.phtml" hash="32632b84161860816dbcfd6e06f09732"/></dir></dir><dir name="system"><dir name="config"><dir name="storage"><dir name="credentials"><dir name="live"><file name="secret.phtml" hash="9b060fe464997596b148cb0e68dc5cad"/></dir><file name="notification.phtml" hash="0f6baf2ffe7abd478ec55c5930e4f001"/><dir name="sandbox"><file name="notification.phtml" hash="8753a4948d1cceb3aae306a26acd20d3"/><file name="secret.phtml" hash="e4182859bdc46c6e235e2f5842be89f9"/></dir><file name="sandbox.phtml" hash="24f0bdfcd8c7784a4e66ecfae1061414"/><file name="validate.phtml" hash="501521604be082fa9c150a23d3e04685"/></dir></dir></dir></dir></dir><file name=".gitignore" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="yapital.xml" hash="e287f912353cc9361531f2970e2b6412"/></dir><dir name="template"><dir name="yapital"><dir><dir name="standard"><file name="accessdenied.phtml" hash="1cc01463abf6c8548295f939ed0aaf47"/><file name="error.phtml" hash="0de94c4b4db0214018c8e3206cb066f3"/><file name="iframe.phtml" hash="a41ce580655291686ae016585d4aa31d"/></dir></dir><file name=".gitignore" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="yapital"><file name="iframe.css" hash="e415f3f5f58ec92b1d8fcc395fc2a717"/><file name=".gitignore" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
- <dependencies><required><php><min>5.2.3</min><max>5.4.16</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>yapital</name>
4
+ <version>1.1.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/apachepl.php">APL</license>
7
  <channel>community</channel>
10
  <description>Yapital, the first Pan-European, cross-channel payment solution, is the fast, easy and secure way for your customers to pay. All payments and transactions immediately show up in your Yapital business account and all payments are guaranteed.</description>
11
  <notes>Yapital, the first Pan-European, cross-channel payment solution, is the fast, easy and secure way for your customers to pay. All payments and transactions immediately show up in your Yapital business account and all payments are guaranteed.</notes>
12
  <authors><author><name>code-x GmbH</name><user>Yapital</user><email>yapital@code-x.de</email></author></authors>
13
+ <date>2014-08-14</date>
14
+ <time>10:29:39</time>
15
+ <contents><target name="magecommunity"><dir name="Codex"><dir name="Yapital"><dir name="Block"><file name="AbstractBlock.php" hash="5c615255446d077cee069bf7d5d21322"/><dir name="Adminhtml"><dir name="Report"><dir name="Yapital"><dir name="Payment"><file name="Grid.php" hash="a0344b462ed361f7d57acfda0ba10798"/></dir><file name="Payment.php" hash="aea486be982bc8741d1eedd221802758"/></dir></dir></dir><file name="Base.php" hash="791be5703ba25b221a7321abec8c0f45"/><dir name="Standard"><file name="Iframe.php" hash="da7daa35b968a1476978823f3e9ad147"/></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Html.php" hash="eb46809f3de2d8b51da4901b10744404"/></dir></dir><file name="Head.php" hash="98857a7e5a5c7a60e557f284372a27c9"/><dir name="Storage"><dir name="Credentials"><file name="Abstract.php" hash="b9d6749b3dcbb0b5ad4e73c2c5d5c6ac"/><file name="Notification.php" hash="c29b57fe4ad03948c40b5b6e3fe1fd2f"/><dir name="Sandbox"><file name="Notification.php" hash="fa725eebec26f853cba1439f5f31df75"/><file name="Secret.php" hash="fb913b0d6c72431559e1c17585847aa8"/><file name="Update.php" hash="6627da68587976eeb659543d73649b6b"/><file name="Validate.php" hash="3a01124738a22135d21b72df34c83d34"/></dir><file name="Secret.php" hash="d5ab18b1ec05d525ff8da4a254b81197"/><file name="Update.php" hash="a68e28133a55796cccfc69c501d1ba9b"/><file name="Validate.php" hash="c2ede6b048073dc7abe5ccba2c59b2fc"/></dir></dir></dir></dir></dir><file name="ErrorException.php" hash="fe1b4ff685300385200970d7d0f25571"/><file name="Exception.php" hash="b0de3f506d7247d17807f2582cef47a7"/><dir name="Helper"><file name="Config.php" hash="39540e7013b532138f2a08e0d95875fa"/><file name="Data.php" hash="818a367f6504849a355e099597ed6d16"/></dir><dir name="Model"><file name="Abstract.php" hash="7d8d5535aa68914342ac867ee90e44cf"/><dir name="Api"><file name="Abstract.php" hash="cb5873cfade75ba19d440626f1cf2218"/><dir name="Basket"><file name="Transaction.php" hash="ec2d81e296d2694c59dfee14aa05e370"/></dir><file name="BasketCollection.php" hash="d11ed911ae215281a521a70ae255d73e"/><file name="Client.php" hash="9442f52c676e1018fc984490ba2cd89e"/><file name="Connection.php" hash="a5fb3e6fa92ce4a304ff676a64400064"/><file name="ErrorMessage.php" hash="c26903fd1f2633c1ca4f42057dab6e36"/><file name="Notification.php" hash="bb528ab9b3110fc4f5fffe73e30d7a5b"/><file name="Restclient.php" hash="aa758166938370a5b0b5e67c973ebea3"/><file name="ReturnBasket.php" hash="64b28c01b7cf3404e633bb78c4207feb"/><file name="Token.php" hash="3a3b5d4497bcf9a48dd9ab4cd01444d7"/></dir><file name="Config.php" hash="e9f3fc07b3063f8e8f0c67ae6c7e566b"/><dir name="Datatype"><file name="Abstract.php" hash="f6cfcdba68d0680cae215fc396453ddc"/><file name="AbstractSimpleType.php" hash="cb14f8247e7e5c501cad829e566e62e8"/><file name="Airlinedata.php" hash="23fb1b88201c6813b9a9f59ac6da8968"/><file name="Amount.php" hash="70688876d82c81886f707d539c026d9b"/><file name="Basket.php" hash="5b3c687efec18bfe955819b1973591f3"/><file name="Basketstransaction.php" hash="96af52e5b7a8ec7d5f19b8f640109d4a"/><file name="Baskettransactioncreated.php" hash="d0123197d7391957eded7a27a249f9d1"/><file name="Currency.php" hash="bfd417f13b4e591086cdd8344908e30c"/><file name="EventType.php" hash="766ca5f6ff202501a2c91ea7c38b387c"/><file name="ISOLanguage.php" hash="a3d8d5418e1b6065ddbd4425bf172cd8"/><file name="Interface.php" hash="ee2a4b504cf88f52dd732b485bb6f200"/><file name="Item.php" hash="9863da0b4b7c8fdb71ef9e40d204b8a6"/><file name="Merchantitem.php" hash="6de991ba501f6c8e0262fc178274e490"/><file name="Notification.php" hash="68403d19e03e029b87ae9f0c222bd9a5"/><file name="Postaladdress.php" hash="fb82d24751a956bac07fe93c541fef50"/><file name="Qrcodebinary.php" hash="d3a11746ea034234feaacf9f9a34c997"/><file name="Returnbasket.php" hash="b94285c70113ce402fc6d8a18fcf942f"/><file name="Shoprestresponse.php" hash="eb24834c14e622c8ac8679a8b14e5b5d"/><file name="Token.php" hash="c88ba481935bace3c72f661fe7ace803"/><file name="Transaction.php" hash="07b67ab42b57b3eca2cf95607e80414b"/><file name="TransactionStatus.php" hash="b0bb4364938c6978f29540008b6d4932"/><file name="Transactions.php" hash="56ab62845ec4fefc29ba89c518af5058"/><file name="Yapitalpublicid.php" hash="6484f8852560106eb9237d354ca2f7a6"/></dir><file name="Log.php" hash="c31d1f06231b7397cb39d01cee19d5d2"/><file name="Notification.php" hash="2730c03b93e3e93ab8e46af6664d2094"/><file name="Observer.php" hash="3ad6f902edb9f40efdd6619eccd1e14a"/><dir name="Order"><file name="Transaction.php" hash="7408eb705773c2ad499219a4677babf1"/></dir><dir name="Payment"><file name="Standard.php" hash="e7dc23d0d18779d367a15f79d1a31e4d"/></dir><dir name="Resource"><dir name="Notification"><file name="Collection.php" hash="e1b79fbcec50d81d1c4174c89b8f1148"/></dir><file name="Notification.php" hash="b0068110480422a9e1b6f2449efba433"/><dir name="Order"><dir name="Transaction"><file name="Collection.php" hash="027427bd2322fd73683ea3c60c61ef04"/></dir><file name="Transaction.php" hash="2c0bac5ca37f822da93b49971458f5d0"/></dir><dir name="Report"><dir name="Paymentmethod"><file name="Collection.php" hash="cc5b60ed4de7e958a0fc79707dd36482"/></dir><file name="Paymentmethod.php" hash="4fac8c278e45ffc46cc01e310979b2d9"/></dir></dir><dir name="System"><dir name="Config"><dir name="Payment"><dir name="Credentials"><file name="Switch.php" hash="348cda17f3003ea434d27457aadf3064"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Report"><file name="YapitalController.php" hash="683e407a92e7c136cee9ec2380368823"/></dir><dir name="Yapital"><file name="ConfigController.php" hash="155c9c0bbc7cf67790cc8bd85cb54657"/><file name="DocumentationController.php" hash="f099a668cf2c40c88fdb35d5f0cf71fe"/><file name="NotificationController.php" hash="6c81c4e056a2e0027557061fe4592f0f"/></dir></dir><file name="NotificationController.php" hash="7b385b3197377378b2fc3273abcb8ae5"/><file name="StandardController.php" hash="07c6d1dfdafddc7950b86e082c2bd260"/></dir><dir name="doc"><file name="phpdoc.xml" hash="2f00609a356a86ae5563d2aab9f18267"/></dir><dir name="etc"><file name="adminhtml.xml" hash="1ff06e4291227e1206db001e2d22d788"/><file name="config.xml" hash="a30d880f9785b0368808073de4844b12"/><file name="system.xml" hash="26763e943d9161ebedf68c4c27498647"/></dir><dir name="sql"><dir name="yapital_setup"><file name="mysql4-install-0.1.0.php" hash="4152644ea01d36e2e3e1b57fec1994ef"/><file name="mysql4-upgrade-0.1.0-0.2.0.php" hash="1293127dc8ed191d4d33de7190e872e6"/><file name="mysql4-upgrade-0.2.0-0.3.0.php" hash="3d9b2e8e1ea855d5d90368d153d52b95"/><file name="mysql4-upgrade-0.3.0-1.0.0.php" hash="6d9e464fbb62007982d3ce4e2d82f8f9"/><file name="mysql4-upgrade-1.0.0-1.1.0.php" hash="45f5bf22bb6ef4d414bcc9a2281300d3"/></dir></dir><file name=".gitignore" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir></target><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Codex_Yapital.xml" hash="a6a24ae1ce947aa47c778521b1f481a0"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="yapital.xml" hash="8b15356d314992f7621338536573034f"/></dir><dir name="template"><dir name="yapital"><dir name="config"><dir name="credentials"><file name="notification.phtml" hash="3544f9ad6c8cdd7424f4f0c5399e2a49"/><file name="secret.phtml" hash="02e727e375e3226cf9b440689b966546"/><file name="update.phtml" hash="3f62690c2ef0e218bc9091a1f99ef1e5"/><file name="validate.phtml" hash="a7f1317f80eeabcfe6110f56765dd712"/></dir><file name="head.phtml" hash="4bf3a8bbb14c816fc9c8076d8b56c8dd"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="yapital.xml" hash="e5c2d771612aee646157f7568a386014"/></dir><dir name="template"><dir name="yapital"><dir name="standard"><file name="accessdenied.phtml" hash="e81555e15bb4aa1b6a9c4893899bf63b"/><file name="documentation.phtml" hash="3dab93389d4798452114eb10ca9cf623"/><file name="error.phtml" hash="42ef58c8e2b267d73c9fc2ad4144225f"/><file name="iframe.phtml" hash="08dcbcfc6d1cfa85458729b205fd91f5"/></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="yapital"><file name="iframe.css" hash="e415f3f5f58ec92b1d8fcc395fc2a717"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><file name="yapital.js" hash="8f3595de0bb696b3f6b9a950c31f09a3"/><dir name="images"><dir name="codex"><dir name="yapital"><file name="yapital150x39.png" hash="f30ea75e5c4c3a006e34c760d8c94f75"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Codex_Yapital.csv" hash="b5c5dcf57c6e0980f434dfae2a6a399d"/></dir></target></contents>
16
  <compatible/>
17
+ <dependencies><required><php><min>5.3.0</min><max>5.6.0</max></php></required></dependencies>
18
  </package>
skin/adminhtml/default/default/images/codex/yapital/yapital150x39.png ADDED
Binary file
skin/adminhtml/default/default/yapital.js ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ YapitalConfig = Class.create();
2
+ YapitalConfig.prototype = {
3
+
4
+ initialize: function (config) {
5
+ this.config = config;
6
+ this.changed = false;
7
+
8
+ var that = this;
9
+ document.observe("dom:loaded", function () {
10
+ that.listenOnChanges();
11
+ });
12
+ },
13
+
14
+ listenOnChanges: function () {
15
+ var that = this;
16
+
17
+ $$('#payment_yapital_standard input').forEach(function (input) {
18
+ input.observe('change', function () {
19
+ if (!that.changed) {
20
+ that.changed = true;
21
+ window.onbeforeunload = that.unloadNotice;
22
+ }
23
+ })
24
+ });
25
+
26
+
27
+ $$('.content-header td.form-buttons button').forEach(function (input) {
28
+
29
+ input.stopObserving('click');
30
+ input.removeAttribute("onclick");
31
+
32
+ input.setAttribute('onclick', 'window.onbeforeunload = null; configForm.submit();');
33
+ });
34
+
35
+ },
36
+
37
+ unloadNotice: function (e) {
38
+ var message = 'Are you sure you want to leave?';
39
+ var e = e || window.event;
40
+ if (e) { // IE, FF<4
41
+ e.returnValue = message;
42
+ }
43
+ // Safari, FF, Chrome
44
+ return message;
45
+ },
46
+
47
+ validate: function () {
48
+
49
+ params = {
50
+ shop_id: 1,
51
+ client_id: $('payment_yapital_' + this.config.config_path + '_client_id').value,
52
+ secret_key: $('payment_yapital_' + this.config.config_path + '_secret_key').value
53
+ };
54
+
55
+ $(this.config.config_path + '_validation_message_span').addClassName('no-display');
56
+ $(this.config.config_path + '_validation_span').removeClassName('no-display');
57
+
58
+ var that = this;
59
+ new Ajax.Request(this.config.validate_url, {
60
+ parameters: params,
61
+ loaderArea: false,
62
+ asynchronous: false,
63
+ onSuccess: function (transport) {
64
+ var response;
65
+
66
+ response = eval('(' + transport.responseText + ')');
67
+ if (false == response.has_errors) {
68
+ // no errors: it works!
69
+ that.disableValidateButton();
70
+ } else {
71
+ // TODO ERROR
72
+ }
73
+
74
+ $(that.config.config_path + '_validation_span').addClassName('no-display');
75
+ $(that.config.config_path + '_validation_message_span').removeClassName('no-display');
76
+ $(that.config.config_path + '_validation_message_span').update(response.message);
77
+ },
78
+
79
+ onFailure: function (transport) {
80
+ $(that.config.config_path + 'validation_span').addClassName('no-display');
81
+ $(that.config.config_path + 'validation_message_span').removeClassName('no-display');
82
+ $(that.config.config_path + 'validation_message_span').update('Internal error during validation.'); // TODO: Multilanguage!
83
+ }
84
+
85
+ });
86
+ this.enableValidateButton();
87
+ },
88
+
89
+
90
+ enableValidateButton: function () {
91
+ Form.Element.enable(this.config.config_path + '_validate_button');
92
+ $(this.config.config_path + '_validate_button').removeClassName('disabled');
93
+ },
94
+
95
+ disableValidateButton: function () {
96
+ Form.Element.disable(this.config.config_path + '_validate_button');
97
+ $(this.config.config_path + '_validate_button').addClassName('disabled');
98
+ },
99
+
100
+ generateNotificationSecret: function () {
101
+ var uniq = Math.floor(Math.random() * 0xF + 10).toString(36);
102
+ uniq += Math.floor(Math.random() * 0x100000000).toString(36);
103
+ uniq += Math.floor(Math.random() * 0x1000).toString(36);
104
+ uniq += Math.floor(Math.random() * 0x1000).toString(36);
105
+ uniq += Math.floor(Math.random() * 0x1000).toString(36);
106
+
107
+ $$('#payment_yapital_' + this.config.config_path + '_notification_secret')[0].value = uniq;
108
+ },
109
+
110
+ register: function (registerUrl) {
111
+
112
+ console.log('#payment_yapital_' + this.config.config_path + '_notification_secret is not long enough.');
113
+ if ($$('#payment_yapital_' + this.config.config_path + '_notification_secret')[0].value.length < 3) {
114
+ this.generateNotificationSecret();
115
+ }
116
+
117
+ params = {
118
+ store_id: 1,
119
+ notification_secret: $('payment_yapital_' + this.config.config_path + '_notification_secret').value,
120
+ notification_id: $('payment_yapital_' + this.config.config_path + '_notification_id').value
121
+ };
122
+
123
+ $(this.config.config_path + '_notification_message_span').addClassName('no-display');
124
+ $(this.config.config_path + '_notification_span').removeClassName('no-display');
125
+
126
+ var that = this;
127
+ new Ajax.Request(registerUrl, {
128
+ parameters: params,
129
+ loaderArea: false,
130
+ asynchronous: false,
131
+ onSuccess: function (transport) {
132
+ var response;
133
+
134
+ response = eval('(' + transport.responseText + ')');
135
+ console.log(response);
136
+ if (false == response.has_errors) {
137
+ // no errors: it works!
138
+ that.disableValidateButton();
139
+ } else {
140
+ // TODO ERROR
141
+ }
142
+
143
+ $(that.config.config_path + '_notification_span').addClassName('no-display');
144
+ $(that.config.config_path + '_notification_message_span').removeClassName('no-display');
145
+ $(that.config.config_path + '_notification_message_span').update(response.message);
146
+ },
147
+
148
+ onFailure: function (transport) {
149
+ $(that.config.config_path + '_notification_span').addClassName('no-display');
150
+ $(that.config.config_path + '_notification_message_span').removeClassName('no-display');
151
+ $(that.config.config_path + '_notification_message_span').update('Internal error during validation.'); // TODO: Multilanguage!
152
+ }
153
+
154
+ });
155
+
156
+ this.enableValidateButton();
157
+ },
158
+
159
+
160
+ unregister: function (unregisterUrl) {
161
+ // TODO: Multilanguage
162
+ if (confirm('This will delete all notifications when a customer has paid. Your shop will no longer receive any note if the order has been paid except you register a new notification.')) {
163
+ params = {
164
+ store_id: 1,
165
+ notification_secret: $('payment_yapital_' + this.config.config_path + '_notification_secret').value,
166
+ notification_id: $('payment_yapital_' + this.config.config_path + '_notification_id').value
167
+ };
168
+
169
+ $(this.config.config_path + '_notification_message_span').addClassName('no-display');
170
+ $(this.config.config_path + '_notification_span').removeClassName('no-display');
171
+
172
+ var that = this;
173
+ new Ajax.Request(unregisterUrl, {
174
+ parameters: params,
175
+ loaderArea: false,
176
+ asynchronous: false,
177
+ onSuccess: function (transport) {
178
+ var response;
179
+
180
+ response = eval('(' + transport.responseText + ')');
181
+ console.log(response);
182
+ if (false == response.has_errors) {
183
+ // no errors: it works!
184
+ } else {
185
+ // TODO ERROR
186
+ }
187
+
188
+ $(that.config.config_path + '_notification_span').addClassName('no-display');
189
+ $(that.config.config_path + '_notification_message_span').removeClassName('no-display');
190
+ $(that.config.config_path + '_notification_message_span').update(response.message);
191
+ },
192
+
193
+ onFailure: function (transport) {
194
+ $(that.config.config_path + '_notification_span').addClassName('no-display');
195
+ $(that.config.config_path + '_notification_message_span').removeClassName('no-display');
196
+ $(that.config.config_path + '_notification_message_span').update('Internal error during validation.'); // TODO: Multilanguage!
197
+ }
198
+
199
+ });
200
+ }
201
+ },
202
+
203
+ updateTransactions: function () {
204
+ $(this.config.config_path + '_update_message_span').addClassName('no-display');
205
+ $(this.config.config_path + '_update_span').removeClassName('no-display');
206
+
207
+ var that = this;
208
+ new Ajax.Request(this.config.update_url, {
209
+ method: 'get',
210
+ onSuccess: function (transport) {
211
+ var response;
212
+ response = eval('(' + transport.responseText + ')');
213
+
214
+ $(that.config.config_path + '_update_span').addClassName('no-display');
215
+ $(that.config.config_path + '_update_message_span').removeClassName('no-display');
216
+ $(that.config.config_path + '_update_message_span').update(response.message);
217
+ },
218
+
219
+ onFailure: function (response) {
220
+ $(that.config.config_path + '_update_span').addClassName('no-display');
221
+ $(that.config.config_path + '_update_message_span').removeClassName('no-display');
222
+ $(that.config.config_path + '_update_message_span').update('Internal error during validation.'); // TODO: Multilanguage!
223
+ }
224
+ });
225
+ }
226
+
227
+ }
skin/frontend/base/default/css/yapital/.gitignore DELETED
File without changes