Securetrading_Stpp - Version 3.5.0

Version Notes

The official SecureTrading STPP Magento integration.

Download this release

Release Info

Developer PeteST
Extension Securetrading_Stpp
Version 3.5.0
Comparing to
See all releases


Code changes from version 3.4.1 to 3.5.0

Files changed (74) hide show
  1. app/code/local/Securetrading/Stpp/Block/Adminhtml/Sales/Transactions/Single.php +12 -1
  2. app/code/local/Securetrading/Stpp/Block/Adminhtml/System/Config/Fieldset/Fields.php +34 -10
  3. app/code/local/Securetrading/Stpp/Block/Checkout/Multishipping/Success/Billing/Agreement.php +25 -0
  4. app/code/local/Securetrading/Stpp/Block/Payment/Direct/Form.php +39 -1
  5. app/code/local/Securetrading/Stpp/Block/Payment/Direct/Post.php +20 -17
  6. app/code/local/Securetrading/Stpp/Block/Payment/Direct/Tokenization/Form.php +17 -0
  7. app/code/local/Securetrading/Stpp/Block/Payment/Redirect/Form.php +27 -0
  8. app/code/local/Securetrading/Stpp/Block/Payment/Tokenization/Form.php +34 -0
  9. app/code/local/Securetrading/Stpp/Block/Payment/Tokenization/Info.php +17 -0
  10. app/code/local/Securetrading/Stpp/Controller/Redirect/Post/Abstract.php +2 -3
  11. app/code/local/Securetrading/Stpp/Helper/Data.php +148 -107
  12. app/code/local/Securetrading/Stpp/Model/Actions/Abstract.php +33 -1
  13. app/code/local/Securetrading/Stpp/Model/Actions/Direct.php +64 -4
  14. app/code/local/Securetrading/Stpp/Model/Actions/Redirect.php +61 -18
  15. app/code/local/Securetrading/Stpp/Model/Billing/Agreement/Currency.php +7 -0
  16. app/code/local/Securetrading/Stpp/Model/Billing/Agreement/Paymenttypedescription.php +7 -0
  17. app/code/local/Securetrading/Stpp/Model/Cron.php +165 -28
  18. app/code/local/Securetrading/Stpp/Model/Integration.php +67 -21
  19. app/code/local/Securetrading/Stpp/Model/Observer.php +15 -3
  20. app/code/local/Securetrading/Stpp/Model/Payment/Abstract.php +48 -31
  21. app/code/local/Securetrading/Stpp/Model/Payment/Direct.php +64 -428
  22. app/code/local/Securetrading/Stpp/Model/Payment/Direct/Abstract.php +83 -0
  23. app/code/local/Securetrading/Stpp/Model/Payment/Handler/Backend/Abstract.php +150 -0
  24. app/code/local/Securetrading/Stpp/Model/Payment/Handler/Backend/Factory.php +44 -0
  25. app/code/local/Securetrading/Stpp/Model/Payment/Handler/Backend/Multishipping.php +99 -0
  26. app/code/local/Securetrading/Stpp/Model/Payment/Handler/Backend/Onepage.php +48 -0
  27. app/code/local/Securetrading/Stpp/Model/Payment/Handler/Frontend/Abstract.php +145 -0
  28. app/code/local/Securetrading/Stpp/Model/Payment/Handler/Frontend/Factory.php +28 -0
  29. app/code/local/Securetrading/Stpp/Model/Payment/Handler/Frontend/Multishipping.php +59 -0
  30. app/code/local/Securetrading/Stpp/Model/Payment/Handler/Frontend/Onepage.php +23 -0
  31. app/code/local/Securetrading/Stpp/Model/Payment/Redirect.php +202 -162
  32. app/code/local/Securetrading/Stpp/Model/Payment/Redirect/Session.php +7 -0
  33. app/code/local/Securetrading/Stpp/Model/Payment/Tokenization.php +161 -0
  34. app/code/local/Securetrading/Stpp/Model/Payment/Tokenization/Session.php +7 -0
  35. app/code/local/Securetrading/Stpp/Model/Resource/Billing/Agreement/Currency.php +9 -0
  36. app/code/local/Securetrading/Stpp/Model/Resource/Billing/Agreement/Paymenttypedescription.php +9 -0
  37. app/code/local/Securetrading/Stpp/Model/Resource/Mage/Sales/Billing/Agreement/Collection.php +21 -0
  38. app/code/local/Securetrading/Stpp/Model/Source/Cardtypes.php +14 -12
  39. app/code/local/Securetrading/Stpp/Model/Source/Configfallback.php +18 -0
  40. app/code/local/Securetrading/Stpp/Model/Source/Settlestatus.php +1 -1
  41. app/code/local/Securetrading/Stpp/Model/Transaction.php +2 -2
  42. app/code/local/Securetrading/Stpp/controllers/Direct/PostController.php +9 -14
  43. app/code/local/Securetrading/Stpp/controllers/DirectController.php +32 -19
  44. app/code/local/Securetrading/Stpp/controllers/MultishippingController.php +15 -9
  45. app/code/local/Securetrading/Stpp/controllers/RedirectController.php +61 -46
  46. app/code/local/Securetrading/Stpp/controllers/Sales/Order/Create/SecuretradingController.php +3 -2
  47. app/code/local/Securetrading/Stpp/controllers/TokenizationController.php +40 -0
  48. app/code/local/Securetrading/Stpp/etc/config.xml +55 -7
  49. app/code/local/Securetrading/Stpp/etc/system.xml +177 -32
  50. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Base.php +12 -9
  51. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Facade.php +11 -0
  52. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Helper.php +26 -2
  53. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Send.php +3 -3
  54. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Xml/Reader.php +13 -3
  55. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Xml/Writer.php +15 -0
  56. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Facade.php +4 -0
  57. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Fields/Admin.php +5 -0
  58. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Fields/Frontend.php +6 -1
  59. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Http/Base.php +15 -3
  60. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Transactionsearch/Base.php +15 -2
  61. app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Types.php +5 -2
  62. app/code/local/Securetrading/Stpp/sql/securetrading_stpp/upgrade-3.4.0-3.5.0.php +70 -0
  63. app/design/adminhtml/default/default/template/securetrading/stpp/payment/direct/form.phtml +1 -1
  64. app/design/adminhtml/default/default/template/securetrading/stpp/payment/tokenization/form.phtml +16 -0
  65. app/design/adminhtml/default/default/template/securetrading/stpp/payment/tokenization/info.phtml +38 -0
  66. app/design/frontend/base/default/layout/securetrading.xml +22 -0
  67. app/design/frontend/base/default/template/securetrading/stpp/checkout/multishipping/success/billing/agreement.phtml +3 -0
  68. app/design/frontend/base/default/template/securetrading/stpp/payment/direct/form.phtml +26 -10
  69. app/design/frontend/base/default/template/securetrading/stpp/payment/direct/tokenization/form.phtml +107 -0
  70. app/design/frontend/base/default/template/securetrading/stpp/payment/redirect/form.phtml +23 -0
  71. app/design/frontend/base/default/template/securetrading/stpp/payment/tokenization/form.phtml +22 -0
  72. app/design/frontend/base/default/template/securetrading/stpp/payment/tokenization/info.phtml +7 -0
  73. app/design/frontend/base/default/template/securetrading/stpp/payment/tokenization/post.phtml +14 -0
  74. package.xml +4 -4
app/code/local/Securetrading/Stpp/Block/Adminhtml/Sales/Transactions/Single.php CHANGED
@@ -60,6 +60,17 @@ class Securetrading_Stpp_Block_Adminhtml_Sales_Transactions_Single extends Mage_
60
  return $this->getTransaction()->getTransactionReference();
61
  }
62
 
 
 
 
 
 
 
 
 
 
 
 
63
  public function hasParentTransaction() {
64
  return $this->getTransaction()->getParentTransactionId();
65
  }
@@ -110,7 +121,7 @@ class Securetrading_Stpp_Block_Adminhtml_Sales_Transactions_Single extends Mage_
110
  }
111
 
112
  public function getMystUrl() {
113
- return 'https://myst.securetrading.net/transactions/singletransaction?transactionreference=' . urlencode($this->getTransactionReference());
114
  }
115
 
116
  public function getParentTransactionIdUrl($parentTransactionId = '') {
60
  return $this->getTransaction()->getTransactionReference();
61
  }
62
 
63
+ public function replaceIfXReference($transactionReferenceOrXReference) {
64
+ if (substr($transactionReferenceOrXReference, 0, 1) === 'X') {
65
+ $filters = $this->getTransaction()->getRequestData('filter');
66
+ $return = $filters['transactionreference'];
67
+ }
68
+ else {
69
+ $return = $transactionReferenceOrXReference;
70
+ }
71
+ return $return;
72
+ }
73
+
74
  public function hasParentTransaction() {
75
  return $this->getTransaction()->getParentTransactionId();
76
  }
121
  }
122
 
123
  public function getMystUrl() {
124
+ return 'https://myst.securetrading.net/transactions/singletransaction?transactionreference=' . urlencode($this->replaceIfXReference($this->getTransactionReference()));
125
  }
126
 
127
  public function getParentTransactionIdUrl($parentTransactionId = '') {
app/code/local/Securetrading/Stpp/Block/Adminhtml/System/Config/Fieldset/Fields.php CHANGED
@@ -120,10 +120,6 @@ class Securetrading_Stpp_Block_Adminhtml_System_Config_Fieldset_Fields
120
  $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_PPG_USE_API);
121
  $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_PPG_USE_API);
122
  break;
123
- case 'ppg_use_iframe':
124
- $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_PPG_USE_IFRAME);
125
- $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_PPG_USE_IFRAME);
126
- break;
127
  case 'connection':
128
  $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_ALL_CONNECTION);
129
  $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_ALL_CONNECTION);
@@ -136,6 +132,10 @@ class Securetrading_Stpp_Block_Adminhtml_System_Config_Fieldset_Fields
136
  $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_ALL_USE_RISK_DECISION);
137
  $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_ALL_USE_RISK_DECISION);
138
  break;
 
 
 
 
139
  case 'use_card_store':
140
  $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_ALL_USE_CARD_STORE);
141
  $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_ALL_USE_CARD_STORE);
@@ -152,10 +152,6 @@ class Securetrading_Stpp_Block_Adminhtml_System_Config_Fieldset_Fields
152
  $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_ALL_ACCEPTED_CARDS);
153
  $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_ALL_ACCEPTED_CARDS);
154
  break;
155
- case 'api_use_iframe':
156
- $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_ALL_USE_IFRAME);
157
- $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_ALL_USE_IFRAME);
158
- break;
159
  case 'stapi_alias':
160
  $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_STAPI_ALIAS);
161
  $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_STAPI_ALIAS);
@@ -204,6 +200,14 @@ class Securetrading_Stpp_Block_Adminhtml_System_Config_Fieldset_Fields
204
  $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_TRANSACTIONSEARCH_CA_FILE);
205
  $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_TRANSACTIONSEARCH_CA_FILE);
206
  break;
 
 
 
 
 
 
 
 
207
  // The following are not retrieved from the framework but are here so the text is not duplicated across the different interfaces in system.xml.
208
  case 'active':
209
  $label = $this->__('Enabled');
@@ -226,12 +230,12 @@ class Securetrading_Stpp_Block_Adminhtml_System_Config_Fieldset_Fields
226
  $tooltip = $this->__('If \'Applicable Countries\' is set to \'Specific Countries\' this list will determine which country this payment method can be used in.');
227
  break;
228
  case 'ppg_iframe_height':
229
- case 'api_iframe_height':
230
  $label = $this->__('Iframe Height');
231
  $tooltip = $this->__('The height of the iframe. Enter one or more numbers followed by "px" or "%".');
232
  break;
233
  case 'ppg_iframe_width':
234
- case 'api_iframe_width':
235
  $label = $this->__('Iframe Width');
236
  $tooltip = $this->__('The width of the iframe. Enter one or more numbers followed by "px" or "%".');
237
  break;
@@ -243,6 +247,26 @@ class Securetrading_Stpp_Block_Adminhtml_System_Config_Fieldset_Fields
243
  $label = $this->__('Show Issue Number');
244
  $tooltip = $this->__('Enable this option to show the issue number input field on the payment form.');
245
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
  default:
247
  $label = $e->getLabel();
248
  $tooltip = $e->getTooltip();
120
  $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_PPG_USE_API);
121
  $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_PPG_USE_API);
122
  break;
 
 
 
 
123
  case 'connection':
124
  $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_ALL_CONNECTION);
125
  $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_ALL_CONNECTION);
132
  $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_ALL_USE_RISK_DECISION);
133
  $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_ALL_USE_RISK_DECISION);
134
  break;
135
+ case 'use_account_check':
136
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_ALL_USE_ACCOUNT_CHECK);
137
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_ALL_USE_ACCOUNT_CHECK);
138
+ break;
139
  case 'use_card_store':
140
  $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_ALL_USE_CARD_STORE);
141
  $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_ALL_USE_CARD_STORE);
152
  $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_ALL_ACCEPTED_CARDS);
153
  $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_ALL_ACCEPTED_CARDS);
154
  break;
 
 
 
 
155
  case 'stapi_alias':
156
  $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_STAPI_ALIAS);
157
  $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_STAPI_ALIAS);
200
  $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_TRANSACTIONSEARCH_CA_FILE);
201
  $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_TRANSACTIONSEARCH_CA_FILE);
202
  break;
203
+ case 'ppg_use_iframe':
204
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_PPG_USE_IFRAME);
205
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_PPG_USE_IFRAME);
206
+ break;
207
+ case 'use_iframe':
208
+ $label = $fields->getLabel(Stpp_Fields_Admin::FIELD_API_ALL_USE_IFRAME);
209
+ $tooltip = $fields->getDescription(Stpp_Fields_Admin::FIELD_API_ALL_USE_IFRAME);
210
+ break;
211
  // The following are not retrieved from the framework but are here so the text is not duplicated across the different interfaces in system.xml.
212
  case 'active':
213
  $label = $this->__('Enabled');
230
  $tooltip = $this->__('If \'Applicable Countries\' is set to \'Specific Countries\' this list will determine which country this payment method can be used in.');
231
  break;
232
  case 'ppg_iframe_height':
233
+ case 'iframe_height':
234
  $label = $this->__('Iframe Height');
235
  $tooltip = $this->__('The height of the iframe. Enter one or more numbers followed by "px" or "%".');
236
  break;
237
  case 'ppg_iframe_width':
238
+ case 'iframe_width':
239
  $label = $this->__('Iframe Width');
240
  $tooltip = $this->__('The width of the iframe. Enter one or more numbers followed by "px" or "%".');
241
  break;
247
  $label = $this->__('Show Issue Number');
248
  $tooltip = $this->__('Enable this option to show the issue number input field on the payment form.');
249
  break;
250
+ case 'allow_billing_agreement_wizard':
251
+ $label = $this->__('Use Billing Agreement Wizard');
252
+ $tooltip = $this->__('Enable this option to allow users to create new billing agreements through the customer account management area.');
253
+ break;
254
+ case 'use_tokenization':
255
+ $label = $this->__('Use Tokenization');
256
+ $tooltip = $this->__('Using tokenization will allow customers who place orders with this payment method to make easy future repeat purchases through the Secue Trading Tokenization payment method.');
257
+ break;
258
+ case 'max_saved_cc':
259
+ $label = $this->__('Max # of Saved Cards');
260
+ $tooltip = $this->__('The number you enter here is the maximum number of cards (billing agreements) your customers can save per store.');
261
+ break;
262
+ case 'save_cc_question':
263
+ $label = $this->__('"Save CC details?" Question');
264
+ $tooltip = $this->__('What you will ask your customers when you suggest they save their card details with your store for easy future order placement.');
265
+ break;
266
+ case 'config_fallback':
267
+ $label = $this->__('Config Inheritance');
268
+ $tooltip = $this->__('Defines which payment method to inherit certain configuration values from.');
269
+ break;
270
  default:
271
  $label = $e->getLabel();
272
  $tooltip = $e->getTooltip();
app/code/local/Securetrading/Stpp/Block/Checkout/Multishipping/Success/Billing/Agreement.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Checkout_Multishipping_Success_Billing_Agreement extends Mage_Core_Block_Template {
4
+ protected function _beforeToHtml() {
5
+ $this->_prepareLastBillingAgreement();
6
+ return parent::_beforeToHtml();
7
+ }
8
+
9
+ // See Mage_Checkout_Block_Onepage_Success::_prepareLastBillingAgreement().
10
+ protected function _prepareLastBillingAgreement() {
11
+ $agreementId = Mage::getSingleton('checkout/session')->getLastBillingAgreementId();
12
+ $customerId = Mage::getSingleton('customer/session')->getCustomerId();
13
+ if ($agreementId && $customerId) {
14
+ $agreement = Mage::getModel('sales/billing_agreement')->load($agreementId);
15
+ if ($agreement->getId() && $customerId == $agreement->getCustomerId()) {
16
+ $this->addData(
17
+ array(
18
+ 'agreement_ref_id' => $agreement->getReferenceId(),
19
+ 'agreement_url' => $this->getUrl('sales/billing_agreement/view', array('agreement' => $agreementId)),
20
+ )
21
+ );
22
+ }
23
+ }
24
+ }
25
+ }
app/code/local/Securetrading/Stpp/Block/Payment/Direct/Form.php CHANGED
@@ -5,7 +5,7 @@ class Securetrading_Stpp_Block_Payment_Direct_Form extends Mage_Payment_Block_Fo
5
  $this->setTemplate('securetrading/stpp/payment/direct/form.phtml');
6
  parent::_construct();
7
  }
8
-
9
  protected function _getIntegration() {
10
  return $this->getMethod()->getIntegration();
11
  }
@@ -13,6 +13,18 @@ class Securetrading_Stpp_Block_Payment_Direct_Form extends Mage_Payment_Block_Fo
13
  public function getDescription() {
14
  return $this->getMethod()->getConfigData('description');
15
  }
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  public function getAcceptedCards() {
18
  $method = $this->getMethod();
@@ -63,6 +75,21 @@ class Securetrading_Stpp_Block_Payment_Direct_Form extends Mage_Payment_Block_Fo
63
  return $this->_getIntegration()->getCardExpiryDateDescription();
64
  }
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  public function getCardSecurityCodeLabel() {
67
  return $this->_getIntegration()->getCardSecurityCodeLabel();
68
  }
@@ -86,4 +113,15 @@ class Securetrading_Stpp_Block_Payment_Direct_Form extends Mage_Payment_Block_Fo
86
  public function canShowIssueNumber() {
87
  return (bool) $this->getMethod()->getConfigData('show_issue_number');
88
  }
 
 
 
 
 
 
 
 
 
 
 
89
  }
5
  $this->setTemplate('securetrading/stpp/payment/direct/form.phtml');
6
  parent::_construct();
7
  }
8
+
9
  protected function _getIntegration() {
10
  return $this->getMethod()->getIntegration();
11
  }
13
  public function getDescription() {
14
  return $this->getMethod()->getConfigData('description');
15
  }
16
+
17
+ public function getSaveCcDetailsLabel() {
18
+ $question = $this->getMethod()->getConfigData('save_cc_question');
19
+ if (empty($question)) {
20
+ $question = $this->_getIntegration()->getSaveCcDetailsLabel();
21
+ }
22
+ return $question;
23
+ }
24
+
25
+ public function getSaveCcDetailsDescription() {
26
+ return $this->_getIntegration()->getSaveCcDetailsDescription();
27
+ }
28
 
29
  public function getAcceptedCards() {
30
  $method = $this->getMethod();
75
  return $this->_getIntegration()->getCardExpiryDateDescription();
76
  }
77
 
78
+ public function getCardExpiryMonthLabel() {
79
+ return $this->_getIntegration()->getCardExpiryMonthLabel();
80
+ }
81
+
82
+ public function getCardExpiryMonthDescription() {
83
+ return $this->_getIntegration()->getCardExpiryMonthDescription();
84
+ }
85
+
86
+ public function getCardExpiryYearLabel() {
87
+ return $this->_getIntegration()->getCardExpiryYearLabel();
88
+ }
89
+
90
+ public function getCardExpiryYearDescription() {
91
+ return $this->_getIntegration()->getCardExpiryYearDescription();
92
+ }
93
  public function getCardSecurityCodeLabel() {
94
  return $this->_getIntegration()->getCardSecurityCodeLabel();
95
  }
113
  public function canShowIssueNumber() {
114
  return (bool) $this->getMethod()->getConfigData('show_issue_number');
115
  }
116
+
117
+ protected function _canSaveCards() {
118
+ $tokenizationMethod = Mage::getModel('securetrading_stpp/payment_tokenization');
119
+ $collection = $tokenizationMethod->getSavedCardsCollection();
120
+ return $tokenizationMethod->canSaveCards($collection);
121
+ }
122
+
123
+ public function getUseCardStore() {
124
+ $customerExists = $this->getMethod()->getInfoInstance()->getQuote()->getCustomerId();
125
+ return $this->getMethod()->getConfigData('use_card_store') && $this->_canSaveCards() && $customerExists;
126
+ }
127
  }
app/code/local/Securetrading/Stpp/Block/Payment/Direct/Post.php CHANGED
@@ -1,23 +1,26 @@
1
  <?php
2
 
3
  class Securetrading_Stpp_Block_Payment_Direct_Post extends Mage_Core_Block_Template {
4
- protected $_params;
 
 
 
 
 
 
 
5
 
6
- protected function _construct() {
7
- $session = Mage::getSingleton('securetrading_stpp/payment_direct_session');
8
-
9
- if (!$session->hasAcsRedirectParams() || !($session->getAcsRedirectParams() instanceof Varien_Object)) {
10
- throw new Exception(Mage::helper('securetrading_stpp')->__('The ACS parameters could not be retrieved correctly.'));
11
- }
12
-
13
- $this->_params = $session->getAcsRedirectParams();
14
- }
15
-
16
- public function getRedirectUrl() {
17
- return $this->_params->getRedirectUrl();
18
- }
19
-
20
- public function getRedirectData() {
21
- return $this->_params->getRedirectData();
22
  }
 
 
 
 
 
 
 
 
 
 
23
  }
1
  <?php
2
 
3
  class Securetrading_Stpp_Block_Payment_Direct_Post extends Mage_Core_Block_Template {
4
+ protected $_params;
5
+
6
+ protected function _getMethodInstance() {
7
+ return Mage::registry(Securetrading_Stpp_Direct_PostController::REGISTRY_METHOD_INSTANCE_KEY);
8
+ }
9
+
10
+ protected function _construct() {
11
+ $session = $this->_getMethodInstance()->getSession();
12
 
13
+ if (!$session->hasAcsRedirectParams() || !($session->getAcsRedirectParams() instanceof Varien_Object)) {
14
+ throw new Exception(Mage::helper('securetrading_stpp')->__('The ACS parameters could not be retrieved correctly.'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  }
16
+ $this->_params = $session->getAcsRedirectParams();
17
+ }
18
+
19
+ public function getRedirectUrl() {
20
+ return $this->_params->getRedirectUrl();
21
+ }
22
+
23
+ public function getRedirectData() {
24
+ return $this->_params->getRedirectData();
25
+ }
26
  }
app/code/local/Securetrading/Stpp/Block/Payment/Direct/Tokenization/Form.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Payment_Direct_Tokenization_Form extends Securetrading_Stpp_Block_Payment_Direct_Form {
4
+ public function _construct() {
5
+ parent::_construct();
6
+ $this->setData('method', Mage::getModel('securetrading_stpp/payment_direct'));
7
+ $this->setTemplate('securetrading/stpp/payment/direct/tokenization/form.phtml');
8
+ }
9
+
10
+ public function getTokenizationPostUrl() {
11
+ return Mage::getUrl('securetrading_stpp/tokenization/newPost');
12
+ }
13
+
14
+ public function getCardstoreDescription() {
15
+ return $this->__('Please enter your credit/debit card details and click the "Submit" button to safely store your credit/debit card details with us. This will let you quickly and easily make future purchases with us.');
16
+ }
17
+ }
app/code/local/Securetrading/Stpp/Block/Payment/Redirect/Form.php CHANGED
@@ -6,7 +6,34 @@ class Securetrading_Stpp_Block_Payment_Redirect_Form extends Mage_Payment_Block_
6
  parent::_construct();
7
  }
8
 
 
 
 
 
9
  public function getDescription() {
10
  return Mage::getModel('securetrading_stpp/payment_redirect')->getConfigData('description');
11
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  }
6
  parent::_construct();
7
  }
8
 
9
+ protected function _getIntegration() {
10
+ return $this->getMethod()->getIntegration();
11
+ }
12
+
13
  public function getDescription() {
14
  return Mage::getModel('securetrading_stpp/payment_redirect')->getConfigData('description');
15
  }
16
+
17
+ public function getSaveCcDetailsLabel() {
18
+ $question = $this->getMethod()->getConfigData('save_cc_question');
19
+ if (empty($question)) {
20
+ $question = $this->_getIntegration()->getSaveCcDetailsLabel();
21
+ }
22
+ return $question;
23
+ }
24
+
25
+ public function getSaveCcDetailsDescription() {
26
+ return $this->_getIntegration()->getSaveCcDetailsDescription();
27
+ }
28
+
29
+ protected function _canSaveCards() {
30
+ $tokenizationMethod = Mage::getModel('securetrading_stpp/payment_tokenization');
31
+ $collection = $tokenizationMethod->getSavedCardsCollection();
32
+ return $tokenizationMethod->canSaveCards($collection);
33
+ }
34
+
35
+ public function getUseTokenization() {
36
+ $customerExists = $this->getMethod()->getInfoInstance()->getQuote()->getCustomerId();
37
+ return $this->getMethod()->getConfigData('use_tokenization') && $this->_canSaveCards() && $customerExists;
38
+ }
39
  }
app/code/local/Securetrading/Stpp/Block/Payment/Tokenization/Form.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Payment_Tokenization_Form extends Mage_Payment_Block_Form {
4
+ public function _construct() {
5
+ $this->setTemplate('securetrading/stpp/payment/tokenization/form.phtml');
6
+ parent::_construct();
7
+ }
8
+
9
+ public function getSavedCards() {
10
+ return $this->getMethod()->getSavedCardsCollection();
11
+ }
12
+
13
+ public function getCardNumberLabel() {
14
+ return $this->_getIntegration()->getCardNumberLabel();
15
+ }
16
+
17
+ protected function _getIntegration() {
18
+ return $this->getMethod()->getIntegration();
19
+ }
20
+
21
+ public function getDescription() {
22
+ return $this->getMethod()->getConfigData('description');
23
+ }
24
+
25
+ public function getAcceptedCards() {
26
+ $method = $this->getMethod();
27
+ return $method->getIntegration()->getAcceptedCards($method->getConfigData('use_3d_secure'), $method->getConfigData('accepted_cards'));
28
+ }
29
+
30
+ public function getAgreementLabel(Mage_Sales_Model_Billing_Agreement $agreement) {
31
+ $agreementLabel = $agreement->getAgreementLabel();
32
+ return preg_replace('/^([^(]+\([^,]+,[^,]+),([^,]+)(\))$/ ', '$1$3', $agreementLabel);
33
+ }
34
+ }
app/code/local/Securetrading/Stpp/Block/Payment/Tokenization/Info.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Block_Payment_Tokenization_Info extends Securetrading_Stpp_Block_Payment_Info_Abstract {
4
+ public function _construct() {
5
+ parent::_construct();
6
+ $this->setTemplate('securetrading/stpp/payment/tokenization/info.phtml');
7
+ }
8
+
9
+ public function getCardLabel() {
10
+ $label = '';
11
+ $activeBillingAgreement = $this->getInfo()->getMethodInstance()->getActiveBillingAgreement(true);
12
+ if ($activeBillingAgreement) {
13
+ $label = $activeBillingAgreement->getAgreementLabel();
14
+ }
15
+ return $label;
16
+ }
17
+ }
app/code/local/Securetrading/Stpp/Controller/Redirect/Post/Abstract.php CHANGED
@@ -7,10 +7,9 @@ abstract class Securetrading_Stpp_Controller_Redirect_Post_Abstract extends Mage
7
 
8
  public function preDispatch() {
9
  parent::preDispatch();
10
-
11
  try {
12
- Mage::getModel('securetrading_stpp/payment_redirect')->validateOrders($this->_getOrderIncrementIds());
13
- $this->_methodInstance = Mage::getModel('securetrading_stpp/payment_redirect')->getFirstMethodInstance($this->_getOrderIncrementIds());
14
  } catch (Exception $e) {
15
  Mage::logException($e);
16
  $this->_redirect(null);
7
 
8
  public function preDispatch() {
9
  parent::preDispatch();
 
10
  try {
11
+ Mage::getModel('securetrading_stpp/payment_redirect')->validateOrdersArePendingPpages($this->_getOrderIncrementIds());
12
+ $this->_methodInstance = Mage::getModel('securetrading_stpp/payment_redirect')->getFirstMethodInstance($this->_getOrderIncrementIds());
13
  } catch (Exception $e) {
14
  Mage::logException($e);
15
  $this->_redirect(null);
app/code/local/Securetrading/Stpp/Helper/Data.php CHANGED
@@ -1,116 +1,157 @@
1
  <?php
2
 
3
  class Securetrading_Stpp_Helper_Data extends Mage_Core_Helper_Abstract {
4
- public function orderIsSuccessful($orderIncrementId) {
5
- $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
6
- $successful = in_array($order->getState(), array(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW), true);
7
- return $successful;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  }
9
-
10
- public function ordersAreSuccessful($orderIncrementIds) {
11
- foreach($orderIncrementIds as $orderIncrementId) {
12
- if ($this->orderIsSuccessful($orderIncrementId)) {
13
- continue;
14
- }
15
- return false;
16
- }
17
- return true;
18
  }
19
-
20
- protected function _getCsvData($startDate, $endDate) {
21
- $csvData = array();
22
- foreach(Mage::app()->getStores() as $storeId => $store) {
23
- $models = array(
24
- Mage::getModel('securetrading_stpp/payment_redirect')->setStore($storeId)->getIntegration(),
25
- Mage::getModel('securetrading_stpp/payment_direct')->setStore($storeId)->getIntegration(),
26
- );
27
- foreach($models as $integration) {
28
- try {
29
- $siteReference = $store->getConfig('payment/' . $integration->getPaymentMethod()->getCode() . '/site_reference');
30
- $csvData[] = $integration->newTransactionSearch()
31
- ->setStartDate($startDate)
32
- ->setEndDate($endDate)
33
- ->setSiteReferences($siteReference)
34
- ->addFilter('requesttypedescriptions', 'AUTH')
35
- ->addOptionalField('orderreference')
36
- ->addOptionalField('settlestatus')
37
- ->getCsvData()
38
- ;
39
- }
40
- catch (Exception $e) {
41
- Mage::logException($e);
42
- continue;
43
- }
44
- }
45
- }
46
-
47
- $transactionReferences = array();
48
- $finalCsvData = array();
49
- foreach($csvData as $postResponse) {
50
- foreach($postResponse as $oneRecord) {
51
- if (in_array($oneRecord[0], $transactionReferences)) {
52
- continue;
53
- }
54
- $transactionReferences[] = $oneRecord[0];
55
- $finalCsvData[] = $oneRecord;
56
- }
57
- }
58
- return $finalCsvData;
59
  }
60
-
61
- public function updateOldOrders($startDate, $endDate) {
62
- $csvData = $this->_getCsvData($startDate, $endDate);
63
-
64
- foreach($csvData as $transactionArray) {
65
- $transactionReference = $transactionArray[0];
66
- $orderIncrementId = $transactionArray[1];
67
- $settleStatus = $transactionArray[2];
68
-
69
- $multishippingModel = Mage::getModel('securetrading_multishipping/order_set_factory');
70
- $orderId = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId)->getId();
71
-
72
- if (!$orderId) {
73
- Mage::getModel('securetrading_stpp/integration')->getDebugLog()->log(sprintf(Mage::helper('securetrading_stpp')->__('Update old orders: The order with ID "%s" and t\
74
- ransaction reference "%s" could not be loaded.', $orderIncrementId, $transactionReference)));
75
- continue;
76
- }
77
-
78
- if ($multishippingModel->orderBelongsToAnySet($orderId)) {
79
- $orderIds = $multishippingModel->getOrderIdsInSameSet($orderId, false);
80
- } else {
81
- $orderIds = array($orderId);
82
- }
83
-
84
- switch($settleStatus) {
85
- case '2':
86
- case '3':
87
- $this->_updateOrders($orderIds, true);
88
- break;
89
- case '100':
90
- $this->_updateOrders($orderIds, false);
91
- break;
92
- case '0':
93
- case '1':
94
- throw new Exception(sprintf(Mage::helper('securetrading_stpp')->__('Orders "%s" should not still be pending settlement.'), $orderIncrementId));
95
- break;
96
- default:
97
- throw new Exception(sprintf(Mage::helper('securetrading_stpp')->__('Order "%s" has an unhandled settle status: "%s".'), $orderIncrementId, $settleStatus));
98
- }
99
- }
100
  }
101
-
102
- protected function _updateOrders(array $orderIds, $cancelOrders = false) {
103
- foreach($orderIds as $orderId) {
104
- $order = Mage::getModel('sales/order')->load($orderId);
105
- $transactions = Mage::getResourceModel('sales/order_payment_transaction_collection')->addOrderIdFilter($order->getId())->addPaymentIdFilter($order->getPayment()->getId())->addFieldToFilter('is_closed', array('neq' => '1'));
106
-
107
- foreach($transactions as $transaction) {
108
- $transaction->setOrderPaymentObject($order->getPayment())->setIsClosed(true)->save();
109
- }
110
- if ($cancelOrders) {
111
- $order->cancel();
112
- }
113
- $order->save();
114
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  }
1
  <?php
2
 
3
  class Securetrading_Stpp_Helper_Data extends Mage_Core_Helper_Abstract {
4
+ public function getSecuretradingPaymentMethodCodes() {
5
+ return array('securetrading_stpp_redirect', 'securetrading_stpp_direct', 'securetrading_stpp_tokenization');
6
+ }
7
+
8
+ public function getSecuretradingApiTypePaymentMethodCodes() {
9
+ return array('securetrading_stpp_direct', 'securetrading_stpp_tokenization');
10
+ }
11
+
12
+ public function isSecuretradingPaymentMethod($code) {
13
+ return in_array($code, $this->getSecuretradingPaymentMethodCodes());
14
+ }
15
+
16
+ public function isSecuretradingApiTypePaymentMethod($code) {
17
+ return in_array($code, $this->getSecuretradingApiTypePaymentMethodCodes());
18
+ }
19
+
20
+ public function getCsvData($paymentModels, $filters, $optionalFields, $startDate, $endDate) {
21
+ $csvData = array();
22
+ foreach(Mage::app()->getStores() as $storeId => $store) {
23
+ foreach($paymentModels as $paymentModel) {
24
+ $paymentModel->setStore($storeId)->getIntegration();
25
+ try {
26
+ $siteReference = $store->getConfig('payment/' . $paymentModel->getCode() . '/site_reference');
27
+ $csvData[] = $paymentModel->getIntegration()->newTransactionSearch()
28
+ ->setStartDate($startDate)
29
+ ->setEndDate($endDate)
30
+ ->setSiteReferences($siteReference)
31
+ ->setFilters($filters)
32
+ ->setOptionalFields($optionalFields)
33
+ ->getCsvData()
34
+ ;
35
  }
36
+ catch (Exception $e) {
37
+ Mage::logException($e);
38
+ continue;
 
 
 
 
 
 
39
  }
40
+ }
41
+ }
42
+
43
+ $transactionReferences = array();
44
+ $finalCsvData = array();
45
+ foreach($csvData as $postResponse) {
46
+ foreach($postResponse as $oneRecord) {
47
+ if (in_array($oneRecord[0], $transactionReferences)) {
48
+ continue;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  }
50
+ $transactionReferences[] = $oneRecord[0];
51
+ $finalCsvData[] = $oneRecord;
52
+ }
53
+ }
54
+ return $finalCsvData;
55
+ }
56
+
57
+ public function updateOrders(array $orderIds, $cancelOrders = false) {
58
+ foreach($orderIds as $orderId) {
59
+ $order = Mage::getModel('sales/order')->load($orderId);
60
+ $transactions = Mage::getResourceModel('sales/order_payment_transaction_collection')->addOrderIdFilter($order->getId())->addPaymentIdFilter($order->getPayment()->getId())->addFieldToFilter('is_closed', array('neq' => '1'));
61
+
62
+ foreach($transactions as $transaction) {
63
+ $transaction->setOrderPaymentObject($order->getPayment())->setIsClosed(true)->save();
64
+ }
65
+ if ($cancelOrders) { // ST_#3508
66
+ if ($order->getState() === Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW) {
67
+ $order->getPayment()->setNotificationResult(true)->registerPaymentReviewAction(Mage_Sales_Model_Order_Payment::REVIEW_ACTION_DENY, false); // Offline review so no TRANSACTIONUPDATE runs.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  }
69
+ $order->cancel();
70
+ }
71
+ $order->save();
72
+ }
73
+ }
74
+
75
+ public function extractCcLast4($pan) {
76
+ if (($return = substr($pan, -4)) === false) {
77
+ throw new Exception(sprintf($this->__('Invalid return: "%s".'), $return));
78
+ }
79
+ return $return;
80
+ }
81
+
82
+ public function maskUntilCcLast4($pan) {
83
+ if (($strlen = strlen($pan)) === null) {
84
+ throw new Exception(sprintf($this->__('Invalid pan: "%s".'), $pan));
85
+ }
86
+ $maskCount = $strlen - 4;
87
+ $return = str_repeat('#', $maskCount) . $this->extractCcLast4($pan);
88
+ return $return;
89
+ }
90
+
91
+ public function isMultishippingCheckout() {
92
+ return Mage::getSingleton('checkout/session')->getQuote()->getIsMultiShipping();
93
+ }
94
+
95
+ public function getOrderIncrementIdsFromSession() {
96
+ if ($this->isMultishippingCheckout()) {
97
+ $orderIncrementIds = Mage::getModel('core/session')->getOrderIds();
98
+ }
99
+ else {
100
+ $orderIncrementIds = array(Mage::getModel('checkout/session')->getLastRealOrderId()); //onepage checkout
101
+ }
102
+ return $orderIncrementIds;
103
+ }
104
+
105
+ public function addBillingAgreement(Mage_Payment_Model_Method_Abstract $paymentMethod, $customerId, $agreementLabel, $transactionReference, $paymentTypeDescription, $currencyIso3a = null, $orderIncrementIds = array(), $storeId = null) {
106
+ if (!$storeId) {
107
+ $storeId = Mage::app()->getStore()->getId();
108
+ }
109
+
110
+ $tokenizationModel = Mage::getModel('securetrading_stpp/payment_tokenization');
111
+ $collection = $tokenizationModel->getSavedCardsCollectionUsingParams($customerId, $storeId, $currencyIso3a, array($paymentTypeDescription));
112
+ if (!$tokenizationModel->canSaveCards($collection)) {
113
+ throw new Exception($this->__('Unable to create billing agreement for customer "%s", store "%s", currency "%s and payment type "%s". Too many exist already.', $customerId, $storeId, $currencyIso3a, $paymentTypeDescription));
114
+ }
115
+
116
+ $agreement = Mage::getModel('sales/billing_agreement')
117
+ ->setCustomerId($customerId)
118
+ ->setMethodCode($paymentMethod->getCode())
119
+ ->setReferenceId($transactionReference)
120
+ ->setStatus(Mage_Sales_Model_Billing_Agreement::STATUS_ACTIVE)
121
+ ->setStoreId($storeId)
122
+ ->setAgreementLabel($agreementLabel)
123
+ ;
124
+
125
+ foreach($orderIncrementIds as $orderIncrementId) {
126
+ $agreement->addOrderRelation(Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId)->getId());
127
+ }
128
+
129
+ $transaction = Mage::getModel('core_resource/transaction');
130
+ $transaction->addObject($agreement);
131
+ $transaction->addCommitCallback(function() use ($agreement, $paymentTypeDescription, $currencyIso3a) {
132
+ Mage::getModel('securetrading_stpp/billing_agreement_paymenttypedescription')->setAgreementId($agreement->getId())->setPaymentTypeDescription($paymentTypeDescription)->save();
133
+ if ($currencyIso3a) {
134
+ Mage::getModel('securetrading_stpp/billing_agreement_currency')->setAgreementId($agreement->getId())->setBaseCurrency($currencyIso3a)->save();
135
  }
136
+ });
137
+ $transaction->save();
138
+ return $agreement;
139
+ }
140
+
141
+ public function registerSuccessfulOrderAfterExternalRedirect(Mage_Sales_Model_Order $order, $requestedSettleStatus) {
142
+ $order->getPayment()->getMethodInstance()->log(sprintf('In %s.', __METHOD__));
143
+
144
+ $amount = $order->getPayment()->getBaseAmountOrdered();
145
+
146
+ if (in_array($requestedSettleStatus, array('0', '1', '100'))) {
147
+ $order->getPayment()->registerCaptureNotification($amount, true);
148
+ }
149
+ elseif($requestedSettleStatus === '2') {
150
+ $order->getPayment()->registerAuthorizationNotification($amount);
151
+ }
152
+ else {
153
+ throw new Exception(sprintf('Invalid settle status: "%s".', $requestedSettleStatus));
154
+ }
155
+ $order->save();
156
+ }
157
  }
app/code/local/Securetrading/Stpp/Model/Actions/Abstract.php CHANGED
@@ -2,6 +2,8 @@
2
 
3
  abstract class Securetrading_Stpp_Model_Actions_Abstract extends Stpp_Actions_Abstract {
4
  protected $_order;
 
 
5
 
6
  public function setOrder(Mage_Sales_Model_Order $order) {
7
  $this->_order = $order;
@@ -25,6 +27,18 @@ abstract class Securetrading_Stpp_Model_Actions_Abstract extends Stpp_Actions_Ab
25
  return $this->_order;
26
  }
27
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  protected function _getRequestedSettleStatus(Stpp_Data_Response $response) {
29
  $transaction = Mage::getModel('securetrading_stpp/transaction')->loadByTransactionReference($response->get('parenttransactionreference'), true);
30
  if ($transaction && $transaction->getResponseType() === Securetrading_Stpp_Model_Transaction_Types::TYPE_THREEDQUERY) { // api 3d query used - so auth request didn't have settlestatus so need to get 3dq request.
@@ -71,10 +85,14 @@ abstract class Securetrading_Stpp_Model_Actions_Abstract extends Stpp_Actions_Ab
71
  }
72
  }
73
  }
 
 
 
74
  else {
75
  throw new Exception(sprintf(Mage::helper('securetrading_stpp')->__('Invalid settle status: "%s".'), $response->get('settlestatus')));
76
  }
77
  }
 
78
  return $result;
79
  }
80
 
@@ -101,7 +119,7 @@ abstract class Securetrading_Stpp_Model_Actions_Abstract extends Stpp_Actions_Ab
101
  }
102
  return $result;
103
  }
104
- //TODO - consistency of auths/captures being open or closed.
105
  protected function _paymentReviewAndDeny(Stpp_Data_Response $response, Mage_Sales_Model_Order $order) {
106
  $payment = $order->getPayment();
107
  $payment->setNotificationResult(true);
@@ -116,6 +134,17 @@ abstract class Securetrading_Stpp_Model_Actions_Abstract extends Stpp_Actions_Ab
116
  $order->save();
117
  }
118
 
 
 
 
 
 
 
 
 
 
 
 
119
  public function processAuth(Stpp_Data_Response $response) {
120
  $this->_log($response, sprintf('In %s.', __METHOD__));
121
 
@@ -133,6 +162,9 @@ abstract class Securetrading_Stpp_Model_Actions_Abstract extends Stpp_Actions_Ab
133
  else if ($this->_authShouldEnterPaymentReviewAndBeDenied($response)) {
134
  $this->_paymentReviewAndDeny($response, $order);
135
  }
 
 
 
136
  else {
137
  $this->_addGenericErrorToOrderStatusHistory($response, $order);
138
  }
2
 
3
  abstract class Securetrading_Stpp_Model_Actions_Abstract extends Stpp_Actions_Abstract {
4
  protected $_order;
5
+
6
+ abstract protected function _handleSofortPayment(Stpp_Data_Response $response);
7
 
8
  public function setOrder(Mage_Sales_Model_Order $order) {
9
  $this->_order = $order;
27
  return $this->_order;
28
  }
29
 
30
+ protected function _handleSuccessfulOrder(Mage_Sales_Model_Order $order, $emailConfirmation) {
31
+ $quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($order->getQuoteId());
32
+
33
+ if ($quote->getIsActive()) {
34
+ $quote->setIsActive(false)->save();
35
+ }
36
+
37
+ if ($emailConfirmation) {
38
+ $order->sendNewOrderEmail()->save(); // Send last - even if notif times out order status updated etc. and payment information updated.
39
+ }
40
+ }
41
+
42
  protected function _getRequestedSettleStatus(Stpp_Data_Response $response) {
43
  $transaction = Mage::getModel('securetrading_stpp/transaction')->loadByTransactionReference($response->get('parenttransactionreference'), true);
44
  if ($transaction && $transaction->getResponseType() === Securetrading_Stpp_Model_Transaction_Types::TYPE_THREEDQUERY) { // api 3d query used - so auth request didn't have settlestatus so need to get 3dq request.
85
  }
86
  }
87
  }
88
+ else if ($response->get('settlestatus') === '10') {
89
+ $result = false;
90
+ }
91
  else {
92
  throw new Exception(sprintf(Mage::helper('securetrading_stpp')->__('Invalid settle status: "%s".'), $response->get('settlestatus')));
93
  }
94
  }
95
+
96
  return $result;
97
  }
98
 
119
  }
120
  return $result;
121
  }
122
+
123
  protected function _paymentReviewAndDeny(Stpp_Data_Response $response, Mage_Sales_Model_Order $order) {
124
  $payment = $order->getPayment();
125
  $payment->setNotificationResult(true);
134
  $order->save();
135
  }
136
 
137
+ protected function _isSuccessfulSofortPayment($response) {
138
+ $result = false;
139
+ if ($response->get('errorcode') === '0' && $response->get('paymenttypedescription') === Mage::getModel('securetrading_stpp/integration')->getSofortName()) {
140
+ if ($response->get('settlestatus') !== '10') {
141
+ throw new Exception(sprintf(Mage::helper('securetrading_stpp')->__('Unexpected settle status: "%s".'), $response->get('settlestatus')));
142
+ }
143
+ $result = true;
144
+ }
145
+ return $result;
146
+ }
147
+
148
  public function processAuth(Stpp_Data_Response $response) {
149
  $this->_log($response, sprintf('In %s.', __METHOD__));
150
 
162
  else if ($this->_authShouldEnterPaymentReviewAndBeDenied($response)) {
163
  $this->_paymentReviewAndDeny($response, $order);
164
  }
165
+ else if ($this->_isSuccessfulSofortPayment($response)) {
166
+ $this->_handleSofortPayment($response);
167
+ }
168
  else {
169
  $this->_addGenericErrorToOrderStatusHistory($response, $order);
170
  }
app/code/local/Securetrading/Stpp/Model/Actions/Direct.php CHANGED
@@ -4,8 +4,7 @@ class Securetrading_Stpp_Model_Actions_Direct extends Securetrading_Stpp_Model_A
4
  const MULTISHIPPING_ORDERS_REGISTRY_KEY = 'securetrading_stpp_actions_direct_multishipping_orders_registry_key';
5
 
6
  protected function _getOrders(Stpp_Data_Response $response) {
7
- if (Mage::getModel('checkout/session')->getQuote()->getIsMultiShipping()) {
8
- $orders = Mage::registry(Securetrading_Stpp_Model_Actions_Direct::MULTISHIPPING_ORDERS_REGISTRY_KEY);
9
  return $orders;
10
  }
11
  else { // onepage
@@ -26,18 +25,42 @@ class Securetrading_Stpp_Model_Actions_Direct extends Securetrading_Stpp_Model_A
26
  ;
27
  $quote->setIsActive(true)->save();
28
  }
 
 
29
  return $this->_isErrorCodeZero($response);
30
  }
 
 
 
 
31
 
32
  protected function _processAuth(Stpp_Data_Response $response) {
33
  parent::processAuth($response);
34
  $order = $this->_getOrder($response);
 
 
 
 
 
 
 
 
 
 
35
 
36
  if ($this->_paymentIsSuccessful($response) || $this->_authShouldEnterPaymentReview($response)) {
37
  if ($response->getRequest()->has('md')) {
38
- Mage::getModel('securetrading_stpp/payment_direct')->registerSuccessfulOrderAfterExternalRedirect($order, $this->_getRequestedSettleStatus($response));
39
  }
40
- $order->getPayment()->getMethodInstance()->handleSuccessfulPayment($order, true);
 
 
 
 
 
 
 
 
41
  }
42
  }
43
 
@@ -80,4 +103,41 @@ class Securetrading_Stpp_Model_Actions_Direct extends Securetrading_Stpp_Model_A
80
  }
81
  return $this->_isErrorCodeZero($response);
82
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  }
4
  const MULTISHIPPING_ORDERS_REGISTRY_KEY = 'securetrading_stpp_actions_direct_multishipping_orders_registry_key';
5
 
6
  protected function _getOrders(Stpp_Data_Response $response) {
7
+ if ($orders = Mage::registry(Securetrading_Stpp_Model_Actions_Direct::MULTISHIPPING_ORDERS_REGISTRY_KEY)) {
 
8
  return $orders;
9
  }
10
  else { // onepage
25
  ;
26
  $quote->setIsActive(true)->save();
27
  }
28
+ $order->getPayment()->getMethodInstance()->getSession()->clear();
29
+
30
  return $this->_isErrorCodeZero($response);
31
  }
32
+
33
+ protected function _handleSofortPayment(Stpp_Data_Response $response) {
34
+ throw new Exception(Mage::helper('securetrading_stpp')->__('The direct payment method does not currently allow sofort payments.'));
35
+ }
36
 
37
  protected function _processAuth(Stpp_Data_Response $response) {
38
  parent::processAuth($response);
39
  $order = $this->_getOrder($response);
40
+ $payment = $order->getPayment();
41
+ $methodInstance = $payment->getMethodInstance();
42
+
43
+ if ($this->_authShouldEnterPaymentReview($response)) {
44
+ if ($methodInstance->getIsMultishipping() && !$methodInstance->getIsFirstMultishipping()) {
45
+ $payment->setIsTransactionPending(false); ## reverse the setting to pending - so exception at bottom of mage_sales_model_order_payment::capture() isn't thrown - but it will be reset by our code in direct payment method's capture() func.
46
+ Mage::register('stpp_test_key', true);
47
+ }
48
+
49
+ }
50
 
51
  if ($this->_paymentIsSuccessful($response) || $this->_authShouldEnterPaymentReview($response)) {
52
  if ($response->getRequest()->has('md')) {
53
+ Mage::helper('securetrading_stpp')->registerSuccessfulOrderAfterExternalRedirect($order, $this->_getRequestedSettleStatus($response));
54
  }
55
+ $this->_handleSuccessfulOrder($order, true);
56
+ }
57
+
58
+ if ($methodInstance->getCode() === Mage::getModel('securetrading_stpp/payment_tokenization')->getCode()) {
59
+ $payment
60
+ ->setCcType($response->get('paymenttypedescription'))
61
+ ->setCcLast4($payment->getMethodInstance()->getIntegration()->getCcLast4($response->get('maskedpan')))
62
+ ->save()
63
+ ;
64
  }
65
  }
66
 
103
  }
104
  return $this->_isErrorCodeZero($response);
105
  }
106
+
107
+ public function processCardstore(Stpp_Data_Response $response) {
108
+ $paymentMethod = Mage::getModel('securetrading_stpp/payment_direct');
109
+ $checkoutUsed = (bool) $this->_getOrder($response)->getPayment();
110
+
111
+ if ($checkoutUsed) { // cardstore done through a checkout
112
+ $orders = $this->_getOrders($response);
113
+ $orderIncrementIds = array();
114
+ foreach($orders as $order) {
115
+ $orderIncrementIds[] = $order->getIncrementId();
116
+ }
117
+ }
118
+ else { // cardstore done thorugh wizard
119
+ $orderIncrementIds = array();
120
+ }
121
+
122
+ $agreement = Mage::helper('securetrading_stpp')->addBillingAgreement(
123
+ $paymentMethod,
124
+ Mage::getSingleton('customer/session')->getId(),
125
+ $paymentMethod->prepareCardstoreLabel($response->get('maskedpan'), $response->get('paymenttypedescription'), $response->getRequest()->get('expirydate')),
126
+ $response->get('transactionreference'),
127
+ $response->get('paymenttypedescription'),
128
+ null,
129
+ $orderIncrementIds
130
+ );
131
+
132
+
133
+ if ($checkoutUsed) { //checkout
134
+ Mage::getSingleton('checkout/session')->setLastBillingAgreementId($agreement->getId());
135
+ Mage::getSingleton('checkout/session')->setLastSecuretradingBillingAgreementId($agreement->getId());// Must do this for onepage checkout (see Mage_Checkout_ModeL_Type_Onepage::saveOrder(), call to Mage_checkout_Model_Session::clearHelperData(). see securetrading_stpp_model_observer::onCheckoutTypeOnepageSaveOrderAfter() too.
136
+ }
137
+ else {
138
+ Mage::getSingleton('customer/session')->setLastBillingAgreementId($agreement->getId());
139
+ }
140
+
141
+ return $this->_isErrorCodeZero($response);
142
+ }
143
  }
app/code/local/Securetrading/Stpp/Model/Actions/Redirect.php CHANGED
@@ -40,13 +40,39 @@ class Securetrading_Stpp_Model_Actions_Redirect extends Securetrading_Stpp_Model
40
  }
41
 
42
  public function processAuth(Stpp_Data_Response $response) {
43
- $firstOrder = true;
44
- foreach($this->_getOrderIncrementIds($response) as $orderIncrementId) {
45
- $this->setOrder(Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId));
46
- $this->_processAuth($response, $firstOrder);
47
- $firstOrder = false;
48
- }
49
- return $this->_isErrorCodeZero($response);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
51
 
52
  public function process3dQuery(Stpp_Data_Response $response) {
@@ -89,12 +115,12 @@ class Securetrading_Stpp_Model_Actions_Redirect extends Securetrading_Stpp_Model
89
  return $this->_isErrorCodeZero($response);
90
  }
91
 
92
- public function _processAuth(Stpp_Data_Response $response, $firstOrder) {
93
  $order = $this->_getOrder($response);
94
  $payment = $order->getPayment();
95
 
96
- if ($order->getStatus() !== Securetrading_Stpp_Model_Payment_Redirect::STATUS_PENDING_PPAGES) {
97
- throw new Stpp_Exception(sprintf(Mage::helper('securetrading_stpp')->__('The order status for order "%s" was not pending payment pages.'), $order->getIncrementId()));
98
  }
99
 
100
  parent::processAuth($response);
@@ -107,9 +133,9 @@ class Securetrading_Stpp_Model_Actions_Redirect extends Securetrading_Stpp_Model
107
 
108
  if ($this->_paymentIsSuccessful($response) || $this->_authShouldEnterPaymentReview($response)) {
109
  $payment = $order->getPayment();
110
- Mage::getModel('securetrading_stpp/payment_redirect')->registerSuccessfulOrderAfterExternalRedirect($order, $this->_getRequestedSettleStatus($response));
111
  $emailConfirmation = $response->get('accounttypedescription') === 'MOTO' ? (bool) $response->get('send_confirmation') : true;
112
- $payment->getMethodInstance()->handleSuccessfulPayment($order, $emailConfirmation);
113
  }
114
  }
115
 
@@ -222,6 +248,7 @@ class Securetrading_Stpp_Model_Actions_Redirect extends Securetrading_Stpp_Model
222
  'billingcountryiso2a',
223
  'billingtelephone',
224
  'billingemail',
 
225
  'customerprefixname',
226
  'customerfirstname',
227
  'customerlastname',
@@ -235,6 +262,7 @@ class Securetrading_Stpp_Model_Actions_Redirect extends Securetrading_Stpp_Model
235
  'customeremail',
236
  'enrolled',
237
  'errorcode',
 
238
  'maskedpan',
239
  'orderreference',
240
  'parenttransactionreference',
@@ -246,12 +274,14 @@ class Securetrading_Stpp_Model_Actions_Redirect extends Securetrading_Stpp_Model
246
  'settlestatus',
247
  'status',
248
  'transactionreference',
249
- // custom fields:
250
- 'errordata',
251
- 'errormessage',
252
- 'order_increment_ids',
253
- 'send_confirmation',
254
- 'fraudcontrolshieldstatuscode',
 
 
255
  );
256
 
257
  foreach($fields as $field) {
@@ -259,6 +289,12 @@ class Securetrading_Stpp_Model_Actions_Redirect extends Securetrading_Stpp_Model
259
  throw new Stpp_Exception(sprintf(Mage::helper('securetrading_stpp')->__('The "%s" is required.'), $field));
260
  }
261
  }
 
 
 
 
 
 
262
  }
263
 
264
  public function checkIsNotificationProcessed($notificationReference) {
@@ -281,4 +317,11 @@ class Securetrading_Stpp_Model_Actions_Redirect extends Securetrading_Stpp_Model
281
  $response->setRequest($request);
282
  }
283
  }
 
 
 
 
 
 
 
284
  }
40
  }
41
 
42
  public function processAuth(Stpp_Data_Response $response) {
43
+ $transaction = Mage::getModel('core_resource/transaction');
44
+ $firstOrder = true;
45
+ foreach($this->_getOrderIncrementIds($response) as $orderIncrementId) {
46
+ $this->setOrder(Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId));
47
+ $this->_processAuth($response, $firstOrder);
48
+ $firstOrder = false;
49
+ }
50
+
51
+ if ($this->_paymentIsSuccessful($response) && $response->get('savecc')) {
52
+ $this->_createBillingAgreement($response);
53
+ }
54
+ return $this->_isErrorCodeZero($response);
55
+ }
56
+
57
+ protected function _handleSofortPayment(Stpp_Data_Response $response) {
58
+ $this->_setCoreTransaction($response, false);
59
+ $order = $this->_getOrder($response);
60
+ $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_SOFORT);
61
+ $order->save();
62
+ }
63
+
64
+ protected function _createBillingAgreement(Stpp_Data_Response $response) {
65
+ $payment = $this->_getOrder($response)->getPayment();
66
+ Mage::helper('securetrading_stpp')->addBillingAgreement(
67
+ $payment->getMethodInstance(),
68
+ $payment->getOrder()->getCustomerId(),
69
+ $this->_createSavedCcLabel($payment, $response->get('maskedpan'), $response->get('paymenttypedescription'), $response->get('expirydate'), $response->get('currencyiso3a')),
70
+ $response->get('transactionreference'),
71
+ $response->get('paymenttypedescription'),
72
+ $response->get('currencyiso3a'),
73
+ $this->_getOrderIncrementIds($response),
74
+ $payment->getOrder()->getStoreId()
75
+ );
76
  }
77
 
78
  public function process3dQuery(Stpp_Data_Response $response) {
115
  return $this->_isErrorCodeZero($response);
116
  }
117
 
118
+ public function _processAuth(Stpp_Data_Response $response, $firstOrder) {
119
  $order = $this->_getOrder($response);
120
  $payment = $order->getPayment();
121
 
122
+ if (!in_array($order->getStatus(), array(Securetrading_Stpp_Model_Payment_Redirect::STATUS_PENDING_PPAGES, Securetrading_Stpp_Model_Payment_Redirect::STATUS_PENDING_SOFORT))) {
123
+ throw new Stpp_Exception(sprintf(Mage::helper('securetrading_stpp')->__('The order status for order "%s" was not pending payment pages or pending sofort.'), $order->getIncrementId()));
124
  }
125
 
126
  parent::processAuth($response);
133
 
134
  if ($this->_paymentIsSuccessful($response) || $this->_authShouldEnterPaymentReview($response)) {
135
  $payment = $order->getPayment();
136
+ Mage::helper('securetrading_stpp')->registerSuccessfulOrderAfterExternalRedirect($order, $this->_getRequestedSettleStatus($response));
137
  $emailConfirmation = $response->get('accounttypedescription') === 'MOTO' ? (bool) $response->get('send_confirmation') : true;
138
+ $this->_handleSuccessfulOrder($order, $emailConfirmation);
139
  }
140
  }
141
 
248
  'billingcountryiso2a',
249
  'billingtelephone',
250
  'billingemail',
251
+ 'currencyiso3a',
252
  'customerprefixname',
253
  'customerfirstname',
254
  'customerlastname',
262
  'customeremail',
263
  'enrolled',
264
  'errorcode',
265
+ 'expirydate',
266
  'maskedpan',
267
  'orderreference',
268
  'parenttransactionreference',
274
  'settlestatus',
275
  'status',
276
  'transactionreference',
277
+ // custom fields:
278
+ //'errordata', // Commented out - ST gateway bug? errordata not present on AUTH 7000 notifications.
279
+ 'errormessage',
280
+ 'order_increment_ids',
281
+ 'send_confirmation',
282
+ 'fraudcontrolshieldstatuscode',
283
+ 'customer_id',
284
+ 'savecc',
285
  );
286
 
287
  foreach($fields as $field) {
289
  throw new Stpp_Exception(sprintf(Mage::helper('securetrading_stpp')->__('The "%s" is required.'), $field));
290
  }
291
  }
292
+
293
+ // Added - ST gateway bug? errordata not present on AUTH 7000 notifications.
294
+ if (!$response->has('errordata')) {
295
+ $response->set('errordata', '');
296
+ }
297
+ // End added.
298
  }
299
 
300
  public function checkIsNotificationProcessed($notificationReference) {
317
  $response->setRequest($request);
318
  }
319
  }
320
+
321
+ protected function _createSavedCcLabel($payment, $maskedPan, $paymentTypeDescription, $expiryDate, $currencyIso3a) {
322
+ $maskedUntilLast4 = Mage::helper('securetrading_stpp')->maskUntilCcLast4($maskedPan);
323
+ $paymentType = $payment->getMethodInstance()->getIntegration()->getCardString($paymentTypeDescription);
324
+ $label = sprintf('%s (%s, %s, %s)', $maskedUntilLast4, $paymentType, $expiryDate, $currencyIso3a);
325
+ return $label;
326
+ }
327
  }
app/code/local/Securetrading/Stpp/Model/Billing/Agreement/Currency.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Billing_Agreement_Currency extends Mage_Core_Model_Abstract {
4
+ public function _construct() {
5
+ $this->_init('securetrading_stpp/billing_agreement_currency');
6
+ }
7
+ }
app/code/local/Securetrading/Stpp/Model/Billing/Agreement/Paymenttypedescription.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Billing_Agreement_Paymenttypedescription extends Mage_Core_Model_Abstract {
4
+ public function _construct() {
5
+ $this->_init('securetrading_stpp/billing_agreement_paymenttypedescription');
6
+ }
7
+ }
app/code/local/Securetrading/Stpp/Model/Cron.php CHANGED
@@ -1,38 +1,175 @@
1
  <?php
2
 
3
  class Securetrading_Stpp_Model_Cron {
4
- const EXPIRED_ORDER_HOURS = 24;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- public function abandonedOrderCleanup() {
7
- $expiredOrderTime = date('Y-m-d H:i:s', strtotime('-' . self::EXPIRED_ORDER_HOURS . ' hours'));
8
-
9
- $collection = Mage::getResourceModel('sales/order_collection')
10
- ->addFieldToFilter('status', array('in', array(Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_PPAGES, Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_3DSECURE)))
11
- ->addFieldToFilter('updated_at', array('lt' => $expiredOrderTime))
12
- ;
13
-
14
- foreach($collection->getItems() as $order) {
15
- if (!$order->getPayment()->getMethodInstance()->getIsSecuretradingPaymentMethod()) {
16
- continue;
17
- }
18
- $order->cancel();
19
- $order->save();
20
- }
21
  }
 
 
 
 
 
 
22
 
23
- public function requestTableCleanup() {
24
- $collection = Mage::getModel('securetrading_stpp/payment_redirect_request')->getCollection();
25
- $collection->join(array('orders' => 'sales/order'),'orders.increment_id = main_table.order_increment_id', array('status'));
26
- $collection->addFieldToFilter('orders.status', array('neq' => Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_PPAGES));
27
-
28
- foreach($collection->getItems() as $item) {
29
- $item->delete();
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
- public function updateOldOrders() {
34
- $startDate = date("Y-m-d", strtotime("-30 day"));
35
- $endDate = date("Y-m-d", strtotime("-8 day"));
36
- Mage::helper('securetrading_stpp')->updateOldOrders($startDate, $endDate);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  }
 
38
  }
1
  <?php
2
 
3
  class Securetrading_Stpp_Model_Cron {
4
+ const EXPIRED_ORDER_HOURS = 24;
5
+
6
+ const SOFORT_HOURS_UPDATED_AFTER = 12;
7
+
8
+ public function abandonedOrderCleanup() {
9
+ $expiredOrderTime = date('Y-m-d H:i:s', strtotime('-' . self::EXPIRED_ORDER_HOURS . ' hours'));
10
+ $orderStatuses = array(
11
+ Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_PPAGES,
12
+ Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_3DSECURE,
13
+ Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_SOFORT,
14
+ );
15
+
16
+ $collection = Mage::getResourceModel('sales/order_collection')
17
+ ->addFieldToFilter('status', array('in', $orderStatuses))
18
+ ->addFieldToFilter('updated_at', array('lt' => $expiredOrderTime))
19
+ ;
20
 
21
+ foreach($collection->getItems() as $order) {
22
+ if (!$order->getPayment()->getMethodInstance()->getIsSecuretradingPaymentMethod()) {
23
+ continue;
24
+ }
25
+
26
+ foreach($order->getInvoiceCollection() as $invoice) { // ST_#3503
27
+ $invoice->cancel()->save();
28
+ }
29
+
30
+ $order->cancel();
31
+ $order->save();
 
 
 
 
32
  }
33
+ }
34
+
35
+ public function requestTableCleanup() {
36
+ $collection = Mage::getModel('securetrading_stpp/payment_redirect_request')->getCollection();
37
+ $collection->join(array('orders' => 'sales/order'),'orders.increment_id = main_table.order_increment_id', array('status'));
38
+ $collection->addFieldToFilter('orders.status', array('neq' => Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_PPAGES));
39
 
40
+ foreach($collection->getItems() as $item) {
41
+ $item->delete();
42
+ }
43
+ }
44
+
45
+ public function updateOldOrders() {
46
+ $csvData = $this->_getOldOrders();
47
+ $this->_updateOldOrders($csvData);
48
+ }
49
+
50
+ public function updateSofortTransactions() {
51
+ $csvData = $this->_getSofortTransactions();
52
+ $this->_updateSofortTransactions($csvData);
53
+ }
54
+
55
+ protected function _getOldOrders() {
56
+ $startDate = date("Y-m-d", strtotime("-30 day"));
57
+ $endDate = date("Y-m-d", strtotime("-8 day"));
58
+
59
+ $models = array(
60
+ Mage::getModel('securetrading_stpp/payment_redirect'),
61
+ Mage::getModel('securetrading_stpp/payment_direct'),
62
+ );
63
+ $filters = array('requesttypedescriptions' => array('AUTH'));
64
+ $additionalFields = array('orderreference', 'settlestatus');
65
+
66
+ $csvData = Mage::helper('securetrading_stpp')->getCsvData($models, $filters, $additionalFields, $startDate, $endDate);
67
+ return $csvData;
68
+ }
69
+
70
+ protected function _updateOldOrders(array $csvData) {
71
+ $errorPending = array();
72
+ $errorOther = array();
73
+ foreach($csvData as $transactionArray) {
74
+ $transactionReference = $transactionArray[0];
75
+ $orderIncrementId = $transactionArray[1];
76
+ $settleStatus = $transactionArray[2];
77
+
78
+ $orderIds = Mage::helper('securetrading_multishipping')->getRelatedMultishippingOrders($orderIncrementId);
79
+
80
+ if ($orderIds === false) {
81
+ Mage::getModel('securetrading_stpp/integration')->getDebugLog()->log(sprintf(Mage::helper('securetrading_stpp')->__('Update old orders: The order with ID "%s" and transaction reference "%s" could not be loaded.', $orderIncrementId, $transactionReference)));
82
+ continue;
83
+ }
84
+
85
+ switch($settleStatus) {
86
+ case '2':
87
+ case '3':
88
+ Mage::helper('securetrading_stpp')->updateOrders($orderIds, true);
89
+ break;
90
+ case '100':
91
+ Mage::helper('securetrading_stpp')->updateOrders($orderIds, false);
92
+ break;
93
+ case '0':
94
+ case '1':
95
+ Mage::getModel('securetrading_stpp/integration')->getDebugLog()->log(Mage::helper('securetrading_stpp')->__('Update old orders: Order "%s" should not still be pending settlement.', $orderIncrementId));
96
+ $errorPending[] = $transactionReference;
97
+ break;
98
+ default:
99
+ $errorOther[] = $transactionReference;
100
+ }
101
  }
102
+ if (!empty($errorPending) || !empty($errorOther)) {
103
+ throw new Exception(Mage::helper('securetrading_stpp')->__('Update old orders: errors. These transaction references should not still be pending settlement: %s. These transaction references had an unexpected settle status: %s.', implode(', ', $errorPending), implode(', ', $errorOther)));
104
+ }
105
+ }
106
+
107
+ protected function _getSofortTransactions() {
108
+ $collection = Mage::getModel('sales/order')->getCollection();
109
+ $collection->addFieldToFilter('status', array('eq' => Securetrading_Stpp_Model_Payment_Abstract::STATUS_PROCESSING_SOFORT));
110
+ $collection->addFieldToSelect('increment_id');
111
+ $orderIncrementIds = array();
112
+ foreach($collection as $order) {
113
+ $orderIncrementIds[] = $order->getIncrementId();
114
+ }
115
+
116
+ $startDate = date('Y-m-d', strtotime('-30 day'));//TODO - the crons have arbitrary limits on start dates. E.g. merchant runs module for year, doesn't configure cron. then sets it up. not all transactions will be retrieved and updated. two potential solutions: allow cron to be manually fired from admin area with no limits, or make start dates configurable.
117
+ $endDate = date('Y-m-d');
118
 
119
+ $models = array(Mage::getModel('securetrading_stpp/payment_redirect'));
120
+ $filters = array('orderreferences' => $orderIncrementIds);
121
+ $additionalFields = array('orderreference', 'settlestatus');
122
+ $csvData = Mage::helper('securetrading_stpp')->getCsvData($models, $filters, $additionalFields, $startDate, $endDate);
123
+
124
+ // take order to SOFORT auth page - it is now pending sofort. if decline - customer can try again. new ST transaction made for each try. all one order id. so multiple transactionreferences - some cancelled, one may be settled - for each order increment id. handle this case - if there is a 100 then the order was a success.
125
+ $finalCsvData = array();
126
+ foreach($csvData as $row) {
127
+ $orderIncrementId = $row[1];
128
+ if (array_key_exists($orderIncrementId, $finalCsvData) && $finalCsvData[$orderIncrementId][2] === '100') { // If a transaction already exists for this order increement ID and is settlestatus 100, continue so that the transaction isn't set back to a 3 again (if a 3 also exists)
129
+ continue;
130
+ }
131
+ $finalCsvData[$orderIncrementId] = $row;
132
+ }
133
+ return $finalCsvData;
134
+ }
135
+
136
+ protected function _updateSofortTransactions(array $csvData) {
137
+ $errors = array();
138
+ foreach($csvData as $transactionArray) {
139
+ $transactionReference = $transactionArray[0];
140
+ $orderIncrementId = $transactionArray[1];
141
+ $settleStatus = $transactionArray[2];
142
+ $orderIds = Mage::helper('securetrading_multishipping')->getRelatedMultishippingOrders($orderIncrementId);
143
+
144
+ if ($orderIds === false) {
145
+ Mage::getModel('securetrading_stpp/integration')->getDebugLog()->log(sprintf(Mage::helper('securetrading_stpp')->__('Update old orders: The order with ID "%s" and transaction reference "%s" could not be loaded.', $orderIncrementId, $transactionReference)));
146
+ continue;
147
+ }
148
+
149
+ switch($settleStatus) {
150
+ case '100':
151
+ Mage::helper('securetrading_stpp')->updateOrders($orderIds, false);
152
+ foreach($orderIds as $orderId) {
153
+ $order = Mage::getModel('sales/order')->load($orderId);
154
+ Mage::helper('securetrading_stpp')->registerSuccessfulOrderAfterExternalRedirect($order, $settleStatus);
155
+ }
156
+ break;
157
+ case '3':
158
+ Mage::helper('securetrading_stpp')->updateOrders($orderIds, true);
159
+ break;
160
+ case '10':
161
+ default:
162
+ $errors[$orderIncrementId] = $settleStatus;
163
+ break;
164
+ }
165
+ }
166
+
167
+ if (!empty($errors)) {
168
+ $e = array();
169
+ foreach($errors as $incrementId => $sStatus) {
170
+ $e[] = $incrementId . ':' . $sStatus;
171
+ }
172
+ throw new Exception(Mage::helper('securetrading_stpp')->__('Update sofort orders: errors. These orders had incorrect settle statuses: %s.', implode(', ', $e)));
173
  }
174
+ }
175
  }
app/code/local/Securetrading/Stpp/Model/Integration.php CHANGED
@@ -66,9 +66,10 @@ class Securetrading_Stpp_Model_Integration extends Mage_Core_Model_Abstract {
66
  'active_connection' => $paymentMethod->getConfigData('connection'),
67
  'use_3d_secure' => $paymentMethod->getConfigData('use_3d_secure'),
68
  'use_risk_decision' => $paymentMethod->getConfigData('use_risk_decision'),
 
69
  'use_card_store' => $paymentMethod->getConfigData('use_card_store'),
70
- 'use_risk_decision_after_auth' => $paymentMethod->getConfigData('delay_risk_decision'),
71
- 'use_auto_card_store' => $paymentMethod->getConfigData('use_auto_card_store'),
72
  )
73
  ),
74
  'transactionsearch' => array(
@@ -81,7 +82,7 @@ class Securetrading_Stpp_Model_Integration extends Mage_Core_Model_Abstract {
81
  )
82
  );
83
  }
84
-
85
  $utilityFacade = Magento_Utility_Facade::instance($config); // Must be done before using any other parts of the STPP framework.
86
  $fieldFacade = Stpp_Fields_Facade::instance($config);
87
 
@@ -162,6 +163,30 @@ class Securetrading_Stpp_Model_Integration extends Mage_Core_Model_Abstract {
162
  return $this;
163
  }
164
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  public function runApiRefund(Mage_Sales_Model_Order_Payment $payment, array $data) {
166
  $this->_setOrderToActionInstances($payment->getOrder());
167
  $request = Stpp_Data_Request::instance()->setMultiple($data);
@@ -173,23 +198,16 @@ class Securetrading_Stpp_Model_Integration extends Mage_Core_Model_Abstract {
173
  return $this;
174
  }
175
 
176
- public function runApiStandard(Mage_Sales_Model_Order_Payment $payment, $isMoto = false) {
177
- $isMoto = $payment->getOrder()->getQuote()->getIsSuperMode();
178
- $this->_setOrderToActionInstances($payment->getOrder());
179
- $orderIncrementIds = Mage::getModel('core/session')->getOrderIds() ? Mage::getModel('core/session')->getOrderIds() : array($payment->getOrder()->getIncrementId()); //multishipping or onepage
180
- $data = $this->getPaymentMethod()->prepareOrderData($payment, $orderIncrementIds);
181
- $request = Stpp_Data_Request::instance()->setMultiple($data);
182
- return $this->_apiFacade->runApiStandard($request, $isMoto);
183
- }
184
-
185
- public function runApi3dAuth() {
186
- return $this->_apiFacade->runApi3dAuth(new Stpp_Data_Request());
187
- }
188
 
189
- public function runPaymentPages(array $data, $isMoto = false) {
190
- $request = Stpp_Data_Request::instance()->setMultiple($data);
191
- $result = $this->_ppagesFacade->runPaymentPagesStandard($request, $isMoto);
192
- Mage::getModel('securetrading_stpp/payment_redirect_request')->addRequest($this->getPaymentMethod()->getInfoInstance(), $result->getRequest());
193
 
194
  $transport = new Varien_Object();
195
  $transport->setRedirectIsPost($result->getRedirectIsPost());
@@ -253,6 +271,10 @@ class Securetrading_Stpp_Model_Integration extends Mage_Core_Model_Abstract {
253
  public function getThreedqueryName() {
254
  return Stpp_Types::API_THREEDQUERY;
255
  }
 
 
 
 
256
 
257
  public function getStartYears() {
258
  return Stpp_Types::getStartYears();
@@ -289,11 +311,27 @@ class Securetrading_Stpp_Model_Integration extends Mage_Core_Model_Abstract {
289
  public function getCardExpiryDateLabel() {
290
  return $this->_getFrontendFields()->getLabel(Stpp_Fields_Frontend::FIELD_EXPIRY_DATE);
291
  }
292
-
293
  public function getCardExpiryDateDescription() {
294
  return $this->_getFrontendFields()->getDescription(Stpp_Fields_Frontend::FIELD_EXPIRY_DATE);
295
  }
296
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  public function getCardSecurityCodeLabel() {
298
  return $this->_getFrontendFields()->getLabel(Stpp_Fields_Frontend::FIELD_SECURITY_CODE);
299
  }
@@ -305,7 +343,15 @@ class Securetrading_Stpp_Model_Integration extends Mage_Core_Model_Abstract {
305
  public function getCardIssueNumberLabel() {
306
  return $this->_getFrontendFields()->getLabel(Stpp_Fields_Frontend::FIELD_ISSUE_NUMBER);
307
  }
308
-
 
 
 
 
 
 
 
 
309
  public function getCardIssueNumberDescription() {
310
  return $this->_getFrontendFields()->getDescription(Stpp_Fields_Frontend::FIELD_ISSUE_NUMBER);
311
  }
66
  'active_connection' => $paymentMethod->getConfigData('connection'),
67
  'use_3d_secure' => $paymentMethod->getConfigData('use_3d_secure'),
68
  'use_risk_decision' => $paymentMethod->getConfigData('use_risk_decision'),
69
+ 'use_account_check' => $paymentMethod->getConfigData('use_account_check'),
70
  'use_card_store' => $paymentMethod->getConfigData('use_card_store'),
71
+ //'use_risk_decision_after_auth' => $paymentMethod->getConfigData('delay_risk_decision'),
72
+ //'use_auto_card_store' => $paymentMethod->getConfigData('use_auto_card_store'),
73
  )
74
  ),
75
  'transactionsearch' => array(
82
  )
83
  );
84
  }
85
+
86
  $utilityFacade = Magento_Utility_Facade::instance($config); // Must be done before using any other parts of the STPP framework.
87
  $fieldFacade = Stpp_Fields_Facade::instance($config);
88
 
163
  return $this;
164
  }
165
 
166
+ public function runApiStandard(Mage_Sales_Model_Order_Payment $payment, $isMoto = false) {
167
+ $isMoto = $payment->getOrder()->getQuote()->getIsSuperMode();
168
+ $this->_setOrderToActionInstances($payment->getOrder());
169
+ $orderIncrementIds = Mage::getModel('core/session')->getOrderIds() ? Mage::getModel('core/session')->getOrderIds() : array($payment->getOrder()->getIncrementId()); //multishipping or onepage
170
+ $data = $this->getPaymentMethod()->prepareOrderData($payment, $orderIncrementIds);
171
+ $request = Stpp_Data_Request::instance()->setMultiple($data);
172
+ $saveCcDetails = $payment->getMethodInstance()->getSession()->getSaveCardDetails();
173
+ $useCardStore = $saveCcDetails && $payment->getMethodInstance()->getConfigData('use_card_store');
174
+ $this->_apiFacade->getConfig()->set('interfaces/api/use_card_store', $useCardStore);
175
+ return $this->_apiFacade->runApiStandard($request, $isMoto);
176
+ }
177
+
178
+ public function runApi3dAuth(array $data = array()) {
179
+ $request = new Stpp_Data_Request();
180
+ if (!empty($data)) {
181
+ $request->setMultiple($data);
182
+ }
183
+ $paymentMethod = $this->getPaymentMethod();
184
+ $saveCcDetails = $paymentMethod->getSession()->getSaveCardDetails();
185
+ $useCardStore = $saveCcDetails && $paymentMethod->getConfigData('use_card_store');
186
+ $this->_apiFacade->getConfig()->set('interfaces/api/use_card_store', $useCardStore);
187
+ return $this->_apiFacade->runApi3dAuth($request);
188
+ }
189
+
190
  public function runApiRefund(Mage_Sales_Model_Order_Payment $payment, array $data) {
191
  $this->_setOrderToActionInstances($payment->getOrder());
192
  $request = Stpp_Data_Request::instance()->setMultiple($data);
198
  return $this;
199
  }
200
 
201
+
202
+ public function runApiCardstore(array $data) {
203
+ return $this->_apiFacade->runApiRequests($data, array(Stpp_Types::API_CARDSTORE));
204
+ }
205
+
206
+ public function runPaymentPages(array $data, $isMoto = false) {
207
+ $request = Stpp_Data_Request::instance()->setMultiple($data);
208
+ $result = $this->_ppagesFacade->runPaymentPagesStandard($request, $isMoto);
209
+ Mage::getModel('securetrading_stpp/payment_redirect_request')->addRequest($this->getPaymentMethod()->getInfoInstance(), $result->getRequest());
 
 
 
210
 
 
 
 
 
211
 
212
  $transport = new Varien_Object();
213
  $transport->setRedirectIsPost($result->getRedirectIsPost());
271
  public function getThreedqueryName() {
272
  return Stpp_Types::API_THREEDQUERY;
273
  }
274
+
275
+ public function getSofortName() {
276
+ return Stpp_Types::CARD_SOFORT;
277
+ }
278
 
279
  public function getStartYears() {
280
  return Stpp_Types::getStartYears();
311
  public function getCardExpiryDateLabel() {
312
  return $this->_getFrontendFields()->getLabel(Stpp_Fields_Frontend::FIELD_EXPIRY_DATE);
313
  }
314
+
315
  public function getCardExpiryDateDescription() {
316
  return $this->_getFrontendFields()->getDescription(Stpp_Fields_Frontend::FIELD_EXPIRY_DATE);
317
  }
318
 
319
+ public function getCardExpiryMonthLabel() {
320
+ return $this->_getFrontendFields()->getLabel(Stpp_Fields_Frontend::FIELD_EXPIRY_MONTH);
321
+ }
322
+
323
+ public function getCardExpiryMonthDescription() {
324
+ return $this->_getFrontendFields()->getDescription(Stpp_Fields_Frontend::FIELD_EXPIRY_MONTH);
325
+ }
326
+
327
+ public function getCardExpiryYearLabel() {
328
+ return $this->_getFrontendFields()->getLabel(Stpp_Fields_Frontend::FIELD_EXPIRY_YEAR);
329
+ }
330
+
331
+ public function getCardExpiryYearDescription() {
332
+ return $this->_getFrontendFields()->getDescription(Stpp_Fields_Frontend::FIELD_EXPIRY_YEAR);
333
+ }
334
+
335
  public function getCardSecurityCodeLabel() {
336
  return $this->_getFrontendFields()->getLabel(Stpp_Fields_Frontend::FIELD_SECURITY_CODE);
337
  }
343
  public function getCardIssueNumberLabel() {
344
  return $this->_getFrontendFields()->getLabel(Stpp_Fields_Frontend::FIELD_ISSUE_NUMBER);
345
  }
346
+
347
+ public function getSaveCcDetailsLabel() {
348
+ return $this->_getFrontendFields()->getLabel(Stpp_Fields_Frontend::FIELD_SAVE_CARD_QUESTION);
349
+ }
350
+
351
+ public function getSaveCcDetailsDescription() {
352
+ return $this->_getFrontendFields()->getDescription(Stpp_Fields_Frontend::FIELD_SAVE_CARD_QUESTION);
353
+ }
354
+
355
  public function getCardIssueNumberDescription() {
356
  return $this->_getFrontendFields()->getDescription(Stpp_Fields_Frontend::FIELD_ISSUE_NUMBER);
357
  }
app/code/local/Securetrading/Stpp/Model/Observer.php CHANGED
@@ -1,6 +1,17 @@
1
  <?php
2
 
3
  class Securetrading_Stpp_Model_Observer {
 
 
 
 
 
 
 
 
 
 
 
4
  public function onCheckoutSubmitAllAfter(Varien_Event_Observer $observer) {
5
  $quote = $observer->getEvent()->getQuote();
6
  $methodInstance = $quote->getPayment()->getMethodInstance();
@@ -12,7 +23,7 @@ class Securetrading_Stpp_Model_Observer {
12
  $orderIncomplete = true;
13
  $methodInstance->log('Multishipping checkout.');
14
  }
15
- else {
16
  $orderIncomplete = (bool) $quote->getPayment()->getOrderPlaceRedirectUrl();
17
  $methodInstance->log(sprintf('One page checkout. Order incomplete: %s.', $orderIncomplete));
18
  }
@@ -30,6 +41,7 @@ class Securetrading_Stpp_Model_Observer {
30
  $observer->getEvent()->getOrder()->setCanSendNewEmailFlag(false)->save();
31
 
32
  $order = $observer->getEvent()->getOrder();
 
33
  $order->getPayment()->getMethodInstance()->setPaymentPlaceWithoutMakingApiRequest(true);
34
  }
35
 
@@ -55,7 +67,7 @@ class Securetrading_Stpp_Model_Observer {
55
  $value = $payment->getAdditionalInformation($key);
56
  $transport->setData($key, $value);
57
  }
58
-
59
  $transport->setData('payment_type', $payment->getCcType());
60
  $transport->setData('cc_last_4', $payment->getCcLast4());
61
  $transport->setData('expiry_month', $payment->getCcExpMonth());
@@ -88,4 +100,4 @@ class Securetrading_Stpp_Model_Observer {
88
  $observer->getConfig()->setNode('sections/securetrading_stpp/show_in_website', 0);
89
  $observer->getConfig()->setNode('sections/securetrading_stpp/show_in_store', 0);
90
  }
91
- }
1
  <?php
2
 
3
  class Securetrading_Stpp_Model_Observer {
4
+ public function onCheckoutTypeOnepageSaveOrderAfter(Varien_Event_Observer $observer) {
5
+ if ($observer->getEvent()->getOrder()->getPayment()->getMethodInstance()->getCode() !== Mage::getModel('securetrading_stpp/payment_direct')->getCode()) {
6
+ return;
7
+ }
8
+ $stBillingAgreementId = Mage::getSingleton('checkout/session')->getLastSecuretradingBillingAgreementId();
9
+ if ($stBillingAgreementId) {
10
+ Mage::getSingleton('checkout/session')->setLastBillingAgreementId($stBillingAgreementId);
11
+ Mage::getSingleton('checkout/session')->unsLastSecuretradingBillingAgreementId();
12
+ }
13
+ }
14
+
15
  public function onCheckoutSubmitAllAfter(Varien_Event_Observer $observer) {
16
  $quote = $observer->getEvent()->getQuote();
17
  $methodInstance = $quote->getPayment()->getMethodInstance();
23
  $orderIncomplete = true;
24
  $methodInstance->log('Multishipping checkout.');
25
  }
26
+ else { // onepage checkout
27
  $orderIncomplete = (bool) $quote->getPayment()->getOrderPlaceRedirectUrl();
28
  $methodInstance->log(sprintf('One page checkout. Order incomplete: %s.', $orderIncomplete));
29
  }
41
  $observer->getEvent()->getOrder()->setCanSendNewEmailFlag(false)->save();
42
 
43
  $order = $observer->getEvent()->getOrder();
44
+ $order->getPayment()->getMethodInstance()->setIsMultishipping(true);
45
  $order->getPayment()->getMethodInstance()->setPaymentPlaceWithoutMakingApiRequest(true);
46
  }
47
 
67
  $value = $payment->getAdditionalInformation($key);
68
  $transport->setData($key, $value);
69
  }
70
+
71
  $transport->setData('payment_type', $payment->getCcType());
72
  $transport->setData('cc_last_4', $payment->getCcLast4());
73
  $transport->setData('expiry_month', $payment->getCcExpMonth());
100
  $observer->getConfig()->setNode('sections/securetrading_stpp/show_in_website', 0);
101
  $observer->getConfig()->setNode('sections/securetrading_stpp/show_in_store', 0);
102
  }
103
+ }
app/code/local/Securetrading/Stpp/Model/Payment/Abstract.php CHANGED
@@ -5,11 +5,23 @@ abstract class Securetrading_Stpp_Model_Payment_Abstract extends Mage_Payment_Mo
5
  const STATUS_SUSPENDED = 'suspended';
6
  const STATUS_PENDING_PPAGES = 'pending_ppages';
7
  const STATUS_PENDING_3DSECURE = 'pending_3dsecure';
8
-
 
 
 
 
 
 
 
 
 
 
 
 
9
  final public function getIsSecuretradingPaymentMethod() {
10
  return true;
11
  }
12
-
13
  public function getIntegration() {
14
  return Mage::getModel('securetrading_stpp/integration', array('payment_method' => $this));
15
  }
@@ -27,7 +39,28 @@ abstract class Securetrading_Stpp_Model_Payment_Abstract extends Mage_Payment_Mo
27
  $this->getIntegration()->getDebugLog()->log($message);
28
  return $this;
29
  }
30
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  public function prepareOrderData(Mage_Sales_Model_Order_Payment $payment, array $orderIncrementIds, $sendEmailConfirmation = true) {
32
  $order = $payment->getOrder();
33
  $billingAddress = $order->getBillingAddress();
@@ -68,6 +101,9 @@ abstract class Securetrading_Stpp_Model_Payment_Abstract extends Mage_Payment_Mo
68
  'settleduedate' => $this->getConfigData('settle_due_date'),
69
  'settlestatus' => $this->getConfigData('payment_action') === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE ? 2 : $this->getConfigData('settle_status'),
70
  'orderreference' => $order->getIncrementId(),
 
 
 
71
  );
72
 
73
  if ($order->getShippingMethod()) {
@@ -91,38 +127,19 @@ abstract class Securetrading_Stpp_Model_Payment_Abstract extends Mage_Payment_Mo
91
  'customercounty' => $customerCounty,
92
  'customerpostcode' => $customerAddress->getPostcode(),
93
  'customercountryiso2a' => $customerAddress->getCountry(),
94
- );
95
  }
96
  return $data;
97
  }
98
-
99
- public function registerSuccessfulOrderAfterExternalRedirect(Mage_Sales_Model_Order $order, $requestedSettleStatus) {
100
- $this->log(sprintf('In %s.', __METHOD__));
101
 
102
- $amount = $order->getPayment()->getBaseAmountOrdered();
103
-
104
- if (in_array($requestedSettleStatus, array('0', '1', '100'))) {
105
- $order->getPayment()->registerCaptureNotification($amount, true);
106
- }
107
- elseif($requestedSettleStatus === '2') {
108
- $order->getPayment()->registerAuthorizationNotification($amount);
109
- }
110
- else {
111
- throw new Exception(sprintf('Invalid settle status: "%s".', $requestedSettleStatus));
112
- }
113
- $order->save();
114
  }
115
-
116
- public function handleSuccessfulPayment(Mage_Sales_Model_Order $order, $emailConfirmation) {
117
- $this->log(sprintf('In %s.', __METHOD__));
118
- $quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($order->getQuoteId());
119
-
120
- if ($quote->getIsActive()) {
121
- $quote->setIsActive(false)->save();
122
- }
123
-
124
- if ($emailConfirmation) {
125
- $order->sendNewOrderEmail()->save(); // Send last - even if notif times out order status updated etc. and payment information updated.
126
- }
127
  }
128
  }
5
  const STATUS_SUSPENDED = 'suspended';
6
  const STATUS_PENDING_PPAGES = 'pending_ppages';
7
  const STATUS_PENDING_3DSECURE = 'pending_3dsecure';
8
+ const STATUS_PENDING_SOFORT = 'pending_sofort';
9
+ const STATUS_PROCESSING_SOFORT = 'processing_sofort';
10
+
11
+ protected function _getBackendHandler($transactionReference) {
12
+ return Mage::getModel('securetrading_stpp/payment_handler_backend_factory', array('transaction_reference' => $transactionReference, 'method_instance' => $this))->getHandler();
13
+ }
14
+
15
+ protected function _captureAuthorized(Mage_Sales_Model_Order_Payment $payment, $amount) {
16
+ $this->log(sprintf('In %s.', __METHOD__));
17
+ $this->_getBackendHandler($payment->getCcTransId())->captureAuthorized($payment, $amount);
18
+ return $this;
19
+ }
20
+
21
  final public function getIsSecuretradingPaymentMethod() {
22
  return true;
23
  }
24
+
25
  public function getIntegration() {
26
  return Mage::getModel('securetrading_stpp/integration', array('payment_method' => $this));
27
  }
39
  $this->getIntegration()->getDebugLog()->log($message);
40
  return $this;
41
  }
42
+
43
+ public function refund(Varien_Object $payment, $amount) {
44
+ $this->log(sprintf('In %s.', __METHOD__));
45
+ parent::refund($payment, $amount);
46
+ $this->_getBackendHandler($payment->getCcTransId())->refund($payment, $amount);
47
+ return $this;
48
+ }
49
+
50
+ public function acceptPayment(Mage_Payment_Model_Info $payment) {
51
+ $this->log(sprintf('In %s.', __METHOD__));
52
+ parent::acceptPayment($payment);
53
+ $this->_getBackendHandler($payment->getCcTransId())->acceptPayment($payment);
54
+ return true;
55
+ }
56
+
57
+ public function denyPayment(Mage_Payment_Model_Info $payment) {
58
+ $this->log(sprintf('In %s.', __METHOD__));
59
+ parent::denyPayment($payment);
60
+ $this->_getBackendHandler($payment->getCcTransId())->denyPayment($payment);
61
+ return true;
62
+ }
63
+
64
  public function prepareOrderData(Mage_Sales_Model_Order_Payment $payment, array $orderIncrementIds, $sendEmailConfirmation = true) {
65
  $order = $payment->getOrder();
66
  $billingAddress = $order->getBillingAddress();
101
  'settleduedate' => $this->getConfigData('settle_due_date'),
102
  'settlestatus' => $this->getConfigData('payment_action') === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE ? 2 : $this->getConfigData('settle_status'),
103
  'orderreference' => $order->getIncrementId(),
104
+
105
+ 'customfield4' => $this->_getCartInformation(),
106
+ 'customfield5' => $this->_getVersionInformation(),
107
  );
108
 
109
  if ($order->getShippingMethod()) {
127
  'customercounty' => $customerCounty,
128
  'customerpostcode' => $customerAddress->getPostcode(),
129
  'customercountryiso2a' => $customerAddress->getCountry(),
130
+ );
131
  }
132
  return $data;
133
  }
 
 
 
134
 
135
+ protected function _getCartInformation() {
136
+ return 'MAGENTO';
 
 
 
 
 
 
 
 
 
 
137
  }
138
+
139
+ protected function _getVersionInformation() {
140
+ $stppVersion = (string) Mage::getConfig()->getModuleConfig('Securetrading_Stpp')->version;
141
+ $multishippingVersion = (string) Mage::getConfig()->getModuleConfig('Securetrading_Multishipping')->version;
142
+ $str = sprintf('Magento %s %s (Securetrading_Stpp-%s Securetrading_Multishipping-%s)', Mage::getEdition(), Mage::getVersion(), $stppVersion, $multishippingVersion);
143
+ return $str;
 
 
 
 
 
 
144
  }
145
  }
app/code/local/Securetrading/Stpp/Model/Payment/Direct.php CHANGED
@@ -1,415 +1,27 @@
1
  <?php
2
 
3
- class Securetrading_Stpp_Model_Payment_Direct extends Securetrading_Stpp_Model_Payment_Abstract {
4
  protected $_code = 'securetrading_stpp_direct';
5
  protected $_formBlockType = 'securetrading_stpp/payment_direct_form';
6
  protected $_infoBlockType = 'securetrading_stpp/payment_direct_info';
7
-
8
- protected $_isGateway = false;
9
- protected $_canOrder = false;
10
- protected $_canAuthorize = true;
11
- protected $_canCapture = true;
12
- protected $_canCapturePartial = true;
13
- protected $_canRefund = true;
14
- protected $_canRefundInvoicePartial = true;
15
- protected $_canVoid = false;
16
- protected $_canUseInternal = true;
17
- protected $_canUseCheckout = true;
18
- protected $_canUseForMultishipping = true;
19
- protected $_isInitializeNeeded = true;
20
- protected $_canFetchTransactionInfo = false;
21
- protected $_canReviewPayment = true;
22
- protected $_canCreateBillingAgreement = false;
23
- protected $_canManageRecurringProfiles = false;
24
-
25
- protected $_stateObject;
26
- protected static $_reviewingIncrementIds = array();
27
-
28
- const MULTISHIPPING_STATE_OBJECT_REGISTRY_KEY = 'securetrading_stpp_payment_direct_multishipping_state_object_registry_key';
29
 
30
- public function setStateObject(Varien_Object $stateObject) {
31
- $this->_stateObject = $stateObject;
32
- return $this;
33
- }
34
-
35
- protected function _getStateObject($graceful = false) {
36
- if ($this->_stateObject === null) {
37
- if ($graceful) {
38
- return false;
39
- }
40
- throw new Exception(Mage::helper('securetrading_stpp')->__('The state object has not been set.'));
41
- }
42
- return $this->_stateObject;
43
- }
44
-
45
- protected function _setReadyForAcsUrlRedirect($bool) {
46
- $this->_getStateObject()->setReadyForAcsRedirect((bool)$bool);
47
- return $this;
48
- }
49
- protected function _getReadyForAcsUrlRedirect() {
50
- $stateObject = $this->_getStateObject(true); // Because processInvoice() is called when capturing a pending invoice.
51
- if ($stateObject) {
52
- return (bool) $stateObject->getReadyForAcsRedirect();
53
- }
54
- return false;
55
- }
56
-
57
- protected function _getFirstMultishippingStateObject() {
58
- return Mage::registry(Securetrading_Stpp_Model_Payment_Direct::MULTISHIPPING_STATE_OBJECT_REGISTRY_KEY);
59
- }
60
-
61
- protected function _setFirstMultishippingStateObject(Varien_Object $stateObject) {
62
- Mage::register(Securetrading_Stpp_Model_Payment_Direct::MULTISHIPPING_STATE_OBJECT_REGISTRY_KEY, $stateObject);
63
- return $this;
64
- }
65
 
66
- public function initialize($action, $stateObject) {
67
- if ($this->getPaymentPlaceWithoutMakingApiRequest()) {
68
- return $this;
69
- }
70
- else if ($this->getIsMultishipping()) {
71
- if ($this->getIsFirstMultishipping()) {
72
- $this->_setFirstMultishippingStateObject($stateObject);
73
- }
74
- else {
75
- $stateObject->setData($this->_getFirstMultishippingStateObject()->getData());
76
- }
77
- }
78
-
79
- $this->setStateObject($stateObject);
80
  $payment = $this->getInfoInstance();
81
- $order = $payment->getOrder();
82
-
83
- switch ($action) {
84
- case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE:
85
- $payment->authorize(true, $order->getBaseTotalDue()); // base amount will be set inside
86
- $payment->setAmountAuthorized($order->getTotalDue());
87
- break;
88
- case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE:
89
- $payment->setAmountAuthorized($order->getTotalDue());
90
- $payment->setBaseAmountAuthorized($order->getBaseTotalDue());
91
- $payment->capture(null);
92
- break;
93
- default:
94
- throw new Exception(sprintf(Mage::helper('securetrading_stpp')->__('Invalid payment action: "%s".'), $action));
95
- }
96
- }
97
-
98
- public function processInvoice($invoice, $payment) {
99
- if ($this->_getReadyForAcsUrlRedirect()) {
100
- foreach($this->getInfoInstance()->getOrder()->getStatusHistoryCollection(true) as $c) {
101
- $c->delete();
102
- }
103
- $invoice->setIsPaid(false);
104
- }
105
- }
106
-
107
- public function authorize(Varien_Object $payment, $amount) {
108
- if ($this->getIsMultishipping() && !$this->getIsFirstMultishipping()) {
109
- return $this;
110
- }
111
- $this->log(sprintf('In %s.', __METHOD__));
112
- parent::authorize($payment, $amount);
113
- $result = $this->getIntegration()->runApiStandard($payment);
114
- $this->_handleStandardPaymentResult($result);
115
- return $this;
116
- }
117
-
118
- public function capture(Varien_Object $payment, $amount) {
119
- if ($this->getIsMultishipping() && !$this->getIsFirstMultishipping()) {
120
- return $this;
121
- }
122
- $this->log(sprintf('In %s.', __METHOD__));
123
- parent::capture($payment, $amount);
124
-
125
- if ($payment->lookupTransaction('', Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH)) {
126
- $this->captureAuthorized($payment, $amount);
127
- }
128
- else {
129
- $this->_authAndCapture($payment);
130
- }
131
- return $this;
132
- }
133
-
134
- protected function _paymentHasSuccessfulRefund(Mage_Sales_Model_Order_Payment $payment) {
135
- $refundTransaction = $payment->lookupTransaction('', Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
136
- if ($refundTransaction) {
137
- $securetradingRefundTransaction = Mage::getModel('securetrading_stpp/transaction')->loadByTransactionReference($refundTransaction->getTxnId(), true);
138
- if ($securetradingRefundTransaction && $securetradingRefundTransaction->getRequestType() === Securetrading_Stpp_Model_Transaction_Types::TYPE_REFUND) {
139
- return true;
140
- }
141
- }
142
- return false;
143
- }
144
-
145
- public function prepareToRefund(Varien_Object $payment, $amount, $siteReference) {
146
- $transactionReference = $payment->getCcTransId();
147
- $orderIncrementIds = $this->_getOrderIncrementIds($transactionReference);
148
-
149
- if ($orderIncrementIds) {
150
- $partialRefundAlreadyProcessed = null;
151
- $orderBaseGrandTotal = null;
152
- $baseTotalPaid = null;
153
- $baseTotalRefunded = null;
154
-
155
- foreach($orderIncrementIds as $orderIncrementId) {
156
- $tempPayment = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId)->getPayment();
157
-
158
- if ($partialRefundAlreadyProcessed !== true) {
159
- $partialRefundAlreadyProcessed = $this->_paymentHasSuccessfulRefund($tempPayment);
160
- }
161
-
162
- $orderBaseGrandTotal += $tempPayment->getOrder()->getBaseGrandTotal();
163
- $baseTotalPaid += $tempPayment->getOrder()->getBaseTotalPaid();
164
- $baseTotalRefunded += $tempPayment->getOrder()->getBaseTotalRefunded();
165
- }
166
- }
167
- else {
168
- $partialRefundAlreadyProcessed = $this->_paymentHasSuccessfulRefund($payment);
169
- $orderBaseGrandTotal = $payment->getOrder()->getBaseGrandTotal();
170
- $baseTotalPaid = $payment->getOrder()->getBaseTotalPaid();
171
- $baseTotalRefunded = $payment->getOrder()->getBaseTotalRefunded() - $amount; // Before this method is called this happens: $payment->getOrder->setBaseTotalRefunded($payment->getOrder()->getBaseTotalRefunded() - $amount). That's why we subtract the $amount here - but don't for multishipping above (because we load new temporary orders when multishipping is being calculated.
172
- }
173
-
174
- $data = array(
175
- 'original_order_total'=> $orderBaseGrandTotal, // Total of original AUTH.
176
- 'order_total_paid'=> $baseTotalPaid, // How much has been captured from the AUTH (do not consider how much has been refunded via TU or REFUND).
177
- 'order_total_refunded'=> $baseTotalRefunded, // How much has been refunded via TU or REFUND.
178
- 'amount_to_refund'=> $amount,
179
- 'partial_refund_already_processed' => $partialRefundAlreadyProcessed,
180
- 'site_reference' => $siteReference,
181
- 'transaction_reference' => $transactionReference,
182
- 'using_main_amount'=> true,
183
- 'currency_iso_3a'=> $payment->getOrder()->getBaseCurrencyCode(),
184
- 'allow_suspend'=> true,
185
- );
186
-
187
- $payment->setShouldCloseParentTransaction(false);
188
- return $data;
189
- }
190
-
191
- public function refund(Varien_Object $payment, $amount) {
192
- $data = $this->prepareToRefund($payment, $amount, $this->getConfigData('site_reference'));
193
- $this->getIntegration()->runApiRefund($payment, $data);
194
- return $this;
195
- }
196
-
197
- public function cancel(Varien_Object $payment) {
198
- return $this; // Do nothing intentionally.
199
- }
200
-
201
- public function denyPaymentAndPrepareApiRequest(Mage_Payment_Model_Info $payment, $siteReference) {
202
- parent::denyPayment($payment);
203
- $data = null;
204
-
205
- if (!empty(self::$_reviewingIncrementIds)) {
206
- $payment->setShouldCloseParentTransaction(true);
207
- $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID);
208
- }
209
- else {
210
- if ($payment->getOrder()->getState() !== Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW) {
211
- throw new Mage_Core_Exception('This order is no longer in the payment review state.');
212
- }
213
-
214
- $transactionReference = $payment->getCcTransId();
215
- $orderIncrementIds = $this->_getOrderIncrementIds($transactionReference);
216
-
217
- if ($orderIncrementIds) {
218
- self::$_reviewingIncrementIds = $orderIncrementIds;
219
- foreach($orderIncrementIds as $orderIncrementId) {
220
- $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
221
- $order->getPayment()->deny();
222
- $order->save();
223
- }
224
- self::$_reviewingIncrementIds = array();
225
- }
226
- else {
227
- $payment->setShouldCloseParentTransaction(true);
228
- $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID);
229
- }
230
- $data = $this->_prepareToUpdateSettleStatus($payment, '3', $siteReference);
231
- }
232
- return $data;
233
- }
234
-
235
- public function acceptPaymentAndPrepareApiRequest(Mage_Payment_Model_Info $payment, $siteReference) {
236
- parent::acceptPayment($payment);
237
- $data = null;
238
-
239
- if (empty(self::$_reviewingIncrementIds)) {
240
- if ($payment->getOrder()->getState() !== Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW) {
241
- throw new Mage_Core_Exception('This order is no longer in the payment review state.');
242
- }
243
-
244
- $transactionReference = $payment->getCcTransId();
245
- $orderIncrementIds = $this->_getOrderIncrementIds($transactionReference);
246
-
247
- if ($orderIncrementIds) {
248
- self::$_reviewingIncrementIds = $orderIncrementIds;
249
- foreach($orderIncrementIds as $orderIncrementId) {
250
- $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
251
- $order->getPayment()->accept();
252
- $order->save();
253
- }
254
- self::$_reviewingIncrementIds = array();
255
- }
256
-
257
- $transaction = Mage::getModel('securetrading_stpp/transaction')->loadByTransactionReference($payment->getCcTransId());
258
- $requestedSettleStatus = $transaction->getRequestData('settlestatus');
259
-
260
- if ($requestedSettleStatus === null) { // Will be null if the $transaction was a 3D AUTH (which has MD/PaRes instead).
261
- if (!$parentTransaction = $transaction->getParentTransaction(true)) {
262
- throw new Exception(sprintf(Mage::helper('securetrading_stpp')->__('Payment "%s" had transaction reference "%s" but had no settle status and no parent transaction reference.'), $payment->getId(), $payment->getCcTransId()));
263
- }
264
- if ($parentTransaction->getRequestData('requesttypedescription') !== $this->getIntegration()->getThreedqueryName()) {
265
- throw new Exception(sprintf(Mage::helper('securetrading_stpp')->__('Payment "%s" had transaction reference "%s" but had no settle status and no parent THREEDQUERY.'), $payment->getId(), $payment->getCcTransId()));
266
- }
267
- if ($parentTransaction->getRequestData('settlestatus') === null) {
268
- throw new Exception(sprintf(Mage::helper('securetrading_stpp')->__('Payment "%s" had transaction reference "%s" but had no settle status and its parent THREEDQUERY had no settle status.'), $payment->getId(), $payment->getCcTransId()));
269
- }
270
- $requestedSettleStatus = $parentTransaction->getRequestData('settlestatus');
271
- }
272
-
273
- if ($requestedSettleStatus !== 2) { // If the requested settlestatus was 2 there is no need to update the payment (an order should only be put into payment review when the response settlestatus == 2).
274
- $data = $this->_prepareToUpdateSettleStatus($payment, $requestedSettleStatus, $siteReference);
275
- }
276
- }
277
- return $data;
278
  }
279
-
280
- public function acceptPayment(Mage_Payment_Model_Info $payment) {
281
- $data = $this->acceptPaymentAndPrepareApiRequest($payment, $this->getConfigData('site_reference'));
282
- if ($data) {
283
- $this->getIntegration()->runApiTransactionUpdate($payment, $data);
284
- }
285
- return true;
286
- }
287
-
288
- public function denyPayment(Mage_Payment_Model_Info $payment) {
289
- $data = $this->denyPaymentAndPrepareApiRequest($payment, $this->getConfigData('site_reference'));
290
- if ($data) {
291
- $this->getIntegration()->runApiTransactionUpdate($payment, $data);
292
- }
293
- return true;
294
- }
295
-
296
- protected function _getOrderIncrementIds($transactionReference) {
297
- $transaction = Mage::getModel('securetrading_stpp/transaction')->loadByTransactionReference($transactionReference);
298
- $orderId = $transaction->getOrderId();
299
- $factory = Mage::getModel('securetrading_multishipping/order_set_factory');
300
-
301
- if ($factory->orderBelongsToAnySet($orderId)) {
302
- $orderIds = $factory->getOrderIdsInSameSet($orderId, false);
303
- $orderIncrementIds = array();
304
- foreach($orderIds as $orderId) {
305
- $orderIncrementIds[] = Mage::getModel('sales/order')->load($orderId)->getIncrementId();
306
- }
307
- return $orderIncrementIds;
308
- }
309
- return null;
310
- }
311
-
312
- public function prepareToCaptureAuthorized(Mage_Sales_Model_Order_Payment $payment, $amount, $siteReference) {
313
- $transactionReference = $payment->getCcTransId();
314
- $orderIncrementIds = $this->_getOrderIncrementIds($transactionReference);
315
 
316
- if ($orderIncrementIds) {
317
- $orderBaseGrandTotal = null;
318
- $baseAmountPaid = null;
319
- $baseAmountRefunded = null;
320
- foreach($orderIncrementIds as $orderIncrementId) {
321
- $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
322
- $orderBaseGrandTotal += $order->getBaseGrandTotal();
323
- $baseAmountPaid += $order->getPayment()->getBaseAmountPaid();
324
- $baseAmountRefunded += $order->getPayment()->getBaseAmountRefunded();
325
- }
326
- $orderBaseGrandTotal = (string) Mage::app()->getStore()->roundPrice($orderBaseGrandTotal);
327
- $baseAmountPaid = (string) Mage::app()->getStore()->roundPrice($baseAmountPaid);
328
- $baseAmountRefunded = (string) Mage::app()->getStore()->roundPrice($baseAmountRefunded);
329
- }
330
- else {
331
- $orderBaseGrandTotal = (string) Mage::app()->getStore()->roundPrice($payment->getOrder()->getBaseGrandTotal());
332
- $baseAmountPaid = (string) Mage::app()->getStore()->roundPrice($payment->getBaseAmountPaid());
333
- $baseAmountRefunded = (string) Mage::app()->getStore()->roundPrice($payment->getBaseAmountRefunded());
334
- }
335
- $amountToCapture = (string) $amount;
336
- $updates = array('settlestatus' => '0');
337
-
338
- if ($amountToCapture !== $orderBaseGrandTotal) {
339
- $updates['settlemainamount'] = ($baseAmountPaid + $amountToCapture) - $baseAmountRefunded;
340
- $updates['currencyiso3a'] = $payment->getOrder()->getBaseCurrencyCode();
341
- }
342
-
343
- $data = $this->_prepareTransactionUpdate($payment, $updates, $siteReference);
344
- return $data;
345
- }
346
-
347
- public function captureAuthorized(Mage_Sales_Model_Order_Payment $payment, $amount) {
348
- $data = $this->prepareToCaptureAuthorized($payment, $amount, $this->getConfigData('site_reference'));
349
- $this->getIntegration()->runApiTransactionUpdate($payment, $data);
350
- return $this;
351
- }
352
-
353
- protected function _handleStandardPaymentResult(Stpp_Api_ResultInterface $result) {
354
- $this->log(sprintf('In %s.', __METHOD__));
355
- if ($result->getRedirectRequired()) {
356
- $this->_setReadyForAcsUrlRedirect(true);
357
- $this->_getStateObject()->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT)->setStatus(Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_3DSECURE);
358
-
359
- $redirectPath = $this->getConfigData('api_use_iframe') ? 'securetrading/direct_post/iframe' : 'securetrading/direct_post/container';
360
- $params = new Varien_Object();
361
- $params
362
- ->setOrderPlaceRedirectUrl(Mage::getUrl($redirectPath))
363
- ->setRedirectIsPost($result->getRedirectIsPost())
364
- ->setRedirectUrl($result->getRedirectUrl())
365
- ->setRedirectData($result->getRedirectData())
366
- ;
367
- Mage::getSingleton('securetrading_stpp/payment_direct_session')->setAcsRedirectParams($params);
368
- }
369
- elseif(!$result->getIsTransactionSuccessful()) {
370
- throw new Mage_Payment_Model_Info_Exception($result->getErrorMessage());
371
- }
372
- else {
373
- $this->_getStateObject()->setState(Mage_Sales_Model_Order::STATE_PROCESSING)->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
374
- }
375
- return $this;
376
- }
377
-
378
- protected function _prepareToUpdateSettleStatus(Mage_Payment_Model_Info $payment, $settleStatus, $siteReference) {
379
- $updates = array('settlestatus' => $settleStatus);
380
- $data = $this->_prepareTransactionUpdate($payment, $updates, $siteReference);
381
- return $data;
382
- }
383
-
384
- protected function _prepareTransactionUpdate(Mage_Sales_Model_Order_Payment $payment, $updates, $siteReference) {
385
- $data = array(
386
- 'filter' => array(
387
- 'sitereference' => $siteReference,
388
- 'transactionreference' => $payment->getCcTransId(),
389
- ),
390
- 'updates' => $updates
391
- );
392
- return $data;
393
- }
394
-
395
- protected function _authAndCapture(Mage_Sales_Model_Order_Payment $payment) {
396
- $result = $this->getIntegration()->runApiStandard($payment);
397
- $this->_handleStandardPaymentResult($result);
398
- return $this;
399
- }
400
-
401
- public function getOrderPlaceRedirectUrl() {
402
- $session = Mage::getSingleton('securetrading_stpp/payment_direct_session');
403
- $acsParamsExist = $session->hasAcsRedirectParams();
404
-
405
- $this->log(sprintf('In %s. ACS Params exist: %s.', __METHOD__, $acsParamsExist));
406
-
407
- if ($acsParamsExist) {
408
- return $session->getAcsRedirectParams()->getOrderPlaceRedirectUrl();
409
- }
410
- return null;
411
- }
412
-
413
  public function assignData($data) {
414
  $payment = $this->getInfoInstance();
415
  $payment->setCcType($data->getSecuretradingStppPaymentType());
@@ -420,48 +32,72 @@ class Securetrading_Stpp_Model_Payment_Direct extends Securetrading_Stpp_Model_P
420
  $payment->setCcSsStartMonth($data->getSecuretradingStppStartDateMonth());
421
  $payment->setCcSsStartYear($data->getSecuretradingStppStartDateYear());
422
  $payment->setCcSsIssue($data->getSecuretradingStppIssueNumber());
423
- Mage::getModel('securetrading_stpp/payment_direct_session')->setSecurityCode($payment->encrypt($data->getSecuretradingStppSecurityCode())); // Cannot save CC CID due to PCI requirements.
 
424
  return $this;
425
  }
426
-
427
  public function prepareOrderData(Mage_Sales_Model_Order_Payment $payment, array $orderIncrementIds = array(), $sendEmailConfirmation = true) {
428
- $data = parent::prepareOrderData($payment, $orderIncrementIds);
429
- $payment = $this->getInfoInstance();
430
-
431
  $data += array(
432
  'termurl' => Mage::getUrl('securetrading/direct/return'),
433
  'paymenttype' => $payment->getCcType(),
434
  'pan' => $payment->decrypt($payment->getCcNumberEnc()),
435
  'expirydate' => sprintf('%02s', $payment->getCcExpMonth()) . '/' . $payment->getCcExpYear(),
436
- 'securitycode' => $payment->decrypt(Mage::getModel('securetrading_stpp/payment_direct_session')->getSecurityCode()),
437
  'issuenumber' => $payment->getCcSsIssue(),
438
- );
439
-
440
  if ($payment->getCcSsStartMonth() && $payment->getCcSsStartYear()) {
441
- $data['startdate'] = $payment->getCcSsStartMonth() . '/' . $payment->getCcSsStartYear();
442
  }
443
  return $data;
444
  }
 
 
 
 
 
 
 
 
 
445
 
446
- public function run3dAuth() {
447
- $this->log(sprintf('In %s.', __METHOD__));
448
- if (Mage::getModel('checkout/session')->getQuote()->getIsMultiShipping()) {
449
- $orderIncrementIds = Mage::getModel('core/session')->getOrderIds();
450
- $orders = array();
451
- foreach($orderIncrementIds as $orderId => $orderIncrementId) {
452
- $orders[] = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
453
- }
454
- Mage::register(Securetrading_Stpp_Model_Actions_Direct::MULTISHIPPING_ORDERS_REGISTRY_KEY, $orders);
455
  }
456
- $result = $this->getIntegration()->runApi3dAuth();
457
- if ($result->getErrorMessage()) {
458
- Mage::getSingleton('checkout/session')->addError($result->getErrorMessage());
 
 
459
  }
460
- return $result->getIsTransactionSuccessful();
 
 
 
461
  }
462
-
463
- public function handleSuccessfulPayment(Mage_Sales_Model_Order $order, $emailConfirmation = true) {
464
- parent::handleSuccessfulPayment($order, $emailConfirmation);
465
- Mage::getSingleton('securetrading_stpp/payment_direct_session')->clear();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
466
  }
467
  }
1
  <?php
2
 
3
+ class Securetrading_Stpp_Model_Payment_Direct extends Securetrading_Stpp_Model_Payment_Direct_Abstract implements Mage_Payment_Model_Billing_Agreement_MethodInterface {
4
  protected $_code = 'securetrading_stpp_direct';
5
  protected $_formBlockType = 'securetrading_stpp/payment_direct_form';
6
  protected $_infoBlockType = 'securetrading_stpp/payment_direct_info';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
+ protected $_canCreateBillingAgreement = true;
9
+
10
+ protected $_sessionModelType = 'securetrading_stpp/payment_direct_session';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
+ protected function _get3dAuthData() {
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  $payment = $this->getInfoInstance();
14
+ $array = array(
15
+ 'paymenttype' => $payment->getCcType(),
16
+ 'pan' => $payment->decrypt($payment->getCcNumberEnc()),
17
+ 'expirydate' => sprintf('%2s', $payment->getCcExpMonth()) . '/' . $payment->getCcExpYear(),
18
+ 'securitycode' => $payment->decrypt($this->getSession()->getSecurityCode()),
19
+ 'issuenumber' => $payment->getCcSsIssue(),
20
+ 'sitereference' => $this->getConfigData("site_reference"),
21
+ );
22
+ return $array;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  public function assignData($data) {
26
  $payment = $this->getInfoInstance();
27
  $payment->setCcType($data->getSecuretradingStppPaymentType());
32
  $payment->setCcSsStartMonth($data->getSecuretradingStppStartDateMonth());
33
  $payment->setCcSsStartYear($data->getSecuretradingStppStartDateYear());
34
  $payment->setCcSsIssue($data->getSecuretradingStppIssueNumber());
35
+ $this->getSession()->setSecurityCode($payment->encrypt($data->getSecuretradingStppSecurityCode())); // Cannot save CC CID due to PCI requirements.
36
+ $this->getSession()->setSaveCardDetails($data->getSecuretradingStppSaveCc());
37
  return $this;
38
  }
39
+
40
  public function prepareOrderData(Mage_Sales_Model_Order_Payment $payment, array $orderIncrementIds = array(), $sendEmailConfirmation = true) {
41
+ $data = parent::prepareOrderData($payment, $orderIncrementIds);
 
 
42
  $data += array(
43
  'termurl' => Mage::getUrl('securetrading/direct/return'),
44
  'paymenttype' => $payment->getCcType(),
45
  'pan' => $payment->decrypt($payment->getCcNumberEnc()),
46
  'expirydate' => sprintf('%02s', $payment->getCcExpMonth()) . '/' . $payment->getCcExpYear(),
47
+ 'securitycode' => $payment->decrypt($this->getSession()->getSecurityCode()),
48
  'issuenumber' => $payment->getCcSsIssue(),
49
+ );
 
50
  if ($payment->getCcSsStartMonth() && $payment->getCcSsStartYear()) {
51
+ $data['startdate'] = sprintf('%02s', $payment->getCcSsStartMonth()) . '/' . $payment->getCcSsStartYear();
52
  }
53
  return $data;
54
  }
55
+
56
+ public function runCardstore($paymentType, $startMonth, $startYear, $expiryMonth, $expiryYear, $cardNumber, $issueNumber) {
57
+ $data = array(
58
+ 'sitereference' => $this->getConfigData('site_reference'),
59
+ 'paymenttype' => $paymentType,
60
+ 'pan' => $cardNumber,
61
+ 'issuenumber' => $issueNumber,
62
+ 'expirydate' => sprintf('%02s', $expiryMonth) . '/' . $expiryYear,
63
+ );
64
 
65
+ if ($startMonth && $startYear) {
66
+ $data['startdate'] = sprintf('%02s', $startMonth) . '/' . $startYear;
 
 
 
 
 
 
 
67
  }
68
+
69
+ $result = $this->getIntegration()->runApiCardstore($data);
70
+
71
+ if ($result->getIsTransactionSuccessful()) {
72
+ $agreement = Mage::getModel('sales/billing_agreement')->load(Mage::getSingleton('customer/session')->getLastBillingAgreementId());
73
  }
74
+ else {
75
+ throw new Exception($result->getErrorMessage());
76
+ }
77
+ return $agreement;
78
  }
79
+
80
+ public function prepareCardstoreLabel($maskedPan, $paymentType, $expiryDate) {
81
+ $maskedUntilLast4 = Mage::helper('securetrading_stpp')->maskUntilCcLast4($maskedPan);
82
+ return sprintf('%s (%s, %s)', $maskedUntilLast4, $this->getIntegration()->getCardString($paymentType), $expiryDate);
83
+ }
84
+
85
+ public function updateBillingAgreementStatus(Mage_Payment_Model_Billing_AgreementAbstract $agreement) {
86
+ return $this;
87
+ }
88
+
89
+ public function initBillingAgreementToken(Mage_Payment_Model_Billing_AgreementAbstract $agreement) {
90
+ $agreement->setRedirectUrl(Mage::getUrl('securetrading_stpp/tokenization/new'));
91
+ return $this;
92
+ }
93
+
94
+ // Function not used.
95
+ public function getBillingAgreementTokenInfo(Mage_Payment_Model_Billing_AgreementAbstract $agreement) {
96
+ return $this;
97
+ }
98
+
99
+ // Function not used.
100
+ public function placeBillingAgreement(Mage_Payment_Model_Billing_AgreementAbstract $agreement) {
101
+ return $this;
102
  }
103
  }
app/code/local/Securetrading/Stpp/Model/Payment/Direct/Abstract.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Securetrading_Stpp_Model_Payment_Direct_Abstract extends Securetrading_Stpp_Model_Payment_Abstract {
4
+ protected $_isGateway = false;
5
+ protected $_canOrder = false;
6
+ protected $_canAuthorize = true;
7
+ protected $_canCapture = true;
8
+ protected $_canCapturePartial = true;
9
+ protected $_canRefund = true;
10
+ protected $_canRefundInvoicePartial = true;
11
+ protected $_canVoid = false;
12
+ protected $_canUseInternal = true;
13
+ protected $_canUseCheckout = true;
14
+ protected $_canUseForMultishipping = true;
15
+ protected $_isInitializeNeeded = true;
16
+ protected $_canFetchTransactionInfo = false;
17
+ protected $_canReviewPayment = true;
18
+ protected $_canCreateBillingAgreement = false;
19
+ protected $_canManageRecurringProfiles = false;
20
+
21
+ protected $_frontendHandler;
22
+ protected $_sessionModelType = '';
23
+
24
+ abstract protected function _get3dAuthData();
25
+
26
+ protected function _getFrontendHandler() {
27
+ if (!$this->_frontendHandler) {
28
+ $this->_frontendHandler = Mage::getModel('securetrading_stpp/payment_handler_frontend_factory', array('integration' => $this->getIntegration()))->getHandler($this);
29
+ }
30
+ return $this->_frontendHandler;
31
+ }
32
+
33
+ public function getSession() {
34
+ return Mage::getSingleton($this->_sessionModelType);
35
+ }
36
+
37
+ public function initialize($action, $stateObject) {
38
+ $this->log(sprintf('In %s.', __METHOD__));
39
+ $this->_getFrontendHandler()->initialize($this->getInfoInstance(), $action, $stateObject);
40
+ }
41
+
42
+ public function processInvoice($invoice, $payment) {
43
+ $this->log(sprintf('In %s.', __METHOD__));
44
+ $this->_getFrontendHandler()->processInvoice($invoice, $payment);
45
+ return $this;
46
+ }
47
+
48
+ public function authorize(Varien_Object $payment, $amount) {
49
+ $this->log(sprintf('In %s.', __METHOD__));
50
+ parent::authorize($payment, $amount);
51
+ $this->_getFrontendHandler()->authorize($payment);
52
+ return $this;
53
+ }
54
+
55
+ public function capture(Varien_Object $payment, $amount) {
56
+ $this->log(sprintf('In %s.', __METHOD__));
57
+ parent::capture($payment, $amount);
58
+ if ($payment->lookupTransaction('', Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH)) {
59
+ $this->_captureAuthorized($payment, $amount);
60
+ }
61
+ else {
62
+ $this->_getFrontendHandler()->capture($payment, $amount);
63
+ }
64
+ return $this;
65
+ }
66
+
67
+ public function run3dAuth() {
68
+ $this->log(sprintf('In %s.', __METHOD__));
69
+ $data = $this->_get3dAuthData();
70
+ $result = $this->_getFrontendHandler()->run3dAuth($data);
71
+ return $result;
72
+ }
73
+
74
+ public function getOrderPlaceRedirectUrl() {
75
+ $this->log(sprintf('In %s.', __METHOD__));
76
+ return $this->_getFrontendHandler()->getOrderPlaceRedirectUrl();
77
+ }
78
+
79
+ public function cancel(Varien_Object $payment) {
80
+ $this->log(sprintf('In %s.', __METHOD__));
81
+ return $this; // Do nothing intentionally.
82
+ }
83
+ }
app/code/local/Securetrading/Stpp/Model/Payment/Handler/Backend/Abstract.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Securetrading_Stpp_Model_Payment_Handler_Backend_Abstract extends Varien_Object {
4
+ abstract protected function _prepareRefund(Mage_Sales_Model_Order_Payment $payment, $amount);
5
+
6
+ abstract protected function _prepareToCaptureAuthorized(Mage_Sales_Model_Order_Payment $payment);
7
+
8
+ abstract protected function _canAcceptPayment(Mage_Payment_Model_Info $payment);
9
+
10
+ abstract protected function _afterAcceptPayment(Mage_Payment_Model_Info $payment);
11
+
12
+ abstract protected function _canDenyPayment(Mage_Payment_Model_Info $payment);
13
+
14
+ abstract protected function _beforeDenyPayment(Mage_Payment_Model_Info $payment);
15
+
16
+ abstract protected function _afterDenyPayment(Mage_Payment_Model_Info $payment);
17
+
18
+ protected function _validateKeysExist(array $keys, array $data, $graceful = false) {
19
+ foreach($keys as $key) {
20
+ if (!array_key_exists($key, $data)) {
21
+ if ($graceful) {
22
+ return false;
23
+ }
24
+ throw new Exception(sprintf(Mage::helper('securetrading_stpp')->__('The key "%s" does not exist.'), $key));
25
+ }
26
+ }
27
+ return true;
28
+ }
29
+
30
+ public function refund(Mage_Sales_Model_Order_payment $payment, $amount) {
31
+ $data = $this->_prepareRefund($payment, $amount);
32
+ $this->_validateKeysExist(array('partial_refund_already_processed', 'order_base_grand_total', 'base_total_paid', 'base_total_refunded'), $data);
33
+
34
+ $fullData = array(
35
+ 'original_order_total'=> $data['order_base_grand_total'], // Total of original AUTH.
36
+ 'order_total_paid'=> $data['base_total_paid'], // How much has been captured from the AUTH (do not consider how much has been refunded via TU or REFUND).
37
+ 'order_total_refunded'=> $data['base_total_refunded'], // How much has been refunded via TU or REFUND.
38
+ 'amount_to_refund'=> $amount,
39
+ 'partial_refund_already_processed' => $data['partial_refund_already_processed'],
40
+ 'site_reference' => $payment->getMethodInstance()->getConfigData('site_reference'),
41
+ 'transaction_reference' => $this->getTransactionReference(),
42
+ 'using_main_amount'=> true,
43
+ 'currency_iso_3a'=> $payment->getOrder()->getBaseCurrencyCode(),
44
+ 'allow_suspend'=> true,
45
+ );
46
+ $payment->setShouldCloseParentTransaction(false);
47
+ $this->getIntegration()->runApiRefund($payment, $fullData);
48
+ }
49
+
50
+ public function captureAuthorized(Mage_Sales_Model_Order_Payment $payment, $amount) {
51
+ $data = $this->_prepareToCaptureAuthorized($payment);
52
+ $this->_validateKeysExist(array('order_base_grand_total', 'base_amount_paid', 'base_amount_refunded'), $data);
53
+
54
+ $amountToCapture = (string) $amount;
55
+ $updates = array('settlestatus' => '0');
56
+
57
+ if ($amountToCapture !== $data['order_base_grand_total']) {
58
+ $updates['settlemainamount'] = ($data['base_amount_paid'] + $amountToCapture) - $data['base_amount_refunded'];
59
+ $updates['currencyiso3a'] = $payment->getOrder()->getBaseCurrencyCode();
60
+ }
61
+
62
+ $fullData = $this->_prepareTransactionUpdate($payment, $updates, $payment->getMethodInstance()->getConfigData('site_reference'));
63
+ $this->getIntegration()->runApiTransactionUpdate($payment, $fullData);
64
+ }
65
+
66
+ public function acceptPayment(Mage_Payment_Model_Info $payment) {
67
+ if ($payment->getOrder()->getState() !== Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW) {
68
+ throw new Mage_Core_Exception('This order is no longer in the payment review state.');
69
+ }
70
+ if ($this->_canAcceptPayment($payment)) {
71
+ $this->_acceptPayment($payment);
72
+ $this->_afterAcceptPayment($payment);
73
+ }
74
+ }
75
+
76
+ public function denyPayment(Mage_Payment_Model_Info $payment) {
77
+ if ($payment->getOrder()->getState() !== Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW) {
78
+ throw new Mage_Core_Exception('This order is no longer in the payment review state.');
79
+ }
80
+
81
+ $payment->setShouldCloseParentTransaction(true);
82
+ $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID);
83
+
84
+ if ($this->_canDenyPayment($payment)) {
85
+ $this->_beforeDenyPayment($payment);
86
+ $this->_denyPayment($payment);
87
+ $this->_afterDenyPayment($payment);
88
+ }
89
+ }
90
+
91
+ protected function _acceptPayment(Mage_Sales_Model_Order_Payment $payment) {
92
+ $transaction = Mage::getModel('securetrading_stpp/transaction')->loadByTransactionReference($payment->getCcTransId());
93
+ $requestedSettleStatus = $transaction->getRequestData('settlestatus');
94
+
95
+ if ($requestedSettleStatus === null) { // Will be null if the $transaction was a 3D AUTH (which has MD/PaRes instead).
96
+ if (!$parentTransaction = $transaction->getParentTransaction(true)) {
97
+ throw new Exception(sprintf(Mage::helper('securetrading_stpp')->__('Payment "%s" had transaction reference "%s" but had no settle status and no parent transaction reference.'), $payment->getId(), $payment->getCcTransId()));
98
+ }
99
+ if ($parentTransaction->getRequestData('requesttypedescription') !== $this->getIntegration()->getThreedqueryName()) {
100
+ throw new Exception(sprintf(Mage::helper('securetrading_stpp')->__('Payment "%s" had transaction reference "%s" but had no settle status and no parent THREEDQUERY.'), $payment->getId(), $payment->getCcTransId()));
101
+ }
102
+ if ($parentTransaction->getRequestData('settlestatus') === null) {
103
+ throw new Exception(sprintf(Mage::helper('securetrading_stpp')->__('Payment "%s" had transaction reference "%s" but had no settle status and its parent THREEDQUERY had no settle status.'), $payment->getId(), $payment->getCcTransId()));
104
+ }
105
+ $requestedSettleStatus = $parentTransaction->getRequestData('settlestatus');
106
+ }
107
+
108
+ $data = null;
109
+ if ($requestedSettleStatus !== 2) { // If the requested settlestatus was 2 there is no need to update the payment (an order should only be put into payment review when the response settlestatus == 2).
110
+ $data = $this->_prepareToUpdateSettleStatus($payment, $requestedSettleStatus, $payment->getMethodInstance()->getConfigData('site_reference'));
111
+ }
112
+
113
+ if ($data) {
114
+ $this->getIntegration()->runApiTransactionUpdate($payment, $data);
115
+ }
116
+ }
117
+
118
+ protected function _denyPayment(Mage_Payment_Model_Info $payment) {
119
+ $data = $this->_prepareToUpdateSettleStatus($payment, '3', $payment->getMethodInstance()->getConfigData('site_reference'));
120
+ $this->getIntegration()->runApiTransactionUpdate($payment, $data);
121
+ }
122
+
123
+ protected function _paymentHasSuccessfulRefund(Mage_Sales_Model_Order_Payment $payment) {
124
+ $refundTransaction = $payment->lookupTransaction('', Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
125
+ if ($refundTransaction) {
126
+ $securetradingRefundTransaction = Mage::getModel('securetrading_stpp/transaction')->loadByTransactionReference($refundTransaction->getTxnId(), true);
127
+ if ($securetradingRefundTransaction && $securetradingRefundTransaction->getRequestType() === Securetrading_Stpp_Model_Transaction_Types::TYPE_REFUND) {
128
+ return true;
129
+ }
130
+ }
131
+ return false;
132
+ }
133
+
134
+ protected function _prepareToUpdateSettleStatus(Mage_Payment_Model_Info $payment, $settleStatus, $siteReference) {
135
+ $updates = array('settlestatus' => $settleStatus);
136
+ $data = $this->_prepareTransactionUpdate($payment, $updates, $siteReference);
137
+ return $data;
138
+ }
139
+
140
+ protected function _prepareTransactionUpdate(Mage_Sales_Model_Order_Payment $payment, $updates, $siteReference) {
141
+ $data = array(
142
+ 'filter' => array(
143
+ 'sitereference' => $siteReference,
144
+ 'transactionreference' => $payment->getCcTransId(),
145
+ ),
146
+ 'updates' => $updates
147
+ );
148
+ return $data;
149
+ }
150
+ }
app/code/local/Securetrading/Stpp/Model/Payment/Handler/Backend/Factory.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Payment_Handler_Backend_Factory extends Varien_Object {
4
+ const REGISTRY_KEY_IS_BACKEND_OP = 'securetrading_stpp_model_payment_handler_backend_factory_registry_key_is_backend_op';
5
+
6
+ public function getHandler() {
7
+ $transactionReference = $this->getTransactionReference();
8
+ if (!$transactionReference) {
9
+ throw new Exception(Mage::helper('securetrading_stpp')->__('The transaction reference has not been set.'));
10
+ }
11
+
12
+ $methodInstance = $this->getMethodInstance();
13
+ if (!($methodInstance instanceof Securetrading_Stpp_Model_Payment_Abstract)) {
14
+ throw new Exception(Mage::helper('securetrading_stpp')->__('The method instance was not set.'));
15
+ }
16
+
17
+ $data = array(
18
+ 'transaction_reference' => $transactionReference,
19
+ 'integration' => $methodInstance->getIntegration(),
20
+ );
21
+ $orderIncrementIds = $this->_getOrderIncrementIds($transactionReference);
22
+ if ($orderIncrementIds) {
23
+ $data['order_increment_ids'] = $orderIncrementIds;
24
+ return Mage::getModel('securetrading_stpp/payment_handler_backend_multishipping', $data);
25
+ }
26
+ return Mage::getModel('securetrading_stpp/payment_handler_backend_onepage', $data);
27
+ }
28
+
29
+ protected function _getOrderIncrementIds($transactionReference) {
30
+ $transaction = Mage::getModel('securetrading_stpp/transaction')->loadByTransactionReference($transactionReference);
31
+ $orderId = $transaction->getOrderId();
32
+ $factory = Mage::getModel('securetrading_multishipping/order_set_factory');
33
+
34
+ if ($factory->orderBelongsToAnySet($orderId)) {
35
+ $orderIds = $factory->getOrderIdsInSameSet($orderId, false);
36
+ $orderIncrementIds = array();
37
+ foreach($orderIds as $orderId) {
38
+ $orderIncrementIds[] = Mage::getModel('sales/order')->load($orderId)->getIncrementId();
39
+ }
40
+ return $orderIncrementIds;
41
+ }
42
+ return null;
43
+ }
44
+ }
app/code/local/Securetrading/Stpp/Model/Payment/Handler/Backend/Multishipping.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Payment_Handler_Backend_Multishipping extends Securetrading_Stpp_Model_Payment_Handler_Backend_Abstract {
4
+ protected function _getOrderIncrementIds() {
5
+ $orderIncrementIds = $this->getOrderIncrementIds();
6
+ if (!is_array($orderIncrementIds) || empty($orderIncrementIds)) {
7
+ throw new Exception(Mage::helper('securetrading_stpp')->__('The order increement IDs have not been set.'));
8
+ }
9
+ return $orderIncrementIds;
10
+ }
11
+
12
+ protected function _prepareRefund(Mage_Sales_Model_Order_Payment $payment, $amount) {
13
+ $partialRefundAlreadyProcessed = null;
14
+ $orderBaseGrandTotal = null;
15
+ $baseTotalPaid = null;
16
+ $baseTotalRefunded = null;
17
+
18
+ foreach($this->_getOrderIncrementIds() as $orderIncrementId) {
19
+ $tempPayment = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId)->getPayment();
20
+
21
+ if ($partialRefundAlreadyProcessed !== true) {
22
+ $partialRefundAlreadyProcessed = $this->_paymentHasSuccessfulRefund($tempPayment);
23
+ }
24
+
25
+ $orderBaseGrandTotal += $tempPayment->getOrder()->getBaseGrandTotal();
26
+ $baseTotalPaid += $tempPayment->getOrder()->getBaseTotalPaid();
27
+ $baseTotalRefunded += $tempPayment->getOrder()->getBaseTotalRefunded();
28
+ }
29
+
30
+ return array(
31
+ 'partial_refund_already_processed' => $partialRefundAlreadyProcessed,
32
+ 'order_base_grand_total' => $orderBaseGrandTotal,
33
+ 'base_total_paid' => $baseTotalPaid,
34
+ 'base_total_refunded' => $baseTotalRefunded,
35
+ );
36
+ }
37
+
38
+ protected function _prepareToCaptureAuthorized(Mage_Sales_Model_Order_Payment $payment) {
39
+ $orderBaseGrandTotal = null;
40
+ $baseAmountPaid = null;
41
+ $baseAmountRefunded = null;
42
+ foreach($this->_getOrderIncrementIds() as $orderIncrementId) {
43
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
44
+ $orderBaseGrandTotal += $order->getBaseGrandTotal();
45
+ $baseAmountPaid += $order->getPayment()->getBaseAmountPaid();
46
+ $baseAmountRefunded += $order->getPayment()->getBaseAmountRefunded();
47
+ }
48
+ $orderBaseGrandTotal = (string) Mage::app()->getStore()->roundPrice($orderBaseGrandTotal);
49
+ $baseAmountPaid = (string) Mage::app()->getStore()->roundPrice($baseAmountPaid);
50
+ $baseAmountRefunded = (string) Mage::app()->getStore()->roundPrice($baseAmountRefunded);
51
+ return array(
52
+ 'order_base_grand_total' => $orderBaseGrandTotal,
53
+ 'base_amount_paid' => $baseAmountPaid,
54
+ 'base_amount_refunded' => $baseAmountRefunded,
55
+ );
56
+ }
57
+
58
+ protected function _canAcceptPayment(Mage_Payment_Model_Info $payment) {
59
+ if ($payment->getSkipAcceptPayment()) {
60
+ return false;
61
+ }
62
+ return true;
63
+ }
64
+
65
+ protected function _afterAcceptPayment(Mage_Payment_Model_Info $payment) {
66
+ foreach($this->_getOrderIncrementIds() as $orderIncrementId) {
67
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
68
+ $payment = $order->getPayment();
69
+ $payment->setSkipAcceptPayment(true);
70
+ $payment->accept();
71
+ $order->save();
72
+ }
73
+ }
74
+
75
+ protected function _canDenyPayment(Mage_Payment_Model_Info $payment) {
76
+ if ($payment->getSkipDenyPayment()) {
77
+ return false;
78
+ }
79
+ return true;
80
+ }
81
+
82
+ protected function _beforeDenyPayment(Mage_Payment_Model_Info $payment) {
83
+ foreach($this->_getOrderIncrementIds() as $incrementId) {
84
+ $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
85
+ $orders[$order->getId()] = $order;
86
+ }
87
+ Mage::register(Securetrading_Stpp_Model_Actions_Direct::MULTISHIPPING_ORDERS_REGISTRY_KEY, $orders);
88
+ return $this;
89
+ }
90
+
91
+ protected function _afterDenyPayment(Mage_Payment_Model_Info $payment) {
92
+ foreach(Mage::registry(Securetrading_Stpp_Model_Actions_Direct::MULTISHIPPING_ORDERS_REGISTRY_KEY) as $order) {
93
+ $payment = $order->getPayment();
94
+ $payment->setSkipDenyPayment(true);
95
+ $payment->deny();
96
+ $order->save();
97
+ }
98
+ }
99
+ }
app/code/local/Securetrading/Stpp/Model/Payment/Handler/Backend/Onepage.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Payment_Handler_Backend_Onepage extends Securetrading_Stpp_Model_Payment_Handler_Backend_Abstract {
4
+ protected function _prepareRefund(Mage_Sales_Model_Order_Payment $payment, $amount) {
5
+ $partialRefundAlreadyProcessed = $this->_paymentHasSuccessfulRefund($payment);
6
+ $orderBaseGrandTotal = $payment->getOrder()->getBaseGrandTotal();
7
+ $baseTotalPaid = $payment->getOrder()->getBaseTotalPaid();
8
+ $baseTotalRefunded = $payment->getOrder()->getBaseTotalRefunded() - $amount; // Before this method is called this happens: $payment->getOrder->setBaseTotalRefunded($payment->getOrder()->getBaseTotalRefunded() - $amount). That's why we subtract the $amount here - but don't for multishipping above (because we load new temporary orders when multishipping is being calculated.
9
+
10
+ return array(
11
+ 'partial_refund_already_processed' => $partialRefundAlreadyProcessed,
12
+ 'order_base_grand_total' => $orderBaseGrandTotal,
13
+ 'base_total_paid' => $baseTotalPaid,
14
+ 'base_total_refunded' => $baseTotalRefunded,
15
+ );
16
+ }
17
+
18
+ protected function _prepareToCaptureAuthorized(Mage_Sales_Model_Order_Payment $payment) {
19
+ $orderBaseGrandTotal = (string) Mage::app()->getStore()->roundPrice($payment->getOrder()->getBaseGrandTotal());
20
+ $baseAmountPaid = (string) Mage::app()->getStore()->roundPrice($payment->getBaseAmountPaid());
21
+ $baseAmountRefunded = (string) Mage::app()->getStore()->roundPrice($payment->getBaseAmountRefunded());
22
+ return array(
23
+ 'order_base_grand_total' => $orderBaseGrandTotal,
24
+ 'base_amount_paid' => $baseAmountPaid,
25
+ 'base_amount_refunded' => $baseAmountRefunded,
26
+ );
27
+ }
28
+
29
+ protected function _canAcceptPayment(Mage_Payment_Model_Info $payment) {
30
+ return true;
31
+ }
32
+
33
+ protected function _afterAcceptPayment(Mage_Payment_Model_Info $payment) {
34
+ return $this;
35
+ }
36
+
37
+ protected function _canDenyPayment(Mage_Payment_Model_Info $payment) {
38
+ return true;
39
+ }
40
+
41
+ protected function _beforeDenyPayment(Mage_Payment_Model_Info $payment) {
42
+ return $this;
43
+ }
44
+
45
+ protected function _afterDenyPayment(Mage_Payment_Model_Info $payment) {
46
+ return $this;
47
+ }
48
+ }
app/code/local/Securetrading/Stpp/Model/Payment/Handler/Frontend/Abstract.php ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Securetrading_Stpp_Model_Payment_Handler_Frontend_Abstract extends Varien_Object {
4
+ protected $_stateObject;
5
+
6
+ abstract protected function _canInitialize();
7
+
8
+ abstract protected function _beforeInitialize(Varien_Object $stateObject);
9
+
10
+ abstract protected function _canAuthorize(Mage_Sales_Model_Order_Payment $payment);
11
+
12
+ abstract protected function _canCapture(Mage_Sales_Model_Order_Payment $payment);
13
+
14
+ public function initialize(Mage_Sales_Model_Order_Payment $payment, $action, $stateObject) {
15
+ if (!$this->_canInitialize()) {
16
+ return;
17
+ }
18
+ $this->_beforeInitialize($stateObject);
19
+ $this->_initialize($payment, $stateObject, $action);
20
+ }
21
+
22
+ public function authorize(Varien_Object $payment) {
23
+ if ($this->_canAuthorize($payment)) {
24
+ $this->_authorize($payment);
25
+ }
26
+ }
27
+
28
+ public function capture(Varien_Object $payment, $amount) {
29
+ if ($this->_canCapture($payment)) {
30
+ $this->_capture($payment, $amount);
31
+ }
32
+ }
33
+
34
+ public function processInvoice($invoice, $payment) {
35
+ if ($this->_getReadyForAcsUrlRedirect()) {
36
+ foreach($payment->getOrder()->getStatusHistoryCollection(true) as $c) {
37
+ $c->delete();
38
+ }
39
+ $invoice->setIsPaid(false);
40
+ }
41
+ }
42
+
43
+ public function run3dAuth(array $data = array()) {
44
+ $this->_beforeRun3dAuth();
45
+ $result = $this->getIntegration()->runApi3dAuth($data);
46
+ if ($result->getErrorMessage()) {
47
+ Mage::getSingleton('checkout/session')->addError($result->getErrorMessage());
48
+ }
49
+ return $result->getIsTransactionSuccessful();
50
+ }
51
+
52
+ public function getOrderPlaceRedirectUrl() {
53
+ $session = $this->getSession();
54
+ $acsParamsExist = $session->hasAcsRedirectParams();
55
+
56
+ $this->getMethodInstance()->log(sprintf('In %s. ACS Params exist: %s.', __METHOD__, $acsParamsExist));
57
+
58
+ if ($acsParamsExist) {
59
+ return $session->getAcsRedirectParams()->getOrderPlaceRedirectUrl();
60
+ }
61
+ return null;
62
+ }
63
+
64
+ protected function _initialize(Mage_Sales_Model_Order_Payment $payment, Varien_Object $stateObject, $action) {
65
+ $this->_setStateObject($stateObject);
66
+ $order = $payment->getOrder();
67
+
68
+ switch ($action) {
69
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE:
70
+ $payment->authorize(true, $order->getBaseTotalDue()); // base amount will be set inside
71
+ $payment->setAmountAuthorized($order->getTotalDue());
72
+ break;
73
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE:
74
+ $payment->setAmountAuthorized($order->getTotalDue());
75
+ $payment->setBaseAmountAuthorized($order->getBaseTotalDue());
76
+ $payment->capture(null);
77
+ break;
78
+ default:
79
+ throw new Exception(sprintf(Mage::helper('securetrading_stpp')->__('Invalid payment action: "%s".'), $action));
80
+ }
81
+ }
82
+
83
+ protected function _authorize(Varien_Object $payment) {
84
+ $result = $this->getIntegration()->runApiStandard($payment);
85
+ $this->_handleStandardPaymentResult($payment, $result);
86
+ return $this;
87
+ }
88
+
89
+ protected function _capture(Varien_Object $payment, $amount) {
90
+ $result = $this->getIntegration()->runApiStandard($payment);
91
+ $this->_handleStandardPaymentResult($payment, $result);
92
+ return $this;
93
+ }
94
+
95
+ protected function _handleStandardPaymentResult(Mage_Sales_Model_Order_Payment $payment, Stpp_Api_ResultInterface $result) {
96
+ if ($result->getRedirectRequired()) {
97
+ $this->_setReadyForAcsUrlRedirect(true);
98
+ $this->_getStateObject()->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT)->setStatus(Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_3DSECURE);
99
+
100
+ $redirectPath = $payment->getMethodInstance()->getConfigData('use_iframe') ? 'securetrading/direct_post/iframe' : 'securetrading/direct_post/container';
101
+ $params = new Varien_Object();
102
+ $params
103
+ ->setOrderPlaceRedirectUrl(Mage::getUrl($redirectPath))
104
+ ->setRedirectIsPost($result->getRedirectIsPost())
105
+ ->setRedirectUrl($result->getRedirectUrl())
106
+ ->setRedirectData($result->getRedirectData())
107
+ ;
108
+ $this->getSession()->setAcsRedirectParams($params);
109
+ }
110
+ elseif(!$result->getIsTransactionSuccessful()) {
111
+ throw new Mage_Payment_Model_Info_Exception($result->getErrorMessage());
112
+ }
113
+ else {
114
+ $this->_getStateObject()->setState(Mage_Sales_Model_Order::STATE_PROCESSING)->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
115
+ }
116
+ return $this;
117
+ }
118
+
119
+ protected function _setStateObject(Varien_Object $stateObject) {
120
+ $this->_stateObject = $stateObject;
121
+ }
122
+
123
+ protected function _getStateObject($graceful = false) {
124
+ if ($this->_stateObject === null) {
125
+ if ($graceful) {
126
+ return false;
127
+ }
128
+ throw new Exception(Mage::helper('securetrading_stpp')->__('The state object has not been set.'));
129
+ }
130
+ return $this->_stateObject;
131
+ }
132
+
133
+ protected function _setReadyForAcsUrlRedirect($bool) {
134
+ $this->_getStateObject()->setReadyForAcsRedirect((bool)$bool);
135
+ return $this;
136
+ }
137
+
138
+ protected function _getReadyForAcsUrlRedirect() {
139
+ $stateObject = $this->_getStateObject(true); // Because processInvoice() is called when capturing a pending invoice.
140
+ if ($stateObject) {
141
+ return (bool) $stateObject->getReadyForAcsRedirect();
142
+ }
143
+ return false;
144
+ }
145
+ }
app/code/local/Securetrading/Stpp/Model/Payment/Handler/Frontend/Factory.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Payment_Handler_Frontend_Factory extends Varien_Object {
4
+ public function getHandler(Mage_Payment_Model_Method_Abstract $methodInstance) {
5
+ $methodInstance->log(sprintf('In %s.', __METHOD__));
6
+ $data = array(
7
+ 'integration' => $this->getIntegration(),
8
+ 'method_instance' => $methodInstance,
9
+ 'session' => $methodInstance->getSession(),
10
+ );
11
+ if ($methodInstance->getIsMultishipping()) {
12
+ $data['is_first_multishipping'] = $methodInstance->getIsFirstMultishipping();
13
+ $data['payment_place_without_making_api_request'] = $methodInstance->getPaymentPlaceWithoutMakingApiRequest();
14
+ return $this->_createMultishippingHandler($methodInstance, $data);
15
+ }
16
+ return $this->_createOnepageHandler($methodInstance, $data);
17
+ }
18
+
19
+ protected function _createMultishippingHandler(Securetrading_Stpp_Model_Payment_Direct_Abstract $methodInstance, array $data) {
20
+ $methodInstance->log(sprintf('In %s.', __METHOD__));
21
+ return Mage::getModel('securetrading_stpp/payment_handler_frontend_multishipping', $data);
22
+ }
23
+
24
+ protected function _createOnepageHandler(Securetrading_Stpp_Model_Payment_Direct_Abstract $methodInstance, array $data) {
25
+ $methodInstance->log(sprintf('In %s.', __METHOD__));
26
+ return Mage::getModel('securetrading_stpp/payment_handler_frontend_onepage', $data);
27
+ }
28
+ }
app/code/local/Securetrading/Stpp/Model/Payment/Handler/Frontend/Multishipping.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Payment_Handler_Frontend_Multishipping extends Securetrading_Stpp_Model_Payment_Handler_Frontend_Abstract {
4
+ const MULTISHIPPING_STATE_OBJECT_REGISTRY_KEY = 'securetrading_stpp_payment_direct_multishipping_state_object_registry_key';
5
+
6
+ protected function _canInitialize() {
7
+ if ($this->getPaymentPlaceWithoutMakingApiRequest()) {
8
+ return false;
9
+ }
10
+ return true;
11
+ }
12
+
13
+ protected function _beforeInitialize(Varien_Object $stateObject) {
14
+ if ($this->getIsFirstMultishipping()) {
15
+ $this->_setFirstMultishippingStateObject($stateObject);
16
+ }
17
+ else {
18
+ $stateObject->setData($this->_getFirstMultishippingStateObject()->getData());
19
+ }
20
+ }
21
+
22
+ protected function _canAuthorize(Mage_Sales_Model_Order_Payment $payment) {
23
+ if ($this->getIsFirstMultishipping()) {
24
+ return true;
25
+ }
26
+ if (Mage::registry('stpp_test_key')) { //TODO - ugly fix. improve.
27
+ $payment->setIsTransactionPending(true);
28
+ }
29
+ return false;
30
+ }
31
+
32
+ protected function _canCapture(Mage_Sales_Model_Order_Payment $payment) {
33
+ if ($this->getIsFirstMultishipping()) {
34
+ return true;
35
+ }
36
+ if (Mage::registry('stpp_test_key')) { //TODO - ugly fix. improve.
37
+ $payment->setIsTransactionPending(true);
38
+ }
39
+ return false;
40
+ }
41
+
42
+ protected function _beforeRun3dAuth() {
43
+ $orderIncrementIds = Mage::getModel('core/session')->getOrderIds();
44
+ $orders = array();
45
+ foreach($orderIncrementIds as $orderId => $orderIncrementId) {
46
+ $orders[] = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
47
+ }
48
+ Mage::register(Securetrading_Stpp_Model_Actions_Direct::MULTISHIPPING_ORDERS_REGISTRY_KEY, $orders);
49
+ }
50
+
51
+ protected function _getFirstMultishippingStateObject() {
52
+ return Mage::registry(Securetrading_Stpp_Model_Payment_Handler_Frontend_Multishipping::MULTISHIPPING_STATE_OBJECT_REGISTRY_KEY);
53
+ }
54
+
55
+ protected function _setFirstMultishippingStateObject(Varien_Object $stateObject) {
56
+ Mage::register(Securetrading_Stpp_Model_Payment_Handler_Frontend_Multishipping::MULTISHIPPING_STATE_OBJECT_REGISTRY_KEY, $stateObject);
57
+ return $this;
58
+ }
59
+ }
app/code/local/Securetrading/Stpp/Model/Payment/Handler/Frontend/Onepage.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Payment_Handler_Frontend_Onepage extends Securetrading_Stpp_Model_Payment_Handler_Frontend_Abstract {
4
+ protected function _canInitialize() {
5
+ return true;
6
+ }
7
+
8
+ protected function _beforeInitialize(Varien_Object $stateObject) {
9
+ return;
10
+ }
11
+
12
+ protected function _canAuthorize(Mage_Sales_Model_Order_Payment $payment) {
13
+ return true;
14
+ }
15
+
16
+ protected function _canCapture(Mage_Sales_Model_Order_Payment $payment) {
17
+ return true;
18
+ }
19
+
20
+ protected function _beforeRun3dAuth() {
21
+ return;
22
+ }
23
+ }
app/code/local/Securetrading/Stpp/Model/Payment/Redirect.php CHANGED
@@ -1,169 +1,209 @@
1
  <?php
2
 
3
- class Securetrading_Stpp_Model_Payment_Redirect extends Securetrading_Stpp_Model_Payment_Abstract {
4
- protected $_code = 'securetrading_stpp_redirect';
5
- protected $_formBlockType = 'securetrading_stpp/payment_redirect_form';
6
- protected $_infoBlockType = 'securetrading_stpp/payment_redirect_info';
7
-
8
- protected $_isGateway = false;
9
- protected $_canOrder = false;
10
- protected $_canAuthorize = false;
11
- protected $_canCapture = true;
12
- protected $_canCapturePartial = false;
13
- protected $_canRefund = false;
14
- protected $_canRefundInvoicePartial = false;
15
- protected $_canVoid = false;
16
- protected $_canUseInternal = true;
17
- protected $_canUseCheckout = true;
18
- protected $_canUseForMultishipping = true;
19
- protected $_isInitializeNeeded = true;
20
- protected $_canFetchTransactionInfo = false;
21
- protected $_canReviewPayment = true;
22
- protected $_canCreateBillingAgreement = false;
23
- protected $_canManageRecurringProfiles = false;
24
-
25
- public function __construct() {
26
- if ($this->getConfigData('use_api')) {
27
- $this->_canCapturePartial = true;
28
- $this->_canRefund = true;
29
- $this->_canRefundInvoicePartial = true;
30
- }
31
- }
32
-
33
- public function initialize($action, $stateObject) {
34
- $this->log(sprintf('In %s.', __METHOD__));
35
- parent::initialize($action, $stateObject);
36
- $stateObject->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT)->setStatus(Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_PPAGES);
37
- }
38
-
39
- public function acceptPayment(Mage_Payment_Model_Info $payment) {
40
- $this->log(sprintf('In %s.', __METHOD__));
41
- $data = $this->_getApi()->acceptPaymentAndPrepareApiRequest($payment, $this->getConfigData('site_reference'));
42
- if ($data) {
43
- $this->getIntegration()->runApiTransactionUpdate($payment, $data);
44
- }
45
- return true;
46
- }
47
-
48
- public function denyPayment(Mage_Payment_Model_Info $payment) {
49
- $this->log(sprintf('In %s.', __METHOD__));
50
- $data = $this->_getApi()->denyPaymentAndPrepareApiRequest($payment, $this->getConfigData('site_reference'));
51
- if ($data) {
52
- $this->getIntegration()->runApiTransactionUpdate($payment, $data);
53
- }
54
- return true;
55
- }
56
-
57
- protected function _useFirstPathIfIframe($path1, $path2) {
58
- if ($this->getConfigData('ppg_use_iframe')) {
59
- return $path1;
60
- }
61
- return $path2;
62
  }
63
-
64
- public function getOrderPlaceRedirectUrl() {
65
- $this->log(sprintf('In %s.', __METHOD__));
 
 
 
 
 
 
 
66
  return Mage::getUrl($this->getOrderPlaceRedirectPath());
67
- }
68
-
69
- public function getOrderPlaceRedirectPath() {
70
- $this->log(sprintf('In %s.', __METHOD__));
71
- return $this->_useFirstPathIfIframe('securetrading/redirect_post_onepage/iframe', 'securetrading/redirect_post_onepage/container');
72
- }
73
- public function getMultishippingRedirectPath() {
74
- $this->log(sprintf('In %s.', __METHOD__));
75
- return $this->_useFirstPathIfIframe('securetrading/redirect_post_multishipping/iframe', 'securetrading/redirect_post_multishipping/container');
76
- }
77
-
78
- public function getMotoOrderRedirectPath() {
79
- $this->log(sprintf('In %s.', __METHOD__));
80
- return $this->_useFirstPathIfIframe('*/sales_order_create_securetrading/iframe', '*/sales_order_create_securetrading/post');
81
- }
82
-
83
- public function prepareOrderData(Mage_Sales_Model_Order_Payment $payment, array $orderIncrementIds, $sendEmailConfirmation = true) {
84
- $this->log(sprintf('In %s.', __METHOD__));
85
- $data = parent::prepareOrderData($payment, $orderIncrementIds);
86
-
87
- return $data += array(
88
- 'customfield1' => $payment->getOrder()->getStoreId(),
89
- 'parentcss' => $this->getConfigData('parent_css'),
90
- 'childcss' => $this->getConfigData('child_css'),
91
- 'parentjs' => $this->getConfigData('parent_js'),
92
- 'childjs' => $this->getConfigData('child_js'),
93
- //'subsitereference' => $this->getConfigData('sub_site_reference'),
94
- '_charset_' => Mage::getStoreConfig('design/head/default_charset'),
95
- 'order_increment_ids' => serialize($orderIncrementIds),
96
- 'send_confirmation' => $sendEmailConfirmation,
97
- );
98
- }
99
-
100
- protected function _getApi() {
101
- return Mage::getModel('securetrading_stpp/payment_direct');
102
- }
103
-
104
- public function capture(Varien_Object $payment, $amount) {
105
- $this->log(sprintf('In %s.', __METHOD__));
106
- parent::capture($payment, $amount);
107
- $data = $this->_getApi()->prepareToCaptureAuthorized($payment, $amount, $this->getConfigData('site_reference'));
108
- $this->getIntegration()->runApiTransactionUpdate($payment, $data);
109
- return $this;
110
- }
111
-
112
- public function refund(Varien_Object $payment, $amount) {
113
- $this->log(sprintf('In %s.', __METHOD__));
114
- parent::refund($payment, $amount);
115
- $data = $this->_getApi()->prepareToRefund($payment, $amount, $this->getConfigData('site_reference'));
116
- $this->getIntegration()->runApiRefund($payment, $data);
117
- return $this;
118
- }
119
-
120
- public function cancel(Varien_Object $payment) {
121
- return $this; // Do nothing intentionally.
122
- }
123
 
124
- public function prepareData($isMoto = false, array $orderIncrementIds = array(), $sendEmailConfirmation = true) {
125
- $this->log(sprintf('In %s.', __METHOD__));
126
- $data = $this->prepareOrderData($this->getInfoInstance(), $orderIncrementIds, $sendEmailConfirmation);
127
- $transport = $this->getIntegration()->runPaymentPages($data, $isMoto);
128
- return $transport;
129
- }
130
-
131
- public function validateOrders(array $orderIncrementIds) {
132
- if (empty($orderIncrementIds)) {
133
- throw new Exception(Mage::helper('securetrading_stpp')->__('No order increment IDs.'));
134
- }
135
-
136
- foreach($orderIncrementIds as $orderIncrementId) {
137
- if ($orderIncrementId === null) {
138
- throw new Exception(Mage::helper('securetrading_stpp')->__('No order ID.'));
139
- }
140
-
141
- $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
142
-
143
- if ($order->getPayment()->getMethodInstance()->getCode() !== Mage::getModel('securetrading_stpp/payment_redirect')->getCode()) {
144
- throw new Exception(Mage::helper('securetrading_stpp')->__('Cannot access payment method.'));
145
- }
146
-
147
- if ($order->getStatus() !== Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_PPAGES) {
148
- throw new Exception(Mage::helper('securetrading_stpp')->__('Order not pending payment pages.'));
149
- }
150
- }
151
- return $this;
152
- }
153
-
154
- public function getFirstMethodInstance(array $orderIncrementIds) {
155
- $firstOrderIncrementId = array_shift($orderIncrementIds);
156
- $order = Mage::getModel('sales/order')->loadByIncrementId($firstOrderIncrementId);
157
- return $order->getPayment()->getMethodInstance();
158
- }
159
-
160
- public function runRedirect() {
161
- $this->log(sprintf('In %s.', __METHOD__));
162
- return $this->getIntegration()->runRedirect();
163
- }
164
-
165
- public function runNotification() {
166
- $this->log(sprintf('In %s.', __METHOD__));
167
- $this->getIntegration()->runNotification();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  }
1
  <?php
2
 
3
+ class Securetrading_Stpp_Model_Payment_Redirect extends Securetrading_Stpp_Model_Payment_Abstract implements Mage_Payment_Model_Billing_Agreement_MethodInterface {
4
+ protected $_code = 'securetrading_stpp_redirect';
5
+ protected $_formBlockType = 'securetrading_stpp/payment_redirect_form';
6
+ protected $_infoBlockType = 'securetrading_stpp/payment_redirect_info';
7
+
8
+ protected $_isGateway = false;
9
+ protected $_canOrder = false;
10
+ protected $_canAuthorize = false;
11
+ protected $_canCapture = true;
12
+ protected $_canCapturePartial = false;
13
+ protected $_canRefund = false;
14
+ protected $_canRefundInvoicePartial = false;
15
+ protected $_canVoid = false;
16
+ protected $_canUseInternal = true;
17
+ protected $_canUseCheckout = true;
18
+ protected $_canUseForMultishipping = true;
19
+ protected $_isInitializeNeeded = true;
20
+ protected $_canFetchTransactionInfo = false;
21
+ protected $_canReviewPayment = true;
22
+ protected $_canCreateBillingAgreement = true;
23
+ protected $_canManageRecurringProfiles = false;
24
+
25
+ public function __construct() {
26
+ if ($this->getConfigData('use_api')) {
27
+ $this->_canCapturePartial = true;
28
+ $this->_canRefund = true;
29
+ $this->_canRefundInvoicePartial = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  }
31
+ }
32
+
33
+ public function initialize($action, $stateObject) {
34
+ $this->log(sprintf('In %s.', __METHOD__));
35
+ parent::initialize($action, $stateObject);
36
+ $stateObject->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT)->setStatus(Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_PPAGES);
37
+ }
38
+
39
+ public function getOrderPlaceRedirectUrl() {
40
+ $this->log(sprintf('In %s.', __METHOD__));
41
  return Mage::getUrl($this->getOrderPlaceRedirectPath());
42
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
+ public function getOrderPlaceRedirectPath() {
45
+ $this->log(sprintf('In %s.', __METHOD__));
46
+ return $this->_useFirstPathIfIframe('securetrading/redirect_post_onepage/iframe', 'securetrading/redirect_post_onepage/container');
47
+ }
48
+ public function getMultishippingRedirectPath() {
49
+ $this->log(sprintf('In %s.', __METHOD__));
50
+ return $this->_useFirstPathIfIframe('securetrading/redirect_post_multishipping/iframe', 'securetrading/redirect_post_multishipping/container');
51
+ }
52
+
53
+ public function getMotoOrderRedirectPath() {
54
+ $this->log(sprintf('In %s.', __METHOD__));
55
+ return $this->_useFirstPathIfIframe('*/sales_order_create_securetrading/iframe', '*/sales_order_create_securetrading/post');
56
+ }
57
+
58
+ public function prepareOrderData(Mage_Sales_Model_Order_Payment $payment, array $orderIncrementIds, $sendEmailConfirmation = true) {
59
+ $this->log(sprintf('In %s.', __METHOD__));
60
+ $data = parent::prepareOrderData($payment, $orderIncrementIds);
61
+ $data += array(
62
+ 'customfield1' => $payment->getOrder()->getStoreId(),
63
+ 'parentcss' => $this->getConfigData('parent_css'),
64
+ 'childcss' => $this->getConfigData('child_css'),
65
+ 'parentjs' => $this->getConfigData('parent_js'),
66
+ 'childjs' => $this->getConfigData('child_js'),
67
+ //'subsitereference' => $this->getConfigData('sub_site_reference'),
68
+ '_charset_' => Mage::getStoreConfig('design/head/default_charset'),
69
+ 'order_increment_ids' => serialize($orderIncrementIds),
70
+ 'send_confirmation' => $sendEmailConfirmation,
71
+ 'customer_id' => Mage::getSingleton('customer/session')->getCustomerId(),
72
+ 'savecc' => Mage::getSingleton('securetrading_stpp/payment_redirect_session')->getSaveCardDetails(),
73
+ );
74
+ return $data;
75
+ }
76
+
77
+ public function assignData($data) {
78
+ Mage::getSingleton('securetrading_stpp/payment_redirect_session')->setSaveCardDetails($data->getSecuretradingStppRedirectSaveCc());
79
+ return $this;
80
+ }
81
+
82
+ public function cancel(Varien_Object $payment) {
83
+ return $this; // Do nothing intentionally.
84
+ }
85
+
86
+ public function capture(Varien_Object $payment, $amount) {
87
+ return $this->_captureAuthorized($payment, $amount);
88
+ }
89
+
90
+ public function prepareData($isMoto = false, array $orderIncrementIds = array(), $sendEmailConfirmation = true) {
91
+ $this->log(sprintf('In %s.', __METHOD__));
92
+ $data = $this->prepareOrderData($this->getInfoInstance(), $orderIncrementIds, $sendEmailConfirmation);
93
+ $transport = $this->getIntegration()->runPaymentPages($data, $isMoto);
94
+ return $transport;
95
+ }
96
+
97
+ public function validateOrdersArePendingPpages(array $orderIncrementIds) {
98
+ if (empty($orderIncrementIds)) {
99
+ throw new Exception(Mage::helper('securetrading_stpp')->__('No order increment IDs.'));
100
+ }
101
+
102
+ foreach($orderIncrementIds as $orderIncrementId) {
103
+ if ($orderIncrementId === null) {
104
+ throw new Exception(Mage::helper('securetrading_stpp')->__('No order ID.'));
105
+ }
106
+
107
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
108
+
109
+ if ($order->getPayment()->getMethodInstance()->getCode() !== Mage::getModel('securetrading_stpp/payment_redirect')->getCode()) {
110
+ throw new Exception(Mage::helper('securetrading_stpp')->__('Cannot access payment method.'));
111
+ }
112
+
113
+ if (!$this->_canTakeOrderToPpages($order)) {
114
+ throw new Exception(Mage::helper('securetrading_stpp')->__('Order cannot be taken to the Payment Pages. State: "%s". Status: "%s".', $order->getState(), $order->getStatus()));
115
+ }
116
+ }
117
+ return $this;
118
+ }
119
+
120
+ public function getFirstMethodInstance(array $orderIncrementIds) {
121
+ $firstOrderIncrementId = array_shift($orderIncrementIds);
122
+ $order = Mage::getModel('sales/order')->loadByIncrementId($firstOrderIncrementId);
123
+ return $order->getPayment()->getMethodInstance();
124
+ }
125
+
126
+ public function runRedirect() {
127
+ $this->log(sprintf('In %s.', __METHOD__));
128
+ return $this->getIntegration()->runRedirect();
129
+ }
130
+
131
+ public function runNotification() {
132
+ $this->log(sprintf('In %s.', __METHOD__));
133
+ $this->getIntegration()->runNotification();
134
+ }
135
+
136
+ public function updateBillingAgreementStatus(Mage_Payment_Model_Billing_AgreementAbstract $agreement) {
137
+ return $this;
138
+ }
139
+
140
+ public function initBillingAgreementToken(Mage_Payment_Model_Billing_AgreementAbstract $agreement) {
141
+ throw new Exception('Unused.');
142
+ }
143
+
144
+ public function getBillingAgreementTokenInfo(Mage_Payment_Model_Billing_AgreementAbstract $agreement) {
145
+ throw new Exception('Unused.');
146
+ }
147
+
148
+ public function placeBillingAgreement(Mage_Payment_Model_Billing_AgreementAbstract $agreement) {
149
+ throw new Exception('Unused.');
150
+ }
151
+
152
+ public function ordersAreSuccessful($orderIncrementIds) {
153
+ foreach($orderIncrementIds as $orderIncrementId) {
154
+ if ($this->orderIsSuccessful($orderIncrementId)) {
155
+ continue;
156
+ }
157
+ return false;
158
+ }
159
+ return true;
160
+ }
161
+
162
+ public function orderIsSuccessful($orderIncrementId) {
163
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
164
+ $successful = (bool) $this->_isProcessingOrPaymentReviewState($order) || $this->_isPendingSofortStatus($order);
165
+ return $successful;
166
+ }
167
+
168
+ protected function _isProcessingOrPaymentReviewState(Mage_Sales_Model_Order $order) {
169
+ return (bool) in_array($order->getState(), array(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW), true);
170
+ }
171
+
172
+ protected function _isPendingPpagesStatus(Mage_Sales_Model_Order $order) {
173
+ return (bool) ($order->getState() === Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) && ($order->getStatus() === Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_PPAGES);
174
+ }
175
+
176
+ protected function _isPendingSofortStatus(Mage_Sales_Model_Order $order) {
177
+ return (bool) ($order->getState() === Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) && ($order->getStatus() === Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_SOFORT);
178
+ }
179
+
180
+ protected function _canTakeOrderToPpages($order) {
181
+ return (bool) $this->_isPendingPpagesStatus($order) || $this->_isPendingSofortStatus($order);
182
+ /*
183
+ Note - if Pending Ppages - then Pending Sofort - then go back to Magento, cart has already been cleared in PPG AUTH notification. Doesn't cause any actual problems but is curious.
184
+ */
185
+ }
186
+
187
+ protected function _useFirstPathIfIframe($path1, $path2) {
188
+ if ($this->getConfigData('ppg_use_iframe')) {
189
+ return $path1;
190
  }
191
+ return $path2;
192
+ }
193
+
194
+ public function onRedirect(array $orderIncrementIds, $errorCode, $paymentTypeDescription) {
195
+ if ($errorCode === '0' && $paymentTypeDescription === $this->getIntegration()->getSofortName()) {
196
+ foreach($orderIncrementIds as $orderIncrementId) {
197
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
198
+ $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Securetrading_Stpp_Model_Payment_Abstract::STATUS_PROCESSING_SOFORT);
199
+ $order->save(); // Must save before sendNewOrderEmail() since that calls $this->load().
200
+ $order->sendNewOrderEmail();
201
+ $order->save();
202
+ }
203
+ $quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($order->getQuoteId());
204
+ if ($quote->getIsActive()) {
205
+ $quote->setIsActive(false)->save();
206
+ }
207
+ }
208
+ }
209
  }
app/code/local/Securetrading/Stpp/Model/Payment/Redirect/Session.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Payment_Redirect_Session extends Mage_Core_Model_Session_Abstract {
4
+ public function __construct() {
5
+ $this->init('securetrading_stpp_payment_redirect');
6
+ }
7
+ }
app/code/local/Securetrading/Stpp/Model/Payment/Tokenization.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Payment_Tokenization extends Securetrading_Stpp_Model_Payment_Direct_Abstract {
4
+ protected $_code = 'securetrading_stpp_tokenization';
5
+ protected $_formBlockType = 'securetrading_stpp/payment_tokenization_form';
6
+ protected $_infoBlockType = 'securetrading_stpp/payment_tokenization_info';
7
+
8
+ protected $_canCreateBillingAgreement = false;
9
+
10
+ protected $_sessionModelType = 'securetrading_stpp/payment_tokenization_session';
11
+
12
+ protected function _get3dAuthData() {
13
+ return array();
14
+ }
15
+
16
+ public function isAvailable($quote = null) {
17
+ return parent::isAvailable($quote) && count($this->getSavedCardsCollection());
18
+ }
19
+
20
+ public function assignData($data) {
21
+ $this->getSession()->setReferenceId($data->getSecuretradingStppReferenceId());
22
+ $this->getSession()->setIsAdmin(Mage::app()->getStore()->isAdmin());
23
+ return $this;
24
+ }
25
+
26
+ public function prepareOrderData(Mage_Sales_Model_Order_Payment $payment, array $orderIncrementIds = array(), $sendEmailConfirmation = true) {
27
+ if (empty($orderIncrementIds)) {
28
+ $orderIncrementIds = array($payment->getOrder()->getId() => $payment->getOrder()->getIncrementId());
29
+ }
30
+ $data = parent::prepareOrderData($payment, $orderIncrementIds);
31
+ $data += array(
32
+ 'parenttransactionreference' => $this->_getParentTransactionReference(),
33
+ 'termurl' => Mage::getUrl('securetrading/direct/return'),
34
+ );
35
+ return $data;
36
+ }
37
+
38
+ public function getSavedCardsCollectionUsingParams($customerId, $storeId, $baseCurrencyCode, $paymentTypeDescriptions) {
39
+ if (!is_array($paymentTypeDescriptions)) {
40
+ $paymentTypeDescriptions = array();
41
+ }
42
+ return Mage::getResourceModel('securetrading_stpp/mage_sales_billing_agreement_collection')
43
+ ->joinWithCurrencyTable()
44
+ ->joinWithPaymenttypedescriptionTable()
45
+ ->addFieldToFilter('customer_id', array('eq' => $customerId))
46
+ ->addFieldToFilter('store_id', $storeId)
47
+ ->addFieldToFilter('base_currency', array(array('eq' => $baseCurrencyCode), array('null' => 'dummyvalue')))
48
+ ->addFieldToFilter('status', array('eq' => Mage_Sales_Model_Billing_Agreement::STATUS_ACTIVE))
49
+ ->addFieldToFilter('payment_type_description', array('in' => $paymentTypeDescriptions));
50
+ ;
51
+ }
52
+
53
+ public function getSavedCardsCollection() {
54
+ $customerId = $this->_getCustomerId();
55
+ $storeId = $this->_getStoreId();
56
+ $baseCurrencyCode = $this->_getBaseCurrencyCode();
57
+ $paymentTypeDescriptions = $this->getConfigData('accepted_cards');
58
+ return $this->getSavedCardsCollectionUsingParams($customerId, $storeId, $baseCurrencyCode, $paymentTypeDescriptions);
59
+ }
60
+
61
+ public function getBillingAgreement($referenceId, $graceful = false) {
62
+ $collection = $this->getSavedCardsCollection();
63
+ $collection->addFieldToFilter('reference_id', array('eq' => $referenceId));
64
+
65
+ if ($collection->getSize() === 1) {
66
+ $return = $collection->getFirstItem();
67
+ }
68
+ else if ($graceful) {
69
+ $return = false;
70
+ }
71
+ else {
72
+ throw new Exception(sprintf(Mage::helper('securetrading_stpp')->__('Invalid reference ID "%s" selected. Possible fraud attempt.'), $referenceId));
73
+ }
74
+ return $return;
75
+ }
76
+
77
+ public function getActiveBillingAgreement($graceful = false) {
78
+ return $this->getBillingAgreement($this->_getReferenceId(), $graceful);
79
+ }
80
+
81
+ public function getConfigData($field, $storeId = null) {
82
+ $return = parent::getConfigData($field, $storeId);
83
+ if ($return === null && $field !== 'config_fallback') { // prevent infinite recurison
84
+ $fallback = $this->getConfigData('config_fallback', $storeId);
85
+ $methodInstance = Mage::helper('payment')->getMethodInstance($fallback); // $fallback must be a payment method code
86
+ if ($methodInstance) {
87
+ $return = $methodInstance->getConfigData($field, $storeId);
88
+ }
89
+ }
90
+ return $return;
91
+ }
92
+
93
+ public function getOrderAndBillingAgreementData($orderId) {
94
+ $collection = Mage::getResourceModel('sales/order_collection');
95
+ $collection->addFieldToSelect('*')
96
+ ->addFieldToFilter('entity_id', $orderId)
97
+ ->getSelect()->joinLeft(
98
+ array('sbao' => $collection->getTable('sales/billing_agreement_order')),
99
+ 'main_table.entity_id = sbao.order_id',
100
+ array('sbao.agreement_id')
101
+ )
102
+ ;
103
+
104
+ if ($collection->getSize() !== 1) {
105
+ throw new Exception(sprintf(Mage::helper('securetrading_stpp')->__('Unexpected size: %s.'), $collection->getSize()));
106
+ }
107
+
108
+ $order = $collection->getFirstItem();
109
+ return $order;
110
+ }
111
+
112
+ public function canSaveCards($collection) {
113
+ return (bool) ($collection->getSize() < $this->getConfigData('max_saved_cc'));
114
+ }
115
+
116
+ protected function _getParentTransactionReference() {
117
+ return $this->getActiveBillingAgreement()->getReferenceId(); // doing this lets us validate the ba belongs to the correct person and is valid.
118
+ }
119
+
120
+ protected function _getReferenceId() {
121
+ return $this->getSession()->getReferenceId();
122
+ }
123
+
124
+ protected function _isBackendOp() {
125
+ return Mage::registry(Securetrading_Stpp_Model_Payment_Handler_Backend_Factory::REGISTRY_KEY_IS_BACKEND_OP);
126
+ }
127
+
128
+ protected function _isAdmin() {
129
+ return Mage::app()->getStore()->isAdmin() || $this->getSession()->getIsAdmin(); // We don't just do Mage::app()->getStore()->isAdmin() since when Mage_Sales_Model_Order::sendNewOrderEmail() starts environment emulation Magento thinks we are in the frontend (since it uses the frontend payment info form).
130
+ }
131
+
132
+ protected function _getStoreId() {
133
+ if ($this->_isAdmin()) {
134
+ $storeId = Mage::getSingleton('adminhtml/session_quote')->getStoreId();
135
+ }
136
+ else {
137
+ $storeId = Mage::app()->getStore()->getId();
138
+ }
139
+ return $storeId;
140
+ }
141
+
142
+ protected function _getCustomerId() {
143
+ if ($this->_isAdmin()) {
144
+ $customerId = Mage::getSingleton('adminhtml/session_quote')->getCustomerId();
145
+ }
146
+ else {
147
+ $customerId = Mage::getSingleton('customer/session')->getCustomerId();
148
+ }
149
+ return $customerId;
150
+ }
151
+
152
+ protected function _getBaseCurrencyCode() {
153
+ if ($this->_isAdmin()) {
154
+ $baseCurrencyCode = Mage::getSingleton('adminhtml/session_quote')->getQuote()->getBaseCurrencyCode();
155
+ }
156
+ else {
157
+ $baseCurrencyCode = Mage::getSingleton('checkout/session')->getQuote()->getBaseCurrencyCode();
158
+ }
159
+ return $baseCurrencyCode;
160
+ }
161
+ }
app/code/local/Securetrading/Stpp/Model/Payment/Tokenization/Session.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Payment_Tokenization_Session extends Mage_Core_Model_Session_Abstract {
4
+ public function __construct() {
5
+ $this->init('securetrading_stpp_payment_tokenization');
6
+ }
7
+ }
app/code/local/Securetrading/Stpp/Model/Resource/Billing/Agreement/Currency.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Resource_Billing_Agreement_Currency extends Mage_Core_Model_Resource_Db_Abstract {
4
+ protected $_isPkAutoIncrement = false;
5
+
6
+ public function _construct() {
7
+ $this->_init('securetrading_stpp/billing_agreement_currency', 'agreement_id');
8
+ }
9
+ }
app/code/local/Securetrading/Stpp/Model/Resource/Billing/Agreement/Paymenttypedescription.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Resource_Billing_Agreement_Paymenttypedescription extends Mage_Core_Model_Resource_Db_Abstract {
4
+ protected $_isPkAutoIncrement = false;
5
+
6
+ public function _construct() {
7
+ $this->_init('securetrading_stpp/billing_agreement_paymenttypedescription', 'agreement_id');
8
+ }
9
+ }
app/code/local/Securetrading/Stpp/Model/Resource/Mage/Sales/Billing/Agreement/Collection.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Resource_Mage_Sales_Billing_Agreement_Collection extends Mage_Sales_Model_Resource_Billing_Agreement_Collection {
4
+ public function joinWithCurrencyTable() {
5
+ $this->getSelect()->joinLeft(
6
+ array('joined_curr' => $this->getTable('securetrading_stpp/billing_agreement_currency')),
7
+ 'joined_curr.agreement_id = main_table.agreement_id',
8
+ array('joined_curr.base_currency')
9
+ );
10
+ return $this;
11
+ }
12
+
13
+ public function joinWithPaymenttypedescriptionTable() {
14
+ $this->getSelect()->joinLeft(
15
+ array('joined_ptd' => $this->getTable('securetrading_stpp/billing_agreement_paymenttypedescription')),
16
+ 'joined_ptd.agreement_id = main_table.agreement_id',
17
+ array('joined_ptd.payment_type_description')
18
+ );
19
+ return $this;
20
+ }
21
+ }
app/code/local/Securetrading/Stpp/Model/Source/Cardtypes.php CHANGED
@@ -1,17 +1,19 @@
1
  <?php
2
 
3
  class Securetrading_Stpp_Model_Source_Cardtypes {
4
- public function toOptionArray()
5
- {
6
- $cardTypes = Mage::getModel('securetrading_stpp/integration')->getCardTypes();
7
- $newArray = array();
8
-
9
- foreach($cardTypes as $cardKey => $cardString) {
10
- $newArray[] = array(
11
- 'value' => $cardKey,
12
- 'label' => $cardString,
13
- );
14
- }
15
- return $newArray;
16
  }
 
 
17
  }
1
  <?php
2
 
3
  class Securetrading_Stpp_Model_Source_Cardtypes {
4
+ public function toOptionArray()
5
+ {
6
+ $integration = Mage::getModel('securetrading_stpp/integration');
7
+ $cardTypes = $integration->getCardTypes();
8
+ unset($cardTypes[$integration->getSofortName()]);
9
+ $newArray = array();
10
+
11
+ foreach($cardTypes as $cardKey => $cardString) {
12
+ $newArray[] = array(
13
+ 'value' => $cardKey,
14
+ 'label' => $cardString,
15
+ );
16
  }
17
+ return $newArray;
18
+ }
19
  }
app/code/local/Securetrading/Stpp/Model/Source/Configfallback.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Securetrading_Stpp_Model_Source_Configfallback {
4
+ public function toOptionArray() {
5
+ $array = array();
6
+ $paymentMethods = array(
7
+ 'Secure Trading Payment Pages' => Mage::getModel('securetrading_stpp/payment_redirect'),
8
+ 'Secure Trading API' => Mage::getModel('securetrading_stpp/payment_direct'),
9
+ );
10
+ foreach($paymentMethods as $name => $paymentMethod) {
11
+ $array[] = array(
12
+ 'value' => $paymentMethod->getCode(),
13
+ 'label' => $name,
14
+ );
15
+ }
16
+ return $array;
17
+ }
18
+ }
app/code/local/Securetrading/Stpp/Model/Source/Settlestatus.php CHANGED
@@ -4,7 +4,7 @@ class Securetrading_Stpp_Model_Source_Settlestatus {
4
  public function toOptionArray()
5
  {
6
  $settleStatuses = Mage::getModel('securetrading_stpp/integration')->getSettleStatuses();
7
- unset($settleStatuses['2'], $settleStatuses['3']);
8
 
9
  $newArray = array();
10
 
4
  public function toOptionArray()
5
  {
6
  $settleStatuses = Mage::getModel('securetrading_stpp/integration')->getSettleStatuses();
7
+ unset($settleStatuses['2'], $settleStatuses['3'], $settleStatuses['100']);
8
 
9
  $newArray = array();
10
 
app/code/local/Securetrading/Stpp/Model/Transaction.php CHANGED
@@ -65,7 +65,7 @@ class Securetrading_Stpp_Model_Transaction extends Mage_Core_Model_Abstract {
65
  if ($graceful) {
66
  return false;
67
  }
68
- throw new Stpp_Exception(Mage::helper('securetrading_stpp')->__('The parent transaction could not be loaded.'));
69
  }
70
 
71
  public function loadByTransactionReference($transactionReference, $graceful = false) {
@@ -75,7 +75,7 @@ class Securetrading_Stpp_Model_Transaction extends Mage_Core_Model_Abstract {
75
  if ($graceful) {
76
  return false;
77
  }
78
- throw new Stpp_Exception(sprintf(Mage::helper('securetrading_stpp')->__('A transaction with a transaction reference of "%s" cannot be found.'), $transactionReference));
79
  }
80
  return $this;
81
  }
65
  if ($graceful) {
66
  return false;
67
  }
68
+ throw new Exception(Mage::helper('securetrading_stpp')->__('The parent transaction could not be loaded.'));
69
  }
70
 
71
  public function loadByTransactionReference($transactionReference, $graceful = false) {
75
  if ($graceful) {
76
  return false;
77
  }
78
+ throw new Exception(sprintf(Mage::helper('securetrading_stpp')->__('A transaction with a transaction reference of "%s" cannot be found.'), $transactionReference));
79
  }
80
  return $this;
81
  }
app/code/local/Securetrading/Stpp/controllers/Direct/PostController.php CHANGED
@@ -3,21 +3,16 @@
3
  class Securetrading_Stpp_Direct_PostController extends Mage_Core_Controller_Front_Action {
4
  protected $_methodInstance;
5
 
 
 
6
  public function preDispatch() {
7
  parent::preDispatch();
8
-
9
- if (Mage::getSingleton('checkout/session')->getQuote()->getIsMultiShipping()) {
10
- $orderIncrementId = array_shift(Mage::getModel('core/session')->getOrderIds());
11
- }
12
- else {
13
- $orderIncrementId = Mage::getModel('checkout/session')->getLastRealOrderId(); //onepage checkout
14
- }
15
-
16
- $this->_methodInstance = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId)->getPayment()->getMethodInstance();
17
-
18
- if ($this->_methodInstance->getCode() !== Mage::getModel('securetrading_stpp/payment_direct')->getCode()) {
19
- throw new Exception(Mage::helper('securetrading_stpp')->__('Cannot access payment method.'));
20
  }
 
21
  }
22
 
23
  public function rawAction() {
@@ -31,8 +26,8 @@ class Securetrading_Stpp_Direct_PostController extends Mage_Core_Controller_Fron
31
  }
32
 
33
  public function iframeAction() {
34
- Mage::register(Securetrading_Stpp_Block_Payment_Iframe::REGISTRY_IFRAME_HEIGHT_KEY, $this->_methodInstance->getConfigData('api_iframe_height'));
35
- Mage::register(Securetrading_Stpp_Block_Payment_Iframe::REGISTRY_IFRAME_WIDTH_KEY, $this->_methodInstance->getConfigData('api_iframe_width'));
36
  $this->loadLayout();
37
  $this->renderLayout();
38
  }
3
  class Securetrading_Stpp_Direct_PostController extends Mage_Core_Controller_Front_Action {
4
  protected $_methodInstance;
5
 
6
+ const REGISTRY_METHOD_INSTANCE_KEY = 'securetrading_stpp_direct_postcontroller_registry_method_instance_key';
7
+
8
  public function preDispatch() {
9
  parent::preDispatch();
10
+ $orderIncrementIds = Mage::helper('securetrading_stpp')->getOrderIncrementIdsFromSession();
11
+ $this->_methodInstance = Mage::getModel('sales/order')->loadByIncrementId(array_shift($orderIncrementIds))->getPayment()->getMethodInstance();
12
+ if (!Mage::helper('securetrading_stpp')->isSecuretradingApiTypePaymentMethod($this->_methodInstance->getCode())) {
13
+ throw new Exception(Mage::helper('securetrading_stpp')->__('Cannot access payment method.'));
 
 
 
 
 
 
 
 
14
  }
15
+ Mage::register(self::REGISTRY_METHOD_INSTANCE_KEY, $this->_methodInstance);
16
  }
17
 
18
  public function rawAction() {
26
  }
27
 
28
  public function iframeAction() {
29
+ Mage::register(Securetrading_Stpp_Block_Payment_Iframe::REGISTRY_IFRAME_HEIGHT_KEY, $this->_methodInstance->getConfigData('iframe_height'));
30
+ Mage::register(Securetrading_Stpp_Block_Payment_Iframe::REGISTRY_IFRAME_WIDTH_KEY, $this->_methodInstance->getConfigData('iframe_width'));
31
  $this->loadLayout();
32
  $this->renderLayout();
33
  }
app/code/local/Securetrading/Stpp/controllers/DirectController.php CHANGED
@@ -2,24 +2,37 @@
2
 
3
  class Securetrading_Stpp_DirectController extends Mage_Core_Controller_Front_Action {
4
  public function returnAction() {
5
- $result = Mage::getModel('securetrading_stpp/payment_direct')->run3dAuth();
6
- if ($result) {
7
- if (Mage::getModel('core/session')->getOrderIds()) {
8
- $path = 'checkout/multishipping/success';
9
- }
10
- else {
11
- $path = 'checkout/onepage/success';
12
- }
13
- }
14
- else {
15
- if (Mage::getModel('core/session')->getOrderIds()) {
16
- $path = 'checkout/multishipping/billing';
17
- }
18
- else {
19
- $path = 'checkout/cart';
20
- }
21
- }
22
- $queryArgs = array('path' => $path);
23
- $this->_redirect('securetrading/payment/location', array('_query' => $queryArgs));
24
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  }
2
 
3
  class Securetrading_Stpp_DirectController extends Mage_Core_Controller_Front_Action {
4
  public function returnAction() {
5
+ $paymentMethod = $this->_getPaymentMethod();
6
+ $isMultishipping = Mage::helper('securetrading_stpp')->isMultishippingCheckout();
7
+ if ($isMultishipping) {
8
+ $paymentMethod->setIsMultishipping(true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  }
10
+ $result = $paymentMethod->run3dAuth();
11
+
12
+ $path = $this->_calculatePath($result, $isMultishipping);
13
+ $queryArgs = array('path' => $path);
14
+ $this->_redirect('securetrading/payment/location', array('_query' => $queryArgs));
15
+ }
16
+
17
+ protected function _getPaymentMethod() {
18
+ $orderIncrementIds = Mage::helper('securetrading_stpp')->getOrderIncrementIdsFromSession();
19
+ $firstOrderIncrementId = array_shift($orderIncrementIds);
20
+ return Mage::getModel('sales/order')->loadByIncrementId($firstOrderIncrementId)->getPayment()->getMethodInstance();
21
+ }
22
+
23
+ protected function _calculatePath($result, $isMultishipping) {
24
+ $paths = array(
25
+ 'success' => array(
26
+ 'onepage' => 'checkout/onepage/success',
27
+ 'multishipping' => 'checkout/multishipping/success',
28
+ ),
29
+ 'failure' => array(
30
+ 'onepage' => 'checkout/cart',
31
+ 'multishipping' => 'checkout/multishipping/billing'
32
+ )
33
+ );
34
+ $key1 = $result ? 'success' : 'failure';
35
+ $key2 = $isMultishipping ? 'multishipping' : 'onepage';
36
+ return $paths[$key1][$key2];
37
+ }
38
  }
app/code/local/Securetrading/Stpp/controllers/MultishippingController.php CHANGED
@@ -22,6 +22,10 @@ class Securetrading_Stpp_MultishippingController extends Mage_Checkout_Multiship
22
  $order->getPayment()->getMethodInstance()->setIsFirstMultishipping(true);
23
  }
24
  $order->setQuote(Mage::getModel('sales/quote')->load($order->getQuoteId()));
 
 
 
 
25
  $order->getPayment()->place();
26
  $order->save();
27
  }
@@ -37,9 +41,11 @@ class Securetrading_Stpp_MultishippingController extends Mage_Checkout_Multiship
37
  public function overviewPostAction()
38
  {
39
  // start st added
40
- if (!in_array($this->_getCheckout()->getQuote()->getPayment()->getMethodInstance()->getCode(), array('securetrading_stpp_direct', 'securetrading_stpp_redirect'))) {
41
  return parent::overviewPostAction();
42
  }
 
 
43
 
44
  $versionInfo = Mage::getVersionInfo();
45
  $validateFormKey = false;
@@ -85,20 +91,16 @@ class Securetrading_Stpp_MultishippingController extends Mage_Checkout_Multiship
85
  $this->_getCheckout()->createOrders();
86
 
87
  // start st added
88
- if ($this->_getCheckout()->getQuote()->getPayment()->getMethodInstance()->getCode() === Mage::getModel('securetrading_stpp/payment_direct')->getCode()) {
89
  $this->_doApiMultishippingPayment();
90
 
91
  }
92
-
93
  $this->_getCheckout()->getQuote()
94
  ->setIsActive(true)
95
  ->save();
96
-
97
- if ($this->_getCheckout()->getQuote()->getPayment()->getMethodInstance()->getCode() === Mage::getModel('securetrading_stpp/payment_redirect')->getCode()) {
98
- $path = Mage::getModel('securetrading_stpp/payment_redirect')->getMultishippingRedirectPath();
99
- $this->_redirect($path);
100
- }
101
- else { // direct
102
  $orderPlaceRedirectUrl = $this->_getCheckout()->getQuote()->getPayment()->getMethodInstance()->getOrderPlaceRedirectUrl();
103
  if ($orderPlaceRedirectUrl) {
104
  $this->getResponse()->setRedirect($orderPlaceRedirectUrl);
@@ -111,6 +113,10 @@ class Securetrading_Stpp_MultishippingController extends Mage_Checkout_Multiship
111
  $this->_redirect('*/*/success');
112
  }
113
  }
 
 
 
 
114
  // end st added
115
  } catch (Mage_Payment_Model_Info_Exception $e) {
116
  $message = $e->getMessage();
22
  $order->getPayment()->getMethodInstance()->setIsFirstMultishipping(true);
23
  }
24
  $order->setQuote(Mage::getModel('sales/quote')->load($order->getQuoteId()));
25
+ }
26
+
27
+ for ($i = 0; $i < count($orders); $i++) { # two loops so is_first_multishipping and is_multishipping set on all orders before this loop begins (first order in this loop makes api request so process*() functions are called)
28
+ $order = $orders[$i];
29
  $order->getPayment()->place();
30
  $order->save();
31
  }
41
  public function overviewPostAction()
42
  {
43
  // start st added
44
+ if (!Mage::helper('securetrading_stpp')->isSecuretradingPaymentMethod($this->_getCheckout()->getQuote()->getPayment()->getMethodInstance()->getCode())) {
45
  return parent::overviewPostAction();
46
  }
47
+
48
+ Mage::getSingleton('checkout/session')->unsLastBillingAgreementId();
49
 
50
  $versionInfo = Mage::getVersionInfo();
51
  $validateFormKey = false;
91
  $this->_getCheckout()->createOrders();
92
 
93
  // start st added
94
+ if (Mage::helper('securetrading_stpp')->isSecuretradingApiTypePaymentMethod($this->_getCheckout()->getQuote()->getPayment()->getMethodInstance()->getCode())) {
95
  $this->_doApiMultishippingPayment();
96
 
97
  }
98
+
99
  $this->_getCheckout()->getQuote()
100
  ->setIsActive(true)
101
  ->save();
102
+
103
+ if (Mage::helper('securetrading_stpp')->isSecuretradingApiTypePaymentMethod($this->_getCheckout()->getQuote()->getPayment()->getMethodInstance()->getCode())) {
 
 
 
 
104
  $orderPlaceRedirectUrl = $this->_getCheckout()->getQuote()->getPayment()->getMethodInstance()->getOrderPlaceRedirectUrl();
105
  if ($orderPlaceRedirectUrl) {
106
  $this->getResponse()->setRedirect($orderPlaceRedirectUrl);
113
  $this->_redirect('*/*/success');
114
  }
115
  }
116
+ else {
117
+ $path = Mage::getModel('securetrading_stpp/payment_redirect')->getMultishippingRedirectPath();
118
+ $this->_redirect($path);
119
+ }
120
  // end st added
121
  } catch (Mage_Payment_Model_Info_Exception $e) {
122
  $message = $e->getMessage();
app/code/local/Securetrading/Stpp/controllers/RedirectController.php CHANGED
@@ -1,54 +1,69 @@
1
  <?php
2
 
3
  class Securetrading_Stpp_RedirectController extends Mage_Core_Controller_Front_Action {
4
- public function notificationAction() {
5
- Mage::getModel('securetrading_stpp/payment_redirect')
6
- ->log(sprintf('In %s.', __METHOD__))
7
- ->runNotification();
8
- exit($this->__("Notification complete."));
9
- }
 
 
 
 
 
10
 
11
- public function redirectAction() {
12
- Mage::getModel('securetrading_stpp/payment_redirect')
13
- ->log(sprintf('In %s.', __METHOD__))
14
- ->runRedirect();
15
-
16
- if (Mage::helper('securetrading_stpp')->ordersAreSuccessful($this->_getOrderIncrementIds())) {
17
- if (Mage::getSingleton('checkout/session')->setLoadInactive(true)->getQuote()->getIsMultiShipping()) {
18
- Mage::getSingleton('checkout/session')->clear();
19
- Mage::getSingleton('checkout/session')->setDisplaySuccess(true);
20
 
21
- Mage::getSingleton('checkout/type_multishipping_state')->setCompleteStep(Mage_Checkout_Model_Type_Multishipping_State::STEP_OVERVIEW);
22
- Mage::getSingleton('checkout/type_multishipping_state')->setActiveStep(Mage_Checkout_Model_Type_Multishipping_State::STEP_SUCCESS);
23
-
24
- $path = 'checkout/multishipping/success';
25
- }
26
- else {
27
- $path = 'checkout/onepage/success';
28
- }
29
- }
30
- else {
31
- Mage::getSingleton('checkout/session')->addError(sprintf(Mage::helper('securetrading_stpp')->__('These order(s) were not processed successfully: %s'), implode(', ', $this->_getOrderIncrementIds())));
32
- $path = 'checkout/cart';
33
- }
34
-
35
- $queryArgs = array('path' => $path);
36
- $this->_redirect('securetrading/payment/location', array('_query' => $queryArgs));
37
- }
38
-
39
- protected function _getOrderIncrementIds() {
40
- $serializedIncrementIds = $this->getRequest()->getParam('order_increment_ids');
41
- $orderIncrementIds = @unserialize($serializedIncrementIds);
42
 
43
- if ($orderIncrementIds === false && $serializedIncrementIds !== serialize(false)) {
44
- throw new Exception(sprintf(Mage::helper('securetrading_stpp')->__('The string "%s" could not be unserialized.'), $serializedIncrementIds));
45
- }
46
 
47
- foreach($orderIncrementIds as $orderIncrementId) { // If responsesitesecurity is not returned the user input is untrusted. Make sure the order IDs are actually in this customers session.
48
- if (!in_array($orderIncrementId,Mage::getSingleton('core/session')->getOrderIds()) && $orderIncrementId !== Mage::getSingleton('checkout/session')->getLastRealOrderId()) {
49
- throw new Exception(sprintf(Mage::helper('securetrading_stpp')->__('The order increment ID "%s" was not in the session.'), $orderIncrementId));
50
- }
51
- }
52
- return $orderIncrementIds;
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  }
1
  <?php
2
 
3
  class Securetrading_Stpp_RedirectController extends Mage_Core_Controller_Front_Action {
4
+ public function notificationAction() {
5
+ Mage::getModel('securetrading_stpp/payment_redirect')
6
+ ->log(sprintf('In %s.', __METHOD__))
7
+ ->runNotification();
8
+ exit($this->__("Notification complete."));
9
+ }
10
+
11
+ public function redirectAction() {
12
+ Mage::getModel('securetrading_stpp/payment_redirect')
13
+ ->log(sprintf('In %s.', __METHOD__))
14
+ ->runRedirect();
15
 
16
+ if (Mage::getModel('securetrading_stpp/payment_redirect')->ordersAreSuccessful($this->_getOrderIncrementIds())) {
17
+ $this->_setBillingAgreementToSession();
18
+ Mage::getModel('securetrading_stpp/payment_redirect')->onRedirect($this->_getOrderIncrementIds(), $this->getRequest()->getParam('errorcode'), $this->getRequest()->getParam('paymenttypedescription'));
 
 
 
 
 
 
19
 
20
+ if (Mage::getSingleton('checkout/session')->setLoadInactive(true)->getQuote()->getIsMultiShipping()) {
21
+ Mage::getSingleton('checkout/session')->clear();
22
+ Mage::getSingleton('checkout/session')->setDisplaySuccess(true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
+ Mage::getSingleton('checkout/type_multishipping_state')->setCompleteStep(Mage_Checkout_Model_Type_Multishipping_State::STEP_OVERVIEW);
25
+ Mage::getSingleton('checkout/type_multishipping_state')->setActiveStep(Mage_Checkout_Model_Type_Multishipping_State::STEP_SUCCESS);
 
26
 
27
+ $path = 'checkout/multishipping/success';
28
+ }
29
+ else {
30
+ $path = 'checkout/onepage/success';
31
+ }
32
+ }
33
+ else {
34
+ Mage::getSingleton('checkout/session')->addError(sprintf(Mage::helper('securetrading_stpp')->__('These order(s) were not processed successfully: %s'), implode(', ', $this->_getOrderIncrementIds())));
35
+ $path = 'checkout/cart';
36
+ }
37
+
38
+ $queryArgs = array('path' => $path);
39
+ $this->_redirect('securetrading/payment/location', array('_query' => $queryArgs));
40
+ }
41
+
42
+ protected function _getOrderIncrementIds() {
43
+ $serializedIncrementIds = $this->getRequest()->getParam('order_increment_ids');
44
+ $orderIncrementIds = @unserialize($serializedIncrementIds);
45
+
46
+ if ($orderIncrementIds === false && $serializedIncrementIds !== serialize(false)) {
47
+ throw new Exception(sprintf(Mage::helper('securetrading_stpp')->__('The string "%s" could not be unserialized.'), $serializedIncrementIds));
48
+ }
49
+
50
+ foreach($orderIncrementIds as $orderIncrementId) { // If responsesitesecurity is not returned the user input is untrusted. Make sure the order IDs are actually in this customers session.
51
+ if ((is_array(Mage::getSingleton('core/session')->getOrderIds()) && !in_array($orderIncrementId,Mage::getSingleton('core/session')->getOrderIds())) && $orderIncrementId !== Mage::getSingleton('checkout/session')->getLastRealOrderId()) {
52
+ throw new Exception(sprintf(Mage::helper('securetrading_stpp')->__('The order increment ID "%s" was not in the session.'), $orderIncrementId));
53
+ }
54
+ }
55
+ return $orderIncrementIds;
56
+ }
57
+
58
+ protected function _setBillingAgreementToSession() {
59
+ $orderIncrementIds = $this->_getOrderIncrementIds();
60
+ $firstOrderId = Mage::getModel('sales/order')->loadByIncrementId(array_shift($orderIncrementIds))->getId();
61
+ $order = Mage::getModel('securetrading_stpp/payment_tokenization')->getOrderAndBillingAgreementData($firstOrderId);
62
+ if ($order->getAgreementId()) {
63
+ Mage::getSingleton('checkout/session')->setLastBillingAgreementId($order->getAgreementId());
64
+ }
65
+ else {
66
+ Mage::getSingleton('checkout/session')->unsLastBillingAgreementId();
67
+ }
68
+ }
69
  }
app/code/local/Securetrading/Stpp/controllers/Sales/Order/Create/SecuretradingController.php CHANGED
@@ -16,7 +16,7 @@ class Securetrading_Stpp_Sales_Order_Create_SecuretradingController extends Mage
16
  public function preDispatch() {
17
  parent::preDispatch();
18
  if (!in_array($this->getRequest()->getRequestedActionName(), array('redirect', 'location'))) {
19
- Mage::getModel('securetrading_stpp/payment_redirect')->validateOrders($this->_getOrderIncrementIds());
20
  $this->_methodInstance = Mage::getModel('securetrading_stpp/payment_redirect')->getFirstMethodInstance($this->_getOrderIncrementIds());
21
  $this->_methodInstance->setStore($this->_methodInstance->getInfoInstance()->getOrder()->getStore()->getId());
22
  }
@@ -61,7 +61,8 @@ class Securetrading_Stpp_Sales_Order_Create_SecuretradingController extends Mage
61
 
62
  Mage::getSingleton('adminhtml/session')->clear();
63
 
64
- if (Mage::helper('securetrading_stpp')->orderIsSuccessful($orderIncrementId)) {
 
65
  Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The order has been created.'));
66
  }
67
  else {
16
  public function preDispatch() {
17
  parent::preDispatch();
18
  if (!in_array($this->getRequest()->getRequestedActionName(), array('redirect', 'location'))) {
19
+ Mage::getModel('securetrading_stpp/payment_redirect')->validateOrdersArePendingPpages($this->_getOrderIncrementIds());
20
  $this->_methodInstance = Mage::getModel('securetrading_stpp/payment_redirect')->getFirstMethodInstance($this->_getOrderIncrementIds());
21
  $this->_methodInstance->setStore($this->_methodInstance->getInfoInstance()->getOrder()->getStore()->getId());
22
  }
61
 
62
  Mage::getSingleton('adminhtml/session')->clear();
63
 
64
+ if (Mage::getModel('securetrading_stpp/payment_redirect')->orderIsSuccessful($orderIncrementId)) {
65
+ Mage::getModel('securetrading_stpp/payment_redirect')->onRedirect(array($orderIncrementId), $this->getRequest()->getParam('errorcode'), $this->getRequest()->getParam('paymenttypedescription'));
66
  Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The order has been created.'));
67
  }
68
  else {
app/code/local/Securetrading/Stpp/controllers/TokenizationController.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Securetrading_Stpp_TokenizationController extends Mage_Core_Controller_Front_Action {
3
+ public function preDispatch() {
4
+ parent::preDispatch();
5
+ if (!Mage::getSingleton('customer/session')->authenticate($this)) {
6
+ $this->setFlag('', 'no-dispatch', true);
7
+ }
8
+ }
9
+
10
+ public function newAction() {
11
+ $this->_title($this->__('Billing Agreements'));
12
+ $this->loadLayout();
13
+ $this->renderLayout();
14
+ }
15
+
16
+ public function newPostAction() {
17
+ try {
18
+ $request = $this->getRequest();
19
+ $agreement = Mage::getModel('securetrading_stpp/payment_direct')->runCardstore(
20
+ $request->getParam('payment_type'),
21
+ $request->getParam('start_date_month'),
22
+ $request->getParam('start_date_year'),
23
+ $request->getParam('expiry_date_month'),
24
+ $request->getParam('expiry_date_year'),
25
+ $request->getParam('card_number'),
26
+ $request->getParam('issue_number')
27
+ );
28
+
29
+ Mage::getSingleton('customer/session')->addSuccess(
30
+ $this->__('The billing agreement "%s" has been created.', $agreement->getReferenceId())
31
+ );
32
+ $this->_redirect('sales/billing_agreement/view', array('agreement' => $agreement->getId()));
33
+ }
34
+ catch (Exception $e) {
35
+ Mage::logException($e);
36
+ Mage::getSingleton('customer/session')->addError($this->__('Unable to create billing agreement.'));
37
+ $this->_redirect('sales/billing_agreement/index');
38
+ }
39
+ }
40
+ }
app/code/local/Securetrading/Stpp/etc/config.xml CHANGED
@@ -3,7 +3,7 @@
3
  <config>
4
  <modules>
5
  <Securetrading_Stpp>
6
- <version>3.4.0</version>
7
  </Securetrading_Stpp>
8
  </modules>
9
 
@@ -35,9 +35,10 @@
35
  <secure_url>
36
  <securetrading_redirect_post_onepage>/securetrading/redirect_post_onepage</securetrading_redirect_post_onepage>
37
  <securetrading_redirect_post_multishipping>/securetrading/redirect_post_multishipping</securetrading_redirect_post_multishipping>
38
- <securetrading_direct_post>/securetrading/direct_post</securetrading_direct_post>
39
  <securetrading_direct_return>/securetrading/direct/return</securetrading_direct_return>
40
  <securetrading_payment_location>/securetrading/payment/location</securetrading_payment_location>
 
41
  </secure_url>
42
  </frontend>
43
 
@@ -101,6 +102,12 @@
101
  <transaction_types>
102
  <table>securetrading_stpp_transaction_types</table>
103
  </transaction_types>
 
 
 
 
 
 
104
  </entities>
105
  </securetrading_stpp_resource>
106
  </models>
@@ -121,7 +128,7 @@
121
  </securetrading_stpp>
122
  </observers>
123
  </payment_info_block_prepare_specific_information>
124
- <checkout_type_multishipping_create_orders_single>
125
  <observers>
126
  <securetrading_stpp>
127
  <class>Securetrading_Stpp_Model_Observer</class>
@@ -137,6 +144,14 @@
137
  </securetrading_stpp>
138
  </observers>
139
  </adminhtml_init_system_config>
 
 
 
 
 
 
 
 
140
  </events>
141
  </global>
142
  <crontab>
@@ -165,15 +180,25 @@
165
  <model>securetrading_stpp/cron::updateOldOrders</model>
166
  </run>
167
  </securetrading_stpp_update_old_orders>
 
 
 
 
 
 
 
 
168
  </jobs>
169
  </crontab>
170
  <default>
171
  <payment>
172
- <securetrading_stpp_direct>
173
- <model>securetrading_stpp/payment_direct</model>
 
174
  <accepted_cards backend_model="securetrading_stpp/adminhtml_system_config_backend_multiselect" />
175
- <api_iframe_width>100%</api_iframe_width>
176
- <api_iframe_height>600px</api_iframe_height>
 
177
  <stapi_alias backend_model="adminhtml/system_config_backend_encrypted" />
178
  <stapi_host backend_model="adminhtml/system_config_backend_encrypted" />
179
  <stapi_port backend_model="adminhtml/system_config_backend_encrypted" />
@@ -185,6 +210,29 @@
185
  <transactionsearch_password backend_model="adminhtml/system_config_backend_encrypted" />
186
  <transactionsearch_verify_ca>1</transactionsearch_verify_ca>
187
  </securetrading_stpp_direct>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  <securetrading_stpp_redirect>
189
  <model>securetrading_stpp/payment_redirect</model>
190
  <site_security_password backend_model="adminhtml/system_config_backend_encrypted" />
3
  <config>
4
  <modules>
5
  <Securetrading_Stpp>
6
+ <version>3.5.0</version>
7
  </Securetrading_Stpp>
8
  </modules>
9
 
35
  <secure_url>
36
  <securetrading_redirect_post_onepage>/securetrading/redirect_post_onepage</securetrading_redirect_post_onepage>
37
  <securetrading_redirect_post_multishipping>/securetrading/redirect_post_multishipping</securetrading_redirect_post_multishipping>
38
+ <securetrading_direct_post>/securetrading/direct_post</securetrading_direct_post>
39
  <securetrading_direct_return>/securetrading/direct/return</securetrading_direct_return>
40
  <securetrading_payment_location>/securetrading/payment/location</securetrading_payment_location>
41
+ <securetrading_tokenization>/securetrading/tokenization</securetrading_tokenization>
42
  </secure_url>
43
  </frontend>
44
 
102
  <transaction_types>
103
  <table>securetrading_stpp_transaction_types</table>
104
  </transaction_types>
105
+ <billing_agreement_currency>
106
+ <table>securetrading_stpp_billing_agreement_currency</table>
107
+ </billing_agreement_currency>
108
+ <billing_agreement_paymenttypedescription>
109
+ <table>securetrading_stpp_billing_agreement_paymenttypedescription</table>
110
+ </billing_agreement_paymenttypedescription>
111
  </entities>
112
  </securetrading_stpp_resource>
113
  </models>
128
  </securetrading_stpp>
129
  </observers>
130
  </payment_info_block_prepare_specific_information>
131
+ <checkout_type_multishipping_create_orders_single>
132
  <observers>
133
  <securetrading_stpp>
134
  <class>Securetrading_Stpp_Model_Observer</class>
144
  </securetrading_stpp>
145
  </observers>
146
  </adminhtml_init_system_config>
147
+ <checkout_type_onepage_save_order_after>
148
+ <observers>
149
+ <securetrading_stpp>
150
+ <class>Securetrading_Stpp_Model_Observer</class>
151
+ <method>onCheckoutTypeOnepageSaveOrderAfter</method>
152
+ </securetrading_stpp>
153
+ </observers>
154
+ </checkout_type_onepage_save_order_after>
155
  </events>
156
  </global>
157
  <crontab>
180
  <model>securetrading_stpp/cron::updateOldOrders</model>
181
  </run>
182
  </securetrading_stpp_update_old_orders>
183
+ <securetrading_stpp_update_sofort_transactions>
184
+ <schedule>
185
+ <cron_expr>0 * * * *</cron_expr>
186
+ </schedule>
187
+ <run>
188
+ <model>securetrading_stpp/cron::updateSofortTransactions</model>
189
+ </run>
190
+ </securetrading_stpp_update_sofort_transactions>
191
  </jobs>
192
  </crontab>
193
  <default>
194
  <payment>
195
+ <securetrading_stpp_direct>
196
+ <model>securetrading_stpp/payment_direct</model>
197
+ <payment_action>authorize_capture</payment_action>
198
  <accepted_cards backend_model="securetrading_stpp/adminhtml_system_config_backend_multiselect" />
199
+ <use_iframe>1</use_iframe>
200
+ <iframe_width>100%</iframe_width>
201
+ <iframe_height>600px</iframe_height>
202
  <stapi_alias backend_model="adminhtml/system_config_backend_encrypted" />
203
  <stapi_host backend_model="adminhtml/system_config_backend_encrypted" />
204
  <stapi_port backend_model="adminhtml/system_config_backend_encrypted" />
210
  <transactionsearch_password backend_model="adminhtml/system_config_backend_encrypted" />
211
  <transactionsearch_verify_ca>1</transactionsearch_verify_ca>
212
  </securetrading_stpp_direct>
213
+ <securetrading_stpp_tokenization>
214
+ <model>securetrading_stpp/payment_tokenization</model>
215
+ <use_iframe>1</use_iframe>
216
+ <iframe_width>100%</iframe_width>
217
+ <iframe_height>600px</iframe_height>
218
+ <accepted_cards backend_model="securetrading_stpp/adminhtml_system_config_backend_multiselect" />
219
+ <use_risk_decision>0</use_risk_decision>
220
+ <use_account_check>0</use_account_check>
221
+ <use_card_store>0</use_card_store>
222
+ <max_saved_cc>10</max_saved_cc>
223
+ <!--
224
+ <stapi_alias backend_model="adminhtml/system_config_backend_encrypted" />
225
+ <stapi_host backend_model="adminhtml/system_config_backend_encrypted" />
226
+ <stapi_port backend_model="adminhtml/system_config_backend_encrypted" />
227
+ <ws_alias backend_model="adminhtml/system_config_backend_encrypted" />
228
+ <ws_username backend_model="adminhtml/system_config_backend_encrypted" />
229
+ <ws_password backend_model="adminhtml/system_config_backend_encrypted" />
230
+ <ws_verify_ca>1</ws_verify_ca>
231
+ <transactionsearch_username backend_model="adminhtml/system_config_backend_encrypted" />
232
+ <transactionsearch_password backend_model="adminhtml/system_config_backend_encrypted" />
233
+ <transactionsearch_verify_ca>1</transactionsearch_verify_ca>
234
+ -->
235
+ </securetrading_stpp_tokenization>
236
  <securetrading_stpp_redirect>
237
  <model>securetrading_stpp/payment_redirect</model>
238
  <site_security_password backend_model="adminhtml/system_config_backend_encrypted" />
app/code/local/Securetrading/Stpp/etc/system.xml CHANGED
@@ -200,11 +200,29 @@
200
  <show_in_store>1</show_in_store>
201
  </sub_site_reference>
202
  -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  <use_api>
204
  <config_path>payment/securetrading_stpp_redirect/use_api</config_path>
205
  <frontend_type>select</frontend_type>
206
  <source_model>adminhtml/system_config_source_yesno</source_model>
207
- <sort_order>10</sort_order>
208
  <show_in_default>1</show_in_default>
209
  <show_in_website>1</show_in_website>
210
  <show_in_store>1</show_in_store>
@@ -213,7 +231,7 @@
213
  <config_path>payment/securetrading_stpp_redirect/payment_action</config_path>
214
  <frontend_type>select</frontend_type>
215
  <source_model>securetrading_stpp/source_paymentaction</source_model>
216
- <sort_order>11</sort_order>
217
  <show_in_default>1</show_in_default>
218
  <show_in_website>1</show_in_website>
219
  <show_in_store>1</show_in_store>
@@ -222,7 +240,7 @@
222
  <config_path>payment/securetrading_stpp_redirect/settle_due_date</config_path>
223
  <frontend_type>select</frontend_type>
224
  <source_model>securetrading_stpp/source_settleduedate</source_model>
225
- <sort_order>12</sort_order>
226
  <show_in_default>1</show_in_default>
227
  <show_in_website>1</show_in_website>
228
  <show_in_store>1</show_in_store>
@@ -231,7 +249,7 @@
231
  <config_path>payment/securetrading_stpp_redirect/settle_status</config_path>
232
  <frontend_type>select</frontend_type>
233
  <source_model>securetrading_stpp/source_settlestatus</source_model>
234
- <sort_order>13</sort_order>
235
  <show_in_default>1</show_in_default>
236
  <show_in_website>1</show_in_website>
237
  <show_in_store>1</show_in_store>
@@ -452,31 +470,31 @@
452
  <show_in_website>1</show_in_website>
453
  <show_in_store>1</show_in_store>
454
  </specificcountry>
455
- <api_use_iframe>
456
- <config_path>payment/securetrading_stpp_direct/api_use_iframe</config_path>
457
  <frontend_type>select</frontend_type>
458
  <source_model>adminhtml/system_config_source_yesno</source_model>
459
  <sort_order>5</sort_order>
460
  <show_in_default>1</show_in_default>
461
  <show_in_website>1</show_in_website>
462
  <show_in_store>1</show_in_store>
463
- </api_use_iframe>
464
- <api_iframe_height>
465
- <config_path>payment/securetrading_stpp_direct/api_iframe_height</config_path>
466
  <frontend_type>text</frontend_type>
467
  <sort_order>6</sort_order>
468
  <show_in_default>1</show_in_default>
469
  <show_in_website>1</show_in_website>
470
  <show_in_store>1</show_in_store>
471
- </api_iframe_height>
472
- <api_iframe_width>
473
- <config_path>payment/securetrading_stpp_direct/api_iframe_width</config_path>
474
  <frontend_type>text</frontend_type>
475
  <sort_order>7</sort_order>
476
  <show_in_default>1</show_in_default>
477
  <show_in_website>1</show_in_website>
478
  <show_in_store>1</show_in_store>
479
- </api_iframe_width>
480
  </fields>
481
  </securetrading_stpp_direct_config_basic>
482
 
@@ -498,7 +516,6 @@
498
  <show_in_website>1</show_in_website>
499
  <show_in_store>1</show_in_store>
500
  </site_reference>
501
-
502
  <use_3d_secure>
503
  <config_path>payment/securetrading_stpp_direct/use_3d_secure</config_path>
504
  <frontend_type>select</frontend_type>
@@ -517,35 +534,33 @@
517
  <show_in_website>1</show_in_website>
518
  <show_in_store>1</show_in_store>
519
  </use_risk_decision>
520
- <!--
521
- <use_card_store>
522
- <config_path>payment/securetrading_stpp_direct/use_card_store</config_path>
523
  <frontend_type>select</frontend_type>
524
  <source_model>adminhtml/system_config_source_yesno</source_model>
525
  <sort_order>3</sort_order>
526
  <show_in_default>1</show_in_default>
527
  <show_in_website>1</show_in_website>
528
  <show_in_store>1</show_in_store>
529
- </use_card_store>
530
- <use_auto_card_store>
531
- <config_path>payment/securetrading_stpp_direct/use_auto_card_store</config_path>
532
  <frontend_type>select</frontend_type>
533
  <source_model>adminhtml/system_config_source_yesno</source_model>
534
  <sort_order>4</sort_order>
535
  <show_in_default>1</show_in_default>
536
  <show_in_website>1</show_in_website>
537
  <show_in_store>1</show_in_store>
538
- </use_auto_card_store>
539
- <delay_risk_decision>
540
- <config_path>payment/securetrading_stpp_direct/delay_risk_decision</config_path>
541
- <frontend_type>select</frontend_type>
542
- <source_model>adminhtml/system_config_source_yesno</source_model>
543
- <sort_order>5</sort_order>
544
- <show_in_default>1</show_in_default>
545
- <show_in_website>1</show_in_website>
546
- <show_in_store>1</show_in_store>
547
- </delay_risk_decision>
548
- -->
549
  <accepted_cards>
550
  <config_path>payment/securetrading_stpp_direct/accepted_cards</config_path>
551
  <frontend_type>multiselect</frontend_type>
@@ -601,6 +616,15 @@
601
  <show_in_website>1</show_in_website>
602
  <show_in_store>1</show_in_store>
603
  </show_issue_number>
 
 
 
 
 
 
 
 
 
604
  </fields>
605
  </securetrading_stpp_direct_config_gateway>
606
  <securetrading_stpp_direct_config_connections>
@@ -763,6 +787,115 @@
763
  </transactionsearch_ca_file>
764
  </fields>
765
  </securetrading_stpp_direct_transactionsearch>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
766
  </groups>
767
  </securetrading_stpp>
768
  </sections>
@@ -820,7 +953,7 @@
820
  <comment>Allows customers to make debit/credit card payments without leaving your store.<![CDATA[<BR />]]>Your website must be PCI compliant to use this payment method.</comment>
821
  <frontend_model>securetrading_stpp/adminhtml_system_config_fieldset_fields</frontend_model>
822
  <expanded>0</expanded>
823
- <sort_order>1</sort_order>
824
  <show_in_default>1</show_in_default>
825
  <show_in_website>1</show_in_website>
826
  <show_in_store>1</show_in_store>
@@ -849,6 +982,18 @@
849
  </securetrading_stpp_direct_transactionsearch>
850
  </fields>
851
  </securetrading_stpp_direct>
 
 
 
 
 
 
 
 
 
 
 
 
852
  </fields>
853
  </securetrading_stpp>
854
  </groups>
200
  <show_in_store>1</show_in_store>
201
  </sub_site_reference>
202
  -->
203
+ <use_tokenization>
204
+ <config_path>payment/securetrading_stpp_redirect/use_tokenization</config_path>
205
+ <frontend_type>select</frontend_type>
206
+ <source_model>adminhtml/system_config_source_yesno</source_model>
207
+ <sort_order>10</sort_order>
208
+ <show_in_default>1</show_in_default>
209
+ <show_in_website>1</show_in_website>
210
+ <show_in_store>1</show_in_store>
211
+ <comment>If you enable this feature you must also configure the Secure Trading Tokenization module.</comment>
212
+ </use_tokenization>
213
+ <save_cc_question>
214
+ <config_path>payment/securetrading_stpp_redirect/save_cc_question</config_path>
215
+ <frontend_type>textarea</frontend_type>
216
+ <sort_order>11</sort_order>
217
+ <show_in_default>1</show_in_default>
218
+ <show_in_website>1</show_in_website>
219
+ <show_in_store>1</show_in_store>
220
+ </save_cc_question>
221
  <use_api>
222
  <config_path>payment/securetrading_stpp_redirect/use_api</config_path>
223
  <frontend_type>select</frontend_type>
224
  <source_model>adminhtml/system_config_source_yesno</source_model>
225
+ <sort_order>12</sort_order>
226
  <show_in_default>1</show_in_default>
227
  <show_in_website>1</show_in_website>
228
  <show_in_store>1</show_in_store>
231
  <config_path>payment/securetrading_stpp_redirect/payment_action</config_path>
232
  <frontend_type>select</frontend_type>
233
  <source_model>securetrading_stpp/source_paymentaction</source_model>
234
+ <sort_order>13</sort_order>
235
  <show_in_default>1</show_in_default>
236
  <show_in_website>1</show_in_website>
237
  <show_in_store>1</show_in_store>
240
  <config_path>payment/securetrading_stpp_redirect/settle_due_date</config_path>
241
  <frontend_type>select</frontend_type>
242
  <source_model>securetrading_stpp/source_settleduedate</source_model>
243
+ <sort_order>14</sort_order>
244
  <show_in_default>1</show_in_default>
245
  <show_in_website>1</show_in_website>
246
  <show_in_store>1</show_in_store>
249
  <config_path>payment/securetrading_stpp_redirect/settle_status</config_path>
250
  <frontend_type>select</frontend_type>
251
  <source_model>securetrading_stpp/source_settlestatus</source_model>
252
+ <sort_order>15</sort_order>
253
  <show_in_default>1</show_in_default>
254
  <show_in_website>1</show_in_website>
255
  <show_in_store>1</show_in_store>
470
  <show_in_website>1</show_in_website>
471
  <show_in_store>1</show_in_store>
472
  </specificcountry>
473
+ <use_iframe>
474
+ <config_path>payment/securetrading_stpp_direct/use_iframe</config_path>
475
  <frontend_type>select</frontend_type>
476
  <source_model>adminhtml/system_config_source_yesno</source_model>
477
  <sort_order>5</sort_order>
478
  <show_in_default>1</show_in_default>
479
  <show_in_website>1</show_in_website>
480
  <show_in_store>1</show_in_store>
481
+ </use_iframe>
482
+ <iframe_height>
483
+ <config_path>payment/securetrading_stpp_direct/iframe_height</config_path>
484
  <frontend_type>text</frontend_type>
485
  <sort_order>6</sort_order>
486
  <show_in_default>1</show_in_default>
487
  <show_in_website>1</show_in_website>
488
  <show_in_store>1</show_in_store>
489
+ </iframe_height>
490
+ <iframe_width>
491
+ <config_path>payment/securetrading_stpp_direct/iframe_width</config_path>
492
  <frontend_type>text</frontend_type>
493
  <sort_order>7</sort_order>
494
  <show_in_default>1</show_in_default>
495
  <show_in_website>1</show_in_website>
496
  <show_in_store>1</show_in_store>
497
+ </iframe_width>
498
  </fields>
499
  </securetrading_stpp_direct_config_basic>
500
 
516
  <show_in_website>1</show_in_website>
517
  <show_in_store>1</show_in_store>
518
  </site_reference>
 
519
  <use_3d_secure>
520
  <config_path>payment/securetrading_stpp_direct/use_3d_secure</config_path>
521
  <frontend_type>select</frontend_type>
534
  <show_in_website>1</show_in_website>
535
  <show_in_store>1</show_in_store>
536
  </use_risk_decision>
537
+ <use_account_check>
538
+ <config_path>payment/securetrading_stpp_direct/use_account_check</config_path>
 
539
  <frontend_type>select</frontend_type>
540
  <source_model>adminhtml/system_config_source_yesno</source_model>
541
  <sort_order>3</sort_order>
542
  <show_in_default>1</show_in_default>
543
  <show_in_website>1</show_in_website>
544
  <show_in_store>1</show_in_store>
545
+ </use_account_check>
546
+ <use_card_store>
547
+ <config_path>payment/securetrading_stpp_direct/use_card_store</config_path>
548
  <frontend_type>select</frontend_type>
549
  <source_model>adminhtml/system_config_source_yesno</source_model>
550
  <sort_order>4</sort_order>
551
  <show_in_default>1</show_in_default>
552
  <show_in_website>1</show_in_website>
553
  <show_in_store>1</show_in_store>
554
+ <comment>If you enable this feature you must also configure the Secure Trading Tokenization module.</comment>
555
+ </use_card_store>
556
+ <save_cc_question>
557
+ <config_path>payment/securetrading_stpp_direct/save_cc_question</config_path>
558
+ <frontend_type>textarea</frontend_type>
559
+ <sort_order>5</sort_order>
560
+ <show_in_default>1</show_in_default>
561
+ <show_in_website>1</show_in_website>
562
+ <show_in_store>1</show_in_store>
563
+ </save_cc_question>
 
564
  <accepted_cards>
565
  <config_path>payment/securetrading_stpp_direct/accepted_cards</config_path>
566
  <frontend_type>multiselect</frontend_type>
616
  <show_in_website>1</show_in_website>
617
  <show_in_store>1</show_in_store>
618
  </show_issue_number>
619
+ <allow_billing_agreement_wizard>
620
+ <config_path>payment/securetrading_stpp_direct/allow_billing_agreement_wizard</config_path>
621
+ <frontend_type>select</frontend_type>
622
+ <source_model>adminhtml/system_config_source_yesno</source_model>
623
+ <sort_order>12</sort_order>
624
+ <show_in_default>1</show_in_default>
625
+ <show_in_website>1</show_in_website>
626
+ <show_in_store>1</show_in_store>
627
+ </allow_billing_agreement_wizard>
628
  </fields>
629
  </securetrading_stpp_direct_config_gateway>
630
  <securetrading_stpp_direct_config_connections>
787
  </transactionsearch_ca_file>
788
  </fields>
789
  </securetrading_stpp_direct_transactionsearch>
790
+ <securetrading_stpp_tokenization>
791
+ <fields>
792
+ <active>
793
+ <config_path>payment/securetrading_stpp_tokenization/active</config_path>
794
+ <frontend_type>select</frontend_type>
795
+ <source_model>adminhtml/system_config_source_yesno</source_model>
796
+ <sort_order>0</sort_order>
797
+ <show_in_default>1</show_in_default>
798
+ <show_in_website>1</show_in_website>
799
+ <show_in_store>1</show_in_store>
800
+ </active>
801
+ <title>
802
+ <config_path>payment/securetrading_stpp_tokenization/title</config_path>
803
+ <frontend_type>text</frontend_type>
804
+ <sort_order>1</sort_order>
805
+ <show_in_default>1</show_in_default>
806
+ <show_in_website>1</show_in_website>
807
+ <show_in_store>1</show_in_store>
808
+ </title>
809
+ <description>
810
+ <config_path>payment/securetrading_stpp_tokenization/description</config_path>
811
+ <frontend_type>textarea</frontend_type>
812
+ <sort_order>2</sort_order>
813
+ <show_in_default>1</show_in_default>
814
+ <show_in_website>1</show_in_website>
815
+ <show_in_store>1</show_in_store>
816
+ </description>
817
+ <allowspecific>
818
+ <config_path>payment/securetrading_stpp_tokenization/allowspecific</config_path>
819
+ <frontend_type>allowspecific</frontend_type>
820
+ <sort_order>3</sort_order>
821
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
822
+ <show_in_default>1</show_in_default>
823
+ <show_in_website>1</show_in_website>
824
+ <show_in_store>1</show_in_store>
825
+ </allowspecific>
826
+ <specificcountry>
827
+ <config_path>payment/securetrading_stpp_tokenization/specificcountry</config_path>
828
+ <frontend_type>multiselect</frontend_type>
829
+ <sort_order>4</sort_order>
830
+ <source_model>adminhtml/system_config_source_country</source_model>
831
+ <show_in_default>1</show_in_default>
832
+ <show_in_website>1</show_in_website>
833
+ <show_in_store>1</show_in_store>
834
+ </specificcountry>
835
+ <use_iframe>
836
+ <config_path>payment/securetrading_stpp_tokenization/use_iframe</config_path>
837
+ <frontend_type>select</frontend_type>
838
+ <source_model>adminhtml/system_config_source_yesno</source_model>
839
+ <sort_order>5</sort_order>
840
+ <show_in_default>1</show_in_default>
841
+ <show_in_website>1</show_in_website>
842
+ <show_in_store>1</show_in_store>
843
+ </use_iframe>
844
+ <iframe_height>
845
+ <config_path>payment/securetrading_stpp_tokenization/iframe_height</config_path>
846
+ <frontend_type>text</frontend_type>
847
+ <sort_order>6</sort_order>
848
+ <show_in_default>1</show_in_default>
849
+ <show_in_website>1</show_in_website>
850
+ <show_in_store>1</show_in_store>
851
+ </iframe_height>
852
+ <iframe_width>
853
+ <config_path>payment/securetrading_stpp_tokenization/iframe_width</config_path>
854
+ <frontend_type>text</frontend_type>
855
+ <sort_order>7</sort_order>
856
+ <show_in_default>1</show_in_default>
857
+ <show_in_website>1</show_in_website>
858
+ <show_in_store>1</show_in_store>
859
+ </iframe_width>
860
+ <max_saved_cc>
861
+ <config_path>payment/securetrading_stpp_tokenization/max_saved_cc</config_path>
862
+ <frontend_type>text</frontend_type>
863
+ <sort_order>8</sort_order>
864
+ <show_in_default>1</show_in_default>
865
+ <show_in_website>1</show_in_website>
866
+ <show_in_store>1</show_in_store>
867
+ </max_saved_cc>
868
+
869
+ <use_3d_secure>
870
+ <config_path>payment/securetrading_stpp_tokenization/use_3d_secure</config_path>
871
+ <frontend_type>select</frontend_type>
872
+ <source_model>adminhtml/system_config_source_yesno</source_model>
873
+ <sort_order>9</sort_order>
874
+ <show_in_default>1</show_in_default>
875
+ <show_in_website>1</show_in_website>
876
+ <show_in_store>1</show_in_store>
877
+ </use_3d_secure>
878
+ <accepted_cards>
879
+ <config_path>payment/securetrading_stpp_tokenization/accepted_cards</config_path>
880
+ <frontend_type>multiselect</frontend_type>
881
+ <backend_model>securetrading_stpp/adminhtml_system_config_backend_multiselect</backend_model>
882
+ <source_model>securetrading_stpp/source_cardtypes</source_model>
883
+ <sort_order>10</sort_order>
884
+ <show_in_default>1</show_in_default>
885
+ <show_in_website>1</show_in_website>
886
+ <show_in_store>1</show_in_store>
887
+ </accepted_cards>
888
+ <config_fallback>
889
+ <config_path>payment/securetrading_stpp_tokenization/config_fallback</config_path>
890
+ <frontend_type>select</frontend_type>
891
+ <source_model>securetrading_stpp/source_configfallback</source_model>
892
+ <sort_order>11</sort_order>
893
+ <show_in_default>1</show_in_default>
894
+ <show_in_website>1</show_in_website>
895
+ <show_in_store>1</show_in_store>
896
+ </config_fallback>
897
+ </fields>
898
+ </securetrading_stpp_tokenization>
899
  </groups>
900
  </securetrading_stpp>
901
  </sections>
953
  <comment>Allows customers to make debit/credit card payments without leaving your store.<![CDATA[<BR />]]>Your website must be PCI compliant to use this payment method.</comment>
954
  <frontend_model>securetrading_stpp/adminhtml_system_config_fieldset_fields</frontend_model>
955
  <expanded>0</expanded>
956
+ <sort_order>102</sort_order>
957
  <show_in_default>1</show_in_default>
958
  <show_in_website>1</show_in_website>
959
  <show_in_store>1</show_in_store>
982
  </securetrading_stpp_direct_transactionsearch>
983
  </fields>
984
  </securetrading_stpp_direct>
985
+ <securetrading_stpp_tokenization type="group" translate="label comment" module="securetrading_stpp">
986
+ <label>Secure Trading Tokenization</label>
987
+ <comment>Allows customers to make debit/credit card payments without leaving your store using card details saved on the Secure Trading servers.<![CDATA[<BR />]]>Your website does not need to be PCI-compliant to use this payment method. Another payment method must be enabled alongside this payment method so that card details can be captured.</comment>
988
+ <frontend_model>securetrading_stpp/adminhtml_system_config_fieldset_fields</frontend_model>
989
+ <expanded>0</expanded>
990
+ <sort_order>103</sort_order>
991
+ <show_in_default>1</show_in_default>
992
+ <show_in_website>1</show_in_website>
993
+ <show_in_store>1</show_in_store>
994
+ <image_logo>st_logo_strapline_100_32.png</image_logo>
995
+ <activity_path>payment/securetrading_stpp_tokenization/active</activity_path>
996
+ </securetrading_stpp_tokenization>
997
  </fields>
998
  </securetrading_stpp>
999
  </groups>
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Base.php CHANGED
@@ -39,7 +39,7 @@ class Stpp_Api_Base extends Stpp_Component_Abstract implements Stpp_Api_BaseInte
39
  $context = $this->getSend()->run($requests);
40
  $result = $this->getProcess()->run($context);
41
 
42
- $this->_endCardStoreHack($cardStoreRequest); // CARDSTORE HACK.
43
 
44
  return $result;
45
  }
@@ -47,22 +47,25 @@ class Stpp_Api_Base extends Stpp_Component_Abstract implements Stpp_Api_BaseInte
47
  // START CARDSTORE HACK.
48
  protected function _startCardStoreHack(array $requests) {
49
  $cardStoreRequest = null;
50
-
51
- foreach($requests as $k => $request) {
52
- if ($request->get('requesttypedescription') === Stpp_Types::API_CARDSTORE) {
53
  $cardStoreRequest = $request;
54
  unset($requests[$k]);
55
  $requests = array_values($requests);
56
- }
 
57
  }
58
  return array($cardStoreRequest, $requests);
59
  }
60
 
61
- protected function _endCardStoreHack(Stpp_Data_Request $cardStoreRequest = null) {
62
  if ($cardStoreRequest) {
63
- $requests = array($cardStoreRequest);
64
- $context = $this->getSend()->run($requests);
65
- $this->getProcess()->run($context);
 
 
66
  }
67
  }
68
  // END CARDSTORE HACK.
39
  $context = $this->getSend()->run($requests);
40
  $result = $this->getProcess()->run($context);
41
 
42
+ $this->_endCardStoreHack($result, $cardStoreRequest); // CARDSTORE HACK.
43
 
44
  return $result;
45
  }
47
  // START CARDSTORE HACK.
48
  protected function _startCardStoreHack(array $requests) {
49
  $cardStoreRequest = null;
50
+ if (count($requests) > 1) { // Only run this hack in a multi-requestblock (i.e. so we don't run this hack for standalone CARDSTORE requests).
51
+ foreach($requests as $k => $request) {
52
+ if ($request->get('requesttypedescription') === Stpp_Types::API_CARDSTORE) {
53
  $cardStoreRequest = $request;
54
  unset($requests[$k]);
55
  $requests = array_values($requests);
56
+ }
57
+ }
58
  }
59
  return array($cardStoreRequest, $requests);
60
  }
61
 
62
+ protected function _endCardStoreHack(Stpp_Api_Result $result, Stpp_Data_Request $cardStoreRequest = null) {
63
  if ($cardStoreRequest) {
64
+ if ($result->getIsTransactionSuccessful()) {
65
+ $requests = array($cardStoreRequest);
66
+ $context = $this->getSend()->run($requests);
67
+ $this->getProcess()->run($context);
68
+ }
69
  }
70
  }
71
  // END CARDSTORE HACK.
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Facade.php CHANGED
@@ -45,6 +45,10 @@ class Stpp_Api_Facade extends Stpp_Facade {
45
  $helper->setUseRiskDecision($this->_config->get('interfaces/api/use_risk_decision'));
46
  }
47
 
 
 
 
 
48
  if ($this->_config->has('interfaces/api/use_card_store')) {
49
  $helper->setUseCardStore($this->_config->get('interfaces/api/use_card_store'));
50
  }
@@ -213,4 +217,11 @@ class Stpp_Api_Facade extends Stpp_Facade {
213
  $result = $this->newApi()->run($requests);
214
  return $result;
215
  }
 
 
 
 
 
 
 
216
  }
45
  $helper->setUseRiskDecision($this->_config->get('interfaces/api/use_risk_decision'));
46
  }
47
 
48
+ if ($this->_config->has('interfaces/api/use_account_check')) {
49
+ $helper->setUseAccountCheck($this->_config->get('interfaces/api/use_account_check'));
50
+ }
51
+
52
  if ($this->_config->has('interfaces/api/use_card_store')) {
53
  $helper->setUseCardStore($this->_config->get('interfaces/api/use_card_store'));
54
  }
217
  $result = $this->newApi()->run($requests);
218
  return $result;
219
  }
220
+
221
+ public function runApiRequests(array $data, array $requestTypes) {
222
+ $request = Stpp_Data_Request::instance()->setMultiple($data);
223
+ $requests = $this->newApiHelper()->generateRequests($request, $requestTypes);
224
+ $result = $this->newApi()->run($requests);
225
+ return $result;
226
+ }
227
  }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Helper.php CHANGED
@@ -5,6 +5,8 @@ class Stpp_Api_Helper extends Stpp_Component_Abstract implements Stpp_Api_Helper
5
 
6
  protected $_useRiskDecision = false;
7
 
 
 
8
  protected $_useCardStore = false;
9
 
10
  protected $_useRiskDecisionAfterAuth = false;
@@ -21,6 +23,11 @@ class Stpp_Api_Helper extends Stpp_Component_Abstract implements Stpp_Api_Helper
21
  return $this;
22
  }
23
 
 
 
 
 
 
24
  public function setUseCardStore($bool) {
25
  $this->_useCardStore = (bool) $bool;
26
  return $this;
@@ -61,6 +68,10 @@ class Stpp_Api_Helper extends Stpp_Component_Abstract implements Stpp_Api_Helper
61
  $requestTypes[] = Stpp_Types::API_RISKDEC;
62
  }
63
 
 
 
 
 
64
  if ($this->_use3dSecure && !$this->_adminAction) {
65
  $requestTypes[] = Stpp_Types::API_THREEDQUERY;
66
  }
@@ -76,6 +87,13 @@ class Stpp_Api_Helper extends Stpp_Component_Abstract implements Stpp_Api_Helper
76
  if ($requestTypes == array(Stpp_Types::API_RISKDEC, Stpp_Types::API_THREEDQUERY, Stpp_Types::API_AUTH)) { // Fix for STPP gateway bug.
77
  $requests[2]->uns('settlestatus');
78
  }
 
 
 
 
 
 
 
79
  return $requests;
80
  }
81
 
@@ -95,12 +113,15 @@ class Stpp_Api_Helper extends Stpp_Component_Abstract implements Stpp_Api_Helper
95
  $requestTypes = array(Stpp_Types::API_AUTH);
96
  }
97
 
 
 
 
 
98
  $request->set('md', $_POST['MD']);
99
  $request->set('pares', $_POST['PaRes']);
100
  $request->set('accounttypedescription', $this->_calculateAccountTypeDescription(Stpp_Types::API_AUTH));
101
-
102
- return $this->generateRequests($request, $requestTypes);
103
 
 
104
  }
105
 
106
  public function prepareRefund(Stpp_Data_Request $originalRequest) {
@@ -209,6 +230,9 @@ class Stpp_Api_Helper extends Stpp_Component_Abstract implements Stpp_Api_Helper
209
  case Stpp_Types::API_RISKDEC:
210
  $accountType = Stpp_Types::ACCOUNT_FRAUDCONTROL;
211
  break;
 
 
 
212
  case Stpp_Types::API_CARDSTORE:
213
  $accountType = Stpp_Types::ACCOUNT_CARDSTORE;
214
  case Stpp_Types::API_REFUND:
5
 
6
  protected $_useRiskDecision = false;
7
 
8
+ protected $_useAccountCheck = false;
9
+
10
  protected $_useCardStore = false;
11
 
12
  protected $_useRiskDecisionAfterAuth = false;
23
  return $this;
24
  }
25
 
26
+ public function setUseAccountCheck($bool) {
27
+ $this->_useAccountCheck = (bool) $bool;
28
+ return $this;
29
+ }
30
+
31
  public function setUseCardStore($bool) {
32
  $this->_useCardStore = (bool) $bool;
33
  return $this;
68
  $requestTypes[] = Stpp_Types::API_RISKDEC;
69
  }
70
 
71
+ if ($this->_useAccountCheck) {
72
+ $requestTypes[] = Stpp_Types::API_ACCOUNTCHECK;
73
+ }
74
+
75
  if ($this->_use3dSecure && !$this->_adminAction) {
76
  $requestTypes[] = Stpp_Types::API_THREEDQUERY;
77
  }
87
  if ($requestTypes == array(Stpp_Types::API_RISKDEC, Stpp_Types::API_THREEDQUERY, Stpp_Types::API_AUTH)) { // Fix for STPP gateway bug.
88
  $requests[2]->uns('settlestatus');
89
  }
90
+
91
+ if ($requestTypes == array(Stpp_Types::API_THREEDQUERY, Stpp_Types::API_AUTH)) {
92
+ if ($requests[0]->has('parenttransactionreference') && $requests[1]->has('parenttransactionreference')) { // I.e. If tokenization has been used. We do this because if 3DQ = N/U-enrolled then the AUTH runs and has two PTRs in the gateway: the one defined in the AUTH request and the other implicitly given by the gateway from the THREEDUERY. The gateway returns 30000 parenttransactionreference on the AUTH without this fix.
93
+ $requests[1]->uns('parenttransactionreference');
94
+ }
95
+ }
96
+
97
  return $requests;
98
  }
99
 
113
  $requestTypes = array(Stpp_Types::API_AUTH);
114
  }
115
 
116
+ if ($this->_useCardStore) {
117
+ $requestTypes[] = Stpp_Types::API_CARDSTORE;
118
+ }
119
+
120
  $request->set('md', $_POST['MD']);
121
  $request->set('pares', $_POST['PaRes']);
122
  $request->set('accounttypedescription', $this->_calculateAccountTypeDescription(Stpp_Types::API_AUTH));
 
 
123
 
124
+ return $this->generateRequests($request, $requestTypes);
125
  }
126
 
127
  public function prepareRefund(Stpp_Data_Request $originalRequest) {
230
  case Stpp_Types::API_RISKDEC:
231
  $accountType = Stpp_Types::ACCOUNT_FRAUDCONTROL;
232
  break;
233
+ case Stpp_Types::API_ACCOUNTCHECK:
234
+ $accountType = Stpp_Types::ACCOUNT_ECOM;
235
+ break;
236
  case Stpp_Types::API_CARDSTORE:
237
  $accountType = Stpp_Types::ACCOUNT_CARDSTORE;
238
  case Stpp_Types::API_REFUND:
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Send.php CHANGED
@@ -61,9 +61,9 @@ class Stpp_Api_Send extends Stpp_Component_Abstract implements Stpp_Api_SendInte
61
  $xmlRequestString = $this->_formXmlRequests($requestArray);
62
  $xmlResponseString = $this->getConnection()->sendAndReceiveData($xmlRequestString);
63
  $responseArray = $this->_getXmlReader()->parseResponses($xmlResponseString);
64
- $this->_mapRequestsToResponses($requestArray, $responseArray);
65
- $this->_getContext()->setRequests($requestArray)->setResponses($responseArray);
66
- return $this->_getContext();
67
  }
68
 
69
  protected function _formXmlRequests(array $requests) {
61
  $xmlRequestString = $this->_formXmlRequests($requestArray);
62
  $xmlResponseString = $this->getConnection()->sendAndReceiveData($xmlRequestString);
63
  $responseArray = $this->_getXmlReader()->parseResponses($xmlResponseString);
64
+ $this->_mapRequestsToResponses($requestArray, $responseArray);
65
+ $this->_getContext()->setRequests($requestArray)->setResponses($responseArray);
66
+ return $this->_getContext();
67
  }
68
 
69
  protected function _formXmlRequests(array $requests) {
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Xml/Reader.php CHANGED
@@ -6,6 +6,7 @@ class Stpp_Api_Xml_Reader extends Stpp_Component_Abstract implements Stpp_Api_Xm
6
  protected $_responseClassName;
7
 
8
  public function __construct($responseClassName) {
 
9
  $this->_responseClassName = $responseClassName;
10
  }
11
 
@@ -52,6 +53,9 @@ class Stpp_Api_Xml_Reader extends Stpp_Component_Abstract implements Stpp_Api_Xm
52
  case Stpp_Types::API_RISKDEC:
53
  $this->_parseRiskDecisionResponse($xmlResponse, $response);
54
  break;
 
 
 
55
  case Stpp_Types::API_CARDSTORE:
56
  $this->_parseCardStoreResponse($xmlResponse, $response);
57
  break;
@@ -102,6 +106,10 @@ class Stpp_Api_Xml_Reader extends Stpp_Component_Abstract implements Stpp_Api_Xm
102
  $response->set('accounttypedescription', (string) $xmlResponse->operation->accounttypedescription);
103
  }
104
 
 
 
 
 
105
  protected function _parseAuthResponse($xmlResponse, &$response) {
106
  $this->_parseAuthOr3dQueryResponse($xmlResponse, $response, false);
107
  }
@@ -126,7 +134,7 @@ class Stpp_Api_Xml_Reader extends Stpp_Component_Abstract implements Stpp_Api_Xm
126
  $response->set('currencyiso3a', (string) $xmlResponse->billing->amount->attributes()->currencycode);
127
  }
128
 
129
- $response->set('paymenttype', (string) $xmlResponse->billing->payment->attributes()->type);
130
  $response->set('maskedpan', (string) $xmlResponse->billing->payment->pan);
131
  $response->set('authcode', (string) $xmlResponse->authcode);
132
 
@@ -146,13 +154,15 @@ class Stpp_Api_Xml_Reader extends Stpp_Component_Abstract implements Stpp_Api_Xm
146
  $response->set('accounttypedescription', (string) $xmlResponse->operation->accounttypedescription);
147
  $response->set('settleduedate', (string) $xmlResponse->settlement->settleduedate);
148
  $response->set('settlestatus', (string) $xmlResponse->settlement->settlestatus);
 
 
149
  }
150
 
151
  protected function _parseCardStoreResponse($xmlResponse, &$response) {
152
  $response->set('merchantname', (string) $xmlResponse->merchant->merchantname);
153
  $response->set('orderreference', (string) $xmlResponse->merchant->orderreference);
154
  $response->set('transactionreference', (string) $xmlResponse->transactionreference);
155
- $response->set('paymenttype', (string) $xmlResponse->billing->payment->attributes()->type);
156
  $response->set('paymentactive', (string) $xmlResponse->billing->payment->active);
157
  $response->set('maskedpan', (string) $xmlResponse->billing->payment->pan);
158
  $response->set('live', (string) $xmlResponse->live);
@@ -168,7 +178,7 @@ class Stpp_Api_Xml_Reader extends Stpp_Component_Abstract implements Stpp_Api_Xm
168
  $response->set('transactionreference', (string) $xmlResponse->transactionreference);
169
  $response->set('baseamount', (string) $xmlResponse->billing->amount);
170
  $response->set('currencyiso3a', (string) $xmlResponse->billing->amount->attributes()->currencycode);
171
- $response->set('paymenttype', (string) $xmlResponse->billing->payment->attributes()->type);
172
  $response->set('maskedpan', (string) $xmlResponse->billing->payment->pan);
173
  $response->set('authcode', (string) $xmlResponse->authcode);
174
  $response->set('securityresponsecode', (string) $xmlResponse->security->securitycode);
6
  protected $_responseClassName;
7
 
8
  public function __construct($responseClassName) {
9
+ parent::__construct();
10
  $this->_responseClassName = $responseClassName;
11
  }
12
 
53
  case Stpp_Types::API_RISKDEC:
54
  $this->_parseRiskDecisionResponse($xmlResponse, $response);
55
  break;
56
+ case Stpp_Types::API_ACCOUNTCHECK:
57
+ $this->_parseAccountCheckResponse($xmlResponse, $response);
58
+ break;
59
  case Stpp_Types::API_CARDSTORE:
60
  $this->_parseCardStoreResponse($xmlResponse, $response);
61
  break;
106
  $response->set('accounttypedescription', (string) $xmlResponse->operation->accounttypedescription);
107
  }
108
 
109
+ protected function _parseAccountCheckResponse($xmlResponse, &$response) {
110
+ $this->_parseAuthOr3dQueryResponse($xmlResponse, $response, false);
111
+ }
112
+
113
  protected function _parseAuthResponse($xmlResponse, &$response) {
114
  $this->_parseAuthOr3dQueryResponse($xmlResponse, $response, false);
115
  }
134
  $response->set('currencyiso3a', (string) $xmlResponse->billing->amount->attributes()->currencycode);
135
  }
136
 
137
+ $response->set('paymenttypedescription', (string) $xmlResponse->billing->payment->attributes()->type);
138
  $response->set('maskedpan', (string) $xmlResponse->billing->payment->pan);
139
  $response->set('authcode', (string) $xmlResponse->authcode);
140
 
154
  $response->set('accounttypedescription', (string) $xmlResponse->operation->accounttypedescription);
155
  $response->set('settleduedate', (string) $xmlResponse->settlement->settleduedate);
156
  $response->set('settlestatus', (string) $xmlResponse->settlement->settlestatus);
157
+
158
+ $response->set('redirecturl', (string) $xmlResponse->other->redirecturl);
159
  }
160
 
161
  protected function _parseCardStoreResponse($xmlResponse, &$response) {
162
  $response->set('merchantname', (string) $xmlResponse->merchant->merchantname);
163
  $response->set('orderreference', (string) $xmlResponse->merchant->orderreference);
164
  $response->set('transactionreference', (string) $xmlResponse->transactionreference);
165
+ $response->set('paymenttypedescription', (string) $xmlResponse->billing->payment->attributes()->type);
166
  $response->set('paymentactive', (string) $xmlResponse->billing->payment->active);
167
  $response->set('maskedpan', (string) $xmlResponse->billing->payment->pan);
168
  $response->set('live', (string) $xmlResponse->live);
178
  $response->set('transactionreference', (string) $xmlResponse->transactionreference);
179
  $response->set('baseamount', (string) $xmlResponse->billing->amount);
180
  $response->set('currencyiso3a', (string) $xmlResponse->billing->amount->attributes()->currencycode);
181
+ $response->set('paymenttypedescription', (string) $xmlResponse->billing->payment->attributes()->type);
182
  $response->set('maskedpan', (string) $xmlResponse->billing->payment->pan);
183
  $response->set('authcode', (string) $xmlResponse->authcode);
184
  $response->set('securityresponsecode', (string) $xmlResponse->security->securitycode);
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Api/Xml/Writer.php CHANGED
@@ -533,6 +533,21 @@ class Stpp_Api_Xml_Writer extends Stpp_Component_Abstract implements Stpp_Api_Xm
533
  // <parenttransactionreference></parenttransactionreference>
534
  $xmlWriter->writeElement('parenttransactionreference', $request->get('parenttransactionreference'));
535
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
536
  // </operation>
537
  $xmlWriter->endElement();
538
 
533
  // <parenttransactionreference></parenttransactionreference>
534
  $xmlWriter->writeElement('parenttransactionreference', $request->get('parenttransactionreference'));
535
 
536
+ // <customfield1></customfield1>
537
+ $xmlWriter->writeElement('customfield1', $request->get('customfield1'));
538
+
539
+ // <customfield2></customfield2>
540
+ $xmlWriter->writeElement('customfield2', $request->get('customfield2'));
541
+
542
+ // <customfield3></customfield3>
543
+ $xmlWriter->writeElement('customfield3', $request->get('customfield3'));
544
+
545
+ // <customfield4></customfield4>
546
+ $xmlWriter->writeElement('customfield4', $request->get('customfield4'));
547
+
548
+ // <customfield5></customfield5>
549
+ $xmlWriter->writeElement('customfield5', $request->get('customfield5'));
550
+
551
  // </operation>
552
  $xmlWriter->endElement();
553
 
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Facade.php CHANGED
@@ -18,4 +18,8 @@ class Stpp_Facade {
18
  public function newHelper() {
19
  return new Stpp_Helper();
20
  }
 
 
 
 
21
  }
18
  public function newHelper() {
19
  return new Stpp_Helper();
20
  }
21
+
22
+ public function getConfig() {
23
+ return $this->_config;
24
+ }
25
  }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Fields/Admin.php CHANGED
@@ -24,6 +24,7 @@ class Stpp_Fields_Admin extends Stpp_Component_Abstract implements Stpp_Fields_A
24
  const FIELD_API_ALL_CONNECTION = 'f_api_a_con';
25
  const FIELD_API_ALL_USE_3D_SECURE = 'f_api_a_use3d';
26
  const FIELD_API_ALL_USE_RISK_DECISION = 'f_api_a_userd';
 
27
  const FIELD_API_ALL_USE_CARD_STORE = 'f_api_a_usecs';
28
  const FIELD_API_ALL_USE_AUTO_CARD_STORE = 'f_api_a_autocs';
29
  const FIELD_API_ALL_DELAY_RISK_DECISION = 'f_api_a_delayrd';
@@ -134,6 +135,10 @@ class Stpp_Fields_Admin extends Stpp_Component_Abstract implements Stpp_Fields_A
134
  self::FIELD_TYPE_NAME => $this->__('Use Risk Decision'),
135
  self::FIELD_TYPE_DESCRIPTION => $this->__('Enabling Risk Decision requests will reduce the possibility of fraudulent transactions by comparing a customer transaction against a fraud-check database and suspending suspicious transactions. Risk Decision requests must be enabled on your Secure Trading account before you can use this feature.'),
136
  ),
 
 
 
 
137
  self::FIELD_API_ALL_USE_CARD_STORE => array(
138
  self::FIELD_TYPE_NAME => $this->__('Use Card Store'),
139
  self::FIELD_TYPE_DESCRIPTION => $this->__('Using Card Store will allow your customers to store their debit/credit card information for easy repeat purchasing. Card information is stored on the Secure Trading servers, not on your own website (a maskedpan and transactionreference only are stored on your site). Card Store requests must be enabled on your Secure Trading account before you can use this feature.'),
24
  const FIELD_API_ALL_CONNECTION = 'f_api_a_con';
25
  const FIELD_API_ALL_USE_3D_SECURE = 'f_api_a_use3d';
26
  const FIELD_API_ALL_USE_RISK_DECISION = 'f_api_a_userd';
27
+ const FIELD_API_ALL_USE_ACCOUNT_CHECK = 'f_api_a_useac';
28
  const FIELD_API_ALL_USE_CARD_STORE = 'f_api_a_usecs';
29
  const FIELD_API_ALL_USE_AUTO_CARD_STORE = 'f_api_a_autocs';
30
  const FIELD_API_ALL_DELAY_RISK_DECISION = 'f_api_a_delayrd';
135
  self::FIELD_TYPE_NAME => $this->__('Use Risk Decision'),
136
  self::FIELD_TYPE_DESCRIPTION => $this->__('Enabling Risk Decision requests will reduce the possibility of fraudulent transactions by comparing a customer transaction against a fraud-check database and suspending suspicious transactions. Risk Decision requests must be enabled on your Secure Trading account before you can use this feature.'),
137
  ),
138
+ self::FIELD_API_ALL_USE_ACCOUNT_CHECK => array(
139
+ self::FIELD_TYPE_NAME => $this->__('Use Account Check'),
140
+ self::FIELD_TYPE_DESCRIPTION => $this->__('Account Check requests must be enabled on your Secure Trading account before you can use this feature.'),
141
+ ),
142
  self::FIELD_API_ALL_USE_CARD_STORE => array(
143
  self::FIELD_TYPE_NAME => $this->__('Use Card Store'),
144
  self::FIELD_TYPE_DESCRIPTION => $this->__('Using Card Store will allow your customers to store their debit/credit card information for easy repeat purchasing. Card information is stored on the Secure Trading servers, not on your own website (a maskedpan and transactionreference only are stored on your site). Card Store requests must be enabled on your Secure Trading account before you can use this feature.'),
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Fields/Frontend.php CHANGED
@@ -15,7 +15,8 @@ class Stpp_Fields_Frontend extends Stpp_Component_Abstract implements Stpp_Field
15
  const FIELD_USE_SAVED_CARD_1 = 'f_usesavedcard1';
16
  const FIELD_SAVE_CARD_0 = 'f_savecard0';
17
  const FIELD_SAVE_CARD_1 = 'f_savecard1';
18
-
 
19
  const FIELD_TYPE_LABEL = 'label';
20
  const FIELD_TYPE_DESCRIPTION = 'desc';
21
 
@@ -80,6 +81,10 @@ class Stpp_Fields_Frontend extends Stpp_Component_Abstract implements Stpp_Field
80
  self::FIELD_TYPE_LABEL => $this->__('Save my card details securely.'),
81
  self::FIELD_TYPE_DESCRIPTION => $this->__('Select this option to securely save your card details with us. This allows you to make future purchases quickly and easily.'),
82
  ),
 
 
 
 
83
  );
84
  }
85
 
15
  const FIELD_USE_SAVED_CARD_1 = 'f_usesavedcard1';
16
  const FIELD_SAVE_CARD_0 = 'f_savecard0';
17
  const FIELD_SAVE_CARD_1 = 'f_savecard1';
18
+ const FIELD_SAVE_CARD_QUESTION = 'f_savecardq';
19
+
20
  const FIELD_TYPE_LABEL = 'label';
21
  const FIELD_TYPE_DESCRIPTION = 'desc';
22
 
81
  self::FIELD_TYPE_LABEL => $this->__('Save my card details securely.'),
82
  self::FIELD_TYPE_DESCRIPTION => $this->__('Select this option to securely save your card details with us. This allows you to make future purchases quickly and easily.'),
83
  ),
84
+ self::FIELD_SAVE_CARD_QUESTION => array(
85
+ self::FIELD_TYPE_LABEL => $this->__('Save Card Details?'),
86
+ self::FIELD_TYPE_DESCRIPTION => $this->__('Would you like to safely store your card details with us? This will allow you to make future purchases quickly and easily.'),
87
+ ),
88
  );
89
  }
90
 
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Http/Base.php CHANGED
@@ -130,7 +130,9 @@ class Stpp_Http_Base extends Stpp_Component_Abstract implements Stpp_Http_BaseIn
130
  public function httpPost($requestBody = '') {
131
  curl_setopt($this->_ch, CURLOPT_POST, 1);
132
  if ($this->_sslCheckCertChainForRevokedCerts) {
133
- $this->addHttpHeader('Content-Length: ' . strlen($requestBody));
 
 
134
  curl_setopt($this->_ch, CURLOPT_INFILE, fopen('data://text/plain,' . urlencode($requestBody), 'r'));
135
  curl_setopt($this->_ch, CURLOPT_INFILESIZE, strlen($requestBody));
136
  curl_setopt($this->_ch, CURLOPT_READFUNCTION, array($this, 'curlReadFunction'));
@@ -138,15 +140,24 @@ class Stpp_Http_Base extends Stpp_Component_Abstract implements Stpp_Http_BaseIn
138
  else {
139
  curl_setopt($this->_ch, CURLOPT_POSTFIELDS, $requestBody);
140
  }
 
141
  $this->_prepareCurl();
142
- return $this->_sendAndReceive();
 
 
 
 
143
  }
144
 
145
  public function httpGet() {
146
  $this->_prepareCurl();
147
  return $this->_sendAndReceive();
148
  }
149
-
 
 
 
 
150
  /**
151
  * Used as CURLOPT_READFUNCTION callback. Should not be used by client code.
152
  */
@@ -173,6 +184,7 @@ class Stpp_Http_Base extends Stpp_Component_Abstract implements Stpp_Http_BaseIn
173
  }
174
 
175
  protected function _sendAndReceive() {
 
176
  $result = $this->_sendAndReceiveWithRetries();
177
  $this->_checkResult($result);
178
  return $result;
130
  public function httpPost($requestBody = '') {
131
  curl_setopt($this->_ch, CURLOPT_POST, 1);
132
  if ($this->_sslCheckCertChainForRevokedCerts) {
133
+ $this->addHttpHeader('Content-Length: ' . strlen($requestBody));
134
+ end($this->_httpHeaders);
135
+ $contentLengthKey = key($this->_httpHeaders);
136
  curl_setopt($this->_ch, CURLOPT_INFILE, fopen('data://text/plain,' . urlencode($requestBody), 'r'));
137
  curl_setopt($this->_ch, CURLOPT_INFILESIZE, strlen($requestBody));
138
  curl_setopt($this->_ch, CURLOPT_READFUNCTION, array($this, 'curlReadFunction'));
140
  else {
141
  curl_setopt($this->_ch, CURLOPT_POSTFIELDS, $requestBody);
142
  }
143
+
144
  $this->_prepareCurl();
145
+ $result = $this->_sendAndReceive();
146
+ if ($this->_sslCheckCertChainForRevokedCerts && $contentLengthKey) {
147
+ unset($this->_httpHeaders[$contentLengthKey]);
148
+ }
149
+ return $result;
150
  }
151
 
152
  public function httpGet() {
153
  $this->_prepareCurl();
154
  return $this->_sendAndReceive();
155
  }
156
+
157
+ public function getInfo($curlInfoOptConstant = 0) {
158
+ return curl_getinfo($this->_ch, $curlInfoOptConstant);
159
+ }
160
+
161
  /**
162
  * Used as CURLOPT_READFUNCTION callback. Should not be used by client code.
163
  */
184
  }
185
 
186
  protected function _sendAndReceive() {
187
+ $this->_curlReadFunctionCalled = false;
188
  $result = $this->_sendAndReceiveWithRetries();
189
  $this->_checkResult($result);
190
  return $result;
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Transactionsearch/Base.php CHANGED
@@ -8,6 +8,8 @@ class Stpp_Transactionsearch_Base extends Stpp_Http_Base implements Stpp_Transac
8
  'paymentttypedescriptions',
9
  'settlestatus',
10
  'errorcodes',
 
 
11
  );
12
 
13
  protected $_url = 'https://myst.securetrading.net/auto/transactions/transactionsearch?';
@@ -86,7 +88,14 @@ class Stpp_Transactionsearch_Base extends Stpp_Http_Base implements Stpp_Transac
86
  $this->_filters[$filterType] = array_fill_keys($filterValue, true);
87
  return $this;
88
  }
89
-
 
 
 
 
 
 
 
90
  public function getFilter($filterType) {
91
  $this->_validateFilterType($filterType);
92
  return $this->_filters[$filterType];
@@ -130,7 +139,11 @@ class Stpp_Transactionsearch_Base extends Stpp_Http_Base implements Stpp_Transac
130
 
131
  public function httpPost($requestBody = '') {
132
  $this->_formUrl();
133
- $this->_rawCsvString = parent::httpPost($requestBody);
 
 
 
 
134
  $this->_parsedCsvArray = $this->_parseCsv($this->_rawCsvString);
135
  return $this;
136
  }
8
  'paymentttypedescriptions',
9
  'settlestatus',
10
  'errorcodes',
11
+ 'transactionreferences',
12
+ 'orderreferences',
13
  );
14
 
15
  protected $_url = 'https://myst.securetrading.net/auto/transactions/transactionsearch?';
88
  $this->_filters[$filterType] = array_fill_keys($filterValue, true);
89
  return $this;
90
  }
91
+
92
+ public function setFilters($filters) {
93
+ foreach($filters as $filterType => $filterValue) {
94
+ $this->setFilter($filterType, $filterValue);
95
+ }
96
+ return $this;
97
+ }
98
+
99
  public function getFilter($filterType) {
100
  $this->_validateFilterType($filterType);
101
  return $this->_filters[$filterType];
139
 
140
  public function httpPost($requestBody = '') {
141
  $this->_formUrl();
142
+ $httpResponseBody = parent::httpPost($requestBody);
143
+ if (($httpResponseCode = $this->getInfo(CURLINFO_HTTP_CODE)) !== 200) {
144
+ throw new Stpp_Exception(sprintf($this->__('Unexpected HTTP response code: "%s".'), $httpResponseCode));
145
+ }
146
+ $this->_rawCsvString = $httpResponseBody;
147
  $this->_parsedCsvArray = $this->_parseCsv($this->_rawCsvString);
148
  return $this;
149
  }
app/code/local/Securetrading/Stpp/lib/code/core/Stpp/Types.php CHANGED
@@ -6,10 +6,10 @@ class Stpp_Types implements Stpp_TypesInterface {
6
  const API_AUTH = 'AUTH';
7
  const API_THREEDQUERY = 'THREEDQUERY';
8
  const API_RISKDEC = 'RISKDEC';
 
9
  const API_TRANSACTIONUPDATE = 'TRANSACTIONUPDATE';
10
  const API_REFUND = 'REFUND';
11
  const API_CARDSTORE = 'STORE';
12
- const API_ACCOUNTCHECK = 'ACCOUNTCHECK';
13
 
14
  const ACCOUNT_ECOM = 'ECOM';
15
  const ACCOUNT_MOTO = 'MOTO';
@@ -33,18 +33,20 @@ class Stpp_Types implements Stpp_TypesInterface {
33
  const CARD_PRINCIPLE = 'PRINCIPLE';
34
  const CARD_PURCHASING = 'PURCHASING';
35
  const CARD_SHOESTUDIO = 'SHOESTUDIO';
 
36
  const CARD_SOLO = 'SOLO';
37
  const CARD_SWITCH = 'SWITCH';
38
  const CARD_VISA = 'VISA';
39
  const CARD_VPAY = 'VPAY';
40
  const CARD_WAREHOUSE = 'WAREHOUSE';
41
-
42
  public static function getRequestAndResponseTypes() {
43
  return array(
44
  self::API_ERROR,
45
  self::API_AUTH,
46
  self::API_THREEDQUERY,
47
  self::API_RISKDEC,
 
48
  self::API_TRANSACTIONUPDATE,
49
  self::API_REFUND,
50
  self::API_CARDSTORE,
@@ -79,6 +81,7 @@ class Stpp_Types implements Stpp_TypesInterface {
79
  self::CARD_PRINCIPLE => 'Principle',
80
  self::CARD_PURCHASING => 'Purchasing',
81
  self::CARD_SHOESTUDIO => 'Shoe Studio',
 
82
  self::CARD_SOLO => 'Solo',
83
  self::CARD_SWITCH => 'Switch',
84
  self::CARD_VISA => 'Visa',
6
  const API_AUTH = 'AUTH';
7
  const API_THREEDQUERY = 'THREEDQUERY';
8
  const API_RISKDEC = 'RISKDEC';
9
+ const API_ACCOUNTCHECK = 'ACCOUNTCHECK';
10
  const API_TRANSACTIONUPDATE = 'TRANSACTIONUPDATE';
11
  const API_REFUND = 'REFUND';
12
  const API_CARDSTORE = 'STORE';
 
13
 
14
  const ACCOUNT_ECOM = 'ECOM';
15
  const ACCOUNT_MOTO = 'MOTO';
33
  const CARD_PRINCIPLE = 'PRINCIPLE';
34
  const CARD_PURCHASING = 'PURCHASING';
35
  const CARD_SHOESTUDIO = 'SHOESTUDIO';
36
+ const CARD_SOFORT = 'SOFORT';
37
  const CARD_SOLO = 'SOLO';
38
  const CARD_SWITCH = 'SWITCH';
39
  const CARD_VISA = 'VISA';
40
  const CARD_VPAY = 'VPAY';
41
  const CARD_WAREHOUSE = 'WAREHOUSE';
42
+
43
  public static function getRequestAndResponseTypes() {
44
  return array(
45
  self::API_ERROR,
46
  self::API_AUTH,
47
  self::API_THREEDQUERY,
48
  self::API_RISKDEC,
49
+ self::API_ACCOUNTCHECK,
50
  self::API_TRANSACTIONUPDATE,
51
  self::API_REFUND,
52
  self::API_CARDSTORE,
81
  self::CARD_PRINCIPLE => 'Principle',
82
  self::CARD_PURCHASING => 'Purchasing',
83
  self::CARD_SHOESTUDIO => 'Shoe Studio',
84
+ self::CARD_SOFORT => 'Sofort',
85
  self::CARD_SOLO => 'Solo',
86
  self::CARD_SWITCH => 'Switch',
87
  self::CARD_VISA => 'Visa',
app/code/local/Securetrading/Stpp/sql/securetrading_stpp/upgrade-3.4.0-3.5.0.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ $table = $installer->getConnection()
7
+ ->newTable($installer->getTable('securetrading_stpp/billing_agreement_currency'))
8
+ ->addColumn('agreement_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
9
+ 'unsigned' => true,
10
+ 'nullable' => false,
11
+ 'primary' => true,
12
+ ), 'Agreement ID')
13
+ ->addColumn('base_currency', Varien_Db_Ddl_Table::TYPE_CHAR, 3, array(
14
+ 'nullable' => false,
15
+ ), 'Base Currency')
16
+ ->addForeignKey($installer->getFkName('securetrading_stpp/billing_agreement_currency', 'agreement_id', 'sales/billing_agreement', 'agreement_id'),
17
+ 'agreement_id', $installer->getTable('sales/billing_agreement'), 'agreement_id',
18
+ Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE
19
+ )
20
+ ->setComment('Restricts a billing agreement so that it can only be used for one curency. If no entries in this table assume the billing agreement can be used for all currencies.')
21
+ ;
22
+ $installer->getConnection()->createTable($table);
23
+
24
+ $table = $installer->getConnection()
25
+ ->newTable($installer->getTable('securetrading_stpp/billing_agreement_paymenttypedescription'))
26
+ ->addColumn('agreement_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
27
+ 'unsigned' => true,
28
+ 'nullable' => false,
29
+ 'primary' => true,
30
+ ), 'Agreement ID')
31
+ ->addColumn('payment_type_description', Varien_Db_Ddl_Table::TYPE_VARCHAR, 30, array(
32
+ 'nullable' => false,
33
+ ), 'Payment Type Description')
34
+ ->addForeignKey($installer->getFkName('securetrading_stpp/billing_agreement_paymenttypedescription', 'agreement_id', 'sales/billing_agreement', 'agreement_id'),
35
+ 'agreement_id', $installer->getTable('sales/billing_agreement'), 'agreement_id',
36
+ Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE
37
+ )
38
+ ->setComment('Stores the Secure Trading paymenttypedescription used for a Secure Trading transaction (the billing agremeent\'s reference ID)')
39
+ ;
40
+ $installer->getConnection()->createTable($table);
41
+
42
+ $data = array(
43
+ array(
44
+ 'status' => Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_SOFORT,
45
+ 'label' => 'Pending Sofort',
46
+ ),
47
+ array(
48
+ 'status' => Securetrading_Stpp_Model_Payment_Abstract::STATUS_PROCESSING_SOFORT,
49
+ 'label' => 'Processing Sofort',
50
+ ),
51
+ );
52
+ $statusTable = $installer->getTable('sales/order_status');
53
+ $installer->getConnection()->insertArray($statusTable, array('status', 'label'), $data);
54
+
55
+ $data = array(
56
+ array(
57
+ 'status' => Securetrading_Stpp_Model_Payment_Abstract::STATUS_PENDING_SOFORT,
58
+ 'state' => Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
59
+ 'is_default' => 0,
60
+ ),
61
+ array(
62
+ 'status' => Securetrading_Stpp_Model_Payment_Abstract::STATUS_PROCESSING_SOFORT,
63
+ 'state' => Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
64
+ 'is_default' => 0,
65
+ ),
66
+ );
67
+ $statusStateTable = $installer->getTable('sales/order_status_state');
68
+ $installer->getConnection()->insertArray($statusStateTable, array('status', 'state', 'is_default'), $data);
69
+
70
+ $installer->endSetup();
app/design/adminhtml/default/default/template/securetrading/stpp/payment/direct/form.phtml CHANGED
@@ -63,7 +63,7 @@
63
  <li>
64
  <label for="<?php print $_code; ?>_security_code">
65
  <?php print $this->getCardSecurityCodeLabel(); ?>
66
- <em class=required">*</em>
67
  </label>
68
  <div class="input-box">
69
  <input type="text" name="payment[securetrading_stpp_security_code]" id="<?php print $_code; ?>_security_code" class="required-entry" maxlength="4" />
63
  <li>
64
  <label for="<?php print $_code; ?>_security_code">
65
  <?php print $this->getCardSecurityCodeLabel(); ?>
66
+ <em class="required">*</em>
67
  </label>
68
  <div class="input-box">
69
  <input type="text" name="payment[securetrading_stpp_security_code]" id="<?php print $_code; ?>_security_code" class="required-entry" maxlength="4" />
app/design/adminhtml/default/default/template/securetrading/stpp/payment/tokenization/form.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_code=$this->getMethodCode() ?>
2
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
3
+ <li>
4
+ <label for="<?php print $_code; ?>_transaction_reference">
5
+ <?php print $this->getCardNumberLabel(); ?>
6
+ </label>
7
+ </li>
8
+ <?php foreach($this->getSavedCards() as $card): ?>
9
+ <li class="control">
10
+ <input type="radio" name="payment[securetrading_stpp_reference_id]" id="<?php print $_code; ?>_reference_id_<?php print $card->getReferenceId(); ?>" value="<?php print $card->getReferenceId(); ?>" class="radio" />
11
+ <label for="<?php print $_code; ?>_reference_id_<?php print $card->getReferenceId(); ?>">
12
+ <?php print $this->getAgreementLabel($card); ?>
13
+ </label>
14
+ </li>
15
+ <?php endforeach; ?>
16
+ </ul>
app/design/adminhtml/default/default/template/securetrading/stpp/payment/tokenization/info.phtml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <b><?php print $this->getTitle(); ?></b>
2
+ <br /><br />
3
+ <ul>
4
+ <?php if ($this->getAccountTypeDescription()): ?>
5
+ <li>Account Type Description: <?php print $this->getAccountTypeDescription(); ?></li>
6
+ <?php endif; ?>
7
+ <?php if ($this->getTransactionReference()): ?>
8
+ <li>Transaction Reference: <a href="<?php print $this->getTransactionReferenceUrl(); ?>"><?php print $this->getTransactionReference(); ?></a></li>
9
+ <?php endif; ?>
10
+ <?php if ($this->getSecurityAddress()): ?>
11
+ <li>Security Response Address: <span style="<?php print $this->getSecurityAddressStyle(); ?>"><?php print $this->getSecurityAddress(); ?></span></li>
12
+ <?php endif; ?>
13
+ <?php if ($this->getSecurityPostcode()): ?>
14
+ <li>Security Response Postcode: <span style="<?php print $this->getSecurityPostcodeStyle(); ?>"><?php print $this->getSecurityPostcode(); ?></span></li>
15
+ <?php endif; ?>
16
+ <?php if ($this->getSecurityCode()): ?>
17
+ <li>Security Response Security Code: <span style="<?php print $this->getSecurityCodeStyle(); ?>"><?php print $this->getSecurityCode(); ?></span></li>
18
+ <?php endif; ?>
19
+ <?php if ($this->getFraudControlShieldStatusCode()): ?>
20
+ <li>Fraud Control Shield Status Code: <span style="<?php print $this->getFraudControlShieldStatusCodeStyle(); ?>"><?php print $this->getFraudControlShieldStatusCode(); ?></span></li>
21
+ <?php endif; ?>
22
+ <?php if ($this->getEnrolled()): ?>
23
+ <li>3D Enrolled: <?php print $this->getEnrolled(); ?></li>
24
+ <?php endif; ?>
25
+ <?php if ($this->getStatus()): ?>
26
+ <li>3D Status: <?php print $this->getStatus(); ?></li>
27
+ <?php endif; ?>
28
+ <?php if ($this->getPaymentType()): ?>
29
+ <li>Payment Type: <?php print $this->getPaymentType(); ?></li>
30
+ <?php endif; ?>
31
+ <?php if ($this->getCcLast4()): ?>
32
+ <li>Last 4 Card Digits: <?php print $this->getCcLast4(); ?></li>
33
+ <?php endif; ?>
34
+ </ul>
35
+ <?php if ($this->getTransactionReference()): ?>
36
+ <a href="<?php print $this->getMystUrl(); ?>" target="_blank">View in MyST</a>
37
+ <br /><br />
38
+ <?php endif; ?>
app/design/frontend/base/default/layout/securetrading.xml CHANGED
@@ -84,4 +84,26 @@
84
  <remove name="root" />
85
  <block type="securetrading_stpp/payment_location" name="securetrading_stpp.payment.location" as="location" template="securetrading/stpp/payment/location.phtml" output="toHtml" />
86
  </securetrading_stpp_payment_location>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  </layout>
84
  <remove name="root" />
85
  <block type="securetrading_stpp/payment_location" name="securetrading_stpp.payment.location" as="location" template="securetrading/stpp/payment/location.phtml" output="toHtml" />
86
  </securetrading_stpp_payment_location>
87
+
88
+
89
+
90
+
91
+ <securetrading_stpp_tokenization_new>
92
+ <update handle="customer_account"/>
93
+ <reference name="root">
94
+ <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
95
+ </reference>
96
+ <reference name="my.account.wrapper">
97
+ <block type="securetrading_stpp/payment_direct_tokenization_form" name="securetrading_stpp.payment.direct.tokenization.form" template="securetrading/stpp/payment/direct/tokenization/form.phtml" />
98
+ </reference>
99
+ <reference name="customer_account_navigation">
100
+ <action method="setActive"><param>sales/billing_agreement</param></action>
101
+ </reference>
102
+ </securetrading_stpp_tokenization_new>
103
+
104
+ <checkout_multishipping_success>
105
+ <reference name="checkout_success">
106
+ <block type="securetrading_stpp/checkout_multishipping_success_billing_agreement" name="securetrading_stpp.checkout.multishipping.success.billing.agreement" template="securetrading/stpp/checkout/multishipping/success/billing/agreement.phtml" />
107
+ </reference>
108
+ </checkout_multishipping_success>
109
  </layout>
app/design/frontend/base/default/template/securetrading/stpp/checkout/multishipping/success/billing/agreement.phtml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php if ($this->getAgreementRefId()): ?>
2
+ <p><?php echo $this->__('Your billing agreement # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getAgreementUrl()), $this->escapeHtml($this->getAgreementRefId())))?></p>
3
+ <?php endif;?>
app/design/frontend/base/default/template/securetrading/stpp/payment/direct/form.phtml CHANGED
@@ -1,5 +1,5 @@
1
- <fieldset class="form-list">
2
- <?php $_code=$this->getMethodCode() ?>
3
  <ul id="payment_form_<?php echo $_code ?>" style="display:none">
4
  <li>
5
  <span id="<?php print $_code; ?>_description"><?php print $this->getDescription(); ?></span>
@@ -16,7 +16,6 @@
16
  <option value="<?php print $key; ?>"><?php print $value; ?></option>
17
  <?php endforeach; ?>
18
  </select>
19
- <?php //print $this->getCardTypeDescription(); ?>
20
  </div>
21
  </li>
22
  <li>
@@ -26,7 +25,6 @@
26
  </label>
27
  <div class="input-box">
28
  <input type="text" name="payment[securetrading_stpp_card_number]" id="<?php print $_code; ?>_card_number" class="required-entry" />
29
- <?php //print $this->getCardNumberDescription(); ?>
30
  </div>
31
  </li>
32
  <?php if ($this->canShowStartDate()): ?>
@@ -81,19 +79,37 @@
81
  </label>
82
  <div class="input-box">
83
  <input type="text" name="payment[securetrading_stpp_security_code]" id="<?php print $_code; ?>_security_code" class="required-entry" maxlength="4" />
84
- <?php //print $this->getCardSecurityCodeDescription(); ?>
85
  </div>
86
- </li>
87
- <?php if ($this->canShowIssueNumber()): ?>
88
- <li>
89
  <label for="<?php print $_code; ?>_issue_number">
90
  <?php print $this->getCardIssueNumberLabel(); ?>
91
  </label>
92
  <div class="input-box">
93
  <input type="text" name="payment[securetrading_stpp_issue_number]" id="<?php print $_code; ?>_issue_number" />
94
- <?php //print $this->getCardIssueNumberDescription(); ?>
95
  </div>
96
- </li>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  <?php endif; ?>
98
  </ul>
99
  </fieldset>
1
+ <?php $_code = $this->getMethodCode() ?>
2
+ <fieldset class="form-list">
3
  <ul id="payment_form_<?php echo $_code ?>" style="display:none">
4
  <li>
5
  <span id="<?php print $_code; ?>_description"><?php print $this->getDescription(); ?></span>
16
  <option value="<?php print $key; ?>"><?php print $value; ?></option>
17
  <?php endforeach; ?>
18
  </select>
 
19
  </div>
20
  </li>
21
  <li>
25
  </label>
26
  <div class="input-box">
27
  <input type="text" name="payment[securetrading_stpp_card_number]" id="<?php print $_code; ?>_card_number" class="required-entry" />
 
28
  </div>
29
  </li>
30
  <?php if ($this->canShowStartDate()): ?>
79
  </label>
80
  <div class="input-box">
81
  <input type="text" name="payment[securetrading_stpp_security_code]" id="<?php print $_code; ?>_security_code" class="required-entry" maxlength="4" />
 
82
  </div>
83
+ </li>
84
+ <?php if ($this->canShowIssueNumber()): ?>
85
+ <li>
86
  <label for="<?php print $_code; ?>_issue_number">
87
  <?php print $this->getCardIssueNumberLabel(); ?>
88
  </label>
89
  <div class="input-box">
90
  <input type="text" name="payment[securetrading_stpp_issue_number]" id="<?php print $_code; ?>_issue_number" />
 
91
  </div>
92
+ </li>
93
+ <?php endif; ?>
94
+ <?php if ($this->getUseCardStore()): ?>
95
+ <li>
96
+ <label class="required">
97
+ <?php print $this->getSaveCcDetailsLabel(); ?>
98
+ <em>*</em>
99
+ </label>
100
+ </li>
101
+ <li class="control">
102
+ <input type="radio" name="payment[securetrading_stpp_save_cc]" id="<?php print $_code; ?>_save_cc_1" value="1" checked="checked" class="radio" />
103
+ <label for="<?php print $_code; ?>_save_cc_1">
104
+ <?php print $this->__('Yes'); ?>
105
+ </label>
106
+ </li>
107
+ <li class="control">
108
+ <input type="radio" name="payment[securetrading_stpp_save_cc]" id="<?php print $_code; ?>_save_cc_0" value="0" class="radio" />
109
+ <label for="<?php print $_code; ?>_save_cc_0">
110
+ <?php print $this->__('No'); ?>
111
+ </label>
112
+ </li>
113
  <?php endif; ?>
114
  </ul>
115
  </fieldset>
app/design/frontend/base/default/template/securetrading/stpp/payment/direct/tokenization/form.phtml ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="page-title">
2
+ <h1><?php echo $this->__('New Billing Agreement') ?></h1>
3
+ </div>
4
+ <p id="payment_description">
5
+ <?php print $this->getCardstoreDescription(); ?>
6
+ </p>
7
+ <br />
8
+
9
+ <form action="<?php print $this->getTokenizationPostUrl(); ?>" method="post">
10
+ <fieldset class="form-list">
11
+ <ul id="payment_form">
12
+ <li>
13
+ <label for="payment_type" class="required">
14
+ <?php print $this->getCardTypeLabel(); ?>
15
+ <em>*</em>
16
+ </label>
17
+ <div class="input-box">
18
+ <select name="payment_type" id="payment_type" class="required-entry">
19
+ <option value=""><?php print $this->__('Please select an option...'); ?></option>
20
+ <?php foreach($this->getAcceptedCards() as $key => $value): ?>
21
+ <option value="<?php print $key; ?>"><?php print $value; ?></option>
22
+ <?php endforeach; ?>
23
+ </select>
24
+ </div>
25
+ </li>
26
+ <li>
27
+ <label for="card_number" class="required">
28
+ <?php print $this->getCardNumberLabel(); ?>
29
+ <em>*</em>
30
+ </label>
31
+ <div class="input-box">
32
+ <input type="text" name="card_number" id="card_number" class="required-entry" />
33
+ </div>
34
+ </li>
35
+ <?php if ($this->canShowStartDate()): ?>
36
+ <li>
37
+ <label for="start_date_month">
38
+ <?php print $this->getCardStartDateLabel(); ?>
39
+ </label>
40
+ <div class="input-box">
41
+ <div class="v-fix">
42
+ <select name="start_date_month" id="start_date_month" class="month">
43
+ <?php foreach($this->getMonths() as $k => $v): ?>
44
+ <option value="<?php print $k; ?>"><?php print $v; ?></option>
45
+ <?php endforeach; ?>
46
+ </select>
47
+ </div>
48
+ <div class="v-fix">
49
+ <select name="start_date_year" id="start_date_year" class="year">
50
+ <?php foreach($this->getStartYears() as $year): ?>
51
+ <option value="<?php print $year; ?>"><?php print $year; ?></option>
52
+ <?php endforeach; ?>
53
+ </select>
54
+ </div>
55
+ </div>
56
+ </li>
57
+ <?php endif; ?>
58
+ <li>
59
+ <label for="expiry_date_month" class="required">
60
+ <?php print $this->getCardExpiryMonthLabel(); ?>
61
+ <em>*</em>
62
+ </label>
63
+ <div class="input-box">
64
+ <div class="v-fix">
65
+ <select name="expiry_date_month" id="expiry_date_month" class="month required-entry">
66
+ <?php foreach($this->getMonths() as $k => $v): ?>
67
+ <option value="<?php print $k; ?>"><?php print $v; ?></option>
68
+ <?php endforeach; ?>
69
+ </select>
70
+ </div>
71
+ </div>
72
+ </li>
73
+ <li>
74
+ <label for="expiry_date_year" class="required">
75
+ <?php print $this->getCardExpiryYearLabel(); ?>
76
+ <em>*</em>
77
+ </label>
78
+ <div class="input-box">
79
+ <div class="v-fix">
80
+ <select name="expiry_date_year" id="expiry_date_year" class="year required-entry">
81
+ <?php foreach($this->getExpiryYears() as $year): ?>
82
+ <option value="<?php print $year; ?>"><?php print $year; ?></option>
83
+ <?php endforeach; ?>
84
+ </select>
85
+ </div>
86
+ </div>
87
+ </li>
88
+ <?php if ($this->canShowIssueNumber()): ?>
89
+ <li>
90
+ <label for="issue_number">
91
+ <?php print $this->getCardIssueNumberLabel(); ?>
92
+ </label>
93
+ <div class="input-box">
94
+ <input type="text" name="issue_number]" id="issue_number" />
95
+ </div>
96
+ </li>
97
+ <?php endif; ?>
98
+ <li style="margin-top: 10px;">
99
+ <div class="input-box">
100
+ <button class="button" title="<?php print $this->__('Submit'); ?>" type="submit">
101
+ <span><?php print $this->__('Submit'); ?></span>
102
+ </button>
103
+ </div>
104
+ </li>
105
+ </ul>
106
+ </fieldset>
107
+ </form>
app/design/frontend/base/default/template/securetrading/stpp/payment/redirect/form.phtml CHANGED
@@ -1,5 +1,28 @@
 
1
  <fieldset class="form-list">
2
  <ul id="payment_form_<?php echo $this->getMethodCode(); ?>" style="display:none">
 
3
  <?php print $this->getDescription(); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  </ul>
5
  </fieldset>
1
+ <?php $_code = $this->getMethodCode() ?>
2
  <fieldset class="form-list">
3
  <ul id="payment_form_<?php echo $this->getMethodCode(); ?>" style="display:none">
4
+ <li>
5
  <?php print $this->getDescription(); ?>
6
+ </li>
7
+ <?php if ($this->getUseTokenization()): ?>
8
+ <li>
9
+ <label class="required">
10
+ <?php print $this->getSaveCcDetailsLabel(); ?>
11
+ <em>*</em>
12
+ </label>
13
+ </li>
14
+ <li class="control">
15
+ <input type="radio" name="payment[securetrading_stpp_redirect_save_cc]" id="<?php print $_code; ?>_save_cc_1" value="1" checked="checked" class="radio" />
16
+ <label for="<?php print $_code; ?>_save_cc_1">
17
+ <?php print $this->__('Yes'); ?>
18
+ </label>
19
+ </li>
20
+ <li class="control">
21
+ <input type="radio" name="payment[securetrading_stpp_redirect_save_cc]" id="<?php print $_code; ?>_save_cc_0" value="0" class="radio" />
22
+ <label for="<?php print $_code; ?>_save_cc_0">
23
+ <?php print $this->__('No'); ?>
24
+ </label>
25
+ </li>
26
+ <?php endif; ?>
27
  </ul>
28
  </fieldset>
app/design/frontend/base/default/template/securetrading/stpp/payment/tokenization/form.phtml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <fieldset class="form-list">
2
+ <?php $_code=$this->getMethodCode() ?>
3
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
4
+ <li>
5
+ <span id="<?php print $_code; ?>_description"><?php print $this->getDescription(); ?></span>
6
+ </li>
7
+ <li>
8
+ <label for="<?php print $_code; ?>_transaction_reference" class="required">
9
+ <?php print $this->getCardNumberLabel(); ?>
10
+ <em>*</em>
11
+ </label>
12
+ </li>
13
+ <?php foreach($this->getSavedCards() as $card): ?>
14
+ <li class="control">
15
+ <input type="radio" name="payment[securetrading_stpp_reference_id]" id="<?php print $_code; ?>_reference_id_<?php print $card->getReferenceId(); ?>" value="<?php print $card->getReferenceId(); ?>" class="radio" />
16
+ <label for="<?php print $_code; ?>_reference_id_<?php print $card->getReferenceId(); ?>">
17
+ <?php print $this->getAgreementLabel($card); ?>
18
+ </label>
19
+ </li>
20
+ <?php endforeach; ?>
21
+ </ul>
22
+ </fieldset>
app/design/frontend/base/default/template/securetrading/stpp/payment/tokenization/info.phtml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php print $this->getTitle(); ?>
2
+ <?php if ($_label = $this->getCardLabel()): ?>
3
+ <br /><br />
4
+ <ul>
5
+ <li>Card: <?php print $_label; ?></li>
6
+ </ul>
7
+ <?php endif; ?>
app/design/frontend/base/default/template/securetrading/stpp/payment/tokenization/post.phtml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <form action="<?php print $this->getRedirectUrl(); ?>" method="post" id="securetrading_stpp_direct_form">
2
+ <?php foreach($this->getRedirectData() as $k => $v): ?>
3
+ <input type="hidden" name="<?php print $k; ?>" value="<?php print $v; ?>" />
4
+ <?php endforeach; ?>
5
+ <input type="submit" value="Pay" />
6
+ </form>
7
+ <script type="text/javascript">
8
+ document.body.onload = function() {
9
+ document.getElementById("securetrading_stpp_direct_form").submit();
10
+ };
11
+ </script>
12
+ <noscript>
13
+ <p>You are seeing this message because JavaScript is disabled. Click "Pay" to continue with your transaction.</p>
14
+ </noscript>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Securetrading_Stpp</name>
4
- <version>3.4.1</version>
5
  <stability>stable</stability>
6
  <license>GPL</license>
7
  <channel>community</channel>
@@ -10,9 +10,9 @@
10
  <description>Integrates Magento with the SecureTrading STPP payment gateway.</description>
11
  <notes>The official SecureTrading STPP Magento integration.</notes>
12
  <authors><author><name>PeteST</name><user>PeteST</user><email>peter.barrow@securetrading.com</email></author></authors>
13
- <date>2014-09-03</date>
14
- <time>16:02:41</time>
15
- <contents><target name="magelocal"><dir name="Securetrading"><dir name="Stpp"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="View"><dir name="Tab"><file name="Modifier.php" hash="0bd4d015736253fdb49a71761e0ce167"/><file name="Transactions.php" hash="a6aa9a1fe720256b57de515eb2fb70f6"/></dir></dir></dir><dir name="Transactions"><file name="Children.php" hash="0b35ac5e3a5640ef299797f2cc2928cb"/><dir name="Data"><file name="Abstract.php" hash="b959d39031f05c4c4cdc9c86d949d2fb"/><file name="Request.php" hash="974c787900f673b88789e077bbb1cdee"/><file name="Response.php" hash="cde9edd437f258f3790d48d4801d1d14"/></dir><file name="Grid.php" hash="3dadcca29051df9ef955fb3f779bc77e"/><file name="Single.php" hash="e0f722dd28882d3f60f73c11a70da963"/><dir name="Type"><file name="Abstract.php" hash="d6fc7cebd2fabb908e56e1b31430606a"/><file name="Default.php" hash="3b079c4dc23ae7ca0dde58d90d76ce1b"/><dir name="Transactionupdate"><file name="Filters.php" hash="fb57db23243321b2e3adbe8d4d6b6b00"/><file name="Updates.php" hash="97cf9ab359d5832eef6e994c76f10229"/></dir><file name="Transactionupdate.php" hash="054a96bd931424b9b8e3123252d815a7"/></dir></dir><file name="Transactions.php" hash="d7a848751b019beed67af4af8d82f19e"/></dir><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Fields.php" hash="f7c19c4ccf6d2182c7afd6060bc23ef9"/></dir><file name="Group.php" hash="fb37a1754315559cb708dc03a5b61219"/></dir></dir><dir name="Widget"><dir name="Grid"><dir name="Column"><dir name="Renderer"><file name="Parenttransactionreference.php" hash="2d1ef69a9554457d150e0064f24a02b2"/></dir></dir></dir></dir></dir><dir name="Payment"><dir name="Direct"><file name="Form.php" hash="f2aceb73c95cae73aa21d02de0431b80"/><file name="Info.php" hash="96b45fd3a2530d32ad5b762d30adb349"/><file name="Post.php" hash="dc9037dbae9b10ccf088b24fc08e7dd2"/></dir><file name="Iframe.php" hash="1bf66cdd951253928cce893d7235ccf2"/><dir name="Info"><file name="Abstract.php" hash="83a78172f8dc75490c820b4d88ff4f49"/></dir><file name="Location.php" hash="2ffcd84c447b187ffa6dc0e45b6393ac"/><dir name="Redirect"><file name="Form.php" hash="4a5c80135121a495a94e193b0d7f1982"/><file name="Info.php" hash="5172a488856a167205abab64819062d5"/><file name="Post.php" hash="00d05d0064ecbc5bdc75b615bdfc4894"/></dir></dir></dir><dir name="Controller"><dir name="Redirect"><dir name="Post"><file name="Abstract.php" hash="f26396762758c1fe090460751d7c50e8"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="43c563ba6a207520f9a4ce3a38ee9138"/></dir><dir name="Model"><dir name="Actions"><file name="Abstract.php" hash="c4f1bc7dc4c5cda23b15ace3c70691d9"/><file name="Direct.php" hash="61b40b715fab6224a8fff4f37c02bc7b"/><file name="Redirect.php" hash="31aedee830305a443608d3dc0b337eb2"/></dir><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Backend"><file name="Multiselect.php" hash="65ca6dd7b6b597aada4978b7c6e803c2"/></dir></dir></dir></dir><file name="Cron.php" hash="34f1a9e397aeb1ecfc8cee8a53dde103"/><file name="Integration.php" hash="25c7bb1309fd54f67d8e02011d28ee8f"/><file name="Observer.php" hash="fd8cdcf9d6688c33db8bd5d1813db36b"/><dir name="Payment"><file name="Abstract.php" hash="b8a340a2c4cd0b1f3d84f3043564bb3e"/><dir name="Direct"><file name="Session.php" hash="981654031f061f1e04efc80b4a57b428"/></dir><file name="Direct.php" hash="a7b2087c6c42996bf53403a8051a4961"/><dir name="Redirect"><file name="Notification.php" hash="22e2a3366aa294f83aabe94decdbc47f"/><file name="Request.php" hash="cb3b90d9bb7a31bec42ae94ae83770cb"/></dir><file name="Redirect.php" hash="afcfdb9e7e66dc4ec4fe3105bb0318a1"/></dir><dir name="Resource"><dir name="Payment"><dir name="Redirect"><file name="Notification.php" hash="251daf3860785e6aab8b5a6594bf397a"/><dir name="Request"><file name="Collection.php" hash="ce960dbcdf4c40f08782750b3e7ec4d4"/></dir><file name="Request.php" hash="9a51ce8b5aa2bf188e39afcd099225d1"/></dir></dir><dir name="Transaction"><file name="Collection.php" hash="c48174c935a30b1df2e545ff3ad71adc"/><dir name="Types"><file name="Collection.php" hash="efc344d22f5b19ad8a239ec3acb20e77"/></dir><file name="Types.php" hash="abbde61e4d29e19bb3a67ad1959b388f"/></dir><file name="Transaction.php" hash="a864a129f03751920262b847a1711f4d"/></dir><dir name="Source"><file name="Cardtypes.php" hash="bdac2842ee54f15d4deab2cd1e0caea6"/><file name="Connection.php" hash="b281807c740f8a79f591789a3d8792d7"/><file name="Paymentaction.php" hash="0f05df5d7e5248808c96700e102a2b11"/><file name="Settleduedate.php" hash="b5acc4d4eae0a22d4bf25e5fd5f2cda0"/><file name="Settlestatus.php" hash="dc304f8a01d89fa8af5c14c7166d9571"/></dir><dir name="Transaction"><file name="Types.php" hash="1c3712f053e0dadd4edc34ec115effff"/></dir><file name="Transaction.php" hash="543277351dad9217f2bd8284e26531b1"/></dir><dir name="controllers"><dir name="Direct"><file name="PostController.php" hash="785f79108093ba54af1029eb667a9015"/></dir><file name="DirectController.php" hash="c9d24ad2bc1f30faba8c33377e2bb27c"/><file name="MultishippingController.php" hash="13baa2b4936070577228b2bbbd14a46c"/><file name="PaymentController.php" hash="5babd6cb7602948f8a2a2cce169b829c"/><dir name="Redirect"><dir name="Post"><file name="MultishippingController.php" hash="77bad529935b43b48e16269572498b8d"/><file name="OnepageController.php" hash="0d9a9aa74f70f2995eb417123ed5242d"/></dir></dir><file name="RedirectController.php" hash="7a3929672dd1e4a665f3af544bfd8d49"/><dir name="Sales"><dir name="Order"><dir name="Create"><file name="SecuretradingController.php" hash="e3c89bb8942d8676b0f043adcc226dfe"/></dir><file name="CreateController.php" hash="7964d98f1574c0f93dbb43e87161f1f8"/><file name="EditController.php" hash="a12e458fac106c021367426031356f58"/></dir></dir><dir name="Securetrading"><file name="TransactionsController.php" hash="ca39e6bb66bfd59cf6bf0176144bd256"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="edf6376a0d883ae4fedc024d346364b3"/><file name="config.xml" hash="80c3769bea8aa84164896119de5166b4"/><file name="system.xml" hash="30fd19155bc95a3505d5dce4874d2098"/></dir><dir name="lib"><file name="Securetrading.php" hash="5c22e508ffd059847ffb882aba923b2b"/><dir name="code"><dir name="core"><dir name="Stpp"><dir name="Actions"><file name="Abstract.php" hash="fce4b439f195bb866983180fe57e3bf7"/><file name="BaseInterface.php" hash="cd3004a4734c99499b41f9442d8406f4"/></dir><dir name="Api"><file name="ActionsInterface.php" hash="20feaa9eaefa912efb02d3cd33212fa2"/><file name="Base.php" hash="68a5b1eff62192578a122f327d32f59a"/><file name="BaseInterface.php" hash="252e16b85c0e7e230934b02c3e16728d"/><dir name="Connection"><file name="BaseInterface.php" hash="8638cb072cf263abd8687e87cdc81fb5"/><file name="Stapi.php" hash="107a6a41d31b021ddbd84739499b1830"/><file name="Store.php" hash="3909b4aa2b618816c4380d4b41d2d375"/><file name="StoreInterface.php" hash="6e8bfff449b86b145ae5b138dde91d50"/><file name="Webservices.php" hash="bb81a31ffc9a8ba20fbe393fdb04cac7"/></dir><file name="Context.php" hash="0ca6f4a61de6113b124795ed8fe83cab"/><file name="ContextInterface.php" hash="b3e9edfa4fe8776140eafce41da98709"/><file name="Facade.php" hash="a1d4eae820c686ab8cfa1ab0ee3b5d1f"/><file name="Helper.php" hash="1dea4cafc21348fb814b62f45172d598"/><file name="HelperInterface.php" hash="aa6f9747d5c2f242455d5c11be51b66b"/><file name="Log.php" hash="8f9df624ea7e440f7d074be07a98e511"/><file name="LogInterface.php" hash="fce5c3d966eaf5885f3575bd800c6d46"/><dir name="Process"><dir name="Calculation"><file name="BaseInterface.php" hash="385960d9d3cd780d194716300a8fc1fa"/><file name="CardstoreNoncardstoreCombined.php" hash="5390f91635fac340ada1bc9d9116a85c"/><file name="Default.php" hash="fc6fbc1b5ad9b405eab5ccfba644fab5"/><file name="RiskdecNonriskdecCombined.php" hash="f72e84f24e5bc57842d15c556e6b275e"/><file name="TuRefundCombined.php" hash="9de65bce6f7d6e49574f4aafb8075ffb"/></dir></dir><file name="Process.php" hash="fb37ea94d51524af9505667ca33161db"/><file name="ProcessInterface.php" hash="76117fc893006c7a927eda90596261f3"/><file name="Result.php" hash="d9da44e9241b8b9d7577de8e7e5d6ef0"/><file name="ResultInterface.php" hash="345346e779a4644c8f29d847100ae779"/><file name="Send.php" hash="353c400fe8a72db44a514df07074b6a3"/><file name="SendInterface.php" hash="0a13ea22e3d2f556be7f02d5b8568e43"/><dir name="Xml"><file name="Reader.php" hash="6c2ffe5d46d5828d695feae5b5c2b969"/><file name="ReaderInterface.php" hash="3a148a5b88af125d766877f33dd882b7"/><file name="Writer.php" hash="2ec6b1e68bd1ca54bcb548db8779b8f3"/><file name="WriterInterface.php" hash="1700903ae09c5dec1a8b6c215a6f0a97"/></dir></dir><dir name="Component"><file name="Abstract.php" hash="d679a67d53fee2ad8a38d8e9175707f6"/><file name="BaseInterface.php" hash="a7a21448d576cba4921a17e3c4c63e26"/><file name="Store.php" hash="8afe5baa023a117085dfca51d8d6d0c4"/></dir><file name="Config.php" hash="e62fcc26e717a67051abd0873998c3d7"/><dir name="Data"><file name="Abstract.php" hash="9186ff9e00d3446e85dbf19ea1216e6a"/><file name="AbstractInterface.php" hash="511f49db6045b20b299ac27a123b0ee1"/><file name="Request.php" hash="a4206b389b91b3506b66b9942d922976"/><file name="Response.php" hash="41bce777ce4baf6d33f5efe1a754e1f1"/></dir><file name="Exception.php" hash="ddef67bc724764d3fa455b3f246e670d"/><file name="Facade.php" hash="b044ddd9a1c2e0097bea099efa1f6bd5"/><dir name="Fields"><file name="Admin.php" hash="5a58bb5684eafc588b3769cca73ea980"/><file name="AdminInterface.php" hash="d60603c6fe6ac4393edc3e699d11cfa2"/><file name="Facade.php" hash="4f00cf6fb606175bb8c1a98988504cb7"/><file name="Frontend.php" hash="e558224f8c3adf54733c1df71e14a8f1"/><file name="FrontendInterface.php" hash="9e7e760b58d9b1aea5169199f85055b8"/></dir><file name="Helper.php" hash="1b9e5cda59cab32904f41a1137732889"/><file name="HelperInterface.php" hash="e74c27a61169ac2dbad549178635b652"/><dir name="Http"><file name="Base.php" hash="0af2b3e2ba1be476a8c828b01502d906"/><file name="BaseInterface.php" hash="ec910ae696a968ba91991d4e9593bc5a"/><file name="Helper.php" hash="0854cc287d4fe2e8db833730db86b3b1"/><file name="HelperInterface.php" hash="f70f0aac9734f70f62483362ec111470"/></dir><dir name="PaymentPages"><file name="ActionsInterface.php" hash="477836396b30505fd77e2edab9228eb9"/><file name="Base.php" hash="644dabfcc9439009a093cbae56f5b51c"/><file name="BaseInterface.php" hash="8e88b88ea80bbc678275b545f5a0ca0e"/><file name="Facade.php" hash="0cb8b0a018774a8d00474857ca048286"/><file name="Helper.php" hash="0f299510045851097ddb2f5e5999130b"/><file name="HelperInterface.php" hash="92cb7856303a054852856f84fce59ab8"/><file name="Result.php" hash="516d99ad6325d3688cb6cf9d96611bad"/><file name="ResultInterface.php" hash="6331633ee01a8f801e6aa92bc4b21a79"/></dir><dir name="Result"><file name="Abstract.php" hash="e101a37e53b02217d9f71896724fc464"/><file name="AbstractInterface.php" hash="67f281eeb616125a6730c9d0bdcdefbf"/></dir><dir name="Transactionsearch"><file name="Base.php" hash="76e61d0f724035f816c399e89d6e6884"/><file name="BaseInterface.php" hash="fbd240c914a21eb174bf7c52fff645fe"/></dir><file name="Types.php" hash="116bf208c9d6e76763f9e8a36e68e1e9"/><file name="TypesInterface.php" hash="01535df4e4e7bb7075a06050841594f0"/><dir name="Utility"><file name="Facade.php" hash="a87ccac18a334e151e109cf07b5338f0"/><dir name="Log"><file name="Base.php" hash="6d4a4ac38eeb8747199ae932caab713b"/><file name="BaseInterface.php" hash="8df2532e217b93725ab15e5a76dfd6e7"/><dir name="User"><file name="Abstract.php" hash="622318fca2ae84a50f50f65153036528"/></dir><file name="UserInterface.php" hash="f88f34cb0338ab4d98c3f5ebcbb22f7d"/><dir name="Writer"><file name="File.php" hash="5eada117593cf8c9bb27a6060f6c3714"/></dir><file name="WriterInterface.php" hash="0e4e743dd4c8da74fea389c8f728b0b4"/></dir><dir name="Translator"><file name="Base.php" hash="4ff1233235a2b58886da2a3b07247d9a"/><file name="BaseInterface.php" hash="f76d5808b75e190bb6499da9608c9efb"/></dir></dir><dir name="Xml"><file name="Writer.php" hash="97a246a7642179bd346cfce33f523c87"/></dir></dir><file name="Stpp.php" hash="2b593e5ee83d4272bb4efac0fb09c88b"/></dir><dir name="overrides"><dir name="Magento"><dir name="Api"><file name="Facade.php" hash="0cd067db115b4f5ed00abc434db2245f"/></dir><dir name="Log"><file name="Writer.php" hash="b27229288c0eda838b9a2113c788344c"/></dir><dir name="Utility"><file name="Facade.php" hash="9b6c7e6955acce41cad9121c8028ae09"/></dir></dir></dir></dir><dir name="stpp_translations"><file name="core.php" hash="8de46a7cce58eadbff4ae9b294e20aec"/></dir></dir><file name="readme.txt" hash="fb7d4f0b1527e6574cbe96073aac6eda"/><dir name="sql"><dir name="securetrading_stpp"><file name="install-3.0.0.php" hash="923d824b156fb74eeb195ee57723e26b"/><file name="upgrade-3.0.0-3.1.0.php" hash="779de6f21f30913707d67573434c5827"/><file name="upgrade-3.1.0-3.2.0.php" hash="6f9e0b4cb006faede031f5a170af8798"/><file name="upgrade-3.2.0-3.2.1.php" hash="fc652e065a2375fa7a61679a5553c7d6"/><file name="upgrade-3.2.1-3.3.0.php" hash="d3ca3b1936b10f8254c676e1fd7392fe"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="securetrading"><dir name="stpp"><dir><dir name="payment"><dir name="direct"><file name="form.phtml" hash="5b41701f83182d12d530a78fc3c24d77"/><file name="info.phtml" hash="0573ae000e6b1df77c89c71b108cfa10"/></dir><file name="iframe.phtml" hash="550f6904467d71a368b03b2ba6852841"/><file name="location.phtml" hash="e790bf7d7f7c453f98cd9e03e0b74ab1"/><dir name="redirect"><file name="form.phtml" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="info.phtml" hash="0573ae000e6b1df77c89c71b108cfa10"/><file name="post.phtml" hash="8b0b70df44ce27b54c57c7369dd59655"/></dir></dir><dir name="sales"><dir name="transactions"><file name="single.phtml" hash="a3dbbda792cb4d806e6283ed7f964634"/></dir></dir><dir name="system"><dir name="config"><dir name="fieldset"><file name="fields.phtml" hash="0c0aff08f256a5cfd2c644e7f629c9d7"/></dir></dir></dir></dir></dir></dir></dir><dir name="layout"><file name="securetrading.xml" hash="c9253b162d0b6ea0fb8297b70606711e"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="securetrading"><dir name="stpp"><dir><dir name="payment"><dir name="direct"><file name="form.phtml" hash="3068d1391e1bbe6bb957b6cafc912651"/><file name="info.phtml" hash="a81bbf7d28e9f1c3e9e837f6542c3a58"/><file name="post.phtml" hash="d8643b7e67de32c311c30b531b0c6392"/></dir><file name="iframe.phtml" hash="550f6904467d71a368b03b2ba6852841"/><file name="location.phtml" hash="e790bf7d7f7c453f98cd9e03e0b74ab1"/><dir name="redirect"><file name="form.phtml" hash="7590b97c94ac8a7058606c82a2bd3766"/><file name="info.phtml" hash="4eaf8674c2de27618920fdcd65d61ade"/><file name="post.phtml" hash="c4edc4e15986cfc9dd010fe4eb915ccc"/></dir></dir></dir></dir></dir></dir><dir name="layout"><file name="securetrading.xml" hash="906aacd5e1f49d2d1b8b710d4b50a26d"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Securetrading_Stpp.xml" hash="eb2a4153d2e9feed7913b46666fb585c"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="securetrading"><dir name="stpp"><file name="st_logo_strapline_100_32.png" hash="002186134f7898800305489774711fb7"/><file name="st_logo_strapline_200_63.png" hash="bca24f2696fca0d2bca54681a635e8e3"/><file name="success_16_16.png" hash="5fa7c06b312cbea3675e844686e434af"/></dir></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.3.0</min><max>5.5.15</max></php><package><name>Securetrading_Multishipping</name><channel>community</channel><min></min><max></max></package></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Securetrading_Stpp</name>
4
+ <version>3.5.0</version>
5
  <stability>stable</stability>
6
  <license>GPL</license>
7
  <channel>community</channel>
10
  <description>Integrates Magento with the SecureTrading STPP payment gateway.</description>
11
  <notes>The official SecureTrading STPP Magento integration.</notes>
12
  <authors><author><name>PeteST</name><user>PeteST</user><email>peter.barrow@securetrading.com</email></author></authors>
13
+ <date>2014-10-13</date>
14
+ <time>12:39:36</time>
15
+ <contents><target name="magelocal"><dir name="Securetrading"><dir name="Stpp"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="View"><dir name="Tab"><file name="Modifier.php" hash="0bd4d015736253fdb49a71761e0ce167"/><file name="Transactions.php" hash="a6aa9a1fe720256b57de515eb2fb70f6"/></dir></dir></dir><dir name="Transactions"><file name="Children.php" hash="0b35ac5e3a5640ef299797f2cc2928cb"/><dir name="Data"><file name="Abstract.php" hash="b959d39031f05c4c4cdc9c86d949d2fb"/><file name="Request.php" hash="974c787900f673b88789e077bbb1cdee"/><file name="Response.php" hash="cde9edd437f258f3790d48d4801d1d14"/></dir><file name="Grid.php" hash="3dadcca29051df9ef955fb3f779bc77e"/><file name="Single.php" hash="a9c1fe8bcc323b48c4d9c537fb5e8596"/><dir name="Type"><file name="Abstract.php" hash="d6fc7cebd2fabb908e56e1b31430606a"/><file name="Default.php" hash="3b079c4dc23ae7ca0dde58d90d76ce1b"/><dir name="Transactionupdate"><file name="Filters.php" hash="fb57db23243321b2e3adbe8d4d6b6b00"/><file name="Updates.php" hash="97cf9ab359d5832eef6e994c76f10229"/></dir><file name="Transactionupdate.php" hash="054a96bd931424b9b8e3123252d815a7"/></dir></dir><file name="Transactions.php" hash="d7a848751b019beed67af4af8d82f19e"/></dir><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Fields.php" hash="6b1270a19dbcfee9750ef8a6e5da280f"/></dir><file name="Group.php" hash="fb37a1754315559cb708dc03a5b61219"/></dir></dir><dir name="Widget"><dir name="Grid"><dir name="Column"><dir name="Renderer"><file name="Parenttransactionreference.php" hash="2d1ef69a9554457d150e0064f24a02b2"/></dir></dir></dir></dir></dir><dir name="Checkout"><dir name="Multishipping"><dir name="Success"><dir name="Billing"><file name="Agreement.php" hash="fb03a4ea511f100565b88453032b6ca9"/></dir></dir></dir></dir><dir name="Payment"><dir name="Direct"><file name="Form.php" hash="9b556c1f1623c4b8fd12be9c9484ba9d"/><file name="Info.php" hash="96b45fd3a2530d32ad5b762d30adb349"/><file name="Post.php" hash="e5adb9df03d0ec2fc43528b1d90fcdf3"/><dir name="Tokenization"><file name="Form.php" hash="19ea180df8513308662be9e57261a56d"/></dir></dir><file name="Iframe.php" hash="1bf66cdd951253928cce893d7235ccf2"/><dir name="Info"><file name="Abstract.php" hash="83a78172f8dc75490c820b4d88ff4f49"/></dir><file name="Location.php" hash="2ffcd84c447b187ffa6dc0e45b6393ac"/><dir name="Redirect"><file name="Form.php" hash="d401da16c1bab604fdaf4ff07b8d14c1"/><file name="Info.php" hash="5172a488856a167205abab64819062d5"/><file name="Post.php" hash="00d05d0064ecbc5bdc75b615bdfc4894"/></dir><dir name="Tokenization"><file name="Form.php" hash="30893422fcfea1f37ba88b071ee45539"/><file name="Info.php" hash="6ce6afe0f5c4d8d677e03f97b85fdc76"/></dir></dir></dir><dir name="Controller"><dir name="Redirect"><dir name="Post"><file name="Abstract.php" hash="20be24bf0ea76adcb77e500a91aa760c"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="e24565a37e981fd399b780ed9384aa70"/></dir><dir name="Model"><dir name="Actions"><file name="Abstract.php" hash="f3fa6af90b9c4c73f0ef5cc29286ada6"/><file name="Direct.php" hash="59557a0f678e6ec67e402568dd760464"/><file name="Redirect.php" hash="9600d4e861851a81bf7ba03a42709646"/></dir><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Backend"><file name="Multiselect.php" hash="65ca6dd7b6b597aada4978b7c6e803c2"/></dir></dir></dir></dir><dir name="Billing"><dir name="Agreement"><file name="Currency.php" hash="10ebcda6f45b76c03796306a19fba78d"/><file name="Paymenttypedescription.php" hash="ccf2260dbb3ebdf5243e8944e0d24d15"/></dir></dir><file name="Cron.php" hash="a64dae7f86dbb85b8ea047adda5c7f22"/><file name="Integration.php" hash="e4d929d71afbfc528b44c5cb151667f3"/><file name="Observer.php" hash="9688e2a1cc0b3a089b228729a9b5d285"/><dir name="Payment"><file name="Abstract.php" hash="42745643e333795194f8fe2f9a32bf7e"/><dir name="Direct"><file name="Abstract.php" hash="3fbf758953fc1540323d0ee2b2b05e63"/><file name="Session.php" hash="981654031f061f1e04efc80b4a57b428"/></dir><file name="Direct.php" hash="77a1f8e0b111f56592cbbb11d993ec1a"/><dir name="Handler"><dir name="Backend"><file name="Abstract.php" hash="15df156e4455ff5a623ef14316be810c"/><file name="Factory.php" hash="c2007ddcce984fb8f447f67fdb7e3473"/><file name="Multishipping.php" hash="19a2ed85fb261040d5969305000ef0c7"/><file name="Onepage.php" hash="d4bea0aadf26fa77da39042aba4f3358"/></dir><dir name="Frontend"><file name="Abstract.php" hash="5b520956cf48f665c0bedc33df372c6c"/><file name="Factory.php" hash="e313029b76ef55cc6476ae4f35a3df2d"/><file name="Multishipping.php" hash="4036dda206c16da153116701bb1c1a4d"/><file name="Onepage.php" hash="2b8b414c449c4ec16e9c25b2bce15ba1"/></dir></dir><dir name="Redirect"><file name="Notification.php" hash="22e2a3366aa294f83aabe94decdbc47f"/><file name="Request.php" hash="cb3b90d9bb7a31bec42ae94ae83770cb"/><file name="Session.php" hash="c74b9d1219d8b50ed69e788f8dee4d28"/></dir><file name="Redirect.php" hash="e39781d7ec834545375ab495a4d598fc"/><dir name="Tokenization"><file name="Session.php" hash="66e2e6ac2f88b38738b1dcf3e584212c"/></dir><file name="Tokenization.php" hash="fe735f3966a55827d31a7ecf3f4eb89b"/></dir><dir name="Resource"><dir name="Billing"><dir name="Agreement"><file name="Currency.php" hash="b51772a4110997b98a542c273f899ed0"/><file name="Paymenttypedescription.php" hash="462311705c9d48cbe3f08532df89bbce"/></dir></dir><dir name="Mage"><dir name="Sales"><dir name="Billing"><dir name="Agreement"><file name="Collection.php" hash="92718149a5702bcb2861ffdcb7fc3060"/></dir></dir></dir></dir><dir name="Payment"><dir name="Redirect"><file name="Notification.php" hash="251daf3860785e6aab8b5a6594bf397a"/><dir name="Request"><file name="Collection.php" hash="ce960dbcdf4c40f08782750b3e7ec4d4"/></dir><file name="Request.php" hash="9a51ce8b5aa2bf188e39afcd099225d1"/></dir></dir><dir name="Transaction"><file name="Collection.php" hash="c48174c935a30b1df2e545ff3ad71adc"/><dir name="Types"><file name="Collection.php" hash="efc344d22f5b19ad8a239ec3acb20e77"/></dir><file name="Types.php" hash="abbde61e4d29e19bb3a67ad1959b388f"/></dir><file name="Transaction.php" hash="a864a129f03751920262b847a1711f4d"/></dir><dir name="Source"><file name="Cardtypes.php" hash="ab4fb821e11d65cb20786f318cecce51"/><file name="Configfallback.php" hash="97a12f5a597b53ff4b1484aa9b179b04"/><file name="Connection.php" hash="b281807c740f8a79f591789a3d8792d7"/><file name="Paymentaction.php" hash="0f05df5d7e5248808c96700e102a2b11"/><file name="Settleduedate.php" hash="b5acc4d4eae0a22d4bf25e5fd5f2cda0"/><file name="Settlestatus.php" hash="f5df8f4feb6fcb4e509201b5ec8dc035"/></dir><dir name="Transaction"><file name="Types.php" hash="1c3712f053e0dadd4edc34ec115effff"/></dir><file name="Transaction.php" hash="0f0e50ed3c177e81e6e5c2ca68a4bad9"/></dir><dir name="controllers"><dir name="Direct"><file name="PostController.php" hash="2b935b6e8dff3a2b234cfc47226d3f5a"/></dir><file name="DirectController.php" hash="1214b10e99b6b2cf1e593f514243bced"/><file name="MultishippingController.php" hash="68e8aa676ff0e03ea7f5b5f0baa3f8c7"/><file name="PaymentController.php" hash="5babd6cb7602948f8a2a2cce169b829c"/><dir name="Redirect"><dir name="Post"><file name="MultishippingController.php" hash="77bad529935b43b48e16269572498b8d"/><file name="OnepageController.php" hash="0d9a9aa74f70f2995eb417123ed5242d"/></dir></dir><file name="RedirectController.php" hash="77ea30f2cdc277871ad0af5a09bfd829"/><dir name="Sales"><dir name="Order"><dir name="Create"><file name="SecuretradingController.php" hash="6a01439c71535441cb5fffb306fb6840"/></dir><file name="CreateController.php" hash="7964d98f1574c0f93dbb43e87161f1f8"/><file name="EditController.php" hash="a12e458fac106c021367426031356f58"/></dir></dir><dir name="Securetrading"><file name="TransactionsController.php" hash="ca39e6bb66bfd59cf6bf0176144bd256"/></dir><file name="TokenizationController.php" hash="376148840e552b27e7ff9ea3aea40d52"/></dir><dir name="etc"><file name="adminhtml.xml" hash="edf6376a0d883ae4fedc024d346364b3"/><file name="config.xml" hash="a868b8d7fbaf7a8afdacd2ca4d677ace"/><file name="system.xml" hash="30e2add81b71036f795757738efeadbe"/></dir><dir name="lib"><file name="Securetrading.php" hash="5c22e508ffd059847ffb882aba923b2b"/><dir name="code"><dir name="core"><dir name="Stpp"><dir name="Actions"><file name="Abstract.php" hash="fce4b439f195bb866983180fe57e3bf7"/><file name="BaseInterface.php" hash="cd3004a4734c99499b41f9442d8406f4"/></dir><dir name="Api"><file name="ActionsInterface.php" hash="20feaa9eaefa912efb02d3cd33212fa2"/><file name="Base.php" hash="17f42df431e356a43752d499540cebd9"/><file name="BaseInterface.php" hash="252e16b85c0e7e230934b02c3e16728d"/><dir name="Connection"><file name="BaseInterface.php" hash="8638cb072cf263abd8687e87cdc81fb5"/><file name="Stapi.php" hash="107a6a41d31b021ddbd84739499b1830"/><file name="Store.php" hash="3909b4aa2b618816c4380d4b41d2d375"/><file name="StoreInterface.php" hash="6e8bfff449b86b145ae5b138dde91d50"/><file name="Webservices.php" hash="bb81a31ffc9a8ba20fbe393fdb04cac7"/></dir><file name="Context.php" hash="0ca6f4a61de6113b124795ed8fe83cab"/><file name="ContextInterface.php" hash="b3e9edfa4fe8776140eafce41da98709"/><file name="Facade.php" hash="fd5f214450f2d6e9a98ad3332af203a8"/><file name="Helper.php" hash="92d293f5557d328b5a3e8483fab635e1"/><file name="HelperInterface.php" hash="aa6f9747d5c2f242455d5c11be51b66b"/><file name="Log.php" hash="8f9df624ea7e440f7d074be07a98e511"/><file name="LogInterface.php" hash="fce5c3d966eaf5885f3575bd800c6d46"/><dir name="Process"><dir name="Calculation"><file name="BaseInterface.php" hash="385960d9d3cd780d194716300a8fc1fa"/><file name="CardstoreNoncardstoreCombined.php" hash="5390f91635fac340ada1bc9d9116a85c"/><file name="Default.php" hash="fc6fbc1b5ad9b405eab5ccfba644fab5"/><file name="RiskdecNonriskdecCombined.php" hash="f72e84f24e5bc57842d15c556e6b275e"/><file name="TuRefundCombined.php" hash="9de65bce6f7d6e49574f4aafb8075ffb"/></dir></dir><file name="Process.php" hash="fb37ea94d51524af9505667ca33161db"/><file name="ProcessInterface.php" hash="76117fc893006c7a927eda90596261f3"/><file name="Result.php" hash="d9da44e9241b8b9d7577de8e7e5d6ef0"/><file name="ResultInterface.php" hash="345346e779a4644c8f29d847100ae779"/><file name="Send.php" hash="e60835ae864e7a079ea25a608852871f"/><file name="SendInterface.php" hash="0a13ea22e3d2f556be7f02d5b8568e43"/><dir name="Xml"><file name="Reader.php" hash="c1c89be7f35c61dc4533f0e3cb71e27d"/><file name="ReaderInterface.php" hash="3a148a5b88af125d766877f33dd882b7"/><file name="Writer.php" hash="228295b3c047a0b192d9c8b33c7eabcf"/><file name="WriterInterface.php" hash="1700903ae09c5dec1a8b6c215a6f0a97"/></dir></dir><dir name="Component"><file name="Abstract.php" hash="d679a67d53fee2ad8a38d8e9175707f6"/><file name="BaseInterface.php" hash="a7a21448d576cba4921a17e3c4c63e26"/><file name="Store.php" hash="8afe5baa023a117085dfca51d8d6d0c4"/></dir><file name="Config.php" hash="e62fcc26e717a67051abd0873998c3d7"/><dir name="Data"><file name="Abstract.php" hash="9186ff9e00d3446e85dbf19ea1216e6a"/><file name="AbstractInterface.php" hash="511f49db6045b20b299ac27a123b0ee1"/><file name="Request.php" hash="a4206b389b91b3506b66b9942d922976"/><file name="Response.php" hash="41bce777ce4baf6d33f5efe1a754e1f1"/></dir><file name="Exception.php" hash="ddef67bc724764d3fa455b3f246e670d"/><file name="Facade.php" hash="880ca0fbf01e89c9e9375e7697e2fe32"/><dir name="Fields"><file name="Admin.php" hash="d0a5467de4c443829da4f32232598023"/><file name="AdminInterface.php" hash="d60603c6fe6ac4393edc3e699d11cfa2"/><file name="Facade.php" hash="4f00cf6fb606175bb8c1a98988504cb7"/><file name="Frontend.php" hash="07e9755644fad28f690454a74fa258a7"/><file name="FrontendInterface.php" hash="9e7e760b58d9b1aea5169199f85055b8"/></dir><file name="Helper.php" hash="1b9e5cda59cab32904f41a1137732889"/><file name="HelperInterface.php" hash="e74c27a61169ac2dbad549178635b652"/><dir name="Http"><file name="Base.php" hash="a45349f030ba53420079a6b041851897"/><file name="BaseInterface.php" hash="ec910ae696a968ba91991d4e9593bc5a"/><file name="Helper.php" hash="0854cc287d4fe2e8db833730db86b3b1"/><file name="HelperInterface.php" hash="f70f0aac9734f70f62483362ec111470"/></dir><dir name="PaymentPages"><file name="ActionsInterface.php" hash="477836396b30505fd77e2edab9228eb9"/><file name="Base.php" hash="644dabfcc9439009a093cbae56f5b51c"/><file name="BaseInterface.php" hash="8e88b88ea80bbc678275b545f5a0ca0e"/><file name="Facade.php" hash="0cb8b0a018774a8d00474857ca048286"/><file name="Helper.php" hash="0f299510045851097ddb2f5e5999130b"/><file name="HelperInterface.php" hash="92cb7856303a054852856f84fce59ab8"/><file name="Result.php" hash="516d99ad6325d3688cb6cf9d96611bad"/><file name="ResultInterface.php" hash="6331633ee01a8f801e6aa92bc4b21a79"/></dir><dir name="Result"><file name="Abstract.php" hash="e101a37e53b02217d9f71896724fc464"/><file name="AbstractInterface.php" hash="67f281eeb616125a6730c9d0bdcdefbf"/></dir><dir name="Transactionsearch"><file name="Base.php" hash="896a6ef06696f51e00d843effa17f5f7"/><file name="BaseInterface.php" hash="fbd240c914a21eb174bf7c52fff645fe"/></dir><file name="Types.php" hash="3d550efd506b1c94ee2e7f66f087396c"/><file name="TypesInterface.php" hash="01535df4e4e7bb7075a06050841594f0"/><dir name="Utility"><file name="Facade.php" hash="a87ccac18a334e151e109cf07b5338f0"/><dir name="Log"><file name="Base.php" hash="6d4a4ac38eeb8747199ae932caab713b"/><file name="BaseInterface.php" hash="8df2532e217b93725ab15e5a76dfd6e7"/><dir name="User"><file name="Abstract.php" hash="622318fca2ae84a50f50f65153036528"/></dir><file name="UserInterface.php" hash="f88f34cb0338ab4d98c3f5ebcbb22f7d"/><dir name="Writer"><file name="File.php" hash="5eada117593cf8c9bb27a6060f6c3714"/></dir><file name="WriterInterface.php" hash="0e4e743dd4c8da74fea389c8f728b0b4"/></dir><dir name="Translator"><file name="Base.php" hash="4ff1233235a2b58886da2a3b07247d9a"/><file name="BaseInterface.php" hash="f76d5808b75e190bb6499da9608c9efb"/></dir></dir><dir name="Xml"><file name="Writer.php" hash="97a246a7642179bd346cfce33f523c87"/></dir></dir><file name="Stpp.php" hash="2b593e5ee83d4272bb4efac0fb09c88b"/></dir><dir name="overrides"><dir name="Magento"><dir name="Api"><file name="Facade.php" hash="0cd067db115b4f5ed00abc434db2245f"/></dir><dir name="Log"><file name="Writer.php" hash="b27229288c0eda838b9a2113c788344c"/></dir><dir name="Utility"><file name="Facade.php" hash="9b6c7e6955acce41cad9121c8028ae09"/></dir></dir></dir></dir><dir name="stpp_translations"><file name="core.php" hash="8de46a7cce58eadbff4ae9b294e20aec"/></dir></dir><file name="readme.txt" hash="fb7d4f0b1527e6574cbe96073aac6eda"/><dir name="sql"><dir name="securetrading_stpp"><file name="install-3.0.0.php" hash="923d824b156fb74eeb195ee57723e26b"/><file name="upgrade-3.0.0-3.1.0.php" hash="779de6f21f30913707d67573434c5827"/><file name="upgrade-3.1.0-3.2.0.php" hash="6f9e0b4cb006faede031f5a170af8798"/><file name="upgrade-3.2.0-3.2.1.php" hash="fc652e065a2375fa7a61679a5553c7d6"/><file name="upgrade-3.2.1-3.3.0.php" hash="d3ca3b1936b10f8254c676e1fd7392fe"/><file name="upgrade-3.4.0-3.5.0.php" hash="01d6b58a7a3678be4eced4c9d87ed1b5"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="securetrading"><dir name="stpp"><dir><dir name="payment"><dir name="direct"><file name="form.phtml" hash="f3fcdf586e3d0fb8f0b0a45a5c4c0242"/><file name="info.phtml" hash="0573ae000e6b1df77c89c71b108cfa10"/></dir><file name="iframe.phtml" hash="550f6904467d71a368b03b2ba6852841"/><file name="location.phtml" hash="e790bf7d7f7c453f98cd9e03e0b74ab1"/><dir name="redirect"><file name="form.phtml" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="info.phtml" hash="0573ae000e6b1df77c89c71b108cfa10"/><file name="post.phtml" hash="8b0b70df44ce27b54c57c7369dd59655"/></dir><dir name="tokenization"><file name="form.phtml" hash="50d1d5e384a039c024901890426f0210"/><file name="info.phtml" hash="35ee126ce93f1cf5d1df42bda32d4437"/></dir></dir><dir name="sales"><dir name="transactions"><file name="single.phtml" hash="a3dbbda792cb4d806e6283ed7f964634"/></dir></dir><dir name="system"><dir name="config"><dir name="fieldset"><file name="fields.phtml" hash="0c0aff08f256a5cfd2c644e7f629c9d7"/></dir></dir></dir></dir></dir></dir></dir><dir name="layout"><file name="securetrading.xml" hash="c9253b162d0b6ea0fb8297b70606711e"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="securetrading"><dir name="stpp"><dir><dir name="checkout"><dir name="multishipping"><dir name="success"><dir name="billing"><file name="agreement.phtml" hash="9b9ccb519995410336727b862086ade7"/></dir></dir></dir></dir><dir name="payment"><dir name="direct"><file name="form.phtml" hash="93720d40108bfeacfe82ace2e3a20c48"/><file name="info.phtml" hash="a81bbf7d28e9f1c3e9e837f6542c3a58"/><file name="post.phtml" hash="d8643b7e67de32c311c30b531b0c6392"/><dir name="tokenization"><file name="form.phtml" hash="ebb8a0892332a3370db6179eaeaf4210"/></dir></dir><file name="iframe.phtml" hash="550f6904467d71a368b03b2ba6852841"/><file name="location.phtml" hash="e790bf7d7f7c453f98cd9e03e0b74ab1"/><dir name="redirect"><file name="form.phtml" hash="fbe9a39729d5a1efe9238d43b38f3a61"/><file name="info.phtml" hash="4eaf8674c2de27618920fdcd65d61ade"/><file name="post.phtml" hash="c4edc4e15986cfc9dd010fe4eb915ccc"/></dir><dir name="tokenization"><file name="form.phtml" hash="939f094d7cced40dba746b2119d7e0d6"/><file name="info.phtml" hash="685c70dbd31b79aecb12b40d0d7b27c0"/><file name="post.phtml" hash="f7057bebaa616dcc52dba6a58178fe19"/></dir></dir></dir></dir></dir></dir><dir name="layout"><file name="securetrading.xml" hash="1090e99fd4657eddab402d75a9bdb476"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Securetrading_Stpp.xml" hash="eb2a4153d2e9feed7913b46666fb585c"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="securetrading"><dir name="stpp"><file name="st_logo_strapline_100_32.png" hash="002186134f7898800305489774711fb7"/><file name="st_logo_strapline_200_63.png" hash="bca24f2696fca0d2bca54681a635e8e3"/><file name="success_16_16.png" hash="5fa7c06b312cbea3675e844686e434af"/></dir></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.3.0</min><max>5.5.15</max></php><package><name>Securetrading_Multishipping</name><channel>community</channel><min></min><max></max></package></required></dependencies>
18
  </package>