AltaPay_for_Magento1 - Version 0.0.1

Version Notes

First version.

Download this release

Release Info

Developer AltaPay Integration Team
Extension AltaPay_for_Magento1
Version 0.0.1
Comparing to
See all releases


Version 0.0.1

Files changed (116) hide show
  1. app/code/community/Altapay/Payment/Block/Customer/Account/Token.php +16 -0
  2. app/code/community/Altapay/Payment/Block/Form/Gateway.php +13 -0
  3. app/code/community/Altapay/Payment/Block/Form/Moto.php +33 -0
  4. app/code/community/Altapay/Payment/Block/Form/Recurring.php +43 -0
  5. app/code/community/Altapay/Payment/Block/Form/Token.php +13 -0
  6. app/code/community/Altapay/Payment/Block/Info/Gateway.php +18 -0
  7. app/code/community/Altapay/Payment/Block/Info/Moto.php +16 -0
  8. app/code/community/Altapay/Payment/Block/Info/Recurring.php +11 -0
  9. app/code/community/Altapay/Payment/Block/Info/Token.php +18 -0
  10. app/code/community/Altapay/Payment/Block/Onepage.php +22 -0
  11. app/code/community/Altapay/Payment/Block/Onepage/Failed.php +23 -0
  12. app/code/community/Altapay/Payment/Block/Onepage/Form.php +9 -0
  13. app/code/community/Altapay/Payment/Block/Onepage/Success.php +13 -0
  14. app/code/community/Altapay/Payment/Block/Onepage/Success/Token.php +69 -0
  15. app/code/community/Altapay/Payment/Helper/CurrencyMapper.php +207 -0
  16. app/code/community/Altapay/Payment/Helper/Data.php +9 -0
  17. app/code/community/Altapay/Payment/Helper/Logger.php +19 -0
  18. app/code/community/Altapay/Payment/Helper/Utilities.php +16 -0
  19. app/code/community/Altapay/Payment/Model/Altapay.php +244 -0
  20. app/code/community/Altapay/Payment/Model/Api/ALTAPAY_VERSION.php +1 -0
  21. app/code/community/Altapay/Payment/Model/Api/AltapayCallbackHandler.class.php +92 -0
  22. app/code/community/Altapay/Payment/Model/Api/AltapayMerchantAPI.class.php +825 -0
  23. app/code/community/Altapay/Payment/Model/Api/IAltapayCommunicationLogger.class.php +19 -0
  24. app/code/community/Altapay/Payment/Model/Api/exceptions/AltapayConnectionFailedException.class.php +10 -0
  25. app/code/community/Altapay/Payment/Model/Api/exceptions/AltapayInvalidResponseException.class.php +6 -0
  26. app/code/community/Altapay/Payment/Model/Api/exceptions/AltapayMerchantAPIException.class.php +6 -0
  27. app/code/community/Altapay/Payment/Model/Api/exceptions/AltapayRequestTimeoutException.class.php +9 -0
  28. app/code/community/Altapay/Payment/Model/Api/exceptions/AltapayUnauthorizedAccessException.class.php +9 -0
  29. app/code/community/Altapay/Payment/Model/Api/exceptions/AltapayUnknownMerchantAPIException.class.php +20 -0
  30. app/code/community/Altapay/Payment/Model/Api/exceptions/AltapayXmlException.class.php +20 -0
  31. app/code/community/Altapay/Payment/Model/Api/http/AltapayCurlBasedHttpUtils.class.php +167 -0
  32. app/code/community/Altapay/Payment/Model/Api/http/AltapayFOpenBasedHttpUtils.class.php +121 -0
  33. app/code/community/Altapay/Payment/Model/Api/http/AltapayHttpRequest.class.php +40 -0
  34. app/code/community/Altapay/Payment/Model/Api/http/AltapayHttpResponse.class.php +126 -0
  35. app/code/community/Altapay/Payment/Model/Api/http/IAltapayHttpUtils.class.php +17 -0
  36. app/code/community/Altapay/Payment/Model/Api/request/AltapayAPITransactionsRequest.class.php +132 -0
  37. app/code/community/Altapay/Payment/Model/Api/response/AltapayAPIAddress.class.php +71 -0
  38. app/code/community/Altapay/Payment/Model/Api/response/AltapayAPIChargebackEvent.class.php +99 -0
  39. app/code/community/Altapay/Payment/Model/Api/response/AltapayAPIChargebackEvents.class.php +34 -0
  40. app/code/community/Altapay/Payment/Model/Api/response/AltapayAPICountryOfOrigin.class.php +31 -0
  41. app/code/community/Altapay/Payment/Model/Api/response/AltapayAPICustomerInfo.class.php +119 -0
  42. app/code/community/Altapay/Payment/Model/Api/response/AltapayAPIFunding.class.php +74 -0
  43. app/code/community/Altapay/Payment/Model/Api/response/AltapayAPIPayment.class.php +286 -0
  44. app/code/community/Altapay/Payment/Model/Api/response/AltapayAPIPaymentInfos.class.php +33 -0
  45. app/code/community/Altapay/Payment/Model/Api/response/AltapayAPIPaymentNatureService.class.php +46 -0
  46. app/code/community/Altapay/Payment/Model/Api/response/AltapayAPIReconciliationIdentifier.class.php +31 -0
  47. app/code/community/Altapay/Payment/Model/Api/response/AltapayAbstractPaymentResponse.class.php +96 -0
  48. app/code/community/Altapay/Payment/Model/Api/response/AltapayAbstractResponse.class.php +69 -0
  49. app/code/community/Altapay/Payment/Model/Api/response/AltapayCalculateSurchargeResponse.class.php +36 -0
  50. app/code/community/Altapay/Payment/Model/Api/response/AltapayCaptureRecurringResponse.class.php +24 -0
  51. app/code/community/Altapay/Payment/Model/Api/response/AltapayCaptureResponse.class.php +22 -0
  52. app/code/community/Altapay/Payment/Model/Api/response/AltapayCreatePaymentRequestResponse.class.php +34 -0
  53. app/code/community/Altapay/Payment/Model/Api/response/AltapayFundingListResponse.class.php +36 -0
  54. app/code/community/Altapay/Payment/Model/Api/response/AltapayGetPaymentResponse.class.php +28 -0
  55. app/code/community/Altapay/Payment/Model/Api/response/AltapayGetTerminalsResponse.class.php +49 -0
  56. app/code/community/Altapay/Payment/Model/Api/response/AltapayLoginResponse.class.php +27 -0
  57. app/code/community/Altapay/Payment/Model/Api/response/AltapayPreauthRecurringResponse.class.php +40 -0
  58. app/code/community/Altapay/Payment/Model/Api/response/AltapayRefundResponse.class.php +21 -0
  59. app/code/community/Altapay/Payment/Model/Api/response/AltapayReleaseResponse.class.php +22 -0
  60. app/code/community/Altapay/Payment/Model/Api/response/AltapayReservationResponse.class.php +34 -0
  61. app/code/community/Altapay/Payment/Model/Api/response/AltapayTerminal.class.php +39 -0
  62. app/code/community/Altapay/Payment/Model/Constants.php +24 -0
  63. app/code/community/Altapay/Payment/Model/Method/Abstract.php +291 -0
  64. app/code/community/Altapay/Payment/Model/Method/Gateway.php +220 -0
  65. app/code/community/Altapay/Payment/Model/Method/Moto.php +75 -0
  66. app/code/community/Altapay/Payment/Model/Method/Recurring.php +90 -0
  67. app/code/community/Altapay/Payment/Model/Method/Token.php +100 -0
  68. app/code/community/Altapay/Payment/Model/Observer.php +26 -0
  69. app/code/community/Altapay/Payment/Model/Resource/Subscription.php +12 -0
  70. app/code/community/Altapay/Payment/Model/Resource/Subscription/Collection.php +19 -0
  71. app/code/community/Altapay/Payment/Model/Resource/Token.php +12 -0
  72. app/code/community/Altapay/Payment/Model/Resource/Token/Collection.php +9 -0
  73. app/code/community/Altapay/Payment/Model/Source/PaymentAction.php +23 -0
  74. app/code/community/Altapay/Payment/Model/Source/Terminals.php +97 -0
  75. app/code/community/Altapay/Payment/Model/Subscription.php +13 -0
  76. app/code/community/Altapay/Payment/Model/Token.php +90 -0
  77. app/code/community/Altapay/Payment/controllers/OnepageController.php +519 -0
  78. app/code/community/Altapay/Payment/controllers/TokenController.php +143 -0
  79. app/code/community/Altapay/Payment/etc/adminhtml.xml +42 -0
  80. app/code/community/Altapay/Payment/etc/config.xml +192 -0
  81. app/code/community/Altapay/Payment/etc/system.xml +369 -0
  82. app/code/community/Altapay/Payment/sql/altapaypayment_setup/install-1.0.0.php +21 -0
  83. app/code/community/Altapay/Payment/sql/altapaypayment_setup/upgrade-1.0.0-1.0.1.php +21 -0
  84. app/design/adminhtml/default/default/layout/altapay.xml +30 -0
  85. app/design/adminhtml/default/default/template/altapay/payment/form/moto.phtml +34 -0
  86. app/design/adminhtml/default/default/template/altapay/payment/info/gateway.phtml +29 -0
  87. app/design/adminhtml/default/default/template/altapay/payment/info/moto.phtml +7 -0
  88. app/design/adminhtml/default/default/template/altapay/payment/info/recurring.phtml +30 -0
  89. app/design/frontend/base/default/layout/altapay.xml +115 -0
  90. app/design/frontend/base/default/template/altapay/checkout/default_styling.css +80 -0
  91. app/design/frontend/base/default/template/altapay/checkout/default_styling_nojs.css +14 -0
  92. app/design/frontend/base/default/template/altapay/checkout/failed.phtml +42 -0
  93. app/design/frontend/base/default/template/altapay/checkout/form.phtml +55 -0
  94. app/design/frontend/base/default/template/altapay/checkout/magento_styling.css +84 -0
  95. app/design/frontend/base/default/template/altapay/checkout/magento_styling_nojs.css +17 -0
  96. app/design/frontend/base/default/template/altapay/checkout/onepage/progress.phtml +110 -0
  97. app/design/frontend/base/default/template/altapay/checkout/onepage/success/token.phtml +16 -0
  98. app/design/frontend/base/default/template/altapay/checkout/success_redirect.phtml +18 -0
  99. app/design/frontend/base/default/template/altapay/customer/account/token/view.phtml +43 -0
  100. app/design/frontend/base/default/template/altapay/payment/form/gateway.phtml +4 -0
  101. app/design/frontend/base/default/template/altapay/payment/form/recurring.phtml +11 -0
  102. app/design/frontend/base/default/template/altapay/payment/form/token.phtml +15 -0
  103. app/design/frontend/base/default/template/altapay/payment/info/gateway.phtml +1 -0
  104. app/design/frontend/base/default/template/altapay/payment/info/recurring.phtml +1 -0
  105. app/design/frontend/base/default/template/altapay/payment/info/token.phtml +1 -0
  106. app/etc/modules/Altapay_Payment.xml +27 -0
  107. app/locale/en_GB/Altapay_Payment.csv +115 -0
  108. app/locale/en_US/Altapay_Payment.csv +115 -0
  109. package.xml +18 -0
  110. skin/adminhtml/default/default/altapay.css +43 -0
  111. skin/adminhtml/default/default/images/altapay.png +0 -0
  112. skin/frontend/base/default/altapay/css/altapay.css +25 -0
  113. skin/frontend/base/default/altapay/images/ajax-loader.gif +0 -0
  114. skin/frontend/base/default/altapay/images/error.png +0 -0
  115. skin/frontend/base/default/altapay/images/success.png +0 -0
  116. skin/frontend/base/default/altapay/js/altapay.js +103 -0
app/code/community/Altapay/Payment/Block/Customer/Account/Token.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Altapay_Payment_Block_Customer_Account_Token extends Mage_Core_Block_Template
3
+ {
4
+ public function getTokens()
5
+ {
6
+ $tokens = false;
7
+ if(Mage::getSingleton('customer/session')->isLoggedIn()) {
8
+ $tokens = Mage::getModel('altapaypayment/token')->getCollection()
9
+ ->addFieldToFilter('customer_id',Mage::getSingleton('customer/session')->getCustomer()->getId());
10
+ }
11
+
12
+ return $tokens;
13
+ }
14
+
15
+
16
+ }
app/code/community/Altapay/Payment/Block/Form/Gateway.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Altapay_Payment_Block_Form_Gateway extends Mage_Payment_Block_Form_Cc
4
+ {
5
+
6
+ protected function _construct()
7
+ {
8
+ parent::_construct();
9
+ $this->setTemplate('altapay/payment/form/gateway.phtml');
10
+ }
11
+
12
+
13
+ }
app/code/community/Altapay/Payment/Block/Form/Moto.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Altapay_Payment_Block_Form_Moto extends Mage_Payment_Block_Form_Cc
4
+ {
5
+
6
+ protected function _construct()
7
+ {
8
+ parent::_construct();
9
+ $this->setTemplate('altapay/payment/form/moto.phtml');
10
+ }
11
+
12
+ /**
13
+ * Verification (CCV) has to display if either been set to use in admin OR
14
+ * request action is set to preauth (note: documentation is wrong as it states it is optional)
15
+ *
16
+ * @return boolean
17
+ */
18
+ public function hasVerification()
19
+ {
20
+ if(parent::hasVerification()){
21
+ return true;
22
+ } else {
23
+ //check payment action
24
+ $method = $this->getMethod();
25
+ $request_action = $method->getConfigPaymentAction();
26
+ if($request_action == Altapay_Payment_Model_Method_Abstract::ACTION_AUTHORIZE) {
27
+ return true;
28
+ }
29
+ }
30
+ return false;
31
+ }
32
+
33
+ }
app/code/community/Altapay/Payment/Block/Form/Recurring.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Altapay_Payment_Block_Form_Recurring extends Mage_Payment_Block_Form_Cc
4
+ {
5
+
6
+ protected function _construct()
7
+ {
8
+ parent::_construct();
9
+ $this->setTemplate('altapay/payment/form/recurring.phtml');
10
+ }
11
+
12
+ protected function getSubscriptions()
13
+ {
14
+ $options = array();
15
+
16
+ $customer = $this->getOnepage()->getCustomerSession()->getCustomer();
17
+ if($customer->getId())
18
+ {
19
+ $subscriptions = Mage::getModel('altapaypayment/subscription')->getCollection()->addFieldToFilter('customer_id',$customer->getId());
20
+
21
+ foreach($subscriptions as $subscription)
22
+ {
23
+ if($subscription->getCurrencyCode() == $this->getOnepage()->getQuote()->getQuoteCurrencyCode())
24
+ {
25
+ $options[$subscription->getId()] = $subscription->getMaskedPan();
26
+ }
27
+ }
28
+ }
29
+ $options['new'] = 'Use a new card';
30
+ return $options;
31
+ }
32
+
33
+
34
+ /**
35
+ * Get one page checkout model
36
+ *
37
+ * @return Mage_Checkout_Model_Type_Onepage
38
+ */
39
+ public function getOnepage()
40
+ {
41
+ return Mage::getSingleton('checkout/type_onepage');
42
+ }
43
+ }
app/code/community/Altapay/Payment/Block/Form/Token.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Altapay_Payment_Block_Form_Token extends Mage_Payment_Block_Form_Cc
4
+ {
5
+
6
+ protected function _construct()
7
+ {
8
+ parent::_construct();
9
+ $this->setTemplate('altapay/payment/form/token.phtml');
10
+ }
11
+
12
+
13
+ }
app/code/community/Altapay/Payment/Block/Info/Gateway.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Altapay_Payment_Block_Info_Gateway extends Mage_Payment_Block_Info_Cc
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('altapay/payment/info/gateway.phtml');
9
+ }
10
+
11
+ public function toPdf()
12
+ {
13
+ $this->setTemplate('altapay/payment/pdf/gateway.phtml');
14
+ return $this->toHtml();
15
+ }
16
+
17
+
18
+ }
app/code/community/Altapay/Payment/Block/Info/Moto.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Altapay_Payment_Block_Info_Moto extends Mage_Payment_Block_Info_Cc
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('altapay/payment/info/moto.phtml');
9
+ }
10
+
11
+ public function toPdf()
12
+ {
13
+ $this->setTemplate('altapay/payment/pdf/moto.phtml');
14
+ return $this->toHtml();
15
+ }
16
+ }
app/code/community/Altapay/Payment/Block/Info/Recurring.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Altapay_Payment_Block_Info_Recurring extends Mage_Payment_Block_Info
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('altapay/payment/info/recurring.phtml');
9
+ }
10
+
11
+ }
app/code/community/Altapay/Payment/Block/Info/Token.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Altapay_Payment_Block_Info_Token extends Mage_Payment_Block_Info_Cc
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('altapay/payment/info/token.phtml');
9
+ }
10
+
11
+ public function toPdf()
12
+ {
13
+ $this->setTemplate('altapay/payment/pdf/token.phtml');
14
+ return $this->toHtml();
15
+ }
16
+
17
+
18
+ }
app/code/community/Altapay/Payment/Block/Onepage.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Altapay_Payment_Block_Onepage extends Mage_Checkout_Block_Onepage {
4
+
5
+ /*
6
+ public function getSteps() {
7
+ $steps = array();
8
+
9
+ if (!$this->isCustomerLoggedIn()) {
10
+ $steps['login'] = $this->getCheckout()->getStepData('login');
11
+ }
12
+
13
+ $stepCodes = array('billing', 'shipping', 'shipping_method', 'payment', 'review');
14
+
15
+ foreach ($stepCodes as $step) {
16
+ $steps[$step] = $this->getCheckout()->getStepData($step);
17
+ }
18
+
19
+ return $steps;
20
+ }
21
+ */
22
+ }
app/code/community/Altapay/Payment/Block/Onepage/Failed.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Altapay_Payment_Block_Onepage_Failed extends Mage_Checkout_Block_Onepage_Abstract {
4
+
5
+ protected function _construct() {
6
+ parent::_construct();
7
+ }
8
+
9
+ public function getSessionAltapayPaymentRedirectUrl()
10
+ {
11
+ return Mage::getSingleton('core/session')->getData('altapay_payment_request_url');
12
+ }
13
+
14
+ public function getErrorMessage()
15
+ {
16
+ return Mage::getSingleton('core/session')->getData('altapay_error_message');
17
+ }
18
+
19
+ public function getPaymentSchemeName()
20
+ {
21
+ return Mage::getSingleton('core/session')->getData('altapay_payment_scheme_name');
22
+ }
23
+ }
app/code/community/Altapay/Payment/Block/Onepage/Form.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Altapay_Payment_Block_Onepage_Form extends Mage_Checkout_Block_Onepage_Abstract {
4
+
5
+ protected function _construct() {
6
+ parent::_construct();
7
+ }
8
+
9
+ }
app/code/community/Altapay/Payment/Block/Onepage/Success.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Altapay_Payment_Block_Onepage_Success extends Mage_Checkout_Block_Onepage_Abstract {
4
+
5
+ protected function _construct() {
6
+ parent::_construct();
7
+ }
8
+
9
+ public function getCheckoutSuccessUrl()
10
+ {
11
+ return Mage::getUrl('checkout/onepage/success');
12
+ }
13
+ }
app/code/community/Altapay/Payment/Block/Onepage/Success/Token.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Altapay_Payment_Block_Onepage_Success_Token extends Mage_Checkout_Block_Onepage_Success
3
+ {
4
+ private $_order;
5
+ private $_customer;
6
+ private $_payment;
7
+
8
+ public function showBlock() {
9
+ if(Mage::getSingleton('customer/session')->isLoggedIn()) {
10
+ $order = $this->getOrder();
11
+ $customer = $this->getCustomer();
12
+
13
+ if($order->getCustomerId() == $customer->getId()) {
14
+ $payment = $this->getPayment();
15
+ if($payment->getMethod() == 'altapay_token') {
16
+ if($token = Mage::getModel('altapaypayment/token')->getTokenByOrder($order)) {
17
+
18
+ $collection = Mage::getModel('altapaypayment/token')->getCollection()
19
+ ->addFieldToFilter('customer_id',$customer->getId())
20
+ ->addFieldToFilter('token',$token)
21
+ ;
22
+ if(!$collection->getSize()) {
23
+ return true;
24
+ }
25
+ }
26
+ }
27
+ }
28
+ }
29
+
30
+ return false;
31
+ }
32
+
33
+ public function getOrder() {
34
+ if($this->_order) {
35
+ return $this->_order;
36
+ }
37
+ $this->_order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());
38
+ return $this->_order;
39
+ }
40
+
41
+ public function getCustomer() {
42
+ if($this->_customer) {
43
+ return $this->_customer;
44
+ }
45
+ $this->_customer = Mage::getSingleton('customer/session')->getCustomer();
46
+ return $this->_customer;
47
+ }
48
+
49
+ public function customerChooseToSaveToken() {
50
+ if(Mage::getSingleton('customer/session')->isLoggedIn()) {
51
+ $order = $this->getOrder();
52
+ $customer = $this->getCustomer();
53
+ if($order->getCustomerId() == $customer->getId()) {
54
+ return Mage::getModel('altapaypayment/token')->customerChooseToSaveCard($order,$customer);
55
+ }
56
+ }
57
+ return false;
58
+ }
59
+
60
+ public function getPayment() {
61
+ if($this->_payment) {
62
+ return $this->_payment;
63
+ }
64
+
65
+ $this->_payment = $this->getOrder()->getPayment();
66
+ return $this->_payment;
67
+ }
68
+
69
+ }
app/code/community/Altapay/Payment/Helper/CurrencyMapper.php ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Altapay_Payment_Helper_CurrencyMapper
4
+ {
5
+ private $currencies = array(
6
+ '978' => 'EUR'
7
+ , '840' => 'USD'
8
+ , '208' => 'DKK'
9
+ , '8' => 'ALL'
10
+ , '12' => 'DZD'
11
+ , '32' => 'ARS'
12
+ , '36' => 'AUD'
13
+ , '44' => 'BSD'
14
+ , '48' => 'BHD'
15
+ , '50' => 'BDT'
16
+ , '51' => 'AMD'
17
+ , '52' => 'BBD'
18
+ , '60' => 'BMD'
19
+ , '64' => 'BTN'
20
+ , '68' => 'BOB'
21
+ , '72' => 'BWP'
22
+ , '84' => 'BZD'
23
+ , '90' => 'SBD'
24
+ , '96' => 'BND'
25
+ , '104' => 'MMK'
26
+ , '108' => 'BIF'
27
+ , '116' => 'KHR'
28
+ , '124' => 'CAD'
29
+ , '132' => 'CVE'
30
+ , '136' => 'KYD'
31
+ , '144' => 'LKR'
32
+ , '152' => 'CLP'
33
+ , '156' => 'CNY'
34
+ , '170' => 'COP'
35
+ , '174' => 'KMF'
36
+ , '188' => 'CRC'
37
+ , '191' => 'HRK'
38
+ , '192' => 'CUP'
39
+ , '203' => 'CZK'
40
+
41
+ , '214' => 'DOP'
42
+ , '222' => 'SVC'
43
+ , '230' => 'ETB'
44
+ , '232' => 'ERN'
45
+ , '233' => 'EEK'
46
+ , '238' => 'FKP'
47
+ , '242' => 'FJD'
48
+ , '262' => 'DJF'
49
+ , '270' => 'GMD'
50
+ , '292' => 'GIP'
51
+ , '320' => 'GTQ'
52
+ , '324' => 'GNF'
53
+ , '328' => 'GYD'
54
+ , '332' => 'HTG'
55
+ , '340' => 'HNL'
56
+ , '344' => 'HKD'
57
+ , '348' => 'HUF'
58
+ , '352' => 'ISK'
59
+ , '356' => 'INR'
60
+ , '360' => 'IDR'
61
+ , '364' => 'IRR'
62
+ , '368' => 'IQD'
63
+ , '376' => 'ILS'
64
+ , '388' => 'JMD'
65
+ , '392' => 'JPY'
66
+ , '398' => 'KZT'
67
+ , '400' => 'JOD'
68
+ , '404' => 'KES'
69
+ , '408' => 'KPW'
70
+ , '410' => 'KRW'
71
+ , '414' => 'KWD'
72
+ , '417' => 'KGS'
73
+ , '418' => 'LAK'
74
+ , '422' => 'LBP'
75
+ , '426' => 'LSL'
76
+ , '428' => 'LVL'
77
+ , '430' => 'LRD'
78
+ , '434' => 'LYD'
79
+ , '440' => 'LTL'
80
+ , '446' => 'MOP'
81
+ , '454' => 'MWK'
82
+ , '458' => 'MYR'
83
+ , '462' => 'MVR'
84
+ , '480' => 'MUR'
85
+ , '484' => 'MXN'
86
+ , '496' => 'MNT'
87
+ , '498' => 'MDL'
88
+ , '504' => 'MAD'
89
+ , '512' => 'OMR'
90
+ , '516' => 'NAD'
91
+ , '524' => 'NPR'
92
+ , '532' => 'ANG'
93
+ , '533' => 'AWG'
94
+ , '548' => 'VUV'
95
+ , '554' => 'NZD'
96
+ , '558' => 'NIO'
97
+ , '566' => 'NGN'
98
+ , '578' => 'NOK'
99
+ , '586' => 'PKR'
100
+ , '598' => 'PGK'
101
+ , '600' => 'PYG'
102
+ , '604' => 'PEN'
103
+ , '608' => 'PHP'
104
+ , '624' => 'GWP'
105
+ , '634' => 'QAR'
106
+ , '643' => 'RUB'
107
+ , '646' => 'RWF'
108
+ , '654' => 'SHP'
109
+ , '678' => 'STD'
110
+ , '682' => 'SAR'
111
+ , '690' => 'SCR'
112
+ , '694' => 'SLL'
113
+ , '702' => 'SGD'
114
+ , '703' => 'SKK'
115
+ , '704' => 'VND'
116
+ , '706' => 'SOS'
117
+ , '710' => 'ZAR'
118
+ , '748' => 'SZL'
119
+ , '752' => 'SEK'
120
+ , '756' => 'CHF'
121
+ , '760' => 'SYP'
122
+ , '764' => 'THB'
123
+ , '776' => 'TOP'
124
+ , '780' => 'TTD'
125
+ , '784' => 'AED'
126
+ , '788' => 'TND'
127
+ , '795' => 'TMM'
128
+ , '800' => 'UGX'
129
+ , '807' => 'MKD'
130
+ , '818' => 'EGP'
131
+ , '826' => 'GBP'
132
+ , '834' => 'TZS'
133
+ , '858' => 'UYU'
134
+ , '860' => 'UZS'
135
+ , '882' => 'WST'
136
+ , '886' => 'YER'
137
+ , '894' => 'ZMK'
138
+ , '901' => 'TWD'
139
+ , '935' => 'ZWR'
140
+ , '936' => 'GHS'
141
+ , '937' => 'VEF'
142
+ , '938' => 'SDG'
143
+ , '941' => 'RSD'
144
+ , '943' => 'MZN'
145
+ , '944' => 'AZN'
146
+ , '946' => 'RON'
147
+ , '947' => 'CHE'
148
+ , '948' => 'CHW'
149
+ , '949' => 'TRY'
150
+ , '950' => 'XAF'
151
+ , '951' => 'XCD'
152
+ , '952' => 'XOF'
153
+ , '953' => 'XPF'
154
+ , '955' => 'XBA'
155
+ , '956' => 'XBB'
156
+ , '957' => 'XBC'
157
+ , '958' => 'XBD'
158
+ , '959' => 'XAU'
159
+ , '960' => 'XDR'
160
+ , '961' => 'XAG'
161
+ , '962' => 'XPT'
162
+ , '963' => 'XTS'
163
+ , '964' => 'XPD'
164
+ , '968' => 'SRD'
165
+ , '970' => 'COU'
166
+ , '971' => 'AFN'
167
+ , '972' => 'TJS'
168
+ , '973' => 'AOA'
169
+ , '974' => 'BYR'
170
+ , '975' => 'BGN'
171
+ , '976' => 'CDF'
172
+ , '977' => 'BAM'
173
+
174
+ , '979' => 'MXV'
175
+ , '980' => 'UAH'
176
+ , '981' => 'GEL'
177
+ , '984' => 'BOV'
178
+ , '985' => 'PLN'
179
+ , '986' => 'BRL'
180
+ , '990' => 'CLF'
181
+ , '997' => 'USN'
182
+ , '998' => 'USS'
183
+ , '999' => 'XXX'
184
+ );
185
+
186
+ public function getCurrencies()
187
+ {
188
+ sort($this->currencies);
189
+ return $this->currencies;
190
+ }
191
+
192
+ public function getAlpha($numeric)
193
+ {
194
+ if(!isset($this->currencies[$numeric]))
195
+ throw new Exception('Unknown currency: '.$numeric);
196
+ return $this->currencies[$numeric];
197
+ }
198
+
199
+ public function getNumeric($alpha)
200
+ {
201
+ $alpha = (string)$alpha;
202
+ $flipped = array_flip($this->currencies);
203
+ if(!isset($flipped[$alpha]))
204
+ throw new Exception('Unknown currency: '.$alpha);
205
+ return $flipped[$alpha];
206
+ }
207
+ }
app/code/community/Altapay/Payment/Helper/Data.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Altapay_Payment_Helper_Data extends Mage_Core_Helper_Abstract {
4
+
5
+ public function getExpiryMonth($expirymonth) {
6
+ return substr("00" . $expirymonth, -2);
7
+ }
8
+
9
+ }
app/code/community/Altapay/Payment/Helper/Logger.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Altapay_Payment_Helper_Logger implements IAltapayCommunicationLogger
4
+ {
5
+
6
+ public function logRequest($message)
7
+ {
8
+ $logId = md5($message.microtime());
9
+
10
+ Mage::log('[Request: '.$logId.']'.$message, Zend_Log::INFO, 'altapay.log', true);
11
+
12
+ return $logId;
13
+ }
14
+
15
+ public function logResponse($logId, $message)
16
+ {
17
+ Mage::log('[Response:'.$logId.']'.$message, Zend_Log::INFO, 'altapay.log', true);
18
+ }
19
+ }
app/code/community/Altapay/Payment/Helper/Utilities.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Altapay_Payment_Helper_Utilities
4
+ {
5
+
6
+ public static function guessStoreIdBasedOnParameters()
7
+ {
8
+ $storeCode = Mage::app()->getFrontController()->getRequest()->getParam('store', null);
9
+ if(is_null($storeCode))
10
+ {
11
+ $storeCode = Mage::app()->getFrontController()->getRequest()->getParam('store_id', null);
12
+ }
13
+
14
+ return $storeCode;
15
+ }
16
+ }
app/code/community/Altapay/Payment/Model/Altapay.php ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ALTAPAY_API_ROOT'))
4
+ {
5
+ define('ALTAPAY_API_ROOT',Mage::getModuleDir(null,'Altapay_Payment').'/Model/Api');
6
+ if(!is_dir(ALTAPAY_API_ROOT))
7
+ {
8
+ throw new Exception("Checkout Altapay Client API: svn co svn+ssh://svn.earth.altapay.com/home/subversion/AltapayClientAPI/trunk/altapay_php_api/lib ".ALTAPAY_API_ROOT);
9
+ }
10
+ }
11
+
12
+ require_once(ALTAPAY_API_ROOT.'/AltapayMerchantAPI.class.php');
13
+
14
+ class Altapay_Payment_Model_Altapay {
15
+
16
+ /**
17
+ * @var AltapayMerchantAPI
18
+ */
19
+ private $_merchantApi;
20
+ private $_merchantApiLogger;
21
+ private $_cachedTerminalList = null;
22
+ private $_error_ = array();
23
+ protected $_varien_response = null;
24
+ private $_canSavePayment = false;
25
+
26
+ /* PUBLIC METHODS */
27
+
28
+ private $storeId;
29
+
30
+ public function __construct($storeId=null)
31
+ {
32
+ $this->storeId = $storeId;
33
+ }
34
+
35
+ private function setupApi()
36
+ {
37
+ if(is_null($this->_merchantApi))
38
+ {
39
+ Mage::log('Create Altapay Merchant API for store: '.$this->storeId, Zend_Log::INFO, 'altapay.log', true);
40
+
41
+ $this->_merchantApiLogger = new Altapay_Payment_Helper_Logger();
42
+ $this->_merchantApi = new AltapayMerchantAPI(
43
+ Mage::getStoreConfig(Altapay_Payment_Model_Constants::CONF_PATH_API_INSTALLATION,$this->storeId),
44
+ Mage::getStoreConfig(Altapay_Payment_Model_Constants::CONF_PATH_API_USERNAME,$this->storeId),
45
+ Mage::helper('core')->decrypt(Mage::getStoreConfig(Altapay_Payment_Model_Constants::CONF_PATH_API_PASSWORD,$this->storeId)),
46
+ $this->_merchantApiLogger
47
+ );
48
+ }
49
+ }
50
+
51
+ public function getActionType($type) {
52
+ if ($type == Altapay_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
53
+ return Altapay_Payment_Model_Constants::ACTION_AUTHORIZE_CAPTURE;
54
+ } else {
55
+ return Altapay_Payment_Model_Constants::ACTION_AUTHORIZE;
56
+ }
57
+ }
58
+
59
+ public function getURI() {
60
+ return $this->_uri;
61
+ }
62
+
63
+ public function getURIMode() {
64
+ return $this->_mode;
65
+ }
66
+
67
+ public function setUriMode($mode) {
68
+ $this->_mode = $mode;
69
+ }
70
+
71
+ public function setMethod($altapay_payment_method) {
72
+ $this->_method = $altapay_payment_method;
73
+ }
74
+
75
+ public function getMethod() {
76
+ return $this->_method;
77
+ }
78
+
79
+ public function getInstallation() {
80
+ return $this->_installation;
81
+ }
82
+
83
+ public function getUserName() {
84
+ return $this->_user_name;
85
+ }
86
+
87
+ public function getPassword() {
88
+ return $this->_password;
89
+ }
90
+
91
+ public function getErrorMessage() {
92
+ if (isset($this->_error_['message'])) {
93
+ return $this->_error_['message'];
94
+ } else {
95
+ return false;
96
+ }
97
+ }
98
+
99
+ public function getErrorType() {
100
+ if (isset($this->_error_['type'])) {
101
+ return $this->_error_['type'];
102
+ } else {
103
+ return false;
104
+ }
105
+ }
106
+
107
+ public function getAltapayMerchantAPI() {
108
+ $this->setupApi();
109
+ if (!$this->_merchantApi->isConnected()) {
110
+ $this->_merchantApi->login();
111
+ }
112
+ return $this->_merchantApi;
113
+ }
114
+
115
+ public function authenticate() {
116
+ return $this->getAltapayMerchantAPI()->login();
117
+ }
118
+
119
+ public function createPaymentRequest(
120
+ $terminal,
121
+ $orderid,
122
+ $amount,
123
+ $currencyCode,
124
+ $paymentType,
125
+ array $customerInfo=array(),
126
+ $cookie=null,
127
+ $language=null,
128
+ array $config = array(),
129
+ array $transactionInfo = array(),
130
+ array $orderLines = array(),
131
+ $accountOffer = false,
132
+ $ccToken = null
133
+ )
134
+ {
135
+ return $this->getAltapayMerchantAPI()->createPaymentRequest(
136
+ $terminal
137
+ , $orderid
138
+ , $amount
139
+ , $currencyCode
140
+ , $paymentType
141
+ , $customerInfo
142
+ , $cookie
143
+ , $language
144
+ , $config
145
+ , $transactionInfo
146
+ , $orderLines
147
+ , $accountOffer
148
+ , $ccToken
149
+ );
150
+ }
151
+
152
+ /**
153
+ * This will capture using the Altapay API.
154
+ * TODO: Support order_lines for invoices
155
+ *
156
+ * @return AltapayCaptureResponse
157
+ */
158
+ public function captureReservation($paymentId, $amount, $orderLines, $salesTax)
159
+ {
160
+ return $this->getAltapayMerchantAPI()->captureReservation($paymentId, $amount, $orderLines, $salesTax);
161
+ }
162
+
163
+ /**
164
+ * This will capture using the Altapay API.
165
+ * TODO: Support order_lines for invoices
166
+ *
167
+ * @return AltapayReleaseResponse
168
+ */
169
+ public function releaseReservation($paymentId, $amount)
170
+ {
171
+ return $this->getAltapayMerchantAPI()->releaseReservation($paymentId, $amount);
172
+ }
173
+
174
+
175
+ /**
176
+ * This will capture using the Altapay API.
177
+ *
178
+ * @return AltapayRefundResponse
179
+ */
180
+ public function refundCapturedReservation($paymentId, $amount, array $orderLines) {
181
+ return $this->getAltapayMerchantAPI()->refundCapturedReservation($paymentId, $amount, $orderLines);
182
+ }
183
+
184
+ /**
185
+ * @return AltapayGetTerminalsResponse
186
+ */
187
+ public function getTerminals() {
188
+ if(is_null($this->_cachedTerminalList))
189
+ {
190
+ $this->_cachedTerminalList = $this->getAltapayMerchantAPI()->getTerminals();
191
+ }
192
+ return $this->_cachedTerminalList;
193
+ }
194
+
195
+ /**
196
+ * @return AltapayReservationResponse
197
+ */
198
+ public function reservationOfFixedAmountMOTO(
199
+ $terminal
200
+ , $shop_orderid
201
+ , $amount
202
+ , $currency
203
+ , $cc_num
204
+ , $cc_expiry_year
205
+ , $cc_expiry_month
206
+ , $cvc) {
207
+ return $this->getAltapayMerchantAPI()->reservationOfFixedAmount(
208
+ $terminal
209
+ , $shop_orderid
210
+ , $amount
211
+ , $currency
212
+ , $cc_num
213
+ , $cc_expiry_year
214
+ , $cc_expiry_month
215
+ , $cvc
216
+ , 'moto');
217
+ }
218
+
219
+ /**
220
+ * This will make a recurring capture based on the subscription obtained via the "Recurring"-method.
221
+ *
222
+ * @return AltapayCaptureRecurringResponse
223
+ */
224
+ public function captureRecurring($subscriptionId, $amount)
225
+ {
226
+ return $this->getAltapayMerchantAPI()->captureRecurring($subscriptionId, $amount);
227
+ }
228
+
229
+ /**
230
+ * This will make a recurring capture based on the subscription obtained via the "Recurring"-method.
231
+ *
232
+ * @return AltapayPreauthRecurringResponse
233
+ */
234
+ public function recurringReservation($subscriptionId, $amount = null)
235
+ {
236
+ return $this->getAltapayMerchantAPI()->preauthRecurring($subscriptionId, $amount);
237
+ }
238
+
239
+ public function reserveSubscriptionCharge($subscriptionId, $amount = null)
240
+ {
241
+ return $this->getAltapayMerchantAPI()->reserveSubscriptionCharge($subscriptionId, $amount);
242
+ }
243
+
244
+ }
app/code/community/Altapay/Payment/Model/Api/ALTAPAY_VERSION.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php define('ALTAPAY_VERSION', 'MagentoPlugin/20151124_134927');
app/code/community/Altapay/Payment/Model/Api/AltapayCallbackHandler.class.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ALTAPAY_API_ROOT'))
4
+ {
5
+ define('ALTAPAY_API_ROOT',__DIR__);
6
+ }
7
+
8
+ require_once(ALTAPAY_API_ROOT.'/AltapayMerchantAPI.class.php');
9
+
10
+ /**
11
+ * The purpose of this class is to parse the callback parameters and return
12
+ * a usefull response object from which your business logic can get information
13
+ * for the decisions it needs to make.
14
+ *
15
+ * @author "Emanuel Holm Greisen" <phpclientapi@altapay.com>
16
+ */
17
+ class AltapayCallbackHandler
18
+ {
19
+ /**
20
+ * @return AltapayAbstractPaymentResponse
21
+ */
22
+ public function parseXmlResponse($xml)
23
+ {
24
+ if(!($xml instanceof SimpleXMLElement))
25
+ {
26
+ $xml = new SimpleXMLElement($xml);
27
+ }
28
+ $this->verifyXml($xml);
29
+
30
+ // This is not a perfect way of figuring out what kind of response would be appropriate
31
+ // At some point we should have a more direct link between something in the header
32
+ // and the way the result should be interpreted.
33
+ $authType = $xml->Body[0]->Transactions[0]->Transaction[0]->AuthType;
34
+ switch($authType)
35
+ {
36
+ case 'payment':
37
+ case 'paymentAndCapture':
38
+ case 'recurring':
39
+ case 'subscription':
40
+ case 'verifyCard':
41
+ return new AltapayReservationResponse($xml);
42
+ case 'subscriptionAndCharge':
43
+ case 'recurringAndCapture':
44
+ return new AltapayCaptureRecurringResponse($xml);
45
+ default:
46
+ throw new Exception("Unsupported 'authType': (".$authType.")");
47
+ }
48
+ }
49
+
50
+ private function verifyXml(SimpleXMLElement $xml)
51
+ {
52
+ if($xml->getName() != 'APIResponse')
53
+ {
54
+ throw new AltapayXmlException("Unknown root-tag <".$xml->getName()."> in XML, should have been <APIResponse>", $xml);
55
+ }
56
+ if(!isset($xml->Header))
57
+ {
58
+ throw new AltapayXmlException("No <Header> in response", $xml);
59
+ }
60
+ if(!isset($xml->Header->ErrorCode))
61
+ {
62
+ throw new AltapayXmlException("No <ErrorCode> in Header of response", $xml);
63
+ }
64
+ if((string)$xml->Header->ErrorCode !== '0')
65
+ {
66
+ throw new Exception($xml->Header->ErrorMessage.' (Error code: '.$xml->Header->ErrorCode.')');
67
+ }
68
+ if(!isset($xml->Body))
69
+ {
70
+ throw new AltapayXmlException("No <Body> in response", $xml);
71
+ }
72
+ if(!isset($xml->Body[0]->Transactions))
73
+ {
74
+ $error = $this->getBodyMerchantErrorMessage($xml);
75
+ throw new AltapayXmlException("No <Transactions> in <Body> of response".($error ? ' ('.$error.')' : ''), $xml);
76
+ }
77
+ if(!isset($xml->Body[0]->Transactions[0]->Transaction))
78
+ {
79
+ $error = $this->getBodyMerchantErrorMessage($xml);
80
+ throw new AltapayXmlException("No <Transaction> in <Transactions> of response".($error ? ' ('.$error.')' : ''), $xml);
81
+ }
82
+ }
83
+
84
+ private function getBodyMerchantErrorMessage(SimpleXMLElement $xml)
85
+ {
86
+ if(isset($xml->Body[0]->MerchantErrorMessage))
87
+ {
88
+ return (string)$xml->Body[0]->MerchantErrorMessage;
89
+ }
90
+ return false;
91
+ }
92
+ }
app/code/community/Altapay/Payment/Model/Api/AltapayMerchantAPI.class.php ADDED
@@ -0,0 +1,825 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ALTAPAY_API_ROOT'))
4
+ {
5
+ define('ALTAPAY_API_ROOT',__DIR__);
6
+ }
7
+
8
+ require_once(ALTAPAY_API_ROOT.'/IAltapayCommunicationLogger.class.php');
9
+ require_once(ALTAPAY_API_ROOT.'/request/AltapayAPITransactionsRequest.class.php');
10
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayGetTerminalsResponse.class.php');
11
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayGetPaymentResponse.class.php');
12
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayLoginResponse.class.php');
13
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayCreatePaymentRequestResponse.class.php');
14
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayCaptureResponse.class.php');
15
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayRefundResponse.class.php');
16
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayReleaseResponse.class.php');
17
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayReservationResponse.class.php');
18
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayCaptureRecurringResponse.class.php');
19
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayPreauthRecurringResponse.class.php');
20
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayAPIPaymentNatureService.class.php');
21
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayAPICustomerInfo.class.php');
22
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayAPICountryOfOrigin.class.php');
23
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayAPIAddress.class.php');
24
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayAPIPaymentInfos.class.php');
25
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayAPIFunding.class.php');
26
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayAPIChargebackEvent.class.php');
27
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayAPIChargebackEvents.class.php');
28
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayCalculateSurchargeResponse.class.php');
29
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayFundingListResponse.class.php');
30
+ require_once(ALTAPAY_API_ROOT.'/http/AltapayFOpenBasedHttpUtils.class.php');
31
+ require_once(ALTAPAY_API_ROOT.'/http/AltapayCurlBasedHttpUtils.class.php');
32
+ require_once(ALTAPAY_API_ROOT.'/exceptions/AltapayMerchantAPIException.class.php');
33
+ require_once(ALTAPAY_API_ROOT.'/exceptions/AltapayUnauthorizedAccessException.class.php');
34
+ require_once(ALTAPAY_API_ROOT.'/exceptions/AltapayRequestTimeoutException.class.php');
35
+ require_once(ALTAPAY_API_ROOT.'/exceptions/AltapayConnectionFailedException.class.php');
36
+ require_once(ALTAPAY_API_ROOT.'/exceptions/AltapayInvalidResponseException.class.php');
37
+ require_once(ALTAPAY_API_ROOT.'/exceptions/AltapayUnknownMerchantAPIException.class.php');
38
+ require_once(ALTAPAY_API_ROOT.'/exceptions/AltapayXmlException.class.php');
39
+ require_once(ALTAPAY_API_ROOT.'/ALTAPAY_VERSION.php');
40
+
41
+ class AltapayMerchantAPI
42
+ {
43
+ private $baseURL, $username, $password;
44
+ private $connected = false;
45
+ /**
46
+ * @var IAltapayCommunicationLogger
47
+ */
48
+ private $logger;
49
+ private $httpUtil;
50
+
51
+ public function __construct($baseURL, $username, $password, IAltapayCommunicationLogger $logger = null, IAltapayHttpUtils $httpUtil = null)
52
+ {
53
+ $this->connected = false;
54
+ $this->baseURL = rtrim($baseURL, '/');
55
+ $this->username = $username;
56
+ $this->password = $password;
57
+ $this->logger = $logger;
58
+
59
+ if(is_null($httpUtil))
60
+ {
61
+ if(function_exists('curl_init'))
62
+ {
63
+ $httpUtil = new AltapayCurlBasedHttpUtils();
64
+ }
65
+ else if(ini_get('allow_url_fopen'))
66
+ {
67
+ $httpUtil = new AltapayFOpenBasedHttpUtils();
68
+ }
69
+ else
70
+ {
71
+ throw new Exception("Neither allow_url_fopen nor cURL is installed, we cannot communicate with Altapay's Payment Gateway without at least one of them.");
72
+ }
73
+ }
74
+ $this->httpUtil = $httpUtil;
75
+ }
76
+
77
+ private function checkConnection()
78
+ {
79
+ if(!$this->connected)
80
+ {
81
+ throw new Exception("Not Connected, invoke login() before using any API calls");
82
+ }
83
+ }
84
+
85
+ public function isConnected()
86
+ {
87
+ return $this->connected;
88
+ }
89
+
90
+ private function maskPan($pan)
91
+ {
92
+ if(strlen($pan) >= 10)
93
+ {
94
+ return substr($pan, 0, 6).str_repeat('x', strlen($pan) - 10).substr($pan, -4);
95
+ }
96
+ else
97
+ {
98
+ return $pan;
99
+ }
100
+ }
101
+
102
+ private function callAPIMethod($method, array $args = array())
103
+ {
104
+ $absoluteUrl = $this->baseURL."/merchant/API/".$method;
105
+
106
+ if(!is_null($this->logger))
107
+ {
108
+ $loggedArgs = $args;
109
+ if(isset($loggedArgs['cardnum']))
110
+ {
111
+ $loggedArgs['cardnum'] = $this->maskPan($loggedArgs['cardnum']);
112
+ }
113
+ if(isset($loggedArgs['cvc']))
114
+ {
115
+ $loggedArgs['cvc'] = str_repeat('x', strlen($loggedArgs['cvc']));
116
+ }
117
+ $logId = $this->logger->logRequest($absoluteUrl.'?'.http_build_query($loggedArgs));
118
+ }
119
+
120
+ $request = new AltapayHttpRequest();
121
+ $request->setUrl($absoluteUrl);
122
+ $request->setParameters($args);
123
+ $request->setUser($this->username);
124
+ $request->setPass($this->password);
125
+ $request->setMethod('POST');
126
+ $request->addHeader('x-altapay-client-version: '.ALTAPAY_VERSION);
127
+
128
+ $response = $this->httpUtil->requestURL($request);
129
+
130
+ if(!is_null($this->logger))
131
+ {
132
+ $this->logger->logResponse($logId, print_r($response, true));
133
+ }
134
+
135
+ if($response->getConnectionResult() == AltapayHttpResponse::CONNECTION_OKAY)
136
+ {
137
+ if($response->getHttpCode() == 200)
138
+ {
139
+ if(stripos($response->getContentType(), "text/xml") !== false)
140
+ {
141
+ try
142
+ {
143
+ return new SimpleXMLElement($response->getContent());
144
+ }
145
+ catch(Exception $e)
146
+ {
147
+ if($e->getMessage() == 'String could not be parsed as XML')
148
+ {
149
+ throw new AltapayInvalidResponseException("Unparsable XML Content in response");
150
+ }
151
+ throw new AltapayUnknownMerchantAPIException($e);
152
+ }
153
+ }
154
+ elseif (stripos($response->getContentType(), "text/csv") !== false)
155
+ {
156
+ return $response->getContent();
157
+ }
158
+ else
159
+ {
160
+ throw new AltapayInvalidResponseException("Non XML ContentType (was: ".$response->getContentType().")");
161
+ }
162
+ }
163
+ else if($response->getHttpCode() == 401)
164
+ {
165
+ throw new AltapayUnauthorizedAccessException($absoluteUrl, $this->username);
166
+ }
167
+ else
168
+ {
169
+ throw new AltapayInvalidResponseException("Non HTTP 200 Response: ".$response->getHttpCode());
170
+ }
171
+ }
172
+ else if($response->getConnectionResult() == AltapayHttpResponse::CONNECTION_REFUSED)
173
+ {
174
+ throw new AltapayConnectionFailedException($absoluteUrl, 'Connection refused');
175
+ }
176
+ else if($response->getConnectionResult() == AltapayHttpResponse::CONNECTION_TIMEOUT)
177
+ {
178
+ throw new AltapayConnectionFailedException($absoluteUrl, 'Connection timed out');
179
+ }
180
+ else if($response->getConnectionResult() == AltapayHttpResponse::CONNECTION_READ_TIMEOUT)
181
+ {
182
+ throw new AltapayRequestTimeoutException($absoluteUrl);
183
+ }
184
+ else
185
+ {
186
+ throw new AltapayUnknownMerchantAPIException();
187
+ }
188
+ }
189
+
190
+ /**
191
+ * @return AltapayFundingListResponse
192
+ * @throws AltapayMerchantAPIException
193
+ */
194
+ public function getFundingList($page=0)
195
+ {
196
+ $this->checkConnection();
197
+
198
+ return new AltapayFundingListResponse($this->callAPIMethod('fundingList', array('page'=>$page)));
199
+ }
200
+
201
+ /**
202
+ * @return string|boolean
203
+ * @throws AltapayMerchantAPIException
204
+ */
205
+ public function downloadFundingCSV(AltapayAPIFunding $funding)
206
+ {
207
+ $this->checkConnection();
208
+
209
+ $request = new AltapayHttpRequest();
210
+ $request->setUrl($funding->getDownloadLink());
211
+ $request->setUser($this->username);
212
+ $request->setPass($this->password);
213
+ $request->setMethod('GET');
214
+
215
+ $response = $this->httpUtil->requestURL($request);
216
+
217
+ if($response->getHttpCode() == 200)
218
+ {
219
+ return $response->getContent();
220
+ }
221
+
222
+ return false;
223
+ }
224
+
225
+ /**
226
+ * @return string|boolean
227
+ * @throws AltapayMerchantAPIException
228
+ */
229
+ public function downloadFundingCSVByLink($downloadLink)
230
+ {
231
+ $this->checkConnection();
232
+
233
+ $request = new AltapayHttpRequest();
234
+
235
+ $request->setUrl($downloadLink);
236
+ $request->setUser($this->username);
237
+ $request->setPass($this->password);
238
+ $request->setMethod('GET');
239
+
240
+ $response = $this->httpUtil->requestURL($request);
241
+
242
+ if($response->getHttpCode() == 200)
243
+ {
244
+ return $response->getContent();
245
+ }
246
+
247
+ return false;
248
+ }
249
+
250
+ private function reservationInternal(
251
+ $apiMethod
252
+ , $terminal
253
+ , $shop_orderid
254
+ , $amount
255
+ , $currency
256
+ , $cc_num
257
+ , $cc_expiry_year
258
+ , $cc_expiry_month
259
+ , $credit_card_token
260
+ , $cvc
261
+ , $type
262
+ , $payment_source
263
+ , array $customerInfo
264
+ , array $transaction_info)
265
+ {
266
+ $this->checkConnection();
267
+
268
+ $args = array(
269
+ 'terminal'=>$terminal,
270
+ 'shop_orderid'=>$shop_orderid,
271
+ 'amount'=>$amount,
272
+ 'currency'=>$currency,
273
+ 'cvc'=>$cvc,
274
+ 'type'=>$type,
275
+ 'payment_source'=>$payment_source
276
+ );
277
+ if(!is_null($credit_card_token))
278
+ {
279
+ $args['credit_card_token'] = $credit_card_token;
280
+ }
281
+ else
282
+ {
283
+ $args['cardnum'] = $cc_num;
284
+ $args['emonth'] = $cc_expiry_month;
285
+ $args['eyear'] = $cc_expiry_year;
286
+ }
287
+
288
+ if(!is_null($customerInfo) && is_array($customerInfo))
289
+ {
290
+ $this->addCustomerInfo($customerInfo, $args);
291
+ }
292
+
293
+ // Not needed when everyone has been upgraded to 20150428
294
+ // ====================================================================
295
+ foreach(array('billing_city', 'billing_region', 'billing_postal', 'billing_country', 'email', 'customer_phone', 'bank_name', 'bank_phone', 'billing_firstname', 'billing_lastname', 'billing_address') as $custField)
296
+ {
297
+ if(isset($customerInfo[$custField]))
298
+ {
299
+ $args[$custField] = $customerInfo[$custField];
300
+ }
301
+ }
302
+ // ====================================================================
303
+ if(count($transaction_info) > 0)
304
+ {
305
+ $args['transaction_info'] = $transaction_info;
306
+ }
307
+
308
+ return new AltapayReservationResponse(
309
+ $this->callAPIMethod(
310
+ $apiMethod,
311
+ $args
312
+ )
313
+ );
314
+ }
315
+
316
+
317
+ /**
318
+ * @return AltapayReservationResponse
319
+ * @throws AltapayMerchantAPIException
320
+ */
321
+ public function reservationOfFixedAmount(
322
+ $terminal
323
+ , $shop_orderid
324
+ , $amount
325
+ , $currency
326
+ , $cc_num
327
+ , $cc_expiry_year
328
+ , $cc_expiry_month
329
+ , $cvc
330
+ , $payment_source
331
+ , array $customerInfo = array()
332
+ , array $transactionInfo = array())
333
+ {
334
+ return $this->reservationInternal(
335
+ 'reservationOfFixedAmountMOTO'
336
+ , $terminal
337
+ , $shop_orderid
338
+ , $amount
339
+ , $currency
340
+ , $cc_num
341
+ , $cc_expiry_year
342
+ , $cc_expiry_month
343
+ , null // $credit_card_token
344
+ , $cvc
345
+ , 'payment'
346
+ , $payment_source
347
+ , $customerInfo
348
+ , $transactionInfo);
349
+ }
350
+
351
+ /**
352
+ * @return AltapayReservationResponse
353
+ * @throws AltapayMerchantAPIException
354
+ */
355
+ public function reservationOfFixedAmountMOTOWithToken(
356
+ $terminal
357
+ , $shop_orderid
358
+ , $amount
359
+ , $currency
360
+ , $credit_card_token
361
+ , $cvc = null
362
+ , $payment_source = 'moto'
363
+ , array $customerInfo = array()
364
+ , array $transactionInfo = array())
365
+ {
366
+ return $this->reservationInternal(
367
+ 'reservationOfFixedAmountMOTO'
368
+ , $terminal
369
+ , $shop_orderid
370
+ , $amount
371
+ , $currency
372
+ , null
373
+ , null
374
+ , null
375
+ , $credit_card_token
376
+ , $cvc
377
+ , 'payment'
378
+ , $payment_source
379
+ , $customerInfo
380
+ , $transactionInfo);
381
+ }
382
+
383
+ /**
384
+ * @return AltapayReservationResponse
385
+ * @throws AltapayMerchantAPIException
386
+ */
387
+ public function setupSubscription(
388
+ $terminal
389
+ , $shop_orderid
390
+ , $amount
391
+ , $currency
392
+ , $cc_num
393
+ , $cc_expiry_year
394
+ , $cc_expiry_month
395
+ , $cvc
396
+ , $payment_source
397
+ , array $customerInfo = array()
398
+ , array $transactionInfo = array())
399
+ {
400
+ return $this->reservationInternal(
401
+ 'setupSubscription'
402
+ , $terminal
403
+ , $shop_orderid
404
+ , $amount
405
+ , $currency
406
+ , $cc_num
407
+ , $cc_expiry_year
408
+ , $cc_expiry_month
409
+ , null // $credit_card_token
410
+ , $cvc
411
+ , 'subscription'
412
+ , $payment_source
413
+ , $customerInfo
414
+ , $transactionInfo);
415
+ }
416
+
417
+ /**
418
+ * @return AltapayReservationResponse
419
+ * @throws AltapayMerchantAPIException
420
+ */
421
+ public function setupSubscriptionWithToken(
422
+ $terminal
423
+ , $shop_orderid
424
+ , $amount
425
+ , $currency
426
+ , $credit_card_token
427
+ , $cvc = null
428
+ , $payment_source = 'moto'
429
+ , array $customerInfo = array()
430
+ , array $transactionInfo = array())
431
+ {
432
+ return $this->reservationInternal(
433
+ 'setupSubscription'
434
+ , $terminal
435
+ , $shop_orderid
436
+ , $amount
437
+ , $currency
438
+ , null
439
+ , null
440
+ , null
441
+ , $credit_card_token
442
+ , $cvc
443
+ , 'subscription'
444
+ , $payment_source
445
+ , $customerInfo
446
+ , $transactionInfo);
447
+ }
448
+
449
+ /**
450
+ * @return AltapayReservationResponse
451
+ * @throws AltapayMerchantAPIException
452
+ */
453
+ public function verifyCard(
454
+ $terminal
455
+ , $shop_orderid
456
+ , $currency
457
+ , $cc_num
458
+ , $cc_expiry_year
459
+ , $cc_expiry_month
460
+ , $cvc
461
+ , $payment_source
462
+ , array $customerInfo = array()
463
+ , array $transactionInfo = array())
464
+ {
465
+ return $this->reservationInternal(
466
+ 'reservationOfFixedAmountMOTO'
467
+ , $terminal
468
+ , $shop_orderid
469
+ , 1.00
470
+ , $currency
471
+ , $cc_num
472
+ , $cc_expiry_year
473
+ , $cc_expiry_month
474
+ , null // $credit_card_token
475
+ , $cvc
476
+ , 'verifyCard'
477
+ , $payment_source
478
+ , $customerInfo
479
+ , $transactionInfo);
480
+ }
481
+
482
+ /**
483
+ * @return AltapayReservationResponse
484
+ * @throws AltapayMerchantAPIException
485
+ */
486
+ public function verifyCardWithToken(
487
+ $terminal
488
+ , $shop_orderid
489
+ , $currency
490
+ , $credit_card_token
491
+ , $cvc = null
492
+ , $payment_source = 'moto'
493
+ , array $customerInfo = array()
494
+ , array $transactionInfo = array())
495
+ {
496
+ return $this->reservationInternal(
497
+ 'reservationOfFixedAmountMOTO'
498
+ , $terminal
499
+ , $shop_orderid
500
+ , 1.00
501
+ , $currency
502
+ , null
503
+ , null
504
+ , null
505
+ , $credit_card_token
506
+ , $cvc
507
+ , 'verifyCard'
508
+ , $payment_source
509
+ , $customerInfo
510
+ , $transactionInfo);
511
+ }
512
+
513
+
514
+ /**
515
+ * @return AltapayCaptureResponse
516
+ * @throws AltapayMerchantAPIException
517
+ */
518
+ public function captureReservation($paymentId, $amount=null, array $orderLines=array(), $salesTax=null, $reconciliationIdentifier=null, $invoiceNumber=null)
519
+ {
520
+ $this->checkConnection();
521
+
522
+ return new AltapayCaptureResponse(
523
+ $this->callAPIMethod(
524
+ 'captureReservation',
525
+ array(
526
+ 'transaction_id'=>$paymentId,
527
+ 'amount'=>$amount,
528
+ 'orderLines'=>$orderLines,
529
+ 'sales_tax'=>$salesTax,
530
+ 'reconciliation_identifier'=>$reconciliationIdentifier,
531
+ 'invoice_number'=>$invoiceNumber
532
+ )
533
+ )
534
+ );
535
+ }
536
+
537
+ /**
538
+ * @return AltapayRefundResponse
539
+ * @throws AltapayMerchantAPIException
540
+ */
541
+ public function refundCapturedReservation($paymentId, $amount=null, $orderLines=null, $reconciliationIdentifier=null, $allowOverRefund=null, $invoiceNumber=null)
542
+ {
543
+ $this->checkConnection();
544
+
545
+ return new AltapayRefundResponse(
546
+ $this->callAPIMethod(
547
+ 'refundCapturedReservation',
548
+ array(
549
+ 'transaction_id'=>$paymentId,
550
+ 'amount'=>$amount,
551
+ 'orderLines'=>$orderLines,
552
+ 'reconciliation_identifier'=>$reconciliationIdentifier,
553
+ 'allow_over_refund'=>$allowOverRefund,
554
+ 'invoice_number'=>$invoiceNumber
555
+ )
556
+ )
557
+ );
558
+ }
559
+
560
+ /**
561
+ * @return AltapayReleaseResponse
562
+ * @throws AltapayMerchantAPIException
563
+ */
564
+ public function releaseReservation($paymentId, $amount=null)
565
+ {
566
+ $this->checkConnection();
567
+
568
+ return new AltapayReleaseResponse(
569
+ $this->callAPIMethod(
570
+ 'releaseReservation',
571
+ array(
572
+ 'transaction_id'=>$paymentId
573
+ )
574
+ )
575
+ );
576
+ }
577
+
578
+ /**
579
+ * @return AltapayGetPaymentResponse
580
+ * @throws AltapayMerchantAPIException
581
+ */
582
+ public function getPayment($paymentId)
583
+ {
584
+ $this->checkConnection();
585
+
586
+ return new AltapayGetPaymentResponse($this->callAPIMethod(
587
+ 'payments',
588
+ array(
589
+ 'transaction'=>$paymentId
590
+ )
591
+ ));
592
+ }
593
+
594
+ /**
595
+ * @return AltapayGetTerminalsResponse
596
+ * @throws AltapayMerchantAPIException
597
+ */
598
+ public function getTerminals()
599
+ {
600
+ $this->checkConnection();
601
+
602
+ return new AltapayGetTerminalsResponse($this->callAPIMethod('getTerminals'));
603
+ }
604
+
605
+ /**
606
+ * @return AltapayLoginResponse
607
+ * @throws AltapayMerchantAPIException
608
+ */
609
+ public function login()
610
+ {
611
+ $this->connected = false;
612
+
613
+ $response = new AltapayLoginResponse($this->callAPIMethod('login'));
614
+
615
+ if($response->getErrorCode() === '0')
616
+ {
617
+ $this->connected = true;
618
+ }
619
+
620
+ return $response;
621
+ }
622
+
623
+ /**
624
+ * @return AltapayCreatePaymentRequestResponse
625
+ * @throws AltapayMerchantAPIException
626
+ */
627
+ public function createPaymentRequest($terminal,
628
+ $orderid,
629
+ $amount,
630
+ $currencyCode,
631
+ $paymentType,
632
+ $customerInfo = null,
633
+ $cookie = null,
634
+ $language = null,
635
+ array $config = array(),
636
+ array $transaction_info = array(),
637
+ array $orderLines = array(),
638
+ $accountOffer = false,
639
+ $ccToken = null
640
+ )
641
+ {
642
+ $args = array(
643
+ 'terminal'=>$terminal,
644
+ 'shop_orderid'=>$orderid,
645
+ 'amount'=>$amount,
646
+ 'currency'=>$currencyCode,
647
+ 'type'=>$paymentType
648
+ );
649
+
650
+ if(!is_null($customerInfo) && is_array($customerInfo))
651
+ {
652
+ $this->addCustomerInfo($customerInfo, $args);
653
+ }
654
+
655
+ if(!is_null($cookie))
656
+ {
657
+ $args['cookie'] = $cookie;
658
+ }
659
+ if(!is_null($language))
660
+ {
661
+ $args['language'] = $language;
662
+ }
663
+ if(count($transaction_info) > 0)
664
+ {
665
+ $args['transaction_info'] = $transaction_info;
666
+ }
667
+ if(count($orderLines) > 0)
668
+ {
669
+ $args['orderLines'] = $orderLines;
670
+ }
671
+ if(in_array($accountOffer, array("required", "disabled")))
672
+ {
673
+ $args['account_offer'] = $accountOffer;
674
+ }
675
+ if(!is_null($ccToken))
676
+ {
677
+ $args['ccToken'] = $ccToken;
678
+ }
679
+
680
+ $args['config'] = $config;
681
+
682
+
683
+ return new AltapayCreatePaymentRequestResponse($this->callAPIMethod('createPaymentRequest', $args));
684
+ }
685
+
686
+ /**
687
+ * @return AltapayCaptureRecurringResponse
688
+ * @deprecated - use chargeSubscription instead.
689
+ * @throws AltapayMerchantAPIException
690
+ */
691
+ public function captureRecurring($subscriptionId, $amount=null)
692
+ {
693
+ return $this->chargeSubscription($subscriptionId, $amount);
694
+ }
695
+
696
+ /**
697
+ * @return AltapayCaptureRecurringResponse
698
+ * @throws AltapayMerchantAPIException
699
+ */
700
+ public function chargeSubscription($subscriptionId, $amount=null)
701
+ {
702
+ $this->checkConnection();
703
+
704
+ return new AltapayCaptureRecurringResponse(
705
+ $this->callAPIMethod(
706
+ 'chargeSubscription',
707
+ array(
708
+ 'transaction_id'=>$subscriptionId,
709
+ 'amount'=>$amount,
710
+ )
711
+ )
712
+ );
713
+ }
714
+
715
+ /**
716
+ * @return AltapayPreauthRecurringResponse
717
+ * @deprecated - use reserveSubscriptionCharge instead
718
+ * @throws AltapayMerchantAPIException
719
+ */
720
+ public function preauthRecurring($subscriptionId, $amount=null)
721
+ {
722
+ return $this->reserveSubscriptionCharge($subscriptionId, $amount);
723
+ }
724
+
725
+
726
+ /**
727
+ * @return AltapayPreauthRecurringResponse
728
+ * @throws AltapayMerchantAPIException
729
+ */
730
+ public function reserveSubscriptionCharge($subscriptionId, $amount=null)
731
+ {
732
+ $this->checkConnection();
733
+
734
+ return new AltapayPreauthRecurringResponse(
735
+ $this->callAPIMethod(
736
+ 'reserveSubscriptionCharge',
737
+ array(
738
+ 'transaction_id'=>$subscriptionId,
739
+ 'amount'=>$amount,
740
+ )
741
+ )
742
+ );
743
+ }
744
+
745
+ /**
746
+ * @return AltapayCalculateSurchargeResponse
747
+ * @throws AltapayMerchantAPIException
748
+ */
749
+ public function calculateSurcharge($terminal, $cardToken, $amount, $currency)
750
+ {
751
+ $this->checkConnection();
752
+
753
+ return new AltapayCalculateSurchargeResponse(
754
+ $this->callAPIMethod(
755
+ 'calculateSurcharge',
756
+ array(
757
+ 'terminal'=>$terminal,
758
+ 'credit_card_token'=>$cardToken,
759
+ 'amount'=>$amount,
760
+ 'currency'=>$currency,
761
+ )
762
+ )
763
+ );
764
+ }
765
+
766
+ /**
767
+ * @return AltapayCalculateSurchargeResponse
768
+ * @throws AltapayMerchantAPIException
769
+ */
770
+ public function calculateSurchargeForSubscription($subscriptionId, $amount)
771
+ {
772
+ $this->checkConnection();
773
+
774
+ return new AltapayCalculateSurchargeResponse(
775
+ $this->callAPIMethod(
776
+ 'calculateSurcharge',
777
+ array(
778
+ 'payment_id'=>$subscriptionId,
779
+ 'amount'=>$amount,
780
+ )
781
+ )
782
+ );
783
+ }
784
+
785
+ /**
786
+ * @return string|boolean
787
+ * @throws AltapayMerchantAPIException
788
+ */
789
+ public function getCustomReport($args)
790
+ {
791
+ $this->checkConnection();
792
+ $response = $this->callAPIMethod('getCustomReport', $args);
793
+ return $response;
794
+ }
795
+
796
+ /**
797
+ * @return string|boolean
798
+ * @throws AltapayMerchantAPIException
799
+ */
800
+ public function getTransactions(AltapayAPITransactionsRequest $transactionsRequest)
801
+ {
802
+ $this->checkConnection();
803
+ return $this->callAPIMethod('transactions', $transactionsRequest->asArray());
804
+ }
805
+
806
+ /**
807
+ * @param $customerInfo
808
+ * @param $args
809
+ * @throws AltapayMerchantAPIException
810
+ */
811
+ private function addCustomerInfo($customerInfo, &$args)
812
+ {
813
+ $errors = array();
814
+
815
+ foreach ($customerInfo as $customerInfoKey => $customerInfoValue) {
816
+ if (is_array($customerInfo[$customerInfoKey])) {
817
+ $errors[] = "customer_info[$customerInfoKey] is not expected to be an array";
818
+ }
819
+ }
820
+ if (count($errors) > 0) {
821
+ throw new AltapayMerchantAPIException("Failed to create customer_info variable: \n" . print_r($errors, true));
822
+ }
823
+ $args['customer_info'] = $customerInfo;
824
+ }
825
+ }
app/code/community/Altapay/Payment/Model/Api/IAltapayCommunicationLogger.class.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ interface IAltapayCommunicationLogger
4
+ {
5
+ /**
6
+ * Will get a string representation of the request being sent to Altapay.
7
+ * @param string $message
8
+ * @return string - A log-id used to match the request and response
9
+ */
10
+ public function logRequest($message);
11
+
12
+ /**
13
+ * Will get a string representation of the response from Altapay for the request identified by the logId
14
+ *
15
+ * @param string $logId
16
+ * @param string $message
17
+ */
18
+ public function logResponse($logId, $message);
19
+ }
app/code/community/Altapay/Payment/Model/Api/exceptions/AltapayConnectionFailedException.class.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AltapayConnectionFailedException extends AltapayMerchantAPIException
4
+ {
5
+ public function __construct($url, $reason)
6
+ {
7
+ parent::__construct("Connection to ".$url." failed (reason: ".$reason.")", 23483431);
8
+ }
9
+
10
+ }
app/code/community/Altapay/Payment/Model/Api/exceptions/AltapayInvalidResponseException.class.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AltapayInvalidResponseException extends AltapayMerchantAPIException
4
+ {
5
+
6
+ }
app/code/community/Altapay/Payment/Model/Api/exceptions/AltapayMerchantAPIException.class.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AltapayMerchantAPIException extends Exception
4
+ {
5
+
6
+ }
app/code/community/Altapay/Payment/Model/Api/exceptions/AltapayRequestTimeoutException.class.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AltapayRequestTimeoutException extends AltapayMerchantAPIException
4
+ {
5
+ public function __construct($url)
6
+ {
7
+ parent::__construct("Request to ".$url." timed out", 39824714);
8
+ }
9
+ }
app/code/community/Altapay/Payment/Model/Api/exceptions/AltapayUnauthorizedAccessException.class.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AltapayUnauthorizedAccessException extends AltapayMerchantAPIException
4
+ {
5
+ public function __construct($url, $username)
6
+ {
7
+ parent::__construct("Unauthorized access to ".$url." for user ".$username, 9283745);
8
+ }
9
+ }
app/code/community/Altapay/Payment/Model/Api/exceptions/AltapayUnknownMerchantAPIException.class.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AltapayUnknownMerchantAPIException extends AltapayMerchantAPIException
4
+ {
5
+ /**
6
+ * @var Exception
7
+ */
8
+ private $cause;
9
+
10
+ public function __construct(Exception $cause = null)
11
+ {
12
+ parent::__construct("Unknown error".(!is_null($cause) ? ' caused by: '.$cause->getMessage() : ''));
13
+ $this->cause = $cause;
14
+ }
15
+
16
+ public function getCause()
17
+ {
18
+ return $this->cause;
19
+ }
20
+ }
app/code/community/Altapay/Payment/Model/Api/exceptions/AltapayXmlException.class.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AltapayXmlException extends Exception
4
+ {
5
+ /**
6
+ * @var SimpleXMLElement
7
+ */
8
+ private $xml;
9
+
10
+ public function __construct($message, SimpleXMLElement $xml)
11
+ {
12
+ parent::__construct($message ."\n\n".$xml->asXML());
13
+ $this->xml = $xml;
14
+ }
15
+
16
+ public function getXml()
17
+ {
18
+ return $this->xml;
19
+ }
20
+ }
app/code/community/Altapay/Payment/Model/Api/http/AltapayCurlBasedHttpUtils.class.php ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ALTAPAY_API_ROOT'))
4
+ {
5
+ define('ALTAPAY_API_ROOT',dirname(__DIR__));
6
+ }
7
+
8
+ require_once(ALTAPAY_API_ROOT.'/http/IAltapayHttpUtils.class.php');
9
+
10
+
11
+ class AltapayCurlBasedHttpUtils implements IAltapayHttpUtils
12
+ {
13
+ public function __construct($timeoutSeconds=60, $connectionTimeout=30)
14
+ {
15
+ $this->timeout = $timeoutSeconds;
16
+ $this->connectionTimeout = $connectionTimeout;
17
+ }
18
+
19
+ /**
20
+ * @return AltapayHttpResponse
21
+ */
22
+ public function requestURL(AltapayHttpRequest $request)
23
+ {
24
+ $curl = curl_init();
25
+ if(!is_null($request->getUser()) && !is_null($request->getPass()))
26
+ {
27
+ curl_setopt($curl, CURLOPT_USERPWD, $request->getUser().":".$request->getPass());
28
+ }
29
+
30
+ curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout);
31
+ curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $this->connectionTimeout);
32
+
33
+ if(!is_null($request->getCookie()))
34
+ {
35
+ curl_setopt($curl, CURLOPT_COOKIE, $request->getCookie());
36
+ }
37
+
38
+ if(!is_null($request->getHeaders()) && count($request->getHeaders()) > 0)
39
+ {
40
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $request->getHeaders());
41
+ }
42
+ curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
43
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, false);
44
+ curl_setopt($curl, CURLOPT_HEADER, false);
45
+
46
+ // Container for the header/content
47
+ $httpResponse = new AltapayHttpResponse();
48
+ curl_setopt($curl, CURLOPT_HEADERFUNCTION, array($httpResponse,'curlReadHeader'));
49
+ curl_setopt($curl, CURLOPT_WRITEFUNCTION, array($httpResponse,'curlReadContent'));
50
+
51
+ $url = $request->getUrl();
52
+ switch($request->getMethod())
53
+ {
54
+ case 'POST':
55
+ if(!is_null($request->getPostContent()))
56
+ {
57
+ $data = $request->getPostContent();
58
+ }
59
+ else
60
+ {
61
+ $data = http_build_query($request->getParameters());
62
+ }
63
+ curl_setopt($curl, CURLOPT_POST, true);
64
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
65
+ break;
66
+ case 'GET':
67
+ $url = $this->appendToUrl($url, $request->getParameters());
68
+ curl_setopt($curl, CURLOPT_HTTPGET, true);
69
+ break;
70
+ }
71
+
72
+ curl_setopt($curl, CURLOPT_URL, $url);
73
+ curl_setopt($curl, CURLINFO_HEADER_OUT, true);
74
+
75
+ curl_exec($curl);
76
+
77
+ $requestHeaders = curl_getinfo($curl, CURLINFO_HEADER_OUT);
78
+ $curl_info = curl_getinfo($curl);
79
+ $charsetAndMime = $this->getCharsetAndMime($curl);
80
+ $errorMessage = curl_error($curl);
81
+ $errorNumber = curl_errno($curl);
82
+ curl_close($curl);
83
+
84
+ $httpResponse->setRequestHeader($requestHeaders);
85
+ $httpResponse->setInfo($curl_info);
86
+ $httpResponse->setErrorMessage($errorMessage);
87
+ $httpResponse->setErrorNumber($errorNumber);
88
+
89
+ // Fix encoding
90
+ if(isset($charsetAndMime['charset']))
91
+ {
92
+ // Actually convert the bytes
93
+ if(strtolower($charsetAndMime['charset']) != 'utf-8')
94
+ {
95
+ $httpResponse->setContent(iconv($charsetAndMime['charset'], 'utf-8', $httpResponse->getContent()));
96
+
97
+ // Replace in header
98
+ if($charsetAndMime['mime'] == 'text/html')
99
+ {
100
+ $httpResponse->setContent(str_ireplace(
101
+ 'charset='.$charsetAndMime['charset'].'',
102
+ 'charset=utf-8',
103
+ $httpResponse->getContent()
104
+ ));
105
+ }
106
+ }
107
+ }
108
+
109
+ if($httpResponse->getErrorMessage() == 'connect() timed out!'
110
+ || preg_match('/Connection timed out/i', $httpResponse->getErrorMessage()))
111
+ {
112
+ $httpResponse->setConnectionResult(AltapayHttpResponse::CONNECTION_TIMEOUT);
113
+ }
114
+ else if($httpResponse->getErrorMessage() == 'couldn\'t connect to host'
115
+ || preg_match('/Connection refused/i', $httpResponse->getErrorMessage()))
116
+ {
117
+ $httpResponse->setConnectionResult(AltapayHttpResponse::CONNECTION_REFUSED);
118
+ }
119
+ else if(preg_match('/Operation timed out/i', $httpResponse->getErrorMessage()))
120
+ {
121
+ $httpResponse->setConnectionResult(AltapayHttpResponse::CONNECTION_READ_TIMEOUT);
122
+ }
123
+ else
124
+ {
125
+ $httpResponse->setConnectionResult(AltapayHttpResponse::CONNECTION_OKAY);
126
+ }
127
+
128
+ return $httpResponse;
129
+ }
130
+
131
+
132
+ private function getCharsetAndMime(&$curl)
133
+ {
134
+ /* Get the content type from CURL */
135
+ $content_type = curl_getinfo( $curl, CURLINFO_CONTENT_TYPE );
136
+
137
+ /* Get the MIME type and character set */
138
+ preg_match( '@([\w/+]+)(;\s+charset=(\S+))?@i', $content_type, $matches );
139
+ $result = array();
140
+ if ( isset( $matches[1] ) )
141
+ {
142
+ $result['mime'] = $matches[1];
143
+ }
144
+ if ( isset( $matches[3] ) )
145
+ {
146
+ $result['charset'] = $matches[3];
147
+ }
148
+ return $result;
149
+ }
150
+
151
+ /**
152
+ * This method will append the given parameters to the URL. Using a ? or a & depending on the url
153
+ *
154
+ * @param string$url
155
+ * @param array $parameters
156
+ * @return string - the URL with the new parameters appended
157
+ */
158
+ public function appendToUrl($url, array $parameters)
159
+ {
160
+ if(count($parameters) > 0)
161
+ {
162
+ $append = http_build_query($parameters);
163
+ return $url.(strstr($url, "?") ? "&" : "?").$append;
164
+ }
165
+ return $url;
166
+ }
167
+ }
app/code/community/Altapay/Payment/Model/Api/http/AltapayFOpenBasedHttpUtils.class.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ALTAPAY_API_ROOT'))
4
+ {
5
+ define('ALTAPAY_API_ROOT',dirname(__DIR__));
6
+ }
7
+
8
+ require_once(ALTAPAY_API_ROOT.'/http/IAltapayHttpUtils.class.php');
9
+
10
+ class AltapayFOpenBasedHttpUtils implements IAltapayHttpUtils
11
+ {
12
+ private $streamState;
13
+
14
+ public function __construct($timeoutSeconds=60, $connectionTimeout=30)
15
+ {
16
+ $this->timeout = $timeoutSeconds;
17
+ $this->connectionTimeout = $connectionTimeout;
18
+ }
19
+
20
+ /**
21
+ * @return AltapayHttpResponse
22
+ */
23
+ public function requestURL(AltapayHttpRequest $request)
24
+ {
25
+ $this->streamState = 'NOT_CONNECTED';
26
+
27
+ global $http_response_header;
28
+ $context = $this->createContext($request);
29
+
30
+ $url = ($request->getMethod() == 'GET') ? $this->appendToUrl($request->getUrl(), $request->getParameters()) : $request->getUrl();
31
+ $content = @file_get_contents($url, false, $context);
32
+ $response = new AltapayHttpResponse();
33
+ $response->setInfo(array('http_code'=>$this->getHttpCodeFromHeader($http_response_header)));
34
+ if($content !== false)
35
+ {
36
+ $response->setHeader($http_response_header);
37
+ $response->setContent($content);
38
+ $response->setConnectionResult(AltapayHttpResponse::CONNECTION_OKAY);
39
+ }
40
+ else
41
+ {
42
+ if($this->streamState == 'NOT_CONNECTED')
43
+ {
44
+ $response->setConnectionResult(AltapayHttpResponse::CONNECTION_REFUSED);
45
+ }
46
+ else
47
+ {
48
+ $response->setConnectionResult(AltapayHttpResponse::CONNECTION_READ_TIMEOUT);
49
+ }
50
+ }
51
+
52
+ return $response;
53
+ }
54
+
55
+ private function createContext(AltapayHttpRequest $request)
56
+ {
57
+ $args = array(
58
+ 'http' => array(
59
+ 'method' => $request->getMethod(),
60
+ 'header' => sprintf("Authorization: Basic %s\r\n", base64_encode($request->getUser().':'.$request->getPass())).
61
+ "Content-type: application/x-www-form-urlencoded\r\n",
62
+ 'timeout' => $this->timeout,
63
+ 'ignore_errors' => true,
64
+ ),
65
+ );
66
+ if($request->getMethod() == 'POST')
67
+ {
68
+ $args['http']['content'] = http_build_query($request->getParameters());
69
+ }
70
+ $context = stream_context_create($args);
71
+ stream_context_set_params($context, array('notification' => array($this, 'stream_notification_callback')));
72
+ return $context;
73
+ }
74
+
75
+ public function stream_notification_callback($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max)
76
+ {
77
+ switch($notification_code) {
78
+ case STREAM_NOTIFY_FAILURE:
79
+ if(strpos($message, '401 Unauthorized'))
80
+ {
81
+ $this->streamState = 'AUTH_FAILED';
82
+ }
83
+ break;
84
+ case STREAM_NOTIFY_CONNECT:
85
+ $this->streamState = 'CONNECTED';
86
+ break;
87
+ default:
88
+ //echo "Notification: ".$notification_code."\n";
89
+ break;
90
+ }
91
+ }
92
+
93
+ private function getHttpCodeFromHeader($http_response_header)
94
+ {
95
+ if(is_array($http_response_header) && isset($http_response_header[0]))
96
+ {
97
+ if(preg_match('/HTTP\/[0-9\.]+ ([0-9]{3}) .*/', $http_response_header[0], $matches))
98
+ {
99
+ return $matches[1];
100
+ }
101
+ }
102
+ return 0;
103
+ }
104
+
105
+ /**
106
+ * This method will append the given parameters to the URL. Using a ? or a & depending on the url
107
+ *
108
+ * @param string$url
109
+ * @param array $parameters
110
+ * @return string - the URL with the new parameters appended
111
+ */
112
+ public function appendToUrl($url, array $parameters)
113
+ {
114
+ if(count($parameters) > 0)
115
+ {
116
+ $append = http_build_query($parameters);
117
+ return $url.(strstr($url, "?") ? "&" : "?").$append;
118
+ }
119
+ return $url;
120
+ }
121
+ }
app/code/community/Altapay/Payment/Model/Api/http/AltapayHttpRequest.class.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AltapayHttpRequest
4
+ {
5
+ private $url;
6
+ private $method = 'GET';
7
+ private $parameters = array();
8
+ private $postContent;
9
+ private $user;
10
+ private $pass;
11
+ private $logPaymentId;
12
+ private $logPaymentRequestId;
13
+ private $cookie;
14
+ private $headers = array();
15
+
16
+ public function getUrl() { return $this->url; }
17
+ public function getMethod() { return $this->method; }
18
+ public function getParameters() { return $this->parameters; }
19
+ public function getPostContent() { return $this->postContent; }
20
+ public function getUser() { return $this->user; }
21
+ public function getPass() { return $this->pass; }
22
+ public function getLogPaymentId() { return $this->logPaymentId; }
23
+ public function getLogPaymentRequestId() { return $this->logPaymentRequestId; }
24
+ public function getCookie() { return $this->cookie; }
25
+ public function getHeaders() { return $this->headers; }
26
+ public function setUrl($x) { $this->url = $x; }
27
+ public function setMethod($x) { $this->method = $x; }
28
+ public function setParameters($x) { $this->parameters = $x; }
29
+ public function setPostContent($x) { $this->postContent = $x; }
30
+ public function setUser($x) { $this->user = $x; }
31
+ public function setPass($x) { $this->pass = $x; }
32
+ public function setLogPaymentId($x) { $this->logPaymentId = $x; }
33
+ public function setLogPaymentRequestId($x) { $this->logPaymentRequestId = $x; }
34
+ public function setCookie($x) { $this->cookie = $x; }
35
+
36
+ public function addHeader($header)
37
+ {
38
+ $this->headers[] = $header;
39
+ }
40
+ }
app/code/community/Altapay/Payment/Model/Api/http/AltapayHttpResponse.class.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AltapayHttpResponse
4
+ {
5
+ const CONNECTION_REFUSED = 'CONNECTION_REFUSED';
6
+ const CONNECTION_TIMEOUT = 'CONNECTION_TIMEOUT';
7
+ const CONNECTION_READ_TIMEOUT = 'CONNECTION_READ_TIMEOUT';
8
+ const CONNECTION_OKAY = 'CONNECTION_OKAY';
9
+
10
+ private $requestHeader = '';
11
+ private $header = '';
12
+ private $content = '';
13
+ private $info;
14
+ private $errorMessage;
15
+ private $errorNumber;
16
+ private $connectionResult;
17
+
18
+ public function getHeader()
19
+ {
20
+ return $this->header;
21
+ }
22
+
23
+ public function getContentType()
24
+ {
25
+ if(preg_match('/^Content-Type: (.+)$/m',$this->header,$matches))
26
+ {
27
+ return trim($matches[1]);
28
+ }
29
+ }
30
+
31
+ public function getLocationHeader()
32
+ {
33
+ if(preg_match('/^Location: (.+)$/m',$this->header,$matches))
34
+ {
35
+ return trim($matches[1]);
36
+ }
37
+ }
38
+
39
+ public function getContent()
40
+ {
41
+ return $this->content;
42
+ }
43
+
44
+ public function setHeader($header)
45
+ {
46
+ if(is_array($header))
47
+ {
48
+ $header = implode("\r\n", $header);
49
+ }
50
+ $this->header = $header;
51
+ }
52
+
53
+ public function setContent($content)
54
+ {
55
+ $this->content = $content;
56
+ }
57
+
58
+ public function getRequestHeader()
59
+ {
60
+ return $this->requestHeader;
61
+ }
62
+
63
+ public function setRequestHeader($requestHeader)
64
+ {
65
+ $this->requestHeader = $requestHeader;
66
+ }
67
+
68
+ public function getInfo()
69
+ {
70
+ return $this->info;
71
+ }
72
+
73
+ public function setInfo($info)
74
+ {
75
+ $this->info = $info;
76
+ }
77
+
78
+ public function getErrorMessage()
79
+ {
80
+ return $this->errorMessage;
81
+ }
82
+
83
+ public function setErrorMessage($errorMessage)
84
+ {
85
+ $this->errorMessage = $errorMessage;
86
+ }
87
+
88
+ public function getErrorNumber()
89
+ {
90
+ return $this->errorNumber;
91
+ }
92
+
93
+ public function setErrorNumber($errorNumber)
94
+ {
95
+ $this->errorNumber = $errorNumber;
96
+ }
97
+
98
+ public function getConnectionResult()
99
+ {
100
+ return $this->connectionResult;
101
+ }
102
+
103
+ public function setConnectionResult($connectionResult)
104
+ {
105
+ $this->connectionResult = $connectionResult;
106
+ }
107
+
108
+ public function getHttpCode()
109
+ {
110
+ return $this->info['http_code'];
111
+ }
112
+
113
+ public function curlReadHeader(&$curl, $header)
114
+ {
115
+ $this->header .= $header;
116
+
117
+ return strlen($header);
118
+ }
119
+
120
+ public function curlReadContent(&$curl, $content)
121
+ {
122
+ $this->content .= $content;
123
+
124
+ return strlen($content);
125
+ }
126
+ }
app/code/community/Altapay/Payment/Model/Api/http/IAltapayHttpUtils.class.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ALTAPAY_API_ROOT'))
4
+ {
5
+ define('ALTAPAY_API_ROOT',dirname(__DIR__));
6
+ }
7
+
8
+ require_once(ALTAPAY_API_ROOT.'/http/AltapayHttpRequest.class.php');
9
+ require_once(ALTAPAY_API_ROOT.'/http/AltapayHttpResponse.class.php');
10
+
11
+ interface IAltapayHttpUtils
12
+ {
13
+ /**
14
+ * @return AltapayHttpResponse
15
+ */
16
+ public function requestURL(AltapayHttpRequest $request);
17
+ }
app/code/community/Altapay/Payment/Model/Api/request/AltapayAPITransactionsRequest.class.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AltapayAPITransactionsRequest
4
+ {
5
+ private $shop;
6
+ private $terminal;
7
+ private $transaction;
8
+ private $transactionId;
9
+ private $shopOrderId;
10
+ private $paymentStatus;
11
+ private $reconciliationIdentifier;
12
+ private $acquirerReconciliationIdentifier;
13
+
14
+ public function getShop()
15
+ {
16
+ return $this->shop;
17
+ }
18
+
19
+ public function setShop($shop)
20
+ {
21
+ $this->shop = $shop;
22
+ }
23
+
24
+ public function getTerminal()
25
+ {
26
+ return $this->terminal;
27
+ }
28
+
29
+ public function setTerminal($terminal)
30
+ {
31
+ $this->terminal = $terminal;
32
+ }
33
+
34
+ public function getTransaction()
35
+ {
36
+ return $this->transaction;
37
+ }
38
+
39
+ public function setTransaction($transaction)
40
+ {
41
+ $this->transaction = $transaction;
42
+ }
43
+
44
+ public function getTransactionId()
45
+ {
46
+ return $this->transactionId;
47
+ }
48
+
49
+ public function setTransactionId($transactionId)
50
+ {
51
+ $this->transactionId = $transactionId;
52
+ }
53
+
54
+ public function getShopOrderId()
55
+ {
56
+ return $this->shopOrderId;
57
+ }
58
+
59
+ public function setShopOrderId($shopOrderId)
60
+ {
61
+ $this->shopOrderId = $shopOrderId;
62
+ }
63
+
64
+ public function getPaymentStatus()
65
+ {
66
+ return $this->paymentStatus;
67
+ }
68
+
69
+ public function setPaymentStatus($paymentStatus)
70
+ {
71
+ $this->paymentStatus = $paymentStatus;
72
+ }
73
+
74
+ public function getReconciliationIdentifier()
75
+ {
76
+ return $this->reconciliationIdentifier;
77
+ }
78
+
79
+ public function setReconciliationIdentifier($reconciliationIdentifier)
80
+ {
81
+ $this->reconciliationIdentifier = $reconciliationIdentifier;
82
+ }
83
+
84
+ public function getAcquirerReconciliationIdentifier()
85
+ {
86
+ return $this->acquirerReconciliationIdentifier;
87
+ }
88
+
89
+ public function setAcquirerReconciliationIdentifier($acquirerReconciliationIdentifier)
90
+ {
91
+ $this->acquirerReconciliationIdentifier = $acquirerReconciliationIdentifier;
92
+ }
93
+
94
+ public function asArray()
95
+ {
96
+ $array = array();
97
+ if (!is_null($this->shop))
98
+ {
99
+ $array['shop'] = $this->shop;
100
+ }
101
+ if (!is_null($this->terminal))
102
+ {
103
+ $array['terminal'] = $this->terminal;
104
+ }
105
+ if (!is_null($this->transaction))
106
+ {
107
+ $array['transaction'] = $this->transaction;
108
+ }
109
+ if (!is_null($this->transactionId))
110
+ {
111
+ $array['transaction_id'] = $this->transactionId;
112
+ }
113
+ if (!is_null($this->shopOrderId))
114
+ {
115
+ $array['shop_orderid'] = $this->shopOrderId;
116
+ }
117
+ if (!is_null($this->paymentStatus))
118
+ {
119
+ $array['payment_status'] = $this->paymentStatus;
120
+ }
121
+ if (!is_null($this->reconciliationIdentifier))
122
+ {
123
+ $array['reconciliation_identifier'] = $this->reconciliationIdentifier;
124
+ }
125
+ if (!is_null($this->acquirerReconciliationIdentifier))
126
+ {
127
+ $array['acquirer_reconciliation_identifier'] = $this->acquirerReconciliationIdentifier;
128
+ }
129
+
130
+ return $array;
131
+ }
132
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayAPIAddress.class.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AltapayAPIAddress
4
+ {
5
+ /*
6
+ <BillingAddress>
7
+ <Firstname><![CDATA[Kødpålæg >-) <script>alert(42);</script>]]></Firstname>
8
+ <Lastname><![CDATA[Lyn]]></Lastname>
9
+ <Address><![CDATA[Rosenkæret 13]]></Address>
10
+ <City><![CDATA[Søborg]]></City>
11
+ <Region><![CDATA[]]></Region>
12
+ <Country><![CDATA[DK]]></Country>
13
+ <PostalCode><![CDATA[2860]]></PostalCode>
14
+ </BillingAddress>
15
+ */
16
+ private $firstName;
17
+ private $lastName;
18
+ private $address;
19
+ private $city;
20
+ private $region;
21
+ private $country;
22
+ private $postalCode;
23
+
24
+ public function __construct(SimpleXmlElement $xml)
25
+ {
26
+ $attrs = $xml->attributes();
27
+
28
+ $this->firstName = (string)$xml->Firstname;
29
+ $this->lastName = (string)$xml->Lastname;
30
+ $this->address = (string)$xml->Address;
31
+ $this->city = (string)$xml->City;
32
+ $this->region = (string)$xml->Region;
33
+ $this->country = (string)$xml->Country;
34
+ $this->postalCode = (string)$xml->PostalCode;
35
+ }
36
+
37
+ public function getFirstName()
38
+ {
39
+ return $this->firstName;
40
+ }
41
+
42
+ public function getLastName()
43
+ {
44
+ return $this->lastName;
45
+ }
46
+
47
+ public function getAddress()
48
+ {
49
+ return $this->address;
50
+ }
51
+
52
+ public function getCity()
53
+ {
54
+ return $this->city;
55
+ }
56
+
57
+ public function getRegion()
58
+ {
59
+ return $this->region;
60
+ }
61
+
62
+ public function getCountry()
63
+ {
64
+ return $this->country;
65
+ }
66
+
67
+ public function getPostalCode()
68
+ {
69
+ return $this->postalCode;
70
+ }
71
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayAPIChargebackEvent.class.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AltapayAPIChargebackEvent
4
+ {
5
+ private $date;
6
+ private $type;
7
+ private $reasonCode;
8
+ private $reason;
9
+ private $amount;
10
+ private $currency;
11
+ private $additionalInfo = array();
12
+
13
+ public function __construct(SimpleXmlElement $xml)
14
+ {
15
+ $this->date = new DateTime((string)$xml->Date);
16
+ $this->type = (string)$xml->Type;
17
+ $this->reasonCode = (string)$xml->ReasonCode;
18
+ $this->reason = (string)$xml->Reason;
19
+ $this->amount = (string)$xml->Amount;
20
+ $this->currency = (string)$xml->Currency;
21
+
22
+ $additionalInfoXml = @simplexml_load_string((string)$xml->AdditionalInfo);
23
+ foreach($additionalInfoXml->info_element as $infoElement)
24
+ {
25
+ $this->additionalInfo[(string)$infoElement->key] = (string)$infoElement->value;
26
+ }
27
+ }
28
+
29
+ public function getDate()
30
+ {
31
+ return $this->date;
32
+ }
33
+
34
+ public function setDate($date)
35
+ {
36
+ return $this->date = $date;
37
+ }
38
+
39
+ public function getType()
40
+ {
41
+ return $this->type;
42
+ }
43
+
44
+ public function setType($type)
45
+ {
46
+ return $this->type = $type;
47
+ }
48
+
49
+ public function getReasonCode()
50
+ {
51
+ return $this->reasonCode;
52
+ }
53
+
54
+ public function setReasonCode($reasonCode)
55
+ {
56
+ return $this->reasonCode = $reasonCode;
57
+ }
58
+
59
+ public function getReason()
60
+ {
61
+ return $this->reason;
62
+ }
63
+
64
+ public function setReason($reason)
65
+ {
66
+ return $this->reason = $reason;
67
+ }
68
+
69
+ public function getAmount()
70
+ {
71
+ return $this->amount;
72
+ }
73
+
74
+ public function setAmount($amount)
75
+ {
76
+ return $this->amount = $amount;
77
+ }
78
+
79
+ public function getCurrency()
80
+ {
81
+ return $this->currency;
82
+ }
83
+
84
+ public function setCurrency($currency)
85
+ {
86
+ return $this->currency = $currency;
87
+ }
88
+
89
+ public function getAdditionalInfo()
90
+ {
91
+ return $this->additionalInfo;
92
+ }
93
+
94
+ public function setAdditionalInfo(array $additionalInfo)
95
+ {
96
+ return $this->additionalInfo = $additionalInfo;
97
+ }
98
+ }
99
+
app/code/community/Altapay/Payment/Model/Api/response/AltapayAPIChargebackEvents.class.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AltapayAPIChargebackEvents
4
+ {
5
+ private $chargebackEvents = array();
6
+
7
+ public function __construct(SimpleXmlElement $xml)
8
+ {
9
+ if(isset($xml->ChargebackEvent))
10
+ {
11
+ foreach($xml->ChargebackEvent as $chargebackEvent)
12
+ {
13
+ $this->chargebackEvents[] = new AltapayAPIChargebackEvent($chargebackEvent);
14
+ }
15
+ }
16
+ }
17
+
18
+ /**
19
+ * @return AltapayAPIChargebackEvent
20
+ */
21
+ public function getNewest()
22
+ {
23
+ $newest = null; /* @var $newest AltapayAPIChargebackEvent */
24
+ foreach($this->chargebackEvents as $chargebackEvent) /* @var $chargebackEvent AltapayAPIChargebackEvent */
25
+ {
26
+ if(is_null($newest) || $newest->getDate()->getTimestamp() < $chargebackEvent->getDate()->getTimestamp())
27
+ {
28
+ $newest = $chargebackEvent;
29
+ }
30
+ }
31
+
32
+ return $newest;
33
+ }
34
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayAPICountryOfOrigin.class.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AltapayAPICountryOfOrigin
4
+ {
5
+ const NotSet = 'NotSet';
6
+ const CardNumber = 'CardNumber';
7
+ const BankAccount = 'BankAccount';
8
+ const BillingAddress = 'BillingAddress';
9
+ const RegisteredAddress = 'RegisteredAddress';
10
+ const ShippingAddress = 'ShippingAddress';
11
+ const PayPal = 'PayPal';
12
+
13
+ private $country;
14
+ private $source;
15
+
16
+ public function __construct(SimpleXmlElement $xml)
17
+ {
18
+ $this->country = (string)$xml->Country;
19
+ $this->source = (string)$xml->Source;
20
+ }
21
+
22
+ public function getCountry()
23
+ {
24
+ return $this->country;
25
+ }
26
+
27
+ public function getSource()
28
+ {
29
+ return $this->source;
30
+ }
31
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayAPICustomerInfo.class.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AltapayAPICustomerInfo
4
+ {
5
+ /*
6
+ <UserAgent>Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:13.0)
7
+ Gecko/20100101 Firefox/13.0.1</UserAgent>
8
+ <IpAddress>81.7.175.18</IpAddress>
9
+ <Email></Email>
10
+ <Username></Username>
11
+ <CustomerPhone></CustomerPhone>
12
+ <OrganisationNumber></OrganisationNumber>
13
+ <CountryOfOrigin>
14
+ <Country></Country><Source>NotSet</Source>
15
+ </CountryOfOrigin>
16
+ */
17
+ private $userAgent;
18
+ private $ipAddress;
19
+ private $email;
20
+ private $username;
21
+ private $phone;
22
+ private $organisationNumber;
23
+
24
+ /**
25
+ * @var AltapayAPIAddress
26
+ */
27
+ private $billingAddress,$shippingAddress,$registeredAddress;
28
+
29
+ private $countryOfOrigin;
30
+
31
+ public function __construct(SimpleXmlElement $xml)
32
+ {
33
+ $this->userAgent = (string)$xml->UserAgent;
34
+ $this->ipAddress = (string)$xml->IpAddress;
35
+ $this->email = (string)$xml->Email;
36
+ $this->username = (string)$xml->Username;
37
+ $this->phone = (string)$xml->CustomerPhone;
38
+ $this->organisationNumber = (string)$xml->OrganisationNumber;
39
+
40
+ if(isset($xml->CountryOfOrigin))
41
+ {
42
+ $this->countryOfOrigin = new AltapayAPICountryOfOrigin($xml->CountryOfOrigin);
43
+ }
44
+ if(isset($xml->BillingAddress))
45
+ {
46
+ $this->billingAddress = new AltapayAPIAddress($xml->BillingAddress);
47
+ }
48
+ if(isset($xml->ShippingAddress))
49
+ {
50
+ $this->shippingAddress = new AltapayAPIAddress($xml->ShippingAddress);
51
+ }
52
+ if(isset($xml->RegisteredAddress))
53
+ {
54
+ $this->registeredAddress = new AltapayAPIAddress($xml->RegisteredAddress);
55
+ }
56
+ }
57
+
58
+ /**
59
+ * @return AltapayAPIAddress
60
+ */
61
+ public function getBillingAddress()
62
+ {
63
+ return $this->billingAddress;
64
+ }
65
+
66
+ /**
67
+ * @return AltapayAPIAddress
68
+ */
69
+ public function getShippingAddress()
70
+ {
71
+ return $this->shippingAddress;
72
+ }
73
+
74
+ /**
75
+ * @return AltapayAPIAddress
76
+ */
77
+ public function getRegisteredAddress()
78
+ {
79
+ return $this->registeredAddress;
80
+ }
81
+
82
+ /**
83
+ * @return AltapayAPICountryOfOrigin
84
+ */
85
+ public function getCountryOfOrigin()
86
+ {
87
+ return $this->countryOfOrigin;
88
+ }
89
+
90
+ public function getUserAgent()
91
+ {
92
+ return $this->userAgent;
93
+ }
94
+
95
+ public function getIpAddress()
96
+ {
97
+ return $this->ipAddress;
98
+ }
99
+
100
+ public function getEmail()
101
+ {
102
+ return $this->email;
103
+ }
104
+
105
+ public function getUsername()
106
+ {
107
+ return $this->username;
108
+ }
109
+
110
+ public function getPhone()
111
+ {
112
+ return $this->phone;
113
+ }
114
+
115
+ public function getOrganisationNumber()
116
+ {
117
+ return $this->organisationNumber;
118
+ }
119
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayAPIFunding.class.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AltapayAPIFunding
4
+ {
5
+ private $filename;
6
+ private $contractIdentifier;
7
+ private $shops = array();
8
+ private $acquirer;
9
+ private $fundingDate;
10
+ private $amount;
11
+ private $currency;
12
+ private $createdDate;
13
+ private $downloadLink;
14
+
15
+ public function __construct(SimpleXmlElement $xml)
16
+ {
17
+ $this->filename = (string)$xml->Filename;
18
+ $this->contractIdentifier = (string)$xml->ContractIdentifier;
19
+ foreach($xml->Shops->Shop as $shop)
20
+ {
21
+ $this->shops[] = (string)$shop;
22
+ }
23
+ $this->acquirer = (string)$xml->Acquirer;
24
+ $this->fundingDate = (string)$xml->FundingDate;
25
+ list($this->amount, $this->currency) = explode(" ", (string)$xml->Amount, 2);
26
+ $this->createdDate = (string)$xml->CreatedDate;
27
+ $this->downloadLink = (string)$xml->DownloadLink;
28
+ }
29
+
30
+ public function getFundingDate()
31
+ {
32
+ return $this->fundingDate;
33
+ }
34
+
35
+ public function getAmount()
36
+ {
37
+ return $this->amount;
38
+ }
39
+
40
+ public function getCurrency()
41
+ {
42
+ return $this->currency;
43
+ }
44
+
45
+ public function getDownloadLink()
46
+ {
47
+ return $this->downloadLink;
48
+ }
49
+
50
+ public function getFilename()
51
+ {
52
+ return $this->filename;
53
+ }
54
+
55
+ public function getContractIdentifier()
56
+ {
57
+ return $this->contractIdentifier;
58
+ }
59
+
60
+ public function getShops()
61
+ {
62
+ return $this->shops;
63
+ }
64
+
65
+ public function getAcquirer()
66
+ {
67
+ return $this->acquirer;
68
+ }
69
+
70
+ public function getCreatedDate()
71
+ {
72
+ return $this->createdDate;
73
+ }
74
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayAPIPayment.class.php ADDED
@@ -0,0 +1,286 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ALTAPAY_API_ROOT'))
4
+ {
5
+ define('ALTAPAY_API_ROOT',dirname(__DIR__));
6
+ }
7
+
8
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayAPIReconciliationIdentifier.class.php');
9
+
10
+ /**
11
+ [Transaction] =&gt; SimpleXMLElement Object
12
+ (
13
+ [TransactionId] =&gt; 5
14
+ [AuthType] =&gt; payment
15
+ [CardStatus] =&gt; Valid
16
+ [CreditCardToken] =&gt; ce657182528301c19032840ba6682bdeb5b342d8
17
+ [CreditCardMaskedPan] =&gt; 555555*****5444
18
+ [ThreeDSecureResult] =&gt; Not_Attempted
19
+ [BlacklistToken] =&gt; 9484bac14dfd5dbb27329f81dcb12ceb8ed7703e
20
+ [ShopOrderId] =&gt; qoute_247
21
+ [Shop] =&gt; Altapay Functional Test Shop
22
+ [Terminal] =&gt; Altapay Dev Terminal
23
+ [TransactionStatus] =&gt; preauth
24
+ [MerchantCurrency] =&gt; 978
25
+ [CardHolderCurrency] =&gt; 978
26
+ [ReservedAmount] =&gt; 14.10
27
+ [CapturedAmount] =&gt; 0
28
+ [RefundedAmount] =&gt; 0
29
+ [RecurringMaxAmount] =&gt; 0
30
+ [CreatedDate] =&gt; 2012-01-06 15:23:12
31
+ [UpdatedDate] =&gt; 2012-01-06 15:23:12
32
+ [PaymentNature] =&gt; CreditCard
33
+ [PaymentNatureService] =&gt; SimpleXMLElement Object
34
+ (
35
+ [@attributes] =&gt; Array
36
+ (
37
+ [name] =&gt; TestAcquirer
38
+ )
39
+
40
+ [SupportsRefunds] =&gt; true
41
+ [SupportsRelease] =&gt; true
42
+ [SupportsMultipleCaptures] =&gt; true
43
+ [SupportsMultipleRefunds] =&gt; true
44
+ )
45
+
46
+ [FraudRiskScore] =&gt; 14
47
+ [FraudExplanation] =&gt; For the test fraud service the risk score is always equal mod 101 of the created amount for the payment
48
+ [TransactionInfo] =&gt; SimpleXMLElement Object
49
+ (
50
+ )
51
+
52
+ [CustomerInfo] =&gt; SimpleXMLElement Object
53
+ (
54
+ [UserAgent] =&gt; SimpleXMLElement Object
55
+ (
56
+ )
57
+
58
+ [IpAddress] =&gt; 127.0.0.1
59
+ )
60
+
61
+ [ReconciliationIdentifiers] =&gt; SimpleXMLElement Object
62
+ (
63
+ )
64
+ * @author emanuel
65
+ */
66
+ class AltapayAPIPayment
67
+ {
68
+ private $xml;
69
+
70
+ private $paymentId;
71
+ private $authType;
72
+ private $creditCardMaskedPan;
73
+ private $creditCardToken;
74
+ private $cardStatus;
75
+ private $shopOrderId;
76
+ private $shop;
77
+ private $terminal;
78
+ private $transactionStatus;
79
+ private $currency;
80
+
81
+ private $reservedAmount;
82
+ private $capturedAmount;
83
+ private $refundedAmount;
84
+ private $recurringMaxAmount;
85
+
86
+ private $paymentSchemeName;
87
+ private $paymentNature;
88
+ private $paymentNatureService;
89
+
90
+ private $fraudRiskScore;
91
+ private $fraudExplanation;
92
+ private $fraudRecommendation;
93
+
94
+ /**
95
+ * @var AltapayAPICustomerInfo
96
+ */
97
+ private $customerInfo;
98
+
99
+ /**
100
+ * @var AltapayAPIPaymentInfos
101
+ */
102
+ private $paymentInfos;
103
+
104
+ private $reconciliationIdentifiers = array();
105
+
106
+ /**
107
+ * @var AltapayAPIChargebackEvents
108
+ */
109
+ private $chargebackEvents;
110
+
111
+ public function __construct(SimpleXmlElement $xml)
112
+ {
113
+ $this->xml = $xml->saveXML();
114
+ $this->paymentId = (string)$xml->TransactionId;
115
+ $this->authType = (string)$xml->AuthType;
116
+ $this->creditCardMaskedPan = (string)$xml->CreditCardMaskedPan;
117
+ $this->creditCardToken = (string)$xml->CreditCardToken;
118
+ $this->cardStatus = (string)$xml->CardStatus;
119
+ $this->shopOrderId = (string)$xml->ShopOrderId;
120
+ $this->shop = (string)$xml->Shop;
121
+ $this->terminal = (string)$xml->Terminal;
122
+ $this->transactionStatus = (string)$xml->TransactionStatus;
123
+ $this->currency = (string)$xml->MerchantCurrency;
124
+
125
+ $this->reservedAmount = (string)$xml->ReservedAmount;
126
+ $this->capturedAmount = (string)$xml->CapturedAmount;
127
+ $this->refundedAmount = (string)$xml->RefundedAmount;
128
+ $this->recurringMaxAmount = (string)$xml->RecurringMaxAmount;
129
+
130
+ $this->paymentSchemeName = (string)$xml->PaymentSchemeName;
131
+ $this->paymentNature = (string)$xml->PaymentNature;
132
+ $this->paymentNatureService = new AltapayAPIPaymentNatureService($xml->PaymentNatureService);
133
+
134
+ $this->fraudRiskScore = (string)$xml->FraudRiskScore;
135
+ $this->fraudExplanation = (string)$xml->FraudExplanation;
136
+ $this->fraudRecommendation = (string)$xml->FraudRecommendation;
137
+
138
+ $this->customerInfo = new AltapayAPICustomerInfo($xml->CustomerInfo);
139
+ $this->paymentInfos = new AltapayAPIPaymentInfos($xml->PaymentInfos);
140
+ $this->chargebackEvents = new AltapayAPIChargebackEvents($xml->ChargebackEvents);
141
+
142
+ if(isset($xml->ReconciliationIdentifiers->ReconciliationIdentifier))
143
+ {
144
+ foreach($xml->ReconciliationIdentifiers->ReconciliationIdentifier as $reconXml)
145
+ {
146
+ $this->reconciliationIdentifiers[] = new AltapayAPIReconciliationIdentifier($reconXml);
147
+ }
148
+ }
149
+ }
150
+
151
+ public function mustBeCaptured()
152
+ {
153
+ return $this->capturedAmount == '0';
154
+ }
155
+
156
+ public function getCurrentStatus()
157
+ {
158
+ return $this->transactionStatus;
159
+ }
160
+
161
+ public function isReleased()
162
+ {
163
+ return $this->getCurrentStatus() == 'released';
164
+ }
165
+
166
+ /**
167
+ * @return AltapayAPIReconciliationIdentifier
168
+ */
169
+ public function getLastReconciliationIdentifier()
170
+ {
171
+ return $this->reconciliationIdentifiers[count($this->reconciliationIdentifiers) - 1];
172
+ }
173
+
174
+ public function getId()
175
+ {
176
+ return $this->paymentId;
177
+ }
178
+
179
+ public function getAuthType()
180
+ {
181
+ return $this->authType;
182
+ }
183
+
184
+ public function getShopOrderId()
185
+ {
186
+ return $this->shopOrderId;
187
+ }
188
+
189
+ public function getMaskedPan()
190
+ {
191
+ return $this->creditCardMaskedPan;
192
+ }
193
+
194
+ public function getCreditCardToken()
195
+ {
196
+ return $this->creditCardToken;
197
+ }
198
+
199
+ public function getCardStatus()
200
+ {
201
+ return $this->cardStatus;
202
+ }
203
+
204
+ public function getPaymentNature()
205
+ {
206
+ return $this->paymentNature;
207
+ }
208
+
209
+ public function getPaymentSchemeName()
210
+ {
211
+ return $this->paymentSchemeName;
212
+ }
213
+
214
+ /**
215
+ * @return AltapayAPIPaymentNatureService
216
+ */
217
+ public function getPaymentNatureService()
218
+ {
219
+ return $this->paymentNatureService;
220
+ }
221
+
222
+ /**
223
+ * @return string
224
+ */
225
+ public function getFraudRiskScore()
226
+ {
227
+ return $this->fraudRiskScore;
228
+ }
229
+
230
+ /**
231
+ * @return string
232
+ */
233
+ public function getFraudExplanation()
234
+ {
235
+ return $this->fraudExplanation;
236
+ }
237
+
238
+ /**
239
+ * @return string
240
+ */
241
+ public function getFraudRecommendation()
242
+ {
243
+ return $this->fraudRecommendation;
244
+ }
245
+
246
+ /**
247
+ * @return AltapayAPICustomerInfo
248
+ */
249
+ public function getCustomerInfo()
250
+ {
251
+ return $this->customerInfo;
252
+ }
253
+
254
+ public function getPaymentInfo($keyName)
255
+ {
256
+ return $this->paymentInfos->getInfo($keyName);
257
+ }
258
+
259
+ public function getCurrency()
260
+ {
261
+ return $this->currency;
262
+ }
263
+
264
+ public function getReservedAmount()
265
+ {
266
+ return $this->reservedAmount;
267
+ }
268
+
269
+ public function getCapturedAmount()
270
+ {
271
+ return $this->capturedAmount;
272
+ }
273
+
274
+ /**
275
+ * @return AltapayAPIChargebackEvents
276
+ */
277
+ public function getChargebackEvents()
278
+ {
279
+ return $this->chargebackEvents;
280
+ }
281
+
282
+ public function getXml()
283
+ {
284
+ return $this->xml;
285
+ }
286
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayAPIPaymentInfos.class.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AltapayAPIPaymentInfos
4
+ {
5
+ /*
6
+ <PaymentInfos>
7
+ <PaymentInfo name="auxkey">aux data (&lt;&#xE6;&#xF8;&#xE5;&gt;)</PaymentInfo>
8
+ </PaymentInfos>
9
+ */
10
+ private $infos = array();
11
+
12
+ public function __construct(SimpleXmlElement $xml)
13
+ {
14
+ if(isset($xml->PaymentInfo))
15
+ {
16
+ foreach($xml->PaymentInfo as $paymentInfo)
17
+ {
18
+ $attrs = $paymentInfo->attributes();
19
+ $this->infos[(string)$attrs['name']] = (string)$paymentInfo;
20
+ }
21
+ }
22
+ }
23
+
24
+ public function getAll()
25
+ {
26
+ return $this->infos;
27
+ }
28
+
29
+ public function getInfo($key)
30
+ {
31
+ return @$this->infos[$key];
32
+ }
33
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayAPIPaymentNatureService.class.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AltapayAPIPaymentNatureService
4
+ {
5
+ private $name;
6
+ private $supportsRefunds;
7
+ private $supportsRelease;
8
+ private $supportsMultipleCaptures;
9
+ private $supportsMultipleRefunds;
10
+
11
+ public function __construct(SimpleXmlElement $xml)
12
+ {
13
+ $attrs = $xml->attributes();
14
+
15
+ $this->name = strval(@$attrs['name']);
16
+ $this->supportsRefunds = (string)$xml->SupportsRefunds;
17
+ $this->supportsRelease = (string)$xml->SupportsRelease;
18
+ $this->supportsMultipleCaptures = (string)$xml->SupportsMultipleCaptures;
19
+ $this->supportsMultipleRefunds = (string)$xml->SupportsMultipleRefunds;
20
+ }
21
+
22
+ public function getName()
23
+ {
24
+ return $this->name;
25
+ }
26
+
27
+ public function getSupportsRefunds()
28
+ {
29
+ return $this->supportsRefunds;
30
+ }
31
+
32
+ public function getSupportsRelease()
33
+ {
34
+ return $this->supportsRelease;
35
+ }
36
+
37
+ public function getSupportsMultipleCaptures()
38
+ {
39
+ return $this->supportsMultipleCaptures;
40
+ }
41
+
42
+ public function getSupportsMultipleRefunds()
43
+ {
44
+ return $this->supportsMultipleRefunds;
45
+ }
46
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayAPIReconciliationIdentifier.class.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ [ReconciliationIdentifier] => SimpleXMLElement Object
5
+ (
6
+ [Id] => 5a9d09b7-4784-4d47-aebc-c0ac63b56722
7
+ [Amount] => 105
8
+ [Type] => captured
9
+ [Date] => 2011-08-31T23:36:14+02:00
10
+ )
11
+
12
+ * @author emanuel
13
+ *
14
+ */
15
+ class AltapayAPIReconciliationIdentifier
16
+ {
17
+ private $id, $amount, $type, $date;
18
+
19
+ public function __construct(SimpleXmlElement $xml)
20
+ {
21
+ $this->id = (string)$xml->Id;
22
+ $this->amount = (string)$xml->Amount;
23
+ $this->type = (string)$xml->Type;
24
+ $this->date = (string)$xml->Date;
25
+ }
26
+
27
+ public function getId()
28
+ {
29
+ return $this->id;
30
+ }
31
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayAbstractPaymentResponse.class.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ALTAPAY_API_ROOT'))
4
+ {
5
+ define('ALTAPAY_API_ROOT',dirname(__DIR__));
6
+ }
7
+
8
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayAbstractResponse.class.php');
9
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayAPIPayment.class.php');
10
+
11
+ abstract class AltapayAbstractPaymentResponse extends AltapayAbstractResponse
12
+ {
13
+ private $result;
14
+ private $merchantErrorMessage, $cardHolderErrorMessage;
15
+ protected $payments = array();
16
+
17
+ public function __construct(SimpleXmlElement $xml)
18
+ {
19
+ parent::__construct($xml);
20
+ $this->initFromXml($xml);
21
+ }
22
+
23
+ public function __wakeup()
24
+ {
25
+ $this->initFromXml(new SimpleXmlElement($this->xml));
26
+ }
27
+
28
+ private function initFromXml(SimpleXmlElement $xml)
29
+ {
30
+ $this->payments = array();
31
+ if($this->getErrorCode() === '0')
32
+ {
33
+ $this->result = strval($xml->Body->Result);
34
+ $this->merchantErrorMessage = (string)$xml->Body->MerchantErrorMessage;
35
+ $this->cardHolderErrorMessage = (string)$xml->Body->CardHolderErrorMessage;
36
+
37
+ $this->parseBody($xml->Body);
38
+
39
+ if(isset($xml->Body->Transactions->Transaction))
40
+ {
41
+ foreach($xml->Body->Transactions->Transaction as $transactionXml)
42
+ {
43
+ $this->addPayment(new AltapayAPIPayment($transactionXml));
44
+ }
45
+ }
46
+ }
47
+ }
48
+
49
+ private function addPayment(AltapayAPIPayment $payment)
50
+ {
51
+ $this->payments[] = $payment;
52
+ }
53
+
54
+ /**
55
+ * @return AltapayAPIPayment[]
56
+ */
57
+ public function getPayments()
58
+ {
59
+ return $this->payments;
60
+ }
61
+
62
+ /**
63
+ * @return AltapayAPIPayment
64
+ */
65
+ public function getPrimaryPayment()
66
+ {
67
+ return isset($this->payments[0]) ? $this->payments[0] : null;
68
+ }
69
+
70
+ public function wasSuccessful()
71
+ {
72
+ return $this->getErrorCode() === '0' && $this->result == 'Success';
73
+ }
74
+
75
+ public function wasDeclined()
76
+ {
77
+ return $this->getErrorCode() === '0' && $this->result == 'Failed';
78
+ }
79
+
80
+ public function wasErroneous()
81
+ {
82
+ return $this->getErrorCode() !== '0' || $this->result == 'Error';
83
+ }
84
+
85
+ public function getMerchantErrorMessage()
86
+ {
87
+ return $this->merchantErrorMessage;
88
+ }
89
+
90
+ public function getCardHolderErrorMessage()
91
+ {
92
+ return $this->cardHolderErrorMessage;
93
+ }
94
+
95
+ abstract protected function parseBody(SimpleXmlElement $body);
96
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayAbstractResponse.class.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * <APIResponse version="20110831">
5
+ * <Header>
6
+ * <Date>2011-08-29T23:48:32+02:00</Date>
7
+ * <Path>API/xxx</Path>
8
+ * <ErrorCode>0</ErrorCode>
9
+ * <ErrorMessage/>
10
+ * </Header>
11
+ * <Body>
12
+ * [.....]
13
+ * </Body>
14
+ * </APIResponse>
15
+ * Enter description here ...
16
+ * @author emanuel
17
+ *
18
+ */
19
+ abstract class AltapayAbstractResponse
20
+ {
21
+ protected $xml;
22
+ private $version;
23
+ private $date;
24
+ private $path;
25
+ private $errorCode;
26
+ private $errorMessage;
27
+
28
+ public function __construct(SimpleXmlElement $xml)
29
+ {
30
+ $this->xml = $xml->saveXml();
31
+ $this->version = (string)$xml['version'];
32
+ $this->date = (string)$xml->Header->Date;
33
+ $this->path = (string)$xml->Header->Path;
34
+ $this->errorCode = (string)$xml->Header->ErrorCode;
35
+ $this->errorMessage = (string)$xml->Header->ErrorMessage;
36
+ }
37
+
38
+ public function getVersion()
39
+ {
40
+ return $this->version;
41
+ }
42
+
43
+ public function getDate()
44
+ {
45
+ return $this->date;
46
+ }
47
+
48
+ public function getPath()
49
+ {
50
+ return $this->path;
51
+ }
52
+
53
+ public function getErrorCode()
54
+ {
55
+ return $this->errorCode;
56
+ }
57
+
58
+ public function getErrorMessage()
59
+ {
60
+ return $this->errorMessage;
61
+ }
62
+
63
+ public function getXml()
64
+ {
65
+ return $this->xml;
66
+ }
67
+
68
+ public abstract function wasSuccessful();
69
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayCalculateSurchargeResponse.class.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ALTAPAY_API_ROOT'))
4
+ {
5
+ define('ALTAPAY_API_ROOT',dirname(__DIR__));
6
+ }
7
+
8
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayAbstractResponse.class.php');
9
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayTerminal.class.php');
10
+
11
+ class AltapayCalculateSurchargeResponse extends AltapayAbstractResponse
12
+ {
13
+ private $result;
14
+ private $surchargeAmount = array();
15
+
16
+ public function __construct(SimpleXmlElement $xml)
17
+ {
18
+ parent::__construct($xml);
19
+
20
+ if($this->getErrorCode() === '0')
21
+ {
22
+ $this->result = (string)$xml->Body->Result;
23
+ $this->surchargeAmount = (string)$xml->Body->SurchageAmount;
24
+ }
25
+ }
26
+
27
+ public function getSurchargeAmount()
28
+ {
29
+ return $this->surchargeAmount;
30
+ }
31
+
32
+ public function wasSuccessful()
33
+ {
34
+ return $this->result === 'Success';
35
+ }
36
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayCaptureRecurringResponse.class.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ALTAPAY_API_ROOT'))
4
+ {
5
+ define('ALTAPAY_API_ROOT',dirname(__DIR__));
6
+ }
7
+
8
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayPreauthRecurringResponse.class.php');
9
+
10
+ class AltapayCaptureRecurringResponse extends AltapayPreauthRecurringResponse
11
+ {
12
+ public function __construct(SimpleXmlElement $xml)
13
+ {
14
+ parent::__construct($xml);
15
+ }
16
+
17
+ /**
18
+ * @return boolean
19
+ */
20
+ public function wasSubscriptionReleased()
21
+ {
22
+ return $this->getSubscriptionPayment()->isReleased();
23
+ }
24
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayCaptureResponse.class.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ALTAPAY_API_ROOT'))
4
+ {
5
+ define('ALTAPAY_API_ROOT',dirname(__DIR__));
6
+ }
7
+
8
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayAbstractPaymentResponse.class.php');
9
+
10
+ class AltapayCaptureResponse extends AltapayAbstractPaymentResponse
11
+ {
12
+ public function __construct(SimpleXmlElement $xml)
13
+ {
14
+ parent::__construct($xml);
15
+ }
16
+
17
+ protected function parseBody(SimpleXmlElement $body)
18
+ {
19
+
20
+ }
21
+
22
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayCreatePaymentRequestResponse.class.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ALTAPAY_API_ROOT'))
4
+ {
5
+ define('ALTAPAY_API_ROOT',dirname(__DIR__));
6
+ }
7
+
8
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayAbstractResponse.class.php');
9
+
10
+ class AltapayCreatePaymentRequestResponse extends AltapayAbstractResponse
11
+ {
12
+ private $redirectURL, $result;
13
+
14
+ public function __construct(SimpleXmlElement $xml)
15
+ {
16
+ parent::__construct($xml);
17
+
18
+ if($this->getErrorCode() === '0')
19
+ {
20
+ $this->result = (string)$xml->Body->Result;
21
+ $this->redirectURL = (string)$xml->Body->Url;
22
+ }
23
+ }
24
+
25
+ public function getRedirectURL()
26
+ {
27
+ return $this->redirectURL;
28
+ }
29
+
30
+ public function wasSuccessful()
31
+ {
32
+ return $this->getErrorCode() === '0' && $this->result == 'Success';
33
+ }
34
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayFundingListResponse.class.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AltapayFundingListResponse extends AltapayAbstractResponse
4
+ {
5
+ private $numberOfPages;
6
+ private $fundings = array();
7
+
8
+ public function __construct(SimpleXmlElement $xml)
9
+ {
10
+ parent::__construct($xml);
11
+ if($this->getErrorCode() === '0')
12
+ {
13
+ $attr = $xml->Body->Fundings->attributes();
14
+ $this->numberOfPages = (string)$attr['numberOfPages'];
15
+ foreach($xml->Body->Fundings->Funding as $funding)
16
+ {
17
+ $this->fundings[] = new AltapayAPIFunding($funding);
18
+ }
19
+ }
20
+ }
21
+
22
+ public function wasSuccessful()
23
+ {
24
+ return $this->getNumberOfPages() > 0;
25
+ }
26
+
27
+ public function getNumberOfPages()
28
+ {
29
+ return $this->numberOfPages;
30
+ }
31
+
32
+ public function getFundings()
33
+ {
34
+ return $this->fundings;
35
+ }
36
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayGetPaymentResponse.class.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ALTAPAY_API_ROOT'))
4
+ {
5
+ define('ALTAPAY_API_ROOT',dirname(__DIR__));
6
+ }
7
+
8
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayAbstractPaymentResponse.class.php');
9
+
10
+ class AltapayGetPaymentResponse extends AltapayAbstractPaymentResponse
11
+ {
12
+ public function __construct(SimpleXmlElement $xml)
13
+ {
14
+ parent::__construct($xml);
15
+ }
16
+
17
+ protected function parseBody(SimpleXmlElement $body)
18
+ {
19
+
20
+ }
21
+
22
+ public function wasSuccessful()
23
+ {
24
+ return $this->getErrorCode() === '0' && !is_null($this->getPrimaryPayment());
25
+ }
26
+
27
+
28
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayGetTerminalsResponse.class.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ALTAPAY_API_ROOT'))
4
+ {
5
+ define('ALTAPAY_API_ROOT',dirname(__DIR__));
6
+ }
7
+
8
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayAbstractResponse.class.php');
9
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayTerminal.class.php');
10
+
11
+ class AltapayGetTerminalsResponse extends AltapayAbstractResponse
12
+ {
13
+ private $terminals = array();
14
+
15
+ public function __construct(SimpleXmlElement $xml)
16
+ {
17
+ parent::__construct($xml);
18
+
19
+ if($this->getErrorCode() === '0')
20
+ {
21
+ foreach($xml->Body->Terminals->Terminal as $terminalXml)
22
+ {
23
+ $terminal = new AltapayTerminal();
24
+ $terminal->setTitle((string)$terminalXml->Title);
25
+ $terminal->setCountry((string)$terminalXml->Country);
26
+ foreach($terminalXml->Natures->Nature as $nature)
27
+ {
28
+ $terminal->addNature((string)$nature);
29
+ }
30
+ foreach($terminalXml->Currencies->Currency as $currency)
31
+ {
32
+ $terminal->addCurrency((string)$currency);
33
+ }
34
+
35
+ $this->terminals[] = $terminal;
36
+ }
37
+ }
38
+ }
39
+
40
+ public function getTerminals()
41
+ {
42
+ return $this->terminals;
43
+ }
44
+
45
+ public function wasSuccessful()
46
+ {
47
+ return $this->getErrorCode() === '0';
48
+ }
49
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayLoginResponse.class.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ALTAPAY_API_ROOT'))
4
+ {
5
+ define('ALTAPAY_API_ROOT',dirname(__DIR__));
6
+ }
7
+
8
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayAbstractResponse.class.php');
9
+
10
+ class AltapayLoginResponse extends AltapayAbstractResponse
11
+ {
12
+ private $result;
13
+
14
+ public function __construct(SimpleXmlElement $xml)
15
+ {
16
+ parent::__construct($xml);
17
+ if($this->getErrorCode() === '0')
18
+ {
19
+ $this->result = (string)$xml->Body->Result;
20
+ }
21
+ }
22
+
23
+ public function wasSuccessful()
24
+ {
25
+ return $this->getErrorCode() === '0' && $this->result == 'OK';
26
+ }
27
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayPreauthRecurringResponse.class.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if(!defined('ALTAPAY_API_ROOT'))
3
+ {
4
+ define('ALTAPAY_API_ROOT',dirname(__DIR__));
5
+ }
6
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayAbstractPaymentResponse.class.php');
7
+
8
+ class AltapayPreauthRecurringResponse extends AltapayAbstractPaymentResponse
9
+ {
10
+ public function __construct(SimpleXmlElement $xml)
11
+ {
12
+ parent::__construct($xml);
13
+ }
14
+
15
+ protected function parseBody(SimpleXmlElement $body)
16
+ {
17
+
18
+ }
19
+
20
+ /**
21
+ * This payment represent the subscription, it is returned as the subscription it
22
+ * self might have changed since last time it was used.
23
+ *
24
+ * @return AltapayAPIPayment
25
+ */
26
+ public function getSubscriptionPayment()
27
+ {
28
+ return isset($this->payments[0]) ? $this->payments[0] : null;
29
+ }
30
+
31
+ /**
32
+ * This is the payment which was pre-authed.
33
+ *
34
+ * @return AltapayAPIPayment
35
+ */
36
+ public function getPrimaryPayment()
37
+ {
38
+ return isset($this->payments[1]) ? $this->payments[1] : null;
39
+ }
40
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayRefundResponse.class.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ALTAPAY_API_ROOT'))
4
+ {
5
+ define('ALTAPAY_API_ROOT',dirname(__DIR__));
6
+ }
7
+
8
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayAbstractPaymentResponse.class.php');
9
+
10
+ class AltapayRefundResponse extends AltapayAbstractPaymentResponse
11
+ {
12
+ public function __construct(SimpleXmlElement $xml)
13
+ {
14
+ parent::__construct($xml);
15
+ }
16
+
17
+ protected function parseBody(SimpleXmlElement $body)
18
+ {
19
+
20
+ }
21
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayReleaseResponse.class.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ALTAPAY_API_ROOT'))
4
+ {
5
+ define('ALTAPAY_API_ROOT',dirname(__DIR__));
6
+ }
7
+
8
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayAbstractPaymentResponse.class.php');
9
+
10
+ class AltapayReleaseResponse extends AltapayAbstractPaymentResponse
11
+ {
12
+ public function __construct(SimpleXmlElement $xml)
13
+ {
14
+ parent::__construct($xml);
15
+ }
16
+
17
+ protected function parseBody(SimpleXmlElement $body)
18
+ {
19
+
20
+ }
21
+
22
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayReservationResponse.class.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if(!defined('ALTAPAY_API_ROOT'))
3
+ {
4
+ define('ALTAPAY_API_ROOT',dirname(__DIR__));
5
+ }
6
+
7
+ require_once(ALTAPAY_API_ROOT.'/response/AltapayAbstractPaymentResponse.class.php');
8
+
9
+ class AltapayReservationResponse extends AltapayAbstractPaymentResponse
10
+ {
11
+ public function __construct(SimpleXmlElement $xml)
12
+ {
13
+ parent::__construct($xml);
14
+ }
15
+
16
+ protected function parseBody(SimpleXmlElement $body)
17
+ {
18
+
19
+ }
20
+
21
+ public function wasSuccessful()
22
+ {
23
+ if(parent::wasSuccessful())
24
+ {
25
+ // There must be at least one Payment
26
+ if(!is_null($this->getPrimaryPayment()))
27
+ {
28
+ // If the current state is supposed to be more than 'created'
29
+ return $this->getPrimaryPayment()->getCurrentStatus() != 'created';
30
+ }
31
+ }
32
+ return false;
33
+ }
34
+ }
app/code/community/Altapay/Payment/Model/Api/response/AltapayTerminal.class.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class AltapayTerminal
4
+ {
5
+ private $title;
6
+ private $country;
7
+ private $natures = array();
8
+ private $currencies = array();
9
+
10
+ public function setTitle($title)
11
+ {
12
+ $this->title = $title;
13
+ }
14
+
15
+ public function getTitle()
16
+ {
17
+ return $this->title;
18
+ }
19
+
20
+ public function setCountry($country)
21
+ {
22
+ $this->country = $country;
23
+ }
24
+
25
+ public function addNature($nature)
26
+ {
27
+ $this->natures[] = $nature;
28
+ }
29
+
30
+ public function addCurrency($currency)
31
+ {
32
+ $this->currencies[] = $currency;
33
+ }
34
+
35
+ public function hasCurrency($currency)
36
+ {
37
+ return in_array('XXX', $this->currencies) || in_array($currency, $this->currencies);
38
+ }
39
+ }
app/code/community/Altapay/Payment/Model/Constants.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Altapay_Payment_Model_Constants {
4
+ // configuration paths
5
+ const CONF_PATH_API_INSTALLATION = 'altapay_general/api_installation';
6
+ const CONF_PATH_API_USERNAME = 'altapay_general/api_username';
7
+ const CONF_PATH_API_PASSWORD = 'altapay_general/api_password';
8
+
9
+ const CONF_PATH_MOTO_TERMINAL = 'payment/altapay_moto/terminal';
10
+
11
+ const CONF_PATH_GATEWAY_TERMINAL = 'payment/altapay_gateway/terminal';
12
+ const CONT_PATH_GATEWAY_ACTION_TYPE = 'payment/altapay_gateway/payment_action';
13
+
14
+ const CONF_PATH_TOKEN_TERMINAL = 'payment/altapay_token/terminal';
15
+ const CONT_PATH_TOKEN_ACTION_TYPE = 'payment/altapay_token/payment_action';
16
+
17
+ const CONF_PATH_RECURRING_TERMINAL = 'payment/altapay_recurring/terminal';
18
+ const CONT_PATH_RECURRING_ACTION_TYPE = 'payment/altapay_recurring/payment_action';
19
+
20
+ // payment types
21
+ const ACTION_AUTHORIZE = 'payment';
22
+ const ACTION_AUTHORIZE_CAPTURE = 'paymentAndCapture';
23
+ const ACTION_RECURRING = 'recurring';
24
+ }
app/code/community/Altapay/Payment/Model/Method/Abstract.php ADDED
@@ -0,0 +1,291 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ALTAPAY_API_ROOT'))
4
+ {
5
+ define('ALTAPAY_API_ROOT',Mage::getModuleDir(null,'Altapay_Payment').'/Model/Api');
6
+ }
7
+ require_once(ALTAPAY_API_ROOT.'/AltapayMerchantAPI.class.php');
8
+
9
+ abstract class Altapay_Payment_Model_Method_Abstract extends Mage_Payment_Model_Method_Abstract {
10
+
11
+ protected function getAltapayModel(Varien_Object $payment = null)
12
+ {
13
+ return new Altapay_Payment_Model_Altapay($this->getStoreId($payment));
14
+ }
15
+
16
+ protected function getStoreId(Varien_Object $payment = null)
17
+ {
18
+ if(is_null($payment))
19
+ {
20
+ return Altapay_Payment_Helper_Utilities::guessStoreIdBasedOnParameters();
21
+ }
22
+ else
23
+ {
24
+ return $payment->getOrder()->getStore()->getId();
25
+ }
26
+ }
27
+
28
+ protected function getAltapayPaymentType($configPath, $storeId = null)
29
+ {
30
+ $type = Mage::getStoreConfig($configPath, $storeId);
31
+ if($type == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE){
32
+ return Altapay_Payment_Model_Constants::ACTION_AUTHORIZE;
33
+ }else{
34
+ return Altapay_Payment_Model_Constants::ACTION_AUTHORIZE_CAPTURE;
35
+ }
36
+ }
37
+
38
+ /**
39
+ * (non-PHPdoc)
40
+ * @see code/core/Mage/Payment/Model/Method/Mage_Payment_Model_Method_Abstract#capture()
41
+ */
42
+ public function capture(Varien_Object $payment, $amount) {
43
+ $session_authTransactionId = Mage::getSingleton('core/session')->getData('altapay_auth_transaction_id');
44
+ Mage::getSingleton('core/session')->unsetData('altapay_auth_transaction_id');
45
+ $session_requiresCapture = Mage::getSingleton('core/session')->getData('altapay_requires_capture');
46
+ Mage::getSingleton('core/session')->unsetData('altapay_requires_capture');
47
+ $paymentStatus = Mage::getSingleton('core/session')->getData('altapay_payment_status');
48
+ Mage::getSingleton('core/session')->unsetData('altapay_payment_status');
49
+
50
+ if ($session_requiresCapture == 'false')
51
+ {
52
+ /**
53
+ * Some ePayments (e.g. Sofort/DirectEbanking) do captures immediately,
54
+ * and we therefore do not need to do a separate capture.
55
+ * In order to refund them we need to set the transaction id, as we would
56
+ * normally do later in the capture process.
57
+ */
58
+ if ($paymentStatus == 'bank_payment_finalized')
59
+ {
60
+ $payment->setIsTransactionClosed(false);
61
+ $payment->setTransactionId($session_authTransactionId);
62
+ }
63
+
64
+ // payment has already been captured by Altapay
65
+ return $this;
66
+ }
67
+
68
+ /* @var $payment Mage_Sales_Model_Order_Payment */
69
+ $invoice = $this->_getInvoice($payment);
70
+
71
+ $invoiceData = $invoice->__toArray();
72
+ $salesTax = number_format($invoiceData['tax_amount'], 2,'.','');
73
+ $amount = number_format($invoiceData['grand_total'], 2,'.',''); // To get the amount in the correct currency
74
+
75
+ $orderLines = $this->_createOrderLinesFromInvoice($invoice);
76
+
77
+ $authTrans = $payment->getAuthorizationTransaction();
78
+
79
+ if (empty($authTrans))
80
+ {
81
+ /**
82
+ * We hit this case when our OnepageController->successAction method is run. During the
83
+ * execution the quote is stored, but while saving, this method is called and that means
84
+ * that we will never find the authorization transaction (because it has not been saved yet).
85
+ */
86
+ $doCapture = true;
87
+ $transaction_id = $session_authTransactionId;
88
+ }
89
+ else
90
+ {
91
+ $transaction_id = $authTrans->getTxnId();
92
+ $authResponse = @unserialize($authTrans->getAdditionalInformation('altapay_response'));
93
+ $doCapture = $authResponse === false || $authResponse->getPrimaryPayment()->mustBeCaptured();
94
+ }
95
+
96
+ // Find out if we need to capture this payment
97
+ if($doCapture)
98
+ {
99
+ $response = $this->getAltapayModel($payment)->captureReservation($transaction_id, $amount, $orderLines, $salesTax);
100
+ $payment->setTransactionAdditionalInfo('altapay_response', serialize($response));
101
+
102
+ if($response->wasSuccessful())
103
+ {
104
+ $payment->setIsTransactionClosed(false);
105
+ $payment->setTransactionId($response->getPrimaryPayment()->getLastReconciliationIdentifier()->getId());
106
+
107
+ return $this;
108
+ }
109
+ else
110
+ {
111
+ Mage::throwException($response->getMerchantErrorMessage());
112
+ }
113
+ }
114
+ else
115
+ {
116
+ $payment->setIsTransactionClosed(false);
117
+ $payment->setTransactionId($authTrans->getTxnId().'-captured');
118
+
119
+ return $this;
120
+ }
121
+ }
122
+
123
+ protected function _createOrderLinesFromInvoice(Mage_Sales_Model_Order_Invoice $invoice)
124
+ {
125
+ $orderLines = array();
126
+ foreach($invoice->getAllItems() as $item) /* @var $item Mage_Sales_Model_Order_Invoice_Item */
127
+ {
128
+ $data = $item->__toArray();
129
+
130
+ $orderLines[] = array(
131
+ 'description'=>$data['name'],
132
+ 'itemId'=>$data['sku'],
133
+ 'quantity'=>$data['qty'],
134
+ 'taxAmount'=>number_format(bcsub($data['price_incl_tax'], $data['price'], 2), 2, '.', ''),
135
+ 'unitCode'=>'pcs', // TODO: Nice this up
136
+ 'unitPrice'=>round($data['price'], 2, PHP_ROUND_HALF_DOWN),
137
+ 'discount'=>0, // There is no such thing on each row, only a total on the invoice....
138
+ 'goodsType'=>'item',
139
+ );
140
+ }
141
+
142
+ $shipping = $invoice->__toArray();
143
+ if($shipping['shipping_amount'] > 0)
144
+ {
145
+ $orderLines[] = array(
146
+ 'description'=>$invoice->getOrder()->getData('shipping_description'),
147
+ 'itemId'=>$invoice->getOrder()->getData('shipping_method'),
148
+ 'quantity'=>1,
149
+ 'taxAmount'=>0,
150
+ 'unitCode'=>'pcs', // TODO: Nice this up
151
+ 'unitPrice'=>$invoice->getData('shipping_amount'),
152
+ 'discount'=>0,
153
+ 'goodsType'=>'shipment',
154
+ );
155
+ }
156
+ return $orderLines;
157
+ }
158
+
159
+
160
+ /**
161
+ * This will dig out the invoice that we are paying for right now As Magento does not tell us we have
162
+ * to investigate the invoices and make a qualified guess (as this is the best we can do).
163
+ *
164
+ * @return Mage_Sales_Model_Order_Invoice
165
+ */
166
+ private function _getInvoice(Mage_Sales_Model_Order_Payment $payment)
167
+ {
168
+ $invoice = Altapay_Payment_Model_Observer::getInvoiceBeingPayedFor();
169
+ if(is_null($invoice))
170
+ {
171
+ Mage::throwException("Could not find the invoice for which the payment is being made");
172
+ }
173
+ return $invoice;
174
+ }
175
+
176
+ /**
177
+ * (non-PHPdoc)
178
+ * @see code/core/Mage/Payment/Model/Method/Mage_Payment_Model_Method_Abstract#refund()
179
+ */
180
+ public function refund(Varien_Object $payment, $amount) {
181
+ /* @var $payment Mage_Sales_Model_Order_Payment */
182
+
183
+ /**
184
+ * @var $creditmemo Mage_Sales_Model_Order_Creditmemo
185
+ */
186
+ $creditmemo = $payment->getCreditmemo();
187
+
188
+ $creditmemoData = $creditmemo->__toArray();
189
+ $amount = number_format($creditmemoData['grand_total'], 2,'.',''); // To get the amount in the correct currency
190
+
191
+ /**
192
+ * @var $items Mage_Sales_Model_Order_Creditmemo_Item[]
193
+ */
194
+ $items = $creditmemo->getAllItems();
195
+
196
+ $orderLines = array();
197
+ foreach ($items as $item)
198
+ {
199
+ $data = $item->__toArray();
200
+
201
+ $orderLines[] = array(
202
+ 'description'=>$data['name'],
203
+ 'itemId'=>$data['sku'],
204
+ 'quantity'=>$data['qty'],
205
+ 'unitPrice'=>round($data['price'], 2, PHP_ROUND_HALF_DOWN),
206
+ );
207
+ }
208
+
209
+ /**
210
+ * @var $collection Mage_Sales_Model_Mysql4_Order_Payment_Transaction_Collection
211
+ *
212
+ * $payment->getAuthorizationTransaction() returns the capture transaction
213
+ * and if we use the transaction id from that, the refund fails in magento
214
+ */
215
+ $collection = Mage::getModel('sales/order_payment_transaction')->getCollection()
216
+ ->setOrderFilter($payment->getOrder())
217
+ ->addPaymentIdFilter($payment->getId())
218
+ ->addTxnTypeFilter(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
219
+
220
+ if (count($collection) < 1)
221
+ {
222
+ throw Mage::exception('Altapay - refund', 'I was unable to find any authorization transactions for order '.$payment->getOrder()->getId());
223
+ }
224
+
225
+ if (count($collection) > 1)
226
+ {
227
+ throw Mage::exception('Altapay - refund', 'I found multiple authorization transactions for order '.$payment->getOrder()->getId().'. I do not know which one to use.');
228
+ }
229
+
230
+ $authTrans = $collection->getFirstItem();
231
+
232
+ $transaction_id = $authTrans->getTxnId();
233
+
234
+ $response = $this->getAltapayModel($payment)->refundCapturedReservation($transaction_id, $amount, $orderLines);
235
+ $payment->setTransactionAdditionalInfo('altapay_response', serialize($response));
236
+
237
+ if($response->wasSuccessful())
238
+ {
239
+ $payment->setShouldCloseParentTransaction(false);
240
+ $payment->setTransactionId($response->getPrimaryPayment()->getLastReconciliationIdentifier()->getId());
241
+
242
+ return $this;
243
+ }
244
+ else
245
+ {
246
+ Mage::throwException($response->getMerchantErrorMessage());
247
+ }
248
+ }
249
+
250
+ /**
251
+ * This will dig out the creditmemo that we are refunding for right now As Magento does not tell us we have
252
+ * to investigate the credit memos and make a qualified guess (as this is the best we can do).
253
+ *
254
+ * @return Mage_Sales_Model_Order_Creditmemo
255
+ */
256
+ private function _getCreditmemo(Mage_Sales_Model_Order_Payment $payment)
257
+ {
258
+ $creditmemo = Altapay_Payment_Model_Observer::getCreditmemoBeingRefunded();
259
+ if(is_null($creditmemo))
260
+ {
261
+ Mage::throwException("Could not find the creditmemo for which the refund is being made");
262
+ }
263
+ return $creditmemo;
264
+ }
265
+
266
+
267
+ /**
268
+ * (non-PHPdoc)
269
+ * @see code/core/Mage/Payment/Model/Method/Mage_Payment_Model_Method_Abstract#void()
270
+ */
271
+ public function void(Varien_Object $payment)
272
+ {
273
+ $authTrans = $payment->getAuthorizationTransaction();
274
+ $transaction_id = $authTrans->getTxnId();
275
+
276
+ $response = $this->getAltapayModel($payment)->releaseReservation($transaction_id);
277
+ $payment->setTransactionAdditionalInfo('altapay_response', serialize($response));
278
+
279
+ $payment->setIsTransactionClosed(false);
280
+ $payment->setTransactionId($transaction_id.'-void');
281
+
282
+ if($response->wasSuccessful())
283
+ {
284
+ return $this;
285
+ }
286
+ else
287
+ {
288
+ Mage::throwException($response->getMerchantErrorMessage());
289
+ }
290
+ }
291
+ }
app/code/community/Altapay/Payment/Model/Method/Gateway.php ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Altapay_Payment_Model_Method_Gateway extends Altapay_Payment_Model_Method_Abstract {
3
+
4
+ protected $_canAuthorize = true;
5
+ protected $_canSaveCc = true;
6
+ protected $_isGateway = true;
7
+ protected $_canOrder = false;
8
+ protected $_canCapture = true;
9
+ protected $_canCapturePartial = true;
10
+ protected $_canRefund = true;
11
+ protected $_canRefundInvoicePartial = true;
12
+ protected $_canVoid = true;
13
+ protected $_canUseInternal = false; // Required to take MO/TO transaction
14
+ protected $_canUseCheckout = true;
15
+ protected $_canUseForMultishipping = true;
16
+ protected $_isInitializeNeeded = false;
17
+ protected $_canFetchTransactionInfo = true;
18
+ protected $_canReviewPayment = true;
19
+ protected $_canCreateBillingAgreement = false;
20
+ protected $_canManageRecurringProfiles = false;
21
+ protected $_code = 'altapay_gateway';
22
+ protected $_formBlockType = 'altapaypayment/form_gateway';
23
+ protected $_infoBlockType = 'altapaypayment/info_gateway';
24
+
25
+ public function __construct($params) {
26
+ parent::__construct($params);
27
+ }
28
+
29
+ public function authorize(Varien_Object $payment, $amount) {
30
+ if($payment->getAdditionalInformation('successType') == 'open')
31
+ {
32
+ $payment->setIsTransactionPending(true);
33
+ $payment->setIsCustomerNotified(false);
34
+ }
35
+ return parent::authorize($payment, $amount);
36
+ }
37
+
38
+ public function getCheckoutRedirectUrl()
39
+ {
40
+ $onePage = $this->getOnepage();
41
+ if(!$onePage->getQuote()->getReservedOrderId())
42
+ {
43
+ $onePage->getQuote()->reserveOrderId();
44
+ $onePage->getQuote()->save();
45
+ }
46
+
47
+ $terminal = $this->getAltapayTerminal();
48
+ $orderid = $onePage->getQuote()->getReservedOrderId(); //'qoute_'.$onePage->getQuote()->getId();
49
+ $totals = $onePage->getQuote()->getTotals(); /** @var $totals Mage_Sales_Model_Quote_Address_Total[] */
50
+ $grandTotal = $totals['grand_total']->getValue();
51
+ $currencyCode = $onePage->getQuote()->getQuoteCurrencyCode();
52
+ $amount = number_format($grandTotal, 2,'.','');
53
+ $billingAddress = $onePage->getQuote()->getBillingAddress();
54
+ $shippingAddress = $onePage->getQuote()->getShippingAddress();
55
+
56
+ $customerInfo = array(
57
+ 'billing_postal'=> $billingAddress->getData('postcode'),
58
+ 'billing_country'=> $billingAddress->getData('country_id'),
59
+ 'billing_address'=> $billingAddress->getData('street'),
60
+ 'billing_city'=>$billingAddress->getData('city'),
61
+ 'billing_region'=>$billingAddress->getData('region'),
62
+ 'billing_firstname'=> $billingAddress->getData('firstname'),
63
+ 'billing_lastname'=> $billingAddress->getData('lastname'),
64
+ 'email'=>$billingAddress->getData('email'),
65
+ 'shipping_postal'=> $shippingAddress->getData('postcode'),
66
+ 'shipping_country'=> $shippingAddress->getData('country_id'),
67
+ 'shipping_address'=> $shippingAddress->getData('street'),
68
+ 'shipping_city'=>$shippingAddress->getData('city'),
69
+ 'shipping_region'=>$shippingAddress->getData('region'),
70
+ 'shipping_firstname'=> $shippingAddress->getData('firstname'),
71
+ 'shipping_lastname'=> $shippingAddress->getData('lastname'),
72
+ 'customer_phone'=> $billingAddress->getData('telephone'),
73
+ );
74
+
75
+ /**
76
+ * Never use our paymentAndCapture type. Magento has it's own
77
+ * flow where payment and capture is performed in two steps.
78
+ */
79
+ //$paymentType = Altapay_Payment_Model_Constants::ACTION_AUTHORIZE;
80
+
81
+ $paymentType = $this->getAltapayPaymentType('altapay/altapay_gateway/payment_action',$onePage->getQuote()->getStoreId());
82
+
83
+ $requestConfig = $this->getAltapayRequestConfig($orderid);
84
+ $transactionInfo = array(
85
+ 'qoute'=>$onePage->getQuote()->getId(),
86
+ );
87
+
88
+ $orderLines = $this->_createOrderLinesFromQuote($onePage->getQuote());
89
+
90
+ $response = $this->getAltapayModel()->createPaymentRequest(
91
+ $terminal,
92
+ $orderid,
93
+ $amount,
94
+ $currencyCode,
95
+ $paymentType,
96
+ $customerInfo,
97
+ $_SERVER['HTTP_COOKIE'],
98
+ Mage::app()->getLocale()->getLocale()->getLanguage(),
99
+ $requestConfig,
100
+ $transactionInfo,
101
+ $orderLines
102
+ );
103
+
104
+ if($response->wasSuccessful())
105
+ {
106
+ Mage::getSingleton('core/session')->setData('altapay_payment_request_url', $response->getRedirectURL());
107
+
108
+ return $response->getRedirectURL();
109
+ }
110
+ else
111
+ {
112
+ throw new Exception($response->getErrorMessage());
113
+ }
114
+ }
115
+
116
+ protected function _createOrderLinesFromQuote(Mage_Sales_Model_Quote $quote)
117
+ {
118
+ $orderLines = array();
119
+ foreach ($this->getQuoteItemsRelevantForAltapayOrderLines($quote) as $item)
120
+ {
121
+ $data = $item->__toArray();
122
+
123
+ $orderLines[] = array(
124
+ 'description'=>$data['name'],
125
+ 'itemId'=>$data['sku'],
126
+ 'quantity'=>$data['qty'],
127
+ 'taxAmount'=>$data['tax_amount'],
128
+ 'unitCode'=>'pcs', // TODO: Nice this up
129
+ 'unitPrice'=>round($data['calculation_price'], 2, PHP_ROUND_HALF_DOWN),
130
+ 'discount'=>round($data['discount_percent'], 2, PHP_ROUND_HALF_DOWN),
131
+ 'goodsType'=>'item',
132
+ );
133
+ }
134
+ $totals = $quote->getTotals();
135
+ if(($quote->getShippingAddress()->getShippingMethod() != "") && (isset($totals['shipping'])))
136
+ {
137
+ $orderLines[] = array(
138
+ 'description'=>$quote->getShippingAddress()->getShippingDescription(),
139
+ 'itemId'=>$quote->getShippingAddress()->getShippingMethod(),
140
+ 'quantity'=>1,
141
+ 'taxAmount'=>0,
142
+ 'unitCode'=>'pcs', // TODO: Nice this up
143
+ 'unitPrice'=>$totals['shipping']->getData('value'),
144
+ 'discount'=>0,
145
+ 'goodsType'=>'shipment',
146
+ );
147
+ }
148
+ return $orderLines;
149
+ }
150
+
151
+ /**
152
+ * @returns Mage_Sales_Model_Order_Invoice_Item[]
153
+ */
154
+ private function getQuoteItemsRelevantForAltapayOrderLines(Mage_Sales_Model_Quote $quote)
155
+ {
156
+ $items = array();
157
+
158
+ foreach($quote->getAllItems() as $item) /* @var $item Mage_Sales_Model_Order_Invoice_Item */
159
+ {
160
+ $data = $item->__toArray();
161
+
162
+ if (!empty($data['parent_item_id']) && $this->doesQuoteHaveItemWithId($quote, $data['parent_item_id']))
163
+ {
164
+ /**
165
+ * Configurable products will be represented
166
+ * as multiple items in the quote.
167
+ * 1) product with data as a combination of the configurable product
168
+ * and the selected underlying simple product
169
+ * 2) the simple product, which has almost no data at all
170
+ *
171
+ * Number 2 is not interesting to us unless the parent item
172
+ * is not in the quote
173
+ */
174
+ continue;
175
+ }
176
+
177
+ $items[] = $item;
178
+ }
179
+
180
+ return $items;
181
+ }
182
+
183
+ private function doesQuoteHaveItemWithId(Mage_Sales_Model_Quote $quote, $itemId)
184
+ {
185
+ foreach($quote->getAllItems() as $item) /* @var $item Mage_Sales_Model_Order_Invoice_Item */
186
+ {
187
+ if ($item->getId() == $itemId)
188
+ {
189
+ return true;
190
+ }
191
+ }
192
+
193
+ return false;
194
+ }
195
+
196
+ /**
197
+ * @return Mage_Checkout_Block_Onepage_Abstract
198
+ */
199
+ protected function getOnepage()
200
+ {
201
+ return Mage::getSingleton('checkout/type_onepage');
202
+ }
203
+
204
+ protected function getAltapayRequestConfig($orderId)
205
+ {
206
+ return array(
207
+ 'callback_form' => Mage::getUrl('altapaypayment/onepage/form').'?orderID=' . $orderId
208
+ , 'callback_ok' => Mage::getUrl('altapaypayment/onepage/success').'?orderID=' . $orderId
209
+ , 'callback_fail' => Mage::getUrl('altapaypayment/onepage/failure').'?orderID=' . $orderId
210
+ , 'callback_redirect' => ''
211
+ , 'callback_open' => Mage::getUrl('altapaypayment/onepage/open').'?orderID=' . $orderId
212
+ , 'callback_notification' => Mage::getUrl('altapaypayment/onepage/notification').'?orderID=' . $orderId
213
+ );
214
+ }
215
+
216
+ protected function getAltapayTerminal()
217
+ {
218
+ return Mage::getStoreConfig(Altapay_Payment_Model_Constants::CONF_PATH_GATEWAY_TERMINAL);
219
+ }
220
+ }
app/code/community/Altapay/Payment/Model/Method/Moto.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Altapay_Payment_Model_Method_Moto extends Altapay_Payment_Model_Method_Abstract {
4
+ protected $_canAuthorize = true;
5
+ protected $_canSaveCc = false;
6
+ protected $_isGateway = false;
7
+ protected $_canOrder = false;
8
+ protected $_canCapture = true;
9
+ protected $_canCapturePartial = true;
10
+ protected $_canRefund = true;
11
+ protected $_canRefundInvoicePartial = true;
12
+ protected $_canVoid = true;
13
+ protected $_canUseInternal = true;
14
+ protected $_canUseCheckout = false;
15
+ protected $_canUseForMultishipping = true;
16
+ protected $_isInitializeNeeded = false;
17
+ protected $_canFetchTransactionInfo = true;
18
+ protected $_canReviewPayment = true;
19
+ protected $_canCreateBillingAgreement = false;
20
+ protected $_canManageRecurringProfiles = false;
21
+ protected $_code = 'altapay_moto';
22
+ protected $_formBlockType = 'altapaypayment/form_moto';
23
+ protected $_infoBlockType = 'altapaypayment/info_moto';
24
+
25
+ private function _getTerminalTitle(Varien_Object $payment = null) {
26
+ return Mage::getStoreConfig(Altapay_Payment_Model_Constants::CONF_PATH_MOTO_TERMINAL, $this->getStoreId($payment));
27
+ }
28
+
29
+ public function authorize(Varien_Object $payment, $amount) {
30
+ parent::authorize($payment, $amount);
31
+
32
+ $order = $payment->getOrder();
33
+
34
+ // Collect the Credit Card Values:
35
+ $expiry_month = Mage::Helper('altapaypayment')->getExpiryMonth($payment->getCcExpMonth());
36
+ $expiry_year = $payment->getCcExpYear();
37
+ $shop_orderid = $order->getIncrementId();
38
+ $currency = $order->getBaseCurrencyCode();
39
+ $cardnum = $payment->getCcNumber();
40
+ $cvc = $payment->getCcCid();
41
+ $type = 'payment';
42
+
43
+ $response = $this->getAltapayModel($payment)->reservationOfFixedAmountMOTO(
44
+ $this->_getTerminalTitle($payment)
45
+ , $shop_orderid
46
+ , $amount
47
+ , $currency
48
+ , $cardnum
49
+ , $expiry_year
50
+ , $expiry_month
51
+ , $cvc
52
+ );
53
+
54
+ if($response->wasSuccessful())
55
+ {
56
+ $payment->setIsTransactionClosed(false);
57
+ $payment->setTransactionId($response->getPrimaryPayment()->getId());
58
+ $maskedPan = $response->getPrimaryPayment()->getMaskedPan();
59
+ $payment->setData('cc_last4', substr('****'.$maskedPan, -4));
60
+ $payment->setData('cc_number_enc', $maskedPan);
61
+
62
+ return $this;
63
+ }
64
+ else
65
+ {
66
+ Mage::throwException($response->getMerchantErrorMessage());
67
+ }
68
+ }
69
+
70
+ public function canUseForCurrency($currencyCode)
71
+ {
72
+ $terminals = new Altapay_Payment_Model_Source_Terminals();
73
+ return $terminals->canUseForCurrency($this->_getTerminalTitle(), $currencyCode);
74
+ }
75
+ }
app/code/community/Altapay/Payment/Model/Method/Recurring.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Altapay_Payment_Model_Method_Recurring extends Altapay_Payment_Model_Method_Gateway {
4
+
5
+ protected $_canAuthorize = true;
6
+ protected $_canSaveCc = true;
7
+ protected $_isGateway = true;
8
+ protected $_canOrder = false;
9
+ protected $_canCapture = true;
10
+ protected $_canCapturePartial = true;
11
+ protected $_canRefund = true;
12
+ protected $_canRefundInvoicePartial = true;
13
+ protected $_canVoid = true;
14
+ protected $_canUseInternal = false; // Required to take MO/TO transaction
15
+ protected $_canUseCheckout = true;
16
+ protected $_canUseForMultishipping = true;
17
+ protected $_isInitializeNeeded = false;
18
+ protected $_canFetchTransactionInfo = true;
19
+ protected $_canReviewPayment = true;
20
+ protected $_canCreateBillingAgreement = false;
21
+ protected $_canManageRecurringProfiles = false;
22
+ protected $_code = 'altapay_recurring';
23
+ protected $_formBlockType = 'altapaypayment/form_recurring';
24
+ protected $_infoBlockType = 'altapaypayment/info_recurring';
25
+
26
+ protected function getAltapayPaymentType($configPath, $storeId = null)
27
+ {
28
+ return Altapay_Payment_Model_Constants::ACTION_RECURRING;
29
+ }
30
+
31
+ public function isAvailable($quote = null)
32
+ {
33
+ return parent::isAvailable($quote) && !in_array($quote->getCheckoutMethod(),array(
34
+ //Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER
35
+ Mage_Checkout_Model_Type_Onepage::METHOD_GUEST
36
+ ));
37
+ //return parent::isAvailable($quote) && !is_null($this->getCustomer()) && !is_null($this->getCustomer()->getId());
38
+ }
39
+
40
+ /**
41
+ * Either we will setup a new subscription - using the same mechanism as the "Gateway" method.
42
+ * Or we will redirect to our controller to take the payment from an existing subscription.
43
+ */
44
+ public function getCheckoutRedirectUrl()
45
+ {
46
+ $params = Mage::app()->getFrontController()->getRequest()->getParams();
47
+
48
+ if(!isset($params['subscription_id']) || $params['subscription_id'] == 'new')
49
+ {
50
+ return parent::getCheckoutRedirectUrl();
51
+ }
52
+ else
53
+ {
54
+ // Get the subscription
55
+ $subscription = Mage::getModel('altapaypayment/subscription')->load($params['subscription_id']);
56
+ if($subscription->getCustomerId() != $this->getCustomer()->getId())
57
+ {
58
+ Mage::throwException("This subscription does not belong to you");
59
+ }
60
+
61
+ return Mage::getUrl('altapaypayment/onepage/recurringPayment?subscription_id='.$subscription->getId());
62
+ }
63
+ }
64
+
65
+ /**
66
+ * @return Mage_Customer_Model_Customer
67
+ */
68
+ private function getCustomer()
69
+ {
70
+ return $this->getOnepage()->getCustomerSession()->getCustomer();
71
+ }
72
+
73
+ protected function getAltapayRequestConfig($orderId)
74
+ {
75
+ return array(
76
+ 'callback_form' => Mage::getUrl('altapaypayment/onepage/form')
77
+ , 'callback_ok' => Mage::getUrl('altapaypayment/onepage/recurringSuccess')
78
+ , 'callback_fail' => Mage::getUrl('altapaypayment/onepage/failure')
79
+ , 'callback_redirect' => ''
80
+ , 'callback_open' => ''
81
+ , 'callback_notification' => ''
82
+ );
83
+ }
84
+
85
+ protected function getAltapayTerminal()
86
+ {
87
+ return Mage::getStoreConfig(Altapay_Payment_Model_Constants::CONF_PATH_RECURRING_TERMINAL);
88
+ }
89
+
90
+ }
app/code/community/Altapay/Payment/Model/Method/Token.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Altapay_Payment_Model_Method_Token extends Altapay_Payment_Model_Method_Gateway {
3
+
4
+ protected $_code = 'altapay_token';
5
+ protected $_formBlockType = 'altapaypayment/form_token';
6
+ protected $_infoBlockType = 'altapaypayment/info_token';
7
+
8
+
9
+ public function getCheckoutRedirectUrl()
10
+ {
11
+ if(!$ccToken = Mage::app()->getRequest()->getParam('ccToken',false)) {
12
+ return parent::getCheckoutRedirectUrl();
13
+ } else {
14
+ $token = Mage::getModel('altapaypayment/token')->load($ccToken);
15
+ $ccToken = $token->getToken();
16
+ }
17
+
18
+ $onePage = $this->getOnepage();
19
+ if(!$onePage->getQuote()->getReservedOrderId())
20
+ {
21
+ $onePage->getQuote()->reserveOrderId();
22
+ $onePage->getQuote()->save();
23
+ }
24
+
25
+ $terminal = $this->getAltapayTerminal();
26
+ $orderid = $onePage->getQuote()->getReservedOrderId(); //'qoute_'.$onePage->getQuote()->getId();
27
+ $totals = $onePage->getQuote()->getTotals(); /** @var $totals Mage_Sales_Model_Quote_Address_Total[] */
28
+ $grandTotal = $totals['grand_total']->getValue();
29
+ $currencyCode = $onePage->getQuote()->getQuoteCurrencyCode();
30
+ $amount = number_format($grandTotal, 2,'.','');
31
+ $billingAddress = $onePage->getQuote()->getBillingAddress();
32
+ $shippingAddress = $onePage->getQuote()->getShippingAddress();
33
+
34
+ $customerInfo = array(
35
+ 'billing_postal'=> $billingAddress->getData('postcode'),
36
+ 'billing_country'=> $billingAddress->getData('country_id'),
37
+ 'billing_address'=> $billingAddress->getData('street'),
38
+ 'billing_city'=>$billingAddress->getData('city'),
39
+ 'billing_region'=>$billingAddress->getData('region'),
40
+ 'billing_firstname'=> $billingAddress->getData('firstname'),
41
+ 'billing_lastname'=> $billingAddress->getData('lastname'),
42
+ 'email'=>$billingAddress->getData('email'),
43
+ 'shipping_postal'=> $shippingAddress->getData('postcode'),
44
+ 'shipping_country'=> $shippingAddress->getData('country_id'),
45
+ 'shipping_address'=> $shippingAddress->getData('street'),
46
+ 'shipping_city'=>$shippingAddress->getData('city'),
47
+ 'shipping_region'=>$shippingAddress->getData('region'),
48
+ 'shipping_firstname'=> $shippingAddress->getData('firstname'),
49
+ 'shipping_lastname'=> $shippingAddress->getData('lastname'),
50
+ 'customer_phone'=> $billingAddress->getData('telephone'),
51
+ );
52
+
53
+ /**
54
+ * Never use our paymentAndCapture type. Magento has it's own
55
+ * flow where payment and capture is performed in two steps.
56
+ */
57
+ $paymentType = Altapay_Payment_Model_Constants::ACTION_AUTHORIZE;
58
+
59
+ $requestConfig = $this->getAltapayRequestConfig($orderid);
60
+ $transactionInfo = array(
61
+ 'qoute'=>$onePage->getQuote()->getId(),
62
+ );
63
+
64
+ $orderLines = $this->_createOrderLinesFromQuote($onePage->getQuote());
65
+ $accountOffer = false;
66
+
67
+ $response = $this->getAltapayModel()->createPaymentRequest(
68
+ $terminal,
69
+ $orderid,
70
+ $amount,
71
+ $currencyCode,
72
+ $paymentType,
73
+ $customerInfo,
74
+ $_SERVER['HTTP_COOKIE'],
75
+ Mage::app()->getLocale()->getLocale()->getLanguage(),
76
+ $requestConfig,
77
+ $transactionInfo,
78
+ $orderLines,
79
+ $accountOffer,
80
+ $ccToken
81
+ );
82
+
83
+ if($response->wasSuccessful())
84
+ {
85
+ Mage::getSingleton('core/session')->setData('altapay_payment_request_url', $response->getRedirectURL());
86
+
87
+ return $response->getRedirectURL();
88
+ }
89
+ else
90
+ {
91
+ throw new Exception($response->getErrorMessage());
92
+ }
93
+ }
94
+
95
+ protected function getAltapayTerminal()
96
+ {
97
+ return Mage::getStoreConfig(Altapay_Payment_Model_Constants::CONF_PATH_TOKEN_TERMINAL);
98
+ }
99
+
100
+ }
app/code/community/Altapay/Payment/Model/Observer.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Altapay_Payment_Model_Observer
4
+ {
5
+ private static $invoiceBeingPayedFor;
6
+
7
+ /**
8
+ * @param Varien_Event_Observer $event
9
+ */
10
+ public function salesOrderPaymentCapture($event)
11
+ {
12
+ self::$invoiceBeingPayedFor = $event->getInvoice();
13
+ }
14
+
15
+ /**
16
+ * Since Magento does not tell our payment "method" what invoices is being payed for
17
+ * we need to make this "hack". The payment it self knows the invoice but the information
18
+ * is not send into the "method".
19
+ *
20
+ * @return Mage_Sales_Model_Order_Invoice
21
+ */
22
+ public static function getInvoiceBeingPayedFor()
23
+ {
24
+ return self::$invoiceBeingPayedFor;
25
+ }
26
+ }
app/code/community/Altapay/Payment/Model/Resource/Subscription.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author emanuel
4
+ *
5
+ */
6
+ class Altapay_Payment_Model_Resource_Subscription extends Mage_Core_Model_Resource_Db_Abstract
7
+ {
8
+ protected function _construct()
9
+ {
10
+ $this->_init('altapaypayment/subscription', 'id');
11
+ }
12
+ }
app/code/community/Altapay/Payment/Model/Resource/Subscription/Collection.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Altapay_Payment_Model_Resource_Subscription_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
3
+ {
4
+ /**
5
+ * Initialize resources
6
+ *
7
+ */
8
+ public function _construct()
9
+ {
10
+ $this->_init('altapaypayment/subscription');
11
+ }
12
+
13
+ public function addAttributeToSort($attribute, $dir='asc')
14
+ {
15
+ $this->addOrder($attribute, $dir);
16
+ return $this;
17
+ }
18
+
19
+ }
app/code/community/Altapay/Payment/Model/Resource/Token.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author emanuel
4
+ *
5
+ */
6
+ class Altapay_Payment_Model_Resource_Token extends Mage_Core_Model_Resource_Db_Abstract
7
+ {
8
+ protected function _construct()
9
+ {
10
+ $this->_init('altapaypayment/token', 'id');
11
+ }
12
+ }
app/code/community/Altapay/Payment/Model/Resource/Token/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Altapay_Payment_Model_Resource_Token_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ $this->_init('altapaypayment/token');
7
+ }
8
+
9
+ }
app/code/community/Altapay/Payment/Model/Source/PaymentAction.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Payment Action Dropdown source
5
+ *
6
+ * @author Emanuel Holm Greisen <eg@altapay.com>
7
+ */
8
+ class Altapay_Payment_Model_Source_PaymentAction
9
+ {
10
+ public function toOptionArray()
11
+ {
12
+ return array(
13
+ array(
14
+ 'value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE,
15
+ 'label' => Mage::helper('altapaypayment')->__('Authorize Only')
16
+ ),
17
+ array(
18
+ 'value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE,
19
+ 'label' => Mage::helper('altapaypayment')->__('Authorize and Capture')
20
+ ),
21
+ );
22
+ }
23
+ }
app/code/community/Altapay/Payment/Model/Source/Terminals.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Drop down to show the terminals available for checkout.
5
+ *
6
+ * @category Altapay
7
+ * @package Altapay_Payment
8
+ * @author Emanuel Holm Greisen <eg@altapay.com>
9
+ */
10
+ class Altapay_Payment_Model_Source_Terminals
11
+ extends Varien_Object {
12
+
13
+ /**
14
+ * @var AltapayGetTerminalsResponse
15
+ */
16
+ private $_response;
17
+ private $_error;
18
+
19
+ public function getTerminalCurrencies($terminalTitle = false){
20
+
21
+ if($terminalTitle){
22
+ return $this->_currencies[$terminalTitle];
23
+ }else{
24
+ return $this->_currencies;
25
+ }
26
+ }
27
+
28
+ public function __construct() {
29
+
30
+ }
31
+
32
+ private function init()
33
+ {
34
+ if(is_null($this->_response))
35
+ {
36
+ $altapay_api = new Altapay_Payment_Model_Altapay(Altapay_Payment_Helper_Utilities::guessStoreIdBasedOnParameters());
37
+ try
38
+ {
39
+ $this->_response = $altapay_api->getTerminals();
40
+ }
41
+ catch(Exception $e)
42
+ {
43
+ $this->_error = $e->getMessage();
44
+ }
45
+ }
46
+ }
47
+
48
+ public function toOptionArray() {
49
+ $this->init();
50
+ $terminals = array();
51
+ if(!is_null($this->_response))
52
+ {
53
+ if($this->_response->wasSuccessful())
54
+ {
55
+ foreach($this->_response->getTerminals() as $terminal) /* @var $terminal AltapayTerminal */
56
+ {
57
+ $terminals[] = array(
58
+ 'value' => $terminal->getTitle(),
59
+ 'label' => $terminal->getTitle(),
60
+ );
61
+ }
62
+
63
+ }
64
+ else
65
+ {
66
+ $terminals[] = array(
67
+ 'value' => '',
68
+ 'label' => 'Could not get list of terminal: '.$this->_response->getErrorMessage(),
69
+ );
70
+ }
71
+ }
72
+ else if(!is_null($this->_error))
73
+ {
74
+ $terminals[] = array(
75
+ 'value' => '',
76
+ 'label' => $this->_error,
77
+ );
78
+ }
79
+ return $terminals;
80
+ }
81
+
82
+ public function canUseForCurrency($terminalTitle, $currency)
83
+ {
84
+ $this->init();
85
+ if($this->_response != null)
86
+ {
87
+ foreach($this->_response->getTerminals() as $terminal) /* @var $terminal AltapayTerminal */
88
+ {
89
+ if($terminal->getTitle() == $terminalTitle)
90
+ {
91
+ return $terminal->hasCurrency($currency);
92
+ }
93
+ }
94
+ }
95
+ return false;
96
+ }
97
+ }
app/code/community/Altapay/Payment/Model/Subscription.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author emanuel
4
+ *
5
+ */
6
+ class Altapay_Payment_Model_Subscription extends Mage_Core_Model_Abstract
7
+ {
8
+ protected function _construct()
9
+ {
10
+ parent::_construct();
11
+ $this->_init('altapaypayment/subscription');
12
+ }
13
+ }
app/code/community/Altapay/Payment/Model/Token.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author emanuel
4
+ *
5
+ */
6
+ class Altapay_Payment_Model_Token extends Mage_Core_Model_Abstract
7
+ {
8
+ protected function _construct()
9
+ {
10
+ parent::_construct();
11
+ $this->_init('altapaypayment/token');
12
+ }
13
+
14
+ public function getTokenByOrder($order)
15
+ {
16
+ if($order->getPayment()->getMethod() == 'altapay_token') {
17
+ $additional_information = $order->getPayment()->getAdditionalInformation();
18
+ $raw_details_info = $additional_information['raw_details_info'];
19
+ return $raw_details_info['credit_card_token'];
20
+ }
21
+
22
+ return false;
23
+ }
24
+
25
+ public function customerChooseToSaveCard($order,$customer) {
26
+
27
+ if($order->getCustomerId() && $customer->getId()) {
28
+
29
+ if($order->getPayment()->getMethod() == 'altapay_token') {
30
+ $additional_information = $order->getPayment()->getAdditionalInformation();
31
+ $raw_details_info = $additional_information['raw_details_info'];
32
+
33
+ if(isset($raw_details_info['transaction_info']) && $transaction_info = $raw_details_info['transaction_info']) {
34
+ if(isset($transaction_info['savecreditcard'])) {
35
+ if($savecreditcard = (bool)$transaction_info['savecreditcard']) {
36
+ $this->saveToken($order,$customer);
37
+ }
38
+ return $savecreditcard;
39
+ }
40
+ }
41
+ }
42
+
43
+ }
44
+
45
+ return false;
46
+ }
47
+
48
+ public function saveToken($order,$customer) {
49
+
50
+ $additional_information = $order->getPayment()->getAdditionalInformation();
51
+ $raw_details_info = $additional_information['raw_details_info'];
52
+
53
+ $collection = Mage::getModel('altapaypayment/token')->getCollection()
54
+ ->addFieldToFilter('customer_id',$customer->getId())
55
+ ->addFieldToFilter('deleted',0);
56
+
57
+ $primary = ($collection->getSize()) ? 0 : 1;
58
+
59
+ $token = Mage::getModel('altapaypayment/token')
60
+ ->setCustomerId($customer->getId())
61
+ ->setToken($raw_details_info['credit_card_token'])
62
+ ->setMaskedPan($raw_details_info['masked_credit_card'])
63
+ ->setCurrencyCode(Mage::helper('altapaypayment/currencyMapper')->getAlpha($raw_details_info['currency']))
64
+ ->setCustomName($raw_details_info['masked_credit_card'])
65
+ ->setPrimary($primary)
66
+ ->save();
67
+
68
+ }
69
+
70
+ public function getAllCustomerTokens()
71
+ {
72
+ if(Mage::getSingleton('customer/session')->isLoggedIn()) {
73
+ $collection = Mage::getModel('altapaypayment/token')->getCollection()
74
+ ->addFieldToFilter('customer_id',Mage::getSingleton('customer/session')->getCustomer()->getId());
75
+ return $collection;
76
+ }
77
+ return false;
78
+ }
79
+
80
+ public function getCollection($includeDeleted = false)
81
+ {
82
+ $collection = parent::getCollection();
83
+ if(!$includeDeleted) {
84
+ $collection->addFieldToFilter('deleted',0);
85
+ }
86
+
87
+ return $collection;
88
+ }
89
+
90
+ }
app/code/community/Altapay/Payment/controllers/OnepageController.php ADDED
@@ -0,0 +1,519 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once 'Mage/Checkout/controllers/OnepageController.php';
4
+ require_once(dirname(__FILE__).'/../Model/Api/AltapayMerchantAPI.class.php');
5
+
6
+
7
+ class Altapay_Payment_OnepageController extends Mage_Checkout_OnepageController {
8
+
9
+ public function failureAction() {
10
+
11
+ $errorMessage = 'Internal error';
12
+ $paymentScheme = 'N/A';
13
+
14
+ try
15
+ {
16
+ if ($this->getRequest()->has('xml'))
17
+ {
18
+ $reservationResponse = new AltapayReservationResponse(new SimpleXmlElement($this->getRequest()->getParam('xml')));
19
+
20
+ $errorMessage = $reservationResponse->getCardHolderErrorMessage();
21
+
22
+ $payments = $reservationResponse->getPayments();
23
+ if (!is_null($payments) && count($payments) > 0)
24
+ {
25
+ $paymentScheme = $payments[0]->getPaymentSchemeName();
26
+ }
27
+ }
28
+ }
29
+ catch (Exception $ex)
30
+ {
31
+ // do something?
32
+ }
33
+ Mage::getSingleton('core/session')->setData('altapay_error_message', $errorMessage);
34
+ Mage::getSingleton('core/session')->setData('altapay_payment_scheme_name', $paymentScheme);
35
+
36
+ $this->loadLayout();
37
+ $this->renderLayout();
38
+ }
39
+
40
+ public function formAction() {
41
+ $this->loadLayout();
42
+ $this->getLayout()->getBlock('head')->setTitle($this->__('Checkout'));
43
+ $this->renderLayout();
44
+ }
45
+
46
+ /**
47
+ * This method is called by Altapay, and the result will be displayed to the customer.
48
+ */
49
+ public function successAction()
50
+ {
51
+
52
+ $reservationResponse = new AltapayReservationResponse(new SimpleXmlElement($this->getRequest()->getParam('xml')));
53
+
54
+ /**
55
+ * Store the authorization transaction id in the session, in order
56
+ * for it to be available in Payment->capture (which is called by Magento
57
+ * when saving the quote)
58
+ */
59
+ Mage::getSingleton('core/session')->setData('altapay_auth_transaction_id', $reservationResponse->getPrimaryPayment()->getId());
60
+ Mage::getSingleton('core/session')->setData('altapay_requires_capture', $this->getRequest()->getParam('require_capture'));
61
+ Mage::getSingleton('core/session')->setData('altapay_payment_status', $this->getRequest()->getParam('payment_status'));
62
+
63
+ $reservationAmount = $this->extractPriceFromXML($reservationResponse->getXml());
64
+
65
+ $amountIsMathing = false;
66
+ if($reservationAmount == $this->getQuoteAmount() || $this->getQuoteAmount() == 0) {
67
+ $amountIsMathing = true;
68
+ }
69
+
70
+ if ($reservationResponse->wasSuccessful() && $amountIsMathing) {
71
+ if($this->isFraudcheckEnabled($reservationResponse)){
72
+ switch ($reservationResponse->getPrimaryPayment()->getFraudRecommendation()) {
73
+ case 'Deny':
74
+ $this->handleTransactionRejection($reservationResponse);
75
+ break;
76
+ case 'Unknown':
77
+ //Intentional fall through
78
+ case 'Challenge': //There is to handle challange cases.
79
+ //Intentional fall through
80
+ case 'Accept':
81
+ default:
82
+ //Intentional fall through
83
+ $this->storeOrderAndPayment($reservationResponse, 'success');
84
+ break;
85
+ }
86
+ }
87
+ else{
88
+ $this->storeOrderAndPayment($reservationResponse, 'success');
89
+ }
90
+ }
91
+ elseif ($reservationResponse->wasSuccessful() && !$amountIsMathing) {
92
+ $this->handleTransactionRejection($reservationResponse);
93
+ }
94
+ else {
95
+ $this->storeOrderAndPayment($reservationResponse, 'failed');
96
+ }
97
+ }
98
+
99
+ /**
100
+ * This method is called by Altapay, and the result will be displayed to the customer.
101
+ */
102
+ public function openAction()
103
+ {
104
+ $reservationResponse = new AltapayReservationResponse(new SimpleXmlElement($this->getRequest()->getParam('xml')));
105
+
106
+ $this->storeOrderAndPayment($reservationResponse, 'open');
107
+ }
108
+
109
+ /**
110
+ * This method is called by Altapay's gateway without the user being there to see the result.
111
+ * For this reason we print out some things which will be visible in the logs in Altapay.
112
+ */
113
+ public function notificationAction()
114
+ {
115
+ $reservationResponse = new AltapayReservationResponse(new SimpleXmlElement($this->getRequest()->getParam('xml')));
116
+
117
+ // Find the order
118
+ $orderId = $reservationResponse->getPrimaryPayment()->getShopOrderId();
119
+
120
+ //Mage_Checkout_Model_Session::getQuote();
121
+
122
+ $order = $this->_loadOrder($orderId);
123
+
124
+
125
+
126
+
127
+ $status = $this->getRequest()->getParam('status');
128
+ if(!is_null($order))
129
+ {
130
+ print("OrderState: ".$order->getState()."\n");
131
+ }
132
+ else
133
+ {
134
+ $merchantErrorMessage = $this->getRequest()->getPost('merchant_error_message', '');
135
+
136
+ if ($merchantErrorMessage == 'Declined')
137
+ {
138
+ // we are ok with not finding the payment
139
+ return;
140
+ }
141
+
142
+ $quote = Mage::getModel('sales/quote')->load($reservationResponse->getPrimaryPayment()->getShopOrderId(), 'reserved_order_id');
143
+
144
+ $this->getOnePage()->setQuote($quote);
145
+
146
+ if($status == 'success' || $status == 'succeeded')
147
+ {
148
+ // create an order etc.
149
+ $this->successAction();
150
+ $order = $this->_loadOrder($orderId);
151
+ }
152
+ else
153
+ {
154
+ print("Could not find order: ".$orderId);
155
+ throw new Exception("Could not find order: ".$orderId);
156
+ }
157
+ }
158
+
159
+ // Handle the actual notification
160
+ if($status == 'success' || $status == 'succeeded')
161
+ {
162
+ if($order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT)
163
+ {
164
+ if(bccomp($reservationResponse->getPrimaryPayment()->getReservedAmount(), $order->getTotalDue(), 2) == 0)
165
+ {
166
+ // The notification is a payment-notification
167
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'The payment is no longer "open" at Altapay, we can start processing the order', false);
168
+ }
169
+ else
170
+ {
171
+ print('The payment is most likely still "open" because the reserved amount and the amount due do not match: '.$reservationResponse->getPrimaryPayment()->getReservedAmount().' and '.$order->getTotalDue()."\n");
172
+ $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, 'The payment is most likely still "open" because the reserved amount and the amount due do not match: '.$reservationResponse->getPrimaryPayment()->getReservedAmount().' and '.$order->getTotalDue(), false);
173
+ }
174
+ $order->save();
175
+ }
176
+ else if($order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING)
177
+ {
178
+ print("The order is already processing, hmm..\n");
179
+ }
180
+ else
181
+ {
182
+ print("Status was success/succeeded, but the order state was unexpected:".$order->getState()."\n");
183
+ }
184
+ }
185
+ else if($status == 'failed')
186
+ {
187
+ print("status is failed\n");
188
+
189
+ /**
190
+ * Cancel the order if it is
191
+ * pending
192
+ * _or_
193
+ * is a paypal payment (as those guys can make all sorts of crazy jumps in state)
194
+ *
195
+ * Keeping it narrow for the time being, as we do not know the consequences of changing
196
+ * the state on the order.
197
+ */
198
+ if($order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT || $reservationResponse->getPrimaryPayment()->getPaymentSchemeName() == 'PayPal')
199
+ {
200
+ print("cancelling order\n");
201
+ // Cancel the order (as the payment was declined)
202
+ $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, 'The payment was declined', false);
203
+ $order->save();
204
+ }
205
+ }
206
+ else
207
+ {
208
+ print("An unknown notification was sent: ".$status);
209
+ throw new Exception("An unknown notification was sent: ".$status);
210
+ }
211
+ }
212
+
213
+ /**
214
+ * This method is called when the user chooses to use an already existing subscription.
215
+ *
216
+ * We should:
217
+ * - Find the subscription and verify that it belongs to the user.
218
+ * - Attempt to make a recurring preauth/capture to cover the order.
219
+ */
220
+ public function recurringPaymentAction()
221
+ {
222
+ $params = $this->getRequest()->getParams();
223
+
224
+ if(!isset($params['subscription_id']) || $params['subscription_id'] == 'new')
225
+ {
226
+ Mage::getSingleton('checkout/session')->setErrorMessage("No subscription provided");
227
+ $this->_redirect('checkout/onepage/failure');
228
+ }
229
+ else
230
+ {
231
+ $subscription = Mage::getModel('altapaypayment/subscription')->load($params['subscription_id']);
232
+ if($subscription->getCustomerId() != $this->getCustomer()->getId())
233
+ {
234
+ Mage::getSingleton('checkout/session')->setErrorMessage("This subscription does not belong to you");
235
+ $this->_redirect('checkout/onepage/failure');
236
+ }
237
+
238
+ if($subscription->getCurrencyCode() != $this->getOnepage()->getQuote()->getQuoteCurrencyCode())
239
+ {
240
+ Mage::getSingleton('checkout/session')->setErrorMessage("This subscription is in the wrong currency");
241
+ $this->_redirect('checkout/onepage/failure');
242
+ }
243
+ else
244
+ {
245
+ $this->processRecurringPayment($subscription);
246
+ }
247
+ }
248
+ }
249
+
250
+ /**
251
+ * This method is called when we have successfully made a subscription.
252
+ *
253
+ * We should:
254
+ * - Store the subscription for later use
255
+ * - Attempt to make a recurring preauth/capture to cover the order.
256
+ */
257
+ public function recurringSuccessAction()
258
+ {
259
+ // Store the subscription
260
+ $subscription = $this->storeSubscription($this->getRequest()->getParam('xml'));
261
+
262
+ $this->processRecurringPayment($subscription);
263
+ }
264
+
265
+ private function storeOrderAndPayment($reservationResponse, $successType='success')
266
+ {
267
+
268
+ if(!$this->getOnepage()->getQuote()){
269
+ Mage::log($_SERVER['REMOTE_ADDR'].': no quote',null,'altapay.log',true);
270
+ // Redirect to success page
271
+ $this->_redirect('checkout/onepage/success');
272
+
273
+ // Render Meta-Redirect success page (could be skipped)
274
+ $this->loadLayout();
275
+ $this->_initLayoutMessages('checkout/session');
276
+ $this->renderLayout();
277
+ return;
278
+ }
279
+
280
+ if(!$this->getOnepage()->getQuote()->getIsActive()){
281
+ Mage::log($_SERVER['REMOTE_ADDR'].': quote not active',null,'altapay.log',true);
282
+ // Redirect to success page
283
+ $this->_redirect('checkout/onepage/success');
284
+
285
+ // Render Meta-Redirect success page (could be skipped)
286
+ $this->loadLayout();
287
+ $this->_initLayoutMessages('checkout/session');
288
+ $this->renderLayout();
289
+ return;
290
+ }
291
+
292
+ $checkoutSessionId = $this->getOnepage()->getCheckout()->getSessionId();
293
+
294
+ try{
295
+ // Clear the basket and save the order (including some info about how the payment went)
296
+ $this->getOnepage()->getQuote()->collectTotals();
297
+ $this->getOnepage()->getQuote()->getPayment()->setAdditionalInformation('successType', $successType);
298
+ $orderId = $this->getOnepage()->saveOrder()->getLastOrderId();
299
+ $this->getOnepage()->getQuote()->save();
300
+ }
301
+ catch(Exception $e){
302
+ Mage::log($_SERVER['REMOTE_ADDR'].': exception: '.$e->getMessage(),null,'altapay.log',true);
303
+ // Redirect to success page
304
+ $this->_redirect('checkout/onepage/success');
305
+
306
+ // Render Meta-Redirect success page (could be skipped)
307
+ $this->loadLayout();
308
+ $this->_initLayoutMessages('checkout/session');
309
+ $this->renderLayout();
310
+ return;
311
+ }
312
+
313
+ // Store the information from Altapay
314
+ {
315
+ $order = $this->_loadOrder($orderId);
316
+
317
+ $payment = $order->getPayment();
318
+ $payment->setTransactionId($reservationResponse->getPrimaryPayment()->getId());
319
+ if($reservationResponse->getPrimaryPayment()->getPaymentNature() == 'CreditCard')
320
+ {
321
+ $payment->setData('cc_last4', substr('****'.$reservationResponse->getPrimaryPayment()->getMaskedPan(), -4));
322
+ $payment->setData('cc_number_enc', $reservationResponse->getPrimaryPayment()->getMaskedPan());
323
+ $payment->setData('cc_trans_id', $reservationResponse->getPrimaryPayment()->getId());
324
+ }
325
+ $payment->setAdditionalData(serialize($reservationResponse));
326
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $this->getRequest()->getParams());
327
+
328
+ $payment->save();
329
+
330
+ $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
331
+ $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $this->getRequest()->getParams());
332
+ $transaction->setAdditionalInformation('altapay_response', serialize($reservationResponse));
333
+ $transaction->setTxnId($reservationResponse->getPrimaryPayment()->getId());
334
+ $transaction->setIsClosed(false);
335
+ $transaction->save();
336
+
337
+ if($successType == 'open')
338
+ {
339
+ $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, 'The payment is "open" at Altapay, we must wait for a notification before it will be processing', false);
340
+ $order->save();
341
+ }
342
+ elseif ($successType == 'failed')
343
+ {
344
+ // Cancel the order (as the payment was declined)
345
+ $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, 'The payment was declined', false);
346
+ $order->save();
347
+ }
348
+ }
349
+
350
+ if($checkoutSessionId != $this->getOnepage()->getCheckout()->getSessionId()) {
351
+ $this->_redirect('altapaypayment/onepage/customerCreated',array('success' => $this->getOnepage()->getCheckout()->getSessionId()));
352
+ } else {
353
+ // Redirect to success page
354
+ $this->_redirect('checkout/onepage/success');
355
+ }
356
+ // Render Meta-Redirect success page (could be skipped)
357
+ $this->loadLayout();
358
+ $this->_initLayoutMessages('checkout/session');
359
+ $this->renderLayout();
360
+ }
361
+
362
+ public function customerCreatedAction() {
363
+
364
+ $session = Mage::getSingleton('checkout/session');
365
+ $sessionId = $this->getRequest()->getParam('success',false);
366
+ if($session->getSessionId() != $sessionId) {
367
+ $session->getCookie()->set($session->getSessionName(),$sessionId);
368
+ }
369
+ $this->_redirect('checkout/onepage/success');
370
+ }
371
+
372
+
373
+ private function processRecurringPayment($subscription)
374
+ {
375
+ $totals = $this->getOnePage()->getQuote()->getTotals();
376
+ $grandTotal = $totals['grand_total']->getValue();
377
+ $amount = number_format($grandTotal, 2,'.','');
378
+
379
+ $storeId = $this->getOnePage()->getQuote()->getStoreId();
380
+ $altapayModel = new Altapay_Payment_Model_Altapay($storeId);
381
+ $reservationResponse = $altapayModel->recurringReservation($subscription->getSubscriptionId(), $amount);
382
+
383
+ if($reservationResponse->wasSuccessful())
384
+ {
385
+ $this->storeOrderAndPayment($reservationResponse, 'success');
386
+ }
387
+ else
388
+ {
389
+ Mage::getSingleton('checkout/session')->setErrorMessage($reservationResponse->getCardHolderErrorMessage());
390
+ $this->_redirect('checkout/onepage/failure');
391
+ }
392
+ }
393
+
394
+ private function storeSubscription($xml)
395
+ {
396
+ $subscriptionResponse = new AltapayReservationResponse(new SimpleXmlElement($xml));
397
+
398
+ $currencyMapper = new Altapay_Payment_Helper_CurrencyMapper();
399
+
400
+ /* @var Mage_Customer_Model_Customer $customer */
401
+ $customer = $this->getOnepage()->getCustomerSession()->getCustomer();
402
+ $subscription = Mage::getModel('altapaypayment/subscription');
403
+ $subscription->setSubscriptionId($subscriptionResponse->getPrimaryPayment()->getId());
404
+ $subscription->setCustomerId($customer->getId());
405
+ $subscription->setMaskedPan($subscriptionResponse->getPrimaryPayment()->getMaskedPan());
406
+ $subscription->setCardToken($subscriptionResponse->getPrimaryPayment()->getCreditCardToken());
407
+ $subscription->setCurrencyCode($currencyMapper->getAlpha($subscriptionResponse->getPrimaryPayment()->getCurrency()));
408
+ $subscription->save();
409
+
410
+ return $subscription;
411
+ }
412
+
413
+ /**
414
+ * @return Mage_Sales_Model_Order
415
+ **/
416
+ private function _loadOrder($orderId)
417
+ {
418
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
419
+ if($order->getIncrementId() == $orderId)
420
+ {
421
+ return $order;
422
+ }
423
+ return null;
424
+ }
425
+
426
+ /**
427
+ * @return Mage_Customer_Model_Customer
428
+ */
429
+ private function getCustomer()
430
+ {
431
+ return $this->getOnepage()->getCustomerSession()->getCustomer();
432
+ }
433
+
434
+ private function getQuoteAmount()
435
+ {
436
+ $totals = $this->getOnePage()->getQuote()->getTotals();
437
+ $grandTotal = $totals['grand_total']->getValue();
438
+ $amount = number_format($grandTotal, 2,'.','');
439
+ return $amount;
440
+ }
441
+
442
+ private function extractPriceFromXML($xml)
443
+ {
444
+ $simpleXML = new SimpleXmlElement($xml);
445
+ $total = $simpleXML->Body->Transactions[0]->Transaction->ReservedAmount;
446
+ $surcharge = $simpleXML->Body->Transactions[0]->Transaction->SurchargeAmount;
447
+ return bcsub($total, $surcharge, 2);
448
+ }
449
+
450
+ private function releasePayment($paymentID)
451
+ {
452
+ try{
453
+ $altapayAPI = $this->getAltapayAPI();
454
+ $altapayAPI->releaseReservation($paymentID);
455
+ }
456
+ catch(Exception $ex){
457
+ //We tried
458
+ }
459
+ }
460
+
461
+ private function refundPayment($paymentID)
462
+ {
463
+ try{
464
+ $altapayAPI = $this->getAltapayAPI();
465
+ $altapayAPI->refundCapturedReservation($paymentID);
466
+ }
467
+ catch(Exception $ex){
468
+ //We tried
469
+ }
470
+ }
471
+
472
+ private function getAltapayAPI()
473
+ {
474
+ $baseURL = Mage::getStoreConfig(Altapay_Payment_Model_Constants::CONF_PATH_API_INSTALLATION);
475
+ $username = Mage::getStoreConfig(Altapay_Payment_Model_Constants::CONF_PATH_API_USERNAME);
476
+ $password = Mage::getStoreConfig(Altapay_Payment_Model_Constants::CONF_PATH_API_PASSWORD);
477
+ return new AltapayMerchantAPI($baseURL, $username, $password);
478
+ }
479
+ private function isReservation($paymentStatus){
480
+ if($paymentStatus == 'preauth'){
481
+ return true;
482
+ }
483
+ elseif($paymentStatus == 'invoice_initialized'){
484
+ return true;
485
+ }
486
+ return false;
487
+ }
488
+
489
+ /**
490
+ * @param AltapayReservationResponse $reservationResponse
491
+ */
492
+ private function isFraudcheckEnabled($reservationResponse)
493
+ {
494
+ try{
495
+ if($reservationResponse->getPrimaryPayment()->getFraudRecommendation() != null) {
496
+ return true;
497
+ }
498
+ }
499
+ catch(Exception $ex){
500
+ //I would assume that there is no fraud detection available.
501
+ }
502
+ return false;
503
+ }
504
+
505
+ /**
506
+ * @param AltapayReservationResponse $reservationResponse
507
+ */
508
+ private function handleTransactionRejection($reservationResponse)
509
+ {
510
+ if($this->isReservation($this->getRequest()->getParam('payment_status')))
511
+ {
512
+ $this->releasePayment($reservationResponse->getPrimaryPayment()->getId());
513
+ }
514
+ else{
515
+ $this->refundPayment($reservationResponse->getPrimaryPayment()->getId());
516
+ }
517
+ $this->_redirect('altapaypayment/onepage/failure?orderID=' . $reservationResponse->getPrimaryPayment()->getShopOrderId());
518
+ }
519
+ }
app/code/community/Altapay/Payment/controllers/TokenController.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Altapay_Payment_TokenController extends Mage_Core_Controller_Front_Action
3
+ {
4
+
5
+ public function preDispatch()
6
+ {
7
+ parent::preDispatch();
8
+ $action = $this->getRequest()->getActionName();
9
+ $loginUrl = Mage::helper('customer')->getLoginUrl();
10
+
11
+ if (!Mage::getSingleton('customer/session')->authenticate($this, $loginUrl)) {
12
+ $this->setFlag('', self::FLAG_NO_DISPATCH, true);
13
+ $this->_redirect('/');
14
+ } elseif(!Mage::getStoreConfig('payment/altapay_token/active_customer_token_control')) {
15
+ $this->setFlag('', self::FLAG_NO_DISPATCH, true);
16
+ $this->_redirect('customer/account');
17
+ }
18
+
19
+ }
20
+
21
+ public function viewAction()
22
+ {
23
+ $this->loadLayout();
24
+ $this->_initLayoutMessages('customer/session');
25
+ $this->renderLayout();
26
+ }
27
+
28
+ public function saveAction()
29
+ {
30
+ $redirect = "/";
31
+ if ($this->_validateFormKey()) {
32
+ if(Mage::getSingleton('customer/session')->isLoggedIn()) {
33
+
34
+ if($incrementId = $this->getRequest()->getParam('order_id',false)) {
35
+ $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
36
+ if($order->getId() && $order->getPayment()->getMethod() == 'altapay_token') {
37
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
38
+ if($order->getCustomerId() == $customer->getId()) {
39
+ $redirect = "customer/token/view";
40
+ // ALT ER GODT
41
+
42
+ Mage::getModel('altapaypayment/token')->saveToken($order,$customer);
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ $this->_redirect($redirect);
49
+ }
50
+
51
+ public function updateCustomNameAction()
52
+ {
53
+ $response = array('status' => 'error');
54
+ $this->getResponse()->setHeader('Content-type', 'text/json; charset=UTF-8');
55
+ $tokenId = $this->getRequest()->getParam('token_id',false);
56
+ $customName = $this->getRequest()->getParam('custom_name',false);
57
+
58
+ if($tokenId && $customName)
59
+ {
60
+ if(Mage::getSingleton('customer/session')->isLoggedIn()) {
61
+
62
+ $token = Mage::getModel('altapaypayment/token')->load($tokenId);
63
+ if($token->getId()) {
64
+ if(Mage::getSingleton('customer/session')->getCustomer()->getId() == $token->getCustomerId()) {
65
+ if($token->getCustomName() != $customName) {
66
+ $token->setCustomName($customName)->save();
67
+ $response = array('status' => 'updated');
68
+ } else {
69
+ $response = array('status' => 'ok');
70
+ }
71
+ }
72
+ }
73
+ }
74
+ }
75
+
76
+ $this->getResponse()->setBody(json_encode($response));
77
+ }
78
+
79
+ public function updatePrimaryTokenAction()
80
+ {
81
+ $response = array('status' => 'error');
82
+ $this->getResponse()->setHeader('Content-type', 'text/json; charset=UTF-8');
83
+ $tokenId = $this->getRequest()->getParam('token_id',false);
84
+
85
+ if($tokenId)
86
+ {
87
+ if(Mage::getSingleton('customer/session')->isLoggedIn()) {
88
+
89
+ $token = Mage::getModel('altapaypayment/token')->load($tokenId);
90
+ if($token->getId()) {
91
+ if(Mage::getSingleton('customer/session')->getCustomer()->getId() == $token->getCustomerId()) {
92
+ try {
93
+ $token->setPrimary(1)->save();
94
+
95
+ $collection = Mage::getModel('altapaypayment/token')->getCollection()
96
+ ->addFieldToFilter('customer_id',$token->getCustomerId())
97
+ ->addFieldToFilter('id',array('neq' => $token->getId()))
98
+ ->addFieldToFilter('primary',1)
99
+ ;
100
+ foreach($collection as $token) {
101
+ $token->setPrimary(0)->save();
102
+ }
103
+
104
+ $response = array('status' => 'updated');
105
+ } catch(Exception $e) {
106
+ $response = array('status' => 'error');
107
+ }
108
+ }
109
+ }
110
+ }
111
+ }
112
+
113
+ $this->getResponse()->setBody(json_encode($response));
114
+ }
115
+
116
+ public function deleteTokenAction()
117
+ {
118
+ $response = array('status' => 'error');
119
+ $this->getResponse()->setHeader('Content-type', 'text/json; charset=UTF-8');
120
+ $tokenId = $this->getRequest()->getParam('token_id',false);
121
+
122
+ if($tokenId)
123
+ {
124
+ if(Mage::getSingleton('customer/session')->isLoggedIn()) {
125
+
126
+ $token = Mage::getModel('altapaypayment/token')->load($tokenId);
127
+ if($token->getId()) {
128
+ if(Mage::getSingleton('customer/session')->getCustomer()->getId() == $token->getCustomerId()) {
129
+ try {
130
+ $token->setDeleted(1)->save();
131
+ $response = array('status' => 'deleted');
132
+ } catch(Exception $e) {
133
+ $response = array('status' => 'error');
134
+ }
135
+ }
136
+ }
137
+ }
138
+ }
139
+
140
+ $this->getResponse()->setBody(json_encode($response));
141
+ }
142
+
143
+ }
app/code/community/Altapay/Payment/etc/adminhtml.xml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Altapay Payment Extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
9
+ * compliance with the License. You may obtain a copy of the License at
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is
12
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and limitations under the License.
14
+ *
15
+ * @category Altapay
16
+ * @package Altapay_Payment
17
+ * @copyright Copyright (c) 2011-2012 Altapay A/S (http://altapay.com)
18
+ * @author Emanuel Holm Greisen
19
+ * @license Apache License, Version 2.0
20
+ */
21
+ -->
22
+ <config>
23
+ <acl>
24
+ <resources>
25
+ <admin>
26
+ <children>
27
+ <system>
28
+ <children>
29
+ <config>
30
+ <children>
31
+ <altapay>
32
+ <title>Altapay</title>
33
+ </altapay>
34
+ </children>
35
+ </config>
36
+ </children>
37
+ </system>
38
+ </children>
39
+ </admin>
40
+ </resources>
41
+ </acl>
42
+ </config>
app/code/community/Altapay/Payment/etc/config.xml ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Altapay Payment Extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
9
+ * compliance with the License. You may obtain a copy of the License at
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is
12
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and limitations under the License.
14
+ *
15
+ * @category Altapay
16
+ * @package Altapay_Payment
17
+ * @copyright Copyright (c) 2011-2012 Altapay A/S (http://altapay.com)
18
+ * @author Emanuel Greisen
19
+ * @license Apache License, Version 2.0
20
+ */
21
+ -->
22
+ <config>
23
+ <modules>
24
+ <Altapay_Payment>
25
+ <version>1.1.2</version>
26
+ </Altapay_Payment>
27
+ </modules>
28
+
29
+ <frontend>
30
+ <layout>
31
+ <updates>
32
+ <altapaypayment>
33
+ <file>altapay.xml</file>
34
+ </altapaypayment>
35
+ </updates>
36
+ </layout>
37
+ <translate>
38
+ <modules>
39
+ <Altapay_Payment>
40
+ <files>
41
+ <default>Altapay_Payment.csv</default>
42
+ </files>
43
+ </Altapay_Payment>
44
+ </modules>
45
+ </translate>
46
+
47
+ <routers>
48
+ <customer>
49
+ <args>
50
+ <modules>
51
+ <altapaypayment before="Mage_Customer">Altapay_Payment</altapaypayment>
52
+ </modules>
53
+ </args>
54
+ </customer>
55
+ <altapaypayment>
56
+ <use>standard</use>
57
+ <args>
58
+ <module>Altapay_Payment</module>
59
+ <frontName>altapaypayment</frontName>
60
+ </args>
61
+ </altapaypayment>
62
+ </routers>
63
+
64
+ </frontend>
65
+
66
+ <global>
67
+ <blocks>
68
+ <altapaypayment>
69
+ <class>Altapay_Payment_Block</class>
70
+ </altapaypayment>
71
+ <checkout>
72
+ <rewrite>
73
+ <onepage>Altapay_Payment_Block_Onepage</onepage>
74
+ </rewrite>
75
+ </checkout>
76
+ </blocks>
77
+
78
+ <helpers>
79
+ <altapaypayment>
80
+ <class>Altapay_Payment_Helper</class>
81
+ </altapaypayment>
82
+ </helpers>
83
+ <models>
84
+ <altapaypayment>
85
+ <class>Altapay_Payment_Model</class>
86
+ <resourceModel>altapaypayment_resource</resourceModel>
87
+ </altapaypayment>
88
+ <altapaypayment_resource>
89
+ <class>Altapay_Payment_Model_Resource</class>
90
+ <entities>
91
+ <subscription>
92
+ <table>altapay_subscriptions</table>
93
+ </subscription>
94
+ <token>
95
+ <table>altapay_token</table>
96
+ </token>
97
+ </entities>
98
+ </altapaypayment_resource>
99
+ </models>
100
+ <resources>
101
+ <altapaypayment_setup>
102
+ <setup>
103
+ <module>Altapay_Payment</module>
104
+ </setup>
105
+ <connection>
106
+ <use>core_setup</use>
107
+ </connection>
108
+ </altapaypayment_setup>
109
+ <altapaypayment_write>
110
+ <connection>
111
+ <use>core_write</use>
112
+ </connection>
113
+ </altapaypayment_write>
114
+ <altapaypayment_read>
115
+ <connection>
116
+ <use>core_read</use>
117
+ </connection>
118
+ </altapaypayment_read>
119
+ </resources>
120
+ <events>
121
+ <sales_order_payment_capture>
122
+ <observers>
123
+ <altapay_hooksystem_invoice_about_to_be_captured>
124
+ <type>singleton</type>
125
+ <class>altapaypayment/observer</class>
126
+ <method>salesOrderPaymentCapture</method>
127
+ </altapay_hooksystem_invoice_about_to_be_captured>
128
+ </observers>
129
+ </sales_order_payment_capture>
130
+ </events>
131
+ </global>
132
+ <admin>
133
+ <routers>
134
+ <altapaypayment>
135
+ <use>admin</use>
136
+ <args>
137
+ <module>Altapay_Payment</module>
138
+ <frontName>altapaypayment</frontName>
139
+ </args>
140
+ </altapaypayment>
141
+ </routers>
142
+ </admin>
143
+ <adminhtml>
144
+ <layout>
145
+ <updates>
146
+ <altapaypayment>
147
+ <file>altapay.xml</file>
148
+ </altapaypayment>
149
+ </updates>
150
+ </layout>
151
+ <translate>
152
+ <modules>
153
+ <Altapay_Payment>
154
+ <files>
155
+ <default>Altapay_Payment.csv</default>
156
+ </files>
157
+ </Altapay_Payment>
158
+ </modules>
159
+ </translate>
160
+ </adminhtml>
161
+ <default>
162
+ <altapay_general>
163
+ <api_installation>https://testgateway.altapaysecure.com/</api_installation>
164
+ <api_username></api_username>
165
+ <api_password></api_password>
166
+ </altapay_general>
167
+ <payment>
168
+ <altapay_moto>
169
+ <active>0</active>
170
+ <model>altapaypayment/method_moto</model>
171
+ <title>Altapay MO/TO</title>
172
+ <useccv>1</useccv>
173
+ </altapay_moto>
174
+ <altapay_gateway>
175
+ <active>0</active>
176
+ <model>altapaypayment/method_gateway</model>
177
+ <title>Altapay Payment Gateway</title>
178
+ </altapay_gateway>
179
+ <altapay_token>
180
+ <active>0</active>
181
+ <active_customer_token_control>0</active_customer_token_control>
182
+ <model>altapaypayment/method_token</model>
183
+ <title>Altapay Payment Gateway with Tokenization</title>
184
+ </altapay_token>
185
+ <altapay_recurring>
186
+ <active>0</active>
187
+ <model>altapaypayment/method_recurring</model>
188
+ <title>Stored Credit Card</title>
189
+ </altapay_recurring>
190
+ </payment>
191
+ </default>
192
+ </config>
app/code/community/Altapay/Payment/etc/system.xml ADDED
@@ -0,0 +1,369 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Altapay Payment Extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
9
+ * compliance with the License. You may obtain a copy of the License at
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is
12
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and limitations under the License.
14
+ *
15
+ * @category Altapay
16
+ * @package Altapay_Payment
17
+ * @copyright Copyright (c) 2011-2012 Altapay A/S (http://altapay.com)
18
+ * @author Emanuel Holm Greisen
19
+ * @license Apache License, Version 2.0
20
+ */
21
+ -->
22
+ <config>
23
+ <sections>
24
+ <altapay translate="label" module="altapaypayment">
25
+ <label>Altapay Payments</label>
26
+ <class>altapay-section</class>
27
+ <header_css>altapay-header</header_css>
28
+ <tab>sales</tab>
29
+ <frontend_type>text</frontend_type>
30
+ <sort_order>360</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_store>1</show_in_store>
33
+ <groups>
34
+ <overview translate="label">
35
+ <label>Overview</label>
36
+ <expanded>1</expanded>
37
+ <frontend_type>text</frontend_type>
38
+ <sort_order>1</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_store>1</show_in_store>
41
+ <comment><![CDATA[
42
+ <div class="box">
43
+ <p class="grand-total"><b>Altapay - One Contact. One Contract.</b></p>
44
+ <p>Altapay is a full-line supplier of payment solutions supporting customers, merchants and financial institutions to
45
+ safely process payment transactions. We are focused on handling customer payments securely and efficiently and on
46
+ offering merchants deep, real-time insight into transaction information.</p>
47
+ <p>Please select from our available methods below.<p>
48
+ <p class="total"><b>PHP/Server Requirements:</b></p>
49
+ <ul>
50
+ <li><code>allow_url_fopen</code> Must be set to true, this is required for our plug-in to communicate via our Payment Gateway</li>
51
+ <li>HTTPS stream-wrapper must be enabled.</li>
52
+ <li>If you run PHP as CGI under Apache, then apache must be compiled <u>without</u> "<code>--with-curlwrappers</code>". This ensures that Basic HTTP authentication works.</li>
53
+ </ul>
54
+ </div>
55
+
56
+ ]]>
57
+ </comment>
58
+ </overview>
59
+ <altapay_general translate="label comment">
60
+ <label>API / Integration Settings</label>
61
+ <fieldset_css>altapay-config</fieldset_css>
62
+ <frontend_type>text</frontend_type>
63
+ <sort_order>4</sort_order>
64
+ <show_in_default>1</show_in_default>
65
+ <show_in_store>1</show_in_store>
66
+ <comment><![CDATA[
67
+ <div class="box">
68
+ <p class="grand-total"><b>Note:</b></p>
69
+ <p>Typically your installation for testing will be "https://testgateway.altapaysecure.com/" and for production it will be "https://yourdomain.altapaysecure.com/". Your Username and Password may be different for testing and live</p>
70
+ </div>]]>
71
+ </comment>
72
+ <fields>
73
+ <api_installation translate="label">
74
+ <label>Installation</label>
75
+ <config_path>altapay_general/api_installation</config_path>
76
+ <sort_order>5</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_store>1</show_in_store>
79
+ </api_installation>
80
+ <api_username translate="label">
81
+ <label>API Username</label>
82
+ <config_path>altapay_general/api_username</config_path>
83
+ <sort_order>5</sort_order>
84
+ <show_in_default>1</show_in_default>
85
+ <show_in_store>1</show_in_store>
86
+ </api_username>
87
+ <api_password translate="label">
88
+ <label>API Password</label>
89
+ <config_path>altapay_general/api_password</config_path>
90
+ <frontend_type>obscure</frontend_type>
91
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
92
+ <sort_order>10</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_store>1</show_in_store>
95
+ </api_password>
96
+ </fields>
97
+ </altapay_general>
98
+
99
+ <altapay_token translate="label">
100
+ <label>Altapay Payment Gateway With Tokenization - Allows your customers store at token of there creditcard.</label>
101
+ <fieldset_css>altapay-config</fieldset_css>
102
+ <frontend_type>text</frontend_type>
103
+ <sort_order>9</sort_order>
104
+ <show_in_default>1</show_in_default>
105
+ <show_in_store>1</show_in_store>
106
+ <comment><![CDATA[
107
+ <div class="box">
108
+ <p class="grand-total"><b>Note:</b></p>
109
+ <p>Before you can use the Gateway you must make sure that your Magento installation is visible to the outside as Altapay's Payment Gateway will be
110
+ performing callback calls with information about the payment.<p>
111
+ </div>]]>
112
+ </comment>
113
+ <fields>
114
+ <active translate="label">
115
+ <label>Enable</label>
116
+ <frontend_type>select</frontend_type>
117
+ <source_model>adminhtml/system_config_source_yesno</source_model>
118
+ <sort_order>0</sort_order>
119
+ <config_path>payment/altapay_token/active</config_path>
120
+ <show_in_default>1</show_in_default>
121
+ <show_in_store>1</show_in_store>
122
+ </active>
123
+
124
+ <active_customer_token_control translate="label">
125
+ <label>Enable Customer Token Control</label>
126
+ <frontend_type>select</frontend_type>
127
+ <source_model>adminhtml/system_config_source_yesno</source_model>
128
+ <sort_order>1</sort_order>
129
+ <config_path>payment/altapay_token/active_customer_token_control</config_path>
130
+ <show_in_default>1</show_in_default>
131
+ <show_in_store>1</show_in_store>
132
+ </active_customer_token_control>
133
+
134
+ <terminal translate="label">
135
+ <label>Terminal</label>
136
+ <comment>You need to set your username / password above before you can choose your Terminal.</comment>
137
+ <frontend_type>select</frontend_type>
138
+ <source_model>altapay_payment_model_source_terminals</source_model>
139
+ <sort_order>10</sort_order>
140
+ <config_path>payment/altapay_token/terminal</config_path>
141
+ <show_in_default>1</show_in_default>
142
+ <show_in_store>1</show_in_store>
143
+ </terminal>
144
+ <title translate="label comment">
145
+ <label>Title</label>
146
+ <config_path>payment/altapay_token/title</config_path>
147
+ <frontend_type>text</frontend_type>
148
+ <sort_order>20</sort_order>
149
+ <show_in_default>1</show_in_default>
150
+ <show_in_store>1</show_in_store>
151
+ </title>
152
+
153
+ <payment_action translate="label">
154
+ <label>Payment Action</label>
155
+ <frontend_type>select</frontend_type>
156
+ <config_path>payment/altapay_token/payment_action</config_path>
157
+ <source_model>altapay_payment_model_source_paymentAction</source_model>
158
+ <sort_order>30</sort_order>
159
+ <show_in_default>1</show_in_default>
160
+ <show_in_store>1</show_in_store>
161
+ </payment_action>
162
+
163
+
164
+
165
+ <sort_order translate="label">
166
+ <label>Sort Order</label>
167
+ <config_path>payment/altapay_token/sort_order</config_path>
168
+ <frontend_type>text</frontend_type>
169
+ <sort_order>100</sort_order>
170
+ <show_in_default>1</show_in_default>
171
+ <show_in_store>1</show_in_store>
172
+ </sort_order>
173
+ </fields>
174
+ </altapay_token>
175
+
176
+ <altapay_gateway translate="label">
177
+ <label>Altapay Payment Gateway - Allows your customers to purchase with any of the payment options you have enabled in your Altapay account.</label>
178
+ <fieldset_css>altapay-config</fieldset_css>
179
+ <frontend_type>text</frontend_type>
180
+ <sort_order>10</sort_order>
181
+ <show_in_default>1</show_in_default>
182
+ <show_in_store>1</show_in_store>
183
+ <comment><![CDATA[
184
+ <div class="box">
185
+ <p class="grand-total"><b>Note:</b></p>
186
+ <p>Before you can use the Gateway you must make sure that your Magento installation is visible to the outside as Altapay's Payment Gateway will be
187
+ performing callback calls with information about the payment.<p>
188
+ </div>]]>
189
+ </comment>
190
+ <fields>
191
+ <active translate="label">
192
+ <label>Enable</label>
193
+ <frontend_type>select</frontend_type>
194
+ <source_model>adminhtml/system_config_source_yesno</source_model>
195
+ <sort_order>0</sort_order>
196
+ <config_path>payment/altapay_gateway/active</config_path>
197
+ <show_in_default>1</show_in_default>
198
+ <show_in_store>1</show_in_store>
199
+ </active>
200
+ <terminal translate="label">
201
+ <label>Terminal</label>
202
+ <comment>You need to set your username / password above before you can choose your Terminal.</comment>
203
+ <frontend_type>select</frontend_type>
204
+ <source_model>altapay_payment_model_source_terminals</source_model>
205
+ <sort_order>1</sort_order>
206
+ <config_path>payment/altapay_gateway/terminal</config_path>
207
+ <show_in_default>1</show_in_default>
208
+ <show_in_store>1</show_in_store>
209
+ </terminal>
210
+ <title translate="label comment">
211
+ <label>Title</label>
212
+ <config_path>payment/altapay_gateway/title</config_path>
213
+ <frontend_type>text</frontend_type>
214
+ <sort_order>2</sort_order>
215
+ <show_in_default>1</show_in_default>
216
+ <show_in_store>1</show_in_store>
217
+ </title>
218
+
219
+ <payment_action translate="label">
220
+ <label>Payment Action</label>
221
+ <frontend_type>select</frontend_type>
222
+ <config_path>payment/altapay_gateway/payment_action</config_path>
223
+ <source_model>altapay_payment_model_source_paymentAction</source_model>
224
+ <sort_order>3</sort_order>
225
+ <show_in_default>1</show_in_default>
226
+ <show_in_store>1</show_in_store>
227
+ </payment_action>
228
+ <sort_order translate="label">
229
+ <label>Sort Order</label>
230
+ <config_path>payment/altapay_gateway/sort_order</config_path>
231
+ <frontend_type>text</frontend_type>
232
+ <sort_order>100</sort_order>
233
+ <show_in_default>1</show_in_default>
234
+ <show_in_store>1</show_in_store>
235
+ </sort_order>
236
+ </fields>
237
+ </altapay_gateway>
238
+
239
+ <altapay_moto translate="label">
240
+ <label>Altapay MO/TO - Used to take payments on behalf of your customers here in the admin area.</label>
241
+ <fieldset_css>altapay-config</fieldset_css>
242
+ <frontend_type>text</frontend_type>
243
+ <sort_order>20</sort_order>
244
+ <show_in_default>1</show_in_default>
245
+ <show_in_store>1</show_in_store>
246
+ <fields>
247
+ <active translate="label comment">
248
+ <label>Enable</label>
249
+ <config_path>payment/altapay_moto/active</config_path>
250
+ <frontend_type>select</frontend_type>
251
+ <source_model>adminhtml/system_config_source_yesno</source_model>
252
+ <sort_order>0</sort_order>
253
+ <show_in_default>1</show_in_default>
254
+ <show_in_store>1</show_in_store>
255
+ </active>
256
+ <moto_terminal translate="label">
257
+ <label>MO/TO Terminal</label>
258
+ <comment>This terminal is only used when taking credit card payments in the back-office</comment>
259
+ <frontend_type>select</frontend_type>
260
+ <source_model>altapay_payment_model_source_terminals</source_model>
261
+ <sort_order>1</sort_order>
262
+ <config_path>payment/altapay_moto/terminal</config_path>
263
+ <show_in_default>1</show_in_default>
264
+ <show_in_store>1</show_in_store>
265
+ </moto_terminal>
266
+ <title translate="label comment">
267
+ <label>Title</label>
268
+ <config_path>payment/altapay_moto/title</config_path>
269
+ <frontend_type>text</frontend_type>
270
+ <sort_order>2</sort_order>
271
+ <show_in_default>1</show_in_default>
272
+ <show_in_store>1</show_in_store>
273
+ </title>
274
+ <payment_action translate="label">
275
+ <label>Payment Action</label>
276
+ <frontend_type>select</frontend_type>
277
+ <config_path>payment/altapay_moto/payment_action</config_path>
278
+ <source_model>altapay_payment_model_source_paymentAction</source_model>
279
+ <sort_order>3</sort_order>
280
+ <show_in_default>1</show_in_default>
281
+ <show_in_store>1</show_in_store>
282
+ </payment_action>
283
+ <useccv translate="label">
284
+ <label>Request Card Security Code</label>
285
+ <config_path>payment/altapay_moto/useccv</config_path>
286
+ <frontend_type>select</frontend_type>
287
+ <source_model>adminhtml/system_config_source_yesno</source_model>
288
+ <sort_order>10</sort_order>
289
+ <show_in_default>1</show_in_default>
290
+ <show_in_store>1</show_in_store>
291
+ </useccv>
292
+ <sort_order translate="label">
293
+ <label>Sort Order</label>
294
+ <config_path>payment/altapay_moto/sort_order</config_path>
295
+ <frontend_type>text</frontend_type>
296
+ <sort_order>100</sort_order>
297
+ <show_in_default>1</show_in_default>
298
+ <show_in_store>1</show_in_store>
299
+ </sort_order>
300
+ </fields>
301
+ </altapay_moto>
302
+
303
+ <altapay_recurring translate="label">
304
+ <label>Stored Credit Card - Allows your customers register their credit card for later use.</label>
305
+ <fieldset_css>altapay-config</fieldset_css>
306
+ <frontend_type>text</frontend_type>
307
+ <sort_order>30</sort_order>
308
+ <show_in_default>1</show_in_default>
309
+ <show_in_store>1</show_in_store>
310
+ <comment><![CDATA[
311
+ <div class="box">
312
+ <p class="grand-total"><b>Note:</b></p>
313
+ <p>Before you can use the Gateway you must make sure that your Magento installation is visible to the outside as Altapay's Payment Gateway will be
314
+ performing callback calls with information about the payment.<p>
315
+ </div>]]>
316
+ </comment>
317
+ <fields>
318
+ <active translate="label">
319
+ <label>Enable</label>
320
+ <frontend_type>select</frontend_type>
321
+ <source_model>adminhtml/system_config_source_yesno</source_model>
322
+ <sort_order>0</sort_order>
323
+ <config_path>payment/altapay_recurring/active</config_path>
324
+ <show_in_default>1</show_in_default>
325
+ <show_in_store>1</show_in_store>
326
+ </active>
327
+ <terminal translate="label">
328
+ <label>Terminal</label>
329
+ <comment>You need to set your username / password above before you can choose your Terminal.</comment>
330
+ <frontend_type>select</frontend_type>
331
+ <source_model>altapay_payment_model_source_terminals</source_model>
332
+ <sort_order>1</sort_order>
333
+ <config_path>payment/altapay_recurring/terminal</config_path>
334
+ <show_in_default>1</show_in_default>
335
+ <show_in_store>1</show_in_store>
336
+ </terminal>
337
+ <title translate="label comment">
338
+ <label>Title</label>
339
+ <config_path>payment/altapay_recurring/title</config_path>
340
+ <frontend_type>text</frontend_type>
341
+ <sort_order>2</sort_order>
342
+ <show_in_default>1</show_in_default>
343
+ <show_in_store>1</show_in_store>
344
+ </title>
345
+ <payment_action translate="label">
346
+ <label>Payment Action</label>
347
+ <frontend_type>select</frontend_type>
348
+ <config_path>payment/altapay_recurring/payment_action</config_path>
349
+ <source_model>altapay_payment_model_source_paymentAction</source_model>
350
+ <sort_order>3</sort_order>
351
+ <show_in_default>1</show_in_default>
352
+ <show_in_store>1</show_in_store>
353
+ </payment_action>
354
+
355
+ <sort_order translate="label">
356
+ <label>Sort Order</label>
357
+ <config_path>payment/altapay_recurring/sort_order</config_path>
358
+ <frontend_type>text</frontend_type>
359
+ <sort_order>10</sort_order>
360
+ <show_in_default>1</show_in_default>
361
+ <show_in_store>1</show_in_store>
362
+ </sort_order>
363
+ </fields>
364
+ </altapay_recurring>
365
+
366
+ </groups>
367
+ </altapay>
368
+ </sections>
369
+ </config>
app/code/community/Altapay/Payment/sql/altapaypayment_setup/install-1.0.0.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+
4
+ $installer->startSetup();
5
+
6
+ $installer->run("
7
+ CREATE TABLE IF NOT EXISTS {$this->getTable('altapay_subscriptions')} (
8
+ `id` int(11) NOT NULL AUTO_INCREMENT,
9
+ `subscription_id` varchar(36) NOT NULL,
10
+ `customer_id` int(11) NOT NULL,
11
+ `masked_pan` varchar(255) NOT NULL,
12
+ `card_token` varchar(255) NOT NULL,
13
+ `currency_code` varchar(3) NOT NULL,
14
+ `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
15
+ PRIMARY KEY (`id`)
16
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
17
+ ");
18
+
19
+
20
+
21
+ $installer->endSetup();
app/code/community/Altapay/Payment/sql/altapaypayment_setup/upgrade-1.0.0-1.0.1.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+
4
+ $installer->startSetup();
5
+
6
+ $installer->run("
7
+ CREATE TABLE IF NOT EXISTS {$this->getTable('altapay_token')} (
8
+ `id` int(11) NOT NULL AUTO_INCREMENT,
9
+ `customer_id` int(11) NOT NULL,
10
+ `token` varchar(128) NOT NULL DEFAULT '',
11
+ `masked_pan` varchar(255) NOT NULL,
12
+ `currency_code` varchar(3) NOT NULL,
13
+ `custom_name` varchar(255) NOT NULL,
14
+ `primary` tinyint(2) NOT NULL DEFAULT '0',
15
+ `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
16
+ `deleted` tinyint(2) NOT NULL DEFAULT '0',
17
+ PRIMARY KEY (`id`)
18
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
19
+ ");
20
+
21
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/altapay.xml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Altapay Payment Extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
9
+ * compliance with the License. You may obtain a copy of the License at
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is
12
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and limitations under the License.
14
+ *
15
+ * @category Altapay
16
+ * @package Altapay_Payment
17
+ * @copyright Copyright (c) 2011-2012 Altapay A/S (http://altapay.com)
18
+ * @author Emanuel Holm Greisen
19
+ * @license Apache License, Version 2.0
20
+ */
21
+ -->
22
+ <layout version="0.1.0">
23
+ <default>
24
+ <reference name="root">
25
+ <reference name="head">
26
+ <action method="addCss"><name>altapay.css</name></action>
27
+ </reference>
28
+ </reference>
29
+ </default>
30
+ </layout>
app/design/adminhtml/default/default/template/altapay/payment/form/moto.phtml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_code=$this->getMethodCode() ?>
2
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
3
+ <li>
4
+ <div class="input-box">
5
+ <label for="<?php echo $_code ?>_cc_number"><?php echo Mage::helper('payment')->__('Credit Card Number') ?> <span class="required">*</span></label><br/>
6
+ <input type="text" id="<?php echo $_code ?>_cc_number" name="payment[cc_number]" title="<?php echo Mage::helper('payment')->__('Credit Card Number') ?>" class="input-text" value="<?php echo $this->getInfoData('cc_number')?>"/>
7
+ </div>
8
+ </li>
9
+ <li>
10
+ <div class="input-box">
11
+ <label for="<?php echo $_code ?>_expiration"><?php echo Mage::helper('payment')->__('Expiration Date') ?> <span class="required">*</span></label><br/>
12
+ <select id="<?php echo $_code ?>_expiration" style="width:140px;" name="payment[cc_exp_month]" class="validate-cc-exp required-entry">
13
+ <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
14
+ <?php foreach ($this->getCcMonths() as $k=>$v): ?>
15
+ <option value="<?php echo $k ?>" <?php if($k==$_ccExpMonth): ?>selected="selected"<?php endif ?>><?php echo $v ?></option>
16
+ <?php endforeach ?>
17
+ </select>
18
+ <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
19
+ <select id="<?php echo $_code ?>_expiration_yr" style="width:103px;" name="payment[cc_exp_year]" class="required-entry">
20
+ <?php foreach ($this->getCcYears() as $k=>$v): ?>
21
+ <option value="<?php echo $k ? $k : '' ?>" <?php if($k==$_ccExpYear): ?>selected="selected"<?php endif ?>><?php echo $v ?></option>
22
+ <?php endforeach ?>
23
+ </select>
24
+ </div>
25
+ </li>
26
+ <?php if($this->hasVerification()): ?>
27
+ <li>
28
+ <div class="input-box">
29
+ <label for="<?php echo $_code ?>_cc_cid"><?php echo Mage::helper('payment')->__('Card Verification Number') ?> <span class="required">*</span></label><br/>
30
+ <input type="text" title="<?php echo Mage::helper('payment')->__('Card Verification Number') ?>" class="required-entry input-text validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" name="payment[cc_cid]" style="width:3em;" value="<?php echo $this->getInfoData('cc_cid')?>"/>
31
+ </div>
32
+ </li>
33
+ <?php endif; ?>
34
+ </ul>
app/design/adminhtml/default/default/template/altapay/payment/info/gateway.phtml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Altapay Payment Gateway<br />
2
+ <?php
3
+ if($_info = $this->getInfo())
4
+ {
5
+ if(!is_null($_info->getAdditionalData()) &&
6
+ ($paymentResponse = @unserialize($_info->getAdditionalData())) !== false)
7
+ {
8
+ //print('<pre>');
9
+ //print_r($paymentResponse);
10
+ if($paymentResponse !== false)
11
+ {
12
+ echo $this->__('Payment Nature: %s (%s)', $this->htmlEscape($paymentResponse->getPrimaryPayment()->getPaymentNature()), $this->htmlEscape($paymentResponse->getPrimaryPayment()->getPaymentNatureService()->getName())).'<br />';
13
+ if($paymentResponse->getPrimaryPayment()->getPaymentNature() == 'CreditCard')
14
+ {
15
+ echo $this->__('Credit Card Number: %s', $this->htmlEscape($paymentResponse->getPrimaryPayment()->getMaskedPan())).'<br />';
16
+ echo $this->__('Credit Card Status: %s', $this->htmlEscape($paymentResponse->getPrimaryPayment()->getCardStatus())).'<br />';
17
+ }
18
+ }
19
+ }
20
+ else
21
+ {
22
+ echo $this->__('Credit Card Number: %s', $this->htmlEscape($this->getInfo()->getData('cc_number_enc'))).'<br />';
23
+ }
24
+ }
25
+ else
26
+ {
27
+ print("Payment Information Missing");
28
+ }
29
+
app/design/adminhtml/default/default/template/altapay/payment/info/moto.phtml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php if($_info = $this->getInfo()): ?>
2
+
3
+ <?php echo $this->__('Credit Card Number: xxxx-%s', $this->htmlEscape($this->getInfo()->getCcLast4())) ?><br />
4
+ <?php echo $this->__('Expiration Date: %s/%s', $this->htmlEscape($this->getCcExpMonth()), $this->htmlEscape($this->getInfo()->getCcExpYear())) ?>
5
+ <?php else: ?>
6
+
7
+ <?php endif; ?>
app/design/adminhtml/default/default/template/altapay/payment/info/recurring.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Altapay Payment Gateway (Stored Credit Card)<br />
2
+ <?php
3
+ if($_info = $this->getInfo())
4
+ {
5
+ if(!is_null($_info->getAdditionalData()) &&
6
+ ($paymentResponse = @unserialize($_info->getAdditionalData())) !== false)
7
+ {
8
+ //print('<pre>');
9
+ //print_r($paymentResponse);
10
+ if($paymentResponse !== false)
11
+ {
12
+ echo $this->__('Payment Nature: %s (%s)', $this->htmlEscape($paymentResponse->getPrimaryPayment()->getPaymentNature()), $this->htmlEscape($paymentResponse->getPrimaryPayment()->getPaymentNatureService()->getName())).'<br />';
13
+ if($paymentResponse->getPrimaryPayment()->getPaymentNature() == 'CreditCard')
14
+ {
15
+ echo $this->__('Credit Card Number: %s', $this->htmlEscape($paymentResponse->getPrimaryPayment()->getMaskedPan())).'<br />';
16
+ echo $this->__('Credit Card Status: %s', $this->htmlEscape($paymentResponse->getPrimaryPayment()->getCardStatus())).'<br />';
17
+ }
18
+ }
19
+ }
20
+ else
21
+ {
22
+ echo $this->__('Credit Card Number: %s', $this->htmlEscape($this->getInfo()->getData('cc_number_enc'))).'<br />';
23
+ }
24
+ }
25
+ else
26
+ {
27
+ print("Payment Information Missing");
28
+ }
29
+
30
+ ?>
app/design/frontend/base/default/layout/altapay.xml ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
7
+ * compliance with the License. You may obtain a copy of the License at
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is
10
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and limitations under the License.
12
+ *
13
+ * @category Altapay
14
+ * @package Altapay_Payment
15
+ * @copyright Copyright (c) 2011-2012 Altapay A/S (http://altapay.com)
16
+ * @author Emanuel Holm Greisen <eg@altapay.com>
17
+ * @license Apache License, Version 2.0
18
+ */
19
+ -->
20
+ <layout version="0.1.0">
21
+
22
+ <!-- This one is used when Altapay calls back to show the payment page -->
23
+ <altapaypayment_onepage_form>
24
+ <remove name="sale.reorder.sidebar" />
25
+ <reference name="root">
26
+ <action method="setTemplate">
27
+ <template>page/2columns-right.phtml</template>
28
+ </action>
29
+ </reference>
30
+ <reference name="content">
31
+ <block type="altapaypayment/onepage_form" name="checkout.form"
32
+ template="altapay/checkout/form.phtml" />
33
+ </reference>
34
+ <reference name="right">
35
+ <action method="unsetChildren"></action>
36
+ <block type="page/html_wrapper" name="checkout.progress.wrapper"
37
+ translate="label">
38
+ <label>Checkout Progress Wrapper</label>
39
+ <action method="setElementId">
40
+ <value>checkout-progress-wrapper</value>
41
+ </action>
42
+ <block type="checkout/onepage_progress" name="checkout.progress"
43
+ before="-" template="altapay/checkout/onepage/progress.phtml" />
44
+ </block>
45
+ </reference>
46
+ </altapaypayment_onepage_form>
47
+
48
+ <!-- This one is used when Altapay calls back to let us know that a payment has failed -->
49
+ <altapaypayment_onepage_failure>
50
+ <remove name="sale.reorder.sidebar" />
51
+ <reference name="root">
52
+ <action method="setTemplate">
53
+ <template>page/2columns-right.phtml</template>
54
+ </action>
55
+ </reference>
56
+ <reference name="content">
57
+ <block type="altapaypayment/onepage_failed" name="checkout.failed"
58
+ template="altapay/checkout/failed.phtml" />
59
+ </reference>
60
+ <reference name="right">
61
+ <action method="unsetChildren"></action>
62
+ <block type="page/html_wrapper" name="checkout.progress.wrapper"
63
+ translate="label">
64
+ <label>Checkout Progress Wrapper</label>
65
+ <action method="setElementId">
66
+ <value>checkout-progress-wrapper</value>
67
+ </action>
68
+ <block type="checkout/onepage_progress" name="checkout.progress"
69
+ before="-" template="altapay/checkout/onepage/progress.phtml" />
70
+ </block>
71
+ </reference>
72
+ </altapaypayment_onepage_failure>
73
+
74
+ <!-- This one is used when Altapay calls back to let us know that a payment has succeeded -->
75
+ <altapaypayment_onepage_success>
76
+ <reference name="root">
77
+ <action method="setTemplate">
78
+ <template>page/1column.phtml</template>
79
+ </action>
80
+ </reference>
81
+ <reference name="content">
82
+ <block type="altapaypayment/onepage_success" name="checkout.success"
83
+ template="altapay/checkout/success_redirect.phtml" />
84
+ </reference>
85
+ </altapaypayment_onepage_success>
86
+
87
+ <checkout_onepage_success>
88
+ <reference name="content">
89
+ <block type="altapaypayment/onepage_success_token" name="checkout.success.token" template="altapay/checkout/onepage/success/token.phtml" after="checkout.success" />
90
+ </reference>
91
+ </checkout_onepage_success>
92
+
93
+ <customer_account>
94
+ <reference name="customer_account_navigation">
95
+ <action ifconfig="payment/altapay_token/active_customer_token_control" method="addLink" translate="label" module="altapaypayment"><name>altapay_token</name><path>customer/token/view</path><label>Credit Cards</label></action>
96
+ </reference>
97
+ </customer_account>
98
+
99
+ <customer_token_view>
100
+ <update handle="customer_account" />
101
+ <reference name="head">
102
+ <action method="addItem"><type>skin_css</type><name>altapay/css/altapay.css</name><params/></action>
103
+ <action method="addItem"><type>skin_js</type><name>altapay/js/altapay.js</name><params/></action>
104
+ </reference>
105
+ <reference name="root">
106
+ <block type="core/messages" name="global_messages" as="global_messages"/>
107
+ <block type="core/messages" name="messages" as="messages"/>
108
+ </reference>
109
+ <reference name="my.account.wrapper">
110
+ <block type="altapaypayment/customer_account_token" name="altapay_token" template="altapay/customer/account/token/view.phtml"/>
111
+ </reference>
112
+ </customer_token_view>
113
+
114
+
115
+ </layout>
app/design/frontend/base/default/template/altapay/checkout/default_styling.css ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @CHARSET "UTF-8";
2
+
3
+ div.AltapayMultiformContainer {
4
+ position: relative;
5
+ }
6
+
7
+ div.AltapayMultiformContainer .FormTypeButton {
8
+ position: relative;
9
+ top: 0px;
10
+ margin-left: 10px;
11
+ background-color: #ffffff;
12
+ border-left: 1px solid black;
13
+ border-top: 1px solid black;
14
+ border-right: 1px solid black;
15
+ border-bottom: 0px;
16
+ z-index: 50;
17
+ border-top-left-radius: 5px;
18
+ -moz-border-radius-topleft: 5px;
19
+ border-top-right-radius: 5px;
20
+ -moz-border-radius-topright: 5px;
21
+ font-size: 14px;
22
+ height: 22px;
23
+ padding-left: 10px;
24
+ padding-right: 10px;
25
+ }
26
+
27
+ div.AltapayMultiformContainer .FormTypeButton.Selected {
28
+ background-color: #eeeeee;
29
+ z-index: 100;
30
+ }
31
+
32
+ div.AltapayMultiformContainer form {
33
+ display: block;
34
+ z-index: 75;
35
+ position: absolute;
36
+ top: 21px;
37
+ background-color: #eeeeee;
38
+ width: 90%;
39
+ padding: 20px;
40
+ margin: 0px;
41
+ border: 1px solid black;
42
+ border-radius: 5px;
43
+ -moz-border-radius: 5px;
44
+ }
45
+
46
+ div.accountTermsAndConditionsBoxBackground {
47
+ position: fixed;
48
+ background-color: #fff;
49
+ width: 100%;
50
+ height: 100%;
51
+ top: 0px;
52
+ left: 0px;
53
+ opacity: 0.8;
54
+ filter: alpha(opacity = 80); /* For IE8 and earlier */
55
+ }
56
+
57
+ div.accountTermsAndConditionsBox {
58
+ position: fixed;
59
+ top: 50%;
60
+ left: 50%;
61
+ margin-left: -250px;
62
+ margin-top: -270px;
63
+ padding: 2px;
64
+ background-color: #aaa;
65
+ width: 500px;
66
+ height: 540px;
67
+ }
68
+
69
+ div.accountTermsAndConditions {
70
+ width: 500px;
71
+ height: 500px;
72
+ background-color: #fff;
73
+ overflow: auto;
74
+ }
75
+
76
+ div.accountTermsAndConditionButtons {
77
+ width: 496px;
78
+ height: 46px;
79
+ padding-top: 10px;
80
+ }
app/design/frontend/base/default/template/altapay/checkout/default_styling_nojs.css ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @CHARSET "UTF-8";
2
+
3
+ div.AltapayMultiformContainer .FormTypeButton {
4
+ float:none;
5
+ position:relative;
6
+ margin-top: 10px;
7
+ background-color:#eeeeee;
8
+ z-index: 100;
9
+ }
10
+
11
+ div.AltapayMultiformContainer form {
12
+ position:relative ;
13
+ top:-1px;
14
+ }
app/design/frontend/base/default/template/altapay/checkout/failed.phtml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento Enterprise Edition
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Magento Enterprise Edition License
8
+ * that is bundled with this package in the file LICENSE_EE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://www.magentocommerce.com/license/enterprise-edition
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://www.magentocommerce.com/license/enterprise-edition
25
+ */
26
+ ?>
27
+ <div class="page-title">
28
+ <h1><?php echo $this->__('Payment Failed') ?></h1>
29
+ </div>
30
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
31
+
32
+ <h2 class="sub-title"><?php echo $this->__('Please try again') ?></h2>
33
+ <?php if (strtolower($this->getPaymentSchemeName()) == 'klarna'): ?>
34
+ <p>Message: <?php echo $this->getErrorMessage(); ?></p>
35
+ <?php endif; ?>
36
+
37
+ <div class="buttons-set">
38
+ <a href="<?php echo Mage::helper('checkout/url')->getCheckoutUrl(); ?>">
39
+ <button type="submit" class="button" title="<?php echo Mage::helper('altapaypayment')->__('Try Again') ?>"><span><span><?php echo Mage::helper('altapaypayment')->__('Try Again') ?></span></span></button>
40
+ </a>
41
+ </div>
42
+
app/design/frontend/base/default/template/altapay/checkout/form.phtml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento Enterprise Edition
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Magento Enterprise Edition License
8
+ * that is bundled with this package in the file LICENSE_EE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://www.magentocommerce.com/license/enterprise-edition
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://www.magentocommerce.com/license/enterprise-edition
25
+ */
26
+ ?>
27
+ <div class="page-title">
28
+ <h1><?php echo $this->__('Almost there, payment required.') ?></h1>
29
+ </div>
30
+
31
+ <!-- The reason the CSS is inlined here is to ensure we override any Altapay CSS -->
32
+ <style id="AltapayDefaultStyling">
33
+ <?php
34
+ // Choose the stylesheet you want to use
35
+ //require_once(dirname(__FILE__).'/default_styling.css');
36
+ require_once(dirname(__FILE__).'/magento_styling.css');
37
+ ?>
38
+ </style>
39
+ <!-- Gracefull degredation, disable JavaScript in your browser to see the result -->
40
+ <noscript>
41
+ <style>
42
+ <?php
43
+ // Choose the stylesheet you want to use
44
+ //require_once(dirname(__FILE__).'/default_styling_nojs.css');
45
+ require_once(dirname(__FILE__).'/magento_styling_nojs.css');
46
+ ?>
47
+ </style>
48
+ </noscript>
49
+ <form id="PensioPaymentForm">
50
+ <div style="width: 500px; height: 400px; border: 1px solid black;">
51
+ <i>Will be replaced by the altapay payment form</i>
52
+ <br />
53
+ <button>Submit</button>
54
+ </div>
55
+ </form>
app/design/frontend/base/default/template/altapay/checkout/magento_styling.css ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @CHARSET "UTF-8";
2
+
3
+ div.AltapayMultiformContainer {
4
+ position: relative;
5
+ }
6
+
7
+ div.AltapayMultiformContainer .FormTypeButton {
8
+ position: relative;
9
+ top: 0px;
10
+ margin-left: 10px;
11
+ z-index: 50;
12
+ padding-left: 20px;
13
+ padding-right: 20px;
14
+ height: 24px;
15
+ margin-left: 5px;
16
+ margin-right: 5px;
17
+ font-size: 13px;
18
+ font-weight: bold;
19
+ line-height: 1.35;
20
+ border: 1px solid #A3AEB3;
21
+ background: none repeat scroll 0 0 #EEEEEE;
22
+ color: #5E8AB4;
23
+ }
24
+
25
+ div.AltapayMultiformContainer .FormTypeButton.Selected {
26
+ background: none repeat scroll 0 0 #D0DCE1;
27
+ top: -2px;
28
+ }
29
+
30
+ div.AltapayMultiformContainer form {
31
+ display: block;
32
+ z-index: 75;
33
+ position: absolute;
34
+ top: 21px;
35
+ width: 90%;
36
+ min-height: 150px;
37
+ -moz-border-bottom-colors: none;
38
+ -moz-border-image: none;
39
+ -moz-border-left-colors: none;
40
+ -moz-border-right-colors: none;
41
+ -moz-border-top-colors: none;
42
+ background: none repeat scroll 0 0 #EEEEEE;
43
+ border-color: -moz-use-text-color #A3AEB3 #A3AEB3;
44
+ border: 1px solid #A3AEB3;
45
+ margin: 0 0 6px;
46
+ padding: 8px 13px;
47
+ }
48
+
49
+ div.accountTermsAndConditionsBoxBackground {
50
+ position: fixed;
51
+ background-color: #fff;
52
+ width: 100%;
53
+ height: 100%;
54
+ top: 0px;
55
+ left: 0px;
56
+ opacity: 0.8;
57
+ filter: alpha(opacity = 80); /* For IE8 and earlier */
58
+ }
59
+
60
+ div.accountTermsAndConditionsBox {
61
+ position: fixed;
62
+ top: 50%;
63
+ left: 50%;
64
+ margin-left: -250px;
65
+ margin-top: -270px;
66
+ padding: 2px;
67
+ background-color: #aaa;
68
+ width: 500px;
69
+ height: 540px;
70
+ }
71
+
72
+ div.accountTermsAndConditions {
73
+ width: 500px;
74
+ height: 500px;
75
+ background-color: #fff;
76
+ overflow: auto;
77
+ }
78
+
79
+ div.accountTermsAndConditionButtons {
80
+ text-align: center;
81
+ width: 496px;
82
+ height: 46px;
83
+ padding-top: 10px;
84
+ }
app/design/frontend/base/default/template/altapay/checkout/magento_styling_nojs.css ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @CHARSET "UTF-8";
2
+
3
+ div.AltapayMultiformContainer .FormTypeButton {
4
+ display: block;
5
+ float:none;
6
+ position:relative;
7
+ margin-top: 10px;
8
+ background: none repeat scroll 0 0 #D0DCE1;
9
+ z-index: 100;
10
+ margin-left: 0px;
11
+ }
12
+
13
+ div.AltapayMultiformContainer form {
14
+ position:relative ;
15
+ top:-1px;
16
+ min-height: inherit;
17
+ }
app/design/frontend/base/default/template/altapay/checkout/onepage/progress.phtml ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <div class="block block-progress opc-block-progress">
28
+ <div class="block-title">
29
+ <strong><span><?php echo $this->__('Your Checkout Progress') ?></span></strong>
30
+ </div>
31
+ <div class="block-content">
32
+ <dl>
33
+ <?php if ($this->getCheckout()->getStepData('billing', 'is_show')): ?>
34
+ <?php if($this->getCheckout()->getStepData('billing', 'complete')): ?>
35
+ <dt class="complete">
36
+ <?php echo $this->__('Billing Address') ?> <span class="separator"></span>
37
+ </dt>
38
+ <dd class="complete">
39
+ <address><?php echo $this->getBilling()->format('html') ?></address>
40
+ </dd>
41
+ <?php else: ?>
42
+ <dt>
43
+ <?php echo $this->__('Billing Address') ?>
44
+ </dt>
45
+ <?php endif; ?>
46
+ <?php endif; ?>
47
+
48
+ <?php if ($this->getCheckout()->getStepData('shipping', 'is_show')): ?>
49
+ <?php if($this->getCheckout()->getStepData('shipping', 'complete')): ?>
50
+ <dt class="complete">
51
+ <?php echo $this->__('Shipping Address') ?> <span class="separator"></span>
52
+ </dt>
53
+ <dd class="complete">
54
+ <address><?php echo $this->getShipping()->format('html') ?></address>
55
+ </dd>
56
+ <?php else: ?>
57
+ <dt>
58
+ <?php echo $this->__('Shipping Address') ?>
59
+ </dt>
60
+ <?php endif; ?>
61
+ <?php endif; ?>
62
+
63
+ <?php if ($this->getCheckout()->getStepData('shipping_method', 'is_show')): ?>
64
+ <?php if($this->getCheckout()->getStepData('shipping_method', 'complete')): ?>
65
+ <dt class="complete">
66
+ <?php echo $this->__('Shipping Method') ?> <span class="separator"></span>
67
+ </dt>
68
+ <dd class="complete">
69
+ <?php if ($this->getShippingMethod()): ?>
70
+ <?php echo $this->getShippingDescription() ?>
71
+
72
+ <?php $_excl = $this->getShippingPriceExclTax(); ?>
73
+ <?php $_incl = $this->getShippingPriceInclTax(); ?>
74
+ <?php if ($this->helper('tax')->displayShippingPriceIncludingTax()): ?>
75
+ <?php echo $_incl; ?>
76
+ <?php else: ?>
77
+ <?php echo $_excl; ?>
78
+ <?php endif; ?>
79
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
80
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
81
+ <?php endif; ?>
82
+
83
+ <?php else: ?>
84
+ <?php echo $this->__('Shipping method has not been selected yet') ?>
85
+ <?php endif; ?>
86
+ </dd>
87
+ <?php else: ?>
88
+ <dt>
89
+ <?php echo $this->__('Shipping Method') ?>
90
+ </dt>
91
+ <?php endif; ?>
92
+ <?php endif; ?>
93
+
94
+ <?php if ($this->getCheckout()->getStepData('payment', 'is_show')): ?>
95
+ <?php if($this->getCheckout()->getStepData('payment', 'complete')): ?>
96
+ <dt class="complete">
97
+ <?php echo $this->__('Payment Method') ?> <span class="separator"></span>
98
+ </dt>
99
+ <dd class="complete">
100
+ Altapay Gateway
101
+ </dd>
102
+ <?php else: ?>
103
+ <dt>
104
+ <?php echo $this->__('Payment Method') ?>
105
+ </dt>
106
+ <?php endif; ?>
107
+ <?php endif; ?>
108
+ </dl>
109
+ </div>
110
+ </div>
app/design/frontend/base/default/template/altapay/checkout/onepage/success/token.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if($this->showBlock()) : ?>
2
+ <?php if($this->customerChooseToSaveToken()) : ?>
3
+ <p>
4
+ <h3 class="sub-title"><?php echo $this->__('Your credit card is added to you account for easy use on your next order'); ?></h3>
5
+ <a class="button" href="<?php echo $this->getUrl('customer/token/view'); ?>">
6
+ <?php echo $this->__('Manage your credit cards here'); ?>
7
+ </a>
8
+ </p>
9
+ <?php else : ?>
10
+ <form id="altapay_save_token" action="<?php echo $this->getUrl('altapaypayment/token/save'); ?>">
11
+ <?php echo $this->getBlockHtml('formkey'); ?>
12
+ <input type="hidden" name="order_id" value="<?php echo $this->getOrderId(); ?>" />
13
+ <button type="submit" class="button"><span><span><?php echo $this->__('Save you creditcard for easy use'); ?></span></span></button>
14
+ </form>
15
+ <?php endif; ?>
16
+ <?php endif; ?>
app/design/frontend/base/default/template/altapay/checkout/success_redirect.phtml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category design
4
+ * @package base_default
5
+ * @copyright Copyright (c) 2011 Altapay A/S (http://www.altapay.com)
6
+ */
7
+ ?>
8
+ <div class="page-title">
9
+ <h1><?php echo $this->__('Payment Successful') ?></h1>
10
+ </div>
11
+ <h2 class="sub-title"><?php echo $this->__('Redirecting...') ?></h2>
12
+ <p><?php echo Mage::helper('altapaypayment')->__('If you are not redirected to the order confirmation page please click the button below.') ?></p>
13
+
14
+ <div class="buttons-set">
15
+ <button type="button" class="button" title="<?php echo Mage::helper('altapaypayment')->__('Order Confirmation') ?>" onclick="window.location='<?php echo $this->getCheckoutSuccessUrl() ?>'"><span><span><?php echo Mage::helper('altapaypayment')->__('Order Confirmation') ?></span></span></button>
16
+ </div>
17
+
18
+ <!meta http-equiv="refresh" content="0;url=<?php echo $this->getCheckoutSuccessUrl(); ?>"/>
app/design/frontend/base/default/template/altapay/customer/account/token/view.phtml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php echo $this->getMessagesBlock()->toHtml() ?>
2
+ <?php $_tokens = $this->getTokens(); ?>
3
+ <div class="page-title">
4
+ <h1><?php echo $this->__('Credit Cards') ?></h1>
5
+ </div>
6
+ <?php echo $this->getPagerHtml(); ?>
7
+ <?php if($_tokens && $_tokens->getSize()): ?>
8
+ <table class="data-table" id="my-tokens-table">
9
+ <col width="1" />
10
+ <col width="1" />
11
+ <col />
12
+ <col width="1" />
13
+ <col width="1" />
14
+ <col width="1" />
15
+ <thead>
16
+ <tr>
17
+ <th><?php echo $this->__('Card') ?></th>
18
+ <th><?php echo $this->__('Name') ?></th>
19
+ <th></th>
20
+ <th><?php echo $this->__('Primary') ?></th>
21
+ <th><?php echo $this->__('Delete') ?></th>
22
+ </tr>
23
+ </thead>
24
+ <tbody>
25
+ <?php $_odd = ''; ?>
26
+ <?php foreach ($_tokens as $_token): ?>
27
+ <tr>
28
+ <td><span class="token-card-type"><?php echo $_token->getCardType(); ?></span><span class="token-masked-pan"><?php echo $_token->getMaskedPan(); ?></span></td>
29
+ <td>
30
+ <input class="token-custom-name" data-token-custom-name="<?php echo ($_token->getCustomName()) ? $_token->getCustomName() : $_token->getMaskedPan(); ?>" data-token-id="<?php echo $_token->getId(); ?>" onblur="Altapay.updateCustomName(this);" value="<?php echo ($_token->getCustomName()) ? $_token->getCustomName() : $_token->getMaskedPan(); ?>"/>
31
+ </td>
32
+ <td><span class="token-status" id="token-custom-name-status-<?php echo $_token->getId(); ?>"></span></td>
33
+ <td><span class="token-primay"><input type="radio" onchange="Altapay.updatePrimaryToken(this);" name="primary-token" value="<?php echo $_token->getId(); ?>"<?php if($_token->getPrimary()) : ?>checked="checked"<?php endif; ?> /></span></td>
34
+ <td><button type="button" class="button token-delete" data-token-id="<?php echo $_token->getId(); ?>" onclick="Altapay.deleteToken(this);"><span><span><?php echo $this->__('Delete') ?></span></span></button></td>
35
+ </tr>
36
+ <?php endforeach; ?>
37
+ </tbody>
38
+ </table>
39
+ <script type="text/javascript">decorateTable('my-tokens-table');</script>
40
+ <?php echo $this->getPagerHtml(); ?>
41
+ <?php else: ?>
42
+ <p><?php echo $this->__('You have no credit cards.'); ?></p>
43
+ <?php endif ?>
app/design/frontend/base/default/template/altapay/payment/form/gateway.phtml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php $_code=$this->getMethodCode() ?>
2
+ <div class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
3
+ <?php echo $this->__('You can supply your payment details securely after clicking Continue') ?>
4
+ </div>
app/design/frontend/base/default/template/altapay/payment/form/recurring.phtml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_code=$this->getMethodCode() ?>
2
+ <div class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
3
+ <?php echo $this->__('If you choose to register a new card you will add it securely after clicking Continue') ?>
4
+ <p>
5
+ <select name="subscription_id">
6
+ <?php foreach($this->getSubscriptions() as $id => $value):?>
7
+ <option value="<?php echo $id;?>"><?php echo $value;?></option>
8
+ <?php endforeach;?>
9
+ </select>
10
+ </p>
11
+ </div>
app/design/frontend/base/default/template/altapay/payment/form/token.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_code=$this->getMethodCode() ?>
2
+ <div class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
3
+ <p><?php echo $this->__('You can supply your payment details securely after clicking Continue') ?></p>
4
+ <?php $customerTokens = Mage::getModel('altapaypayment/token')->getAllCustomerTokens(); ?>
5
+ <?php if($customerTokens && $customerTokens->getSize()) : ?>
6
+ <select name="ccToken">
7
+ <option value=""><?php echo $this->__('Please select a creditcard'); ?></option>
8
+ <?php foreach($customerTokens as $token) : ?>
9
+ <option value="<?php echo $token->getId(); ?>"<?php if($token->getPrimary()) : ?> selected="selected"<?php endif; ?>><?php echo ($token->getCustomName()) ? $token->getCustomName() : $token->getMaskedPan() ?></option>
10
+ <?php endforeach; ?>
11
+ </select>
12
+ <?php else : ?>
13
+ <p><?php echo $this->__('When your order is confirmed, you will be presented with the option to save your creditcard for easy use on all following orders.') ?></p>
14
+ <?php endif; ?>
15
+ </div>
app/design/frontend/base/default/template/altapay/payment/info/gateway.phtml ADDED
@@ -0,0 +1 @@
 
1
+ Altapay Payment Gateway
app/design/frontend/base/default/template/altapay/payment/info/recurring.phtml ADDED
@@ -0,0 +1 @@
 
1
+ Altapay Payment Gateway
app/design/frontend/base/default/template/altapay/payment/info/token.phtml ADDED
@@ -0,0 +1 @@
 
1
+ Altapay Payment Gateway
app/etc/modules/Altapay_Payment.xml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
7
+ * compliance with the License. You may obtain a copy of the License at
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is
10
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the License for the specific language governing permissions and limitations under the License.
12
+ *
13
+ * @category Altapay
14
+ * @package Altapay_Payment
15
+ * @copyright Copyright (c) 2011-2012 Altapay A/S (http://altapay.com)
16
+ * @author Emanuel Holm Greisen <eg@altapay.com>
17
+ * @license Apache License, Version 2.0
18
+ */
19
+ -->
20
+ <config>
21
+ <modules>
22
+ <Altapay_Payment>
23
+ <active>true</active>
24
+ <codePool>community</codePool>
25
+ </Altapay_Payment>
26
+ </modules>
27
+ </config>
app/locale/en_GB/Altapay_Payment.csv ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ " - Emulation Mode"," - Emulation Mode"
2
+ " - Live Account"," - Live Account"
3
+ " - Test Account"," - Test Account"
4
+ "Acquirer","Acquirer"
5
+ "Action","Action"
6
+ "Amount","Amount"
7
+ "Archive","Archive"
8
+ "Archived Fundings List","Archived Fundings List"
9
+ "Archived Transaction List","Archived Transaction List"
10
+ "Are you sure you want to archive funding/s?","Are you sure you want to archive funding/s?"
11
+ "Are you sure you want to archive this funding?","Are you sure you want to archive this funding?"
12
+ "Are you sure you want to archive these transaction/s?","Are you sure you want to archive these transaction/s?"
13
+ "Are you sure you want to archive this transaction?","Are you sure you want to archive this transaction?"
14
+ "Are you sure you want to release the authorisations on these transactions?","Are you sure you want to release the authorisations on these transactions?"
15
+ "Are you sure you want to release the authorisation on this transaction?","Are you sure you want to release the authorisation on this transaction?"
16
+ "Are you sure you want to un-archive these funding/s?","Are you sure you want to un-archive these funding/s?"
17
+ "Are you sure you want to un-archive this funding?","Are you sure you want to un-archive this funding?"
18
+ "Are you sure you want to un-archive these transaction/s?","Are you sure you want to un-archive these transaction/s?"
19
+ "Are you sure you want to un-archive this transaction?","Are you sure you want to un-archive this transaction?"
20
+ "Authorize and Capture","Authorize and Capture"
21
+ "Authorize Only","Authorize Only"
22
+ "Captured","Captured"
23
+ "Captured Amount","Captured Amount"
24
+ "Card Verification Number","Card Verification Number"
25
+ "Connection failed! Check Credentials and try again.","Connection failed! Check Credentials and try again."
26
+ "Connection Successful.","Connection Successful."
27
+ "Contract ID","Contract ID"
28
+ "Created Date","Created Date"
29
+ "Credit Card (Masked)","Credit Card (Masked)"
30
+ "Credit Card Number","Credit Card Number"
31
+ "Credit Card Number: xxxx-%s","Credit Card Number: xxxx-%s"
32
+ "Credit Card Token","Credit Card Token"
33
+ "Credit Card Type","Credit Card Type"
34
+ "Credit Card Type: %s","Credit Card Type: %s"
35
+ "Date","Date"
36
+ "Download","Download"
37
+ "Expiration Date","Expiration Date"
38
+ "Expiration Date: %s/%s","Expiration Date: %s/%s"
39
+ "Fraud Score","Fraud Score"
40
+ "Funding Date","Funding Date"
41
+ "Fundings List","Fundings List"
42
+ "Funding %s successfully archived","Funding %s successfully archived"
43
+ "Funding %s successfully un-archived","Funding %s successfully un-archived"
44
+ "Help","Help"
45
+ "ID","ID"
46
+ "Invalid amount for authorization.","Invalid amount for authorization."
47
+ "Is Closed","Is Closed"
48
+ "Issue Number","Issue Number"
49
+ "Last Updated Date","Last Updated Date"
50
+ "Learn More","Learn More"
51
+ "Live","Live"
52
+ "Name on the Card","Name on the Card"
53
+ "Name on the Card: %s","Name on the Card: %s"
54
+ "No Reconciliation Details","No Reconciliation Details"
55
+ "No Transaction History","No Transaction History"
56
+ "Order ID","Order ID"
57
+ "Parent Transaction ID","Parent Transaction ID"
58
+ "Payment capture error","Payment capture error"
59
+ "Payment Method Name","Payment Method Name"
60
+ "Payment refund error","Payment refund error"
61
+ "Altapay Fundings List","Altapay Fundings List"
62
+ "Altapay Payment","Altapay Payment"
63
+ "Altapay Payment Information","Altapay Payment Information"
64
+ "Altapay Transaction List","Altapay Transaction List"
65
+ "Please provide credentials and try again.","Please provide credentials and try again."
66
+ "Please provide your password and try again.","Please provide your password and try again."
67
+ "Please provide your username and try again.","Please provide your username and try again."
68
+ "Reconciliations","Reconciliations"
69
+ "Reurring Max Amount","Reurring Max Amount"
70
+ "Refunded","Refunded"
71
+ "Refunded Amount","Refunded Amount"
72
+ "Release","Release"
73
+ "Release Authorisation","Release Authorisation"
74
+ "Reserved","Reserved"
75
+ "Reserved Amount","Reserved Amount"
76
+ "Running in Emulation mode!!!","Running in Emulation mode!!!"
77
+ "Shop","Shop"
78
+ "Status","Status"
79
+ "Successfuly archived %s fundings","Successfuly archived %s fundings"
80
+ "Successfuly archived %s transactions","Successfuly archived %s transactions"
81
+ "Successfuly un-archived %s fundings","Successfuly un-archived %s fundings"
82
+ "Successfuly un-archived %s transactions","Successfuly un-archived %s transactions"
83
+ "Sorry, we could not connect to the payment gateway - please try again","Sorry, we could not connect to the payment gateway - please try again"
84
+ "Sorry, we could not process your refund request - please try again.","Sorry, we could not process your refund request - please try again."
85
+ "Status","Status"
86
+ "Start Date","Start Date"
87
+ "Summary","Summary"
88
+ "Switch/Solo/Maestro Only","Switch/Solo/Maestro Only"
89
+ "Terminal","Terminal"
90
+ "Testing","Testing"
91
+ "Transaction ID","Transaction ID"
92
+ "Transaction Information","Transaction Information"
93
+ "Transaction List","Transaction List"
94
+ "Transaction: %s","Transaction: %s"
95
+ "Transaction %s successfully archived","Transaction %s successfully archived"
96
+ "Transaction %s successfully released!","Transaction %s successfully released!"
97
+ "Transaction %s successfully un-archived","Transaction %s successfully un-archived"
98
+ "Transactions","Transactions"
99
+ "Transactions successfully updated!","Transactions successfully updated!"
100
+ "Transactions: %s successfully released!","Transactions: %s successfully released!"
101
+ "Trans. ID","Trans. ID"
102
+ "Trans. Type","Trans. Type"
103
+ "Type","Type"
104
+ "Un-Archive","Un-Archive"
105
+ "Update Fundings List","Update Fundings List"
106
+ "Update Transactions","Update Transactions"
107
+ "View","View"
108
+ "View Archived Fundings","View Archived Fundings"
109
+ "View Archived Transactions","View Archived Transactions"
110
+ "View Demo","View Demo"
111
+ "View Transaction Details","View Transaction Details"
112
+ "View Un-Archived Fundings","View Un-Archived Fundings"
113
+ "View Un-Archived Transactions","View Un-Archived Transactions"
114
+ "What is this?","What is this?"
115
+ "You can supply your payment details securely after clicking Continue","You can supply your payment details securely after clicking Continue"
app/locale/en_US/Altapay_Payment.csv ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ " - Emulation Mode"," - Emulation Mode"
2
+ " - Live Account"," - Live Account"
3
+ " - Test Account"," - Test Account"
4
+ "Acquirer","Acquirer"
5
+ "Action","Action"
6
+ "Amount","Amount"
7
+ "Archive","Archive"
8
+ "Archived Fundings List","Archived Fundings List"
9
+ "Archived Transaction List","Archived Transaction List"
10
+ "Are you sure you want to archive funding/s?","Are you sure you want to archive funding/s?"
11
+ "Are you sure you want to archive this funding?","Are you sure you want to archive this funding?"
12
+ "Are you sure you want to archive these transaction/s?","Are you sure you want to archive these transaction/s?"
13
+ "Are you sure you want to archive this transaction?","Are you sure you want to archive this transaction?"
14
+ "Are you sure you want to release the authorisations on these transactions?","Are you sure you want to release the authorisations on these transactions?"
15
+ "Are you sure you want to release the authorisation on this transaction?","Are you sure you want to release the authorisation on this transaction?"
16
+ "Are you sure you want to un-archive these funding/s?","Are you sure you want to un-archive these funding/s?"
17
+ "Are you sure you want to un-archive this funding?","Are you sure you want to un-archive this funding?"
18
+ "Are you sure you want to un-archive these transaction/s?","Are you sure you want to un-archive these transaction/s?"
19
+ "Are you sure you want to un-archive this transaction?","Are you sure you want to un-archive this transaction?"
20
+ "Authorize and Capture","Authorize and Capture"
21
+ "Authorize Only","Authorize Only"
22
+ "Captured","Captured"
23
+ "Captured Amount","Captured Amount"
24
+ "Card Verification Number","Card Verification Number"
25
+ "Connection failed! Check Credentials and try again.","Connection failed! Check Credentials and try again."
26
+ "Connection Successful.","Connection Successful."
27
+ "Contract ID","Contract ID"
28
+ "Created Date","Created Date"
29
+ "Credit Card (Masked)","Credit Card (Masked)"
30
+ "Credit Card Number","Credit Card Number"
31
+ "Credit Card Number: xxxx-%s","Credit Card Number: xxxx-%s"
32
+ "Credit Card Token","Credit Card Token"
33
+ "Credit Card Type","Credit Card Type"
34
+ "Credit Card Type: %s","Credit Card Type: %s"
35
+ "Date","Date"
36
+ "Download","Download"
37
+ "Expiration Date","Expiration Date"
38
+ "Expiration Date: %s/%s","Expiration Date: %s/%s"
39
+ "Fraud Score","Fraud Score"
40
+ "Funding Date","Funding Date"
41
+ "Fundings List","Fundings List"
42
+ "Funding %s successfully archived","Funding %s successfully archived"
43
+ "Funding %s successfully un-archived","Funding %s successfully un-archived"
44
+ "Help","Help"
45
+ "ID","ID"
46
+ "Invalid amount for authorization.","Invalid amount for authorization."
47
+ "Is Closed","Is Closed"
48
+ "Issue Number","Issue Number"
49
+ "Last Updated Date","Last Updated Date"
50
+ "Learn More","Learn More"
51
+ "Live","Live"
52
+ "Name on the Card","Name on the Card"
53
+ "Name on the Card: %s","Name on the Card: %s"
54
+ "No Reconciliation Details","No Reconciliation Details"
55
+ "No Transaction History","No Transaction History"
56
+ "Order ID","Order ID"
57
+ "Parent Transaction ID","Parent Transaction ID"
58
+ "Payment capture error","Payment capture error"
59
+ "Payment Method Name","Payment Method Name"
60
+ "Payment refund error","Payment refund error"
61
+ "Altapay Fundings List","Altapay Fundings List"
62
+ "Altapay Payment","Altapay Payment"
63
+ "Altapay Payment Information","Altapay Payment Information"
64
+ "Altapay Transaction List","Altapay Transaction List"
65
+ "Please provide credentials and try again.","Please provide credentials and try again."
66
+ "Please provide your password and try again.","Please provide your password and try again."
67
+ "Please provide your username and try again.","Please provide your username and try again."
68
+ "Reconciliations","Reconciliations"
69
+ "Reurring Max Amount","Reurring Max Amount"
70
+ "Refunded","Refunded"
71
+ "Refunded Amount","Refunded Amount"
72
+ "Release","Release"
73
+ "Release Authorisation","Release Authorisation"
74
+ "Reserved","Reserved"
75
+ "Reserved Amount","Reserved Amount"
76
+ "Running in Emulation mode!!!","Running in Emulation mode!!!"
77
+ "Shop","Shop"
78
+ "Status","Status"
79
+ "Successfuly archived %s fundings","Successfuly archived %s fundings"
80
+ "Successfuly archived %s transactions","Successfuly archived %s transactions"
81
+ "Successfuly un-archived %s fundings","Successfuly un-archived %s fundings"
82
+ "Successfuly un-archived %s transactions","Successfuly un-archived %s transactions"
83
+ "Sorry, we could not connect to the payment gateway - please try again","Sorry, we could not connect to the payment gateway - please try again"
84
+ "Sorry, we could not process your refund request - please try again.","Sorry, we could not process your refund request - please try again."
85
+ "Status","Status"
86
+ "Start Date","Start Date"
87
+ "Summary","Summary"
88
+ "Switch/Solo/Maestro Only","Switch/Solo/Maestro Only"
89
+ "Terminal","Terminal"
90
+ "Testing","Testing"
91
+ "Transaction ID","Transaction ID"
92
+ "Transaction Information","Transaction Information"
93
+ "Transaction List","Transaction List"
94
+ "Transaction: %s","Transaction: %s"
95
+ "Transaction %s successfully archived","Transaction %s successfully archived"
96
+ "Transaction %s successfully released!","Transaction %s successfully released!"
97
+ "Transaction %s successfully un-archived","Transaction %s successfully un-archived"
98
+ "Transactions","Transactions"
99
+ "Transactions successfully updated!","Transactions successfully updated!"
100
+ "Transactions: %s successfully released!","Transactions: %s successfully released!"
101
+ "Trans. ID","Trans. ID"
102
+ "Trans. Type","Trans. Type"
103
+ "Type","Type"
104
+ "Un-Archive","Un-Archive"
105
+ "Update Fundings List","Update Fundings List"
106
+ "Update Transactions","Update Transactions"
107
+ "View","View"
108
+ "View Archived Fundings","View Archived Fundings"
109
+ "View Archived Transactions","View Archived Transactions"
110
+ "View Demo","View Demo"
111
+ "View Transaction Details","View Transaction Details"
112
+ "View Un-Archived Fundings","View Un-Archived Fundings"
113
+ "View Un-Archived Transactions","View Un-Archived Transactions"
114
+ "What is this?","What is this?"
115
+ "You can supply your payment details securely after clicking Continue","You can supply your payment details securely after clicking Continue"
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>AltaPay_for_Magento1</name>
4
+ <version>0.0.1</version>
5
+ <stability>stable</stability>
6
+ <license>The MIT License (MIT)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Plugin that integrates Magento to the AltaPay payment gateway.</summary>
10
+ <description>AltaPay has made it much easier for you as merchant/developer to receive secure payments in your Magento web shop. AltaPay is fully integrated with Magento via a plug-in.</description>
11
+ <notes>First version.</notes>
12
+ <authors><author><name>AltaPay Integration Team</name><user>altapay_int</user><email>integration@altapay.com</email></author></authors>
13
+ <date>2016-09-01</date>
14
+ <time>11:09:13</time>
15
+ <contents><target name="magecommunity"><dir name="Altapay"><dir name="Payment"><dir name="Block"><dir name="Customer"><dir name="Account"><file name="Token.php" hash="62e630661f5a28a033773f30041667a2"/></dir></dir><dir name="Form"><file name="Gateway.php" hash="10963a08e6553eafb6c13b3211d1873a"/><file name="Moto.php" hash="c722348e5e2f3b17ea3b06402bfba4f9"/><file name="Recurring.php" hash="2cac58ab0231f7071479fe0770c5b2fe"/><file name="Token.php" hash="77763cc1be021e04d46f3d8754e7077a"/></dir><dir name="Info"><file name="Gateway.php" hash="b3a133fb41b393da80658a35417967b1"/><file name="Moto.php" hash="86b593e08d0ab00f86e7c41ef711d8a2"/><file name="Recurring.php" hash="0c4da217141f7ba8aecd8fe564e344ce"/><file name="Token.php" hash="2ce16d8a5c01b193092611ff6c9fc8a8"/></dir><dir name="Onepage"><file name="Failed.php" hash="445738a686c709fd59343aff587c73f4"/><file name="Form.php" hash="b23ad18f71e2ace2e6a44320d747b7a1"/><dir name="Success"><file name="Token.php" hash="6aa5da3158d6ec668e0d001254b4d99d"/></dir><file name="Success.php" hash="2564809634dc37e16ceb81ef9b86d34b"/></dir><file name="Onepage.php" hash="ad81e2d0e68761f9a8c9b0237a3c36ff"/></dir><dir name="Helper"><file name="CurrencyMapper.php" hash="03088924615092d202ec3dfe3c2ad9a3"/><file name="Data.php" hash="f5350cf643355583e62bf97f066582c9"/><file name="Logger.php" hash="9e2ab6436a5e22af40ae39108d9d4ea5"/><file name="Utilities.php" hash="3c55a010f3b4705b3cd168257f43dfea"/></dir><dir name="Model"><file name="Altapay.php" hash="273bccfe651da6bb48fd8ad1448f8a59"/><dir name="Api"><file name="ALTAPAY_VERSION.php" hash="f09924828ecdd17f9b21f1b44d0c2294"/><file name="AltapayCallbackHandler.class.php" hash="964370c9295b1823fa65b2760d1b8d28"/><file name="AltapayMerchantAPI.class.php" hash="429831af898d1b7b83dda0b93aef9022"/><file name="IAltapayCommunicationLogger.class.php" hash="99b8f25360bbbd29e50ea829d3bfe5b7"/><dir name="exceptions"><file name="AltapayConnectionFailedException.class.php" hash="652416bff05f7534c9d723c0f6108dc6"/><file name="AltapayInvalidResponseException.class.php" hash="ddbf173a9f40444c20e90a3a27b9519c"/><file name="AltapayMerchantAPIException.class.php" hash="50237012813c5525df1aabfe35ebaf31"/><file name="AltapayRequestTimeoutException.class.php" hash="dd37a9977e4485f6512a583accc98ef6"/><file name="AltapayUnauthorizedAccessException.class.php" hash="b52faff4abd48c75ab483d100e87cb36"/><file name="AltapayUnknownMerchantAPIException.class.php" hash="1e19cd3c3bbec2224eb4e4f221caf7ff"/><file name="AltapayXmlException.class.php" hash="19a435d6c5ae0d6c37cda11e1e18e09b"/></dir><dir name="http"><file name="AltapayCurlBasedHttpUtils.class.php" hash="cb47ed7599fc36cf6da0dcd8ec5e9d5e"/><file name="AltapayFOpenBasedHttpUtils.class.php" hash="596956789903c8b201c4c8a645264666"/><file name="AltapayHttpRequest.class.php" hash="97955f33a1b127e892264ed0dd8c84a6"/><file name="AltapayHttpResponse.class.php" hash="de62a9d507ae836bdd8e7773194ffd47"/><file name="IAltapayHttpUtils.class.php" hash="63007aaa93e155019ef670a77ef4541b"/></dir><dir name="request"><file name="AltapayAPITransactionsRequest.class.php" hash="c723def7d72c961fa2b5213396126733"/></dir><dir name="response"><file name="AltapayAPIAddress.class.php" hash="f9f2f225ca4b2e5155e57bd112cb047e"/><file name="AltapayAPIChargebackEvent.class.php" hash="bcb0b4430aa943c7389edde862364af7"/><file name="AltapayAPIChargebackEvents.class.php" hash="0ab35b4c56f9f5a79eb028ed6e5c2a53"/><file name="AltapayAPICountryOfOrigin.class.php" hash="c24653e0dee13c3229a778c4bbc26b13"/><file name="AltapayAPICustomerInfo.class.php" hash="4be6bf4e24d749979edd95556dc55ec1"/><file name="AltapayAPIFunding.class.php" hash="71fdfbe0113702bf9292224d10e1b845"/><file name="AltapayAPIPayment.class.php" hash="2292b4c8715d5a7bdba8e5f4af5943bc"/><file name="AltapayAPIPaymentInfos.class.php" hash="926b2335da38c6e8209b450659e3a32b"/><file name="AltapayAPIPaymentNatureService.class.php" hash="ff99401cf50429dcd2845a77673882c8"/><file name="AltapayAPIReconciliationIdentifier.class.php" hash="0b75f7ba353d304e021612043f64471b"/><file name="AltapayAbstractPaymentResponse.class.php" hash="8b8920f3f331d81eff7109d4c9bbd1f6"/><file name="AltapayAbstractResponse.class.php" hash="36c199c005dfd92b6bfb7618fd0dce82"/><file name="AltapayCalculateSurchargeResponse.class.php" hash="f22251db3145e8d895af0ff993522ce6"/><file name="AltapayCaptureRecurringResponse.class.php" hash="559967cc555bf7e79ab2717a06fbefe4"/><file name="AltapayCaptureResponse.class.php" hash="8fd5d56c9df9e61233432fb79270d84a"/><file name="AltapayCreatePaymentRequestResponse.class.php" hash="1999636b78fc5988e1f899f7e1ef7eb5"/><file name="AltapayFundingListResponse.class.php" hash="e8994ffe5e039c273a649d8779256769"/><file name="AltapayGetPaymentResponse.class.php" hash="fb83e969b9dd1647cd4d2ac9e2de9644"/><file name="AltapayGetTerminalsResponse.class.php" hash="d6b471ef2579c791ce15ab99f426727c"/><file name="AltapayLoginResponse.class.php" hash="17a33bf9f1359f52441c24c86cc88471"/><file name="AltapayPreauthRecurringResponse.class.php" hash="9d4b71a0a26b398b4ef84e981afb0b30"/><file name="AltapayRefundResponse.class.php" hash="5a5275d4a4c8ea52a60e775a7b54158b"/><file name="AltapayReleaseResponse.class.php" hash="31c751505ce70222e394fb7f1c48e8f8"/><file name="AltapayReservationResponse.class.php" hash="e77596681b58a39949a4e23e0c5ff98b"/><file name="AltapayTerminal.class.php" hash="3e467641e1d612be5380ccb99c9a733d"/></dir></dir><file name="Constants.php" hash="3827d373ae0dfe70841b10fb7001a831"/><dir name="Method"><file name="Abstract.php" hash="677726f1c65536ab48faa988e82de4d7"/><file name="Gateway.php" hash="cee8e408d032e652ee11596beeb316fb"/><file name="Moto.php" hash="b21e961bc6eeea479f1b6fd70597fa29"/><file name="Recurring.php" hash="f0107de1c333a264a55770e9265e1d59"/><file name="Token.php" hash="2abe1866f4d467176535591717964472"/></dir><file name="Observer.php" hash="79cff57b4406853f8054ba0bf8913462"/><dir name="Resource"><dir name="Subscription"><file name="Collection.php" hash="75569c1889f06201d07420f7fbb225a2"/></dir><file name="Subscription.php" hash="3122e10012cb8ff5697abe3f2445c27b"/><dir name="Token"><file name="Collection.php" hash="fb0bbaa1c5d4cf71c8f5099db31f0782"/></dir><file name="Token.php" hash="9e75ce9111f171e3841bb99df5928632"/></dir><dir name="Source"><file name="PaymentAction.php" hash="0ff49129bfdb9a74899e7603ba18e9b2"/><file name="Terminals.php" hash="73d01eb63dab4ea16c07a8e33904bc09"/></dir><file name="Subscription.php" hash="6c86a22de4c6dc6a53ba8ed5624a81ad"/><file name="Token.php" hash="4bb26c0862c5425075c180c82e56485d"/></dir><dir name="controllers"><file name="OnepageController.php" hash="713236f1490d0aee69026a42f914263d"/><file name="TokenController.php" hash="c0f15cb458edcd4ec3c4dbc989cfdf99"/></dir><dir name="etc"><file name="adminhtml.xml" hash="38829e4c43a434d811f52315e0127af7"/><file name="config.xml" hash="90d20c296308abcfd6a02828cb14022b"/><file name="system.xml" hash="dccf8992ce4e6e12b5716151f9cc8bc5"/></dir><dir name="sql"><dir name="altapaypayment_setup"><file name="install-1.0.0.php" hash="45d8306bc7d51feff9a795d5107b02dc"/><file name="upgrade-1.0.0-1.0.1.php" hash="492b11587e232b46030e1c7702e1ea01"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="altapay.xml" hash="4155d8d8f691f56322231374573a4ff7"/></dir><dir name="template"><dir name="altapay"><dir name="payment"><dir name="form"><file name="moto.phtml" hash="4ff0daaa4221e2f2457e9a8353de6626"/></dir><dir name="info"><file name="gateway.phtml" hash="35c1107df98fcc3fa5038913e83e676a"/><file name="moto.phtml" hash="f327b26f0e978536f5d28271513a3efa"/><file name="recurring.phtml" hash="3fe4c5e2c9bd278f28ada23823c7a13a"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="altapay.xml" hash="2415a8d0dd5a90f436f9723ed383d06c"/></dir><dir name="template"><dir name="altapay"><dir name="checkout"><file name="default_styling.css" hash="ecdee520dfae2bb7330f68c509f5acdb"/><file name="default_styling_nojs.css" hash="d4bc0421cce0fffa9708cd048db2e891"/><file name="failed.phtml" hash="6126855f97a7efc4defbd8c3ed051799"/><file name="form.phtml" hash="a2fe2963491a9742b40f50d7fc35d0c7"/><file name="magento_styling.css" hash="cb7bc729a64a7efd29bfa19a06d02bf3"/><file name="magento_styling_nojs.css" hash="e9fcb8f00e73fc5bee029298fa61fc0c"/><dir name="onepage"><file name="progress.phtml" hash="c1dd84dcf00cd10330d492767684dce1"/><dir name="success"><file name="token.phtml" hash="8743dbdeb2de8d63fc712af2b040773b"/></dir></dir><file name="success_redirect.phtml" hash="9616c7799e8c3cde544ae9522832cd12"/></dir><dir name="customer"><dir name="account"><dir name="token"><file name="view.phtml" hash="c23e1b9d6eef7706851079ce35d73029"/></dir></dir></dir><dir name="payment"><dir name="form"><file name="gateway.phtml" hash="24f8298198c9dbe7a1157a3af3bf905d"/><file name="recurring.phtml" hash="43ff5ed38cf301bfb2898d7df4647570"/><file name="token.phtml" hash="f3b1bf30a6587c5927cc1736c4de1605"/></dir><dir name="info"><file name="gateway.phtml" hash="1cd140b78afaddd992ee990482fbf229"/><file name="recurring.phtml" hash="1cd140b78afaddd992ee990482fbf229"/><file name="token.phtml" hash="1cd140b78afaddd992ee990482fbf229"/></dir></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_GB"><file name="Altapay_Payment.csv" hash="2a097614d7a9414f5a06b082814b38a2"/></dir><dir name="en_US"><file name="Altapay_Payment.csv" hash="2a097614d7a9414f5a06b082814b38a2"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><file name="altapay.css" hash="4c522d61f889ff448bd45d1bbcf35a0e"/><dir name="images"><file name="altapay.png" hash="b10208d0a82dd80562eb03e7508e97b4"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="altapay"><dir name="css"><file name="altapay.css" hash="aa3ded5e41e19abc114b39c5c7bcbdcc"/></dir><dir name="images"><file name="ajax-loader.gif" hash="2ef5e9c1839462b187c93535a1670b92"/><file name="error.png" hash="1e1534f925cb26b45ad30536f1bc1896"/><file name="success.png" hash="5ea5d6dac9344616dd7de4b8c2695937"/></dir><dir name="js"><file name="altapay.js" hash="59bd1ba2566fec5ba134340d8a750eb7"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Altapay_Payment.xml" hash="0369f728a6767df0ea7b7f9f9bbd6b31"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.5.9</min><max>7.0.8</max></php></required></dependencies>
18
+ </package>
skin/adminhtml/default/default/altapay.css ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*--SIDE MENU--*/
2
+ ul.tabs a.altapay-section,ul.tabs a.altapay-section:hover {
3
+ background:url(images/tabs_span_bg.gif) repeat-x scroll 0 100% transparent;
4
+ border-bottom:medium none;
5
+ }
6
+
7
+ ul.tabs a.altapay-section span,ul.tabs a.altapay-section:hover span {
8
+ background: url(images/altapay.png) no-repeat 0 0;
9
+ height: 25px;
10
+ overflow: hidden;
11
+ width: auto;
12
+ background-size: 70px;
13
+ font-size: 0;
14
+ background-position: left 18px center
15
+ }
16
+
17
+ /*--SETTINGS--*/
18
+ .altapay-selection {
19
+ border-collapse:collapse;
20
+ width:100%;
21
+ }
22
+
23
+ .altapay-selection th {
24
+ font-size:13px;
25
+ padding:5px 0;
26
+ text-align:left;
27
+ vertical-align:middle;
28
+ }
29
+
30
+ .altapay-selection .altapay-selection-info {
31
+ text-align:right;
32
+ }
33
+
34
+ .altapay-selection td {
35
+ background:none repeat scroll 0 0 #F2F2F2;
36
+ border-bottom:5px solid #FFF;
37
+ padding:5px;
38
+ vertical-align:top;
39
+ }
40
+
41
+ .altapay-selection .altapay-selection-info {
42
+ text-align:right;
43
+ }
skin/adminhtml/default/default/images/altapay.png ADDED
Binary file
skin/frontend/base/default/altapay/css/altapay.css ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #my-tokens-table tr.deleting {
2
+ background-color: gray;
3
+ text-align:
4
+ }
5
+
6
+ #my-tokens-table tr.deleting {
7
+ display: none;
8
+ }
9
+
10
+ #my-tokens-table .token-status {
11
+ height: 25px;
12
+ width: 20px;
13
+ display: inline-block;
14
+ background-repeat: no-repeat;
15
+ background-position: center;
16
+ }
17
+ #my-tokens-table .token-status.updating {
18
+ background-image: url('../images/ajax-loader.gif');
19
+ }
20
+ #my-tokens-table .token-status.updated {
21
+ background-image: url('../images/success.png');
22
+ }
23
+ #my-tokens-table .token-status.error {
24
+ background-image: url('../images/error.png');
25
+ }
skin/frontend/base/default/altapay/images/ajax-loader.gif ADDED
Binary file
skin/frontend/base/default/altapay/images/error.png ADDED
Binary file
skin/frontend/base/default/altapay/images/success.png ADDED
Binary file
skin/frontend/base/default/altapay/js/altapay.js ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Altapay = {
2
+ deleteToken : function(element) {
3
+ url = '/customer/token/deleteToken';
4
+ token_id = jQuery(element).data('token-id');
5
+ data = {token_id:token_id};
6
+ console.log(data);
7
+ jQuery.ajax({
8
+ type:'POST',
9
+ url:url,
10
+ data:data,
11
+ beforeSend:function(){
12
+ jQuery("#token-custom-name-status-"+token_id).addClass('updating');
13
+ var tr = jQuery(element).closest('tr');
14
+ jQuery('button.token-delete',tr).attr('disabled',true);
15
+ jQuery('input.token-custom-name',tr).attr('disabled',true);
16
+ }
17
+ }).done(function(data){
18
+ if(data.status == 'deleted') {
19
+ jQuery(element).closest('tr').remove();
20
+ }
21
+ });
22
+ },
23
+ updatePrimaryToken : function(element) {
24
+ url = '/customer/token/updatePrimaryToken';
25
+ token_id = element.value;
26
+ data = {token_id:token_id};
27
+ console.log(data);
28
+ jQuery.ajax({
29
+ type:'POST',
30
+ url:url,
31
+ data:data,
32
+ beforeSend:function(){
33
+ jQuery("#token-custom-name-status-"+token_id).addClass('updating');
34
+ var tr = jQuery(element).closest('tr');
35
+ jQuery('button.token-delete',tr).attr('disabled',true);
36
+ jQuery('input.token-custom-name',tr).attr('disabled',true);
37
+ jQuery('#my-tokens-table input.radio[primary-token]').attr('disabled',true);
38
+ }
39
+ }).done(function(data){
40
+ element.disabled = false;
41
+ if(data.status == 'ok' || data.status == 'updated') {
42
+ jQuery("#token-custom-name-status-"+token_id).addClass('updated');
43
+ setInterval(function() {
44
+ jQuery("#token-custom-name-status-"+token_id).removeClass('updated');
45
+ },2000);
46
+ } else if(data.status == 'error') {
47
+ jQuery("#token-custom-name-status-"+token_id).addClass('error');
48
+ setInterval(function() {
49
+ jQuery("#token-custom-name-status-"+token_id).removeClass('error');
50
+ },2000);
51
+ }
52
+ }).always(function() {
53
+ jQuery("#token-custom-name-status-"+token_id).removeClass('updating');
54
+ var tr = jQuery(element).closest('tr');
55
+ jQuery('button.token-delete',tr).attr('disabled',false);
56
+ jQuery('input.token-custom-name',tr).attr('disabled',false);
57
+ jQuery('#my-tokens-table input.radio[primary-token]').attr('disabled',false);
58
+ }).error(function() {
59
+ jQuery("#token-custom-name-status-"+token_id).addClass('error');
60
+ setInterval(function() {
61
+ jQuery("#token-custom-name-status-"+token_id).removeClass('error');
62
+ },2000);
63
+ });
64
+ },
65
+ updateCustomName : function(element) {
66
+ if(jQuery(element).data('token-custom-name') != element.value) {
67
+ element.disabled = true;
68
+ var url = '/customer/token/updateCustomName';
69
+ token_id = jQuery(element).data('token-id');
70
+ var data = {token_id:token_id,custom_name:element.value};
71
+
72
+ jQuery.ajax({
73
+ type:'POST',
74
+ url:url,
75
+ data:data,
76
+ beforeSend:function(){
77
+ jQuery("#token-custom-name-status-"+token_id).addClass('updating');
78
+ }
79
+ }).done(function(data){
80
+ element.disabled = false;
81
+ if(data.status == 'ok' || data.status == 'updated') {
82
+ jQuery("#token-custom-name-status-"+token_id).addClass('updated');
83
+ setInterval(function() {
84
+ jQuery("#token-custom-name-status-"+token_id).removeClass('updated');
85
+ },2000);
86
+ } else if(data.status == 'error') {
87
+ jQuery("#token-custom-name-status-"+token_id).addClass('error');
88
+ setInterval(function() {
89
+ jQuery("#token-custom-name-status-"+token_id).removeClass('error');
90
+ },2000);
91
+ }
92
+
93
+ }).always(function() {
94
+ jQuery("#token-custom-name-status-"+token_id).removeClass('updating');
95
+ }).error(function() {
96
+ jQuery("#token-custom-name-status-"+token_id).addClass('error');
97
+ setInterval(function() {
98
+ jQuery("#token-custom-name-status-"+token_id).removeClass('error');
99
+ },2000);
100
+ });
101
+ }
102
+ }
103
+ }