EMerchantPay_Genesis_Client - Version 1.2.9

Version Notes

1.) Fix Order Status Update after Synchronous Transaction (Sale, Authorize) using Direct Payment Method

2.) Online Refund was not possible after processing Sale3D Transaction using Direct Payment Method

Download this release

Release Info

Developer eMerchantPay Ltd.
Extension EMerchantPay_Genesis_Client
Version 1.2.9
Comparing to
See all releases


Code changes from version 1.2.8 to 1.2.9

app/code/community/EMerchantPay/Genesis/Block/Form/Direct.php CHANGED
@@ -73,7 +73,7 @@ class EMerchantPay_Genesis_Block_Form_Direct extends Mage_Payment_Block_Form
73
  public function getCcMonths()
74
  {
75
  $months = $this->getData('cc_months');
76
- if (is_null($months)) {
77
  $months[0] = $this->__('Month');
78
  $months = array_merge($months, $this->_getConfig()->getMonths());
79
  $this->setData('cc_months', $months);
@@ -89,7 +89,7 @@ class EMerchantPay_Genesis_Block_Form_Direct extends Mage_Payment_Block_Form
89
  public function getCcYears()
90
  {
91
  $years = $this->getData('cc_years');
92
- if (is_null($years)) {
93
  $years = $this->_getConfig()->getYears();
94
  $years = array(0=>$this->__('Year'))+$years;
95
  $this->setData('cc_years', $years);
@@ -106,7 +106,7 @@ class EMerchantPay_Genesis_Block_Form_Direct extends Mage_Payment_Block_Form
106
  {
107
  if ($this->getMethod()) {
108
  $configData = $this->getMethod()->getConfigData('useccv');
109
- if (is_null($configData)) {
110
  return true;
111
  }
112
  return (bool) $configData;
@@ -121,9 +121,12 @@ class EMerchantPay_Genesis_Block_Form_Direct extends Mage_Payment_Block_Form
121
  */
122
  protected function _toHtml()
123
  {
124
- Mage::dispatchEvent('payment_form_block_to_html_before', array(
125
- 'block' => $this
126
- ));
 
 
 
127
 
128
  return parent::_toHtml();
129
  }
73
  public function getCcMonths()
74
  {
75
  $months = $this->getData('cc_months');
76
+ if ($months === null) {
77
  $months[0] = $this->__('Month');
78
  $months = array_merge($months, $this->_getConfig()->getMonths());
79
  $this->setData('cc_months', $months);
89
  public function getCcYears()
90
  {
91
  $years = $this->getData('cc_years');
92
+ if ($years === null) {
93
  $years = $this->_getConfig()->getYears();
94
  $years = array(0=>$this->__('Year'))+$years;
95
  $this->setData('cc_years', $years);
106
  {
107
  if ($this->getMethod()) {
108
  $configData = $this->getMethod()->getConfigData('useccv');
109
+ if ($configData === null) {
110
  return true;
111
  }
112
  return (bool) $configData;
121
  */
122
  protected function _toHtml()
123
  {
124
+ Mage::dispatchEvent(
125
+ 'payment_form_block_to_html_before',
126
+ array(
127
+ 'block' => $this
128
+ )
129
+ );
130
 
131
  return parent::_toHtml();
132
  }
app/code/community/EMerchantPay/Genesis/Block/Redirect/Checkout.php CHANGED
@@ -25,9 +25,9 @@
25
  class EMerchantPay_Genesis_Block_Redirect_Checkout extends Mage_Core_Block_Template
26
  {
27
  /** @var String */
28
- private $unique_id;
29
  /** @var EMerchantPay_Genesis_Helper_Data $helper */
30
- private $helper;
31
 
32
  protected function _construct()
33
  {
@@ -51,7 +51,7 @@ class EMerchantPay_Genesis_Block_Redirect_Checkout extends Mage_Core_Block_Templ
51
 
52
  $form
53
  ->setAction(
54
- $this->helper->getCheckoutSession()->getEmerchantPayCheckoutRedirectUrl()
55
  )
56
  ->setId('emerchantpay_redirect_notification')
57
  ->setName('emerchantpay_redirect_notification')
@@ -80,22 +80,22 @@ class EMerchantPay_Genesis_Block_Redirect_Checkout extends Mage_Core_Block_Templ
80
  */
81
  public function getButtonId()
82
  {
83
- return sprintf('redirect_to_dest_%s', $this->unique_id);
84
  }
85
 
86
  /**
87
  * Set Helper
88
  */
89
- private function setHelper()
90
  {
91
- $this->helper = Mage::helper('emerchantpay');
92
  }
93
 
94
  /**
95
  * Set Unique Id
96
  */
97
- private function setUniqueId()
98
  {
99
- $this->unique_id = Mage::helper('core')->uniqHash();
100
  }
101
  }
25
  class EMerchantPay_Genesis_Block_Redirect_Checkout extends Mage_Core_Block_Template
26
  {
27
  /** @var String */
28
+ protected $_uniqueId;
29
  /** @var EMerchantPay_Genesis_Helper_Data $helper */
30
+ protected $_helper;
31
 
32
  protected function _construct()
33
  {
51
 
52
  $form
53
  ->setAction(
54
+ $this->_helper->getCheckoutSession()->getEmerchantPayCheckoutRedirectUrl()
55
  )
56
  ->setId('emerchantpay_redirect_notification')
57
  ->setName('emerchantpay_redirect_notification')
80
  */
81
  public function getButtonId()
82
  {
83
+ return sprintf('redirect_to_dest_%s', $this->_uniqueId);
84
  }
85
 
86
  /**
87
  * Set Helper
88
  */
89
+ protected function setHelper()
90
  {
91
+ $this->_helper = Mage::helper('emerchantpay');
92
  }
93
 
94
  /**
95
  * Set Unique Id
96
  */
97
+ protected function setUniqueId()
98
  {
99
+ $this->_uniqueId = Mage::helper('core')->uniqHash();
100
  }
101
  }
app/code/community/EMerchantPay/Genesis/Block/Redirect/Direct.php CHANGED
@@ -25,9 +25,9 @@
25
  class EMerchantPay_Genesis_Block_Redirect_Direct extends Mage_Core_Block_Template
26
  {
27
  /** @var String */
28
- private $unique_id;
29
  /** @var EMerchantPay_Genesis_Helper_Data $helper */
30
- private $helper;
31
 
32
  protected function _construct()
33
  {
@@ -47,7 +47,7 @@ class EMerchantPay_Genesis_Block_Redirect_Direct extends Mage_Core_Block_Templat
47
  */
48
  public function getButtonId()
49
  {
50
- return sprintf('redirect_to_dest_%s', $this->unique_id);
51
  }
52
 
53
  /**
@@ -61,7 +61,7 @@ class EMerchantPay_Genesis_Block_Redirect_Direct extends Mage_Core_Block_Templat
61
 
62
  $form
63
  ->setAction(
64
- $this->helper->getCheckoutSession()->getEmerchantPayDirectRedirectUrl()
65
  )
66
  ->setId('emerchantpay_redirect_notification')
67
  ->setName('emerchantpay_redirect_notification')
@@ -86,16 +86,16 @@ class EMerchantPay_Genesis_Block_Redirect_Direct extends Mage_Core_Block_Templat
86
  /**
87
  * Set Helper
88
  */
89
- private function setHelper()
90
  {
91
- $this->helper = Mage::helper('emerchantpay');
92
  }
93
 
94
  /**
95
  * Set Unique Id
96
  */
97
- private function setUniqueId()
98
  {
99
- $this->unique_id = Mage::helper('core')->uniqHash();
100
  }
101
  }
25
  class EMerchantPay_Genesis_Block_Redirect_Direct extends Mage_Core_Block_Template
26
  {
27
  /** @var String */
28
+ protected $_uniqueId;
29
  /** @var EMerchantPay_Genesis_Helper_Data $helper */
30
+ protected $_helper;
31
 
32
  protected function _construct()
33
  {
47
  */
48
  public function getButtonId()
49
  {
50
+ return sprintf('redirect_to_dest_%s', $this->_uniqueId);
51
  }
52
 
53
  /**
61
 
62
  $form
63
  ->setAction(
64
+ $this->_helper->getCheckoutSession()->getEmerchantPayDirectRedirectUrl()
65
  )
66
  ->setId('emerchantpay_redirect_notification')
67
  ->setName('emerchantpay_redirect_notification')
86
  /**
87
  * Set Helper
88
  */
89
+ protected function setHelper()
90
  {
91
+ $this->_helper = Mage::helper('emerchantpay');
92
  }
93
 
94
  /**
95
  * Set Unique Id
96
  */
97
+ protected function setUniqueId()
98
  {
99
+ $this->_uniqueId = Mage::helper('core')->uniqHash();
100
  }
101
  }
app/code/community/EMerchantPay/Genesis/Helper/Data.php CHANGED
@@ -37,7 +37,9 @@ class EMerchantPay_Genesis_Helper_Data extends Mage_Core_Helper_Abstract
37
  public function initLibrary()
38
  {
39
  if (!class_exists('\Genesis\Genesis', false)) {
 
40
  include Mage::getBaseDir('lib') . DS . 'Genesis' . DS . 'vendor' . DS . 'autoload.php';
 
41
  }
42
  }
43
 
@@ -201,7 +203,8 @@ class EMerchantPay_Genesis_Helper_Data extends Mage_Core_Helper_Abstract
201
 
202
  if (!\Genesis\API\Constants\i18n::isValidLanguageCode($languageCode)) {
203
  Mage::throwException(
204
- $this->__('The provided argument is not a valid ISO-639-1 language code ' .
 
205
  'or is not supported by the Payment Gateway!'
206
  )
207
  );
@@ -234,7 +237,9 @@ class EMerchantPay_Genesis_Helper_Data extends Mage_Core_Helper_Abstract
234
  public function getQuote($quoteId)
235
  {
236
  return Mage::getModel('sales/quote')->load(
237
- abs(intval($quoteId))
 
 
238
  );
239
  }
240
 
@@ -246,36 +251,36 @@ class EMerchantPay_Genesis_Helper_Data extends Mage_Core_Helper_Abstract
246
  */
247
  public function getArrayFromGatewayResponse($response)
248
  {
249
- $transaction_details = array();
250
 
251
  foreach ($response as $key => $value) {
252
  if (is_string($value)) {
253
- $transaction_details[$key] = $value;
254
  }
255
 
256
  if ($value instanceof DateTime) {
257
- $transaction_details[$key] = $value->format('c');
258
  }
259
  }
260
 
261
- return $transaction_details;
262
  }
263
 
264
  /**
265
  * Get DESC list of specific transactions from payment object
266
  *
267
  * @param Mage_Sales_Model_Order_Payment $payment
268
- * @param array|string $type_filter
269
  * @return array
270
  */
271
- public function getTransactionFromPaymentObject($payment, $type_filter)
272
  {
273
  $transactions = array();
274
 
275
  $collection = Mage::getModel('sales/order_payment_transaction')->getCollection()
276
  ->setOrderFilter($payment->getOrder())
277
  ->addPaymentIdFilter($payment->getId())
278
- ->addTxnTypeFilter($type_filter)
279
  ->setOrder('created_at', Varien_Data_Collection::SORT_ORDER_DESC);
280
 
281
  /** @var Mage_Sales_Model_Order_Payment_Transaction $txn */
@@ -291,7 +296,7 @@ class EMerchantPay_Genesis_Helper_Data extends Mage_Core_Helper_Abstract
291
  *
292
  * @see API parameter "Usage" or "Description"
293
  *
294
- * @param Mage_Sales_Model_Order_Payment $order
295
  *
296
  * @return string Formatted List of Items
297
  */
@@ -493,8 +498,6 @@ class EMerchantPay_Genesis_Helper_Data extends Mage_Core_Helper_Abstract
493
  ->getResponse()
494
  ->setRedirect($target)
495
  ->sendHeaders();
496
-
497
- exit(0);
498
  }
499
  }
500
 
@@ -564,12 +567,8 @@ class EMerchantPay_Genesis_Helper_Data extends Mage_Core_Helper_Abstract
564
  * @param bool $supportsRecurring
565
  * @return bool
566
  */
567
- public function getIsMethodAvailable(
568
- $method,
569
- $quote,
570
- $requiresSecureConnection = false,
571
- $supportsRecurring = true
572
- ) {
573
  return
574
  $this->getIsMethodActive($method) &&
575
  (!$requiresSecureConnection || $this->getIsSecureConnectionEnabled()) &&
@@ -617,45 +616,15 @@ class EMerchantPay_Genesis_Helper_Data extends Mage_Core_Helper_Abstract
617
  {
618
  $remoteAddress = Mage::helper('core/http')->getRemoteAddr(false);
619
 
620
- if (empty($remoteAddress) && function_exists("parse_url") && function_exists("gethostbyname")) {
621
- $parsedUrl = parse_url(
622
- Mage::getBaseUrl(Mage_Core_Model_store::URL_TYPE_WEB)
623
- );
624
 
625
- if (isset($parsedUrl['host'])) {
626
- $remoteAddress = gethostbyname(
627
- $parsedUrl['host']
628
- );
629
- }
630
  }
631
 
632
  return $remoteAddress ?: "127.0.0.1";
633
  }
634
 
635
- /**
636
- * Builds a Genesis Transaction Class name by Genesis Transaction
637
- * @param string $transactionType
638
- * @return string
639
- */
640
- public function getGenesisTransactionClassName($transactionType)
641
- {
642
- $this->initLibrary();
643
-
644
- $className = \Genesis\Utils\Common::snakeCaseToCamelCase($transactionType);
645
-
646
- if ($this->getIsTransaction3dSecure($transactionType)) {
647
- $className =
648
- substr(
649
- $className,
650
- 0,
651
- strlen($className) - strlen(self::SECURE_TRANSCTION_TYPE_SUFFIX)
652
- ) .
653
- self::SECURE_TRANSCTION_TYPE_SUFFIX;
654
- }
655
-
656
- return $className;
657
- }
658
-
659
  /**
660
  * @param string $transactionType
661
  * @return bool
@@ -785,17 +754,12 @@ class EMerchantPay_Genesis_Helper_Data extends Mage_Core_Helper_Abstract
785
  }
786
 
787
  /**
788
- * Returns a formatted MySQL Datetime Value
789
- * @param int $time
790
  * @return string
791
  */
792
- public function formatDateTimeToMySQLDateTime($time)
793
  {
794
- return
795
- strftime(
796
- '%Y-%m-%d %H:%M:%S',
797
- $time
798
- );
799
  }
800
 
801
  /**
37
  public function initLibrary()
38
  {
39
  if (!class_exists('\Genesis\Genesis', false)) {
40
+ // @codingStandardsIgnoreStart
41
  include Mage::getBaseDir('lib') . DS . 'Genesis' . DS . 'vendor' . DS . 'autoload.php';
42
+ // @codingStandardsIgnoreEnd
43
  }
44
  }
45
 
203
 
204
  if (!\Genesis\API\Constants\i18n::isValidLanguageCode($languageCode)) {
205
  Mage::throwException(
206
+ $this->__(
207
+ 'The provided argument is not a valid ISO-639-1 language code ' .
208
  'or is not supported by the Payment Gateway!'
209
  )
210
  );
237
  public function getQuote($quoteId)
238
  {
239
  return Mage::getModel('sales/quote')->load(
240
+ abs(
241
+ (int) $quoteId
242
+ )
243
  );
244
  }
245
 
251
  */
252
  public function getArrayFromGatewayResponse($response)
253
  {
254
+ $transactionDetails = array();
255
 
256
  foreach ($response as $key => $value) {
257
  if (is_string($value)) {
258
+ $transactionDetails[$key] = $value;
259
  }
260
 
261
  if ($value instanceof DateTime) {
262
+ $transactionDetails[$key] = $value->format('c');
263
  }
264
  }
265
 
266
+ return $transactionDetails;
267
  }
268
 
269
  /**
270
  * Get DESC list of specific transactions from payment object
271
  *
272
  * @param Mage_Sales_Model_Order_Payment $payment
273
+ * @param array|string $typeFilter
274
  * @return array
275
  */
276
+ public function getTransactionFromPaymentObject($payment, $typeFilter)
277
  {
278
  $transactions = array();
279
 
280
  $collection = Mage::getModel('sales/order_payment_transaction')->getCollection()
281
  ->setOrderFilter($payment->getOrder())
282
  ->addPaymentIdFilter($payment->getId())
283
+ ->addTxnTypeFilter($typeFilter)
284
  ->setOrder('created_at', Varien_Data_Collection::SORT_ORDER_DESC);
285
 
286
  /** @var Mage_Sales_Model_Order_Payment_Transaction $txn */
296
  *
297
  * @see API parameter "Usage" or "Description"
298
  *
299
+ * @param Mage_Sales_Model_Order $order
300
  *
301
  * @return string Formatted List of Items
302
  */
498
  ->getResponse()
499
  ->setRedirect($target)
500
  ->sendHeaders();
 
 
501
  }
502
  }
503
 
567
  * @param bool $supportsRecurring
568
  * @return bool
569
  */
570
+ public function getIsMethodAvailable($method, $quote, $requiresSecureConnection = false, $supportsRecurring = true)
571
+ {
 
 
 
 
572
  return
573
  $this->getIsMethodActive($method) &&
574
  (!$requiresSecureConnection || $this->getIsSecureConnectionEnabled()) &&
616
  {
617
  $remoteAddress = Mage::helper('core/http')->getRemoteAddr(false);
618
 
619
+ if (!$remoteAddress && function_exists("gethostbyname")) {
620
+ $requestHostName = Mage::app()->getRequest()->getHttpHost();
 
 
621
 
622
+ $remoteAddress = gethostbyname($requestHostName);
 
 
 
 
623
  }
624
 
625
  return $remoteAddress ?: "127.0.0.1";
626
  }
627
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
628
  /**
629
  * @param string $transactionType
630
  * @return bool
754
  }
755
 
756
  /**
757
+ * Returns the current datetime as a formatted MySQL Datetime Value
 
758
  * @return string
759
  */
760
+ public function formatCurrentDateTimeToMySQLDateTime()
761
  {
762
+ return Mage::getSingleton('core/date')->gmtDate();
 
 
 
 
763
  }
764
 
765
  /**
app/code/community/EMerchantPay/Genesis/Model/Checkout.php CHANGED
@@ -22,7 +22,8 @@
22
  *
23
  * Class EMerchantPay_Genesis_Model_Checkout
24
  */
25
- class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abstract implements Mage_Payment_Model_Recurring_Profile_MethodInterface
 
26
  {
27
  protected $_code = 'emerchantpay_checkout';
28
 
@@ -118,31 +119,31 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
118
  ->setLanguage($this->getHelper()->getLocale());
119
 
120
 
121
- foreach ($this->getTransactionTypes() as $transaction_type) {
122
- if (is_array($transaction_type)) {
123
  $genesis->request()->addTransactionType(
124
- $transaction_type['name'],
125
- $transaction_type['parameters']
126
  );
127
  } else {
128
- if (\Genesis\API\Constants\Transaction\Types::isPayByVoucher($transaction_type)) {
129
- $parameters = [
130
  'card_type' =>
131
  \Genesis\API\Constants\Transaction\Parameters\PayByVouchers\CardTypes::VIRTUAL,
132
  'redeem_type' =>
133
  \Genesis\API\Constants\Transaction\Parameters\PayByVouchers\RedeemTypes::INSTANT
134
- ];
135
- if ($transaction_type == \Genesis\API\Constants\Transaction\Types::PAYBYVOUCHER_YEEPAY) {
136
  $parameters['product_name'] = $orderItemsList;
137
  $parameters['product_category'] = $orderItemsList;
138
  }
139
  $genesis
140
  ->request()
141
- ->addTransactionType($transaction_type, $parameters);
142
  } else {
143
  $genesis
144
  ->request()
145
- ->addTransactionType($transaction_type);
146
  }
147
  }
148
  }
@@ -203,7 +204,7 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
203
  return $this;
204
  }
205
 
206
- $reference_id = $authorize->getTxnId();
207
 
208
  $genesis = new \Genesis\Genesis('Financial\Capture');
209
 
@@ -218,7 +219,7 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
218
  $this->getHelper('core/http')->getRemoteAddr(false)
219
  )
220
  ->setReferenceId(
221
- $reference_id
222
  )
223
  ->setCurrency(
224
  $payment->getOrder()->getOrderCurrencyCode()
@@ -233,10 +234,12 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
233
 
234
  $payment
235
  ->setTransactionId(
 
236
  $responseObject->unique_id
 
237
  )
238
  ->setParentTransactionId(
239
- $reference_id
240
  )
241
  ->setShouldCloseParentTransaction(
242
  true
@@ -308,7 +311,7 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
308
  return $this;
309
  }
310
 
311
- $reference_id = $capture->getTxnId();
312
 
313
  $genesis = new \Genesis\Genesis('Financial\Refund');
314
 
@@ -323,7 +326,7 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
323
  $this->getHelper('core/http')->getRemoteAddr(false)
324
  )
325
  ->setReferenceId(
326
- $reference_id
327
  )
328
  ->setCurrency(
329
  $payment->getOrder()->getOrderCurrencyCode()
@@ -336,10 +339,12 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
336
 
337
  $payment
338
  ->setTransactionId(
 
339
  $responseObject->unique_id
 
340
  )
341
  ->setParentTransactionId(
342
- $reference_id
343
  )
344
  ->setShouldCloseParentTransaction(
345
  true
@@ -412,12 +417,15 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
412
 
413
  $this->getHelper()->setTokenByPaymentTransaction($payment);
414
 
415
- $transactions = $this->getHelper()->getTransactionFromPaymentObject($payment, array(
416
- Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH,
417
- Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE
418
- ));
 
 
 
419
 
420
- $reference_id = $transactions ? reset($transactions)->getTxnId() : null;
421
 
422
  $genesis = new \Genesis\Genesis('Financial\Void');
423
 
@@ -432,7 +440,7 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
432
  $this->getHelper('core/http')->getRemoteAddr(false)
433
  )
434
  ->setReferenceId(
435
- $reference_id
436
  );
437
 
438
  $genesis->execute();
@@ -441,10 +449,12 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
441
 
442
  $payment
443
  ->setTransactionId(
 
444
  $responseObject->unique_id
 
445
  )
446
  ->setParentTransactionId(
447
- $reference_id
448
  )
449
  ->setShouldCloseParentTransaction(
450
  true
@@ -508,32 +518,38 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
508
  /** @var Mage_Sales_Model_Order_Payment_Transaction $transaction */
509
  $transaction = Mage::getModel('sales/order_payment_transaction')->load($transactionId, 'txn_id');
510
 
511
- $checkout_transaction = $transaction->getOrder()->getPayment()->lookupTransaction(
512
  null,
513
  Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER
514
  );
515
 
516
- $reconcile = $this->reconcile($checkout_transaction->getTxnId());
 
 
517
 
518
  // Get the current details
519
- $transaction_details = $payment->getAdditionalInformation(
520
  Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS
521
  );
522
 
523
  // Try to extract transaction details from the Gateway response
 
524
  if ($reconcile->unique_id == $transactionId) {
525
- $transaction_details = $reconcile;
526
  } else {
527
  if ($reconcile->payment_transaction instanceof stdClass) {
528
  if ($reconcile->payment_transaction->unique_id == $transactionId) {
529
- $transaction_details = $reconcile->payment_transaction;
 
530
  }
531
  }
532
 
 
533
  if ($reconcile->payment_transaction instanceof ArrayObject) {
534
- foreach ($reconcile->payment_transaction as $payment_transaction) {
535
- if ($payment_transaction->unique_id == $transactionId) {
536
- $transaction_details = $payment_transaction;
 
537
  }
538
  }
539
  }
@@ -549,7 +565,7 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
549
  array(
550
  Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS =>
551
  $this->getHelper()->getArrayFromGatewayResponse(
552
- $transaction_details
553
  )
554
  ),
555
  null
@@ -565,20 +581,20 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
565
  /**
566
  * Execute a WPF Reconcile
567
  *
568
- * @param $unique_id
569
  *
570
- * @return EMerchantPay_Genesis_Model_Checkout
571
  *
572
  * @throws Mage_Core_Exception
573
  */
574
- public function reconcile($unique_id)
575
  {
576
  try {
577
  $this->getHelper()->initClient($this->getCode());
578
 
579
  $genesis = new \Genesis\Genesis('WPF\Reconcile');
580
 
581
- $genesis->request()->setUniqueId($unique_id);
582
 
583
  $genesis->execute();
584
 
@@ -597,121 +613,151 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
597
  /**
598
  * Handle an incoming Genesis notification
599
  *
600
- * @param stdClass $reconcile
601
  * @return bool
602
  */
603
- public function processNotification($checkout_transaction)
 
604
  {
 
605
  try {
606
  $this->getHelper()->initClient($this->getCode());
607
 
608
  /** @var Mage_Sales_Model_Order_Payment_Transaction $transaction */
609
  $transaction = Mage::getModel('sales/order_payment_transaction')->load(
610
- $checkout_transaction->unique_id,
 
 
611
  'txn_id'
612
  );
613
 
614
  $order = $transaction->getOrder();
615
 
616
- if ($order) {
617
- $transaction
618
- ->setOrderPaymentObject(
619
- $order->getPayment()
620
- )
621
- ->setAdditionalInformation(
622
- Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS,
623
- $this->getHelper()->getArrayFromGatewayResponse(
624
- $checkout_transaction
625
- )
 
 
626
  )
627
- ->save();
628
-
629
- if (isset($checkout_transaction->payment_transaction)) {
630
- $payment_transaction = $checkout_transaction->payment_transaction;
631
-
632
- $payment = $order->getPayment();
633
-
634
- $payment
635
- ->setTransactionId($payment_transaction->unique_id)
636
- ->setParentTransactionId($checkout_transaction->unique_id)
637
- ->setShouldCloseParentTransaction(true)
638
- ->setIsTransactionPending(false)
639
- ->resetTransactionAdditionalInfo()
640
- ->setTransactionAdditionalInfo(
641
- array(
642
- Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS =>
643
- $this->getHelper()->getArrayFromGatewayResponse(
644
- $payment_transaction
645
- )
646
- ),
647
- null
648
- );
649
 
650
- if ($payment_transaction->status == \Genesis\API\Constants\Transaction\States::APPROVED) {
651
- $payment->setIsTransactionClosed(false);
652
- } else {
653
- $payment->setIsTransactionClosed(true);
654
- }
655
 
656
- switch ($payment_transaction->transaction_type) {
657
- case \Genesis\API\Constants\Transaction\Types::AUTHORIZE:
658
- case \Genesis\API\Constants\Transaction\Types::AUTHORIZE_3D:
659
- $payment->registerAuthorizationNotification(
660
- $payment_transaction->amount
661
- );
662
- break;
663
- case \Genesis\API\Constants\Transaction\Types::ABNIDEAL:
664
- case \Genesis\API\Constants\Transaction\Types::CASHU:
665
- case \Genesis\API\Constants\Transaction\Types::NETELLER:
666
- case \Genesis\API\Constants\Transaction\Types::PAYSAFECARD:
667
- case \Genesis\API\Constants\Transaction\Types::PPRO:
668
- case \Genesis\API\Constants\Transaction\Types::SALE:
669
- case \Genesis\API\Constants\Transaction\Types::SALE_3D:
670
- case \Genesis\API\Constants\Transaction\Types::SOFORT:
671
- case \Genesis\API\Constants\Transaction\Types::INIT_RECURRING_SALE:
672
- case \Genesis\API\Constants\Transaction\Types::INIT_RECURRING_SALE_3D:
673
- $payment->registerCaptureNotification(
674
- $payment_transaction->amount
675
- );
676
- break;
677
- default:
678
- break;
679
- }
680
 
681
- $isTransactionApproved =
682
- ($payment_transaction->status == \Genesis\API\Constants\Transaction\States::APPROVED);
683
 
684
- if ($this->getHelper()->getIsTransactionTypeInitRecurring($payment_transaction->transaction_type)) {
685
- $recurringProfile = Mage::getModel('sales/recurring_profile')->load(
686
- $checkout_transaction->unique_id,
687
- 'reference_id'
688
- );
689
 
690
- if ($recurringProfile && $recurringProfile->getId()) {
691
- if ($recurringProfile->getState() == Mage_Sales_Model_Recurring_Profile::STATE_PENDING) {
692
- $recurringProfile->setState(
693
- ($isTransactionApproved
694
- ? Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE
695
- : Mage_Sales_Model_Recurring_Profile::STATE_CANCELED
696
- )
697
- );
698
- $recurringProfile->save();
699
- }
700
- }
701
- }
702
 
703
- $payment->save();
704
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
705
 
706
- $this->getHelper()->setOrderState(
707
- $order,
708
- isset($payment_transaction)
709
- ? $payment_transaction->status
710
- : $checkout_transaction->status
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
711
  );
712
 
713
- return true;
 
 
 
 
 
 
 
 
 
 
714
  }
 
 
 
 
 
 
 
 
 
715
  } catch (Exception $exception) {
716
  Mage::logException($exception);
717
  }
@@ -741,9 +787,9 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
741
  */
742
  public function getTransactionTypes()
743
  {
744
- $processed_list = array();
745
 
746
- $selected_types = array_map(
747
  'trim',
748
  explode(
749
  ',',
@@ -751,7 +797,7 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
751
  )
752
  );
753
 
754
- $alias_map = array(
755
  \Genesis\API\Constants\Payment\Methods::EPS =>
756
  \Genesis\API\Constants\Transaction\Types::PPRO,
757
  \Genesis\API\Constants\Payment\Methods::GIRO_PAY =>
@@ -768,21 +814,21 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
768
  \Genesis\API\Constants\Transaction\Types::PPRO,
769
  );
770
 
771
- foreach ($selected_types as $selected_type) {
772
- if (array_key_exists($selected_type, $alias_map)) {
773
- $transaction_type = $alias_map[$selected_type];
774
 
775
- $processed_list[$transaction_type]['name'] = $transaction_type;
776
 
777
- $processed_list[$transaction_type]['parameters'][] = array(
778
- 'payment_method' => $selected_type
779
  );
780
  } else {
781
- $processed_list[] = $selected_type;
782
  }
783
  }
784
 
785
- return $processed_list;
786
  }
787
 
788
  /**
@@ -802,13 +848,6 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
802
  return $this->getHelper()->getRedirectUrl('checkout');
803
  }
804
 
805
- /*
806
- public function getCheckoutRedirectUrl()
807
- {
808
- return Mage::getUrl('checkout/onepage/index', array('_fragment' => 'review', '_secure' => true));
809
- }*/
810
-
811
-
812
  /**
813
  * Get the helper or return its instance
814
  *
@@ -816,9 +855,9 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
816
  *
817
  * @return EMerchantPay_Genesis_Helper_Data|mixed
818
  */
819
- private function getHelper($helper = '')
820
  {
821
- if (empty($helper)) {
822
  return Mage::helper('emerchantpay');
823
  } else {
824
  return Mage::helper($helper);
@@ -889,7 +928,8 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
889
  public function submitRecurringProfile(
890
  Mage_Payment_Model_Recurring_Profile $profile,
891
  Mage_Payment_Model_Info $payment
892
- ) {
 
893
  $logFileName = $this->getConfigData('cron_recurring_log_file');
894
  $isLogEnabled = !empty($logFileName);
895
 
@@ -903,7 +943,7 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
903
 
904
  $amount = $profile->getInitAmount() ?: 0;
905
 
906
- if (empty($amount)) {
907
  Mage::throwException(
908
  $this->getHelper()->__("Unable to create Init Recurring Transaction! Initial Fee must not be empty!")
909
  );
@@ -995,8 +1035,8 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
995
  );
996
 
997
 
998
- foreach ($this->getRecurringTransactionTypes() as $transaction_type) {
999
- $genesis->request()->addTransactionType($transaction_type);
1000
  }
1001
 
1002
  try {
@@ -1004,17 +1044,23 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
1004
 
1005
  $responseObject = $genesis->response()->getResponseObject();
1006
 
 
1007
  if (isset($responseObject->redirect_url)) {
 
1008
  $this
1009
  ->getHelper()
1010
  ->getCheckoutSession()
1011
  ->setEmerchantPayCheckoutRedirectUrl(
 
1012
  $responseObject->redirect_url
 
1013
  );
1014
  }
1015
 
1016
  $profile->setReferenceId(
 
1017
  $responseObject->unique_id
 
1018
  );
1019
 
1020
  $payment->setSkipTransactionCreation(true);
@@ -1039,10 +1085,14 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
1039
  );
1040
 
1041
  $payment = $order->getPayment();
 
1042
  $payment
1043
  ->setTransactionId(
 
1044
  $responseObject->unique_id
 
1045
  );
 
1046
  $payment
1047
  ->setIsTransactionPending(
1048
  true
@@ -1077,12 +1127,13 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
1077
  Mage_Sales_Model_Recurring_Profile::STATE_PENDING
1078
  );
1079
 
1080
- return $this;
1081
  } catch (Exception $e) {
1082
  Mage::throwException(
1083
  $e->getMessage()
1084
  );
1085
  }
 
 
1086
  }
1087
 
1088
  /**
@@ -1110,7 +1161,7 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
1110
  * Update RP data
1111
  *
1112
  * @param Mage_Payment_Model_Recurring_Profile $profile
1113
- * @return bool
1114
  */
1115
  public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
1116
  {
@@ -1128,7 +1179,7 @@ class EMerchantPay_Genesis_Model_Checkout extends Mage_Payment_Model_Method_Abst
1128
  * Manage status
1129
  *
1130
  * @param Mage_Payment_Model_Recurring_Profile $profile
1131
- * @return bool
1132
  */
1133
  public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile)
1134
  {
22
  *
23
  * Class EMerchantPay_Genesis_Model_Checkout
24
  */
25
+ class EMerchantPay_Genesis_Model_Checkout
26
+ extends Mage_Payment_Model_Method_Abstract implements Mage_Payment_Model_Recurring_Profile_MethodInterface
27
  {
28
  protected $_code = 'emerchantpay_checkout';
29
 
119
  ->setLanguage($this->getHelper()->getLocale());
120
 
121
 
122
+ foreach ($this->getTransactionTypes() as $transactionType) {
123
+ if (is_array($transactionType)) {
124
  $genesis->request()->addTransactionType(
125
+ $transactionType['name'],
126
+ $transactionType['parameters']
127
  );
128
  } else {
129
+ if (\Genesis\API\Constants\Transaction\Types::isPayByVoucher($transactionType)) {
130
+ $parameters = array(
131
  'card_type' =>
132
  \Genesis\API\Constants\Transaction\Parameters\PayByVouchers\CardTypes::VIRTUAL,
133
  'redeem_type' =>
134
  \Genesis\API\Constants\Transaction\Parameters\PayByVouchers\RedeemTypes::INSTANT
135
+ );
136
+ if ($transactionType == \Genesis\API\Constants\Transaction\Types::PAYBYVOUCHER_YEEPAY) {
137
  $parameters['product_name'] = $orderItemsList;
138
  $parameters['product_category'] = $orderItemsList;
139
  }
140
  $genesis
141
  ->request()
142
+ ->addTransactionType($transactionType, $parameters);
143
  } else {
144
  $genesis
145
  ->request()
146
+ ->addTransactionType($transactionType);
147
  }
148
  }
149
  }
204
  return $this;
205
  }
206
 
207
+ $referenceId = $authorize->getTxnId();
208
 
209
  $genesis = new \Genesis\Genesis('Financial\Capture');
210
 
219
  $this->getHelper('core/http')->getRemoteAddr(false)
220
  )
221
  ->setReferenceId(
222
+ $referenceId
223
  )
224
  ->setCurrency(
225
  $payment->getOrder()->getOrderCurrencyCode()
234
 
235
  $payment
236
  ->setTransactionId(
237
+ // @codingStandardsIgnoreStart
238
  $responseObject->unique_id
239
+ // @codingStandardsIgnoreEnd
240
  )
241
  ->setParentTransactionId(
242
+ $referenceId
243
  )
244
  ->setShouldCloseParentTransaction(
245
  true
311
  return $this;
312
  }
313
 
314
+ $referenceId = $capture->getTxnId();
315
 
316
  $genesis = new \Genesis\Genesis('Financial\Refund');
317
 
326
  $this->getHelper('core/http')->getRemoteAddr(false)
327
  )
328
  ->setReferenceId(
329
+ $referenceId
330
  )
331
  ->setCurrency(
332
  $payment->getOrder()->getOrderCurrencyCode()
339
 
340
  $payment
341
  ->setTransactionId(
342
+ // @codingStandardsIgnoreStart
343
  $responseObject->unique_id
344
+ // @codingStandardsIgnoreEnd
345
  )
346
  ->setParentTransactionId(
347
+ $referenceId
348
  )
349
  ->setShouldCloseParentTransaction(
350
  true
417
 
418
  $this->getHelper()->setTokenByPaymentTransaction($payment);
419
 
420
+ $transactions = $this->getHelper()->getTransactionFromPaymentObject(
421
+ $payment,
422
+ array(
423
+ Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH,
424
+ Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE
425
+ )
426
+ );
427
 
428
+ $referenceId = $transactions ? reset($transactions)->getTxnId() : null;
429
 
430
  $genesis = new \Genesis\Genesis('Financial\Void');
431
 
440
  $this->getHelper('core/http')->getRemoteAddr(false)
441
  )
442
  ->setReferenceId(
443
+ $referenceId
444
  );
445
 
446
  $genesis->execute();
449
 
450
  $payment
451
  ->setTransactionId(
452
+ // @codingStandardsIgnoreStart
453
  $responseObject->unique_id
454
+ // @codingStandardsIgnoreEnd
455
  )
456
  ->setParentTransactionId(
457
+ $referenceId
458
  )
459
  ->setShouldCloseParentTransaction(
460
  true
518
  /** @var Mage_Sales_Model_Order_Payment_Transaction $transaction */
519
  $transaction = Mage::getModel('sales/order_payment_transaction')->load($transactionId, 'txn_id');
520
 
521
+ $checkoutTransaction = $transaction->getOrder()->getPayment()->lookupTransaction(
522
  null,
523
  Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER
524
  );
525
 
526
+ $reconcile = $this->reconcile(
527
+ $checkoutTransaction->getTxnId()
528
+ );
529
 
530
  // Get the current details
531
+ $transactionDetails = $payment->getAdditionalInformation(
532
  Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS
533
  );
534
 
535
  // Try to extract transaction details from the Gateway response
536
+ // @codingStandardsIgnoreStart
537
  if ($reconcile->unique_id == $transactionId) {
538
+ $transactionDetails = $reconcile;
539
  } else {
540
  if ($reconcile->payment_transaction instanceof stdClass) {
541
  if ($reconcile->payment_transaction->unique_id == $transactionId) {
542
+ $transactionDetails = $reconcile->payment_transaction;
543
+ // @codingStandardsIgnoreEnd
544
  }
545
  }
546
 
547
+ // @codingStandardsIgnoreStart
548
  if ($reconcile->payment_transaction instanceof ArrayObject) {
549
+ foreach ($reconcile->payment_transaction as $paymentTransaction) {
550
+ if ($paymentTransaction->unique_id == $transactionId) {
551
+ // @codingStandardsIgnoreEnd
552
+ $transactionDetails = $paymentTransaction;
553
  }
554
  }
555
  }
565
  array(
566
  Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS =>
567
  $this->getHelper()->getArrayFromGatewayResponse(
568
+ $transactionDetails
569
  )
570
  ),
571
  null
581
  /**
582
  * Execute a WPF Reconcile
583
  *
584
+ * @param string $uniqueId
585
  *
586
+ * @return bool|stdClass
587
  *
588
  * @throws Mage_Core_Exception
589
  */
590
+ public function reconcile($uniqueId)
591
  {
592
  try {
593
  $this->getHelper()->initClient($this->getCode());
594
 
595
  $genesis = new \Genesis\Genesis('WPF\Reconcile');
596
 
597
+ $genesis->request()->setUniqueId($uniqueId);
598
 
599
  $genesis->execute();
600
 
613
  /**
614
  * Handle an incoming Genesis notification
615
  *
616
+ * @param stdClass $checkoutTransaction
617
  * @return bool
618
  */
619
+ // @codingStandardsIgnoreStart
620
+ public function processNotification($checkoutTransaction)
621
  {
622
+ // @codingStandardsIgnoreEnd
623
  try {
624
  $this->getHelper()->initClient($this->getCode());
625
 
626
  /** @var Mage_Sales_Model_Order_Payment_Transaction $transaction */
627
  $transaction = Mage::getModel('sales/order_payment_transaction')->load(
628
+ // @codingStandardsIgnoreStart
629
+ $checkoutTransaction->unique_id,
630
+ // @codingStandardsIgnoreEnd
631
  'txn_id'
632
  );
633
 
634
  $order = $transaction->getOrder();
635
 
636
+ if (!$order) {
637
+ return false;
638
+ }
639
+
640
+ $transaction
641
+ ->setOrderPaymentObject(
642
+ $order->getPayment()
643
+ )
644
+ ->setAdditionalInformation(
645
+ Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS,
646
+ $this->getHelper()->getArrayFromGatewayResponse(
647
+ $checkoutTransaction
648
  )
649
+ )
650
+ ->save();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
651
 
652
+ // @codingStandardsIgnoreStart
653
+ if (!isset($checkoutTransaction->payment_transaction)) {
654
+ // @codingStandardsIgnoreEnd
 
 
655
 
656
+ $this->getHelper()->setOrderState(
657
+ $order,
658
+ $checkoutTransaction->status
659
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
660
 
661
+ return false;
662
+ }
663
 
664
+ // @codingStandardsIgnoreStart
665
+ $paymentTransaction = $checkoutTransaction->payment_transaction;
666
+ // @codingStandardsIgnoreEnd
 
 
667
 
668
+ $payment = $order->getPayment();
 
 
 
 
 
 
 
 
 
 
 
669
 
670
+ $payment
671
+ ->setTransactionId(
672
+ // @codingStandardsIgnoreStart
673
+ $paymentTransaction->unique_id
674
+ // @codingStandardsIgnoreEnd
675
+ )
676
+ ->setParentTransactionId(
677
+ // @codingStandardsIgnoreStart
678
+ $checkoutTransaction->unique_id
679
+ // @codingStandardsIgnoreEnd
680
+ )
681
+ ->setShouldCloseParentTransaction(true)
682
+ ->setIsTransactionPending(false)
683
+ ->resetTransactionAdditionalInfo()
684
+ ->setTransactionAdditionalInfo(
685
+ array(
686
+ Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS =>
687
+ $this->getHelper()->getArrayFromGatewayResponse(
688
+ $paymentTransaction
689
+ )
690
+ ),
691
+ null
692
+ );
693
 
694
+ if ($paymentTransaction->status == \Genesis\API\Constants\Transaction\States::APPROVED) {
695
+ $payment->setIsTransactionClosed(false);
696
+ } else {
697
+ $payment->setIsTransactionClosed(true);
698
+ }
699
+
700
+ // @codingStandardsIgnoreStart
701
+ switch ($paymentTransaction->transaction_type) {
702
+ // @codingStandardsIgnoreEnd
703
+ case \Genesis\API\Constants\Transaction\Types::AUTHORIZE:
704
+ case \Genesis\API\Constants\Transaction\Types::AUTHORIZE_3D:
705
+ $payment->registerAuthorizationNotification(
706
+ $paymentTransaction->amount
707
+ );
708
+ break;
709
+ case \Genesis\API\Constants\Transaction\Types::ABNIDEAL:
710
+ case \Genesis\API\Constants\Transaction\Types::CASHU:
711
+ case \Genesis\API\Constants\Transaction\Types::NETELLER:
712
+ case \Genesis\API\Constants\Transaction\Types::PAYSAFECARD:
713
+ case \Genesis\API\Constants\Transaction\Types::PPRO:
714
+ case \Genesis\API\Constants\Transaction\Types::SALE:
715
+ case \Genesis\API\Constants\Transaction\Types::SALE_3D:
716
+ case \Genesis\API\Constants\Transaction\Types::SOFORT:
717
+ case \Genesis\API\Constants\Transaction\Types::INIT_RECURRING_SALE:
718
+ case \Genesis\API\Constants\Transaction\Types::INIT_RECURRING_SALE_3D:
719
+ $payment->registerCaptureNotification(
720
+ $paymentTransaction->amount
721
+ );
722
+ break;
723
+ default:
724
+ break;
725
+ }
726
+
727
+ $isTransactionApproved =
728
+ ($paymentTransaction->status == \Genesis\API\Constants\Transaction\States::APPROVED);
729
+
730
+ // @codingStandardsIgnoreStart
731
+ if ($this->getHelper()->getIsTransactionTypeInitRecurring($paymentTransaction->transaction_type)) {
732
+ // @codingStandardsIgnoreEnd
733
+ $recurringProfile = Mage::getModel('sales/recurring_profile')->load(
734
+ // @codingStandardsIgnoreStart
735
+ $checkoutTransaction->unique_id,
736
+ // @codingStandardsIgnoreEnd
737
+ 'reference_id'
738
  );
739
 
740
+ if ($recurringProfile && $recurringProfile->getId()) {
741
+ if ($recurringProfile->getState() == Mage_Sales_Model_Recurring_Profile::STATE_PENDING) {
742
+ $recurringProfile->setState(
743
+ ($isTransactionApproved
744
+ ? Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE
745
+ : Mage_Sales_Model_Recurring_Profile::STATE_CANCELED
746
+ )
747
+ );
748
+ $recurringProfile->save();
749
+ }
750
+ }
751
  }
752
+
753
+ $payment->save();
754
+
755
+ $this->getHelper()->setOrderState(
756
+ $order,
757
+ $paymentTransaction->status
758
+ );
759
+
760
+ return true;
761
  } catch (Exception $exception) {
762
  Mage::logException($exception);
763
  }
787
  */
788
  public function getTransactionTypes()
789
  {
790
+ $processedList = array();
791
 
792
+ $selectedTypes = array_map(
793
  'trim',
794
  explode(
795
  ',',
797
  )
798
  );
799
 
800
+ $aliasMap = array(
801
  \Genesis\API\Constants\Payment\Methods::EPS =>
802
  \Genesis\API\Constants\Transaction\Types::PPRO,
803
  \Genesis\API\Constants\Payment\Methods::GIRO_PAY =>
814
  \Genesis\API\Constants\Transaction\Types::PPRO,
815
  );
816
 
817
+ foreach ($selectedTypes as $selectedType) {
818
+ if (array_key_exists($selectedType, $aliasMap)) {
819
+ $transactionType = $aliasMap[$selectedType];
820
 
821
+ $processedList[$transactionType]['name'] = $transactionType;
822
 
823
+ $processedList[$transactionType]['parameters'][] = array(
824
+ 'payment_method' => $selectedType
825
  );
826
  } else {
827
+ $processedList[] = $selectedType;
828
  }
829
  }
830
 
831
+ return $processedList;
832
  }
833
 
834
  /**
848
  return $this->getHelper()->getRedirectUrl('checkout');
849
  }
850
 
 
 
 
 
 
 
 
851
  /**
852
  * Get the helper or return its instance
853
  *
855
  *
856
  * @return EMerchantPay_Genesis_Helper_Data|mixed
857
  */
858
+ protected function getHelper($helper = '')
859
  {
860
+ if (!$helper) {
861
  return Mage::helper('emerchantpay');
862
  } else {
863
  return Mage::helper($helper);
928
  public function submitRecurringProfile(
929
  Mage_Payment_Model_Recurring_Profile $profile,
930
  Mage_Payment_Model_Info $payment
931
+ )
932
+ {
933
  $logFileName = $this->getConfigData('cron_recurring_log_file');
934
  $isLogEnabled = !empty($logFileName);
935
 
943
 
944
  $amount = $profile->getInitAmount() ?: 0;
945
 
946
+ if (!$amount) {
947
  Mage::throwException(
948
  $this->getHelper()->__("Unable to create Init Recurring Transaction! Initial Fee must not be empty!")
949
  );
1035
  );
1036
 
1037
 
1038
+ foreach ($this->getRecurringTransactionTypes() as $transactionType) {
1039
+ $genesis->request()->addTransactionType($transactionType);
1040
  }
1041
 
1042
  try {
1044
 
1045
  $responseObject = $genesis->response()->getResponseObject();
1046
 
1047
+ // @codingStandardsIgnoreStart
1048
  if (isset($responseObject->redirect_url)) {
1049
+ // @codingStandardsIgnoreEnd
1050
  $this
1051
  ->getHelper()
1052
  ->getCheckoutSession()
1053
  ->setEmerchantPayCheckoutRedirectUrl(
1054
+ // @codingStandardsIgnoreStart
1055
  $responseObject->redirect_url
1056
+ // @codingStandardsIgnoreEnd
1057
  );
1058
  }
1059
 
1060
  $profile->setReferenceId(
1061
+ // @codingStandardsIgnoreStart
1062
  $responseObject->unique_id
1063
+ // @codingStandardsIgnoreEnd
1064
  );
1065
 
1066
  $payment->setSkipTransactionCreation(true);
1085
  );
1086
 
1087
  $payment = $order->getPayment();
1088
+
1089
  $payment
1090
  ->setTransactionId(
1091
+ // @codingStandardsIgnoreStart
1092
  $responseObject->unique_id
1093
+ // @codingStandardsIgnoreEnd
1094
  );
1095
+
1096
  $payment
1097
  ->setIsTransactionPending(
1098
  true
1127
  Mage_Sales_Model_Recurring_Profile::STATE_PENDING
1128
  );
1129
 
 
1130
  } catch (Exception $e) {
1131
  Mage::throwException(
1132
  $e->getMessage()
1133
  );
1134
  }
1135
+
1136
+ return $this;
1137
  }
1138
 
1139
  /**
1161
  * Update RP data
1162
  *
1163
  * @param Mage_Payment_Model_Recurring_Profile $profile
1164
+ * @return $this
1165
  */
1166
  public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
1167
  {
1179
  * Manage status
1180
  *
1181
  * @param Mage_Payment_Model_Recurring_Profile $profile
1182
+ * @return $this
1183
  */
1184
  public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile)
1185
  {
app/code/community/EMerchantPay/Genesis/Model/Direct.php CHANGED
@@ -29,7 +29,8 @@
29
  *
30
  * @category
31
  */
32
- class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc implements Mage_Payment_Model_Recurring_Profile_MethodInterface
 
33
  {
34
  // Variables
35
  protected $_code = 'emerchantpay_direct';
@@ -116,6 +117,67 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
116
  return $this;
117
  }
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  /**
120
  * Payment action getter compatible with payment model
121
  *
@@ -127,16 +189,15 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
127
  {
128
  $this->getHelper()->initLibrary();
129
 
130
- switch ($this->getConfigData('genesis_type')) {
131
  default:
132
  case \Genesis\API\Constants\Transaction\Types::AUTHORIZE:
133
  case \Genesis\API\Constants\Transaction\Types::AUTHORIZE_3D:
134
  return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE;
135
- break;
136
  case \Genesis\API\Constants\Transaction\Types::SALE:
137
  case \Genesis\API\Constants\Transaction\Types::SALE_3D:
138
  return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE;
139
- break;
140
  }
141
  }
142
 
@@ -150,11 +211,13 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
150
  */
151
  public function authorize(Varien_Object $payment, $amount)
152
  {
153
- if ($this->is3dEnabled()) {
154
- return $this->_authorize3d($payment, $amount);
155
  } else {
156
- return $this->_authorize($payment, $amount);
157
  }
 
 
158
  }
159
 
160
  /**
@@ -170,274 +233,161 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
170
  $authorize = $payment->lookupTransaction(null, Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
171
 
172
  if ($authorize) {
173
- return $this->_capture($payment, $amount);
174
  } else {
175
- if ($this->is3dEnabled()) {
176
- return $this->_sale3d($payment, $amount);
177
  } else {
178
- return $this->_sale($payment, $amount);
179
  }
 
 
180
  }
181
  }
182
 
183
  /**
184
- * Genesis Authorize Payment Method
 
 
 
 
185
  *
186
  * @param Varien_Object|Mage_Sales_Model_Order_Payment $payment
187
- * @param String $amount
188
  *
189
  * @return EMerchantPay_Genesis_Model_Direct
190
  */
191
- private function _authorize($payment, $amount)
192
  {
193
- Mage::log('Authorize transaction for order #' . $payment->getOrder()->getIncrementId());
194
-
195
  try {
196
  $this->getHelper()->initClient($this->getCode());
197
 
 
 
 
 
198
  /** @var Mage_Sales_Model_Order $order */
199
  $order = $payment->getOrder();
200
 
201
- $billing = $order->getBillingAddress();
202
  $shipping = $order->getShippingAddress();
203
 
204
- $genesis = new \Genesis\Genesis('Financial\Cards\Authorize');
 
 
 
 
205
 
206
  $genesis
207
  ->request()
208
- ->setTransactionId($this->getHelper()->genTransactionId($order->getIncrementId()))
209
- ->setRemoteIp($this->getHelper()->getRemoteAddress())
210
- ->setUsage($this->getHelper()->getItemList($order))
211
- ->setCurrency(
212
- $order->getOrderCurrencyCode()
213
- )
214
- ->setAmount($amount)
215
- ->setCardHolder($payment->getCcOwner())
216
- ->setCardNumber($payment->getCcNumber())
217
- ->setExpirationYear($payment->getCcExpYear())
218
- ->setExpirationMonth($payment->getCcExpMonth())
219
- ->setCvv($payment->getCcCid())
220
- ->setCustomerEmail($order->getCustomerEmail())
221
- ->setCustomerPhone($billing->getTelephone())
222
- ->setBillingFirstName($billing->getData('firstname'))
223
- ->setBillingLastName($billing->getData('lastname'))
224
- ->setBillingAddress1($billing->getStreet(1))
225
- ->setBillingAddress2($billing->getStreet(2))
226
- ->setBillingZipCode($billing->getPostcode())
227
- ->setBillingCity($billing->getCity())
228
- ->setBillingState($billing->getRegion())
229
- ->setBillingCountry($billing->getCountry())
230
- ->setShippingFirstName($shipping->getData('firstname'))
231
- ->setShippingLastName($shipping->getData('lastname'))
232
- ->setShippingAddress1($shipping->getStreet(1))
233
- ->setShippingAddress2($shipping->getStreet(2))
234
- ->setShippingZipCode($shipping->getPostcode())
235
- ->setShippingCity($shipping->getCity())
236
- ->setShippingState($shipping->getRegion())
237
- ->setShippinCountry($shipping->getCountry());
238
-
239
- $genesis->execute();
240
-
241
- $this->setGenesisResponse(
242
- $genesis->response()->getResponseObject()
243
- );
244
-
245
- $payment
246
  ->setTransactionId(
247
- $this->getGenesisResponse()->unique_id
 
 
248
  )
249
- ->setIsTransactionClosed(
250
- false
251
  )
252
- ->setIsTransactionPending(
253
- false
254
  )
255
- ->setTransactionAdditionalInfo(
256
- array(
257
- Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS =>
258
- $this->getHelper()->getArrayFromGatewayResponse(
259
- $this->getGenesisResponse()
260
- )
261
- ),
262
- null
263
- );
264
-
265
- $payment->save();
266
-
267
- if ($this->getGenesisResponse()->status == \Genesis\API\Constants\Transaction\States::DECLINED) {
268
- throw new \Genesis\Exceptions\ErrorAPI(
269
- $this->getGenesisResponse()->message
 
 
 
 
 
 
 
 
 
 
 
270
  );
271
- }
272
- } catch (Exception $exception) {
273
- Mage::logException($exception);
274
-
275
- Mage::throwException(
276
- $this->getHelper()->__($exception->getMessage())
277
- );
278
- }
279
-
280
- return $this;
281
- }
282
-
283
- /**
284
- * Genesis Authorize Payment Method with 3D-Secure
285
- *
286
- * @param Varien_Object|Mage_Sales_Model_Order_Payment $payment
287
- * @param String $amount
288
- *
289
- * @return EMerchantPay_Genesis_Model_Direct
290
- */
291
- private function _authorize3d($payment, $amount)
292
- {
293
- Mage::log('Authorize 3D-Secure transaction for order #' . $payment->getOrder()->getIncrementId());
294
-
295
- try {
296
- $this->getHelper()->initClient($this->getCode());
297
-
298
- $order = $payment->getOrder();
299
-
300
- $billing = $order->getBillingAddress();
301
- $shipping = $order->getShippingAddress();
302
-
303
- $genesis = new \Genesis\Genesis('Financial\Cards\Authorize3D');
304
 
 
305
  $genesis
306
  ->request()
307
- ->setTransactionId($this->getHelper()->genTransactionId($order->getIncrementId()))
308
- ->setRemoteIp($this->getHelper()->getRemoteAddress())
309
- ->setUsage($this->getHelper()->getItemList($order))
310
- ->setCurrency(
311
- $order->getOrderCurrencyCode()
312
- )
313
- ->setAmount($amount)
314
- ->setCardHolder($payment->getCcOwner())
315
- ->setCardNumber($payment->getCcNumber())
316
- ->setExpirationYear($payment->getCcExpYear())
317
- ->setExpirationMonth($payment->getCcExpMonth())
318
- ->setCvv($payment->getCcCid())
319
- ->setCustomerEmail($order->getCustomerEmail())
320
- ->setCustomerPhone($billing->getTelephone())
321
- ->setBillingFirstName($billing->getData('firstname'))
322
- ->setBillingLastName($billing->getData('lastname'))
323
- ->setBillingAddress1($billing->getStreet(1))
324
- ->setBillingAddress2($billing->getStreet(2))
325
- ->setBillingZipCode($billing->getPostcode())
326
- ->setBillingCity($billing->getCity())
327
- ->setBillingState($billing->getRegion())
328
- ->setBillingCountry($billing->getCountry())
329
- ->setShippingFirstName($shipping->getData('firstname'))
330
- ->setShippingLastName($shipping->getData('lastname'))
331
- ->setShippingAddress1($shipping->getStreet(1))
332
- ->setShippingAddress2($shipping->getStreet(2))
333
- ->setShippingZipCode($shipping->getPostcode())
334
- ->setShippingCity($shipping->getCity())
335
- ->setShippingState($shipping->getRegion())
336
- ->setShippinCountry($shipping->getCountry())
337
- ->setNotificationUrl($this->getHelper()->getNotifyURL('direct'))
338
- ->setReturnSuccessUrl($this->getHelper()->getSuccessURL('direct'))
339
- ->setReturnFailureUrl($this->getHelper()->getFailureURL('direct'));
340
-
341
- $genesis->execute();
342
-
343
- $this->setGenesisResponse(
344
- $genesis->response()->getResponseObject()
345
- );
346
-
347
- $payment
348
- ->setTransactionId(
349
- $this->getGenesisResponse()->unique_id
350
  )
351
- ->setIsTransactionClosed(false)
352
- ->setIsTransactionPending(true)
353
- ->setPreparedMessage('3D-Secure: Redirecting customer to a verification page.')
354
- ->setTransactionAdditionalInfo(
355
- array(
356
- Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS =>
357
- $this->getHelper()->getArrayFromGatewayResponse(
358
- $this->getGenesisResponse()
359
- )
360
- ),
361
- null
362
- );
363
-
364
- $payment->save();
365
-
366
- if ($this->getGenesisResponse()->status == \Genesis\API\Constants\Transaction\States::DECLINED) {
367
- throw new \Genesis\Exceptions\ErrorAPI(
368
- $this->getGenesisResponse()->message
 
 
369
  );
370
- }
371
-
372
- // Save the redirect url with our
373
- $this->getHelper()->getCheckoutSession()->setEmerchantPayDirectRedirectUrl(
374
- $this->getGenesisResponse()->redirect_url
375
- );
376
- } catch (Exception $exception) {
377
- Mage::logException($exception);
378
-
379
- Mage::throwException(
380
- $this->getHelper()->__($exception->getMessage())
381
- );
382
- }
383
-
384
- return $this;
385
- }
386
-
387
- /**
388
- * Genesis Sale (Auth/Capture) Payment Method
389
- *
390
- * @param Varien_Object|Mage_Sales_Model_Order_Payment $payment
391
- * @param String $amount
392
- *
393
- * @return EMerchantPay_Genesis_Model_Direct
394
- */
395
- private function _sale($payment, $amount)
396
- {
397
- Mage::log('Sale transaction for order #' . $payment->getOrder()->getIncrementId());
398
-
399
- try {
400
- $this->getHelper()->initClient($this->getCode());
401
-
402
- $order = $payment->getOrder();
403
-
404
- $billing = $order->getBillingAddress();
405
- $shipping = $order->getShippingAddress();
406
-
407
- $genesis = new \Genesis\Genesis('Financial\Cards\Sale');
408
 
 
409
  $genesis
410
  ->request()
411
- ->setTransactionId($this->getHelper()->genTransactionId($order->getIncrementId()))
412
- ->setRemoteIp($this->getHelper()->getRemoteAddress())
413
- ->setUsage($this->getHelper()->getItemList($order))
414
- ->setCurrency(
415
- $order->getOrderCurrencyCode()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
416
  )
417
- ->setAmount($amount)
418
- ->setCardHolder($payment->getCcOwner())
419
- ->setCardNumber($payment->getCcNumber())
420
- ->setExpirationYear($payment->getCcExpYear())
421
- ->setExpirationMonth($payment->getCcExpMonth())
422
- ->setCvv($payment->getCcCid())
423
- ->setCustomerEmail($order->getCustomerEmail())
424
- ->setCustomerPhone($billing->getTelephone())
425
- ->setBillingFirstName($billing->getData('firstname'))
426
- ->setBillingLastName($billing->getData('lastname'))
427
- ->setBillingAddress1($billing->getStreet(1))
428
- ->setBillingAddress2($billing->getStreet(2))
429
- ->setBillingZipCode($billing->getPostcode())
430
- ->setBillingCity($billing->getCity())
431
- ->setBillingState($billing->getRegion())
432
- ->setBillingCountry($billing->getCountry())
433
- ->setShippingFirstName($shipping->getData('firstname'))
434
- ->setShippingLastName($shipping->getData('lastname'))
435
- ->setShippingAddress1($shipping->getStreet(1))
436
- ->setShippingAddress2($shipping->getStreet(2))
437
- ->setShippingZipCode($shipping->getPostcode())
438
- ->setShippingCity($shipping->getCity())
439
- ->setShippingState($shipping->getRegion())
440
- ->setShippinCountry($shipping->getCountry());
441
 
442
  $genesis->execute();
443
 
@@ -449,11 +399,12 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
449
  ->setTransactionId(
450
  $this->getGenesisResponse()->unique_id
451
  )
452
- ->setCurrencyCode(
453
- $this->getGenesisResponse()->currency
 
 
 
454
  )
455
- ->setIsTransactionClosed(false)
456
- ->setIsTransactionPending(false)
457
  ->setTransactionAdditionalInfo(
458
  array(
459
  Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS =>
@@ -464,120 +415,28 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
464
  null
465
  );
466
 
467
- $payment->save();
468
-
469
- if ($this->getGenesisResponse()->status == \Genesis\API\Constants\Transaction\States::DECLINED) {
470
- throw new \Genesis\Exceptions\ErrorAPI(
471
- $this->getGenesisResponse()->message
472
  );
473
  }
474
- } catch (Exception $exception) {
475
- Mage::logException($exception);
476
 
477
- Mage::throwException(
478
- $exception->getMessage()
479
- );
480
- }
481
-
482
- return $this;
483
- }
484
-
485
- /**
486
- * Genesis Sale (Auth/Capture) Payment Method with 3D-Secure
487
- *
488
- * @param Varien_Object|Mage_Sales_Model_Order_Payment $payment
489
- * @param String $amount
490
- *
491
- * @return EMerchantPay_Genesis_Model_Direct
492
- */
493
- private function _sale3d($payment, $amount)
494
- {
495
- Mage::log('Sale 3D-Secure transaction for order #' . $payment->getOrder()->getIncrementId());
496
-
497
- try {
498
- $this->getHelper()->initClient($this->getCode());
499
-
500
- $order = $payment->getOrder();
501
-
502
- $billing = $order->getBillingAddress();
503
- $shipping = $order->getShippingAddress();
504
-
505
- $genesis = new \Genesis\Genesis('Financial\Cards\Sale3D');
506
-
507
- $genesis
508
- ->request()
509
- ->setTransactionId($this->getHelper()->genTransactionId($order->getIncrementId()))
510
- ->setRemoteIp($this->getHelper()->getRemoteAddress())
511
- ->setUsage($this->getHelper()->getItemList($order))
512
- ->setCurrency(
513
- $order->getOrderCurrencyCode()
514
- )
515
- ->setAmount($amount)
516
- ->setCardHolder($payment->getCcOwner())
517
- ->setCardNumber($payment->getCcNumber())
518
- ->setExpirationYear($payment->getCcExpYear())
519
- ->setExpirationMonth($payment->getCcExpMonth())
520
- ->setCvv($payment->getCcCid())
521
- ->setCustomerEmail($order->getCustomerEmail())
522
- ->setCustomerPhone($billing->getTelephone())
523
- ->setBillingFirstName($billing->getData('firstname'))
524
- ->setBillingLastName($billing->getData('lastname'))
525
- ->setBillingAddress1($billing->getStreet(1))
526
- ->setBillingAddress2($billing->getStreet(2))
527
- ->setBillingZipCode($billing->getPostcode())
528
- ->setBillingCity($billing->getCity())
529
- ->setBillingState($billing->getRegion())
530
- ->setBillingCountry($billing->getCountry())
531
- ->setShippingFirstName($shipping->getData('firstname'))
532
- ->setShippingLastName($shipping->getData('lastname'))
533
- ->setShippingAddress1($shipping->getStreet(1))
534
- ->setShippingAddress2($shipping->getStreet(2))
535
- ->setShippingZipCode($shipping->getPostcode())
536
- ->setShippingCity($shipping->getCity())
537
- ->setShippingState($shipping->getRegion())
538
- ->setShippinCountry($shipping->getCountry())
539
- ->setNotificationUrl($this->getHelper()->getNotifyURL('direct'))
540
- ->setReturnSuccessUrl($this->getHelper()->getSuccessURL('direct'))
541
- ->setReturnFailureUrl($this->getHelper()->getFailureURL('direct'));
542
-
543
- $genesis->execute();
544
 
545
- $this->setGenesisResponse(
546
- $genesis->response()->getResponseObject()
547
  );
548
 
549
- // Hold transaction creation
550
- $payment
551
- ->setTransactionId(
552
- $this->getGenesisResponse()->unique_id
553
- )
554
- ->setIsTransactionClosed(false)
555
- ->setIsTransactionPending(true)
556
- ->setPreparedMessage(
557
- $this->getHelper()->__('3D-Secure: Redirecting customer to a verification page.')
558
- )
559
- ->setTransactionAdditionalInfo(
560
- array(
561
- Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS =>
562
- $this->getHelper()->getArrayFromGatewayResponse(
563
- $this->getGenesisResponse()
564
- )
565
- ),
566
- null
567
  );
568
-
569
- $payment->save();
570
-
571
- if ($this->getGenesisResponse()->status == \Genesis\API\Constants\Transaction\States::DECLINED) {
572
  throw new \Genesis\Exceptions\ErrorAPI(
573
  $this->getGenesisResponse()->message
574
  );
575
  }
576
-
577
- // Save the redirect url with our
578
- $this->getHelper()->getCheckoutSession()->setEmerchantPayDirectRedirectUrl(
579
- $this->getGenesisResponse()->redirect_url
580
- );
581
  } catch (Exception $exception) {
582
  Mage::logException($exception);
583
 
@@ -599,7 +458,7 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
599
  *
600
  * @throws Mage_Core_Exception
601
  */
602
- private function _capture($payment, $amount)
603
  {
604
  Mage::log('Capture transaction for order #' . $payment->getOrder()->getIncrementId());
605
 
@@ -608,7 +467,7 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
608
 
609
  $authorize = $payment->lookupTransaction(null, Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
610
 
611
- $reference_id = $authorize->getTxnId();
612
 
613
  $genesis = new \Genesis\Genesis('Financial\Capture');
614
 
@@ -623,7 +482,7 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
623
  $this->getHelper()->getRemoteAddress()
624
  )
625
  ->setReferenceId(
626
- $reference_id
627
  )
628
  ->setCurrency(
629
  $payment->getOrder()->getOrderCurrencyCode()
@@ -638,10 +497,12 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
638
 
639
  $payment
640
  ->setTransactionId(
 
641
  $responseObject->unique_id
 
642
  )
643
  ->setParentTransactionId(
644
- $reference_id
645
  )
646
  ->setIsTransactionClosed(
647
  false
@@ -701,7 +562,7 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
701
 
702
  $capture = $payment->lookupTransaction(null, Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
703
 
704
- $reference_id = $capture->getTxnId();
705
 
706
  $genesis = new \Genesis\Genesis('Financial\Refund');
707
 
@@ -716,7 +577,7 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
716
  $this->getHelper()->getRemoteAddress()
717
  )
718
  ->setReferenceId(
719
- $reference_id
720
  )
721
  ->setCurrency(
722
  $payment->getOrder()->getOrderCurrencyCode()
@@ -729,10 +590,12 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
729
 
730
  $payment
731
  ->setTransactionId(
 
732
  $responseObject->unique_id
 
733
  )
734
  ->setParentTransactionId(
735
- $reference_id
736
  )
737
  ->setShouldCloseParentTransaction(
738
  true
@@ -800,12 +663,15 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
800
  try {
801
  $this->getHelper()->initClient($this->getCode());
802
 
803
- $transactions = $this->getHelper()->getTransactionFromPaymentObject($payment, array(
804
- Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH,
805
- Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE
806
- ));
 
 
 
807
 
808
- $reference_id = $transactions ? reset($transactions)->getTxnId() : null;
809
 
810
  $genesis = new \Genesis\Genesis('Financial\Void');
811
 
@@ -818,7 +684,7 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
818
  $this->getHelper()->getRemoteAddress()
819
  )
820
  ->setReferenceId(
821
- $reference_id
822
  );
823
 
824
  $genesis->execute();
@@ -827,10 +693,12 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
827
 
828
  $payment
829
  ->setTransactionId(
 
830
  $responseObject->unique_id
 
831
  )
832
  ->setParentTransactionId(
833
- $reference_id
834
  )
835
  ->setShouldCloseParentTransaction(
836
  true
@@ -919,17 +787,17 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
919
  *
920
  * @see EMerchantPay_Genesis_DirectController::notifyAction
921
  *
922
- * @param $unique_id
923
  * @return mixed
924
  */
925
- public function reconcile($unique_id)
926
  {
927
  try {
928
  $this->getHelper()->initClient($this->getCode());
929
 
930
  $genesis = new \Genesis\Genesis('NonFinancial\Reconcile\Transaction');
931
 
932
- $genesis->request()->setUniqueId($unique_id);
933
 
934
  $genesis->execute();
935
 
@@ -949,16 +817,20 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
949
  * Handle an incoming Genesis notification
950
  *
951
  * @param stdClass $reconcile
952
- * @return bool
953
  */
 
954
  public function processNotification($reconcile)
955
  {
 
956
  try {
957
  $this->getHelper()->initClient($this->getCode());
958
 
959
  /** @var Mage_Sales_Model_Order_Payment_Transaction $transaction */
960
  $transaction = Mage::getModel('sales/order_payment_transaction')->load(
 
961
  $reconcile->unique_id,
 
962
  'txn_id'
963
  );
964
 
@@ -987,7 +859,9 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
987
 
988
  $transaction->save();
989
 
 
990
  switch ($reconcile->transaction_type) {
 
991
  case \Genesis\API\Constants\Transaction\Types::AUTHORIZE:
992
  case \Genesis\API\Constants\Transaction\Types::AUTHORIZE_3D:
993
  $payment->registerAuthorizationNotification($reconcile->amount);
@@ -997,15 +871,25 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
997
  case \Genesis\API\Constants\Transaction\Types::INIT_RECURRING_SALE:
998
  case \Genesis\API\Constants\Transaction\Types::INIT_RECURRING_SALE_3D:
999
  $payment->setShouldCloseParentTransaction(true);
 
 
 
 
 
 
1000
  $payment->registerCaptureNotification($reconcile->amount);
1001
  break;
1002
  default:
1003
  break;
1004
  }
1005
 
 
1006
  if ($this->getHelper()->getIsTransactionTypeInitRecurring($reconcile->transaction_type)) {
 
1007
  $recurringProfile = Mage::getModel('sales/recurring_profile')->load(
 
1008
  $reconcile->unique_id,
 
1009
  'reference_id'
1010
  );
1011
 
@@ -1048,27 +932,13 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
1048
  */
1049
  public function getOrderPlaceRedirectUrl()
1050
  {
1051
- if ($this->is3dEnabled()) {
1052
  return $this->getHelper()->getRedirectUrl('direct');
1053
  }
1054
 
1055
  return false;
1056
  }
1057
 
1058
- /**
1059
- * Check whether we're doing 3D transactions,
1060
- * based on the module configuration
1061
- *
1062
- * @return bool
1063
- */
1064
- private function is3dEnabled()
1065
- {
1066
- return
1067
- $this->getHelper()->getIsTransaction3dSecure(
1068
- $this->getConfigData('genesis_type')
1069
- );
1070
- }
1071
-
1072
  /**
1073
  * Get the helper or return its instance
1074
  *
@@ -1076,9 +946,9 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
1076
  *
1077
  * @return EMerchantPay_Genesis_Helper_Data|mixed
1078
  */
1079
- private function getHelper($helper = '')
1080
  {
1081
- if (empty($helper)) {
1082
  return Mage::helper('emerchantpay');
1083
  } else {
1084
  return Mage::helper($helper);
@@ -1109,11 +979,14 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
1109
  * @param Mage_Payment_Model_Recurring_Profile $profile
1110
  * @param Mage_Payment_Model_Info $payment
1111
  * @return $this
 
1112
  */
 
1113
  public function submitRecurringProfile(
1114
  Mage_Payment_Model_Recurring_Profile $profile,
1115
  Mage_Payment_Model_Info $payment
1116
  ) {
 
1117
  $logFileName = $this->getConfigData('cron_recurring_log_file');
1118
  $isLogEnabled = !empty($logFileName);
1119
 
@@ -1124,11 +997,12 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
1124
  $this->getHelper()->initClient($this->getCode());
1125
 
1126
  $transactionType = $this->getConfigData('recurring_transaction_type');
1127
- $transactionClassName = $this->getHelper()->getGenesisTransactionClassName(
1128
- $transactionType
1129
- );
1130
 
1131
- $genesis = new \Genesis\Genesis("Financial\\Cards\\Recurring\\{$transactionClassName}");
 
 
 
 
1132
 
1133
  $amount = $profile->getInitAmount() ?: 0;
1134
 
@@ -1237,16 +1111,20 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
1237
 
1238
  $responseObject = $genesis->response()->getResponseObject();
1239
 
 
1240
  if (isset($responseObject->redirect_url)) {
1241
- $this->getHelper()
1242
- ->getCheckoutSession()
1243
- ->setEmerchantPayCheckoutRedirectUrl(
1244
- $responseObject->redirect_url
1245
- );
 
1246
  }
1247
 
1248
  $profile->setReferenceId(
 
1249
  $responseObject->unique_id
 
1250
  );
1251
 
1252
  $payment->setSkipTransactionCreation(true);
@@ -1284,7 +1162,9 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
1284
 
1285
  $payment
1286
  ->setTransactionId(
 
1287
  $responseObject->unique_id
 
1288
  );
1289
  $payment
1290
  ->setIsTransactionPending(
@@ -1347,6 +1227,8 @@ class EMerchantPay_Genesis_Model_Direct extends Mage_Payment_Model_Method_Cc imp
1347
  $e->getMessage()
1348
  );
1349
  }
 
 
1350
  }
1351
 
1352
  /**
29
  *
30
  * @category
31
  */
32
+ class EMerchantPay_Genesis_Model_Direct
33
+ extends Mage_Payment_Model_Method_Cc implements Mage_Payment_Model_Recurring_Profile_MethodInterface
34
  {
35
  // Variables
36
  protected $_code = 'emerchantpay_direct';
117
  return $this;
118
  }
119
 
120
+ /**
121
+ * Retrieve information from payment configuration
122
+ *
123
+ * @param string $field
124
+ * @param int|string|null|Mage_Core_Model_Store $storeId
125
+ *
126
+ * @return mixed
127
+ */
128
+ public function getConfigData($field, $storeId = null)
129
+ {
130
+ if (($field == 'order_status') && (!$this->getIsThreeDEnabled())) {
131
+ //This will force Mage_Sales_Model_Order_Payment to load the default status for State
132
+ //Look into: Mage_Sales_Model_Order_Payment->place()
133
+ return null;
134
+ } else {
135
+ return parent::getConfigData($field, $storeId);
136
+ }
137
+ }
138
+
139
+ /**
140
+ * Retrieves the Module Transaction Type Setting
141
+ *
142
+ * @return string
143
+ */
144
+ protected function getConfigTransactionType()
145
+ {
146
+ return $this->getConfigData('genesis_type');
147
+ }
148
+
149
+ /**
150
+ * Check whether we're doing 3D transactions,
151
+ * based on the module configuration
152
+ *
153
+ * @return bool
154
+ */
155
+ protected function getIsThreeDEnabled()
156
+ {
157
+ return
158
+ $this->getHelper()->getIsTransaction3dSecure(
159
+ $this->getConfigTransactionType()
160
+ );
161
+ }
162
+
163
+ /**
164
+ * Builds full Request Class Name by Transaction Type
165
+ * @param string $transactionType
166
+ * @return string
167
+ */
168
+ protected function getTransactionTypeRequestClassName($transactionType)
169
+ {
170
+ $requestClassName = \Genesis\Utils\Common::snakeCaseToCamelCase(
171
+ str_replace('3d', '3D', $transactionType)
172
+ );
173
+
174
+ $recurringInnerNamespace =
175
+ strpos($transactionType, 'recurring') !== false
176
+ ? "Recurring\\"
177
+ : '';
178
+ return "Financial\\Cards\\{$recurringInnerNamespace}{$requestClassName}";
179
+ }
180
+
181
  /**
182
  * Payment action getter compatible with payment model
183
  *
189
  {
190
  $this->getHelper()->initLibrary();
191
 
192
+ switch ($this->getConfigTransactionType()) {
193
  default:
194
  case \Genesis\API\Constants\Transaction\Types::AUTHORIZE:
195
  case \Genesis\API\Constants\Transaction\Types::AUTHORIZE_3D:
196
  return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE;
197
+
198
  case \Genesis\API\Constants\Transaction\Types::SALE:
199
  case \Genesis\API\Constants\Transaction\Types::SALE_3D:
200
  return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE;
 
201
  }
202
  }
203
 
211
  */
212
  public function authorize(Varien_Object $payment, $amount)
213
  {
214
+ if ($this->getIsThreeDEnabled()) {
215
+ Mage::log('Authorize 3D-Secure transaction for order #' . $payment->getOrder()->getIncrementId());
216
  } else {
217
+ Mage::log('Authorize transaction for order #' . $payment->getOrder()->getIncrementId());
218
  }
219
+
220
+ return $this->processTransaction($payment, $amount);
221
  }
222
 
223
  /**
233
  $authorize = $payment->lookupTransaction(null, Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
234
 
235
  if ($authorize) {
236
+ return $this->doCapture($payment, $amount);
237
  } else {
238
+ if ($this->getIsThreeDEnabled()) {
239
+ Mage::log('Sale 3D-Secure transaction for order #' . $payment->getOrder()->getIncrementId());
240
  } else {
241
+ Mage::log('Sale transaction for order #' . $payment->getOrder()->getIncrementId());
242
  }
243
+
244
+ return $this->processTransaction($payment, $amount);
245
  }
246
  }
247
 
248
  /**
249
+ * Sends a transaction to the Gateway
250
+ * - Authorize
251
+ * - Authorize (3D Secure)
252
+ * - Sale
253
+ * - Sale (3D Secure)
254
  *
255
  * @param Varien_Object|Mage_Sales_Model_Order_Payment $payment
256
+ * @param float $amount
257
  *
258
  * @return EMerchantPay_Genesis_Model_Direct
259
  */
260
+ protected function processTransaction(Varien_Object $payment, $amount)
261
  {
 
 
262
  try {
263
  $this->getHelper()->initClient($this->getCode());
264
 
265
+ $transactionType = $this->getConfigTransactionType();
266
+
267
+ $isThreeDEnabled = $this->getIsThreeDEnabled();
268
+
269
  /** @var Mage_Sales_Model_Order $order */
270
  $order = $payment->getOrder();
271
 
272
+ $billing = $order->getBillingAddress();
273
  $shipping = $order->getShippingAddress();
274
 
275
+ $genesis = new \Genesis\Genesis(
276
+ $this->getTransactionTypeRequestClassName(
277
+ $transactionType
278
+ )
279
+ );
280
 
281
  $genesis
282
  ->request()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  ->setTransactionId(
284
+ $this->getHelper()->genTransactionId(
285
+ $order->getIncrementId()
286
+ )
287
  )
288
+ ->setRemoteIp(
289
+ $this->getHelper()->getRemoteAddress()
290
  )
291
+ ->setUsage(
292
+ $this->getHelper()->getItemList($order)
293
  )
294
+ ->setCurrency(
295
+ $order->getOrderCurrencyCode()
296
+ )
297
+ ->setAmount(
298
+ $amount
299
+ )
300
+ ->setCardHolder(
301
+ $payment->getCcOwner()
302
+ )
303
+ ->setCardNumber(
304
+ $payment->getCcNumber()
305
+ )
306
+ ->setExpirationYear(
307
+ $payment->getCcExpYear()
308
+ )
309
+ ->setExpirationMonth(
310
+ $payment->getCcExpMonth()
311
+ )
312
+ ->setCvv(
313
+ $payment->getCcCid()
314
+ )
315
+ ->setCustomerEmail(
316
+ $order->getCustomerEmail()
317
+ )
318
+ ->setCustomerPhone(
319
+ $billing->getTelephone()
320
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
 
322
+ //Billing Information
323
  $genesis
324
  ->request()
325
+ ->setBillingFirstName(
326
+ $billing->getData('firstname')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
327
  )
328
+ ->setBillingLastName(
329
+ $billing->getData('lastname')
330
+ )
331
+ ->setBillingAddress1(
332
+ $billing->getStreet(1)
333
+ )
334
+ ->setBillingAddress2(
335
+ $billing->getStreet(2)
336
+ )
337
+ ->setBillingZipCode(
338
+ $billing->getPostcode()
339
+ )
340
+ ->setBillingCity(
341
+ $billing->getCity()
342
+ )
343
+ ->setBillingState(
344
+ $billing->getRegion()
345
+ )
346
+ ->setBillingCountry(
347
+ $billing->getCountry()
348
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
349
 
350
+ //Shipping Information
351
  $genesis
352
  ->request()
353
+ ->setShippingFirstName(
354
+ $shipping->getData('firstname')
355
+ )
356
+ ->setShippingLastName(
357
+ $shipping->getData('lastname')
358
+ )
359
+ ->setShippingAddress1(
360
+ $shipping->getStreet(1)
361
+ )
362
+ ->setShippingAddress2(
363
+ $shipping->getStreet(2)
364
+ )
365
+ ->setShippingZipCode(
366
+ $shipping->getPostcode()
367
+ )
368
+ ->setShippingCity(
369
+ $shipping->getCity()
370
+ )
371
+ ->setShippingState(
372
+ $shipping->getRegion()
373
+ )
374
+ ->setShippingCountry(
375
+ $shipping->getCountry()
376
+ );
377
+
378
+ if ($isThreeDEnabled) {
379
+ $genesis
380
+ ->request()
381
+ ->setNotificationUrl(
382
+ $this->getHelper()->getNotifyURL('direct')
383
  )
384
+ ->setReturnSuccessUrl(
385
+ $this->getHelper()->getSuccessURL('direct')
386
+ )
387
+ ->setReturnFailureUrl(
388
+ $this->getHelper()->getFailureURL('direct')
389
+ );
390
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
391
 
392
  $genesis->execute();
393
 
399
  ->setTransactionId(
400
  $this->getGenesisResponse()->unique_id
401
  )
402
+ ->setIsTransactionClosed(
403
+ false
404
+ )
405
+ ->setIsTransactionPending(
406
+ $isThreeDEnabled
407
  )
 
 
408
  ->setTransactionAdditionalInfo(
409
  array(
410
  Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS =>
415
  null
416
  );
417
 
418
+ if ($isThreeDEnabled) {
419
+ $payment->setPreparedMessage(
420
+ $this->getHelper()->__('3D-Secure: Redirecting customer to a verification page.')
 
 
421
  );
422
  }
 
 
423
 
424
+ $payment->save();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
425
 
426
+ $gatewayStatus = new \Genesis\API\Constants\Transaction\States(
427
+ $this->getGenesisResponse()->status
428
  );
429
 
430
+ if ($gatewayStatus->isPendingAsync()) {
431
+ // Save the redirect url with our
432
+ $this->getHelper()->getCheckoutSession()->setEmerchantPayDirectRedirectUrl(
433
+ $this->getGenesisResponse()->redirect_url
 
 
 
 
 
 
 
 
 
 
 
 
 
 
434
  );
435
+ } elseif (!$gatewayStatus->isApproved()) {
 
 
 
436
  throw new \Genesis\Exceptions\ErrorAPI(
437
  $this->getGenesisResponse()->message
438
  );
439
  }
 
 
 
 
 
440
  } catch (Exception $exception) {
441
  Mage::logException($exception);
442
 
458
  *
459
  * @throws Mage_Core_Exception
460
  */
461
+ protected function doCapture($payment, $amount)
462
  {
463
  Mage::log('Capture transaction for order #' . $payment->getOrder()->getIncrementId());
464
 
467
 
468
  $authorize = $payment->lookupTransaction(null, Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
469
 
470
+ $referenceId = $authorize->getTxnId();
471
 
472
  $genesis = new \Genesis\Genesis('Financial\Capture');
473
 
482
  $this->getHelper()->getRemoteAddress()
483
  )
484
  ->setReferenceId(
485
+ $referenceId
486
  )
487
  ->setCurrency(
488
  $payment->getOrder()->getOrderCurrencyCode()
497
 
498
  $payment
499
  ->setTransactionId(
500
+ // @codingStandardsIgnoreStart
501
  $responseObject->unique_id
502
+ // @codingStandardsIgnoreEnd
503
  )
504
  ->setParentTransactionId(
505
+ $referenceId
506
  )
507
  ->setIsTransactionClosed(
508
  false
562
 
563
  $capture = $payment->lookupTransaction(null, Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
564
 
565
+ $referenceId = $capture->getTxnId();
566
 
567
  $genesis = new \Genesis\Genesis('Financial\Refund');
568
 
577
  $this->getHelper()->getRemoteAddress()
578
  )
579
  ->setReferenceId(
580
+ $referenceId
581
  )
582
  ->setCurrency(
583
  $payment->getOrder()->getOrderCurrencyCode()
590
 
591
  $payment
592
  ->setTransactionId(
593
+ // @codingStandardsIgnoreStart
594
  $responseObject->unique_id
595
+ // @codingStandardsIgnoreEnd
596
  )
597
  ->setParentTransactionId(
598
+ $referenceId
599
  )
600
  ->setShouldCloseParentTransaction(
601
  true
663
  try {
664
  $this->getHelper()->initClient($this->getCode());
665
 
666
+ $transactions = $this->getHelper()->getTransactionFromPaymentObject(
667
+ $payment,
668
+ array(
669
+ Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH,
670
+ Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE
671
+ )
672
+ );
673
 
674
+ $referenceId = $transactions ? reset($transactions)->getTxnId() : null;
675
 
676
  $genesis = new \Genesis\Genesis('Financial\Void');
677
 
684
  $this->getHelper()->getRemoteAddress()
685
  )
686
  ->setReferenceId(
687
+ $referenceId
688
  );
689
 
690
  $genesis->execute();
693
 
694
  $payment
695
  ->setTransactionId(
696
+ // @codingStandardsIgnoreStart
697
  $responseObject->unique_id
698
+ // @codingStandardsIgnoreEnd
699
  )
700
  ->setParentTransactionId(
701
+ $referenceId
702
  )
703
  ->setShouldCloseParentTransaction(
704
  true
787
  *
788
  * @see EMerchantPay_Genesis_DirectController::notifyAction
789
  *
790
+ * @param $uniqueId
791
  * @return mixed
792
  */
793
+ public function reconcile($uniqueId)
794
  {
795
  try {
796
  $this->getHelper()->initClient($this->getCode());
797
 
798
  $genesis = new \Genesis\Genesis('NonFinancial\Reconcile\Transaction');
799
 
800
+ $genesis->request()->setUniqueId($uniqueId);
801
 
802
  $genesis->execute();
803
 
817
  * Handle an incoming Genesis notification
818
  *
819
  * @param stdClass $reconcile
820
+ * @return $this
821
  */
822
+ // @codingStandardsIgnoreStart
823
  public function processNotification($reconcile)
824
  {
825
+ // @codingStandardsIgnoreEnd
826
  try {
827
  $this->getHelper()->initClient($this->getCode());
828
 
829
  /** @var Mage_Sales_Model_Order_Payment_Transaction $transaction */
830
  $transaction = Mage::getModel('sales/order_payment_transaction')->load(
831
+ // @codingStandardsIgnoreStart
832
  $reconcile->unique_id,
833
+ // @codingStandardsIgnoreEnd
834
  'txn_id'
835
  );
836
 
859
 
860
  $transaction->save();
861
 
862
+ // @codingStandardsIgnoreStart
863
  switch ($reconcile->transaction_type) {
864
+ // @codingStandardsIgnoreEnd
865
  case \Genesis\API\Constants\Transaction\Types::AUTHORIZE:
866
  case \Genesis\API\Constants\Transaction\Types::AUTHORIZE_3D:
867
  $payment->registerAuthorizationNotification($reconcile->amount);
871
  case \Genesis\API\Constants\Transaction\Types::INIT_RECURRING_SALE:
872
  case \Genesis\API\Constants\Transaction\Types::INIT_RECURRING_SALE_3D:
873
  $payment->setShouldCloseParentTransaction(true);
874
+ $payment->setTransactionId(
875
+ // @codingStandardsIgnoreStart
876
+ $reconcile->unique_id
877
+ // @codingStandardsIgnoreEnd
878
+ );
879
+
880
  $payment->registerCaptureNotification($reconcile->amount);
881
  break;
882
  default:
883
  break;
884
  }
885
 
886
+ // @codingStandardsIgnoreStart
887
  if ($this->getHelper()->getIsTransactionTypeInitRecurring($reconcile->transaction_type)) {
888
+ // @codingStandardsIgnoreEnd
889
  $recurringProfile = Mage::getModel('sales/recurring_profile')->load(
890
+ // @codingStandardsIgnoreStart
891
  $reconcile->unique_id,
892
+ // @codingStandardsIgnoreEnd
893
  'reference_id'
894
  );
895
 
932
  */
933
  public function getOrderPlaceRedirectUrl()
934
  {
935
+ if ($this->getIsThreeDEnabled()) {
936
  return $this->getHelper()->getRedirectUrl('direct');
937
  }
938
 
939
  return false;
940
  }
941
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
942
  /**
943
  * Get the helper or return its instance
944
  *
946
  *
947
  * @return EMerchantPay_Genesis_Helper_Data|mixed
948
  */
949
+ protected function getHelper($helper = '')
950
  {
951
+ if (!$helper) {
952
  return Mage::helper('emerchantpay');
953
  } else {
954
  return Mage::helper($helper);
979
  * @param Mage_Payment_Model_Recurring_Profile $profile
980
  * @param Mage_Payment_Model_Info $payment
981
  * @return $this
982
+ * @throws Mage_Core_Exception
983
  */
984
+ // @codingStandardsIgnoreStart
985
  public function submitRecurringProfile(
986
  Mage_Payment_Model_Recurring_Profile $profile,
987
  Mage_Payment_Model_Info $payment
988
  ) {
989
+ // @codingStandardsIgnoreEnd
990
  $logFileName = $this->getConfigData('cron_recurring_log_file');
991
  $isLogEnabled = !empty($logFileName);
992
 
997
  $this->getHelper()->initClient($this->getCode());
998
 
999
  $transactionType = $this->getConfigData('recurring_transaction_type');
 
 
 
1000
 
1001
+ $genesis = new \Genesis\Genesis(
1002
+ $this->getTransactionTypeRequestClassName(
1003
+ $transactionType
1004
+ )
1005
+ );
1006
 
1007
  $amount = $profile->getInitAmount() ?: 0;
1008
 
1111
 
1112
  $responseObject = $genesis->response()->getResponseObject();
1113
 
1114
+ // @codingStandardsIgnoreStart
1115
  if (isset($responseObject->redirect_url)) {
1116
+ // @codingStandardsIgnoreEnd
1117
+ $this->getHelper()->getCheckoutSession()->setEmerchantPayCheckoutRedirectUrl(
1118
+ // @codingStandardsIgnoreStart
1119
+ $responseObject->redirect_url
1120
+ // @codingStandardsIgnoreEnd
1121
+ );
1122
  }
1123
 
1124
  $profile->setReferenceId(
1125
+ // @codingStandardsIgnoreStart
1126
  $responseObject->unique_id
1127
+ // @codingStandardsIgnoreEnd
1128
  );
1129
 
1130
  $payment->setSkipTransactionCreation(true);
1162
 
1163
  $payment
1164
  ->setTransactionId(
1165
+ // @codingStandardsIgnoreStart
1166
  $responseObject->unique_id
1167
+ // @codingStandardsIgnoreEnd
1168
  );
1169
  $payment
1170
  ->setIsTransactionPending(
1227
  $e->getMessage()
1228
  );
1229
  }
1230
+
1231
+ return $this;
1232
  }
1233
 
1234
  /**
app/code/community/EMerchantPay/Genesis/Model/Task/Recurring.php CHANGED
@@ -41,7 +41,7 @@ class EMerchantPay_Genesis_Model_Task_Recurring
41
  /**
42
  * Cron job Observer Method for Direct PM
43
  * @param Mage_Cron_Model_Schedule $schedule
44
- * @return array
45
  */
46
  public function processDirect(Mage_Cron_Model_Schedule $schedule)
47
  {
@@ -53,10 +53,12 @@ class EMerchantPay_Genesis_Model_Task_Recurring
53
  *
54
  * @param Mage_Cron_Model_Schedule $schedule
55
  * @param string $methodCode
56
- * @return array
57
  */
 
58
  protected function run(Mage_Cron_Model_Schedule $schedule, $methodCode)
59
  {
 
60
  $result = array();
61
 
62
  $vendorName = "emerchantpay";
@@ -89,6 +91,7 @@ class EMerchantPay_Genesis_Model_Task_Recurring
89
  $resource = Mage::getSingleton('core/resource');
90
  $adapter = $resource->getConnection('read');
91
 
 
92
  $select = $adapter->select();
93
  $select
94
  ->from(
@@ -107,7 +110,9 @@ class EMerchantPay_Genesis_Model_Task_Recurring
107
  WHEN "semi_month" THEN DATE_ADD(updated_at, INTERVAL (period_frequency * 2) WEEK)
108
  WHEN "month" THEN DATE_ADD(updated_at, INTERVAL period_frequency MONTH)
109
  WHEN "year" THEN DATE_ADD(updated_at, INTERVAL period_frequency YEAR)
110
- END))');
 
 
111
 
112
  $binds = array(
113
  'method_code' =>
@@ -115,82 +120,102 @@ class EMerchantPay_Genesis_Model_Task_Recurring
115
  'state' =>
116
  Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE,
117
  'now' =>
118
- $this->getHelper()->formatDateTimeToMySQLDateTime(
119
- time()
120
- )
121
  );
122
 
123
  $chargedProfiles = 0;
124
 
 
125
  foreach ($adapter->fetchAll($select, $binds) as $profileArr) {
 
126
  if (!isset($profileArr['profile_id'])) {
127
  continue;
128
  }
129
 
130
- $profile = Mage::getModel('sales/recurring_profile')->load(
131
- $profileArr['profile_id']
132
- );
133
-
134
- $orders = $profile->getResource()->getChildOrderIds($profile);
135
- $countBillingCycles = count($orders);
136
 
137
- if ($profile->getInitAmount()) {
138
- $countBillingCycles--;
139
  }
 
140
 
141
- $msgChargingProfile =
142
- $this->getHelper()->__("Charging Recurring Profile #") .
143
- $profile->getReferenceId();
144
 
145
- $result[] = $msgChargingProfile;
 
146
 
147
- if ($isLogEnabled) {
148
- Mage::log($msgChargingProfile, null, $logFileName);
149
- }
 
 
 
 
 
 
 
 
 
 
150
 
151
- $mustSetUpdateDateToNextPeriod = (bool) $countBillingCycles > 0;
152
- try {
153
- $this->chargeRecurringProfile($methodCode, $profile, $mustSetUpdateDateToNextPeriod);
154
- $chargedProfiles++;
155
- $countBillingCycles++;
156
 
157
- if ($this->doCheckAndSuspendRecurringProfile($profile, $countBillingCycles)) {
158
- $msgChargingProfile =
159
- $this->getHelper()->__("Billing Cycles reached. Suspending Recurring Profile #") .
160
- $profile->getReferenceId();
161
 
162
- $result[] = $msgChargingProfile;
 
 
163
 
164
- if ($isLogEnabled) {
165
- Mage::log($msgChargingProfile, null, $logFileName);
166
- }
167
- }
168
- } catch (\Exception $e) {
169
- $profile->setState(
170
- Mage_Sales_Model_Recurring_Profile::STATE_SUSPENDED
171
- );
172
- $profile->save();
173
 
174
- $msgProfileSuspended = $this->getHelper()->__(
175
- sprintf(
176
- "Recurring Profile #%s is set to suspended, because of a failed Recurring Transaction",
177
- $profile->getReferenceId()
178
- )
179
- );
180
 
181
- $result[] = $msgProfileSuspended;
 
 
 
 
 
 
 
 
 
 
182
 
183
  if ($isLogEnabled) {
184
- Mage::log($msgProfileSuspended, null, $logFileName);
185
  }
186
  }
187
- }
188
 
189
- if ($chargedProfiles == 0) {
190
- $result[] = $this->getHelper()->__("No Profiles have been charged!");
191
- }
 
 
 
192
 
193
- return $result;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  }
195
 
196
  /**
@@ -201,7 +226,7 @@ class EMerchantPay_Genesis_Model_Task_Recurring
201
  */
202
  protected function doCheckAndSuspendRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile, $billingCycles)
203
  {
204
- if (!empty($profile->getPeriodMaxCycles()) && $billingCycles >= $profile->getPeriodMaxCycles()) {
205
  $profile->setState(
206
  Mage_Sales_Model_Recurring_Profile::STATE_SUSPENDED
207
  );
@@ -232,7 +257,8 @@ class EMerchantPay_Genesis_Model_Task_Recurring
232
  $methodCode,
233
  Mage_Payment_Model_Recurring_Profile $profile,
234
  $mustSetUpdateDateToNextPeriod
235
- ) {
 
236
  $logFileName = $this->getHelper()->getConfigData(
237
  $methodCode,
238
  'cron_recurring_log_file'
@@ -257,10 +283,10 @@ class EMerchantPay_Genesis_Model_Task_Recurring
257
 
258
  $recurringToken = $this->getHelper()->getRecurringSaleToken($methodCode);
259
 
260
- if (!empty($recurringToken)) {
261
  \Genesis\Config::setToken($recurringToken);
262
  } else {
263
- if (empty(\Genesis\Config::getToken())) {
264
  \Genesis\Config::setToken(
265
  $this->getHelper()->getGenesisPaymentTransactionToken(
266
  $initRecurringCaptureTransaction
@@ -268,7 +294,7 @@ class EMerchantPay_Genesis_Model_Task_Recurring
268
  );
269
  }
270
 
271
- if (empty(\Genesis\Config::getToken())) {
272
  Mage::throwException(
273
  $this->getHelper()->__(
274
  "Could not extract Terminal Token from Init Recurring Transaction"
@@ -330,16 +356,18 @@ class EMerchantPay_Genesis_Model_Task_Recurring
330
  : Mage_Sales_Model_Order::STATE_CANCELED
331
  );
332
 
333
- $trans_id = $responseObject->unique_id;
 
334
 
335
  $responseObject->terminal_token = $this->getHelper()->getGenesisPaymentTransactionToken(
336
  $initRecurringCaptureTransaction
337
  );
 
338
 
339
  $payment = $order->getPayment();
340
  $payment
341
  ->setTransactionId(
342
- $trans_id
343
  )
344
  ->setIsTransactionClosed(
345
  true
@@ -378,7 +406,7 @@ class EMerchantPay_Genesis_Model_Task_Recurring
378
 
379
  $profile->save();
380
 
381
- $updatedAt = ($mustSetUpdateDateToNextPeriod ? null : time());
382
 
383
  $this->updateRecurringProfileDateToNextPeriod(
384
  $methodCode,
@@ -390,11 +418,11 @@ class EMerchantPay_Genesis_Model_Task_Recurring
390
  /**
391
  * Prepares the Recurring Profile for the next recurring period
392
  * @param string $methodCode
393
- * @param int $profile_id
394
  * @param int|null $updatedAt
395
  * @return mixed
396
  */
397
- protected function updateRecurringProfileDateToNextPeriod($methodCode, $profile_id, $updatedAt = null)
398
  {
399
  $logFileName = $this->getHelper()->getConfigData(
400
  $methodCode,
@@ -404,7 +432,7 @@ class EMerchantPay_Genesis_Model_Task_Recurring
404
  $isLogEnabled = !empty($logFileName);
405
 
406
  if ($isLogEnabled) {
407
- Mage::log(__METHOD__ . '; Profile #' . $profile_id, null, $logFileName);
408
  }
409
 
410
  $_resource = Mage::getSingleton('core/resource');
@@ -424,13 +452,11 @@ class EMerchantPay_Genesis_Model_Task_Recurring
424
 
425
  $connection = $_resource->getConnection('core_write');
426
  $pdoStatement = $connection->prepare($sql);
427
- $pdoStatement->bindValue(':pid', $profile_id);
428
  if ($updatedAt) {
429
  $pdoStatement->bindValue(
430
  ':updated_at',
431
- $this->getHelper()->formatDateTimeToMySQLDateTime(
432
- $updatedAt
433
- )
434
  );
435
  }
436
  return $pdoStatement->execute();
@@ -444,21 +470,32 @@ class EMerchantPay_Genesis_Model_Task_Recurring
444
  protected function getProfileInitRecurringTransaction($profile)
445
  {
446
  foreach ($profile->getChildOrderIds() as $orderId) {
447
- $order = Mage::getModel("sales/order")->load($orderId);
 
448
 
449
- if (is_object($order) && $order->getId() && is_object($order->getPayment())) {
450
- $captureTransaction = $order->getPayment()->lookupTransaction(
451
- null,
452
- Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE
453
- );
454
 
455
- $genesisTransactionType = $this->getHelper()->getGenesisPaymentTransactionType(
456
- $captureTransaction
457
- );
 
 
 
 
458
 
459
- if ($this->getHelper()->getIsTransactionTypeInitRecurring($genesisTransactionType)) {
460
- return $captureTransaction;
461
- }
 
 
 
 
 
 
 
 
 
462
  }
463
  }
464
 
41
  /**
42
  * Cron job Observer Method for Direct PM
43
  * @param Mage_Cron_Model_Schedule $schedule
44
+ * @return bool|array
45
  */
46
  public function processDirect(Mage_Cron_Model_Schedule $schedule)
47
  {
53
  *
54
  * @param Mage_Cron_Model_Schedule $schedule
55
  * @param string $methodCode
56
+ * @return bool|array
57
  */
58
+ // @codingStandardsIgnoreStart
59
  protected function run(Mage_Cron_Model_Schedule $schedule, $methodCode)
60
  {
61
+ // @codingStandardsIgnoreEnd
62
  $result = array();
63
 
64
  $vendorName = "emerchantpay";
91
  $resource = Mage::getSingleton('core/resource');
92
  $adapter = $resource->getConnection('read');
93
 
94
+ // @codingStandardsIgnoreStart
95
  $select = $adapter->select();
96
  $select
97
  ->from(
110
  WHEN "semi_month" THEN DATE_ADD(updated_at, INTERVAL (period_frequency * 2) WEEK)
111
  WHEN "month" THEN DATE_ADD(updated_at, INTERVAL period_frequency MONTH)
112
  WHEN "year" THEN DATE_ADD(updated_at, INTERVAL period_frequency YEAR)
113
+ END))'
114
+ );
115
+ // @codingStandardsIgnoreEnd
116
 
117
  $binds = array(
118
  'method_code' =>
120
  'state' =>
121
  Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE,
122
  'now' =>
123
+ $this->getHelper()->formatCurrentDateTimeToMySQLDateTime()
 
 
124
  );
125
 
126
  $chargedProfiles = 0;
127
 
128
+ // @codingStandardsIgnoreStart
129
  foreach ($adapter->fetchAll($select, $binds) as $profileArr) {
130
+ // @codingStandardsIgnoreEnd
131
  if (!isset($profileArr['profile_id'])) {
132
  continue;
133
  }
134
 
135
+ $profileId = $profileArr['profile_id'];
 
 
 
 
 
136
 
137
+ if ($this->doCheckRecurringProfile($result, $profileId, $methodCode, $isLogEnabled, $logFileName)) {
138
+ $chargedProfiles++;
139
  }
140
+ }
141
 
142
+ if ($chargedProfiles == 0) {
143
+ $result[] = $this->getHelper()->__("No Profiles have been charged!");
144
+ }
145
 
146
+ return $result;
147
+ }
148
 
149
+ /**
150
+ * Does a check if the Profile has to charged and sends a Charge
151
+ *
152
+ * @param array $result
153
+ * @param int $profileId
154
+ * @param string $methodCode
155
+ * @param bool $isLogEnabled
156
+ * @param string $logFileName
157
+ * @return bool
158
+ */
159
+ protected function doCheckRecurringProfile(&$result, $profileId, $methodCode, $isLogEnabled, $logFileName)
160
+ {
161
+ $profile = Mage::getModel('sales/recurring_profile')->load($profileId);
162
 
163
+ $orders = $profile->getResource()->getChildOrderIds($profile);
164
+ $countBillingCycles = count($orders);
 
 
 
165
 
166
+ if ($profile->getInitAmount()) {
167
+ $countBillingCycles--;
168
+ }
 
169
 
170
+ $msgChargingProfile =
171
+ $this->getHelper()->__("Charging Recurring Profile #") .
172
+ $profile->getReferenceId();
173
 
174
+ $result[] = $msgChargingProfile;
 
 
 
 
 
 
 
 
175
 
176
+ if ($isLogEnabled) {
177
+ Mage::log($msgChargingProfile, null, $logFileName);
178
+ }
 
 
 
179
 
180
+ $mustSetUpdateDateToNextPeriod = (bool) $countBillingCycles > 0;
181
+ try {
182
+ $this->chargeRecurringProfile($methodCode, $profile, $mustSetUpdateDateToNextPeriod);
183
+ $countBillingCycles++;
184
+
185
+ if ($this->doCheckAndSuspendRecurringProfile($profile, $countBillingCycles)) {
186
+ $msgChargingProfile =
187
+ $this->getHelper()->__("Billing Cycles reached. Suspending Recurring Profile #") .
188
+ $profile->getReferenceId();
189
+
190
+ $result[] = $msgChargingProfile;
191
 
192
  if ($isLogEnabled) {
193
+ Mage::log($msgChargingProfile, null, $logFileName);
194
  }
195
  }
 
196
 
197
+ return true;
198
+ } catch (\Exception $e) {
199
+ $profile->setState(
200
+ Mage_Sales_Model_Recurring_Profile::STATE_SUSPENDED
201
+ );
202
+ $profile->save();
203
 
204
+ $msgProfileSuspended = $this->getHelper()->__(
205
+ sprintf(
206
+ "Recurring Profile #%s is set to suspended, because of a failed Recurring Transaction",
207
+ $profile->getReferenceId()
208
+ )
209
+ );
210
+
211
+ $result[] = $msgProfileSuspended;
212
+
213
+ if ($isLogEnabled) {
214
+ Mage::log($msgProfileSuspended, null, $logFileName);
215
+ }
216
+
217
+ return false;
218
+ }
219
  }
220
 
221
  /**
226
  */
227
  protected function doCheckAndSuspendRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile, $billingCycles)
228
  {
229
+ if ($profile->getPeriodMaxCycles() && ($billingCycles >= $profile->getPeriodMaxCycles())) {
230
  $profile->setState(
231
  Mage_Sales_Model_Recurring_Profile::STATE_SUSPENDED
232
  );
257
  $methodCode,
258
  Mage_Payment_Model_Recurring_Profile $profile,
259
  $mustSetUpdateDateToNextPeriod
260
+ )
261
+ {
262
  $logFileName = $this->getHelper()->getConfigData(
263
  $methodCode,
264
  'cron_recurring_log_file'
283
 
284
  $recurringToken = $this->getHelper()->getRecurringSaleToken($methodCode);
285
 
286
+ if ($recurringToken) {
287
  \Genesis\Config::setToken($recurringToken);
288
  } else {
289
+ if (!\Genesis\Config::getToken()) {
290
  \Genesis\Config::setToken(
291
  $this->getHelper()->getGenesisPaymentTransactionToken(
292
  $initRecurringCaptureTransaction
294
  );
295
  }
296
 
297
+ if (!\Genesis\Config::getToken()) {
298
  Mage::throwException(
299
  $this->getHelper()->__(
300
  "Could not extract Terminal Token from Init Recurring Transaction"
356
  : Mage_Sales_Model_Order::STATE_CANCELED
357
  );
358
 
359
+ // @codingStandardsIgnoreStart
360
+ $transactionId = $responseObject->unique_id;
361
 
362
  $responseObject->terminal_token = $this->getHelper()->getGenesisPaymentTransactionToken(
363
  $initRecurringCaptureTransaction
364
  );
365
+ // @codingStandardsIgnoreEnd
366
 
367
  $payment = $order->getPayment();
368
  $payment
369
  ->setTransactionId(
370
+ $transactionId
371
  )
372
  ->setIsTransactionClosed(
373
  true
406
 
407
  $profile->save();
408
 
409
+ $updatedAt = ($mustSetUpdateDateToNextPeriod ? null : true);
410
 
411
  $this->updateRecurringProfileDateToNextPeriod(
412
  $methodCode,
418
  /**
419
  * Prepares the Recurring Profile for the next recurring period
420
  * @param string $methodCode
421
+ * @param int $profileId
422
  * @param int|null $updatedAt
423
  * @return mixed
424
  */
425
+ protected function updateRecurringProfileDateToNextPeriod($methodCode, $profileId, $updatedAt = null)
426
  {
427
  $logFileName = $this->getHelper()->getConfigData(
428
  $methodCode,
432
  $isLogEnabled = !empty($logFileName);
433
 
434
  if ($isLogEnabled) {
435
+ Mage::log(__METHOD__ . '; Profile #' . $profileId, null, $logFileName);
436
  }
437
 
438
  $_resource = Mage::getSingleton('core/resource');
452
 
453
  $connection = $_resource->getConnection('core_write');
454
  $pdoStatement = $connection->prepare($sql);
455
+ $pdoStatement->bindValue(':pid', $profileId);
456
  if ($updatedAt) {
457
  $pdoStatement->bindValue(
458
  ':updated_at',
459
+ $this->getHelper()->formatCurrentDateTimeToMySQLDateTime()
 
 
460
  );
461
  }
462
  return $pdoStatement->execute();
470
  protected function getProfileInitRecurringTransaction($profile)
471
  {
472
  foreach ($profile->getChildOrderIds() as $orderId) {
473
+ return $this->getProfileInitRecurringTrxByOrder($orderId);
474
+ }
475
 
476
+ return null;
477
+ }
 
 
 
478
 
479
+ /**
480
+ * @param int $orderId
481
+ * @return Mage_Sales_Model_Order_Payment_Transaction|null
482
+ */
483
+ protected function getProfileInitRecurringTrxByOrder($orderId)
484
+ {
485
+ $order = Mage::getModel("sales/order")->load($orderId);
486
 
487
+ if (is_object($order) && $order->getId() && is_object($order->getPayment())) {
488
+ $captureTransaction = $order->getPayment()->lookupTransaction(
489
+ null,
490
+ Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE
491
+ );
492
+
493
+ $genesisTransactionType = $this->getHelper()->getGenesisPaymentTransactionType(
494
+ $captureTransaction
495
+ );
496
+
497
+ if ($this->getHelper()->getIsTransactionTypeInitRecurring($genesisTransactionType)) {
498
+ return $captureTransaction;
499
  }
500
  }
501
 
app/code/community/EMerchantPay/Genesis/Observer/CheckoutSubmitAllAfter.php CHANGED
@@ -35,11 +35,11 @@ class EMerchantPay_Genesis_Observer_CheckoutSubmitAllAfter
35
  $event = $observer->getEvent();
36
  $recurringProfiles = $event->getRecurringProfiles();
37
 
38
- if (is_array($recurringProfiles) && count($recurringProfiles) > 0) {
39
  $checkoutSession = Mage::helper('emerchantpay')->getCheckoutSession();
40
  $redirectUrl = $checkoutSession->getEmerchantPayCheckoutRedirectUrl();
41
 
42
- if (!empty($redirectUrl)) {
43
  $checkoutSession->setRedirectUrl(
44
  $redirectUrl
45
  );
35
  $event = $observer->getEvent();
36
  $recurringProfiles = $event->getRecurringProfiles();
37
 
38
+ if (is_array($recurringProfiles) && !empty($recurringProfiles)) {
39
  $checkoutSession = Mage::helper('emerchantpay')->getCheckoutSession();
40
  $redirectUrl = $checkoutSession->getEmerchantPayCheckoutRedirectUrl();
41
 
42
+ if ($redirectUrl) {
43
  $checkoutSession->setRedirectUrl(
44
  $redirectUrl
45
  );
app/code/community/EMerchantPay/Genesis/Observer/SalesQuoteAddressCollectTotalsBefore.php CHANGED
@@ -25,7 +25,7 @@
25
  */
26
  class EMerchantPay_Genesis_Observer_SalesQuoteAddressCollectTotalsBefore
27
  {
28
- private $_methodCodes = array(
29
  'emerchantpay_checkout',
30
  'emerchantpay_direct'
31
  );
@@ -33,38 +33,50 @@ class EMerchantPay_Genesis_Observer_SalesQuoteAddressCollectTotalsBefore
33
  /**
34
  * Observer Event Handler
35
  * @param Varien_Event_Observer $observer
 
36
  */
37
  public function handleAction($observer)
38
  {
39
  $event = $observer->getEvent();
40
  $quoteAddress = $event->getQuoteAddress();
41
 
42
- if (is_object($quoteAddress) && is_object($quoteAddress->getQuote()->getPayment())) {
43
- $paymentMethodCode = $quoteAddress->getQuote()->getPayment()->getMethod();
 
 
 
 
 
 
 
 
 
 
 
44
 
45
- if (isset($paymentMethodCode) && in_array($paymentMethodCode, $this->getMethodCodes())) {
 
46
 
47
- if ($this->getHelper()->getIsMethodAvailable($paymentMethodCode, $quoteAddress->getQuote())) {
48
- foreach ($quoteAddress->getAllNominalItems() as $item) {
49
- $product = $item->getProduct();
50
 
51
- if (is_object($product) && $product->getIsRecurring() && is_array($product->getRecurringProfile())) {
52
- $productRecurringProfile = $product->getRecurringProfile();
53
 
54
- if ($this->getMustOverrideProfileInitAmount($productRecurringProfile)) {
55
- $productRecurringProfile['init_amount'] =
56
- $this->getHelper()->getMethodInitRecurringFee(
57
- $paymentMethodCode
58
- );
59
- $product->setRecurringProfile(
60
- $productRecurringProfile
61
- );
62
- }
63
- }
64
- }
65
- }
66
  }
 
 
 
 
 
 
 
 
67
  }
 
 
68
  }
69
 
70
  /**
25
  */
26
  class EMerchantPay_Genesis_Observer_SalesQuoteAddressCollectTotalsBefore
27
  {
28
+ protected $_methodCodes = array(
29
  'emerchantpay_checkout',
30
  'emerchantpay_direct'
31
  );
33
  /**
34
  * Observer Event Handler
35
  * @param Varien_Event_Observer $observer
36
+ * @return bool|EMerchantPay_Genesis_Observer_SalesQuoteAddressCollectTotalsBefore
37
  */
38
  public function handleAction($observer)
39
  {
40
  $event = $observer->getEvent();
41
  $quoteAddress = $event->getQuoteAddress();
42
 
43
+ if (!is_object($quoteAddress) || !is_object($quoteAddress->getQuote()->getPayment())) {
44
+ return false;
45
+ }
46
+
47
+ $paymentMethodCode = $quoteAddress->getQuote()->getPayment()->getMethod();
48
+
49
+ if (!isset($paymentMethodCode) || !in_array($paymentMethodCode, $this->getMethodCodes())) {
50
+ return false;
51
+ }
52
+
53
+ if (!$this->getHelper()->getIsMethodAvailable($paymentMethodCode, $quoteAddress->getQuote())) {
54
+ return false;
55
+ }
56
 
57
+ foreach ($quoteAddress->getAllNominalItems() as $item) {
58
+ $product = $item->getProduct();
59
 
60
+ if (!is_object($product) || !$product->getIsRecurring() || !is_array($product->getRecurringProfile())) {
61
+ continue;
62
+ }
63
 
64
+ $productRecurringProfile = $product->getRecurringProfile();
 
65
 
66
+ if (!$this->getMustOverrideProfileInitAmount($productRecurringProfile)) {
67
+ continue;
 
 
 
 
 
 
 
 
 
 
68
  }
69
+
70
+ $productRecurringProfile['init_amount'] =
71
+ $this->getHelper()->getMethodInitRecurringFee(
72
+ $paymentMethodCode
73
+ );
74
+ $product->setRecurringProfile(
75
+ $productRecurringProfile
76
+ );
77
  }
78
+
79
+ return $this;
80
  }
81
 
82
  /**
app/code/community/EMerchantPay/Genesis/controllers/CheckoutController.php CHANGED
@@ -25,16 +25,16 @@
25
  class EMerchantPay_Genesis_CheckoutController extends Mage_Core_Controller_Front_Action
26
  {
27
  /** @var EMerchantPay_Genesis_Helper_Data $helper */
28
- private $helper;
29
 
30
  /** @var EMerchantPay_Genesis_Model_Checkout $checkout */
31
- private $checkout;
32
 
33
  protected function _construct()
34
  {
35
- $this->helper = Mage::helper('emerchantpay');
36
 
37
- $this->checkout = Mage::getModel('emerchantpay/checkout');
38
  }
39
 
40
  /**
@@ -55,7 +55,7 @@ class EMerchantPay_Genesis_CheckoutController extends Mage_Core_Controller_Front
55
  }
56
 
57
  try {
58
- $this->helper->initClient($this->checkout->getCode());
59
 
60
  $notification = new \Genesis\API\Notification(
61
  $this->getRequest()->getPost()
@@ -66,8 +66,10 @@ class EMerchantPay_Genesis_CheckoutController extends Mage_Core_Controller_Front
66
 
67
  $reconcile = $notification->getReconciliationObject();
68
 
 
69
  if (isset($reconcile->unique_id)) {
70
- $this->checkout->processNotification($reconcile);
 
71
 
72
  $this->getResponse()->clearHeaders();
73
  $this->getResponse()->clearBody();
@@ -123,10 +125,10 @@ class EMerchantPay_Genesis_CheckoutController extends Mage_Core_Controller_Front
123
  */
124
  public function failureAction()
125
  {
126
- $this->helper->restoreQuote();
127
 
128
- $this->helper->getCheckoutSession()->addError(
129
- $this->helper->__('We were unable to process your payment! Please check your input or try again later.')
130
  );
131
 
132
  $this->_redirect('checkout/cart', array('_secure' => true));
@@ -139,10 +141,10 @@ class EMerchantPay_Genesis_CheckoutController extends Mage_Core_Controller_Front
139
  */
140
  public function cancelAction()
141
  {
142
- $this->helper->restoreQuote($shouldCancel = true);
143
 
144
- $this->helper->getCheckoutSession()->addSuccess(
145
- $this->helper->__('Your payment session has been cancelled successfully!')
146
  );
147
 
148
  $this->_redirect('checkout/cart', array('_secure' => true));
25
  class EMerchantPay_Genesis_CheckoutController extends Mage_Core_Controller_Front_Action
26
  {
27
  /** @var EMerchantPay_Genesis_Helper_Data $helper */
28
+ protected $_helper;
29
 
30
  /** @var EMerchantPay_Genesis_Model_Checkout $checkout */
31
+ protected $_checkout;
32
 
33
  protected function _construct()
34
  {
35
+ $this->_helper = Mage::helper('emerchantpay');
36
 
37
+ $this->_checkout = Mage::getModel('emerchantpay/checkout');
38
  }
39
 
40
  /**
55
  }
56
 
57
  try {
58
+ $this->_helper->initClient($this->_checkout->getCode());
59
 
60
  $notification = new \Genesis\API\Notification(
61
  $this->getRequest()->getPost()
66
 
67
  $reconcile = $notification->getReconciliationObject();
68
 
69
+ // @codingStandardsIgnoreStart
70
  if (isset($reconcile->unique_id)) {
71
+ // @codingStandardsIgnoreStart
72
+ $this->_checkout->processNotification($reconcile);
73
 
74
  $this->getResponse()->clearHeaders();
75
  $this->getResponse()->clearBody();
125
  */
126
  public function failureAction()
127
  {
128
+ $this->_helper->restoreQuote();
129
 
130
+ $this->_helper->getCheckoutSession()->addError(
131
+ $this->_helper->__('We were unable to process your payment! Please check your input or try again later.')
132
  );
133
 
134
  $this->_redirect('checkout/cart', array('_secure' => true));
141
  */
142
  public function cancelAction()
143
  {
144
+ $this->_helper->restoreQuote($shouldCancel = true);
145
 
146
+ $this->_helper->getCheckoutSession()->addSuccess(
147
+ $this->_helper->__('Your payment session has been cancelled successfully!')
148
  );
149
 
150
  $this->_redirect('checkout/cart', array('_secure' => true));
app/code/community/EMerchantPay/Genesis/controllers/DirectController.php CHANGED
@@ -25,16 +25,16 @@
25
  class EMerchantPay_Genesis_DirectController extends Mage_Core_Controller_Front_Action
26
  {
27
  /** @var EMerchantPay_Genesis_Helper_Data $helper */
28
- private $helper;
29
 
30
  /** @var EMerchantPay_Genesis_Model_Direct $direct */
31
- private $direct;
32
 
33
  protected function _construct()
34
  {
35
- $this->helper = Mage::helper('emerchantpay');
36
 
37
- $this->direct = Mage::getModel('emerchantpay/direct');
38
  }
39
 
40
  /**
@@ -55,7 +55,7 @@ class EMerchantPay_Genesis_DirectController extends Mage_Core_Controller_Front_A
55
  }
56
 
57
  try {
58
- $this->helper->initClient($this->direct->getCode());
59
 
60
  $notification = new \Genesis\API\Notification(
61
  $this->getRequest()->getPost()
@@ -66,8 +66,11 @@ class EMerchantPay_Genesis_DirectController extends Mage_Core_Controller_Front_A
66
 
67
  $reconcile = $notification->getReconciliationObject();
68
 
 
69
  if (isset($reconcile->unique_id)) {
70
- $this->direct->processNotification($reconcile);
 
 
71
 
72
  $this->getResponse()->clearHeaders();
73
  $this->getResponse()->clearBody();
@@ -121,10 +124,10 @@ class EMerchantPay_Genesis_DirectController extends Mage_Core_Controller_Front_A
121
  */
122
  public function failureAction()
123
  {
124
- $this->helper->restoreQuote();
125
 
126
- $this->helper->getCheckoutSession()->addError(
127
- $this->helper->__('We were unable to process your payment! Please check your input or try again later.')
128
  );
129
 
130
  $this->_redirect('checkout/cart', array('_secure' => true));
25
  class EMerchantPay_Genesis_DirectController extends Mage_Core_Controller_Front_Action
26
  {
27
  /** @var EMerchantPay_Genesis_Helper_Data $helper */
28
+ protected $_helper;
29
 
30
  /** @var EMerchantPay_Genesis_Model_Direct $direct */
31
+ protected $_direct;
32
 
33
  protected function _construct()
34
  {
35
+ $this->_helper = Mage::helper('emerchantpay');
36
 
37
+ $this->_direct = Mage::getModel('emerchantpay/direct');
38
  }
39
 
40
  /**
55
  }
56
 
57
  try {
58
+ $this->_helper->initClient($this->_direct->getCode());
59
 
60
  $notification = new \Genesis\API\Notification(
61
  $this->getRequest()->getPost()
66
 
67
  $reconcile = $notification->getReconciliationObject();
68
 
69
+ // @codingStandardsIgnoreStart
70
  if (isset($reconcile->unique_id)) {
71
+ // @codingStandardsIgnoreEnd
72
+
73
+ $this->_direct->processNotification($reconcile);
74
 
75
  $this->getResponse()->clearHeaders();
76
  $this->getResponse()->clearBody();
124
  */
125
  public function failureAction()
126
  {
127
+ $this->_helper->restoreQuote();
128
 
129
+ $this->_helper->getCheckoutSession()->addError(
130
+ $this->_helper->__('We were unable to process your payment! Please check your input or try again later.')
131
  );
132
 
133
  $this->_redirect('checkout/cart', array('_secure' => true));
app/code/community/EMerchantPay/Genesis/etc/config.xml CHANGED
@@ -19,7 +19,7 @@ GNU General Public License for more details.
19
  <config>
20
  <modules>
21
  <EMerchantPay_Genesis>
22
- <version>1.2.8</version>
23
  </EMerchantPay_Genesis>
24
  </modules>
25
 
19
  <config>
20
  <modules>
21
  <EMerchantPay_Genesis>
22
+ <version>1.2.9</version>
23
  </EMerchantPay_Genesis>
24
  </modules>
25
 
lib/Genesis/src/Genesis/API/.DS_Store DELETED
Binary file
lib/Genesis/src/Genesis/API/Request/.DS_Store DELETED
Binary file
lib/Genesis/src/Genesis/API/Request/WPF/.DS_Store DELETED
Binary file
lib/Genesis/src/Genesis/Utils/.DS_Store DELETED
Binary file
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>EMerchantPay_Genesis_Client</name>
4
- <version>1.2.8</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
@@ -10,18 +10,13 @@
10
  <description>This is a Payment Module for Magento Community Edition, that gives you the ability to process payments through eMerchantPay's Payment Gateway - Genesis.&#xD;
11
  &#xD;
12
  The Payment Gateway supports all of the major credit/debit card brands and more than 40 alternative payment methods (APMs) and e-wallets. When using the module, the merchant benefits from eMerchantPay&#x2019;s vast payment industry experience and a full suite of value-added services such as sophisticated risk management and monitoring tools, with the added benefit of removing the burden of PCI DSS compliance from the merchant.</description>
13
- <notes>1.) Added Extensions for Recurring Transactions&#xD;
14
- - eMerchantPay Direct Payment Method&#xD;
15
- --Added admin setting "Recurring Token" for processing Recurring Transactions&#xD;
16
- --Changed validation for "Initial Fee" admin setting&#xD;
17
  &#xD;
18
- - eMerchantPay Checkout Payment Method&#xD;
19
- --Added admin setting "Recurring Token" for processing Recurring Transactions&#xD;
20
- --Changed validation for "Initial Fee" admin setting</notes>
21
  <authors><author><name>eMerchantPay Ltd.</name><user>chrisrive</user><email>chris@emerchantpay.com</email></author></authors>
22
- <date>2016-07-19</date>
23
- <time>10:51:40</time>
24
- <contents><target name="magecommunity"><dir name="EMerchantPay"><dir name="Genesis"><dir name="Block"><dir name="Form"><file name="Checkout.php" hash="abe450bd6746651abf03c32b8db17543"/><file name="Direct.php" hash="6b13a0b0bf2d26434c8e7207a9b1286b"/></dir><dir name="Info"><file name="Checkout.php" hash="3233f4ade14cee154c064f2deea1bd8f"/><file name="Direct.php" hash="76a10eddefc97b01fafb6fff0f36f837"/></dir><dir name="Redirect"><file name="Checkout.php" hash="1cf157bbc17a25e17dee10ec9ade0ab2"/><file name="Direct.php" hash="7c2aba2803e4c72ec91235f2d21905c9"/></dir></dir><dir name="Helper"><file name="Data.php" hash="0b54c498f1d4f5345cb02cfe65a363af"/></dir><dir name="Model"><dir name="Admin"><dir name="Checkout"><dir name="Options"><dir name="Transaction"><dir name="Recurring"><file name="Type.php" hash="41338f33c9f649701e5fd8a47363ffea"/></dir><file name="Type.php" hash="bbe07732d7febf995c470ab36eec2234"/></dir></dir></dir><dir name="Direct"><dir name="Options"><dir name="Transaction"><dir name="Recurring"><file name="Type.php" hash="c5bcbb4e6c62daac0ecdfe8ef0315023"/></dir><file name="Type.php" hash="a8ee95bff6d13736e1639fe4a52fb862"/></dir></dir></dir><file name="Environment.php" hash="168ae448e5478560e079be92b3810507"/></dir><file name="Checkout.php" hash="0d5ac8a7d3637452c0fa8ebf0dc8b95a"/><file name="Direct.php" hash="c54fd27fa7e81574120238049dbe92f1"/><dir name="Task"><file name="Recurring.php" hash="4658db938f4f1aa284aa8a00f57a208e"/></dir></dir><dir name="Observer"><file name="CheckoutSubmitAllAfter.php" hash="c90595c7a57f0cebe3f35cefa9d62907"/><file name="SalesQuoteAddressCollectTotalsBefore.php" hash="9f57bd3d0a244941f2d0eb3dce06c018"/></dir><dir name="controllers"><file name="CheckoutController.php" hash="864566ef67b94e9b2bf482390a6f71f2"/><file name="DirectController.php" hash="de9c366cd07c01a74392e7704a716df2"/></dir><dir name="etc"><file name="config.xml" hash="e7ca96893c3c7b2784e82517b9fe5073"/><file name="system.xml" hash="63a9042dcf422feaeb4eb116b90313e2"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="emerchantpay"><dir name="info"><file name="checkout.phtml" hash="121f777049b801219f2792ca9aaedd3e"/><file name="direct.phtml" hash="121f777049b801219f2792ca9aaedd3e"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="emerchantpay"><dir name="form"><file name="checkout.phtml" hash="835a61d301f75e3d39a84ed412941ae0"/><file name="direct.phtml" hash="adbe6e9f00f15ea5db9de983cd6a7880"/></dir><dir name="info"><file name="checkout.phtml" hash="939277e4db9bda19b6932775a03fbaac"/><file name="direct.phtml" hash="939277e4db9bda19b6932775a03fbaac"/></dir><dir name="redirect"><file name="checkout.phtml" hash="caee38fbfc90ebc340730b83066486d3"/><file name="direct.phtml" hash="caee38fbfc90ebc340730b83066486d3"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="EMerchantPay_Genesis.xml" hash="83879cf40aba5587eecc86c162398e43"/></dir></target><target name="magelocale"><dir name="en_GB"><file name="EMerchantPay_Genesis.csv" hash="4bfb9000f103576377a939c945860e1c"/></dir><dir name="en_US"><file name="EMerchantPay_Genesis.csv" hash="4bfb9000f103576377a939c945860e1c"/></dir></target><target name="magelib"><dir name="Genesis"><dir name="src"><dir name="Genesis"><dir name="API"><dir name="Constants"><file name="Banks.php" hash="b7b1fc98be9aa2c0e2bd7c03086ca397"/><file name="Endpoints.php" hash="2036dc4c26f6e7418d5ce198170f96a1"/><file name="Environments.php" hash="4054e40a140cd9b4010a49e7928457f4"/><file name="Errors.php" hash="434b001eb137e74e654020d63b7c4f72"/><dir name="Payment"><file name="Methods.php" hash="de89e5298e49aea3f5eb8c9f89317576"/></dir><dir name="Transaction"><dir name="Parameters"><dir name="PayByVouchers"><file name="CardTypes.php" hash="d9e632a4b269948079af8f96bf3c56f1"/><file name="RedeemTypes.php" hash="ed1c30bc2b9cc435e7b66afad9ab3832"/></dir></dir><file name="States.php" hash="52a8c37ba2ab1597b928b5a4de89cdf3"/><file name="Types.php" hash="40db1b4803eb29d2987d1e7cef04230a"/></dir><file name="i18n.php" hash="577058e53e7c935e3e883fd4792ee548"/></dir><file name="Notification.php" hash="dfa03ae89de997ef9ac98ec08b51a3b5"/><dir name="Request"><dir name="Financial"><dir name="Alternatives"><file name="ABNiDEAL.php" hash="9ad0d2f75fcdf5b2cb94c78b3b3d6ea3"/><file name="CashU.php" hash="f28471dfff04de6e8e0c7b47aa1c08da"/><file name="POLi.php" hash="31ef3c44fa6c367f207c0633950ec8f1"/><file name="PPRO.php" hash="48ba59d3f53d5b15720b0b4f4e5fbc26"/><file name="Paysafecard.php" hash="83a298fd99434d6c207f1e1f23905061"/><file name="Sofort.php" hash="6cf9bcb7a47eb0ea7c1fa1e97ca5887c"/></dir><file name="Capture.php" hash="4074b82a2cd3ace1e655316c4dcc8064"/><dir name="Cards"><file name="Authorize.php" hash="f8cd42657ba5655af03de32c829f65ea"/><file name="Authorize3D.php" hash="57a35302fa7e08d72ec577169b64fd3c"/><file name="Credit.php" hash="a24fb37241999072f55319baf5056415"/><file name="Payout.php" hash="dae3a6cb34dc29dc583a8958a82e3628"/><dir name="Recurring"><file name="InitRecurringSale.php" hash="5903a5d82a5eceee4ac266099b708894"/><file name="InitRecurringSale3D.php" hash="ec06f91acaf4ad5d79682ec61058eac2"/><file name="RecurringSale.php" hash="324d2bf186578303a0ad084a78013051"/></dir><file name="Sale.php" hash="84b08a879c9f10b2c766a34de9878207"/><file name="Sale3D.php" hash="f6517e874dc37d123808bfa0ee5a5a1d"/></dir><dir name="PayByVouchers"><file name="Sale.php" hash="367c3036c60014aa0804ce22323001da"/><file name="oBeP.php" hash="af5b1586d15aed1b85defee8e6907d12"/></dir><file name="Refund.php" hash="399b75255fa787009e978053314a6925"/><file name="Void.php" hash="5d8d5744bb55bc4821a06f5b36ab29db"/><dir name="Wallets"><file name="Neteller.php" hash="404e7eb71cb655f9abbc0febb6783a1a"/><file name="WebMoney.php" hash="1a326d4502743c7c63c132e1911e9f78"/><file name="eZeeWallet.php" hash="6cb8d492a5ada59163f4cebad6b0d7dc"/></dir></dir><dir name="NonFinancial"><file name="AVS.php" hash="28c1506a04b88a6e0e3d19a27d00a335"/><file name="AccountVerification.php" hash="bc1e2775bef0a1f23345dac5b24b72f8"/><file name="Blacklist.php" hash="5da01bedc92c6979953d29901c3f113c"/><dir name="Fraud"><dir name="Chargeback"><file name="DateRange.php" hash="fb33c10f6375d145b5e159b883d37f3c"/><file name="Transaction.php" hash="eb8997ced7f9cc45b4df3056415dce3e"/></dir><dir name="Reports"><file name="DateRange.php" hash="53419659a6c5aff80edf0c7a31a31d31"/><file name="Transaction.php" hash="a8dd1ab07cca3537687c126572a39d25"/></dir><dir name="Retrieval"><file name="DateRange.php" hash="899f1bc77c47c6fde65451f2d2257a55"/><file name="Transaction.php" hash="73b7e9bfda8e385ea7dde1dab66bcb63"/></dir></dir><dir name="Reconcile"><file name="DateRange.php" hash="83d388eae9785c04ab2b961496faf490"/><file name="Transaction.php" hash="ed77990ff74e33faf4d26ba5e1cf7431"/></dir><dir name="Retrieve"><file name="AbniDealBanks.php" hash="0c0b187f29a20cf84550dc535e365a6b"/></dir></dir><dir name="WPF"><file name="Create.php" hash="169fdc03b480e6dd45ec54496c590b21"/><file name="Reconcile.php" hash="45aa4cd09b512b04a6b5a19c259d45ab"/><file name=".DS_Store" hash="79d680ef2d9c3e4a355285a412a2f3d0"/></dir><file name=".DS_Store" hash="61d1bfdf8f4d84420b28837ca4d5c17f"/></dir><file name="Request.php" hash="590d63882937f1c558f1e31fe6add200"/><file name="Response.php" hash="59db1b505572d73f7ba5eb373eb18fde"/><file name=".DS_Store" hash="49aac6b791d48c0903291b9d29ecf5a9"/></dir><file name="Builder.php" hash="a1d259798cb8a118d59b2f3c5a313e3e"/><dir name="Builders"><file name="JSON.php" hash="387f44beabc6271d60cfdfa4de42b2b0"/><file name="XML.php" hash="c5dc6d4dcef1036c154e2833d21819c4"/></dir><dir name="Certificates"><file name="ca-bundle.pem" hash="1d4f036201f82a743da147db09a6d8ca"/></dir><file name="Config.php" hash="47d41b358bc7acaeed7492896e057536"/><dir name="Exceptions"><file name="EnvironmentNotSet.php" hash="a6f425cd8922b3615fa79cc9885328e9"/><file name="ErrorAPI.php" hash="f437c2e2423397ceaee0491e5e43d136"/><file name="ErrorNetwork.php" hash="ef4686482899ebfa53a79dd470fb751c"/><file name="ErrorParameter.php" hash="c9518f203b97e168c7db12e091635946"/><file name="InvalidArgument.php" hash="6c0f4c620ec5fda8cb46e3ff9c61d07d"/><file name="InvalidMethod.php" hash="f90abed4eb6a22d6c77da9a2c60ad5c9"/><file name="InvalidResponse.php" hash="0bab84b8816d83418062dc960648ca30"/></dir><file name="Genesis.php" hash="c14b9c20cbc534f09e891332a2794ded"/><dir name="Interfaces"><file name="Builder.php" hash="ce3aaa42bf5be788488142c420e2160f"/><file name="Network.php" hash="97f13f574a31683fd25c69b930a4b39d"/><file name="Parser.php" hash="391f365d54bfd245e901f56071238c0f"/></dir><dir name="Network"><file name="Stream.php" hash="36b286e49b6b998a883511f9902f8a5a"/><file name="cURL.php" hash="e3534bf2e3254343b0cd344d9eca6b77"/></dir><file name="Network.php" hash="9a7152dd32fee74a103e08eef03c7bbf"/><file name="Parser.php" hash="b32834c751a57c9cc2e971792d125aa0"/><dir name="Parsers"><file name="XML.php" hash="7c8c64ea006668a25b0aa0cb882425d7"/></dir><dir name="Utils"><file name="Common.php" hash="f669b461894af8650fe9af3d4b7b2f81"/><file name="Country.php" hash="53890c12438b00a5908d3a4f7f92c785"/><file name="Currency.php" hash="29fc4143a6ed046917fef3fd3286b811"/><file name="Requirements.php" hash="f2b8ab0a131e878ff35d30d7512dd133"/><file name=".DS_Store" hash="3f4e64fc3ee983a0d4d219a9af0ac304"/></dir></dir></dir><dir name="vendor"><file name="autoload.php" hash="59c384c9fd04a63a1609c0c507cdc384"/><dir name="composer"><file name="ClassLoader.php" hash="479613a7d15cfdf2bcdf0399a032ff9a"/><file name="LICENSE" hash="caa653f07bb161e830d67b0ab35dd642"/><file name="autoload_classmap.php" hash="8645d3a4e3ad87e7cf4d88a46717aab4"/><file name="autoload_namespaces.php" hash="af4fa780231e7182bbd1430a1973a21d"/><file name="autoload_psr4.php" hash="dd3a00f0d13eb29781edd8c77d4c5100"/><file name="autoload_real.php" hash="a80c290f6d5d3cc4b7d03108d55b36eb"/><file name="installed.json" hash="30a799458964967a17ca693a6b2d1c65"/></dir></dir></dir></target></contents>
25
  <compatible/>
26
  <dependencies><required><php><min>5.3.2</min><max>7.0.2</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.7</min><max/></package><extension><name>bcmath</name><min/><max/></extension><extension><name>curl</name><min/><max/></extension><extension><name>filter</name><min/><max/></extension><extension><name>hash</name><min/><max/></extension><extension><name>xmlreader</name><min/><max/></extension><extension><name>xmlwriter</name><min/><max/></extension></required></dependencies>
27
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>EMerchantPay_Genesis_Client</name>
4
+ <version>1.2.9</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
10
  <description>This is a Payment Module for Magento Community Edition, that gives you the ability to process payments through eMerchantPay's Payment Gateway - Genesis.&#xD;
11
  &#xD;
12
  The Payment Gateway supports all of the major credit/debit card brands and more than 40 alternative payment methods (APMs) and e-wallets. When using the module, the merchant benefits from eMerchantPay&#x2019;s vast payment industry experience and a full suite of value-added services such as sophisticated risk management and monitoring tools, with the added benefit of removing the burden of PCI DSS compliance from the merchant.</description>
13
+ <notes>1.) Fix Order Status Update after Synchronous Transaction (Sale, Authorize) using Direct Payment Method&#xD;
 
 
 
14
  &#xD;
15
+ 2.) Online Refund was not possible after processing Sale3D Transaction using Direct Payment Method </notes>
 
 
16
  <authors><author><name>eMerchantPay Ltd.</name><user>chrisrive</user><email>chris@emerchantpay.com</email></author></authors>
17
+ <date>2016-12-27</date>
18
+ <time>09:18:15</time>
19
+ <contents><target name="magecommunity"><dir name="EMerchantPay"><dir name="Genesis"><dir name="Block"><dir name="Form"><file name="Checkout.php" hash="abe450bd6746651abf03c32b8db17543"/><file name="Direct.php" hash="a8e080ce122886d51cb7a82f2ed62412"/></dir><dir name="Info"><file name="Checkout.php" hash="3233f4ade14cee154c064f2deea1bd8f"/><file name="Direct.php" hash="76a10eddefc97b01fafb6fff0f36f837"/></dir><dir name="Redirect"><file name="Checkout.php" hash="b00b4e6cc7d3f93fbd2ac67f5d2e960f"/><file name="Direct.php" hash="2f6d4ffa32f737df09c3b6aa659add4e"/></dir></dir><dir name="Helper"><file name="Data.php" hash="5b5e757cddf8f2d2e4f9663cabf40c90"/></dir><dir name="Model"><dir name="Admin"><dir name="Checkout"><dir name="Options"><dir name="Transaction"><dir name="Recurring"><file name="Type.php" hash="41338f33c9f649701e5fd8a47363ffea"/></dir><file name="Type.php" hash="bbe07732d7febf995c470ab36eec2234"/></dir></dir></dir><dir name="Direct"><dir name="Options"><dir name="Transaction"><dir name="Recurring"><file name="Type.php" hash="c5bcbb4e6c62daac0ecdfe8ef0315023"/></dir><file name="Type.php" hash="a8ee95bff6d13736e1639fe4a52fb862"/></dir></dir></dir><file name="Environment.php" hash="168ae448e5478560e079be92b3810507"/></dir><file name="Checkout.php" hash="2fa1f8945d1094e836a2e6c8596129c0"/><file name="Direct.php" hash="57b428cc31d384e3c42197a1931bb53f"/><dir name="Task"><file name="Recurring.php" hash="0c830d82e90ec4be13f75afac7c26b88"/></dir></dir><dir name="Observer"><file name="CheckoutSubmitAllAfter.php" hash="aea62d4d5facf2b605cc7ea1f4295dc4"/><file name="SalesQuoteAddressCollectTotalsBefore.php" hash="e26c5af345b7a475f9f719979597111b"/></dir><dir name="controllers"><file name="CheckoutController.php" hash="fee5132397f438b47139f30f10c40bf6"/><file name="DirectController.php" hash="b6dbe6db006e7f0421289c06a6712c6d"/></dir><dir name="etc"><file name="config.xml" hash="ca1b24b69e3b63ef92513e4580771dfd"/><file name="system.xml" hash="63a9042dcf422feaeb4eb116b90313e2"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="emerchantpay"><dir name="info"><file name="checkout.phtml" hash="121f777049b801219f2792ca9aaedd3e"/><file name="direct.phtml" hash="121f777049b801219f2792ca9aaedd3e"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="emerchantpay"><dir name="form"><file name="checkout.phtml" hash="835a61d301f75e3d39a84ed412941ae0"/><file name="direct.phtml" hash="adbe6e9f00f15ea5db9de983cd6a7880"/></dir><dir name="info"><file name="checkout.phtml" hash="939277e4db9bda19b6932775a03fbaac"/><file name="direct.phtml" hash="939277e4db9bda19b6932775a03fbaac"/></dir><dir name="redirect"><file name="checkout.phtml" hash="caee38fbfc90ebc340730b83066486d3"/><file name="direct.phtml" hash="caee38fbfc90ebc340730b83066486d3"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="EMerchantPay_Genesis.xml" hash="83879cf40aba5587eecc86c162398e43"/></dir></target><target name="magelocale"><dir name="en_GB"><file name="EMerchantPay_Genesis.csv" hash="4bfb9000f103576377a939c945860e1c"/></dir><dir name="en_US"><file name="EMerchantPay_Genesis.csv" hash="4bfb9000f103576377a939c945860e1c"/></dir></target><target name="magelib"><dir name="Genesis"><dir name="src"><dir name="Genesis"><dir name="API"><dir name="Constants"><file name="Banks.php" hash="b7b1fc98be9aa2c0e2bd7c03086ca397"/><file name="Endpoints.php" hash="2036dc4c26f6e7418d5ce198170f96a1"/><file name="Environments.php" hash="4054e40a140cd9b4010a49e7928457f4"/><file name="Errors.php" hash="434b001eb137e74e654020d63b7c4f72"/><dir name="Payment"><file name="Methods.php" hash="de89e5298e49aea3f5eb8c9f89317576"/></dir><dir name="Transaction"><dir name="Parameters"><dir name="PayByVouchers"><file name="CardTypes.php" hash="d9e632a4b269948079af8f96bf3c56f1"/><file name="RedeemTypes.php" hash="ed1c30bc2b9cc435e7b66afad9ab3832"/></dir></dir><file name="States.php" hash="52a8c37ba2ab1597b928b5a4de89cdf3"/><file name="Types.php" hash="40db1b4803eb29d2987d1e7cef04230a"/></dir><file name="i18n.php" hash="577058e53e7c935e3e883fd4792ee548"/></dir><file name="Notification.php" hash="dfa03ae89de997ef9ac98ec08b51a3b5"/><dir name="Request"><dir name="Financial"><dir name="Alternatives"><file name="ABNiDEAL.php" hash="9ad0d2f75fcdf5b2cb94c78b3b3d6ea3"/><file name="CashU.php" hash="f28471dfff04de6e8e0c7b47aa1c08da"/><file name="POLi.php" hash="31ef3c44fa6c367f207c0633950ec8f1"/><file name="PPRO.php" hash="48ba59d3f53d5b15720b0b4f4e5fbc26"/><file name="Paysafecard.php" hash="83a298fd99434d6c207f1e1f23905061"/><file name="Sofort.php" hash="6cf9bcb7a47eb0ea7c1fa1e97ca5887c"/></dir><file name="Capture.php" hash="4074b82a2cd3ace1e655316c4dcc8064"/><dir name="Cards"><file name="Authorize.php" hash="f8cd42657ba5655af03de32c829f65ea"/><file name="Authorize3D.php" hash="57a35302fa7e08d72ec577169b64fd3c"/><file name="Credit.php" hash="a24fb37241999072f55319baf5056415"/><file name="Payout.php" hash="dae3a6cb34dc29dc583a8958a82e3628"/><dir name="Recurring"><file name="InitRecurringSale.php" hash="5903a5d82a5eceee4ac266099b708894"/><file name="InitRecurringSale3D.php" hash="ec06f91acaf4ad5d79682ec61058eac2"/><file name="RecurringSale.php" hash="324d2bf186578303a0ad084a78013051"/></dir><file name="Sale.php" hash="84b08a879c9f10b2c766a34de9878207"/><file name="Sale3D.php" hash="f6517e874dc37d123808bfa0ee5a5a1d"/></dir><dir name="PayByVouchers"><file name="Sale.php" hash="367c3036c60014aa0804ce22323001da"/><file name="oBeP.php" hash="af5b1586d15aed1b85defee8e6907d12"/></dir><file name="Refund.php" hash="399b75255fa787009e978053314a6925"/><file name="Void.php" hash="5d8d5744bb55bc4821a06f5b36ab29db"/><dir name="Wallets"><file name="Neteller.php" hash="404e7eb71cb655f9abbc0febb6783a1a"/><file name="WebMoney.php" hash="1a326d4502743c7c63c132e1911e9f78"/><file name="eZeeWallet.php" hash="6cb8d492a5ada59163f4cebad6b0d7dc"/></dir></dir><dir name="NonFinancial"><file name="AVS.php" hash="28c1506a04b88a6e0e3d19a27d00a335"/><file name="AccountVerification.php" hash="bc1e2775bef0a1f23345dac5b24b72f8"/><file name="Blacklist.php" hash="5da01bedc92c6979953d29901c3f113c"/><dir name="Fraud"><dir name="Chargeback"><file name="DateRange.php" hash="fb33c10f6375d145b5e159b883d37f3c"/><file name="Transaction.php" hash="eb8997ced7f9cc45b4df3056415dce3e"/></dir><dir name="Reports"><file name="DateRange.php" hash="53419659a6c5aff80edf0c7a31a31d31"/><file name="Transaction.php" hash="a8dd1ab07cca3537687c126572a39d25"/></dir><dir name="Retrieval"><file name="DateRange.php" hash="899f1bc77c47c6fde65451f2d2257a55"/><file name="Transaction.php" hash="73b7e9bfda8e385ea7dde1dab66bcb63"/></dir></dir><dir name="Reconcile"><file name="DateRange.php" hash="83d388eae9785c04ab2b961496faf490"/><file name="Transaction.php" hash="ed77990ff74e33faf4d26ba5e1cf7431"/></dir><dir name="Retrieve"><file name="AbniDealBanks.php" hash="0c0b187f29a20cf84550dc535e365a6b"/></dir></dir><dir name="WPF"><file name="Create.php" hash="169fdc03b480e6dd45ec54496c590b21"/><file name="Reconcile.php" hash="45aa4cd09b512b04a6b5a19c259d45ab"/></dir></dir><file name="Request.php" hash="590d63882937f1c558f1e31fe6add200"/><file name="Response.php" hash="59db1b505572d73f7ba5eb373eb18fde"/></dir><file name="Builder.php" hash="a1d259798cb8a118d59b2f3c5a313e3e"/><dir name="Builders"><file name="JSON.php" hash="387f44beabc6271d60cfdfa4de42b2b0"/><file name="XML.php" hash="c5dc6d4dcef1036c154e2833d21819c4"/></dir><dir name="Certificates"><file name="ca-bundle.pem" hash="1d4f036201f82a743da147db09a6d8ca"/></dir><file name="Config.php" hash="47d41b358bc7acaeed7492896e057536"/><dir name="Exceptions"><file name="EnvironmentNotSet.php" hash="a6f425cd8922b3615fa79cc9885328e9"/><file name="ErrorAPI.php" hash="f437c2e2423397ceaee0491e5e43d136"/><file name="ErrorNetwork.php" hash="ef4686482899ebfa53a79dd470fb751c"/><file name="ErrorParameter.php" hash="c9518f203b97e168c7db12e091635946"/><file name="InvalidArgument.php" hash="6c0f4c620ec5fda8cb46e3ff9c61d07d"/><file name="InvalidMethod.php" hash="f90abed4eb6a22d6c77da9a2c60ad5c9"/><file name="InvalidResponse.php" hash="0bab84b8816d83418062dc960648ca30"/></dir><file name="Genesis.php" hash="c14b9c20cbc534f09e891332a2794ded"/><dir name="Interfaces"><file name="Builder.php" hash="ce3aaa42bf5be788488142c420e2160f"/><file name="Network.php" hash="97f13f574a31683fd25c69b930a4b39d"/><file name="Parser.php" hash="391f365d54bfd245e901f56071238c0f"/></dir><dir name="Network"><file name="Stream.php" hash="36b286e49b6b998a883511f9902f8a5a"/><file name="cURL.php" hash="e3534bf2e3254343b0cd344d9eca6b77"/></dir><file name="Network.php" hash="9a7152dd32fee74a103e08eef03c7bbf"/><file name="Parser.php" hash="b32834c751a57c9cc2e971792d125aa0"/><dir name="Parsers"><file name="XML.php" hash="7c8c64ea006668a25b0aa0cb882425d7"/></dir><dir name="Utils"><file name="Common.php" hash="f669b461894af8650fe9af3d4b7b2f81"/><file name="Country.php" hash="53890c12438b00a5908d3a4f7f92c785"/><file name="Currency.php" hash="29fc4143a6ed046917fef3fd3286b811"/><file name="Requirements.php" hash="f2b8ab0a131e878ff35d30d7512dd133"/></dir></dir></dir><dir name="vendor"><file name="autoload.php" hash="59c384c9fd04a63a1609c0c507cdc384"/><dir name="composer"><file name="ClassLoader.php" hash="479613a7d15cfdf2bcdf0399a032ff9a"/><file name="LICENSE" hash="caa653f07bb161e830d67b0ab35dd642"/><file name="autoload_classmap.php" hash="8645d3a4e3ad87e7cf4d88a46717aab4"/><file name="autoload_namespaces.php" hash="af4fa780231e7182bbd1430a1973a21d"/><file name="autoload_psr4.php" hash="dd3a00f0d13eb29781edd8c77d4c5100"/><file name="autoload_real.php" hash="a80c290f6d5d3cc4b7d03108d55b36eb"/><file name="installed.json" hash="30a799458964967a17ca693a6b2d1c65"/></dir></dir></dir></target></contents>
20
  <compatible/>
21
  <dependencies><required><php><min>5.3.2</min><max>7.0.2</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.7</min><max/></package><extension><name>bcmath</name><min/><max/></extension><extension><name>curl</name><min/><max/></extension><extension><name>filter</name><min/><max/></extension><extension><name>hash</name><min/><max/></extension><extension><name>xmlreader</name><min/><max/></extension><extension><name>xmlwriter</name><min/><max/></extension></required></dependencies>
22
  </package>