PayEx_Payments - Version 3.1.0

Version Notes

Version 3.1.0
* Implemented PayEx Billing Agreement Method
* Removed PayEx AutoPay Method

Version 3.0.3
* Improvements of Social Security Number addon
* Improvements of Payment Fee feature
* Option: Perform validation of SSN before checkout
* Option: Discount calculation mode
* Option: Credit Check for Invoice method
* Removed unnecessary info that is presented to end user
* AutoPay frontend changes
* PartPayment fixes
* More descriptions for error codes
* Added Unit Tests

Version 3.0.2
* Social Security Number: Use secure base URL
* Added Missing Block: payex/invoice_totals_fee
* Fixed capturing
* Fixed invoicing
* Set to inactive status of payment methods by default
* Updated Px library

Version 3.0.1
* Implemented Swish Payment Method
* Financing Invoice: Invoice link
* Fixed payex account problem for multiple stores

Version 3.0.0
* Init release of PayEx Payments module
* Payment modules have been assembled in a single module
* Integrated "Social Security Number" module
* Implemented PayEx Faktura (Financing Invoice)
* Implemented PayEx Delbetala (PartPayment)
* Implemented PayEx Invoice (Ledger Service)
* Implemented MasterPass Payments
* Social Security Number: IWD_Opc support
* Taxable discounts
* Taxable fees
* Option: Send order lines and billing/delivery addresses to PayEx
* Option: Replace illegal characters of product names
* Tune: Use order_id instead customer_id for productNumber
* Improved Transaction Callback
* Install using modman
* Many various code changes and fixes
* Removed deprecated code

Version 2.0.31
* Fixed bug with wrong order state when capture via backend

Version 2.0.30
* Improved update checker

Version 2.0.29
* PayEx Payment Page 2.0 for 'Credit Card' and 'Direct Debit' views

Version 2.0.28
* Improved rounding issue workaround

Version 2.0.27
* Added Reward points support

Version 2.0.26
* Improved transaction processing
* Set correct order state
* Sending mail when failed payments

Version 2.0.25
* Fixed problem with handling of canceled transactions

Version 2.0.24
* Fixed problem "The transaction "xxx" (capture) is already closed"
* Removed unused functions
* Minor changes

Version 2.0.23
* Fixed problems with order state
* Small bugfixes

Version 2.0.22
* Fixed bug with empty invoice totals
* Updated Px library to 2.0.1

Version 2.0.21
* Fixed problem with empty TotalPaid value
* Fixed problem with empty tax for bundled product
* Small bugfixes
* Added version hint

Version 2.0.20
* Fixed problem with downloadable products

Version 2.0.19
* Fixed bug with multiple currencies setup
* Use Initialize8, Capture5, Credit5
* Updated Px library (moved to lib directory)
* Removed deprecated code
* Various bugfixes

Version 2.0.18
* Responsive Skinning

Version 2.0.17
* Fixed rounding issue

Version 2.0.16
* Added PayPal Payment View
* Saving the refunded/canceled/failed transactions.
* Verbose error messages
* Save cart when fails
* Updated translations
* Bugfixes

Version 2.0.15
* Fixed multi store support

Version 2.0.14
* Updated Payex Library

Version 2.0.13
* Enabled Partial Refund in Invoice

Version 2.0.12
* Fixed rounding error bug

Version 2.0.11
* Fixed CodeOrder_AmountNotEqualOrderLinesTotal

Version 2.0.10
* Fix amount bug in AddOrderLine function
* Fixed some bugs in order statuses

Version 2.0.9
* Fixed Tax Calc bug
* Fixed CodeOrder_AmountNotEqualOrderLinesTotal

Version 2.0.8
* Improved Order Info
* Added Order Info in PDF Invoice

Version 2.0.7
* Fixed bug with order (in sale mode the order is not finalized)
* Fixed bug with refund
* Moved design templates in base directory

Version 2.0.6
* Fixed bug with wrong capture/refund amount

Version 2.0.5
* Added options for cleaning time in Payment Config

Version 2.0.4
* Fixed Pending Order Cleaner bug

Version 2.0.3
* Many bugfixes

Version 2.0.2
* Division by zero fix (When Shipping is 0)

Version 2.0.1
* Rewrited API Helper

Version 2.0.0
* Changend namespace
* Rewrited payment engine
* Added Translations
* Bugfixes

Version 1.2.3-r20120329
* Added compatibility with AAIT PayEx Core

Version 1.2.3
* Small bugfixes

Version 1.2.2
* Fixed DirectDebit bug (Payment Cancel)
* Added option "Payment Type" in the settings panel.
* Small bugfixes

Version 1.2.1
* Small bugfixes

Version 1.2.0
* Required PayEx Core module v1.0.1
* Transaction fetching
* Bugfixes

Download this release

Release Info

Developer AAIT
Extension PayEx_Payments
Version 3.1.0
Comparing to
See all releases


Code changes from version 3.0.1 to 3.1.0

Files changed (122) hide show
  1. app/code/community/PayEx/Payments/Block/Checkout/Fee.php +46 -22
  2. app/code/community/PayEx/Payments/Block/Creditmemo/Totals/Fee.php +62 -0
  3. app/code/community/PayEx/Payments/Block/Form/Autopay.php +0 -10
  4. app/code/community/PayEx/Payments/Block/Form/Billing/Agreement.php +37 -0
  5. app/code/community/PayEx/Payments/Block/Form/CC.php +18 -0
  6. app/code/community/PayEx/Payments/Block/Info/Autopay.php +0 -94
  7. app/code/community/PayEx/Payments/Block/Info/Billing/Agreement.php +41 -0
  8. app/code/community/PayEx/Payments/Block/Invoice/Totals/Fee.php +75 -0
  9. app/code/community/PayEx/Payments/Block/Order/Totals/Fee.php +49 -15
  10. app/code/community/PayEx/Payments/Helper/Agreement.php +0 -48
  11. app/code/community/PayEx/Payments/Helper/Api.php +15 -4
  12. app/code/community/PayEx/Payments/Helper/Data.php +57 -1
  13. app/code/community/PayEx/Payments/Helper/Discount.php +45 -14
  14. app/code/community/PayEx/Payments/Helper/Fee.php +3 -1
  15. app/code/community/PayEx/Payments/Helper/Order.php +94 -49
  16. app/code/community/PayEx/Payments/Helper/Tools.php +7 -2
  17. app/code/community/PayEx/Payments/Model/Agreement.php +0 -10
  18. app/code/community/PayEx/Payments/Model/Creditmemo/Tax.php +49 -0
  19. app/code/community/PayEx/Payments/Model/Creditmemo/Total.php +45 -0
  20. app/code/community/PayEx/Payments/Model/Fee/Config.php +75 -0
  21. app/code/community/PayEx/Payments/Model/Invoice/Pdf/Total.php +99 -0
  22. app/code/community/PayEx/Payments/Model/Invoice/Tax.php +30 -0
  23. app/code/community/PayEx/Payments/Model/Invoice/Total.php +6 -17
  24. app/code/community/PayEx/Payments/Model/Mysql4/Agreement.php +0 -10
  25. app/code/community/PayEx/Payments/Model/Mysql4/Agreement/Collection.php +0 -10
  26. app/code/community/PayEx/Payments/Model/Observer.php +2 -2
  27. app/code/community/PayEx/Payments/Model/Payment/Agreement.php +457 -0
  28. app/code/community/PayEx/Payments/Model/Payment/Autopay.php +0 -422
  29. app/code/community/PayEx/Payments/Model/Payment/Bankdebit.php +4 -0
  30. app/code/community/PayEx/Payments/Model/Payment/CC.php +106 -27
  31. app/code/community/PayEx/Payments/Model/Payment/Financing.php +15 -1
  32. app/code/community/PayEx/Payments/Model/Payment/Invoice.php +9 -0
  33. app/code/community/PayEx/Payments/Model/Payment/MasterPass.php +4 -0
  34. app/code/community/PayEx/Payments/Model/Payment/PartPayment.php +16 -2
  35. app/code/community/PayEx/Payments/Model/Payment/Swish.php +4 -0
  36. app/code/community/PayEx/Payments/Model/Payment/Wywallet.php +4 -0
  37. app/code/community/PayEx/Payments/Model/Quote/Tax.php +90 -0
  38. app/code/community/PayEx/Payments/Model/Quote/Total.php +15 -42
  39. app/code/community/PayEx/Payments/Model/Source/DiscountCalculation.php +18 -0
  40. app/code/community/PayEx/Payments/Test/Block/Form/Bankdebit.php +32 -0
  41. app/code/community/PayEx/Payments/Test/Block/Form/CC.php +32 -0
  42. app/code/community/PayEx/Payments/Test/Block/Form/Financing.php +32 -0
  43. app/code/community/PayEx/Payments/Test/Block/Form/Invoice.php +32 -0
  44. app/code/community/PayEx/Payments/Test/Block/Form/MasterPass.php +32 -0
  45. app/code/community/PayEx/Payments/Test/Block/Form/PartPayment.php +32 -0
  46. app/code/community/PayEx/Payments/Test/Block/Form/Swish.php +32 -0
  47. app/code/community/PayEx/Payments/Test/Block/Form/Wywallet.php +32 -0
  48. app/code/community/PayEx/Payments/Test/Block/Info/Bankdebit.php +32 -0
  49. app/code/community/PayEx/Payments/Test/Block/Info/CC.php +32 -0
  50. app/code/community/PayEx/Payments/Test/Block/Info/MasterPass.php +32 -0
  51. app/code/community/PayEx/Payments/Test/Block/Info/PartPayment.php +32 -0
  52. app/code/community/PayEx/Payments/Test/Block/Info/Swish.php +32 -0
  53. app/code/community/PayEx/Payments/Test/Block/Info/Wywallet.php +32 -0
  54. app/code/community/PayEx/Payments/Test/Helper/Api.php +35 -0
  55. app/code/community/PayEx/Payments/Test/Helper/Order.php +40 -0
  56. app/code/community/PayEx/Payments/Test/Helper/Tools.php +61 -0
  57. app/code/community/PayEx/Payments/Test/Model/Payment/Bankdebit.php +61 -0
  58. app/code/community/PayEx/Payments/Test/Model/Payment/CC.php +61 -0
  59. app/code/community/PayEx/Payments/Test/Model/Payment/Financing.php +61 -0
  60. app/code/community/PayEx/Payments/Test/Model/Payment/Invoice.php +61 -0
  61. app/code/community/PayEx/Payments/Test/Model/Payment/MasterPass.php +61 -0
  62. app/code/community/PayEx/Payments/Test/Model/Payment/PartPayment.php +61 -0
  63. app/code/community/PayEx/Payments/Test/Model/Payment/Swish.php +61 -0
  64. app/code/community/PayEx/Payments/Test/Model/Payment/Wywallet.php +61 -0
  65. app/code/community/PayEx/Payments/controllers/AutopayController.php +0 -546
  66. app/code/community/PayEx/Payments/controllers/InvoiceController.php +16 -2
  67. app/code/community/PayEx/Payments/controllers/PaymentController.php +46 -1
  68. app/code/community/PayEx/Payments/data/payex_setup/data-upgrade-3.0.2-3.0.3.php +69 -0
  69. app/code/community/PayEx/Payments/data/payex_setup/data-upgrade-3.0.3-3.1.0.php +128 -0
  70. app/code/community/PayEx/Payments/etc/config.xml +81 -36
  71. app/code/community/PayEx/Payments/etc/system.xml +213 -160
  72. app/code/community/PayEx/Payments/sql/payex_setup/install-3.1.0.php +67 -0
  73. app/code/community/PayEx/Payments/sql/payex_setup/upgrade-3.0.2-3.0.3.php +46 -0
  74. app/design/adminhtml/default/default/layout/payex/payment_fee.xml +25 -0
  75. app/design/adminhtml/default/default/template/payex/billing/agreement/form.phtml +15 -0
  76. app/design/adminhtml/default/default/template/payex/billing/agreement/info.phtml +15 -0
  77. app/design/adminhtml/default/default/template/payex/financing/form.phtml +0 -19
  78. app/design/adminhtml/default/default/template/payex/invoice/form.phtml +0 -19
  79. app/design/adminhtml/default/default/template/payex/partpayment/form.phtml +0 -19
  80. app/design/frontend/base/default/layout/payex/social_security_number.xml +4 -0
  81. app/design/frontend/base/default/template/payex/billing/agreement/form.phtml +15 -0
  82. app/design/frontend/base/default/template/payex/billing/agreement/info.phtml +15 -0
  83. app/design/frontend/base/default/template/payex/cc/form.phtml +6 -0
  84. app/design/frontend/base/default/template/payex/cc/info.phtml +3 -0
  85. app/design/frontend/base/default/template/payex/cc/pdf/info.phtml +3 -0
  86. app/design/frontend/base/default/template/payex/checkout/fee.phtml +24 -28
  87. app/design/frontend/base/default/template/payex/checkout/onepage/billing_with_ssn.phtml +41 -17
  88. app/design/frontend/base/default/template/payex/financing/form.phtml +0 -19
  89. app/design/frontend/base/default/template/payex/financing/info.phtml +4 -0
  90. app/design/frontend/base/default/template/payex/financing/pdf/info.phtml +4 -0
  91. app/design/frontend/base/default/template/payex/invoice/form.phtml +0 -19
  92. app/design/frontend/base/default/template/payex/iwd_opc/billing_with_ssn.phtml +1 -1
  93. app/design/frontend/base/default/template/payex/partpayment/form.phtml +0 -19
  94. app/design/frontend/base/default/template/payex/partpayment/info.phtml +4 -0
  95. app/design/frontend/base/default/template/payex/partpayment/pdf/info.phtml +4 -0
  96. app/design/frontend/base/default/template/payex/swish/pdf/info.phtml +3 -0
  97. app/design/frontend/base/default/template/payex/wywallet/info.phtml +3 -0
  98. app/design/frontend/base/default/template/payex/wywallet/pdf/info.phtml +3 -0
  99. app/etc/modules/PayEx_Payments.xml +1 -1
  100. app/locale/sv_SE/PayEx_Payments.csv +32 -8
  101. js/payex/social_security_number.js +29 -6
  102. lib/PHP-Name-Parser/README.md +47 -0
  103. lib/PHP-Name-Parser/composer.json +12 -0
  104. lib/PHP-Name-Parser/examples.php +283 -0
  105. lib/{Px → PHP-Name-Parser}/parser.php +453 -388
  106. lib/PHP-Name-Parser/tests/FullNameParserTest.php +477 -0
  107. lib/PHP-Name-Parser/tests/phpunit.xml +27 -0
  108. lib/PHP-Name-Parser/tests/style.css +21 -0
  109. lib/PayEx.Ecommerce.Php/LICENSE +21 -0
  110. lib/PayEx.Ecommerce.Php/README.md +24 -0
  111. lib/PayEx.Ecommerce.Php/composer.json +19 -0
  112. lib/{Px → PayEx.Ecommerce.Php/src/PayEx}/Px.php +94 -71
  113. lib/PayEx.Ecommerce.Php/tests/.gitignore +1 -0
  114. lib/PayEx.Ecommerce.Php/tests/ExceptionTest.php +48 -0
  115. lib/PayEx.Ecommerce.Php/tests/PaymentTest.php +42 -0
  116. lib/PayEx.Ecommerce.Php/tests/SocialSecurityNumberTest.php +60 -0
  117. lib/PayEx.Ecommerce.Php/tests/TestCase.php +27 -0
  118. lib/PayEx.Ecommerce.Php/tests/bootstrap.php +15 -0
  119. lib/PayEx.Ecommerce.Php/tests/config.ini +4 -0
  120. lib/PayEx.Ecommerce.Php/tests/phpunit.xml +2 -0
  121. package.xml +30 -6
  122. skin/frontend/base/default/css/payex/social_security_number.css +28 -0
app/code/community/PayEx/Payments/Block/Checkout/Fee.php CHANGED
@@ -9,37 +9,61 @@ class PayEx_Payments_Block_Checkout_Fee extends Mage_Checkout_Block_Total_Defaul
9
  'payex_partpayment',
10
  'payex_invoice'
11
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  /**
14
- * Get Payment fee
15
- * @return float
16
  */
17
- public function getPaymentFee()
18
  {
19
- $paymentMethod = Mage::app()->getFrontController()->getRequest()->getParam('payment');
20
- $paymentMethod = Mage::app()->getStore()->isAdmin() && isset($paymentMethod['method']) ? $paymentMethod['method'] : null;
21
- if (!in_array($paymentMethod, self::$_allowed_methods) && (!count($this->getQuote()->getPaymentsCollection()) || !$this->getQuote()->getPayment()->hasMethodInstance())) {
22
- return $this;
23
- }
24
-
25
- $paymentMethod = $this->getQuote()->getPayment()->getMethodInstance();
26
- if (!in_array($paymentMethod->getCode(), self::$_allowed_methods)) {
27
- return $this;
28
- }
29
-
30
- $price = (float) $paymentMethod->getConfigData('paymentfee');
31
- $tax_class = $paymentMethod->getConfigData('paymentfee_tax_class');
32
- $fee = Mage::helper('payex/fee')->getPaymentFeePrice($price, $tax_class);
33
- return $fee;
34
  }
35
 
36
  /**
37
- * Get Quote
38
- * @return Mage_Sales_Model_Quote
39
  */
40
- public function getQuote()
41
  {
42
- return Mage::getModel('checkout/cart')->getQuote();
43
  }
44
 
45
  }
9
  'payex_partpayment',
10
  'payex_invoice'
11
  );
12
+
13
+ /**
14
+ * Get Payment Fee Incl Tax
15
+ * @return mixed
16
+ */
17
+ public function getPayExFeeIncludeTax()
18
+ {
19
+ return $this->getTotal()->getAddress()->getPayexPaymentFee() + $this->getTotal()->getAddress()->getPayexPaymentFeeTax();
20
+ }
21
+
22
+ /**
23
+ * Get Payment Fee Excl Tax
24
+ * @return mixed
25
+ */
26
+ public function getPayExFeeExcludeTax()
27
+ {
28
+ return $this->getTotal()->getAddress()->getPayexPaymentFee();
29
+ }
30
+
31
+ /**
32
+ * Check if display cart prices fee included and excluded tax
33
+ * @return mixed
34
+ */
35
+ public function displayCartPayExFeeBoth()
36
+ {
37
+ $config = Mage::getSingleton('payex/fee_config');
38
+ return $config->displayCartPayExFeeBoth($this->getStore());
39
+ }
40
+
41
+ /**
42
+ * Check if display cart prices fee included tax
43
+ * @return mixed
44
+ */
45
+ public function displayCartPayExFeeInclTax()
46
+ {
47
+ $config = Mage::getSingleton('payex/fee_config');
48
+ return $config->displayCartPayExFeeInclTax($this->getStore());
49
+ }
50
 
51
  /**
52
+ * Get "Exclude Tax" Label
53
+ * @return mixed
54
  */
55
+ public function getExcludeTaxLabel()
56
  {
57
+ return Mage::helper('tax')->getIncExcTaxLabel(false);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  }
59
 
60
  /**
61
+ * Get "Include Tax" Label
62
+ * @return mixed
63
  */
64
+ public function getIncludeTaxLabel()
65
  {
66
+ return Mage::helper('tax')->getIncExcTaxLabel(true);
67
  }
68
 
69
  }
app/code/community/PayEx/Payments/Block/Creditmemo/Totals/Fee.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Creditmemo_Totals_Fee extends Mage_Adminhtml_Block_Template
4
+ {
5
+ public function initTotals()
6
+ {
7
+ $parent = $this->getParentBlock();
8
+ if ($parent->getSource()->getBasePayexPaymentFee() > 0) {
9
+ if ($this->displaySalesPayExFeeBoth()) {
10
+ $total = new Varien_Object();
11
+ $total->setLabel(Mage::helper('payex')->__('Payment fee (Incl.Tax)'));
12
+ $total->setValue($parent->getSource()->getPayexPaymentFee() + $parent->getSource()->getPayexPaymentFeeTax());
13
+ $total->setBaseValue($parent->getSource()->getBasePayexPaymentFee() + $parent->getSource()->getBasePayexPaymentFeeTax());
14
+ $total->setCode('payex_payment_fee_with_tax');
15
+ $parent->addTotalBefore($total, 'shipping');
16
+
17
+ $total = new Varien_Object();
18
+ $total->setLabel(Mage::helper('payex')->__('Payment fee (Excl.Tax)'));
19
+ $total->setValue($parent->getSource()->getPayexPaymentFee());
20
+ $total->setBaseValue($parent->getSource()->getBasePayexPaymentFee());
21
+ $total->setCode('payex_payment_fee');
22
+ $parent->addTotalBefore($total, 'payex_payment_fee_with_tax');
23
+ } elseif ($this->displaySalesPayExFeeInclTax()) {
24
+ $total = new Varien_Object();
25
+ $total->setLabel(Mage::helper('payex')->__('Payment fee'));
26
+ $total->setValue($parent->getSource()->getPayexPaymentFee() + $parent->getSource()->getPayexPaymentFeeTax());
27
+ $total->setBaseValue($parent->getSource()->getBasePayexPaymentFee() + $parent->getSource()->getBasePayexPaymentFeeTax());
28
+ $total->setCode('payex_payment_fee_with_tax');
29
+ $parent->addTotalBefore($total, 'shipping');
30
+ } else {
31
+ $total = new Varien_Object();
32
+ $total->setLabel(Mage::helper('payex')->__('Payment fee'));
33
+ $total->setValue($parent->getSource()->getPayexPaymentFee());
34
+ $total->setBaseValue($parent->getSource()->getBasePayexPaymentFee());
35
+ $total->setCode('payex_payment_fee');
36
+ $parent->addTotalBefore($total, 'shipping');
37
+ }
38
+ }
39
+
40
+ return $this;
41
+ }
42
+
43
+ /**
44
+ * Check if display cart prices fee included and excluded tax
45
+ * @return mixed
46
+ */
47
+ public function displaySalesPayExFeeBoth()
48
+ {
49
+ $config = Mage::getSingleton('payex/fee_config');
50
+ return $config->displaySalesPayExFeeBoth($this->getParentBlock()->getSource()->getStoreId());
51
+ }
52
+
53
+ /**
54
+ * Check if display cart prices fee included tax
55
+ * @return mixed
56
+ */
57
+ public function displaySalesPayExFeeInclTax()
58
+ {
59
+ $config = Mage::getSingleton('payex/fee_config');
60
+ return $config->displaySalesPayExFeeInclTax($this->getParentBlock()->getSource()->getStoreId());
61
+ }
62
+ }
app/code/community/PayEx/Payments/Block/Form/Autopay.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
-
3
- class PayEx_Payments_Block_Form_Autopay extends Mage_Payment_Block_Form
4
- {
5
- protected function _construct()
6
- {
7
- parent::_construct();
8
- $this->setTemplate('payex/autopay/form.phtml');
9
- }
10
- }
 
 
 
 
 
 
 
 
 
 
app/code/community/PayEx/Payments/Block/Form/Billing/Agreement.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Form_Billing_Agreement extends Mage_Payment_Block_Form
4
+ {
5
+ /**
6
+ * Set custom template
7
+ *
8
+ */
9
+ public function __construct()
10
+ {
11
+ parent::__construct();
12
+ $this->setTemplate('payex/billing/agreement/form.phtml');
13
+ $this->setTransportName(Mage_Sales_Model_Payment_Method_Billing_AgreementAbstract::TRANSPORT_BILLING_AGREEMENT_ID);
14
+ }
15
+
16
+ /**
17
+ * Retrieve available customer billing agreements
18
+ *
19
+ * @return array
20
+ */
21
+ public function getBillingAgreements()
22
+ {
23
+ $data = array();
24
+ $quote = $this->getParentBlock()->getQuote();
25
+ if (!$quote || !$quote->getCustomer()) {
26
+ return $data;
27
+ }
28
+ $collection = Mage::getModel('sales/billing_agreement')->getAvailableCustomerBillingAgreements(
29
+ $quote->getCustomer()->getId()
30
+ );
31
+
32
+ foreach ($collection as $item) {
33
+ $data[$item->getId()] = $item->getAgreementLabel();
34
+ }
35
+ return $data;
36
+ }
37
+ }
app/code/community/PayEx/Payments/Block/Form/CC.php CHANGED
@@ -7,4 +7,22 @@ class PayEx_Payments_Block_Form_CC extends Mage_Payment_Block_Form
7
  parent::_construct();
8
  $this->setTemplate('payex/cc/form.phtml');
9
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  }
7
  parent::_construct();
8
  $this->setTemplate('payex/cc/form.phtml');
9
  }
10
+
11
+ /**
12
+ * Set data to block
13
+ *
14
+ * @return Mage_Core_Block_Abstract
15
+ */
16
+ protected function _beforeToHtml()
17
+ {
18
+ $customerId = Mage::getSingleton('customer/session')->getCustomerId();
19
+ if (
20
+ $customerId > 0 &&
21
+ Mage::helper('payex')->isBillingAgreementAvailable() &&
22
+ $this->canCreateBillingAgreement()
23
+ ) {
24
+ $this->setCreateBACode(PayEx_Payments_Model_Payment_Agreement::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);
25
+ }
26
+ return parent::_beforeToHtml();
27
+ }
28
  }
app/code/community/PayEx/Payments/Block/Info/Autopay.php DELETED
@@ -1,94 +0,0 @@
1
- <?php
2
-
3
- class PayEx_Payments_Block_Info_Autopay extends Mage_Payment_Block_Info
4
- {
5
- protected function _construct()
6
- {
7
- parent::_construct();
8
- $this->setTemplate('payex/autopay/info.phtml');
9
- // Template for Checkout page
10
- if ($this->getRequest()->getRequestedActionName() === 'progress') {
11
- $this->setTemplate('payex/autopay/title.phtml');
12
- }
13
- }
14
-
15
- /**
16
- * Returns code of payment method
17
- *
18
- * @return string
19
- */
20
- public function getMethodCode()
21
- {
22
- return $this->getInfo()->getMethodInstance()->getCode();
23
- }
24
-
25
- /**
26
- * Get some specific information in format of array($label => $value)
27
- *
28
- * @return array
29
- */
30
- public function getSpecificInformation()
31
- {
32
- // Get Payment Info
33
- $_info = $this->getInfo();
34
-
35
- // Transaction Fields
36
- $fields = array(
37
- 'PayEx Payment Method' => array('paymentMethod', 'cardProduct'),
38
- //'Masked Number' => array('maskedNumber', 'maskedCard'),
39
- //'Bank Hash' => array('BankHash', 'csId', 'panId'),
40
- 'Bank Reference' => array('bankReference'),
41
- 'Authenticated Status' => array('AuthenticatedStatus', 'authenticatedStatus'),
42
- 'Transaction Ref' => array('transactionRef'),
43
- 'PayEx Transaction Number' => array('transactionNumber'),
44
- 'PayEx Transaction Status' => array('transactionStatus'),
45
- 'Transaction Error Code' => array('transactionErrorCode'),
46
- 'Transaction Error Description' => array('transactionErrorDescription'),
47
- 'Transaction ThirdParty Error' => array('transactionThirdPartyError')
48
- );
49
-
50
- if ($_info) {
51
- $transactionId = $_info->getLastTransId();
52
-
53
- if ($transactionId) {
54
- // Load transaction
55
- $transaction = $_info->getTransaction($transactionId);
56
- if ($transaction) {
57
- $transaction_data = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
58
- if (!$transaction_data) {
59
- $payment = $_info->getOrder()->getPayment();
60
- $transaction_data = $payment->getMethodInstance()->fetchTransactionInfo($payment, $transactionId);
61
- $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $transaction_data);
62
- $transaction->save();
63
- }
64
-
65
- $result = array();
66
- foreach ($fields as $description => $list) {
67
- foreach ($list as $key => $value) {
68
- if (!empty($transaction_data[$value])) {
69
- $result[$description] = $transaction_data[$value];
70
- break;
71
- }
72
- }
73
- }
74
-
75
- return $result;
76
- }
77
- }
78
- }
79
-
80
- // @todo Info in email when invoicing
81
- return $this->_prepareSpecificInformation()->getData();
82
- }
83
-
84
- /**
85
- * Build PDF content of info block
86
- *
87
- * @return string
88
- */
89
- public function toPdf()
90
- {
91
- $this->setTemplate('payex/autopay/pdf/info.phtml');
92
- return $this->toHtml();
93
- }
94
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/PayEx/Payments/Block/Info/Billing/Agreement.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Info_Billing_Agreement extends Mage_Payment_Block_Info
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('payex/billing/agreement/info.phtml');
9
+ }
10
+
11
+ /**
12
+ * Add reference id to payment method information
13
+ * @param null $transport
14
+ * @return null|Varien_Object
15
+ */
16
+ protected function _prepareSpecificInformation($transport = null)
17
+ {
18
+ if (null !== $this->_paymentSpecificInformation) {
19
+ return $this->_paymentSpecificInformation;
20
+ }
21
+
22
+ $info = $this->getInfo();
23
+ $referenceID = $info->getAdditionalInformation(
24
+ Mage_Sales_Model_Payment_Method_Billing_AgreementAbstract::PAYMENT_INFO_REFERENCE_ID
25
+ );
26
+ $transport = new Varien_Object(array(
27
+ $this->__('Reference ID') => $referenceID,
28
+ ));
29
+ if (!empty($referenceID)) {
30
+ /** @var Mage_Sales_Model_Billing_Agreement $billing_agreement */
31
+ $billing_agreement = Mage::getModel('sales/billing_agreement')->load($referenceID, 'reference_id');
32
+ if ($billing_agreement->getId()) {
33
+ $transport->setData($this->__('Payment Method'), $billing_agreement->getAgreementLabel());
34
+ }
35
+ }
36
+
37
+ $transport = parent::_prepareSpecificInformation($transport);
38
+
39
+ return $transport;
40
+ }
41
+ }
app/code/community/PayEx/Payments/Block/Invoice/Totals/Fee.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Invoice_Totals_Fee extends Mage_Core_Block_Abstract
4
+ {
5
+ protected static $_allowed_methods = array(
6
+ 'payex_financing',
7
+ 'payex_partpayment',
8
+ 'payex_invoice'
9
+ );
10
+
11
+ public function initTotals()
12
+ {
13
+ $parent = $this->getParentBlock();
14
+ $invoice = $parent->getInvoice();
15
+ $paymentMethod = $invoice->getOrder()->getPayment()->getMethodInstance()->getCode();
16
+
17
+ if (!in_array($paymentMethod, self::$_allowed_methods)) {
18
+ return $this;
19
+ }
20
+
21
+ if ($invoice->getBasePayexPaymentFeeTax() > 0) {
22
+ if ($this->displaySalesPayExFeeBoth()) {
23
+ $total = new Varien_Object();
24
+ $total->setLabel(Mage::helper('payex')->__('Payment fee (Incl.Tax)'));
25
+ $total->setValue($invoice->getPayexPaymentFee() + $invoice->getPayexPaymentFeeTax());
26
+ $total->setBaseValue($invoice->getPayexBasePaymentFee() + $invoice->getPayexBasePaymentFeeTax());
27
+ $total->setCode('payex_payment_fee_with_tax');
28
+ $parent->addTotalBefore($total, 'tax');
29
+
30
+ $total = new Varien_Object();
31
+ $total->setLabel(Mage::helper('payex')->__('Payment fee (Excl.Tax)'));
32
+ $total->setValue($invoice->getPayexPaymentFee());
33
+ $total->setBaseValue($invoice->getPayexBasePaymentFee());
34
+ $total->setCode('payex_payment_fee');
35
+ $parent->addTotalBefore($total, 'payex_payment_fee_with_tax');
36
+ } elseif ($this->displaySalesPayExFeeInclTax()) {
37
+ $total = new Varien_Object();
38
+ $total->setLabel(Mage::helper('payex')->__('Payment fee'));
39
+ $total->setValue($invoice->getPayexPaymentFee() + $invoice->getPayexPaymentFeeTax());
40
+ $total->setBaseValue($invoice->getPayexBasePaymentFee() + $invoice->getPayexBasePaymentFeeTax());
41
+ $total->setCode('payex_payment_fee_with_tax');
42
+ $parent->addTotalBefore($total, 'tax');
43
+ } else {
44
+ $total = new Varien_Object();
45
+ $total->setLabel(Mage::helper('payex')->__('Payment fee'));
46
+ $total->setValue($invoice->getPayexPaymentFee());
47
+ $total->setBaseValue($invoice->getPayexBasePaymentFee());
48
+ $total->setCode('payex_payment_fee');
49
+ $parent->addTotalBefore($total, 'tax');
50
+ }
51
+ }
52
+
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * Check if display cart prices fee included and excluded tax
58
+ * @return mixed
59
+ */
60
+ public function displaySalesPayExFeeBoth()
61
+ {
62
+ $config = Mage::getSingleton('payex/fee_config');
63
+ return $config->displaySalesPayExFeeBoth($this->getParentBlock()->getInvoice()->getStoreId());
64
+ }
65
+
66
+ /**
67
+ * Check if display cart prices fee included tax
68
+ * @return mixed
69
+ */
70
+ public function displaySalesPayExFeeInclTax()
71
+ {
72
+ $config = Mage::getSingleton('payex/fee_config');
73
+ return $config->displaySalesPayExFeeInclTax($this->getParentBlock()->getInvoice()->getStoreId());
74
+ }
75
+ }
app/code/community/PayEx/Payments/Block/Order/Totals/Fee.php CHANGED
@@ -17,24 +17,58 @@ class PayEx_Payments_Block_Order_Totals_Fee extends Mage_Core_Block_Abstract
17
  return $this;
18
  }
19
 
20
- if ($parent->getOrder()->getBasePayexPaymentFeeTax()) {
21
- $total = new Varien_Object();
22
- $total->setLabel(Mage::helper('payex')->__('Payment fee (Incl.Tax)'));
23
- $total->setValue($parent->getOrder()->getPayexPaymentFee() + $parent->getOrder()->getPayexPaymentFeeTax());
24
- $total->setBaseValue($parent->getOrder()->getPayexBasePaymentFee() + $parent->getOrder()->getPayexBasePaymentFeeTax());
25
- $total->setCode('payex_payment_fee_with_tax');
26
- $parent->addTotalBefore($total, 'tax');
27
- }
28
 
29
- if ($parent->getOrder()->getBasePayexPaymentFee()) {
30
- $total = new Varien_Object();
31
- $total->setLabel(Mage::helper('payex')->__('Payment fee (Excl.Tax)'));
32
- $total->setValue($parent->getOrder()->getPayexPaymentFee());
33
- $total->setBaseValue($parent->getOrder()->getPayexBasePaymentFee());
34
- $total->setCode('payex_payment_fee');
35
- $parent->addTotalBefore($total, 'payex_payment_fee_with_tax');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  }
37
 
38
  return $this;
39
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  }
17
  return $this;
18
  }
19
 
20
+ if ($parent->getOrder()->getBasePayexPaymentFee() > 0) {
21
+ if ($this->displaySalesPayExFeeBoth()) {
22
+ $total = new Varien_Object();
23
+ $total->setLabel(Mage::helper('payex')->__('Payment fee (Incl.Tax)'));
24
+ $total->setValue($parent->getOrder()->getPayexPaymentFee() + $parent->getOrder()->getPayexPaymentFeeTax());
25
+ $total->setBaseValue($parent->getOrder()->getPayexBasePaymentFee() + $parent->getOrder()->getPayexBasePaymentFeeTax());
26
+ $total->setCode('payex_payment_fee_with_tax');
27
+ $parent->addTotalBefore($total, 'grand_total');
28
 
29
+ $total = new Varien_Object();
30
+ $total->setLabel(Mage::helper('payex')->__('Payment fee (Excl.Tax)'));
31
+ $total->setValue($parent->getOrder()->getPayexPaymentFee());
32
+ $total->setBaseValue($parent->getOrder()->getPayexBasePaymentFee());
33
+ $total->setCode('payex_payment_fee');
34
+ $parent->addTotalBefore($total, 'payex_payment_fee_with_tax');
35
+ } elseif ($this->displaySalesPayExFeeInclTax()) {
36
+ $total = new Varien_Object();
37
+ $total->setLabel(Mage::helper('payex')->__('Payment fee'));
38
+ $total->setValue($parent->getOrder()->getPayexPaymentFee() + $parent->getOrder()->getPayexPaymentFeeTax());
39
+ $total->setBaseValue($parent->getOrder()->getPayexBasePaymentFee() + $parent->getOrder()->getPayexBasePaymentFeeTax());
40
+ $total->setCode('payex_payment_fee_with_tax');
41
+ $parent->addTotalBefore($total, 'grand_total');
42
+ } else {
43
+ $total = new Varien_Object();
44
+ $total->setLabel(Mage::helper('payex')->__('Payment fee'));
45
+ $total->setValue($parent->getOrder()->getPayexPaymentFee());
46
+ $total->setBaseValue($parent->getOrder()->getPayexBasePaymentFee());
47
+ $total->setCode('payex_payment_fee');
48
+ $parent->addTotalBefore($total, 'grand_total');
49
+ }
50
  }
51
 
52
  return $this;
53
  }
54
+
55
+ /**
56
+ * Check if display cart prices fee included and excluded tax
57
+ * @return mixed
58
+ */
59
+ public function displaySalesPayExFeeBoth()
60
+ {
61
+ $config = Mage::getSingleton('payex/fee_config');
62
+ return $config->displaySalesPayExFeeBoth($this->getParentBlock()->getOrder()->getStore());
63
+ }
64
+
65
+ /**
66
+ * Check if display cart prices fee included tax
67
+ * @return mixed
68
+ */
69
+ public function displaySalesPayExFeeInclTax()
70
+ {
71
+ $config = Mage::getSingleton('payex/fee_config');
72
+ return $config->displaySalesPayExFeeInclTax($this->getParentBlock()->getOrder()->getStore());
73
+ }
74
  }
app/code/community/PayEx/Payments/Helper/Agreement.php DELETED
@@ -1,48 +0,0 @@
1
- <?php
2
-
3
- class PayEx_Payments_Helper_Agreement extends Mage_Core_Helper_Abstract
4
- {
5
- /**
6
- * Get Customer Agreement ID from Database
7
- * @return bool
8
- */
9
- public function getCustomerAgreement()
10
- {
11
- $customer_id = (Mage::getSingleton('customer/session')->isLoggedIn() == true) ? Mage::getSingleton('customer/session')->getCustomer()->getId() : '0';
12
- $agreement = Mage::getModel('payex/agreement')->load($customer_id, 'customer_id');
13
- return $agreement->getId() ? $agreement->getAgreementRef() : false;
14
- }
15
-
16
- /**
17
- * Check status Customer Agreement
18
- * @param $agreement_ref
19
- * @return bool | int
20
- */
21
- public function getPxAgreementStatus($agreement_ref)
22
- {
23
- if (!$agreement_ref) {
24
- return PayEx_Payments_Model_Payment_Autopay::AGREEMENT_NOTEXISTS;
25
- }
26
-
27
- // Init Environment
28
- Mage::getSingleton('payex/payment_autopay');
29
-
30
- // Call PxAgreement.AgreementCheck
31
- $params = array(
32
- 'accountNumber' => '',
33
- 'agreementRef' => $agreement_ref,
34
- );
35
- $result = Mage::helper('payex/api')->getPx()->AgreementCheck($params);
36
- Mage::helper('payex/tools')->debugApi($result, 'PxAgreement.AgreementCheck');
37
-
38
- // Check Errors
39
- if ($result['code'] !== 'OK' && $result['description'] !== 'OK') {
40
- return PayEx_Payments_Model_Payment_Autopay::AGREEMENT_NOTEXISTS;
41
- }
42
-
43
- $agreement_status = (int)$result['agreementStatus'];
44
- Mage::helper('payex/tools')->addToDebug('PxAgreement.AgreementCheck Status is ' . $agreement_status . ' (NotVerified = 0, Verified = 1, Deleted = 2)');
45
- return $agreement_status;
46
- }
47
-
48
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/PayEx/Payments/Helper/Api.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- require_once(Mage::getBaseDir('lib') . '/Px/Px.php');
4
 
5
  class PayEx_Payments_Helper_Api extends Mage_Core_Helper_Abstract
6
  {
@@ -9,14 +9,25 @@ class PayEx_Payments_Helper_Api extends Mage_Core_Helper_Abstract
9
  /**
10
  * Get PayEx Api Handler
11
  * @static
12
- * @return Px
13
  */
14
  public static function getPx()
15
  {
16
  // Use Singleton
17
  if (is_null(self::$_px)) {
18
- self::$_px = new Px();
 
 
 
 
 
 
 
 
 
 
 
19
  }
20
  return self::$_px;
21
  }
22
- }
1
  <?php
2
 
3
+ require_once(Mage::getBaseDir('lib') . '/PayEx.Ecommerce.Php/src/PayEx/Px.php');
4
 
5
  class PayEx_Payments_Helper_Api extends Mage_Core_Helper_Abstract
6
  {
9
  /**
10
  * Get PayEx Api Handler
11
  * @static
12
+ * @return PayEx\Px
13
  */
14
  public static function getPx()
15
  {
16
  // Use Singleton
17
  if (is_null(self::$_px)) {
18
+ self::$_px = new PayEx\Px();
19
+
20
+ // Set User Agent
21
+ $modules = Mage::getConfig()->getNode('modules')->children();
22
+ $modulesArray = (array)$modules;
23
+ self::$_px->setUserAgent(sprintf("PayEx.Ecommerce.Php/%s PHP/%s Magento%s/%s PayEx.Magento/%s",
24
+ \PayEx\Px::VERSION,
25
+ phpversion(),
26
+ Mage::getEdition(),
27
+ Mage::getVersion(),
28
+ (string)$modulesArray['PayEx_Payments']->version
29
+ ));
30
  }
31
  return self::$_px;
32
  }
33
+ }
app/code/community/PayEx/Payments/Helper/Data.php CHANGED
@@ -2,5 +2,61 @@
2
 
3
  class PayEx_Payments_Helper_Data extends Mage_Core_Helper_Abstract
4
  {
5
- //
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  }
2
 
3
  class PayEx_Payments_Helper_Data extends Mage_Core_Helper_Abstract
4
  {
5
+ /**
6
+ * Billing Agreement Config
7
+ */
8
+ const XML_PATH_PAYEX_BILLING_AGREEMENT = 'payment/payex_billing_agreement/active';
9
+
10
+ /**
11
+ * PayEx CC Payment View Config
12
+ */
13
+ const XML_PATH_PAYEX_CC_PAYMENT_VIEW = 'payment/payex_cc/paymentview';
14
+
15
+ /**
16
+ * Cache for shouldAskToCreateBillingAgreement()
17
+ *
18
+ * @var bool
19
+ */
20
+ protected static $_shouldAskToCreateBillingAgreement = null;
21
+
22
+ /**
23
+ * Check whether customer should be asked confirmation whether to sign a billing agreement
24
+ *
25
+ * @param int $customerId
26
+ * @return bool
27
+ */
28
+ public function shouldAskToCreateBillingAgreement($customerId)
29
+ {
30
+ if (null === self::$_shouldAskToCreateBillingAgreement) {
31
+ self::$_shouldAskToCreateBillingAgreement = false;
32
+ if ($customerId && $this->isBillingAgreementEnabled()) {
33
+ if (Mage::getModel('sales/billing_agreement')->needToCreateForCustomer($customerId)) {
34
+ self::$_shouldAskToCreateBillingAgreement = true;
35
+ }
36
+ }
37
+ }
38
+
39
+ return self::$_shouldAskToCreateBillingAgreement;
40
+ }
41
+
42
+ /**
43
+ * Check if Billing Agreement Enabled
44
+ * @param mixed $store
45
+ * @return bool
46
+ */
47
+ public function isBillingAgreementEnabled($store = null)
48
+ {
49
+ return (bool)Mage::getStoreConfig(self::XML_PATH_PAYEX_BILLING_AGREEMENT, $store);
50
+ }
51
+
52
+ /**
53
+ * Check if Billing Agreement Enabled
54
+ * @param mixed $store
55
+ * @return bool
56
+ */
57
+ public function isBillingAgreementAvailable($store = null)
58
+ {
59
+ return $this->isBillingAgreementEnabled($store) &&
60
+ Mage::getStoreConfig(self::XML_PATH_PAYEX_CC_PAYMENT_VIEW, $store) === 'CREDITCARD';
61
+ }
62
  }
app/code/community/PayEx/Payments/Helper/Discount.php CHANGED
@@ -42,9 +42,14 @@ class PayEx_Payments_Helper_Discount extends Mage_Core_Helper_Abstract
42
  */
43
  public function getDiscountData(Mage_Sales_Model_Quote $quote)
44
  {
45
- // if catalog-prices includes tax
46
- $CatPriceIncl = Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX);
 
 
 
 
47
 
 
48
  /** @var Mage_Sales_Model_Quote_Address $shippingAddress */
49
  $shippingAddress = $quote->getShippingAddress();
50
 
@@ -54,7 +59,7 @@ class PayEx_Payments_Helper_Discount extends Mage_Core_Helper_Abstract
54
  // find discount on the items
55
  foreach ($quote->getItemsCollection() as $item) {
56
  /** @var Mage_Sales_Model_Quote_Item $item */
57
- if (!$CatPriceIncl) {
58
  $discountExcl += $item->getDiscountAmount();
59
  $discountIncl += $item->getDiscountAmount() * (($item->getTaxPercent() / 100) + 1);
60
  } else {
@@ -64,7 +69,7 @@ class PayEx_Payments_Helper_Discount extends Mage_Core_Helper_Abstract
64
  }
65
 
66
  // find out tax-rate for the shipping
67
- if ((float)$shippingAddress->getShippingInclTax() && (float)$shippingAddress->getShippingAmount()) {
68
  $shippingTaxRate = $shippingAddress->getShippingInclTax() / $shippingAddress->getShippingAmount();
69
  } else {
70
  $shippingTaxRate = 1;
@@ -72,14 +77,14 @@ class PayEx_Payments_Helper_Discount extends Mage_Core_Helper_Abstract
72
 
73
  // how much differs between $discountExcl and total discount?
74
  // (the difference is due to discount on the shipping)
75
- if (!$CatPriceIncl) {
76
  $shippingDiscount = abs($quote->getShippingAddress()->getDiscountAmount()) - $discountExcl;
77
  } else {
78
  $shippingDiscount = abs($quote->getShippingAddress()->getDiscountAmount()) - $discountIncl;
79
  }
80
 
81
  // apply/remove tax to shipping-discount
82
- if (!$CatPriceIncl) {
83
  $discountIncl += $shippingDiscount * $shippingTaxRate;
84
  $discountExcl += $shippingDiscount;
85
  } else {
@@ -119,16 +124,21 @@ class PayEx_Payments_Helper_Discount extends Mage_Core_Helper_Abstract
119
  */
120
  public function getOrderDiscountData(Mage_Sales_Model_Order $order)
121
  {
122
- // if catalog-prices includes tax
123
- $CatPriceIncl = Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX, $order->getStore());
 
 
 
 
124
 
 
125
  $discountIncl = 0;
126
  $discountExcl = 0;
127
 
128
  // find discount on the items
129
  foreach ($order->getItemsCollection() as $item) {
130
  /** @var Mage_Sales_Model_Quote_Item $item */
131
- if (!$CatPriceIncl) {
132
  $discountExcl += $item->getDiscountAmount();
133
  $discountIncl += $item->getDiscountAmount() * (($item->getTaxPercent() / 100) + 1);
134
  } else {
@@ -138,7 +148,7 @@ class PayEx_Payments_Helper_Discount extends Mage_Core_Helper_Abstract
138
  }
139
 
140
  // find out tax-rate for the shipping
141
- if ((float)$order->getShippingInclTax() && (float)$order->getShippingAmount()) {
142
  $shippingTaxRate = $order->getShippingInclTax() / $order->getShippingAmount();
143
  } else {
144
  $shippingTaxRate = 1;
@@ -148,7 +158,7 @@ class PayEx_Payments_Helper_Discount extends Mage_Core_Helper_Abstract
148
  $shippingDiscount = (float)$order->getShippingDiscountAmount();
149
 
150
  // apply/remove tax to shipping-discount
151
- if (!$CatPriceIncl) {
152
  $discountIncl += $shippingDiscount * $shippingTaxRate;
153
  $discountExcl += $shippingDiscount;
154
  } else {
@@ -159,12 +169,33 @@ class PayEx_Payments_Helper_Discount extends Mage_Core_Helper_Abstract
159
  // Workaround: Apply Customer Tax: Before Discount + Apply Discount On Prices: Including Tax
160
  if (!Mage::helper('tax')->applyTaxAfterDiscount($order->getStore()) && Mage::helper('tax')->discountTax($order->getStore())) {
161
  // Use Discount + Tax to get correct discount for order total
162
- $discountVatPercent = round((($discountIncl / $discountExcl) - 1) * 100);
163
- $discountIncl = $discountExcl + $order->getTaxAmount();
164
- $discountExcl = $discountIncl / (($discountVatPercent / 100) + 1);
 
 
 
 
 
165
  }
166
 
167
  $return = new Varien_Object();
168
  return $return->setDiscountInclTax($discountIncl)->setDiscountExclTax($discountExcl);
169
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  }
42
  */
43
  public function getDiscountData(Mage_Sales_Model_Quote $quote)
44
  {
45
+ // Classic Mode
46
+ if ($this->getDiscountCalcMode($quote) === 'classic') {
47
+ $discount = -1 * ($quote->getDiscountAmount() + $quote->getShippingDiscountAmount());
48
+ $return = new Varien_Object();
49
+ return $return->setDiscountInclTax($discount)->setDiscountExclTax($discount);
50
+ }
51
 
52
+ // Advanced Mode
53
  /** @var Mage_Sales_Model_Quote_Address $shippingAddress */
54
  $shippingAddress = $quote->getShippingAddress();
55
 
59
  // find discount on the items
60
  foreach ($quote->getItemsCollection() as $item) {
61
  /** @var Mage_Sales_Model_Quote_Item $item */
62
+ if (!Mage::helper('tax')->priceIncludesTax($quote->getStore())) {
63
  $discountExcl += $item->getDiscountAmount();
64
  $discountIncl += $item->getDiscountAmount() * (($item->getTaxPercent() / 100) + 1);
65
  } else {
69
  }
70
 
71
  // find out tax-rate for the shipping
72
+ if ($shippingAddress->getShippingInclTax() > 0 && $shippingAddress->getShippingAmount() > 0) {
73
  $shippingTaxRate = $shippingAddress->getShippingInclTax() / $shippingAddress->getShippingAmount();
74
  } else {
75
  $shippingTaxRate = 1;
77
 
78
  // how much differs between $discountExcl and total discount?
79
  // (the difference is due to discount on the shipping)
80
+ if (!Mage::helper('tax')->shippingPriceIncludesTax($quote->getStore())) {
81
  $shippingDiscount = abs($quote->getShippingAddress()->getDiscountAmount()) - $discountExcl;
82
  } else {
83
  $shippingDiscount = abs($quote->getShippingAddress()->getDiscountAmount()) - $discountIncl;
84
  }
85
 
86
  // apply/remove tax to shipping-discount
87
+ if (!Mage::helper('tax')->priceIncludesTax($quote->getStore())) {
88
  $discountIncl += $shippingDiscount * $shippingTaxRate;
89
  $discountExcl += $shippingDiscount;
90
  } else {
124
  */
125
  public function getOrderDiscountData(Mage_Sales_Model_Order $order)
126
  {
127
+ // Classic Mode
128
+ if ($this->getDiscountCalcMode($order) === 'classic') {
129
+ $discount = -1 * ($order->getDiscountAmount() + $order->getShippingDiscountAmount());
130
+ $return = new Varien_Object();
131
+ return $return->setDiscountInclTax($discount)->setDiscountExclTax($discount);
132
+ }
133
 
134
+ // Advanced Mode
135
  $discountIncl = 0;
136
  $discountExcl = 0;
137
 
138
  // find discount on the items
139
  foreach ($order->getItemsCollection() as $item) {
140
  /** @var Mage_Sales_Model_Quote_Item $item */
141
+ if (!Mage::helper('tax')->priceIncludesTax($order->getStore())) {
142
  $discountExcl += $item->getDiscountAmount();
143
  $discountIncl += $item->getDiscountAmount() * (($item->getTaxPercent() / 100) + 1);
144
  } else {
148
  }
149
 
150
  // find out tax-rate for the shipping
151
+ if ($order->getShippingInclTax() > 0 && $order->getShippingAmount() > 0) {
152
  $shippingTaxRate = $order->getShippingInclTax() / $order->getShippingAmount();
153
  } else {
154
  $shippingTaxRate = 1;
158
  $shippingDiscount = (float)$order->getShippingDiscountAmount();
159
 
160
  // apply/remove tax to shipping-discount
161
+ if (!Mage::helper('tax')->shippingPriceIncludesTax($order->getStore())) {
162
  $discountIncl += $shippingDiscount * $shippingTaxRate;
163
  $discountExcl += $shippingDiscount;
164
  } else {
169
  // Workaround: Apply Customer Tax: Before Discount + Apply Discount On Prices: Including Tax
170
  if (!Mage::helper('tax')->applyTaxAfterDiscount($order->getStore()) && Mage::helper('tax')->discountTax($order->getStore())) {
171
  // Use Discount + Tax to get correct discount for order total
172
+ if ($discountExcl > 0) {
173
+ $discountVatPercent = round((($discountIncl / $discountExcl) - 1) * 100);
174
+ $discountIncl = $discountExcl + $order->getTaxAmount();
175
+ $discountExcl = $discountIncl / (($discountVatPercent / 100) + 1);
176
+ } else {
177
+ $discountIncl = 0;
178
+ $discountExcl = 0;
179
+ }
180
  }
181
 
182
  $return = new Varien_Object();
183
  return $return->setDiscountInclTax($discountIncl)->setDiscountExclTax($discountExcl);
184
  }
185
+
186
+ /**
187
+ * Get Discount Calculation Mode
188
+ * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $obj
189
+ * @return string
190
+ */
191
+ public function getDiscountCalcMode($obj)
192
+ {
193
+ $method = $obj->getPayment()->getMethodInstance();
194
+ $discount_calc = $method->getConfigData('discount_calc', $obj->getStoreId());
195
+ if (empty($discount_calc)) {
196
+ $discount_calc = 'advanced';
197
+ }
198
+
199
+ return $discount_calc;
200
+ }
201
  }
app/code/community/PayEx/Payments/Helper/Fee.php CHANGED
@@ -28,8 +28,10 @@ class PayEx_Payments_Helper_Fee extends Mage_Core_Helper_Abstract
28
  }
29
 
30
  $result = new Varien_Object();
31
- return $result->setPaymentFeePrice($fee)
 
32
  ->setPaymentFeeTax($taxAmount);
 
33
  }
34
 
35
  /**
28
  }
29
 
30
  $result = new Varien_Object();
31
+ $result->setPaymentFeeExclTax($fee)
32
+ ->setPaymentFeeInclTax($fee + $taxAmount)
33
  ->setPaymentFeeTax($taxAmount);
34
+ return $result;
35
  }
36
 
37
  /**
app/code/community/PayEx/Payments/Helper/Order.php CHANGED
@@ -110,48 +110,34 @@ class PayEx_Payments_Helper_Order extends Mage_Core_Helper_Abstract
110
 
111
  /**
112
  * Create Invoice
113
- * @param $order
114
  * @param bool $online
115
  * @return Mage_Sales_Model_Order_Invoice
116
  */
117
  public function makeInvoice(&$order, $online = false)
118
  {
119
  // Prepare Invoice
120
- $magento_version = Mage::getVersion();
121
- if (version_compare($magento_version, '1.4.2', '>=')) {
122
- $invoice = Mage::getModel('sales/order_invoice_api_v2');
123
- $invoice_id = $invoice->create($order->getIncrementId(), $order->getAllItems(), Mage::helper('payex')->__('Auto-generated from PayEx module'), false, false);
124
- $invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($invoice_id);
125
-
126
- if ($online) {
127
- $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
128
- $invoice->capture()->save();
129
- } else {
130
- $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
131
- $invoice->pay()->save();
132
- }
133
- } else {
134
- $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
135
- $invoice->addComment(Mage::helper('payex')->__('Auto-generated from PayEx module'), false, false);
136
- $invoice->setRequestedCaptureCase($online ? Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE : Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
137
- $invoice->register();
138
-
139
- $invoice->getOrder()->setIsInProcess(true);
140
-
141
- try {
142
- $transactionSave = Mage::getModel('core/resource_transaction')
143
- ->addObject($invoice)
144
- ->addObject($invoice->getOrder());
145
- $transactionSave->save();
146
- } catch (Mage_Core_Exception $e) {
147
- // Save Error Message
148
- $order->addStatusToHistory(
149
- $order->getStatus(),
150
- 'Failed to create invoice: ' . $e->getMessage(),
151
- true
152
- );
153
- Mage::throwException($e->getMessage());
154
- }
155
  }
156
 
157
  $invoice->setIsPaid(true);
@@ -371,11 +357,10 @@ class PayEx_Payments_Helper_Order extends Mage_Core_Helper_Abstract
371
 
372
  // add Discount
373
  $discountData = Mage::helper('payex/discount')->getOrderDiscountData($order);
374
- $discountInclTax = (int) (100 * $discountData->getDiscountInclTax());
375
- $discountExclTax = (int) (100 * $discountData->getDiscountExclTax());
376
- $discountVatAmount = $discountInclTax - $discountExclTax;
377
-
378
- if (abs($discountInclTax) > 0) {
379
  $discountVatPercent = (($discountInclTax / $discountExclTax) - 1) * 100;
380
 
381
  $params = array(
@@ -405,7 +390,7 @@ class PayEx_Payments_Helper_Order extends Mage_Core_Helper_Abstract
405
  $feeIncTax = $feeExclTax + $feeTax;
406
 
407
  // find out tax-rate for the fee
408
- if ((float) $feeIncTax && (float) $feeExclTax) {
409
  $feeTaxRate = Mage::app()->getStore()->roundPrice((($feeIncTax / $feeExclTax) - 1) * 100);
410
  } else {
411
  $feeTaxRate = 0;
@@ -648,7 +633,7 @@ class PayEx_Payments_Helper_Order extends Mage_Core_Helper_Abstract
648
  $feeIncTax = $feeExclTax + $feeTax;
649
 
650
  // find out tax-rate for the fee
651
- if ((float) $feeIncTax && (float) $feeExclTax) {
652
  $feeTaxRate = round((($feeIncTax / $feeExclTax) - 1) * 100);
653
  } else {
654
  $feeTaxRate = 0;
@@ -666,12 +651,11 @@ class PayEx_Payments_Helper_Order extends Mage_Core_Helper_Abstract
666
 
667
  // add Discount
668
  $discountData = Mage::helper('payex/discount')->getOrderDiscountData($order);
669
- $discountInclTax = $discountData->getDiscountInclTax();
670
- $discountExclTax = $discountData->getDiscountExclTax();
671
- $discountVatAmount = $discountInclTax - $discountExclTax;
672
- $discountVatPercent = round((($discountInclTax / $discountExclTax) - 1) * 100);
673
-
674
- if (abs($discountInclTax) > 0) {
675
  $discount_description = ($order->getDiscountDescription() !== null) ? Mage::helper('sales')->__('Discount (%s)', $order->getDiscountDescription()) : Mage::helper('sales')->__('Discount');
676
 
677
  $OrderLine = $dom->createElement('OrderLine');
@@ -727,4 +711,65 @@ class PayEx_Payments_Helper_Order extends Mage_Core_Helper_Abstract
727
  $result = Mage::helper('payex/api')->getPx()->InvoiceLinkGet($params);
728
  return $result;
729
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
730
  }
110
 
111
  /**
112
  * Create Invoice
113
+ * @param Mage_Sales_Model_Order $order
114
  * @param bool $online
115
  * @return Mage_Sales_Model_Order_Invoice
116
  */
117
  public function makeInvoice(&$order, $online = false)
118
  {
119
  // Prepare Invoice
120
+ /** @var Mage_Sales_Model_Order_Invoice $invoice */
121
+ $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
122
+ $invoice->addComment(Mage::helper('payex')->__('Auto-generated from PayEx module'), false, false);
123
+ $invoice->setRequestedCaptureCase($online ? Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE : Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
124
+ $invoice->register();
125
+
126
+ $invoice->getOrder()->setIsInProcess(true);
127
+
128
+ try {
129
+ $transactionSave = Mage::getModel('core/resource_transaction')
130
+ ->addObject($invoice)
131
+ ->addObject($invoice->getOrder());
132
+ $transactionSave->save();
133
+ } catch (Mage_Core_Exception $e) {
134
+ // Save Error Message
135
+ $order->addStatusToHistory(
136
+ $order->getStatus(),
137
+ 'Failed to create invoice: ' . $e->getMessage(),
138
+ true
139
+ );
140
+ Mage::throwException($e->getMessage());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  }
142
 
143
  $invoice->setIsPaid(true);
357
 
358
  // add Discount
359
  $discountData = Mage::helper('payex/discount')->getOrderDiscountData($order);
360
+ if (abs($discountData->getDiscountInclTax()) > 0) {
361
+ $discountInclTax = (int) (100 * $discountData->getDiscountInclTax());
362
+ $discountExclTax = (int) (100 * $discountData->getDiscountExclTax());
363
+ $discountVatAmount = $discountInclTax - $discountExclTax;
 
364
  $discountVatPercent = (($discountInclTax / $discountExclTax) - 1) * 100;
365
 
366
  $params = array(
390
  $feeIncTax = $feeExclTax + $feeTax;
391
 
392
  // find out tax-rate for the fee
393
+ if ($feeIncTax > 0 && $feeExclTax > 0) {
394
  $feeTaxRate = Mage::app()->getStore()->roundPrice((($feeIncTax / $feeExclTax) - 1) * 100);
395
  } else {
396
  $feeTaxRate = 0;
633
  $feeIncTax = $feeExclTax + $feeTax;
634
 
635
  // find out tax-rate for the fee
636
+ if ($feeIncTax > 0 && $feeExclTax > 0) {
637
  $feeTaxRate = round((($feeIncTax / $feeExclTax) - 1) * 100);
638
  } else {
639
  $feeTaxRate = 0;
651
 
652
  // add Discount
653
  $discountData = Mage::helper('payex/discount')->getOrderDiscountData($order);
654
+ if (abs($discountData->getDiscountInclTax()) > 0) {
655
+ $discountInclTax = $discountData->getDiscountInclTax();
656
+ $discountExclTax = $discountData->getDiscountExclTax();
657
+ $discountVatAmount = $discountInclTax - $discountExclTax;
658
+ $discountVatPercent = round((($discountInclTax / $discountExclTax) - 1) * 100);
 
659
  $discount_description = ($order->getDiscountDescription() !== null) ? Mage::helper('sales')->__('Discount (%s)', $order->getDiscountDescription()) : Mage::helper('sales')->__('Discount');
660
 
661
  $OrderLine = $dom->createElement('OrderLine');
711
  $result = Mage::helper('payex/api')->getPx()->InvoiceLinkGet($params);
712
  return $result;
713
  }
714
+
715
+ /**
716
+ * Extract Credit Card Details
717
+ * @param array $transaction
718
+ * @return Varien_Object
719
+ */
720
+ public function getCCDetails(array $transaction)
721
+ {
722
+ // Get Masked Credit Card Number
723
+ $masked_number = Mage::helper('payex')->__('Untitled Credit Card');
724
+ if (!empty($transaction['maskedNumber'])) {
725
+ $masked_number = $transaction['maskedNumber'];
726
+ } elseif (!empty($transaction['maskedCard'])) {
727
+ $masked_number = $transaction['maskedCard'];
728
+ }
729
+
730
+ // Get Card Type
731
+ $card_type = '';
732
+ if (!empty($transaction['cardProduct'])) {
733
+ $card_type = $transaction['cardProduct'];
734
+ } elseif (!empty( $transaction['paymentMethod'])) {
735
+ $card_type = $transaction['paymentMethod'];
736
+ }
737
+
738
+ /**
739
+ * Card types: VISA, MC (Mastercard), EUROCARD, MAESTRO, DINERS (Diners Club), AMEX (American Express), LIC,
740
+ * FDM, FORBRUGSFORENINGEN, JCB, FINAX, DANKORT
741
+ */
742
+ $card_type = strtolower(preg_replace('/[^A-Z]+/', '', $card_type));
743
+ $card_type = str_replace('mc', 'mastercard', $card_type);
744
+ if (empty($card_type)){
745
+ $card_type = 'visa';
746
+ }
747
+
748
+ // Get Expired
749
+ $expire_date = '';
750
+ if (!empty($transaction['paymentMethodExpireDate'])) {
751
+ $expire_date = $transaction['paymentMethodExpireDate'];
752
+ }
753
+
754
+ $return = new Varien_Object();
755
+ return $return->setMaskedNumber($masked_number)
756
+ ->setType($card_type)
757
+ ->setExpireDate($expire_date);
758
+ }
759
+
760
+ /**
761
+ * Get Formatted CC name
762
+ * Pattern: TYPE MASKED_NUMBER YYYY/MM
763
+ * @param array $transaction
764
+ * @return string
765
+ */
766
+ public function getFormattedCC(array $transaction)
767
+ {
768
+ $details = $this->getCCDetails($transaction);
769
+ return sprintf('%s %s %s', strtoupper(
770
+ $details->getType()),
771
+ $details->getMaskedNumber(),
772
+ date('Y/m', strtotime($details->getExpireDate()))
773
+ );
774
+ }
775
  }
app/code/community/PayEx/Payments/Helper/Tools.php CHANGED
@@ -98,7 +98,12 @@ class PayEx_Payments_Helper_Tools extends Mage_Core_Helper_Abstract
98
  'REJECTED_BY_ACQUIRER_INVALID_AMOUNT' => Mage::helper('payex')->__('Incorrect amount'),
99
  'USER_CANCELED' => Mage::helper('payex')->__('Payment cancelled'),
100
  'CardNotAcceptedForThisPurchase' => Mage::helper('payex')->__('Your Credit Card not accepted for this purchase'),
101
- 'CreditCheckNotApproved' => Mage::helper('payex')->__('Credit check was declined, please try another payment option')
 
 
 
 
 
102
  );
103
  $errorMessages = array_change_key_case($errorMessages, CASE_UPPER);
104
 
@@ -165,7 +170,7 @@ class PayEx_Payments_Helper_Tools extends Mage_Core_Helper_Abstract
165
  public function getNameParser()
166
  {
167
  if (!class_exists('FullNameParser', false)) {
168
- require_once Mage::getBaseDir('lib') . '/Px/parser.php';
169
  }
170
 
171
  return new FullNameParser();
98
  'REJECTED_BY_ACQUIRER_INVALID_AMOUNT' => Mage::helper('payex')->__('Incorrect amount'),
99
  'USER_CANCELED' => Mage::helper('payex')->__('Payment cancelled'),
100
  'CardNotAcceptedForThisPurchase' => Mage::helper('payex')->__('Your Credit Card not accepted for this purchase'),
101
+ 'CreditCheckNotApproved' => Mage::helper('payex')->__('Credit check was declined, please try another payment option'),
102
+ 'IssuerCountryNotSupported' => Mage::helper('payex')->__('Payment is not allowed from your country'),
103
+ 'FraudPatternDetected' => Mage::helper('payex')->__('Your payment has been flagged as possible fraud by the bank. The payment has been cancelled.'),
104
+ 'CardStoreTypeNotSupported' => Mage::helper('payex')->__('Your card is not accepted for this purchase'),
105
+ 'MaximumCountExceeded' => Mage::helper('payex')->__('The amount of allowed tries to pay was exceeded. Please wait a couple of hours and try again.'),
106
+ 'CommunicationError' => Mage::helper('payex')->__('There is a technical problem with communication to the bank. Please try again later.'),
107
  );
108
  $errorMessages = array_change_key_case($errorMessages, CASE_UPPER);
109
 
170
  public function getNameParser()
171
  {
172
  if (!class_exists('FullNameParser', false)) {
173
+ require_once Mage::getBaseDir('lib') . '/PHP-Name-Parser/parser.php';
174
  }
175
 
176
  return new FullNameParser();
app/code/community/PayEx/Payments/Model/Agreement.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
-
3
- class PayEx_Payments_Model_Agreement extends Mage_Core_Model_Abstract
4
- {
5
- public function _construct()
6
- {
7
- parent::_construct();
8
- $this->_init('payex/agreement');
9
- }
10
- }
 
 
 
 
 
 
 
 
 
 
app/code/community/PayEx/Payments/Model/Creditmemo/Tax.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Creditmemo_Tax extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract
4
+ {
5
+ protected static $_allowed_methods = array(
6
+ 'payex_financing',
7
+ 'payex_partpayment',
8
+ 'payex_invoice'
9
+ );
10
+
11
+ public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
12
+ {
13
+ $order = $creditmemo->getOrder();
14
+ $paymentMethod = $order->getPayment()->getMethodInstance()->getCode();
15
+ if (!in_array($paymentMethod, self::$_allowed_methods)) {
16
+ return $this;
17
+ }
18
+
19
+ $creditmemoBaseGrandTotal = $creditmemo->getBaseGrandTotal();
20
+ $creditmemoGrandTotal = $creditmemo->getGrandTotal();
21
+ $creditmemoBaseTaxAmount = $creditmemo->getBaseTaxAmount();
22
+ $creditmemoTaxAmount = $creditmemo->getTaxAmount();
23
+
24
+ $basePayexPaymentFeeTaxRefunded = $order->getBasePayexPaymentFeeTaxRefunded();
25
+ $payexPaymentFeeTaxRefunded = $order->getPayexPaymentFeeTaxRefunded();
26
+
27
+ $basePayexPaymentFeeTaxInvoiced = $order->getBasePayexPaymentFeeTaxInvoiced();
28
+ $payexPaymentFeeTaxInvoiced = $order->getPayexPaymentFeeTaxInvoiced();
29
+
30
+ $basePayexPaymentFeeTaxToRefund = abs($basePayexPaymentFeeTaxInvoiced - $basePayexPaymentFeeTaxRefunded);
31
+ $payexPaymentFeeTaxToRefund = abs($payexPaymentFeeTaxInvoiced - $payexPaymentFeeTaxRefunded);
32
+
33
+ if ($basePayexPaymentFeeTaxToRefund <= 0) {
34
+ return $this;
35
+ }
36
+
37
+ $creditmemo->setBaseGrandTotal($creditmemoBaseGrandTotal + $basePayexPaymentFeeTaxToRefund)
38
+ ->setGrandTotal($creditmemoGrandTotal + $payexPaymentFeeTaxToRefund)
39
+ ->setBaseTaxAmount($creditmemoBaseTaxAmount + $basePayexPaymentFeeTaxToRefund)
40
+ ->setTaxAmount($creditmemoTaxAmount + $payexPaymentFeeTaxToRefund)
41
+ ->setBasePayexPaymentFeeTax($basePayexPaymentFeeTaxToRefund)
42
+ ->setPayexPaymentFeeTax($payexPaymentFeeTaxToRefund);
43
+
44
+ $order->setBasePayexPaymentFeeTaxRefunded($basePayexPaymentFeeTaxRefunded + $basePayexPaymentFeeTaxToRefund)
45
+ ->setPayexPaymentFeeTaxRefunded($payexPaymentFeeTaxRefunded + $payexPaymentFeeTaxToRefund);
46
+
47
+ return $this;
48
+ }
49
+ }
app/code/community/PayEx/Payments/Model/Creditmemo/Total.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Creditmemo_Total extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract
4
+ {
5
+ protected static $_allowed_methods = array(
6
+ 'payex_financing',
7
+ 'payex_partpayment',
8
+ 'payex_invoice'
9
+ );
10
+
11
+ public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
12
+ {
13
+ $order = $creditmemo->getOrder();
14
+ $paymentMethod = $order->getPayment()->getMethodInstance()->getCode();
15
+ if (!in_array($paymentMethod, self::$_allowed_methods)) {
16
+ return $this;
17
+ }
18
+
19
+ $creditmemoBaseGrandTotal = $creditmemo->getBaseGrandTotal();
20
+ $creditmemoGrandTotal = $creditmemo->getGrandTotal();
21
+
22
+ $basePayexPaymentFeeRefunded = $order->getBasePayexPaymentFeeRefunded();
23
+ $payexPaymentFeeRefunded = $order->getPayexPaymentFeeRefunded();
24
+
25
+ $basePayexPaymentFeeInvoiced = $order->getBasePayexPaymentFeeInvoiced();
26
+ $payexPaymentFeeInvoiced = $order->getPayexPaymentFeeInvoiced();
27
+
28
+ $basePayexPaymentFeeToRefund = abs($basePayexPaymentFeeInvoiced - $basePayexPaymentFeeRefunded);
29
+ $payexPaymentFeeToRefund = abs($payexPaymentFeeInvoiced - $payexPaymentFeeRefunded);
30
+
31
+ if ($payexPaymentFeeToRefund <= 0) {
32
+ return $this;
33
+ }
34
+
35
+ $creditmemo->setBaseGrandTotal($creditmemoBaseGrandTotal + $payexPaymentFeeToRefund)
36
+ ->setGrandTotal($creditmemoGrandTotal + $payexPaymentFeeToRefund)
37
+ ->setBasePayexPaymentFee($basePayexPaymentFeeToRefund)
38
+ ->setPayexPaymentFee($payexPaymentFeeToRefund);
39
+
40
+ $order->setBasePayexPaymentFeeRefunded($basePayexPaymentFeeRefunded + $basePayexPaymentFeeToRefund)
41
+ ->setPayexPaymentFeeRefunded($payexPaymentFeeRefunded + $payexPaymentFeeToRefund);
42
+
43
+ return $this;
44
+ }
45
+ }
app/code/community/PayEx/Payments/Model/Fee/Config.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Fee_Config extends Mage_Tax_Model_Config
4
+ {
5
+ /**
6
+ * Shopping cart display settings
7
+ */
8
+ const XML_PATH_DISPLAY_CART_PAYEX_FEE = 'tax/cart_display/payex_fee';
9
+
10
+ /**
11
+ * Shopping cart display settings
12
+ */
13
+ const XML_PATH_DISPLAY_SALES_PAYEX_FEE = 'tax/sales_display/payex_fee';
14
+
15
+ /**
16
+ * Check if display cart prices fee included tax
17
+ * @param mixed $store
18
+ * @return bool
19
+ */
20
+ public function displayCartPayExFeeInclTax($store = null)
21
+ {
22
+ return Mage::getStoreConfig(self::XML_PATH_DISPLAY_CART_PAYEX_FEE, $store) == self::DISPLAY_TYPE_INCLUDING_TAX;
23
+ }
24
+
25
+ /**
26
+ * Check if display cart prices fee excluded tax
27
+ * @param mixed $store
28
+ * @return bool
29
+ */
30
+ public function displayCartPayExFeeExclTax($store = null)
31
+ {
32
+ return Mage::getStoreConfig(self::XML_PATH_DISPLAY_CART_PAYEX_FEE, $store) == self::DISPLAY_TYPE_EXCLUDING_TAX;
33
+ }
34
+
35
+ /**
36
+ * Check if display cart prices fee included and excluded tax
37
+ * @param mixed $store
38
+ * @return bool
39
+ */
40
+ public function displayCartPayExFeeBoth($store = null)
41
+ {
42
+ return Mage::getStoreConfig(self::XML_PATH_DISPLAY_CART_PAYEX_FEE, $store) == self::DISPLAY_TYPE_BOTH;
43
+ }
44
+
45
+ /**
46
+ * Check if display sales prices fee included tax
47
+ * @param mixed $store
48
+ * @return bool
49
+ */
50
+ public function displaySalesPayExFeeInclTax($store = null)
51
+ {
52
+ return Mage::getStoreConfig(self::XML_PATH_DISPLAY_SALES_PAYEX_FEE, $store) == self::DISPLAY_TYPE_INCLUDING_TAX;
53
+ }
54
+
55
+ /**
56
+ * Check if display sales prices fee excluded tax
57
+ * @param mixed $store
58
+ * @return bool
59
+ */
60
+ public function displaySalesPayExFeeExclTax($store = null)
61
+ {
62
+ return Mage::getStoreConfig(self::XML_PATH_DISPLAY_SALES_PAYEX_FEE, $store) == self::DISPLAY_TYPE_EXCLUDING_TAX;
63
+ }
64
+
65
+ /**
66
+ * Check if display sales prices fee included and excluded tax
67
+ * @param mixed $store
68
+ * @return bool
69
+ */
70
+ public function displaySalesPayExFeeBoth($store = null)
71
+ {
72
+ return Mage::getStoreConfig(self::XML_PATH_DISPLAY_SALES_PAYEX_FEE, $store) == self::DISPLAY_TYPE_BOTH;
73
+ }
74
+ }
75
+
app/code/community/PayEx/Payments/Model/Invoice/Pdf/Total.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Invoice_Pdf_Total extends Mage_Sales_Model_Order_Pdf_Total_Default
4
+ {
5
+ /**
6
+ * Get array of arrays with totals information for display in PDF
7
+ * array(
8
+ * $index => array(
9
+ * 'amount' => $amount,
10
+ * 'label' => $label,
11
+ * 'font_size'=> $font_size
12
+ * )
13
+ * )
14
+ * @return array
15
+ */
16
+ public function getTotalsForDisplay()
17
+ {
18
+ $fontSize = $this->getFontSize() ? $this->getFontSize() : 7;
19
+ $amountInclTax = $this->getAmount() + $this->getOrder()->getPayexPaymentFeeTax();
20
+ $amountExclTax = $this->getAmount();
21
+
22
+ if ($this->displaySalesPayExFeeBoth()) {
23
+ $totals = array(
24
+ array(
25
+ 'amount' => $this->getAmountPrefix() . $this->getOrder()->formatPriceTxt($amountInclTax) ,
26
+ 'label' => Mage::helper('payex')->__('Payment fee (Incl.Tax)') . ':',
27
+ 'font_size' => $fontSize
28
+ ),
29
+ array(
30
+ 'amount' => $this->getAmountPrefix() . $this->getOrder()->formatPriceTxt($amountExclTax),
31
+ 'label' => Mage::helper('payex')->__('Payment fee (Excl.Tax)') . ':',
32
+ 'font_size' => $fontSize
33
+ )
34
+ );
35
+ } elseif ($this->displaySalesPayExFeeInclTax()) {
36
+ $totals = array(
37
+ array(
38
+ 'amount' => $this->getAmountPrefix() . $this->getOrder()->formatPriceTxt($amountInclTax) ,
39
+ 'label' => Mage::helper('payex')->__('Payment fee') . ':',
40
+ 'font_size' => $fontSize
41
+ )
42
+ );
43
+ } else {
44
+ $totals = array(
45
+ array(
46
+ 'amount' => $this->getAmountPrefix() . $this->getOrder()->formatPriceTxt($amountExclTax),
47
+ 'label' => Mage::helper('payex')->__('Payment fee') . ':',
48
+ 'font_size' => $fontSize
49
+ )
50
+ );
51
+ }
52
+
53
+ return $totals;
54
+ }
55
+
56
+ /**
57
+ * Check if we can display total information in PDF
58
+ * @return bool
59
+ */
60
+ public function canDisplay()
61
+ {
62
+ $amount = $this->getAmount();
63
+ return ($this->getDisplayZero() || ($amount != 0));
64
+ }
65
+
66
+ /**
67
+ * Get Total amount from source
68
+ * @return float
69
+ */
70
+ public function getAmount()
71
+ {
72
+ $fee = $this->getOrder()->getPayexPaymentFee();
73
+ if (!$fee){
74
+ return 0;
75
+ }
76
+
77
+ return $fee;
78
+ }
79
+
80
+ /**
81
+ * Check if display cart prices fee included and excluded tax
82
+ * @return mixed
83
+ */
84
+ public function displaySalesPayExFeeBoth()
85
+ {
86
+ $config = Mage::getSingleton('payex/fee_config');
87
+ return $config->displaySalesPayExFeeBoth($this->getOrder()->getStore());
88
+ }
89
+
90
+ /**
91
+ * Check if display cart prices fee included tax
92
+ * @return mixed
93
+ */
94
+ public function displaySalesPayExFeeInclTax()
95
+ {
96
+ $config = Mage::getSingleton('payex/fee_config');
97
+ return $config->displaySalesPayExFeeInclTax($this->getOrder()->getStore());
98
+ }
99
+ }
app/code/community/PayEx/Payments/Model/Invoice/Tax.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Invoice_Tax extends Mage_Sales_Model_Order_Invoice_Total_Abstract
4
+ {
5
+ protected static $_allowed_methods = array(
6
+ 'payex_financing',
7
+ 'payex_partpayment',
8
+ 'payex_invoice'
9
+ );
10
+
11
+ public function collect(Mage_Sales_Model_Order_Invoice $invoice)
12
+ {
13
+ $order = $invoice->getOrder();
14
+ $paymentMethod = $order->getPayment()->getMethodInstance()->getCode();
15
+ if (!in_array($paymentMethod, self::$_allowed_methods)) {
16
+ return $this;
17
+ }
18
+
19
+ if ($order->getBasePayexPaymentFeeTax()) {
20
+ $invoice->setBaseTaxAmount($invoice->getBaseTaxAmount() + $order->getBasePayexPaymentFeeTax());
21
+ $invoice->setTaxAmount($invoice->getTaxAmount() + $order->getPayexPaymentFeeTax());
22
+
23
+ $invoice->setBasePayexPaymentFeeTax($order->getBasePayexPaymentFeeTax());
24
+ $invoice->setPayexPaymentFeeTax($order->getPayexPaymentFeeTax());
25
+
26
+ $order->setBasePayexPaymentFeeTaxInvoiced($order->getBasePayexPaymentFeeTax());
27
+ $order->setPayexPaymentFeeTaxInvoiced($order->getPayexPaymentFeeTax());
28
+ }
29
+ }
30
+ }
app/code/community/PayEx/Payments/Model/Invoice/Total.php CHANGED
@@ -17,25 +17,14 @@ class PayEx_Payments_Model_Invoice_Total extends Mage_Sales_Model_Order_Invoice_
17
  }
18
 
19
  if ($order->getBasePayexPaymentFee()) {
20
- $baseInvoiceTotal = $invoice->getBaseGrandTotal();
21
- $invoiceTotal = $invoice->getGrandTotal();
22
 
23
- $baseInvoiceTotal = $baseInvoiceTotal + $order->getBasePayexPaymentFee();
24
- $invoiceTotal = $invoiceTotal + $order->getPayexPaymentFee();
25
 
26
- $invoice->setBaseGrandTotal($baseInvoiceTotal);
27
- $invoice->setGrandTotal($invoiceTotal);
28
- }
29
-
30
- if ($order->getBasePayexPaymentFeeTax()) {
31
- $baseInvoiceTotal = $invoice->getBaseGrandTotal();
32
- $invoiceTotal = $invoice->getGrandTotal();
33
-
34
- $baseInvoiceTotal = $baseInvoiceTotal + $order->getBasePayexPaymentFeeTax();
35
- $invoiceTotal = $invoiceTotal + $order->getPayexPaymentFeeTax();
36
-
37
- $invoice->setBaseGrandTotal($baseInvoiceTotal);
38
- $invoice->setGrandTotal($invoiceTotal);
39
  }
40
  }
41
  }
17
  }
18
 
19
  if ($order->getBasePayexPaymentFee()) {
20
+ $invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $order->getBasePayexPaymentFee());
21
+ $invoice->setGrandTotal($invoice->getGrandTotal() + $order->getPayexPaymentFee());
22
 
23
+ $invoice->setBasePayexPaymentFee($order->getBasePayexPaymentFee());
24
+ $invoice->setPayexPaymentFee($order->getPayexPaymentFee());
25
 
26
+ $order->setBasePayexPaymentFeeInvoiced($order->getBasePayexPaymentFee());
27
+ $order->setPayexPaymentFeeInvoiced($order->getPayexPaymentFee());
 
 
 
 
 
 
 
 
 
 
 
28
  }
29
  }
30
  }
app/code/community/PayEx/Payments/Model/Mysql4/Agreement.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
-
3
- class PayEx_Payments_Model_Mysql4_Agreement extends Mage_Core_Model_Mysql4_Abstract
4
- {
5
- public function _construct()
6
- {
7
- // Note that "agreement_id" refers to the key field in your database table.
8
- $this->_init('payex/payex_agreement', 'agreement_id');
9
- }
10
- }
 
 
 
 
 
 
 
 
 
 
app/code/community/PayEx/Payments/Model/Mysql4/Agreement/Collection.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
-
3
- class PayEx_Payments_Model_Mysql4_Agreement_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
- {
5
- public function _construct()
6
- {
7
- parent::_construct();
8
- $this->_init('payex/agreement');
9
- }
10
- }
 
 
 
 
 
 
 
 
 
 
app/code/community/PayEx/Payments/Model/Observer.php CHANGED
@@ -108,7 +108,7 @@ class PayEx_Payments_Model_Observer extends Mage_Core_Model_Abstract
108
  */
109
  public function sales_quote_collect_totals_after(Varien_Event_Observer $observer)
110
  {
111
- $quote = $observer->getEvent()->getQuote();
112
  $quote->setBasePayexPaymentFee(0);
113
  $quote->setBasePayexPaymentFeeTax(0);
114
  $quote->setPayexPaymentFee(0);
@@ -119,7 +119,7 @@ class PayEx_Payments_Model_Observer extends Mage_Core_Model_Abstract
119
  $quote->setBasePayexPaymentFeeTax((float)($quote->getBasePayexPaymentFeeTax() + $address->getBasePayexPaymentFeeTax()));
120
  $quote->setPayexPaymentFee((float)($quote->getPayexPaymentFee() + $address->getPayexPaymentFee()));
121
  $quote->setPayexPaymentFeeTax((float)($quote->getPayexPaymentFeeTax() + $address->getPayexPaymentFeeTax()));
122
- }
123
  return $this;
124
  }
125
 
108
  */
109
  public function sales_quote_collect_totals_after(Varien_Event_Observer $observer)
110
  {
111
+ /* $quote = $observer->getEvent()->getQuote();
112
  $quote->setBasePayexPaymentFee(0);
113
  $quote->setBasePayexPaymentFeeTax(0);
114
  $quote->setPayexPaymentFee(0);
119
  $quote->setBasePayexPaymentFeeTax((float)($quote->getBasePayexPaymentFeeTax() + $address->getBasePayexPaymentFeeTax()));
120
  $quote->setPayexPaymentFee((float)($quote->getPayexPaymentFee() + $address->getPayexPaymentFee()));
121
  $quote->setPayexPaymentFeeTax((float)($quote->getPayexPaymentFeeTax() + $address->getPayexPaymentFeeTax()));
122
+ } */
123
  return $this;
124
  }
125
 
app/code/community/PayEx/Payments/Model/Payment/Agreement.php ADDED
@@ -0,0 +1,457 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Payment_Agreement extends Mage_Sales_Model_Payment_Method_Billing_AgreementAbstract
4
+ implements Mage_Payment_Model_Billing_Agreement_MethodInterface
5
+ {
6
+
7
+ /**
8
+ * Billing Agreement Method Code
9
+ */
10
+ const METHOD_BILLING_AGREEMENT = 'payex_billing_agreement';
11
+
12
+ /**
13
+ * PayEx Billing Agreement Flag
14
+ */
15
+ const PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT = 'payex_create_ba';
16
+
17
+ /**
18
+ * PayEx Billing Agreement Reference
19
+ */
20
+ const PAYMENT_INFO_TRANSPORT_AGREEMENT_REFERENCE = 'payex_agreement_reference';
21
+
22
+ /**
23
+ * Agreement Verification Codes
24
+ */
25
+ const AGREEMENT_NOTVERIFIED = 0;
26
+ const AGREEMENT_VERIFIED = 1;
27
+ const AGREEMENT_DELETED = 2;
28
+ const AGREEMENT_NOTEXISTS = 3;
29
+
30
+ /**
31
+ * Method code
32
+ * @var string
33
+ */
34
+ protected $_code = self::METHOD_BILLING_AGREEMENT;
35
+
36
+ /**
37
+ * Method instance settings
38
+ */
39
+ protected $_canAuthorize = true;
40
+ protected $_canCapture = true;
41
+ protected $_canCapturePartial = true;
42
+ protected $_canRefund = true;
43
+ protected $_canRefundInvoicePartial = true;
44
+ protected $_canVoid = true;
45
+ protected $_canUseCheckout = false;
46
+ protected $_canUseInternal = false;
47
+ protected $_isInitializeNeeded = true;
48
+ protected $_canFetchTransactionInfo = true;
49
+ protected $_canReviewPayment = false;
50
+
51
+ /**
52
+ * Payment method blocks
53
+ */
54
+ protected $_infoBlockType = 'payex/info_billing_agreement';
55
+ protected $_formBlockType = 'payex/form_billing_agreement';
56
+
57
+ /**
58
+ * PayEx Payments CC Model
59
+ * @var PayEx_Payments_Model_Payment_CC
60
+ */
61
+ protected $_cc = null;
62
+
63
+ /**
64
+ * Initialize PayEx_Payments_Model_Payment_CC model
65
+ *
66
+ * @param array $params
67
+ */
68
+ public function __construct($params = array())
69
+ {
70
+ $this->_cc = Mage::helper('payment')->getMethodInstance(PayEx_Payments_Model_Payment_CC::METHOD_CODE);
71
+ }
72
+
73
+ /**
74
+ * Store setter
75
+ * Also updates store ID in config object
76
+ * @param Mage_Core_Model_Store|int $store $store
77
+ * @return $this
78
+ */
79
+ public function setStore($store)
80
+ {
81
+ $this->setData('store', $store);
82
+ if (null === $store) {
83
+ $store = Mage::app()->getStore()->getId();
84
+ }
85
+
86
+ $this->_cc->setStore(!is_object($store) ? Mage::app()->getStore($store) : $store);
87
+ return $this;
88
+ }
89
+
90
+ /**
91
+ * Get config action to process initialization
92
+ * @return string
93
+ */
94
+ public function getConfigPaymentAction()
95
+ {
96
+ $paymentAction = $this->getConfigData('payment_action');
97
+ return empty($paymentAction) ? true : $paymentAction;
98
+ }
99
+
100
+ /**
101
+ * Check whether payment method can be used
102
+ * @param Mage_Sales_Model_Quote $quote
103
+ * @return bool
104
+ */
105
+ public function isAvailable($quote = null)
106
+ {
107
+ if (parent::isAvailable($quote) === false) {
108
+ return false;
109
+ }
110
+
111
+ return $this->_cc->isAvailable($quote);
112
+ }
113
+
114
+ /**
115
+ * Instantiate state and set it to state object
116
+ * @param $paymentAction
117
+ * @param $stateObject
118
+ * @return $this
119
+ */
120
+ public function initialize($paymentAction, $stateObject)
121
+ {
122
+ Mage::helper('payex/tools')->addToDebug('Action: Initialize');
123
+
124
+ /** @var Mage_Payment_Model_Info $info */
125
+ $info = $this->getInfoInstance();
126
+
127
+ /** @var Mage_Sales_Model_Order $order */
128
+ $order = $info->getOrder();
129
+
130
+ $order_id = $order->getIncrementId();
131
+
132
+ // Get Currency code
133
+ $currency_code = $order->getOrderCurrency()->getCurrencyCode();
134
+
135
+ // Get Operation Type (AUTHORIZATION / SALE)
136
+ $operation = ($this->getConfigData('transactiontype') == 0) ? 'AUTHORIZATION' : 'SALE';
137
+
138
+ // Get Amount
139
+ //$amount = $order->getGrandTotal();
140
+ $amount = Mage::helper('payex/order')->getCalculatedOrderAmount($order)->getAmount();
141
+
142
+ // Agreement Reference
143
+ $agreement_reference = $info->getAdditionalInformation(self::PAYMENT_INFO_REFERENCE_ID);
144
+
145
+ /** @var Mage_Sales_Model_Billing_Agreement $billing_agreement */
146
+ $billing_agreement = Mage::getModel('sales/billing_agreement')->load($agreement_reference, 'reference_id');
147
+ if (!$billing_agreement->getId()) {
148
+ $message = Mage::helper('payex')->__('Wrong Agreement Reference');
149
+ Mage::throwException($message);
150
+ return $this;
151
+ }
152
+
153
+ // Verify Agreement Status
154
+ // Call PxAgreement.AgreementCheck
155
+ $params = array(
156
+ 'accountNumber' => '',
157
+ 'agreementRef' => $billing_agreement->getReferenceId(),
158
+ );
159
+ $result = Mage::helper('payex/api')->getPx()->AgreementCheck($params);
160
+ Mage::helper('payex/tools')->debugApi($result, 'PxAgreement.AgreementCheck');
161
+ if ($result['code'] !== 'OK' && $result['description'] !== 'OK') {
162
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
163
+ Mage::throwException($message);
164
+ return $this;
165
+ }
166
+
167
+ // Check is verified
168
+ if ((int)$result['agreementStatus'] !== self::AGREEMENT_VERIFIED) {
169
+ $message = Mage::helper('payex')->__('This agreement is invalid');
170
+ Mage::throwException($message);
171
+ return $this;
172
+ }
173
+
174
+ // Call PxAgreement.AutoPay3
175
+ $params = array(
176
+ 'accountNumber' => '',
177
+ 'agreementRef' => $billing_agreement->getReferenceId(),
178
+ 'price' => round($amount * 100),
179
+ 'productNumber' => $order_id,
180
+ 'description' => Mage::app()->getStore()->getName(),
181
+ 'orderId' => $order_id,
182
+ 'purchaseOperation' => $operation,
183
+ 'currency' => $currency_code
184
+ );
185
+ $result = Mage::helper('payex/api')->getPx()->AutoPay3($params);
186
+ Mage::helper('payex/tools')->debugApi($result, 'PxAgreement.AutoPay3');
187
+ if ($result['errorCodeSimple'] !== 'OK') {
188
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
189
+ Mage::throwException($message);
190
+ return $this;
191
+ }
192
+
193
+ // Validate transactionStatus value
194
+ if (!isset($result['transactionStatus']) || !is_numeric($result['transactionStatus'])) {
195
+ // AutoPay: No transactionsStatus in response
196
+ Mage::helper('payex/tools')->addToDebug('Error: No transactionsStatus in response.', $order->getIncrementId());
197
+ $message = Mage::helper('payex')->__('Payment failed. Invalid transaction status');
198
+ Mage::throwException($message);
199
+ return $this;
200
+ }
201
+
202
+ // Save Order
203
+ $order->save();
204
+
205
+ // Register Transaction
206
+ $transaction_id = isset($result['transactionNumber']) ? $result['transactionNumber'] : null;
207
+ $transaction_status = isset($result['transactionStatus']) ? (int)$result['transactionStatus'] : null;
208
+
209
+ $order->getPayment()->setTransactionId($transaction_id);
210
+ $transaction = Mage::helper('payex/order')->processPaymentTransaction($order, $result);
211
+
212
+ // Set Last Transaction ID
213
+ $order->getPayment()->setLastTransId($transaction_id)->save();
214
+
215
+ // Add Order Relation
216
+ if ($billing_agreement->getId()) {
217
+ //$billing_agreement->addOrderRelation($order->getId())->save();
218
+ $billing_agreement->getResource()->addOrderRelation($billing_agreement->getId(), $order->getId());
219
+ }
220
+
221
+ /* Transaction statuses: 0=Sale, 1=Initialize, 2=Credit, 3=Authorize, 4=Cancel, 5=Failure, 6=Capture */
222
+ switch ($transaction_status) {
223
+ case 1:
224
+ case 3:
225
+ // Payment authorized
226
+ $message = Mage::helper('payex')->__('Payment has been authorized');
227
+
228
+ // Change order status
229
+ $new_status = $this->_cc->getConfigData('order_status_authorize');
230
+
231
+ /** @var Mage_Sales_Model_Order_Status $status */
232
+ $status = Mage::helper('payex/order')->getAssignedStatus($new_status);
233
+ $order->setData('state', $status->getState());
234
+ $order->setStatus($status->getStatus());
235
+ $order->save();
236
+ $order->addStatusHistoryComment($message);
237
+
238
+ // Set state object
239
+ /** @var Mage_Sales_Model_Order_Status $status */
240
+ $status = Mage::helper('payex/order')->getAssignedStatus($new_status);
241
+ $stateObject->setState($status->getState());
242
+ $stateObject->setStatus($status->getStatus());
243
+ $stateObject->setIsNotified(true);
244
+ break;
245
+ case 0:
246
+ case 6:
247
+ // Payment captured
248
+ $message = Mage::helper('payex')->__('Payment has been captured');
249
+
250
+ // Change order status
251
+ $new_status = $this->_cc->getConfigData('order_status_capture');
252
+
253
+ /** @var Mage_Sales_Model_Order_Status $status */
254
+ $status = Mage::helper('payex/order')->getAssignedStatus($new_status);
255
+ $order->setData('state', $status->getState());
256
+ $order->setStatus($status->getStatus());
257
+ $order->save();
258
+ $order->addStatusHistoryComment($message);
259
+
260
+ // Set state object
261
+ $stateObject->setState($status->getState());
262
+ $stateObject->setStatus($status->getStatus());
263
+ $stateObject->setIsNotified(true);
264
+
265
+ // Create Invoice for Sale Transaction
266
+ $invoice = Mage::helper('payex/order')->makeInvoice($order, false);
267
+ $invoice->setTransactionId($result['transactionNumber']);
268
+ $invoice->save();
269
+ break;
270
+ case 2:
271
+ case 4:
272
+ case 5:
273
+ if ($transaction_status === 2) {
274
+ $message = Mage::helper('payex')->__('Detected an abnormal payment process (Transaction Status: %s).', $transaction_status);
275
+ } elseif ($transaction_status === 4) {
276
+ $message = Mage::helper('payex')->__('Order automatically canceled.');
277
+ } else {
278
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
279
+ }
280
+
281
+ // Cancel order
282
+ $order->cancel();
283
+ $order->addStatusHistoryComment($message);
284
+ $order->save();
285
+
286
+ // Set state object
287
+ /** @var Mage_Sales_Model_Order_Status $status */
288
+ $status = Mage::helper('payex/order')->getAssignedStatus(Mage_Sales_Model_Order::STATE_CANCELED);
289
+ $stateObject->setState($status->getState());
290
+ $stateObject->setStatus($status->getStatus());
291
+ $stateObject->setIsNotified(true);
292
+
293
+ Mage::throwException($message);
294
+ break;
295
+ default:
296
+ // Invalid transaction status
297
+ $message = Mage::helper('payex')->__('Invalid transaction status.');
298
+
299
+ // Cancel order
300
+ $order->cancel();
301
+ $order->addStatusHistoryComment($message);
302
+ $order->save();
303
+
304
+ // Set state object
305
+ /** @var Mage_Sales_Model_Order_Status $status */
306
+ $status = Mage::helper('payex/order')->getAssignedStatus(Mage_Sales_Model_Order::STATE_CANCELED);
307
+ $stateObject->setState($status->getState());
308
+ $stateObject->setStatus($status->getStatus());
309
+ $stateObject->setIsNotified(true);
310
+
311
+ Mage::throwException($message);
312
+ break;
313
+ }
314
+
315
+ return $this;
316
+ }
317
+
318
+ /**
319
+ * Init billing agreement
320
+ * @param Mage_Payment_Model_Billing_AgreementAbstract $agreement
321
+ * @return $this
322
+ */
323
+ public function initBillingAgreementToken(Mage_Payment_Model_Billing_AgreementAbstract $agreement)
324
+ {
325
+ return $this;
326
+ }
327
+
328
+ /**
329
+ * Retrieve billing agreement customer details by token
330
+ * @param Mage_Payment_Model_Billing_AgreementAbstract $agreement
331
+ * @return array
332
+ */
333
+ public function getBillingAgreementTokenInfo(Mage_Payment_Model_Billing_AgreementAbstract $agreement)
334
+ {
335
+ // Verify Agreement Status
336
+ // Call PxAgreement.AgreementCheck
337
+ $params = array(
338
+ 'accountNumber' => '',
339
+ 'agreementRef' => $agreement->getReferenceId(),
340
+ );
341
+ $result = Mage::helper('payex/api')->getPx()->AgreementCheck($params);
342
+ Mage::helper('payex/tools')->debugApi($result, 'PxAgreement.AgreementCheck');
343
+ if ($result['code'] !== 'OK' && $result['description'] !== 'OK') {
344
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
345
+ Mage::throwException($message);
346
+ return $this;
347
+ }
348
+
349
+ $responseData = array(
350
+ 'agreement_status' => (int)$result['agreementStatus'],
351
+ );
352
+ $agreement->addData($responseData);
353
+ return $responseData;
354
+ }
355
+
356
+ /**
357
+ * Create billing agreement by token specified in request
358
+ * @param Mage_Payment_Model_Billing_AgreementAbstract $agreement
359
+ * @return $this
360
+ */
361
+ public function placeBillingAgreement(Mage_Payment_Model_Billing_AgreementAbstract $agreement)
362
+ {
363
+ return $this;
364
+ }
365
+
366
+ /**
367
+ * Update billing agreement status
368
+ * @param Mage_Payment_Model_Billing_AgreementAbstract $agreement
369
+ * @return $this
370
+ */
371
+ public function updateBillingAgreementStatus(Mage_Payment_Model_Billing_AgreementAbstract $agreement)
372
+ {
373
+ switch ($agreement->getStatus()) {
374
+ case (Mage_Sales_Model_Billing_Agreement::STATUS_CANCELED):
375
+ // Call PxAgreement.DeleteAgreement
376
+ $params = array(
377
+ 'accountNumber' => '',
378
+ 'agreementRef' => $agreement->getReferenceId(),
379
+ );
380
+
381
+ $result = Mage::helper('payex/api')->getPx()->DeleteAgreement($params);
382
+ Mage::helper('payex/tools')->debugApi($result, 'PxAgreement.DeleteAgreement');
383
+ if ($result['code'] !== 'OK' || $result['description'] !== 'OK') {
384
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
385
+ Mage::throwException($message);
386
+ }
387
+ break;
388
+ default:
389
+ // no break
390
+ }
391
+
392
+ return $this;
393
+ }
394
+
395
+ /**
396
+ * Capture payment
397
+ * @param Varien_Object $payment
398
+ * @param $amount
399
+ * @return $this
400
+ */
401
+ public function capture(Varien_Object $payment, $amount)
402
+ {
403
+ return $this->_cc->capture($payment, $amount);
404
+ }
405
+
406
+ /**
407
+ * Cancel payment
408
+ * @param Varien_Object $payment
409
+ * @return $this
410
+ */
411
+ public function cancel(Varien_Object $payment)
412
+ {
413
+ return $this->_cc->cancel($payment);
414
+ }
415
+
416
+ /**
417
+ * Refund capture
418
+ * @param Varien_Object $payment
419
+ * @param $amount
420
+ * @return $this
421
+ */
422
+ public function refund(Varien_Object $payment, $amount)
423
+ {
424
+ return $this->_cc->refund($payment, $amount);
425
+ }
426
+
427
+ /**
428
+ * Void payment
429
+ * @param Varien_Object $payment
430
+ * @return $this
431
+ */
432
+ public function void(Varien_Object $payment)
433
+ {
434
+ return $this->_cc->void($payment);
435
+ }
436
+
437
+ /**
438
+ * Fetch transaction details info
439
+ * @param Mage_Payment_Model_Info $payment
440
+ * @param string $transactionId
441
+ * @return array
442
+ */
443
+ public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
444
+ {
445
+ return $this->_cc->fetchTransactionInfo($payment, $transactionId);
446
+ }
447
+
448
+ /**
449
+ * @param Mage_Sales_Model_Quote $quote
450
+ * @return bool
451
+ */
452
+ protected function _isAvailable($quote)
453
+ {
454
+ return true;
455
+ }
456
+
457
+ }
app/code/community/PayEx/Payments/Model/Payment/Autopay.php DELETED
@@ -1,422 +0,0 @@
1
- <?php
2
-
3
- class PayEx_Payments_Model_Payment_Autopay extends PayEx_Payments_Model_Payment_Abstract
4
- {
5
- /**
6
- * Payment method code
7
- */
8
- public $_code = 'payex_autopay';
9
-
10
- /**
11
- * Availability options
12
- */
13
- protected $_isGateway = true;
14
- protected $_canAuthorize = true;
15
- protected $_canCapture = true;
16
- protected $_canCapturePartial = false;
17
- protected $_canRefund = true;
18
- protected $_canRefundInvoicePartial = true;
19
- protected $_canVoid = true;
20
- protected $_canUseInternal = true;
21
- protected $_canUseCheckout = true;
22
- protected $_canUseForMultishipping = false;
23
- protected $_canFetchTransactionInfo = true;
24
-
25
- /**
26
- * Payment method blocks
27
- */
28
- protected $_infoBlockType = 'payex/info_autopay';
29
- protected $_formBlockType = 'payex/form_autopay';
30
-
31
- const AGREEMENT_NOTVERIFIED = 0;
32
- const AGREEMENT_VERIFIED = 1;
33
- const AGREEMENT_DELETED = 2;
34
- const AGREEMENT_NOTEXISTS = 3;
35
-
36
- /**
37
- * Get initialized flag status
38
- * @return true
39
- */
40
- public function isInitializeNeeded()
41
- {
42
- return true;
43
- }
44
-
45
- /**
46
- * Instantiate state and set it to state onject
47
- * @param $paymentAction
48
- * @param $stateObject
49
- * @return void
50
- */
51
- public function initialize($paymentAction, $stateObject)
52
- {
53
- // Set Initial Order Status
54
- $state = Mage_Sales_Model_Order::STATE_NEW;
55
- $stateObject->setState($state);
56
- $stateObject->setStatus($state);
57
- $stateObject->setIsNotified(false);
58
- }
59
-
60
- /**
61
- * Get config action to process initialization
62
- * @return string
63
- */
64
- public function getConfigPaymentAction()
65
- {
66
- $paymentAction = $this->getConfigData('payment_action');
67
- return empty($paymentAction) ? true : $paymentAction;
68
- }
69
-
70
- /**
71
- * Check whether payment method can be used
72
- * @param Mage_Sales_Model_Quote $quote
73
- * @return bool
74
- */
75
- public function isAvailable($quote = null)
76
- {
77
- // is Disabled
78
- if (parent::isAvailable($quote) === false) {
79
- return false;
80
- }
81
-
82
- if (Mage::app()->getStore()->isAdmin() == true) {
83
- return true; // Available for Admin only
84
- }
85
-
86
- // Check currency
87
- $allowedCurrency = array('DKK', 'EUR', 'GBP', 'NOK', 'SEK', 'USD');
88
- if (!in_array($quote->getQuoteCurrencyCode(), $allowedCurrency)) {
89
- return false;
90
- }
91
-
92
- // Available only for Logged
93
- return Mage::getSingleton('customer/session')->isLoggedIn();
94
- }
95
-
96
- /**
97
- * Validate
98
- * @return bool
99
- */
100
- public function validate()
101
- {
102
- Mage::helper('payex/tools')->addToDebug('Action: Validate');
103
- return parent::validate();
104
- }
105
-
106
- /**
107
- * Get the redirect url
108
- * @return string
109
- */
110
- public function getOrderPlaceRedirectUrl()
111
- {
112
- Mage::helper('payex/tools')->addToDebug('Action: getOrderPlaceRedirectUrl');
113
- return Mage::getUrl('payex/autopay/autopay', array('_secure' => true));
114
- }
115
-
116
- /**
117
- * Capture payment
118
- * @param Varien_Object $payment
119
- * @param $amount
120
- * @return $this
121
- */
122
- public function capture(Varien_Object $payment, $amount)
123
- {
124
- Mage::helper('payex/tools')->addToDebug('Action: Capture');
125
-
126
- parent::capture($payment, $amount);
127
-
128
- if ($amount <= 0) {
129
- Mage::throwException(Mage::helper('paygate')->__('Invalid amount for capture.'));
130
- }
131
-
132
- if (!$payment->getLastTransId()) {
133
- Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
134
- }
135
-
136
- $payment->setAmount($amount);
137
-
138
- // Load transaction Data
139
- $transactionId = $payment->getLastTransId();
140
- $transaction = $payment->getTransaction($transactionId);
141
- if (!$transaction) {
142
- Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
143
- }
144
-
145
- // Get Transaction Details
146
- $details = $this->fetchTransactionInfo($payment, $transactionId);
147
-
148
- // Not to execute for Sale transactions
149
- if ($details['transactionStatus'] !== 3) {
150
- Mage::throwException(Mage::helper('payex')->__('Can\'t capture captured order.'));
151
- }
152
-
153
- $transactionNumber = $details['transactionNumber'];
154
- $order_id = $details['orderId'];
155
- if (!$order_id) {
156
- $order_id = $payment->getOrder()->getIncrementId();
157
- }
158
-
159
- // Call PXOrder.Capture5
160
- $params = array(
161
- 'accountNumber' => '',
162
- 'transactionNumber' => $transactionNumber,
163
- 'amount' => round($amount * 100),
164
- 'orderId' => $order_id,
165
- 'vatAmount' => 0,
166
- 'additionalValues' => ''
167
- );
168
- $result = Mage::helper('payex/api')->getPx()->Capture5($params);
169
- Mage::helper('payex/tools')->addToDebug('PXOrder.Capture5:' . $result['description'], $order_id);
170
-
171
- // Check Results
172
- if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
173
- // Note: Order Status will be changed in Observer
174
-
175
- // Add Capture Transaction
176
- $payment->setStatus(self::STATUS_APPROVED)
177
- ->setTransactionId($result['transactionNumber'])
178
- ->setIsTransactionClosed(0);
179
-
180
- // Add Transaction fields
181
- $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
182
- return $this;
183
- }
184
-
185
- // Show Error
186
- Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Capture5');
187
- return $this;
188
- }
189
-
190
- /**
191
- * Cancel payment
192
- * @param Varien_Object $payment
193
- * @return $this
194
- */
195
- public function cancel(Varien_Object $payment)
196
- {
197
- Mage::helper('payex/tools')->addToDebug('Action: Cancel');
198
-
199
- if (!$payment->getLastTransId()) {
200
- Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
201
- }
202
-
203
- // Load transaction Data
204
- $transactionId = $payment->getLastTransId();
205
- $transaction = $payment->getTransaction($transactionId);
206
- if (!$transaction) {
207
- Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
208
- }
209
-
210
- // Get Transaction Details
211
- $details = $this->fetchTransactionInfo($payment, $transactionId);
212
-
213
- // Not to execute for Sale transactions
214
- if ((int)$details['transactionStatus'] !== 3) {
215
- Mage::throwException(Mage::helper('payex')->__('Unable to execute cancel.'));
216
- }
217
-
218
- $transactionNumber = $details['transactionNumber'];
219
- $order_id = $details['orderId'];
220
- if (!$order_id) {
221
- $order_id = $payment->getOrder()->getId();
222
- }
223
-
224
- // Call PXOrder.Cancel2
225
- $params = array(
226
- 'accountNumber' => '',
227
- 'transactionNumber' => $transactionNumber
228
- );
229
- $result = Mage::helper('payex/api')->getPx()->Cancel2($params);
230
- Mage::helper('payex/tools')->addToDebug('PxOrder.Cancel2:' . $result['description'], $order_id);
231
-
232
- // Check Results
233
- if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
234
- // Add Cancel Transaction
235
- $payment->setStatus(self::STATUS_DECLINED)
236
- ->setTransactionId($result['transactionNumber'])
237
- ->setIsTransactionClosed(1); // Closed
238
-
239
- // Add Transaction fields
240
- $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
241
- return $this;
242
- }
243
-
244
- // Show Error
245
- Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Cancel2');
246
- return $this;
247
- }
248
-
249
- /**
250
- * Refund capture
251
- * @param Varien_Object $payment
252
- * @param $amount
253
- * @return $this
254
- */
255
- public function refund(Varien_Object $payment, $amount)
256
- {
257
- Mage::helper('payex/tools')->addToDebug('Action: Refund');
258
-
259
- parent::refund($payment, $amount);
260
-
261
- if ($amount <= 0) {
262
- Mage::throwException(Mage::helper('paygate')->__('Invalid amount for refund.'));
263
- }
264
-
265
- if (!$payment->getLastTransId()) {
266
- Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
267
- }
268
-
269
- // Load transaction Data
270
- $transactionId = $payment->getLastTransId();
271
- $transaction = $payment->getTransaction($transactionId);
272
- if (!$transaction) {
273
- Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
274
- }
275
-
276
- // Get Transaction Details
277
- $details = $this->fetchTransactionInfo($payment, $transactionId);
278
-
279
- // Check for Capture and Authorize transaction only
280
- if ((int)$details['transactionStatus'] !== 6 && (int)$details['transactionStatus'] !== 0) {
281
- Mage::throwException(Mage::helper('payex')->__('This payment has not yet captured.'));
282
- }
283
-
284
- $transactionNumber = $details['transactionNumber'];
285
- $order_id = $details['orderId'];
286
- if (!$order_id) {
287
- $order_id = $payment->getOrder()->getId();
288
- }
289
-
290
- // Call PXOrder.PXOrder.Credit5
291
- $params = array(
292
- 'accountNumber' => '',
293
- 'transactionNumber' => $transactionNumber,
294
- 'amount' => round(100 * $amount),
295
- 'orderId' => $order_id,
296
- 'vatAmount' => 0,
297
- 'additionalValues' => ''
298
- );
299
- $result = Mage::helper('payex/api')->getPx()->Credit5($params);
300
- Mage::helper('payex/tools')->debugApi($result, 'PxOrder.Credit');
301
-
302
- // Check Results
303
- if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
304
- // Add Credit Transaction
305
- $payment->setAnetTransType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
306
- $payment->setAmount($amount);
307
-
308
- $payment->setStatus(self::STATUS_APPROVED)
309
- ->setTransactionId($result['transactionNumber'])
310
- ->setIsTransactionClosed(0); // No-Closed
311
-
312
- // Add Transaction fields
313
- $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
314
- return $this;
315
- }
316
-
317
- // Show Error
318
- Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Credit5');
319
- return $this;
320
- }
321
-
322
- /**
323
- * Void payment
324
- * @param Varien_Object $payment
325
- * @return $this
326
- */
327
- public function void(Varien_Object $payment)
328
- {
329
- Mage::helper('payex/tools')->addToDebug('Action: Void');
330
- return $this->cancel($payment);
331
- }
332
-
333
- /**
334
- * Fetch transaction details info
335
- * @param Mage_Payment_Model_Info $payment
336
- * @param string $transactionId
337
- * @return array
338
- */
339
- public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
340
- {
341
- Mage::helper('payex/tools')->addToDebug('Action: fetchTransactionInfo. ID ' . $transactionId);
342
-
343
- parent::fetchTransactionInfo($payment, $transactionId);
344
-
345
- // Get Transaction Details
346
- $params = array(
347
- 'accountNumber' => '',
348
- 'transactionNumber' => $transactionId,
349
- );
350
- $details = Mage::helper('payex/api')->getPx()->GetTransactionDetails2($params);
351
- Mage::helper('payex/tools')->debugApi($details, 'PxOrder.GetTransactionDetails2');
352
-
353
- // Check Results
354
- if ($details['code'] == 'OK' && $details['errorCode'] == 'OK' && $details['description'] == 'OK') {
355
- // Filter details
356
- foreach ($details as $key => $value) {
357
- if (empty($value)) {
358
- unset($details[$key]);
359
- }
360
- }
361
- return $details;
362
- }
363
-
364
- // Show Error
365
- Mage::helper('payex/tools')->throwPayExException($details, 'GetTransactionDetails2');
366
- }
367
-
368
- public function getStandardCheckoutFormFields()
369
- {
370
- return array();
371
- }
372
-
373
- /**
374
- * Check void availability
375
- * @param Varien_Object $payment
376
- * @return bool
377
- */
378
- public function canVoid(Varien_Object $payment)
379
- {
380
- if ($payment instanceof Mage_Sales_Model_Order_Invoice
381
- || $payment instanceof Mage_Sales_Model_Order_Creditmemo
382
- ) {
383
- return false;
384
- }
385
- return $this->_canVoid;
386
- }
387
-
388
- public function canEdit()
389
- {
390
- return false;
391
- }
392
-
393
- public function canUseInternal()
394
- {
395
- return $this->_canUseInternal;
396
- }
397
-
398
- public function canUseForMultishipping()
399
- {
400
- return $this->_canUseForMultishipping;
401
- }
402
-
403
- public function onOrderValidate(Mage_Sales_Model_Order_Payment $payment)
404
- {
405
- return $this;
406
- }
407
-
408
- public function onInvoiceCreate(Mage_Sales_Model_Order_Invoice $payment)
409
- {
410
- }
411
-
412
- public function canCapture()
413
- {
414
- return $this->_canCapture;
415
- }
416
-
417
- public function canFetchTransactionInfo()
418
- {
419
- return $this->_canFetchTransactionInfo;
420
- }
421
-
422
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/PayEx/Payments/Model/Payment/Bankdebit.php CHANGED
@@ -74,6 +74,10 @@ class PayEx_Payments_Model_Payment_Bankdebit extends PayEx_Payments_Model_Paymen
74
  return false;
75
  }
76
 
 
 
 
 
77
  // Check currency
78
  $allowedCurrency = array('DKK', 'EUR', 'GBP', 'NOK', 'SEK', 'USD');
79
  return in_array($quote->getQuoteCurrencyCode(), $allowedCurrency);
74
  return false;
75
  }
76
 
77
+ if (!$quote) {
78
+ return false;
79
+ }
80
+
81
  // Check currency
82
  $allowedCurrency = array('DKK', 'EUR', 'GBP', 'NOK', 'SEK', 'USD');
83
  return in_array($quote->getQuoteCurrencyCode(), $allowedCurrency);
app/code/community/PayEx/Payments/Model/Payment/CC.php CHANGED
@@ -2,15 +2,21 @@
2
 
3
  class PayEx_Payments_Model_Payment_CC extends PayEx_Payments_Model_Payment_Abstract
4
  {
 
 
 
 
 
5
  /**
6
  * Payment method code
7
  */
8
- public $_code = 'payex_cc';
9
 
10
  /**
11
  * Availability options
12
  */
13
  protected $_isGateway = true;
 
14
  protected $_canAuthorize = true;
15
  protected $_canCapture = true;
16
  protected $_canCapturePartial = false;
@@ -20,7 +26,10 @@ class PayEx_Payments_Model_Payment_CC extends PayEx_Payments_Model_Payment_Abstr
20
  protected $_canUseInternal = true;
21
  protected $_canUseCheckout = true;
22
  protected $_canUseForMultishipping = false;
 
23
  protected $_canFetchTransactionInfo = true;
 
 
24
 
25
  /**
26
  * Payment method blocks
@@ -28,38 +37,13 @@ class PayEx_Payments_Model_Payment_CC extends PayEx_Payments_Model_Payment_Abstr
28
  protected $_infoBlockType = 'payex/info_CC';
29
  protected $_formBlockType = 'payex/form_CC';
30
 
31
- /**
32
- * Get initialized flag status
33
- * @return true
34
- */
35
- public function isInitializeNeeded()
36
- {
37
- return true;
38
- }
39
-
40
- /**
41
- * Instantiate state and set it to state object
42
- * @param $paymentAction
43
- * @param $stateObject
44
- * @return void
45
- */
46
- public function initialize($paymentAction, $stateObject)
47
- {
48
- // Set Initial Order Status
49
- $state = Mage_Sales_Model_Order::STATE_NEW;
50
- $stateObject->setState($state);
51
- $stateObject->setStatus($state);
52
- $stateObject->setIsNotified(false);
53
- }
54
-
55
  /**
56
  * Get config action to process initialization
57
  * @return string
58
  */
59
  public function getConfigPaymentAction()
60
  {
61
- $paymentAction = $this->getConfigData('payment_action');
62
- return empty($paymentAction) ? true : $paymentAction;
63
  }
64
 
65
  /**
@@ -73,6 +57,10 @@ class PayEx_Payments_Model_Payment_CC extends PayEx_Payments_Model_Payment_Abstr
73
  return false;
74
  }
75
 
 
 
 
 
76
  // Check currency
77
  $allowedCurrency = array('DKK', 'EUR', 'GBP', 'NOK', 'SEK', 'USD');
78
  //if ($this->getConfigData('paymentview') === 'DIRECTDEBIT') {
@@ -82,6 +70,97 @@ class PayEx_Payments_Model_Payment_CC extends PayEx_Payments_Model_Payment_Abstr
82
  return in_array($quote->getQuoteCurrencyCode(), $allowedCurrency);
83
  }
84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  /**
86
  * Validate
87
  * @return bool
2
 
3
  class PayEx_Payments_Model_Payment_CC extends PayEx_Payments_Model_Payment_Abstract
4
  {
5
+ /**
6
+ * Payment Method Code
7
+ */
8
+ const METHOD_CODE = 'payex_cc';
9
+
10
  /**
11
  * Payment method code
12
  */
13
+ public $_code = self::METHOD_CODE;
14
 
15
  /**
16
  * Availability options
17
  */
18
  protected $_isGateway = true;
19
+ protected $_canOrder = true;
20
  protected $_canAuthorize = true;
21
  protected $_canCapture = true;
22
  protected $_canCapturePartial = false;
26
  protected $_canUseInternal = true;
27
  protected $_canUseCheckout = true;
28
  protected $_canUseForMultishipping = false;
29
+ protected $_isInitializeNeeded = false;
30
  protected $_canFetchTransactionInfo = true;
31
+ protected $_canCreateBillingAgreement = true;
32
+ protected $_canManageRecurringProfiles = false;
33
 
34
  /**
35
  * Payment method blocks
37
  protected $_infoBlockType = 'payex/info_CC';
38
  protected $_formBlockType = 'payex/form_CC';
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  /**
41
  * Get config action to process initialization
42
  * @return string
43
  */
44
  public function getConfigPaymentAction()
45
  {
46
+ return Mage_Payment_Model_Method_Abstract::ACTION_ORDER;
 
47
  }
48
 
49
  /**
57
  return false;
58
  }
59
 
60
+ if (!$quote) {
61
+ return false;
62
+ }
63
+
64
  // Check currency
65
  $allowedCurrency = array('DKK', 'EUR', 'GBP', 'NOK', 'SEK', 'USD');
66
  //if ($this->getConfigData('paymentview') === 'DIRECTDEBIT') {
70
  return in_array($quote->getQuoteCurrencyCode(), $allowedCurrency);
71
  }
72
 
73
+ /**
74
+ * Assign data to info model instance
75
+ *
76
+ * @param mixed $data
77
+ * @return Mage_Payment_Model_Info
78
+ */
79
+ public function assignData($data)
80
+ {
81
+ $result = parent::assignData($data);
82
+ $key = PayEx_Payments_Model_Payment_Agreement::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT;
83
+ if (is_array($data)) {
84
+ $this->getInfoInstance()->setAdditionalInformation($key, isset($data[$key]) ? $data[$key] : null);
85
+ } elseif ($data instanceof Varien_Object) {
86
+ $this->getInfoInstance()->setAdditionalInformation($key, $data->getData($key));
87
+ }
88
+ return $result;
89
+ }
90
+
91
+ /**
92
+ * Order payment method
93
+ *
94
+ * @param Varien_Object $payment
95
+ * @param float $amount
96
+ *
97
+ * @return $this
98
+ */
99
+ public function order(Varien_Object $payment, $amount)
100
+ {
101
+ Mage::helper('payex/tools')->addToDebug('Action: Order');
102
+ parent::order($payment, $amount);
103
+
104
+ // Set state
105
+ /** @var Mage_Sales_Model_Order $order */
106
+ $order = $payment->getOrder();
107
+ $order->setState(Mage_Sales_Model_Order::STATE_NEW, true);
108
+
109
+ $isBARequested = (bool)$this->getInfoInstance()->getAdditionalInformation(
110
+ PayEx_Payments_Model_Payment_Agreement::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT
111
+ );
112
+ if ($isBARequested) {
113
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
114
+ if ($customer && $customer->getId()) {
115
+ /** @var PayEx_Payments_Model_Payment_Agreement $method */
116
+ $method = Mage::helper('payment')->getMethodInstance(PayEx_Payments_Model_Payment_Agreement::METHOD_BILLING_AGREEMENT);
117
+
118
+ // Call PxAgreement.CreateAgreement3
119
+ $params = array(
120
+ 'accountNumber' => '',
121
+ 'merchantRef' => $method->getConfigData('agreementurl', $order->getStore()),
122
+ 'description' => Mage::app()->getStore()->getName(),
123
+ 'purchaseOperation' => ($this->getConfigData('transactiontype') == 0) ? 'AUTHORIZATION' : 'SALE',
124
+ 'maxAmount' => round($method->getConfigData('maxamount', $order->getStore()) * 100),
125
+ 'notifyUrl' => '',
126
+ 'startDate' => '',
127
+ 'stopDate' => ''
128
+ );
129
+ $result = Mage::helper('payex/api')->getPx()->CreateAgreement3($params);
130
+ Mage::helper('payex/tools')->debugApi($result, 'PxAgreement.CreateAgreement3');
131
+ if ($result['code'] !== 'OK' || $result['description'] !== 'OK' || $result['errorCode'] !== 'OK') {
132
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
133
+
134
+ // Cancel order
135
+ $order->cancel();
136
+ $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
137
+ $order->save();
138
+
139
+ Mage::throwException($message);
140
+ return $this;
141
+ }
142
+
143
+ // Agreement Reference
144
+ $agreement_reference = $result['agreementRef'];
145
+
146
+ // Set Agreement Reference Info
147
+ $this->getInfoInstance()->setAdditionalInformation(
148
+ PayEx_Payments_Model_Payment_Agreement::PAYMENT_INFO_TRANSPORT_AGREEMENT_REFERENCE,
149
+ $agreement_reference
150
+ );
151
+
152
+ // Set Billing Agreement Data
153
+ $payment->setBillingAgreementData(array(
154
+ 'billing_agreement_id' => $agreement_reference,
155
+ 'method_code' => PayEx_Payments_Model_Payment_Agreement::METHOD_BILLING_AGREEMENT,
156
+ ));
157
+ }
158
+ }
159
+
160
+ $payment->setSkipOrderProcessing(true);
161
+ return $this;
162
+ }
163
+
164
  /**
165
  * Validate
166
  * @return bool
app/code/community/PayEx/Payments/Model/Payment/Financing.php CHANGED
@@ -79,6 +79,10 @@ class PayEx_Payments_Model_Payment_Financing extends PayEx_Payments_Model_Paymen
79
  return false;
80
  }
81
 
 
 
 
 
82
  return true;
83
  }
84
 
@@ -139,7 +143,17 @@ class PayEx_Payments_Model_Payment_Financing extends PayEx_Payments_Model_Paymen
139
 
140
  // Get Social Security Number
141
  // You can use 8111032382 in Test Environment
142
- $ssn = Mage::app()->getRequest()->getParam('social-security-number');
 
 
 
 
 
 
 
 
 
 
143
 
144
  $params = array(
145
  'accountNumber' => '',
79
  return false;
80
  }
81
 
82
+ if (!$quote) {
83
+ return false;
84
+ }
85
+
86
  return true;
87
  }
88
 
143
 
144
  // Get Social Security Number
145
  // You can use 8111032382 in Test Environment
146
+ $ssn = trim(Mage::app()->getRequest()->getParam('social-security-number'));
147
+ if (empty($ssn)) {
148
+ Mage::throwException(Mage::helper('payex')->__('Please enter Social Security Number.'));
149
+ }
150
+
151
+ // Don't perform SSN validation
152
+ if (!$this->getConfigData('ssn_check')) {
153
+ // Save Social Security Number
154
+ $this->getCheckout()->setSocialSecurityNumber($ssn);
155
+ return;
156
+ }
157
 
158
  $params = array(
159
  'accountNumber' => '',
app/code/community/PayEx/Payments/Model/Payment/Invoice.php CHANGED
@@ -73,6 +73,10 @@ class PayEx_Payments_Model_Payment_Invoice extends PayEx_Payments_Model_Payment_
73
  return false;
74
  }
75
 
 
 
 
 
76
  // Check currency
77
  $allowedCurrency = array('DKK', 'EUR', 'GBP', 'NOK', 'SEK', 'USD');
78
  return in_array($quote->getQuoteCurrencyCode(), $allowedCurrency);
@@ -86,6 +90,11 @@ class PayEx_Payments_Model_Payment_Invoice extends PayEx_Payments_Model_Payment_
86
  {
87
  Mage::helper('payex/tools')->addToDebug('Action: Validate');
88
 
 
 
 
 
 
89
  // Get Total Amount
90
  $amount = $this->getQuote()->getGrandTotal();
91
 
73
  return false;
74
  }
75
 
76
+ if (!$quote) {
77
+ return false;
78
+ }
79
+
80
  // Check currency
81
  $allowedCurrency = array('DKK', 'EUR', 'GBP', 'NOK', 'SEK', 'USD');
82
  return in_array($quote->getQuoteCurrencyCode(), $allowedCurrency);
90
  {
91
  Mage::helper('payex/tools')->addToDebug('Action: Validate');
92
 
93
+ // Credit Check is disabled
94
+ if (!$this->getConfigData('credit_check')) {
95
+ return true;
96
+ }
97
+
98
  // Get Total Amount
99
  $amount = $this->getQuote()->getGrandTotal();
100
 
app/code/community/PayEx/Payments/Model/Payment/MasterPass.php CHANGED
@@ -73,6 +73,10 @@ class PayEx_Payments_Model_Payment_MasterPass extends PayEx_Payments_Model_Payme
73
  return false;
74
  }
75
 
 
 
 
 
76
  // Check currency
77
  $allowedCurrency = array('DKK', 'EUR', 'GBP', 'NOK', 'SEK', 'USD');
78
  return in_array($quote->getQuoteCurrencyCode(), $allowedCurrency);
73
  return false;
74
  }
75
 
76
+ if (!$quote) {
77
+ return false;
78
+ }
79
+
80
  // Check currency
81
  $allowedCurrency = array('DKK', 'EUR', 'GBP', 'NOK', 'SEK', 'USD');
82
  return in_array($quote->getQuoteCurrencyCode(), $allowedCurrency);
app/code/community/PayEx/Payments/Model/Payment/PartPayment.php CHANGED
@@ -79,6 +79,10 @@ class PayEx_Payments_Model_Payment_PartPayment extends PayEx_Payments_Model_Paym
79
  return false;
80
  }
81
 
 
 
 
 
82
  return true;
83
  }
84
 
@@ -132,11 +136,21 @@ class PayEx_Payments_Model_Payment_PartPayment extends PayEx_Payments_Model_Paym
132
 
133
  // Get Social Security Number
134
  // You can use 8111032382 in Test Environment
135
- $ssn = Mage::app()->getRequest()->getParam('social-security-number');
 
 
 
 
 
 
 
 
 
 
136
 
137
  $params = array(
138
  'accountNumber' => '',
139
- 'paymentMethod' => $country_code === 'SE' ? 'PXFINANCINGINVOICESE' : 'PXFINANCINGINVOICENO',
140
  'ssn' => $ssn,
141
  'zipcode' => $postcode,
142
  'countryCode' => $country_code,
79
  return false;
80
  }
81
 
82
+ if (!$quote) {
83
+ return false;
84
+ }
85
+
86
  return true;
87
  }
88
 
136
 
137
  // Get Social Security Number
138
  // You can use 8111032382 in Test Environment
139
+ $ssn = trim(Mage::app()->getRequest()->getParam('social-security-number'));
140
+ if (empty($ssn)) {
141
+ Mage::throwException(Mage::helper('payex')->__('Please enter Social Security Number.'));
142
+ }
143
+
144
+ // Don't perform SSN validation
145
+ if (!$this->getConfigData('ssn_check')) {
146
+ // Save Social Security Number
147
+ $this->getCheckout()->setSocialSecurityNumber($ssn);
148
+ return;
149
+ }
150
 
151
  $params = array(
152
  'accountNumber' => '',
153
+ 'paymentMethod' => $country_code === 'SE' ? 'PXCREDITACCOUNTSE' : 'PXCREDITACCOUNTNO',
154
  'ssn' => $ssn,
155
  'zipcode' => $postcode,
156
  'countryCode' => $country_code,
app/code/community/PayEx/Payments/Model/Payment/Swish.php CHANGED
@@ -74,6 +74,10 @@ class PayEx_Payments_Model_Payment_Swish extends PayEx_Payments_Model_Payment_Ab
74
  return false;
75
  }
76
 
 
 
 
 
77
  // Check currency
78
  $allowedCurrency = array('DKK', 'EUR', 'GBP', 'NOK', 'SEK', 'USD');
79
  return in_array($quote->getQuoteCurrencyCode(), $allowedCurrency);
74
  return false;
75
  }
76
 
77
+ if (!$quote) {
78
+ return false;
79
+ }
80
+
81
  // Check currency
82
  $allowedCurrency = array('DKK', 'EUR', 'GBP', 'NOK', 'SEK', 'USD');
83
  return in_array($quote->getQuoteCurrencyCode(), $allowedCurrency);
app/code/community/PayEx/Payments/Model/Payment/Wywallet.php CHANGED
@@ -79,6 +79,10 @@ class PayEx_Payments_Model_Payment_Wywallet extends PayEx_Payments_Model_Payment
79
  return false;
80
  }
81
 
 
 
 
 
82
  return true;
83
  }
84
 
79
  return false;
80
  }
81
 
82
+ if (!$quote) {
83
+ return false;
84
+ }
85
+
86
  return true;
87
  }
88
 
app/code/community/PayEx/Payments/Model/Quote/Tax.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Quote_Tax extends Mage_Sales_Model_Quote_Address_Total_Tax
4
+ {
5
+ protected static $_allowed_methods = array(
6
+ 'payex_financing',
7
+ 'payex_partpayment',
8
+ 'payex_invoice'
9
+ );
10
+
11
+ public function getCode()
12
+ {
13
+ return 'payex_payment_fee_tax';
14
+ }
15
+
16
+ public function collect(Mage_Sales_Model_Quote_Address $address)
17
+ {
18
+ $paymentMethod = Mage::app()->getFrontController()->getRequest()->getParam('payment');
19
+ $paymentMethod = Mage::app()->getStore()->isAdmin() && isset($paymentMethod['method']) ? $paymentMethod['method'] : null;
20
+ if (!in_array($paymentMethod, self::$_allowed_methods) && (!count($address->getQuote()->getPaymentsCollection()) || !$address->getQuote()->getPayment()->hasMethodInstance())) {
21
+ return $this;
22
+ }
23
+
24
+ $paymentMethod = $address->getQuote()->getPayment()->getMethodInstance();
25
+ if (!in_array($paymentMethod->getCode(), self::$_allowed_methods)) {
26
+ return $this;
27
+ }
28
+
29
+ $items = $address->getAllItems();
30
+ if (!count($items)) {
31
+ return $this;
32
+ }
33
+
34
+ if (!$address->getPayexPaymentFee()) {
35
+ return $this;
36
+ }
37
+
38
+ $quote = $address->getQuote();
39
+
40
+ // Calculate Payment Fee
41
+ $price = (float)$paymentMethod->getConfigData('paymentfee', $quote->getStore()->getId());
42
+ $tax_class = $paymentMethod->getConfigData('paymentfee_tax_class', $quote->getStore()->getId());
43
+ if (!$price) {
44
+ return $this;
45
+ }
46
+
47
+ $fee = Mage::helper('payex/fee')->getPaymentFeePrice($price, $tax_class);
48
+ if (!$fee) {
49
+ return $this;
50
+ }
51
+
52
+ $address->setBasePayexPaymentFeeTax($fee->getPaymentFeeTax());
53
+ $address->setPayexPaymentFeeTax($quote->getStore()->convertPrice($fee->getPaymentFeeTax(), false));
54
+
55
+ $quote->setBasePayexPaymentFeeTax($fee->getPaymentFeeTax());
56
+ $quote->setPayexPaymentFeeTax($quote->getStore()->convertPrice($fee->getPaymentFeeTax(), false));
57
+
58
+ // update taxes
59
+ $address->setTaxAmount($address->getTaxAmount() + $fee->getPaymentFeeTax());
60
+ $address->setBaseTaxAmount($address->getBaseTaxAmount() + $quote->getStore()->convertPrice($fee->getPaymentFeeTax(), false));
61
+
62
+ // update totals
63
+ $address->setBaseGrandTotal($address->getBaseGrandTotal() + $fee->getPaymentFeeTax());
64
+ $address->setGrandTotal($address->getGrandTotal() + $quote->getStore()->convertPrice($fee->getPaymentFeeTax(), false));
65
+
66
+ return $this;
67
+ }
68
+
69
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
70
+ {
71
+ $store = $address->getQuote()->getStore();
72
+
73
+ if (Mage::getSingleton('tax/config')->displayCartSubtotalBoth($store) || Mage::getSingleton('tax/config')->displayCartSubtotalInclTax($store)) {
74
+ if ($address->getSubtotalInclTax() > 0) {
75
+ $subtotalInclTax = $address->getSubtotalInclTax();
76
+ } else {
77
+ $subtotalInclTax = $address->getSubtotal()+$address->getTaxAmount()-$address->getShippingTaxAmount()-$address->getPaymentFeeTax();
78
+ }
79
+
80
+ $address->addTotal(array(
81
+ 'code' => 'subtotal',
82
+ 'title' => Mage::helper('sales')->__('Subtotal'),
83
+ 'value' => $subtotalInclTax,
84
+ 'value_incl_tax' => $subtotalInclTax,
85
+ 'value_excl_tax' => $address->getSubtotal(),
86
+ ));
87
+ }
88
+ return $this;
89
+ }
90
+ }
app/code/community/PayEx/Payments/Model/Quote/Total.php CHANGED
@@ -31,58 +31,40 @@ class PayEx_Payments_Model_Quote_Total extends Mage_Sales_Model_Quote_Address_To
31
  return $this;
32
  }
33
 
 
 
34
  $address->setBasePayexPaymentFee(0);
35
  $address->setBasePayexPaymentFeeTax(0);
36
  $address->setPayexPaymentFee(0);
37
  $address->setPayexPaymentFeeTax(0);
38
 
39
- // Get totals
40
- $address1 = clone $address;
41
- foreach ($address1->getTotalCollector()->getCollectors() as $model) {
42
- if ($model->getCode() !== $this->getCode()) {
43
- $model->collect($address1);
44
- }
45
- }
46
-
47
- // Address is the reference for grand total
48
- // Calculated total is $address1->getGrandTotal()
49
- $price = (float)$paymentMethod->getConfigData('paymentfee');
50
- $tax_class = $paymentMethod->getConfigData('paymentfee_tax_class');
51
  if (!$price) {
52
  return $this;
53
  }
54
 
55
- // Get Payment Fee
56
  $fee = Mage::helper('payex/fee')->getPaymentFeePrice($price, $tax_class);
 
 
 
57
 
58
- $baseTotal = $address->getBaseGrandTotal();
59
- $baseTotal += $fee->getPaymentFeePrice() + $fee->getPaymentFeeTax();
60
 
61
- $address->setBasePayexPaymentFee($fee->getPaymentFeePrice());
62
- $address->setBasePayexPaymentFeeTax($fee->getPaymentFeeTax());
63
- $address->setPayexPaymentFee($address->getQuote()->getStore()->convertPrice($fee->getPaymentFeePrice(), false));
64
- $address->setPayexPaymentFeeTax($address->getQuote()->getStore()->convertPrice($fee->getPaymentFeeTax(), false));
65
 
66
- // update totals
67
- $address->setBaseGrandTotal($baseTotal);
68
- $address->setGrandTotal($address->getQuote()->getStore()->convertPrice($baseTotal, false));
69
 
70
  return $this;
71
  }
72
 
73
  public function fetch(Mage_Sales_Model_Quote_Address $address)
74
  {
75
- $paymentMethod = Mage::app()->getFrontController()->getRequest()->getParam('payment');
76
- $paymentMethod = Mage::app()->getStore()->isAdmin() && isset($paymentMethod['method']) ? $paymentMethod['method'] : null;
77
- if (!in_array($paymentMethod, self::$_allowed_methods) && (!count($address->getQuote()->getPaymentsCollection()) || !$address->getQuote()->getPayment()->hasMethodInstance())) {
78
- return $this;
79
- }
80
-
81
- $paymentMethod = $address->getQuote()->getPayment()->getMethodInstance();
82
- if (!in_array($paymentMethod->getCode(), self::$_allowed_methods)) {
83
- return $this;
84
- }
85
-
86
  $fee = $address->getPayexPaymentFee();
87
  if ($fee > 0) {
88
  $address->addTotal(array(
@@ -92,15 +74,6 @@ class PayEx_Payments_Model_Quote_Total extends Mage_Sales_Model_Quote_Address_To
92
  ));
93
  }
94
 
95
- $fee_tax = $address->getPayexPaymentFeeTax();
96
- if ($fee_tax > 0) {
97
- $address->addTotal(array(
98
- 'code' => $this->getCode() . '_tax',
99
- 'title' => Mage::helper('payex')->__('Payment fee (tax)'),
100
- 'value' => $fee_tax,
101
- ));
102
- }
103
-
104
  return $this;
105
  }
106
  }
31
  return $this;
32
  }
33
 
34
+ $quote = $address->getQuote();
35
+
36
  $address->setBasePayexPaymentFee(0);
37
  $address->setBasePayexPaymentFeeTax(0);
38
  $address->setPayexPaymentFee(0);
39
  $address->setPayexPaymentFeeTax(0);
40
 
41
+ // Calculate Payment Fee
42
+ $price = (float)$paymentMethod->getConfigData('paymentfee', $quote->getStore()->getId());
43
+ $tax_class = $paymentMethod->getConfigData('paymentfee_tax_class', $quote->getStore()->getId());
 
 
 
 
 
 
 
 
 
44
  if (!$price) {
45
  return $this;
46
  }
47
 
 
48
  $fee = Mage::helper('payex/fee')->getPaymentFeePrice($price, $tax_class);
49
+ if (!$fee) {
50
+ return $this;
51
+ }
52
 
53
+ $address->setBasePayexPaymentFee($fee->getPaymentFeeExclTax());
54
+ $address->setPayexPaymentFee($address->getQuote()->getStore()->convertPrice($fee->getPaymentFeeExclTax(), false));
55
 
56
+ $quote->setBasePayexPaymentFee($fee->getPaymentFeeExclTax());
57
+ $quote->setPayexPaymentFee($address->getQuote()->getStore()->convertPrice($fee->getPaymentFeeExclTax(), false));
 
 
58
 
59
+ // Update totals
60
+ $address->setBaseGrandTotal($address->getBaseGrandTotal() + $fee->getPaymentFeeExclTax());
61
+ $address->setGrandTotal($address->getGrandTotal() + $address->getQuote()->getStore()->convertPrice($fee->getPaymentFeeExclTax(), false));
62
 
63
  return $this;
64
  }
65
 
66
  public function fetch(Mage_Sales_Model_Quote_Address $address)
67
  {
 
 
 
 
 
 
 
 
 
 
 
68
  $fee = $address->getPayexPaymentFee();
69
  if ($fee > 0) {
70
  $address->addTotal(array(
74
  ));
75
  }
76
 
 
 
 
 
 
 
 
 
 
77
  return $this;
78
  }
79
  }
app/code/community/PayEx/Payments/Model/Source/DiscountCalculation.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Source_DiscountCalculation
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array(
9
+ 'value' => 'classic',
10
+ 'label' => Mage::helper('payex')->__('Classic')
11
+ ),
12
+ array(
13
+ 'value' => 'advanced',
14
+ 'label' => Mage::helper('payex')->__('Advanced (experimental)')
15
+ ),
16
+ );
17
+ }
18
+ }
app/code/community/PayEx/Payments/Test/Block/Form/Bankdebit.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Block_Form_Bankdebit extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * setUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = self::app()->getLayout()->createBlock('payex/form_bankdebit');
14
+ }
15
+
16
+ /**
17
+ * Test Block
18
+ */
19
+ public function testInfoBlock()
20
+ {
21
+ $this->assertAttributeEquals('payex/bankdebit/form.phtml', '_template', $this->object);
22
+ }
23
+
24
+ /**
25
+ * tearDown
26
+ */
27
+ public function tearDown()
28
+ {
29
+ unset($this->object);
30
+ parent::tearDown();
31
+ }
32
+ }
app/code/community/PayEx/Payments/Test/Block/Form/CC.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Block_Form_CC extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * setUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = self::app()->getLayout()->createBlock('payex/form_CC');
14
+ }
15
+
16
+ /**
17
+ * Test Block
18
+ */
19
+ public function testInfoBlock()
20
+ {
21
+ $this->assertAttributeEquals('payex/cc/form.phtml', '_template', $this->object);
22
+ }
23
+
24
+ /**
25
+ * tearDown
26
+ */
27
+ public function tearDown()
28
+ {
29
+ unset($this->object);
30
+ parent::tearDown();
31
+ }
32
+ }
app/code/community/PayEx/Payments/Test/Block/Form/Financing.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Block_Form_Financing extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * setUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = self::app()->getLayout()->createBlock('payex/form_financing');
14
+ }
15
+
16
+ /**
17
+ * Test Block
18
+ */
19
+ public function testInfoBlock()
20
+ {
21
+ $this->assertAttributeEquals('payex/financing/form.phtml', '_template', $this->object);
22
+ }
23
+
24
+ /**
25
+ * tearDown
26
+ */
27
+ public function tearDown()
28
+ {
29
+ unset($this->object);
30
+ parent::tearDown();
31
+ }
32
+ }
app/code/community/PayEx/Payments/Test/Block/Form/Invoice.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Block_Form_Invoice extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * setUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = self::app()->getLayout()->createBlock('payex/form_invoice');
14
+ }
15
+
16
+ /**
17
+ * Test Block
18
+ */
19
+ public function testInfoBlock()
20
+ {
21
+ $this->assertAttributeEquals('payex/invoice/form.phtml', '_template', $this->object);
22
+ }
23
+
24
+ /**
25
+ * tearDown
26
+ */
27
+ public function tearDown()
28
+ {
29
+ unset($this->object);
30
+ parent::tearDown();
31
+ }
32
+ }
app/code/community/PayEx/Payments/Test/Block/Form/MasterPass.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Block_Form_MasterPass extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * setUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = self::app()->getLayout()->createBlock('payex/form_MasterPass');
14
+ }
15
+
16
+ /**
17
+ * Test Block
18
+ */
19
+ public function testInfoBlock()
20
+ {
21
+ $this->assertAttributeEquals('payex/masterpass/form.phtml', '_template', $this->object);
22
+ }
23
+
24
+ /**
25
+ * tearDown
26
+ */
27
+ public function tearDown()
28
+ {
29
+ unset($this->object);
30
+ parent::tearDown();
31
+ }
32
+ }
app/code/community/PayEx/Payments/Test/Block/Form/PartPayment.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Block_Form_PartPayment extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * setUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = self::app()->getLayout()->createBlock('payex/form_PartPayment');
14
+ }
15
+
16
+ /**
17
+ * Test Block
18
+ */
19
+ public function testInfoBlock()
20
+ {
21
+ $this->assertAttributeEquals('payex/partpayment/form.phtml', '_template', $this->object);
22
+ }
23
+
24
+ /**
25
+ * tearDown
26
+ */
27
+ public function tearDown()
28
+ {
29
+ unset($this->object);
30
+ parent::tearDown();
31
+ }
32
+ }
app/code/community/PayEx/Payments/Test/Block/Form/Swish.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Block_Form_Swish extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * setUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = self::app()->getLayout()->createBlock('payex/form_swish');
14
+ }
15
+
16
+ /**
17
+ * Test Block
18
+ */
19
+ public function testInfoBlock()
20
+ {
21
+ $this->assertAttributeEquals('payex/swish/form.phtml', '_template', $this->object);
22
+ }
23
+
24
+ /**
25
+ * tearDown
26
+ */
27
+ public function tearDown()
28
+ {
29
+ unset($this->object);
30
+ parent::tearDown();
31
+ }
32
+ }
app/code/community/PayEx/Payments/Test/Block/Form/Wywallet.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Block_Form_Wywallet extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * setUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = self::app()->getLayout()->createBlock('payex/form_wywallet');
14
+ }
15
+
16
+ /**
17
+ * Test Block
18
+ */
19
+ public function testInfoBlock()
20
+ {
21
+ $this->assertAttributeEquals('payex/wywallet/form.phtml', '_template', $this->object);
22
+ }
23
+
24
+ /**
25
+ * tearDown
26
+ */
27
+ public function tearDown()
28
+ {
29
+ unset($this->object);
30
+ parent::tearDown();
31
+ }
32
+ }
app/code/community/PayEx/Payments/Test/Block/Info/Bankdebit.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Block_Info_Bankdebit extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * setUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = self::app()->getLayout()->createBlock('payex/info_bankdebit');
14
+ }
15
+
16
+ /**
17
+ * Test Block
18
+ */
19
+ public function testInfoBlock()
20
+ {
21
+ $this->assertAttributeEquals('payex/bankdebit/info.phtml', '_template', $this->object);
22
+ }
23
+
24
+ /**
25
+ * tearDown
26
+ */
27
+ public function tearDown()
28
+ {
29
+ unset($this->object);
30
+ parent::tearDown();
31
+ }
32
+ }
app/code/community/PayEx/Payments/Test/Block/Info/CC.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Block_Info_CC extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * setUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = self::app()->getLayout()->createBlock('payex/info_CC');
14
+ }
15
+
16
+ /**
17
+ * Test Block
18
+ */
19
+ public function testInfoBlock()
20
+ {
21
+ $this->assertAttributeEquals('payex/cc/info.phtml', '_template', $this->object);
22
+ }
23
+
24
+ /**
25
+ * tearDown
26
+ */
27
+ public function tearDown()
28
+ {
29
+ unset($this->object);
30
+ parent::tearDown();
31
+ }
32
+ }
app/code/community/PayEx/Payments/Test/Block/Info/MasterPass.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Block_Info_MasterPass extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * setUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = self::app()->getLayout()->createBlock('payex/info_MasterPass');
14
+ }
15
+
16
+ /**
17
+ * Test Block
18
+ */
19
+ public function testInfoBlock()
20
+ {
21
+ $this->assertAttributeEquals('payex/masterpass/info.phtml', '_template', $this->object);
22
+ }
23
+
24
+ /**
25
+ * tearDown
26
+ */
27
+ public function tearDown()
28
+ {
29
+ unset($this->object);
30
+ parent::tearDown();
31
+ }
32
+ }
app/code/community/PayEx/Payments/Test/Block/Info/PartPayment.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Block_Info_PartPayment extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * setUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = self::app()->getLayout()->createBlock('payex/info_PartPayment');
14
+ }
15
+
16
+ /**
17
+ * Test Block
18
+ */
19
+ public function testInfoBlock()
20
+ {
21
+ $this->assertAttributeEquals('payex/partpayment/info.phtml', '_template', $this->object);
22
+ }
23
+
24
+ /**
25
+ * tearDown
26
+ */
27
+ public function tearDown()
28
+ {
29
+ unset($this->object);
30
+ parent::tearDown();
31
+ }
32
+ }
app/code/community/PayEx/Payments/Test/Block/Info/Swish.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Block_Info_Swish extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * setUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = self::app()->getLayout()->createBlock('payex/info_swish');
14
+ }
15
+
16
+ /**
17
+ * Test Block
18
+ */
19
+ public function testInfoBlock()
20
+ {
21
+ $this->assertAttributeEquals('payex/swish/info.phtml', '_template', $this->object);
22
+ }
23
+
24
+ /**
25
+ * tearDown
26
+ */
27
+ public function tearDown()
28
+ {
29
+ unset($this->object);
30
+ parent::tearDown();
31
+ }
32
+ }
app/code/community/PayEx/Payments/Test/Block/Info/Wywallet.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Block_Info_Wywallet extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * setUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = self::app()->getLayout()->createBlock('payex/info_wywallet');
14
+ }
15
+
16
+ /**
17
+ * Test Block
18
+ */
19
+ public function testInfoBlock()
20
+ {
21
+ $this->assertAttributeEquals('payex/wywallet/info.phtml', '_template', $this->object);
22
+ }
23
+
24
+ /**
25
+ * tearDown
26
+ */
27
+ public function tearDown()
28
+ {
29
+ unset($this->object);
30
+ parent::tearDown();
31
+ }
32
+ }
app/code/community/PayEx/Payments/Test/Helper/Api.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Helper_Api extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * setUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = Mage::helper('payex/api');
14
+ }
15
+
16
+ /**
17
+ * Check Px
18
+ */
19
+ public function testPx()
20
+ {
21
+
22
+ $px = $this->object->getPx();
23
+ $this->assertEquals('PayEx\Px', get_class($px));
24
+ }
25
+
26
+
27
+ /**
28
+ * tearDown
29
+ */
30
+ protected function tearDown()
31
+ {
32
+ unset($this->object);
33
+ parent::tearDown();
34
+ }
35
+ }
app/code/community/PayEx/Payments/Test/Helper/Order.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Helper_Order extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * setUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = Mage::helper('payex/order');
14
+ }
15
+
16
+ /**
17
+ * Check Methods
18
+ */
19
+ public function testMethods()
20
+ {
21
+ $methods = array(
22
+ 'processPaymentTransaction', 'makeInvoice', 'makeCreditMemo', 'getCalculatedOrderAmount', 'addOrderLine',
23
+ 'addOrderAddress', 'getShoppingCartXML', 'getInvoiceExtraPrintBlocksXML', 'getAssignedStatus',
24
+ 'getInvoiceLink'
25
+ );
26
+ foreach ($methods as $method) {
27
+ $this->assertTrue(method_exists($this->object, $method), 'Class does not have method ' . $method);
28
+ }
29
+ }
30
+
31
+
32
+ /**
33
+ * tearDown
34
+ */
35
+ protected function tearDown()
36
+ {
37
+ unset($this->object);
38
+ parent::tearDown();
39
+ }
40
+ }
app/code/community/PayEx/Payments/Test/Helper/Tools.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Helper_Tools extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * setUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = Mage::helper('payex/tools');
14
+ }
15
+
16
+ /**
17
+ * Check Methods
18
+ */
19
+ public function testMethods()
20
+ {
21
+ $methods = array(
22
+ 'throwPayExException', 'debugApi', 'addToDebug', 'getErrorMessageByCode', 'getVerboseErrorMessage',
23
+ 'getNameParser'
24
+ );
25
+ foreach ($methods as $method) {
26
+ $this->assertTrue(method_exists($this->object, $method), 'Class does not have method ' . $method);
27
+ }
28
+ }
29
+
30
+ /**
31
+ * Test Logging
32
+ */
33
+ public function testLogging()
34
+ {
35
+ $log_file = Mage::getBaseDir('var') . DS . 'log' . DS . 'payment_payex.log';
36
+ if (file_exists($log_file)) {
37
+ unlink($log_file);
38
+ }
39
+ $this->object->addToDebug('Log test');
40
+ //$this->assertFileExists($log_file);
41
+ //$this->assertContains('Log test', file_get_contents($log_file));
42
+ }
43
+
44
+ /**
45
+ * Check NameParser
46
+ */
47
+ public function testNameParser()
48
+ {
49
+ $nameparser = $this->object->getNameParser();
50
+ $this->assertEquals('FullNameParser', get_class($nameparser));
51
+ }
52
+
53
+ /**
54
+ * tearDown
55
+ */
56
+ protected function tearDown()
57
+ {
58
+ unset($this->object);
59
+ parent::tearDown();
60
+ }
61
+ }
app/code/community/PayEx/Payments/Test/Model/Payment/Bankdebit.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Model_Payment_Bankdebit extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * SetUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = Mage::getModel('payex/payment_bankdebit');
14
+ }
15
+
16
+
17
+ /**
18
+ * Check Attributes
19
+ */
20
+ public function testAttributes()
21
+ {
22
+ $this->assertAttributeEquals('payex_bankdebit', '_code', $this->object);
23
+ $this->assertAttributeEquals('payex/form_bankdebit', '_formBlockType', $this->object);
24
+ $this->assertAttributeEquals('payex/info_bankdebit', '_infoBlockType', $this->object);
25
+ $this->assertAttributeEquals(true, '_isGateway', $this->object);
26
+ $this->assertAttributeEquals(true, '_canAuthorize', $this->object);
27
+ $this->assertAttributeEquals(true, '_canCapture', $this->object);
28
+ $this->assertAttributeEquals(false, '_canCapturePartial', $this->object);
29
+ $this->assertAttributeEquals(true, '_canRefund', $this->object);
30
+ $this->assertAttributeEquals(true, '_canRefundInvoicePartial', $this->object);
31
+ $this->assertAttributeEquals(true, '_canVoid', $this->object);
32
+ $this->assertAttributeEquals(true, '_canUseInternal', $this->object);
33
+ $this->assertAttributeEquals(true, '_canUseCheckout', $this->object);
34
+ $this->assertAttributeEquals(false, '_canUseForMultishipping', $this->object);
35
+ $this->assertAttributeEquals(true, '_canFetchTransactionInfo', $this->object);
36
+ }
37
+
38
+ /**
39
+ * Check Methods
40
+ */
41
+ public function testMethods()
42
+ {
43
+ $methods = array(
44
+ 'isAvailable', 'validate', 'getOrderPlaceRedirectUrl', 'capture', 'cancel', 'refund', 'void',
45
+ 'fetchTransactionInfo'
46
+ );
47
+ foreach ($methods as $method) {
48
+ $this->assertTrue(method_exists($this->object, $method), 'Class does not have method ' . $method);
49
+ }
50
+ }
51
+
52
+ /**
53
+ * tearDown
54
+ */
55
+ protected function tearDown()
56
+ {
57
+
58
+ unset($this->object);
59
+ parent::tearDown();
60
+ }
61
+ }
app/code/community/PayEx/Payments/Test/Model/Payment/CC.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Model_Payment_CC extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * SetUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = Mage::getModel('payex/payment_CC');
14
+ }
15
+
16
+
17
+ /**
18
+ * Check Attributes
19
+ */
20
+ public function testAttributes()
21
+ {
22
+ $this->assertAttributeEquals('payex_cc', '_code', $this->object);
23
+ $this->assertAttributeEquals('payex/form_CC', '_formBlockType', $this->object);
24
+ $this->assertAttributeEquals('payex/info_CC', '_infoBlockType', $this->object);
25
+ $this->assertAttributeEquals(true, '_isGateway', $this->object);
26
+ $this->assertAttributeEquals(true, '_canAuthorize', $this->object);
27
+ $this->assertAttributeEquals(true, '_canCapture', $this->object);
28
+ $this->assertAttributeEquals(false, '_canCapturePartial', $this->object);
29
+ $this->assertAttributeEquals(true, '_canRefund', $this->object);
30
+ $this->assertAttributeEquals(true, '_canRefundInvoicePartial', $this->object);
31
+ $this->assertAttributeEquals(true, '_canVoid', $this->object);
32
+ $this->assertAttributeEquals(true, '_canUseInternal', $this->object);
33
+ $this->assertAttributeEquals(true, '_canUseCheckout', $this->object);
34
+ $this->assertAttributeEquals(false, '_canUseForMultishipping', $this->object);
35
+ $this->assertAttributeEquals(true, '_canFetchTransactionInfo', $this->object);
36
+ }
37
+
38
+ /**
39
+ * Check Methods
40
+ */
41
+ public function testMethods()
42
+ {
43
+ $methods = array(
44
+ 'isAvailable', 'validate', 'getOrderPlaceRedirectUrl', 'capture', 'cancel', 'refund', 'void',
45
+ 'fetchTransactionInfo'
46
+ );
47
+ foreach ($methods as $method) {
48
+ $this->assertTrue(method_exists($this->object, $method), 'Class does not have method ' . $method);
49
+ }
50
+ }
51
+
52
+ /**
53
+ * tearDown
54
+ */
55
+ protected function tearDown()
56
+ {
57
+
58
+ unset($this->object);
59
+ parent::tearDown();
60
+ }
61
+ }
app/code/community/PayEx/Payments/Test/Model/Payment/Financing.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Model_Payment_Financing extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * SetUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = Mage::getModel('payex/payment_financing');
14
+ }
15
+
16
+
17
+ /**
18
+ * Check Attributes
19
+ */
20
+ public function testAttributes()
21
+ {
22
+ $this->assertAttributeEquals('payex_financing', '_code', $this->object);
23
+ $this->assertAttributeEquals('payex/form_financing', '_formBlockType', $this->object);
24
+ $this->assertAttributeEquals('payex/info_financing', '_infoBlockType', $this->object);
25
+ $this->assertAttributeEquals(true, '_isGateway', $this->object);
26
+ $this->assertAttributeEquals(true, '_canAuthorize', $this->object);
27
+ $this->assertAttributeEquals(true, '_canCapture', $this->object);
28
+ $this->assertAttributeEquals(false, '_canCapturePartial', $this->object);
29
+ $this->assertAttributeEquals(true, '_canRefund', $this->object);
30
+ $this->assertAttributeEquals(false, '_canRefundInvoicePartial', $this->object);
31
+ $this->assertAttributeEquals(true, '_canVoid', $this->object);
32
+ $this->assertAttributeEquals(true, '_canUseInternal', $this->object);
33
+ $this->assertAttributeEquals(true, '_canUseCheckout', $this->object);
34
+ $this->assertAttributeEquals(false, '_canUseForMultishipping', $this->object);
35
+ $this->assertAttributeEquals(true, '_canFetchTransactionInfo', $this->object);
36
+ }
37
+
38
+ /**
39
+ * Check Methods
40
+ */
41
+ public function testMethods()
42
+ {
43
+ $methods = array(
44
+ 'isAvailable', 'validate', 'getOrderPlaceRedirectUrl', 'capture', 'cancel', 'refund', 'void',
45
+ 'fetchTransactionInfo'
46
+ );
47
+ foreach ($methods as $method) {
48
+ $this->assertTrue(method_exists($this->object, $method), 'Class does not have method ' . $method);
49
+ }
50
+ }
51
+
52
+ /**
53
+ * tearDown
54
+ */
55
+ protected function tearDown()
56
+ {
57
+
58
+ unset($this->object);
59
+ parent::tearDown();
60
+ }
61
+ }
app/code/community/PayEx/Payments/Test/Model/Payment/Invoice.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Model_Payment_Invoice extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * SetUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = Mage::getModel('payex/payment_invoice');
14
+ }
15
+
16
+
17
+ /**
18
+ * Check Attributes
19
+ */
20
+ public function testAttributes()
21
+ {
22
+ $this->assertAttributeEquals('payex_invoice', '_code', $this->object);
23
+ $this->assertAttributeEquals('payex/form_invoice', '_formBlockType', $this->object);
24
+ $this->assertAttributeEquals('payex/info_invoice', '_infoBlockType', $this->object);
25
+ $this->assertAttributeEquals(true, '_isGateway', $this->object);
26
+ $this->assertAttributeEquals(true, '_canAuthorize', $this->object);
27
+ $this->assertAttributeEquals(true, '_canCapture', $this->object);
28
+ $this->assertAttributeEquals(false, '_canCapturePartial', $this->object);
29
+ $this->assertAttributeEquals(true, '_canRefund', $this->object);
30
+ $this->assertAttributeEquals(false, '_canRefundInvoicePartial', $this->object);
31
+ $this->assertAttributeEquals(true, '_canVoid', $this->object);
32
+ $this->assertAttributeEquals(true, '_canUseInternal', $this->object);
33
+ $this->assertAttributeEquals(true, '_canUseCheckout', $this->object);
34
+ $this->assertAttributeEquals(false, '_canUseForMultishipping', $this->object);
35
+ $this->assertAttributeEquals(true, '_canFetchTransactionInfo', $this->object);
36
+ }
37
+
38
+ /**
39
+ * Check Methods
40
+ */
41
+ public function testMethods()
42
+ {
43
+ $methods = array(
44
+ 'isAvailable', 'validate', 'getOrderPlaceRedirectUrl', 'capture', 'cancel', 'refund', 'void',
45
+ 'fetchTransactionInfo'
46
+ );
47
+ foreach ($methods as $method) {
48
+ $this->assertTrue(method_exists($this->object, $method), 'Class does not have method ' . $method);
49
+ }
50
+ }
51
+
52
+ /**
53
+ * tearDown
54
+ */
55
+ protected function tearDown()
56
+ {
57
+
58
+ unset($this->object);
59
+ parent::tearDown();
60
+ }
61
+ }
app/code/community/PayEx/Payments/Test/Model/Payment/MasterPass.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Model_Payment_MasterPass extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * SetUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = Mage::getModel('payex/payment_MasterPass');
14
+ }
15
+
16
+
17
+ /**
18
+ * Check Attributes
19
+ */
20
+ public function testAttributes()
21
+ {
22
+ $this->assertAttributeEquals('payex_masterpass', '_code', $this->object);
23
+ $this->assertAttributeEquals('payex/form_MasterPass', '_formBlockType', $this->object);
24
+ $this->assertAttributeEquals('payex/info_MasterPass', '_infoBlockType', $this->object);
25
+ $this->assertAttributeEquals(true, '_isGateway', $this->object);
26
+ $this->assertAttributeEquals(true, '_canAuthorize', $this->object);
27
+ $this->assertAttributeEquals(true, '_canCapture', $this->object);
28
+ $this->assertAttributeEquals(false, '_canCapturePartial', $this->object);
29
+ $this->assertAttributeEquals(true, '_canRefund', $this->object);
30
+ $this->assertAttributeEquals(true, '_canRefundInvoicePartial', $this->object);
31
+ $this->assertAttributeEquals(true, '_canVoid', $this->object);
32
+ $this->assertAttributeEquals(true, '_canUseInternal', $this->object);
33
+ $this->assertAttributeEquals(true, '_canUseCheckout', $this->object);
34
+ $this->assertAttributeEquals(false, '_canUseForMultishipping', $this->object);
35
+ $this->assertAttributeEquals(true, '_canFetchTransactionInfo', $this->object);
36
+ }
37
+
38
+ /**
39
+ * Check Methods
40
+ */
41
+ public function testMethods()
42
+ {
43
+ $methods = array(
44
+ 'isAvailable', 'validate', 'getOrderPlaceRedirectUrl', 'capture', 'cancel', 'refund', 'void',
45
+ 'fetchTransactionInfo'
46
+ );
47
+ foreach ($methods as $method) {
48
+ $this->assertTrue(method_exists($this->object, $method), 'Class does not have method ' . $method);
49
+ }
50
+ }
51
+
52
+ /**
53
+ * tearDown
54
+ */
55
+ protected function tearDown()
56
+ {
57
+
58
+ unset($this->object);
59
+ parent::tearDown();
60
+ }
61
+ }
app/code/community/PayEx/Payments/Test/Model/Payment/PartPayment.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Model_Payment_PartPayment extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * SetUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = Mage::getModel('payex/payment_PartPayment');
14
+ }
15
+
16
+
17
+ /**
18
+ * Check Attributes
19
+ */
20
+ public function testAttributes()
21
+ {
22
+ $this->assertAttributeEquals('payex_partpayment', '_code', $this->object);
23
+ $this->assertAttributeEquals('payex/form_PartPayment', '_formBlockType', $this->object);
24
+ $this->assertAttributeEquals('payex/info_PartPayment', '_infoBlockType', $this->object);
25
+ $this->assertAttributeEquals(true, '_isGateway', $this->object);
26
+ $this->assertAttributeEquals(true, '_canAuthorize', $this->object);
27
+ $this->assertAttributeEquals(true, '_canCapture', $this->object);
28
+ $this->assertAttributeEquals(false, '_canCapturePartial', $this->object);
29
+ $this->assertAttributeEquals(true, '_canRefund', $this->object);
30
+ $this->assertAttributeEquals(false, '_canRefundInvoicePartial', $this->object);
31
+ $this->assertAttributeEquals(true, '_canVoid', $this->object);
32
+ $this->assertAttributeEquals(true, '_canUseInternal', $this->object);
33
+ $this->assertAttributeEquals(true, '_canUseCheckout', $this->object);
34
+ $this->assertAttributeEquals(false, '_canUseForMultishipping', $this->object);
35
+ $this->assertAttributeEquals(true, '_canFetchTransactionInfo', $this->object);
36
+ }
37
+
38
+ /**
39
+ * Check Methods
40
+ */
41
+ public function testMethods()
42
+ {
43
+ $methods = array(
44
+ 'isAvailable', 'validate', 'getOrderPlaceRedirectUrl', 'capture', 'cancel', 'refund', 'void',
45
+ 'fetchTransactionInfo'
46
+ );
47
+ foreach ($methods as $method) {
48
+ $this->assertTrue(method_exists($this->object, $method), 'Class does not have method ' . $method);
49
+ }
50
+ }
51
+
52
+ /**
53
+ * tearDown
54
+ */
55
+ protected function tearDown()
56
+ {
57
+
58
+ unset($this->object);
59
+ parent::tearDown();
60
+ }
61
+ }
app/code/community/PayEx/Payments/Test/Model/Payment/Swish.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Model_Payment_Swish extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * SetUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = Mage::getModel('payex/payment_swish');
14
+ }
15
+
16
+
17
+ /**
18
+ * Check Attributes
19
+ */
20
+ public function testAttributes()
21
+ {
22
+ $this->assertAttributeEquals('payex_swish', '_code', $this->object);
23
+ $this->assertAttributeEquals('payex/form_swish', '_formBlockType', $this->object);
24
+ $this->assertAttributeEquals('payex/info_swish', '_infoBlockType', $this->object);
25
+ $this->assertAttributeEquals(true, '_isGateway', $this->object);
26
+ $this->assertAttributeEquals(true, '_canAuthorize', $this->object);
27
+ $this->assertAttributeEquals(true, '_canCapture', $this->object);
28
+ $this->assertAttributeEquals(false, '_canCapturePartial', $this->object);
29
+ $this->assertAttributeEquals(true, '_canRefund', $this->object);
30
+ $this->assertAttributeEquals(true, '_canRefundInvoicePartial', $this->object);
31
+ $this->assertAttributeEquals(true, '_canVoid', $this->object);
32
+ $this->assertAttributeEquals(true, '_canUseInternal', $this->object);
33
+ $this->assertAttributeEquals(true, '_canUseCheckout', $this->object);
34
+ $this->assertAttributeEquals(false, '_canUseForMultishipping', $this->object);
35
+ $this->assertAttributeEquals(true, '_canFetchTransactionInfo', $this->object);
36
+ }
37
+
38
+ /**
39
+ * Check Methods
40
+ */
41
+ public function testMethods()
42
+ {
43
+ $methods = array(
44
+ 'isAvailable', 'validate', 'getOrderPlaceRedirectUrl', 'capture', 'cancel', 'refund', 'void',
45
+ 'fetchTransactionInfo'
46
+ );
47
+ foreach ($methods as $method) {
48
+ $this->assertTrue(method_exists($this->object, $method), 'Class does not have method ' . $method);
49
+ }
50
+ }
51
+
52
+ /**
53
+ * tearDown
54
+ */
55
+ protected function tearDown()
56
+ {
57
+
58
+ unset($this->object);
59
+ parent::tearDown();
60
+ }
61
+ }
app/code/community/PayEx/Payments/Test/Model/Payment/Wywallet.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Test_Model_Payment_Wywallet extends EcomDev_PHPUnit_Test_Case
4
+ {
5
+ var $object;
6
+
7
+ /**
8
+ * SetUp
9
+ */
10
+ public function setUp()
11
+ {
12
+ parent::setUp();
13
+ $this->object = Mage::getModel('payex/payment_wywallet');
14
+ }
15
+
16
+
17
+ /**
18
+ * Check Attributes
19
+ */
20
+ public function testAttributes()
21
+ {
22
+ $this->assertAttributeEquals('payex_wywallet', '_code', $this->object);
23
+ $this->assertAttributeEquals('payex/form_wywallet', '_formBlockType', $this->object);
24
+ $this->assertAttributeEquals('payex/info_wywallet', '_infoBlockType', $this->object);
25
+ $this->assertAttributeEquals(true, '_isGateway', $this->object);
26
+ $this->assertAttributeEquals(true, '_canAuthorize', $this->object);
27
+ $this->assertAttributeEquals(true, '_canCapture', $this->object);
28
+ $this->assertAttributeEquals(false, '_canCapturePartial', $this->object);
29
+ $this->assertAttributeEquals(true, '_canRefund', $this->object);
30
+ $this->assertAttributeEquals(false, '_canRefundInvoicePartial', $this->object);
31
+ $this->assertAttributeEquals(true, '_canVoid', $this->object);
32
+ $this->assertAttributeEquals(true, '_canUseInternal', $this->object);
33
+ $this->assertAttributeEquals(true, '_canUseCheckout', $this->object);
34
+ $this->assertAttributeEquals(false, '_canUseForMultishipping', $this->object);
35
+ $this->assertAttributeEquals(true, '_canFetchTransactionInfo', $this->object);
36
+ }
37
+
38
+ /**
39
+ * Check Methods
40
+ */
41
+ public function testMethods()
42
+ {
43
+ $methods = array(
44
+ 'isAvailable', 'validate', 'getOrderPlaceRedirectUrl', 'capture', 'cancel', 'refund', 'void',
45
+ 'fetchTransactionInfo'
46
+ );
47
+ foreach ($methods as $method) {
48
+ $this->assertTrue(method_exists($this->object, $method), 'Class does not have method ' . $method);
49
+ }
50
+ }
51
+
52
+ /**
53
+ * tearDown
54
+ */
55
+ protected function tearDown()
56
+ {
57
+
58
+ unset($this->object);
59
+ parent::tearDown();
60
+ }
61
+ }
app/code/community/PayEx/Payments/controllers/AutopayController.php DELETED
@@ -1,546 +0,0 @@
1
- <?php
2
-
3
- class PayEx_Payments_AutopayController extends Mage_Core_Controller_Front_Action
4
- {
5
- public function _construct()
6
- {
7
- // Bootstrap PayEx Environment
8
- Mage::getSingleton('payex/payment_autopay');
9
- }
10
-
11
- public function autopayAction()
12
- {
13
- Mage::helper('payex/tools')->addToDebug('Controller: autopay');
14
-
15
- // Load Order
16
- $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
17
-
18
- /** @var Mage_Sales_Model_Order $order */
19
- $order = Mage::getModel('sales/order');
20
- $order->loadByIncrementId($order_id);
21
- if (!$order->getId()) {
22
- Mage::throwException('No order for processing found');
23
- }
24
-
25
- // Set quote to inactive
26
- Mage::getSingleton('checkout/session')->setPayexQuoteId(Mage::getSingleton('checkout/session')->getQuoteId());
27
- Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
28
- Mage::getSingleton('checkout/session')->clear();
29
-
30
- /** @var PayEx_Payments_Model_Payment_Abstract $method */
31
- $method = $order->getPayment()->getMethodInstance();
32
-
33
- // Get Currency code
34
- $currency_code = $order->getOrderCurrency()->getCurrencyCode();
35
-
36
- // Get Operation Type (AUTHORIZATION / SALE)
37
- $operation = ($method->getConfigData('transactiontype') == 0) ? 'AUTHORIZATION' : 'SALE';
38
-
39
- // Get CustomerId
40
- $customer_id = (Mage::getSingleton('customer/session')->isLoggedIn() == true) ? Mage::getSingleton('customer/session')->getCustomer()->getId() : '0';
41
-
42
- // Get Amount
43
- //$amount = $order->getGrandTotal();
44
- $amount = Mage::helper('payex/order')->getCalculatedOrderAmount($order)->getAmount();
45
-
46
- // Get Current Customer Agreement
47
- $agreement = Mage::getModel('payex/agreement')->load($customer_id, 'customer_id');
48
- $agreement_status = PayEx_Payments_Model_Payment_Autopay::AGREEMENT_NOTEXISTS;
49
-
50
- // Get Agreement Status
51
- if ($agreement->getId()) {
52
- // Call PxAgreement.AgreementCheck
53
- $params = array(
54
- 'accountNumber' => '',
55
- 'agreementRef' => $agreement->getAgreementRef(),
56
- );
57
- $result = Mage::helper('payex/api')->getPx()->AgreementCheck($params);
58
- Mage::helper('payex/tools')->debugApi($result, 'PxAgreement.AgreementCheck');
59
-
60
- // Check Errors
61
- if ($result['code'] !== 'OK' && $result['description'] !== 'OK') {
62
- $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
63
-
64
- // Cancel order
65
- $order->cancel();
66
- $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
67
- $order->save();
68
-
69
- // Set quote to active
70
- if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
71
- $quote = Mage::getModel('sales/quote')->load($quoteId);
72
- if ($quote->getId()) {
73
- $quote->setIsActive(true)->save();
74
- Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
75
- }
76
- }
77
-
78
- Mage::getSingleton('checkout/session')->addError($message);
79
- $this->_redirect('checkout/cart');
80
- return;
81
- }
82
-
83
- $agreement_status = (int)$result['agreementStatus'];
84
- Mage::helper('payex/tools')->addToDebug('PxAgreement.AgreementCheck Status is ' . $agreement_status . ' (NotVerified = 0, Verified = 1, Deleted = 2)');
85
- Mage::helper('payex/tools')->addToDebug('Reserved Order for CustomerId #' . $customer_id, $order_id);
86
- Mage::helper('payex/tools')->addToDebug('Current Agreement Status for CustomerId #' . $customer_id . ' is ' . var_export($agreement_status, true));
87
- }
88
-
89
- // Check Agreement Status
90
- switch ($agreement_status) {
91
- case (PayEx_Payments_Model_Payment_Autopay::AGREEMENT_DELETED):
92
- // Remove Deleted Agreement ID
93
- $agreement->delete();
94
- case (PayEx_Payments_Model_Payment_Autopay::AGREEMENT_NOTEXISTS):
95
- // Create Agreement ID
96
- // Call PxAgreement.CreateAgreement3
97
- $params = array(
98
- 'accountNumber' => '',
99
- 'merchantRef' => $method->getConfigData('agreementurl'),
100
- 'description' => Mage::app()->getStore()->getName(),
101
- 'purchaseOperation' => $operation,
102
- 'maxAmount' => round($method->getConfigData('maxamount') * 100),
103
- 'notifyUrl' => '',
104
- 'startDate' => '',
105
- 'stopDate' => ''
106
- );
107
- $result = Mage::helper('payex/api')->getPx()->CreateAgreement3($params);
108
- Mage::helper('payex/tools')->debugApi($result, 'PxAgreement.CreateAgreement3');
109
- if ($result['code'] !== 'OK' || $result['description'] !== 'OK' || $result['errorCode'] !== 'OK') {
110
- $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
111
-
112
- // Cancel order
113
- $order->cancel();
114
- $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
115
- $order->save();
116
-
117
- // Set quote to active
118
- if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
119
- $quote = Mage::getModel('sales/quote')->load($quoteId);
120
- if ($quote->getId()) {
121
- $quote->setIsActive(true)->save();
122
- Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
123
- }
124
- }
125
-
126
- Mage::getSingleton('checkout/session')->addError($message);
127
- $this->_redirect('checkout/cart');
128
- return;
129
- }
130
-
131
- // Save Customer Agreement ID
132
- $model = Mage::getModel('payex/agreement');
133
- $model->setCustomerId($customer_id)
134
- ->setAgreementRef($result['agreementRef'])
135
- ->setCreatedAt(date('Y-m-d H:i:s', time()))
136
- ->save();
137
-
138
- Mage::helper('payex/tools')->addToDebug('Agreement for CustomerId #' . $customer_id . ' created');
139
- case (PayEx_Payments_Model_Payment_Autopay::AGREEMENT_VERIFIED):
140
- // Call PxAgreement.AutoPay3
141
- $params = array(
142
- 'accountNumber' => '',
143
- 'agreementRef' => $agreement->getAgreementRef(),
144
- 'price' => round($amount * 100),
145
- 'productNumber' => $order_id,
146
- 'description' => Mage::app()->getStore()->getName(),
147
- 'orderId' => $order_id,
148
- 'purchaseOperation' => $operation,
149
- 'currency' => $currency_code
150
- );
151
- $result = Mage::helper('payex/api')->getPx()->AutoPay3($params);
152
- Mage::helper('payex/tools')->debugApi($result, 'PxAgreement.AutoPay3');
153
-
154
- // Check errors
155
- if ($result['errorCodeSimple'] !== 'OK') {
156
- // AutoPay: NOT successful
157
- // Reset Customer Agreement
158
- Mage::helper('payex/tools')->addToDebug('Warning: AgreementId ' . $agreement->getAgreementRef() . ' of CustomerId ' . $customer_id . ' is removed!');
159
- $agreement->delete();
160
-
161
- // Try to pay again using PayEx Credit Card
162
- $redirectUrl = Mage::getUrl('payex/autopay/redirect', array('_secure' => true));
163
- $this->_redirectUrl($redirectUrl);
164
- return;
165
- }
166
-
167
- // Validate transactionStatus value
168
- if (!isset($result['transactionStatus']) || !is_numeric($result['transactionStatus'])) {
169
- // AutoPay: No transactionsStatus in response
170
- Mage::helper('payex/tools')->addToDebug('Error: No transactionsStatus in response.', $order->getIncrementId());
171
-
172
- // Reset Customer Agreement
173
- Mage::helper('payex/tools')->addToDebug('Warning: AgreementId ' . $agreement->getAgreementRef() . ' of CustomerId ' . $customer_id . ' is removed!');
174
- $agreement->delete();
175
-
176
- // Try to pay again using PayEx Credit Card
177
- $redirectUrl = Mage::getUrl('payex/autopay/redirect', array('_secure' => true));
178
- $this->_redirectUrl($redirectUrl);
179
- return;
180
- }
181
-
182
- // Redirect to Success Action
183
- Mage::getSingleton('checkout/session')->setTransaction($result);
184
- $redirectUrl = Mage::getUrl('payex/autopay/success', array('_secure' => true));
185
- $this->_redirectUrl($redirectUrl);
186
- return;
187
- }
188
-
189
- // Show Error
190
- $message = Mage::helper('payex')->__('Failed to process order');
191
-
192
- // Cancel order
193
- $order->cancel();
194
- $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
195
- $order->save();
196
-
197
- // Set quote to active
198
- if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
199
- $quote = Mage::getModel('sales/quote')->load($quoteId);
200
- if ($quote->getId()) {
201
- $quote->setIsActive(true)->save();
202
- Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
203
- }
204
- }
205
-
206
- Mage::getSingleton('checkout/session')->addError($message);
207
- $this->_redirect('checkout/cart');
208
- }
209
-
210
- public function redirectAction()
211
- {
212
- Mage::helper('payex/tools')->addToDebug('Controller: redirect');
213
-
214
- // Load Order
215
- $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
216
-
217
- /** @var Mage_Sales_Model_Order $order */
218
- $order = Mage::getModel('sales/order');
219
- $order->loadByIncrementId($order_id);
220
- if (!$order->getId()) {
221
- Mage::throwException('No order for processing found');
222
- }
223
-
224
- /** @var PayEx_Payments_Model_Payment_Abstract $method */
225
- $method = $order->getPayment()->getMethodInstance();
226
-
227
- // Get Currency code
228
- $currency_code = $order->getOrderCurrency()->getCurrencyCode();
229
-
230
- // Get Operation Type (AUTHORIZATION / SALE)
231
- $operation = ($method->getConfigData('transactiontype') == 0) ? 'AUTHORIZATION' : 'SALE';
232
-
233
- // Get CustomerId
234
- $customer_id = (Mage::getSingleton('customer/session')->isLoggedIn() == true) ? Mage::getSingleton('customer/session')->getCustomer()->getId() : '0';
235
-
236
- // Get Additional Values
237
- $additional = '';
238
-
239
- // Responsive Skinning
240
- if ($method->getConfigData('responsive') === '1') {
241
- $separator = (!empty($additional) && mb_substr($additional, -1) !== '&') ? '&' : '';
242
- $additional .= $separator . 'USECSS=RESPONSIVEDESIGN';
243
- }
244
-
245
- // Get Amount
246
- //$amount = $order->getGrandTotal();
247
- $amount = Mage::helper('payex/order')->getCalculatedOrderAmount($order)->getAmount();
248
-
249
- // Get Current Customer Agreement
250
- $agreement = Mage::getModel('payex/agreement')->load($customer_id, 'customer_id');
251
-
252
- // Call PxOrder.Initialize8
253
- $params = array(
254
- 'accountNumber' => '',
255
- 'purchaseOperation' => $operation,
256
- 'price' => round($amount * 100),
257
- 'priceArgList' => '',
258
- 'currency' => $currency_code,
259
- 'vat' => 0,
260
- 'orderID' => $order_id,
261
- 'productNumber' => $order_id,
262
- 'description' => Mage::app()->getStore()->getName(),
263
- 'clientIPAddress' => Mage::helper('core/http')->getRemoteAddr(),
264
- 'clientIdentifier' => 'USERAGENT=' . Mage::helper('core/http')->getHttpUserAgent(),
265
- 'additionalValues' => $additional,
266
- 'externalID' => '',
267
- 'returnUrl' => Mage::getUrl('payex/autopay/success', array('_secure' => true)),
268
- 'view' => 'CREDITCARD',
269
- 'agreementRef' => $agreement->getAgreementRef(),
270
- 'cancelUrl' => Mage::getUrl('payex/autopay/cancel', array('_secure' => true)),
271
- 'clientLanguage' => $method->getConfigData('clientlanguage')
272
- );
273
- $result = Mage::helper('payex/api')->getPx()->Initialize8($params);
274
- Mage::helper('payex/tools')->addToDebug('PxOrder.Initialize8:' . $result['description']);
275
-
276
- // Check Errors
277
- if ($result['code'] !== 'OK' || $result['description'] !== 'OK') {
278
- $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
279
-
280
- // Cancel order
281
- $order->cancel();
282
- $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
283
- $order->save();
284
-
285
- // Set quote to active
286
- if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
287
- $quote = Mage::getModel('sales/quote')->load($quoteId);
288
- if ($quote->getId()) {
289
- $quote->setIsActive(true)->save();
290
- Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
291
- }
292
- }
293
-
294
- Mage::getSingleton('checkout/session')->addError($message);
295
- $this->_redirect('checkout/cart');
296
- return;
297
- }
298
- $order_ref = $result['orderRef'];
299
- $redirectUrl = $result['redirectUrl'];
300
-
301
- // Add Order Lines and Orders Address
302
- if ($method->getConfigData('checkoutinfo')) {
303
- Mage::helper('payex/order')->addOrderLine($order_ref, $order);
304
- Mage::helper('payex/order')->addOrderAddress($order_ref, $order);
305
- }
306
-
307
- // Set Pending Payment status
308
- $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('payex')->__('The customer was redirected to PayEx.'));
309
- $order->save();
310
-
311
- // Redirect to PayEx
312
- header('Location: ' . $redirectUrl);
313
- exit();
314
- }
315
-
316
- public function successAction()
317
- {
318
- Mage::helper('payex/tools')->addToDebug('Controller: success');
319
-
320
- // Load Order
321
- $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
322
-
323
- /** @var Mage_Sales_Model_Order $order */
324
- $order = Mage::getModel('sales/order');
325
- $order->loadByIncrementId($order_id);
326
- if (!$order->getId()) {
327
- Mage::throwException('No order for processing found');
328
- }
329
-
330
- /** @var PayEx_Payments_Model_Payment_Abstract $method */
331
- $method = $order->getPayment()->getMethodInstance();
332
-
333
- $result = Mage::getSingleton('checkout/session')->getTransaction();
334
- if (!$result) {
335
- // Check OrderRef
336
- if (empty($_GET['orderRef'])) {
337
- $this->_redirect('checkout/cart');
338
- return;
339
- }
340
-
341
- // Call PxOrder.Complete
342
- $params = array(
343
- 'accountNumber' => '',
344
- 'orderRef' => $_GET['orderRef']
345
- );
346
- $result = Mage::helper('payex/api')->getPx()->Complete($params);
347
- Mage::helper('payex/tools')->debugApi($result, 'PxOrder.Complete');
348
- if ($result['errorCodeSimple'] !== 'OK') {
349
- // Cancel order
350
- $order->cancel();
351
- $order->addStatusHistoryComment(Mage::helper('payex')->__('Order automatically canceled. Failed to complete payment.'));
352
- $order->save();
353
-
354
- // Set quote to active
355
- if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
356
- $quote = Mage::getModel('sales/quote')->load($quoteId);
357
- if ($quote->getId()) {
358
- $quote->setIsActive(true)->save();
359
- Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
360
- }
361
- }
362
-
363
- $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
364
- Mage::getSingleton('checkout/session')->addError($message);
365
- $this->_redirect('checkout/cart');
366
- return;
367
- }
368
- }
369
-
370
- // Prevent Order cancellation when used TC
371
- if (in_array((int)$result['transactionStatus'], array(0, 3, 6)) && $order->getState() === Mage_Sales_Model_Order::STATE_CANCELED) {
372
- if ($order->getState() === Mage_Sales_Model_Order::STATE_CANCELED) {
373
- $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING);
374
- $order->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
375
- $order->save();
376
-
377
- foreach ($order->getAllItems() as $item) {
378
- $item->setQtyCanceled(0);
379
- $item->save();
380
- }
381
- }
382
-
383
- Mage::helper('payex/tools')->addToDebug('Order has been uncanceled.', $order_id);
384
- }
385
-
386
- // Process Transaction
387
- Mage::helper('payex/tools')->addToDebug('Process Payment Transaction...', $order_id);
388
- $transaction = Mage::helper('payex/order')->processPaymentTransaction($order, $result);
389
- $transaction_status = isset($result['transactionStatus']) ? (int)$result['transactionStatus'] : null;
390
-
391
- // Check Order and Transaction Result
392
- /* Transaction statuses: 0=Sale, 1=Initialize, 2=Credit, 3=Authorize, 4=Cancel, 5=Failure, 6=Capture */
393
- switch ($transaction_status) {
394
- case 0;
395
- case 1;
396
- case 3;
397
- case 6:
398
- // Select Order Status
399
- if (in_array($transaction_status, array(0, 6))) {
400
- $new_status = $method->getConfigData('order_status_capture');
401
- } elseif ($transaction_status === 3 || (isset($result['pending']) && $result['pending'] === 'true')) {
402
- $new_status = $method->getConfigData('order_status_authorize');
403
- } else {
404
- $new_status = $order->getStatus();
405
- }
406
-
407
- // Get Order Status
408
- /** @var Mage_Sales_Model_Order_Status $status */
409
- $status = Mage::helper('payex/order')->getAssignedStatus($new_status);
410
-
411
- // Change order status
412
- $order->setData('state', $status->getState());
413
- $order->setStatus($status->getStatus());
414
- $order->addStatusHistoryComment(Mage::helper('payex')->__('Order has been paid'), $new_status);
415
-
416
- // Create Invoice for Sale Transaction
417
- if (in_array($transaction_status, array(0, 6))) {
418
- $invoice = Mage::helper('payex/order')->makeInvoice($order, false);
419
- $invoice->setTransactionId($result['transactionNumber']);
420
- $invoice->save();
421
-
422
- // Update Order Totals: "Total Due" on Sale Transactions bugfix
423
- if ($transaction_status === 0) {
424
- $order->setTotalPaid($order->getTotalDue());
425
- $order->setBaseTotalPaid($order->getBaseTotalDue());
426
- $order->setTotalDue($order->getTotalDue() - $order->getTotalPaid());
427
- $order->getBaseTotalDue($order->getBaseTotalDue() - $order->getBaseTotalPaid());
428
-
429
- // Update Order Totals because API V2 don't update order totals
430
- /** @var $invoice Mage_Sales_Model_Order_Invoice */
431
- $invoice = Mage::getResourceModel('sales/order_invoice_collection')
432
- ->setOrderFilter($order->getId())->getFirstItem();
433
-
434
- $order->setTotalInvoiced($order->getTotalInvoiced() + $invoice->getGrandTotal());
435
- $order->setBaseTotalInvoiced($order->getBaseTotalInvoiced() + $invoice->getBaseGrandTotal());
436
- $order->setSubtotalInvoiced($order->getSubtotalInvoiced() + $invoice->getSubtotal());
437
- $order->setBaseSubtotalInvoiced($order->getBaseSubtotalInvoiced() + $invoice->getBaseSubtotal());
438
- $order->setTaxInvoiced($order->getTaxInvoiced() + $invoice->getTaxAmount());
439
- $order->setBaseTaxInvoiced($order->getBaseTaxInvoiced() + $invoice->getBaseTaxAmount());
440
- $order->setHiddenTaxInvoiced($order->getHiddenTaxInvoiced() + $invoice->getHiddenTaxAmount());
441
- $order->setBaseHiddenTaxInvoiced($order->getBaseHiddenTaxInvoiced() + $invoice->getBaseHiddenTaxAmount());
442
- $order->setShippingTaxInvoiced($order->getShippingTaxInvoiced() + $invoice->getShippingTaxAmount());
443
- $order->setBaseShippingTaxInvoiced($order->getBaseShippingTaxInvoiced() + $invoice->getBaseShippingTaxAmount());
444
- $order->setShippingInvoiced($order->getShippingInvoiced() + $invoice->getShippingAmount());
445
- $order->setBaseShippingInvoiced($order->getBaseShippingInvoiced() + $invoice->getBaseShippingAmount());
446
- $order->setDiscountInvoiced($order->getDiscountInvoiced() + $invoice->getDiscountAmount());
447
- $order->setBaseDiscountInvoiced($order->getBaseDiscountInvoiced() + $invoice->getBaseDiscountAmount());
448
- $order->setBaseTotalInvoicedCost($order->getBaseTotalInvoicedCost() + $invoice->getBaseCost());
449
- }
450
- }
451
-
452
- $order->save();
453
- $order->sendNewOrderEmail();
454
-
455
- // Redirect to Success Page
456
- Mage::getSingleton('checkout/session')->setLastSuccessQuoteId(Mage::getSingleton('checkout/session')->getPayexQuoteId());
457
- $this->_redirect('checkout/onepage/success', array('_secure' => true));
458
- break;
459
- default:
460
- // Cancel order
461
- if ($transaction->getIsCancel()) {
462
- Mage::helper('payex/tools')->addToDebug('Cancel: ' . $transaction->getMessage(), $order->getIncrementId());
463
-
464
- $order->cancel();
465
- $order->addStatusHistoryComment($transaction->getMessage());
466
- $order->save();
467
- $order->sendOrderUpdateEmail(true, $transaction->getMessage());
468
- }
469
-
470
- // Set quote to active
471
- if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
472
- $quote = Mage::getModel('sales/quote')->load($quoteId);
473
- if ($quote->getId()) {
474
- $quote->setIsActive(true)->save();
475
- Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
476
- }
477
- }
478
-
479
- Mage::getSingleton('checkout/session')->addError($transaction->getMessage());
480
- $this->_redirect('checkout/cart');
481
- }
482
- }
483
-
484
- public function cancelAction()
485
- {
486
- Mage::helper('payex/tools')->addToDebug('Controller: cancel');
487
-
488
- $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
489
-
490
- /** @var Mage_Sales_Model_Order $order */
491
- $order = Mage::getModel('sales/order');
492
- $order->loadByIncrementId($order_id);
493
-
494
- // Note: Cancel only non-captured orders!
495
- if (!$order->isCanceled() && !$order->hasInvoices()) {
496
- // Set Canceled State
497
- $order->cancel();
498
- $order->addStatusHistoryComment(Mage::helper('payex')->__('Order canceled by user'), Mage_Sales_Model_Order::STATE_CANCELED);
499
- $order->save();
500
- }
501
-
502
- // Set quote to active
503
- if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
504
- $quote = Mage::getModel('sales/quote')->load($quoteId);
505
- if ($quote->getId()) {
506
- $quote->setIsActive(true)->save();
507
- Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
508
- }
509
- }
510
-
511
- Mage::getSingleton('checkout/session')->addError(Mage::helper('payex')->__('Order canceled by user'));
512
- $this->_redirect('checkout/cart');
513
- }
514
-
515
- public function cancel_agreementAction()
516
- {
517
- Mage::helper('payex/tools')->addToDebug('Controller: cancel_agreement');
518
-
519
- // Get CustomerId
520
- $customer_id = (Mage::getSingleton('customer/session')->isLoggedIn() == true) ? Mage::getSingleton('customer/session')->getCustomer()->getId() : '0';
521
- $agreement = Mage::getModel('payex/agreement')->load($customer_id, 'customer_id');
522
-
523
- // Cancel Agreement
524
- if ($agreement->getId()) {
525
- // Call PxAgreement.DeleteAgreement
526
- $params = array(
527
- 'accountNumber' => '',
528
- 'agreementRef' => $agreement->getAgreementRef(),
529
- );
530
-
531
- $result = Mage::helper('payex/api')->getPx()->DeleteAgreement($params);
532
- Mage::helper('payex/tools')->debugApi($result, 'PxAgreement.DeleteAgreement');
533
- }
534
-
535
- // Remove Agreement
536
- $agreement->delete();
537
-
538
- // Redirect to back
539
- if (!empty($_SERVER['HTTP_REFERER'])) {
540
- header('Location: ' . $_SERVER['HTTP_REFERER']);
541
- exit();
542
- } else {
543
- $this->_redirect('/', array('_secure' => true));
544
- }
545
- }
546
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/PayEx/Payments/controllers/InvoiceController.php CHANGED
@@ -53,7 +53,21 @@ class PayEx_Payments_InvoiceController extends Mage_Core_Controller_Front_Action
53
  $amount = Mage::helper('payex/order')->getCalculatedOrderAmount($order)->getAmount();
54
 
55
  $ssn = Mage::getSingleton('checkout/session')->getSocialSecurtyNumber();
56
- $credit_data = Mage::getSingleton('checkout/session')->getCreditData();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
  // Call PxOrder.Initialize8
59
  $params = array(
@@ -107,7 +121,7 @@ class PayEx_Payments_InvoiceController extends Mage_Core_Controller_Front_Action
107
  Mage::helper('payex/order')->addOrderLine($order_ref, $order);
108
  Mage::helper('payex/order')->addOrderAddress($order_ref, $order);
109
 
110
- $credit_data['full_name'] = $credit_data['firstName'] . ' ' . $credit_data['lastName'];
111
 
112
  // Limit strings
113
  $limit_rules = array(
53
  $amount = Mage::helper('payex/order')->getCalculatedOrderAmount($order)->getAmount();
54
 
55
  $ssn = Mage::getSingleton('checkout/session')->getSocialSecurtyNumber();
56
+
57
+ // Credit Check is disabled
58
+ if ($method->getConfigData('credit_check')) {
59
+ $credit_data = Mage::getSingleton('checkout/session')->getCreditData();
60
+ } else {
61
+ $credit_data = array(
62
+ 'firstName' => $order->getBillingAddress()->getFirstname(),
63
+ 'lastName' => $order->getBillingAddress()->getLastname(),
64
+ 'address' => $order->getBillingAddress()->getStreetFull(),
65
+ 'postCode' => $order->getBillingAddress()->getPostcode(),
66
+ 'city' => $order->getBillingAddress()->getCity(),
67
+ 'name' => $order->getBillingAddress()->getCompany(),
68
+ 'creditCheckRef' => ''
69
+ );
70
+ }
71
 
72
  // Call PxOrder.Initialize8
73
  $params = array(
121
  Mage::helper('payex/order')->addOrderLine($order_ref, $order);
122
  Mage::helper('payex/order')->addOrderAddress($order_ref, $order);
123
 
124
+ $credit_data['full_name'] = trim($credit_data['firstName'] . ' ' . $credit_data['lastName']);
125
 
126
  // Limit strings
127
  $limit_rules = array(
app/code/community/PayEx/Payments/controllers/PaymentController.php CHANGED
@@ -63,6 +63,15 @@ class PayEx_Payments_PaymentController extends Mage_Core_Controller_Front_Action
63
  }
64
  }
65
 
 
 
 
 
 
 
 
 
 
66
  // Get Amount
67
  //$amount = $order->getGrandTotal();
68
  $amount = Mage::helper('payex/order')->getCalculatedOrderAmount($order)->getAmount();
@@ -84,7 +93,7 @@ class PayEx_Payments_PaymentController extends Mage_Core_Controller_Front_Action
84
  'externalID' => '',
85
  'returnUrl' => Mage::getUrl('payex/payment/success', array('_secure' => true)),
86
  'view' => $paymentview,
87
- 'agreementRef' => '',
88
  'cancelUrl' => Mage::getUrl('payex/payment/cancel', array('_secure' => true)),
89
  'clientLanguage' => $method->getConfigData('clientlanguage')
90
  );
@@ -222,6 +231,42 @@ class PayEx_Payments_PaymentController extends Mage_Core_Controller_Front_Action
222
  $transaction = Mage::helper('payex/order')->processPaymentTransaction($order, $result);
223
  $transaction_status = isset($result['transactionStatus']) ? (int)$result['transactionStatus'] : null;
224
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  // Check Order and Transaction Result
226
  /* Transaction statuses: 0=Sale, 1=Initialize, 2=Credit, 3=Authorize, 4=Cancel, 5=Failure, 6=Capture */
227
  switch ($transaction_status) {
63
  }
64
  }
65
 
66
+ // Get Agreement Reference
67
+ $agreement = '';
68
+ $isBARequested = (bool)$order->getPayment()
69
+ ->getAdditionalInformation(PayEx_Payments_Model_Payment_Agreement::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);
70
+ if ($isBARequested) {
71
+ $agreement = (string)$order->getPayment()
72
+ ->getAdditionalInformation(PayEx_Payments_Model_Payment_Agreement::PAYMENT_INFO_TRANSPORT_AGREEMENT_REFERENCE);
73
+ }
74
+
75
  // Get Amount
76
  //$amount = $order->getGrandTotal();
77
  $amount = Mage::helper('payex/order')->getCalculatedOrderAmount($order)->getAmount();
93
  'externalID' => '',
94
  'returnUrl' => Mage::getUrl('payex/payment/success', array('_secure' => true)),
95
  'view' => $paymentview,
96
+ 'agreementRef' => $agreement,
97
  'cancelUrl' => Mage::getUrl('payex/payment/cancel', array('_secure' => true)),
98
  'clientLanguage' => $method->getConfigData('clientlanguage')
99
  );
231
  $transaction = Mage::helper('payex/order')->processPaymentTransaction($order, $result);
232
  $transaction_status = isset($result['transactionStatus']) ? (int)$result['transactionStatus'] : null;
233
 
234
+ // Save Agreement Reference
235
+ if (!empty($result['agreementRef'])) {
236
+ /** @var Mage_Sales_Model_Billing_Agreement $billing_agreement */
237
+ $billing_agreement = Mage::getModel('sales/billing_agreement')->load($result['agreementRef'], 'reference_id');
238
+ if ($billing_agreement->getId()) {
239
+ // Verify Agreement Reference
240
+ // Call PxAgreement.AgreementCheck
241
+ $params = array(
242
+ 'accountNumber' => '',
243
+ 'agreementRef' => $result['agreementRef'],
244
+ );
245
+ $check = Mage::helper('payex/api')->getPx()->AgreementCheck($params);
246
+ Mage::helper('payex/tools')->debugApi($result, 'PxAgreement.AgreementCheck');
247
+ if ($check['code'] === 'OK' && $check['description'] === 'OK' && $check['errorCode'] === 'OK') {
248
+ $agreement_status = (int)$check['agreementStatus'];
249
+
250
+ // Check Agreement Status
251
+ switch ($agreement_status) {
252
+ case (PayEx_Payments_Model_Payment_Agreement::AGREEMENT_VERIFIED):
253
+ // Update Billing Agreement
254
+ $masked_number = Mage::helper('payex/order')->getFormattedCC($result);
255
+ $billing_agreement->setAgreementLabel($masked_number)->save();
256
+ break;
257
+ case (PayEx_Payments_Model_Payment_Agreement::AGREEMENT_NOTVERIFIED):
258
+ case (PayEx_Payments_Model_Payment_Agreement::AGREEMENT_DELETED):
259
+ case (PayEx_Payments_Model_Payment_Agreement::AGREEMENT_NOTEXISTS):
260
+ // Remove Billing Agreement
261
+ $billing_agreement->delete();
262
+ break;
263
+ default:
264
+ // no break
265
+ }
266
+ }
267
+ }
268
+ }
269
+
270
  // Check Order and Transaction Result
271
  /* Transaction statuses: 0=Sale, 1=Initialize, 2=Credit, 3=Authorize, 4=Cancel, 5=Failure, 6=Capture */
272
  switch ($transaction_status) {
app/code/community/PayEx/Payments/data/payex_setup/data-upgrade-3.0.2-3.0.3.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $orders = Mage::getModel('sales/order')->getCollection();
3
+ $orders->getSelect()->join(
4
+ array('p' => $orders->getResource()->getTable('sales/order_payment')),
5
+ 'p.parent_id = main_table.entity_id',
6
+ array()
7
+ );
8
+ $orders->addFieldToFilter('method', array('in' => array('payex_financing', 'payex_invoice', 'payex_partpayment')));
9
+ foreach ($orders as $order) {
10
+ /** @var Mage_Sales_Model_Order $order */
11
+ try {
12
+ $method = $order->getPayment()->getMethodInstance()->getCode();
13
+ } catch (Exception $e) {
14
+ continue;
15
+ }
16
+
17
+ // Process Invoices
18
+ if ($order->hasInvoices()) {
19
+ $update = false;
20
+ $invoices = $order->getInvoiceCollection();
21
+ foreach ($invoices as $invoice) {
22
+ if ($order->getBasePayexPaymentFee() > 0 && !$invoice->getBasePayexPaymentFee()) {
23
+ $invoice->setBasePayexPaymentFee($order->getBasePayexPaymentFee());
24
+ $invoice->setPayexPaymentFee($order->getPayexPaymentFee());
25
+ $invoice->setBasePayexPaymentFeeTax($order->getBasePayexPaymentFeeTax());
26
+ $invoice->setPayexPaymentFeeTax($order->getPayexPaymentFeeTax());
27
+ try {
28
+ $invoice->save();
29
+ } catch (Exception $e) {
30
+ //
31
+ }
32
+
33
+ $update = true;
34
+ }
35
+ }
36
+
37
+ if ($update) {
38
+ $order->setBasePayexPaymentFeeInvoiced($order->getBasePayexPaymentFee());
39
+ $order->setPayexPaymentFeeInvoiced($order->getPayexPaymentFee());
40
+ $order->setBasePayexPaymentFeeTaxInvoiced($order->getBasePayexPaymentFeeTax());
41
+ $order->setPayexPaymentFeeTaxInvoiced($order->getPayexPaymentFeeTax());
42
+ $order->save();
43
+ }
44
+ }
45
+
46
+ // Process CreditMemos
47
+ if ($order->hasCreditmemos()) {
48
+ $update = false;
49
+ $creditmemos = $order->getCreditmemosCollection();
50
+ foreach ($creditmemos as $creditmemo) {
51
+ if ($order->getBasePayexPaymentFee() > 0 && !$creditmemo->getBasePayexPaymentFee()) {
52
+ $creditmemo->setBasePayexPaymentFee($order->getBasePayexPaymentFee());
53
+ $creditmemo->setPayexPaymentFee($order->getPayexPaymentFee());
54
+ $creditmemo->setBasePayexPaymentFeeTax($order->getBasePayexPaymentFeeTax());
55
+ $creditmemo->setPayexPaymentFeeTax($order->getPayexPaymentFeeTax());
56
+ $creditmemo->save();
57
+
58
+ $update = true;
59
+ }
60
+ }
61
+
62
+ if ($update) {
63
+ $order->setBasePayexPaymentFeeRefunded($order->getBasePayexPaymentFee());
64
+ $order->setPayexPaymentFeeRefunded($order->getPayexPaymentFee());
65
+ $order->setBasePayexPaymentFeeTaxRefunded($order->getBasePayexPaymentFeeTax());
66
+ $order->setPayexPaymentFeeTaxRefunded($order->getPayexPaymentFeeTax());
67
+ }
68
+ }
69
+ }
app/code/community/PayEx/Payments/data/payex_setup/data-upgrade-3.0.3-3.1.0.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This script perform follow actions:
4
+ * 1) Create Billing Agreements using AutoPay References
5
+ * 2) Convert AutoPay orders to Billing Agreement orders
6
+ */
7
+
8
+ $resource = Mage::getSingleton('core/resource');
9
+ $writeConnection = $resource->getConnection('core_write');
10
+ $readConnection = $resource->getConnection('core_read');
11
+
12
+ // Convert Agreements to PayEx Billing Agreement
13
+ $default_label = Mage::helper('payex')->__('Untitled Credit Card');
14
+ $payexautopay_agreement_table = $resource->getTableName('payexautopay_agreement');
15
+ $records = $readConnection->fetchAll("SELECT * FROM {$payexautopay_agreement_table};");
16
+ foreach ($records as $record) {
17
+ $customer_id = $record['customer_id'];
18
+ $agreement_ref = $record['agreement_ref'];
19
+ $created_at = $record['created_at'];
20
+
21
+ // Skip empty lines
22
+ if (empty($agreement_ref)) {
23
+ continue;
24
+ }
25
+
26
+ // Check Billing Agreement is already exists
27
+ /** @var Mage_Sales_Model_Billing_Agreement $billing_agreement */
28
+ $billing_agreement = Mage::getModel('sales/billing_agreement')->load($agreement_ref, 'reference_id');
29
+ if ($billing_agreement->getId()) {
30
+ continue;
31
+ }
32
+
33
+ // Create Billing Agreement
34
+ $billing_agreement = Mage::getModel('sales/billing_agreement');
35
+ $billing_agreement->setCustomerId($customer_id)
36
+ ->setMethodCode(PayEx_Payments_Model_Payment_Agreement::METHOD_BILLING_AGREEMENT)
37
+ ->setReferenceId($agreement_ref)
38
+ ->setStatus(Mage_Sales_Model_Billing_Agreement::STATUS_ACTIVE)
39
+ ->setCreatedAt($created_at)
40
+ ->setAgreementLabel($default_label)
41
+ ->save();
42
+ }
43
+
44
+ // Update AutoPay Orders to use Billing Agreement
45
+ $orders = Mage::getModel('sales/order')->getCollection();
46
+ $orders->getSelect()->join(
47
+ array('p' => $orders->getResource()->getTable('sales/order_payment')),
48
+ 'p.parent_id = main_table.entity_id',
49
+ array()
50
+ );
51
+ $orders->addFieldToFilter('method', 'payex_autopay');
52
+ foreach ($orders as $order) {
53
+ /** @var Mage_Sales_Model_Order $order */
54
+ $customer_id = (int) $order->getCustomerId();
55
+ if ($customer_id > 0) {
56
+ $payexautopay_agreement_table = $resource->getTableName('payexautopay_agreement');
57
+ $agreement_ref = $readConnection->fetchOne("SELECT agreement_ref FROM {$payexautopay_agreement_table} WHERE customer_id = {$customer_id} LIMIT 1;");
58
+
59
+ /** @var Mage_Sales_Model_Billing_Agreement $billing_agreement */
60
+ $billing_agreement = Mage::getModel('sales/billing_agreement')->load($agreement_ref, 'reference_id');
61
+ if ($billing_agreement->getId()) {
62
+ // Add Order Relation
63
+ //$billing_agreement->addOrderRelation($order->getId())->save();
64
+ $billing_agreement->getResource()->addOrderRelation($billing_agreement->getId(), $order->getId());
65
+
66
+ // Set Agreement Reference
67
+ try {
68
+ $order->getPayment()->setAdditionalInformation(
69
+ Mage_Sales_Model_Payment_Method_Billing_AgreementAbstract::TRANSPORT_BILLING_AGREEMENT_ID,
70
+ $billing_agreement->getId()
71
+ );
72
+ $order->getPayment()->setAdditionalInformation(
73
+ Mage_Sales_Model_Payment_Method_Billing_AgreementAbstract::PAYMENT_INFO_REFERENCE_ID,
74
+ $billing_agreement->getReferenceId()
75
+ );
76
+ $order->getPayment()->save();
77
+ } catch (Exception $e) {
78
+ continue;
79
+ }
80
+
81
+ // Update Quote Payment
82
+ $quoteId = $order->getQuoteId();
83
+
84
+ /** @var Mage_Sales_Model_Quote $quote */
85
+ $quote = Mage::getModel('sales/quote')->setStore($order->getStore())->load($quoteId);
86
+ if ($quote) {
87
+ // Set Agreement Reference for Quote
88
+ try {
89
+ $quote->getPayment()->setAdditionalInformation(
90
+ Mage_Sales_Model_Payment_Method_Billing_AgreementAbstract::TRANSPORT_BILLING_AGREEMENT_ID,
91
+ $billing_agreement->getId()
92
+ );
93
+ $quote->getPayment()->setAdditionalInformation(
94
+ Mage_Sales_Model_Payment_Method_Billing_AgreementAbstract::PAYMENT_INFO_REFERENCE_ID,
95
+ $billing_agreement->getReferenceId()
96
+ );
97
+ $quote->getPayment()->save();
98
+ } catch (Exception $e) {
99
+ continue;
100
+ }
101
+ }
102
+
103
+ // Try to set Agreement Label
104
+ if (in_array($billing_agreement->getAgreementLabel(), array('', $default_label))) {
105
+ if ($transactionId = $order->getPayment()->getLastTransId()) {
106
+ if ($transaction = $order->getPayment()->getTransaction($transactionId)) {
107
+ $transaction_data = $transaction->getAdditionalInformation(
108
+ Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS
109
+ );
110
+ if (is_array($transaction_data)) {
111
+ if (!empty($transaction_data['maskedNumber']) || $transaction_data['maskedCard']) {
112
+ $masked_number = Mage::helper('payex/order')->getFormattedCC($transaction_data);
113
+ $billing_agreement->setAgreementLabel($masked_number)->save();
114
+ }
115
+ }
116
+ }
117
+ }
118
+ }
119
+ }
120
+ }
121
+ }
122
+
123
+ // Convert AutoPay orders to Billing Agreement orders
124
+ $method_code = PayEx_Payments_Model_Payment_Agreement::METHOD_BILLING_AGREEMENT;
125
+ $sales_flat_order_payment_table = $resource->getTableName('sales_flat_order_payment');
126
+ $sales_flat_quote_payment_table = $resource->getTableName('sales_flat_quote_payment');
127
+ $writeConnection->query("UPDATE `{$sales_flat_order_payment_table}` SET method = '{$method_code}' WHERE method = 'payex_autopay';");
128
+ $writeConnection->query("UPDATE `{$sales_flat_quote_payment_table}` SET method = '{$method_code}' WHERE method = 'payex_autopay';");
app/code/community/PayEx/Payments/etc/config.xml CHANGED
@@ -3,7 +3,7 @@
3
  <modules>
4
  <PayEx_Payments>
5
  <!-- declare module's version information for database updates -->
6
- <version>3.0.1</version>
7
  </PayEx_Payments>
8
  </modules>
9
 
@@ -18,14 +18,14 @@
18
  <resourceModel>payex_mysql4</resourceModel>
19
  </payex>
20
 
21
- <payex_mysql4>
22
  <class>PayEx_Payments_Model_Mysql4</class>
23
  <entities>
24
  <payex_agreement>
25
  <table>payexautopay_agreement</table>
26
  </payex_agreement>
27
  </entities>
28
- </payex_mysql4>
29
  </models>
30
 
31
  <!-- IMPORTANT: if you use your own namespace (i.e. CompanyName) you also have to declare blocks group for new module. See topic: http://www.magentocommerce.com/boards/viewthread/22416/#t102732 -->
@@ -76,19 +76,58 @@
76
  <after>subtotal,discount,shipping</after>
77
  <before>tax,grand_total</before>
78
  <renderer>payex/checkout_fee</renderer>
79
- <admin_renderer>payex/adminhtml_sales_order_create_totals_fee</admin_renderer>
80
  </payex_payment_fee>
 
 
 
 
 
81
  </totals>
82
  </quote>
83
  <order_invoice>
84
  <totals>
85
  <payex_payment_fee>
86
  <class>payex/invoice_total</class>
 
 
87
  </payex_payment_fee>
 
 
 
 
 
88
  </totals>
89
  </order_invoice>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  </sales>
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  <events>
93
  <sales_order_invoice_save_after>
94
  <observers>
@@ -127,7 +166,7 @@
127
  <!-- 'newmodule' configuration group (fieldset) -->
128
  <payex_cc>
129
  <!-- by default this payment method is inactive -->
130
- <active>1</active>
131
  <!-- model to handle logic for this payment method -->
132
  <model>payex/payment_CC</model>
133
  <!-- default title for payment checkout page and order view page -->
@@ -144,12 +183,23 @@
144
  <cleantime>20</cleantime>
145
  <responsive>0</responsive>
146
  <checkoutinfo>1</checkoutinfo>
 
147
  </payex_cc>
148
 
 
 
 
 
 
 
 
 
 
 
149
  <!-- 'newmodule' configuration group (fieldset) -->
150
  <payex_bankdebit>
151
  <!-- by default this payment method is inactive -->
152
- <active>1</active>
153
  <!-- model to handle logic for this payment method -->
154
  <model>payex/payment_bankdebit</model>
155
  <!-- default title for payment checkout page and order view page -->
@@ -164,12 +214,13 @@
164
  <cleantime>20</cleantime>
165
  <responsive>0</responsive>
166
  <checkoutinfo>1</checkoutinfo>
 
167
  </payex_bankdebit>
168
 
169
  <!-- 'newmodule' configuration group (fieldset) -->
170
  <payex_wywallet>
171
  <!-- by default this payment method is inactive -->
172
- <active>1</active>
173
  <!-- model to handle logic for this payment method -->
174
  <model>payex/payment_wywallet</model>
175
  <!-- default title for payment checkout page and order view page -->
@@ -185,36 +236,13 @@
185
  <cleantime>20</cleantime>
186
  <responsive>0</responsive>
187
  <checkoutinfo>1</checkoutinfo>
 
188
  </payex_wywallet>
189
 
190
- <!-- 'newmodule' configuration group (fieldset) -->
191
- <payex_autopay>
192
- <!-- by default this payment method is inactive -->
193
- <active>1</active>
194
- <!-- model to handle logic for this payment method -->
195
- <model>payex/payment_autopay</model>
196
- <!-- order status for new orders paid by this payment method -->
197
- <order_status>1</order_status>
198
- <!-- default title for payment checkout page and order view page -->
199
- <title>PayEx Credit Card One-click Payments</title>
200
- <allowspecific>0</allowspecific>
201
- <accountnumber>payex account number</accountnumber>
202
- <encryptionkey>payex encryption key</encryptionkey>
203
- <transactiontype>1</transactiontype>
204
- <debug>1</debug>
205
- <order_status>1</order_status>
206
- <clientlanguage>en-US</clientlanguage>
207
- <agreementurl>http://example.com</agreementurl>
208
- <maxamount>1000</maxamount>
209
- <cleantime>20</cleantime>
210
- <responsive>0</responsive>
211
- <checkoutinfo>1</checkoutinfo>
212
- </payex_autopay>
213
-
214
  <!-- 'newmodule' configuration group (fieldset) -->
215
  <payex_masterpass>
216
  <!-- by default this payment method is inactive -->
217
- <active>1</active>
218
  <!-- model to handle logic for this payment method -->
219
  <model>payex/payment_MasterPass</model>
220
  <!-- default title for payment checkout page and order view page -->
@@ -228,12 +256,13 @@
228
  <order_status_capture>complete</order_status_capture>
229
  <clientlanguage>en-US</clientlanguage>
230
  <cleantime>20</cleantime>
 
231
  </payex_masterpass>
232
 
233
  <!-- 'newmodule' configuration group (fieldset) -->
234
  <payex_financing>
235
  <!-- by default this payment method is inactive -->
236
- <active>1</active>
237
  <!-- model to handle logic for this payment method -->
238
  <model>payex/payment_financing</model>
239
  <!-- default title for payment checkout page and order view page -->
@@ -250,12 +279,14 @@
250
  <cleantime>20</cleantime>
251
  <replace_illegal>1</replace_illegal>
252
  <replacement_char>-</replacement_char>
 
 
253
  </payex_financing>
254
 
255
  <!-- 'newmodule' configuration group (fieldset) -->
256
  <payex_partpayment>
257
  <!-- by default this payment method is inactive -->
258
- <active>1</active>
259
  <!-- model to handle logic for this payment method -->
260
  <model>payex/payment_PartPayment</model>
261
  <!-- default title for payment checkout page and order view page -->
@@ -272,13 +303,15 @@
272
  <cleantime>20</cleantime>
273
  <replace_illegal>1</replace_illegal>
274
  <replacement_char>-</replacement_char>
 
 
275
  </payex_partpayment>
276
 
277
  <!-- 'newmodule' configuration group (fieldset) -->
278
  <payex_invoice>
279
  <!-- model to handle logic for this payment method -->
280
  <model>payex/payment_invoice</model>
281
- <active>1</active>
282
  <!-- default title for payment checkout page and order view page -->
283
  <title>PayEx Invoice Payments (Ledger Service)</title>
284
  <allowspecific>0</allowspecific>
@@ -296,12 +329,14 @@
296
  <invoicetext>Invoice text</invoicetext>
297
  <invoiceduedays>15</invoiceduedays>
298
  <unapproved>0</unapproved>
 
 
299
  </payex_invoice>
300
 
301
  <!-- 'newmodule' configuration group (fieldset) -->
302
  <payex_swish>
303
  <!-- by default this payment method is inactive -->
304
- <active>1</active>
305
  <!-- model to handle logic for this payment method -->
306
  <model>payex/payment_swish</model>
307
  <!-- default title for payment checkout page and order view page -->
@@ -315,8 +350,18 @@
315
  <cleantime>20</cleantime>
316
  <responsive>0</responsive>
317
  <checkoutinfo>1</checkoutinfo>
 
318
  </payex_swish>
319
  </payment>
 
 
 
 
 
 
 
 
 
320
  </default>
321
 
322
  <adminhtml>
3
  <modules>
4
  <PayEx_Payments>
5
  <!-- declare module's version information for database updates -->
6
+ <version>3.1.0</version>
7
  </PayEx_Payments>
8
  </modules>
9
 
18
  <resourceModel>payex_mysql4</resourceModel>
19
  </payex>
20
 
21
+ <!-- <payex_mysql4>
22
  <class>PayEx_Payments_Model_Mysql4</class>
23
  <entities>
24
  <payex_agreement>
25
  <table>payexautopay_agreement</table>
26
  </payex_agreement>
27
  </entities>
28
+ </payex_mysql4> -->
29
  </models>
30
 
31
  <!-- IMPORTANT: if you use your own namespace (i.e. CompanyName) you also have to declare blocks group for new module. See topic: http://www.magentocommerce.com/boards/viewthread/22416/#t102732 -->
76
  <after>subtotal,discount,shipping</after>
77
  <before>tax,grand_total</before>
78
  <renderer>payex/checkout_fee</renderer>
79
+ <!-- <admin_renderer>payex/adminhtml_sales_order_create_totals_fee</admin_renderer> -->
80
  </payex_payment_fee>
81
+ <payex_payment_fee_tax>
82
+ <class>payex/quote_tax</class>
83
+ <after>subtotal,discount,shipping,tax</after>
84
+ <before>grand_total</before>
85
+ </payex_payment_fee_tax>
86
  </totals>
87
  </quote>
88
  <order_invoice>
89
  <totals>
90
  <payex_payment_fee>
91
  <class>payex/invoice_total</class>
92
+ <after>subtotal,discount,shipping</after>
93
+ <before>tax,grand_total</before>
94
  </payex_payment_fee>
95
+ <payex_payment_fee_tax>
96
+ <class>payex/invoice_tax</class>
97
+ <after>subtotal,discount,shipping,tax</after>
98
+ <before>grand_total</before>
99
+ </payex_payment_fee_tax>
100
  </totals>
101
  </order_invoice>
102
+ <order_creditmemo>
103
+ <totals>
104
+ <payex_payment_fee>
105
+ <class>payex/creditmemo_total</class>
106
+ <after>subtotal,discount,shipping</after>
107
+ <before>tax,grand_total</before>
108
+ </payex_payment_fee>
109
+ <payex_payment_fee_tax>
110
+ <class>payex/creditmemo_tax</class>
111
+ <after>subtotal,discount,shipping,tax</after>
112
+ <before>grand_total</before>
113
+ </payex_payment_fee_tax>
114
+ </totals>
115
+ </order_creditmemo>
116
  </sales>
117
 
118
+ <pdf>
119
+ <totals>
120
+ <payex_payment_fee translate="title">
121
+ <title>Payment fee</title>
122
+ <source_field>payment_fee</source_field>
123
+ <font_size>7</font_size>
124
+ <display_zero>0</display_zero>
125
+ <sort_order>550</sort_order>
126
+ <model>payex/invoice_pdf_total</model>
127
+ </payex_payment_fee>
128
+ </totals>
129
+ </pdf>
130
+
131
  <events>
132
  <sales_order_invoice_save_after>
133
  <observers>
166
  <!-- 'newmodule' configuration group (fieldset) -->
167
  <payex_cc>
168
  <!-- by default this payment method is inactive -->
169
+ <active>0</active>
170
  <!-- model to handle logic for this payment method -->
171
  <model>payex/payment_CC</model>
172
  <!-- default title for payment checkout page and order view page -->
183
  <cleantime>20</cleantime>
184
  <responsive>0</responsive>
185
  <checkoutinfo>1</checkoutinfo>
186
+ <discount_calc>advanced</discount_calc>
187
  </payex_cc>
188
 
189
+ <payex_billing_agreement>
190
+ <active>0</active>
191
+ <model>payex/payment_agreement</model>
192
+ <title>PayEx Billing Agreement</title>
193
+ <transactiontype>1</transactiontype>
194
+ <allow_billing_agreement_wizard>0</allow_billing_agreement_wizard>
195
+ <agreementurl>http://example.com</agreementurl>
196
+ <maxamount>1000</maxamount>
197
+ </payex_billing_agreement>
198
+
199
  <!-- 'newmodule' configuration group (fieldset) -->
200
  <payex_bankdebit>
201
  <!-- by default this payment method is inactive -->
202
+ <active>0</active>
203
  <!-- model to handle logic for this payment method -->
204
  <model>payex/payment_bankdebit</model>
205
  <!-- default title for payment checkout page and order view page -->
214
  <cleantime>20</cleantime>
215
  <responsive>0</responsive>
216
  <checkoutinfo>1</checkoutinfo>
217
+ <discount_calc>advanced</discount_calc>
218
  </payex_bankdebit>
219
 
220
  <!-- 'newmodule' configuration group (fieldset) -->
221
  <payex_wywallet>
222
  <!-- by default this payment method is inactive -->
223
+ <active>0</active>
224
  <!-- model to handle logic for this payment method -->
225
  <model>payex/payment_wywallet</model>
226
  <!-- default title for payment checkout page and order view page -->
236
  <cleantime>20</cleantime>
237
  <responsive>0</responsive>
238
  <checkoutinfo>1</checkoutinfo>
239
+ <discount_calc>advanced</discount_calc>
240
  </payex_wywallet>
241
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  <!-- 'newmodule' configuration group (fieldset) -->
243
  <payex_masterpass>
244
  <!-- by default this payment method is inactive -->
245
+ <active>0</active>
246
  <!-- model to handle logic for this payment method -->
247
  <model>payex/payment_MasterPass</model>
248
  <!-- default title for payment checkout page and order view page -->
256
  <order_status_capture>complete</order_status_capture>
257
  <clientlanguage>en-US</clientlanguage>
258
  <cleantime>20</cleantime>
259
+ <discount_calc>advanced</discount_calc>
260
  </payex_masterpass>
261
 
262
  <!-- 'newmodule' configuration group (fieldset) -->
263
  <payex_financing>
264
  <!-- by default this payment method is inactive -->
265
+ <active>0</active>
266
  <!-- model to handle logic for this payment method -->
267
  <model>payex/payment_financing</model>
268
  <!-- default title for payment checkout page and order view page -->
279
  <cleantime>20</cleantime>
280
  <replace_illegal>1</replace_illegal>
281
  <replacement_char>-</replacement_char>
282
+ <ssn_check>1</ssn_check>
283
+ <discount_calc>advanced</discount_calc>
284
  </payex_financing>
285
 
286
  <!-- 'newmodule' configuration group (fieldset) -->
287
  <payex_partpayment>
288
  <!-- by default this payment method is inactive -->
289
+ <active>0</active>
290
  <!-- model to handle logic for this payment method -->
291
  <model>payex/payment_PartPayment</model>
292
  <!-- default title for payment checkout page and order view page -->
303
  <cleantime>20</cleantime>
304
  <replace_illegal>1</replace_illegal>
305
  <replacement_char>-</replacement_char>
306
+ <ssn_check>1</ssn_check>
307
+ <discount_calc>advanced</discount_calc>
308
  </payex_partpayment>
309
 
310
  <!-- 'newmodule' configuration group (fieldset) -->
311
  <payex_invoice>
312
  <!-- model to handle logic for this payment method -->
313
  <model>payex/payment_invoice</model>
314
+ <active>0</active>
315
  <!-- default title for payment checkout page and order view page -->
316
  <title>PayEx Invoice Payments (Ledger Service)</title>
317
  <allowspecific>0</allowspecific>
329
  <invoicetext>Invoice text</invoicetext>
330
  <invoiceduedays>15</invoiceduedays>
331
  <unapproved>0</unapproved>
332
+ <credit_check>0</credit_check>
333
+ <discount_calc>advanced</discount_calc>
334
  </payex_invoice>
335
 
336
  <!-- 'newmodule' configuration group (fieldset) -->
337
  <payex_swish>
338
  <!-- by default this payment method is inactive -->
339
+ <active>0</active>
340
  <!-- model to handle logic for this payment method -->
341
  <model>payex/payment_swish</model>
342
  <!-- default title for payment checkout page and order view page -->
350
  <cleantime>20</cleantime>
351
  <responsive>0</responsive>
352
  <checkoutinfo>1</checkoutinfo>
353
+ <discount_calc>advanced</discount_calc>
354
  </payex_swish>
355
  </payment>
356
+
357
+ <tax>
358
+ <cart_display>
359
+ <payex_fee>3</payex_fee>
360
+ </cart_display>
361
+ <sales_display>
362
+ <payex_fee>3</payex_fee>
363
+ </sales_display>
364
+ </tax>
365
  </default>
366
 
367
  <adminhtml>
app/code/community/PayEx/Payments/etc/system.xml CHANGED
@@ -25,7 +25,7 @@
25
  <!-- will have title 'New Module' -->
26
  <label>PayEx Payments</label>
27
  <!-- position between other payment methods -->
28
- <sort_order>610</sort_order>
29
  <!-- do not show this configuration options in store scope -->
30
  <show_in_default>1</show_in_default>
31
  <show_in_website>1</show_in_website>
@@ -188,31 +188,35 @@
188
  <show_in_website>1</show_in_website>
189
  <show_in_store>1</show_in_store>
190
  </checkoutinfo>
 
 
 
 
 
 
 
 
 
 
191
  </fields>
192
  </payex_cc>
193
 
194
- <!-- newmodule fieldset -->
195
- <payex_bankdebit translate="label" module="payex">
196
  <!-- will have title 'New Module' -->
197
- <label>PayEx Bank Debit</label>
198
  <!-- position between other payment methods -->
199
- <sort_order>611</sort_order>
200
  <!-- do not show this configuration options in store scope -->
201
  <show_in_default>1</show_in_default>
202
  <show_in_website>1</show_in_website>
203
- <show_in_store>0</show_in_store>
 
204
  <fields>
205
- <!-- is this payment method active for the website? -->
206
  <active translate="label">
207
- <!-- label for the field -->
208
- <label>Enabled</label>
209
- <!-- input type for configuration value -->
210
  <frontend_type>select</frontend_type>
211
- <!-- model to take the option values from -->
212
  <source_model>adminhtml/system_config_source_yesno</source_model>
213
- <!-- field position -->
214
  <sort_order>1</sort_order>
215
- <!-- do not show this field in store scope -->
216
  <show_in_default>1</show_in_default>
217
  <show_in_website>1</show_in_website>
218
  <show_in_store>1</show_in_store>
@@ -220,6 +224,7 @@
220
 
221
  <title translate="label">
222
  <label>Title</label>
 
223
  <frontend_type>text</frontend_type>
224
  <sort_order>2</sort_order>
225
  <show_in_default>1</show_in_default>
@@ -227,10 +232,20 @@
227
  <show_in_store>1</show_in_store>
228
  </title>
229
 
 
 
 
 
 
 
 
 
 
 
230
  <allowspecific translate="label">
231
  <label>Payment to applicable countries</label>
232
  <frontend_type>allowspecific</frontend_type>
233
- <sort_order>3</sort_order>
234
  <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
235
  <show_in_default>1</show_in_default>
236
  <show_in_website>1</show_in_website>
@@ -240,117 +255,53 @@
240
  <specificcountry translate="label">
241
  <label>Payment to Specific countries</label>
242
  <frontend_type>multiselect</frontend_type>
243
- <sort_order>4</sort_order>
244
  <source_model>adminhtml/system_config_source_country</source_model>
245
  <show_in_default>1</show_in_default>
246
  <show_in_website>1</show_in_website>
247
  <show_in_store>1</show_in_store>
248
  </specificcountry>
249
 
250
- <debug translate="label">
251
- <label>Enable test mode</label>
252
  <frontend_type>select</frontend_type>
253
- <source_model>adminhtml/system_config_source_yesno</source_model>
254
- <sort_order>5</sort_order>
255
- <show_in_default>1</show_in_default>
256
- <show_in_website>1</show_in_website>
257
- <show_in_store>0</show_in_store>
258
- </debug>
259
-
260
- <accountnumber>
261
- <label>Account Number</label>
262
- <frontend_type>text</frontend_type>
263
  <sort_order>6</sort_order>
264
  <show_in_default>1</show_in_default>
265
  <show_in_website>1</show_in_website>
266
  <show_in_store>1</show_in_store>
267
- </accountnumber>
268
 
269
- <encryptionkey>
270
- <label>Encryption Key</label>
271
  <frontend_type>text</frontend_type>
272
  <sort_order>7</sort_order>
273
  <show_in_default>1</show_in_default>
274
  <show_in_website>1</show_in_website>
275
  <show_in_store>1</show_in_store>
276
- </encryptionkey>
277
-
278
- <order_status translate="label">
279
- <label>New order status</label>
280
- <frontend_type>select</frontend_type>
281
- <source_model>adminhtml/system_config_source_order_status</source_model>
282
- <sort_order>8</sort_order>
283
- <show_in_default>1</show_in_default>
284
- <show_in_website>1</show_in_website>
285
- <show_in_store>1</show_in_store>
286
- </order_status>
287
-
288
- <banks translate="label">
289
- <label>Available banks</label>
290
- <frontend_type>multiselect</frontend_type>
291
- <sort_order>9</sort_order>
292
- <source_model>payex/source_banks</source_model>
293
- <show_in_default>1</show_in_default>
294
- <show_in_website>1</show_in_website>
295
- <show_in_store>1</show_in_store>
296
- </banks>
297
-
298
- <clientlanguage translate="label">
299
- <label>Client language</label>
300
- <frontend_type>select</frontend_type>
301
- <source_model>payex/source_clientLanguage</source_model>
302
- <sort_order>10</sort_order>
303
- <show_in_default>1</show_in_default>
304
- <show_in_website>1</show_in_website>
305
- <show_in_store>1</show_in_store>
306
- </clientlanguage>
307
 
308
- <cleantime translate="label">
309
- <label>Time to clean pending orders (0 - disabled)</label>
310
  <frontend_type>text</frontend_type>
311
- <sort_order>11</sort_order>
312
- <show_in_default>1</show_in_default>
313
- <show_in_website>1</show_in_website>
314
- <show_in_store>1</show_in_store>
315
- </cleantime>
316
-
317
- <responsive translate="label">
318
- <!-- label for the field -->
319
- <label>Enable Responsive Skinning</label>
320
- <!-- input type for configuration value -->
321
- <frontend_type>select</frontend_type>
322
- <!-- model to take the option values from -->
323
- <source_model>adminhtml/system_config_source_yesno</source_model>
324
- <!-- field position -->
325
- <sort_order>12</sort_order>
326
- <!-- do not show this field in store scope -->
327
- <show_in_default>1</show_in_default>
328
- <show_in_website>1</show_in_website>
329
- <show_in_store>1</show_in_store>
330
- </responsive>
331
-
332
- <checkoutinfo translate="label">
333
- <label>Send order lines and billing/delivery addresses to PayEx</label>
334
- <frontend_type>select</frontend_type>
335
- <source_model>adminhtml/system_config_source_yesno</source_model>
336
- <sort_order>13</sort_order>
337
  <show_in_default>1</show_in_default>
338
  <show_in_website>1</show_in_website>
339
  <show_in_store>1</show_in_store>
340
- </checkoutinfo>
341
  </fields>
342
- </payex_bankdebit>
343
 
344
  <!-- newmodule fieldset -->
345
- <payex_wywallet translate="label" module="payex">
346
  <!-- will have title 'New Module' -->
347
- <label>PayEx WyWallet</label>
348
  <!-- position between other payment methods -->
349
- <sort_order>612</sort_order>
350
  <!-- do not show this configuration options in store scope -->
351
  <show_in_default>1</show_in_default>
352
  <show_in_website>1</show_in_website>
353
- <show_in_store>1</show_in_store>
354
  <fields>
355
  <!-- is this payment method active for the website? -->
356
  <active translate="label">
@@ -380,7 +331,7 @@
380
  <allowspecific translate="label">
381
  <label>Payment to applicable countries</label>
382
  <frontend_type>allowspecific</frontend_type>
383
- <sort_order>4</sort_order>
384
  <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
385
  <show_in_default>1</show_in_default>
386
  <show_in_website>1</show_in_website>
@@ -390,7 +341,7 @@
390
  <specificcountry translate="label">
391
  <label>Payment to Specific countries</label>
392
  <frontend_type>multiselect</frontend_type>
393
- <sort_order>5</sort_order>
394
  <source_model>adminhtml/system_config_source_country</source_model>
395
  <show_in_default>1</show_in_default>
396
  <show_in_website>1</show_in_website>
@@ -401,16 +352,16 @@
401
  <label>Enable test mode</label>
402
  <frontend_type>select</frontend_type>
403
  <source_model>adminhtml/system_config_source_yesno</source_model>
404
- <sort_order>6</sort_order>
405
  <show_in_default>1</show_in_default>
406
  <show_in_website>1</show_in_website>
407
- <show_in_store>1</show_in_store>
408
  </debug>
409
 
410
  <accountnumber>
411
  <label>Account Number</label>
412
  <frontend_type>text</frontend_type>
413
- <sort_order>7</sort_order>
414
  <show_in_default>1</show_in_default>
415
  <show_in_website>1</show_in_website>
416
  <show_in_store>1</show_in_store>
@@ -419,47 +370,37 @@
419
  <encryptionkey>
420
  <label>Encryption Key</label>
421
  <frontend_type>text</frontend_type>
422
- <sort_order>8</sort_order>
423
  <show_in_default>1</show_in_default>
424
  <show_in_website>1</show_in_website>
425
  <show_in_store>1</show_in_store>
426
  </encryptionkey>
427
 
428
- <transactiontype translate="label">
429
- <label>Transaction Type</label>
430
- <frontend_type>select</frontend_type>
431
- <source_model>payex/source_paymentAction</source_model>
432
- <sort_order>9</sort_order>
433
- <show_in_default>1</show_in_default>
434
- <show_in_website>1</show_in_website>
435
- <show_in_store>1</show_in_store>
436
- </transactiontype>
437
-
438
- <order_status_authorize translate="label">
439
- <label>Order status (for authorize)</label>
440
  <frontend_type>select</frontend_type>
441
  <source_model>adminhtml/system_config_source_order_status</source_model>
442
- <sort_order>10</sort_order>
443
  <show_in_default>1</show_in_default>
444
  <show_in_website>1</show_in_website>
445
  <show_in_store>1</show_in_store>
446
- </order_status_authorize>
447
 
448
- <order_status_capture translate="label">
449
- <label>Order status (for capture)</label>
450
- <frontend_type>select</frontend_type>
451
- <source_model>adminhtml/system_config_source_order_status</source_model>
452
- <sort_order>11</sort_order>
453
  <show_in_default>1</show_in_default>
454
  <show_in_website>1</show_in_website>
455
  <show_in_store>1</show_in_store>
456
- </order_status_capture>
457
 
458
  <clientlanguage translate="label">
459
  <label>Client language</label>
460
  <frontend_type>select</frontend_type>
461
  <source_model>payex/source_clientLanguage</source_model>
462
- <sort_order>12</sort_order>
463
  <show_in_default>1</show_in_default>
464
  <show_in_website>1</show_in_website>
465
  <show_in_store>1</show_in_store>
@@ -468,7 +409,7 @@
468
  <cleantime translate="label">
469
  <label>Time to clean pending orders (0 - disabled)</label>
470
  <frontend_type>text</frontend_type>
471
- <sort_order>13</sort_order>
472
  <show_in_default>1</show_in_default>
473
  <show_in_website>1</show_in_website>
474
  <show_in_store>1</show_in_store>
@@ -482,7 +423,7 @@
482
  <!-- model to take the option values from -->
483
  <source_model>adminhtml/system_config_source_yesno</source_model>
484
  <!-- field position -->
485
- <sort_order>14</sort_order>
486
  <!-- do not show this field in store scope -->
487
  <show_in_default>1</show_in_default>
488
  <show_in_website>1</show_in_website>
@@ -493,20 +434,30 @@
493
  <label>Send order lines and billing/delivery addresses to PayEx</label>
494
  <frontend_type>select</frontend_type>
495
  <source_model>adminhtml/system_config_source_yesno</source_model>
496
- <sort_order>15</sort_order>
497
  <show_in_default>1</show_in_default>
498
  <show_in_website>1</show_in_website>
499
  <show_in_store>1</show_in_store>
500
  </checkoutinfo>
 
 
 
 
 
 
 
 
 
 
501
  </fields>
502
- </payex_wywallet>
503
 
504
  <!-- newmodule fieldset -->
505
- <payex_autopay translate="label" module="payex">
506
  <!-- will have title 'New Module' -->
507
- <label>PayEx Credit Card One-click Payments</label>
508
  <!-- position between other payment methods -->
509
- <sort_order>613</sort_order>
510
  <!-- do not show this configuration options in store scope -->
511
  <show_in_default>1</show_in_default>
512
  <show_in_website>1</show_in_website>
@@ -540,7 +491,7 @@
540
  <allowspecific translate="label">
541
  <label>Payment to applicable countries</label>
542
  <frontend_type>allowspecific</frontend_type>
543
- <sort_order>3</sort_order>
544
  <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
545
  <show_in_default>1</show_in_default>
546
  <show_in_website>1</show_in_website>
@@ -550,7 +501,7 @@
550
  <specificcountry translate="label">
551
  <label>Payment to Specific countries</label>
552
  <frontend_type>multiselect</frontend_type>
553
- <sort_order>4</sort_order>
554
  <source_model>adminhtml/system_config_source_country</source_model>
555
  <show_in_default>1</show_in_default>
556
  <show_in_website>1</show_in_website>
@@ -561,7 +512,7 @@
561
  <label>Enable test mode</label>
562
  <frontend_type>select</frontend_type>
563
  <source_model>adminhtml/system_config_source_yesno</source_model>
564
- <sort_order>5</sort_order>
565
  <show_in_default>1</show_in_default>
566
  <show_in_website>1</show_in_website>
567
  <show_in_store>1</show_in_store>
@@ -570,7 +521,7 @@
570
  <accountnumber>
571
  <label>Account Number</label>
572
  <frontend_type>text</frontend_type>
573
- <sort_order>6</sort_order>
574
  <show_in_default>1</show_in_default>
575
  <show_in_website>1</show_in_website>
576
  <show_in_store>1</show_in_store>
@@ -579,7 +530,7 @@
579
  <encryptionkey>
580
  <label>Encryption Key</label>
581
  <frontend_type>text</frontend_type>
582
- <sort_order>7</sort_order>
583
  <show_in_default>1</show_in_default>
584
  <show_in_website>1</show_in_website>
585
  <show_in_store>1</show_in_store>
@@ -589,7 +540,7 @@
589
  <label>Transaction Type</label>
590
  <frontend_type>select</frontend_type>
591
  <source_model>payex/source_paymentAction</source_model>
592
- <sort_order>8</sort_order>
593
  <show_in_default>1</show_in_default>
594
  <show_in_website>1</show_in_website>
595
  <show_in_store>1</show_in_store>
@@ -599,7 +550,7 @@
599
  <label>Order status (for authorize)</label>
600
  <frontend_type>select</frontend_type>
601
  <source_model>adminhtml/system_config_source_order_status</source_model>
602
- <sort_order>9</sort_order>
603
  <show_in_default>1</show_in_default>
604
  <show_in_website>1</show_in_website>
605
  <show_in_store>1</show_in_store>
@@ -609,7 +560,7 @@
609
  <label>Order status (for capture)</label>
610
  <frontend_type>select</frontend_type>
611
  <source_model>adminhtml/system_config_source_order_status</source_model>
612
- <sort_order>10</sort_order>
613
  <show_in_default>1</show_in_default>
614
  <show_in_website>1</show_in_website>
615
  <show_in_store>1</show_in_store>
@@ -619,34 +570,16 @@
619
  <label>Client language</label>
620
  <frontend_type>select</frontend_type>
621
  <source_model>payex/source_clientLanguage</source_model>
622
- <sort_order>11</sort_order>
623
- <show_in_default>1</show_in_default>
624
- <show_in_website>1</show_in_website>
625
- <show_in_store>1</show_in_store>
626
- </clientlanguage>
627
-
628
- <agreementurl translate="label">
629
- <label>Agreement url</label>
630
- <frontend_type>text</frontend_type>
631
  <sort_order>12</sort_order>
632
  <show_in_default>1</show_in_default>
633
  <show_in_website>1</show_in_website>
634
  <show_in_store>1</show_in_store>
635
- </agreementurl>
636
-
637
- <maxamount translate="label">
638
- <label>Max amount of single transaction</label>
639
- <frontend_type>text</frontend_type>
640
- <sort_order>13</sort_order>
641
- <show_in_default>1</show_in_default>
642
- <show_in_website>1</show_in_website>
643
- <show_in_store>1</show_in_store>
644
- </maxamount>
645
 
646
  <cleantime translate="label">
647
  <label>Time to clean pending orders (0 - disabled)</label>
648
  <frontend_type>text</frontend_type>
649
- <sort_order>14</sort_order>
650
  <show_in_default>1</show_in_default>
651
  <show_in_website>1</show_in_website>
652
  <show_in_store>1</show_in_store>
@@ -660,7 +593,7 @@
660
  <!-- model to take the option values from -->
661
  <source_model>adminhtml/system_config_source_yesno</source_model>
662
  <!-- field position -->
663
- <sort_order>15</sort_order>
664
  <!-- do not show this field in store scope -->
665
  <show_in_default>1</show_in_default>
666
  <show_in_website>1</show_in_website>
@@ -671,13 +604,23 @@
671
  <label>Send order lines and billing/delivery addresses to PayEx</label>
672
  <frontend_type>select</frontend_type>
673
  <source_model>adminhtml/system_config_source_yesno</source_model>
674
- <sort_order>16</sort_order>
675
  <show_in_default>1</show_in_default>
676
  <show_in_website>1</show_in_website>
677
  <show_in_store>1</show_in_store>
678
  </checkoutinfo>
 
 
 
 
 
 
 
 
 
 
679
  </fields>
680
- </payex_autopay>
681
 
682
  <!-- newmodule fieldset -->
683
  <payex_masterpass translate="label" module="payex">
@@ -821,6 +764,16 @@
821
  <show_in_website>1</show_in_website>
822
  <show_in_store>1</show_in_store>
823
  </shipping_method>
 
 
 
 
 
 
 
 
 
 
824
  </fields>
825
  </payex_masterpass>
826
 
@@ -984,6 +937,26 @@
984
  <show_in_website>1</show_in_website>
985
  <show_in_store>1</show_in_store>
986
  </replacement_char>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
987
  </fields>
988
  </payex_financing>
989
 
@@ -1147,6 +1120,26 @@
1147
  <show_in_website>1</show_in_website>
1148
  <show_in_store>1</show_in_store>
1149
  </replacement_char>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1150
  </fields>
1151
  </payex_partpayment>
1152
 
@@ -1339,6 +1332,26 @@
1339
  <show_in_website>1</show_in_website>
1340
  <show_in_store>1</show_in_store>
1341
  </unapproved>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1342
  </fields>
1343
  </payex_invoice>
1344
 
@@ -1479,6 +1492,16 @@
1479
  <show_in_website>1</show_in_website>
1480
  <show_in_store>1</show_in_store>
1481
  </checkoutinfo>
 
 
 
 
 
 
 
 
 
 
1482
  </fields>
1483
  </payex_swish>
1484
  </groups>
@@ -1542,5 +1565,35 @@
1542
  </payex_ssn>
1543
  </groups>
1544
  </payex_ssn>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1545
  </sections>
1546
  </config>
25
  <!-- will have title 'New Module' -->
26
  <label>PayEx Payments</label>
27
  <!-- position between other payment methods -->
28
+ <sort_order>609</sort_order>
29
  <!-- do not show this configuration options in store scope -->
30
  <show_in_default>1</show_in_default>
31
  <show_in_website>1</show_in_website>
188
  <show_in_website>1</show_in_website>
189
  <show_in_store>1</show_in_store>
190
  </checkoutinfo>
191
+
192
+ <discount_calc translate="label">
193
+ <label>Discount Calculation</label>
194
+ <frontend_type>select</frontend_type>
195
+ <source_model>payex/source_discountCalculation</source_model>
196
+ <sort_order>16</sort_order>
197
+ <show_in_default>1</show_in_default>
198
+ <show_in_website>1</show_in_website>
199
+ <show_in_store>1</show_in_store>
200
+ </discount_calc>
201
  </fields>
202
  </payex_cc>
203
 
204
+ <payex_billing_agreement>
 
205
  <!-- will have title 'New Module' -->
206
+ <label>PayEx Billing Agreement</label>
207
  <!-- position between other payment methods -->
208
+ <sort_order>610</sort_order>
209
  <!-- do not show this configuration options in store scope -->
210
  <show_in_default>1</show_in_default>
211
  <show_in_website>1</show_in_website>
212
+ <show_in_store>1</show_in_store>
213
+ <comment><![CDATA[This payment module provide PayEx Billing Agreement Payments.]]></comment>
214
  <fields>
 
215
  <active translate="label">
216
+ <label>Enable Billing Agreement</label>
 
 
217
  <frontend_type>select</frontend_type>
 
218
  <source_model>adminhtml/system_config_source_yesno</source_model>
 
219
  <sort_order>1</sort_order>
 
220
  <show_in_default>1</show_in_default>
221
  <show_in_website>1</show_in_website>
222
  <show_in_store>1</show_in_store>
224
 
225
  <title translate="label">
226
  <label>Title</label>
227
+ <config_path>payment/paypal_billing_agreement/title</config_path>
228
  <frontend_type>text</frontend_type>
229
  <sort_order>2</sort_order>
230
  <show_in_default>1</show_in_default>
232
  <show_in_store>1</show_in_store>
233
  </title>
234
 
235
+ <sort_order translate="label">
236
+ <label>Sort Order</label>
237
+ <frontend_type>text</frontend_type>
238
+ <sort_order>3</sort_order>
239
+ <show_in_default>1</show_in_default>
240
+ <show_in_website>1</show_in_website>
241
+ <show_in_store>1</show_in_store>
242
+ <frontend_class>validate-number</frontend_class>
243
+ </sort_order>
244
+
245
  <allowspecific translate="label">
246
  <label>Payment to applicable countries</label>
247
  <frontend_type>allowspecific</frontend_type>
248
+ <sort_order>4</sort_order>
249
  <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
250
  <show_in_default>1</show_in_default>
251
  <show_in_website>1</show_in_website>
255
  <specificcountry translate="label">
256
  <label>Payment to Specific countries</label>
257
  <frontend_type>multiselect</frontend_type>
258
+ <sort_order>5</sort_order>
259
  <source_model>adminhtml/system_config_source_country</source_model>
260
  <show_in_default>1</show_in_default>
261
  <show_in_website>1</show_in_website>
262
  <show_in_store>1</show_in_store>
263
  </specificcountry>
264
 
265
+ <transactiontype translate="label">
266
+ <label>Transaction Type</label>
267
  <frontend_type>select</frontend_type>
268
+ <source_model>payex/source_paymentAction</source_model>
 
 
 
 
 
 
 
 
 
269
  <sort_order>6</sort_order>
270
  <show_in_default>1</show_in_default>
271
  <show_in_website>1</show_in_website>
272
  <show_in_store>1</show_in_store>
273
+ </transactiontype>
274
 
275
+ <agreementurl translate="label">
276
+ <label>Agreement url</label>
277
  <frontend_type>text</frontend_type>
278
  <sort_order>7</sort_order>
279
  <show_in_default>1</show_in_default>
280
  <show_in_website>1</show_in_website>
281
  <show_in_store>1</show_in_store>
282
+ </agreementurl>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
 
284
+ <maxamount translate="label">
285
+ <label>Max amount of single transaction</label>
286
  <frontend_type>text</frontend_type>
287
+ <sort_order>8</sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  <show_in_default>1</show_in_default>
289
  <show_in_website>1</show_in_website>
290
  <show_in_store>1</show_in_store>
291
+ </maxamount>
292
  </fields>
293
+ </payex_billing_agreement>
294
 
295
  <!-- newmodule fieldset -->
296
+ <payex_bankdebit translate="label" module="payex">
297
  <!-- will have title 'New Module' -->
298
+ <label>PayEx Bank Debit</label>
299
  <!-- position between other payment methods -->
300
+ <sort_order>611</sort_order>
301
  <!-- do not show this configuration options in store scope -->
302
  <show_in_default>1</show_in_default>
303
  <show_in_website>1</show_in_website>
304
+ <show_in_store>0</show_in_store>
305
  <fields>
306
  <!-- is this payment method active for the website? -->
307
  <active translate="label">
331
  <allowspecific translate="label">
332
  <label>Payment to applicable countries</label>
333
  <frontend_type>allowspecific</frontend_type>
334
+ <sort_order>3</sort_order>
335
  <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
336
  <show_in_default>1</show_in_default>
337
  <show_in_website>1</show_in_website>
341
  <specificcountry translate="label">
342
  <label>Payment to Specific countries</label>
343
  <frontend_type>multiselect</frontend_type>
344
+ <sort_order>4</sort_order>
345
  <source_model>adminhtml/system_config_source_country</source_model>
346
  <show_in_default>1</show_in_default>
347
  <show_in_website>1</show_in_website>
352
  <label>Enable test mode</label>
353
  <frontend_type>select</frontend_type>
354
  <source_model>adminhtml/system_config_source_yesno</source_model>
355
+ <sort_order>5</sort_order>
356
  <show_in_default>1</show_in_default>
357
  <show_in_website>1</show_in_website>
358
+ <show_in_store>0</show_in_store>
359
  </debug>
360
 
361
  <accountnumber>
362
  <label>Account Number</label>
363
  <frontend_type>text</frontend_type>
364
+ <sort_order>6</sort_order>
365
  <show_in_default>1</show_in_default>
366
  <show_in_website>1</show_in_website>
367
  <show_in_store>1</show_in_store>
370
  <encryptionkey>
371
  <label>Encryption Key</label>
372
  <frontend_type>text</frontend_type>
373
+ <sort_order>7</sort_order>
374
  <show_in_default>1</show_in_default>
375
  <show_in_website>1</show_in_website>
376
  <show_in_store>1</show_in_store>
377
  </encryptionkey>
378
 
379
+ <order_status translate="label">
380
+ <label>New order status</label>
 
 
 
 
 
 
 
 
 
 
381
  <frontend_type>select</frontend_type>
382
  <source_model>adminhtml/system_config_source_order_status</source_model>
383
+ <sort_order>8</sort_order>
384
  <show_in_default>1</show_in_default>
385
  <show_in_website>1</show_in_website>
386
  <show_in_store>1</show_in_store>
387
+ </order_status>
388
 
389
+ <banks translate="label">
390
+ <label>Available banks</label>
391
+ <frontend_type>multiselect</frontend_type>
392
+ <sort_order>9</sort_order>
393
+ <source_model>payex/source_banks</source_model>
394
  <show_in_default>1</show_in_default>
395
  <show_in_website>1</show_in_website>
396
  <show_in_store>1</show_in_store>
397
+ </banks>
398
 
399
  <clientlanguage translate="label">
400
  <label>Client language</label>
401
  <frontend_type>select</frontend_type>
402
  <source_model>payex/source_clientLanguage</source_model>
403
+ <sort_order>10</sort_order>
404
  <show_in_default>1</show_in_default>
405
  <show_in_website>1</show_in_website>
406
  <show_in_store>1</show_in_store>
409
  <cleantime translate="label">
410
  <label>Time to clean pending orders (0 - disabled)</label>
411
  <frontend_type>text</frontend_type>
412
+ <sort_order>11</sort_order>
413
  <show_in_default>1</show_in_default>
414
  <show_in_website>1</show_in_website>
415
  <show_in_store>1</show_in_store>
423
  <!-- model to take the option values from -->
424
  <source_model>adminhtml/system_config_source_yesno</source_model>
425
  <!-- field position -->
426
+ <sort_order>12</sort_order>
427
  <!-- do not show this field in store scope -->
428
  <show_in_default>1</show_in_default>
429
  <show_in_website>1</show_in_website>
434
  <label>Send order lines and billing/delivery addresses to PayEx</label>
435
  <frontend_type>select</frontend_type>
436
  <source_model>adminhtml/system_config_source_yesno</source_model>
437
+ <sort_order>13</sort_order>
438
  <show_in_default>1</show_in_default>
439
  <show_in_website>1</show_in_website>
440
  <show_in_store>1</show_in_store>
441
  </checkoutinfo>
442
+
443
+ <discount_calc translate="label">
444
+ <label>Discount Calculation</label>
445
+ <frontend_type>select</frontend_type>
446
+ <source_model>payex/source_discountCalculation</source_model>
447
+ <sort_order>14</sort_order>
448
+ <show_in_default>1</show_in_default>
449
+ <show_in_website>1</show_in_website>
450
+ <show_in_store>1</show_in_store>
451
+ </discount_calc>
452
  </fields>
453
+ </payex_bankdebit>
454
 
455
  <!-- newmodule fieldset -->
456
+ <payex_wywallet translate="label" module="payex">
457
  <!-- will have title 'New Module' -->
458
+ <label>PayEx WyWallet</label>
459
  <!-- position between other payment methods -->
460
+ <sort_order>612</sort_order>
461
  <!-- do not show this configuration options in store scope -->
462
  <show_in_default>1</show_in_default>
463
  <show_in_website>1</show_in_website>
491
  <allowspecific translate="label">
492
  <label>Payment to applicable countries</label>
493
  <frontend_type>allowspecific</frontend_type>
494
+ <sort_order>4</sort_order>
495
  <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
496
  <show_in_default>1</show_in_default>
497
  <show_in_website>1</show_in_website>
501
  <specificcountry translate="label">
502
  <label>Payment to Specific countries</label>
503
  <frontend_type>multiselect</frontend_type>
504
+ <sort_order>5</sort_order>
505
  <source_model>adminhtml/system_config_source_country</source_model>
506
  <show_in_default>1</show_in_default>
507
  <show_in_website>1</show_in_website>
512
  <label>Enable test mode</label>
513
  <frontend_type>select</frontend_type>
514
  <source_model>adminhtml/system_config_source_yesno</source_model>
515
+ <sort_order>6</sort_order>
516
  <show_in_default>1</show_in_default>
517
  <show_in_website>1</show_in_website>
518
  <show_in_store>1</show_in_store>
521
  <accountnumber>
522
  <label>Account Number</label>
523
  <frontend_type>text</frontend_type>
524
+ <sort_order>7</sort_order>
525
  <show_in_default>1</show_in_default>
526
  <show_in_website>1</show_in_website>
527
  <show_in_store>1</show_in_store>
530
  <encryptionkey>
531
  <label>Encryption Key</label>
532
  <frontend_type>text</frontend_type>
533
+ <sort_order>8</sort_order>
534
  <show_in_default>1</show_in_default>
535
  <show_in_website>1</show_in_website>
536
  <show_in_store>1</show_in_store>
540
  <label>Transaction Type</label>
541
  <frontend_type>select</frontend_type>
542
  <source_model>payex/source_paymentAction</source_model>
543
+ <sort_order>9</sort_order>
544
  <show_in_default>1</show_in_default>
545
  <show_in_website>1</show_in_website>
546
  <show_in_store>1</show_in_store>
550
  <label>Order status (for authorize)</label>
551
  <frontend_type>select</frontend_type>
552
  <source_model>adminhtml/system_config_source_order_status</source_model>
553
+ <sort_order>10</sort_order>
554
  <show_in_default>1</show_in_default>
555
  <show_in_website>1</show_in_website>
556
  <show_in_store>1</show_in_store>
560
  <label>Order status (for capture)</label>
561
  <frontend_type>select</frontend_type>
562
  <source_model>adminhtml/system_config_source_order_status</source_model>
563
+ <sort_order>11</sort_order>
564
  <show_in_default>1</show_in_default>
565
  <show_in_website>1</show_in_website>
566
  <show_in_store>1</show_in_store>
570
  <label>Client language</label>
571
  <frontend_type>select</frontend_type>
572
  <source_model>payex/source_clientLanguage</source_model>
 
 
 
 
 
 
 
 
 
573
  <sort_order>12</sort_order>
574
  <show_in_default>1</show_in_default>
575
  <show_in_website>1</show_in_website>
576
  <show_in_store>1</show_in_store>
577
+ </clientlanguage>
 
 
 
 
 
 
 
 
 
578
 
579
  <cleantime translate="label">
580
  <label>Time to clean pending orders (0 - disabled)</label>
581
  <frontend_type>text</frontend_type>
582
+ <sort_order>13</sort_order>
583
  <show_in_default>1</show_in_default>
584
  <show_in_website>1</show_in_website>
585
  <show_in_store>1</show_in_store>
593
  <!-- model to take the option values from -->
594
  <source_model>adminhtml/system_config_source_yesno</source_model>
595
  <!-- field position -->
596
+ <sort_order>14</sort_order>
597
  <!-- do not show this field in store scope -->
598
  <show_in_default>1</show_in_default>
599
  <show_in_website>1</show_in_website>
604
  <label>Send order lines and billing/delivery addresses to PayEx</label>
605
  <frontend_type>select</frontend_type>
606
  <source_model>adminhtml/system_config_source_yesno</source_model>
607
+ <sort_order>15</sort_order>
608
  <show_in_default>1</show_in_default>
609
  <show_in_website>1</show_in_website>
610
  <show_in_store>1</show_in_store>
611
  </checkoutinfo>
612
+
613
+ <discount_calc translate="label">
614
+ <label>Discount Calculation</label>
615
+ <frontend_type>select</frontend_type>
616
+ <source_model>payex/source_discountCalculation</source_model>
617
+ <sort_order>16</sort_order>
618
+ <show_in_default>1</show_in_default>
619
+ <show_in_website>1</show_in_website>
620
+ <show_in_store>1</show_in_store>
621
+ </discount_calc>
622
  </fields>
623
+ </payex_wywallet>
624
 
625
  <!-- newmodule fieldset -->
626
  <payex_masterpass translate="label" module="payex">
764
  <show_in_website>1</show_in_website>
765
  <show_in_store>1</show_in_store>
766
  </shipping_method>
767
+
768
+ <discount_calc translate="label">
769
+ <label>Discount Calculation</label>
770
+ <frontend_type>select</frontend_type>
771
+ <source_model>payex/source_discountCalculation</source_model>
772
+ <sort_order>15</sort_order>
773
+ <show_in_default>1</show_in_default>
774
+ <show_in_website>1</show_in_website>
775
+ <show_in_store>1</show_in_store>
776
+ </discount_calc>
777
  </fields>
778
  </payex_masterpass>
779
 
937
  <show_in_website>1</show_in_website>
938
  <show_in_store>1</show_in_store>
939
  </replacement_char>
940
+
941
+ <ssn_check>
942
+ <label>Perform validation of SSN before checkout</label>
943
+ <frontend_type>select</frontend_type>
944
+ <source_model>adminhtml/system_config_source_yesno</source_model>
945
+ <sort_order>16</sort_order>
946
+ <show_in_default>1</show_in_default>
947
+ <show_in_website>1</show_in_website>
948
+ <show_in_store>1</show_in_store>
949
+ </ssn_check>
950
+
951
+ <discount_calc translate="label">
952
+ <label>Discount Calculation</label>
953
+ <frontend_type>select</frontend_type>
954
+ <source_model>payex/source_discountCalculation</source_model>
955
+ <sort_order>16</sort_order>
956
+ <show_in_default>1</show_in_default>
957
+ <show_in_website>1</show_in_website>
958
+ <show_in_store>1</show_in_store>
959
+ </discount_calc>
960
  </fields>
961
  </payex_financing>
962
 
1120
  <show_in_website>1</show_in_website>
1121
  <show_in_store>1</show_in_store>
1122
  </replacement_char>
1123
+
1124
+ <ssn_check>
1125
+ <label>Perform validation of SSN before checkout</label>
1126
+ <frontend_type>select</frontend_type>
1127
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1128
+ <sort_order>18</sort_order>
1129
+ <show_in_default>1</show_in_default>
1130
+ <show_in_website>1</show_in_website>
1131
+ <show_in_store>1</show_in_store>
1132
+ </ssn_check>
1133
+
1134
+ <discount_calc translate="label">
1135
+ <label>Discount Calculation</label>
1136
+ <frontend_type>select</frontend_type>
1137
+ <source_model>payex/source_discountCalculation</source_model>
1138
+ <sort_order>19</sort_order>
1139
+ <show_in_default>1</show_in_default>
1140
+ <show_in_website>1</show_in_website>
1141
+ <show_in_store>1</show_in_store>
1142
+ </discount_calc>
1143
  </fields>
1144
  </payex_partpayment>
1145
 
1332
  <show_in_website>1</show_in_website>
1333
  <show_in_store>1</show_in_store>
1334
  </unapproved>
1335
+
1336
+ <credit_check translate="label">
1337
+ <label>Enable Credit Check</label>
1338
+ <frontend_type>select</frontend_type>
1339
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1340
+ <sort_order>20</sort_order>
1341
+ <show_in_default>1</show_in_default>
1342
+ <show_in_website>1</show_in_website>
1343
+ <show_in_store>1</show_in_store>
1344
+ </credit_check>
1345
+
1346
+ <discount_calc translate="label">
1347
+ <label>Discount Calculation</label>
1348
+ <frontend_type>select</frontend_type>
1349
+ <source_model>payex/source_discountCalculation</source_model>
1350
+ <sort_order>21</sort_order>
1351
+ <show_in_default>1</show_in_default>
1352
+ <show_in_website>1</show_in_website>
1353
+ <show_in_store>1</show_in_store>
1354
+ </discount_calc>
1355
  </fields>
1356
  </payex_invoice>
1357
 
1492
  <show_in_website>1</show_in_website>
1493
  <show_in_store>1</show_in_store>
1494
  </checkoutinfo>
1495
+
1496
+ <discount_calc translate="label">
1497
+ <label>Discount Calculation</label>
1498
+ <frontend_type>select</frontend_type>
1499
+ <source_model>payex/source_discountCalculation</source_model>
1500
+ <sort_order>16</sort_order>
1501
+ <show_in_default>1</show_in_default>
1502
+ <show_in_website>1</show_in_website>
1503
+ <show_in_store>1</show_in_store>
1504
+ </discount_calc>
1505
  </fields>
1506
  </payex_swish>
1507
  </groups>
1565
  </payex_ssn>
1566
  </groups>
1567
  </payex_ssn>
1568
+ <tax>
1569
+ <groups>
1570
+ <cart_display>
1571
+ <fields>
1572
+ <payex_fee translate="label">
1573
+ <label>Display PayEx fee</label>
1574
+ <frontend_type>select</frontend_type>
1575
+ <source_model>tax/system_config_source_tax_display_type</source_model>
1576
+ <sort_order>35</sort_order>
1577
+ <show_in_default>1</show_in_default>
1578
+ <show_in_website>1</show_in_website>
1579
+ <show_in_store>1</show_in_store>
1580
+ </payex_fee>
1581
+ </fields>
1582
+ </cart_display>
1583
+ <sales_display>
1584
+ <fields>
1585
+ <payex_fee translate="label">
1586
+ <label>Display PayEx fee</label>
1587
+ <frontend_type>select</frontend_type>
1588
+ <source_model>tax/system_config_source_tax_display_type</source_model>
1589
+ <sort_order>35</sort_order>
1590
+ <show_in_default>1</show_in_default>
1591
+ <show_in_website>1</show_in_website>
1592
+ <show_in_store>1</show_in_store>
1593
+ </payex_fee>
1594
+ </fields>
1595
+ </sales_display>
1596
+ </groups>
1597
+ </tax>
1598
  </sections>
1599
  </config>
app/code/community/PayEx/Payments/sql/payex_setup/install-3.1.0.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $this->startSetup();
4
+
5
+ // Install fee
6
+ $this->_conn->addColumn($this->getTable('sales_flat_quote'), 'payex_payment_fee', 'decimal(12,4)');
7
+ $this->_conn->addColumn($this->getTable('sales_flat_quote'), 'payex_payment_fee_tax', 'decimal(12,4)');
8
+ $this->_conn->addColumn($this->getTable('sales_flat_quote'), 'base_payex_payment_fee', 'decimal(12,4)');
9
+ $this->_conn->addColumn($this->getTable('sales_flat_quote'), 'base_payex_payment_fee_tax', 'decimal(12,4)');
10
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'payex_payment_fee', 'decimal(12,4)');
11
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'payex_payment_fee_tax', 'decimal(12,4)');
12
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'base_payex_payment_fee', 'decimal(12,4)');
13
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'base_payex_payment_fee_tax', 'decimal(12,4)');
14
+
15
+ $eav = new Mage_Sales_Model_Resource_Setup('sales_setup');
16
+ $eav->addAttribute('quote', 'payex_payment_fee', array('type' => 'decimal'));
17
+ $eav->addAttribute('quote', 'payex_payment_fee_tax', array('type' => 'decimal'));
18
+ $eav->addAttribute('quote', 'base_payex_payment_fee', array('type' => 'decimal'));
19
+ $eav->addAttribute('quote', 'base_payex_payment_fee_tax', array('type' => 'decimal'));
20
+ $eav->addAttribute('order', 'payex_payment_fee', array('type' => 'decimal'));
21
+ $eav->addAttribute('order', 'payex_payment_fee_tax', array('type' => 'decimal'));
22
+ $eav->addAttribute('order', 'base_payex_payment_fee', array('type' => 'decimal'));
23
+ $eav->addAttribute('order', 'base_payex_payment_fee_tax', array('type' => 'decimal'));
24
+
25
+ // Install "fee invoiced" and "fee refunded"
26
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'payex_payment_fee_invoiced', 'decimal(12,4)');
27
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'payex_payment_fee_tax_invoiced', 'decimal(12,4)');
28
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'base_payex_payment_fee_invoiced', 'decimal(12,4)');
29
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'base_payex_payment_fee_tax_invoiced', 'decimal(12,4)');
30
+
31
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'payex_payment_fee_refunded', 'decimal(12,4)');
32
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'payex_payment_fee_tax_refunded', 'decimal(12,4)');
33
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'base_payex_payment_fee_refunded', 'decimal(12,4)');
34
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'base_payex_payment_fee_tax_refunded', 'decimal(12,4)');
35
+
36
+ $this->_conn->addColumn($this->getTable('sales_flat_invoice'), 'payex_payment_fee', 'decimal(12,4)');
37
+ $this->_conn->addColumn($this->getTable('sales_flat_invoice'), 'payex_payment_fee_tax', 'decimal(12,4)');
38
+ $this->_conn->addColumn($this->getTable('sales_flat_invoice'), 'base_payex_payment_fee', 'decimal(12,4)');
39
+ $this->_conn->addColumn($this->getTable('sales_flat_invoice'), 'base_payex_payment_fee_tax', 'decimal(12,4)');
40
+
41
+ $this->_conn->addColumn($this->getTable('sales_flat_creditmemo'), 'payex_payment_fee', 'decimal(12,4)');
42
+ $this->_conn->addColumn($this->getTable('sales_flat_creditmemo'), 'payex_payment_fee_tax', 'decimal(12,4)');
43
+ $this->_conn->addColumn($this->getTable('sales_flat_creditmemo'), 'base_payex_payment_fee', 'decimal(12,4)');
44
+ $this->_conn->addColumn($this->getTable('sales_flat_creditmemo'), 'base_payex_payment_fee_tax', 'decimal(12,4)');
45
+
46
+ $eav = new Mage_Sales_Model_Resource_Setup('sales_setup');
47
+ $eav->addAttribute('order', 'payex_payment_fee_invoiced', array('type' => 'decimal'));
48
+ $eav->addAttribute('order', 'payex_payment_fee_tax_invoiced', array('type' => 'decimal'));
49
+ $eav->addAttribute('order', 'base_payex_payment_fee_invoiced', array('type' => 'decimal'));
50
+ $eav->addAttribute('order', 'base_payex_payment_fee_tax_invoiced', array('type' => 'decimal'));
51
+
52
+ $eav->addAttribute('order', 'payex_payment_fee_refunded', array('type' => 'decimal'));
53
+ $eav->addAttribute('order', 'payex_payment_fee_tax_refunded', array('type' => 'decimal'));
54
+ $eav->addAttribute('order', 'base_payex_payment_fee_refunded', array('type' => 'decimal'));
55
+ $eav->addAttribute('order', 'base_payex_payment_fee_tax_refunded', array('type' => 'decimal'));
56
+
57
+ $eav->addAttribute('invoice', 'payex_payment_fee', array('type' => 'decimal'));
58
+ $eav->addAttribute('invoice', 'payex_payment_fee_tax', array('type' => 'decimal'));
59
+ $eav->addAttribute('invoice', 'base_payex_payment_fee', array('type' => 'decimal'));
60
+ $eav->addAttribute('invoice', 'base_payex_payment_fee_tax', array('type' => 'decimal'));
61
+
62
+ $eav->addAttribute('creditmemo', 'payex_payment_fee', array('type' => 'decimal'));
63
+ $eav->addAttribute('creditmemo', 'payex_payment_fee_tax', array('type' => 'decimal'));
64
+ $eav->addAttribute('creditmemo', 'base_payex_payment_fee', array('type' => 'decimal'));
65
+ $eav->addAttribute('creditmemo', 'base_payex_payment_fee_tax', array('type' => 'decimal'));
66
+
67
+ $this->endSetup();
app/code/community/PayEx/Payments/sql/payex_setup/upgrade-3.0.2-3.0.3.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $this->startSetup();
4
+
5
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'payex_payment_fee_invoiced', 'decimal(12,4)');
6
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'payex_payment_fee_tax_invoiced', 'decimal(12,4)');
7
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'base_payex_payment_fee_invoiced', 'decimal(12,4)');
8
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'base_payex_payment_fee_tax_invoiced', 'decimal(12,4)');
9
+
10
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'payex_payment_fee_refunded', 'decimal(12,4)');
11
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'payex_payment_fee_tax_refunded', 'decimal(12,4)');
12
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'base_payex_payment_fee_refunded', 'decimal(12,4)');
13
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'base_payex_payment_fee_tax_refunded', 'decimal(12,4)');
14
+
15
+ $this->_conn->addColumn($this->getTable('sales_flat_invoice'), 'payex_payment_fee', 'decimal(12,4)');
16
+ $this->_conn->addColumn($this->getTable('sales_flat_invoice'), 'payex_payment_fee_tax', 'decimal(12,4)');
17
+ $this->_conn->addColumn($this->getTable('sales_flat_invoice'), 'base_payex_payment_fee', 'decimal(12,4)');
18
+ $this->_conn->addColumn($this->getTable('sales_flat_invoice'), 'base_payex_payment_fee_tax', 'decimal(12,4)');
19
+
20
+ $this->_conn->addColumn($this->getTable('sales_flat_creditmemo'), 'payex_payment_fee', 'decimal(12,4)');
21
+ $this->_conn->addColumn($this->getTable('sales_flat_creditmemo'), 'payex_payment_fee_tax', 'decimal(12,4)');
22
+ $this->_conn->addColumn($this->getTable('sales_flat_creditmemo'), 'base_payex_payment_fee', 'decimal(12,4)');
23
+ $this->_conn->addColumn($this->getTable('sales_flat_creditmemo'), 'base_payex_payment_fee_tax', 'decimal(12,4)');
24
+
25
+ $eav = new Mage_Sales_Model_Resource_Setup('sales_setup');
26
+ $eav->addAttribute('order', 'payex_payment_fee_invoiced', array('type' => 'decimal'));
27
+ $eav->addAttribute('order', 'payex_payment_fee_tax_invoiced', array('type' => 'decimal'));
28
+ $eav->addAttribute('order', 'base_payex_payment_fee_invoiced', array('type' => 'decimal'));
29
+ $eav->addAttribute('order', 'base_payex_payment_fee_tax_invoiced', array('type' => 'decimal'));
30
+
31
+ $eav->addAttribute('order', 'payex_payment_fee_refunded', array('type' => 'decimal'));
32
+ $eav->addAttribute('order', 'payex_payment_fee_tax_refunded', array('type' => 'decimal'));
33
+ $eav->addAttribute('order', 'base_payex_payment_fee_refunded', array('type' => 'decimal'));
34
+ $eav->addAttribute('order', 'base_payex_payment_fee_tax_refunded', array('type' => 'decimal'));
35
+
36
+ $eav->addAttribute('invoice', 'payex_payment_fee', array('type' => 'decimal'));
37
+ $eav->addAttribute('invoice', 'payex_payment_fee_tax', array('type' => 'decimal'));
38
+ $eav->addAttribute('invoice', 'base_payex_payment_fee', array('type' => 'decimal'));
39
+ $eav->addAttribute('invoice', 'base_payex_payment_fee_tax', array('type' => 'decimal'));
40
+
41
+ $eav->addAttribute('creditmemo', 'payex_payment_fee', array('type' => 'decimal'));
42
+ $eav->addAttribute('creditmemo', 'payex_payment_fee_tax', array('type' => 'decimal'));
43
+ $eav->addAttribute('creditmemo', 'base_payex_payment_fee', array('type' => 'decimal'));
44
+ $eav->addAttribute('creditmemo', 'base_payex_payment_fee_tax', array('type' => 'decimal'));
45
+
46
+ $this->endSetup();
app/design/adminhtml/default/default/layout/payex/payment_fee.xml CHANGED
@@ -17,4 +17,29 @@
17
  <block name="payex_payment_fee" type="payex/invoice_totals_fee" before="tax"/>
18
  </reference>
19
  </adminhtml_sales_order_invoice_new>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  </layout>
17
  <block name="payex_payment_fee" type="payex/invoice_totals_fee" before="tax"/>
18
  </reference>
19
  </adminhtml_sales_order_invoice_new>
20
+
21
+ <adminhtml_sales_order_invoice_updateqty>
22
+ <reference name="invoice_totals">
23
+ <block name="payex_payment_fee" type="payex/invoice_totals_fee" before="tax"/>
24
+ </reference>
25
+ </adminhtml_sales_order_invoice_updateqty>
26
+
27
+ <adminhtml_sales_order_creditmemo_view>
28
+ <reference name="creditmemo_totals">
29
+ <block name="payex_payment_fee" type="payex/creditmemo_totals_fee" before="tax" />
30
+ </reference>
31
+ </adminhtml_sales_order_creditmemo_view>
32
+
33
+ <adminhtml_sales_order_creditmemo_new>
34
+ <reference name="creditmemo_totals">
35
+ <block name="payex_payment_fee" type="payex/creditmemo_totals_fee" before="tax" />
36
+ </reference>
37
+ </adminhtml_sales_order_creditmemo_new>
38
+
39
+ <adminhtml_sales_order_creditmemo_updateqty>
40
+ <reference name="creditmemo_totals">
41
+ <block name="payex_payment_fee" type="payex/creditmemo_totals_fee" before="tax" />
42
+ </reference>
43
+ </adminhtml_sales_order_creditmemo_updateqty>
44
+
45
  </layout>
app/design/adminhtml/default/default/template/payex/billing/agreement/form.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /* @var $this PayEx_Payments_Block_Form_Billing_Agreement */ ?>
2
+ <?php $_code = $this->getMethodCode() ?>
3
+ <ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
4
+ <li>
5
+ <label for="<?php echo $_code ?>_ba_agreement_id" class="required"><em>*</em><?php echo $this->__('Credit Card') ?></label>
6
+ <div class="input-box">
7
+ <select id="<?php echo $_code ?>_ba_agreement_id" name="payment[<?php echo $this->getTransportName(); ?>]" class="required-entry">
8
+ <option value=""><?php echo $this->__('-- Please Select Credit Card--') ?></option>
9
+ <?php foreach ($this->getBillingAgreements() as $id => $agreementLabel): ?>
10
+ <option value="<?php echo $id ?>"><?php echo $this->escapeHtml($agreementLabel) ?></option>
11
+ <?php endforeach ?>
12
+ </select>
13
+ </div>
14
+ </li>
15
+ </ul>
app/design/adminhtml/default/default/template/payex/billing/agreement/info.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /* @var $this PayEx_Payments_Block_Info_Billing_Agreement */ ?>
2
+ <?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?>
3
+
4
+ <?php if ($_specificInfo = $this->getSpecificInformation()):?>
5
+ <table>
6
+ <?php foreach ($_specificInfo as $_label => $_value):?>
7
+ <tr>
8
+ <td><?php echo $this->escapeHtml($_label)?>:</td>
9
+ <td><?php echo nl2br(implode($this->getValueAsArray($_value, true), "\n"))?></td>
10
+ </tr>
11
+ <?php endforeach; ?>
12
+ </table>
13
+ <?php endif;?>
14
+
15
+ <?php echo $this->getChildHtml()?>
app/design/adminhtml/default/default/template/payex/financing/form.phtml CHANGED
@@ -34,25 +34,6 @@ $fee = $this->getPayexPaymentFee();
34
  class="required-entry input-text" type="text" readonly/><br/>
35
  <?php endif; ?>
36
  </form>
37
- <?php if ($fee->getPaymentFeePrice() > 0): ?>
38
- <div>
39
- <?php if ($this->helper('tax')->displayBothPrices()): ?>
40
- <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
41
- <br />
42
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
43
- <?php echo $this->helper('checkout')->__('(Excl. Tax)'); ?>
44
- <br />
45
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
46
- <?php echo $this->helper('checkout')->__('(Incl. Tax)'); ?>
47
- <?php elseif ($this->helper('tax')->displayPriceIncludingTax()): ?>
48
- <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
49
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
50
- <?php else: ?>
51
- <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
52
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
53
- <?php endif; ?>
54
- </div>
55
- <?php endif; ?>
56
  <!-- End PayEx Financing block -->
57
  </div>
58
  <div style="float:right"></div>
34
  class="required-entry input-text" type="text" readonly/><br/>
35
  <?php endif; ?>
36
  </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  <!-- End PayEx Financing block -->
38
  </div>
39
  <div style="float:right"></div>
app/design/adminhtml/default/default/template/payex/invoice/form.phtml CHANGED
@@ -92,25 +92,6 @@ $fee = $this->getPayexPaymentFee();
92
  </li>
93
  </ul>
94
  </form>
95
- <?php if ($fee->getPaymentFeePrice() > 0): ?>
96
- <div>
97
- <?php if ($this->helper('tax')->displayBothPrices()): ?>
98
- <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
99
- <br />
100
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
101
- <?php echo $this->helper('checkout')->__('(Excl. Tax)'); ?>
102
- <br />
103
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
104
- <?php echo $this->helper('checkout')->__('(Incl. Tax)'); ?>
105
- <?php elseif ($this->helper('tax')->displayPriceIncludingTax()): ?>
106
- <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
107
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
108
- <?php else: ?>
109
- <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
110
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
111
- <?php endif; ?>
112
- </div>
113
- <?php endif; ?>
114
  <!-- End PayEx Invoice block -->
115
  </div>
116
  <div style="float:right"></div>
92
  </li>
93
  </ul>
94
  </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  <!-- End PayEx Invoice block -->
96
  </div>
97
  <div style="float:right"></div>
app/design/adminhtml/default/default/template/payex/partpayment/form.phtml CHANGED
@@ -34,25 +34,6 @@ $fee = $this->getPayexPaymentFee();
34
  class="required-entry input-text" type="text" readonly/><br/>
35
  <?php endif; ?>
36
  </form>
37
- <?php if ($fee->getPaymentFeePrice() > 0): ?>
38
- <div>
39
- <?php if ($this->helper('tax')->displayBothPrices()): ?>
40
- <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
41
- <br />
42
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
43
- <?php echo $this->helper('checkout')->__('(Excl. Tax)'); ?>
44
- <br />
45
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
46
- <?php echo $this->helper('checkout')->__('(Incl. Tax)'); ?>
47
- <?php elseif ($this->helper('tax')->displayPriceIncludingTax()): ?>
48
- <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
49
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
50
- <?php else: ?>
51
- <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
52
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
53
- <?php endif; ?>
54
- </div>
55
- <?php endif; ?>
56
  <!-- End PayEx PartPayment block -->
57
  </div>
58
  <div style="float:right"></div>
34
  class="required-entry input-text" type="text" readonly/><br/>
35
  <?php endif; ?>
36
  </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  <!-- End PayEx PartPayment block -->
38
  </div>
39
  <div style="float:right"></div>
app/design/frontend/base/default/layout/payex/social_security_number.xml CHANGED
@@ -9,6 +9,10 @@
9
  <action method="addJs" ifconfig="payex_ssn/payex_ssn/active">
10
  <script>payex/social_security_number.js</script>
11
  </action>
 
 
 
 
12
  </reference>
13
  </checkout_onepage_index>
14
 
9
  <action method="addJs" ifconfig="payex_ssn/payex_ssn/active">
10
  <script>payex/social_security_number.js</script>
11
  </action>
12
+ <action method="addItem" ifconfig="payex_ssn/payex_ssn/active">
13
+ <type>skin_css</type>
14
+ <name>css/payex/social_security_number.css</name>
15
+ </action>
16
  </reference>
17
  </checkout_onepage_index>
18
 
app/design/frontend/base/default/template/payex/billing/agreement/form.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /* @var $this PayEx_Payments_Block_Form_Billing_Agreement */ ?>
2
+ <?php $_code = $this->getMethodCode() ?>
3
+ <ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
4
+ <li>
5
+ <label for="<?php echo $_code ?>_ba_agreement_id" class="required"><em>*</em><?php echo $this->__('Credit Card') ?></label>
6
+ <div class="input-box">
7
+ <select id="<?php echo $_code ?>_ba_agreement_id" name="payment[<?php echo $this->getTransportName(); ?>]" class="required-entry">
8
+ <option value=""><?php echo $this->__('-- Please Select Credit Card--') ?></option>
9
+ <?php foreach ($this->getBillingAgreements() as $id => $agreementLabel): ?>
10
+ <option value="<?php echo $id ?>"><?php echo $this->escapeHtml($agreementLabel) ?></option>
11
+ <?php endforeach ?>
12
+ </select>
13
+ </div>
14
+ </li>
15
+ </ul>
app/design/frontend/base/default/template/payex/billing/agreement/info.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /* @var $this PayEx_Payments_Block_Info_Billing_Agreement */ ?>
2
+ <?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?>
3
+
4
+ <?php if ($_specificInfo = $this->getSpecificInformation()):?>
5
+ <table>
6
+ <?php foreach ($_specificInfo as $_label => $_value):?>
7
+ <tr>
8
+ <td><?php echo $this->escapeHtml($_label)?>:</td>
9
+ <td><?php echo nl2br(implode($this->getValueAsArray($_value, true), "\n"))?></td>
10
+ </tr>
11
+ <?php endforeach; ?>
12
+ </table>
13
+ <?php endif;?>
14
+
15
+ <?php echo $this->getChildHtml()?>
app/design/frontend/base/default/template/payex/cc/form.phtml CHANGED
@@ -26,5 +26,11 @@
26
  <li><img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/american_express_64.png'); ?>" /></li>
27
  </ul>
28
  </li>
 
 
 
 
 
 
29
  </ul>
30
  </fieldset>
26
  <li><img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/american_express_64.png'); ?>" /></li>
27
  </ul>
28
  </li>
29
+ <?php if ($code = $this->getCreateBACode()): ?>
30
+ <li class="form-alt">
31
+ <label for="<?php echo $code ?>"><input type="checkbox" id="<?php echo $code ?>" value="1" name="payment[<?php echo $code ?>]" class="checkbox" />
32
+ <?php echo $this->__('Sign a billing agreement to streamline further purchases with PayEx.') ?></label>
33
+ </li>
34
+ <?php endif; ?>
35
  </ul>
36
  </fieldset>
app/design/frontend/base/default/template/payex/cc/info.phtml CHANGED
@@ -7,6 +7,9 @@
7
  <?php if (!empty($trans_id)): ?>
8
  <?php $specific = $this->getSpecificInformation(); ?>
9
  <?php if (count($specific) > 0): ?>
 
 
 
10
  <?php foreach($specific as $key => $value): ?>
11
  <?php echo Mage::helper('payex')->__($key) . ': ' . $this->htmlEscape($value); ?><br />
12
  <?php endforeach; ?>
7
  <?php if (!empty($trans_id)): ?>
8
  <?php $specific = $this->getSpecificInformation(); ?>
9
  <?php if (count($specific) > 0): ?>
10
+ <?php unset($specific['Authenticated Status']); ?>
11
+ <?php unset($specific['Transaction Ref']); ?>
12
+ <?php unset($specific['PayEx Transaction Status']); ?>
13
  <?php foreach($specific as $key => $value): ?>
14
  <?php echo Mage::helper('payex')->__($key) . ': ' . $this->htmlEscape($value); ?><br />
15
  <?php endforeach; ?>
app/design/frontend/base/default/template/payex/cc/pdf/info.phtml CHANGED
@@ -3,6 +3,9 @@
3
  <?php if (!empty($trans_id)): ?>
4
  <?php $specific = $this->getSpecificInformation(); ?>
5
  <?php if (count($specific) > 0): ?>
 
 
 
6
  <?php foreach($specific as $key => $value): ?>
7
  <?php echo Mage::helper('payex')->__($key) . ': ' . $value; ?>
8
  {{pdf_row_separator}}
3
  <?php if (!empty($trans_id)): ?>
4
  <?php $specific = $this->getSpecificInformation(); ?>
5
  <?php if (count($specific) > 0): ?>
6
+ <?php unset($specific['Authenticated Status']); ?>
7
+ <?php unset($specific['Transaction Ref']); ?>
8
+ <?php unset($specific['PayEx Transaction Status']); ?>
9
  <?php foreach($specific as $key => $value): ?>
10
  <?php echo Mage::helper('payex')->__($key) . ': ' . $value; ?>
11
  {{pdf_row_separator}}
app/design/frontend/base/default/template/payex/checkout/fee.phtml CHANGED
@@ -2,48 +2,44 @@
2
  /**
3
  * @var $this PayEx_Payments_Block_Checkout_Fee
4
  */
5
-
6
- $fee = $this->getPaymentFee();
7
  ?>
8
  <!-- Start PayEx Payment Fee -->
9
- <?php if ($this->helper('tax')->displayBothPrices()): ?>
10
- <tr>
11
- <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
12
- <?php echo $this->helper('payex')->__('Payment fee'); ?>
13
- <?php echo $this->helper('checkout')->__('(Excl. Tax)'); ?>
14
- </td>
15
- <td style="<?php echo $this->getStyle() ?>" class="a-right">
16
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
17
- </td>
18
- </tr>
19
- <tr>
20
- <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
21
- <?php echo $this->helper('payex')->__('Payment fee'); ?>
22
- <?php echo $this->helper('checkout')->__('(Incl. Tax)'); ?>
23
- </td>
24
- <td style="<?php echo $this->getStyle() ?>" class="a-right">
25
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
26
- </td>
27
- </tr>
28
- <?php else: ?>
29
- <?php if ($this->helper('tax')->displayPriceIncludingTax()): ?>
30
  <tr>
31
  <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
32
- <?php echo $this->helper('payex')->__('Payment fee'); ?>
33
  </td>
34
  <td style="<?php echo $this->getStyle() ?>" class="a-right">
35
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  </td>
37
  </tr>
38
  <?php else: ?>
39
  <tr>
40
  <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
41
- <?php echo $this->helper('payex')->__('Payment fee'); ?>
42
  </td>
43
  <td style="<?php echo $this->getStyle() ?>" class="a-right">
44
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
45
  </td>
46
  </tr>
47
  <?php endif; ?>
48
  <?php endif; ?>
49
- <!-- End PayEx Payment Fee -->
2
  /**
3
  * @var $this PayEx_Payments_Block_Checkout_Fee
4
  */
 
 
5
  ?>
6
  <!-- Start PayEx Payment Fee -->
7
+ <?php if ($this->getPayExFeeIncludeTax() > 0): ?>
8
+ <?php if ($this->displayCartPayExFeeBoth()): ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  <tr>
10
  <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
11
+ <?php echo $this->getTotal()->getTitle() . ' ' . $this->getExcludeTaxLabel() ?>
12
  </td>
13
  <td style="<?php echo $this->getStyle() ?>" class="a-right">
14
+ <?php echo $this->helper('checkout')->formatPrice($this->getPayExFeeExcludeTax()) ?>
15
+ </td>
16
+ </tr>
17
+ <tr>
18
+ <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
19
+ <?php echo $this->getTotal()->getTitle() . ' ' . $this->getIncludeTaxLabel() ?>
20
+ </td>
21
+ <td style="<?php echo $this->getStyle() ?>" class="a-right">
22
+ <?php echo $this->helper('checkout')->formatPrice($this->getPayExFeeIncludeTax()) ?>
23
+ </td>
24
+ </tr>
25
+ <?php elseif($this->displayCartPayExFeeInclTax()): ?>
26
+ <tr>
27
+ <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
28
+ <?php echo $this->getTotal()->getTitle() ?>
29
+ </td>
30
+ <td style="<?php echo $this->getStyle() ?>" class="a-right">
31
+ <?php echo $this->helper('checkout')->formatPrice($this->getPayExFeeIncludeTax()) ?>
32
  </td>
33
  </tr>
34
  <?php else: ?>
35
  <tr>
36
  <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
37
+ <?php echo $this->getTotal()->getTitle() ?>
38
  </td>
39
  <td style="<?php echo $this->getStyle() ?>" class="a-right">
40
+ <?php echo $this->helper('checkout')->formatPrice($this->getPayExFeeExcludeTax()) ?>
41
  </td>
42
  </tr>
43
  <?php endif; ?>
44
  <?php endif; ?>
45
+ <!-- End PayEx Payment Fee -->
app/design/frontend/base/default/template/payex/checkout/onepage/billing_with_ssn.phtml CHANGED
@@ -25,41 +25,65 @@
25
  */
26
  ?>
27
  <!-- Start Social Security Number Block -->
28
- <form id="social_security_number_form">
29
  <div class="form-list">
 
 
 
 
 
 
 
 
 
 
 
 
30
  <div class="field">
31
  <label for="socialSecurityNumber" class="required"><em>*</em><?php echo Mage::helper('payex')->__('Social Security Number'); ?></label>
32
  <div class="input-box">
33
  <input type="text" title="<?php echo Mage::helper('payex')->__('Social Security Number'); ?>" name="socialSecurityNumber" id="socialSecurityNumber" class="input-text required-entry" />
34
  </div>
35
  </div>
36
- <div class="field">
37
- <button style="margin-top: 17px;" type="button" title="<?php echo Mage::helper('payex')->__('Get Address'); ?>" class="button" id="ssn_click"><span><span><?php echo Mage::helper('payex')->__('Get Address'); ?></span></span></button>
38
- </div>
39
  <div class="clearer">&nbsp;</div>
40
- <div class="field">
41
- <label for="check_country" class="required"><em>*</em><?php echo Mage::helper('payex')->__('Country'); ?></label>
42
- <div class="input-box">
43
- <select name="check_country" id="check_country" class="validate-select required-entry" title="Country">
44
- <option value="SE" selected="selected"><?php echo Mage::helper('payex')->__('Sweden'); ?></option>
45
- <option value="NO"><?php echo Mage::helper('payex')->__('Norway'); ?></option>
46
- </select>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  </div>
48
  </div>
49
- <div class="clearer">&nbsp;</div>
50
  <div class="field">
51
- <label for="check_postcode" class="required"><em>*</em><?php echo Mage::helper('payex')->__('Postal Code'); ?></label>
52
- <div class="input-box">
53
- <input type="text" title="<?php echo Mage::helper('payex')->__('Postal Code'); ?>" name="check_postcode" id="check_postcode" class="input-text validate-zip required-entry" />
54
- </div>
55
  </div>
 
 
56
  </div>
57
  </form>
58
  <div class="clearer">&nbsp;</div>
59
 
60
  <script type="application/javascript">
61
  //<![CDATA[
62
- var MAGENTO_BASE_URL = '<?php echo Mage::getBaseUrl(); ?>';
63
  window.PAYEX_SSN_FORM = new VarienForm('social_security_number_form', false);
64
  //]]>
65
  </script>
25
  */
26
  ?>
27
  <!-- Start Social Security Number Block -->
28
+ <form id="social_security_number_form" class="theme-<?php echo Mage::getSingleton('core/design_package')->getPackageName(); ?>">
29
  <div class="form-list">
30
+ <div id="ssn-error-placeholder" class="field" style="display: none">
31
+ <ul class="messages">
32
+ <li class="error-msg">
33
+ <ul>
34
+ <li>
35
+ <span id="ssn-error">&nbsp;</span>
36
+ </li>
37
+ </ul>
38
+ </li>
39
+ </ul>
40
+ </div>
41
+
42
  <div class="field">
43
  <label for="socialSecurityNumber" class="required"><em>*</em><?php echo Mage::helper('payex')->__('Social Security Number'); ?></label>
44
  <div class="input-box">
45
  <input type="text" title="<?php echo Mage::helper('payex')->__('Social Security Number'); ?>" name="socialSecurityNumber" id="socialSecurityNumber" class="input-text required-entry" />
46
  </div>
47
  </div>
 
 
 
48
  <div class="clearer">&nbsp;</div>
49
+
50
+ <div id="ssn_details" style="display: none">
51
+ <div class="field">
52
+ <strong><?php echo Mage::helper('payex')->__('Please enter additional fields:'); ?></strong>
53
+ </div>
54
+ <div class="clearer">&nbsp;</div>
55
+ <div class="field">
56
+ <div class="field_left">
57
+ <div class="input-box">
58
+ <label for="check_country" class="required"><em>*</em><?php echo Mage::helper('payex')->__('Country'); ?></label>
59
+ <select name="check_country" id="check_country" class="validate-select required-entry" title="Country">
60
+ <option value="SE" selected="selected"><?php echo Mage::helper('payex')->__('Sweden'); ?></option>
61
+ <option value="NO"><?php echo Mage::helper('payex')->__('Norway'); ?></option>
62
+ </select>
63
+ </div>
64
+ </div>
65
+
66
+ <div class="field_right">
67
+ <div class="input-box">
68
+ <label for="check_postcode" class="required"><em>*</em><?php echo Mage::helper('payex')->__('Postal Code'); ?></label>
69
+ <input type="text" title="<?php echo Mage::helper('payex')->__('Postal Code'); ?>" name="check_postcode" id="check_postcode" class="input-text validate-zip required-entry" />
70
+ </div>
71
+ </div>
72
  </div>
73
  </div>
74
+
75
  <div class="field">
76
+ <button type="button" title="<?php echo Mage::helper('payex')->__('Get Address'); ?>" class="button" id="ssn_click"><span><span><?php echo Mage::helper('payex')->__('Get Address'); ?></span></span></button>
 
 
 
77
  </div>
78
+
79
+ <div class="clearer">&nbsp;</div>
80
  </div>
81
  </form>
82
  <div class="clearer">&nbsp;</div>
83
 
84
  <script type="application/javascript">
85
  //<![CDATA[
86
+ var MAGENTO_BASE_URL = '<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true); ?>';
87
  window.PAYEX_SSN_FORM = new VarienForm('social_security_number_form', false);
88
  //]]>
89
  </script>
app/design/frontend/base/default/template/payex/financing/form.phtml CHANGED
@@ -34,25 +34,6 @@ $fee = $this->getPayexPaymentFee();
34
  class="required-entry input-text" type="text" readonly/><br/>
35
  <?php endif; ?>
36
  </form>
37
- <?php if ($fee->getPaymentFeePrice() > 0): ?>
38
- <div>
39
- <?php if ($this->helper('tax')->displayBothPrices()): ?>
40
- <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
41
- <br />
42
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
43
- <?php echo $this->helper('checkout')->__('(Excl. Tax)'); ?>
44
- <br />
45
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
46
- <?php echo $this->helper('checkout')->__('(Incl. Tax)'); ?>
47
- <?php elseif ($this->helper('tax')->displayPriceIncludingTax()): ?>
48
- <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
49
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
50
- <?php else: ?>
51
- <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
52
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
53
- <?php endif; ?>
54
- </div>
55
- <?php endif; ?>
56
  <!-- End PayEx Financing block -->
57
  </div>
58
  <div style="float:right"></div>
34
  class="required-entry input-text" type="text" readonly/><br/>
35
  <?php endif; ?>
36
  </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  <!-- End PayEx Financing block -->
38
  </div>
39
  <div style="float:right"></div>
app/design/frontend/base/default/template/payex/financing/info.phtml CHANGED
@@ -7,6 +7,10 @@
7
  <?php if (!empty($trans_id)): ?>
8
  <?php $specific = $this->getSpecificInformation(); ?>
9
  <?php if (count($specific) > 0): ?>
 
 
 
 
10
  <?php foreach ($specific as $key => $value): ?>
11
  <?php if ($key === 'Invoice'): ?>
12
  <a href="<?php echo $this->htmlEscape($value); ?>" target="_blank">
7
  <?php if (!empty($trans_id)): ?>
8
  <?php $specific = $this->getSpecificInformation(); ?>
9
  <?php if (count($specific) > 0): ?>
10
+ <?php unset($specific['PayEx Payment Method']); ?>
11
+ <?php unset($specific['Authenticated Status']); ?>
12
+ <?php unset($specific['Transaction Ref']); ?>
13
+ <?php unset($specific['PayEx Transaction Status']); ?>
14
  <?php foreach ($specific as $key => $value): ?>
15
  <?php if ($key === 'Invoice'): ?>
16
  <a href="<?php echo $this->htmlEscape($value); ?>" target="_blank">
app/design/frontend/base/default/template/payex/financing/pdf/info.phtml CHANGED
@@ -3,6 +3,10 @@
3
  <?php if (!empty($trans_id)): ?>
4
  <?php $specific = $this->getSpecificInformation(); ?>
5
  <?php if (count($specific) > 0): ?>
 
 
 
 
6
  <?php foreach($specific as $key => $value): ?>
7
  <?php echo Mage::helper('payex')->__($key) . ': ' . $value; ?>
8
  {{pdf_row_separator}}
3
  <?php if (!empty($trans_id)): ?>
4
  <?php $specific = $this->getSpecificInformation(); ?>
5
  <?php if (count($specific) > 0): ?>
6
+ <?php unset($specific['PayEx Payment Method']); ?>
7
+ <?php unset($specific['Authenticated Status']); ?>
8
+ <?php unset($specific['Transaction Ref']); ?>
9
+ <?php unset($specific['PayEx Transaction Status']); ?>
10
  <?php foreach($specific as $key => $value): ?>
11
  <?php echo Mage::helper('payex')->__($key) . ': ' . $value; ?>
12
  {{pdf_row_separator}}
app/design/frontend/base/default/template/payex/invoice/form.phtml CHANGED
@@ -92,25 +92,6 @@ $fee = $this->getPayexPaymentFee();
92
  </li>
93
  </ul>
94
  </form>
95
- <?php if ($fee->getPaymentFeePrice() > 0): ?>
96
- <div>
97
- <?php if ($this->helper('tax')->displayBothPrices()): ?>
98
- <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
99
- <br />
100
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
101
- <?php echo $this->helper('checkout')->__('(Excl. Tax)'); ?>
102
- <br />
103
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
104
- <?php echo $this->helper('checkout')->__('(Incl. Tax)'); ?>
105
- <?php elseif ($this->helper('tax')->displayPriceIncludingTax()): ?>
106
- <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
107
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
108
- <?php else: ?>
109
- <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
110
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
111
- <?php endif; ?>
112
- </div>
113
- <?php endif; ?>
114
  <!-- End PayEx Invoice block -->
115
  </div>
116
  <div style="float:right"></div>
92
  </li>
93
  </ul>
94
  </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  <!-- End PayEx Invoice block -->
96
  </div>
97
  <div style="float:right"></div>
app/design/frontend/base/default/template/payex/iwd_opc/billing_with_ssn.phtml CHANGED
@@ -26,7 +26,7 @@
26
  </div>
27
  <script type="application/javascript">
28
  //<![CDATA[
29
- var MAGENTO_BASE_URL = '<?php echo Mage::getBaseUrl(); ?>';
30
  window.PAYEX_SSN_FORM = new VarienForm('social_security_number_form', false);
31
  //]]>
32
  </script>
26
  </div>
27
  <script type="application/javascript">
28
  //<![CDATA[
29
+ var MAGENTO_BASE_URL = '<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true); ?>';
30
  window.PAYEX_SSN_FORM = new VarienForm('social_security_number_form', false);
31
  //]]>
32
  </script>
app/design/frontend/base/default/template/payex/partpayment/form.phtml CHANGED
@@ -34,25 +34,6 @@ $fee = $this->getPayexPaymentFee();
34
  class="required-entry input-text" type="text" readonly/><br/>
35
  <?php endif; ?>
36
  </form>
37
- <?php if ($fee->getPaymentFeePrice() > 0): ?>
38
- <div>
39
- <?php if ($this->helper('tax')->displayBothPrices()): ?>
40
- <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
41
- <br />
42
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
43
- <?php echo $this->helper('checkout')->__('(Excl. Tax)'); ?>
44
- <br />
45
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
46
- <?php echo $this->helper('checkout')->__('(Incl. Tax)'); ?>
47
- <?php elseif ($this->helper('tax')->displayPriceIncludingTax()): ?>
48
- <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
49
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
50
- <?php else: ?>
51
- <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
52
- <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
53
- <?php endif; ?>
54
- </div>
55
- <?php endif; ?>
56
  <!-- End PayEx PartPayment block -->
57
  </div>
58
  <div style="float:right"></div>
34
  class="required-entry input-text" type="text" readonly/><br/>
35
  <?php endif; ?>
36
  </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  <!-- End PayEx PartPayment block -->
38
  </div>
39
  <div style="float:right"></div>
app/design/frontend/base/default/template/payex/partpayment/info.phtml CHANGED
@@ -7,6 +7,10 @@
7
  <?php if (!empty($trans_id)): ?>
8
  <?php $specific = $this->getSpecificInformation(); ?>
9
  <?php if (count($specific) > 0): ?>
 
 
 
 
10
  <?php foreach ($specific as $key => $value): ?>
11
  <?php echo Mage::helper('payex')->__($key) . ': ' . $this->htmlEscape($value); ?><br/>
12
  <?php endforeach; ?>
7
  <?php if (!empty($trans_id)): ?>
8
  <?php $specific = $this->getSpecificInformation(); ?>
9
  <?php if (count($specific) > 0): ?>
10
+ <?php unset($specific['PayEx Payment Method']); ?>
11
+ <?php unset($specific['Authenticated Status']); ?>
12
+ <?php unset($specific['Transaction Ref']); ?>
13
+ <?php unset($specific['PayEx Transaction Status']); ?>
14
  <?php foreach ($specific as $key => $value): ?>
15
  <?php echo Mage::helper('payex')->__($key) . ': ' . $this->htmlEscape($value); ?><br/>
16
  <?php endforeach; ?>
app/design/frontend/base/default/template/payex/partpayment/pdf/info.phtml CHANGED
@@ -3,6 +3,10 @@
3
  <?php if (!empty($trans_id)): ?>
4
  <?php $specific = $this->getSpecificInformation(); ?>
5
  <?php if (count($specific) > 0): ?>
 
 
 
 
6
  <?php foreach($specific as $key => $value): ?>
7
  <?php echo Mage::helper('payex')->__($key) . ': ' . $value; ?>
8
  {{pdf_row_separator}}
3
  <?php if (!empty($trans_id)): ?>
4
  <?php $specific = $this->getSpecificInformation(); ?>
5
  <?php if (count($specific) > 0): ?>
6
+ <?php unset($specific['PayEx Payment Method']); ?>
7
+ <?php unset($specific['Authenticated Status']); ?>
8
+ <?php unset($specific['Transaction Ref']); ?>
9
+ <?php unset($specific['PayEx Transaction Status']); ?>
10
  <?php foreach($specific as $key => $value): ?>
11
  <?php echo Mage::helper('payex')->__($key) . ': ' . $value; ?>
12
  {{pdf_row_separator}}
app/design/frontend/base/default/template/payex/swish/pdf/info.phtml CHANGED
@@ -4,6 +4,9 @@
4
  <?php $specific = $this->getSpecificInformation(); ?>
5
  <?php if (count($specific) > 0): ?>
6
  <?php foreach($specific as $key => $value): ?>
 
 
 
7
  <?php echo Mage::helper('payex')->__($key) . ': ' . $value; ?>
8
  {{pdf_row_separator}}
9
  <?php endforeach; ?>
4
  <?php $specific = $this->getSpecificInformation(); ?>
5
  <?php if (count($specific) > 0): ?>
6
  <?php foreach($specific as $key => $value): ?>
7
+ <?php unset($specific['Authenticated Status']); ?>
8
+ <?php unset($specific['Transaction Ref']); ?>
9
+ <?php unset($specific['PayEx Transaction Status']); ?>
10
  <?php echo Mage::helper('payex')->__($key) . ': ' . $value; ?>
11
  {{pdf_row_separator}}
12
  <?php endforeach; ?>
app/design/frontend/base/default/template/payex/wywallet/info.phtml CHANGED
@@ -7,6 +7,9 @@
7
  <?php if (!empty($trans_id)): ?>
8
  <?php $specific = $this->getSpecificInformation(); ?>
9
  <?php if (count($specific) > 0): ?>
 
 
 
10
  <?php foreach($specific as $key => $value): ?>
11
  <?php echo Mage::helper('payex')->__($key) . ': ' . $this->htmlEscape($value); ?><br />
12
  <?php endforeach; ?>
7
  <?php if (!empty($trans_id)): ?>
8
  <?php $specific = $this->getSpecificInformation(); ?>
9
  <?php if (count($specific) > 0): ?>
10
+ <?php unset($specific['Authenticated Status']); ?>
11
+ <?php unset($specific['Transaction Ref']); ?>
12
+ <?php unset($specific['PayEx Transaction Status']); ?>
13
  <?php foreach($specific as $key => $value): ?>
14
  <?php echo Mage::helper('payex')->__($key) . ': ' . $this->htmlEscape($value); ?><br />
15
  <?php endforeach; ?>
app/design/frontend/base/default/template/payex/wywallet/pdf/info.phtml CHANGED
@@ -5,6 +5,9 @@
5
  <?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?>
6
  {{pdf_row_separator}}
7
  <?php if (count($specific) > 0): ?>
 
 
 
8
  <?php foreach($specific as $key => $value): ?>
9
  <?php echo Mage::helper('payex')->__($key) . ': ' . $this->htmlEscape($value); ?>
10
  {{pdf_row_separator}}
5
  <?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?>
6
  {{pdf_row_separator}}
7
  <?php if (count($specific) > 0): ?>
8
+ <?php unset($specific['Authenticated Status']); ?>
9
+ <?php unset($specific['Transaction Ref']); ?>
10
+ <?php unset($specific['PayEx Transaction Status']); ?>
11
  <?php foreach($specific as $key => $value): ?>
12
  <?php echo Mage::helper('payex')->__($key) . ': ' . $this->htmlEscape($value); ?>
13
  {{pdf_row_separator}}
app/etc/modules/PayEx_Payments.xml CHANGED
@@ -10,7 +10,7 @@
10
  <Mage_Payment />
11
  </depends>
12
  <!-- declare module's version information for database updates -->
13
- <version>3.0.1</version>
14
  </PayEx_Payments>
15
  </modules>
16
  </config>
10
  <Mage_Payment />
11
  </depends>
12
  <!-- declare module's version information for database updates -->
13
+ <version>3.0.4</version>
14
  </PayEx_Payments>
15
  </modules>
16
  </config>
app/locale/sv_SE/PayEx_Payments.csv CHANGED
@@ -27,10 +27,10 @@
27
  "<a target=""_blank"" href=""%s"">agreement</a>","<a target=""_blank"" href=""%s"">överenskommelse</a>"
28
  "Sign a %s to streamline further purchases with PayEx.","Gör en %s för att underlätta vidare köp."
29
  "I accept the agreement","Jag godkänner överenskommelsen"
30
- "You already %s the agreement.","Du har redan %s överenskommelsen."
31
- "Payment will be made automatically by credit card.","Betalningen görs automatiskt med kort."
32
- "Cancel agreement?","Upphäv överenskommelsen?"
33
- "Cancel agreement","Upphäv överenskommelsen"
34
  "Selected currency code (%s) is not compatible with PayEx","Vald valuta (%s) är inte godkänd av PayEx"
35
  "Can't load last transaction.","Kan inte ladda senaste transaktion."
36
  "Unable to execute capture. Accept only Authorize transactions.","Kan inte fånga ordern. Bara order med Authorize accepteras."
@@ -106,7 +106,7 @@
106
  "Order automatically canceled. Transaction is failed.","Order automatically canceled. Transaction is failed."
107
  "Invalid transaction status.","Invalid transaction status."
108
  "Reward points","Reward points"
109
- "Your customers bank declined the transaction, your customer can contact their bank for more information","Your customers bank declined the transaction, your customer can contact their bank for more information"
110
  "An unhandled exception occurred","An unhandled exception occurred"
111
  "A problem with Visa or MasterCards directory server, that communicates transactions for 3D-Secure verification","A problem with Visa or MasterCards directory server, that communicates transactions for 3D-Secure verification"
112
  "Communication error with the acquiring bank","Communication error with the acquiring bank"
@@ -123,7 +123,8 @@
123
  "Generic validation error","Generic validation error"
124
  "The hash on request is not valid, this might be due to the encryption key being incorrect","The hash on request is not valid, this might be due to the encryption key being incorrect"
125
  "One of the input parameters has invalid data. See paramName and description for more information","One of the input parameters has invalid data. See paramName and description for more information"
126
- "The operation was cancelled by the client","The operation was cancelled by the client"
 
127
  "Unexpecter error at 3rd party","Unexpecter error at 3rd party"
128
  "The amount is not valid for this operation","The amount is not valid for this operation"
129
  "No data found","No data found"
@@ -135,7 +136,12 @@
135
  "Insufficient funds","Insufficient funds"
136
  "Incorrect amount","Incorrect amount"
137
  "Payment cancelled","Payment cancelled"
138
- "Your Credit Card not accepted for this purchase","Your Credit Card not accepted for this purchase"
 
 
 
 
 
139
  "PayEx error: %s","PayEx error: %s"
140
  "Can't load last transaction.","Can't load last transaction."
141
  "Can't capture captured order.","Can't capture captured order."
@@ -177,4 +183,22 @@
177
  "Invalid Social Security Number","Invalid Social Security Number"
178
  "Country is empty","Country is empty"
179
  "Your country don't supported","Your country don't supported"
180
- "Postcode is empty","Postcode is empty"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  "<a target=""_blank"" href=""%s"">agreement</a>","<a target=""_blank"" href=""%s"">överenskommelse</a>"
28
  "Sign a %s to streamline further purchases with PayEx.","Gör en %s för att underlätta vidare köp."
29
  "I accept the agreement","Jag godkänner överenskommelsen"
30
+ "You already have an <a target=""_blank"" href=""%s"">agreement</a>.","Du har redan en <a target=""_blank"" href=""%s"">överenskommelse</a>."
31
+ "Payment will be automatically charged on your card.","Betalningen görs automatiskt med kort."
32
+ "Cancel agreement?","Avbryt överenskommelsen?"
33
+ "Cancel agreement","Avbryt överenskommelsen"
34
  "Selected currency code (%s) is not compatible with PayEx","Vald valuta (%s) är inte godkänd av PayEx"
35
  "Can't load last transaction.","Kan inte ladda senaste transaktion."
36
  "Unable to execute capture. Accept only Authorize transactions.","Kan inte fånga ordern. Bara order med Authorize accepteras."
106
  "Order automatically canceled. Transaction is failed.","Order automatically canceled. Transaction is failed."
107
  "Invalid transaction status.","Invalid transaction status."
108
  "Reward points","Reward points"
109
+ "Your customers bank declined the transaction, your customer can contact their bank for more information","Handlarens bank acceperade inte din betalning. Det kan bero ett tekniskt fel eller att du inte har pengar på kontot, eller något annat."
110
  "An unhandled exception occurred","An unhandled exception occurred"
111
  "A problem with Visa or MasterCards directory server, that communicates transactions for 3D-Secure verification","A problem with Visa or MasterCards directory server, that communicates transactions for 3D-Secure verification"
112
  "Communication error with the acquiring bank","Communication error with the acquiring bank"
123
  "Generic validation error","Generic validation error"
124
  "The hash on request is not valid, this might be due to the encryption key being incorrect","The hash on request is not valid, this might be due to the encryption key being incorrect"
125
  "One of the input parameters has invalid data. See paramName and description for more information","One of the input parameters has invalid data. See paramName and description for more information"
126
+ "The operation was cancelled by the client","Betalningen avbruten av kund"
127
+ "Your payment has been flagged as possible fraud by the bank. The payment has been cancelled.","Betalningen misstänks vara bedrägeri. Köpet har stoppats."
128
  "Unexpecter error at 3rd party","Unexpecter error at 3rd party"
129
  "The amount is not valid for this operation","The amount is not valid for this operation"
130
  "No data found","No data found"
136
  "Insufficient funds","Insufficient funds"
137
  "Incorrect amount","Incorrect amount"
138
  "Payment cancelled","Payment cancelled"
139
+ "Your Credit Card not accepted for this purchase","Kortet är inte tillåtet för detta köp"
140
+ "Credit check was declined, please try another payment option","Köpet godkändes inte. Kunden klarade inte den automatiska kreditprövningen"
141
+ "Payment is not allowed from your country","Handlarens bank tillåter inte betalning från ditt land"
142
+ "Your card is not accepted for this purchase","Kortet är inte tillåtet för detta köp"
143
+ "The amount of allowed tries to pay was exceeded. Please wait a couple of hours and try again.","Du har försökt att betala för många gånger. Försök igen om några timmar."
144
+ "There is a technical problem with communication to the bank. Please try again later.","Det är kommunikationsproblem med banken. Försök senare."
145
  "PayEx error: %s","PayEx error: %s"
146
  "Can't load last transaction.","Can't load last transaction."
147
  "Can't capture captured order.","Can't capture captured order."
183
  "Invalid Social Security Number","Invalid Social Security Number"
184
  "Country is empty","Country is empty"
185
  "Your country don't supported","Your country don't supported"
186
+ "Postcode is empty","Postcode is empty"
187
+ "Perform validation of SSN before checkout";"Perform validation of SSN before checkout"
188
+ "Please enter Social Security Number.";"Please enter Social Security Number."
189
+ "Discount Calculation";"Discount Calculation"
190
+ "Classic";"Classic"
191
+ "Advanced (experimental)";"Advanced (experimental)"
192
+ "Please enter additional fields:";"Please enter additional fields:"
193
+ "Country";"Country"
194
+ "Postal Code";"Postal Code"
195
+ "Get Address";"Get Address"
196
+ "Sweden";"Sweden"
197
+ "-- Please Select Credit Card--";"-- Please Select Credit Card--"
198
+ "Untitled Credit Card";"Untitled Credit Card"
199
+ "This agreement is invalid";"This agreement is invalid"
200
+ "Wrong Agreement Reference";"Wrong Agreement Reference"
201
+ "This agreement is invalid";"This agreement is invalid"
202
+ "Payment failed. Invalid transaction status";"Payment failed. Invalid transaction status"
203
+ "Payment has been authorized";"Payment has been authorized"
204
+ "Payment has been captured";"Payment has been captured"
js/payex/social_security_number.js CHANGED
@@ -13,10 +13,9 @@ function fireEvent(element, event) {
13
  }
14
 
15
  Event.observe(document, 'dom:loaded', function () {
16
- if ($('billing-address-select')) {
17
- document.getElementById('billing-address-select').value = '';
18
- fireEvent(document.getElementById('billing-address-select'), 'change');
19
- }
20
 
21
  $('ssn_click').observe('click', function (event) {
22
  // Check button is disabled
@@ -45,9 +44,29 @@ Event.observe(document, 'dom:loaded', function () {
45
  $(self).removeClassName('disabled');
46
  var json = response.responseText.evalJSON();
47
  if (!json.success) {
48
- alert(json.message);
 
 
 
 
 
 
 
 
49
  return;
50
  }
 
 
 
 
 
 
 
 
 
 
 
 
51
  // Set Form Fields
52
  if ($('billing:firstname')) $('billing:firstname').setValue(json.first_name);
53
  if ($('billing:lastname')) $('billing:lastname').setValue(json.last_name);
@@ -61,7 +80,11 @@ Event.observe(document, 'dom:loaded', function () {
61
  if ($('billing:city')) $('billing:city').setValue(json.city);
62
  if ($('billing:region')) $('billing:region').setValue('');
63
  if ($('billing:postcode')) $('billing:postcode').setValue(json.postcode);
64
- if ($('billing:country_id')) $('billing:country_id').setValue(json.country);
 
 
 
 
65
  }
66
  }
67
  );
13
  }
14
 
15
  Event.observe(document, 'dom:loaded', function () {
16
+ $('socialSecurityNumber').on('focus', 'input', function() {
17
+ $('ssn_details').show();
18
+ });
 
19
 
20
  $('ssn_click').observe('click', function (event) {
21
  // Check button is disabled
44
  $(self).removeClassName('disabled');
45
  var json = response.responseText.evalJSON();
46
  if (!json.success) {
47
+ if ($('social_security_number_form') != undefined) {
48
+ // Use HTML placeholder to show message
49
+ $('ssn-error').update(json.message);
50
+ $('ssn-error-placeholder').show();
51
+ } else {
52
+ // Use popup message as failback
53
+ alert(json.message);
54
+ }
55
+
56
  return;
57
  }
58
+
59
+ // Show "New Address" fieldset
60
+ if ($('billing-address-select')) {
61
+ document.getElementById('billing-address-select').value = '';
62
+ fireEvent(document.getElementById('billing-address-select'), 'change');
63
+ }
64
+
65
+ // Hide error placeholder
66
+ if ($('social_security_number_form') != undefined) {
67
+ $('social_security_number_form').hide();
68
+ }
69
+
70
  // Set Form Fields
71
  if ($('billing:firstname')) $('billing:firstname').setValue(json.first_name);
72
  if ($('billing:lastname')) $('billing:lastname').setValue(json.last_name);
80
  if ($('billing:city')) $('billing:city').setValue(json.city);
81
  if ($('billing:region')) $('billing:region').setValue('');
82
  if ($('billing:postcode')) $('billing:postcode').setValue(json.postcode);
83
+ if ($('billing:country_id')) {
84
+ $('billing:country_id').setValue(json.country);
85
+ //$('billing:country_id').fire('change');
86
+ fireEvent(document.getElementById('billing:country_id'), 'change');
87
+ }
88
  }
89
  }
90
  );
lib/PHP-Name-Parser/README.md ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ PHP-Name-Parser
2
+ ===============
3
+
4
+ PHP library to split names into their respective components. Besides detecting first and last names, this library attempts to handle prefixes, suffixes, initials and compound last names like "Von Fange". It also normalizes prefixes (Mister -> Mr.) and fixes capitalization (JOHN SMITH -> John Smith).
5
+
6
+ **Usage:**
7
+
8
+ include("parser.php");
9
+
10
+ $parser = new FullNameParser();
11
+ $parser->parse_name("Mr Anthony R Von Fange III");
12
+
13
+ **Results:**
14
+
15
+ Array (
16
+ [nickname] =>
17
+ [salutation] => Mr.
18
+ [fname] => Anthony
19
+ [initials] => R
20
+ [lname] => Von Fange
21
+ [suffix] => III
22
+ )
23
+
24
+ **The algorithm:**
25
+
26
+ We start by splitting the full name into separate words. We then do a dictionary lookup on the first and last words to see if they are a common prefix or suffix. Next, we take the middle portion of the string (everything minus the prefix & suffix) and look at everything except the last word of that string. We then loop through each of those words concatenating them together to make up the first name. While we’re doing that, we watch for any indication of a compound last name. It turns out that almost every compound last name starts with 1 of 16 prefixes (Von, Van, Vere, etc). If we see one of those prefixes, we break out of the first name loop and move on to concatenating the last name. We handle the capitalization issue by checking for camel-case before uppercasing the first letter of each word and lowercasing everything else. I wrote special cases for periods and dashes. We also have a couple other special cases, like ignoring words in parentheses all-together.
27
+
28
+ Check examples.php for the test suite and examples of how various name formats are parsed.
29
+
30
+ **To-do**
31
+
32
+ * Handle the "Lname, Fname" format
33
+ * Support non-English names (handle unicode characters & better understand global naming rules)
34
+ * Separate the parsing of the name from the normalization & capitalization & make those optional.
35
+ * Add common name libraries to allow for things like gender detection
36
+
37
+ **Same logic, different languages**
38
+
39
+ * [Name Parser in Java](https://github.com/gkhays/NameParser)
40
+ * [Name Parser in JavaScript](https://github.com/joshfraser/JavaScript-Name-Parser)
41
+
42
+ **Credits & license:**
43
+
44
+ * Read more about the inspiration for this [PHP Name Parser](http://www.onlineaspect.com/2009/08/17/splitting-names/) library by [Josh Fraser](http://joshfraser.com)
45
+ * Special thanks to [Josh Jones](https://github.com/UberNerdBoy), [Timothy Wood](https://github.com/codearachnid), [Michael Waskosky](https://github.com/waskosky), [Eric Celeste](https://github.com/efc) and [Josh Houghtelin](https://github.com/jhoughtelin) for their contributions. Pull requests are always welcome as long as you don't break the test suite.
46
+ * Released under Apache 2.0 license
47
+
lib/PHP-Name-Parser/composer.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "joshfraser/php-name-parser",
3
+ "description": "PHP library to split names into their respective components (first, last, etc)",
4
+ "require": {
5
+ "php": "^5.3.3 || ^7.0"
6
+ },
7
+ "autoload": {
8
+ "files": [
9
+ "parser.php"
10
+ ]
11
+ }
12
+ }
lib/PHP-Name-Parser/examples.php ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once('parser.php');
4
+
5
+ // examples & a poor mans test suite
6
+ // intentionally shows examples that fail
7
+
8
+ $names = array(
9
+ "Mr Anthony R Von Fange III" => array("salutation" => "Mr.",
10
+ "fname" => "Anthony",
11
+ "initials" => "R",
12
+ "lname" => "Von Fange",
13
+ "suffix" => "III"),
14
+ "J. B. Hunt" => array("salutation" => "",
15
+ "fname" => "J.",
16
+ "initials" => "B.",
17
+ "lname" => "Hunt",
18
+ "suffix" => ""),
19
+ "J.B. Hunt" => array("salutation" => "",
20
+ "fname" => "J.B.",
21
+ "initials" => "",
22
+ "lname" => "Hunt",
23
+ "suffix" => ""),
24
+ "Edward Senior III" => array("salutation" => "",
25
+ "fname" => "Edward",
26
+ "initials" => "",
27
+ "lname" => "Senior",
28
+ "suffix" => "III"),
29
+ "Edward Dale Senior II" => array("salutation" => "",
30
+ "fname" => "Edward Dale",
31
+ "initials" => "",
32
+ "lname" => "Senior",
33
+ "suffix" => "II"),
34
+ "Dale Edward Jones Senior" => array("salutation" => "",
35
+ "fname" => "Dale Edward",
36
+ "initials" => "",
37
+ "lname" => "Jones",
38
+ "suffix" => "Senior"),
39
+ "Edward Senior II" => array("salutation" => "",
40
+ "fname" => "Edward",
41
+ "initials" => "",
42
+ "lname" => "Senior",
43
+ "suffix" => "II"),
44
+ "Dale Edward Senior II, PhD" => array("salutation" => "",
45
+ "fname" => "Dale Edward",
46
+ "initials" => "",
47
+ "lname" => "Senior",
48
+ "suffix" => "II, PhD"),
49
+ "Jason Rodriguez Sr." => array("salutation" => "",
50
+ "fname" => "Jason",
51
+ "initials" => "",
52
+ "lname" => "Rodriguez",
53
+ "suffix" => "Sr"),
54
+ "Jason Senior" => array("salutation" => "",
55
+ "fname" => "Jason",
56
+ "initials" => "",
57
+ "lname" => "Senior",
58
+ "suffix" => ""),
59
+ "Bill Junior" => array("salutation" => "",
60
+ "fname" => "Bill",
61
+ "initials" => "",
62
+ "lname" => "Junior",
63
+ "suffix" => ""),
64
+ "Sara Ann Fraser" => array("salutation" => "",
65
+ "fname" => "Sara Ann",
66
+ "initials" => "",
67
+ "lname" => "Fraser",
68
+ "suffix" => ""),
69
+ "Adam" => array("salutation" => "",
70
+ "fname" => "Adam",
71
+ "initials" => "",
72
+ "lname" => "",
73
+ "suffix" => ""),
74
+ "OLD MACDONALD" => array("salutation" => "",
75
+ "fname" => "Old",
76
+ "initials" => "",
77
+ "lname" => "Macdonald",
78
+ "suffix" => ""),
79
+ "Old MacDonald" => array("salutation" => "",
80
+ "fname" => "Old",
81
+ "initials" => "",
82
+ "lname" => "MacDonald",
83
+ "suffix" => ""),
84
+ "Old McDonald" => array("salutation" => "",
85
+ "fname" => "Old",
86
+ "initials" => "",
87
+ "lname" => "McDonald",
88
+ "suffix" => ""),
89
+ "Old Mc Donald" => array("salutation" => "",
90
+ "fname" => "Old Mc",
91
+ "initials" => "",
92
+ "lname" => "Donald",
93
+ "suffix" => ""),
94
+ "Old Mac Donald" => array("salutation" => "",
95
+ "fname" => "Old Mac",
96
+ "initials" => "",
97
+ "lname" => "Donald",
98
+ "suffix" => ""),
99
+ "James van Allen" => array("salutation" => "",
100
+ "fname" => "James",
101
+ "initials" => "",
102
+ "lname" => "Van Allen",
103
+ "suffix" => ""),
104
+ "Jimmy (Bubba) Smith" => array("nickname" => "Bubba",
105
+ "salutation" => "",
106
+ "fname" => "Jimmy",
107
+ "initials" => "",
108
+ "lname" => "Smith",
109
+ "suffix" => ""),
110
+ "Miss Jennifer Shrader Lawrence" => array("salutation" => "Ms.",
111
+ "fname" => "Jennifer Shrader",
112
+ "initials" => "",
113
+ "lname" => "Lawrence",
114
+ "suffix" => ""),
115
+ "Jonathan Smith, MD" => array("salutation" => "",
116
+ "fname" => "Jonathan",
117
+ "initials" => "",
118
+ "lname" => "Smith",
119
+ "suffix" => "MD"),
120
+ "Dr. Jonathan Smith" => array("salutation" => "Dr.",
121
+ "fname" => "Jonathan",
122
+ "initials" => "",
123
+ "lname" => "Smith",
124
+ "suffix" => ""),
125
+ "Jonathan Smith IV, PhD" => array("salutation" => "",
126
+ "fname" => "Jonathan",
127
+ "initials" => "",
128
+ "lname" => "Smith",
129
+ "suffix" => "IV, PhD"),
130
+ "Miss Jamie P. Harrowitz" => array("salutation" => "Ms.",
131
+ "fname" => "Jamie",
132
+ "initials" => "P.",
133
+ "lname" => "Harrowitz",
134
+ "suffix" => ""),
135
+ "Mr John Doe" => array("salutation" => "Mr.",
136
+ "fname" => "John",
137
+ "initials" => "",
138
+ "lname" => "Doe",
139
+ "suffix" => ""),
140
+ "Rev. Dr John Doe" => array("salutation" => "Rev. Dr.",
141
+ "fname" => "John",
142
+ "initials" => "",
143
+ "lname" => "Doe",
144
+ "suffix" => ""),
145
+ "Anthony Von Fange III" => array("salutation" => "",
146
+ "fname" => "Anthony",
147
+ "initials" => "",
148
+ "lname" => "Von Fange",
149
+ "suffix" => "III"),
150
+ "Anthony Von Fange III, PhD" => array("salutation" => "",
151
+ "fname" => "Anthony",
152
+ "initials" => "",
153
+ "lname" => "Von Fange",
154
+ "suffix" => "III, PhD"),
155
+ "Smarty Pants Phd" => array("salutation" => "",
156
+ "fname" => "Smarty",
157
+ "initials" => "",
158
+ "lname" => "Pants",
159
+ "suffix" => "PhD"),
160
+ "Mark Peter Williams" => array("salutation" => "",
161
+ "fname" => "Mark Peter",
162
+ "initials" => "",
163
+ "lname" => "Williams",
164
+ "suffix" => ""),
165
+ "Mark P Williams" => array("salutation" => "",
166
+ "fname" => "Mark",
167
+ "initials" => "P",
168
+ "lname" => "Williams",
169
+ "suffix" => ""),
170
+ "Mark P. Williams" => array("salutation" => "",
171
+ "fname" => "Mark",
172
+ "initials" => "P.",
173
+ "lname" => "Williams",
174
+ "suffix" => ""),
175
+ "M Peter Williams" => array("salutation" => "",
176
+ "fname" => "Peter",
177
+ "initials" => "M",
178
+ "lname" => "Williams",
179
+ "suffix" => ""),
180
+ "M. Peter Williams" => array("salutation" => "",
181
+ "fname" => "Peter",
182
+ "initials" => "M.",
183
+ "lname" => "Williams",
184
+ "suffix" => ""),
185
+ "M. P. Williams" => array("salutation" => "",
186
+ "fname" => "M.",
187
+ "initials" => "P.",
188
+ "lname" => "Williams",
189
+ "suffix" => ""),
190
+ "The Rev. Mark Williams" => array("salutation" => "Rev.",
191
+ "fname" => "Mark",
192
+ "initials" => "",
193
+ "lname" => "Williams",
194
+ "suffix" => ""),
195
+ "Mister Mark Williams" => array("salutation" => "Mr.",
196
+ "fname" => "Mark",
197
+ "initials" => "",
198
+ "lname" => "Williams",
199
+ "suffix" => ""),
200
+ // fails. format not yet supported
201
+ "Fraser, Joshua" => array("salutation" => "",
202
+ "fname" => "Joshua",
203
+ "initials" => "",
204
+ "lname" => "Fraser",
205
+ "suffix" => ""),
206
+ // fails. both initials should be capitalized
207
+ "JB Hunt" => array("salutation" => "",
208
+ "fname" => "JB",
209
+ "initials" => "",
210
+ "lname" => "Hunt",
211
+ "suffix" => ""),
212
+ // fails. doesn't handle multiple words inside parenthesis
213
+ "Jimmy (Bubba Junior) Smith" => array("nickname" => "Bubba Junior",
214
+ "salutation" => "",
215
+ "fname" => "Jimmy",
216
+ "initials" => "",
217
+ "lname" => "Smith",
218
+ "suffix" => ""),
219
+ // fails. should normalize the PhD suffix
220
+ "Anthony Von Fange III, PHD" => array("salutation" => "",
221
+ "fname" => "Anthony",
222
+ "initials" => "",
223
+ "lname" => "Von Fange",
224
+ "suffix" => "III, PhD"),
225
+ // fails. should treat "Silly" as the nickname or remove altogether
226
+ "Not So Smarty Pants, Silly" => array("nickname" => "Silly",
227
+ "salutation" => "",
228
+ "fname" => "Not So Smarty",
229
+ "initials" => "",
230
+ "lname" => "Pants",
231
+ "suffix" => ""),
232
+ "Rev Al Sharpton" => array("salutation" => "Rev.",
233
+ "fname" => "Al",
234
+ "initials" => "",
235
+ "lname" => "Sharpton",
236
+ "suffix" => ""),
237
+ "Dr Ty P. Bennington iIi" => array("salutation" => "Dr.",
238
+ "fname" => "Ty",
239
+ "initials" => "P.",
240
+ "lname" => "Bennington",
241
+ "suffix" => "III"),
242
+ );
243
+
244
+
245
+ $parser = new FullNameParser();
246
+
247
+ $headers = array("salutation","fname","initials","lname","suffix","nickname");
248
+ ?>
249
+ <!DOCTYPE html>
250
+ <html lang="en-US">
251
+ <head>
252
+ <meta charset="UTF-8">
253
+ <meta name="viewport" content="width=device-width, initial-scale=1">
254
+ <title>PHP Name Parser | Unit Tests</title>
255
+ <link rel="stylesheet" href="./tests/style.css" type="text/css" media="all">
256
+ </head>
257
+ <body>
258
+ <div class="wrapper">
259
+ <table class="unit-tests">
260
+ <thead>
261
+ <tr>
262
+ <th>Full Name</th>
263
+ <?php foreach ($headers as $col): ?>
264
+ <th><?= ucfirst($col); ?></th>
265
+ <?php endforeach; ?>
266
+ <th>Passed</th>
267
+ </tr>
268
+ </thead>
269
+ <tbody>
270
+ <?php foreach ($names as $name => $expected_values): $split_name = $parser->parse_name($name); $passed = ($split_name === $expected_values); ?>
271
+ <tr class="<?= ($passed) ? 'pass' : 'fail'; ?>">
272
+ <td><?= $name; ?></td>
273
+ <?php foreach ($headers as $col): ?>
274
+ <td><?= (isset($split_name[$col])) ? $split_name[$col] : ''; ?></td>
275
+ <?php endforeach; ?>
276
+ <td><?= ($passed) ? 'PASS' : 'FAIL'; ?></td>
277
+ </tr>
278
+ <?php endforeach; ?>
279
+ </tbody>
280
+ </table>
281
+ </div>
282
+ </body>
283
+ </html>
lib/{Px → PHP-Name-Parser}/parser.php RENAMED
@@ -1,388 +1,453 @@
1
- <?php
2
-
3
-
4
-
5
- /**
6
- * Split a full name into its constituent parts
7
- * - prefix/salutation (Mr. Mrs. Dr. etc)
8
- * - given/first name
9
- * - middle name/initial(s)
10
- * - surname (last name)
11
- * - suffix (II, PhD, Jr. etc)
12
- */
13
- class FullNameParser {
14
-
15
-
16
-
17
- /**
18
- * Create the dictionary of terms for use later
19
- *
20
- * - Common honorific prefixes (english)
21
- * - Common compound surname identifiers
22
- * - Common suffixes (lineage and professional)
23
- */
24
- protected $dict = array(
25
- 'prefix' => array(
26
- 'Mr.' => array('mr', 'mister', 'master'),
27
- 'Mrs.' => array('mrs', 'missus', 'missis'),
28
- 'Ms.' => array('ms', 'miss'),
29
- 'Dr.' => array('dr'),
30
- 'Rev.' => array("rev", "rev'd", "reverend"),
31
- 'Fr.' => array('fr', 'father'),
32
- 'Sr.' => array('sr', 'sister'),
33
- 'Prof.' => array('prof', 'professor'),
34
- 'Sir' => array('sir'),
35
- ' ' => array('the')
36
- ),
37
- 'compound' => array('da','de','del','della','der','di','du','la','pietro','st.','st','ter','van','vanden','vere','von'),
38
- 'suffixes' => array(
39
- 'line' => array('I','II','III','IV','V','1st','2nd','3rd','4th','5th','Senior','Junior','Jr','Sr'),
40
- 'prof' => array('PhD','APR','RPh','PE','MD','MA','DMD','CME')
41
- ),
42
- 'vowels' => array('a','e','i','o','u')
43
- );
44
-
45
-
46
-
47
- /**
48
- * This is the primary method which calls all other methods
49
- *
50
- * @param string $name the full name you wish to parse
51
- * @return array returns associative array of name parts
52
- */
53
- public function parse_name($full_name) {
54
-
55
- # Remove leading/trailing whitespace
56
- $full_name = trim($full_name);
57
-
58
- # Setup default vars
59
- extract(array('salutation' => '', 'fname' => '', 'initials' => '', 'lname' => '', 'suffix' => ''));
60
-
61
- # If name contains professional suffix, assign and remove it
62
- $professional_suffix = $this->get_pro_suffix($full_name);
63
- if ($professional_suffix) {
64
- # Remove the suffix from full name
65
- $full_name = str_replace($professional_suffix, '', $full_name);
66
- # Remove the preceeding comma and space(s) from suffix
67
- $professional_suffix = preg_replace("/, */", '', $professional_suffix);
68
- # Normalize the case of suffix if found in dictionary
69
- foreach ($this->dict['suffixes']['prof'] as $prosuffix) {
70
- if (strtolower($prosuffix) === strtolower($professional_suffix)) {
71
- $professional_suffix = $prosuffix;
72
- }
73
- }
74
- }
75
-
76
- # Deal with nickname, push to array
77
- $has_nick = $this->get_nickname($full_name);
78
- if ($has_nick) {
79
- # Remove wrapper chars from around nickname
80
- $name['nickname'] = substr($has_nick, 1, (strlen($has_nick) - 2));
81
- # Remove the nickname from the full name
82
- $full_name = str_replace($has_nick, '', $full_name);
83
- # Get rid of consecutive spaces left by the removal
84
- $full_name = str_replace(' ', ' ', $full_name);
85
- }
86
-
87
- # Grab a list of words from name
88
- $unfiltered_name_parts = $this->break_words($full_name);
89
-
90
- # Is first word a title or multiple titles consecutively?
91
- while ($s = $this->is_salutation($unfiltered_name_parts[0])) {
92
- $salutation .= "$s ";
93
- array_shift($unfiltered_name_parts);
94
- }
95
- $salutation = trim($salutation);
96
-
97
- # Is last word a suffix or multiple suffixes consecutively?
98
- while ($s = $this->is_suffix($unfiltered_name_parts[count($unfiltered_name_parts)-1], $full_name)) {
99
- $suffix .= "$s ";
100
- array_pop($unfiltered_name_parts);
101
- }
102
- $suffix = trim($suffix);
103
-
104
- # If suffix and professional suffix not empty, add comma
105
- if (!empty($professional_suffix) && !empty($suffix)) {
106
- $suffix .= ', ';
107
- }
108
-
109
- # Concat professional suffix to suffix
110
- $suffix .= $professional_suffix;
111
-
112
- # set the ending range after prefix/suffix trim
113
- $end = count($unfiltered_name_parts);
114
-
115
- # concat the first name
116
- for ($i=0; $i<$end-1; $i++) {
117
- $word = $unfiltered_name_parts[$i];
118
- # move on to parsing the last name if we find an indicator of a compound last name (Von, Van, etc)
119
- # we use $i != 0 to allow for rare cases where an indicator is actually the first name (like "Von Fabella")
120
- if ($this->is_compound($word) && $i != 0) {
121
- break;
122
- }
123
- # is it a middle initial or part of their first name?
124
- # if we start off with an initial, we'll call it the first name
125
- if ($this->is_initial($word)) {
126
- # is the initial the first word?
127
- if ($i == 0) {
128
- # if so, do a look-ahead to see if they go by their middle name
129
- # for ex: "R. Jason Smith" => "Jason Smith" & "R." is stored as an initial
130
- # but "R. J. Smith" => "R. Smith" and "J." is stored as an initial
131
- if ($this->is_initial($unfiltered_name_parts[$i+1])) {
132
- $fname .= " ".strtoupper($word);
133
- }
134
- else {
135
- $initials .= " ".strtoupper($word);
136
- }
137
- }
138
- # otherwise, just go ahead and save the initial
139
- else {
140
- $initials .= " ".strtoupper($word);
141
- }
142
- }
143
- else {
144
- $fname .= " ".$this->fix_case($word);
145
- }
146
- }
147
-
148
- # check that we have more than 1 word in our string
149
- if ($end-0 > 1) {
150
- # concat the last name
151
- for ($i; $i < $end; $i++) {
152
- $lname .= " ".$this->fix_case($unfiltered_name_parts[$i]);
153
- }
154
- }
155
- else {
156
- # otherwise, single word strings are assumed to be first names
157
- $fname = $this->fix_case($unfiltered_name_parts[$i]);
158
- }
159
-
160
- # return the various parts in an array
161
- $name['salutation'] = $salutation;
162
- $name['fname'] = trim($fname);
163
- $name['initials'] = trim($initials);
164
- $name['lname'] = trim($lname);
165
- $name['suffix'] = $suffix;
166
- return $name;
167
- }
168
-
169
-
170
-
171
- /**
172
- * Breaks name into individual words
173
- *
174
- * @param string $name the full name you wish to parse
175
- * @return array full list of words broken down by spaces
176
- */
177
- public function break_words($name) {
178
- return explode(' ', $name);
179
- }
180
-
181
-
182
-
183
- /**
184
- * Checks for the existence of, and returns professional suffix
185
- *
186
- * @param string $name the name you wish to test
187
- * @return mixed returns the suffix if exists, false otherwise
188
- */
189
- protected function get_pro_suffix($name) {
190
- foreach ($this->dict['suffixes']['prof'] as $suffix) {
191
- if (preg_match("/,[\s]*$suffix\b/i", $name, $matches)) {
192
- return $matches[0];
193
- }
194
- }
195
- return false;
196
- }
197
-
198
-
199
-
200
- /**
201
- * Function to check name for existence of nickname based on these stipulations
202
- * - String wrapped in parentheses (string)
203
- * - String wrapped in double quotes "string"
204
- * x String wrapped in single quotes 'string'
205
- *
206
- * I removed the check for strings in single quotes 'string' due to possible
207
- * conflicts with names that may include apostrophes. Arabic transliterations, for example
208
- *
209
- * @param string $name the name you wish to test against
210
- * @return mixed returns nickname if exists, false otherwise
211
- */
212
- protected function get_nickname($name) {
213
- if (preg_match("/[\(|\"].*?[\)|\"]/", $name, $matches)) {
214
- return $matches[0];
215
- }
216
- return false;
217
- }
218
-
219
-
220
-
221
- /**
222
- * Checks word against array of common suffixes
223
- *
224
- * @param string $word the single word you wish to test
225
- * @param string $name full name for context in determining edge-cases
226
- * @return mixed boolean if false, string if true (returns suffix)
227
- */
228
- protected function is_suffix($word, $name) {
229
-
230
- # Ignore periods, normalize case
231
- $word = str_replace('.', '', strtolower($word));
232
-
233
- # Search the array for our word
234
- $line_match = array_search($word, array_map('strtolower', $this->dict['suffixes']['line']));
235
- $prof_match = array_search($word, array_map('strtolower', $this->dict['suffixes']['prof']));
236
-
237
- # Break out for professional suffix matches first
238
- if ($prof_match !== false) {
239
- return $this->dict['suffixes']['prof'][$prof_match];
240
- }
241
-
242
- # Now test our edge cases based on lineage
243
- if ($line_match !== false) {
244
-
245
- # Store our match
246
- $matched_case = $this->dict['suffixes']['line'][$line_match];
247
-
248
- # Remove it from the array
249
- $temp_array = $this->dict['suffixes']['line'];
250
- unset($temp_array[$line_match]);
251
-
252
- # Make sure we're dealing with the suffix and not a surname
253
- if ($word == 'senior' || $word == 'junior') {
254
-
255
- # If name is Joshua Senior, it's pretty likely that Senior is the surname
256
- # However, if the name is Joshua Jones Senior, then it's likely a suffix
257
- if (str_word_count($name) < 3) {
258
- return false;
259
- }
260
-
261
- # If the word Junior or Senior is contained, but so is some other
262
- # lineage suffix, then the word is likely a surname and not a suffix
263
- foreach ($temp_array as $suffix) {
264
- if (preg_match("/\b".$suffix."\b/i", $name)) {
265
- return false;
266
- }
267
- }
268
- }
269
- return $matched_case;
270
- }
271
- return false;
272
- }
273
-
274
-
275
-
276
- /**
277
- * Checks word against list of common honorific prefixes
278
- *
279
- * @param string $word the single word you wish to test
280
- * @return boolean
281
- */
282
- protected function is_salutation($word) {
283
- $word = str_replace('.', '', strtolower($word));
284
- foreach ($this->dict['prefix'] as $replace => $originals) {
285
- if (in_array($word, $originals)) {
286
- return $replace;
287
- }
288
- }
289
- return false;
290
- }
291
-
292
-
293
-
294
- /**
295
- * Checks our dictionary of compound indicators to see if last name is compound
296
- *
297
- * @param string $word the single word you wish to test
298
- * @return boolean
299
- */
300
- protected function is_compound($word) {
301
- return array_search(strtolower($word), $this->dict['compound']);
302
- }
303
-
304
-
305
-
306
- /**
307
- * Test string to see if it's a single letter/initial (period optional)
308
- *
309
- * @param string $word the single word you wish to test
310
- * @return boolean
311
- */
312
- protected function is_initial($word) {
313
- return ((strlen($word) == 1) || (strlen($word) == 2 && $word{1} == "."));
314
- }
315
-
316
-
317
-
318
- /**
319
- * Checks for camelCase words such as McDonald and MacElroy
320
- *
321
- * @param string $word the single word you wish to test
322
- * @return boolean
323
- */
324
- protected function is_camel_case($word) {
325
- if (preg_match("/[A-Za-z]([A-Z]*[a-z][a-z]*[A-Z]|[a-z]*[A-Z][A-Z]*[a-z])[A-Za-z]*/", $word)) {
326
- return true;
327
- }
328
- return false;
329
- }
330
-
331
- # ucfirst words split by dashes or periods
332
- # ucfirst all upper/lower strings, but leave camelcase words alone
333
- public function fix_case($word) {
334
-
335
- # Fix case for words split by periods (J.P.)
336
- if (strpos($word, '.') !== false) {
337
- $word = $this->safe_ucfirst(".", $word);;
338
- }
339
-
340
- # Fix case for words split by hyphens (Kimura-Fay)
341
- if (strpos($word, '-') !== false) {
342
- $word = $this->safe_ucfirst("-", $word);
343
- }
344
-
345
- # Special case for single letters
346
- if (strlen($word) == 1) {
347
- $word = strtoupper($word);
348
- }
349
-
350
- # Special case for 2-letter words
351
- if (strlen($word) == 2) {
352
- # Both letters vowels (uppercase both)
353
- if (in_array(strtolower($word{0}), $this->dict['vowels']) && in_array(strtolower($word{1}), $this->dict['vowels'])) {
354
- $word = strtoupper($word);
355
- }
356
- # Both letters consonants (uppercase both)
357
- if (!in_array(strtolower($word{0}), $this->dict['vowels']) && !in_array(strtolower($word{1}), $this->dict['vowels'])) {
358
- $word = strtoupper($word);
359
- }
360
- # First letter is vowel, second letter consonant (uppercase first)
361
- if (in_array(strtolower($word{0}), $this->dict['vowels']) && !in_array(strtolower($word{1}), $this->dict['vowels'])) {
362
- $word = ucfirst(strtolower($word));
363
- }
364
- # First letter consonant, second letter vowel or "y" (uppercase first)
365
- if (!in_array(strtolower($word{0}), $this->dict['vowels']) && (in_array(strtolower($word{1}), $this->dict['vowels']) || strtolower($word{1}) == 'y')) {
366
- $word = ucfirst(strtolower($word));
367
- }
368
- }
369
-
370
- # Fix case for words which aren't initials, but are all upercase or lowercase
371
- if ( (strlen($word) >= 3) && (ctype_upper($word) || ctype_lower($word)) ) {
372
- $word = ucfirst(strtolower($word));
373
- }
374
-
375
- return $word;
376
- }
377
-
378
- # helper public function for fix_case
379
- public function safe_ucfirst($seperator, $word) {
380
- # uppercase words split by the seperator (ex. dashes or periods)
381
- $parts = explode($seperator, $word);
382
- foreach ($parts as $word) {
383
- $words[] = ($this->is_camel_case($word)) ? $word : ucfirst(strtolower($word));
384
- }
385
- return implode($seperator, $words);
386
- }
387
-
388
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+
5
+ /**
6
+ * Split a full name into its constituent parts
7
+ * - prefix/salutation (Mr. Mrs. Dr. etc)
8
+ * - given/first name
9
+ * - middle name/initial(s)
10
+ * - surname (last name)
11
+ * - suffix (II, PhD, Jr. etc)
12
+ *
13
+ * Author: Josh Frazer
14
+ *
15
+ * Contribution from Clive Verrall www.cliveverrall.com February 2016
16
+ */
17
+ class FullNameParser {
18
+
19
+
20
+
21
+ /**
22
+ * Create the dictionary of terms for use later
23
+ *
24
+ * - Common honorific prefixes (english)
25
+ * - Common compound surname identifiers
26
+ * - Common suffixes (lineage and professional)
27
+ * Note: longer professional titles should appear earlier in the array than shorter titles to reduce the risk of mis-identification e.g. BEng before BE
28
+ * Also note that case and periods are part of the matching for professional titles and therefore need to be correct, there are no case conversions
29
+ */
30
+ protected $dict = array(
31
+ 'prefix' => array(
32
+ 'Mr.' => array('mr', 'mister', 'master'),
33
+ 'Mrs.' => array('mrs', 'missus', 'missis'),
34
+ 'Ms.' => array('ms', 'miss'),
35
+ 'Dr.' => array('dr'),
36
+ 'Rev.' => array("rev", "rev'd", "reverend"),
37
+ 'Fr.' => array('fr', 'father'),
38
+ 'Sr.' => array('sr', 'sister'),
39
+ 'Prof.' => array('prof', 'professor'),
40
+ 'Sir' => array('sir'),
41
+ ' ' => array('the')
42
+ ),
43
+ 'compound' => array('da','de','del','della','der','di','du','la','pietro','st.','st','ter','van','vanden','vere','von'),
44
+ 'suffixes' => array(
45
+ 'line' => array('I','II','III','IV','V','1st','2nd','3rd','4th','5th','Senior','Junior','Jr','Sr'),
46
+ 'prof' => array('AO', 'B.A.', 'M.Sc', 'BCompt', 'PhD', 'Ph.D.','APR','RPh','PE','MD', 'M.D.', 'MA','DMD','CME', 'BSc', 'Bsc', 'BSc(hons)', 'Ph.D.', 'BEng', 'M.B.A.', 'MBA', 'FAICD', 'CM', 'OBC', 'M.B.', 'ChB', 'FRCP', 'FRSC',
47
+ 'FREng', 'Esq', 'MEng', 'MSc', 'J.D.', 'JD', 'BGDipBus', 'Dip', 'Dipl.Phys','M.H.Sc.', 'MPA', 'B.Comm', 'B.Eng', 'B.Acc', 'FSA', 'PGDM', 'FCPA', 'RN', 'R.N.', 'MSN',
48
+ 'PCA', 'PCCRM','PCFP','PCGD','PCHR','PCM','PCPS','PCPM','PCSCM','PCSM','PCMM','PCTC','ACA', 'FCA','ACMA', 'FCMA','AAIA', 'FAIA','CCC','MIPA','FIPA','CIA','CFE','CISA','CFAP',
49
+ 'QC', 'Q.C.', 'M.Tech', 'CTA', 'C.I.M.A.', 'B.Ec',
50
+ 'CFIA','ICCP','CPS','CAP-OM','CAPTA','TNAOAP','AFA','AVA','ASA','CAIA','CBA','CVA','ICVS','CIIA','CMU','PFM','PRM','CFP','CWM','CCP','EA','CCMT','CGAP','CDFM','CFO','CGFM','CGAT','CGFO','CMFO','CPFO','CPFA',
51
+ 'BMD','BIET','P.Eng','PE', 'MBBS', 'MB', 'BCh', 'BAO', 'BMBS', 'MBBChir', 'MBChBa','MPhil','LL.D', 'LLD', 'D.Lit','DEA', 'DESS', 'DClinPsy', 'DSc', 'MRes', 'M.Res', 'Psy.D', 'Pharm.D',
52
+ 'BA(Admin)', 'BAcc','BACom','BAdmin','BAE','BAEcon','BA(Ed)','BA(FS)','BAgr','BAH','BAI','BAI(Elect)','BAI(Mech)','BALaw','BAO','BAppSc','BArch','BArchSc','BARelSt','BASc','BASoc', 'D.D.S.',
53
+ 'BASS','BATheol','BBA','BBLS', 'BBS','BBus','BChem','BCJ','BCL','BCLD(SocSc)','BClinSci','BCom','BCombSt','BCommEdCommDev','BComp','BComSc','BCoun','BD','BDes','BE','BEcon','BEcon&Fin', 'M.P.P.M.', 'MPPM',
54
+ 'BEconSci', 'BEd','BEng','BES','BEng(Tech)','BFA','BFin','BFLS','BFST','BH','BHealthSc','BHSc','BHy','BJur','BL','BLE','BLegSc','BLib','BLing','BLitt','BLittCelt','BLS','BMedSc','BMet',
55
+ 'BMid', 'BMin','BMS','BMSc','BMSc','BMS','BMus','BMusEd','BMusPerf','BN', 'BNS','BNurs','BOptom','BPA','BPharm', 'BPhil', 'TTC', 'DIP', 'Tchg', 'BEd', 'MEd','ACIB', 'FCIM', 'FCIS', 'FCS', 'Fcs',
56
+ 'Bachelor', 'O.C.', 'JP', 'C.Eng', 'C.P.A.', 'B.B.S.', 'MBE', 'GBE', 'KBE', 'DBE', 'CBE', 'OBE', 'MRICS', 'D.P.S.K.', 'D.P.P.J.', 'DPSK', 'DPPJ', 'B.B.A.', 'GBS', 'MIGEM', 'M.I.G.E.M.', 'FCIS',
57
+ 'BPhil(Ed)', 'BPhys','BPhysio','BPl','BRadiog','BSc', 'B.Sc', 'BScAgr','BSc(Dairy)','BSc(DomSc)','BScEc','BScEcon','BSc(Econ)','BSc(Eng)','BScFor','BSc(HealthSc)','BSc(Hort)', 'BBA', 'B.B.A.',
58
+ 'BSc(MCRM)', 'BSc(Med)','BSc(Mid)','BSc(Min)','BSc(Psych)', 'BSc(Tech)','BSD', 'BSocSc','BSS','BStSu','BTchg','BTCP','BTech','BTechEd','BTh','BTheol','BTS','EdB','LittB','LLB','MA','MusB','ScBTech',
59
+ 'CEng', 'FCA', 'CFA', 'Cfa', 'C.F.A.', 'LLB', 'LL.B', 'LLM', 'LL.M', 'CA(SA)', 'C.A.', 'CA','CPA', 'Solicitor', 'DMS', 'FIWO', 'CEnv', 'MICE', 'MIWEM', 'B.Com', 'BCom', 'BAcc', 'BA', 'BEc', 'MEc', 'HDip', 'B.Bus.', 'E.S.C.P.' )
60
+ ),
61
+ 'vowels' => array('a','e','i','o','u')
62
+ );
63
+
64
+ protected $not_nicknames = array( "(hons)");
65
+
66
+
67
+ /**
68
+ * This is the primary method which calls all other methods
69
+ *
70
+ * @param string $name the full name you wish to parse
71
+ * @return array returns associative array of name parts
72
+ */
73
+ public function parse_name($full_name) {
74
+
75
+ # Remove leading/trailing whitespace
76
+ $full_name = trim($full_name);
77
+
78
+ // remove any words that don't add value
79
+ // $full_name = str_replace("(Hons)", '', $full_name );
80
+ // $full_name = str_replace("(hons)", '', $full_name );
81
+
82
+ # Setup default vars
83
+ extract(array('salutation' => '', 'fname' => '', 'initials' => '', 'lname' => '', 'suffix' => ''));
84
+
85
+ # Find all the professional suffixes possible
86
+ $professional_suffix = $this->get_pro_suffix($full_name);
87
+
88
+ // The position of the first professional suffix denotes then end of the name and the start of the suffixes
89
+ $first_suffix_index = strlen($full_name);
90
+ foreach ($professional_suffix as $key => $psx) {
91
+ $start = strpos($full_name, $psx);
92
+ if( $start === FALSE ) {
93
+ echo "ASSERT ERROR, the professional suffix:".$psx." cannot be found in the full name:".$full_name."<br>";
94
+ continue;
95
+ }
96
+ if( $start < $first_suffix_index) {
97
+ $first_suffix_index = $start;
98
+ }
99
+ }
100
+
101
+ // everything to the right of the first professional suffix is part of the suffix
102
+ $suffix = substr($full_name, $first_suffix_index);
103
+
104
+ // remove the suffixes from the full_name
105
+ $full_name = substr($full_name, 0, $first_suffix_index);
106
+
107
+ # Deal with nickname, push to array
108
+ $has_nick = $this->get_nickname($full_name);
109
+ if ($has_nick) {
110
+ # Remove wrapper chars from around nickname
111
+ $name['nickname'] = substr($has_nick, 1, (strlen($has_nick) - 2));
112
+ # Remove the nickname from the full name
113
+ $full_name = str_replace($has_nick, '', $full_name);
114
+ # Get rid of consecutive spaces left by the removal
115
+ $full_name = str_replace(' ', ' ', $full_name);
116
+ }
117
+
118
+ # Grab a list of words from the remainder of the full name
119
+ $unfiltered_name_parts = $this->break_words($full_name);
120
+
121
+ # Is first word a title or multiple titles consecutively?
122
+ if( count($unfiltered_name_parts)) {
123
+ // only start looking if there are any words left in the name to process
124
+ while ($s = $this->is_salutation($unfiltered_name_parts[0])) {
125
+ $salutation .= "$s ";
126
+ array_shift($unfiltered_name_parts);
127
+ }
128
+ $salutation = trim($salutation);
129
+ // Find if there is a line suffix, if so then move it out
130
+ # Is last word a suffix or multiple suffixes consecutively?
131
+ while ($s = $this->is_line_suffix($unfiltered_name_parts[count($unfiltered_name_parts)-1], $full_name)) {
132
+ if( $suffix != "") {
133
+ $suffix = $s.", ".$suffix;
134
+ } else {
135
+ $suffix .= $s;
136
+ }
137
+ array_pop($unfiltered_name_parts);
138
+ }
139
+ $suffix = trim($suffix);
140
+ } else {
141
+ $salutation = "";
142
+ $suffix = "";
143
+ }
144
+
145
+ // Re-pack the unfiltered name parts array and exclude empty words
146
+ $name_arr = array();
147
+ foreach ($unfiltered_name_parts as $key => $name_part) {
148
+ $name_part = trim($name_part);
149
+ if(strlen($name_part) == '1') {
150
+ // If any word left is of one character that is not alphabetic then it is not a real word, so remove it
151
+ if( ! ctype_alpha($name_part)) {
152
+ $name_part = "";
153
+ }
154
+ }
155
+ if( strlen(trim($name_part)) ) {
156
+ $name_arr[] = $name_part;
157
+ }
158
+ }
159
+ $unfiltered_name_parts = $name_arr;
160
+
161
+ # set the ending range after prefix/suffix trim
162
+ $end = count($unfiltered_name_parts);
163
+
164
+ # concat the first name
165
+ for ($i=0; $i<$end-1; $i++) {
166
+ $word = $unfiltered_name_parts[$i];
167
+ # move on to parsing the last name if we find an indicator of a compound last name (Von, Van, etc)
168
+ # we use $i != 0 to allow for rare cases where an indicator is actually the first name (like "Von Fabella")
169
+ if ($this->is_compound($word) && $i != 0) {
170
+ break;
171
+ }
172
+ # is it a middle initial or part of their first name?
173
+ # if we start off with an initial, we'll call it the first name
174
+ if ($this->is_initial($word)) {
175
+ # is the initial the first word?
176
+ if ($i == 0) {
177
+ # if so, do a look-ahead to see if they go by their middle name
178
+ # for ex: "R. Jason Smith" => "Jason Smith" & "R." is stored as an initial
179
+ # but "R. J. Smith" => "R. Smith" and "J." is stored as an initial
180
+ if ($this->is_initial($unfiltered_name_parts[$i+1])) {
181
+ $fname .= " ".strtoupper($word);
182
+ }
183
+ else {
184
+ $initials .= " ".strtoupper($word);
185
+ }
186
+ }
187
+ # otherwise, just go ahead and save the initial
188
+ else {
189
+ $initials .= " ".strtoupper($word);
190
+ }
191
+ }
192
+ else {
193
+ $fname .= " ".$this->fix_case($word);
194
+ }
195
+ }
196
+
197
+ if( count($unfiltered_name_parts)) {
198
+ # check that we have more than 1 word in our string
199
+ if ($end-0 > 1) {
200
+ # concat the last name
201
+ for ($i; $i < $end; $i++) {
202
+ $lname .= " ".$this->fix_case($unfiltered_name_parts[$i]);
203
+ }
204
+ }
205
+ else {
206
+ # otherwise, single word strings are assumed to be first names
207
+ $fname = $this->fix_case($unfiltered_name_parts[$i]);
208
+ }
209
+ } else {
210
+ $fname = "";
211
+ }
212
+
213
+ # return the various parts in an array
214
+ $name['salutation'] = $salutation;
215
+ $name['fname'] = trim($fname);
216
+ $name['initials'] = trim($initials);
217
+ $name['lname'] = trim($lname);
218
+ $name['suffix'] = $suffix;
219
+ return $name;
220
+ }
221
+
222
+
223
+
224
+ /**
225
+ * Breaks name into individual words
226
+ *
227
+ * @param string $name the full name you wish to parse
228
+ * @return array full list of words broken down by spaces
229
+ */
230
+ public function break_words($name) {
231
+ $temp_word_arr = explode(' ', $name);
232
+ $final_word_arr = array();
233
+ foreach ($temp_word_arr as $key => $word) {
234
+ if( $word != "" && $word != ",") {
235
+ $final_word_arr[] = $word;
236
+ }
237
+ }
238
+ return $final_word_arr;
239
+ }
240
+
241
+
242
+
243
+ /**
244
+ * Checks for the existence of, and returns professional suffix
245
+ *
246
+ * @param string $name the name you wish to test
247
+ * @return mixed returns the suffix if exists, false otherwise
248
+ */
249
+ public function get_pro_suffix($name) {
250
+
251
+ $found_suffix_arr = array();
252
+ foreach ($this->dict['suffixes']['prof'] as $suffix) {
253
+ if (preg_match("/,[\s]*$suffix\b/i", $name, $matches)) {
254
+ $found_suffix = trim($matches[0]);
255
+ $found_suffix = rtrim($found_suffix,',');
256
+ $found_suffix = ltrim($found_suffix,',');
257
+ $found_suffix_arr[] = trim($found_suffix);
258
+ } else if( strpos($name, $suffix) !== FALSE ) {
259
+ $found_suffix_arr[] = $suffix;
260
+ }
261
+ }
262
+ return $found_suffix_arr;
263
+ }
264
+
265
+
266
+
267
+ /**
268
+ * Function to check name for existence of nickname based on these stipulations
269
+ * - String wrapped in parentheses (string)
270
+ * - String wrapped in double quotes "string"
271
+ * x String wrapped in single quotes 'string'
272
+ *
273
+ * I removed the check for strings in single quotes 'string' due to possible
274
+ * conflicts with names that may include apostrophes. Arabic transliterations, for example
275
+ *
276
+ * @param string $name the name you wish to test against
277
+ * @return mixed returns nickname if exists, false otherwise
278
+ */
279
+ protected function get_nickname($name) {
280
+ if (preg_match("/[\(|\"].*?[\)|\"]/", $name, $matches)) {
281
+ if( ! in_array( strtolower($matches[0]), $this->not_nicknames ) ) {
282
+ return $matches[0];
283
+ } else {
284
+ return false;
285
+ }
286
+ }
287
+ return false;
288
+ }
289
+
290
+
291
+
292
+ /**
293
+ * Checks word against array of common lineage suffixes
294
+ *
295
+ * @param string $word the single word you wish to test
296
+ * @param string $name full name for context in determining edge-cases
297
+ * @return mixed boolean if false, string if true (returns suffix)
298
+ */
299
+ protected function is_line_suffix($word, $name) {
300
+
301
+ # Ignore periods and righ commas, normalize case
302
+ $word = str_replace('.', '', strtolower($word));
303
+ $word = rtrim($word,',');
304
+
305
+ # Search the array for our word
306
+ $line_match = array_search($word, array_map('strtolower', $this->dict['suffixes']['line']));
307
+
308
+ # Now test our edge cases based on lineage
309
+ if ($line_match !== false) {
310
+ # Store our match
311
+ $matched_case = $this->dict['suffixes']['line'][$line_match];
312
+
313
+ # Remove it from the array
314
+ $temp_array = $this->dict['suffixes']['line'];
315
+ unset($temp_array[$line_match]);
316
+
317
+ # Make sure we're dealing with the suffix and not a surname
318
+ if ($word == 'senior' || $word == 'junior') {
319
+
320
+ # If name is Joshua Senior, it's pretty likely that Senior is the surname
321
+ # However, if the name is Joshua Jones Senior, then it's likely a suffix
322
+ if (str_word_count($name) < 3) {
323
+ return false;
324
+ }
325
+
326
+ # If the word Junior or Senior is contained, but so is some other
327
+ # lineage suffix, then the word is likely a surname and not a suffix
328
+ foreach ($temp_array as $suffix) {
329
+ if (preg_match("/\b".$suffix."\b/i", $name)) {
330
+ return false;
331
+ }
332
+ }
333
+ }
334
+ return $matched_case;
335
+ }
336
+ return false;
337
+ }
338
+
339
+
340
+
341
+ /**
342
+ * Checks word against list of common honorific prefixes
343
+ *
344
+ * @param string $word the single word you wish to test
345
+ * @return boolean
346
+ */
347
+ protected function is_salutation($word) {
348
+ $word = str_replace('.', '', strtolower($word));
349
+ foreach ($this->dict['prefix'] as $replace => $originals) {
350
+ if (in_array($word, $originals)) {
351
+ return $replace;
352
+ }
353
+ }
354
+ return false;
355
+ }
356
+
357
+
358
+
359
+ /**
360
+ * Checks our dictionary of compound indicators to see if last name is compound
361
+ *
362
+ * @param string $word the single word you wish to test
363
+ * @return boolean
364
+ */
365
+ protected function is_compound($word) {
366
+ return array_search(strtolower($word), $this->dict['compound']);
367
+ }
368
+
369
+
370
+
371
+ /**
372
+ * Test string to see if it's a single letter/initial (period optional)
373
+ *
374
+ * @param string $word the single word you wish to test
375
+ * @return boolean
376
+ */
377
+ protected function is_initial($word) {
378
+ return ((strlen($word) == 1) || (strlen($word) == 2 && $word{1} == "."));
379
+ }
380
+
381
+
382
+
383
+ /**
384
+ * Checks for camelCase words such as McDonald and MacElroy
385
+ *
386
+ * @param string $word the single word you wish to test
387
+ * @return boolean
388
+ */
389
+ protected function is_camel_case($word) {
390
+ if (preg_match("/[A-Za-z]([A-Z]*[a-z][a-z]*[A-Z]|[a-z]*[A-Z][A-Z]*[a-z])[A-Za-z]*/", $word)) {
391
+ return true;
392
+ }
393
+ return false;
394
+ }
395
+
396
+ # ucfirst words split by dashes or periods
397
+ # ucfirst all upper/lower strings, but leave camelcase words alone
398
+ public function fix_case($word) {
399
+
400
+ # Fix case for words split by periods (J.P.)
401
+ if (strpos($word, '.') !== false) {
402
+ $word = $this->safe_ucfirst(".", $word);;
403
+ }
404
+
405
+ # Fix case for words split by hyphens (Kimura-Fay)
406
+ if (strpos($word, '-') !== false) {
407
+ $word = $this->safe_ucfirst("-", $word);
408
+ }
409
+
410
+ # Special case for single letters
411
+ if (strlen($word) == 1) {
412
+ $word = strtoupper($word);
413
+ }
414
+
415
+ # Special case for 2-letter words
416
+ if (strlen($word) == 2) {
417
+ # Both letters vowels (uppercase both)
418
+ if (in_array(strtolower($word{0}), $this->dict['vowels']) && in_array(strtolower($word{1}), $this->dict['vowels'])) {
419
+ $word = strtoupper($word);
420
+ }
421
+ # Both letters consonants (uppercase both)
422
+ if (!in_array(strtolower($word{0}), $this->dict['vowels']) && !in_array(strtolower($word{1}), $this->dict['vowels'])) {
423
+ $word = strtoupper($word);
424
+ }
425
+ # First letter is vowel, second letter consonant (uppercase first)
426
+ if (in_array(strtolower($word{0}), $this->dict['vowels']) && !in_array(strtolower($word{1}), $this->dict['vowels'])) {
427
+ $word = ucfirst(strtolower($word));
428
+ }
429
+ # First letter consonant, second letter vowel or "y" (uppercase first)
430
+ if (!in_array(strtolower($word{0}), $this->dict['vowels']) && (in_array(strtolower($word{1}), $this->dict['vowels']) || strtolower($word{1}) == 'y')) {
431
+ $word = ucfirst(strtolower($word));
432
+ }
433
+ }
434
+
435
+ # Fix case for words which aren't initials, but are all upercase or lowercase
436
+ if ( (strlen($word) >= 3) && (ctype_upper($word) || ctype_lower($word)) ) {
437
+ $word = ucfirst(strtolower($word));
438
+ }
439
+
440
+ return $word;
441
+ }
442
+
443
+ # helper public function for fix_case
444
+ public function safe_ucfirst($seperator, $word) {
445
+ # uppercase words split by the seperator (ex. dashes or periods)
446
+ $parts = explode($seperator, $word);
447
+ foreach ($parts as $word) {
448
+ $words[] = ($this->is_camel_case($word)) ? $word : ucfirst(strtolower($word));
449
+ }
450
+ return implode($seperator, $words);
451
+ }
452
+
453
+ }
lib/PHP-Name-Parser/tests/FullNameParserTest.php ADDED
@@ -0,0 +1,477 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class FullNameParserTest extends PHPUnit_Framework_TestCase
4
+ {
5
+
6
+ /**
7
+ * @dataProvider functionalNameProvider
8
+ */
9
+ public function testName($name, $expected_result)
10
+ {
11
+ $parser = new FullNameParser();
12
+ $split_name = $parser->parse_name($name, true);
13
+ $this->assertSame($split_name, $expected_result);
14
+ }
15
+
16
+ /**
17
+ * @dataProvider disfunctionalNameProvider
18
+ */
19
+ public function testBadNames($name, $expected_result)
20
+ {
21
+ $parser = new FullNameParser();
22
+ $split_name = $parser->parse_name($name, true);
23
+ $array_equal = ($split_name === $expected_result);
24
+ // These tests pass because the expected results do NOT match the actual results.
25
+ $this->assertFalse($array_equal);
26
+ }
27
+
28
+ public function functionalNameProvider()
29
+ {
30
+ return array(
31
+ array(
32
+ "Mr Anthony R Von Fange III",
33
+ array(
34
+ "salutation" => "Mr.",
35
+ "fname" => "Anthony",
36
+ "initials" => "R",
37
+ "lname" => "Von Fange",
38
+ "suffix" => "III"
39
+ )
40
+ ),
41
+ array(
42
+ "J. B. Hunt",
43
+ array(
44
+ "salutation" => "",
45
+ "fname" => "J.",
46
+ "initials" => "B.",
47
+ "lname" => "Hunt",
48
+ "suffix" => ""
49
+ )
50
+ ),
51
+ array(
52
+ "J.B. Hunt",
53
+ array(
54
+ "salutation" => "",
55
+ "fname" => "J.B.",
56
+ "initials" => "",
57
+ "lname" => "Hunt",
58
+ "suffix" => ""
59
+ )
60
+ ),
61
+ array(
62
+ "Edward Senior III",
63
+ array(
64
+ "salutation" => "",
65
+ "fname" => "Edward",
66
+ "initials" => "",
67
+ "lname" => "Senior",
68
+ "suffix" => "III"
69
+ )
70
+ ),
71
+ array(
72
+ "Edward Dale Senior II",
73
+ array(
74
+ "salutation" => "",
75
+ "fname" => "Edward Dale",
76
+ "initials" => "",
77
+ "lname" => "Senior",
78
+ "suffix" => "II"
79
+ )
80
+ ),
81
+ array(
82
+ "Dale Edward Jones Senior",
83
+ array(
84
+ "salutation" => "",
85
+ "fname" => "Dale Edward",
86
+ "initials" => "",
87
+ "lname" => "Jones",
88
+ "suffix" => "Senior"
89
+ )
90
+ ),
91
+ array(
92
+ "Edward Senior II",
93
+ array(
94
+ "salutation" => "",
95
+ "fname" => "Edward",
96
+ "initials" => "",
97
+ "lname" => "Senior",
98
+ "suffix" => "II"
99
+ )
100
+ ),
101
+ array(
102
+ "Dale Edward Senior II, PhD",
103
+ array(
104
+ "salutation" => "",
105
+ "fname" => "Dale Edward",
106
+ "initials" => "",
107
+ "lname" => "Senior",
108
+ "suffix" => "II, PhD"
109
+ )
110
+ ),
111
+ array(
112
+ "Jason Rodriguez Sr.",
113
+ array(
114
+ "salutation" => "",
115
+ "fname" => "Jason",
116
+ "initials" => "",
117
+ "lname" => "Rodriguez",
118
+ "suffix" => "Sr"
119
+ )
120
+ ),
121
+ array(
122
+ "Jason Senior",
123
+ array(
124
+ "salutation" => "",
125
+ "fname" => "Jason",
126
+ "initials" => "",
127
+ "lname" => "Senior",
128
+ "suffix" => ""
129
+ )
130
+ ),
131
+ array(
132
+ "Bill Junior",
133
+ array(
134
+ "salutation" => "",
135
+ "fname" => "Bill",
136
+ "initials" => "",
137
+ "lname" => "Junior",
138
+ "suffix" => ""
139
+ )
140
+ ),
141
+ array(
142
+ "Sara Ann Fraser",
143
+ array(
144
+ "salutation" => "",
145
+ "fname" => "Sara Ann",
146
+ "initials" => "",
147
+ "lname" => "Fraser",
148
+ "suffix" => ""
149
+ )
150
+ ),
151
+ array(
152
+ "Adam",
153
+ array(
154
+ "salutation" => "",
155
+ "fname" => "Adam",
156
+ "initials" => "",
157
+ "lname" => "",
158
+ "suffix" => ""
159
+ )
160
+ ),
161
+ array(
162
+ "OLD MACDONALD",
163
+ array(
164
+ "salutation" => "",
165
+ "fname" => "Old",
166
+ "initials" => "",
167
+ "lname" => "Macdonald",
168
+ "suffix" => ""
169
+ )
170
+ ),
171
+ array(
172
+ "Old MacDonald",
173
+ array(
174
+ "salutation" => "",
175
+ "fname" => "Old",
176
+ "initials" => "",
177
+ "lname" => "MacDonald",
178
+ "suffix" => ""
179
+ )
180
+ ),
181
+ array(
182
+ "Old McDonald",
183
+ array(
184
+ "salutation" => "",
185
+ "fname" => "Old",
186
+ "initials" => "",
187
+ "lname" => "McDonald",
188
+ "suffix" => ""
189
+ )
190
+ ),
191
+ array(
192
+ "Old Mc Donald",
193
+ array(
194
+ "salutation" => "",
195
+ "fname" => "Old Mc",
196
+ "initials" => "",
197
+ "lname" => "Donald",
198
+ "suffix" => ""
199
+ )
200
+ ),
201
+ array(
202
+ "Old Mac Donald",
203
+ array(
204
+ "salutation" => "",
205
+ "fname" => "Old Mac",
206
+ "initials" => "",
207
+ "lname" => "Donald",
208
+ "suffix" => ""
209
+ )
210
+ ),
211
+ array(
212
+ "James van Allen",
213
+ array(
214
+ "salutation" => "",
215
+ "fname" => "James",
216
+ "initials" => "",
217
+ "lname" => "Van Allen",
218
+ "suffix" => ""
219
+ )
220
+ ),
221
+ array(
222
+ "Jimmy (Bubba) Smith",
223
+ array(
224
+ "nickname" => "Bubba",
225
+ "salutation" => "",
226
+ "fname" => "Jimmy",
227
+ "initials" => "",
228
+ "lname" => "Smith",
229
+ "suffix" => ""
230
+ )
231
+ ),
232
+ array(
233
+ "Miss Jennifer Shrader Lawrence",
234
+ array(
235
+ "salutation" => "Ms.",
236
+ "fname" => "Jennifer Shrader",
237
+ "initials" => "",
238
+ "lname" => "Lawrence",
239
+ "suffix" => ""
240
+ )
241
+ ),
242
+ array(
243
+ "Jonathan Smith, MD",
244
+ array(
245
+ "salutation" => "",
246
+ "fname" => "Jonathan",
247
+ "initials" => "",
248
+ "lname" => "Smith",
249
+ "suffix" => "MD"
250
+ )
251
+ ),
252
+ array(
253
+ "Dr. Jonathan Smith",
254
+ array(
255
+ "salutation" => "Dr.",
256
+ "fname" => "Jonathan",
257
+ "initials" => "",
258
+ "lname" => "Smith",
259
+ "suffix" => ""
260
+ )
261
+ ),
262
+ array(
263
+ "Jonathan Smith IV, PhD",
264
+ array(
265
+ "salutation" => "",
266
+ "fname" => "Jonathan",
267
+ "initials" => "",
268
+ "lname" => "Smith",
269
+ "suffix" => "IV, PhD"
270
+ )
271
+ ),
272
+ array(
273
+ "Miss Jamie P. Harrowitz",
274
+ array(
275
+ "salutation" => "Ms.",
276
+ "fname" => "Jamie",
277
+ "initials" => "P.",
278
+ "lname" => "Harrowitz",
279
+ "suffix" => ""
280
+ )
281
+ ),
282
+ array(
283
+ "Mr John Doe",
284
+ array(
285
+ "salutation" => "Mr.",
286
+ "fname" => "John",
287
+ "initials" => "",
288
+ "lname" => "Doe",
289
+ "suffix" => ""
290
+ )
291
+ ),
292
+ array(
293
+ "Rev. Dr John Doe",
294
+ array(
295
+ "salutation" => "Rev. Dr.",
296
+ "fname" => "John",
297
+ "initials" => "",
298
+ "lname" => "Doe",
299
+ "suffix" => ""
300
+ )
301
+ ),
302
+ array(
303
+ "Anthony Von Fange III",
304
+ array(
305
+ "salutation" => "",
306
+ "fname" => "Anthony",
307
+ "initials" => "",
308
+ "lname" => "Von Fange",
309
+ "suffix" => "III"
310
+ )
311
+ ),
312
+ array(
313
+ "Anthony Von Fange III, PhD",
314
+ array(
315
+ "salutation" => "",
316
+ "fname" => "Anthony",
317
+ "initials" => "",
318
+ "lname" => "Von Fange",
319
+ "suffix" => "III, PhD"
320
+ )
321
+ ),
322
+ array(
323
+ "Smarty Pants Phd",
324
+ array(
325
+ "salutation" => "",
326
+ "fname" => "Smarty",
327
+ "initials" => "",
328
+ "lname" => "Pants",
329
+ "suffix" => "PhD"
330
+ )
331
+ ),
332
+ array(
333
+ "Mark Peter Williams",
334
+ array(
335
+ "salutation" => "",
336
+ "fname" => "Mark Peter",
337
+ "initials" => "",
338
+ "lname" => "Williams",
339
+ "suffix" => ""
340
+ )
341
+ ),
342
+ array(
343
+ "Mark P Williams",
344
+ array(
345
+ "salutation" => "",
346
+ "fname" => "Mark",
347
+ "initials" => "P",
348
+ "lname" => "Williams",
349
+ "suffix" => ""
350
+ )
351
+ ),
352
+ array(
353
+ "Mark P. Williams",
354
+ array(
355
+ "salutation" => "",
356
+ "fname" => "Mark",
357
+ "initials" => "P.",
358
+ "lname" => "Williams",
359
+ "suffix" => ""
360
+ )
361
+ ),
362
+ array(
363
+ "M Peter Williams",
364
+ array(
365
+ "salutation" => "",
366
+ "fname" => "Peter",
367
+ "initials" => "M",
368
+ "lname" => "Williams",
369
+ "suffix" => ""
370
+ )
371
+ ),
372
+ array(
373
+ "M. Peter Williams",
374
+ array(
375
+ "salutation" => "",
376
+ "fname" => "Peter",
377
+ "initials" => "M.",
378
+ "lname" => "Williams",
379
+ "suffix" => ""
380
+ )
381
+ ),
382
+ array(
383
+ "M. P. Williams",
384
+ array(
385
+ "salutation" => "",
386
+ "fname" => "M.",
387
+ "initials" => "P.",
388
+ "lname" => "Williams",
389
+ "suffix" => ""
390
+ )
391
+ ),
392
+ array(
393
+ "The Rev. Mark Williams",
394
+ array(
395
+ "salutation" => "Rev.",
396
+ "fname" => "Mark",
397
+ "initials" => "",
398
+ "lname" => "Williams",
399
+ "suffix" => ""
400
+ )
401
+ ),
402
+ array(
403
+ "Mister Mark Williams",
404
+ array(
405
+ "salutation" => "Mr.",
406
+ "fname" => "Mark",
407
+ "initials" => "",
408
+ "lname" => "Williams",
409
+ "suffix" => ""
410
+ )
411
+ )
412
+ );
413
+ }
414
+
415
+ public function disfunctionalNameProvider()
416
+ {
417
+ return array(
418
+ // fails. format not yet supported
419
+ array(
420
+ "Fraser, Joshua",
421
+ array(
422
+ "salutation" => "",
423
+ "fname" => "Joshua",
424
+ "initials" => "",
425
+ "lname" => "Fraser",
426
+ "suffix" => ""
427
+ )
428
+ ),
429
+ // fails. both initials should be capitalized
430
+ array(
431
+ "JB Hunt",
432
+ array(
433
+ "salutation" => "",
434
+ "fname" => "JB",
435
+ "initials" => "",
436
+ "lname" => "Hunt",
437
+ "suffix" => ""
438
+ )
439
+ ),
440
+ // fails. doesn't handle multiple words inside parenthesis
441
+ array(
442
+ "Jimmy (Bubba Junior) Smith",
443
+ array(
444
+ "nickname" => "Bubba Junior",
445
+ "salutation" => "",
446
+ "fname" => "Jimmy",
447
+ "initials" => "",
448
+ "lname" => "Smith",
449
+ "suffix" => ""
450
+ )
451
+ ),
452
+ // fails. should normalize the PhD suffix
453
+ array(
454
+ "Anthony Von Fange III, PHD",
455
+ array(
456
+ "salutation" => "",
457
+ "fname" => "Anthony",
458
+ "initials" => "",
459
+ "lname" => "Von Fange",
460
+ "suffix" => "III, PhD"
461
+ )
462
+ ),
463
+ // fails. should treat "Silly" as the nickname or remove altogether
464
+ array(
465
+ "Not So Smarty Pants, Silly",
466
+ array(
467
+ "nickname" => "Silly",
468
+ "salutation" => "",
469
+ "fname" => "Not So Smarty",
470
+ "initials" => "",
471
+ "lname" => "Pants",
472
+ "suffix" => ""
473
+ )
474
+ )
475
+ );
476
+ }
477
+ }
lib/PHP-Name-Parser/tests/phpunit.xml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <phpunit bootstrap="../parser.php"
4
+ backupGlobals="false"
5
+ backupStaticAttributes="false"
6
+ strict="true"
7
+ verbose="true">
8
+
9
+ <testsuites>
10
+ <testsuite name="Full Name Parser Test Suite">
11
+ <directory suffix="Test.php">./</directory>
12
+ </testsuite>
13
+ </testsuites>
14
+
15
+ <logging>
16
+ <log type="coverage-html"
17
+ target="./coverage"
18
+ title="Full Name Parser"
19
+ charset="UTF-8"
20
+ yui="true"
21
+ highlight="true"
22
+ lowUpperBound="35"
23
+ highLowerBound="70"/>
24
+ <log type="coverage-clover" target="./logs/clover.xml"/>
25
+ <log type="junit" target="./logs/junit.xml" logIncompleteSkipped="false"/>
26
+ </logging>
27
+ </phpunit>
lib/PHP-Name-Parser/tests/style.css ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ table { border-collapse: collapse; border-spacing: 0; font-family: 'Open Sans', sans-serif; font-weight: 300 }
2
+ thead { display: table-header-group }
3
+ tr{ page-break-inside: avoid; }
4
+ .wrapper { width:75%; margin:30px auto; overflow: hidden; }
5
+ .unit-tests { float: left; width: 100%; border-bottom: 1px solid #ddd; }
6
+ .unit-tests thead{ background:#666; border: 1px solid #555; }
7
+ .unit-tests tr th{ padding: 0px 24px; height: 48px; line-height: 48px; font-weight: 900; color:#fff; border-right:1px solid #555 }
8
+ .unit-tests tbody td { padding: 0px 24px; height: 48px; line-height: 48px; text-align: center; border:1px solid #ddd; }
9
+ .unit-tests tbody tr:first-child td { border-top:0 none; }
10
+ .unit-tests tr td:first-child,
11
+ .unit-tests tr th:first-child{ text-align: left; }
12
+ .unit-tests tbody tr:first-child { border-top: 0 none; }
13
+ .unit-tests tbody tr:nth-child(even) { background:#f8f8f8; }
14
+ .unit-tests tbody tr:hover { cursor:default; border-color:rgba(0,0,0,0.04); }
15
+ .unit-tests tbody tr:hover td { border-color:rgba(0,0,0,0.06); }
16
+ .unit-tests tbody .pass td:last-child { background:#ecffc1; border-color:rgba(0,0,0,0.04); border-right-color:rgba(0,0,0,0.1); color:#7ec43c; }
17
+ .unit-tests tbody .fail td:last-child { background:#ffc1c1; border-color:rgba(0,0,0,0.03); border-right-color:rgba(0,0,0,0.1); color:#e53d3d; }
18
+ .unit-tests tbody .pass:hover { background:#ecffc1; color:#7ec43c; }
19
+ .unit-tests tbody .fail:hover { background:#ffc1c1; color:#e53d3d; }
20
+ .unit-tests tbody .pass td:hover { background:#c5f458; color:#8ec100; }
21
+ .unit-tests tbody .fail td:hover { background:#f25959; color:#c10000; }
lib/PayEx.Ecommerce.Php/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 aait
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
lib/PayEx.Ecommerce.Php/README.md ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PayEx Payments API Library for PHP
2
+
3
+ ## Description ##
4
+ PayEx Payments API Library for PHP provide library work with PayEx Payments API.
5
+
6
+ ## Documentation ##
7
+ http://www.payexpim.com/
8
+
9
+ ## Installation ##
10
+ You can use Composer or simply Download the Release
11
+
12
+ ## Composer ##
13
+ The preferred method is via [composer](https://getcomposer.org). Follow the
14
+ [installation instructions](https://getcomposer.org/doc/00-intro.md) if you do not already have
15
+ composer installed.
16
+
17
+ Once composer is installed, execute the following command in your project root to install this library:
18
+
19
+ ```sh
20
+ composer require payex/php-api
21
+ ```
22
+
23
+ ## Examples ##
24
+ TODO
lib/PayEx.Ecommerce.Php/composer.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "payex/php-api",
3
+ "type": "library",
4
+ "description": "A PHP client library for PayEx Payments API",
5
+ "keywords": ["payex"],
6
+ "homepage": "https://github.com/aait/payex-php-api",
7
+ "license": "MIT",
8
+ "require": {
9
+ "php": ">=5.3",
10
+ "ext-soap": "*",
11
+ "ext-dom": "*",
12
+ "ext-xml": "*"
13
+ },
14
+ "autoload": {
15
+ "psr-4": {
16
+ "PayEx\\": "src/PayEx/"
17
+ }
18
+ }
19
+ }
lib/{Px → PayEx.Ecommerce.Php/src/PayEx}/Px.php RENAMED
@@ -1,14 +1,10 @@
1
  <?php
2
- /**
3
- * PayEx API
4
- * @see http://www.payexpim.com/technical-reference/
5
- * Created by AAIT Team.
6
- */
7
 
8
  class Px
9
  {
10
- /** @var array SOAP Options */
11
- protected $_options = array();
12
 
13
  /** @var bool PayEx Debug mode */
14
  protected $_debug_mode = true;
@@ -19,20 +15,26 @@ class Px
19
  /** @var string Encryption Key */
20
  protected $_encryption_key = '';
21
 
 
 
 
 
 
 
22
  /** @see http://www.payexpim.com/technical-reference/wsdl/wsdl-files/ */
23
  /** @var array WSDL Files */
24
- protected static $_wsdl = array(
25
  'PxOrderWSDL' => '',
26
  'PxVerificationWSDL' => '',
27
  'PxAgreementWSDL' => '',
28
  'PxRecurringWSDL' => '',
29
  'PxConfinedWSDL' => ''
30
- );
31
 
32
  /** @var array PayEx SOAP API List */
33
- protected static $_rules = array(
34
  /** @see http://www.payexpim.com/category/pxorder/ */
35
- 'PxOrderWSDL' => array(
36
  'AddOrderAddress2', 'AddSingleOrderLine2', 'AuthorizeEVC', 'AuthorizeGC', 'AuthorizeInvoice',
37
  'AuthorizeInvoiceLedger', 'Cancel2', 'Capture5', 'Check2', 'Complete', 'Credit5', 'CreditOrderLine3',
38
  'FinalizeTransaction', 'GetAddressByPaymentMethod', 'GetApprovedDeliveryAddress', 'GetLowestMonthlyInvoiceSaleAmount',
@@ -40,56 +42,32 @@ class Px
40
  'PurchaseFinancingInvoice', 'PurchaseInvoiceCorporate', 'PurchaseInvoicePrivate', 'PurchaseInvoiceSale',
41
  'PurchasePartPaymentSale', 'PurchaseOTT', 'PurchaseInvoicePartPaymentSale', 'PurchasePX', 'SaleEVC',
42
  'SaleInvoiceLedger', 'SaleGC', 'PurchaseWyWallet', 'PreparePurchaseWyWallet', 'PurchaseCreditAccount'
43
- ),
44
  /** @see http://www.payexpim.com/category/pxverification/ */
45
- 'PxVerificationWSDL' => array(
46
  'CreditCheckCorporate2', 'CreditCheckPrivate2', 'GetConsumerLegalAddress', 'NameCheckPrivate'
47
- ),
48
  /** @see http://www.payexpim.com/category/pxagreement/ */
49
- 'PxAgreementWSDL' => array(
50
  'ActivatePxAgreement', 'AutoPay3', 'AgreementCheck', 'CreateAgreement3', 'DeleteAgreement'
51
- ),
52
  /** @see http://www.payexpim.com/category/pxagreement/ */
53
- 'PxRecurringWSDL' => array(
54
  'Check', 'Start', 'Stop'
55
- ),
56
  /** @see http://www.payexpim.com/category/pxconfined/ */
57
- 'PxConfinedWSDL' => array(
58
  'PreparePurchaseCC', 'PurchaseCC'
59
- )
60
- );
61
 
62
  /**
63
- * Constructor
64
- * @param array $options
65
- */
66
- public function __construct($options = array())
67
- {
68
- // SSL Verification option
69
- if (isset($options['ssl_verify'])) {
70
- if (!$options['ssl_verify']) {
71
- $context = stream_context_create(array(
72
- 'ssl' => array(
73
- 'verify_peer' => false,
74
- 'allow_self_signed' => true
75
- )
76
- ));
77
- $options['stream_context'] = $context;
78
- }
79
-
80
- unset($options['ssl_verify']);
81
- }
82
-
83
- $this->_options = $options;
84
- }
85
-
86
- /**
87
- * Get Library Version
88
  * @return string
89
  */
90
  public function getVersion()
91
  {
92
- return '2.0.3';
93
  }
94
 
95
  /**
@@ -108,6 +86,58 @@ class Px
108
  $this->initWSDL($this->_debug_mode);
109
  }
110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  /**
112
  * Init WSDL Values
113
  * @param bool $debug_mode
@@ -121,7 +151,7 @@ class Px
121
  self::$_wsdl['PxRecurringWSDL'] = 'https://test-external.payex.com/pxagreement/pxrecurring.asmx?WSDL';
122
 
123
  // Set Live environment
124
- if (!$debug_mode ) {
125
  self::$_wsdl['PxOrderWSDL'] = 'https://external.payex.com/pxorder/pxorder.asmx?WSDL';
126
  self::$_wsdl['PxConfinedWSDL'] = 'https://confined.payex.com/PxConfined/pxorder.asmx?WSDL';
127
  self::$_wsdl['PxVerificationWSDL'] = 'https://external.payex.com/pxverification/pxverification.asmx?WSDL';
@@ -132,7 +162,7 @@ class Px
132
 
133
  /**
134
  * Get WSDL File
135
- * @param $px_function
136
  * @return bool
137
  */
138
  protected function getWSDL($px_function)
@@ -147,21 +177,21 @@ class Px
147
 
148
  /**
149
  * Parse PayEx XML Response
150
- * @param $xml_body
151
  * @return array|bool
152
  */
153
  protected function parseFields($xml_body)
154
  {
155
  // Load XML
156
  libxml_use_internal_errors(true);
157
- $doc = new DOMDocument();
158
  $status = @$doc->loadXML($xml_body);
159
  if ($status === false) {
160
  return false;
161
  }
162
 
163
- $result = array();
164
- $blacklisted = array('header', 'id', 'status');
165
  $items = $doc->getElementsByTagName('payex')->item(0)->getElementsByTagName('*');
166
  foreach ($items as $item) {
167
  $key = $item->nodeName;
@@ -183,24 +213,24 @@ class Px
183
 
184
  /**
185
  * Magic Method: Call PayEx Function
186
- * @param $px_function
187
- * @param $arguments
188
  * @return array|bool
189
- * @throws Exception
190
  */
191
  public function __call($px_function, $arguments)
192
  {
193
  if (empty($this->_account_number) || empty($this->_encryption_key)) {
194
- throw new Exception('Account number or Encryption key not defined. Use setEnvironment().');
195
  }
196
 
197
  $wsdl = $this->getWSDL($px_function);
198
  if (!$wsdl || empty($wsdl)) {
199
- throw new Exception('Unknown PayEx Method.');
200
  }
201
 
202
  if (!isset($arguments[0]) || !is_array($arguments[0])) {
203
- throw new Exception('Invalid PayEx Method params.');
204
  }
205
 
206
  // Set Account Number param automatically
@@ -217,15 +247,15 @@ class Px
217
  $arguments[0]['hash'] = $this->getHash($arguments[0]);
218
 
219
  // Call PayEx Method
220
- $client = new SoapClient($wsdl, $this->_options);
221
  $result = $client->__soapCall($px_function, $arguments);
222
  if (!property_exists($result, $px_function . 'Result')) {
223
- throw new Exception('Invalid PayEx Response.');
224
  }
225
  $result = $result->{$px_function . 'Result'};
226
  $result = $this->parseFields($result);
227
  if (!$result) {
228
- throw new Exception('Failed to parse PayEx Response.');
229
  }
230
 
231
  return $result;
@@ -233,18 +263,11 @@ class Px
233
 
234
  /**
235
  * Get Hash Params
236
- *
237
- * Hexadecimal md5 hash built up by the value of the following parameters (for Initialize7):
238
- * accountNumber + purchaseOperation + price + priceArgList + currency + vat + orderID +
239
- * productNumber + description + clientIPAddress + clientIdentifier + additionalValues +
240
- * externalID + returnUrl + view + agreementRef + cancelUrl + clientLanguage
241
- *
242
- * All parameters are added together – the ‘plus’ character is not included.
243
- * In addition the encryption key must be included at the end of the string before performing the md5-hash.
244
  * @param array $params
245
  * @return string
246
  */
247
- protected function getHash($params)
248
  {
249
  $params = trim(implode('', $params));
250
  return strtoupper(md5($params . $this->_encryption_key));
1
  <?php
2
+
3
+ namespace PayEx;
 
 
 
4
 
5
  class Px
6
  {
7
+ const VERSION = '1.0.1';
 
8
 
9
  /** @var bool PayEx Debug mode */
10
  protected $_debug_mode = true;
15
  /** @var string Encryption Key */
16
  protected $_encryption_key = '';
17
 
18
+ /** @var string User Agent */
19
+ protected $_user_agent = '';
20
+
21
+ /** @var bool SSL verify */
22
+ protected $_is_ssl_verify = true;
23
+
24
  /** @see http://www.payexpim.com/technical-reference/wsdl/wsdl-files/ */
25
  /** @var array WSDL Files */
26
+ protected static $_wsdl = [
27
  'PxOrderWSDL' => '',
28
  'PxVerificationWSDL' => '',
29
  'PxAgreementWSDL' => '',
30
  'PxRecurringWSDL' => '',
31
  'PxConfinedWSDL' => ''
32
+ ];
33
 
34
  /** @var array PayEx SOAP API List */
35
+ protected static $_rules = [
36
  /** @see http://www.payexpim.com/category/pxorder/ */
37
+ 'PxOrderWSDL' => [
38
  'AddOrderAddress2', 'AddSingleOrderLine2', 'AuthorizeEVC', 'AuthorizeGC', 'AuthorizeInvoice',
39
  'AuthorizeInvoiceLedger', 'Cancel2', 'Capture5', 'Check2', 'Complete', 'Credit5', 'CreditOrderLine3',
40
  'FinalizeTransaction', 'GetAddressByPaymentMethod', 'GetApprovedDeliveryAddress', 'GetLowestMonthlyInvoiceSaleAmount',
42
  'PurchaseFinancingInvoice', 'PurchaseInvoiceCorporate', 'PurchaseInvoicePrivate', 'PurchaseInvoiceSale',
43
  'PurchasePartPaymentSale', 'PurchaseOTT', 'PurchaseInvoicePartPaymentSale', 'PurchasePX', 'SaleEVC',
44
  'SaleInvoiceLedger', 'SaleGC', 'PurchaseWyWallet', 'PreparePurchaseWyWallet', 'PurchaseCreditAccount'
45
+ ],
46
  /** @see http://www.payexpim.com/category/pxverification/ */
47
+ 'PxVerificationWSDL' => [
48
  'CreditCheckCorporate2', 'CreditCheckPrivate2', 'GetConsumerLegalAddress', 'NameCheckPrivate'
49
+ ],
50
  /** @see http://www.payexpim.com/category/pxagreement/ */
51
+ 'PxAgreementWSDL' => [
52
  'ActivatePxAgreement', 'AutoPay3', 'AgreementCheck', 'CreateAgreement3', 'DeleteAgreement'
53
+ ],
54
  /** @see http://www.payexpim.com/category/pxagreement/ */
55
+ 'PxRecurringWSDL' => [
56
  'Check', 'Start', 'Stop'
57
+ ],
58
  /** @see http://www.payexpim.com/category/pxconfined/ */
59
+ 'PxConfinedWSDL' => [
60
  'PreparePurchaseCC', 'PurchaseCC'
61
+ ]
62
+ ];
63
 
64
  /**
65
+ * Get Version
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  * @return string
67
  */
68
  public function getVersion()
69
  {
70
+ return self::VERSION;
71
  }
72
 
73
  /**
86
  $this->initWSDL($this->_debug_mode);
87
  }
88
 
89
+ /**
90
+ * Set User Agent
91
+ * @param string $user_agent
92
+ */
93
+ public function setUserAgent($user_agent)
94
+ {
95
+ $this->_user_agent = $user_agent;
96
+ }
97
+
98
+ /**
99
+ * Set SSL Verification Flag
100
+ * @param bool $is_ssl_verify
101
+ */
102
+ public function setIsSSLVerify($is_ssl_verify)
103
+ {
104
+ $this->_is_ssl_verify = $is_ssl_verify;
105
+ }
106
+
107
+ /**
108
+ * Get SOAP Options
109
+ * @return array
110
+ */
111
+ protected function getOptions()
112
+ {
113
+ // Stream Context Options
114
+ $stream_context_options = [];
115
+
116
+ // User Agent option
117
+ if (!empty($this->_user_agent)) {
118
+ $stream_context_options = array_merge($stream_context_options, [
119
+ 'http' => [
120
+ 'header' => 'User-Agent: ' . $this->_user_agent
121
+ ]
122
+ ]);
123
+ }
124
+
125
+ // SSL Verification option
126
+ if (!$this->_is_ssl_verify) {
127
+ $stream_context_options = array_merge($stream_context_options, [
128
+ 'ssl' => [
129
+ 'verify_peer' => false,
130
+ 'allow_self_signed' => true
131
+ ]
132
+ ]);
133
+ }
134
+
135
+ // Create Stream Context
136
+ return [
137
+ 'stream_context' => stream_context_create($stream_context_options)
138
+ ];
139
+ }
140
+
141
  /**
142
  * Init WSDL Values
143
  * @param bool $debug_mode
151
  self::$_wsdl['PxRecurringWSDL'] = 'https://test-external.payex.com/pxagreement/pxrecurring.asmx?WSDL';
152
 
153
  // Set Live environment
154
+ if (!$debug_mode) {
155
  self::$_wsdl['PxOrderWSDL'] = 'https://external.payex.com/pxorder/pxorder.asmx?WSDL';
156
  self::$_wsdl['PxConfinedWSDL'] = 'https://confined.payex.com/PxConfined/pxorder.asmx?WSDL';
157
  self::$_wsdl['PxVerificationWSDL'] = 'https://external.payex.com/pxverification/pxverification.asmx?WSDL';
162
 
163
  /**
164
  * Get WSDL File
165
+ * @param string $px_function
166
  * @return bool
167
  */
168
  protected function getWSDL($px_function)
177
 
178
  /**
179
  * Parse PayEx XML Response
180
+ * @param string $xml_body
181
  * @return array|bool
182
  */
183
  protected function parseFields($xml_body)
184
  {
185
  // Load XML
186
  libxml_use_internal_errors(true);
187
+ $doc = new \DOMDocument();
188
  $status = @$doc->loadXML($xml_body);
189
  if ($status === false) {
190
  return false;
191
  }
192
 
193
+ $result = [];
194
+ $blacklisted = ['header', 'id', 'status'];
195
  $items = $doc->getElementsByTagName('payex')->item(0)->getElementsByTagName('*');
196
  foreach ($items as $item) {
197
  $key = $item->nodeName;
213
 
214
  /**
215
  * Magic Method: Call PayEx Function
216
+ * @param string $px_function
217
+ * @param array $arguments
218
  * @return array|bool
219
+ * @throws \Exception
220
  */
221
  public function __call($px_function, $arguments)
222
  {
223
  if (empty($this->_account_number) || empty($this->_encryption_key)) {
224
+ throw new \Exception('Account number or Encryption key not defined. Use setEnvironment().');
225
  }
226
 
227
  $wsdl = $this->getWSDL($px_function);
228
  if (!$wsdl || empty($wsdl)) {
229
+ throw new \Exception('Unknown PayEx Method.');
230
  }
231
 
232
  if (!isset($arguments[0]) || !is_array($arguments[0])) {
233
+ throw new \Exception('Invalid PayEx Method params.');
234
  }
235
 
236
  // Set Account Number param automatically
247
  $arguments[0]['hash'] = $this->getHash($arguments[0]);
248
 
249
  // Call PayEx Method
250
+ $client = new \SoapClient($wsdl, $this->getOptions());
251
  $result = $client->__soapCall($px_function, $arguments);
252
  if (!property_exists($result, $px_function . 'Result')) {
253
+ throw new \Exception('Invalid PayEx Response.');
254
  }
255
  $result = $result->{$px_function . 'Result'};
256
  $result = $this->parseFields($result);
257
  if (!$result) {
258
+ throw new \Exception('Failed to parse PayEx Response.');
259
  }
260
 
261
  return $result;
263
 
264
  /**
265
  * Get Hash Params
266
+ * Hexadecimal md5 hash
 
 
 
 
 
 
 
267
  * @param array $params
268
  * @return string
269
  */
270
+ protected function getHash(array $params)
271
  {
272
  $params = trim(implode('', $params));
273
  return strtoupper(md5($params . $this->_encryption_key));
lib/PayEx.Ecommerce.Php/tests/.gitignore ADDED
@@ -0,0 +1 @@
 
1
+ *.local.ini
lib/PayEx.Ecommerce.Php/tests/ExceptionTest.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayEx;
4
+
5
+ class ExceptionTest extends TestCase
6
+ {
7
+ public function testExceptionUndefinedEnvironment()
8
+ {
9
+ // Set empty environment
10
+ $this->px->setEnvironment('', '', TEST_MODE);
11
+
12
+ $e = null;
13
+ try {
14
+ $result = $this->px->Test([]);
15
+ } catch (\Exception $e) {
16
+ //
17
+ }
18
+
19
+ $this->assertEquals('Exception', get_class($e));
20
+ $this->assertEquals('Account number or Encryption key not defined. Use setEnvironment().', $e->getMessage());
21
+ }
22
+
23
+ public function testExceptionUnknownMethod()
24
+ {
25
+ $e = null;
26
+ try {
27
+ $result = $this->px->Test([]);
28
+ } catch (\Exception $e) {
29
+ //
30
+ }
31
+
32
+ $this->assertEquals('Exception', get_class($e));
33
+ $this->assertEquals('Unknown PayEx Method.', $e->getMessage());
34
+ }
35
+
36
+ public function testExceptionUnknownMethod1()
37
+ {
38
+ $e = null;
39
+ try {
40
+ $result = $this->px->__call('Initialize8', null);
41
+ } catch (\Exception $e) {
42
+ //
43
+ }
44
+
45
+ $this->assertEquals('Exception', get_class($e));
46
+ $this->assertEquals('Invalid PayEx Method params.', $e->getMessage());
47
+ }
48
+ }
lib/PayEx.Ecommerce.Php/tests/PaymentTest.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayEx;
4
+
5
+ class PaymentTest extends TestCase
6
+ {
7
+ public function testInitialize()
8
+ {
9
+ // Call PxOrder.Initialize8
10
+ $params = [
11
+ 'accountNumber' => '',
12
+ 'purchaseOperation' => 'AUTHORIZATION',
13
+ 'price' => round(1 * 100),
14
+ 'priceArgList' => '',
15
+ 'currency' => 'USD',
16
+ 'vat' => 0,
17
+ 'orderID' => '10000001',
18
+ 'productNumber' => '10000001',
19
+ 'description' => 'Test Order (phpunit)',
20
+ 'clientIPAddress' => '127.0.0.1',
21
+ 'clientIdentifier' => 'USERAGENT=PHPUNIT',
22
+ 'additionalValues' => 'NO3DS=true',
23
+ 'externalID' => '',
24
+ 'returnUrl' => 'http://localhost.no/return',
25
+ 'view' => 'CREDITCARD',
26
+ 'agreementRef' => '',
27
+ 'cancelUrl' => 'http://localhost.no/cancel',
28
+ 'clientLanguage' => 'en-US'
29
+ ];
30
+ $result = $this->px->Initialize8($params);
31
+
32
+ // Array Check
33
+ $this->assertInternalType('array', $result);
34
+
35
+ // Response Check
36
+ $this->assertTrue($result['code'] === 'OK' && $result['description'] === 'OK' && $result['errorCode'] === 'OK');
37
+
38
+ // Result Check
39
+ $this->assertTrue(isset($result['orderRef']));
40
+ $this->assertTrue(isset($result['redirectUrl']));
41
+ }
42
+ }
lib/PayEx.Ecommerce.Php/tests/SocialSecurityNumberTest.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayEx;
4
+
5
+ class SocialSecurityNumberTest extends TestCase
6
+ {
7
+ public function testSE()
8
+ {
9
+ $params = [
10
+ 'accountNumber' => '',
11
+ 'paymentMethod' => 'PXFINANCINGINVOICESE',
12
+ 'ssn' => '590719-5662',
13
+ 'zipcode' => '29620',
14
+ 'countryCode' => 'SE',
15
+ 'ipAddress' => '127.0.0.1'
16
+ ];
17
+ $result = $this->px->GetAddressByPaymentMethod($params);
18
+
19
+ // Array Check
20
+ $this->assertInternalType('array', $result);
21
+
22
+ // Response Check
23
+ $this->assertTrue($result['code'] === 'OK' && $result['description'] === 'OK' && $result['errorCode'] === 'OK');
24
+
25
+ // Result Check
26
+ $this->assertEquals('Eva Dagmar Christina Tannerdal', $result['name']);
27
+ $this->assertEquals('Gunbritt Boden p12', $result['streetAddress']);
28
+ $this->assertEquals('', $result['coAddress']);
29
+ $this->assertEquals('29620', $result['zipCode']);
30
+ $this->assertEquals('Småbyen', $result['city']);
31
+ $this->assertEquals('SE', $result['countryCode']);
32
+ }
33
+
34
+ public function testNO()
35
+ {
36
+ $params = [
37
+ 'accountNumber' => '',
38
+ 'paymentMethod' => 'PXFINANCINGINVOICENO',
39
+ 'ssn' => '12067543937',
40
+ 'zipcode' => '3179',
41
+ 'countryCode' => 'NO',
42
+ 'ipAddress' => '127.0.0.1'
43
+ ];
44
+ $result = $this->px->GetAddressByPaymentMethod($params);
45
+
46
+ // Array Check
47
+ $this->assertInternalType('array', $result);
48
+
49
+ // Response Check
50
+ $this->assertTrue($result['code'] === 'OK' && $result['description'] === 'OK' && $result['errorCode'] === 'OK');
51
+
52
+ // Result Check
53
+ $this->assertEquals('Are Eriksen', $result['name']);
54
+ $this->assertEquals('Strandsveien 560', $result['streetAddress']);
55
+ $this->assertEquals('Ares coAddress', $result['coAddress']);
56
+ $this->assertEquals('3179', $result['zipCode']);
57
+ $this->assertEquals('Oslo', $result['city']);
58
+ $this->assertEquals('NO', $result['countryCode']);
59
+ }
60
+ }
lib/PayEx.Ecommerce.Php/tests/TestCase.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PayEx;
4
+
5
+ class TestCase extends \PHPUnit_Framework_TestCase
6
+ {
7
+ /** @var Px */
8
+ protected $px;
9
+
10
+ protected function setUp()
11
+ {
12
+ if (!defined('ACCOUNT_NUMBER') ||
13
+ !defined('ENCRYPTION_KEY')||
14
+ !defined('TEST_MODE'))
15
+ {
16
+ $this->fail('Test failed: Constants are not defined');
17
+ }
18
+
19
+ $this->px = new Px();
20
+ $this->px->setEnvironment(ACCOUNT_NUMBER, ENCRYPTION_KEY, TEST_MODE);
21
+ }
22
+
23
+ protected function tearDown()
24
+ {
25
+ $this->px = null;
26
+ }
27
+ }
lib/PayEx.Ecommerce.Php/tests/bootstrap.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once __DIR__ . '/../src/PayEx/Px.php';
4
+ require_once __DIR__ . '/TestCase.php';
5
+
6
+ // Load config
7
+ if (file_exists(__DIR__ . '/config.local.ini')) {
8
+ $config = parse_ini_file(__DIR__ . '/config.local.ini', true);
9
+ } else {
10
+ $config = parse_ini_file(__DIR__ . '/config.ini', true);
11
+ }
12
+
13
+ define('ACCOUNT_NUMBER', $config['account_number']);
14
+ define('ENCRYPTION_KEY', $config['encryption_key']);
15
+ define('TEST_MODE', $config['test_mode']);
lib/PayEx.Ecommerce.Php/tests/config.ini ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ ; PayEx Merchant Environment
2
+ account_number = 12345678
3
+ encryption_key = xxxxxxxxxxxxxxxxxxxx
4
+ test_mode = true
lib/PayEx.Ecommerce.Php/tests/phpunit.xml ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <phpunit bootstrap="bootstrap.php">
2
+ </phpunit>
package.xml CHANGED
@@ -1,14 +1,38 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>PayEx_Payments</name>
4
- <version>3.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>PayEx Payments for Magento</summary>
10
  <description>Official PayEx Payments Extension for Magento</description>
11
- <notes>Version 3.0.1&#xD;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  * Implemented Swish Payment Method&#xD;
13
  * Financing Invoice: Invoice link&#xD;
14
  * Fixed payex account problem for multiple stores&#xD;
@@ -174,9 +198,9 @@ Version 1.2.0&#xD;
174
  * Bugfixes&#xD;
175
  </notes>
176
  <authors><author><name>AAIT</name><user>aaight</user><email>info@aait.se</email></author></authors>
177
- <date>2016-05-04</date>
178
- <time>11:59:32</time>
179
- <contents><target name="magecommunity"><dir name="PayEx"><dir name="Payments"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><file name="Hint.php" hash="eb183968bc78ad610698149c2e43eee8"/></dir><dir name="Sales"><dir name="Order"><dir name="Create"><dir name="Totals"><file name="Fee.php" hash="8a2e94e150260233793bc234175860ca"/></dir></dir></dir></dir></dir><dir name="Bankdebit"><file name="Banks.php" hash="513151012cfc3b50ba664a4dd5ae0506"/></dir><dir name="Checkout"><file name="Fee.php" hash="19e183ebcca0fd0124e16e8a5ee12a27"/></dir><dir name="Form"><file name="Autopay.php" hash="fe9b0f2c290929b65cffc0d9d82c8134"/><file name="Bankdebit.php" hash="7ac259e42c1750b039333bdf8e251120"/><file name="CC.php" hash="3a1e2c04277ad1112f6c02e1a69feb6b"/><file name="Financing.php" hash="407259a988ac5184d26530b196ef5fd6"/><file name="Invoice.php" hash="da5b1a05319df937787fccb383d10603"/><file name="MasterPass.php" hash="c498e2a8348e69c38363bbfb4637a9db"/><file name="PartPayment.php" hash="5109b405a3bf50af8abef09382f9832d"/><file name="Swish.php" hash="3bafe7744b0d7b6d7cf58b801368da6c"/><file name="Wywallet.php" hash="6d93149b4708369cf9b162b28acf93ae"/></dir><dir name="Info"><file name="Autopay.php" hash="87efd7d5e0c013c50698e951806e61a4"/><file name="Bankdebit.php" hash="0adc20468181f262f96a85d0cc660294"/><file name="CC.php" hash="5e5719393bf435ad43262d8cff99ff7d"/><file name="Financing.php" hash="3f00c97d360931ab26e43cf7fc51c802"/><file name="Invoice.php" hash="b5279f695dd4a3b2f03359d31024d715"/><file name="MasterPass.php" hash="e89dfab07bc90dbbde17add8ec86edd4"/><file name="PartPayment.php" hash="8af5c7d10d46f198835823a2246411e4"/><file name="Swish.php" hash="ced50c4956bbf1b47d75bf6e17add7a2"/><file name="Wywallet.php" hash="cf2ab25ee18ce1864d54295bce9c5413"/></dir><dir name="MasterPass"><file name="Button.php" hash="a21664578bd2e64dd0da17c78d86acd4"/></dir><dir name="Order"><dir name="Totals"><file name="Fee.php" hash="5c17b48ff4af838118d2f3a79f8196de"/></dir></dir></dir><dir name="Helper"><file name="Agreement.php" hash="669e23be0609b8b2b6e8ef69828237bb"/><file name="Api.php" hash="efcbba9c2b74bf2856e70c975e7441cc"/><file name="Data.php" hash="222c131eaa7ec9b9a63f5d04d1396cdf"/><file name="Discount.php" hash="a9e14a27371bfa658d145fa4c1645528"/><file name="Fee.php" hash="3704dd59b91e450824b14d7ce815fcd2"/><file name="Order.php" hash="2cdd01cdd85fce52003c2cdb2352cb5c"/><file name="Tools.php" hash="44532d39b11fc0d8bc100a70de695ca1"/></dir><dir name="Model"><file name="Agreement.php" hash="424c46027050c8414c43acb16da6eb62"/><file name="Feed.php" hash="f5da40677cf63bc951ef79b76cc5511d"/><dir name="Invoice"><file name="Total.php" hash="8882f98404b07353eee6acbe1958c6dd"/></dir><dir name="Mysql4"><dir name="Agreement"><file name="Collection.php" hash="b3e90711a42b1809a19ea020229af8bf"/></dir><file name="Agreement.php" hash="08a61c11053577ac16c63e3d205bfb24"/></dir><file name="Observer.php" hash="70f737166e3db85715ac87b5f7dcf0af"/><dir name="Payment"><file name="Abstract.php" hash="ca596169a9f999e9cf2e41df37502c17"/><file name="Autopay.php" hash="c884987d4bf87dc3ae354443ab21c2a4"/><file name="Bankdebit.php" hash="a26006557a1e61deead2fc5c86f264db"/><file name="CC.php" hash="5d76e80dfea312753b5b73c4d69306c1"/><file name="Financing.php" hash="8748a14ac071767b615c9cb330c69a76"/><file name="Invoice.php" hash="6a7fd1e01d5d10aac1238e2730446fd1"/><file name="MasterPass.php" hash="bd42b6804285d1d38bce2da87ede0b7d"/><file name="PartPayment.php" hash="db870218eb9d13cccf894a0088d90f1b"/><file name="Swish.php" hash="79421605835b4d959749a9dad3538a36"/><file name="Wywallet.php" hash="723a11740b07ace3a29cd07e2090a273"/></dir><dir name="Quote"><file name="Total.php" hash="f8afbb402a17d429a55a238d1c09df04"/></dir><file name="Session.php" hash="1fecbc5cfae2895af571ec4f6bd94b77"/><dir name="Source"><file name="Banks.php" hash="0ef09b35734564738624c49124288429"/><file name="ClientLanguage.php" hash="6a62ed649614a3fdb8544d6a028518a1"/><file name="MediaDistribution.php" hash="f01d02d087d8d006b91ef542ad9bd3e7"/><file name="PaymentAction.php" hash="9dcb319d3987c285b297d40f0318f079"/><file name="PaymentView.php" hash="a1ed5ba1386ca6a294c53125fafe80fa"/><file name="ShippingMethod.php" hash="6c05068faae319ebb27319733ed5e95a"/><file name="TaxClasses.php" hash="b6ceeb12e575d6c1296cbc3850165a12"/></dir></dir><dir name="controllers"><file name="AutopayController.php" hash="3fab1a3c8c477a3bb4877e0820efed8d"/><file name="BankdebitController.php" hash="70ffcc53b5fd45f57153c29e0d6269b1"/><file name="FinancingController.php" hash="9777fd538daf0ad5a70386b04a23a4c2"/><file name="GetaddrController.php" hash="c119f5771b6b9f35b17bad472d0b1165"/><file name="InvoiceController.php" hash="058265b8390894c9c2b9f3cf4c7caee1"/><file name="MasterpassController.php" hash="078f8f71b7f1c28ef404f7023c41ccf3"/><file name="PartpaymentController.php" hash="5adccde9244fd6da6a667383f726bec4"/><file name="PaymentController.php" hash="36108a68423d34f606b0c658f6fa7e24"/><file name="SwishController.php" hash="040f8394796e59dc49f52b507d45afec"/><file name="TransactionController.php" hash="2b9b42ebd63e1f0202fb05881651269a"/><file name="WywalletController.php" hash="b41ca2f84d9304c21cbe97ea2e2e8bc8"/></dir><dir name="data"><dir name="payex_setup"><file name="data-install-3.0.0.php" hash="3a93c2049db69949fc615fddee97c818"/></dir></dir><dir name="etc"><file name="config.xml" hash="1c8b2830b6ce5fa3a0dbef33ff0ab555"/><file name="system.xml" hash="e7cd1bacbc84087d998c47e064397e3d"/></dir><dir name="sql"><dir name="payex_setup"><file name="install-3.0.0.php" hash="3182c5ce1647a38e805f86abef05bc8a"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="PayEx_Payments.csv" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir><dir name="sv_SE"><file name="PayEx_Payments.csv" hash="07b5a1df1d4ed49bc803b1d505f9d2f5"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="payex"><dir name="autopay"><file name="form.phtml" hash="eeff0becc642b3f2f468e80d96144dbc"/><file name="info.phtml" hash="d9b8f551ac4d53b1fe2e9b82d365e4c3"/><dir name="pdf"><file name="info.phtml" hash="1a7bb5d58cabb8a4a66234ffd3d6c230"/></dir><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="bankdebit"><file name="form.phtml" hash="9840095a4d2f87dd955579cb053d6327"/><file name="info.phtml" hash="8b43e84bae9c4ffc96e57537c042bc42"/></dir><dir name="cc"><file name="form.phtml" hash="8286f66533534c36b1a8284dc55f543b"/><file name="info.phtml" hash="01f5da45f5a3668f3228a72bbd0b6aae"/><dir name="pdf"><file name="info.phtml" hash="fbbe9f65f9e36ddb630ab9a9b019ed49"/></dir><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="checkout"><file name="fee.phtml" hash="78f6f419e4324fb76a5b25d5d9dbbe29"/><dir name="onepage"><file name="billing_with_ssn.phtml" hash="b0a7f7aafc449eb05488ee31c72fc5ae"/></dir></dir><dir name="financing"><file name="form.phtml" hash="08e98c6954d14276f57eb8339567bfb7"/><file name="info.phtml" hash="15700ce473736a214fc1aa41daf7f1e6"/><dir name="pdf"><file name="info.phtml" hash="fbbe9f65f9e36ddb630ab9a9b019ed49"/></dir><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="invoice"><file name="form.phtml" hash="fba1c82b52d3204f9db93e55f0501f1d"/><file name="info.phtml" hash="a90f8aa90e56265c9e4533551bd3f1d2"/></dir><dir name="iwd_opc"><file name="billing_with_ssn.phtml" hash="fa37263b495924da540607989c845b51"/></dir><dir name="masterpass"><file name="button.phtml" hash="a845fe3f3965b4c151a87132a2560502"/><file name="form.phtml" hash="d7b01403fb3c58c2de79fdfa4ee38bc9"/><file name="info.phtml" hash="a3fe264db69fc49b65f05a7d2fc64590"/><dir name="pdf"><file name="info.phtml" hash="fbbe9f65f9e36ddb630ab9a9b019ed49"/></dir><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="partpayment"><file name="form.phtml" hash="e321b2421e706f328c531595dcaf1316"/><file name="info.phtml" hash="e8d0ef852c3b899bf305a9b486a253a7"/><dir name="pdf"><file name="info.phtml" hash="fbbe9f65f9e36ddb630ab9a9b019ed49"/></dir><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="swish"><file name="form.phtml" hash="44a68dc45b8db91bfb715ca9467ab827"/><file name="info.phtml" hash="b2c51aa0a4383c5465cebdc50cda5ec4"/><dir name="pdf"><file name="info.phtml" hash="fbbe9f65f9e36ddb630ab9a9b019ed49"/></dir><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="wywallet"><file name="form.phtml" hash="6e1bd3fb7bc50bfc3cf4e6808ebfb7b7"/><file name="info.phtml" hash="600d2c36c2691f1cddd3f05e4aafbc70"/><dir name="pdf"><file name="info.phtml" hash="1a7bb5d58cabb8a4a66234ffd3d6c230"/></dir></dir></dir></dir><dir name="layout"><dir name="payex"><file name="masterpass.xml" hash="d98963f85886570e21246f34d798ffa7"/><file name="payment_fee.xml" hash="d79c4ac5c4a9fddbadf8e156f67643bc"/><file name="social_security_number.xml" hash="67bcd100a20f68a45b52eb063ecc23c6"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="payex"><dir name="adminhtml"><file name="hint.phtml" hash="e50c7fd0c9ea1fd315ea713a88e1b3e2"/></dir><dir name="autopay"><file name="form.phtml" hash="eeff0becc642b3f2f468e80d96144dbc"/><file name="info.phtml" hash="d9b8f551ac4d53b1fe2e9b82d365e4c3"/><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="bankdebit"><file name="form.phtml" hash="9840095a4d2f87dd955579cb053d6327"/><file name="info.phtml" hash="8b43e84bae9c4ffc96e57537c042bc42"/></dir><dir name="cc"><file name="form.phtml" hash="8286f66533534c36b1a8284dc55f543b"/><file name="info.phtml" hash="01f5da45f5a3668f3228a72bbd0b6aae"/><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="financing"><file name="form.phtml" hash="ef3303f50ce4a7d27b2fe2eb89f5b532"/><file name="info.phtml" hash="15700ce473736a214fc1aa41daf7f1e6"/><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="invoice"><file name="form.phtml" hash="fba1c82b52d3204f9db93e55f0501f1d"/><file name="info.phtml" hash="a90f8aa90e56265c9e4533551bd3f1d2"/></dir><dir name="masterpass"><file name="button.phtml" hash="a845fe3f3965b4c151a87132a2560502"/><file name="form.phtml" hash="d7b01403fb3c58c2de79fdfa4ee38bc9"/><file name="info.phtml" hash="a3fe264db69fc49b65f05a7d2fc64590"/><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="partpayment"><file name="form.phtml" hash="e321b2421e706f328c531595dcaf1316"/><file name="info.phtml" hash="e8d0ef852c3b899bf305a9b486a253a7"/><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="swish"><file name="form.phtml" hash="44a68dc45b8db91bfb715ca9467ab827"/><file name="info.phtml" hash="8cab37ca1d161bc1751d26d6b647dd75"/><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="wywallet"><file name="form.phtml" hash="6e1bd3fb7bc50bfc3cf4e6808ebfb7b7"/><file name="info.phtml" hash="600d2c36c2691f1cddd3f05e4aafbc70"/></dir></dir></dir><dir name="layout"><dir name="payex"><file name="adminhtml.xml" hash="09843499521cc0d049e598af3bc93577"/><file name="payment_fee.xml" hash="8901262fe753925034024f90519a00b6"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="PayEx_Payments.xml" hash="17ebbe7078c7a64531d9bccab1c04dd9"/></dir></dir></dir><dir name="."><file name="Changelog_payex.txt" hash="d8bba54533b8b245a48e33630107bf05"/></dir><dir name="js"><dir name="payex"><dir name="iwd_opc"><file name="social_security_number.js" hash="8be665ea511415c9a955db3454fc0110"/></dir><file name="social_security_number.js" hash="58e057aabbf97ae0506fd5c4522a36d2"/></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><dir name="payex"><file name="american_express_64.png" hash="0e4379f8c5963b4eb550b1941b89821e"/><file name="diners_club_64.png" hash="76ad504729a6a86ed3be9a496a5def73"/><file name="financing-logo.gif" hash="601ac8ee1101dc6e83393c15b92f3761"/><file name="jcb_64.png" hash="79fd2798aa7c8695da293c25fa6e18a5"/><file name="mastercard_64.png" hash="a656e3028f69c593b4261555c75351d6"/><file name="masterpass-140.png" hash="b74662352d7a83ce5586ab26c3dafe91"/><file name="masterpass.png" hash="681673dd599a743a512a3697fc6576cc"/><file name="partpayment-logo.gif" hash="db8f8f8bcfb4decd106ff49dbe9a955e"/><file name="payex-invoice.png" hash="568683eca82952bf847e0b08d88274d7"/><file name="payex-small.gif" hash="b760e19d0024a994a0d07058038201db"/><file name="payex.gif" hash="b760e19d0024a994a0d07058038201db"/><file name="swish.png" hash="a21c66a591a13823a9b546a13f22c843"/><file name="visa_64.png" hash="2f263bca4b195b6b18eac60c5e889891"/><file name="ww_logo.png" hash="77f03db05e5c2c557fc7a69f778f94e1"/></dir></dir><dir name="css"><dir name="payex"><file name="masterpass.css" hash="9aabd17cdc8a0f58662d86581c418294"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="images"><dir name="payex"><file name="swish.png" hash="a21c66a591a13823a9b546a13f22c843"/></dir></dir><dir name="payex"><file name="payex-logo.png" hash="5b493d130ef51483a3190d1285380242"/><file name="payex_admin.css" hash="bd5d31f628944b6b2e338b2bfcbf64ac"/></dir></dir></dir></dir></target><target name="magelib"><dir name="Px"><file name="Px.php" hash="2324304980e6252284da2eab7def26b2"/><file name="parser.php" hash="cfa3dfa8be36ebbf5ca50c512b370f0f"/></dir></target></contents>
180
  <compatible/>
181
- <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><extension><name>soap</name><min/><max/></extension></required></dependencies>
182
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>PayEx_Payments</name>
4
+ <version>3.1.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>PayEx Payments for Magento</summary>
10
  <description>Official PayEx Payments Extension for Magento</description>
11
+ <notes>Version 3.1.0&#xD;
12
+ * Implemented PayEx Billing Agreement Method&#xD;
13
+ * Removed PayEx AutoPay Method&#xD;
14
+ &#xD;
15
+ Version 3.0.3&#xD;
16
+ * Improvements of Social Security Number addon&#xD;
17
+ * Improvements of Payment Fee feature&#xD;
18
+ * Option: Perform validation of SSN before checkout&#xD;
19
+ * Option: Discount calculation mode&#xD;
20
+ * Option: Credit Check for Invoice method&#xD;
21
+ * Removed unnecessary info that is presented to end user&#xD;
22
+ * AutoPay frontend changes&#xD;
23
+ * PartPayment fixes&#xD;
24
+ * More descriptions for error codes&#xD;
25
+ * Added Unit Tests&#xD;
26
+ &#xD;
27
+ Version 3.0.2&#xD;
28
+ * Social Security Number: Use secure base URL&#xD;
29
+ * Added Missing Block: payex/invoice_totals_fee&#xD;
30
+ * Fixed capturing&#xD;
31
+ * Fixed invoicing&#xD;
32
+ * Set to inactive status of payment methods by default&#xD;
33
+ * Updated Px library&#xD;
34
+ &#xD;
35
+ Version 3.0.1&#xD;
36
  * Implemented Swish Payment Method&#xD;
37
  * Financing Invoice: Invoice link&#xD;
38
  * Fixed payex account problem for multiple stores&#xD;
198
  * Bugfixes&#xD;
199
  </notes>
200
  <authors><author><name>AAIT</name><user>aaight</user><email>info@aait.se</email></author></authors>
201
+ <date>2016-08-23</date>
202
+ <time>11:47:25</time>
203
+ <contents><target name="magecommunity"><dir name="PayEx"><dir name="Payments"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><file name="Hint.php" hash="eb183968bc78ad610698149c2e43eee8"/></dir><dir name="Sales"><dir name="Order"><dir name="Create"><dir name="Totals"><file name="Fee.php" hash="8a2e94e150260233793bc234175860ca"/></dir></dir></dir></dir></dir><dir name="Bankdebit"><file name="Banks.php" hash="513151012cfc3b50ba664a4dd5ae0506"/></dir><dir name="Checkout"><file name="Fee.php" hash="c8f7e28a1994e1b19f61d1511dc2921a"/></dir><dir name="Creditmemo"><dir name="Totals"><file name="Fee.php" hash="fbb8dae687528f64c3f6b9b9415e4e48"/></dir></dir><dir name="Form"><file name="Bankdebit.php" hash="7ac259e42c1750b039333bdf8e251120"/><dir name="Billing"><file name="Agreement.php" hash="967b23eaf8e0ef1bc3260c68f170b535"/></dir><file name="CC.php" hash="300511caeed6b89245b217ce831738b3"/><file name="Financing.php" hash="407259a988ac5184d26530b196ef5fd6"/><file name="Invoice.php" hash="da5b1a05319df937787fccb383d10603"/><file name="MasterPass.php" hash="c498e2a8348e69c38363bbfb4637a9db"/><file name="PartPayment.php" hash="5109b405a3bf50af8abef09382f9832d"/><file name="Swish.php" hash="3bafe7744b0d7b6d7cf58b801368da6c"/><file name="Wywallet.php" hash="6d93149b4708369cf9b162b28acf93ae"/></dir><dir name="Info"><file name="Bankdebit.php" hash="0adc20468181f262f96a85d0cc660294"/><dir name="Billing"><file name="Agreement.php" hash="4ec431a6b63f84ef4b7eac8fbb728a25"/></dir><file name="CC.php" hash="5e5719393bf435ad43262d8cff99ff7d"/><file name="Financing.php" hash="3f00c97d360931ab26e43cf7fc51c802"/><file name="Invoice.php" hash="b5279f695dd4a3b2f03359d31024d715"/><file name="MasterPass.php" hash="e89dfab07bc90dbbde17add8ec86edd4"/><file name="PartPayment.php" hash="8af5c7d10d46f198835823a2246411e4"/><file name="Swish.php" hash="ced50c4956bbf1b47d75bf6e17add7a2"/><file name="Wywallet.php" hash="cf2ab25ee18ce1864d54295bce9c5413"/></dir><dir name="Invoice"><dir name="Totals"><file name="Fee.php" hash="cc7648e88cb10cf4cddbbe6fc0ad662f"/></dir></dir><dir name="MasterPass"><file name="Button.php" hash="a21664578bd2e64dd0da17c78d86acd4"/></dir><dir name="Order"><dir name="Totals"><file name="Fee.php" hash="bcffa4ba69a8dcc5a180ac72f83f97df"/></dir></dir></dir><dir name="Helper"><file name="Api.php" hash="1ce53e8839788869cef007e5c8757f1f"/><file name="Data.php" hash="822bc9d81bfc2688cb85b7f6d533a6bd"/><file name="Discount.php" hash="caaea480eb6983997957454fd35a068b"/><file name="Fee.php" hash="21a654132b640dad3e14b79481997d50"/><file name="Order.php" hash="f5e644872e3b8e07dd088c1c3374b432"/><file name="Tools.php" hash="4462048a592cb1548eb48f7ed9739418"/></dir><dir name="Model"><dir name="Creditmemo"><file name="Tax.php" hash="d929e3eab0c4bf19dccd9f91a0cfc31a"/><file name="Total.php" hash="a8fb8f96a4aa26a66bdd1c605448f1c4"/></dir><dir name="Fee"><file name="Config.php" hash="9bcd18629425efff66fb7889b20bbd49"/></dir><file name="Feed.php" hash="f5da40677cf63bc951ef79b76cc5511d"/><dir name="Invoice"><dir name="Pdf"><file name="Total.php" hash="e50e44f88d8015792995c3fd9269e238"/></dir><file name="Tax.php" hash="59dc6b02e1ce3237165ff920093c3f18"/><file name="Total.php" hash="814d71354efb2366fdafd6e5176ef92e"/></dir><file name="Observer.php" hash="52c12adf027c894f61b865a884e4418f"/><dir name="Payment"><file name="Abstract.php" hash="ca596169a9f999e9cf2e41df37502c17"/><file name="Agreement.php" hash="b23c4d6fbbb9b8a21c52bada2d6dd1d2"/><file name="Bankdebit.php" hash="77427f17569fcc0bc00583a502721fce"/><file name="CC.php" hash="ac5ca8c454773c1908403631e45f4ff6"/><file name="Financing.php" hash="d1bea52ff897a2116d2a018a9c2dfcf2"/><file name="Invoice.php" hash="d087bd27bb8bf9b89fe89019689dd37e"/><file name="MasterPass.php" hash="f11be9e2e9c482fab1cd2394e6362560"/><file name="PartPayment.php" hash="466f21f2474adcb5b3fe13f230f95ab3"/><file name="Swish.php" hash="be74bffea41f5e06df86b114c390321e"/><file name="Wywallet.php" hash="8ab61565bc9c6e5181ed495ab0a3ffb1"/></dir><dir name="Quote"><file name="Tax.php" hash="f8457d99ecbc45569cdb5ed96da17ee3"/><file name="Total.php" hash="3078278ae4bc6398e67ed5cec3451597"/></dir><file name="Session.php" hash="1fecbc5cfae2895af571ec4f6bd94b77"/><dir name="Source"><file name="Banks.php" hash="0ef09b35734564738624c49124288429"/><file name="ClientLanguage.php" hash="6a62ed649614a3fdb8544d6a028518a1"/><file name="DiscountCalculation.php" hash="01f46845126c4fa97f6badb2821db8c6"/><file name="MediaDistribution.php" hash="f01d02d087d8d006b91ef542ad9bd3e7"/><file name="PaymentAction.php" hash="9dcb319d3987c285b297d40f0318f079"/><file name="PaymentView.php" hash="a1ed5ba1386ca6a294c53125fafe80fa"/><file name="ShippingMethod.php" hash="6c05068faae319ebb27319733ed5e95a"/><file name="TaxClasses.php" hash="b6ceeb12e575d6c1296cbc3850165a12"/></dir></dir><dir name="Test"><dir name="Block"><dir name="Form"><file name="Bankdebit.php" hash="2d36bf30e8d5f940b56f64513162075a"/><file name="CC.php" hash="8caed5ae1af2afbbb1a4fd8ba9a2bf51"/><file name="Financing.php" hash="1332bf659d4cc21e6e1a02f0f8e00523"/><file name="Invoice.php" hash="725f2a395570ce6f6659a61979e88e38"/><file name="MasterPass.php" hash="5134b69f8bab79128545e76265735131"/><file name="PartPayment.php" hash="234f78cb3ed0471b90f4e4ea52063bbb"/><file name="Swish.php" hash="4780efbd52b21544389196c18bc3574d"/><file name="Wywallet.php" hash="c484194c90c4b98ec222cea82abe8365"/></dir><dir name="Info"><file name="Bankdebit.php" hash="180f28d05b83770680f849c9ed0fb99b"/><file name="CC.php" hash="04a7e5449995cb2f9df295ca1b854be9"/><file name="MasterPass.php" hash="170f645c0a64e442fe94436bb36612f0"/><file name="PartPayment.php" hash="f5e056eb58b5c0f8d2cc88083aa98646"/><file name="Swish.php" hash="072e49173418fe53ea7b7011b7366269"/><file name="Wywallet.php" hash="6bb347e7b614bd78a96974e810beda43"/></dir></dir><dir name="Helper"><file name="Api.php" hash="895012e4ce797a458e13c33455b5f8f4"/><file name="Order.php" hash="88ce7813939433c0c19ed459bd75d857"/><file name="Tools.php" hash="49a00318fe0d2acfc714b503c19a7fc7"/></dir><dir name="Model"><dir name="Payment"><file name="Bankdebit.php" hash="5e3880162758fc6aeccaba9b3bc5c692"/><file name="CC.php" hash="bdfb02c0d8e3ee68eceb97363f363284"/><file name="Financing.php" hash="07c12d0ffa58c6ba296a352fdf78ab78"/><file name="Invoice.php" hash="ff113dd2ff846d8cdca48a74bfab8f04"/><file name="MasterPass.php" hash="259057fd9262fa60b0c85da84326dee1"/><file name="PartPayment.php" hash="85f73e8e06e16ac4186266befd50fe83"/><file name="Swish.php" hash="e288d7c93aa30a447a30571b12b04cf0"/><file name="Wywallet.php" hash="53732843df569fe985d563aa6c20da34"/></dir></dir></dir><dir name="controllers"><file name="BankdebitController.php" hash="70ffcc53b5fd45f57153c29e0d6269b1"/><file name="FinancingController.php" hash="9777fd538daf0ad5a70386b04a23a4c2"/><file name="GetaddrController.php" hash="c119f5771b6b9f35b17bad472d0b1165"/><file name="InvoiceController.php" hash="59dcb499c0ff792fc31a87751d53f035"/><file name="MasterpassController.php" hash="078f8f71b7f1c28ef404f7023c41ccf3"/><file name="PartpaymentController.php" hash="5adccde9244fd6da6a667383f726bec4"/><file name="PaymentController.php" hash="0d876e6f8a6a1126aeab7ea9ae37a9b3"/><file name="SwishController.php" hash="040f8394796e59dc49f52b507d45afec"/><file name="TransactionController.php" hash="2b9b42ebd63e1f0202fb05881651269a"/><file name="WywalletController.php" hash="b41ca2f84d9304c21cbe97ea2e2e8bc8"/></dir><dir name="data"><dir name="payex_setup"><file name="data-install-3.0.0.php" hash="3a93c2049db69949fc615fddee97c818"/><file name="data-upgrade-3.0.2-3.0.3.php" hash="6a10340e6996eef25c18231142e18207"/><file name="data-upgrade-3.0.3-3.1.0.php" hash="108e447e57c2aac6f04f6a77bc644e11"/></dir></dir><dir name="etc"><file name="config.xml" hash="8d4089e871cb8582c4821745b897abe9"/><file name="system.xml" hash="02c9c0082827e25aa35a8ed0e8625357"/></dir><dir name="sql"><dir name="payex_setup"><file name="install-3.0.0.php" hash="3182c5ce1647a38e805f86abef05bc8a"/><file name="install-3.1.0.php" hash="b53f8362226e779698bc7093b3869bdb"/><file name="upgrade-3.0.2-3.0.3.php" hash="b0d9d6ee76bedd47ee7d707bbf8fedf0"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="PayEx_Payments.csv" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir><dir name="sv_SE"><file name="PayEx_Payments.csv" hash="c425c10c567f10fc903a25f397b8f70a"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="payex"><dir name="autopay"><file name="form.phtml" hash="eeff0becc642b3f2f468e80d96144dbc"/><file name="info.phtml" hash="d9b8f551ac4d53b1fe2e9b82d365e4c3"/><dir name="pdf"><file name="info.phtml" hash="1a7bb5d58cabb8a4a66234ffd3d6c230"/></dir><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="bankdebit"><file name="form.phtml" hash="9840095a4d2f87dd955579cb053d6327"/><file name="info.phtml" hash="8b43e84bae9c4ffc96e57537c042bc42"/></dir><dir name="billing"><dir name="agreement"><file name="form.phtml" hash="b487001c6ae985d25efeda4cf7cf4ddc"/><file name="info.phtml" hash="2fba38394416ddc61c7462e7dd02207e"/></dir></dir><dir name="cc"><file name="form.phtml" hash="c479f42de3463b7957cee7063d6a200f"/><file name="info.phtml" hash="2a95b272b28f907c135f66d6452fa7a5"/><dir name="pdf"><file name="info.phtml" hash="010078bc76f687682f8a1d86eb5ae4ca"/></dir><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="checkout"><file name="fee.phtml" hash="48d97cc321ed366ad89f618ca99f40a8"/><dir name="onepage"><file name="billing_with_ssn.phtml" hash="36d083f6c392822e5bfbd520f5aae5f0"/></dir></dir><dir name="financing"><file name="form.phtml" hash="8a7a8197d6de7fe076c12b51df13f8c2"/><file name="info.phtml" hash="c011e637ee4686535fd62024bc2445b6"/><dir name="pdf"><file name="info.phtml" hash="a4140bfd63a3c558e22935243b253ae9"/></dir><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="invoice"><file name="form.phtml" hash="56cb4dbc37962ee65228222d800a374d"/><file name="info.phtml" hash="a90f8aa90e56265c9e4533551bd3f1d2"/></dir><dir name="iwd_opc"><file name="billing_with_ssn.phtml" hash="de2d81f3aa1dcdab90845c4501f14029"/></dir><dir name="masterpass"><file name="button.phtml" hash="a845fe3f3965b4c151a87132a2560502"/><file name="form.phtml" hash="d7b01403fb3c58c2de79fdfa4ee38bc9"/><file name="info.phtml" hash="a3fe264db69fc49b65f05a7d2fc64590"/><dir name="pdf"><file name="info.phtml" hash="fbbe9f65f9e36ddb630ab9a9b019ed49"/></dir><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="partpayment"><file name="form.phtml" hash="0d91898640f70c482a9a22370cc43fca"/><file name="info.phtml" hash="c88c8bc0bb3c1b1c030a3f621ceff66f"/><dir name="pdf"><file name="info.phtml" hash="a4140bfd63a3c558e22935243b253ae9"/></dir><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="swish"><file name="form.phtml" hash="44a68dc45b8db91bfb715ca9467ab827"/><file name="info.phtml" hash="b2c51aa0a4383c5465cebdc50cda5ec4"/><dir name="pdf"><file name="info.phtml" hash="27f0335f7d9751c187d35a5837ba9d35"/></dir><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="wywallet"><file name="form.phtml" hash="6e1bd3fb7bc50bfc3cf4e6808ebfb7b7"/><file name="info.phtml" hash="05703ddc8ac731023b5336c41865b343"/><dir name="pdf"><file name="info.phtml" hash="a36c05319049914f739485a80f44d9d8"/></dir></dir></dir></dir><dir name="layout"><dir name="payex"><file name="masterpass.xml" hash="d98963f85886570e21246f34d798ffa7"/><file name="payment_fee.xml" hash="d79c4ac5c4a9fddbadf8e156f67643bc"/><file name="social_security_number.xml" hash="f6df8d558fca12c5dc1871d1ca82f76a"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="payex"><dir name="adminhtml"><file name="hint.phtml" hash="e50c7fd0c9ea1fd315ea713a88e1b3e2"/></dir><dir name="autopay"><file name="form.phtml" hash="eeff0becc642b3f2f468e80d96144dbc"/><file name="info.phtml" hash="d9b8f551ac4d53b1fe2e9b82d365e4c3"/><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="bankdebit"><file name="form.phtml" hash="9840095a4d2f87dd955579cb053d6327"/><file name="info.phtml" hash="8b43e84bae9c4ffc96e57537c042bc42"/></dir><dir name="billing"><dir name="agreement"><file name="form.phtml" hash="b487001c6ae985d25efeda4cf7cf4ddc"/><file name="info.phtml" hash="f9ddb4fd74e952325a70ea47fd00b574"/></dir></dir><dir name="cc"><file name="form.phtml" hash="8286f66533534c36b1a8284dc55f543b"/><file name="info.phtml" hash="01f5da45f5a3668f3228a72bbd0b6aae"/><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="financing"><file name="form.phtml" hash="8a7a8197d6de7fe076c12b51df13f8c2"/><file name="info.phtml" hash="15700ce473736a214fc1aa41daf7f1e6"/><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="invoice"><file name="form.phtml" hash="56cb4dbc37962ee65228222d800a374d"/><file name="info.phtml" hash="a90f8aa90e56265c9e4533551bd3f1d2"/></dir><dir name="masterpass"><file name="button.phtml" hash="a845fe3f3965b4c151a87132a2560502"/><file name="form.phtml" hash="d7b01403fb3c58c2de79fdfa4ee38bc9"/><file name="info.phtml" hash="a3fe264db69fc49b65f05a7d2fc64590"/><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="partpayment"><file name="form.phtml" hash="0d91898640f70c482a9a22370cc43fca"/><file name="info.phtml" hash="e8d0ef852c3b899bf305a9b486a253a7"/><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="swish"><file name="form.phtml" hash="44a68dc45b8db91bfb715ca9467ab827"/><file name="info.phtml" hash="8cab37ca1d161bc1751d26d6b647dd75"/><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="wywallet"><file name="form.phtml" hash="6e1bd3fb7bc50bfc3cf4e6808ebfb7b7"/><file name="info.phtml" hash="600d2c36c2691f1cddd3f05e4aafbc70"/></dir></dir></dir><dir name="layout"><dir name="payex"><file name="adminhtml.xml" hash="09843499521cc0d049e598af3bc93577"/><file name="payment_fee.xml" hash="b089c348af96916be2308e547a7aa541"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="PayEx_Payments.xml" hash="27ca9b51b59e28ee9a0f7713ba618a53"/></dir></dir></dir><dir name="."><file name="Changelog_payex.txt" hash="d8bba54533b8b245a48e33630107bf05"/></dir><dir name="js"><dir name="payex"><dir name="iwd_opc"><file name="social_security_number.js" hash="8be665ea511415c9a955db3454fc0110"/></dir><file name="social_security_number.js" hash="b7f6048ccc4834979745c41892810dfd"/></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><dir name="payex"><file name="american_express_64.png" hash="0e4379f8c5963b4eb550b1941b89821e"/><file name="diners_club_64.png" hash="76ad504729a6a86ed3be9a496a5def73"/><file name="financing-logo.gif" hash="601ac8ee1101dc6e83393c15b92f3761"/><file name="jcb_64.png" hash="79fd2798aa7c8695da293c25fa6e18a5"/><file name="mastercard_64.png" hash="a656e3028f69c593b4261555c75351d6"/><file name="masterpass-140.png" hash="b74662352d7a83ce5586ab26c3dafe91"/><file name="masterpass.png" hash="681673dd599a743a512a3697fc6576cc"/><file name="partpayment-logo.gif" hash="db8f8f8bcfb4decd106ff49dbe9a955e"/><file name="payex-invoice.png" hash="568683eca82952bf847e0b08d88274d7"/><file name="payex-small.gif" hash="b760e19d0024a994a0d07058038201db"/><file name="payex.gif" hash="b760e19d0024a994a0d07058038201db"/><file name="swish.png" hash="a21c66a591a13823a9b546a13f22c843"/><file name="visa_64.png" hash="2f263bca4b195b6b18eac60c5e889891"/><file name="ww_logo.png" hash="77f03db05e5c2c557fc7a69f778f94e1"/></dir></dir><dir name="css"><dir name="payex"><file name="masterpass.css" hash="9aabd17cdc8a0f58662d86581c418294"/><file name="social_security_number.css" hash="f4c6be59ab030a10eb364a203242e8a2"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="images"><dir name="payex"><file name="swish.png" hash="a21c66a591a13823a9b546a13f22c843"/></dir></dir><dir name="payex"><file name="payex-logo.png" hash="5b493d130ef51483a3190d1285380242"/><file name="payex_admin.css" hash="bd5d31f628944b6b2e338b2bfcbf64ac"/></dir></dir></dir></dir></target><target name="magelib"><dir name="PayEx.Ecommerce.Php"><file name="LICENSE" hash="45fa4c0c9383cd79867ff84e3e09571f"/><file name="README.md" hash="54fce3564e1258d1e880ac5cc127c07c"/><file name="composer.json" hash="d992c25dd1a8eeeb4ca1f7609e84f0e0"/><dir name="src"><dir name="PayEx"><file name="Px.php" hash="9de27cca51ca7e8193eac57386973178"/></dir></dir><dir name="tests"><file name="ExceptionTest.php" hash="308c6aaa528c347bede31866814a52b8"/><file name="PaymentTest.php" hash="b65ea0baf888a022b46b2073a815b999"/><file name="SocialSecurityNumberTest.php" hash="716b81ccdf90dc86b1200bbd884bc733"/><file name="TestCase.php" hash="ecf7b761fcb13f3dfd0bbefd7f54cf3e"/><file name="bootstrap.php" hash="1513092b03d32908847972ce9f3f5de6"/><file name="config.ini" hash="b188ac7e751642a68acf8f85ef9ea29b"/><file name="phpunit.xml" hash="6ec124af67b56dba727ce95fa31346a1"/><file name=".gitignore" hash="c70c974c0e8123f383d38b3b0a02cf22"/></dir><file name=".git" hash="de008fb3d5fba327bd3166873e3eada5"/></dir><dir name="PHP-Name-Parser"><file name="README.md" hash="9e92e1a38faba55000f627ed0a71542e"/><file name="composer.json" hash="e5279f5f22785a33e165118d8031cb75"/><file name="examples.php" hash="d3d1948019c2a01fbb1a6394f39404df"/><file name="parser.php" hash="8c6f8764a4e372317cc7831f01b02353"/><dir name="tests"><file name="FullNameParserTest.php" hash="8b0428389df97b01341731b6b6dbeaac"/><file name="phpunit.xml" hash="5172e30007858dfcc4c23b77f97bc1e2"/><file name="style.css" hash="64301de4d41233d6da7d759df86e94f9"/></dir><file name=".git" hash="19d6fa68462e469ae8ca389195cb92ea"/></dir></target></contents>
204
  <compatible/>
205
+ <dependencies><required><php><min>5.2.0</min><max>7.1.0</max></php><extension><name>soap</name><min/><max/></extension></required></dependencies>
206
  </package>
skin/frontend/base/default/css/payex/social_security_number.css ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .field_left {
2
+ display: inline-block;
3
+ vertical-align: top;
4
+ width: 137px;
5
+ }
6
+
7
+ .field_right {
8
+ display: inline-block;
9
+ vertical-align: top;
10
+ width: 225px;
11
+ }
12
+
13
+ #ssn_click {
14
+ margin-top: 17px;
15
+ }
16
+
17
+ #social_security_number_form label[for="socialSecurityNumber"].required:after {
18
+ display: none;
19
+ }
20
+
21
+ #ssn-error-placeholder {
22
+ clear: both;
23
+ width: 100%;
24
+ }
25
+
26
+ .theme-rwd .clearer {
27
+ display: none;
28
+ }