Omise_Gateway - Version 1.8.0.0

Version Notes

Highlights


- Introduce 3-D Secure feature!

- Introduce Internet Banking feature!

- Support JPY, IDR and SGD currencies.

Enhancements


- Refactor the PaymentMethod class for the extensibility, polymorphism and reduce code complexity that usually, will keep maintain in only one file (Omise_Gateway_Model_PaymentMethod).

- Import squizlabs/php_codesniffer package to the project.

- Code styling.

Download this release

Release Info

Developer Omise
Extension Omise_Gateway
Version 1.8.0.0
Comparing to
See all releases


Code changes from version 1.9.0.6 to 1.8.0.0

Files changed (65) hide show
  1. app/code/community/Omise/Gateway/Block/Adminhtml/Config/Edit.php +1 -1
  2. app/code/community/Omise/Gateway/Block/Adminhtml/Config/Edit/Form.php +49 -27
  3. app/code/community/Omise/Gateway/Block/Adminhtml/Dashboard/Dashboard.php +1 -1
  4. app/code/community/Omise/Gateway/Block/Adminhtml/System/Config/Fieldset/Payment.php +44 -0
  5. app/code/community/Omise/Gateway/Block/Form/Cc.php +68 -18
  6. app/code/community/Omise/Gateway/Block/Form/OffsiteInternetBankingPayment.php +34 -0
  7. app/code/community/Omise/Gateway/Helper/Data.php +32 -2
  8. app/code/community/Omise/Gateway/Model/Config.php +1 -1
  9. app/code/community/Omise/Gateway/Model/Config/Var/Paymentaction.php +1 -0
  10. app/code/community/Omise/Gateway/Model/OffsiteInternetBankingPayment.php +145 -0
  11. app/code/community/Omise/Gateway/Model/Omise.php +96 -17
  12. app/code/community/Omise/Gateway/Model/OmiseAccount.php +4 -1
  13. app/code/community/Omise/Gateway/Model/OmiseBalance.php +4 -1
  14. app/code/community/Omise/Gateway/Model/OmiseCharge.php +11 -3
  15. app/code/community/Omise/Gateway/Model/OmiseTransfer.php +19 -7
  16. app/code/community/Omise/Gateway/Model/Payment.php +68 -0
  17. app/code/community/Omise/Gateway/Model/PaymentMethod.php +263 -59
  18. app/code/community/Omise/Gateway/Model/Resource/Config.php +1 -1
  19. app/code/community/Omise/Gateway/Model/Strategies/AuthorizeStrategy.php +56 -0
  20. app/code/community/Omise/Gateway/Model/Strategies/AuthorizeThreeDSecureStrategy.php +56 -0
  21. app/code/community/Omise/Gateway/Model/Strategies/CaptureStrategy.php +56 -0
  22. app/code/community/Omise/Gateway/Model/Strategies/CaptureThreeDSecureStrategy.php +56 -0
  23. app/code/community/Omise/Gateway/Model/Strategies/ManualCaptureStrategy.php +51 -0
  24. app/code/community/Omise/Gateway/Model/Strategies/OffsiteInternetBankingStrategy.php +55 -0
  25. app/code/community/Omise/Gateway/Model/Strategies/StrategyAbstract.php +27 -0
  26. app/code/community/Omise/Gateway/Model/Strategies/StrategyInterface.php +23 -0
  27. app/code/community/Omise/Gateway/controllers/Adminhtml/OmiseController.php +18 -9
  28. app/code/community/Omise/Gateway/controllers/Callback/ValidateOffsiteInternetBankingController.php +87 -0
  29. app/code/community/Omise/Gateway/controllers/Callback/ValidateThreeDSecureController.php +92 -0
  30. app/code/community/Omise/Gateway/data/omise_gateway_setup/data-install-0.0.0.1.php +1 -1
  31. app/code/community/Omise/Gateway/etc/config.xml +20 -1
  32. app/code/community/Omise/Gateway/etc/system.xml +75 -33
  33. app/code/community/Omise/Gateway/sql/omise_gateway_setup/install-0.0.0.1.php +1 -1
  34. app/design/adminhtml/default/default/template/omise/dashboard.phtml +6 -12
  35. app/design/frontend/base/default/template/payment/form/omise-inapplicable-method.phtml +11 -0
  36. app/design/frontend/base/default/template/payment/form/omiseoffsiteinternetbankingpayment.phtml +63 -0
  37. lib/omise-php/CHANGELOG.md +17 -0
  38. lib/omise-php/README.md +2 -0
  39. lib/omise-php/lib/Omise.php +3 -0
  40. lib/omise-php/lib/omise/OmiseAccount.php +33 -26
  41. lib/omise-php/lib/omise/OmiseBalance.php +33 -25
  42. lib/omise-php/lib/omise/OmiseCard.php +71 -57
  43. lib/omise-php/lib/omise/OmiseCardList.php +49 -30
  44. lib/omise-php/lib/omise/OmiseCharge.php +95 -65
  45. lib/omise-php/lib/omise/OmiseCustomer.php +102 -77
  46. lib/omise-php/lib/omise/OmiseDispute.php +48 -37
  47. lib/omise-php/lib/omise/OmiseEvent.php +48 -0
  48. lib/omise-php/lib/omise/OmiseLink.php +60 -0
  49. lib/omise-php/lib/omise/OmiseRecipient.php +85 -57
  50. lib/omise-php/lib/omise/OmiseRefund.php +12 -10
  51. lib/omise-php/lib/omise/OmiseRefundList.php +52 -42
  52. lib/omise-php/lib/omise/OmiseTest.php +12 -10
  53. lib/omise-php/lib/omise/OmiseToken.php +48 -38
  54. lib/omise-php/lib/omise/OmiseTransaction.php +37 -30
  55. lib/omise-php/lib/omise/OmiseTransfer.php +84 -67
  56. lib/omise-php/lib/omise/exception/OmiseExceptions.php +75 -101
  57. lib/omise-php/lib/omise/res/OmiseApiResource.php +292 -247
  58. lib/omise-php/lib/omise/res/OmiseVaultResource.php +11 -8
  59. lib/omise-php/lib/omise/res/obj/OmiseObject.php +99 -77
  60. package.xml +53 -39
  61. skin/frontend/base/default/omise/css/offsiteinternetbankingpayment.css +72 -0
  62. skin/frontend/base/default/omise/images/bay.svg +26 -0
  63. skin/frontend/base/default/omise/images/bbl.svg +13 -0
  64. skin/frontend/base/default/omise/images/ktb.svg +32 -0
  65. skin/frontend/base/default/omise/images/scb.svg +16 -0
app/code/community/Omise/Gateway/Block/Adminhtml/Config/Edit.php CHANGED
@@ -8,4 +8,4 @@ class Omise_Gateway_Block_Adminhtml_Config_Edit extends Mage_Adminhtml_Block_Wid
8
  $this->_mode = 'edit';
9
  $this->_headerText = $this->__('Omise Gateway Configuration');
10
  }
11
- }
8
  $this->_mode = 'edit';
9
  $this->_headerText = $this->__('Omise Gateway Configuration');
10
  }
11
+ }
app/code/community/Omise/Gateway/Block/Adminhtml/Config/Edit/Form.php CHANGED
@@ -3,42 +3,62 @@ class Omise_Gateway_Block_Adminhtml_Config_Edit_Form extends Mage_Adminhtml_Bloc
3
  {
4
  /**
5
  * Prepare a form for setting Omise Keys
 
6
  * @return self
7
  */
8
  protected function _prepareForm()
9
  {
10
  // Instantiate a new form to display our brand for editing.
11
- $form = new Varien_Data_Form(array( 'id' => 'edit_form',
12
- 'action' => $this->getUrl('adminhtml/omise/config/edit', array('_current' => true,
13
- 'continue' => 0)),
14
- 'method' => 'post'));
 
 
15
  $form->setUseContainer(true);
16
  $this->setForm($form);
17
 
18
  /* Field set for Test Keys */
19
  $fieldset = $form->addFieldset('omise_key_test', array('legend' => $this->__('Test Keys')));
20
- $this->_addFieldsToFieldset($fieldset, array( 'public_key_test' => array( 'label' => $this->__('Public Key for Test'),
21
- 'input' => 'password',
22
- 'required' => false),
23
-
24
- 'secret_key_test' => array( 'label' => $this->__('Secret Key for Test'),
25
- 'input' => 'password',
26
- 'required' => false),
27
-
28
- 'test_mode' => array( 'label' => $this->__('Enable Test mode'),
29
- 'input' => 'checkbox',
30
- 'required' => false,
31
- 'onclick' => 'this.value = this.checked ? 1 : 0;')));
 
 
 
 
 
 
 
 
 
32
 
33
  /* Field set for Live Keys */
34
  $fieldset = $form->addFieldset('omise_key_live', array('legend' => $this->__('Live Keys')));
35
- $this->_addFieldsToFieldset($fieldset, array( 'public_key' => array( 'label' => $this->__('Public Key'),
36
- 'input' => 'password',
37
- 'required' => true),
38
-
39
- 'secret_key' => array( 'label' => $this->__('Secret Key'),
40
- 'input' => 'password',
41
- 'required' => true)));
 
 
 
 
 
 
 
 
42
 
43
  return $this;
44
  }
@@ -49,6 +69,7 @@ class Omise_Gateway_Block_Adminhtml_Config_Edit_Form extends Mage_Adminhtml_Bloc
49
  * in 'brandData' so that we can easily separate all relevant information
50
  * in the controller. You could of course omit this method entirely
51
  * and call the $fieldset->addField() method directly.
 
52
  * @return self
53
  */
54
  protected function _addFieldsToFieldset(Varien_Data_Form_Element_Fieldset $fieldset, $fields)
@@ -61,7 +82,7 @@ class Omise_Gateway_Block_Adminhtml_Config_Edit_Form extends Mage_Adminhtml_Bloc
61
  $_data['title'] = $_data['label'];
62
 
63
  // If no new value exists, use the existing data.
64
- if (!array_key_exists('value', $_data)) {
65
  $_data['value'] = $this->_getValue()->getData($name);
66
  }
67
 
@@ -79,16 +100,17 @@ class Omise_Gateway_Block_Adminhtml_Config_Edit_Form extends Mage_Adminhtml_Bloc
79
  /**
80
  * Retrieve the existing brand for pre-populating the form fields.
81
  * For a new brand entry, this will return an empty brand object.
 
82
  * @return string|int
83
  */
84
  protected function _getValue()
85
  {
86
- if (!$this->hasData('value')) {
87
  // This will have been set in the controller.
88
  $value = Mage::registry('current_value');
89
 
90
  // Just in case the controller does not register the value.
91
- if (!$value instanceof Omise_Gateway_Model_Config) {
92
  $value = Mage::getModel('omise_gateway/config');
93
  }
94
 
@@ -97,4 +119,4 @@ class Omise_Gateway_Block_Adminhtml_Config_Edit_Form extends Mage_Adminhtml_Bloc
97
 
98
  return $this->getData('value');
99
  }
100
- }
3
  {
4
  /**
5
  * Prepare a form for setting Omise Keys
6
+ *
7
  * @return self
8
  */
9
  protected function _prepareForm()
10
  {
11
  // Instantiate a new form to display our brand for editing.
12
+ $form = new Varien_Data_Form(array(
13
+ 'id' => 'edit_form',
14
+ 'action' => $this->getUrl('adminhtml/omise/config/edit', array('_current' => true, 'continue' => 0)),
15
+ 'method' => 'post'
16
+ ));
17
+
18
  $form->setUseContainer(true);
19
  $this->setForm($form);
20
 
21
  /* Field set for Test Keys */
22
  $fieldset = $form->addFieldset('omise_key_test', array('legend' => $this->__('Test Keys')));
23
+ $this->_addFieldsToFieldset(
24
+ $fieldset,
25
+ array(
26
+ 'public_key_test' => array(
27
+ 'label' => $this->__('Public Key for Test'),
28
+ 'input' => 'password',
29
+ 'required' => false
30
+ ),
31
+ 'secret_key_test' => array(
32
+ 'label' => $this->__('Secret Key for Test'),
33
+ 'input' => 'password',
34
+ 'required' => false
35
+ ),
36
+ 'test_mode' => array(
37
+ 'label' => $this->__('Enable Test mode'),
38
+ 'input' => 'checkbox',
39
+ 'required' => false,
40
+ 'onclick' => 'this.value = this.checked ? 1 : 0;'
41
+ )
42
+ )
43
+ );
44
 
45
  /* Field set for Live Keys */
46
  $fieldset = $form->addFieldset('omise_key_live', array('legend' => $this->__('Live Keys')));
47
+ $this->_addFieldsToFieldset(
48
+ $fieldset,
49
+ array(
50
+ 'public_key' => array(
51
+ 'label' => $this->__('Public Key'),
52
+ 'input' => 'password',
53
+ 'required' => true
54
+ ),
55
+ 'secret_key' => array(
56
+ 'label' => $this->__('Secret Key'),
57
+ 'input' => 'password',
58
+ 'required' => true
59
+ )
60
+ )
61
+ );
62
 
63
  return $this;
64
  }
69
  * in 'brandData' so that we can easily separate all relevant information
70
  * in the controller. You could of course omit this method entirely
71
  * and call the $fieldset->addField() method directly.
72
+ *
73
  * @return self
74
  */
75
  protected function _addFieldsToFieldset(Varien_Data_Form_Element_Fieldset $fieldset, $fields)
82
  $_data['title'] = $_data['label'];
83
 
84
  // If no new value exists, use the existing data.
85
+ if (! array_key_exists('value', $_data)) {
86
  $_data['value'] = $this->_getValue()->getData($name);
87
  }
88
 
100
  /**
101
  * Retrieve the existing brand for pre-populating the form fields.
102
  * For a new brand entry, this will return an empty brand object.
103
+ *
104
  * @return string|int
105
  */
106
  protected function _getValue()
107
  {
108
+ if (! $this->hasData('value')) {
109
  // This will have been set in the controller.
110
  $value = Mage::registry('current_value');
111
 
112
  // Just in case the controller does not register the value.
113
+ if (! $value instanceof Omise_Gateway_Model_Config) {
114
  $value = Mage::getModel('omise_gateway/config');
115
  }
116
 
119
 
120
  return $this->getData('value');
121
  }
122
+ }
app/code/community/Omise/Gateway/Block/Adminhtml/Dashboard/Dashboard.php CHANGED
@@ -6,4 +6,4 @@ class Omise_Gateway_Block_Adminhtml_Dashboard_Dashboard extends Mage_Adminhtml_B
6
  parent::__construct();
7
  $this->setTemplate('omise/dashboard.phtml');
8
  }
9
- }
6
  parent::__construct();
7
  $this->setTemplate('omise/dashboard.phtml');
8
  }
9
+ }
app/code/community/Omise/Gateway/Block/Adminhtml/System/Config/Fieldset/Payment.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Omise_Gateway_Block_Adminhtml_System_Config_Fieldset_Payment extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
3
+ {
4
+ /**
5
+ * Return header title part of html for fieldset.
6
+ *
7
+ * @param Varien_Data_Form_Element_Abstract $element
8
+ *
9
+ * @return string
10
+ *
11
+ * @see Mage_Adminhtml_Block_System_Config_Form_Fieldset::_getHeaderTitleHtml()
12
+ */
13
+ protected function _getHeaderTitleHtml($element)
14
+ {
15
+ $html = '<div class="config-heading entry-edit-head collapseable">';
16
+ $html .= ' <a id="' . $element->getHtmlId() . '-head"
17
+ href="#"
18
+ onclick="Fieldset.toggleCollapse(\'' . $element->getHtmlId() . '\', \'' . $this->getUrl('*/*/state') . '\'); return false;">';
19
+ $html .= $element->getLegend();
20
+ $html .= ' </a>';
21
+
22
+ if ($element->getComment()) {
23
+ $html .= '<span class="heading-intro">' . $element->getComment() . '</span>';
24
+ }
25
+
26
+ $html .= '</div>';
27
+
28
+ return $html;
29
+ }
30
+
31
+ /**
32
+ * Return header comment part of html for fieldset.
33
+ *
34
+ * @param Varien_Data_Form_Element_Abstract $element
35
+ *
36
+ * @return string
37
+ *
38
+ * @see Mage_Adminhtml_Block_System_Config_Form_Fieldset::_getHeaderCommentHtml()
39
+ */
40
+ protected function _getHeaderCommentHtml($element)
41
+ {
42
+ return '';
43
+ }
44
+ }
app/code/community/Omise/Gateway/Block/Form/Cc.php CHANGED
@@ -4,11 +4,17 @@ class Omise_Gateway_Block_Form_Cc extends Mage_Payment_Block_Form
4
  protected function _construct()
5
  {
6
  parent::_construct();
7
- $this->setTemplate('payment/form/omisecc.phtml');
 
 
 
 
 
8
  }
9
 
10
  /**
11
  * Retrieve payment configuration object
 
12
  * @return Mage_Payment_Model_Config
13
  */
14
  protected function _getConfig()
@@ -16,8 +22,42 @@ class Omise_Gateway_Block_Form_Cc extends Mage_Payment_Block_Form
16
  return Mage::getSingleton('payment/config');
17
  }
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  /**
20
  * Retrieve Omise keys from database
 
21
  * @return string|array
22
  */
23
  public function getOmiseKeys($omise_key = '')
@@ -34,14 +74,16 @@ class Omise_Gateway_Block_Form_Cc extends Mage_Payment_Block_Form
34
  $data['secret_key'] = $config->secret_key_test;
35
  }
36
 
37
- if ($omise_key == '')
38
  return $data;
39
- else
40
- return isset($data[$omise_key]) ? $data[$omise_key] : '';
 
41
  }
42
 
43
  /**
44
  * Retrieve availables credit card types
 
45
  * @return array
46
  */
47
  public function getCcAvailableTypes()
@@ -51,8 +93,8 @@ class Omise_Gateway_Block_Form_Cc extends Mage_Payment_Block_Form
51
  $availableTypes = $method->getConfigData('cctypes');
52
  if ($availableTypes) {
53
  $availableTypes = explode(',', $availableTypes);
54
- foreach ($types as $code=>$name) {
55
- if (!in_array($code, $availableTypes)) {
56
  unset($types[$code]);
57
  }
58
  }
@@ -63,6 +105,7 @@ class Omise_Gateway_Block_Form_Cc extends Mage_Payment_Block_Form
63
 
64
  /**
65
  * Retrieve credit card expire months
 
66
  * @return array
67
  */
68
  public function getCcMonths()
@@ -78,6 +121,7 @@ class Omise_Gateway_Block_Form_Cc extends Mage_Payment_Block_Form
78
 
79
  /**
80
  * Retrieve credit card expire years
 
81
  * @return array
82
  */
83
  public function getCcYears()
@@ -85,21 +129,22 @@ class Omise_Gateway_Block_Form_Cc extends Mage_Payment_Block_Form
85
  $years = $this->getData('cc_years');
86
  if (is_null($years)) {
87
  $years = $this->_getConfig()->getYears();
88
- $years = array(0=>$this->__('Year'))+$years;
89
  $this->setData('cc_years', $years);
90
  }
91
  return $years;
92
  }
93
 
94
  /**
95
- * Retrive has verification configuration
 
96
  * @return boolean
97
  */
98
  public function hasVerification()
99
  {
100
  if ($this->getMethod()) {
101
  $configData = $this->getMethod()->getConfigData('useccv');
102
- if(is_null($configData)){
103
  return true;
104
  }
105
  return (bool) $configData;
@@ -109,13 +154,14 @@ class Omise_Gateway_Block_Form_Cc extends Mage_Payment_Block_Form
109
 
110
  /**
111
  * Whether switch/solo card type available
 
112
  * @return boolean
113
  */
114
  public function hasSsCardType()
115
  {
116
- $availableTypes = explode(',', $this->getMethod()->getConfigData('cctypes'));
117
- $ssPresenations = array_intersect(array('SS', 'SM', 'SO'), $availableTypes);
118
- if ($availableTypes && count($ssPresenations) > 0) {
119
  return true;
120
  }
121
  return false;
@@ -123,30 +169,34 @@ class Omise_Gateway_Block_Form_Cc extends Mage_Payment_Block_Form
123
 
124
  /**
125
  * solo/ switch card start year
 
126
  * @return array
127
  */
128
- public function getSsStartYears()
129
  {
130
  $years = array();
131
  $first = date("Y");
132
 
133
- for ($index=5; $index>=0; $index--) {
134
  $year = $first - $index;
135
  $years[$year] = $year;
136
  }
137
- $years = array(0=>$this->__('Year'))+$years;
138
  return $years;
139
  }
140
 
141
  /**
142
  * Render block HTML
 
143
  * @return string
144
  */
145
  protected function _toHtml()
146
  {
147
- Mage::dispatchEvent('payment_form_block_to_html_before', array(
148
- 'block' => $this
149
- ));
 
 
150
  return parent::_toHtml();
151
  }
152
  }
4
  protected function _construct()
5
  {
6
  parent::_construct();
7
+
8
+ if ($this->isApplicable()) {
9
+ $this->setTemplate('payment/form/omisecc.phtml');
10
+ } else {
11
+ $this->setTemplate('payment/form/omise-inapplicable-method.phtml');
12
+ }
13
  }
14
 
15
  /**
16
  * Retrieve payment configuration object
17
+ *
18
  * @return Mage_Payment_Model_Config
19
  */
20
  protected function _getConfig()
22
  return Mage::getSingleton('payment/config');
23
  }
24
 
25
+ /**
26
+ * Check if the payment method is applicable for the checkout form.
27
+ *
28
+ * @return bool
29
+ */
30
+ protected function isApplicable()
31
+ {
32
+ if (! $this->isStoreCurrencySupported()) {
33
+ return false;
34
+ }
35
+
36
+ return true;
37
+ }
38
+
39
+ /**
40
+ * @return bool
41
+ */
42
+ protected function isStoreCurrencySupported()
43
+ {
44
+ $currencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
45
+
46
+ switch ($currencyCode) {
47
+ case 'THB':
48
+ case 'JPY':
49
+ case 'IDR':
50
+ case 'SGD':
51
+ return true;
52
+ break;
53
+ }
54
+
55
+ return false;
56
+ }
57
+
58
  /**
59
  * Retrieve Omise keys from database
60
+ *
61
  * @return string|array
62
  */
63
  public function getOmiseKeys($omise_key = '')
74
  $data['secret_key'] = $config->secret_key_test;
75
  }
76
 
77
+ if ($omise_key == '') {
78
  return $data;
79
+ }
80
+
81
+ return isset($data[$omise_key]) ? $data[$omise_key] : '';
82
  }
83
 
84
  /**
85
  * Retrieve availables credit card types
86
+ *
87
  * @return array
88
  */
89
  public function getCcAvailableTypes()
93
  $availableTypes = $method->getConfigData('cctypes');
94
  if ($availableTypes) {
95
  $availableTypes = explode(',', $availableTypes);
96
+ foreach ($types as $code => $name) {
97
+ if (! in_array($code, $availableTypes)) {
98
  unset($types[$code]);
99
  }
100
  }
105
 
106
  /**
107
  * Retrieve credit card expire months
108
+ *
109
  * @return array
110
  */
111
  public function getCcMonths()
121
 
122
  /**
123
  * Retrieve credit card expire years
124
+ *
125
  * @return array
126
  */
127
  public function getCcYears()
129
  $years = $this->getData('cc_years');
130
  if (is_null($years)) {
131
  $years = $this->_getConfig()->getYears();
132
+ $years = array(0 => $this->__('Year')) + $years;
133
  $this->setData('cc_years', $years);
134
  }
135
  return $years;
136
  }
137
 
138
  /**
139
+ * Retrieve has verification configuration
140
+ *
141
  * @return boolean
142
  */
143
  public function hasVerification()
144
  {
145
  if ($this->getMethod()) {
146
  $configData = $this->getMethod()->getConfigData('useccv');
147
+ if (is_null($configData)) {
148
  return true;
149
  }
150
  return (bool) $configData;
154
 
155
  /**
156
  * Whether switch/solo card type available
157
+ *
158
  * @return boolean
159
  */
160
  public function hasSsCardType()
161
  {
162
+ $availableTypes = explode(',', $this->getMethod()->getConfigData('cctypes'));
163
+ $ssPresentations = array_intersect(array('SS', 'SM', 'SO'), $availableTypes);
164
+ if ($availableTypes && count($ssPresentations) > 0) {
165
  return true;
166
  }
167
  return false;
169
 
170
  /**
171
  * solo/ switch card start year
172
+ *
173
  * @return array
174
  */
175
+ public function getSsStartYears()
176
  {
177
  $years = array();
178
  $first = date("Y");
179
 
180
+ for ($index = 5; $index >= 0; $index--) {
181
  $year = $first - $index;
182
  $years[$year] = $year;
183
  }
184
+ $years = array(0 => $this->__('Year')) + $years;
185
  return $years;
186
  }
187
 
188
  /**
189
  * Render block HTML
190
+ *
191
  * @return string
192
  */
193
  protected function _toHtml()
194
  {
195
+ Mage::dispatchEvent(
196
+ 'payment_form_block_to_html_before',
197
+ array('block' => $this)
198
+ );
199
+
200
  return parent::_toHtml();
201
  }
202
  }
app/code/community/Omise/Gateway/Block/Form/OffsiteInternetBankingPayment.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Omise_Gateway_Block_Form_OffsiteInternetBankingPayment extends Mage_Payment_Block_Form
3
+ {
4
+ protected function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->setTemplate('payment/form/omiseoffsiteinternetbankingpayment.phtml');
8
+ }
9
+
10
+ /**
11
+ * Retrieve payment configuration object
12
+ *
13
+ * @return Mage_Payment_Model_Config
14
+ */
15
+ protected function _getConfig()
16
+ {
17
+ return Mage::getSingleton('payment/config');
18
+ }
19
+
20
+ /**
21
+ * Render block HTML
22
+ *
23
+ * @return string
24
+ */
25
+ protected function _toHtml()
26
+ {
27
+ Mage::dispatchEvent(
28
+ 'payment_form_block_to_html_before',
29
+ array('block' => $this)
30
+ );
31
+
32
+ return parent::_toHtml();
33
+ }
34
+ }
app/code/community/Omise/Gateway/Helper/Data.php CHANGED
@@ -1,5 +1,35 @@
1
  <?php
2
  class Omise_Gateway_Helper_Data extends Mage_Core_Helper_Abstract
3
  {
4
- // ...
5
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
  class Omise_Gateway_Helper_Data extends Mage_Core_Helper_Abstract
3
  {
4
+ public function formatPrice($currency, $amount)
5
+ {
6
+ switch (strtoupper($currency)) {
7
+ case 'THB':
8
+ $amount = "฿" . number_format(($amount / 100), 2);
9
+ if (preg_match('/\.00$/', $amount)) {
10
+ $amount = substr($amount, 0, -3);
11
+ }
12
+ break;
13
+
14
+ case 'IDR':
15
+ $amount = "Rp" . number_format(($amount / 100), 2);
16
+ if (preg_match('/\.00$/', $amount)) {
17
+ $amount = substr($amount, 0, -3);
18
+ }
19
+ break;
20
+
21
+ case 'SGD':
22
+ $amount = "S$" . number_format(($amount / 100), 2);
23
+ if (preg_match('/\.00$/', $amount)) {
24
+ $amount = substr($amount, 0, -3);
25
+ }
26
+ break;
27
+
28
+ case 'JPY':
29
+ $amount = number_format($amount) . "円";
30
+ break;
31
+ }
32
+
33
+ return $amount;
34
+ }
35
+ }
app/code/community/Omise/Gateway/Model/Config.php CHANGED
@@ -5,4 +5,4 @@ class Omise_Gateway_Model_Config extends Mage_Core_Model_Abstract
5
  {
6
  $this->_init('omise_gateway/config');
7
  }
8
- }
5
  {
6
  $this->_init('omise_gateway/config');
7
  }
8
+ }
app/code/community/Omise/Gateway/Model/Config/Var/Paymentaction.php CHANGED
@@ -3,6 +3,7 @@ class Omise_Gateway_Model_Config_Var_Paymentaction
3
  {
4
  /**
5
  * Return an array that use for 'payment action' configuration
 
6
  * @return array
7
  */
8
  public function toOptionArray()
3
  {
4
  /**
5
  * Return an array that use for 'payment action' configuration
6
+ *
7
  * @return array
8
  */
9
  public function toOptionArray()
app/code/community/Omise/Gateway/Model/OffsiteInternetBankingPayment.php ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Omise_Gateway_Model_OffsiteInternetBankingPayment extends Omise_Gateway_Model_Payment
3
+ {
4
+ /**
5
+ * @var string
6
+ */
7
+ const STRATEGY_OFFSITE_INTERNET_BANKING = 'OffsiteInternetBankingStrategy';
8
+
9
+ /**
10
+ * @var string
11
+ */
12
+ protected $_code = 'omise_offsite_internet_banking';
13
+
14
+ /**
15
+ * @var string
16
+ */
17
+ protected $_formBlockType = 'omise_gateway/form_offsiteinternetbankingpayment';
18
+
19
+ /**
20
+ * @var string
21
+ */
22
+ protected $_infoBlockType = 'payment/info';
23
+
24
+ /**
25
+ * Payment Method features
26
+ *
27
+ * @var bool
28
+ */
29
+ protected $_isGateway = true;
30
+ protected $_canCapture = true;
31
+ protected $_canReviewPayment = true;
32
+
33
+ /**
34
+ * Capture payment method
35
+ *
36
+ * @param Varien_Object $payment
37
+ * @param float $amount
38
+ *
39
+ * @return Mage_Payment_Model_Abstract
40
+ */
41
+ public function capture(Varien_Object $payment, $amount)
42
+ {
43
+ Mage::log('Start processing internet banking payment method with Omise payment gateway.');
44
+
45
+ $result = $this->perform(
46
+ Mage::getModel('omise_gateway/Strategies_' . self::STRATEGY_OFFSITE_INTERNET_BANKING),
47
+ $payment,
48
+ $amount
49
+ );
50
+
51
+ $payment->setIsTransactionPending(true);
52
+
53
+ $this->getInfoInstance()->setAdditionalInformation('omise_charge_id', $result['id']);
54
+
55
+ Mage::getSingleton('checkout/session')->setOmiseAuthorizeUri($result['authorize_uri']);
56
+
57
+ Mage::log('The transaction was created, processing internet banking payment by Omise payment gateway.');
58
+ return $this;
59
+ }
60
+
61
+ /**
62
+ * {@inheritDoc}
63
+ *
64
+ * @see app/code/community/Omise/Gateway/Model/PaymentMethod.php
65
+ */
66
+ public function acceptPayment(Mage_Payment_Model_Info $payment)
67
+ {
68
+ parent::acceptPayment($payment);
69
+
70
+ return true;
71
+ }
72
+
73
+ /**
74
+ * {@inheritDoc}
75
+ *
76
+ * @see app/code/community/Omise/Gateway/Model/PaymentMethod.php
77
+ */
78
+ public function denyPayment(Mage_Payment_Model_Info $payment)
79
+ {
80
+ parent::denyPayment($payment);
81
+
82
+ return true;
83
+ }
84
+
85
+ /**
86
+ * {@inheritDoc}
87
+ *
88
+ * @see app/code/core/Mage/Payment/Model/Method/Abstract.php
89
+ */
90
+ public function assignData($data)
91
+ {
92
+ parent::assignData($data);
93
+
94
+ $this->getInfoInstance()->setAdditionalInformation('offsite', $data->getData('offsite'));
95
+ }
96
+
97
+ /**
98
+ * {@inheritDoc}
99
+ *
100
+ * @see app/code/core/Mage/Sales/Model/Quote/Payment.php
101
+ */
102
+ public function getOrderPlaceRedirectUrl()
103
+ {
104
+ return Mage::getSingleton('checkout/session')->getOmiseAuthorizeUri();
105
+ }
106
+
107
+ /**
108
+ * Format a Magento's amount to be a small-unit that Omise's API requires.
109
+ * Note, no specific format for JPY currency.
110
+ *
111
+ * @param string $currency
112
+ * @param integer | float $amount
113
+ *
114
+ * @return integer
115
+ */
116
+ public function formatAmount($currency, $amount)
117
+ {
118
+ switch (strtoupper($currency)) {
119
+ case 'THB':
120
+ case 'IDR':
121
+ case 'SGD':
122
+ // Convert to a small unit
123
+ $amount = $amount * 100;
124
+ break;
125
+ }
126
+
127
+ return $amount;
128
+ }
129
+
130
+ /**
131
+ * @param array $params
132
+ *
133
+ * @return string
134
+ */
135
+ public function getCallbackUri($params = array())
136
+ {
137
+ return Mage::getUrl(
138
+ 'omise/callback_validateoffsiteinternetbanking',
139
+ array(
140
+ '_secure' => Mage::app()->getStore()->isCurrentlySecure(),
141
+ '_query' => $params
142
+ )
143
+ );
144
+ }
145
+ }
app/code/community/Omise/Gateway/Model/Omise.php CHANGED
@@ -1,26 +1,28 @@
1
  <?php
2
- // Define 'OMISE_USER_AGENT_SUFFIX'
3
- if(!defined('OMISE_USER_AGENT_SUFFIX'))
4
- define('OMISE_USER_AGENT_SUFFIX', 'OmiseMagento/1.9.0.6 Magento/'.Mage::getVersion());
5
-
6
- // Define 'OMISE_API_VERSION'
7
- if(!defined('OMISE_API_VERSION'))
8
- define('OMISE_API_VERSION', '2014-07-27');
9
-
10
  class Omise_Gateway_Model_Omise extends Mage_Core_Model_Abstract
11
  {
12
  /**
 
 
13
  * @var string Omise public key
14
  */
15
  protected $_public_key;
16
 
17
  /**
 
 
18
  * @var string Omise secret key
19
  */
20
  protected $_secret_key;
21
 
 
 
 
 
 
22
  /**
23
  * Load necessary file and setup Omise keys
 
24
  * @return void
25
  */
26
  protected function _construct()
@@ -29,14 +31,91 @@ class Omise_Gateway_Model_Omise extends Mage_Core_Model_Abstract
29
  require_once(Mage::getBaseDir('lib') . '/omise-php/lib/Omise.php');
30
 
31
  // Retrieve Omise's keys from table.
32
- $omise = Mage::getModel('omise_gateway/config')->load(1);
33
- $this->_public_key = $omise->public_key;
34
- $this->_secret_key = $omise->secret_key;
35
-
36
- // Replace keys with test keys if test mode was enabled.
37
- if ($omise->test_mode) {
38
- $this->_public_key = $omise->public_key_test;
39
- $this->_secret_key = $omise->secret_key_test;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  }
42
- }
1
  <?php
 
 
 
 
 
 
 
 
2
  class Omise_Gateway_Model_Omise extends Mage_Core_Model_Abstract
3
  {
4
  /**
5
+ * @deprecated use $this->getPublicKey(); instead.
6
+ *
7
  * @var string Omise public key
8
  */
9
  protected $_public_key;
10
 
11
  /**
12
+ * @deprecated use $this->getSecretKey(); instead.
13
+ *
14
  * @var string Omise secret key
15
  */
16
  protected $_secret_key;
17
 
18
+ /**
19
+ * @var \Omise_Gateway_Model_Config
20
+ */
21
+ protected $config;
22
+
23
  /**
24
  * Load necessary file and setup Omise keys
25
+ *
26
  * @return void
27
  */
28
  protected function _construct()
31
  require_once(Mage::getBaseDir('lib') . '/omise-php/lib/Omise.php');
32
 
33
  // Retrieve Omise's keys from table.
34
+ $this->config = Mage::getModel('omise_gateway/config')->load(1);
35
+
36
+ // @deprecated use $this->getPublicKey() and $this->getSecretKey() instead.
37
+ $this->_public_key = $this->getPublicKey();
38
+ $this->_secret_key = $this->getSecretKey();
39
+ }
40
+
41
+ /**
42
+ * @return bool
43
+ */
44
+ public function isTestMode()
45
+ {
46
+ return $this->config->test_mode;
47
+ }
48
+
49
+ /**
50
+ * @return string
51
+ */
52
+ public function getPublicKey()
53
+ {
54
+ if ($this->isTestMode()) {
55
+ return $this->config->public_key_test;
56
  }
57
+
58
+ return $this->config->public_key;
59
+ }
60
+
61
+ /**
62
+ * @return string
63
+ */
64
+ public function getSecretKey()
65
+ {
66
+ if ($this->isTestMode()) {
67
+ return $this->config->secret_key_test;
68
+ }
69
+
70
+ return $this->config->secret_key;
71
+ }
72
+
73
+ /**
74
+ * @param string $public_key
75
+ * @param string $secret_key
76
+ *
77
+ * @return void
78
+ */
79
+ public function defineApiKeys($public_key = '', $secret_key = '')
80
+ {
81
+ if (! defined('OMISE_PUBLIC_KEY')) {
82
+ define('OMISE_PUBLIC_KEY', $public_key ? $public_key : $this->getPublicKey());
83
+ }
84
+
85
+ if (! defined('OMISE_SECRET_KEY')) {
86
+ define('OMISE_SECRET_KEY', $secret_key ? $secret_key : $this->getSecretKey());
87
+ }
88
+ }
89
+
90
+ /**
91
+ * @param string $version
92
+ *
93
+ * @return void
94
+ */
95
+ public function defineApiVersion($version = '2014-07-27')
96
+ {
97
+ if (! defined('OMISE_API_VERSION')) {
98
+ define('OMISE_API_VERSION', $version);
99
+ }
100
+ }
101
+
102
+ /**
103
+ * @return void
104
+ */
105
+ public function defineUserAgent()
106
+ {
107
+ if (! defined('OMISE_USER_AGENT_SUFFIX')) {
108
+ define('OMISE_USER_AGENT_SUFFIX', 'OmiseMagento/1.8 Magento/' . Mage::getVersion());
109
+ }
110
+ }
111
+
112
+ /**
113
+ * @return void
114
+ */
115
+ public function initNecessaryConstant()
116
+ {
117
+ $this->defineApiKeys();
118
+ $this->defineApiVersion();
119
+ $this->defineUserAgent();
120
  }
121
+ }
app/code/community/Omise/Gateway/Model/OmiseAccount.php CHANGED
@@ -3,14 +3,17 @@ class Omise_Gateway_Model_OmiseAccount extends Omise_Gateway_Model_Omise
3
  {
4
  /**
5
  * Retrieve user's account from their Omise account
 
6
  * @return OmiseAccount|Exception
7
  */
8
  public function retrieveOmiseAccount()
9
  {
 
 
10
  try {
11
  return OmiseAccount::retrieve($this->_public_key, $this->_secret_key);
12
  } catch (Exception $e) {
13
  return array('error' => $e->getMessage());
14
  }
15
  }
16
- }
3
  {
4
  /**
5
  * Retrieve user's account from their Omise account
6
+ *
7
  * @return OmiseAccount|Exception
8
  */
9
  public function retrieveOmiseAccount()
10
  {
11
+ $this->initNecessaryConstant();
12
+
13
  try {
14
  return OmiseAccount::retrieve($this->_public_key, $this->_secret_key);
15
  } catch (Exception $e) {
16
  return array('error' => $e->getMessage());
17
  }
18
  }
19
+ }
app/code/community/Omise/Gateway/Model/OmiseBalance.php CHANGED
@@ -3,14 +3,17 @@ class Omise_Gateway_Model_OmiseBalance extends Omise_Gateway_Model_Omise
3
  {
4
  /**
5
  * Retrieve user's balance from their Omise account
 
6
  * @return OmiseBalance|Exception
7
  */
8
  public function retrieveOmiseBalance()
9
  {
 
 
10
  try {
11
  return OmiseBalance::retrieve($this->_public_key, $this->_secret_key);
12
  } catch (Exception $e) {
13
  return array('error' => $e->getMessage());
14
  }
15
  }
16
- }
3
  {
4
  /**
5
  * Retrieve user's balance from their Omise account
6
+ *
7
  * @return OmiseBalance|Exception
8
  */
9
  public function retrieveOmiseBalance()
10
  {
11
+ $this->initNecessaryConstant();
12
+
13
  try {
14
  return OmiseBalance::retrieve($this->_public_key, $this->_secret_key);
15
  } catch (Exception $e) {
16
  return array('error' => $e->getMessage());
17
  }
18
  }
19
+ }
app/code/community/Omise/Gateway/Model/OmiseCharge.php CHANGED
@@ -3,11 +3,15 @@ class Omise_Gateway_Model_OmiseCharge extends Omise_Gateway_Model_Omise
3
  {
4
  /**
5
  * Creates a new charge with Omise Payment Gateway.
6
- * @param array $params
 
 
7
  * @return OmiseCharge|Exception
8
  */
9
  public function createOmiseCharge($params)
10
  {
 
 
11
  try {
12
  return OmiseCharge::create($params, $this->_public_key, $this->_secret_key);
13
  } catch (Exception $e) {
@@ -17,11 +21,15 @@ class Omise_Gateway_Model_OmiseCharge extends Omise_Gateway_Model_Omise
17
 
18
  /**
19
  * Capture a charge that retrieve from charge id
20
- * @param array $params
 
 
21
  * @return OmiseCharge|Exception
22
  */
23
  public function captureOmiseCharge($id)
24
  {
 
 
25
  try {
26
  $charge = OmiseCharge::retrieve($id, $this->_public_key, $this->_secret_key);
27
  return $charge->capture();
@@ -29,4 +37,4 @@ class Omise_Gateway_Model_OmiseCharge extends Omise_Gateway_Model_Omise
29
  return array('error' => $e->getMessage());
30
  }
31
  }
32
- }
3
  {
4
  /**
5
  * Creates a new charge with Omise Payment Gateway.
6
+ *
7
+ * @param array $params
8
+ *
9
  * @return OmiseCharge|Exception
10
  */
11
  public function createOmiseCharge($params)
12
  {
13
+ $this->initNecessaryConstant();
14
+
15
  try {
16
  return OmiseCharge::create($params, $this->_public_key, $this->_secret_key);
17
  } catch (Exception $e) {
21
 
22
  /**
23
  * Capture a charge that retrieve from charge id
24
+ *
25
+ * @param string $id
26
+ *
27
  * @return OmiseCharge|Exception
28
  */
29
  public function captureOmiseCharge($id)
30
  {
31
+ $this->initNecessaryConstant();
32
+
33
  try {
34
  $charge = OmiseCharge::retrieve($id, $this->_public_key, $this->_secret_key);
35
  return $charge->capture();
37
  return array('error' => $e->getMessage());
38
  }
39
  }
40
+ }
app/code/community/Omise/Gateway/Model/OmiseTransfer.php CHANGED
@@ -2,11 +2,14 @@
2
  class Omise_Gateway_Model_OmiseTransfer extends Omise_Gateway_Model_Omise
3
  {
4
  /**
5
- * @param string $id
 
6
  * @return OmiseTransfer|array
7
  */
8
  public function retrieveOmiseTransfer($id = '')
9
  {
 
 
10
  try {
11
  return OmiseTransfer::retrieve('', $this->_public_key, $this->_secret_key);
12
  } catch (Exception $e) {
@@ -15,19 +18,24 @@ class Omise_Gateway_Model_OmiseTransfer extends Omise_Gateway_Model_Omise
15
  }
16
 
17
  /**
18
- * @param unknown $params
 
19
  * @return OmiseTransfer|array
20
  */
21
  public function createOmiseTransfer($params)
22
  {
 
 
23
  try {
24
  // Validate $params
25
  // If it not contain `amount` key.
26
- if (!isset($params['amount']))
27
  throw new Exception("Amount was required", 1);
 
28
 
29
- if ($params['amount'] == '')
30
  throw new Exception("Don't let amount with empty value", 1);
 
31
 
32
  // Remove `.`
33
  $params['amount'] = str_replace('.', '', $params['amount']);
@@ -39,14 +47,18 @@ class Omise_Gateway_Model_OmiseTransfer extends Omise_Gateway_Model_Omise
39
  }
40
 
41
  /**
42
- * @param string $id
 
43
  * @return OmiseTransfer|array
44
  */
45
  public function deleteOmiseTransfer($id = '')
46
  {
 
 
47
  try {
48
- if ($id == '')
49
  throw new Exception("Id was required", 1);
 
50
 
51
  $object = OmiseTransfer::retrieve($id, $this->_public_key, $this->_secret_key);
52
 
@@ -55,4 +67,4 @@ class Omise_Gateway_Model_OmiseTransfer extends Omise_Gateway_Model_Omise
55
  return array('error' => $e->getMessage());
56
  }
57
  }
58
- }
2
  class Omise_Gateway_Model_OmiseTransfer extends Omise_Gateway_Model_Omise
3
  {
4
  /**
5
+ * @param string $id
6
+ *
7
  * @return OmiseTransfer|array
8
  */
9
  public function retrieveOmiseTransfer($id = '')
10
  {
11
+ $this->initNecessaryConstant();
12
+
13
  try {
14
  return OmiseTransfer::retrieve('', $this->_public_key, $this->_secret_key);
15
  } catch (Exception $e) {
18
  }
19
 
20
  /**
21
+ * @param array $params
22
+ *
23
  * @return OmiseTransfer|array
24
  */
25
  public function createOmiseTransfer($params)
26
  {
27
+ $this->initNecessaryConstant();
28
+
29
  try {
30
  // Validate $params
31
  // If it not contain `amount` key.
32
+ if (! isset($params['amount'])) {
33
  throw new Exception("Amount was required", 1);
34
+ }
35
 
36
+ if ($params['amount'] == '') {
37
  throw new Exception("Don't let amount with empty value", 1);
38
+ }
39
 
40
  // Remove `.`
41
  $params['amount'] = str_replace('.', '', $params['amount']);
47
  }
48
 
49
  /**
50
+ * @param string $id
51
+ *
52
  * @return OmiseTransfer|array
53
  */
54
  public function deleteOmiseTransfer($id = '')
55
  {
56
+ $this->initNecessaryConstant();
57
+
58
  try {
59
+ if ($id == '') {
60
  throw new Exception("Id was required", 1);
61
+ }
62
 
63
  $object = OmiseTransfer::retrieve($id, $this->_public_key, $this->_secret_key);
64
 
67
  return array('error' => $e->getMessage());
68
  }
69
  }
70
+ }
app/code/community/Omise/Gateway/Model/Payment.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ abstract class Omise_Gateway_Model_Payment extends Mage_Payment_Model_Method_Abstract
3
+ {
4
+ /**
5
+ * @var \Omise_Gateway_Model_Config
6
+ */
7
+ protected $config;
8
+
9
+ /**
10
+ * @var \Omise_Gateway_Model_Omise
11
+ */
12
+ protected $omise;
13
+
14
+ /**
15
+ * @var \Mage_Sales_Model_Order_Payment
16
+ */
17
+ protected $payment_information;
18
+
19
+ /**
20
+ * Load necessary file and setup Omise keys
21
+ *
22
+ * @return void
23
+ */
24
+ public function __construct()
25
+ {
26
+ $this->config = Mage::getModel('omise_gateway/config')->load(1);
27
+ $this->omise = Mage::getModel('omise_gateway/omise');
28
+ }
29
+
30
+ /**
31
+ * @return \Mage_Sales_Model_Order_Payment
32
+ */
33
+ public function getPaymentInformation()
34
+ {
35
+ return $this->payment_information;
36
+ }
37
+
38
+ /**
39
+ * @param \Omise_Gateway_Model_Strategies_StrategyInterface $strategy
40
+ * @param \Mage_Sales_Model_Order_Payment $payment
41
+ * @param int|float $amount
42
+ *
43
+ * @return Mage_Payment_Model_Abstract
44
+ */
45
+ public function perform(
46
+ Omise_Gateway_Model_Strategies_StrategyInterface $strategy,
47
+ Mage_Sales_Model_Order_Payment $payment,
48
+ $amount
49
+ ) {
50
+ $this->omise->defineApiKeys();
51
+ $this->omise->defineApiVersion();
52
+ $this->omise->defineUserAgent();
53
+
54
+ $this->payment_information = $payment;
55
+
56
+ try {
57
+ $result = $strategy->perform($this, $amount);
58
+ } catch (Exception $e) {
59
+ Mage::throwException(Mage::helper('payment')->__($e->getMessage()));
60
+ }
61
+
62
+ if (! $strategy->validate($result)) {
63
+ Mage::throwException(Mage::helper('payment')->__($strategy->getMessage()));
64
+ }
65
+
66
+ return $result;
67
+ }
68
+ }
app/code/community/Omise/Gateway/Model/PaymentMethod.php CHANGED
@@ -1,96 +1,237 @@
1
  <?php
2
- class Omise_Gateway_Model_PaymentMethod extends Mage_Payment_Model_Method_Abstract
3
  {
4
- /** @var string */
5
- protected $_code = 'omise_gateway';
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
- /** @var string */
8
- protected $_formBlockType = 'omise_gateway/form_cc';
 
 
9
 
10
- /** @var string */
11
- protected $_infoBlockType = 'payment/info_cc';
 
 
12
 
13
  /**
14
  * Payment Method features
 
15
  * @var bool
16
  */
17
- protected $_isGateway = true;
18
- protected $_canAuthorize = true;
19
- protected $_canCapture = true;
 
20
 
21
  /**
22
  * Authorize payment method
23
- * @param Varien_Object $payment
24
- * @param float $amount
 
 
25
  * @return Mage_Payment_Model_Abstract
26
  */
27
  public function authorize(Varien_Object $payment, $amount)
28
  {
29
- Mage::log('Start authorize with OmiseCharge API!');
30
-
31
- $omise_token = $payment->getData('additional_information');
32
- $charge = Mage::getModel('omise_gateway/omiseCharge')->createOmiseCharge(array(
33
- "amount" => number_format($amount, 2, '', ''),
34
- "currency" => "thb",
35
- "description" => 'Charge a card from Magento that order id is '.$payment->getData('entity_id'),
36
- "capture" => false,
37
- "card" => $omise_token['omise_token']
38
- ));
39
-
40
- if (isset($charge['error']))
41
- Mage::throwException(Mage::helper('payment')->__('OmiseCharge:: '.$charge['error']));
42
-
43
- if (!$charge['authorized'])
44
- Mage::throwException(Mage::helper('payment')->__('Your authorize failed:: ('.$charge['failure_code'].') - '.$charge['failure_code']));
45
-
46
- $this->getInfoInstance()->setAdditionalInformation('omise_charge_id', $charge['id']);
47
-
48
- Mage::log('This transaction was authorized! (by OmiseCharge API)');
49
  return $this;
50
  }
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  /**
53
  * Capture payment method
54
- * @param Varien_Object $payment
55
- * @param float $amount
 
 
56
  * @return Mage_Payment_Model_Abstract
57
  */
58
  public function capture(Varien_Object $payment, $amount)
59
  {
60
- $additional_information = $payment->getData('additional_information');
61
- $authorized = isset($additional_information['omise_charge_id']) ? $additional_information['omise_charge_id'] : false;
62
- if ($authorized) {
63
- // Capture only.
64
- Mage::log('Start capture with OmiseCharge API!');
65
 
66
- $charge = Mage::getModel('omise_gateway/omiseCharge')->captureOmiseCharge($authorized);
 
 
 
67
  } else {
68
- // Authorize and capture.
69
- Mage::log('Start capture with OmiseCharge API!');
70
-
71
- $omise_token = $payment->getData('additional_information');
72
- $charge = Mage::getModel('omise_gateway/omiseCharge')->createOmiseCharge(array(
73
- "amount" => number_format($amount, 2, '', ''),
74
- "currency" => "thb",
75
- "description" => 'Charge a card from Magento that order id is '.$payment->getData('entity_id'),
76
- "card" => $omise_token['omise_token']
77
- ));
78
  }
79
 
80
- if (isset($charge['error']))
81
- Mage::throwException(Mage::helper('payment')->__('OmiseCharge:: '.$charge['error']));
82
-
83
- if (!$charge['authorized'] || !$charge['captured'])
84
- Mage::throwException(Mage::helper('payment')->__('Your payment failed:: ('.$charge['failure_code'].') - '.$charge['failure_code']));
85
 
86
- Mage::log('This transaction was authorized and captured! (by OmiseCharge API)');
87
  return $this;
88
  }
89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
 
91
  /**
92
  * Assign data to info model instance
 
93
  * @param mixed $data
 
94
  * @return Mage_Payment_Model_Info
95
  */
96
  public function assignData($data)
@@ -100,14 +241,16 @@ class Omise_Gateway_Model_PaymentMethod extends Mage_Payment_Model_Method_Abstra
100
  $result = parent::assignData($data);
101
 
102
  if (is_array($data)) {
103
- if (!isset($data['omise_token']))
104
  Mage::throwException(Mage::helper('payment')->__('Need Omise\'s keys'));
 
105
 
106
  Mage::log('Data that assign is Array');
107
  $this->getInfoInstance()->setAdditionalInformation('omise_token', $data['omise_token']);
108
  } elseif ($data instanceof Varien_Object) {
109
- if (!$data->getData('omise_token'))
110
  Mage::throwException(Mage::helper('payment')->__('Need Omise\'s keys'));
 
111
 
112
  Mage::log('Data that assign is Object');
113
  $this->getInfoInstance()->setAdditionalInformation('omise_token', $data->getData('omise_token'));
@@ -115,4 +258,65 @@ class Omise_Gateway_Model_PaymentMethod extends Mage_Payment_Model_Method_Abstra
115
 
116
  return $result;
117
  }
118
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ class Omise_Gateway_Model_PaymentMethod extends Omise_Gateway_Model_Payment
3
  {
4
+ /**
5
+ * Payment strategies
6
+ *
7
+ * @var string
8
+ */
9
+ const STRATEGY_AUTHORIZE = 'AuthorizeStrategy';
10
+ const STRATEGY_AUTHORIZE_THREE_D_SECURE = 'AuthorizeThreeDSecureStrategy';
11
+ const STRATEGY_AUTHORIZE_CAPTURE = 'CaptureStrategy';
12
+ const STRATEGY_AUTHORIZE_CAPTURE_THREE_D_SECURE = 'CaptureThreeDSecureStrategy';
13
+ const STRATEGY_MANUAL_CAPTURE = 'ManualCaptureStrategy';
14
+
15
+ /**
16
+ * @var string
17
+ */
18
+ protected $_code = 'omise_gateway';
19
 
20
+ /**
21
+ * @var string
22
+ */
23
+ protected $_formBlockType = 'omise_gateway/form_cc';
24
 
25
+ /**
26
+ * @var string
27
+ */
28
+ protected $_infoBlockType = 'payment/info_cc';
29
 
30
  /**
31
  * Payment Method features
32
+ *
33
  * @var bool
34
  */
35
+ protected $_isGateway = true;
36
+ protected $_canAuthorize = true;
37
+ protected $_canCapture = true;
38
+ protected $_canReviewPayment = true;
39
 
40
  /**
41
  * Authorize payment method
42
+ *
43
+ * @param Varien_Object $payment
44
+ * @param float $amount
45
+ *
46
  * @return Mage_Payment_Model_Abstract
47
  */
48
  public function authorize(Varien_Object $payment, $amount)
49
  {
50
+ Mage::log('Start authorizing with Omise Payment Gateway.');
51
+
52
+ if ($this->isThreeDSecureNeeded()) {
53
+ $result = $this->performAuthorizeThreeDSecure($payment, $amount);
54
+ } else {
55
+ $result = $this->performAuthorize($payment, $amount);
56
+ }
57
+
58
+ $this->getInfoInstance()->setAdditionalInformation('omise_charge_id', $result['id']);
59
+ Mage::log('Assigned charge id ' . $result['id'] . ' to the transaction');
60
+
 
 
 
 
 
 
 
 
 
61
  return $this;
62
  }
63
 
64
+ /**
65
+ * Perform authorize action
66
+ *
67
+ * @param Varien_Object $payment
68
+ * @param float $amount
69
+ *
70
+ * @return Mage_Payment_Model_Abstract
71
+ */
72
+ protected function performAuthorize(Varien_Object $payment, $amount)
73
+ {
74
+ $result = $this->perform(
75
+ Mage::getModel('omise_gateway/Strategies_' . self::STRATEGY_AUTHORIZE),
76
+ $payment,
77
+ $amount
78
+ );
79
+
80
+ Mage::log('The transaction was authorized! (by OmiseCharge API)');
81
+ return $result;
82
+ }
83
+
84
+ /**
85
+ * Perform authorize with 3-D Secure action
86
+ *
87
+ * @param Varien_Object $payment
88
+ * @param float $amount
89
+ *
90
+ * @return Mage_Payment_Model_Abstract
91
+ */
92
+ protected function performAuthorizeThreeDSecure(Varien_Object $payment, $amount)
93
+ {
94
+ $result = $this->perform(
95
+ Mage::getModel('omise_gateway/Strategies_' . self::STRATEGY_AUTHORIZE_THREE_D_SECURE),
96
+ $payment,
97
+ $amount
98
+ );
99
+
100
+ $payment->setIsTransactionPending(true);
101
+
102
+ Mage::getSingleton('checkout/session')->setOmiseAuthorizeUri($result['authorize_uri']);
103
+
104
+ Mage::log('The transaction was created, processing 3-D Secure authentication.');
105
+ return $result;
106
+ }
107
+
108
  /**
109
  * Capture payment method
110
+ *
111
+ * @param Varien_Object $payment
112
+ * @param float $amount
113
+ *
114
  * @return Mage_Payment_Model_Abstract
115
  */
116
  public function capture(Varien_Object $payment, $amount)
117
  {
118
+ Mage::log('Start capturing with Omise Payment Gateway.');
 
 
 
 
119
 
120
+ if ($payment->getAdditionalInformation('omise_charge_id')) {
121
+ $result = $this->performManualCapture($payment, $amount);
122
+ } else if ($this->isThreeDSecureNeeded()) {
123
+ $result = $this->performCaptureThreeDSecure($payment, $amount);
124
  } else {
125
+ $result = $this->performCapture($payment, $amount);
 
 
 
 
 
 
 
 
 
126
  }
127
 
128
+ $this->getInfoInstance()->setAdditionalInformation('omise_charge_id', $result['id']);
129
+ Mage::log('Assigned charge id ' . $result['id'] . ' to the transaction');
 
 
 
130
 
 
131
  return $this;
132
  }
133
 
134
+ /**
135
+ * Perform auto capture action
136
+ *
137
+ * @param Varien_Object $payment
138
+ * @param float $amount
139
+ *
140
+ * @return Mage_Payment_Model_Abstract
141
+ */
142
+ protected function performCapture(Varien_Object $payment, $amount)
143
+ {
144
+ $result = $this->perform(
145
+ Mage::getModel('omise_gateway/Strategies_' . self::STRATEGY_AUTHORIZE_CAPTURE),
146
+ $payment,
147
+ $amount
148
+ );
149
+
150
+ Mage::log('The transaction was authorized and captured by Omise payment gateway.');
151
+ return $result;
152
+ }
153
+
154
+ /**
155
+ * Perform auto capture with 3-D Secure action
156
+ *
157
+ * @param Varien_Object $payment
158
+ * @param float $amount
159
+ *
160
+ * @return Mage_Payment_Model_Abstract
161
+ */
162
+ protected function performCaptureThreeDSecure(Varien_Object $payment, $amount)
163
+ {
164
+ $result = $this->perform(
165
+ Mage::getModel('omise_gateway/Strategies_' . self::STRATEGY_AUTHORIZE_CAPTURE_THREE_D_SECURE),
166
+ $payment,
167
+ $amount
168
+ );
169
+
170
+ $payment->setIsTransactionPending(true);
171
+
172
+ Mage::getSingleton('checkout/session')->setOmiseAuthorizeUri($result['authorize_uri']);
173
+
174
+ Mage::log('The transaction was created, processing 3-D Secure authentication by Omise payment gateway.');
175
+ return $result;
176
+ }
177
+
178
+ /**
179
+ * Capture an authorized transaction
180
+ *
181
+ * @param Varien_Object $payment
182
+ * @param float $amount
183
+ *
184
+ * @return Mage_Payment_Model_Abstract
185
+ */
186
+ protected function performManualCapture(Varien_Object $payment, $amount)
187
+ {
188
+ $result = $this->perform(
189
+ Mage::getModel('omise_gateway/Strategies_' . self::STRATEGY_MANUAL_CAPTURE),
190
+ $payment,
191
+ $amount
192
+ );
193
+
194
+ Mage::log('The transaction was performed manual capture by Omise payment gateway and successful.');
195
+ return $result;
196
+ }
197
+
198
+ /**
199
+ * Attempt to accept a payment that us under review
200
+ *
201
+ * @param Mage_Payment_Model_Info $payment
202
+ *
203
+ * @return bool
204
+ *
205
+ * @throws Mage_Core_Exception
206
+ */
207
+ public function acceptPayment(Mage_Payment_Model_Info $payment)
208
+ {
209
+ parent::acceptPayment($payment);
210
+
211
+ return true;
212
+ }
213
+
214
+ /**
215
+ * Attempt to deny a payment that us under review
216
+ *
217
+ * @param Mage_Payment_Model_Info $payment
218
+ *
219
+ * @return bool
220
+ *
221
+ * @throws Mage_Core_Exception
222
+ */
223
+ public function denyPayment(Mage_Payment_Model_Info $payment)
224
+ {
225
+ parent::denyPayment($payment);
226
+
227
+ return true;
228
+ }
229
 
230
  /**
231
  * Assign data to info model instance
232
+ *
233
  * @param mixed $data
234
+ *
235
  * @return Mage_Payment_Model_Info
236
  */
237
  public function assignData($data)
241
  $result = parent::assignData($data);
242
 
243
  if (is_array($data)) {
244
+ if (! isset($data['omise_token'])) {
245
  Mage::throwException(Mage::helper('payment')->__('Need Omise\'s keys'));
246
+ }
247
 
248
  Mage::log('Data that assign is Array');
249
  $this->getInfoInstance()->setAdditionalInformation('omise_token', $data['omise_token']);
250
  } elseif ($data instanceof Varien_Object) {
251
+ if (! $data->getData('omise_token')) {
252
  Mage::throwException(Mage::helper('payment')->__('Need Omise\'s keys'));
253
+ }
254
 
255
  Mage::log('Data that assign is Object');
256
  $this->getInfoInstance()->setAdditionalInformation('omise_token', $data->getData('omise_token'));
258
 
259
  return $result;
260
  }
261
+
262
+ /**
263
+ * {@inheritDoc}
264
+ *
265
+ * @see app/code/core/Mage/Sales/Model/Quote/Payment.php
266
+ */
267
+ public function getOrderPlaceRedirectUrl()
268
+ {
269
+ if ($this->isThreeDSecureNeeded()) {
270
+ return Mage::getSingleton('checkout/session')->getOmiseAuthorizeUri();
271
+ }
272
+
273
+ return '';
274
+ }
275
+
276
+ /**
277
+ * Format a Magento's amount to be a small-unit that Omise's API requires.
278
+ * Note, no specific format for JPY currency.
279
+ *
280
+ * @param string $currency
281
+ * @param integer | float $amount
282
+ *
283
+ * @return integer
284
+ */
285
+ public function formatAmount($currency, $amount)
286
+ {
287
+ switch (strtoupper($currency)) {
288
+ case 'THB':
289
+ case 'IDR':
290
+ case 'SGD':
291
+ // Convert to a small unit
292
+ $amount = $amount * 100;
293
+ break;
294
+ }
295
+
296
+ return $amount;
297
+ }
298
+
299
+ /**
300
+ * @return bool
301
+ */
302
+ public function isThreeDSecureNeeded()
303
+ {
304
+ return Mage::getStoreConfig('payment/omise_gateway/threedsecure') ? true : false;
305
+ }
306
+
307
+ /**
308
+ * @param array $params
309
+ *
310
+ * @return string
311
+ */
312
+ public function getThreeDSecureCallbackUri($params = array())
313
+ {
314
+ return Mage::getUrl(
315
+ 'omise/callback_validatethreedsecure',
316
+ array(
317
+ '_secure' => Mage::app()->getStore()->isCurrentlySecure(),
318
+ '_query' => $params
319
+ )
320
+ );
321
+ }
322
+ }
app/code/community/Omise/Gateway/Model/Resource/Config.php CHANGED
@@ -6,4 +6,4 @@ class Omise_Gateway_Model_Resource_Config extends Mage_Core_Model_Resource_Db_Ab
6
  $this->_init('omise_gateway/omise', 'id');
7
  $this->_isPkAutoIncrement = false;
8
  }
9
- }
6
  $this->_init('omise_gateway/omise', 'id');
7
  $this->_isPkAutoIncrement = false;
8
  }
9
+ }
app/code/community/Omise/Gateway/Model/Strategies/AuthorizeStrategy.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Omise_Gateway_Model_Strategies_AuthorizeStrategy extends Omise_Gateway_Model_Strategies_StrategyAbstract
3
+ {
4
+ /**
5
+ * {@inheritDoc}
6
+ */
7
+ public function perform($payment, $amount)
8
+ {
9
+ $info = $payment->getPaymentInformation();
10
+
11
+ return OmiseCharge::create(array(
12
+ 'amount' => $payment->formatAmount($info->getOrder()->getOrderCurrencyCode(), $amount),
13
+ 'currency' => $info->getOrder()->getOrderCurrencyCode(),
14
+ 'description' => 'Charge a card from Magento that order id is ' . $info->getData('entity_id'),
15
+ 'capture' => false,
16
+ 'card' => $info->getAdditionalInformation('omise_token')
17
+ ));
18
+ }
19
+
20
+ /**
21
+ * Validate a payment process result.
22
+ *
23
+ * @param \OmiseCharge $charge
24
+ *
25
+ * @return boolean
26
+ *
27
+ * @see https://github.com/omise/omise-php/blob/master/lib/omise/OmiseCharge.php
28
+ */
29
+ public function validate($charge)
30
+ {
31
+ if (! isset($charge['object'])) {
32
+ $this->message = 'Cannot retrieve a payment result, please contact our support to confirm the payment.';
33
+ return false;
34
+ }
35
+
36
+ if ($charge['object'] === 'error') {
37
+ $this->message = $charge['message'];
38
+ return false;
39
+ }
40
+
41
+ if (! $charge['authorized']) {
42
+ $this->message = 'Payment authorization failed, ' . $charge['failure_message'] . ' (code: ' . $charge['failure_code'] . ')';
43
+ return false;
44
+ }
45
+
46
+ if ($charge['object'] === 'charge'
47
+ && $charge['status'] === 'pending'
48
+ && $charge['capture'] === false
49
+ && $charge['authorized'] === true) {
50
+ return true;
51
+ }
52
+
53
+ $this->message = 'Error payment result validation, please contact our support to confirm the payment.';
54
+ return false;
55
+ }
56
+ }
app/code/community/Omise/Gateway/Model/Strategies/AuthorizeThreeDSecureStrategy.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Omise_Gateway_Model_Strategies_AuthorizeThreeDSecureStrategy extends Omise_Gateway_Model_Strategies_StrategyAbstract
3
+ {
4
+ /**
5
+ * {@inheritDoc}
6
+ */
7
+ public function perform($payment, $amount)
8
+ {
9
+ $info = $payment->getPaymentInformation();
10
+
11
+ return OmiseCharge::create(array(
12
+ 'amount' => $payment->formatAmount($info->getOrder()->getOrderCurrencyCode(), $amount),
13
+ 'currency' => $info->getOrder()->getOrderCurrencyCode(),
14
+ 'description' => 'Charge a card from Magento that order id is ' . $info->getData('entity_id'),
15
+ 'capture' => false,
16
+ 'card' => $info->getAdditionalInformation('omise_token'),
17
+ 'return_uri' => $payment->getThreeDSecureCallbackUri(array('order_id' => $info->getOrder()->getIncrementId()))
18
+ ));
19
+ }
20
+
21
+ /**
22
+ * Validate a payment process result.
23
+ *
24
+ * @param \OmiseCharge $charge
25
+ *
26
+ * @return boolean
27
+ *
28
+ * @see https://github.com/omise/omise-php/blob/master/lib/omise/OmiseCharge.php
29
+ */
30
+ public function validate($charge)
31
+ {
32
+ if (! isset($charge['object'])) {
33
+ $this->message = 'Cannot retrieve a payment result, please contact our support to confirm the payment.';
34
+ return false;
35
+ }
36
+
37
+ if ($charge['object'] === 'error') {
38
+ $this->message = $charge['message'];
39
+ return false;
40
+ }
41
+
42
+ if ($charge['failure_code'] || $charge['failure_message']) {
43
+ $this->message = 'Payment authorization failed, ' . $charge['failure_message'] . ' (code: ' . $charge['failure_code'] . ')';
44
+ return false;
45
+ }
46
+
47
+ if ($charge['object'] === 'charge'
48
+ && $charge['status'] !== 'failed'
49
+ && $charge['authorize_uri']) {
50
+ return true;
51
+ }
52
+
53
+ $this->message = 'Error payment result validation, please contact our support to confirm the payment.';
54
+ return false;
55
+ }
56
+ }
app/code/community/Omise/Gateway/Model/Strategies/CaptureStrategy.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Omise_Gateway_Model_Strategies_CaptureStrategy extends Omise_Gateway_Model_Strategies_StrategyAbstract
3
+ {
4
+ /**
5
+ * {@inheritDoc}
6
+ */
7
+ public function perform($payment, $amount)
8
+ {
9
+ $info = $payment->getPaymentInformation();
10
+
11
+ return OmiseCharge::create(array(
12
+ 'amount' => $payment->formatAmount($info->getOrder()->getOrderCurrencyCode(), $amount),
13
+ 'currency' => $info->getOrder()->getOrderCurrencyCode(),
14
+ 'description' => 'Charge a card from Magento that order id is ' . $info->getData('entity_id'),
15
+ 'capture' => true,
16
+ 'card' => $info->getAdditionalInformation('omise_token')
17
+ ));
18
+ }
19
+
20
+ /**
21
+ * Validate a payment process result.
22
+ *
23
+ * @param \OmiseCharge $charge
24
+ *
25
+ * @return boolean
26
+ *
27
+ * @see https://github.com/omise/omise-php/blob/master/lib/omise/OmiseCharge.php
28
+ */
29
+ public function validate($charge)
30
+ {
31
+ if (! isset($charge['object'])) {
32
+ $this->message = 'Cannot retrieve a payment result, please contact our support to confirm the payment.';
33
+ return false;
34
+ }
35
+
36
+ if ($charge['object'] === 'error') {
37
+ $this->message = $charge['message'];
38
+ return false;
39
+ }
40
+
41
+ if (! $charge['authorized'] || ! $charge['captured']) {
42
+ $this->message = 'Payment process failed, ' . $charge['failure_message'] . ' (code: ' . $charge['failure_code'] . ')';
43
+ return false;
44
+ }
45
+
46
+ if ($charge['object'] === 'charge'
47
+ && $charge['status'] === 'successful'
48
+ && $charge['authorized'] === true
49
+ && $charge['captured'] === true) {
50
+ return true;
51
+ }
52
+
53
+ $this->message = 'Error payment result validation, please contact our support to confirm the payment.';
54
+ return false;
55
+ }
56
+ }
app/code/community/Omise/Gateway/Model/Strategies/CaptureThreeDSecureStrategy.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Omise_Gateway_Model_Strategies_CaptureThreeDSecureStrategy extends Omise_Gateway_Model_Strategies_StrategyAbstract
3
+ {
4
+ /**
5
+ * {@inheritDoc}
6
+ */
7
+ public function perform($payment, $amount)
8
+ {
9
+ $info = $payment->getPaymentInformation();
10
+
11
+ return OmiseCharge::create(array(
12
+ 'amount' => $payment->formatAmount($info->getOrder()->getOrderCurrencyCode(), $amount),
13
+ 'currency' => $info->getOrder()->getOrderCurrencyCode(),
14
+ 'description' => 'Charge a card from Magento that order id is ' . $info->getData('entity_id'),
15
+ 'capture' => true,
16
+ 'card' => $info->getAdditionalInformation('omise_token'),
17
+ 'return_uri' => $payment->getThreeDSecureCallbackUri(array('order_id' => $info->getOrder()->getIncrementId()))
18
+ ));
19
+ }
20
+
21
+ /**
22
+ * Validate a payment process result.
23
+ *
24
+ * @param \OmiseCharge $charge
25
+ *
26
+ * @return boolean
27
+ *
28
+ * @see https://github.com/omise/omise-php/blob/master/lib/omise/OmiseCharge.php
29
+ */
30
+ public function validate($charge)
31
+ {
32
+ if (! isset($charge['object'])) {
33
+ $this->message = 'Cannot retrieve a payment result, please contact our support to confirm the payment.';
34
+ return false;
35
+ }
36
+
37
+ if ($charge['object'] === 'error') {
38
+ $this->message = $charge['message'];
39
+ return false;
40
+ }
41
+
42
+ if ($charge['failure_code'] || $charge['failure_message']) {
43
+ $this->message = 'Payment process failed, ' . $charge['failure_message'] . ' (code: ' . $charge['failure_code'] . ')';
44
+ return false;
45
+ }
46
+
47
+ if ($charge['object'] === 'charge'
48
+ && $charge['status'] !== 'failed'
49
+ && $charge['authorize_uri']) {
50
+ return true;
51
+ }
52
+
53
+ $this->message = 'Error payment result validation, please contact our support to confirm the payment.';
54
+ return false;
55
+ }
56
+ }
app/code/community/Omise/Gateway/Model/Strategies/ManualCaptureStrategy.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Omise_Gateway_Model_Strategies_ManualCaptureStrategy extends Omise_Gateway_Model_Strategies_StrategyAbstract
3
+ {
4
+ /**
5
+ * {@inheritDoc}
6
+ */
7
+ public function perform($payment, $amount)
8
+ {
9
+ $info = $payment->getPaymentInformation();
10
+ $charge = OmiseCharge::retrieve($info->getAdditionalInformation('omise_charge_id'));
11
+
12
+ return $charge->capture();
13
+ }
14
+
15
+ /**
16
+ * Validate a payment process result.
17
+ *
18
+ * @param \OmiseCharge $charge
19
+ *
20
+ * @return boolean
21
+ *
22
+ * @see https://github.com/omise/omise-php/blob/master/lib/omise/OmiseCharge.php
23
+ */
24
+ public function validate($charge)
25
+ {
26
+ if (! isset($charge['object'])) {
27
+ $this->message = 'Cannot retrieve a payment result, please contact our support to confirm the payment.';
28
+ return false;
29
+ }
30
+
31
+ if ($charge['object'] === 'error') {
32
+ $this->message = $charge['message'];
33
+ return false;
34
+ }
35
+
36
+ if (! $charge['authorized'] || ! $charge['captured']) {
37
+ $this->message = 'Payment process failed, ' . $charge['failure_message'] . ' (code: ' . $charge['failure_code'] . ')';
38
+ return false;
39
+ }
40
+
41
+ if ($charge['object'] === 'charge'
42
+ && $charge['status'] === 'successful'
43
+ && $charge['authorized'] === true
44
+ && $charge['captured'] === true) {
45
+ return true;
46
+ }
47
+
48
+ $this->message = 'Error payment result validation, please contact our support to confirm the payment.';
49
+ return false;
50
+ }
51
+ }
app/code/community/Omise/Gateway/Model/Strategies/OffsiteInternetBankingStrategy.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Omise_Gateway_Model_Strategies_OffsiteInternetBankingStrategy extends Omise_Gateway_Model_Strategies_StrategyAbstract
3
+ {
4
+ /**
5
+ * {@inheritDoc}
6
+ */
7
+ public function perform($payment, $amount)
8
+ {
9
+ $info = $payment->getPaymentInformation();
10
+
11
+ return OmiseCharge::create(array(
12
+ 'amount' => $payment->formatAmount($info->getOrder()->getOrderCurrencyCode(), $amount),
13
+ 'currency' => $info->getOrder()->getOrderCurrencyCode(),
14
+ 'description' => 'Charge a card from Magento that order id is ' . $info->getData('entity_id'),
15
+ 'offsite' => $info->getAdditionalInformation('offsite'),
16
+ 'return_uri' => $payment->getCallbackUri(array('order_id' => $info->getOrder()->getIncrementId()))
17
+ ));
18
+ }
19
+
20
+ /**
21
+ * Validate a payment process result.
22
+ *
23
+ * @param \OmiseCharge $charge
24
+ *
25
+ * @return boolean
26
+ *
27
+ * @see https://github.com/omise/omise-php/blob/master/lib/omise/OmiseCharge.php
28
+ */
29
+ public function validate($charge)
30
+ {
31
+ if (! isset($charge['object'])) {
32
+ $this->message = 'Cannot retrieve a payment result, please contact our support to confirm the payment.';
33
+ return false;
34
+ }
35
+
36
+ if ($charge['object'] === 'error') {
37
+ $this->message = $charge['message'];
38
+ return false;
39
+ }
40
+
41
+ if ($charge['failure_code'] || $charge['failure_message']) {
42
+ $this->message = 'Payment process failed, ' . $charge['failure_message'] . ' (code: ' . $charge['failure_code'] . ')';
43
+ return false;
44
+ }
45
+
46
+ if ($charge['object'] === 'charge'
47
+ && $charge['status'] !== 'failed'
48
+ && $charge['authorize_uri']) {
49
+ return true;
50
+ }
51
+
52
+ $this->message = 'Error payment result validation, please contact our support to confirm the payment.';
53
+ return false;
54
+ }
55
+ }
app/code/community/Omise/Gateway/Model/Strategies/StrategyAbstract.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ abstract class Omise_Gateway_Model_Strategies_StrategyAbstract implements
3
+ Omise_Gateway_Model_Strategies_StrategyInterface
4
+ {
5
+ /**
6
+ * @var string
7
+ */
8
+ protected $message;
9
+
10
+ /**
11
+ * {@inheritDoc}
12
+ */
13
+ abstract public function perform($payment, $amount);
14
+
15
+ /**
16
+ * {@inheritDoc}
17
+ */
18
+ abstract public function validate($data);
19
+
20
+ /**
21
+ * @return string
22
+ */
23
+ public function getMessage()
24
+ {
25
+ return $this->message;
26
+ }
27
+ }
app/code/community/Omise/Gateway/Model/Strategies/StrategyInterface.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ interface Omise_Gateway_Model_Strategies_StrategyInterface
3
+ {
4
+ /**
5
+ * Perform a payment action.
6
+ * i.e. authorize a payment, capture a charge, etc.
7
+ *
8
+ * @param object $payment
9
+ * @param int|float $amount
10
+ *
11
+ * @return mixed
12
+ */
13
+ public function perform($payment, $amount);
14
+
15
+ /**
16
+ * Validate a payment process result.
17
+ *
18
+ * @param mixed $data
19
+ *
20
+ * @return boolean
21
+ */
22
+ public function validate($data);
23
+ }
app/code/community/Omise/Gateway/controllers/Adminhtml/OmiseController.php CHANGED
@@ -3,6 +3,7 @@ class Omise_Gateway_Adminhtml_OmiseController extends Mage_Adminhtml_Controller_
3
  {
4
  /**
5
  * Init page.
 
6
  * @return self
7
  */
8
  protected function _initAction()
@@ -16,6 +17,7 @@ class Omise_Gateway_Adminhtml_OmiseController extends Mage_Adminhtml_Controller_
16
 
17
  /**
18
  * Index page
 
19
  * @return void
20
  */
21
  public function indexAction()
@@ -26,18 +28,21 @@ class Omise_Gateway_Adminhtml_OmiseController extends Mage_Adminhtml_Controller_
26
  try {
27
  // Retrieve Omise Account.
28
  $omise_account = Mage::getModel('omise_gateway/omiseAccount')->retrieveOmiseAccount();
29
- if (isset($omise_account['error']))
30
  throw new Exception('Omise Account:: '.$omise_account['error'], 1);
 
31
 
32
  // Retrieve Omise Balance.
33
  $omise_balance = Mage::getModel('omise_gateway/omiseBalance')->retrieveOmiseBalance();
34
- if (isset($omise_balance['error']))
35
  throw new Exception('Omise Balance:: '.$omise_balance['error'], 1);
 
36
 
37
  // Retrieve Omise Transfer List.
38
  $omise_transfer = Mage::getModel('omise_gateway/omiseTransfer')->retrieveOmiseTransfer();
39
- if (isset($omise_transfer['error']))
40
  throw new Exception('Omise Transfer:: '.$omise_transfer['error'], 1);
 
41
 
42
  $data['omise'] = array(
43
  'email' => $omise_account['email'],
@@ -73,6 +78,7 @@ class Omise_Gateway_Adminhtml_OmiseController extends Mage_Adminhtml_Controller_
73
 
74
  /**
75
  * Config page
 
76
  * @return void
77
  */
78
  public function configAction()
@@ -83,8 +89,9 @@ class Omise_Gateway_Adminhtml_OmiseController extends Mage_Adminhtml_Controller_
83
  // process a submit form if it was submitted.
84
  if ($post = $this->getRequest()->getPost('configData')) {
85
  try {
86
- if (!isset($post['test_mode']))
87
  $post['test_mode'] = 0;
 
88
 
89
  $config->addData($post);
90
  $config->save();
@@ -100,7 +107,6 @@ class Omise_Gateway_Adminhtml_OmiseController extends Mage_Adminhtml_Controller_
100
  // Make the current value object available to blocks.
101
  Mage::register('current_value', $config);
102
 
103
-
104
  $edit_block = $this->getLayout()
105
  ->createBlock('omise_gateway_adminhtml/config_edit');
106
 
@@ -112,26 +118,29 @@ class Omise_Gateway_Adminhtml_OmiseController extends Mage_Adminhtml_Controller_
112
 
113
  /**
114
  * Transfers
 
115
  * @return void
116
  */
117
  public function transfersAction()
118
  {
119
- if (!Mage::app()->getRequest()->isPost() || (!$post = Mage::app()->getRequest()->getPost('OmiseTransfer'))) {
120
  Mage::getSingleton('core/session')->addError('Omise Transfer:: Required amount');
121
  } else {
122
  try {
123
  if (isset($post['action']) && $post['action'] == 'delete') {
124
  // Delete action
125
  $response = Mage::getModel('omise_gateway/omiseTransfer')->deleteOmiseTransfer(Mage::app()->getRequest()->getParam('delete'));
126
- if (isset($response['error']))
127
  throw new Exception($response['error'], 1);
 
128
 
129
  $success = "Deleted";
130
  } else {
131
  // Create action
132
  $response = Mage::getModel('omise_gateway/omiseTransfer')->createOmiseTransfer($post);
133
- if (isset($response['error']))
134
  throw new Exception($response['error'], 1);
 
135
 
136
  $success = "Transferred";
137
  }
@@ -144,4 +153,4 @@ class Omise_Gateway_Adminhtml_OmiseController extends Mage_Adminhtml_Controller_
144
 
145
  return $this->_redirect('adminhtml/omise/index', array());
146
  }
147
- }
3
  {
4
  /**
5
  * Init page.
6
+ *
7
  * @return self
8
  */
9
  protected function _initAction()
17
 
18
  /**
19
  * Index page
20
+ *
21
  * @return void
22
  */
23
  public function indexAction()
28
  try {
29
  // Retrieve Omise Account.
30
  $omise_account = Mage::getModel('omise_gateway/omiseAccount')->retrieveOmiseAccount();
31
+ if (isset($omise_account['error'])) {
32
  throw new Exception('Omise Account:: '.$omise_account['error'], 1);
33
+ }
34
 
35
  // Retrieve Omise Balance.
36
  $omise_balance = Mage::getModel('omise_gateway/omiseBalance')->retrieveOmiseBalance();
37
+ if (isset($omise_balance['error'])) {
38
  throw new Exception('Omise Balance:: '.$omise_balance['error'], 1);
39
+ }
40
 
41
  // Retrieve Omise Transfer List.
42
  $omise_transfer = Mage::getModel('omise_gateway/omiseTransfer')->retrieveOmiseTransfer();
43
+ if (isset($omise_transfer['error'])) {
44
  throw new Exception('Omise Transfer:: '.$omise_transfer['error'], 1);
45
+ }
46
 
47
  $data['omise'] = array(
48
  'email' => $omise_account['email'],
78
 
79
  /**
80
  * Config page
81
+ *
82
  * @return void
83
  */
84
  public function configAction()
89
  // process a submit form if it was submitted.
90
  if ($post = $this->getRequest()->getPost('configData')) {
91
  try {
92
+ if (! isset($post['test_mode'])) {
93
  $post['test_mode'] = 0;
94
+ }
95
 
96
  $config->addData($post);
97
  $config->save();
107
  // Make the current value object available to blocks.
108
  Mage::register('current_value', $config);
109
 
 
110
  $edit_block = $this->getLayout()
111
  ->createBlock('omise_gateway_adminhtml/config_edit');
112
 
118
 
119
  /**
120
  * Transfers
121
+ *
122
  * @return void
123
  */
124
  public function transfersAction()
125
  {
126
+ if (! Mage::app()->getRequest()->isPost() || (! $post = Mage::app()->getRequest()->getPost('OmiseTransfer'))) {
127
  Mage::getSingleton('core/session')->addError('Omise Transfer:: Required amount');
128
  } else {
129
  try {
130
  if (isset($post['action']) && $post['action'] == 'delete') {
131
  // Delete action
132
  $response = Mage::getModel('omise_gateway/omiseTransfer')->deleteOmiseTransfer(Mage::app()->getRequest()->getParam('delete'));
133
+ if (isset($response['error'])) {
134
  throw new Exception($response['error'], 1);
135
+ }
136
 
137
  $success = "Deleted";
138
  } else {
139
  // Create action
140
  $response = Mage::getModel('omise_gateway/omiseTransfer')->createOmiseTransfer($post);
141
+ if (isset($response['error'])) {
142
  throw new Exception($response['error'], 1);
143
+ }
144
 
145
  $success = "Transferred";
146
  }
153
 
154
  return $this->_redirect('adminhtml/omise/index', array());
155
  }
156
+ }
app/code/community/Omise/Gateway/controllers/Callback/ValidateOffsiteInternetBankingController.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Omise_Gateway_Callback_ValidateOffsiteInternetBankingController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ $omise = Mage::getModel('omise_gateway/omise');
7
+ $omise->initNecessaryConstant();
8
+
9
+ // Callback validation.
10
+ $order = $this->getOrder();
11
+
12
+ if (! $payment = $order->getPayment()) {
13
+ Mage::getSingleton('core/session')->addError(
14
+ $this->__('Internet banking validation was invalid, cannot retrieve your payment information. Please contact our support to confirm the payment.')
15
+ );
16
+ $this->_redirect('checkout/cart');
17
+ return;
18
+ }
19
+
20
+ try {
21
+ $charge_id = $payment->getMethodInstance()->getInfoInstance()->getAdditionalInformation('omise_charge_id');
22
+ $charge = OmiseCharge::retrieve($charge_id);
23
+
24
+ if (! $this->validate($charge)) {
25
+ return $this->considerFail(
26
+ $order,
27
+ $this->__('The payment was invalid, ' . $charge['failure_message'] . ' (' . $charge['failure_code'] . ').')
28
+ );
29
+ }
30
+
31
+ $payment->accept();
32
+ $order->save();
33
+ return $this->_redirect('checkout/onepage/success');
34
+ } catch (Exception $e) {
35
+ return $this->considerFail(
36
+ $order,
37
+ $this->__($e->getMessage())
38
+ );
39
+ }
40
+ }
41
+
42
+ /**
43
+ * @return \Mage_Sales_Model_Order
44
+ */
45
+ protected function getOrder()
46
+ {
47
+ $order_increment_id = $this->getRequest()->getParam('order_id');
48
+
49
+ if ($order_increment_id) {
50
+ return Mage::getModel('sales/order')->loadByIncrementId($order_increment_id);
51
+ }
52
+
53
+ return Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
54
+ }
55
+
56
+ /**
57
+ * @param \Mage_Sales_Model_Order $order
58
+ * @param string $message
59
+ *
60
+ * @return self
61
+ */
62
+ protected function considerFail($order, $message)
63
+ {
64
+ $order->getPayment()
65
+ ->setPreparedMessage($message)
66
+ ->deny();
67
+ $order->save();
68
+
69
+ Mage::getSingleton('core/session')->addError($message);
70
+ return $this->_redirect('checkout/cart');
71
+ }
72
+
73
+ /**
74
+ * @param \OmiseCharge $charge
75
+ *
76
+ * @return bool
77
+ */
78
+ protected function validate($charge)
79
+ {
80
+ // check for auto capture.
81
+ if ($charge['status'] === 'successful' && $charge['authorized'] && $charge['captured']) {
82
+ return true;
83
+ }
84
+
85
+ return false;
86
+ }
87
+ }
app/code/community/Omise/Gateway/controllers/Callback/ValidateThreeDSecureController.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Omise_Gateway_Callback_ValidateThreeDSecureController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ $omise = Mage::getModel('omise_gateway/omise');
7
+ $omise->initNecessaryConstant();
8
+
9
+ // Callback validation.
10
+ $order = $this->getOrder();
11
+
12
+ if (! $payment = $order->getPayment()) {
13
+ Mage::getSingleton('core/session')->addError(
14
+ $this->__('3-D Secure validation was invalid, cannot retrieve your payment information. Please contact our support to confirm the payment.')
15
+ );
16
+ $this->_redirect('checkout/cart');
17
+ return;
18
+ }
19
+
20
+ try {
21
+ $charge_id = $payment->getMethodInstance()->getInfoInstance()->getAdditionalInformation('omise_charge_id');
22
+ $charge = OmiseCharge::retrieve($charge_id);
23
+
24
+ if (! $this->validate($charge)) {
25
+ return $this->considerFail(
26
+ $order,
27
+ $this->__('The payment was invalid, ' . $charge['failure_message'] . ' (' . $charge['failure_code'] . ').')
28
+ );
29
+ }
30
+
31
+ $payment->accept();
32
+ $order->save();
33
+ return $this->_redirect('checkout/onepage/success');
34
+ } catch (Exception $e) {
35
+ return $this->considerFail(
36
+ $order,
37
+ $this->__($e->getMessage())
38
+ );
39
+ }
40
+ }
41
+
42
+ /**
43
+ * @return \Mage_Sales_Model_Order
44
+ */
45
+ protected function getOrder()
46
+ {
47
+ $order_increment_id = $this->getRequest()->getParam('order_id');
48
+
49
+ if ($order_increment_id) {
50
+ return Mage::getModel('sales/order')->loadByIncrementId($order_increment_id);
51
+ }
52
+
53
+ return Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
54
+ }
55
+
56
+ /**
57
+ * @param \Mage_Sales_Model_Order $order
58
+ * @param string $message
59
+ *
60
+ * @return self
61
+ */
62
+ protected function considerFail($order, $message)
63
+ {
64
+ $order->getPayment()
65
+ ->setPreparedMessage($message)
66
+ ->deny();
67
+ $order->save();
68
+
69
+ Mage::getSingleton('core/session')->addError($message);
70
+ return $this->_redirect('checkout/cart');
71
+ }
72
+
73
+ /**
74
+ * @param \OmiseCharge $charge
75
+ *
76
+ * @return bool
77
+ */
78
+ protected function validate($charge)
79
+ {
80
+ // check for auto capture.
81
+ if ($charge['capture'] && $charge['status'] === 'successful' && $charge['authorized'] && $charge['captured']) {
82
+ return true;
83
+ }
84
+
85
+ // Check for authorize only.
86
+ if (! $charge['capture'] && $charge['status'] === 'pending' && $charge['authorized']) {
87
+ return true;
88
+ }
89
+
90
+ return false;
91
+ }
92
+ }
app/code/community/Omise/Gateway/data/omise_gateway_setup/data-install-0.0.0.1.php CHANGED
@@ -14,4 +14,4 @@ foreach ($dataRows as $row) {
14
  $model->setData($row)
15
  ->setOrigData()
16
  ->save();
17
- }
14
  $model->setData($row)
15
  ->setOrigData()
16
  ->save();
17
+ }
app/code/community/Omise/Gateway/etc/config.xml CHANGED
@@ -14,7 +14,7 @@
14
  -->
15
  <modules>
16
  <Omise_Gateway>
17
- <version>1.9.0.6</version>
18
  </Omise_Gateway>
19
  </modules>
20
 
@@ -82,6 +82,18 @@
82
  </routers>
83
  </admin>
84
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  <!--
86
  /**
87
  * Payment Method configuration for front-end
@@ -97,6 +109,13 @@
97
  <cctypes>VI,MC</cctypes>
98
  <title>Credit Card (Powered by Omise)</title>
99
  </omise_gateway>
 
 
 
 
 
 
 
100
  </payment>
101
  </default>
102
  </config>
14
  -->
15
  <modules>
16
  <Omise_Gateway>
17
+ <version>1.8.0.0</version>
18
  </Omise_Gateway>
19
  </modules>
20
 
82
  </routers>
83
  </admin>
84
 
85
+ <frontend>
86
+ <routers>
87
+ <omise_gateway>
88
+ <use>standard</use>
89
+ <args>
90
+ <module>Omise_Gateway</module>
91
+ <frontName>omise</frontName>
92
+ </args>
93
+ </omise_gateway>
94
+ </routers>
95
+ </frontend>
96
+
97
  <!--
98
  /**
99
  * Payment Method configuration for front-end
109
  <cctypes>VI,MC</cctypes>
110
  <title>Credit Card (Powered by Omise)</title>
111
  </omise_gateway>
112
+
113
+ <omise_offsite_internet_banking>
114
+ <active>0</active>
115
+ <payment_action>authorize_capture</payment_action>
116
+ <model>omise_gateway/OffsiteInternetBankingPayment</model>
117
+ <title>Internet Banking</title>
118
+ </omise_offsite_internet_banking>
119
  </payment>
120
  </default>
121
  </config>
app/code/community/Omise/Gateway/etc/system.xml CHANGED
@@ -3,54 +3,96 @@
3
  <sections>
4
  <payment>
5
  <groups>
6
- <omise_gateway translate="label" module="payment">
7
  <label>Omise Payment Gateway</label>
8
  <sort_order>670</sort_order>
9
  <show_in_default>1</show_in_default>
10
  <show_in_website>1</show_in_website>
11
  <show_in_store>0</show_in_store>
 
12
  <fields>
13
- <active translate="label">
14
- <label>Module Enabled</label>
15
- <frontend_type>select</frontend_type>
16
- <source_model>adminhtml/system_config_source_yesno</source_model>
17
- <sort_order>1</sort_order>
18
  <show_in_default>1</show_in_default>
19
  <show_in_website>1</show_in_website>
20
  <show_in_store>0</show_in_store>
21
- </active>
 
 
 
 
 
 
 
 
 
 
22
 
23
- <payment_action translate="label">
24
- <label>Payment Action</label>
25
- <frontend_type>select</frontend_type>
26
- <source_model>omise_gateway/config_var_paymentaction</source_model>
27
- <sort_order>2</sort_order>
28
- <show_in_default>1</show_in_default>
29
- <show_in_website>1</show_in_website>
30
- <show_in_store>0</show_in_store>
31
- </payment_action>
32
 
33
- <currency translate="label">
34
- <label>Currency</label>
35
- <frontend_type>select</frontend_type>
36
- <source_model>omise_gateway/config_var_currency</source_model>
37
- <sort_order>3</sort_order>
38
- <show_in_default>1</show_in_default>
39
- <show_in_website>1</show_in_website>
40
- <show_in_store>0</show_in_store>
41
- </currency>
42
-
43
- <order_status translate="label">
44
- <label>New order status</label>
45
- <frontend_type>select</frontend_type>
46
- <source_model>adminhtml/system_config_source_order_status_newprocessing</source_model>
47
- <sort_order>4</sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  <show_in_default>1</show_in_default>
49
  <show_in_website>1</show_in_website>
50
  <show_in_store>0</show_in_store>
51
- </order_status>
 
 
 
 
 
 
 
 
 
 
 
 
52
  </fields>
53
- </omise_gateway>
54
  </groups>
55
  </payment>
56
  </sections>
3
  <sections>
4
  <payment>
5
  <groups>
6
+ <omise_payment translate="label" module="payment">
7
  <label>Omise Payment Gateway</label>
8
  <sort_order>670</sort_order>
9
  <show_in_default>1</show_in_default>
10
  <show_in_website>1</show_in_website>
11
  <show_in_store>0</show_in_store>
12
+ <frontend_class>complex</frontend_class>
13
  <fields>
14
+ <omise_gateway type="group">
15
+ <label>Credit Card</label>
16
+ <comment>Powerful payment features that allows you to easily and securely accept credit/debit card payments on your store.</comment>
17
+ <sort_order>680</sort_order>
 
18
  <show_in_default>1</show_in_default>
19
  <show_in_website>1</show_in_website>
20
  <show_in_store>0</show_in_store>
21
+ <frontend_model>omise_gateway/adminhtml_system_config_fieldset_payment</frontend_model>
22
+ <fields>
23
+ <active translate="label">
24
+ <label>Enabled</label>
25
+ <frontend_type>select</frontend_type>
26
+ <source_model>adminhtml/system_config_source_yesno</source_model>
27
+ <sort_order>1</sort_order>
28
+ <show_in_default>1</show_in_default>
29
+ <show_in_website>1</show_in_website>
30
+ <show_in_store>0</show_in_store>
31
+ </active>
32
 
33
+ <payment_action translate="label">
34
+ <label>Payment Action</label>
35
+ <frontend_type>select</frontend_type>
36
+ <source_model>omise_gateway/config_var_paymentaction</source_model>
37
+ <sort_order>2</sort_order>
38
+ <show_in_default>1</show_in_default>
39
+ <show_in_website>1</show_in_website>
40
+ <show_in_store>0</show_in_store>
41
+ </payment_action>
42
 
43
+ <advance_settings translate="label">
44
+ <label>Advance Settings</label>
45
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
46
+ <sort_order>3</sort_order>
47
+ <show_in_default>1</show_in_default>
48
+ <show_in_website>1</show_in_website>
49
+ <show_in_store>0</show_in_store>
50
+ </advance_settings>
51
+
52
+ <threedsecure translate="label">
53
+ <label>3-D Secure support</label>
54
+ <frontend_type>select</frontend_type>
55
+ <source_model>adminhtml/system_config_source_yesno</source_model>
56
+ <sort_order>4</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>0</show_in_store>
60
+ </threedsecure>
61
+
62
+ <order_status translate="label">
63
+ <label>New order status</label>
64
+ <frontend_type>select</frontend_type>
65
+ <source_model>adminhtml/system_config_source_order_status_newprocessing</source_model>
66
+ <sort_order>5</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>0</show_in_store>
70
+ </order_status>
71
+ </fields>
72
+ </omise_gateway>
73
+
74
+ <omise_offsite_internet_banking type="group">
75
+ <label>Internet Banking</label>
76
+ <comment>Enables customers of a bank to easily conduct financial transactions through a bank-operated website (only available in Thailand).</comment>
77
+ <sort_order>690</sort_order>
78
  <show_in_default>1</show_in_default>
79
  <show_in_website>1</show_in_website>
80
  <show_in_store>0</show_in_store>
81
+ <frontend_model>omise_gateway/adminhtml_system_config_fieldset_payment</frontend_model>
82
+ <fields>
83
+ <active translate="label">
84
+ <label>Enabled</label>
85
+ <frontend_type>select</frontend_type>
86
+ <source_model>adminhtml/system_config_source_yesno</source_model>
87
+ <sort_order>1</sort_order>
88
+ <show_in_default>1</show_in_default>
89
+ <show_in_website>1</show_in_website>
90
+ <show_in_store>0</show_in_store>
91
+ </active>
92
+ </fields>
93
+ </omise_offsite_internet_banking>
94
  </fields>
95
+ </omise_payment>
96
  </groups>
97
  </payment>
98
  </sections>
app/code/community/Omise/Gateway/sql/omise_gateway_setup/install-0.0.0.1.php CHANGED
@@ -20,4 +20,4 @@ $table->setOption('charset', 'utf8');
20
 
21
  $this->getConnection()->createTable($table);
22
 
23
- $this->endSetup();
20
 
21
  $this->getConnection()->createTable($table);
22
 
23
+ $this->endSetup();
app/design/adminhtml/default/default/template/omise/dashboard.phtml CHANGED
@@ -42,8 +42,8 @@ $data = $this->getData(); ?>
42
 
43
  <!-- Balance -->
44
  <div class="omise-balance omise-clearfix">
45
- <div class="left"><span class="omise-number"><?php echo number_format(($data['omise']['total']/100), 2); ?></span><br/>Total Balance</div>
46
- <div class="right"><span class="omise-number"><?php echo number_format(($data['omise']['available']/100), 2); ?></span><br/>Transferable Balance</div>
47
  </div>
48
  </div>
49
  </div>
@@ -71,7 +71,7 @@ $data = $this->getData(); ?>
71
  <?php if (!empty($data['omise']['transfer']['data'])):
72
  foreach ($data['omise']['transfer']['data'] as $key => $value): $date = new \DateTime($value['created']); ?>
73
  <tr class="<?php echo $key%2 == 0 ? 'even' : ''; ?> pointer">
74
- <td><?php echo number_format(($value['amount']/100), 2); ?></td>
75
  <td><?php echo $value['id']; ?></td>
76
  <td><?php echo $value['sent'] ? 'Yes' : '<strong class="error-label">No</strong>'; ?></td>
77
  <td><?php echo $value['paid'] ? 'Yes' : '<strong class="error-label">No</strong>'; ?></td>
@@ -89,14 +89,8 @@ $data = $this->getData(); ?>
89
 
90
  <!-- Create transfer form -->
91
  <tr class="even pointer">
92
- <?php if ($data['omise']['available'] > 3000): ?>
93
- <td class="a-right" colspan="6"><input class="transfer-amount input-text no-changes" min="0" type="number" name="OmiseTransfer[amount]" placeholder="Transfer amount (number only, icluding 'satang')"></td>
94
- <td class="a-center last"><button class="button btn-transfer">CREATE TRANSFER</button></td>
95
- <?php elseif ($data['omise']['available'] > 0): ?>
96
- <td class="a-right" colspan="7">Minimum withdrawal is 30 Baht</td>
97
- <?php else: ?>
98
- <td class="a-right" colspan="7">&nbsp;</td>
99
- <?php endif; ?>
100
  </tr>
101
  </tbody>
102
  </table>
@@ -124,4 +118,4 @@ $data = $this->getData(); ?>
124
  }
125
  });
126
  });
127
- </script>
42
 
43
  <!-- Balance -->
44
  <div class="omise-balance omise-clearfix">
45
+ <div class="left"><span class="omise-number"><?php echo Mage::helper('omise_gateway')->formatPrice($data['omise']['currency'], $data['omise']['total']); ?></span><br/>Total Balance</div>
46
+ <div class="right"><span class="omise-number"><?php echo Mage::helper('omise_gateway')->formatPrice($data['omise']['currency'], $data['omise']['available']); ?></span><br/>Transferable Balance</div>
47
  </div>
48
  </div>
49
  </div>
71
  <?php if (!empty($data['omise']['transfer']['data'])):
72
  foreach ($data['omise']['transfer']['data'] as $key => $value): $date = new \DateTime($value['created']); ?>
73
  <tr class="<?php echo $key%2 == 0 ? 'even' : ''; ?> pointer">
74
+ <td><?php echo Mage::helper('omise_gateway')->formatPrice($data['omise']['currency'], $value['amount']); ?></td>
75
  <td><?php echo $value['id']; ?></td>
76
  <td><?php echo $value['sent'] ? 'Yes' : '<strong class="error-label">No</strong>'; ?></td>
77
  <td><?php echo $value['paid'] ? 'Yes' : '<strong class="error-label">No</strong>'; ?></td>
89
 
90
  <!-- Create transfer form -->
91
  <tr class="even pointer">
92
+ <td class="a-right" colspan="6"><input class="transfer-amount input-text no-changes" min="0" type="number" name="OmiseTransfer[amount]" placeholder="<?php echo Mage::helper('omise_gateway')->formatPrice($data['omise']['currency'], $data['omise']['available']); ?>"></td>
93
+ <td class="a-center last"><button class="button btn-transfer">CREATE TRANSFER</button></td>
 
 
 
 
 
 
94
  </tr>
95
  </tbody>
96
  </table>
118
  }
119
  });
120
  });
121
+ </script>
app/design/frontend/base/default/template/payment/form/omise-inapplicable-method.phtml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $code = $this->getMethodCode();
3
+ ?>
4
+
5
+ <ul id="payment_form_<?php echo $code; ?>" class="form-list">
6
+ <li>
7
+ <div class="validation-advice">
8
+ Checkout with Credit Card (Powered by Omise) is not support for the current currency.
9
+ </div>
10
+ </li>
11
+ </ul>
app/design/frontend/base/default/template/payment/form/omiseoffsiteinternetbankingpayment.phtml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $code = $this->getMethodCode();
3
+ ?>
4
+
5
+ <link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('omise/css/offsiteinternetbankingpayment.css'); ?>" />
6
+
7
+ <ul id="payment_form_<?php echo $code; ?>" class="form-list" style="display:none;">
8
+ <!-- SCB -->
9
+ <li class="item">
10
+ <input id="internet_banking_scb" type="radio" name="payment[offsite]" value="internet_banking_scb" />
11
+ <label for="internet_banking_scb">
12
+ <div class="omise-logo-wrapper scb">
13
+ <img class="scb" />
14
+ </div>
15
+ <div class="omise-banking-text-wrapper">
16
+ <span class="title">Siam Commercial Bank</span><br/>
17
+ <span class="rate secondary-text">Fee: 15 THB (same zone), 30 THB (out zone)</span>
18
+ </div>
19
+ </label>
20
+ </li>
21
+
22
+ <!-- KTB -->
23
+ <li class="item">
24
+ <input id="internet_banking_ktb" type="radio" name="payment[offsite]" value="internet_banking_ktb" />
25
+ <label for="internet_banking_ktb">
26
+ <div class="omise-logo-wrapper ktb">
27
+ <img class="ktb" />
28
+ </div>
29
+ <div class="omise-banking-text-wrapper">
30
+ <span class="title">Krungthai Bank</span><br/>
31
+ <span class="rate secondary-text">Fee: 15 THB (same zone), 15 THB (out zone)</span>
32
+ </div>
33
+ </label>
34
+ </li>
35
+
36
+ <!-- BAY -->
37
+ <li class="item">
38
+ <input id="internet_banking_bay" type="radio" name="payment[offsite]" value="internet_banking_bay" />
39
+ <label for="internet_banking_bay">
40
+ <div class="omise-logo-wrapper bay">
41
+ <img class="bay" />
42
+ </div>
43
+ <div class="omise-banking-text-wrapper">
44
+ <span class="title">Krungsri Bank</span><br/>
45
+ <span class="rate secondary-text">Fee: 15 THB (same zone), 15 THB (out zone)</span>
46
+ </div>
47
+ </label>
48
+ </li>
49
+
50
+ <!-- BBL -->
51
+ <li class="item">
52
+ <input id="internet_banking_bbl" type="radio" name="payment[offsite]" value="internet_banking_bbl" />
53
+ <label for="internet_banking_bbl">
54
+ <div class="omise-logo-wrapper bbl">
55
+ <img class="bbl" />
56
+ </div>
57
+ <div class="omise-banking-text-wrapper">
58
+ <span class="title">Bangkok Bank</span><br/>
59
+ <span class="rate secondary-text">Fee: 10 THB (same zone), 20 THB (out zone)</span>
60
+ </div>
61
+ </label>
62
+ </li>
63
+ </ul>
lib/omise-php/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
  # Change Log
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ## [2.4.0] 2015-11-13
4
  - [Added] Add Omise-Version header to request.
5
  - [Added] Add `OMISE_USER_AGENT_SUFFIX` constant that let's people add the suffix into the `user-agent` string.
1
  # Change Log
2
 
3
+ ## [2.6.0] 2016-12-15
4
+ - [added] OmiseLink api is now available. (@turboza)
5
+ - [added] OmiseRecipient object be able to reload resource itself (@guzzilar)
6
+ - [added] OmiseEvent api is now available. (@guzzilar)
7
+ - [updated] phpunit configuration file. (@oaattia)
8
+ - [updated] Revised code style to match with PSR-2 (http://www.php-fig.org/psr/psr-2) spec. (@guzzilar)
9
+ - [fixed] Autoload OmiseDispute class in lib/Omise.php file (@guzzilar)
10
+
11
+ For more information, please visit https://github.com/omise/omise-php/releases/tag/v2.6.0
12
+
13
+ ## [2.5.0] 2016-07-01
14
+ - [Added] Add charge reverse method (@zentetsukenz)
15
+ - [Fixed] Change condition when matching phpunit from using fixed string to regex (@zentetsukenz)
16
+
17
+ ## [2.4.1] 2015-12-03
18
+ - [Added] Add fetching options to customer cards (bde7986)
19
+
20
  ## [2.4.0] 2015-11-13
21
  - [Added] Add Omise-Version header to request.
22
  - [Added] Add `OMISE_USER_AGENT_SUFFIX` constant that let's people add the suffix into the `user-agent` string.
lib/omise-php/README.md CHANGED
@@ -1,5 +1,7 @@
1
  # Omise PHP Client
2
 
 
 
3
  `omise-php` is Omise API library written in PHP.
4
 
5
  ## Requirements
1
  # Omise PHP Client
2
 
3
+ [![Join the chat at https://gitter.im/omise/omise-php](https://badges.gitter.im/omise/omise-php.svg)](https://gitter.im/omise/omise-php?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
+
5
  `omise-php` is Omise API library written in PHP.
6
 
7
  ## Requirements
lib/omise-php/lib/Omise.php CHANGED
@@ -4,6 +4,8 @@ require_once dirname(__FILE__).'/omise/OmiseAccount.php';
4
  require_once dirname(__FILE__).'/omise/OmiseBalance.php';
5
  require_once dirname(__FILE__).'/omise/OmiseCard.php';
6
  require_once dirname(__FILE__).'/omise/OmiseCardList.php';
 
 
7
  require_once dirname(__FILE__).'/omise/OmiseToken.php';
8
  require_once dirname(__FILE__).'/omise/OmiseCharge.php';
9
  require_once dirname(__FILE__).'/omise/OmiseCustomer.php';
@@ -12,3 +14,4 @@ require_once dirname(__FILE__).'/omise/OmiseRefundList.php';
12
  require_once dirname(__FILE__).'/omise/OmiseTransfer.php';
13
  require_once dirname(__FILE__).'/omise/OmiseTransaction.php';
14
  require_once dirname(__FILE__).'/omise/OmiseRecipient.php';
 
4
  require_once dirname(__FILE__).'/omise/OmiseBalance.php';
5
  require_once dirname(__FILE__).'/omise/OmiseCard.php';
6
  require_once dirname(__FILE__).'/omise/OmiseCardList.php';
7
+ require_once dirname(__FILE__).'/omise/OmiseDispute.php';
8
+ require_once dirname(__FILE__).'/omise/OmiseEvent.php';
9
  require_once dirname(__FILE__).'/omise/OmiseToken.php';
10
  require_once dirname(__FILE__).'/omise/OmiseCharge.php';
11
  require_once dirname(__FILE__).'/omise/OmiseCustomer.php';
14
  require_once dirname(__FILE__).'/omise/OmiseTransfer.php';
15
  require_once dirname(__FILE__).'/omise/OmiseTransaction.php';
16
  require_once dirname(__FILE__).'/omise/OmiseRecipient.php';
17
+ require_once dirname(__FILE__).'/omise/OmiseLink.php';
lib/omise-php/lib/omise/OmiseAccount.php CHANGED
@@ -2,33 +2,40 @@
2
 
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
 
5
- class OmiseAccount extends OmiseApiResource {
6
- const ENDPOINT = 'account';
 
7
 
8
- /**
9
- * Retrieves an account.
10
- * @param string $publickey
11
- * @param string $secretkey
12
- * @return OmiseAccount
13
- */
14
- public static function retrieve($publickey = null, $secretkey = null) {
15
- return parent::g_retrieve(get_class(), self::getUrl(), $publickey, $secretkey);
16
- }
 
 
 
17
 
18
- /**
19
- * (non-PHPdoc)
20
- * @see OmiseApiResource::g_reload()
21
- */
22
- public function reload() {
23
- parent::g_reload(self::getUrl());
24
- }
 
 
25
 
26
- /**
27
- *
28
- * @param string $id
29
- * @return string
30
- */
31
- private static function getUrl($id = '') {
32
- return OMISE_API_URL.self::ENDPOINT.'/'.$id;
33
- }
 
34
  }
2
 
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
 
5
+ class OmiseAccount extends OmiseApiResource
6
+ {
7
+ const ENDPOINT = 'account';
8
 
9
+ /**
10
+ * Retrieves an account.
11
+ *
12
+ * @param string $publickey
13
+ * @param string $secretkey
14
+ *
15
+ * @return OmiseAccount
16
+ */
17
+ public static function retrieve($publickey = null, $secretkey = null)
18
+ {
19
+ return parent::g_retrieve(get_class(), self::getUrl(), $publickey, $secretkey);
20
+ }
21
 
22
+ /**
23
+ * (non-PHPdoc)
24
+ *
25
+ * @see OmiseApiResource::g_reload()
26
+ */
27
+ public function reload()
28
+ {
29
+ parent::g_reload(self::getUrl());
30
+ }
31
 
32
+ /**
33
+ * @param string $id
34
+ *
35
+ * @return string
36
+ */
37
+ private static function getUrl($id = '')
38
+ {
39
+ return OMISE_API_URL.self::ENDPOINT.'/'.$id;
40
+ }
41
  }
lib/omise-php/lib/omise/OmiseBalance.php CHANGED
@@ -2,32 +2,40 @@
2
 
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
 
5
- class OmiseBalance extends OmiseApiResource {
6
- const ENDPOINT = 'balance';
 
7
 
8
- /**
9
- * Retrieves a current balance in the account.
10
- * @param string $publickey
11
- * @param string $secretkey
12
- * @return OmiseBalance
13
- */
14
- public static function retrieve($publickey = null, $secretkey = null) {
15
- return parent::g_retrieve(get_class(), self::getUrl(), $publickey, $secretkey);
16
- }
 
 
 
17
 
18
- /**
19
- * (non-PHPdoc)
20
- * @see OmiseApiResource::g_reload()
21
- */
22
- public function reload() {
23
- parent::g_reload(self::getUrl());
24
- }
 
 
25
 
26
- /**
27
- * @param string $id
28
- * @return string
29
- */
30
- private static function getUrl($id = '') {
31
- return OMISE_API_URL.self::ENDPOINT.'/'.$id;
32
- }
 
 
33
  }
2
 
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
 
5
+ class OmiseBalance extends OmiseApiResource
6
+ {
7
+ const ENDPOINT = 'balance';
8
 
9
+ /**
10
+ * Retrieves a current balance in the account.
11
+ *
12
+ * @param string $publickey
13
+ * @param string $secretkey
14
+ *
15
+ * @return OmiseBalance
16
+ */
17
+ public static function retrieve($publickey = null, $secretkey = null)
18
+ {
19
+ return parent::g_retrieve(get_class(), self::getUrl(), $publickey, $secretkey);
20
+ }
21
 
22
+ /**
23
+ * (non-PHPdoc)
24
+ *
25
+ * @see OmiseApiResource::g_reload()
26
+ */
27
+ public function reload()
28
+ {
29
+ parent::g_reload(self::getUrl());
30
+ }
31
 
32
+ /**
33
+ * @param string $id
34
+ *
35
+ * @return string
36
+ */
37
+ private static function getUrl($id = '')
38
+ {
39
+ return OMISE_API_URL.self::ENDPOINT.'/'.$id;
40
+ }
41
  }
lib/omise-php/lib/omise/OmiseCard.php CHANGED
@@ -3,61 +3,75 @@
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
  require_once dirname(__FILE__).'/OmiseCustomer.php';
5
 
6
- class OmiseCard extends OmiseApiResource {
7
- private $_customerID;
8
- const ENDPOINT = 'cards';
9
-
10
- /**
11
- * Object representing a card. Cards are retrieved using a `Customer`.
12
- * @param array $array
13
- * @param string $customerID
14
- * @param string $publickey
15
- * @param string $secretkey
16
- */
17
- public function __construct($array, $customerID, $publickey = null, $secretkey = null) {
18
- parent::__construct($publickey, $secretkey);
19
- $this->_customerID = $customerID;
20
- $this->refresh($array);
21
- }
22
-
23
- /**
24
- * (non-PHPdoc)
25
- * @see OmiseApiResource::g_reload()
26
- */
27
- public function reload() {
28
- parent::g_reload($this->getUrl($this['id']));
29
- }
30
-
31
- /**
32
- * (non-PHPdoc)
33
- * @see OmiseApiResource::g_update()
34
- */
35
- public function update($params) {
36
- parent::g_update($this->getUrl($this['id']), $params);
37
- }
38
-
39
- /**
40
- * (non-PHPdoc)
41
- * @see OmiseApiResource::g_destroy()
42
- */
43
- public function destroy() {
44
- parent::g_destroy($this->getUrl($this['id']));
45
- }
46
-
47
- /**
48
- * (non-PHPdoc)
49
- * @see OmiseApiResource::isDestroyed()
50
- */
51
- public function isDestroyed() {
52
- return parent::isDestroyed();
53
- }
54
-
55
- /**
56
- *
57
- * @param string $cardID
58
- * @return string
59
- */
60
- private function getUrl($cardID = '') {
61
- return OMISE_API_URL.OmiseCustomer::ENDPOINT.'/'.$this->_customerID.'/'.self::ENDPOINT.'/'.$cardID;
62
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  }
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
  require_once dirname(__FILE__).'/OmiseCustomer.php';
5
 
6
+ class OmiseCard extends OmiseApiResource
7
+ {
8
+ const ENDPOINT = 'cards';
9
+
10
+ private $_customerID;
11
+
12
+ /**
13
+ * Object representing a card. Cards are retrieved using a `Customer`.
14
+ *
15
+ * @param array $array
16
+ * @param string $customerID
17
+ * @param string $publickey
18
+ * @param string $secretkey
19
+ */
20
+ public function __construct($array, $customerID, $publickey = null, $secretkey = null)
21
+ {
22
+ parent::__construct($publickey, $secretkey);
23
+
24
+ $this->_customerID = $customerID;
25
+ $this->refresh($array);
26
+ }
27
+
28
+ /**
29
+ * (non-PHPdoc)
30
+ *
31
+ * @see OmiseApiResource::g_reload()
32
+ */
33
+ public function reload()
34
+ {
35
+ parent::g_reload($this->getUrl($this['id']));
36
+ }
37
+
38
+ /**
39
+ * (non-PHPdoc)
40
+ *
41
+ * @see OmiseApiResource::g_update()
42
+ */
43
+ public function update($params)
44
+ {
45
+ parent::g_update($this->getUrl($this['id']), $params);
46
+ }
47
+
48
+ /**
49
+ * (non-PHPdoc)
50
+ *
51
+ * @see OmiseApiResource::g_destroy()
52
+ */
53
+ public function destroy()
54
+ {
55
+ parent::g_destroy($this->getUrl($this['id']));
56
+ }
57
+
58
+ /**
59
+ * (non-PHPdoc)
60
+ *
61
+ * @see OmiseApiResource::isDestroyed()
62
+ */
63
+ public function isDestroyed()
64
+ {
65
+ return parent::isDestroyed();
66
+ }
67
+
68
+ /**
69
+ * @param string $cardID
70
+ *
71
+ * @return string
72
+ */
73
+ private function getUrl($cardID = '')
74
+ {
75
+ return OMISE_API_URL.OmiseCustomer::ENDPOINT.'/'.$this->_customerID.'/'.self::ENDPOINT.'/'.$cardID;
76
+ }
77
  }
lib/omise-php/lib/omise/OmiseCardList.php CHANGED
@@ -3,38 +3,57 @@
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
  require_once dirname(__FILE__).'/OmiseCard.php';
5
 
6
- class OmiseCardList extends OmiseApiResource {
7
- const ENDPOINT = 'cards';
8
- private $_customerID;
 
 
9
 
10
- /**
11
- * @param array $cards
12
- * @param string $customerID
13
- * @param string $publickey
14
- * @param string $secretkey
15
- */
16
- public function __construct($cards, $customerID, $publickey = null, $secretkey = null) {
17
- parent::__construct($publickey, $secretkey);
18
- $this->_customerID = $customerID;
19
- $this->refresh($cards);
20
- }
 
 
 
 
 
 
 
 
 
 
 
21
 
22
- /**
23
- * retrieve
24
- * @param stroing $id
25
- * @return OmiseCard
26
- */
27
- public function retrieve($id) {
28
- $result = parent::execute($this->getUrl($id), parent::REQUEST_GET, self::getResourceKey());
29
- return new OmiseCard($result, $this->_customerID, $this->_publickey, $this->_secretkey);
30
- }
 
 
 
 
31
 
32
 
33
- /**
34
- * @param string $id
35
- * @return string
36
- */
37
- private function getUrl($id = '') {
38
- return OMISE_API_URL.'customers/'.$this->_customerID.'/'.self::ENDPOINT.'/'.$id;
39
- }
 
 
40
  }
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
  require_once dirname(__FILE__).'/OmiseCard.php';
5
 
6
+ class OmiseCardList extends OmiseApiResource
7
+ {
8
+ const ENDPOINT = 'cards';
9
+
10
+ private $_customerID;
11
 
12
+ /**
13
+ * @param array $cards
14
+ * @param string $customerID
15
+ * @param string $publickey
16
+ * @param string $secretkey
17
+ */
18
+ public function __construct($cards, $customerID, $options = array(), $publickey = null, $secretkey = null)
19
+ {
20
+ if (! is_array($options) && func_num_args() == 4) {
21
+ $publickey = func_get_arg(2);
22
+ $secretkey = func_get_arg(3);
23
+ }
24
+
25
+ parent::__construct($publickey, $secretkey);
26
+ $this->_customerID = $customerID;
27
+
28
+ if (is_array($options)) {
29
+ parent::g_reload($this->getUrl('?'.http_build_query($options)));
30
+ } else {
31
+ $this->refresh($cards);
32
+ }
33
+ }
34
 
35
+ /**
36
+ * retrieve a card
37
+ *
38
+ * @param string $id
39
+ *
40
+ * @return OmiseCard
41
+ */
42
+ public function retrieve($id)
43
+ {
44
+ $result = parent::execute($this->getUrl($id), parent::REQUEST_GET, self::getResourceKey());
45
+
46
+ return new OmiseCard($result, $this->_customerID, $this->_publickey, $this->_secretkey);
47
+ }
48
 
49
 
50
+ /**
51
+ * @param string $id
52
+ *
53
+ * @return string
54
+ */
55
+ private function getUrl($id = '')
56
+ {
57
+ return OMISE_API_URL.'customers/'.$this->_customerID.'/'.self::ENDPOINT.'/'.$id;
58
+ }
59
  }
lib/omise-php/lib/omise/OmiseCharge.php CHANGED
@@ -3,77 +3,107 @@
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
  require_once dirname(__FILE__).'/OmiseRefundList.php';
5
 
6
- class OmiseCharge extends OmiseApiResource {
7
- const ENDPOINT = 'charges';
 
8
 
9
- /**
10
- * Retrieves a charge.
11
- * @param string $id
12
- * @param string $publickey
13
- * @param string $secretkey
14
- * @return OmiseCharge
15
- */
16
- public static function retrieve($id = '', $publickey = null, $secretkey = null) {
17
- return parent::g_retrieve(get_class(), self::getUrl($id), $publickey, $secretkey);
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
- /**
21
- * (non-PHPdoc)
22
- * @see OmiseApiResource::g_reload()
23
- */
24
- public function reload() {
25
- if($this['object'] === 'charge') {
26
- parent::g_reload(self::getUrl($this['id']));
27
- } else {
28
- parent::g_reload(self::getUrl());
 
 
 
29
  }
30
- }
31
 
32
- /**
33
- * Creates a new charge.
34
- * @param array $params
35
- * @param string $publickey
36
- * @param string $secretkey
37
- * @return OmiseCharge
38
- */
39
- public static function create($params, $publickey = null, $secretkey = null) {
40
- return parent::g_create(get_class(), self::getUrl(), $params, $publickey, $secretkey);
41
- }
42
 
43
- /**
44
- * (non-PHPdoc)
45
- * @see OmiseApiResource::g_update()
46
- */
47
- public function update($params) {
48
- parent::g_update(self::getUrl($this['id']), $params);
49
- }
 
 
50
 
51
- /**
52
- * Captures a charge.
53
- * @return OmiseCharge
54
- */
55
- public function capture() {
56
- $result = parent::execute(self::getUrl($this['id']).'/capture', parent::REQUEST_POST, parent::getResourceKey());
57
- $this->refresh($result);
58
 
59
- return $this;
60
- }
61
-
62
- /**
63
- * list refunds
64
- * @return OmiseRefundList
65
- */
66
- public function refunds() {
67
- $result = parent::execute(self::getUrl($this['id']).'/refunds', parent::REQUEST_GET, parent::getResourceKey());
68
- return new OmiseRefundList($result, $this['id'], $this->_publickey, $this->_secretkey);
69
- }
70
 
71
- /**
72
- *
73
- * @param string $id
74
- * @return string
75
- */
76
- private static function getUrl($id = '') {
77
- return OMISE_API_URL.self::ENDPOINT.'/'.$id;
78
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
  require_once dirname(__FILE__).'/OmiseRefundList.php';
5
 
6
+ class OmiseCharge extends OmiseApiResource
7
+ {
8
+ const ENDPOINT = 'charges';
9
 
10
+ /**
11
+ * Retrieves a charge.
12
+ *
13
+ * @param string $id
14
+ * @param string $publickey
15
+ * @param string $secretkey
16
+ *
17
+ * @return OmiseCharge
18
+ */
19
+ public static function retrieve($id = '', $publickey = null, $secretkey = null)
20
+ {
21
+ return parent::g_retrieve(get_class(), self::getUrl($id), $publickey, $secretkey);
22
+ }
23
+
24
+ /**
25
+ * (non-PHPdoc)
26
+ *
27
+ * @see OmiseApiResource::g_reload()
28
+ */
29
+ public function reload()
30
+ {
31
+ if ($this['object'] === 'charge') {
32
+ parent::g_reload(self::getUrl($this['id']));
33
+ } else {
34
+ parent::g_reload(self::getUrl());
35
+ }
36
+ }
37
 
38
+ /**
39
+ * Creates a new charge.
40
+ *
41
+ * @param array $params
42
+ * @param string $publickey
43
+ * @param string $secretkey
44
+ *
45
+ * @return OmiseCharge
46
+ */
47
+ public static function create($params, $publickey = null, $secretkey = null)
48
+ {
49
+ return parent::g_create(get_class(), self::getUrl(), $params, $publickey, $secretkey);
50
  }
 
51
 
52
+ /**
53
+ * (non-PHPdoc)
54
+ *
55
+ * @see OmiseApiResource::g_update()
56
+ */
57
+ public function update($params)
58
+ {
59
+ parent::g_update(self::getUrl($this['id']), $params);
60
+ }
 
61
 
62
+ /**
63
+ * Captures a charge.
64
+ *
65
+ * @return OmiseCharge
66
+ */
67
+ public function capture()
68
+ {
69
+ $result = parent::execute(self::getUrl($this['id']).'/capture', parent::REQUEST_POST, parent::getResourceKey());
70
+ $this->refresh($result);
71
 
72
+ return $this;
73
+ }
 
 
 
 
 
74
 
75
+ /**
76
+ * Reverses a charge.
77
+ *
78
+ * @return OmiseCharge
79
+ */
80
+ public function reverse()
81
+ {
82
+ $result = parent::execute(self::getUrl($this['id']).'/reverse', parent::REQUEST_POST, parent::getResourceKey());
83
+ $this->refresh($result);
 
 
84
 
85
+ return $this;
86
+ }
87
+
88
+ /**
89
+ * list refunds
90
+ *
91
+ * @return OmiseRefundList
92
+ */
93
+ public function refunds()
94
+ {
95
+ $result = parent::execute(self::getUrl($this['id']).'/refunds', parent::REQUEST_GET, parent::getResourceKey());
96
+
97
+ return new OmiseRefundList($result, $this['id'], $this->_publickey, $this->_secretkey);
98
+ }
99
+
100
+ /**
101
+ * @param string $id
102
+ *
103
+ * @return string
104
+ */
105
+ private static function getUrl($id = '')
106
+ {
107
+ return OMISE_API_URL.self::ENDPOINT.'/'.$id;
108
+ }
109
  }
lib/omise-php/lib/omise/OmiseCustomer.php CHANGED
@@ -3,92 +3,117 @@
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
  require_once dirname(__FILE__).'/OmiseCardList.php';
5
 
6
- class OmiseCustomer extends OmiseApiResource {
7
- const ENDPOINT = 'customers';
 
8
 
9
- /**
10
- * Retrieves a customer.
11
- * @param string $id
12
- * @param string $publickey
13
- * @param string $secretkey
14
- * @return OmiseCustomer
15
- */
16
- public static function retrieve($id = '', $publickey = null, $secretkey = null) {
17
- return parent::g_retrieve(get_class(), self::getUrl($id), $publickey, $secretkey);
18
- }
 
 
 
19
 
20
- /**
21
- * Creates a new customer.
22
- * @param array $params
23
- * @param string $publickey
24
- * @param string $secretkey
25
- * @return OmiseCustomer
26
- */
27
- public static function create($params, $publickey = null, $secretkey = null) {
28
- return parent::g_create(get_class(), self::getUrl(), $params, $publickey, $secretkey);
29
- }
 
 
 
30
 
31
- /**
32
- * (non-PHPdoc)
33
- * @see OmiseApiResource::g_reload()
34
- */
35
- public function reload() {
36
- if($this['object'] === 'customer') {
37
- parent::g_reload(self::getUrl($this['id']));
38
- } else {
39
- parent::g_reload(self::getUrl());
 
 
 
40
  }
41
- }
42
 
43
- /**
44
- * (non-PHPdoc)
45
- * @see OmiseApiResource::g_update()
46
- */
47
- public function update($params) {
48
- parent::g_update(self::getUrl($this['id']), $params);
49
- }
 
 
50
 
51
- /**
52
- * (non-PHPdoc)
53
- * @see OmiseApiResource::g_destroy()
54
- */
55
- public function destroy() {
56
- parent::g_destroy(self::getUrl($this['id']));
57
- }
 
 
58
 
59
- /**
60
- * (non-PHPdoc)
61
- * @see OmiseApiResource::isDestroyed()
62
- */
63
- public function isDestroyed() {
64
- return parent::isDestroyed();
65
- }
 
 
66
 
67
- /**
68
- * Gets a list of all cards belongs to this customer.
69
- * @return OmiseCardList
70
- */
71
- public function cards() {
72
- if($this['object'] === 'customer') {
73
- return new OmiseCardList($this['cards'], $this['id'], $this->_publickey, $this->_secretkey);
 
 
 
 
 
 
 
74
  }
75
- }
76
 
77
- /**
78
- * cards() alias
79
- * @deprecated deprecated since version 2.0.0 use '$customer->cards()'
80
- * @return OmiseCardList
81
- */
82
- public function getCards() {
83
- return $this->cards();
84
- }
 
 
 
85
 
86
- /**
87
- *
88
- * @param string $id
89
- * @return string
90
- */
91
- private static function getUrl($id = '') {
92
- return OMISE_API_URL.self::ENDPOINT.'/'.$id;
93
- }
 
94
  }
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
  require_once dirname(__FILE__).'/OmiseCardList.php';
5
 
6
+ class OmiseCustomer extends OmiseApiResource
7
+ {
8
+ const ENDPOINT = 'customers';
9
 
10
+ /**
11
+ * Retrieves a customer.
12
+ *
13
+ * @param string $id
14
+ * @param string $publickey
15
+ * @param string $secretkey
16
+ *
17
+ * @return OmiseCustomer
18
+ */
19
+ public static function retrieve($id = '', $publickey = null, $secretkey = null)
20
+ {
21
+ return parent::g_retrieve(get_class(), self::getUrl($id), $publickey, $secretkey);
22
+ }
23
 
24
+ /**
25
+ * Creates a new customer.
26
+ *
27
+ * @param array $params
28
+ * @param string $publickey
29
+ * @param string $secretkey
30
+ *
31
+ * @return OmiseCustomer
32
+ */
33
+ public static function create($params, $publickey = null, $secretkey = null)
34
+ {
35
+ return parent::g_create(get_class(), self::getUrl(), $params, $publickey, $secretkey);
36
+ }
37
 
38
+ /**
39
+ * (non-PHPdoc)
40
+ *
41
+ * @see OmiseApiResource::g_reload()
42
+ */
43
+ public function reload()
44
+ {
45
+ if ($this['object'] === 'customer') {
46
+ parent::g_reload(self::getUrl($this['id']));
47
+ } else {
48
+ parent::g_reload(self::getUrl());
49
+ }
50
  }
 
51
 
52
+ /**
53
+ * (non-PHPdoc)
54
+ *
55
+ * @see OmiseApiResource::g_update()
56
+ */
57
+ public function update($params)
58
+ {
59
+ parent::g_update(self::getUrl($this['id']), $params);
60
+ }
61
 
62
+ /**
63
+ * (non-PHPdoc)
64
+ *
65
+ * @see OmiseApiResource::g_destroy()
66
+ */
67
+ public function destroy()
68
+ {
69
+ parent::g_destroy(self::getUrl($this['id']));
70
+ }
71
 
72
+ /**
73
+ * (non-PHPdoc)
74
+ *
75
+ * @see OmiseApiResource::isDestroyed()
76
+ */
77
+ public function isDestroyed()
78
+ {
79
+ return parent::isDestroyed();
80
+ }
81
 
82
+ /**
83
+ * Gets a list of all cards belongs to this customer.
84
+ *
85
+ * @param array $options
86
+ *
87
+ * @return OmiseCardList
88
+ */
89
+ public function cards($options = array())
90
+ {
91
+ if ($this['object'] === 'customer' && ! empty($options)) {
92
+ return new OmiseCardList($this['cards'], $this['id'], $options, $this->_publickey, $this->_secretkey);
93
+ } else if ($this['object'] === 'customer') {
94
+ return new OmiseCardList($this['cards'], $this['id'], $this->_publickey, $this->_secretkey);
95
+ }
96
  }
 
97
 
98
+ /**
99
+ * cards() alias
100
+ *
101
+ * @deprecated deprecated since version 2.0.0 use '$customer->cards()'
102
+ *
103
+ * @return OmiseCardList
104
+ */
105
+ public function getCards($options = array())
106
+ {
107
+ return $this->cards($options);
108
+ }
109
 
110
+ /**
111
+ * @param string $id
112
+ *
113
+ * @return string
114
+ */
115
+ private static function getUrl($id = '')
116
+ {
117
+ return OMISE_API_URL.self::ENDPOINT.'/'.$id;
118
+ }
119
  }
lib/omise-php/lib/omise/OmiseDispute.php CHANGED
@@ -2,46 +2,57 @@
2
 
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
 
5
- class OmiseDispute extends OmiseApiResource {
6
- const ENDPOINT = 'disputes';
 
7
 
8
- /**
9
- * Retrieves a dispute.
10
- * @param string $id
11
- * @param string $publickey
12
- * @param string $secretkey
13
- * @return OmiseDispute
14
- */
15
- public static function retrieve($id = '', $publickey = null, $secretkey = null) {
16
- return parent::g_retrieve(get_class(), self::getUrl($id), $publickey, $secretkey);
17
- }
 
 
 
18
 
19
- /**
20
- * (non-PHPdoc)
21
- * @see OmiseApiResource::g_reload()
22
- */
23
- public function reload() {
24
- if($this['object'] === 'dispute') {
25
- parent::g_reload(self::getUrl($this['id']));
26
- } else {
27
- parent::g_reload(self::getUrl());
 
 
 
28
  }
29
- }
30
 
31
- /**
32
- * (non-PHPdoc)
33
- * @see OmiseApiResource::g_update()
34
- */
35
- public function update($params) {
36
- parent::g_update(self::getUrl($this['id']), $params);
37
- }
 
 
38
 
39
- /**
40
- * Generate request url.
41
- * @param string $id
42
- * @return string
43
- */
44
- private static function getUrl($id = '') {
45
- return OMISE_API_URL.self::ENDPOINT.'/'.$id;
46
- }
 
 
 
47
  }
2
 
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
 
5
+ class OmiseDispute extends OmiseApiResource
6
+ {
7
+ const ENDPOINT = 'disputes';
8
 
9
+ /**
10
+ * Retrieves a dispute.
11
+ *
12
+ * @param string $id
13
+ * @param string $publickey
14
+ * @param string $secretkey
15
+ *
16
+ * @return OmiseDispute
17
+ */
18
+ public static function retrieve($id = '', $publickey = null, $secretkey = null)
19
+ {
20
+ return parent::g_retrieve(get_class(), self::getUrl($id), $publickey, $secretkey);
21
+ }
22
 
23
+ /**
24
+ * (non-PHPdoc)
25
+ *
26
+ * @see OmiseApiResource::g_reload()
27
+ */
28
+ public function reload()
29
+ {
30
+ if ($this['object'] === 'dispute') {
31
+ parent::g_reload(self::getUrl($this['id']));
32
+ } else {
33
+ parent::g_reload(self::getUrl());
34
+ }
35
  }
 
36
 
37
+ /**
38
+ * (non-PHPdoc)
39
+ *
40
+ * @see OmiseApiResource::g_update()
41
+ */
42
+ public function update($params)
43
+ {
44
+ parent::g_update(self::getUrl($this['id']), $params);
45
+ }
46
 
47
+ /**
48
+ * Generate request url.
49
+ *
50
+ * @param string $id
51
+ *
52
+ * @return string
53
+ */
54
+ private static function getUrl($id = '')
55
+ {
56
+ return OMISE_API_URL.self::ENDPOINT.'/'.$id;
57
+ }
58
  }
lib/omise-php/lib/omise/OmiseEvent.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
+
5
+ class OmiseEvent extends OmiseApiResource
6
+ {
7
+ const ENDPOINT = 'events';
8
+
9
+ /**
10
+ * Retrieves an event.
11
+ *
12
+ * @param string $id
13
+ * @param string $publickey
14
+ * @param string $secretkey
15
+ *
16
+ * @return OmiseEvent
17
+ */
18
+ public static function retrieve($id = '', $publickey = null, $secretkey = null)
19
+ {
20
+ return parent::g_retrieve(get_class(), self::getUrl($id), $publickey, $secretkey);
21
+ }
22
+
23
+ /**
24
+ * (non-PHPdoc)
25
+ *
26
+ * @see OmiseApiResource::g_reload()
27
+ */
28
+ public function reload()
29
+ {
30
+ if ($this['object'] === 'event') {
31
+ parent::g_reload(self::getUrl($this['id']));
32
+ } else {
33
+ parent::g_reload(self::getUrl());
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Generate request url.
39
+ *
40
+ * @param string $id
41
+ *
42
+ * @return string
43
+ */
44
+ private static function getUrl($id = '')
45
+ {
46
+ return OMISE_API_URL.self::ENDPOINT.'/'.$id;
47
+ }
48
+ }
lib/omise-php/lib/omise/OmiseLink.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
+
5
+ class OmiseLink extends OmiseApiResource
6
+ {
7
+ const ENDPOINT = 'links';
8
+
9
+ /**
10
+ * Retrieves a link.
11
+ *
12
+ * @param string $id
13
+ * @param string $publickey
14
+ * @param string $secretkey
15
+ *
16
+ * @return OmiseLink
17
+ */
18
+ public static function retrieve($id = '', $publickey = null, $secretkey = null)
19
+ {
20
+ return parent::g_retrieve(get_class(), self::getUrl($id), $publickey, $secretkey);
21
+ }
22
+
23
+ /**
24
+ * (non-PHPdoc)
25
+ *
26
+ * @see OmiseApiResource::g_reload()
27
+ */
28
+ public function reload()
29
+ {
30
+ if ($this['object'] === 'link') {
31
+ parent::g_reload(self::getUrl($this['id']));
32
+ } else {
33
+ parent::g_reload(self::getUrl());
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Creates a new link.
39
+ *
40
+ * @param array $params
41
+ * @param string $publickey
42
+ * @param string $secretkey
43
+ *
44
+ * @return OmiseLink
45
+ */
46
+ public static function create($params, $publickey = null, $secretkey = null)
47
+ {
48
+ return parent::g_create(get_class(), self::getUrl(), $params, $publickey, $secretkey);
49
+ }
50
+
51
+ /**
52
+ * @param string $id
53
+ *
54
+ * @return string
55
+ */
56
+ private static function getUrl($id = '')
57
+ {
58
+ return OMISE_API_URL.self::ENDPOINT.'/'.$id;
59
+ }
60
+ }
lib/omise-php/lib/omise/OmiseRecipient.php CHANGED
@@ -2,61 +2,89 @@
2
 
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
 
5
- class OmiseRecipient extends OmiseApiResource {
6
- const ENDPOINT = 'recipients';
7
-
8
- /**
9
- * Retrieves recipients.
10
- * @param string $id
11
- * @param string $publickey
12
- * @param string $secretkey
13
- * @return OmiseRecipient
14
- */
15
- public static function retrieve($id = '', $publickey = null, $secretkey = null) {
16
- return parent::g_retrieve(get_class(), self::getUrl($id), $publickey, $secretkey);
17
- }
18
-
19
- /**
20
- * Creates a new recipient.
21
- * @param array $params
22
- * @param string $publickey
23
- * @param string $secretkey
24
- * @return OmiseRecipient
25
- */
26
- public static function create($params, $publickey = null, $secretkey = null) {
27
- return parent::g_create(get_class(), self::getUrl(), $params, $publickey, $secretkey);
28
- }
29
-
30
- /**
31
- * (non-PHPdoc)
32
- * @see OmiseApiResource::g_update()
33
- */
34
- public function update($params) {
35
- parent::g_update(self::getUrl($this['id']), $params);
36
- }
37
-
38
- /**
39
- * (non-PHPdoc)
40
- * @see OmiseApiResource::g_destroy()
41
- */
42
- public function destroy() {
43
- parent::g_destroy(self::getUrl($this['id']));
44
- }
45
-
46
- /**
47
- * (non-PHPdoc)
48
- * @see OmiseApiResource::isDestroyed()
49
- */
50
- public function isDestroyed() {
51
- return parent::isDestroyed();
52
- }
53
-
54
- /**
55
- *
56
- * @param string $id
57
- * @return string
58
- */
59
- private static function getUrl($id = '') {
60
- return OMISE_API_URL.self::ENDPOINT.'/'.$id;
61
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  }
2
 
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
 
5
+ class OmiseRecipient extends OmiseApiResource
6
+ {
7
+ const ENDPOINT = 'recipients';
8
+
9
+ /**
10
+ * Retrieves recipients.
11
+ *
12
+ * @param string $id
13
+ * @param string $publickey
14
+ * @param string $secretkey
15
+ *
16
+ * @return OmiseRecipient
17
+ */
18
+ public static function retrieve($id = '', $publickey = null, $secretkey = null)
19
+ {
20
+ return parent::g_retrieve(get_class(), self::getUrl($id), $publickey, $secretkey);
21
+ }
22
+
23
+ /**
24
+ * Creates a new recipient.
25
+ *
26
+ * @param array $params
27
+ * @param string $publickey
28
+ * @param string $secretkey
29
+ *
30
+ * @return OmiseRecipient
31
+ */
32
+ public static function create($params, $publickey = null, $secretkey = null)
33
+ {
34
+ return parent::g_create(get_class(), self::getUrl(), $params, $publickey, $secretkey);
35
+ }
36
+
37
+ /**
38
+ * (non-PHPdoc)
39
+ *
40
+ * @see OmiseApiResource::g_update()
41
+ */
42
+ public function update($params)
43
+ {
44
+ parent::g_update(self::getUrl($this['id']), $params);
45
+ }
46
+
47
+ /**
48
+ * (non-PHPdoc)
49
+ *
50
+ * @see OmiseApiResource::g_destroy()
51
+ */
52
+ public function destroy()
53
+ {
54
+ parent::g_destroy(self::getUrl($this['id']));
55
+ }
56
+
57
+ /**
58
+ * (non-PHPdoc)
59
+ *
60
+ * @see OmiseApiResource::isDestroyed()
61
+ */
62
+ public function isDestroyed()
63
+ {
64
+ return parent::isDestroyed();
65
+ }
66
+
67
+ /**
68
+ * (non-PHPdoc)
69
+ *
70
+ * @see OmiseApiResource::g_reload()
71
+ */
72
+ public function reload()
73
+ {
74
+ if ($this['object'] === 'recipient') {
75
+ parent::g_reload(self::getUrl($this['id']));
76
+ } else {
77
+ parent::g_reload(self::getUrl());
78
+ }
79
+ }
80
+
81
+ /**
82
+ * @param string $id
83
+ *
84
+ * @return string
85
+ */
86
+ private static function getUrl($id = '')
87
+ {
88
+ return OMISE_API_URL.self::ENDPOINT.'/'.$id;
89
+ }
90
  }
lib/omise-php/lib/omise/OmiseRefund.php CHANGED
@@ -2,14 +2,16 @@
2
 
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
 
5
- class OmiseRefund extends OmiseApiResource {
6
- /**
7
- * @param array $refund
8
- * @param string $publickey
9
- * @param string $secretkey
10
- */
11
- public function __construct($refund, $publickey = null, $secretkey = null) {
12
- parent::__construct($publickey, $secretkey);
13
- $this->refresh($refund);
14
- }
 
 
15
  }
2
 
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
 
5
+ class OmiseRefund extends OmiseApiResource
6
+ {
7
+ /**
8
+ * @param array $refund
9
+ * @param string $publickey
10
+ * @param string $secretkey
11
+ */
12
+ public function __construct($refund, $publickey = null, $secretkey = null)
13
+ {
14
+ parent::__construct($publickey, $secretkey);
15
+ $this->refresh($refund);
16
+ }
17
  }
lib/omise-php/lib/omise/OmiseRefundList.php CHANGED
@@ -3,46 +3,56 @@
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
  require_once dirname(__FILE__).'/OmiseRefund.php';
5
 
6
- class OmiseRefundList extends OmiseApiResource {
7
- const ENDPOINT = 'refunds';
8
- private $_chargeID;
9
-
10
- /**
11
- * @param array $refunds
12
- * @param string $chargeID
13
- * @param string $publickey
14
- * @param string $secretkey
15
- */
16
- public function __construct($refunds, $chargeID, $publickey = null, $secretkey = null) {
17
- parent::__construct($publickey, $secretkey);
18
- $this->_chargeID = $chargeID;
19
- $this->refresh($refunds);
20
- }
21
-
22
- /**
23
- * @param array $amount
24
- * @return OmiseRefund
25
- */
26
- public function create($params) {
27
- $result = parent::execute($this->getUrl(), parent::REQUEST_POST, self::getResourceKey(), $params);
28
- return new OmiseRefund($result, $this->_publickey, $this->_secretkey);
29
- }
30
-
31
- /**
32
- *
33
- * @param string $id
34
- * @return OmiseRefund
35
- */
36
- public function retrieve($id) {
37
- $result = parent::execute($this->getUrl($id), parent::REQUEST_GET, self::getResourceKey());
38
- return new OmiseRefund($result, $this->_publickey, $this->_secretkey);
39
- }
40
-
41
- /**
42
- * @param string $id
43
- * @return string
44
- */
45
- private function getUrl($id = '') {
46
- return OMISE_API_URL.'charges/'.$this->_chargeID.'/'.self::ENDPOINT.'/'.$id;
47
- }
 
 
 
 
 
 
 
 
 
 
48
  }
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
  require_once dirname(__FILE__).'/OmiseRefund.php';
5
 
6
+ class OmiseRefundList extends OmiseApiResource
7
+ {
8
+ const ENDPOINT = 'refunds';
9
+
10
+ private $_chargeID;
11
+
12
+ /**
13
+ * @param array $refunds
14
+ * @param string $chargeID
15
+ * @param string $publickey
16
+ * @param string $secretkey
17
+ */
18
+ public function __construct($refunds, $chargeID, $publickey = null, $secretkey = null)
19
+ {
20
+ parent::__construct($publickey, $secretkey);
21
+ $this->_chargeID = $chargeID;
22
+ $this->refresh($refunds);
23
+ }
24
+
25
+ /**
26
+ * @param array $amount
27
+ *
28
+ * @return OmiseRefund
29
+ */
30
+ public function create($params)
31
+ {
32
+ $result = parent::execute($this->getUrl(), parent::REQUEST_POST, self::getResourceKey(), $params);
33
+
34
+ return new OmiseRefund($result, $this->_publickey, $this->_secretkey);
35
+ }
36
+
37
+ /**
38
+ * @param string $id
39
+ *
40
+ * @return OmiseRefund
41
+ */
42
+ public function retrieve($id)
43
+ {
44
+ $result = parent::execute($this->getUrl($id), parent::REQUEST_GET, self::getResourceKey());
45
+
46
+ return new OmiseRefund($result, $this->_publickey, $this->_secretkey);
47
+ }
48
+
49
+ /**
50
+ * @param string $id
51
+ *
52
+ * @return string
53
+ */
54
+ private function getUrl($id = '')
55
+ {
56
+ return OMISE_API_URL.'charges/'.$this->_chargeID.'/'.self::ENDPOINT.'/'.$id;
57
+ }
58
  }
lib/omise-php/lib/omise/OmiseTest.php CHANGED
@@ -2,13 +2,15 @@
2
 
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
 
5
- class OmiseTest extends OmiseApiResource {
6
-
7
- /**
8
- * (non-PHPdoc)
9
- * @see OmiseApiResource::getInstance()
10
- */
11
- public static function resource() {
12
- return parent::getInstance(get_class());
13
- }
14
- }
 
 
2
 
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
 
5
+ class OmiseTest extends OmiseApiResource
6
+ {
7
+ /**
8
+ * (non-PHPdoc)
9
+ *
10
+ * @see OmiseApiResource::getInstance()
11
+ */
12
+ public static function resource()
13
+ {
14
+ return parent::getInstance(get_class());
15
+ }
16
+ }
lib/omise-php/lib/omise/OmiseToken.php CHANGED
@@ -2,46 +2,56 @@
2
 
3
  require_once dirname(__FILE__).'/res/OmiseVaultResource.php';
4
 
5
- class OmiseToken extends OmiseVaultResource {
6
- const ENDPOINT = 'tokens';
 
7
 
8
- /**
9
- * Retrieves a token.
10
- * @param string $id
11
- * @param string $publickey
12
- * @param string $secretkey
13
- * @return OmiseToken
14
- */
15
- public static function retrieve($id, $publickey = null, $secretkey = null) {
16
- return parent::g_retrieve(get_class(), self::getUrl($id), $publickey, $secretkey);
17
- }
 
 
 
18
 
19
- /**
20
- * Creates a new token. Please note that this method should be used only
21
- * in development. In production please use Omise.js!
22
- * @param array $params
23
- * @param string $publickey
24
- * @param string $secretkey
25
- * @return OmiseToken
26
- */
27
- public static function create($params, $publickey = null, $secretkey = null) {
28
- return parent::g_create(get_class(), self::getUrl(), $params, $publickey, $secretkey);
29
- }
 
 
 
30
 
31
- /**
32
- * (non-PHPdoc)
33
- * @see OmiseApiResource::g_reload()
34
- */
35
- public function reload() {
36
- parent::g_reload(self::getUrl($this['id']));
37
- }
 
 
38
 
39
- /**
40
- *
41
- * @param string $id
42
- * @return string
43
- */
44
- private static function getUrl($id = '') {
45
- return OMISE_VAULT_URL.self::ENDPOINT.'/'.$id;
46
- }
 
47
  }
2
 
3
  require_once dirname(__FILE__).'/res/OmiseVaultResource.php';
4
 
5
+ class OmiseToken extends OmiseVaultResource
6
+ {
7
+ const ENDPOINT = 'tokens';
8
 
9
+ /**
10
+ * Retrieves a token.
11
+ *
12
+ * @param string $id
13
+ * @param string $publickey
14
+ * @param string $secretkey
15
+ *
16
+ * @return OmiseToken
17
+ */
18
+ public static function retrieve($id, $publickey = null, $secretkey = null)
19
+ {
20
+ return parent::g_retrieve(get_class(), self::getUrl($id), $publickey, $secretkey);
21
+ }
22
 
23
+ /**
24
+ * Creates a new token. Please note that this method should be used only
25
+ * in development. In production please use Omise.js!
26
+ *
27
+ * @param array $params
28
+ * @param string $publickey
29
+ * @param string $secretkey
30
+ *
31
+ * @return OmiseToken
32
+ */
33
+ public static function create($params, $publickey = null, $secretkey = null)
34
+ {
35
+ return parent::g_create(get_class(), self::getUrl(), $params, $publickey, $secretkey);
36
+ }
37
 
38
+ /**
39
+ * (non-PHPdoc)
40
+ *
41
+ * @see OmiseApiResource::g_reload()
42
+ */
43
+ public function reload()
44
+ {
45
+ parent::g_reload(self::getUrl($this['id']));
46
+ }
47
 
48
+ /**
49
+ * @param string $id
50
+ *
51
+ * @return string
52
+ */
53
+ private static function getUrl($id = '')
54
+ {
55
+ return OMISE_VAULT_URL.self::ENDPOINT.'/'.$id;
56
+ }
57
  }
lib/omise-php/lib/omise/OmiseTransaction.php CHANGED
@@ -2,38 +2,45 @@
2
 
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
 
5
- class OmiseTransaction extends OmiseApiResource {
6
- const ENDPOINT = 'transactions';
 
7
 
8
- /**
9
- * Retrieves a transaction.
10
- * @param string $id
11
- * @param string $publickey
12
- * @param string $secretkey
13
- * @return OmiseTransaction
14
- */
15
- public static function retrieve($id = '', $publickey = null, $secretkey = null) {
16
- return parent::g_retrieve(get_class(), self::getUrl($id), $publickey, $secretkey);
17
- }
 
 
 
18
 
19
- /**
20
- * (non-PHPdoc)
21
- * @see OmiseApiResource::g_reload()
22
- */
23
- public function reload() {
24
- if($this['object'] === 'transaction') {
25
- parent::reload(self::getUrl($this['id']));
26
- } else {
27
- parent::g_reload(self::getUrl());
 
 
 
28
  }
29
- }
30
 
31
- /**
32
- *
33
- * @param string $id
34
- * @return string
35
- */
36
- private static function getUrl($id = '') {
37
- return OMISE_API_URL.self::ENDPOINT.'/'.$id;
38
- }
 
39
  }
2
 
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
 
5
+ class OmiseTransaction extends OmiseApiResource
6
+ {
7
+ const ENDPOINT = 'transactions';
8
 
9
+ /**
10
+ * Retrieves a transaction.
11
+ *
12
+ * @param string $id
13
+ * @param string $publickey
14
+ * @param string $secretkey
15
+ *
16
+ * @return OmiseTransaction
17
+ */
18
+ public static function retrieve($id = '', $publickey = null, $secretkey = null)
19
+ {
20
+ return parent::g_retrieve(get_class(), self::getUrl($id), $publickey, $secretkey);
21
+ }
22
 
23
+ /**
24
+ * (non-PHPdoc)
25
+ *
26
+ * @see OmiseApiResource::g_reload()
27
+ */
28
+ public function reload()
29
+ {
30
+ if ($this['object'] === 'transaction') {
31
+ parent::reload(self::getUrl($this['id']));
32
+ } else {
33
+ parent::g_reload(self::getUrl());
34
+ }
35
  }
 
36
 
37
+ /**
38
+ * @param string $id
39
+ *
40
+ * @return string
41
+ */
42
+ private static function getUrl($id = '')
43
+ {
44
+ return OMISE_API_URL.self::ENDPOINT.'/'.$id;
45
+ }
46
  }
lib/omise-php/lib/omise/OmiseTransfer.php CHANGED
@@ -2,80 +2,97 @@
2
 
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
 
5
- class OmiseTransfer extends OmiseApiResource {
6
- const ENDPOINT = 'transfers';
 
7
 
8
- /**
9
- * Retrieves a transfer.
10
- * @param string $id
11
- * @param string $publickey
12
- * @param string $secretkey
13
- * @return OmiseTransfer
14
- */
15
- public static function retrieve($id = '', $publickey = null, $secretkey = null) {
16
- return parent::g_retrieve(get_class(), self::getUrl($id), $publickey, $secretkey);
17
- }
 
 
 
18
 
19
- /**
20
- * Creates a transfer.
21
- * @param unknown $params
22
- * @param string $publickey
23
- * @param string $secretkey
24
- * @return OmiseTransfer
25
- */
26
- public static function create($params, $publickey = null, $secretkey = null) {
27
- return parent::g_create(get_class(), self::getUrl(), $params, $publickey, $secretkey);
28
- }
 
 
 
29
 
30
- /**
31
- * (non-PHPdoc)
32
- * @see OmiseApiResource::g_reload()
33
- */
34
- public function reload() {
35
- if($this['object'] === 'transfers') {
36
- parent::g_reload(self::getUrl($this['id']));
37
- } else {
38
- parent::g_reload(self::getUrl());
 
 
 
39
  }
40
- }
41
 
42
- /**
43
- * Updates the transfer amount.
44
- */
45
- public function save() {
46
- $this->update(array('amount' => $this['amount']));
47
- }
 
48
 
49
- /**
50
- * (non-PHPdoc)
51
- * @see OmiseApiResource::g_update()
52
- */
53
- protected function update($params) {
54
- parent::g_update(self::getUrl($this['id']), $params);
55
- }
 
 
56
 
57
- /**
58
- * (non-PHPdoc)
59
- * @see OmiseApiResource::g_destroy()
60
- */
61
- public function destroy() {
62
- parent::g_destroy(self::getUrl($this['id']));
63
- }
 
 
64
 
65
- /**
66
- * (non-PHPdoc)
67
- * @see OmiseApiResource::isDestroyed()
68
- */
69
- public function isDestroyed() {
70
- return parent::isDestroyed();
71
- }
 
 
72
 
73
- /**
74
- *
75
- * @param string $id
76
- * @return string
77
- */
78
- private static function getUrl($id = '') {
79
- return OMISE_API_URL.self::ENDPOINT.'/'.$id;
80
- }
 
81
  }
2
 
3
  require_once dirname(__FILE__).'/res/OmiseApiResource.php';
4
 
5
+ class OmiseTransfer extends OmiseApiResource
6
+ {
7
+ const ENDPOINT = 'transfers';
8
 
9
+ /**
10
+ * Retrieves a transfer.
11
+ *
12
+ * @param string $id
13
+ * @param string $publickey
14
+ * @param string $secretkey
15
+ *
16
+ * @return OmiseTransfer
17
+ */
18
+ public static function retrieve($id = '', $publickey = null, $secretkey = null)
19
+ {
20
+ return parent::g_retrieve(get_class(), self::getUrl($id), $publickey, $secretkey);
21
+ }
22
 
23
+ /**
24
+ * Creates a transfer.
25
+ *
26
+ * @param mixed $params
27
+ * @param string $publickey
28
+ * @param string $secretkey
29
+ *
30
+ * @return OmiseTransfer
31
+ */
32
+ public static function create($params, $publickey = null, $secretkey = null)
33
+ {
34
+ return parent::g_create(get_class(), self::getUrl(), $params, $publickey, $secretkey);
35
+ }
36
 
37
+ /**
38
+ * (non-PHPdoc)
39
+ *
40
+ * @see OmiseApiResource::g_reload()
41
+ */
42
+ public function reload()
43
+ {
44
+ if ($this['object'] === 'transfers') {
45
+ parent::g_reload(self::getUrl($this['id']));
46
+ } else {
47
+ parent::g_reload(self::getUrl());
48
+ }
49
  }
 
50
 
51
+ /**
52
+ * Updates the transfer amount.
53
+ */
54
+ public function save()
55
+ {
56
+ $this->update(array('amount' => $this['amount']));
57
+ }
58
 
59
+ /**
60
+ * (non-PHPdoc)
61
+ *
62
+ * @see OmiseApiResource::g_update()
63
+ */
64
+ protected function update($params)
65
+ {
66
+ parent::g_update(self::getUrl($this['id']), $params);
67
+ }
68
 
69
+ /**
70
+ * (non-PHPdoc)
71
+ *
72
+ * @see OmiseApiResource::g_destroy()
73
+ */
74
+ public function destroy()
75
+ {
76
+ parent::g_destroy(self::getUrl($this['id']));
77
+ }
78
 
79
+ /**
80
+ * (non-PHPdoc)
81
+ *
82
+ * @see OmiseApiResource::isDestroyed()
83
+ */
84
+ public function isDestroyed()
85
+ {
86
+ return parent::isDestroyed();
87
+ }
88
 
89
+ /**
90
+ * @param string $id
91
+ *
92
+ * @return string
93
+ */
94
+ private static function getUrl($id = '')
95
+ {
96
+ return OMISE_API_URL.self::ENDPOINT.'/'.$id;
97
+ }
98
  }
lib/omise-php/lib/omise/exception/OmiseExceptions.php CHANGED
@@ -1,120 +1,94 @@
1
  <?php
2
 
3
- class OmiseException extends Exception {
4
- private $_omiseError = null;
5
-
6
- public function __construct($message = null, $omiseError = null) {
7
- parent::__construct($message);
8
- $this->setOmiseError($omiseError);
9
- }
10
-
11
- /**
12
- * Returns an instance of an exception class from the given error response.
13
- * @param array $array
14
- * @return OmiseAuthenticationFailureException|OmiseNotFoundException|OmiseUsedTokenException|OmiseInvalidCardException|OmiseInvalidCardTokenException|OmiseMissingCardException|OmiseInvalidChargeException|OmiseFailedCaptureException|OmiseFailedFraudCheckException|OmiseUndefinedException
15
- */
16
- public static function getInstance($array) {
17
- switch ($array['code']) {
18
- case 'authentication_failure':
19
- return new OmiseAuthenticationFailureException($array['message'], $array);
20
-
21
- case 'not_found':
22
- return new OmiseNotFoundException($array['message'], $array);
23
-
24
- case 'used_token':
25
- return new OmiseUsedTokenException($array['message'], $array);
26
-
27
- case 'invalid_card':
28
- return new OmiseInvalidCardException($array['message'], $array);
29
-
30
- case 'invalid_card_token':
31
- return new OmiseInvalidCardTokenException($array['message'], $array);
32
-
33
- case 'missing_card':
34
- return new OmiseMissingCardException($array['message'], $array);
35
-
36
- case 'invalid_charge':
37
- return new OmiseInvalidChargeException($array['message'], $array);
38
-
39
- case 'failed_capture':
40
- return new OmiseFailedCaptureException($array['message'], $array);
41
-
42
- case 'failed_fraud_check':
43
- return new OmiseFailedFraudCheckException($array['message'], $array);
44
-
45
- case 'invalid_recipient':
46
- return new OmiseInvalidRecipientException($array['message'], $array);
47
-
48
- case 'invalid_bank_account':
49
- return new OmiseInvalidBankAccountException($array['message'], $array);
50
-
51
- default:
52
- return new OmiseUndefinedException($array['message'], $array);
53
  }
54
- }
55
-
56
- /**
57
- * Sets the error.
58
- * @param OmiseError $omiseError
59
- */
60
- public function setOmiseError($omiseError) {
61
- $this->_omiseError = $omiseError;
62
- }
63
-
64
- /**
65
- * Gets the OmiseError object. This method will return null if an error happens outside of the API. (For example, due to HTTP connectivity problem.)
66
- * Please see https://docs.omise.co/api/errors/ for a list of possible errors.
67
- * @return OmiseError
68
- */
69
- public function getOmiseError() {
70
- return $this->_omiseError;
71
- }
72
- }
73
 
74
- class OmiseAuthenticationFailureException extends OmiseException {
 
 
 
 
 
 
 
 
 
 
 
75
 
76
- }
 
77
 
78
- class OmiseNotFoundException extends OmiseException {
 
79
 
80
- }
 
81
 
82
- class OmiseUsedTokenException extends OmiseException {
 
83
 
84
- }
 
85
 
86
- class OmiseInvalidCardException extends OmiseException {
 
87
 
88
- }
 
89
 
90
- class OmiseInvalidCardTokenException extends OmiseException {
 
91
 
92
- }
 
93
 
94
- class OmiseMissingCardException extends OmiseException {
 
95
 
96
- }
97
-
98
- class OmiseInvalidChargeException extends OmiseException {
99
-
100
- }
101
-
102
- class OmiseFailedCaptureException extends OmiseException {
103
-
104
- }
105
-
106
- class OmiseFailedFraudCheckException extends OmiseException {
107
-
108
- }
109
-
110
- class OmiseInvalidRecipientException extends OmiseException {
111
-
112
- }
113
 
114
- class OmiseInvalidBankAccountException extends OmiseException {
 
 
 
 
 
 
 
 
115
 
 
 
 
 
 
 
 
 
 
 
116
  }
117
 
118
- class OmiseUndefinedException extends OmiseException {
119
-
120
- }
 
 
 
 
 
 
 
 
 
1
  <?php
2
 
3
+ class OmiseException extends Exception
4
+ {
5
+ private $_omiseError = null;
6
+
7
+ public function __construct($message = null, $omiseError = null)
8
+ {
9
+ parent::__construct($message);
10
+ $this->setOmiseError($omiseError);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
+ /**
14
+ * Returns an instance of an exception class from the given error response.
15
+ *
16
+ * @param array $array
17
+ *
18
+ * @return OmiseAuthenticationFailureException|OmiseNotFoundException|OmiseUsedTokenException|OmiseInvalidCardException|OmiseInvalidCardTokenException|OmiseMissingCardException|OmiseInvalidChargeException|OmiseFailedCaptureException|OmiseFailedFraudCheckException|OmiseUndefinedException
19
+ */
20
+ public static function getInstance($array)
21
+ {
22
+ switch ($array['code']) {
23
+ case 'authentication_failure':
24
+ return new OmiseAuthenticationFailureException($array['message'], $array);
25
 
26
+ case 'not_found':
27
+ return new OmiseNotFoundException($array['message'], $array);
28
 
29
+ case 'used_token':
30
+ return new OmiseUsedTokenException($array['message'], $array);
31
 
32
+ case 'invalid_card':
33
+ return new OmiseInvalidCardException($array['message'], $array);
34
 
35
+ case 'invalid_card_token':
36
+ return new OmiseInvalidCardTokenException($array['message'], $array);
37
 
38
+ case 'missing_card':
39
+ return new OmiseMissingCardException($array['message'], $array);
40
 
41
+ case 'invalid_charge':
42
+ return new OmiseInvalidChargeException($array['message'], $array);
43
 
44
+ case 'failed_capture':
45
+ return new OmiseFailedCaptureException($array['message'], $array);
46
 
47
+ case 'failed_fraud_check':
48
+ return new OmiseFailedFraudCheckException($array['message'], $array);
49
 
50
+ case 'invalid_recipient':
51
+ return new OmiseInvalidRecipientException($array['message'], $array);
52
 
53
+ case 'invalid_bank_account':
54
+ return new OmiseInvalidBankAccountException($array['message'], $array);
55
 
56
+ default:
57
+ return new OmiseUndefinedException($array['message'], $array);
58
+ }
59
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
+ /**
62
+ * Sets the error.
63
+ *
64
+ * @param OmiseError $omiseError
65
+ */
66
+ public function setOmiseError($omiseError)
67
+ {
68
+ $this->_omiseError = $omiseError;
69
+ }
70
 
71
+ /**
72
+ * Gets the OmiseError object. This method will return null if an error happens outside of the API. (For example, due to HTTP connectivity problem.)
73
+ * Please see https://docs.omise.co/api/errors/ for a list of possible errors.
74
+ *
75
+ * @return OmiseError
76
+ */
77
+ public function getOmiseError()
78
+ {
79
+ return $this->_omiseError;
80
+ }
81
  }
82
 
83
+ class OmiseAuthenticationFailureException extends OmiseException { }
84
+ class OmiseNotFoundException extends OmiseException { }
85
+ class OmiseUsedTokenException extends OmiseException { }
86
+ class OmiseInvalidCardException extends OmiseException { }
87
+ class OmiseInvalidCardTokenException extends OmiseException { }
88
+ class OmiseMissingCardException extends OmiseException { }
89
+ class OmiseInvalidChargeException extends OmiseException { }
90
+ class OmiseFailedCaptureException extends OmiseException { }
91
+ class OmiseFailedFraudCheckException extends OmiseException { }
92
+ class OmiseInvalidRecipientException extends OmiseException { }
93
+ class OmiseInvalidBankAccountException extends OmiseException { }
94
+ class OmiseUndefinedException extends OmiseException { }
lib/omise-php/lib/omise/res/OmiseApiResource.php CHANGED
@@ -3,269 +3,314 @@
3
  require_once dirname(__FILE__).'/obj/OmiseObject.php';
4
  require_once dirname(__FILE__).'/../exception/OmiseExceptions.php';
5
 
6
- define('OMISE_PHP_LIB_VERSION', '2.4.0');
7
  define('OMISE_API_URL', 'https://api.omise.co/');
8
  define('OMISE_VAULT_URL', 'https://vault.omise.co/');
9
 
10
- class OmiseApiResource extends OmiseObject {
11
- // Request methods
12
- const REQUEST_GET = 'GET';
13
- const REQUEST_POST = 'POST';
14
- const REQUEST_DELETE = 'DELETE';
15
- const REQUEST_PATCH = 'PATCH';
16
-
17
- // Timeout settings
18
- private $OMISE_CONNECTTIMEOUT = 30;
19
- private $OMISE_TIMEOUT = 60;
20
-
21
- /**
22
- * Returns an instance of the class given in $clazz or raise an error.
23
- * @param string $clazz
24
- * @param string $publickey
25
- * @param string $secretkey
26
- * @throws Exception
27
- * @return OmiseResource
28
- */
29
- protected static function getInstance($clazz, $publickey = null, $secretkey = null) {
30
- if(class_exists($clazz)) {
31
- return new $clazz($publickey, $secretkey);
32
- } else {
33
- throw new Exception('Undefined class.');
 
 
 
 
 
 
34
  }
35
- }
36
-
37
- /**
38
- * Retrieves the resource.
39
- * @param string $clazz
40
- * @param string $publickey
41
- * @param string $secretkey
42
- * @return OmiseAccount|OmiseBalance|OmiseCharge|OmiseCustomer|OmiseToken|OmiseTransaction|OmiseTransfer
43
- * @throws Exception|OmiseException
44
- */
45
- protected static function g_retrieve($clazz, $url, $publickey = null, $secretkey = null) {
46
- $resource = call_user_func(array($clazz, 'getInstance'), $clazz, $publickey, $secretkey);
47
- $result = $resource->execute($url, self::REQUEST_GET, $resource->getResourceKey());
48
- $resource->refresh($result);
49
-
50
- return $resource;
51
- }
52
-
53
- /**
54
- * Creates the resource with given parameters.in an associative array.
55
- * @param string $clazz
56
- * @param string $url
57
- * @param array $params
58
- * @param string $publickey
59
- * @param string $secretkey
60
- * @return OmiseAccount|OmiseBalance|OmiseCharge|OmiseCustomer|OmiseToken|OmiseTransaction|OmiseTransfer
61
- * @throws Exception|OmiseException
62
- */
63
- protected static function g_create($clazz, $url, $params, $publickey = null, $secretkey = null) {
64
- $resource = call_user_func(array($clazz, 'getInstance'), $clazz, $publickey, $secretkey);
65
- $result = $resource->execute($url, self::REQUEST_POST, $resource->getResourceKey(), $params);
66
- $resource->refresh($result);
67
-
68
- return $resource;
69
- }
70
-
71
- /**
72
- * Updates the resource with the given parameters in an associative array.
73
- * @param string $url
74
- * @param array $params
75
- * @throws Exception|OmiseException
76
- */
77
- protected function g_update($url, $params) {
78
- $result = $this->execute($url, self::REQUEST_PATCH, $this->getResourceKey(), $params);
79
- $this->refresh($result);
80
- }
81
-
82
- /**
83
- * Destroys the resource.
84
- * @param string $url
85
- * @return OmiseApiResource
86
- * @throws Exception|OmiseException
87
- */
88
- protected function g_destroy($url) {
89
- $result = $this->execute($url, self::REQUEST_DELETE, $this->getResourceKey());
90
- $this->refresh($result, true);
91
- }
92
-
93
- /**
94
- * Reloads the resource with latest data.
95
- * @param string $url
96
- * @throws Exception|OmiseException
97
- */
98
- protected function g_reload($url) {
99
- $result = $this->execute($url, self::REQUEST_GET, $this->getResourceKey());
100
- $this->refresh($result);
101
- }
102
-
103
- /**
104
- * Makes a request and returns a decoded JSON data as an associative array.
105
- * @param string $url
106
- * @param string $requestMethod
107
- * @param array $params
108
- * @throws OmiseException
109
- * @return array
110
- */
111
- protected function execute($url, $requestMethod, $key, $params = null) {
112
-
113
- // If this class is execute by phpunit > get test mode.
114
- if ($_SERVER['SCRIPT_NAME'] == "./vendor/bin/phpunit") {
115
- $result = $this->_executeTest($url, $requestMethod, $key, $params);
116
- } else {
117
- $result = $this->_executeCurl($url, $requestMethod, $key, $params);
118
- }
119
-
120
- // Decode the JSON response as an associative array.
121
- $array = json_decode($result, true);
122
-
123
- // If response is invalid or not a JSON.
124
- if(count($array) === 0 || !isset($array['object'])) throw new Exception('Unknown error. (Bad Response)');
125
-
126
- // If response is an error object.
127
- if($array['object'] === 'error') throw OmiseException::getInstance($array);
128
-
129
- return $array;
130
- }
131
 
132
- /**
133
- * @param string $url
134
- * @param string $requestMethod
135
- * @param array $params
136
- * @throws OmiseException
137
- * @return string
138
- */
139
- private function _executeCurl($url, $requestMethod, $key, $params = null) {
140
- $ch = curl_init($url);
141
-
142
- curl_setopt_array($ch, $this->genOptions($requestMethod, $key.':', $params));
143
-
144
- // Make a request or thrown an exception.
145
- if(($result = curl_exec($ch)) === false) {
146
- $error = curl_error($ch);
147
- curl_close($ch);
148
-
149
- throw new Exception($error);
150
  }
151
 
152
- // Close.
153
- curl_close($ch);
154
-
155
- return $result;
156
- }
157
-
158
- /**
159
- * @param string $url
160
- * @param string $requestMethod
161
- * @param array $params
162
- * @throws OmiseException
163
- * @return string
164
- */
165
- private function _executeTest($url, $requestMethod, $key, $params = null) {
166
- // Remove Http, Https protocal from $url (string).
167
- $request_url = preg_replace('#^(http|https)://#', '', $url);
168
-
169
- // Remove slash if it had in last letter.
170
- $request_url = rtrim($request_url, '/');
 
 
171
 
172
- // Finally.
173
- $request_url = dirname(__FILE__).'/../../../tests/fixtures/'.$request_url.'-'.strtolower($requestMethod).'.json';
 
 
 
 
 
 
 
 
 
 
 
174
 
175
- // Make a request from Curl if json file was not exists.
176
- if (!file_exists($request_url)) {
 
 
 
 
 
 
 
 
 
 
 
 
177
 
178
- // Get a directory that's file should contain.
179
- $request_dir = explode('/', $request_url);
180
- unset($request_dir[count($request_dir) - 1]);
181
- $request_dir = implode('/', $request_dir);
 
 
 
 
 
 
 
 
182
 
183
- // Create directory if it not exists.
184
- if (!file_exists($request_dir)) {
185
- mkdir($request_dir, 0777, true);
186
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
 
188
- $result = $this->_executeCurl($url, $requestMethod, $key, $params);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
 
190
- $f = fopen($request_url, 'w');
191
- if ($f) {
192
- fwrite($f, $result);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
 
194
- fclose($f);
195
- }
196
- } else { // Or get response from json file.
197
- $result = file_get_contents($request_url);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  }
199
 
200
- return $result;
201
- }
202
-
203
- /**
204
- * Creates an option for php-curl from the given request method and parameters in an associative array.
205
- * @param string $requestMethod
206
- * @param array $params
207
- * @return array
208
- */
209
- private function genOptions($requestMethod, $userpwd, $params) {
210
- $user_agent = "OmisePHP/".OMISE_PHP_LIB_VERSION;
211
- $omise_api_version = defined('OMISE_API_VERSION') ? OMISE_API_VERSION : null;
212
-
213
- $options = array(
214
- // Set the HTTP version to 1.1.
215
- CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
216
- // Set the request method.
217
- CURLOPT_CUSTOMREQUEST => $requestMethod,
218
- // Make php-curl returns the data as string.
219
- CURLOPT_RETURNTRANSFER => true,
220
- // Do not include the header in the output.
221
- CURLOPT_HEADER => false,
222
- // Track the header request string and set the referer on redirect.
223
- CURLINFO_HEADER_OUT => true,
224
- CURLOPT_AUTOREFERER => true,
225
- // Make HTTP error code above 400 an error.
226
- // CURLOPT_FAILONERROR => true,
227
- // Time before the request is aborted.
228
- CURLOPT_TIMEOUT => $this->OMISE_TIMEOUT,
229
- // Time before the request is aborted when attempting to connect.
230
- CURLOPT_CONNECTTIMEOUT => $this->OMISE_CONNECTTIMEOUT,
231
- // Authentication.
232
- CURLOPT_USERPWD => $userpwd,
233
- // CA bundle.
234
- CURLOPT_CAINFO => dirname(__FILE__).'/../../../data/ca_certificates.pem'
235
- );
236
-
237
- // Config Omise API Version
238
- if ($omise_api_version) {
239
- $options += array(CURLOPT_HTTPHEADER => array("Omise-Version: ".$omise_api_version));
240
-
241
- $user_agent .= ' OmiseAPI/'.$omise_api_version;
242
  }
243
 
244
- // Config UserAgent
245
- if (defined('OMISE_USER_AGENT_SUFFIX'))
246
- $options += array(CURLOPT_USERAGENT => $user_agent." ".OMISE_USER_AGENT_SUFFIX);
247
- else
248
- $options += array(CURLOPT_USERAGENT => $user_agent);
249
-
250
- // Also merge POST parameters with the option.
251
- if(count($params) > 0) $options += array(CURLOPT_POSTFIELDS => http_build_query($params));
252
-
253
- return $options;
254
- }
255
-
256
- /**
257
- * Checks whether the resource has been destroyed.
258
- * @return OmiseApiResource
259
- */
260
- protected function isDestroyed() {
261
- return $this['deleted'];
262
- }
263
-
264
- /**
265
- * Returns the secret key.
266
- * @return string
267
- */
268
- protected function getResourceKey() {
269
- return $this->_secretkey;
270
- }
271
  }
3
  require_once dirname(__FILE__).'/obj/OmiseObject.php';
4
  require_once dirname(__FILE__).'/../exception/OmiseExceptions.php';
5
 
6
+ define('OMISE_PHP_LIB_VERSION', '2.6.0');
7
  define('OMISE_API_URL', 'https://api.omise.co/');
8
  define('OMISE_VAULT_URL', 'https://vault.omise.co/');
9
 
10
+ class OmiseApiResource extends OmiseObject
11
+ {
12
+ // Request methods
13
+ const REQUEST_GET = 'GET';
14
+ const REQUEST_POST = 'POST';
15
+ const REQUEST_DELETE = 'DELETE';
16
+ const REQUEST_PATCH = 'PATCH';
17
+
18
+ // Timeout settings
19
+ private $OMISE_CONNECTTIMEOUT = 30;
20
+ private $OMISE_TIMEOUT = 60;
21
+
22
+ /**
23
+ * Returns an instance of the class given in $clazz or raise an error.
24
+ *
25
+ * @param string $clazz
26
+ * @param string $publickey
27
+ * @param string $secretkey
28
+ *
29
+ * @throws Exception
30
+ *
31
+ * @return OmiseResource
32
+ */
33
+ protected static function getInstance($clazz, $publickey = null, $secretkey = null)
34
+ {
35
+ if (class_exists($clazz)) {
36
+ return new $clazz($publickey, $secretkey);
37
+ }
38
+
39
+ throw new Exception('Undefined class.');
40
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
+ /**
43
+ * Retrieves the resource.
44
+ *
45
+ * @param string $clazz
46
+ * @param string $publickey
47
+ * @param string $secretkey
48
+ *
49
+ * @throws Exception|OmiseException
50
+ *
51
+ * @return OmiseAccount|OmiseBalance|OmiseCharge|OmiseCustomer|OmiseToken|OmiseTransaction|OmiseTransfer
52
+ */
53
+ protected static function g_retrieve($clazz, $url, $publickey = null, $secretkey = null)
54
+ {
55
+ $resource = call_user_func(array($clazz, 'getInstance'), $clazz, $publickey, $secretkey);
56
+ $result = $resource->execute($url, self::REQUEST_GET, $resource->getResourceKey());
57
+ $resource->refresh($result);
58
+
59
+ return $resource;
60
  }
61
 
62
+ /**
63
+ * Creates the resource with given parameters.in an associative array.
64
+ *
65
+ * @param string $clazz
66
+ * @param string $url
67
+ * @param array $params
68
+ * @param string $publickey
69
+ * @param string $secretkey
70
+ *
71
+ * @throws Exception|OmiseException
72
+ *
73
+ * @return OmiseAccount|OmiseBalance|OmiseCharge|OmiseCustomer|OmiseToken|OmiseTransaction|OmiseTransfer
74
+ */
75
+ protected static function g_create($clazz, $url, $params, $publickey = null, $secretkey = null)
76
+ {
77
+ $resource = call_user_func(array($clazz, 'getInstance'), $clazz, $publickey, $secretkey);
78
+ $result = $resource->execute($url, self::REQUEST_POST, $resource->getResourceKey(), $params);
79
+ $resource->refresh($result);
80
+
81
+ return $resource;
82
+ }
83
 
84
+ /**
85
+ * Updates the resource with the given parameters in an associative array.
86
+ *
87
+ * @param string $url
88
+ * @param array $params
89
+ *
90
+ * @throws Exception|OmiseException
91
+ */
92
+ protected function g_update($url, $params)
93
+ {
94
+ $result = $this->execute($url, self::REQUEST_PATCH, $this->getResourceKey(), $params);
95
+ $this->refresh($result);
96
+ }
97
 
98
+ /**
99
+ * Destroys the resource.
100
+ *
101
+ * @param string $url
102
+ *
103
+ * @throws Exception|OmiseException
104
+ *
105
+ * @return OmiseApiResource
106
+ */
107
+ protected function g_destroy($url)
108
+ {
109
+ $result = $this->execute($url, self::REQUEST_DELETE, $this->getResourceKey());
110
+ $this->refresh($result, true);
111
+ }
112
 
113
+ /**
114
+ * Reloads the resource with latest data.
115
+ *
116
+ * @param string $url
117
+ *
118
+ * @throws Exception|OmiseException
119
+ */
120
+ protected function g_reload($url)
121
+ {
122
+ $result = $this->execute($url, self::REQUEST_GET, $this->getResourceKey());
123
+ $this->refresh($result);
124
+ }
125
 
126
+ /**
127
+ * Makes a request and returns a decoded JSON data as an associative array.
128
+ *
129
+ * @param string $url
130
+ * @param string $requestMethod
131
+ * @param array $params
132
+ *
133
+ * @throws OmiseException
134
+ *
135
+ * @return array
136
+ */
137
+ protected function execute($url, $requestMethod, $key, $params = null)
138
+ {
139
+ // If this class is execute by phpunit > get test mode.
140
+ if (preg_match('/phpunit/', $_SERVER['SCRIPT_NAME'])) {
141
+ $result = $this->_executeTest($url, $requestMethod, $key, $params);
142
+ } else {
143
+ $result = $this->_executeCurl($url, $requestMethod, $key, $params);
144
+ }
145
+
146
+ // Decode the JSON response as an associative array.
147
+ $array = json_decode($result, true);
148
+
149
+ // If response is invalid or not a JSON.
150
+ if (count($array) === 0 || ! isset($array['object'])) {
151
+ throw new Exception('Unknown error. (Bad Response)');
152
+ }
153
+
154
+ // If response is an error object.
155
+ if ($array['object'] === 'error') {
156
+ throw OmiseException::getInstance($array);
157
+ }
158
+
159
+ return $array;
160
+ }
161
 
162
+ /**
163
+ * @param string $url
164
+ * @param string $requestMethod
165
+ * @param array $params
166
+ *
167
+ * @throws OmiseException
168
+ *
169
+ * @return string
170
+ */
171
+ private function _executeCurl($url, $requestMethod, $key, $params = null)
172
+ {
173
+ $ch = curl_init($url);
174
+
175
+ curl_setopt_array($ch, $this->genOptions($requestMethod, $key.':', $params));
176
+
177
+ // Make a request or thrown an exception.
178
+ if (($result = curl_exec($ch)) === false) {
179
+ $error = curl_error($ch);
180
+ curl_close($ch);
181
+
182
+ throw new Exception($error);
183
+ }
184
+
185
+ // Close.
186
+ curl_close($ch);
187
+
188
+ return $result;
189
+ }
190
 
191
+ /**
192
+ * @param string $url
193
+ * @param string $requestMethod
194
+ * @param array $params
195
+ *
196
+ * @throws OmiseException
197
+ *
198
+ * @return string
199
+ */
200
+ private function _executeTest($url, $requestMethod, $key, $params = null)
201
+ {
202
+ // Remove Http, Https protocal from $url (string).
203
+ $request_url = preg_replace('#^(http|https)://#', '', $url);
204
+
205
+ // Remove slash if it had in last letter.
206
+ $request_url = rtrim($request_url, '/');
207
+
208
+ // Finally.
209
+ $request_url = dirname(__FILE__).'/../../../tests/fixtures/'.$request_url.'-'.strtolower($requestMethod).'.json';
210
+
211
+ // Make a request from Curl if json file was not exists.
212
+ if (! file_exists($request_url)) {
213
+ // Get a directory that's file should contain.
214
+ $request_dir = explode('/', $request_url);
215
+ unset($request_dir[count($request_dir) - 1]);
216
+ $request_dir = implode('/', $request_dir);
217
+
218
+ // Create directory if it not exists.
219
+ if (! file_exists($request_dir)) {
220
+ mkdir($request_dir, 0777, true);
221
+ }
222
+
223
+ $result = $this->_executeCurl($url, $requestMethod, $key, $params);
224
+
225
+ $f = fopen($request_url, 'w');
226
+ if ($f) {
227
+ fwrite($f, $result);
228
+
229
+ fclose($f);
230
+ }
231
+ } else { // Or get response from json file.
232
+ $result = file_get_contents($request_url);
233
+ }
234
+
235
+ return $result;
236
+ }
237
 
238
+ /**
239
+ * Creates an option for php-curl from the given request method and parameters in an associative array.
240
+ *
241
+ * @param string $requestMethod
242
+ * @param array $params
243
+ *
244
+ * @return array
245
+ */
246
+ private function genOptions($requestMethod, $userpwd, $params)
247
+ {
248
+ $user_agent = "OmisePHP/".OMISE_PHP_LIB_VERSION;
249
+ $omise_api_version = defined('OMISE_API_VERSION') ? OMISE_API_VERSION : null;
250
+
251
+ $options = array(
252
+ // Set the HTTP version to 1.1.
253
+ CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
254
+ // Set the request method.
255
+ CURLOPT_CUSTOMREQUEST => $requestMethod,
256
+ // Make php-curl returns the data as string.
257
+ CURLOPT_RETURNTRANSFER => true,
258
+ // Do not include the header in the output.
259
+ CURLOPT_HEADER => false,
260
+ // Track the header request string and set the referer on redirect.
261
+ CURLINFO_HEADER_OUT => true,
262
+ CURLOPT_AUTOREFERER => true,
263
+ // Make HTTP error code above 400 an error.
264
+ // CURLOPT_FAILONERROR => true,
265
+ // Time before the request is aborted.
266
+ CURLOPT_TIMEOUT => $this->OMISE_TIMEOUT,
267
+ // Time before the request is aborted when attempting to connect.
268
+ CURLOPT_CONNECTTIMEOUT => $this->OMISE_CONNECTTIMEOUT,
269
+ // Authentication.
270
+ CURLOPT_USERPWD => $userpwd,
271
+ // CA bundle.
272
+ CURLOPT_CAINFO => dirname(__FILE__).'/../../../data/ca_certificates.pem'
273
+ );
274
+
275
+ // Config Omise API Version
276
+ if ($omise_api_version) {
277
+ $options += array(CURLOPT_HTTPHEADER => array("Omise-Version: ".$omise_api_version));
278
+
279
+ $user_agent .= ' OmiseAPI/'.$omise_api_version;
280
+ }
281
+
282
+ // Config UserAgent
283
+ if (defined('OMISE_USER_AGENT_SUFFIX')) {
284
+ $options += array(CURLOPT_USERAGENT => $user_agent." ".OMISE_USER_AGENT_SUFFIX);
285
+ } else {
286
+ $options += array(CURLOPT_USERAGENT => $user_agent);
287
+ }
288
+
289
+ // Also merge POST parameters with the option.
290
+ if (count($params) > 0) {
291
+ $options += array(CURLOPT_POSTFIELDS => http_build_query($params));
292
+ }
293
+
294
+ return $options;
295
  }
296
 
297
+ /**
298
+ * Checks whether the resource has been destroyed.
299
+ *
300
+ * @return OmiseApiResource
301
+ */
302
+ protected function isDestroyed()
303
+ {
304
+ return $this['deleted'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
  }
306
 
307
+ /**
308
+ * Returns the secret key.
309
+ *
310
+ * @return string
311
+ */
312
+ protected function getResourceKey()
313
+ {
314
+ return $this->_secretkey;
315
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  }
lib/omise-php/lib/omise/res/OmiseVaultResource.php CHANGED
@@ -2,12 +2,15 @@
2
 
3
  require_once dirname(__FILE__).'/OmiseApiResource.php';
4
 
5
- class OmiseVaultResource extends OmiseApiResource {
6
- /**
7
- * Returns the public key.
8
- * @return string
9
- */
10
- protected function getResourceKey() {
11
- return $this->_publickey;
12
- }
 
 
 
13
  }
2
 
3
  require_once dirname(__FILE__).'/OmiseApiResource.php';
4
 
5
+ class OmiseVaultResource extends OmiseApiResource
6
+ {
7
+ /**
8
+ * Returns the public key.
9
+ *
10
+ * @return string
11
+ */
12
+ protected function getResourceKey()
13
+ {
14
+ return $this->_publickey;
15
+ }
16
  }
lib/omise-php/lib/omise/res/obj/OmiseObject.php CHANGED
@@ -1,83 +1,105 @@
1
  <?php
2
 
3
- class OmiseObject implements ArrayAccess, Iterator, Countable {
4
- // Store the attributes of the object.
5
- protected $_values = array();
6
-
7
- // Omise secret et public keys.
8
- protected $_secretkey, $_publickey;
9
-
10
- /**
11
- * Setup the Omise object. If no secret and public are passed the one defined
12
- * in config.php will be used.
13
- * @param string $publickey
14
- * @param string $secretkey
15
- */
16
- protected function __construct($publickey = null, $secretkey = null) {
17
- if($publickey !== null) {
18
- $this->_publickey = $publickey;
19
- } else {
20
- $this->_publickey = OMISE_PUBLIC_KEY;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  }
22
- if($secretkey !== null) {
23
- $this->_secretkey = $secretkey;
24
- } else {
25
- $this->_secretkey = OMISE_SECRET_KEY;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  }
27
 
28
- $this->_values = array();
29
- }
30
-
31
- /**
32
- * Reload the object.
33
- * @param array $values
34
- */
35
- public function refresh($values, $clear = false) {
36
- if($clear) $this->_values = array();
37
-
38
- $this->_values = array_merge($this->_values, $values);
39
- }
40
-
41
- // Override methods of ArrayAccess
42
- public function offsetSet($key, $value) {
43
- $this->_values[$key] = $value;
44
- }
45
-
46
- public function offsetExists($key) {
47
- return isset($this->_values[$key]);
48
- }
49
-
50
- public function offsetUnset($key) {
51
- unset($this->_values[$key]);
52
- }
53
-
54
- public function offsetGet($key) {
55
- return isset($this->_values[$key]) ? $this->_values[$key] : null;
56
- }
57
-
58
- // Override methods of Iterator
59
- public function rewind() {
60
- reset($this->_values);
61
- }
62
-
63
- public function current() {
64
- return current($this->_values);
65
- }
66
-
67
- public function key() {
68
- return key($this->_values);
69
- }
70
-
71
- public function next() {
72
- return next($this->_values);
73
- }
74
-
75
- public function valid() {
76
- return ($this->current() !== false);
77
- }
78
-
79
- // Override methods of Countable
80
- public function count() {
81
- return count($this->_values);
82
- }
83
  }
1
  <?php
2
 
3
+ class OmiseObject implements ArrayAccess, Iterator, Countable
4
+ {
5
+ // Store the attributes of the object.
6
+ protected $_values = array();
7
+
8
+ // Omise secret key.
9
+ protected $_secretkey;
10
+
11
+ // Omise public key.
12
+ protected $_publickey;
13
+
14
+ /**
15
+ * Setup the Omise object. If no secret and public are passed the one defined
16
+ * in config.php will be used.
17
+ *
18
+ * @param string $publickey
19
+ * @param string $secretkey
20
+ */
21
+ protected function __construct($publickey = null, $secretkey = null)
22
+ {
23
+ if ($publickey !== null) {
24
+ $this->_publickey = $publickey;
25
+ } else {
26
+ $this->_publickey = OMISE_PUBLIC_KEY;
27
+ }
28
+
29
+ if ($secretkey !== null) {
30
+ $this->_secretkey = $secretkey;
31
+ } else {
32
+ $this->_secretkey = OMISE_SECRET_KEY;
33
+ }
34
+
35
+ $this->_values = array();
36
  }
37
+
38
+ /**
39
+ * Reload the object.
40
+ *
41
+ * @param array $values
42
+ * @param boolean $clear
43
+ */
44
+ public function refresh($values, $clear = false)
45
+ {
46
+ if ($clear) {
47
+ $this->_values = array();
48
+ }
49
+
50
+ $this->_values = array_merge($this->_values, $values);
51
+ }
52
+
53
+ // Override methods of ArrayAccess
54
+ public function offsetSet($key, $value)
55
+ {
56
+ $this->_values[$key] = $value;
57
+ }
58
+
59
+ public function offsetExists($key)
60
+ {
61
+ return isset($this->_values[$key]);
62
+ }
63
+
64
+ public function offsetUnset($key)
65
+ {
66
+ unset($this->_values[$key]);
67
+ }
68
+
69
+ public function offsetGet($key)
70
+ {
71
+ return isset($this->_values[$key]) ? $this->_values[$key] : null;
72
+ }
73
+
74
+ // Override methods of Iterator
75
+ public function rewind()
76
+ {
77
+ reset($this->_values);
78
+ }
79
+
80
+ public function current()
81
+ {
82
+ return current($this->_values);
83
+ }
84
+
85
+ public function key()
86
+ {
87
+ return key($this->_values);
88
  }
89
 
90
+ public function next()
91
+ {
92
+ return next($this->_values);
93
+ }
94
+
95
+ public function valid()
96
+ {
97
+ return ($this->current() !== false);
98
+ }
99
+
100
+ // Override methods of Countable
101
+ public function count()
102
+ {
103
+ return count($this->_values);
104
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  }
package.xml CHANGED
@@ -1,49 +1,63 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Omise_Gateway</name>
4
- <version>1.9.0.6</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Start accepting Omise Payment Gateway with your magento store now.</summary>
10
- <description>Start accepting omise payment gateway with your magento store now. Omise is a Payment Gateway in Thailand. This extension integrate omise api.&#xD;
11
- &#xD;
12
- &lt;h1&gt;Features&lt;/h1&gt;&#xD;
13
- 1. Support for all major international debit and credit cards - Visa, Mastercard.&#xD;
14
- &#xD;
15
- 2. Build-in Omise configuration in Magento admin system for predefining Omise API Key.&#xD;
16
- &#xD;
17
- 3. Provide Omise option in checkout process.&#xD;
18
- &#xD;
19
- 4. Show briefly Omise payment information.&#xD;
20
- &#xD;
21
- 5. Integrate Omise refund with Magento refund system.&#xD;
22
- &#xD;
23
- 7. Omise dashbord show the lastest transaction.&#xD;
24
- &#xD;
25
- 8. Allow sending transfer request from omise account to bank account.</description>
26
- <notes>_last updated: Aug 11, 2016_&#xD;
27
- &#xD;
28
- ## Objective&#xD;
29
- &#xD;
30
- #### 1. MAKE PLUGIN WORKS WELL WITH MAGENTO'S TEMPLATE (ENHANCEMENT) (PR #24)&#xD;
31
- For the previous, some users could't use Omise's checkout form because their theme/template doesn't include/import jQuery library to the project at the initial step that our plugin required. (they always got "Need Omise's key" error when try to checkout the order)&#xD;
32
- &#xD;
33
- This enhancement's providing a solution to detach the 3rd-party library out from the project to make those templates work.&#xD;
34
- &#xD;
35
- ## Tested on&#xD;
36
- &#xD;
37
- **PHP 5.6.21**&#xD;
38
- &#xD;
39
- **Magento (community edition) 1.9.2.4**&#xD;
40
- &#xD;
41
- ---&#xD;
42
- See [CHANGELOG.md](https://github.com/omise/omise-magento/blob/master/CHANGELOG.md#1906-2016-08-10) for more information.</notes>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  <authors><author><name>Omise</name><user>omise</user><email>apps@omise.co</email></author></authors>
44
- <date>2016-08-21</date>
45
- <time>18:34:28</time>
46
- <contents><target name="magecommunity"><dir name="Omise"><dir name="Gateway"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><dir name="Edit"><file name="Form.php" hash="054202ddf6a68ca939a91e83f11c69a5"/></dir><file name="Edit.php" hash="2809bd01cafdae402b4e13cb4ad65634"/></dir><dir name="Dashboard"><file name="Dashboard.php" hash="3576b49045c637c0f5945f0c9efa8a77"/></dir></dir><dir name="Form"><file name="Cc.php" hash="732fc793c78406cae18607fcbfa853b6"/></dir></dir><dir name="Helper"><file name="Data.php" hash="452185cad964f13ea481c9d6bced22b1"/></dir><dir name="Model"><dir name="Config"><dir name="Var"><file name="Currency.php" hash="9f2f2e2e0a6e8afe4035cf86cc5df109"/><file name="Paymentaction.php" hash="a1337a3e869c8b563d434b1b691b5d53"/></dir></dir><file name="Config.php" hash="50be3ce038026a6554cf87af96ed3ab9"/><file name="Omise.php" hash="0a20c97a63506843aa7b8c6add18db8f"/><file name="OmiseAccount.php" hash="d4de8e3237a4b8c906035eb00d4ec591"/><file name="OmiseBalance.php" hash="b2f03f29d2682a1b8a01be8358f2a7fc"/><file name="OmiseCharge.php" hash="19c077d6ab0f58e4636318ef1e2ef581"/><file name="OmiseTransfer.php" hash="3e03c0b51419ffe73d29b16a1119afcb"/><file name="PaymentMethod.php" hash="440043c5cd2851dddf815f9b6f97bb5a"/><dir name="Resource"><file name="Config.php" hash="4e7f6d668ef0e61b6b9dfb67ea943d3d"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="OmiseController.php" hash="d76592c3f3cb70c11317191aaecf9fca"/></dir></dir><dir name="data"><dir name="omise_gateway_setup"><file name="data-install-0.0.0.1.php" hash="28ffdd99157244db56f444ee2fd4fffb"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="6904e384ede6b5e4ba3203d748e9d802"/><file name="config.xml" hash="4a9fa71473a353a22a2fa5d43b32342d"/><file name="system.xml" hash="34cfa722e906fcfbbfeef5e45727da08"/></dir><dir name="sql"><dir name="omise_gateway_setup"><file name="install-0.0.0.1.php" hash="413280bc428e285a4ee29200668bcf96"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Omise_Gateway.xml" hash="6d354708ee537b9bd833e0916135e6bf"/></dir></target><target name="magelib"><dir name="omise-php"><file name="CHANGELOG.md" hash="1a62ce220b573dff8638721090bb60b6"/><file name="LICENSE" hash="4b764c86995cbfed1e733d4e1b28edc1"/><file name="README.md" hash="791f37d5a23d012a83d412f3b558574c"/><file name="circle.yml" hash="fd592afc9207e55436bc6a50d226f5cd"/><file name="composer.json" hash="bfbc905757e707cd906f500b8a75752f"/><dir name="data"><file name="ca_certificates.pem" hash="e2c6e1ebee2ffc481d3be02aaf12c46c"/></dir><dir name="lib"><file name="Omise.php" hash="fcc47369f482d3b32bd8b5d180e51977"/><dir name="omise"><file name="OmiseAccount.php" hash="4ace83cd415ca6fd79f1bc6ab228edbc"/><file name="OmiseBalance.php" hash="f3e3ebdd3e44d62bc5495c445663b3e3"/><file name="OmiseCard.php" hash="51978bfca8b983ca9acfe474007779c2"/><file name="OmiseCardList.php" hash="8b6aefa9cc128af0763e83852614f3a2"/><file name="OmiseCharge.php" hash="4c448bb8d7ddc57405896ab924526b47"/><file name="OmiseCustomer.php" hash="f824255b8bd48b17432428f5166d6f86"/><file name="OmiseDispute.php" hash="64e936274241550cb95c0ee3011856ab"/><file name="OmiseRecipient.php" hash="60240921485d59071ac3da516b698bef"/><file name="OmiseRefund.php" hash="c117d970052cd477c50f12b0c655c489"/><file name="OmiseRefundList.php" hash="6e5fcb11b14b95d7af3dfeaf84a7faa4"/><file name="OmiseTest.php" hash="13446fbdd16b279a72b00c54504a8737"/><file name="OmiseToken.php" hash="1f3afeff7989118be61676c42e71a7a9"/><file name="OmiseTransaction.php" hash="4c2667aa507feba21c4a2411127e5ff7"/><file name="OmiseTransfer.php" hash="c1cf4132509c35fe043ca09183a91781"/><dir name="exception"><file name="OmiseExceptions.php" hash="88cc98f46392a3803e0cb3d36ef3fd58"/></dir><dir name="res"><file name="OmiseApiResource.php" hash="b95cece57fd215429af2334bcb17f8e7"/><file name="OmiseVaultResource.php" hash="c581b12a6ee35ce3d296377b654534d8"/><dir name="obj"><file name="OmiseObject.php" hash="818880c775de17b1187cae8f1220ed34"/></dir></dir></dir></dir><file name="phpunit.xml" hash="10b1894c6e40b45e1166876607894599"/><dir name="tests"><dir name="fixtures"><dir name="api.omise.co"><file name="account-get.json" hash="dd0af5ba4e83c37dce0f528ae55265e1"/><file name="balance-get.json" hash="2411326d435dac7e322982809ad2f0a6"/><dir name="charges"><dir name="chrg_test_4zmrjgxdh4ycj2qncoj"><file name="capture-post.json" hash="2e2f1d5f84978a706c4861fd5fa32bf2"/><dir name="refunds"><file name="rfnd_test_4zmrjhlbqy587sw6fwt-get.json" hash="63abc2d0c623f9fd9b861fed39491250"/></dir><file name="refunds-get.json" hash="724c40cf4fe34aa5646b34a8291e98d7"/><file name="refunds-post.json" hash="63abc2d0c623f9fd9b861fed39491250"/></dir><file name="chrg_test_4zmrjgxdh4ycj2qncoj-get.json" hash="a2cf3a2e9a9e98e5df2b3cce956eeb9b"/><file name="chrg_test_4zmrjgxdh4ycj2qncoj-patch.json" hash="7a17e253ee103c65e630b9f12a02a0cf"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name="charges-get.json" hash="8de2a2546605ddd0463adb693b789fc4"/><file name="charges-post.json" hash="5b42f42b3d37ed1f2985cb87ed6b4c91"/><dir name="customers"><dir name="cust_test_4zmrjg2hct06ybwobqc"><dir name="cards"><file name="card_test_4zmrjfzf0spz3mh63cs-delete.json" hash="7e2355759cb45b39648e47b66d674e82"/><file name="card_test_4zmrjfzf0spz3mh63cs-get.json" hash="93db2746e1ab36922c53a5a46df49313"/><file name="card_test_4zmrjfzf0spz3mh63cs-patch.json" hash="658fe2f9d32e06ed9690c711907c35ea"/></dir></dir><file name="cust_test_4zmrjg2hct06ybwobqc-delete.json" hash="39393c074fbfc549d54a4462d0418ae2"/><file name="cust_test_4zmrjg2hct06ybwobqc-get.json" hash="2359ed7cac6f06e7ab2134b78f0a80c0"/><file name="cust_test_4zmrjg2hct06ybwobqc-patch.json" hash="c9f43bc5d6abda836af2219b89d37322"/></dir><file name="customers-get.json" hash="94004c38dc91a85508111b8aa5f6f4db"/><file name="customers-post.json" hash="9ab098c4d510a2eb19e54619bae1ac5f"/><dir name="disputes"><file name="closed-get.json" hash="3b42074f4c51022cb697043d3c269476"/><file name="dspt_test_4zgf15h89w8t775kcm8-get.json" hash="74c867b793f5c44c202d34e15b43545c"/><file name="dspt_test_4zgf15h89w8t775kcm8-patch.json" hash="4a0a57988efa7b5b2906108e27172afd"/><file name="open-get.json" hash="d594c8a57bc478840ef257a7c0a4d247"/><file name="pending-get.json" hash="c4df6e0b877658489e0dcf521104dbca"/></dir><file name="disputes-get.json" hash="a41dae7bc2453230e63028fbb012d6af"/><dir name="recipients"><file name="recp_test_508a9dytz793gxv9m77-delete.json" hash="8f2911b4009127be4fae4c74ea7807dc"/><file name="recp_test_508a9dytz793gxv9m77-get.json" hash="c2b6e427c63e74feb4805da8fc64b1aa"/><file name="recp_test_508a9dytz793gxv9m77-patch.json" hash="d2a8fdd18d6989b472297fcb01529670"/></dir><file name="recipients-get.json" hash="e932beb18693f23bce525d2b8ff80104"/><file name="recipients-post.json" hash="c2b6e427c63e74feb4805da8fc64b1aa"/><dir name="transactions"><file name="trxn_test_4zmrjhlflnz6id6q0bo-get.json" hash="07eec8be08692f87f43a9c20b37f9be4"/></dir><file name="transactions-get.json" hash="4046a654d53076e4c11439fe560820fc"/><dir name="transfers"><file name="trsf_test_4zmrjicrvw7j6uhv1l4-delete.json" hash="c33d94ae8855086a6347f231401f7d62"/><file name="trsf_test_4zmrjicrvw7j6uhv1l4-get.json" hash="324d71559ca7f3a57181ba94d8b35d10"/><file name="trsf_test_4zmrjicrvw7j6uhv1l4-patch.json" hash="14eb0ad78c28df8ee1adc2447ad5568a"/></dir><file name="transfers-get.json" hash="4661e19d530501a9bd82a8272f7f35ef"/><file name="transfers-post.json" hash="324d71559ca7f3a57181ba94d8b35d10"/></dir><dir name="vault.omise.co"><dir name="tokens"><file name="tokn_test_4zmrjhuk2rndz24a6x0-get.json" hash="bed4f9d84db36bc8ee2394d46e098299"/></dir><file name="tokens-post.json" hash="bed4f9d84db36bc8ee2394d46e098299"/></dir></dir><dir name="omise"><file name="AccountTest.php" hash="2b31cc6ec17a55849c8545fe95c62285"/><file name="BalanceTest.php" hash="e6754c58230c754dd5dbd6d181d0463f"/><file name="CardTest.php" hash="579bd6674eec60869f03d503dcac546f"/><file name="ChargeTest.php" hash="4ffa6412c4061e9ccaa0163685908c33"/><file name="CustomerTest.php" hash="77fe9af1773a27517ba7ba6999c52f78"/><file name="DisputeTest.php" hash="e28bf8dbd3f65b4005feaf54eba7a1bb"/><file name="RecipientTest.php" hash="622056f6ab1cc07e660a0e728e6aaba0"/><file name="RefundTest.php" hash="2476fee14d25e739594e2a4418fc35df"/><file name="TestConfig.php" hash="0582a4d154688d30e247d14584f5189c"/><file name="TokenTest.php" hash="2ae61745b127c9545218b98e69f7efdd"/><file name="TransactionTest.php" hash="73b76cae43f3f439852d8565ab36a343"/><file name="TransferTest.php" hash="c32dd0a74d83f2fc26a5da347870f8f6"/><dir name="exception"><file name="OmiseExceptionTest.php" hash="6935decc4d1cc6758d773139e4529a9e"/></dir><dir name="res"><dir name="obj"><file name="OmiseObjectTest.php" hash="8c9e04bd9d6afb303827bc5f5d1afec2"/></dir></dir><file name="testall.sh" hash="4821c00f7473e7abffba790d91420c8a"/></dir></dir><file name=".gitignore" hash="04c5ce480da5e27bb9a1c2da304bbbca"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="omise"><file name="dashboard.phtml" hash="cc719fbf45e1639d97f573c786103d75"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="payment"><dir name="form"><file name="omisecc.phtml" hash="e65ce4f060e83204e37760e4ca813d57"/></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="omise"><file name="omise-admin.css" hash="6a293ba8afa28789c349baa5e2fe1e18"/></dir></dir></dir></dir></target></contents>
47
  <compatible/>
48
- <dependencies><required><php><min>5.4.0</min><max>5.6.25</max></php></required></dependencies>
49
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Omise_Gateway</name>
4
+ <version>1.8.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/mit-license.php">MIT License</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Omise is the official payment extension which provides support for Omise payment gateway for store builders.</summary>
10
+ <description>Solidifying your checkout experience can really be hassle-free. The Omise payment extension comes complete with powerful payment features that allows you to easily and securely accept credit/debit card payments on your store.&lt;br/&gt;&#xD;
11
+ &lt;br/&gt;&#xD;
12
+ For the service pricing, &lt;strong&gt;we charge 3.65% per transaction. In other words, We only charge you when you make money. There is no minimum monthly volume nor minimum fee. You can start and stop using us anytime you want at no charge. However, a 7% Vat is applied on top of Omise fee.&lt;/strong&gt;&lt;br/&gt;&#xD;
13
+ Further information, please check &lt;a href="https://www.omise.co/pricing"&gt;https://www.omise.co/pricing&lt;/a&gt;&lt;br/&gt;&#xD;
14
+ &#xD;
15
+ &lt;h3&gt;Accepting payments&lt;/h3&gt;&#xD;
16
+ &#xD;
17
+ Omise payment platform is built with the whole customer experience in mind. The service is white-labeled, meaning that your customers never get redirected offsite when making payments, and you never lose sales because of drop-offs.&lt;br/&gt;&#xD;
18
+ &lt;br/&gt;&#xD;
19
+ We also provide a JavaScript library, Omise.js which is a ready-built checkout form that is carefully designed and refined to reduce shopping friction for your customers.&lt;br/&gt;&#xD;
20
+ &#xD;
21
+ &lt;h3&gt;The Infrastructure&lt;/h3&gt;&#xD;
22
+ &#xD;
23
+ The platform is architected for the highest levels of reliability and scale with 99.99% availability. Our current transaction throughput benchmark is at 100 million transactions per day &#x2014; which means congestion free for peak processing times.&lt;br/&gt;&#xD;
24
+ &lt;br/&gt;&#xD;
25
+ We don't rely on third-party payment providers to deliver domestic payments, thereby eliminating an additional point of failure while at the same time improving the customer experience.&lt;br/&gt;&#xD;
26
+ &#xD;
27
+ &lt;h3&gt;Security&lt;/h3&gt;&#xD;
28
+ &#xD;
29
+ Omise reduces your PCI scope by providing a JavaScript library which directly sends sensitive card information from your customer's browser to Omise's servers. This means that the transaction is routed through our servers, while your customer gets to complete the payments on your site.&lt;br/&gt;&#xD;
30
+ &lt;br/&gt;&#xD;
31
+ - PCI DSS 3.2 compliance&lt;br/&gt;&#xD;
32
+ - Tokenization&lt;br/&gt;&#xD;
33
+ - HTTPS/TLS&lt;br/&gt;&#xD;
34
+ - 24/7 Monitoring&lt;br/&gt;&#xD;
35
+ &#xD;
36
+ &lt;h3&gt;Reporting&lt;/h3&gt;&#xD;
37
+ &#xD;
38
+ When integrating Omise, you are provided with a dashboard which displays realtime data visualisation of your account's balances. Here, you can expect to find your balances, history of transfers, and list of any refunds/disputes you have.&lt;br/&gt;&#xD;
39
+ Transaction data can be exported in CSV format.&lt;br/&gt;&#xD;
40
+ &lt;br/&gt;&#xD;
41
+ There's also advance search which helps narrow down your search to specific dates, charges or filter transactions from specific time periods.&lt;br/&gt;&#xD;
42
+ *The Dashboard App is coming soon.&#xD;
43
+ &#xD;
44
+ &lt;h3&gt;User Guides&lt;/h3&gt;&#xD;
45
+ &#xD;
46
+ Please check the following link to see "Installation Instruction" &amp; "User Guides"&lt;br/&gt;&#xD;
47
+ &lt;a href="http://omise.co/magento-plugin"&gt;http://omise.co/magento-plugin&lt;/a&gt;</description>
48
+ <notes>&lt;h3&gt;Highlights&lt;/h3&gt;&#xD;
49
+ - Introduce 3-D Secure feature!&lt;br/&gt;&#xD;
50
+ - Introduce Internet Banking feature!&lt;br/&gt;&#xD;
51
+ - Support JPY, IDR and SGD currencies.&lt;br/&gt;&#xD;
52
+ &#xD;
53
+ &lt;h3&gt;Enhancements&lt;/h3&gt;&#xD;
54
+ - Refactor the PaymentMethod class for the extensibility, polymorphism and reduce code complexity that usually, will keep maintain in only one file (Omise_Gateway_Model_PaymentMethod).&lt;br/&gt;&#xD;
55
+ - Import squizlabs/php_codesniffer package to the project.&lt;br/&gt;&#xD;
56
+ - Code styling.&lt;br/&gt;</notes>
57
  <authors><author><name>Omise</name><user>omise</user><email>apps@omise.co</email></author></authors>
58
+ <date>2017-03-07</date>
59
+ <time>09:01:04</time>
60
+ <contents><target name="magecommunity"><dir name="Omise"><dir name="Gateway"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><dir name="Edit"><file name="Form.php" hash="35295e47578bfd3b034bfe6c36c8a4cc"/></dir><file name="Edit.php" hash="84fdd93ef432aba685bcac6cdb9bbe49"/></dir><dir name="Dashboard"><file name="Dashboard.php" hash="993c3d2c63d3b2a6c64940a09042155b"/></dir><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Payment.php" hash="c5c162c6c4d58bd8b479445097ae2299"/></dir></dir></dir></dir><dir name="Form"><file name="Cc.php" hash="9ece8b02993c3e9a84a5cfafe0150438"/><file name="OffsiteInternetBankingPayment.php" hash="cb1c9d4c71252c69629a7cfbe83c2537"/></dir></dir><dir name="Helper"><file name="Data.php" hash="5c586a7cd4c9ac106cceda2fbd758145"/></dir><dir name="Model"><dir name="Config"><dir name="Var"><file name="Currency.php" hash="9f2f2e2e0a6e8afe4035cf86cc5df109"/><file name="Paymentaction.php" hash="2606f24f33aaae56b780e67011711b99"/></dir></dir><file name="Config.php" hash="328cae40a1233e412d3386be9bcf3ce2"/><file name="OffsiteInternetBankingPayment.php" hash="4c1d061eb4e2cb17ceeb5213d5edb01c"/><file name="Omise.php" hash="3a8bd3d669d229dfcdc624ccf6f5adac"/><file name="OmiseAccount.php" hash="f716dcd2ece38c0381a61c1ff5f1151b"/><file name="OmiseBalance.php" hash="c2ab02f0a72423d4c5bec5df62459477"/><file name="OmiseCharge.php" hash="1fa0ff4a69881f9b67f353af017b76d4"/><file name="OmiseTransfer.php" hash="5d1f80b32ee835629977c483cee53330"/><file name="Payment.php" hash="68d2c07bebe659a841a010d9ead2f411"/><file name="PaymentMethod.php" hash="580295e13553d8eac13d0ee45fb02665"/><dir name="Resource"><file name="Config.php" hash="940c4e25613da01ce6c419c9a69f9577"/></dir><dir name="Strategies"><file name="AuthorizeStrategy.php" hash="fa143b7e10a88846263e8c4098618593"/><file name="AuthorizeThreeDSecureStrategy.php" hash="8c588b44729843b1dc8d3653a189a232"/><file name="CaptureStrategy.php" hash="d7dc0a76f52de532231273070888ac06"/><file name="CaptureThreeDSecureStrategy.php" hash="6abb4dc786965b09a8f460861311cd22"/><file name="ManualCaptureStrategy.php" hash="070b050bd18474d2164b5c36bfd5f81b"/><file name="OffsiteInternetBankingStrategy.php" hash="81dec322da649bad78f64b53d0bd9232"/><file name="StrategyAbstract.php" hash="1fa0a02d32d013da0f19ee286f78b423"/><file name="StrategyInterface.php" hash="b6efc25d7cfe232cd5b597ed6dfdd4cf"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="OmiseController.php" hash="12e10c8f1b72437b5bea2a24df9ecab5"/></dir><dir name="Callback"><file name="ValidateOffsiteInternetBankingController.php" hash="263aa4054e46c41b1eb7c771bdf78ee4"/><file name="ValidateThreeDSecureController.php" hash="328e6ca6adbae177b00c4dc0208fe221"/></dir></dir><dir name="data"><dir name="omise_gateway_setup"><file name="data-install-0.0.0.1.php" hash="ace699435b757bc10c2f19a5e9555dab"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="6904e384ede6b5e4ba3203d748e9d802"/><file name="config.xml" hash="58b600ffb218b1928549a9f418f7c0af"/><file name="system.xml" hash="06f2006db585e032bcf626f7e172f629"/></dir><dir name="sql"><dir name="omise_gateway_setup"><file name="install-0.0.0.1.php" hash="93f7f4a16be87ef83a84215c72e667a1"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Omise_Gateway.xml" hash="6d354708ee537b9bd833e0916135e6bf"/></dir></target><target name="magelib"><dir name="omise-php"><file name="CHANGELOG.md" hash="af2d75bd1b753a93f3e3b3b063955626"/><file name="LICENSE" hash="4b764c86995cbfed1e733d4e1b28edc1"/><file name="README.md" hash="3d89f55c740c0db6f3ce8ae420b73bfd"/><file name="circle.yml" hash="fd592afc9207e55436bc6a50d226f5cd"/><file name="composer.json" hash="bfbc905757e707cd906f500b8a75752f"/><dir name="data"><file name="ca_certificates.pem" hash="e2c6e1ebee2ffc481d3be02aaf12c46c"/></dir><dir name="lib"><file name="Omise.php" hash="0dd224bf0853d3c99a3cbcd4ceabdcce"/><dir name="omise"><file name="OmiseAccount.php" hash="a6f6065fa76ef7558bc9133ad42202b2"/><file name="OmiseBalance.php" hash="fe3c179b7b07aebe49216ce91fe5f941"/><file name="OmiseCard.php" hash="852846c4427d826011bb609d420134ca"/><file name="OmiseCardList.php" hash="4c065f866feb0fa1f469f4348595bb45"/><file name="OmiseCharge.php" hash="7e71211c81553de18bd9052fc73b680b"/><file name="OmiseCustomer.php" hash="4ca950703e6637de1d9cd7fde744c3a7"/><file name="OmiseDispute.php" hash="5828d42b8ea897d1e38a499979d6d68d"/><file name="OmiseEvent.php" hash="5a9ca900edb659178c4daf336b258c09"/><file name="OmiseLink.php" hash="6a0e55db8c00632eff2f3cefeb5b937b"/><file name="OmiseRecipient.php" hash="8563eb9f56716f19ef8bd86c0c0669a2"/><file name="OmiseRefund.php" hash="2188a91cdc0b8fe65b1eff49bf787935"/><file name="OmiseRefundList.php" hash="47a8b2ac14867921b394f31fe283bf11"/><file name="OmiseTest.php" hash="2c3f9a6aa6e8d074e2c3b62fdef9193b"/><file name="OmiseToken.php" hash="3d47a1fb374a783aa23d913f33a35554"/><file name="OmiseTransaction.php" hash="5913fa5e050ec79b36c95a70eb878579"/><file name="OmiseTransfer.php" hash="370d34418761adb3664b66105a2e78b0"/><dir name="exception"><file name="OmiseExceptions.php" hash="cdfb3256ceda24c0aabe0e4dedfbe3ee"/></dir><dir name="res"><file name="OmiseApiResource.php" hash="fe4664e814f1e9d9d8c4a13a19c2fcd3"/><file name="OmiseVaultResource.php" hash="989cde47ba91688e1c48e9826e7b559f"/><dir name="obj"><file name="OmiseObject.php" hash="bc1cc21f51d557f8c2640696699e3556"/></dir></dir></dir></dir><file name="phpunit.xml" hash="10b1894c6e40b45e1166876607894599"/><dir name="tests"><dir name="fixtures"><dir name="api.omise.co"><file name="account-get.json" hash="dd0af5ba4e83c37dce0f528ae55265e1"/><file name="balance-get.json" hash="2411326d435dac7e322982809ad2f0a6"/><dir name="charges"><dir name="chrg_test_4zmrjgxdh4ycj2qncoj"><file name="capture-post.json" hash="2e2f1d5f84978a706c4861fd5fa32bf2"/><dir name="refunds"><file name="rfnd_test_4zmrjhlbqy587sw6fwt-get.json" hash="63abc2d0c623f9fd9b861fed39491250"/></dir><file name="refunds-get.json" hash="724c40cf4fe34aa5646b34a8291e98d7"/><file name="refunds-post.json" hash="63abc2d0c623f9fd9b861fed39491250"/></dir><file name="chrg_test_4zmrjgxdh4ycj2qncoj-get.json" hash="a2cf3a2e9a9e98e5df2b3cce956eeb9b"/><file name="chrg_test_4zmrjgxdh4ycj2qncoj-patch.json" hash="7a17e253ee103c65e630b9f12a02a0cf"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><file name="charges-get.json" hash="8de2a2546605ddd0463adb693b789fc4"/><file name="charges-post.json" hash="5b42f42b3d37ed1f2985cb87ed6b4c91"/><dir name="customers"><dir name="cust_test_4zmrjg2hct06ybwobqc"><dir name="cards"><file name="card_test_4zmrjfzf0spz3mh63cs-delete.json" hash="7e2355759cb45b39648e47b66d674e82"/><file name="card_test_4zmrjfzf0spz3mh63cs-get.json" hash="93db2746e1ab36922c53a5a46df49313"/><file name="card_test_4zmrjfzf0spz3mh63cs-patch.json" hash="658fe2f9d32e06ed9690c711907c35ea"/></dir></dir><file name="cust_test_4zmrjg2hct06ybwobqc-delete.json" hash="39393c074fbfc549d54a4462d0418ae2"/><file name="cust_test_4zmrjg2hct06ybwobqc-get.json" hash="2359ed7cac6f06e7ab2134b78f0a80c0"/><file name="cust_test_4zmrjg2hct06ybwobqc-patch.json" hash="c9f43bc5d6abda836af2219b89d37322"/></dir><file name="customers-get.json" hash="94004c38dc91a85508111b8aa5f6f4db"/><file name="customers-post.json" hash="9ab098c4d510a2eb19e54619bae1ac5f"/><dir name="disputes"><file name="closed-get.json" hash="3b42074f4c51022cb697043d3c269476"/><file name="dspt_test_4zgf15h89w8t775kcm8-get.json" hash="74c867b793f5c44c202d34e15b43545c"/><file name="dspt_test_4zgf15h89w8t775kcm8-patch.json" hash="4a0a57988efa7b5b2906108e27172afd"/><file name="open-get.json" hash="d594c8a57bc478840ef257a7c0a4d247"/><file name="pending-get.json" hash="c4df6e0b877658489e0dcf521104dbca"/></dir><file name="disputes-get.json" hash="a41dae7bc2453230e63028fbb012d6af"/><dir name="recipients"><file name="recp_test_508a9dytz793gxv9m77-delete.json" hash="8f2911b4009127be4fae4c74ea7807dc"/><file name="recp_test_508a9dytz793gxv9m77-get.json" hash="c2b6e427c63e74feb4805da8fc64b1aa"/><file name="recp_test_508a9dytz793gxv9m77-patch.json" hash="d2a8fdd18d6989b472297fcb01529670"/></dir><file name="recipients-get.json" hash="e932beb18693f23bce525d2b8ff80104"/><file name="recipients-post.json" hash="c2b6e427c63e74feb4805da8fc64b1aa"/><dir name="transactions"><file name="trxn_test_4zmrjhlflnz6id6q0bo-get.json" hash="07eec8be08692f87f43a9c20b37f9be4"/></dir><file name="transactions-get.json" hash="4046a654d53076e4c11439fe560820fc"/><dir name="transfers"><file name="trsf_test_4zmrjicrvw7j6uhv1l4-delete.json" hash="c33d94ae8855086a6347f231401f7d62"/><file name="trsf_test_4zmrjicrvw7j6uhv1l4-get.json" hash="324d71559ca7f3a57181ba94d8b35d10"/><file name="trsf_test_4zmrjicrvw7j6uhv1l4-patch.json" hash="14eb0ad78c28df8ee1adc2447ad5568a"/></dir><file name="transfers-get.json" hash="4661e19d530501a9bd82a8272f7f35ef"/><file name="transfers-post.json" hash="324d71559ca7f3a57181ba94d8b35d10"/></dir><dir name="vault.omise.co"><dir name="tokens"><file name="tokn_test_4zmrjhuk2rndz24a6x0-get.json" hash="bed4f9d84db36bc8ee2394d46e098299"/></dir><file name="tokens-post.json" hash="bed4f9d84db36bc8ee2394d46e098299"/></dir></dir><dir name="omise"><file name="AccountTest.php" hash="2b31cc6ec17a55849c8545fe95c62285"/><file name="BalanceTest.php" hash="e6754c58230c754dd5dbd6d181d0463f"/><file name="CardTest.php" hash="579bd6674eec60869f03d503dcac546f"/><file name="ChargeTest.php" hash="4ffa6412c4061e9ccaa0163685908c33"/><file name="CustomerTest.php" hash="77fe9af1773a27517ba7ba6999c52f78"/><file name="DisputeTest.php" hash="e28bf8dbd3f65b4005feaf54eba7a1bb"/><file name="RecipientTest.php" hash="622056f6ab1cc07e660a0e728e6aaba0"/><file name="RefundTest.php" hash="2476fee14d25e739594e2a4418fc35df"/><file name="TestConfig.php" hash="0582a4d154688d30e247d14584f5189c"/><file name="TokenTest.php" hash="2ae61745b127c9545218b98e69f7efdd"/><file name="TransactionTest.php" hash="73b76cae43f3f439852d8565ab36a343"/><file name="TransferTest.php" hash="c32dd0a74d83f2fc26a5da347870f8f6"/><dir name="exception"><file name="OmiseExceptionTest.php" hash="6935decc4d1cc6758d773139e4529a9e"/></dir><dir name="res"><dir name="obj"><file name="OmiseObjectTest.php" hash="8c9e04bd9d6afb303827bc5f5d1afec2"/></dir></dir><file name="testall.sh" hash="4821c00f7473e7abffba790d91420c8a"/></dir></dir><file name=".gitignore" hash="04c5ce480da5e27bb9a1c2da304bbbca"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="omise"><file name="dashboard.phtml" hash="857dcf59e34e484b1e0db3cb49beef7b"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="payment"><dir name="form"><file name="omisecc.phtml" hash="e65ce4f060e83204e37760e4ca813d57"/><file name="omiseoffsiteinternetbankingpayment.phtml" hash="850380c1b5a0e6647abde75aa1613727"/><file name="omise-inapplicable-method.phtml" hash="f829e89be8470f340300c6d0227ddec2"/></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="omise"><file name="omise-admin.css" hash="6a293ba8afa28789c349baa5e2fe1e18"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="omise"><dir name="css"><file name="offsiteinternetbankingpayment.css" hash="2f9407e493c2a769d960e03c2f63ea16"/></dir><dir name="images"><file name="bay.svg" hash="78f135040300d87f34f070141712ea39"/><file name="bbl.svg" hash="23ef91aab184f73cb0fd340d33ec78ba"/><file name="ktb.svg" hash="bccf1cdf5d4383f6403afe26111d47b6"/><file name="scb.svg" hash="341040cf1820811793b30928623cc43f"/></dir></dir></dir></dir></dir></target></contents>
61
  <compatible/>
62
+ <dependencies><required><php><min>5.4.0</min><max>7.1.1</max></php></required></dependencies>
63
  </package>
skin/frontend/base/default/omise/css/offsiteinternetbankingpayment.css ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #payment_form_omise_offsite_internet_banking { }
2
+ #payment_form_omise_offsite_internet_banking > li {
3
+ border-bottom: 1px solid #eee;
4
+ padding: 4px 0 12px;
5
+ position: relative;
6
+ }
7
+
8
+ #payment_form_omise_offsite_internet_banking > li > input {
9
+ position: absolute;
10
+ top: 18px;
11
+ left: 14px;
12
+ }
13
+
14
+ #payment_form_omise_offsite_internet_banking > li > label {
15
+ width: 100%;
16
+ margin-left: 36px;
17
+ cursor: pointer;
18
+ }
19
+
20
+ #payment_form_omise_offsite_internet_banking .omise-logo-wrapper {
21
+ display: inline-block;
22
+ padding: 5px;
23
+ margin: 0 10px;
24
+ border-radius: 2px;
25
+ vertical-align: top;
26
+ }
27
+
28
+ #payment_form_omise_offsite_internet_banking .omise-logo-wrapper img {
29
+ width: 30px;
30
+ height: 30px;
31
+ }
32
+
33
+ #payment_form_omise_offsite_internet_banking .omise-banking-text-wrapper {
34
+ display: inline-block;
35
+ }
36
+
37
+ #payment_form_omise_offsite_internet_banking .secondary-text {
38
+ color: #aaa;
39
+ font-size: 80%;
40
+ }
41
+
42
+ /** SCB **/
43
+ #payment_form_omise_offsite_internet_banking .scb {
44
+ background: #4e2e7f;
45
+ }
46
+ #payment_form_omise_offsite_internet_banking img.scb {
47
+ background: url('../images/scb.svg') #4e2e7f;
48
+ }
49
+
50
+ /** KTB **/
51
+ #payment_form_omise_offsite_internet_banking .ktb {
52
+ background: #1ba5e1;
53
+ }
54
+ #payment_form_omise_offsite_internet_banking img.ktb {
55
+ background: url('../images/ktb.svg') #1ba5e1;
56
+ }
57
+
58
+ /** BAY **/
59
+ #payment_form_omise_offsite_internet_banking .bay {
60
+ background: #fec43b;
61
+ }
62
+ #payment_form_omise_offsite_internet_banking img.bay {
63
+ background: url('../images/bay.svg') #fec43b;
64
+ }
65
+
66
+ /** BBL **/
67
+ #payment_form_omise_offsite_internet_banking .bbl {
68
+ background: #1e4598;
69
+ }
70
+ #payment_form_omise_offsite_internet_banking img.bbl {
71
+ background: url('../images/bbl.svg') #1e4598;
72
+ }
skin/frontend/base/default/omise/images/bay.svg ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ viewBox="0 0 128 128" enable-background="new 0 0 128 128" xml:space="preserve">
6
+ <g>
7
+ <path fill="#FFFFFF" d="M42.2,50.7c2.1,4.5,4.6,8.9,7.9,12.6c1.2-2.2,2.1-4.5,3.1-6.8c3.9-10.2,6-21,7.4-31.7
8
+ c1-8.1,1.7-16.4,1.6-24.5C52.9,0.5,43.4,2.9,35,7.1c-0.2,0.1-0.5,0.3-0.7,0.5c-0.2,1.6,0,3.3-0.1,4.9
9
+ C34.5,25.5,36.8,38.7,42.2,50.7z"/>
10
+ <path fill="#FFFFFF" d="M72.6,50.2c1.4,4.4,3,8.9,5.2,13c2.4-2.8,4.4-5.9,6.2-9.1c5.3-9.9,8.1-21.1,9.2-32.3
11
+ c0.4-4.7,0.7-9.5,0.5-14.2c-2.1-1.3-4.5-2.2-6.7-3.2c-6.8-2.6-14-4-21.3-4.2c-0.1,4,0.1,8,0.4,11.9C67,25,68.8,37.8,72.6,50.2z"/>
12
+ <path fill="#FFFFFF" d="M18.8,56.5c4.8-7.1,7.7-15.3,9.6-23.6C30.1,25.2,31,17.3,31,9.4c-0.5,0.2-1,0.5-1.4,0.8
13
+ c-8.1,5.2-15.1,12.2-20.2,20.5c-7.5,12.1-10.7,27-8.9,41.1C8,68.7,14.3,63.1,18.8,56.5z"/>
14
+ <path fill="#FFFFFF" d="M120.5,34.2c-4.5-8.6-11.1-16.2-19-21.9c-1.5-1-2.9-2.1-4.5-2.9c0,6.3,0.6,12.7,1.7,19
15
+ c1.7,9.5,4.7,19,9.9,27.1c4.5,7.1,11,13.1,18.9,16.3C129.1,59,126.6,45.6,120.5,34.2z"/>
16
+ <path fill="#FFFFFF" d="M44.8,74.9c-0.4-0.8-1.2-1.4-1.8-2.1c-2.7-3.1-4.9-6.6-6.8-10.2c-1.5-2.9-2.6-6-3.6-9
17
+ c-0.6,0.9-0.9,1.9-1.2,2.9c-1.8,5.1-4.4,10-7.7,14.3C18.6,77.4,11.8,83,3.9,85.9c0.1,0.6,0.3,1.2,0.5,1.7c2,5,4.6,9.8,7.8,14.1
18
+ c1.3,1.6,2.5,3.4,4,4.8c1-0.3,1.8-0.9,2.7-1.4c9.6-6.2,17.2-15.2,23-24.9C43,78.5,44.1,76.8,44.8,74.9z"/>
19
+ <path fill="#FFFFFF" d="M64.8,56.9c-0.3-1.1-0.2-2.3-0.9-3.2c-0.7,0.9-0.6,2.2-0.9,3.2c-2.1,10.8-5.3,21.5-9.6,31.6
20
+ c-4.9,11.4-11.3,22.4-20.3,31.1c-0.4,0.5,0.5,0.7,0.8,0.9c9,4.7,19.2,7.3,29.4,7.4c10.9,0.1,22-2.6,31.5-8
21
+ c-9-8.9-15.7-20-20.6-31.6C70.2,78.2,66.9,67.7,64.8,56.9z"/>
22
+ <path fill="#FFFFFF" d="M96.5,56.4c-0.3-0.9-0.5-1.9-1.1-2.7c-0.6,1-0.9,2.2-1.3,3.3c-2.4,6.5-6,12.5-10.7,17.6
23
+ c-0.5,0.4-0.1,0.9,0.1,1.3c2.1,4,4.5,7.8,7.1,11.4c5.1,6.9,11.2,13.2,18.5,18c0.8,0.5,1.6,1.1,2.5,1.3c0.7-0.5,1.2-1.3,1.7-1.9
24
+ c3.4-4.1,6.2-8.6,8.5-13.4c0.8-1.7,1.6-3.5,2.1-5.3c-4.3-1.6-8.2-3.9-11.7-6.8C105,73.2,99.6,65.2,96.5,56.4z"/>
25
+ </g>
26
+ </svg>
skin/frontend/base/default/omise/images/bbl.svg ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ viewBox="0 0 128 128" enable-background="new 0 0 128 128" xml:space="preserve">
6
+ <path fill="#FFFFFF" d="M86.8,29.8L64,0L41.2,29.8c-17.2,22.5-24,32.6-24,47.7c0,12.8,3.3,19,15.3,27.7L64,128l31.5-22.8
7
+ c12-8.7,15.3-14.9,15.3-27.7C110.8,62.4,104,52.3,86.8,29.8z M57,103.8l-0.2,6.2c0,0.8-0.5,0.9-1,0.5C47.6,104.6,38,97.6,38,97.6
8
+ c-10-7.2-10.6-15-10.6-20.3c0-3.6,0.5-7.5,2.2-11.5c0.1-0.3,0.3-0.8,0.6-0.8c0.2,0,0.3,0.1,0.4,0.3c3.5,5.1,9.1,13.4,14.7,20.2
9
+ C56.1,98.5,57.2,97.4,57,103.8z M64,92.1c-0.1,0-0.2-0.1-0.3-0.1L41.6,65.8c-2.5-3-3.9-6.3-3.9-9.6c0-2.2,0.8-4.5,2.4-6.6l23.6-32.4
10
+ c0.1-0.1,0.2-0.2,0.3-0.2c0.1,0,0.2,0.1,0.3,0.2l23.6,32.4c1.5,2.1,2.4,4.4,2.4,6.6c0,3.3-1.3,6.6-3.9,9.6L64.3,92
11
+ C64.2,92.1,64.1,92.1,64,92.1z M90,97.6c0,0-9.7,7-17.8,12.9c-0.5,0.4-0.9,0.3-1-0.5l-0.2-6.2c-0.2-6.4,0.9-5.3,11.7-18.3
12
+ c5.6-6.8,11.2-15,14.7-20.2c0.1-0.2,0.3-0.3,0.4-0.3c0.2,0,0.5,0.5,0.6,0.8c1.6,4,2.2,7.9,2.2,11.5C100.6,82.6,100,90.4,90,97.6z"/>
13
+ </svg>
skin/frontend/base/default/omise/images/ktb.svg ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ viewBox="0 0 128 128" enable-background="new 0 0 128 128" xml:space="preserve">
6
+ <g id="g6429_1_" transform="matrix(1.25,0,0,-1.25,363.7077,521.25435)">
7
+ <path id="path6431_1_" fill="#FFFFFF" d="M-220.1,336.6c0,0,0.6,1,0.9-0.4c0,0,0.6-8.1-4.1-13.1c-3.2-3.3-10.6-8-18.9-5.9
8
+ c0,0,13.3,0.9,16.7,14.1l0.4,1.5C-225.3,332.8-222,333.7-220.1,336.6 M-189.8,377.4c0,0.2,0,0.3-0.1,0.5c0,0-0.2,0.8-0.7,2.2
9
+ c-0.1,0.2-0.2,0.4-0.2,0.6l0,0c0,0.1-0.1,0.2-0.1,0.2c-0.9,2.1-2.6,5.1-5.5,8c0,0,3.1,0.2-0.3,4c0,0-5.6,6.6-16.5,11.7
10
+ c-5.8,2.7-12.4,1.6-11.8-4.9c0.4-4.5-3.8-6.3-7.1-5.9c-3.9,0.5-6.3,3.7-5.6,6.3c0.7,2.8,2.1,5,4.3,6.7c1.5,1.2,2.5,2,5.2,2.5
11
+ c1.6,0.3,3.8,0.9,4.4-1c1.1,0.6,3.1,4.4-3.4,4.4c0,0-1,2.1-3.2,1.7c0,0-6.5,6.4-13.8-1.5c0,0-2.8-1.1-3,0c0.6-0.5,1.7,1,0.3,1.6
12
+ c-0.7,0.3-1.5-0.5-1.6-1.1c-0.1-0.5,0.1-1.7,1.5-1.9c0.4-0.1,1.1,0,1.1,0l-0.5-0.6c-2.2-0.9-4.2-0.2-4.6,1.3
13
+ c0.5-0.3,1.1,0.1,1.2,0.6c0.2,0.6-0.2,1.4-1.1,1.5c-1.2,0.2-1.7-1.2-1.5-2.4c0.4-1.9,2.2-3.2,4.6-2.8l-0.4-0.6c0,0-2.4-3-4.3-6.4
14
+ c-2-3.4-10.1-7.2-8.7,1c0.4,2.6-3.9,5.7-11.6,0.5c-4-2.8-9-7-12.8-13.8c0,0-1.6-2.6,1.1-2.7c0,0-5.5-2.6-5.8-15.1l0,0
15
+ c0,0,0-0.5,0-1.2c0-0.4,0-0.9,0-1.3c0-1.4,0.1-3,0.2-3.9c0,0,0.6-7.5,1.9-8.8c0,0,0.1,0,0.2,0c0.4-0.3,0.9-0.4,1.6,0.3l0,0
16
+ c0-0.1,1.7-8.5,5.1-15.6c2.8-5.6,7.9-13.8,5.9-15.8c-2-2-4.8,2-4.4,0.4c0.9-3.3,4.4-3.8,6.2-2.4c4.8,3.8-2.2,12.9-4.4,24.4
17
+ c4.6,2,4.4,9.2,4.4,9.2s6.5,0.2,8.5,7.9c0,0,7.9-2.3,11.7,4.6c0,0,0,0,0,0.1l0.1,0.1c0.8-2.4,2.3-4.5,4.4-6.4c0,0-0.4-3.3-4.1-4.5
18
+ c0,0-4.5,1.9-9.5,0c-4.5-1.8-2.7-6.6,0.6-5.4c-1,0.5-1.3,2.1,0.3,2.5c0.4-0.3,0.8-0.5,1.3-0.6l0,0c0.1,0,4-0.7,6.8,0.4
19
+ c0.2,0.1,0.4,0.1,0.6,0.3h0.1l0,0c0.3,0.2,0.5,0.4,0.7,0.6c1-0.1,1.7-1.6,0.3-2.3c2.7-0.6,3.7,2.3,2.6,3.8c0,0,0.6,0.4,1.4,1
20
+ c0,0,0.9,0.8,1.5,1.8c0,0,2.7-2.1,7.6-3.3c0,0-2.6-4.3-6.4-5.1c0,0-5.4,1.8-9.1-0.5c0,0-2-1.1-1.7-3.2c0.2-1.6,1.6-2.8,3.5-2.5
21
+ c-0.8,0.4-2.6,2.4-0.3,3.3c0.4-0.6,0.9-1,1.6-1.1l0,0c0,0,3.4-0.8,7.6,1c0.2,0.1,0.3,0.1,0.5,0.2c0,0,0.1,0,0.2,0.1l0,0
22
+ c0.3,0.2,0.5,0.4,0.6,0.6c1.1,0.2,2.6-0.3,2-2.4c1.3,0.2,3.4,2.5,0.3,4.4c0,0,1.8,0.9,3.3,2.2l2.2,2.2c4.3-0.6,7.5-4.7,7.5-9.7
23
+ c0-4.1-3.5-8.9-7.2-9.9c0.1,0,0.3,0.1,0.4,0.1l-0.5-0.1h0.1c-0.6-0.1-1.2-0.2-2-0.2c-3.8,0.1-1.5,4.5-1.5,4.5
24
+ c-0.6,0.1-1.2-0.1-1.7-0.7c-0.6-0.7-0.8-2-0.6-3.4c-0.2,0.1-0.4,0.1-0.5,0.2c-3.3,1.4-3.1,3.9-3.1,3.9c-0.9-0.4-1.5-1.5-1.2-3.4
25
+ c0.5-2.5,3.7-3.6,6.3-3.9c1.5-1.5,3.9-3,9.4-2.1c0,0-2.4-12.8-18.6-12.2c0,0-4.9,1.8-4.7,5.9c0.2,5.5,4,7.4,4,7.4
26
+ c-1.4,0.2-4.8-0.2-6.3-4.7c-0.7-2-0.5-5.4,1.3-7.7c-6.1,1.6-10.7,6.2-8.8,12.6c0.3,1,0.9,2,1.7,2.9c4.6,4.3,11.4,1.7,11.4,1.7
27
+ c-0.3,1.5-2.2,3.5-5.6,3.7c-3.5,0.2-10.2-1.9-10.7-10c-0.5-7.4,4.2-12.8,15.9-14.5l0.2-0.1c0,0,7.1-5,17.1-2.3
28
+ c0,0,20.2,4.1,15.9,27.2c0,0,4.7,15.4-5.2,24.1c6.1-5,13.6-2.1,13.6-2.1c-0.5-14,5.4-15.8,5.4-15.8l0.2,0.1c0,0-11.1-23.9-4.6-27
29
+ c2.2-1,4.8-0.5,6.1,2.3c1.1,2.3-2.4-2.2-4.4-0.3c-2.4,2.4,0.6,8.1,3.5,14.2c4.1,8.2,6.8,14.3,7.3,18.4c0,0,0.6-0.4,1.3-0.1l0.1-0.1
30
+ c1.6,0.4,2.6,7,2.8,8.1C-188.8,370-189.2,374.5-189.8,377.4"/>
31
+ </g>
32
+ </svg>
skin/frontend/base/default/omise/images/scb.svg ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
+ viewBox="0 0 128 128" enable-background="new 0 0 128 128" xml:space="preserve">
6
+ <path fill="#FFFFFF" d="M8.2,107.6c9.2,4.3,18.4,8.7,27.6,13.1c0.4,0.3,1.1,0.3,1.6,0.3c7,0,14,0,21,0c1.2,0,1.4-0.4,1.4-1.5
7
+ c-0.1-6.2,0-12.4,0-18.6c0-0.4-0.1-0.6-0.1-1.2c-0.5,0.3-1,0.4-1.4,0.6c-6.4,2.8-13,5.1-20.2,4.2c-2.8-0.4-5.3-1.3-7.4-3.3
8
+ c-3.7-3.5-4.7-8.1-4.8-12.9c-0.1-4,0.3-8,0.8-12c0.5-4.7,1.7-9.2,3.7-13.5c5.3-11.7,13.1-21.7,22.3-30.5c3-2.9,6.6-5.2,10-7.8
9
+ c0.8-0.6,1.6-0.6,2.5,0c2.7,2,5.5,3.8,8,5.9c6.5,5.7,12,12.2,16.8,19.3c4.9,7.1,9,14.7,10.6,23.3c1.2,6.3,2,12.7,0.9,19.1
10
+ c-1.6,8.6-6.7,12.3-14.4,12.5c-3.8,0.1-7.5-0.7-11.1-2c-2.6-0.9-5.2-2-7.8-3c0,0.4,0,0.6,0,0.9c0,6.2,0,12.4,0,18.5
11
+ c0,1.3,0.4,1.6,1.7,1.6c6.8-0.1,13.5,0,20.3-0.1c0.9,0,1.8-0.3,2.6-0.6c8.9-4.2,17.8-8.5,26.6-12.7c1.8-0.9,1.8-0.8,1.3-2.8
12
+ c-5-19.6-9.9-39.1-14.9-58.7c-0.2-0.6-0.5-1.3-1.1-1.9c-2-2-4.1-3.9-6.1-5.8c-3.9-3.6-7.8-7.2-11.8-10.8
13
+ c-5.3-4.8-10.5-9.5-15.8-14.4c-2-1.9-4.2-3.8-6.2-5.8c-0.7-0.6-1.2-0.6-1.9,0.1c-0.9,0.9-1.9,1.7-2.8,2.5
14
+ c-4.1,3.8-8.2,7.6-12.3,11.3c-4.4,4-8.7,8-13.2,12c-3.2,2.9-6.4,5.8-9.6,8.7c-1.2,1.2-2.7,2.2-3.2,4.1c-4.9,19.5-9.8,39.1-14.8,58.6
15
+ C6.8,106.4,7,107.1,8.2,107.6z"/>
16
+ </svg>