Klarna_KlarnaPaymentModule_CE_13 - Version 1.2.4

Version Notes

1.2.4
---------------------------------
* Fixed an issue with get_addresses and guest checkout
===================

Download this release

Release Info

Developer Magento Core Team
Extension Klarna_KlarnaPaymentModule_CE_13
Version 1.2.4
Comparing to
See all releases


Version 1.2.4

Files changed (98) hide show
  1. app/code/local/Kreditor/Kreditor/Block/Address/List.php +38 -0
  2. app/code/local/Kreditor/Kreditor/Block/Adminhtml/Invoice/Create/Items.php +44 -0
  3. app/code/local/Kreditor/Kreditor/Block/Adminhtml/Pclass.php +67 -0
  4. app/code/local/Kreditor/Kreditor/Block/Adminhtml/Pclass/Matrix.php +47 -0
  5. app/code/local/Kreditor/Kreditor/Block/Adminhtml/Sales/Order/Totals/Item.php +34 -0
  6. app/code/local/Kreditor/Kreditor/Block/Form/Invoice.php +134 -0
  7. app/code/local/Kreditor/Kreditor/Block/Form/Partpayment.php +116 -0
  8. app/code/local/Kreditor/Kreditor/Block/Info/Invoice.php +57 -0
  9. app/code/local/Kreditor/Kreditor/Block/Info/Partpayment.php +57 -0
  10. app/code/local/Kreditor/Kreditor/Block/Product/Price.php +169 -0
  11. app/code/local/Kreditor/Kreditor/Block/Sales/Order/Email/Invoice/Items.php +44 -0
  12. app/code/local/Kreditor/Kreditor/Block/Sales/Order/Email/Items.php +43 -0
  13. app/code/local/Kreditor/Kreditor/Block/Sales/Order/Invoice/Items.php +43 -0
  14. app/code/local/Kreditor/Kreditor/Block/Sales/Order/Items.php +43 -0
  15. app/code/local/Kreditor/Kreditor/Block/Sales/Order/Print.php +44 -0
  16. app/code/local/Kreditor/Kreditor/Block/Sales/Order/Print/Invoice.php +43 -0
  17. app/code/local/Kreditor/Kreditor/Helper/Data.php +167 -0
  18. app/code/local/Kreditor/Kreditor/Model/Api/Kreditor.php +899 -0
  19. app/code/local/Kreditor/Kreditor/Model/Api/Pclass.php +110 -0
  20. app/code/local/Kreditor/Kreditor/Model/Api/kreditor_no_pear.php +4835 -0
  21. app/code/local/Kreditor/Kreditor/Model/Api/pclasses.php +47 -0
  22. app/code/local/Kreditor/Kreditor/Model/Convert/Order.php +53 -0
  23. app/code/local/Kreditor/Kreditor/Model/Convert/Quote.php +53 -0
  24. app/code/local/Kreditor/Kreditor/Model/Entity/Setup.php +33 -0
  25. app/code/local/Kreditor/Kreditor/Model/Method/Invoice.php +174 -0
  26. app/code/local/Kreditor/Kreditor/Model/Method/Partpayment.php +268 -0
  27. app/code/local/Kreditor/Kreditor/Model/Method/Shared.php +233 -0
  28. app/code/local/Kreditor/Kreditor/Model/Mysql4/Api/Pclass.php +35 -0
  29. app/code/local/Kreditor/Kreditor/Model/Mysql4/Api/Pclass/Collection.php +64 -0
  30. app/code/local/Kreditor/Kreditor/Model/Sales/Order.php +135 -0
  31. app/code/local/Kreditor/Kreditor/Model/Sales/Order/Invoice/Total/Invoicefee.php +65 -0
  32. app/code/local/Kreditor/Kreditor/Model/Sales/Quote.php +174 -0
  33. app/code/local/Kreditor/Kreditor/Model/Sales/Quote/Address/Total/Invoicefee.php +48 -0
  34. app/code/local/Kreditor/Kreditor/Model/Sales/Total/Invoicefee.php +48 -0
  35. app/code/local/Kreditor/Kreditor/Model/Source/Invoicecountry.php +51 -0
  36. app/code/local/Kreditor/Kreditor/Model/Source/Partpaymentcountry.php +51 -0
  37. app/code/local/Kreditor/Kreditor/Model/Source/TransactionMode.php +48 -0
  38. app/code/local/Kreditor/Kreditor/controllers/AddressController.php +51 -0
  39. app/code/local/Kreditor/Kreditor/controllers/PclassController.php +54 -0
  40. app/code/local/Kreditor/Kreditor/etc/config.xml +224 -0
  41. app/code/local/Kreditor/Kreditor/etc/system.xml +388 -0
  42. app/code/local/Kreditor/Kreditor/sql/kreditor_setup/mysql4-install-0.1.0.php +75 -0
  43. app/code/local/Kreditor/Kreditor/sql/kreditor_setup/mysql4-upgrade-0.1.0-1.13.15.php +41 -0
  44. app/code/local/Kreditor/Kreditor/sql/kreditor_setup/mysql4-upgrade-1.13.15-1.20.0.php +57 -0
  45. app/design/adminhtml/default/default/layout/kreditor.xml +29 -0
  46. app/design/adminhtml/default/default/template/kreditor/form/invoice.phtml +30 -0
  47. app/design/adminhtml/default/default/template/kreditor/form/partpayment.phtml +30 -0
  48. app/design/adminhtml/default/default/template/kreditor/info/invoice.phtml +42 -0
  49. app/design/adminhtml/default/default/template/kreditor/info/partpayment.phtml +49 -0
  50. app/design/adminhtml/default/default/template/kreditor/pclass.phtml +48 -0
  51. app/design/adminhtml/default/default/template/kreditor/pclass/matrix.phtml +68 -0
  52. app/design/adminhtml/default/default/template/kreditor/sales/order/totals/invoicefee.phtml +42 -0
  53. app/design/frontend/default/default/layout/kreditor.xml +11 -0
  54. app/design/frontend/default/default/template/kreditor/address/list.phtml +77 -0
  55. app/design/frontend/default/default/template/kreditor/form/invoice.phtml +158 -0
  56. app/design/frontend/default/default/template/kreditor/form/partpayment.phtml +203 -0
  57. app/design/frontend/default/default/template/kreditor/info/invoice.phtml +44 -0
  58. app/design/frontend/default/default/template/kreditor/info/partpayment.phtml +62 -0
  59. app/design/frontend/default/default/template/kreditor/order/email_invoice_items.phtml +86 -0
  60. app/design/frontend/default/default/template/kreditor/order/email_items.phtml +94 -0
  61. app/design/frontend/default/default/template/kreditor/order/invoice_items.phtml +98 -0
  62. app/design/frontend/default/default/template/kreditor/order/items.phtml +127 -0
  63. app/design/frontend/default/default/template/kreditor/order/print_invoice.phtml +142 -0
  64. app/design/frontend/default/default/template/kreditor/order/print_order.phtml +122 -0
  65. app/design/frontend/default/default/template/kreditor/product/price.phtml +63 -0
  66. app/etc/modules/Kreditor_Kreditor.xml +9 -0
  67. app/locale/da_DK/Kreditor_Kreditor.csv +71 -0
  68. app/locale/de_DE/Kreditor_Kreditor.csv +84 -0
  69. app/locale/en_US/Kreditor_Kreditor.csv +40 -0
  70. app/locale/fi_FI/Kreditor_Kreditor.csv +72 -0
  71. app/locale/nb_NO/Kreditor_Kreditor.csv +75 -0
  72. app/locale/nl_NL/Kreditor_Kreditor.csv +77 -0
  73. app/locale/nn_NO/Kreditor_Kreditor.csv +75 -0
  74. app/locale/sv_SE/Kreditor_Kreditor.csv +78 -0
  75. package.xml +21 -0
  76. skin/adminhtml/default/default/images/kreditor/invoice/Thumbs.db +0 -0
  77. skin/adminhtml/default/default/images/kreditor/invoice/klarna.png +0 -0
  78. skin/adminhtml/default/default/images/kreditor/invoice/logo.png +0 -0
  79. skin/adminhtml/default/default/images/kreditor/invoice/logo_de.gif +0 -0
  80. skin/adminhtml/default/default/images/kreditor/invoice/logo_fi.png +0 -0
  81. skin/adminhtml/default/default/images/kreditor/invoice/logo_no.gif +0 -0
  82. skin/adminhtml/default/default/images/kreditor/invoice/logo_se.gif +0 -0
  83. skin/adminhtml/default/default/images/kreditor/partpayment/Thumbs.db +0 -0
  84. skin/adminhtml/default/default/images/kreditor/partpayment/logo.png +0 -0
  85. skin/adminhtml/default/default/images/kreditor/partpayment/logo_de.png +0 -0
  86. skin/adminhtml/default/default/images/kreditor/partpayment/logo_fi.png +0 -0
  87. skin/adminhtml/default/default/images/kreditor/partpayment/logo_se.gif +0 -0
  88. skin/frontend/default/default/images/kreditor/invoice/klarna.png +0 -0
  89. skin/frontend/default/default/images/kreditor/invoice/logo.png +0 -0
  90. skin/frontend/default/default/images/kreditor/invoice/logo_de.png +0 -0
  91. skin/frontend/default/default/images/kreditor/invoice/logo_fi.png +0 -0
  92. skin/frontend/default/default/images/kreditor/invoice/logo_nl.png +0 -0
  93. skin/frontend/default/default/images/kreditor/partpayment/dutch_credit.jpg +0 -0
  94. skin/frontend/default/default/images/kreditor/partpayment/logo.png +0 -0
  95. skin/frontend/default/default/images/kreditor/partpayment/logo_de.png +0 -0
  96. skin/frontend/default/default/images/kreditor/partpayment/logo_fi.png +0 -0
  97. skin/frontend/default/default/images/kreditor/partpayment/logo_nl.png +0 -0
  98. skin/frontend/default/default/images/kreditor/test_mode.png +0 -0
app/code/local/Kreditor/Kreditor/Block/Address/List.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_Block_Address_List extends Mage_Core_Block_Template
32
+ {
33
+ protected function _construct() {
34
+
35
+ }
36
+
37
+
38
+ }
app/code/local/Kreditor/Kreditor/Block/Adminhtml/Invoice/Create/Items.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_Block_Adminhtml_Invoice_Create_Items extends Mage_Adminhtml_Block_Sales_Order_Invoice_Create_Items
32
+ {
33
+ /**
34
+ * Retrieve order totalbar block data
35
+ *
36
+ * @return array
37
+ */
38
+ public function getOrderTotalbarData()
39
+ {
40
+
41
+ return parent::getOrderTotalbarData();
42
+ }
43
+
44
+ }
app/code/local/Kreditor/Kreditor/Block/Adminhtml/Pclass.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_Block_Adminhtml_Pclass extends Mage_Adminhtml_Block_Template {
32
+ protected function _construct() {
33
+ $this->setTemplate('kreditor/pclass.phtml');
34
+ }
35
+
36
+ protected function getHeader() {
37
+ return Mage::helper('kreditor')->__('Manage Klarna Pclasses');
38
+ }
39
+
40
+ protected function _prepareLayout() {
41
+ $this->setChild('update_button',
42
+ $this->getLayout()->createBlock('adminhtml/widget_button')
43
+ ->setData(array(
44
+ 'label' => Mage::helper('adminhtml')->__('Update'),
45
+ 'class' => 'add',
46
+ 'type' => 'submit',
47
+ )));
48
+
49
+ $this->setChild('pclasses_matrix',
50
+ $this->getLayout()->createBlock('kreditor/adminhtml_pclass_matrix')
51
+ );
52
+
53
+ return parent::_prepareLayout();
54
+ }
55
+
56
+ protected function getUpdateButtonHtml() {
57
+ return $this->getChildHtml('update_button');
58
+ }
59
+
60
+ protected function getPclassesMatrixHtml() {
61
+ return $this->getChildHtml('pclasses_matrix');
62
+ }
63
+
64
+ protected function getUpdateFormAction() {
65
+ return $this->getUrl('*/*/fetchPclasses');
66
+ }
67
+ }
app/code/local/Kreditor/Kreditor/Block/Adminhtml/Pclass/Matrix.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_Block_Adminhtml_Pclass_Matrix extends Mage_Adminhtml_Block_Template {
32
+ protected function _construct() {
33
+ $this->setTemplate('kreditor/pclass/matrix.phtml');
34
+ }
35
+
36
+ protected function _prepareLayout() {
37
+ $pclassModel = Mage::getModel('kreditor/api_pclass');
38
+
39
+ $this->setPclassCollection($pclassModel->getCollection());
40
+
41
+ return parent::_prepareLayout();
42
+ }
43
+
44
+ protected function getPclassFormAction() {
45
+ return $this->getUrl('*/*/savePclasses');
46
+ }
47
+ }
app/code/local/Kreditor/Kreditor/Block/Adminhtml/Sales/Order/Totals/Item.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_Block_Adminhtml_Sales_Order_Totals_Item extends Mage_Adminhtml_Block_Sales_Order_Totals
32
+ {
33
+
34
+ }
app/code/local/Kreditor/Kreditor/Block/Form/Invoice.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ ?>
31
+
32
+ <?php
33
+
34
+ class Kreditor_Kreditor_Block_Form_Invoice extends Mage_Payment_Block_Form
35
+ {
36
+ protected function _construct() {
37
+ parent::_construct();
38
+ $this->setTemplate('kreditor/form/invoice.phtml');
39
+ }
40
+
41
+ public function getLogoSrc() {
42
+ return $this->getMethod()->getLogoUrl();
43
+ }
44
+
45
+ public function getTermsUrl() {
46
+ $countryId = $this->getMethod()->getShippingCountry();
47
+
48
+ switch($countryId) {
49
+ case 'SE':
50
+ return 'https://online.klarna.com/villkor.yaws?eid=' . $this->getMerchantId() . '&charge=' . $this->getInvoiceFee();
51
+ case 'FI':
52
+ return 'https://online.klarna.com/villkor_fi.yaws?eid=' . $this->getMerchantId() . '&charge=' . $this->getInvoiceFee();
53
+ case 'NO':
54
+ return 'https://online.klarna.com/villkor_no.yaws?eid=' . $this->getMerchantId() . '&charge=' . $this->getInvoiceFee();
55
+ case 'DK':
56
+ return 'https://online.klarna.com/villkor_dk.yaws?eid=' . $this->getMerchantId() . '&charge=' . $this->getInvoiceFee();
57
+ case 'DE':
58
+ return 'https://online.klarna.com/villkor_de.yaws?eid=' . $this->getMerchantId() . '&charge=' . $this->getInvoiceFee();
59
+ case 'NL':
60
+ return 'https://online.klarna.com/villkor_nl.yaws?eid=' . $this->getMerchantId() . '&charge=' . $this->getInvoiceFee();
61
+ default: return '';
62
+ }
63
+ }
64
+
65
+ // xxx We only need to display the salary box when we
66
+ // have an order for Norway that exceeds the limit
67
+ public function showSalaryBox() {
68
+
69
+ $checkout = Mage::getSingleton('checkout/session');
70
+ $grandTotal = $checkout->getQuote()->getGrandTotal();
71
+ $currency = Mage::app()->getStore()->getCurrentCurrencyCode();
72
+ if(($grandTotal > Mage::getStoreConfig('advanced/klarna/yearly_sal_limit_no')) && $currency == "NOK")
73
+ return true;
74
+
75
+
76
+ return false;
77
+ }
78
+
79
+ public function getInvoiceFee() {
80
+ return $this->getMethod()->_getInvoiceFee();
81
+ }
82
+
83
+ public function getCurrency() {
84
+ return $this->getMethod()
85
+ ->getCheckout()
86
+ ->getQuote()
87
+ ->getBaseCurrencyCode();
88
+ }
89
+
90
+ public function getMerchantId() {
91
+ return $this->getMethod()->getMerchantId();
92
+ }
93
+
94
+ public function addressUpdate() {
95
+ $checkout = Mage::getSingleton('checkout/session');
96
+ $currency = Mage::app()->getStore()->getCurrentCurrencyCode();
97
+ if($currency != 'SEK') return false;
98
+ return $this->getMethod()->getConfigData('update_address');
99
+ }
100
+
101
+ public function getInfoUrlLang() {
102
+ $checkout = Mage::getSingleton('checkout/session');
103
+ $countryId = $this->getMethod()->getShippingCountry();
104
+
105
+ switch ($countryId) {
106
+ case 'SE': return '';
107
+ case 'DK': return '_dk';
108
+ case 'NO': return '_no';
109
+ case 'NO': return '_no';
110
+ case 'FI': return '_fi';
111
+ case 'DE': return '_de';
112
+ case 'NL': return '_nl';
113
+ default: return '';
114
+ // xxx Mage::throwException(Mage::helper('kreditor')->__('Unsupported currency'));
115
+ }
116
+ }
117
+
118
+ public function isGerman() {
119
+ return $this->getMethod()->getShippingCountry() == 'DE';
120
+ }
121
+
122
+ public function isDutch() {
123
+ return $this->getMethod()->getShippingCountry() == 'NL';
124
+ }
125
+
126
+ public function showGenderOption() {
127
+ return ($this->isDutch() || $this->isGerman());
128
+ }
129
+
130
+ public function isTestMode() {
131
+ return (Mage::getStoreConfig('payment/kreditor_invoice/transaction_mode') == 'test');
132
+ }
133
+
134
+ }
app/code/local/Kreditor/Kreditor/Block/Form/Partpayment.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ ?>
31
+ <?php
32
+
33
+ class Kreditor_Kreditor_Block_Form_Partpayment extends Mage_Payment_Block_Form {
34
+ protected function _construct() {
35
+ parent::_construct();
36
+ $this->setTemplate('kreditor/form/partpayment.phtml');
37
+ }
38
+
39
+ public function getLogoSrc() {
40
+ return $this->getMethod()->getLogoUrl();
41
+ }
42
+
43
+ public function getPartpayOptions() {
44
+ return $this->getMethod()->getPayOptions(true);
45
+ }
46
+
47
+ public function getTermsUrl() {
48
+ $countryId = $this->getMethod()->getShippingCountry();
49
+
50
+ switch($countryId) {
51
+ case 'SE':
52
+ return 'https://online.klarna.com/account_se.yaws?eid=' . $this->getMethod()->getMerchantId();
53
+ case 'FI':
54
+ return 'https://online.klarna.com/account_fi.yaws?eid=' . $this->getMethod()->getMerchantId();
55
+ case 'NO':
56
+ return 'https://online.klarna.com/account_no.yaws?eid=' . $this->getMethod()->getMerchantId();
57
+ case 'DK':
58
+ return 'https://online.klarna.com/account_dk.yaws?eid=' . $this->getMethod()->getMerchantId();
59
+ case 'DE':
60
+ return 'https://online.klarna.com/account_de.yaws?eid=' . $this->getMethod()->getMerchantId();
61
+ case 'NL':
62
+ return 'http://klarna.com/pdf/kredietprospectus_klarna_account_juli_2010.pdf';
63
+ default: return '';
64
+ }
65
+ }
66
+
67
+ // xxx Currently the only one that we show the salary box for are danish customers
68
+ public function showSalaryBox() {
69
+
70
+ $checkout = Mage::getSingleton('checkout/session');
71
+ $grandTotal = $checkout->getQuote()->getGrandTotal();
72
+ $currency = Mage::app()->getStore()->getCurrentCurrencyCode();
73
+ if($currency == "DKK" || ($grandTotal > Mage::getStoreConfig('advanced/klarna/yearly_sal_limit_no') && $currency == "NOK"))
74
+ return true;
75
+
76
+ return false;
77
+
78
+ }
79
+
80
+ public function addressUpdate() {
81
+ $checkout = Mage::getSingleton('checkout/session');
82
+ $currency = Mage::app()->getStore()->getCurrentCurrencyCode();
83
+ if($currency != 'SEK') return false;
84
+ return $this->getMethod()->getConfigData('update_address');
85
+ }
86
+
87
+ public function showMinamountText() {
88
+ $options = $this->getMethod()->getPayOptions();
89
+ if(isset($options[0])) $minamount = $options[0]->getMinamount();
90
+ else $minamount = 0;
91
+
92
+ if($minamount == 20000)
93
+ return true;
94
+ else return false;
95
+ }
96
+
97
+ public function getCurrency() {
98
+ return Mage::app()->getStore()->getCurrentCurrencyCode();
99
+ }
100
+
101
+ public function isGerman() {
102
+ return $this->getMethod()->getShippingCountry() == 'DE';
103
+ }
104
+
105
+ public function isDutch() {
106
+ return $this->getMethod()->getShippingCountry() == 'NL';
107
+ }
108
+
109
+ public function isTestMode() {
110
+ return (Mage::getStoreConfig('payment/kreditor_partpayment/transaction_mode') == 'test');
111
+ }
112
+
113
+ public function showGenderOption() {
114
+ return ($this->isDutch() || $this->isGerman());
115
+ }
116
+ }
app/code/local/Kreditor/Kreditor/Block/Info/Invoice.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ ?>
31
+ <?php
32
+
33
+ class Kreditor_Kreditor_Block_Info_Invoice extends Mage_Payment_Block_Info {
34
+
35
+ protected function _construct() {
36
+ parent::_construct();
37
+ $this->setTemplate('kreditor/info/invoice.phtml');
38
+ }
39
+
40
+ public function toPdf() {
41
+ $this->setTemplate('payment/info/pdf/purchaseorder.phtml');
42
+ return $this->toHtml();
43
+ }
44
+
45
+ public function getLogoSrc() {
46
+ return $this->getMethod()->getLogoUrl();
47
+ }
48
+
49
+ public function getInvoiceFee() {
50
+ return $this->getMethod()->_getInvoiceFee();
51
+ }
52
+
53
+ public function getKreditorPno() {
54
+ return $this->getInfo()->getKreditorPno();
55
+ }
56
+
57
+ }
app/code/local/Kreditor/Kreditor/Block/Info/Partpayment.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ ?>
31
+ <?php
32
+
33
+ class Kreditor_Kreditor_Block_Info_Partpayment extends Mage_Payment_Block_Info {
34
+
35
+ protected function _construct() {
36
+ parent::_construct();
37
+ $this->setTemplate('kreditor/info/partpayment.phtml');
38
+ }
39
+
40
+ public function getLogoSrc() {
41
+ return $this->getMethod()->getLogoUrl();
42
+ }
43
+
44
+ public function getKreditorPno() {
45
+ return $this->getInfo()->getKreditorPno();
46
+ }
47
+
48
+ public function getPayoption() {
49
+ $pclassid = $this->getInfo()->getKreditorPayopt();
50
+ $results = $this->getMethod()->getPayOptions();
51
+ foreach($results as $pclassitem) {
52
+ if($pclassitem->getPclassId() == $pclassid)
53
+ return $pclassitem;
54
+ }
55
+ return null;
56
+ }
57
+ }
app/code/local/Kreditor/Kreditor/Block/Product/Price.php ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ ?>
31
+ <?php
32
+ class Kreditor_Kreditor_Block_Product_Price extends Mage_Catalog_Block_Product_Price
33
+ {
34
+ // xxx Override toHtml and append our own Html
35
+ protected function _toHtml()
36
+ {
37
+ if($this->getTemplate() == "catalog/product/price.phtml")
38
+ {
39
+
40
+ $curr = Mage::app()->getStore()-> getCurrentCurrencyCode();
41
+ $tcpc = 0;
42
+
43
+ switch(strtolower($curr))
44
+ {
45
+ case 'sek':
46
+ $lang = "se";
47
+ $klarna_curr = 0;
48
+ $curr_sign = " kr";
49
+ $country = 209;
50
+ break;
51
+ case 'nok':
52
+ $klarna_curr = 1;
53
+ $lang = "no";
54
+ $curr_sign = " kr";
55
+ $country = 164;
56
+ break;
57
+ case 'eur':
58
+ if(Mage::app()->getLocale()->getLocaleCode() == "de_DE") {
59
+ $klarna_curr = 2;
60
+ $lang = "de";
61
+ $curr_sign = " &euro;";
62
+ $country = 81;
63
+ } elseif(Mage::app()->getLocale()->getLocaleCode() == "nl_NL") {
64
+ $klarna_curr = 2;
65
+ $lang = "nl";
66
+ $curr_sign = " &euro;";
67
+ $country = 154;
68
+ } else {
69
+ $klarna_curr = 2;
70
+ $lang = "fi";
71
+ $curr_sign = " &euro;";
72
+ $country = 73;
73
+ }
74
+ break;
75
+ case 'dkk':
76
+ $klarna_curr = 3;
77
+ $lang = "dk";
78
+ $curr_sign = " kr";
79
+ $country = 59;
80
+ break;
81
+ default:
82
+ $lang = "se";
83
+ $curr_sign = " kr";
84
+ $country = 209;
85
+ break;
86
+ }
87
+
88
+ $pclass = $this->GetKontoPclass($country);
89
+
90
+ // xxx If we get -1 we do not have any konto pclass for this currency
91
+ if(!is_object($pclass) || (int)Mage::getStoreConfig('payment/kreditor_partpayment/active') == 0)
92
+ return parent::_toHtml();
93
+
94
+
95
+
96
+ $base_currency = Mage::app()->getStore()->getBaseCurrencyCode();
97
+ $convert = ($base_currency != $curr);
98
+
99
+ $rate = 1;
100
+
101
+
102
+ if($convert)
103
+ {
104
+ $cCurr = Mage::getModel('directory/currency');
105
+ $cCurr->load($base_currency);
106
+ $rate = $cCurr->getRate($curr);
107
+ }
108
+
109
+ $product = $this->getProduct();
110
+
111
+ $this->getApi()->calc_monthly_cost($product->getFinalPrice()*($product->getTaxPercent()/100+1)*$rate*100, $pclass->getPclassId(), 1, $country, $result);
112
+
113
+ // Only calculate the total credit purchase cost for Norway
114
+ if($lang == 'no') {
115
+ $tcpc = $this->getApi()->total_credit_purchase_cost($product->getFinalPrice()*($product->getTaxPercent()/100+1)*$rate*100, $pclass->getInterest()/100, $pclass->getHandlingfee(), $pclass->getMinamount(), $pclass->getMonths(), $pclass->getStartfee(), $pclass->getType() == 1);
116
+ $tcpc = array('tcpc' => $tcpc, 'apr' => 0);
117
+ }
118
+
119
+ // xxx If we are at product page and already have created the price block we do not want to do that again
120
+ if($this->getLayout()->getBlock('klarna_price_block') && Mage::app()->getFrontController()->getRequest()->getRouteName() == "catalog")
121
+ {
122
+ return parent::_toHtml();
123
+ }
124
+ else if(Mage::app()->getFrontController()->getRequest()->getRouteName() == "catalog" && !(strstr(strtolower(Mage::app()->getFrontController()->getRequest()->getRequestUri()), "/category/view/")))
125
+ {
126
+ $html = parent::_toHtml() . $this->getLayout()->createBlock('core/template', 'klarna_price_block')->setTemplate('kreditor/product/price.phtml')->setData('monthlycost', round(ceil($result/100)) . $curr_sign)->setData('lang', $lang)->setData("sum", $product->getFinalPrice()*($product->getTaxPercent()/100+1)*$rate*100)->setData('total_credit_purchase_cost', $tcpc)->toHtml();
127
+ }
128
+ else
129
+ $html = parent::_toHtml() . $this->getLayout()->createBlock('core/template', chr(rand(97,122)).chr(rand(97,122)).chr(rand(97,122)).chr(rand(97,122)).chr(rand(97,122)).chr(rand(97,122)).chr(rand(97,122)))->setTemplate('kreditor/product/price.phtml')->setData('monthlycost', round(ceil($result/100)) . $curr_sign)->setData('lang', $lang)->setData("sum", $product->getFinalPrice()*($product->getTaxPercent()/100+1)*$rate*100)->toHtml();
130
+
131
+ return $html;
132
+ }
133
+ else
134
+ return parent::_toHtml();
135
+ }
136
+
137
+ private function GetKontoPclass($cc)
138
+ {
139
+ $pclassModel = Mage::getModel('kreditor/api_pclass');
140
+ $pclassCollection = $pclassModel->getCollection()->addCountryFilter($cc);
141
+
142
+ $pclass = -1;
143
+
144
+ foreach($pclassCollection as $pclassdata)
145
+ {
146
+ if($pclassdata->getType() == 1)
147
+ {
148
+ $pclass = $pclassdata;
149
+ break;
150
+ }
151
+ }
152
+
153
+ return $pclass;
154
+ }
155
+
156
+ private function getApi()
157
+ {
158
+ $api = Mage::getSingleton('kreditor/api_kreditor');
159
+ $api->setMerchantId(Mage::getStoreConfig('payment/kreditor_partpayment/merchant_id'));
160
+ $api->setSecurityKey(Mage::getStoreConfig('payment/kreditor_partpayment/security_key'));
161
+ $api->setTransactionMode(Mage::getStoreConfig('payment/kreditor_partpayment/security_key'));
162
+
163
+ return $api;
164
+
165
+
166
+ }
167
+
168
+ }
169
+ ?>
app/code/local/Kreditor/Kreditor/Block/Sales/Order/Email/Invoice/Items.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ ?>
31
+ <?php
32
+
33
+
34
+ class Kreditor_Kreditor_Block_Sales_Order_Email_Invoice_Items extends Mage_Sales_Block_Order_Email_Invoice_Items
35
+ {
36
+
37
+ protected function _toHtml()
38
+ {
39
+ // xxx Set the template to our own
40
+ $this->getLayout()->getBlock('items')->setTemplate("kreditor/order/email_invoice_items.phtml");
41
+ return parent::_toHtml();
42
+ }
43
+
44
+ }
app/code/local/Kreditor/Kreditor/Block/Sales/Order/Email/Items.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ ?>
31
+ <?php
32
+
33
+ class Kreditor_Kreditor_Block_Sales_Order_Email_Items extends Mage_Sales_Block_Order_Email_Items
34
+ {
35
+
36
+ protected function _toHtml()
37
+ {
38
+ // xxx Set the template to our own
39
+ $this->getLayout()->getBlock('items')->setTemplate("kreditor/order/email_items.phtml");
40
+ return parent::_toHtml();
41
+ }
42
+
43
+ }
app/code/local/Kreditor/Kreditor/Block/Sales/Order/Invoice/Items.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ ?>
31
+ <?php
32
+
33
+ class Kreditor_Kreditor_Block_Sales_Order_Invoice_Items extends Mage_Sales_Block_Order_Invoice_Items
34
+ {
35
+
36
+ protected function _toHtml()
37
+ {
38
+ // xxx Set the template to our own
39
+ $this->getLayout()->getBlock('invoice_items')->setTemplate("kreditor/order/invoice_items.phtml");
40
+ return parent::_toHtml();
41
+ }
42
+
43
+ }
app/code/local/Kreditor/Kreditor/Block/Sales/Order/Items.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ ?>
31
+ <?php
32
+
33
+ class Kreditor_Kreditor_Block_Sales_Order_Items extends Mage_Sales_Block_Order_Items
34
+ {
35
+
36
+ protected function _toHtml()
37
+ {
38
+ // xxx Set the template to our own
39
+ $this->getLayout()->getBlock('order_items')->setTemplate("kreditor/order/items.phtml");
40
+ return parent::_toHtml();
41
+ }
42
+
43
+ }
app/code/local/Kreditor/Kreditor/Block/Sales/Order/Print.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ ?>
31
+
32
+ <?php
33
+
34
+ class Kreditor_Kreditor_Block_Sales_Order_Print extends Mage_Sales_Block_Order_Print
35
+ {
36
+ protected function _toHtml()
37
+ {
38
+ // xxx Set the template to our own
39
+ $this->getLayout()->getBlock('sales.order.print')->setTemplate("kreditor/order/print_order.phtml");
40
+ return parent::_toHtml();
41
+ }
42
+
43
+ }
44
+
app/code/local/Kreditor/Kreditor/Block/Sales/Order/Print/Invoice.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ ?>
31
+ <?php
32
+
33
+ class Kreditor_Kreditor_Block_Sales_Order_Print_Invoice extends Mage_Sales_Block_Order_Print_Invoice
34
+ {
35
+
36
+ protected function _toHtml()
37
+ {
38
+ // xxx Set the template to our own
39
+ $this->getLayout()->getBlock('sales.order.print.invoice')->setTemplate("kreditor/order/print_invoice.phtml");
40
+ return parent::_toHtml();
41
+ }
42
+ }
43
+
app/code/local/Kreditor/Kreditor/Helper/Data.php ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_Helper_Data extends Mage_Payment_Helper_Data {
32
+ const XML_PATH_PAYMENT_METHODS = 'kreditor';
33
+
34
+ //xxx Calculate the handling and shipping vat
35
+ public function calculateShippingAndHandlingVAT($order)
36
+ {
37
+ $products = $order->getAllItems();
38
+ $handlingvat = 0;
39
+ $tot_inc_vat = 0;
40
+ $tot_excl_vat = 0;
41
+
42
+ foreach($products as $p)
43
+ {
44
+ if($p->getProductType() == 'simple' && (!$p->getParentItemId() && !$p->getQuoteParentItemId())) {
45
+ $tot_inc_vat += ($p->getRowTotal() + $p->getTaxAmount());
46
+ $tot_excl_vat += $p->getRowTotal();
47
+ } elseif($p->getProductType() != 'simple') {
48
+ $tot_inc_vat += ($p->getRowTotal() + $p->getTaxAmount());
49
+ $tot_excl_vat += $p->getRowTotal();
50
+ }
51
+ }
52
+
53
+ if($tot_excl_vat > 0)
54
+ $handlingvat = (round($tot_inc_vat/$tot_excl_vat, 6)-1)*100;
55
+ else
56
+ $handlingvat = 0;
57
+
58
+ return array("TaxPercent" => $handlingvat);
59
+
60
+ }
61
+
62
+ // xxx This method simply returns the correct invoice fee
63
+ public function getInvoiceFee($t)
64
+ {
65
+ $temp = Mage::getStoreConfig('payment/kreditor_invoice/invoice_fee_' . strtolower($t->getShippingAddress()->getCountryId()));
66
+
67
+ return $temp;
68
+ }
69
+
70
+ // xxx This method returns the handling VAT for other countries than sweden
71
+ public function getHandlingVAT($t)
72
+ {
73
+ switch($t->getShippingAddress()->getCountryId())
74
+ {
75
+ case 'NO':
76
+ return Mage::getStoreConfig('payment/kreditor_invoice/invoice_fee_' . strtolower($t->getShippingAddress()->getCountryId()) . '_vat');
77
+ case 'DK':
78
+ return Mage::getStoreConfig('payment/kreditor_invoice/invoice_fee_' . strtolower($t->getShippingAddress()->getCountryId()) . '_vat');
79
+ case 'FI':
80
+ return Mage::getStoreConfig('payment/kreditor_invoice/invoice_fee_' . strtolower($t->getShippingAddress()->getCountryId()) . '_vat');
81
+ case 'DE':
82
+ return Mage::getStoreConfig('payment/kreditor_invoice/invoice_fee_' . strtolower($t->getShippingAddress()->getCountryId()) . '_vat');
83
+ case 'NL':
84
+ return Mage::getStoreConfig('payment/kreditor_invoice/invoice_fee_' . strtolower($t->getShippingAddress()->getCountryId()) . '_vat');
85
+ }
86
+ }
87
+
88
+ public function getUpdateValues($t)
89
+ {
90
+ return array();
91
+ }
92
+
93
+ public function round_up($x, $p = 0) {
94
+ if(strstr($x, '.'))
95
+ {
96
+ $x = trim($x);
97
+ $data = explode(".",$x);
98
+ if(substr($data[1],$p,1) >= "5")
99
+ {
100
+ $i=0;
101
+ $addString = "5";
102
+ while($i < $p)
103
+ {
104
+ $addString = "0" . $addString;
105
+ $i++;
106
+ }//end while.
107
+ $addString = "." . $addString;
108
+ $sum = bcadd($data[0] . "." . $data[1],$addString,$p+1);
109
+ $sumData = explode(".",$sum);
110
+ return $sumData[0] . "." . substr($sumData[1],0,$p);
111
+ }
112
+ else
113
+ {
114
+ return $data[0] . "." . substr($data[1],0,$p);
115
+ }
116
+ } else
117
+ return $x;
118
+ }
119
+
120
+ public function getStreetParts($address) {
121
+
122
+ $numbers = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
123
+ $characters = array('-', '/', ' ', '#', '.', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
124
+ $specialchars = array('-', '/', ' ', '#', '.');
125
+
126
+ $numpos = $this->strpos_arr($address,$numbers,2); //Where do the numbers start? Allow for leading numbers
127
+ $streetname = substr($address, 0, $numpos); //Get the streetname by splitting off the from the start of the numbers
128
+ $streetname = trim($streetname); //Strip off spaces at the end
129
+
130
+ $numberpart = substr($address, $numpos); //Get the housenumber+extension
131
+ $numberpart = trim($numberpart); //and strip off spaces
132
+
133
+ $extpos = $this->strpos_arr($numberpart, $characters, 0); //Get the start position of the extension
134
+ if ($extpos != '') { //See if there is one, if so
135
+ $housenumber = substr($numberpart, 0, $extpos); //get the housenumber
136
+ $houseextension = substr($numberpart, $extpos); // and the extension
137
+ $houseextension = str_replace ($specialchars, '', $houseextension); // and strip special characters from it
138
+ }
139
+ else $housenumber = $numberpart;
140
+
141
+ return array('street' => $streetname, 'house_number' => $housenumber, 'house_extension' => $houseextension);
142
+
143
+
144
+ }
145
+
146
+ function strpos_arr($haystack, $needle, $where) {
147
+ $defpos = 10000;
148
+ if(!is_array($needle)) $needle = array($needle);
149
+ foreach($needle as $what) {
150
+ if(($pos = strpos($haystack, $what, $where))!==false) {
151
+ if ($pos < $defpos) $defpos = $pos;
152
+ }
153
+ }
154
+ return $defpos;
155
+ exit;
156
+ }
157
+
158
+ function replace_non_klarna_characters($input) {
159
+
160
+ $separators = array('/','.',"_",',',':',';', ' ', '-', '\\');
161
+
162
+ return str_replace($separators, '', $input);
163
+
164
+ }
165
+
166
+
167
+ }
app/code/local/Kreditor/Kreditor/Model/Api/Kreditor.php ADDED
@@ -0,0 +1,899 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+
32
+
33
+ $_strictStandards = error_reporting(E_ALL);
34
+ require_once dirname(__FILE__) . '/kreditor_no_pear.php';
35
+ error_reporting($_strictStandards);
36
+
37
+ class Kreditor_Kreditor_Model_Api_Kreditor {
38
+
39
+ protected $_merchantId = '';
40
+ protected $_secretKey = '';
41
+ protected $_transactionMode = 'live';
42
+
43
+ private $params = array();
44
+
45
+ private $helper = null;
46
+
47
+ private $payment = null;
48
+ private $country;
49
+ private $currency;
50
+ private $language;
51
+ private $pnoEncoding;
52
+ private $handlingVAT;
53
+ private $handlingFee;
54
+
55
+ private $KRED_ANNUITY_PCLASS = 0;
56
+ private $KRED_DIVISOR_PCLASS = 1;
57
+
58
+ private $KRED_ACTUAL_COST = 1;
59
+ private $KRED_LIMIT_COST = 0;
60
+
61
+ protected $accuracy = 0.01;
62
+
63
+ function __construct() {
64
+ $this->helper = Mage::helper('kreditor');
65
+ }
66
+
67
+ private function getCountrySpecificData($countryId) {
68
+ global $KRED_ISO3166_SE, $KRED_ISO3166_NO,
69
+ $KRED_ISO3166_DK, $KRED_ISO3166_FI,
70
+ $KRED_ISO3166_DE, $KRED_ISO3166_NL,
71
+ $KRED_ISO639_SV, $KRED_ISO639_NB,
72
+ $KRED_ISO639_DA, $KRED_ISO639_FI,
73
+ $KRED_ISO639_DE, $KRED_ISO639_NL;
74
+
75
+ switch($countryId) {
76
+ case 'SE': return array('country' => $KRED_ISO3166_SE, 'language' => $KRED_ISO639_SV, 'pnoencoding' => 2);
77
+ case 'NO': return array('country' => $KRED_ISO3166_NO, 'language' => $KRED_ISO639_NB, 'pnoencoding' => 3);
78
+ case 'DK': return array('country' => $KRED_ISO3166_DK, 'language' => $KRED_ISO639_DA, 'pnoencoding' => 5);
79
+ case 'FI': return array('country' => $KRED_ISO3166_FI, 'language' => $KRED_ISO639_FI, 'pnoencoding' => 4);
80
+ case 'DE': return array('country' => $KRED_ISO3166_DE, 'language' => $KRED_ISO639_DE, 'pnoencoding' => 6);
81
+ case 'NL': return array('country' => $KRED_ISO3166_NL, 'language' => $KRED_ISO639_NL, 'pnoencoding' => 7);
82
+ default:
83
+ Mage::throwException(Mage::helper('kreditor')->__("Selected payment type is not allowed for billing country."));
84
+ }
85
+ }
86
+
87
+ private function getCurrency($occ) {
88
+ global $KRED_SEK, $KRED_NOK, $KRED_DKK, $KRED_EUR;
89
+
90
+ if($occ == 'SEK') { return $KRED_SEK; }
91
+ if($occ == 'NOK') { return $KRED_NOK; }
92
+ if($occ == 'DKK') { return $KRED_DKK; }
93
+ if($occ == 'EUR') { return $KRED_EUR; }
94
+ else {
95
+ Mage::throwException(Mage::helper('kreditor')->__('Selected currency code is not compatible with Kreditor'));
96
+ }
97
+ }
98
+
99
+ private function checkCurrency($currency, $country) {
100
+ if($currency == 'SEK' && $country != 'SE')
101
+ Mage::throwException(Mage::helper('kreditor')->__('This currency is not compatible with your country.'));
102
+ if($currency == 'NOK' && $country != 'NO')
103
+ Mage::throwException(Mage::helper('kreditor')->__('This currency is not compatible with your country.'));
104
+ if($currency == 'DKK' && $country != 'DK')
105
+ Mage::throwException(Mage::helper('kreditor')->__('This currency is not compatible with your country.'));
106
+ if($currency == 'EUR' && ($country != 'FI' && $country != 'NL' && $country != 'DE'))
107
+ Mage::throwException(Mage::helper('kreditor')->__('This currency is not compatible with your country.'));
108
+ }
109
+
110
+ public function setMerchantId($id) {
111
+ $this->_merchantId = $id;
112
+ }
113
+
114
+ public function setSecurityKey($key) {
115
+ $this->_secretKey = $key;
116
+ }
117
+
118
+ public function setTransactionMode($mode) {
119
+ $this->_transactionMode = $mode;
120
+ }
121
+
122
+ public static function convertKreditorCountryCode($ccode) {
123
+ global $KRED_ISO3166_SE, $KRED_ISO3166_NO,
124
+ $KRED_ISO3166_DK, $KRED_ISO3166_FI, $KRED_ISO3166_DE, $KRED_ISO3166_NL;
125
+ switch($ccode) {
126
+ case $KRED_ISO3166_SE: return 'SE';
127
+ case $KRED_ISO3166_NO: return 'NO';
128
+ case $KRED_ISO3166_DK: return 'DK';
129
+ case $KRED_ISO3166_FI: return 'FI';
130
+ case $KRED_ISO3166_DE: return 'DE';
131
+ case $KRED_ISO3166_NL: return 'NL';
132
+ default: Mage::throwException(Mage::helper('kreditor')->__('The country code is either invalid or not permitted'));
133
+ }
134
+ }
135
+
136
+ public function getAddressFromKreditor($pnoNumber, $countryId) {
137
+
138
+ $countryInfo = $this->getCountrySpecificData($countryId);
139
+ $_strictStandards = error_reporting(E_ALL);
140
+
141
+ $address = get_addresses($this->_merchantId, $pnoNumber,
142
+ $this->_secretKey, $countryInfo['pnoencoding'],
143
+ 1, $result);
144
+ error_reporting($_strictStandards);
145
+
146
+ return $result;
147
+ }
148
+
149
+ private function setCountrySpecificData() {
150
+ global $KRED_ISO3166_SE, $KRED_ISO3166_NO,
151
+ $KRED_ISO3166_DK, $KRED_ISO3166_FI,
152
+ $KRED_ISO3166_DE, $KRED_ISO3166_NL,
153
+ $KRED_ISO639_SV, $KRED_ISO639_NB,
154
+ $KRED_ISO639_DA, $KRED_ISO639_FI,
155
+ $KRED_ISO639_DE, $KRED_ISO639_NL,
156
+ $KRED_SEK, $KRED_NOK, $KRED_DKK, $KRED_EUR;
157
+
158
+ $order = $this->payment->getOrder();
159
+ $countryId = $order->getShippingAddress()->getCountryId();
160
+ switch($countryId) {
161
+ case 'SE':
162
+ $this->country = $KRED_ISO3166_SE;
163
+ $this->language = $KRED_ISO639_SV;
164
+ $this->currency = $KRED_SEK;
165
+ $this->pnoEncoding = 2;
166
+ $this->handlingVAT = 25;
167
+ break;
168
+ case 'NO':
169
+ $this->country = $KRED_ISO3166_NO;
170
+ $this->language = $KRED_ISO639_NB;
171
+ $this->currency = $KRED_NOK;
172
+ $this->pnoEncoding = 3;
173
+ $this->handlingVAT = Mage::getStoreConfig('payment/kreditor_invoice/invoice_fee_' . strtolower($countryId) . '_vat');
174
+ break;
175
+ case 'DK':
176
+ $this->country = $KRED_ISO3166_DK;
177
+ $this->language = $KRED_ISO639_DA;
178
+ $this->currency = $KRED_DKK;
179
+ $this->pnoEncoding = 5;
180
+ $this->handlingVAT = Mage::getStoreConfig('payment/kreditor_invoice/invoice_fee_' . strtolower($countryId) . '_vat');
181
+ break;
182
+ case 'FI':
183
+ $this->country = $KRED_ISO3166_FI;
184
+ $this->language = $KRED_ISO639_FI;
185
+ $this->currency = $KRED_EUR;
186
+ $this->pnoEncoding = 4;
187
+ $this->handlingVAT = Mage::getStoreConfig('payment/kreditor_invoice/invoice_fee_' . strtolower($countryId) . '_vat');
188
+ break;
189
+ case 'DE':
190
+ $this->country = $KRED_ISO3166_DE;
191
+ $this->language = $KRED_ISO639_DE;
192
+ $this->currency = $KRED_EUR;
193
+ $this->pnoEncoding = 6;
194
+ $this->handlingVAT = Mage::getStoreConfig('payment/kreditor_invoice/invoice_fee_' . strtolower($countryId) . '_vat');
195
+ break;
196
+ case 'NL':
197
+ $this->country = $KRED_ISO3166_NL;
198
+ $this->language = $KRED_ISO639_NL;
199
+ $this->currency = $KRED_EUR;
200
+ $this->pnoEncoding = 7;
201
+ $this->handlingVAT = Mage::getStoreConfig('payment/kreditor_invoice/invoice_fee_' . strtolower($countryId) . '_vat');
202
+ break;
203
+ default:
204
+ Mage::throwException(Mage::helper('kreditor')->__("Selected payment type is not allowed for billing country."));
205
+ }
206
+ }
207
+
208
+ private function setHandlingFee($fee) {
209
+ $handlingFee = trim($fee);
210
+ if(empty($handlingFee)) $handlingFee = 0;
211
+
212
+ $this->handlingFee = $handlingFee * 100;;
213
+ }
214
+ // xxx
215
+ private function setAddress() {
216
+ $order = $this->payment->getOrder();
217
+ $billingAdress = $order->getShippingAddress();
218
+
219
+ $street = $billingAdress->getStreet();
220
+ $addr = mk_addr(null, ($this->payment->getKreditorStreet() != null ? utf8_decode($this->payment->getKreditorStreet()) : utf8_decode($street[0])),
221
+ $billingAdress->getPostcode(),
222
+ utf8_decode($billingAdress->getCity()),
223
+ $this->country,
224
+ '',
225
+ $billingAdress->getTelephone(),
226
+ $order->getCustomerEmail(),
227
+ $this->payment->getKreditorHouseNumber(),
228
+ $this->payment->getKreditorHouseExtension());
229
+
230
+ if($this->payment->getIsCompany() === true) {
231
+ $this->params['lname'] = utf8_decode($billingAdress->getCompany());
232
+ } else if($this->payment->getIsCompany() !== false) {
233
+ $this->params['lname'] = utf8_decode($billingAdress->getLastname());
234
+ } else {
235
+ // we are not allowed to run get_address for finland
236
+ // so if company field is set then treat it as a company otherwise private
237
+ $company = $billingAdress->getCompany();
238
+ if(empty($company)) $this->params['lname'] = utf8_decode($billingAdress->getLastname());
239
+ else $this->params['lname'] = utf8_decode($billingAdress->getCompany());
240
+ }
241
+
242
+ $this->params['fname'] = utf8_decode($billingAdress->getFirstname());
243
+ $this->params['addr'] = $addr;
244
+ }
245
+
246
+ private function setGoodsList() {
247
+
248
+ $priceincVAT = Mage::helper('tax')->priceIncludesTax();
249
+ $shippingincVAT = Mage::helper('tax')->shippingPriceIncludesTax();
250
+
251
+ $apply_tax_after_discount = Mage::helper('tax')->applyTaxAfterDiscount();
252
+ $apply_discount_inc_vat = Mage::helper('tax')->discountTax();
253
+
254
+ $discount_amount = 0;
255
+
256
+
257
+
258
+ $order = $this->payment->getOrder();
259
+ $shippingtax = 0;
260
+ $products = $order->getAllItems();
261
+
262
+ $goodsList = array();
263
+
264
+ foreach($products as $p) {
265
+
266
+ $name = null;
267
+ $sku = null;
268
+ // xxx Add the custom options to the product name that are sent to Klarna.
269
+ $arr = $p->getProductOptions();
270
+ $optionstring = "";
271
+ if(isset($arr['options']))
272
+ {
273
+ foreach($arr['options'] as $option)
274
+ {
275
+ $optionstring .= ', ' . $option['label'] . ' - ' . $option['value'];
276
+ }
277
+ }
278
+
279
+ if($p->getProductType() == 'simple' && !$p->getQuoteParentItemId()) {
280
+ $goodsList[] = mk_goods_flags($p->getQtyOrdered(),
281
+ ($p->getSku()),
282
+ utf8_decode($p->getName() . ' ' . $optionstring),
283
+ ($p->getPrice()* ($p->getTaxPercent()/100+1)) * 100,
284
+ $p->getTaxPercent(),
285
+ 0,
286
+ 32); // $KRED_INC_VAT
287
+
288
+ } elseif($p->getProductType() == "configurable") {
289
+
290
+
291
+ if($p->getHasChildren()) {
292
+ $child = $p->getChildrenItems();
293
+ $child = $child[0];
294
+ $sku = $child->getSku();
295
+ $name = $child->getName();
296
+ }
297
+
298
+ $goodsList[] = mk_goods_flags($p->getQtyOrdered(),
299
+ (($sku != null ? $sku : $p->getSku())),
300
+ utf8_decode(($name != null ? $name : $p->getName()) . ' ' . $optionstring),
301
+ ($p->getPrice()* ($p->getTaxPercent()/100+1)) * 100,
302
+ $p->getTaxPercent(),
303
+ 0,
304
+ 32); // $KRED_INC_VAT
305
+
306
+
307
+ } elseif($p->getProductType() == 'bundle') {
308
+ $children = array();
309
+ $vat = (round(($p->getPrice()+$p->getTaxAmount())/$p->getPrice(), 6)-1)*100/$p->getQtyOrdered();
310
+
311
+ foreach($p->getChildrenItems() as $child) {
312
+ $children[] = mk_goods_flags($child->getQtyOrdered(),
313
+ ($child->getSku()),
314
+ utf8_decode($child->getName() . ' ' . $optionstring),
315
+ 0,
316
+ 0,
317
+ 0,
318
+ 32); // $KRED_INC_VAT
319
+
320
+ if($child->getDiscountAmount() > 0 && $apply_tax_after_discount) {
321
+ $children[] = mk_goods_flags(1,
322
+ $child->getSku(),
323
+ utf8_decode($child->getName()),
324
+ ($child->getDiscountAmount()) * -1 * 100,
325
+ 0,
326
+ 0,32);
327
+
328
+ }
329
+ }
330
+ $goodsList[] = mk_goods_flags($p->getQtyOrdered(),
331
+ ($p->getSku()),
332
+ utf8_decode($p->getName() . ' ' . $optionstring),
333
+ ($p->getPrice()+($p->getTaxAmount()/$p->getQtyOrdered()))*100,
334
+ $vat,
335
+ 0,
336
+ 32); // $KRED_INC_VAT
337
+
338
+ $goodsList = array_merge($goodsList, $children);
339
+
340
+
341
+ } elseif($p->getProductType() != 'simple') {
342
+ $goodsList[] = mk_goods_flags($p->getQtyOrdered(),
343
+ ($p->getSku()),
344
+ utf8_decode($p->getName() . ' ' . $optionstring),
345
+ ($p->getPrice()* ($p->getTaxPercent()/100+1)) * 100,
346
+ $p->getTaxPercent(),
347
+ 0,
348
+ 32); // $KRED_INC_VAT
349
+ }
350
+
351
+ // xxx If there is any discounts, substract those
352
+ if($p->getDiscountAmount() != 0)
353
+ {
354
+ if($apply_tax_after_discount) {
355
+
356
+ if(!($p->getProductType() == 'simple' && $p->getQuoteParentItemId())) {
357
+ $goodsList[] = mk_goods_flags(1,
358
+ $p->getSku(),
359
+ utf8_decode($p->getName()),
360
+ ($p->getDiscountAmount()) * ($p->getTaxPercent()/100+1) * -1 * 100,
361
+ $p->getTaxPercent(),
362
+ 0,32);
363
+ $discount_amount += $p->getDiscountAmount();
364
+ }
365
+ } else {
366
+ $goodsList[] = mk_goods_flags(1,
367
+ $p->getSku(),
368
+ utf8_decode($p->getName()),
369
+ ($p->getDiscountAmount()) * -1 * 100,
370
+ 0,
371
+ 0,32);
372
+ }
373
+ }
374
+ }
375
+
376
+ // xxx If we are creating invoices for sweden we need to make some adjustment
377
+ // to the taxes for shipping and handling as those should be calculated based on
378
+ // the taxes for the items in the cart.
379
+ if($this->country == 209)
380
+ {
381
+ // xxx Get the new Shipping and handling VAT
382
+ $tax = $this->helper->calculateShippingAndHandlingVAT($this->payment->getOrder());
383
+ $this->handlingVAT = $tax['TaxPercent'];
384
+ $shippingtax = $tax['TaxPercent'];
385
+ }
386
+ else
387
+ {
388
+ if($order->getShippingAmount()>0)
389
+ {
390
+ $shippingtax = ($order->getShippingTaxAmount()/$order->getShippingAmount())*100;
391
+ }
392
+ else
393
+ {
394
+ $shippingtax = 0;
395
+ }
396
+ }
397
+ // add handling fee
398
+ $goodsList[] = mk_goods_flags(1, null,
399
+ html_entity_decode(Mage::helper('kreditor')->__('Handling fee')),
400
+ $this->handlingFee,
401
+ $this->handlingVAT,
402
+ 0,
403
+ 16 + 32); // $KRED_IS_HANDLING + $KRED_INC_VAT
404
+
405
+ // add shipping fee
406
+ $goodsList[] = mk_goods_flags(1, null,
407
+ html_entity_decode(Mage::helper('kreditor')->__('Shipping fee')),
408
+ ($order->getShippingAmount() + $order->getShippingTaxAmount()) * 100,
409
+ ($order->getShippingTaxAmount() == 0 ? 0 : $shippingtax),
410
+ 0,
411
+ 16 + 32); // $KRED_IS_HANDLING + $KRED_INC_VAT
412
+
413
+ $this->params['handlingfee'] = 0;
414
+ $this->params['shipmentfee'] = 0;
415
+ $this->params['shipmenttype'] = 1; // $KRED_NORMAL_SHIPMENT
416
+ $this->params['goodsList'] = $goodsList;
417
+
418
+ }
419
+
420
+ public function tryAuthorize($paymentInfo) {
421
+
422
+ $this->payment = $paymentInfo['payment'];
423
+
424
+ $this->setHandlingFee(str_replace(',','.',$paymentInfo['invoicefee']));
425
+
426
+ $this->setCountrySpecificData();
427
+
428
+ $this->setGoodsList();
429
+
430
+
431
+ $this->setAddress();
432
+ $this->params['estoreOrderNo'] = $this->payment->getOrder()->getIncrementId();
433
+ $this->params['clientIp'] = $this->payment->getOrder()->getRemoteIp();
434
+ $this->params['flags'] = ($this->_transactionMode == 'test' ? 2 : 0); // 2 = $KRED_TEST_MODE
435
+ $this->params['currency'] = $this->currency;
436
+ $this->params['country'] = $this->country;
437
+ $this->params['language'] = $this->language;
438
+ $this->params['pno_encoding'] = $this->pnoEncoding;
439
+ $this->params['pno'] = $this->payment->getKreditorPno() . ($this->payment->getKreditorGender() != null ? $this->payment->getKreditorGender() : '');
440
+ $this->params['eid'] = $this->_merchantId;
441
+ $this->params['secret'] = $this->_secretKey;
442
+ $this->params['pclass'] = ($this->payment->getKreditorPayopt() ? $this->payment->getKreditorPayopt() : -1);
443
+ $this->params['ysalary'] = ($this->payment->getKreditorSalary() ? $this->payment->getKreditorSalary()*100 : 0);
444
+
445
+ $data = $this->params;
446
+
447
+ $_strictStandards = error_reporting(E_ALL);
448
+
449
+ $result = null;
450
+
451
+ $invoiceId = add_transaction($this->params['eid'], '', $this->params['secret'], $this->params['estoreOrderNo'], $this->params['goodsList'],
452
+ $this->params['shipmentfee'], $this->params['shipmenttype'], $this->params['handlingfee'],
453
+ $this->params['pno'], $this->params['fname'], $this->params['lname'],
454
+ $this->params['addr'], '', $this->params['clientIp'], '', $this->params['flags'],
455
+ '', '', '', $this->params['currency'], $this->params['country'],
456
+ $this->params['language'], $this->params['pno_encoding'],
457
+ $this->params['pclass'], $this->params['ysalary'], $result);
458
+
459
+
460
+ error_reporting($_strictStandards);
461
+
462
+ if($invoiceId != 0) {
463
+ Mage::throwException(utf8_encode($result));
464
+ }
465
+
466
+ return $result;
467
+ }
468
+
469
+ public function fetchPclasses() {
470
+ global $KRED_ISO3166_SE, $KRED_ISO3166_NO,
471
+ $KRED_ISO3166_DK, $KRED_ISO3166_FI,
472
+ $KRED_ISO3166_DE, $KRED_ISO3166_NL, $KRED_ISO639_SV, $KRED_ISO639_NB,
473
+ $KRED_ISO639_DA, $KRED_ISO639_FI, $KRED_ISO639_DE, $KRED_ISO639_NL, $KRED_SEK, $KRED_NOK, $KRED_DKK, $KRED_EUR;
474
+ $currencies = array(array($KRED_SEK, $KRED_ISO3166_SE, $KRED_ISO639_SV), array($KRED_NOK, $KRED_ISO3166_NO, $KRED_ISO639_NB), array($KRED_DKK, $KRED_ISO3166_DK, $KRED_ISO639_DA),
475
+ array($KRED_EUR, $KRED_ISO3166_FI, $KRED_ISO639_FI), array($KRED_EUR, $KRED_ISO3166_DE, $KRED_ISO639_DE), array($KRED_EUR, $KRED_ISO3166_NL, $KRED_ISO639_NL));
476
+ $pclasses = array();
477
+ foreach($currencies as $c) {
478
+ $pclasses[] = $this->getPclassesByCurrency($c);
479
+ }
480
+ return $pclasses;
481
+ }
482
+
483
+ /**
484
+ * @param string $currency Magento currency code. SEK, NOK etc
485
+ */
486
+ public function getPclassesByCurrency($currency) {
487
+ $_strictStandards = error_reporting(E_ALL);
488
+ $eid = $this->_merchantId;
489
+ //$currency = $this->getCurrency($currency);
490
+ our_settype_integer($eid);
491
+ $hash = invoice_digest($eid, $currency[0], $this->_secretKey);
492
+ $p = kred_call('get_pclasses', array($eid, $currency[0], $hash, $currency[1], $currency[2]), $result, $eid, $this->_secretKey);
493
+ error_reporting($_strictStandards);
494
+ if($p == 0) return $result;
495
+ else Mage::throwException(Mage::helper('kreditor')->__('Something went wrong in the communication to Kreditor. Please try again later.'));
496
+ }
497
+
498
+ public function periodicCost($totalCost, $months, $monthlyFee, $startFee, $rate) {
499
+ $_strictStandards = error_reporting(E_ALL);
500
+ $cost = periodic_cost2($totalCost, $months, $monthlyFee, $startFee, $rate);
501
+ error_reporting($_strictStandards);
502
+ return $cost;
503
+ }
504
+
505
+
506
+ /**
507
+ * Calculate monthly cost for orders with low total values
508
+ *
509
+ * @param int $sum The total sum in cents
510
+ * @param int $months Number of months from pclasses
511
+ * @param int $handlingfee Handling fee in cents
512
+ * @param int $rate Interest rate in %
513
+ * @param string $currency Currency identifier from Magento
514
+ * @return int Monthly cost in cents
515
+ */
516
+ public function calcMonthlyCostForLowOrders($sum, $months, $handlingfee, $rate, $country) {
517
+
518
+ if($months == 0)
519
+ return 0;
520
+
521
+ $ret = $this->monthly_cost($sum, $rate, $months, $handlingfee, 0, $country, $result);
522
+ if($ret < 0)
523
+ Mage::throwException(Mage::helper('kreditor')->__('A error occured. Please contact customer support.'));
524
+
525
+ return $result;
526
+ }
527
+
528
+ private function error($code) {
529
+ $countryId = $this->payment->getOrder()->getShippingAddress()->getCountryId();
530
+
531
+ switch($countryId) {
532
+ case 'SE':
533
+ return $this->strerror_se($code);
534
+ case 'NO':
535
+ return $this->strerror_no($code);
536
+ case 'DK':
537
+ return $this->strerror_dk($code);
538
+ case 'FI':
539
+ return $this->strerror_fi($code);
540
+ default:
541
+ return $this->strerror_en($code);
542
+ }
543
+ }
544
+
545
+ function monthly_cost($sum, $rate, $months, $monthsfee, $flags, $country, &$result)
546
+ {
547
+ global $KRED_ISO3166_SE, $KRED_ISO3166_NO, $KRED_ISO3166_DK, $KRED_ISO3166_FI, $KRED_ISO3166_DE, $KRED_ISO3166_NL, $KRED_EUR, $KRED_NOK, $KRED_SEK, $KRED_DKK;
548
+ if($rate < 100)
549
+ $rate = $rate*100;
550
+
551
+ switch ($country) {
552
+ case $KRED_ISO3166_SE:
553
+ $lowest_monthly_payment = 5000.00;
554
+ $currency = $KRED_SEK;
555
+ break;
556
+ case $KRED_ISO3166_NO:
557
+ $lowest_monthly_payment = 9500.00;
558
+ $currency = $KRED_NOK;
559
+ break;
560
+ case $KRED_ISO3166_FI:
561
+ $lowest_monthly_payment = 895.00;
562
+ $currency = $KRED_EUR;
563
+ break;
564
+ case $KRED_ISO3166_DK:
565
+ $lowest_monthly_payment = 8900.00;
566
+ $currency = $KRED_DKK;
567
+ break;
568
+ case $KRED_ISO3166_DE:
569
+ $lowest_monthly_payment = 695.00;
570
+ $currency = $KRED_EUR;
571
+ break;
572
+ case $KRED_ISO3166_NL:
573
+ $lowest_monthly_payment = 500.00;
574
+ $currency = $KRED_EUR;
575
+ break;
576
+ default:
577
+ return -2;
578
+ }
579
+
580
+ $average_interest_period = 45;
581
+ $calcRate = ($rate / 10000);
582
+
583
+ $interest_value = ($average_interest_period / 365.0) * $calcRate * $sum;
584
+ $periodic_cost = ($sum + $interest_value)/$months;
585
+
586
+ if ($flags == 1)
587
+ {
588
+ $result = $this->round_up($periodic_cost, $currency);
589
+ }
590
+ else if ($flags == 0)
591
+ {
592
+ $periodic_cost = $periodic_cost + $monthsfee;
593
+ if ($periodic_cost < $lowest_monthly_payment)
594
+ $result = round($lowest_monthly_payment, 0);
595
+ else
596
+ $result = $this->round_up($periodic_cost, $currency);
597
+ }
598
+ else
599
+ return -2;
600
+
601
+ return 0;
602
+ }
603
+
604
+ /*************************************************************************
605
+ * API: monthly_cost_new
606
+ *************************************************************************/
607
+ function calc_monthly_cost($sum, $pclass,
608
+ $flags, $country,
609
+ &$result){
610
+
611
+ $pclassModel = Mage::getModel('kreditor/api_pclass');
612
+ $pclassCollection = $pclassModel->getCollection();
613
+ $pclassCollection->addFieldToFilter('pclass_id', $pclass);
614
+
615
+ foreach($pclassCollection as $pclassdata)
616
+ {
617
+ $months = $pclassdata->getMonths();
618
+ $monthsfee = $pclassdata->getHandlingfee();
619
+
620
+ $rate = $pclassdata->getInterest();
621
+ $startfee = $pclassdata->getStartfee();
622
+ $type = $startfee == 0 ? 1 : 0;
623
+
624
+ if($months == 0) return 0;
625
+
626
+ return $this->monthly_cost_new2($sum, $rate, $months, $monthsfee, $startfee, $flags,
627
+ $country, $type, $result);
628
+ }
629
+
630
+
631
+
632
+ }
633
+
634
+ /*************************************************************************
635
+ * API: monthly_cost_new2
636
+ *************************************************************************/
637
+ public function monthly_cost_new2($sum, $rate, $months,
638
+ $monthsfee, $startfee,
639
+ $flags, $currency,
640
+ $type, &$result){
641
+
642
+ if($type == $this->KRED_ANNUITY_PCLASS){
643
+ return $this->periodic_cost_new($sum, $months, $monthsfee, $rate, $startfee,
644
+ $currency, $flags, $result);
645
+ }else if($type == $this->KRED_DIVISOR_PCLASS){
646
+
647
+ return $this->monthly_cost($sum, $rate, $months, $monthsfee, $flags, $currency,
648
+ $result);
649
+ }
650
+
651
+ return -1;
652
+ }
653
+
654
+ /*************************************************************************
655
+ * API: periodic_cost
656
+ *************************************************************************/
657
+ function periodic_cost_new($sum, $months, $monthfee,
658
+ $rate, $startfee, $currency, $flags, &$result){
659
+
660
+ if($rate > 100)
661
+ $rate /= 100;
662
+
663
+ if($flags == $this->KRED_ACTUAL_COST){
664
+ $credit_cost = $this->total_credit_purchase_cost($sum, $rate, 0, 0, $months, 0);
665
+ }else if($flags == $this->KRED_LIMIT_COST){
666
+ $credit_cost = $this->total_credit_purchase_cost($sum, $rate, $monthfee, 0, $months, $startfee);
667
+ }else{
668
+ $result = -2;
669
+ }
670
+ $result = ($credit_cost)/$months;
671
+ }
672
+
673
+ /*
674
+ * From Kreditor API 1.3.2
675
+ */
676
+ public function round_up($value, $curr) //value, currency
677
+ {
678
+ $result;
679
+ $divisor;
680
+
681
+ if ($curr == 2)
682
+ $divisor = 10;
683
+ else
684
+ $divisor = 100;
685
+
686
+ $result = $divisor * round((($divisor/2)+$value)/$divisor); //We want to roundup to closest integer.
687
+
688
+ return $result;
689
+ }
690
+
691
+ function midpoint ($a, $b)
692
+ {
693
+ return (($a+$b)/2);
694
+ }
695
+
696
+ function npv ($pval, $payarray, $rate, $fromdayone)
697
+ {
698
+ $month = $fromdayone;
699
+ foreach ($payarray as $payment)
700
+ {
701
+ $pval -= $payment / pow (1 + $rate/(12*100.0), $month++);
702
+ }
703
+ return ($pval);
704
+ }
705
+
706
+ function irr ($pval, $payarray, $fromdayone)
707
+ {
708
+
709
+
710
+ $low = 0.0;
711
+ $high = 100.0;
712
+ $lowval = npv ($pval, $payarray, $low, $fromdayone);
713
+ $highval = npv ($pval, $payarray, $high, $fromdayone);
714
+
715
+ // The sum of $payarray is smaller than $pval, impossible!
716
+ if ($lowval > 0.0)
717
+ {
718
+ return (-1);
719
+ }
720
+
721
+ // Standard divide and conquer.
722
+ do
723
+ {
724
+ $mid = midpoint ($low, $high);
725
+ $midval = npv ($pval, $payarray, $mid, $fromdayone);
726
+ if (abs($midval) < $this->accuracy)
727
+ {
728
+ //we are close enough
729
+ return ($mid);
730
+ }
731
+
732
+ if ($highval < 0.0)
733
+ {
734
+ // we are not in range, so double it
735
+ $low = $high;
736
+ $lowval = $highval;
737
+ $high *= 2;
738
+ $highval = npv ($pval, $payarray,
739
+ $high, $fromdayone);
740
+ } elseif ($midval >= 0.0)
741
+ {
742
+ // irr is between low and mid
743
+ $high = $mid;
744
+ $highval = $midval;
745
+ } else
746
+ {
747
+ // irr is between mid and high
748
+ $low = $mid;
749
+ $lowval = $midval;
750
+ }
751
+ } while ($high < 1000000);
752
+ // bad input, insanely high interest. APR will be INSANER!
753
+ return (-2);
754
+ }
755
+
756
+ function irr2apr ($irr)
757
+ {
758
+ return (100 * (pow (1 + $irr / (12 * 100.0), 12) - 1));
759
+ }
760
+
761
+ function fulpacc ($pval, $rate, $fee, $minpay, $payment, $months, $base = false)
762
+ {
763
+
764
+
765
+ $bal = $pval;
766
+ $payarray = array ();
767
+ while ( $months != 0 and $bal > $this->accuracy)
768
+ {
769
+ $interest = $bal * $rate / (100.0 * 12);
770
+ $newbal = $bal + $interest + $fee;
771
+
772
+ if ($minpay >= $newbal || $payment >= $newbal)
773
+ {
774
+
775
+ $payarray[] = $newbal;
776
+
777
+ return $payarray;
778
+ }
779
+
780
+ $newpay = max ($payment,
781
+ $minpay);
782
+ if ($base)
783
+ {
784
+ $newpay = max ($newpay,
785
+ $bal/24.0 + $fee + $interest);
786
+ }
787
+
788
+ $bal = $newbal - $newpay;
789
+ $payarray[] = $newpay;
790
+ $months -= 1;
791
+ }
792
+
793
+ return $payarray;
794
+ }
795
+
796
+ function annuity ($pval, $months, $rate)
797
+ {
798
+ if($rate <= 0)
799
+ return $pval/$months;
800
+
801
+ $p = $rate / (100.0*12);
802
+ return $pval * $p / (1 - pow((1+$p), -$months));
803
+ }
804
+
805
+ function fixed ($pval, $monthly, $rate, $fromdayone)
806
+ {
807
+ $p = $rate / (100.0*12);
808
+ $f = 1 + $p;
809
+ if ($fromdayone == 0)
810
+ {
811
+ if ( $f < $pval * $p / $monthly )
812
+ {
813
+ return -1;
814
+ }
815
+ // this might be wrong. check it.
816
+ return 1 - log($f - $pval * $p / $monthly) /
817
+ log($f);
818
+ } elseif ($fromdayone == 1)
819
+ {
820
+ if (1.0 < $pval * $p / $monthly )
821
+ {
822
+ return -1;
823
+ }
824
+ return -log(1.0 - $pval * $p / $monthly) /
825
+ log($f);
826
+ } else
827
+ {
828
+ return -2;
829
+ }
830
+ }
831
+
832
+ function apr_annuity ($pval, $months, $rate, $fee, $minpay)
833
+ {
834
+ $payment = annuity ($pval, $months, $rate) + $fee;
835
+ if($payment < 0) { return $payment; }
836
+ $payarray = fulpacc ($pval, $rate, $fee, $minpay, $payment, $months,
837
+ false);
838
+ $apr = irr2apr (irr ($pval, $payarray, 1));
839
+ return $apr;
840
+ }
841
+
842
+ function apr_fixed ($pval, $payment, $rate, $fee, $minpay)
843
+ {
844
+ $months = fixed ($pval, $payment-$fee, $rate, 1);
845
+ if($months < 0) { return $months; }
846
+ $months = ceil ($months);
847
+ $payarray = fulpacc ($pval, $rate, $fee, $minpay, $payment, $months,
848
+ false);
849
+ $apr = irr2apr (irr ($pval, $payarray, 1));
850
+ return $apr;
851
+ }
852
+
853
+ function apr_min ($pval, $rate, $fee, $minpay)
854
+ {
855
+ $payarray = fulpacc ($pval, $rate, $fee, $minpay, 0.0, -1, true);
856
+ $apr = irr2apr (irr ($pval, $payarray, 1));
857
+ return $apr;
858
+ }
859
+
860
+ //kinda untested against real life.
861
+ function apr_payin_X_months ($pval, $payment, $rate, $fee, $minpay, $free)
862
+ {
863
+ $firstpay = $payment + $fee;
864
+ $months = fixed ($pval, $payment-$fee, $rate, 0);
865
+ if($months < 0) { return $months; }
866
+ $months = ceil ($months);
867
+ $newpval = $pval - $firstpay;
868
+ $farray = array();
869
+ while ($free--)
870
+ {
871
+ $farray[] = 0.0;
872
+ }
873
+ $pval += $fee;
874
+ $farray[] = $firstpay;
875
+ $pval -= $firstpay;
876
+ $payarray = fulpacc ($pval, $rate, $fee, $minpay, $payment, $months,
877
+ false);
878
+ $newarray = array_merge($farray, $payarray);
879
+ $apr = irr2apr (irr ($pval, $newarray, 1));
880
+ return $apr;
881
+ }
882
+
883
+ public function total_credit_purchase_cost($pval, $rate, $fee, $minpay, $months, $startfee, $base = false) {
884
+
885
+
886
+ $credit_cost = 0;
887
+ $payment = $this->annuity ($pval, $months, $rate) + $fee;
888
+ $payarr = $this->fulpacc($pval, $rate, $fee, $minpay, $payment, $months, $base);
889
+
890
+ foreach($payarr as $pay)
891
+ $credit_cost += $pay;
892
+
893
+
894
+ return ($credit_cost)+$startfee;
895
+ }
896
+
897
+
898
+
899
+ }
app/code/local/Kreditor/Kreditor/Model/Api/Pclass.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_Model_Api_Pclass extends Mage_Core_Model_Abstract {
32
+ protected function _construct() {
33
+ parent::_construct();
34
+ $this->_init('kreditor/api_pclass');
35
+ }
36
+
37
+ public function updatePclasses() {
38
+ $partPayment = Mage::getModel('kreditor/method_partpayment');
39
+
40
+ // xxx Get all pclasses that we have stored
41
+ $collection = $this->getCollection();
42
+
43
+ // Delete the old ones
44
+ foreach($collection as $item) {
45
+ $item->delete();
46
+ }
47
+ // We want to get pclasses for all
48
+ // stores
49
+ foreach(Mage::app()->getStores() as $store) {
50
+
51
+ // xxx Get the settings for a store
52
+ $api = $partPayment->getApi($store->getId(), 'kreditor_partpayment');
53
+ // xxx Fetch the pclasses
54
+ $result = $api->fetchPclasses();
55
+
56
+ // xxx Add the new pclass to the database
57
+ foreach($result as $currency => $pclasses) {
58
+ foreach($pclasses as $pclass) {
59
+ $object = Mage::getModel('kreditor/api_pclass');
60
+ $object->setPclassId($pclass[0])
61
+ ->setDescription(utf8_encode($pclass[1]))
62
+ ->setMonths($pclass[2])
63
+ ->setStartfee($pclass[3])
64
+ ->setHandlingfee($pclass[4])
65
+ ->setInterest($pclass[5])
66
+ ->setMinamount($pclass[6])
67
+ ->setMaxamount(0)
68
+ ->setCurrency($this->getKlarnaCurrency($pclass[7]))
69
+ ->setStoreid($store->getId())
70
+ ->setCountry($pclass[7])
71
+ ->setType($pclass[8])
72
+ ->save();
73
+ }
74
+ }
75
+ }
76
+ }
77
+
78
+ public function getInterestPretty() {
79
+ $interest = $this->getInterest();
80
+ if(empty($interest) || $interest < 1) return 0;
81
+ else return $interest / 100;
82
+ }
83
+
84
+ protected function getAmountPretty($amount) {
85
+ if(empty($amount) || $amount < 1) return 0;
86
+ else return $amount / 100;
87
+ }
88
+
89
+ public function getStartfeePretty() {
90
+ return $this->getAmountPretty($this->getStartfee());
91
+ }
92
+
93
+ public function getHandlingfeePretty() {
94
+ return $this->getAmountPretty($this->getHandlingfee());
95
+ }
96
+
97
+ public function getMinamountPretty() {
98
+ return $this->getAmountPretty($this->getMinamount());
99
+ }
100
+
101
+ private function getKlarnaCurrency($cc = null) {
102
+
103
+ if($cc == 209) { return "SEK"; }
104
+ if($cc == 164) { return "NOK"; }
105
+ if($cc == 59) { return "DKK"; }
106
+ if($cc == 73 || $cc == 81 || $cc == 154) { return "EUR"; }
107
+ }
108
+
109
+
110
+ }
app/code/local/Kreditor/Kreditor/Model/Api/kreditor_no_pear.php ADDED
@@ -0,0 +1,4835 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php include 'pclasses.php';
2
+ /**
3
+ * **** NOTE: This file is generated, do not edit. ****
4
+ */
5
+
6
+ /**
7
+ * Removes the definition of class pear.
8
+ * Necessary if pear is already defined
9
+ */
10
+
11
+ if(false){
12
+
13
+ /**
14
+ *
15
+ * PEAR, the PHP Extension and Application Repository
16
+ *
17
+ * PEAR class and PEAR_Error class
18
+ *
19
+ * PHP versions 4 and 5
20
+ *
21
+ * LICENSE: This source file is subject to version 3.0 of the PHP license
22
+ * that is available through the world-wide-web at the following URI:
23
+ * http://www.php.net/license/3_0.txt. If you did not receive a copy of
24
+ * the PHP License and are unable to obtain it through the web, please
25
+ * send a note to license@php.net so we can mail you a copy immediately.
26
+ *
27
+ * @category pear
28
+ * @package PEAR
29
+ * @author Sterling Hughes <sterling@php.net>
30
+ * @author Stig Bakken <ssb@php.net>
31
+ * @author Tomas V.V.Cox <cox@idecnet.com>
32
+ * @author Greg Beaver <cellog@php.net>
33
+ * @copyright 1997-2005 The PHP Group
34
+ * @license http://www.php.net/license/3_0.txt PHP License 3.0
35
+ * @version CVS: $Id: kreditor.php.src 12388 2008-06-03 08:07:05Z mikael $
36
+ * @link http://pear.php.net/package/PEAR
37
+ * @since File available since Release 0.1
38
+ */
39
+
40
+ /**#@+
41
+ * ERROR constants
42
+ */
43
+ define('PEAR_ERROR_RETURN', 1);
44
+ define('PEAR_ERROR_PRINT', 2);
45
+ define('PEAR_ERROR_TRIGGER', 4);
46
+ define('PEAR_ERROR_DIE', 8);
47
+ define('PEAR_ERROR_CALLBACK', 16);
48
+ /**
49
+ * WARNING: obsolete
50
+ * @deprecated
51
+ */
52
+ define('PEAR_ERROR_EXCEPTION', 32);
53
+ /**#@-*/
54
+ define('PEAR_ZE2', (function_exists('version_compare') &&
55
+ version_compare(zend_version(), "2-dev", "ge")));
56
+
57
+ if (substr(PHP_OS, 0, 3) == 'WIN') {
58
+ define('OS_WINDOWS', true);
59
+ define('OS_UNIX', false);
60
+ define('PEAR_OS', 'Windows');
61
+ } else {
62
+ define('OS_WINDOWS', false);
63
+ define('OS_UNIX', true);
64
+ define('PEAR_OS', 'Unix'); // blatant assumption
65
+ }
66
+
67
+ // instant backwards compatibility
68
+ if (!defined('PATH_SEPARATOR')) {
69
+ if (OS_WINDOWS) {
70
+ define('PATH_SEPARATOR', ';');
71
+ } else {
72
+ define('PATH_SEPARATOR', ':');
73
+ }
74
+ }
75
+
76
+ $GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN;
77
+ $GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE;
78
+ $GLOBALS['_PEAR_destructor_object_list'] = array();
79
+ $GLOBALS['_PEAR_shutdown_funcs'] = array();
80
+ $GLOBALS['_PEAR_error_handler_stack'] = array();
81
+
82
+ /* @ini_set('track_errors', true); */
83
+
84
+ /**
85
+ * Base class for other PEAR classes. Provides rudimentary
86
+ * emulation of destructors.
87
+ *
88
+ * If you want a destructor in your class, inherit PEAR and make a
89
+ * destructor method called _yourclassname (same name as the
90
+ * constructor, but with a "_" prefix). Also, in your constructor you
91
+ * have to call the PEAR constructor: $this->PEAR();.
92
+ * The destructor method will be called without parameters. Note that
93
+ * at in some SAPI implementations (such as Apache), any output during
94
+ * the request shutdown (in which destructors are called) seems to be
95
+ * discarded. If you need to get any debug information from your
96
+ * destructor, use error_log(), syslog() or something similar.
97
+ *
98
+ * IMPORTANT! To use the emulated destructors you need to create the
99
+ * objects by reference: $obj =& new PEAR_child;
100
+ *
101
+ * @category pear
102
+ * @package PEAR
103
+ * @author Stig Bakken <ssb@php.net>
104
+ * @author Tomas V.V. Cox <cox@idecnet.com>
105
+ * @author Greg Beaver <cellog@php.net>
106
+ * @copyright 1997-2005 The PHP Group
107
+ * @license http://www.php.net/license/3_0.txt PHP License 3.0
108
+ * @version Release: 1.4.5
109
+ * @link http://pear.php.net/package/PEAR
110
+ * @see PEAR_Error
111
+ * @since Class available since PHP 4.0.2
112
+ * @link http://pear.php.net/manual/en/core.pear.php#core.pear.pear
113
+ */
114
+ class PEAR
115
+ {
116
+ // {{{ properties
117
+
118
+ /**
119
+ * Whether to enable internal debug messages.
120
+ *
121
+ * @var bool
122
+ * @access private
123
+ */
124
+ var $_debug = false;
125
+
126
+ /**
127
+ * Default error mode for this object.
128
+ *
129
+ * @var int
130
+ * @access private
131
+ */
132
+ var $_default_error_mode = null;
133
+
134
+ /**
135
+ * Default error options used for this object when error mode
136
+ * is PEAR_ERROR_TRIGGER.
137
+ *
138
+ * @var int
139
+ * @access private
140
+ */
141
+ var $_default_error_options = null;
142
+
143
+ /**
144
+ * Default error handler (callback) for this object, if error mode is
145
+ * PEAR_ERROR_CALLBACK.
146
+ *
147
+ * @var string
148
+ * @access private
149
+ */
150
+ var $_default_error_handler = '';
151
+
152
+ /**
153
+ * Which class to use for error objects.
154
+ *
155
+ * @var string
156
+ * @access private
157
+ */
158
+ var $_error_class = 'PEAR_Error';
159
+
160
+ /**
161
+ * An array of expected errors.
162
+ *
163
+ * @var array
164
+ * @access private
165
+ */
166
+ var $_expected_errors = array();
167
+
168
+ // }}}
169
+
170
+ // {{{ constructor
171
+
172
+ /**
173
+ * Constructor. Registers this object in
174
+ * $_PEAR_destructor_object_list for destructor emulation if a
175
+ * destructor object exists.
176
+ *
177
+ * @param string $error_class (optional) which class to use for
178
+ * error objects, defaults to PEAR_Error.
179
+ * @access public
180
+ * @return void
181
+ */
182
+ function PEAR($error_class = null)
183
+ {
184
+ $classname = strtolower(get_class($this));
185
+ if ($this->_debug) {
186
+ print "PEAR constructor called, class=$classname\n";
187
+ }
188
+ if ($error_class !== null) {
189
+ $this->_error_class = $error_class;
190
+ }
191
+ while ($classname && strcasecmp($classname, "pear")) {
192
+ $destructor = "_$classname";
193
+ if (method_exists($this, $destructor)) {
194
+ global $_PEAR_destructor_object_list;
195
+ $_PEAR_destructor_object_list[] = &$this;
196
+ if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {
197
+ register_shutdown_function("_PEAR_call_destructors");
198
+ $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;
199
+ }
200
+ break;
201
+ } else {
202
+ $classname = get_parent_class($classname);
203
+ }
204
+ }
205
+ }
206
+
207
+ // }}}
208
+ // {{{ destructor
209
+
210
+ /**
211
+ * Destructor (the emulated type of...). Does nothing right now,
212
+ * but is included for forward compatibility, so subclass
213
+ * destructors should always call it.
214
+ *
215
+ * See the note in the class desciption about output from
216
+ * destructors.
217
+ *
218
+ * @access public
219
+ * @return void
220
+ */
221
+ function _PEAR() {
222
+ if ($this->_debug) {
223
+ printf("PEAR destructor called, class=%s\n", strtolower(get_class($this)));
224
+ }
225
+ }
226
+
227
+ // }}}
228
+ // {{{ getStaticProperty()
229
+
230
+ /**
231
+ * If you have a class that's mostly/entirely static, and you need static
232
+ * properties, you can use this method to simulate them. Eg. in your method(s)
233
+ * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar');
234
+ * You MUST use a reference, or they will not persist!
235
+ *
236
+ * @access public
237
+ * @param string $class The calling classname, to prevent clashes
238
+ * @param string $var The variable to retrieve.
239
+ * @return mixed A reference to the variable. If not set it will be
240
+ * auto initialised to NULL.
241
+ */
242
+ function &getStaticProperty($class, $var)
243
+ {
244
+ static $properties;
245
+ return $properties[$class][$var];
246
+ }
247
+
248
+ // }}}
249
+ // {{{ registerShutdownFunc()
250
+
251
+ /**
252
+ * Use this function to register a shutdown method for static
253
+ * classes.
254
+ *
255
+ * @access public
256
+ * @param mixed $func The function name (or array of class/method) to call
257
+ * @param mixed $args The arguments to pass to the function
258
+ * @return void
259
+ */
260
+ function registerShutdownFunc($func, $args = array())
261
+ {
262
+ $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args);
263
+ }
264
+
265
+ // }}}
266
+ // {{{ isError()
267
+
268
+ /**
269
+ * Tell whether a value is a PEAR error.
270
+ *
271
+ * @param mixed $data the value to test
272
+ * @param int $code if $data is an error object, return true
273
+ * only if $code is a string and
274
+ * $obj->getMessage() == $code or
275
+ * $code is an integer and $obj->getCode() == $code
276
+ * @access public
277
+ * @return bool true if parameter is an error
278
+ */
279
+ function isError($data, $code = null)
280
+ {
281
+ if (is_a($data, 'PEAR_Error')) {
282
+ if (is_null($code)) {
283
+ return true;
284
+ } elseif (is_string($code)) {
285
+ return $data->getMessage() == $code;
286
+ } else {
287
+ return $data->getCode() == $code;
288
+ }
289
+ }
290
+ return false;
291
+ }
292
+
293
+ // }}}
294
+ // {{{ setErrorHandling()
295
+
296
+ /**
297
+ * Sets how errors generated by this object should be handled.
298
+ * Can be invoked both in objects and statically. If called
299
+ * statically, setErrorHandling sets the default behaviour for all
300
+ * PEAR objects. If called in an object, setErrorHandling sets
301
+ * the default behaviour for that object.
302
+ *
303
+ * @param int $mode
304
+ * One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
305
+ * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,
306
+ * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION.
307
+ *
308
+ * @param mixed $options
309
+ * When $mode is PEAR_ERROR_TRIGGER, this is the error level (one
310
+ * of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
311
+ *
312
+ * When $mode is PEAR_ERROR_CALLBACK, this parameter is expected
313
+ * to be the callback function or method. A callback
314
+ * function is a string with the name of the function, a
315
+ * callback method is an array of two elements: the element
316
+ * at index 0 is the object, and the element at index 1 is
317
+ * the name of the method to call in the object.
318
+ *
319
+ * When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is
320
+ * a printf format string used when printing the error
321
+ * message.
322
+ *
323
+ * @access public
324
+ * @return void
325
+ * @see PEAR_ERROR_RETURN
326
+ * @see PEAR_ERROR_PRINT
327
+ * @see PEAR_ERROR_TRIGGER
328
+ * @see PEAR_ERROR_DIE
329
+ * @see PEAR_ERROR_CALLBACK
330
+ * @see PEAR_ERROR_EXCEPTION
331
+ *
332
+ * @since PHP 4.0.5
333
+ */
334
+
335
+ function setErrorHandling($mode = null, $options = null)
336
+ {
337
+ if (isset($this) && is_a($this, 'PEAR')) {
338
+ $setmode = &$this->_default_error_mode;
339
+ $setoptions = &$this->_default_error_options;
340
+ } else {
341
+ $setmode = &$GLOBALS['_PEAR_default_error_mode'];
342
+ $setoptions = &$GLOBALS['_PEAR_default_error_options'];
343
+ }
344
+
345
+ switch ($mode) {
346
+ case PEAR_ERROR_EXCEPTION:
347
+ case PEAR_ERROR_RETURN:
348
+ case PEAR_ERROR_PRINT:
349
+ case PEAR_ERROR_TRIGGER:
350
+ case PEAR_ERROR_DIE:
351
+ case null:
352
+ $setmode = $mode;
353
+ $setoptions = $options;
354
+ break;
355
+
356
+ case PEAR_ERROR_CALLBACK:
357
+ $setmode = $mode;
358
+ // class/object method callback
359
+ if (is_callable($options)) {
360
+ $setoptions = $options;
361
+ } else {
362
+ trigger_error("invalid error callback", E_USER_WARNING);
363
+ }
364
+ break;
365
+
366
+ default:
367
+ trigger_error("invalid error mode", E_USER_WARNING);
368
+ break;
369
+ }
370
+ }
371
+
372
+ // }}}
373
+ // {{{ expectError()
374
+
375
+ /**
376
+ * This method is used to tell which errors you expect to get.
377
+ * Expected errors are always returned with error mode
378
+ * PEAR_ERROR_RETURN. Expected error codes are stored in a stack,
379
+ * and this method pushes a new element onto it. The list of
380
+ * expected errors are in effect until they are popped off the
381
+ * stack with the popExpect() method.
382
+ *
383
+ * Note that this method can not be called statically
384
+ *
385
+ * @param mixed $code a single error code or an array of error codes to expect
386
+ *
387
+ * @return int the new depth of the "expected errors" stack
388
+ * @access public
389
+ */
390
+ function expectError($code = '*')
391
+ {
392
+ if (is_array($code)) {
393
+ array_push($this->_expected_errors, $code);
394
+ } else {
395
+ array_push($this->_expected_errors, array($code));
396
+ }
397
+ return sizeof($this->_expected_errors);
398
+ }
399
+
400
+ // }}}
401
+ // {{{ popExpect()
402
+
403
+ /**
404
+ * This method pops one element off the expected error codes
405
+ * stack.
406
+ *
407
+ * @return array the list of error codes that were popped
408
+ */
409
+ function popExpect()
410
+ {
411
+ return array_pop($this->_expected_errors);
412
+ }
413
+
414
+ // }}}
415
+ // {{{ _checkDelExpect()
416
+
417
+ /**
418
+ * This method checks unsets an error code if available
419
+ *
420
+ * @param mixed error code
421
+ * @return bool true if the error code was unset, false otherwise
422
+ * @access private
423
+ * @since PHP 4.3.0
424
+ */
425
+ function _checkDelExpect($error_code)
426
+ {
427
+ $deleted = false;
428
+
429
+ foreach ($this->_expected_errors AS $key => $error_array) {
430
+ if (in_array($error_code, $error_array)) {
431
+ unset($this->_expected_errors[$key][array_search($error_code, $error_array)]);
432
+ $deleted = true;
433
+ }
434
+
435
+ // clean up empty arrays
436
+ if (0 == count($this->_expected_errors[$key])) {
437
+ unset($this->_expected_errors[$key]);
438
+ }
439
+ }
440
+ return $deleted;
441
+ }
442
+
443
+ // }}}
444
+ // {{{ delExpect()
445
+
446
+ /**
447
+ * This method deletes all occurences of the specified element from
448
+ * the expected error codes stack.
449
+ *
450
+ * @param mixed $error_code error code that should be deleted
451
+ * @return mixed list of error codes that were deleted or error
452
+ * @access public
453
+ * @since PHP 4.3.0
454
+ */
455
+ function delExpect($error_code)
456
+ {
457
+ $deleted = false;
458
+
459
+ if ((is_array($error_code) && (0 != count($error_code)))) {
460
+ // $error_code is a non-empty array here;
461
+ // we walk through it trying to unset all
462
+ // values
463
+ foreach($error_code as $key => $error) {
464
+ if ($this->_checkDelExpect($error)) {
465
+ $deleted = true;
466
+ } else {
467
+ $deleted = false;
468
+ }
469
+ }
470
+ return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
471
+ } elseif (!empty($error_code)) {
472
+ // $error_code comes alone, trying to unset it
473
+ if ($this->_checkDelExpect($error_code)) {
474
+ return true;
475
+ } else {
476
+ return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
477
+ }
478
+ } else {
479
+ // $error_code is empty
480
+ return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME
481
+ }
482
+ }
483
+
484
+ // }}}
485
+ // {{{ raiseError()
486
+
487
+ /**
488
+ * This method is a wrapper that returns an instance of the
489
+ * configured error class with this object's default error
490
+ * handling applied. If the $mode and $options parameters are not
491
+ * specified, the object's defaults are used.
492
+ *
493
+ * @param mixed $message a text error message or a PEAR error object
494
+ *
495
+ * @param int $code a numeric error code (it is up to your class
496
+ * to define these if you want to use codes)
497
+ *
498
+ * @param int $mode One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
499
+ * PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,
500
+ * PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION.
501
+ *
502
+ * @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter
503
+ * specifies the PHP-internal error level (one of
504
+ * E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
505
+ * If $mode is PEAR_ERROR_CALLBACK, this
506
+ * parameter specifies the callback function or
507
+ * method. In other error modes this parameter
508
+ * is ignored.
509
+ *
510
+ * @param string $userinfo If you need to pass along for example debug
511
+ * information, this parameter is meant for that.
512
+ *
513
+ * @param string $error_class The returned error object will be
514
+ * instantiated from this class, if specified.
515
+ *
516
+ * @param bool $skipmsg If true, raiseError will only pass error codes,
517
+ * the error message parameter will be dropped.
518
+ *
519
+ * @access public
520
+ * @return object a PEAR error object
521
+ * @see PEAR::setErrorHandling
522
+ * @since PHP 4.0.5
523
+ */
524
+ function &raiseError($message = null,
525
+ $code = null,
526
+ $mode = null,
527
+ $options = null,
528
+ $userinfo = null,
529
+ $error_class = null,
530
+ $skipmsg = false)
531
+ {
532
+ // The error is yet a PEAR error object
533
+ if (is_object($message)) {
534
+ $code = $message->getCode();
535
+ $userinfo = $message->getUserInfo();
536
+ $error_class = $message->getType();
537
+ $message->error_message_prefix = '';
538
+ $message = $message->getMessage();
539
+ }
540
+
541
+ if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) {
542
+ if ($exp[0] == "*" ||
543
+ (is_int(reset($exp)) && in_array($code, $exp)) ||
544
+ (is_string(reset($exp)) && in_array($message, $exp))) {
545
+ $mode = PEAR_ERROR_RETURN;
546
+ }
547
+ }
548
+ // No mode given, try global ones
549
+ if ($mode === null) {
550
+ // Class error handler
551
+ if (isset($this) && isset($this->_default_error_mode)) {
552
+ $mode = $this->_default_error_mode;
553
+ $options = $this->_default_error_options;
554
+ // Global error handler
555
+ } elseif (isset($GLOBALS['_PEAR_default_error_mode'])) {
556
+ $mode = $GLOBALS['_PEAR_default_error_mode'];
557
+ $options = $GLOBALS['_PEAR_default_error_options'];
558
+ }
559
+ }
560
+
561
+ if ($error_class !== null) {
562
+ $ec = $error_class;
563
+ } elseif (isset($this) && isset($this->_error_class)) {
564
+ $ec = $this->_error_class;
565
+ } else {
566
+ $ec = 'PEAR_Error';
567
+ }
568
+ if ($skipmsg) {
569
+ $a = &new $ec($code, $mode, $options, $userinfo);
570
+ return $a;
571
+ } else {
572
+ $a = &new $ec($message, $code, $mode, $options, $userinfo);
573
+ return $a;
574
+ }
575
+ }
576
+
577
+ // }}}
578
+ // {{{ throwError()
579
+
580
+ /**
581
+ * Simpler form of raiseError with fewer options. In most cases
582
+ * message, code and userinfo are enough.
583
+ *
584
+ * @param string $message
585
+ *
586
+ */
587
+ function &throwError($message = null,
588
+ $code = null,
589
+ $userinfo = null)
590
+ {
591
+ if (isset($this) && is_a($this, 'PEAR')) {
592
+ $a = &$this->raiseError($message, $code, null, null, $userinfo);
593
+ return $a;
594
+ } else {
595
+ $a = &PEAR::raiseError($message, $code, null, null, $userinfo);
596
+ return $a;
597
+ }
598
+ }
599
+
600
+ // }}}
601
+ function staticPushErrorHandling($mode, $options = null)
602
+ {
603
+ $stack = &$GLOBALS['_PEAR_error_handler_stack'];
604
+ $def_mode = &$GLOBALS['_PEAR_default_error_mode'];
605
+ $def_options = &$GLOBALS['_PEAR_default_error_options'];
606
+ $stack[] = array($def_mode, $def_options);
607
+ switch ($mode) {
608
+ case PEAR_ERROR_EXCEPTION:
609
+ case PEAR_ERROR_RETURN:
610
+ case PEAR_ERROR_PRINT:
611
+ case PEAR_ERROR_TRIGGER:
612
+ case PEAR_ERROR_DIE:
613
+ case null:
614
+ $def_mode = $mode;
615
+ $def_options = $options;
616
+ break;
617
+
618
+ case PEAR_ERROR_CALLBACK:
619
+ $def_mode = $mode;
620
+ // class/object method callback
621
+ if (is_callable($options)) {
622
+ $def_options = $options;
623
+ } else {
624
+ trigger_error("invalid error callback", E_USER_WARNING);
625
+ }
626
+ break;
627
+
628
+ default:
629
+ trigger_error("invalid error mode", E_USER_WARNING);
630
+ break;
631
+ }
632
+ $stack[] = array($mode, $options);
633
+ return true;
634
+ }
635
+
636
+ function staticPopErrorHandling()
637
+ {
638
+ $stack = &$GLOBALS['_PEAR_error_handler_stack'];
639
+ $setmode = &$GLOBALS['_PEAR_default_error_mode'];
640
+ $setoptions = &$GLOBALS['_PEAR_default_error_options'];
641
+ array_pop($stack);
642
+ list($mode, $options) = $stack[sizeof($stack) - 1];
643
+ array_pop($stack);
644
+ switch ($mode) {
645
+ case PEAR_ERROR_EXCEPTION:
646
+ case PEAR_ERROR_RETURN:
647
+ case PEAR_ERROR_PRINT:
648
+ case PEAR_ERROR_TRIGGER:
649
+ case PEAR_ERROR_DIE:
650
+ case null:
651
+ $setmode = $mode;
652
+ $setoptions = $options;
653
+ break;
654
+
655
+ case PEAR_ERROR_CALLBACK:
656
+ $setmode = $mode;
657
+ // class/object method callback
658
+ if (is_callable($options)) {
659
+ $setoptions = $options;
660
+ } else {
661
+ trigger_error("invalid error callback", E_USER_WARNING);
662
+ }
663
+ break;
664
+
665
+ default:
666
+ trigger_error("invalid error mode", E_USER_WARNING);
667
+ break;
668
+ }
669
+ return true;
670
+ }
671
+
672
+ // {{{ pushErrorHandling()
673
+
674
+ /**
675
+ * Push a new error handler on top of the error handler options stack. With this
676
+ * you can easily override the actual error handler for some code and restore
677
+ * it later with popErrorHandling.
678
+ *
679
+ * @param mixed $mode (same as setErrorHandling)
680
+ * @param mixed $options (same as setErrorHandling)
681
+ *
682
+ * @return bool Always true
683
+ *
684
+ * @see PEAR::setErrorHandling
685
+ */
686
+ function pushErrorHandling($mode, $options = null)
687
+ {
688
+ $stack = &$GLOBALS['_PEAR_error_handler_stack'];
689
+ if (isset($this) && is_a($this, 'PEAR')) {
690
+ $def_mode = &$this->_default_error_mode;
691
+ $def_options = &$this->_default_error_options;
692
+ } else {
693
+ $def_mode = &$GLOBALS['_PEAR_default_error_mode'];
694
+ $def_options = &$GLOBALS['_PEAR_default_error_options'];
695
+ }
696
+ $stack[] = array($def_mode, $def_options);
697
+
698
+ if (isset($this) && is_a($this, 'PEAR')) {
699
+ $this->setErrorHandling($mode, $options);
700
+ } else {
701
+ PEAR::setErrorHandling($mode, $options);
702
+ }
703
+ $stack[] = array($mode, $options);
704
+ return true;
705
+ }
706
+
707
+ // }}}
708
+ // {{{ popErrorHandling()
709
+
710
+ /**
711
+ * Pop the last error handler used
712
+ *
713
+ * @return bool Always true
714
+ *
715
+ * @see PEAR::pushErrorHandling
716
+ */
717
+ function popErrorHandling()
718
+ {
719
+ $stack = &$GLOBALS['_PEAR_error_handler_stack'];
720
+ array_pop($stack);
721
+ list($mode, $options) = $stack[sizeof($stack) - 1];
722
+ array_pop($stack);
723
+ if (isset($this) && is_a($this, 'PEAR')) {
724
+ $this->setErrorHandling($mode, $options);
725
+ } else {
726
+ PEAR::setErrorHandling($mode, $options);
727
+ }
728
+ return true;
729
+ }
730
+
731
+ // }}}
732
+ // {{{ loadExtension()
733
+
734
+ /**
735
+ * OS independant PHP extension load. Remember to take care
736
+ * on the correct extension name for case sensitive OSes.
737
+ *
738
+ * @param string $ext The extension name
739
+ * @return bool Success or not on the dl() call
740
+ */
741
+ function loadExtension($ext)
742
+ {
743
+ if (!extension_loaded($ext)) {
744
+ // if either returns true dl() will produce a FATAL error, stop that
745
+ if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) {
746
+ return false;
747
+ }
748
+ if (OS_WINDOWS) {
749
+ $suffix = '.dll';
750
+ } elseif (PHP_OS == 'HP-UX') {
751
+ $suffix = '.sl';
752
+ } elseif (PHP_OS == 'AIX') {
753
+ $suffix = '.a';
754
+ } elseif (PHP_OS == 'OSX') {
755
+ $suffix = '.bundle';
756
+ } else {
757
+ $suffix = '.so';
758
+ }
759
+ return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix);
760
+ }
761
+ return true;
762
+ }
763
+
764
+ // }}}
765
+ }
766
+
767
+ // {{{ _PEAR_call_destructors()
768
+
769
+ function _PEAR_call_destructors()
770
+ {
771
+ global $_PEAR_destructor_object_list;
772
+ if (is_array($_PEAR_destructor_object_list) &&
773
+ sizeof($_PEAR_destructor_object_list))
774
+ {
775
+ reset($_PEAR_destructor_object_list);
776
+ if (@PEAR::getStaticProperty('PEAR', 'destructlifo')) {
777
+ $_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list);
778
+ }
779
+ while (list($k, $objref) = each($_PEAR_destructor_object_list)) {
780
+ $classname = get_class($objref);
781
+ while ($classname) {
782
+ $destructor = "_$classname";
783
+ if (method_exists($objref, $destructor)) {
784
+ $objref->$destructor();
785
+ break;
786
+ } else {
787
+ $classname = get_parent_class($classname);
788
+ }
789
+ }
790
+ }
791
+ // Empty the object list to ensure that destructors are
792
+ // not called more than once.
793
+ $_PEAR_destructor_object_list = array();
794
+ }
795
+
796
+ // Now call the shutdown functions
797
+ if (is_array($GLOBALS['_PEAR_shutdown_funcs']) AND !empty($GLOBALS['_PEAR_shutdown_funcs'])) {
798
+ foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) {
799
+ call_user_func_array($value[0], $value[1]);
800
+ }
801
+ }
802
+ }
803
+
804
+ // }}}
805
+ /**
806
+ * Standard PEAR error class for PHP 4
807
+ *
808
+ * This class is supserseded by {@link PEAR_Exception} in PHP 5
809
+ *
810
+ * @category pear
811
+ * @package PEAR
812
+ * @author Stig Bakken <ssb@php.net>
813
+ * @author Tomas V.V. Cox <cox@idecnet.com>
814
+ * @author Gregory Beaver <cellog@php.net>
815
+ * @copyright 1997-2005 The PHP Group
816
+ * @license http://www.php.net/license/3_0.txt PHP License 3.0
817
+ * @version Release: 1.4.5
818
+ * @link http://pear.php.net/manual/en/core.pear.pear-error.php
819
+ * @see PEAR::raiseError(), PEAR::throwError()
820
+ * @since Class available since PHP 4.0.2
821
+ */
822
+ class PEAR_Error
823
+ {
824
+ // {{{ properties
825
+
826
+ var $error_message_prefix = '';
827
+ var $mode = PEAR_ERROR_RETURN;
828
+ var $level = E_USER_NOTICE;
829
+ var $code = -1;
830
+ var $message = '';
831
+ var $userinfo = '';
832
+ var $backtrace = null;
833
+
834
+ // }}}
835
+ // {{{ constructor
836
+
837
+ /**
838
+ * PEAR_Error constructor
839
+ *
840
+ * @param string $message message
841
+ *
842
+ * @param int $code (optional) error code
843
+ *
844
+ * @param int $mode (optional) error mode, one of: PEAR_ERROR_RETURN,
845
+ * PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER,
846
+ * PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION
847
+ *
848
+ * @param mixed $options (optional) error level, _OR_ in the case of
849
+ * PEAR_ERROR_CALLBACK, the callback function or object/method
850
+ * tuple.
851
+ *
852
+ * @param string $userinfo (optional) additional user/debug info
853
+ *
854
+ * @access public
855
+ *
856
+ */
857
+ function PEAR_Error($message = 'unknown error', $code = null,
858
+ $mode = null, $options = null, $userinfo = null)
859
+ {
860
+ if ($mode === null) {
861
+ $mode = PEAR_ERROR_RETURN;
862
+ }
863
+ $this->message = $message;
864
+ $this->code = $code;
865
+ $this->mode = $mode;
866
+ $this->userinfo = $userinfo;
867
+ if (function_exists("debug_backtrace")) {
868
+ if (@!PEAR::getStaticProperty('PEAR_Error', 'skiptrace')) {
869
+ $this->backtrace = debug_backtrace();
870
+ }
871
+ }
872
+ if ($mode & PEAR_ERROR_CALLBACK) {
873
+ $this->level = E_USER_NOTICE;
874
+ $this->callback = $options;
875
+ } else {
876
+ if ($options === null) {
877
+ $options = E_USER_NOTICE;
878
+ }
879
+ $this->level = $options;
880
+ $this->callback = null;
881
+ }
882
+ if ($this->mode & PEAR_ERROR_PRINT) {
883
+ if (is_null($options) || is_int($options)) {
884
+ $format = "%s";
885
+ } else {
886
+ $format = $options;
887
+ }
888
+ printf($format, $this->getMessage());
889
+ }
890
+ if ($this->mode & PEAR_ERROR_TRIGGER) {
891
+ trigger_error($this->getMessage(), $this->level);
892
+ }
893
+ if ($this->mode & PEAR_ERROR_DIE) {
894
+ $msg = $this->getMessage();
895
+ if (is_null($options) || is_int($options)) {
896
+ $format = "%s";
897
+ if (substr($msg, -1) != "\n") {
898
+ $msg .= "\n";
899
+ }
900
+ } else {
901
+ $format = $options;
902
+ }
903
+ die(sprintf($format, $msg));
904
+ }
905
+ if ($this->mode & PEAR_ERROR_CALLBACK) {
906
+ if (is_callable($this->callback)) {
907
+ call_user_func($this->callback, $this);
908
+ }
909
+ }
910
+ if ($this->mode & PEAR_ERROR_EXCEPTION) {
911
+ trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING);
912
+ eval('$e = new Exception($this->message, $this->code);throw($e);');
913
+ }
914
+ }
915
+
916
+ // }}}
917
+ // {{{ getMode()
918
+
919
+ /**
920
+ * Get the error mode from an error object.
921
+ *
922
+ * @return int error mode
923
+ * @access public
924
+ */
925
+ function getMode() {
926
+ return $this->mode;
927
+ }
928
+
929
+ // }}}
930
+ // {{{ getCallback()
931
+
932
+ /**
933
+ * Get the callback function/method from an error object.
934
+ *
935
+ * @return mixed callback function or object/method array
936
+ * @access public
937
+ */
938
+ function getCallback() {
939
+ return $this->callback;
940
+ }
941
+
942
+ // }}}
943
+ // {{{ getMessage()
944
+
945
+
946
+ /**
947
+ * Get the error message from an error object.
948
+ *
949
+ * @return string full error message
950
+ * @access public
951
+ */
952
+ function getMessage()
953
+ {
954
+ return ($this->error_message_prefix . $this->message);
955
+ }
956
+
957
+
958
+ // }}}
959
+ // {{{ getCode()
960
+
961
+ /**
962
+ * Get error code from an error object
963
+ *
964
+ * @return int error code
965
+ * @access public
966
+ */
967
+ function getCode()
968
+ {
969
+ return $this->code;
970
+ }
971
+
972
+ // }}}
973
+ // {{{ getType()
974
+
975
+ /**
976
+ * Get the name of this error/exception.
977
+ *
978
+ * @return string error/exception name (type)
979
+ * @access public
980
+ */
981
+ function getType()
982
+ {
983
+ return get_class($this);
984
+ }
985
+
986
+ // }}}
987
+ // {{{ getUserInfo()
988
+
989
+ /**
990
+ * Get additional user-supplied information.
991
+ *
992
+ * @return string user-supplied information
993
+ * @access public
994
+ */
995
+ function getUserInfo()
996
+ {
997
+ return $this->userinfo;
998
+ }
999
+
1000
+ // }}}
1001
+ // {{{ getDebugInfo()
1002
+
1003
+ /**
1004
+ * Get additional debug information supplied by the application.
1005
+ *
1006
+ * @return string debug information
1007
+ * @access public
1008
+ */
1009
+ function getDebugInfo()
1010
+ {
1011
+ return $this->getUserInfo();
1012
+ }
1013
+
1014
+ // }}}
1015
+ // {{{ getBacktrace()
1016
+
1017
+ /**
1018
+ * Get the call backtrace from where the error was generated.
1019
+ * Supported with PHP 4.3.0 or newer.
1020
+ *
1021
+ * @param int $frame (optional) what frame to fetch
1022
+ * @return array Backtrace, or NULL if not available.
1023
+ * @access public
1024
+ */
1025
+ function getBacktrace($frame = null)
1026
+ {
1027
+ if (defined('PEAR_IGNORE_BACKTRACE')) {
1028
+ return null;
1029
+ }
1030
+ if ($frame === null) {
1031
+ return $this->backtrace;
1032
+ }
1033
+ return $this->backtrace[$frame];
1034
+ }
1035
+
1036
+ // }}}
1037
+ // {{{ addUserInfo()
1038
+
1039
+ function addUserInfo($info)
1040
+ {
1041
+ if (empty($this->userinfo)) {
1042
+ $this->userinfo = $info;
1043
+ } else {
1044
+ $this->userinfo .= " ** $info";
1045
+ }
1046
+ }
1047
+
1048
+ // }}}
1049
+ // {{{ toString()
1050
+
1051
+ /**
1052
+ * Make a string representation of this object.
1053
+ *
1054
+ * @return string a string with an object summary
1055
+ * @access public
1056
+ */
1057
+ function toString() {
1058
+ $modes = array();
1059
+ $levels = array(E_USER_NOTICE => 'notice',
1060
+ E_USER_WARNING => 'warning',
1061
+ E_USER_ERROR => 'error');
1062
+ if ($this->mode & PEAR_ERROR_CALLBACK) {
1063
+ if (is_array($this->callback)) {
1064
+ $callback = (is_object($this->callback[0]) ?
1065
+ strtolower(get_class($this->callback[0])) :
1066
+ $this->callback[0]) . '::' .
1067
+ $this->callback[1];
1068
+ } else {
1069
+ $callback = $this->callback;
1070
+ }
1071
+ return sprintf('[%s: message="%s" code=%d mode=callback '.
1072
+ 'callback=%s prefix="%s" info="%s"]',
1073
+ strtolower(get_class($this)), $this->message, $this->code,
1074
+ $callback, $this->error_message_prefix,
1075
+ $this->userinfo);
1076
+ }
1077
+ if ($this->mode & PEAR_ERROR_PRINT) {
1078
+ $modes[] = 'print';
1079
+ }
1080
+ if ($this->mode & PEAR_ERROR_TRIGGER) {
1081
+ $modes[] = 'trigger';
1082
+ }
1083
+ if ($this->mode & PEAR_ERROR_DIE) {
1084
+ $modes[] = 'die';
1085
+ }
1086
+ if ($this->mode & PEAR_ERROR_RETURN) {
1087
+ $modes[] = 'return';
1088
+ }
1089
+ return sprintf('[%s: message="%s" code=%d mode=%s level=%s '.
1090
+ 'prefix="%s" info="%s"]',
1091
+ strtolower(get_class($this)), $this->message, $this->code,
1092
+ implode("|", $modes), $levels[$this->level],
1093
+ $this->error_message_prefix,
1094
+ $this->userinfo);
1095
+ }
1096
+
1097
+ // }}}
1098
+ }
1099
+
1100
+ /*
1101
+ * Local Variables:
1102
+ * mode: php
1103
+ * tab-width: 4
1104
+ * c-basic-offset: 4
1105
+ * End:
1106
+ */
1107
+
1108
+ }
1109
+ ?>
1110
+ <?php
1111
+ /*
1112
+ * XMLRPC protocol and kreditor.php version
1113
+ */
1114
+
1115
+ global $XMLRPC_LIB;
1116
+ $XMLRPC_LIB = "KPEAR";
1117
+ global $PROTO_VSN;
1118
+ $PROTO_VSN = "4.0";
1119
+ global $CLIENT_VSN;
1120
+ $CLIENT_VSN = "magento:1.2.4";
1121
+ global $KREDITOR_PORT;
1122
+ $KREDITOR_PORT = 443;
1123
+ //$KREDITOR_PORT = 80;
1124
+ global $KREDITOR_HOST;
1125
+ $KREDITOR_HOST = "payment.klarna.com";
1126
+ //$KREDITOR_HOST = "beta-test.klarna.com";
1127
+
1128
+ /*
1129
+ * Mode: $shipmenttype in add_invoice
1130
+ */
1131
+
1132
+ global $KRED_NORMAL_SHIPMENT;
1133
+ $KRED_NORMAL_SHIPMENT = 1;
1134
+ global $NORMAL_SHIPMENT; // backwards compatibility
1135
+ $NORMAL_SHIPMENT = 1;
1136
+ global $KRED_EXPRESS_SHIPMENT;
1137
+ $KRED_EXPRESS_SHIPMENT = 2;
1138
+ global $EXPRESS_SHIPMENT; // backwards compatibility
1139
+ $EXPRESS_SHIPMENT = 2;
1140
+
1141
+ /*
1142
+ * Flags: $flags in add_invoice
1143
+ */
1144
+
1145
+ global $KRED_AUTO_ACTIVATE;
1146
+ $KRED_AUTO_ACTIVATE = 1;
1147
+ global $AUTO_ACTIVATE; // backwards compatibility
1148
+ $AUTO_ACTIVATE = 1;
1149
+ global $KRED_TEST_MODE;
1150
+ $KRED_TEST_MODE = 2;
1151
+ global $TEST_MODE; // backwards compatibility
1152
+ $TEST_MODE = 2;
1153
+ global $KRED_MANUAL_AUTO_ACTIVATE;
1154
+ $KRED_MANUAL_AUTO_ACTIVATE = 4;
1155
+ global $KRED_PRE_PAY;
1156
+ $KRED_PRE_PAY = 8;
1157
+ global $KRED_DELAYED_PAY;
1158
+ $KRED_DELAYED_PAY = 16;
1159
+
1160
+ /*
1161
+ * Flags: $flags in mk_goods
1162
+ */
1163
+
1164
+ global $KRED_PRINT_1000;
1165
+ $KRED_PRINT_1000 = 1;
1166
+ global $KRED_PRINT_100;
1167
+ $KRED_PRINT_100 = 2;
1168
+ global $KRED_PRINT_10;
1169
+ $KRED_PRINT_10 = 4;
1170
+ global $KRED_IS_SHIPMENT;
1171
+ $KRED_IS_SHIPMENT = 8;
1172
+ global $KRED_IS_HANDLING;
1173
+ $KRED_IS_HANDLING = 16;
1174
+
1175
+ /*
1176
+ * Mode: $type in get_addresses
1177
+ */
1178
+ global $GA_OLD;
1179
+ $GA_OLD = 1;
1180
+ global $GA_NEW;
1181
+ $GA_NEW = 2;
1182
+
1183
+ /*
1184
+ * Mode: $type in update_charge_amount (Same as ?KD_GT_* in kdb.hrl)
1185
+ */
1186
+
1187
+ global $KRED_SHIPMENT;
1188
+ $KRED_SHIPMENT = 1;
1189
+ global $KRED_HANDLING;
1190
+ $KRED_HANDLING = 2;
1191
+
1192
+ /*
1193
+ * Mode: pnoencodings
1194
+ */
1195
+
1196
+ global $PNO_FAKE; // Fake
1197
+ $PNO_FAKE = 1;
1198
+ global $PNO_SE; // Swedish
1199
+ $PNO_SE = 2;
1200
+ global $PNO_NO; // Norwegian
1201
+ $PNO_NO = 3;
1202
+ global $PNO_FI; // Finnish
1203
+ $PNO_FI = 4;
1204
+ global $PNO_DK; // Danish
1205
+ $PNO_DK = 5;
1206
+
1207
+ /*
1208
+ * Mode: $currency in add_invoice
1209
+ */
1210
+
1211
+ global $KRED_SEK; // Swedish krona
1212
+ $KRED_SEK = 0;
1213
+ global $KRED_NOK; // Norwegian krona
1214
+ $KRED_NOK = 1;
1215
+ global $KRED_EUR; // Euro
1216
+ $KRED_EUR = 2;
1217
+ global $KRED_DKK; // Danish krona
1218
+ $KRED_DKK = 3;
1219
+
1220
+
1221
+ /*
1222
+ * Mode: $country in add_invoice
1223
+ */
1224
+
1225
+ global $KRED_ISO3166_AF;
1226
+ $KRED_ISO3166_AF = 1; // AFGHANISTAN
1227
+ global $KRED_ISO3166_AX;
1228
+ $KRED_ISO3166_AX = 2; // �LAND ISLANDS
1229
+ global $KRED_ISO3166_AL;
1230
+ $KRED_ISO3166_AL = 3; // ALBANIA
1231
+ global $KRED_ISO3166_DZ;
1232
+ $KRED_ISO3166_DZ = 4; // ALGERIA
1233
+ global $KRED_ISO3166_AS;
1234
+ $KRED_ISO3166_AS = 5; // AMERICAN SAMOA
1235
+ global $KRED_ISO3166_AD;
1236
+ $KRED_ISO3166_AD = 6; // ANDORRA
1237
+ global $KRED_ISO3166_AO;
1238
+ $KRED_ISO3166_AO = 7; // ANGOLA
1239
+ global $KRED_ISO3166_AI;
1240
+ $KRED_ISO3166_AI = 8; // ANGUILLA
1241
+ global $KRED_ISO3166_AQ;
1242
+ $KRED_ISO3166_AQ = 9; // ANTARCTICA
1243
+ global $KRED_ISO3166_AG;
1244
+ $KRED_ISO3166_AG = 10; // ANTIGUA AND BARBUDA
1245
+ global $KRED_ISO3166_AR;
1246
+ $KRED_ISO3166_AR = 11; // ARGENTINA
1247
+ global $KRED_ISO3166_AM;
1248
+ $KRED_ISO3166_AM = 12; // ARMENIA
1249
+ global $KRED_ISO3166_AW;
1250
+ $KRED_ISO3166_AW = 13; // ARUBA
1251
+ global $KRED_ISO3166_AU;
1252
+ $KRED_ISO3166_AU = 14; // AUSTRALIA
1253
+ global $KRED_ISO3166_AT;
1254
+ $KRED_ISO3166_AT = 15; // AUSTRIA
1255
+ global $KRED_ISO3166_AZ;
1256
+ $KRED_ISO3166_AZ = 16; // AZERBAIJAN
1257
+ global $KRED_ISO3166_BS;
1258
+ $KRED_ISO3166_BS = 17; // BAHAMAS
1259
+ global $KRED_ISO3166_BH;
1260
+ $KRED_ISO3166_BH = 18; // BAHRAIN
1261
+ global $KRED_ISO3166_BD;
1262
+ $KRED_ISO3166_BD = 19; // BANGLADESH
1263
+ global $KRED_ISO3166_BB;
1264
+ $KRED_ISO3166_BB = 20; // BARBADOS
1265
+ global $KRED_ISO3166_BY;
1266
+ $KRED_ISO3166_BY = 21; // BELARUS
1267
+ global $KRED_ISO3166_BE;
1268
+ $KRED_ISO3166_BE = 22; // BELGIUM
1269
+ global $KRED_ISO3166_BZ;
1270
+ $KRED_ISO3166_BZ = 23; // BELIZE
1271
+ global $KRED_ISO3166_BJ;
1272
+ $KRED_ISO3166_BJ = 24; // BENIN
1273
+ global $KRED_ISO3166_BM;
1274
+ $KRED_ISO3166_BM = 25; // BERMUDA
1275
+ global $KRED_ISO3166_BT;
1276
+ $KRED_ISO3166_BT = 26; // BHUTAN
1277
+ global $KRED_ISO3166_BO;
1278
+ $KRED_ISO3166_BO = 27; // BOLIVIA
1279
+ global $KRED_ISO3166_BA;
1280
+ $KRED_ISO3166_BA = 28; // BOSNIA AND HERZEGOVINA
1281
+ global $KRED_ISO3166_BW;
1282
+ $KRED_ISO3166_BW = 29; // BOTSWANA
1283
+ global $KRED_ISO3166_BV;
1284
+ $KRED_ISO3166_BV = 30; // BOUVET ISLAND
1285
+ global $KRED_ISO3166_BR;
1286
+ $KRED_ISO3166_BR = 31; // BRAZIL
1287
+ global $KRED_ISO3166_IO;
1288
+ $KRED_ISO3166_IO = 32; // BRITISH INDIAN OCEAN TERRITORY
1289
+ global $KRED_ISO3166_BN;
1290
+ $KRED_ISO3166_BN = 33; // BRUNEI DARUSSALAM
1291
+ global $KRED_ISO3166_BG;
1292
+ $KRED_ISO3166_BG = 34; // BULGARIA
1293
+ global $KRED_ISO3166_BF;
1294
+ $KRED_ISO3166_BF = 35; // BURKINA FASO
1295
+ global $KRED_ISO3166_BI;
1296
+ $KRED_ISO3166_BI = 36; // BURUNDI
1297
+ global $KRED_ISO3166_KH;
1298
+ $KRED_ISO3166_KH = 37; // CAMBODIA
1299
+ global $KRED_ISO3166_CM;
1300
+ $KRED_ISO3166_CM = 38; // CAMEROON
1301
+ global $KRED_ISO3166_CA;
1302
+ $KRED_ISO3166_CA = 39; // CANADA
1303
+ global $KRED_ISO3166_CV;
1304
+ $KRED_ISO3166_CV = 40; // CAPE VERDE
1305
+ global $KRED_ISO3166_KY;
1306
+ $KRED_ISO3166_KY = 41; // CAYMAN ISLANDS
1307
+ global $KRED_ISO3166_CF;
1308
+ $KRED_ISO3166_CF = 42; // CENTRAL AFRICAN REPUBLIC
1309
+ global $KRED_ISO3166_TD;
1310
+ $KRED_ISO3166_TD = 43; // CHAD
1311
+ global $KRED_ISO3166_CL;
1312
+ $KRED_ISO3166_CL = 44; // CHILE
1313
+ global $KRED_ISO3166_CN;
1314
+ $KRED_ISO3166_CN = 45; // CHINA
1315
+ global $KRED_ISO3166_CX;
1316
+ $KRED_ISO3166_CX = 46; // CHRISTMAS ISLAND
1317
+ global $KRED_ISO3166_CC;
1318
+ $KRED_ISO3166_CC = 47; // COCOS (KEELING) ISLANDS
1319
+ global $KRED_ISO3166_CO;
1320
+ $KRED_ISO3166_CO = 48; // COLOMBIA
1321
+ global $KRED_ISO3166_KM;
1322
+ $KRED_ISO3166_KM = 49; // COMOROS
1323
+ global $KRED_ISO3166_CG;
1324
+ $KRED_ISO3166_CG = 50; // CONGO
1325
+ global $KRED_ISO3166_CD;
1326
+ $KRED_ISO3166_CD = 51; // CONGO, THE DEMOCRATIC REPUBLIC OF THE
1327
+ global $KRED_ISO3166_CK;
1328
+ $KRED_ISO3166_CK = 52; // COOK ISLANDS
1329
+ global $KRED_ISO3166_CT;
1330
+ $KRED_ISO3166_CR = 53; // COSTA RICA
1331
+ global $KRED_ISO3166_CI;
1332
+ $KRED_ISO3166_CI = 54; // COTE D'IVOIRE
1333
+ global $KRED_ISO3166_HR;
1334
+ $KRED_ISO3166_HR = 55; // CROATIA
1335
+ global $KRED_ISO3166_CU;
1336
+ $KRED_ISO3166_CU = 56; // CUBA
1337
+ global $KRED_ISO3166_CY;
1338
+ $KRED_ISO3166_CY = 57; // CYPRUS
1339
+ global $KRED_ISO3166_CZ;
1340
+ $KRED_ISO3166_CZ = 58; // CZECH REPUBLIC
1341
+ global $KRED_ISO3166_DK;
1342
+ $KRED_ISO3166_DK = 59; // DENMARK
1343
+ global $KRED_ISO3166_DJ;
1344
+ $KRED_ISO3166_DJ = 60; // DJIBOUTI
1345
+ global $KRED_ISO3166_DM;
1346
+ $KRED_ISO3166_DM = 61; // DOMINICA
1347
+ global $KRED_ISO3166_DO;
1348
+ $KRED_ISO3166_DO = 62; // DOMINICAN REPUBLIC
1349
+ global $KRED_ISO3166_EC;
1350
+ $KRED_ISO3166_EC = 63; // ECUADOR
1351
+ global $KRED_ISO3166_EG;
1352
+ $KRED_ISO3166_EG = 64; // EGYPT
1353
+ global $KRED_ISO3166_SV;
1354
+ $KRED_ISO3166_SV = 65; // EL SALVADOR
1355
+ global $KRED_ISO3166_GQ;
1356
+ $KRED_ISO3166_GQ = 66; // EQUATORIAL GUINEA
1357
+ global $KRED_ISO3166_ER;
1358
+ $KRED_ISO3166_ER = 67; // ERITREA
1359
+ global $KRED_ISO3166_EE;
1360
+ $KRED_ISO3166_EE = 68; // ESTONIA
1361
+ global $KRED_ISO3166_ET;
1362
+ $KRED_ISO3166_ET = 69; // ETHIOPIA
1363
+ global $KRED_ISO3166_FK;
1364
+ $KRED_ISO3166_FK = 70; // FALKLAND ISLANDS (MALVINAS)
1365
+ global $KRED_ISO3166_FO;
1366
+ $KRED_ISO3166_FO = 71; // FAROE ISLANDS
1367
+ global $KRED_ISO3166_FJ;
1368
+ $KRED_ISO3166_FJ = 72; // FIJI
1369
+ global $KRED_ISO3166_FI;
1370
+ $KRED_ISO3166_FI = 73; // FINLAND
1371
+ global $KRED_ISO3166_FR;
1372
+ $KRED_ISO3166_FR = 74; // FRANCE
1373
+ global $KRED_ISO3166_GF;
1374
+ $KRED_ISO3166_GF = 75; // FRENCH GUIANA
1375
+ global $KRED_ISO3166_PF;
1376
+ $KRED_ISO3166_PF = 76; // FRENCH POLYNESIA
1377
+ global $KRED_ISO3166_TF;
1378
+ $KRED_ISO3166_TF = 77; // FRENCH SOUTHERN TERRITORIES
1379
+ global $KRED_ISO3166_GA;
1380
+ $KRED_ISO3166_GA = 78; // GABON
1381
+ global $KRED_ISO3166_GA;
1382
+ $KRED_ISO3166_GM = 79; // GAMBIA
1383
+ global $KRED_ISO3166_GE;
1384
+ $KRED_ISO3166_GE = 80; // GEORGIA
1385
+ global $KRED_ISO3166_DE;
1386
+ $KRED_ISO3166_DE = 81; // GERMANY
1387
+ global $KRED_ISO3166_GH;
1388
+ $KRED_ISO3166_GH = 82; // GHANA
1389
+ global $KRED_ISO3166_GI;
1390
+ $KRED_ISO3166_GI = 83; // GIBRALTAR
1391
+ global $KRED_ISO3166_GR;
1392
+ $KRED_ISO3166_GR = 84; // GREECE
1393
+ global $KRED_ISO3166_GL;
1394
+ $KRED_ISO3166_GL = 85; // GREENLAND
1395
+ global $KRED_ISO3166_GD;
1396
+ $KRED_ISO3166_GD = 86; // GRENADA
1397
+ global $KRED_ISO3166_GP;
1398
+ $KRED_ISO3166_GP = 87; // GUADELOUPE
1399
+ global $KRED_ISO3166_GU;
1400
+ $KRED_ISO3166_GU = 88; // GUAM
1401
+ global $KRED_ISO3166_GT;
1402
+ $KRED_ISO3166_GT = 89; // GUATEMALA
1403
+ global $KRED_ISO3166_GG;
1404
+ $KRED_ISO3166_GG = 90; // GUERNSEY
1405
+ global $KRED_ISO3166_GN;
1406
+ $KRED_ISO3166_GN = 91; // GUINEA
1407
+ global $KRED_ISO3166_GW;
1408
+ $KRED_ISO3166_GW = 92; // GUINEA-BISSAU
1409
+ global $KRED_ISO3166_GY;
1410
+ $KRED_ISO3166_GY = 93; // GUYANA
1411
+ global $KRED_ISO3166_HT;
1412
+ $KRED_ISO3166_HT = 94; // HAITI
1413
+ global $KRED_ISO3166_HM;
1414
+ $KRED_ISO3166_HM = 95; // HEARD ISLAND AND MCDONALD ISLANDS
1415
+ global $KRED_ISO3166_VA;
1416
+ $KRED_ISO3166_VA = 96; // HOLY SEE (VATICAN CITY STATE)
1417
+ global $KRED_ISO3166_HN;
1418
+ $KRED_ISO3166_HN = 97; // HONDURAS
1419
+ global $KRED_ISO3166_HK;
1420
+ $KRED_ISO3166_HK = 98; // HONG KONG
1421
+ global $KRED_ISO3166_HU;
1422
+ $KRED_ISO3166_HU = 99; // HUNGARY
1423
+ global $KRED_ISO3166_IS;
1424
+ $KRED_ISO3166_IS = 100; // ICELAND
1425
+ global $KRED_ISO3166_IN;
1426
+ $KRED_ISO3166_IN = 101; // INDIA
1427
+ global $KRED_ISO3166_ID;
1428
+ $KRED_ISO3166_ID = 102; // INDONESIA
1429
+ global $KRED_ISO3166_IR;
1430
+ $KRED_ISO3166_IR = 103; // IRAN, ISLAMIC REPUBLIC OF
1431
+ global $KRED_ISO3166_IQ;
1432
+ $KRED_ISO3166_IQ = 104; // IRAQ
1433
+ global $KRED_ISO3166_IE;
1434
+ $KRED_ISO3166_IE = 105; // IRELAND
1435
+ global $KRED_ISO3166_IM;
1436
+ $KRED_ISO3166_IM = 106; // ISLE OF MAN
1437
+ global $KRED_ISO3166_IL;
1438
+ $KRED_ISO3166_IL = 107; // ISRAEL
1439
+ global $KRED_ISO3166_IT;
1440
+ $KRED_ISO3166_IT = 108; // ITALY
1441
+ global $KRED_ISO3166_JM;
1442
+ $KRED_ISO3166_JM = 109; // JAMAICA
1443
+ global $KRED_ISO3166_JP;
1444
+ $KRED_ISO3166_JP = 110; // JAPAN
1445
+ global $KRED_ISO3166_JE;
1446
+ $KRED_ISO3166_JE = 111; // JERSEY
1447
+ global $KRED_ISO3166_JO;
1448
+ $KRED_ISO3166_JO = 112; // JORDAN
1449
+ global $KRED_ISO3166_KZ;
1450
+ $KRED_ISO3166_KZ = 113; // KAZAKHSTAN
1451
+ global $KRED_ISO3166_KE;
1452
+ $KRED_ISO3166_KE =114; // KENYA
1453
+ global $KRED_ISO3166_KI;
1454
+ $KRED_ISO3166_KI =115; // KIRIBATI
1455
+ global $KRED_ISO3166_KP;
1456
+ $KRED_ISO3166_KP =116; // KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF
1457
+ global $KRED_ISO3166_KR;
1458
+ $KRED_ISO3166_KR =117; // KOREA, REPUBLIC OF
1459
+ global $KRED_ISO3166_KW;
1460
+ $KRED_ISO3166_KW = 118; // KUWAIT
1461
+ global $KRED_ISO3166_KG;
1462
+ $KRED_ISO3166_KG = 119; // KYRGYZSTAN
1463
+ global $KRED_ISO3166_LA;
1464
+ $KRED_ISO3166_LA = 120; // LAO PEOPLE'S DEMOCRATIC REPUBLIC
1465
+ global $KRED_ISO3166_LV;
1466
+ $KRED_ISO3166_LV = 121; // LATVIA
1467
+ global $KRED_ISO3166_LB;
1468
+ $KRED_ISO3166_LB = 122; // LEBANON
1469
+ global $KRED_ISO3166_LS;
1470
+ $KRED_ISO3166_LS = 123; // LESOTHO
1471
+ global $KRED_ISO3166_LR;
1472
+ $KRED_ISO3166_LR = 124; // LIBERIA
1473
+ global $KRED_ISO3166_LY;
1474
+ $KRED_ISO3166_LY = 125; // LIBYAN ARAB JAMAHIRIYA
1475
+ global $KRED_ISO3166_LI;
1476
+ $KRED_ISO3166_LI = 126; // LIECHTENSTEIN
1477
+ global $KRED_ISO3166_LT;
1478
+ $KRED_ISO3166_LT = 127; // LITHUANIA
1479
+ global $KRED_ISO3166_LU;
1480
+ $KRED_ISO3166_LU = 128; // LUXEMBOURG
1481
+ global $KRED_ISO3166_MO;
1482
+ $KRED_ISO3166_MO = 129; // MACAO
1483
+ global $KRED_ISO3166_MK;
1484
+ $KRED_ISO3166_MK = 130; // MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF
1485
+ global $KRED_ISO3166_MG;
1486
+ $KRED_ISO3166_MG = 131; // MADAGASCAR
1487
+ global $KRED_ISO3166_MW;
1488
+ $KRED_ISO3166_MW = 132; // MALAWI
1489
+ global $KRED_ISO3166_MY;
1490
+ $KRED_ISO3166_MY = 133; // MALAYSIA
1491
+ global $KRED_ISO3166_MV;
1492
+ $KRED_ISO3166_MV = 134; // MALDIVES
1493
+ global $KRED_ISO3166_ML;
1494
+ $KRED_ISO3166_ML = 135; // MALI
1495
+ global $KRED_ISO3166_MT;
1496
+ $KRED_ISO3166_MT = 136; // MALTA
1497
+ global $KRED_ISO3166_MH;
1498
+ $KRED_ISO3166_MH = 137; // MARSHALL ISLANDS
1499
+ global $KRED_ISO3166_MQ;
1500
+ $KRED_ISO3166_MQ = 138; // MARTINIQUE
1501
+ global $KRED_ISO3166_MR;
1502
+ $KRED_ISO3166_MR = 139; // MAURITANIA
1503
+ global $KRED_ISO3166_MU;
1504
+ $KRED_ISO3166_MU = 140; // MAURITIUS
1505
+ global $KRED_ISO3166_YT;
1506
+ $KRED_ISO3166_YT = 141; // MAYOTTE
1507
+ global $KRED_ISO3166_MX;
1508
+ $KRED_ISO3166_MX = 142; // MEXICO
1509
+ global $KRED_ISO3166_FM;
1510
+ $KRED_ISO3166_FM = 143; // MICRONESIA FEDERATED STATES OF
1511
+ global $KRED_ISO3166_MD;
1512
+ $KRED_ISO3166_MD = 144; // MOLDOVA, REPUBLIC OF
1513
+ global $KRED_ISO3166_MC;
1514
+ $KRED_ISO3166_MC = 145; // MONACO
1515
+ global $KRED_ISO3166_MN;
1516
+ $KRED_ISO3166_MN = 146; // MONGOLIA
1517
+ global $KRED_ISO3166_MS;
1518
+ $KRED_ISO3166_MS = 147; // MONTSERRAT
1519
+ global $KRED_ISO3166_MA;
1520
+ $KRED_ISO3166_MA = 148; // MOROCCO
1521
+ global $KRED_ISO3166_MZ;
1522
+ $KRED_ISO3166_MZ = 149; // MOZAMBIQUE
1523
+ global $KRED_ISO3166_MM;
1524
+ $KRED_ISO3166_MM = 150; // MYANMAR
1525
+ global $KRED_ISO3166_NA;
1526
+ $KRED_ISO3166_NA = 151; // NAMIBIA
1527
+ global $KRED_ISO3166_NR;
1528
+ $KRED_ISO3166_NR = 152; // NAURU
1529
+ global $KRED_ISO3166_NP;
1530
+ $KRED_ISO3166_NP = 153; // NEPAL
1531
+ global $KRED_ISO3166_NL;
1532
+ $KRED_ISO3166_NL = 154; // NETHERLANDS
1533
+ global $KRED_ISO3166_AN;
1534
+ $KRED_ISO3166_AN = 155; // NETHERLANDS ANTILLES
1535
+ global $KRED_ISO3166_NC;
1536
+ $KRED_ISO3166_NC = 156; // NEW CALEDONIA
1537
+ global $KRED_ISO3166_NZ;
1538
+ $KRED_ISO3166_NZ = 157; // NEW ZEALAND
1539
+ global $KRED_ISO3166_NI;
1540
+ $KRED_ISO3166_NI = 158; // NICARAGUA
1541
+ global $KRED_ISO3166_NE;
1542
+ $KRED_ISO3166_NE = 159; // NIGER
1543
+ global $KRED_ISO3166_NG;
1544
+ $KRED_ISO3166_NG = 160; // NIGERIA
1545
+ global $KRED_ISO3166_NU;
1546
+ $KRED_ISO3166_NU = 161; // NIUE
1547
+ global $KRED_ISO3166_NF;
1548
+ $KRED_ISO3166_NF = 162; // NORFOLK ISLAND
1549
+ global $KRED_ISO3166_MP;
1550
+ $KRED_ISO3166_MP = 163; // NORTHERN MARIANA ISLANDS
1551
+ global $KRED_ISO3166_NO;
1552
+ $KRED_ISO3166_NO = 164; // NORWAY
1553
+ global $KRED_ISO3166_OM;
1554
+ $KRED_ISO3166_OM = 165; // OMAN
1555
+ global $KRED_ISO3166_PK;
1556
+ $KRED_ISO3166_PK = 166; // PAKISTAN
1557
+ global $KRED_ISO3166_PW;
1558
+ $KRED_ISO3166_PW = 167; // PALAU
1559
+ global $KRED_ISO3166_PS;
1560
+ $KRED_ISO3166_PS = 168; // PALESTINIAN TERRITORY OCCUPIED
1561
+ global $KRED_ISO3166_PA;
1562
+ $KRED_ISO3166_PA = 169; // PANAMA
1563
+ global $KRED_ISO3166_PG;
1564
+ $KRED_ISO3166_PG = 170; // PAPUA NEW GUINEA
1565
+ global $KRED_ISO3166_PY;
1566
+ $KRED_ISO3166_PY = 171; // PARAGUAY
1567
+ global $KRED_ISO3166_PE;
1568
+ $KRED_ISO3166_PE = 172; // PERU
1569
+ global $KRED_ISO3166_PH;
1570
+ $KRED_ISO3166_PH = 173; // PHILIPPINES
1571
+ global $KRED_ISO3166_PN;
1572
+ $KRED_ISO3166_PN = 174; // PITCAIRN
1573
+ global $KRED_ISO3166_PL;
1574
+ $KRED_ISO3166_PL = 175; // POLAND
1575
+ global $KRED_ISO3166_PT;
1576
+ $KRED_ISO3166_PT = 176; // PORTUGAL
1577
+ global $KRED_ISO3166_PR;
1578
+ $KRED_ISO3166_PR = 177; // PUERTO RICO
1579
+ global $KRED_ISO3166_QA;
1580
+ $KRED_ISO3166_QA = 178; // QATAR
1581
+ global $KRED_ISO3166_RE;
1582
+ $KRED_ISO3166_RE = 179; // REUNION
1583
+ global $KRED_ISO3166_RO;
1584
+ $KRED_ISO3166_RO = 180; // ROMANIA
1585
+ global $KRED_ISO3166_RU;
1586
+ $KRED_ISO3166_RU = 181; // RUSSIAN FEDERATION
1587
+ global $KRED_ISO3166_RW;
1588
+ $KRED_ISO3166_RW = 182; // RWANDA
1589
+ global $KRED_ISO3166_SH;
1590
+ $KRED_ISO3166_SH = 183; // SAINT HELENA
1591
+ global $KRED_ISO3166_KN;
1592
+ $KRED_ISO3166_KN = 184; // SAINT KITTS AND NEVIS
1593
+ global $KRED_ISO3166_LC;
1594
+ $KRED_ISO3166_LC = 185; // SAINT LUCIA
1595
+ global $KRED_ISO3166_PM;
1596
+ $KRED_ISO3166_PM = 186; // SAINT PIERRE AND MIQUELON
1597
+ global $KRED_ISO3166_VC;
1598
+ $KRED_ISO3166_VC = 187; // SAINT VINCENT AND THE GRENADINES
1599
+ global $KRED_ISO3166_WS;
1600
+ $KRED_ISO3166_WS = 188; // SAMOA
1601
+ global $KRED_ISO3166_SM;
1602
+ $KRED_ISO3166_SM = 189; // SAN MARINO
1603
+ global $KRED_ISO3166_ST;
1604
+ $KRED_ISO3166_ST = 190; // SAO TOME AND PRINCIPE
1605
+ global $KRED_ISO3166_SA;
1606
+ $KRED_ISO3166_SA = 191; // SAUDI ARABIA
1607
+ global $KRED_ISO3166_SN;
1608
+ $KRED_ISO3166_SN = 192; // SENEGAL
1609
+ global $KRED_ISO3166_CS;
1610
+ $KRED_ISO3166_CS = 193; // SERBIA AND MONTENEGRO
1611
+ global $KRED_ISO3166_SC;
1612
+ $KRED_ISO3166_SC = 194; // SEYCHELLES
1613
+ global $KRED_ISO3166_SL;
1614
+ $KRED_ISO3166_SL = 195; // SIERRA LEONE
1615
+ global $KRED_ISO3166_SG;
1616
+ $KRED_ISO3166_SG = 196; // SINGAPORE
1617
+ global $KRED_ISO3166_SK;
1618
+ $KRED_ISO3166_SK = 197; // SLOVAKIA
1619
+ global $KRED_ISO3166_SI;
1620
+ $KRED_ISO3166_SI = 198; // SLOVENIA
1621
+ global $KRED_ISO3166_SB;
1622
+ $KRED_ISO3166_SB = 199; // SOLOMON ISLANDS
1623
+ global $KRED_ISO3166_SO;
1624
+ $KRED_ISO3166_SO = 200; // SOMALIA
1625
+ global $KRED_ISO3166_ZA;
1626
+ $KRED_ISO3166_ZA = 201; // SOUTH AFRICA
1627
+ global $KRED_ISO3166_GS;
1628
+ $KRED_ISO3166_GS = 202; // SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS
1629
+ global $KRED_ISO3166_ES;
1630
+ $KRED_ISO3166_ES = 203; // SPAIN
1631
+ global $KRED_ISO3166_LK;
1632
+ $KRED_ISO3166_LK = 204; // SRI LANKA
1633
+ global $KRED_ISO3166_SD;
1634
+ $KRED_ISO3166_SD = 205; // SUDAN
1635
+ global $KRED_ISO3166_SR;
1636
+ $KRED_ISO3166_SR = 206; // SURINAME
1637
+ global $KRED_ISO3166_SJ;
1638
+ $KRED_ISO3166_SJ = 207; // SVALBARD AND JAN MAYEN
1639
+ global $KRED_ISO3166_SZ;
1640
+ $KRED_ISO3166_SZ = 208; // SWAZILAND
1641
+ global $KRED_ISO3166_SE;
1642
+ $KRED_ISO3166_SE = 209; // SWEDEN
1643
+ global $KRED_ISO3166_CH;
1644
+ $KRED_ISO3166_CH = 210; // SWITZERLAND
1645
+ global $KRED_ISO3166_SY;
1646
+ $KRED_ISO3166_SY = 211; // SYRIAN ARAB REPUBLIC
1647
+ global $KRED_ISO3166_TW;
1648
+ $KRED_ISO3166_TW = 212; // TAIWAN PROVINCE OF CHINA
1649
+ global $KRED_ISO3166_TJ;
1650
+ $KRED_ISO3166_TJ = 213; // TAJIKISTAN
1651
+ global $KRED_ISO3166_TZ;
1652
+ $KRED_ISO3166_TZ = 214; // TANZANIA, UNITED REPUBLIC OF
1653
+ global $KRED_ISO3166_TH;
1654
+ $KRED_ISO3166_TH = 215; // THAILAND
1655
+ global $KRED_ISO3166_TL;
1656
+ $KRED_ISO3166_TL = 216; // TIMOR-LESTE
1657
+ global $KRED_ISO3166_TC;
1658
+ $KRED_ISO3166_TG = 217; // TOGO
1659
+ global $KRED_ISO3166_TK;
1660
+ $KRED_ISO3166_TK = 218; // TOKELAU
1661
+ global $KRED_ISO3166_TO;
1662
+ $KRED_ISO3166_TO = 219; // TONGA
1663
+ global $KRED_ISO3166_TT;
1664
+ $KRED_ISO3166_TT = 220; // TRINIDAD AND TOBAGO
1665
+ global $KRED_ISO3166_TN;
1666
+ $KRED_ISO3166_TN = 221; // TUNISIA
1667
+ global $KRED_ISO3166_TR;
1668
+ $KRED_ISO3166_TR = 222; // TURKEY
1669
+ global $KRED_ISO3166_TM;
1670
+ $KRED_ISO3166_TM = 223; // TURKMENISTAN
1671
+ global $KRED_ISO3166_TC;
1672
+ $KRED_ISO3166_TC = 224; // TURKS AND CAICOS ISLANDS
1673
+ global $KRED_ISO3166_TV;
1674
+ $KRED_ISO3166_TV = 225; // TUVALU
1675
+ global $KRED_ISO3166_UG;
1676
+ $KRED_ISO3166_UG = 226; // UGANDA
1677
+ global $KRED_ISO3166_UA;
1678
+ $KRED_ISO3166_UA = 227; // UKRAINE
1679
+ global $KRED_ISO3166_AE;
1680
+ $KRED_ISO3166_AE = 228; // UNITED ARAB EMIRATES
1681
+ global $KRED_ISO3166_GB;
1682
+ $KRED_ISO3166_GB = 229; // UNITED KINGDOM
1683
+ global $KRED_ISO3166_US;
1684
+ $KRED_ISO3166_US = 230; // UNITED STATES
1685
+ global $KRED_ISO3166_UM;
1686
+ $KRED_ISO3166_UM = 231; // UNITED STATES MINOR OUTLYING ISLANDS
1687
+ global $KRED_ISO3166_UY;
1688
+ $KRED_ISO3166_UY = 232; // URUGUAY
1689
+ global $KRED_ISO3166_UZ;
1690
+ $KRED_ISO3166_UZ = 233; // UZBEKISTAN
1691
+ global $KRED_ISO3166_VU;
1692
+ $KRED_ISO3166_VU = 234; // VANUATU
1693
+ global $KRED_ISO3166_VE;
1694
+ $KRED_ISO3166_VE = 235; // VENEZUELA
1695
+ global $KRED_ISO3166_VN;
1696
+ $KRED_ISO3166_VN = 236; // VIET NAM
1697
+ global $KRED_ISO3166_VG;
1698
+ $KRED_ISO3166_VG = 237; // VIRGIN ISLANDS, BRITISH
1699
+ global $KRED_ISO3166_VI;
1700
+ $KRED_ISO3166_VI = 238; // VIRGIN ISLANDS, US
1701
+ global $KRED_ISO3166_WF;
1702
+ $KRED_ISO3166_WF = 239; // WALLIS AND FUTUNA
1703
+ global $KRED_ISO3166_EH;
1704
+ $KRED_ISO3166_EH = 240; // WESTERN SAHARA
1705
+ global $KRED_ISO3166_YE;
1706
+ $KRED_ISO3166_YE = 241; // YEMEN
1707
+ global $KRED_ISO3166_ZM;
1708
+ $KRED_ISO3166_ZM = 242; // ZAMBIA
1709
+ global $KRED_ISO3166_ZW;
1710
+ $KRED_ISO3166_ZW = 243; // ZIMBABWE
1711
+
1712
+
1713
+
1714
+ /*
1715
+ * Language code in add_invoice
1716
+ */
1717
+
1718
+ global $KRED_ISO639_AA;
1719
+ $KRED_ISO639_AA = 1; // Afar
1720
+ global $KRED_ISO639_AB;
1721
+ $KRED_ISO639_AB = 2; // Abkhazian
1722
+ global $KRED_ISO639_AE;
1723
+ $KRED_ISO639_AE = 3; // Avestan
1724
+ global $KRED_ISO639_AF;
1725
+ $KRED_ISO639_AF = 4; // Afrikaans
1726
+ global $KRED_ISO639_AM;
1727
+ $KRED_ISO639_AM = 5; // Amharic
1728
+ global $KRED_ISO639_AR;
1729
+ $KRED_ISO639_AR = 6; // Arabic
1730
+ global $KRED_ISO639_AS;
1731
+ $KRED_ISO639_AS = 7; // Assamese
1732
+ global $KRED_ISO639_AY;
1733
+ $KRED_ISO639_AY = 8; // Aymara
1734
+ global $KRED_ISO639_AZ;
1735
+ $KRED_ISO639_AZ = 9; // Azerbaijani
1736
+ global $KRED_ISO639_BA;
1737
+ $KRED_ISO639_BA = 10; // Bashkir
1738
+ global $KRED_ISO639_BE;
1739
+ $KRED_ISO639_BE = 11; // Byelorussian; Belarusian
1740
+ global $KRED_ISO639_BG;
1741
+ $KRED_ISO639_BG = 12; // Bulgarian
1742
+ global $KRED_ISO639_BH;
1743
+ $KRED_ISO639_BH = 13; // Bihari
1744
+ global $KRED_ISO639_BI;
1745
+ $KRED_ISO639_BI = 14; // Bislama
1746
+ global $KRED_ISO639_BN;
1747
+ $KRED_ISO639_BN = 15; // Bengali; Bangla
1748
+ global $KRED_ISO639_BO;
1749
+ $KRED_ISO639_BO = 16; // Tibetan
1750
+ global $KRED_ISO639_BR;
1751
+ $KRED_ISO639_BR = 17; // Breton
1752
+ global $KRED_ISO639_BS;
1753
+ $KRED_ISO639_BS = 18; // Bosnian
1754
+ global $KRED_ISO639_CA;
1755
+ $KRED_ISO639_CA = 19; // Catalan
1756
+ global $KRED_ISO639_CE;
1757
+ $KRED_ISO639_CE = 20; // Chechen
1758
+ global $KRED_ISO639_CH;
1759
+ $KRED_ISO639_CH = 21; // Chamorro
1760
+ global $KRED_ISO639_CO;
1761
+ $KRED_ISO639_CO = 22; // Corsican
1762
+ global $KRED_ISO639_CS;
1763
+ $KRED_ISO639_CS = 23; // Czech
1764
+ global $KRED_ISO639_CU;
1765
+ $KRED_ISO639_CU = 24; // Church Slavic
1766
+ global $KRED_ISO639_CV;
1767
+ $KRED_ISO639_CV = 25; // Chuvash
1768
+ global $KRED_ISO639_CY;
1769
+ $KRED_ISO639_CY = 26; // Welsh
1770
+ global $KRED_ISO639_DA;
1771
+ $KRED_ISO639_DA = 27; // Danish
1772
+ global $KRED_ISO639_DE;
1773
+ $KRED_ISO639_DE = 28; // German
1774
+ global $KRED_ISO639_DZ;
1775
+ $KRED_ISO639_DZ = 29; // Dzongkha; Bhutani
1776
+ global $KRED_ISO639_EL;
1777
+ $KRED_ISO639_EL = 30; // Greek
1778
+ global $KRED_ISO639_EN;
1779
+ $KRED_ISO639_EN = 31; // English
1780
+ global $KRED_ISO639_EO;
1781
+ $KRED_ISO639_EO = 32; // Esperanto
1782
+ global $KRED_ISO639_ES;
1783
+ $KRED_ISO639_ES = 33; // Spanish
1784
+ global $KRED_ISO639_ET;
1785
+ $KRED_ISO639_ET = 34; // Estonian
1786
+ global $KRED_ISO639_EU;
1787
+ $KRED_ISO639_EU = 35; // Basque
1788
+ global $KRED_ISO639_FA;
1789
+ $KRED_ISO639_FA = 36; // Persian
1790
+ global $KRED_ISO639_FI;
1791
+ $KRED_ISO639_FI = 37; // Finnish
1792
+ global $KRED_ISO639_FJ;
1793
+ $KRED_ISO639_FJ = 38; // Fijian; Fiji
1794
+ global $KRED_ISO639_FO;
1795
+ $KRED_ISO639_FO = 39; // Faroese
1796
+ global $KRED_ISO639_FR;
1797
+ $KRED_ISO639_FR = 40; // French
1798
+ global $KRED_ISO639_FY;
1799
+ $KRED_ISO639_FY = 41; // Frisian
1800
+ global $KRED_ISO639_GA;
1801
+ $KRED_ISO639_GA = 42; // Irish
1802
+ global $KRED_ISO639_GD;
1803
+ $KRED_ISO639_GD = 43; // Scots; Gaelic
1804
+ global $KRED_ISO639_GL;
1805
+ $KRED_ISO639_GL = 44; // Gallegan; Galician
1806
+ global $KRED_ISO639_GN;
1807
+ $KRED_ISO639_GN = 45; // Guarani
1808
+ global $KRED_ISO639_GU;
1809
+ $KRED_ISO639_GU = 46; // Gujarati
1810
+ global $KRED_ISO639_GV;
1811
+ $KRED_ISO639_GV = 47; // Manx
1812
+ global $KRED_ISO639_HA;
1813
+ $KRED_ISO639_HA = 48; // Hausa (?)
1814
+ global $KRED_ISO639_HE;
1815
+ $KRED_ISO639_HE = 49; // Hebrew (formerly iw)
1816
+ global $KRED_ISO639_HI;
1817
+ $KRED_ISO639_HI = 50; // Hindi
1818
+ global $KRED_ISO639_HO;
1819
+ $KRED_ISO639_HO = 51; // Hiri Motu
1820
+ global $KRED_ISO639_HR;
1821
+ $KRED_ISO639_HR = 52; // Croatian
1822
+ global $KRED_ISO639_HU;
1823
+ $KRED_ISO639_HU = 53; // Hungarian
1824
+ global $KRED_ISO639_HY;
1825
+ $KRED_ISO639_HY = 54; // Armenian
1826
+ global $KRED_ISO639_HZ;
1827
+ $KRED_ISO639_HZ = 55; // Herero
1828
+ global $KRED_ISO639_IA;
1829
+ $KRED_ISO639_IA = 56; // Interlingua
1830
+ global $KRED_ISO639_ID;
1831
+ $KRED_ISO639_ID = 57; // Indonesian (formerly in)
1832
+ global $KRED_ISO639_IE;
1833
+ $KRED_ISO639_IE = 58; // Interlingue
1834
+ global $KRED_ISO639_IK;
1835
+ $KRED_ISO639_IK = 59; // Inupiak
1836
+ global $KRED_ISO639_IO;
1837
+ $KRED_ISO639_IO = 60; // Ido
1838
+ global $KRED_ISO639_IS;
1839
+ $KRED_ISO639_IS = 61; // Icelandic
1840
+ global $KRED_ISO639_IT;
1841
+ $KRED_ISO639_IT = 62; // Italian
1842
+ global $KRED_ISO639_IU;
1843
+ $KRED_ISO639_IU = 63; // Inuktitut
1844
+ global $KRED_ISO639_JA;
1845
+ $KRED_ISO639_JA = 64; // Japanese
1846
+ global $KRED_ISO639_JV;
1847
+ $KRED_ISO639_JV = 65; // Javanese
1848
+ global $KRED_ISO639_KA;
1849
+ $KRED_ISO639_KA = 66; // Georgian
1850
+ global $KRED_ISO639_KI;
1851
+ $KRED_ISO639_KI = 67; // Kikuyu
1852
+ global $KRED_ISO639_KJ;
1853
+ $KRED_ISO639_KJ = 68; // Kuanyama
1854
+ global $KRED_ISO639_KK;
1855
+ $KRED_ISO639_KK = 69; // Kazakh
1856
+ global $KRED_ISO639_KL;
1857
+ $KRED_ISO639_KL = 70; // Kalaallisut; Greenlandic
1858
+ global $KRED_ISO639_KM;
1859
+ $KRED_ISO639_KM = 71; // Khmer; Cambodian
1860
+ global $KRED_ISO639_KN;
1861
+ $KRED_ISO639_KN = 72; // Kannada
1862
+ global $KRED_ISO639_KO;
1863
+ $KRED_ISO639_KO = 73; // Korean
1864
+ global $KRED_ISO639_KS;
1865
+ $KRED_ISO639_KS = 74; // Kashmiri
1866
+ global $KRED_ISO639_KU;
1867
+ $KRED_ISO639_KU = 75; // Kurdish
1868
+ global $KRED_ISO639_KV;
1869
+ $KRED_ISO639_KV = 76; // Komi
1870
+ global $KRED_ISO639_KW;
1871
+ $KRED_ISO639_KW = 77; // Cornish
1872
+ global $KRED_ISO639_KY;
1873
+ $KRED_ISO639_KY = 78; // Kirghiz
1874
+ global $KRED_ISO639_LA;
1875
+ $KRED_ISO639_LA = 79; // Latin
1876
+ global $KRED_ISO639_LB;
1877
+ $KRED_ISO639_LB = 80; // Letzeburgesch
1878
+ global $KRED_ISO639_LN;
1879
+ $KRED_ISO639_LN = 81; // Lingala
1880
+ global $KRED_ISO639_LO;
1881
+ $KRED_ISO639_LO = 82; // Lao; Laotian
1882
+ global $KRED_ISO639_LT;
1883
+ $KRED_ISO639_LT = 83; // Lithuanian
1884
+ global $KRED_ISO639_LV;
1885
+ $KRED_ISO639_LV = 84; // Latvian; Lettish
1886
+ global $KRED_ISO639_MG;
1887
+ $KRED_ISO639_MG = 85; // Malagasy
1888
+ global $KRED_ISO639_MH;
1889
+ $KRED_ISO639_MH = 86; // Marshall
1890
+ global $KRED_ISO639_MI;
1891
+ $KRED_ISO639_MI = 87; // Maori
1892
+ global $KRED_ISO639_MK;
1893
+ $KRED_ISO639_MK = 88; // Macedonian
1894
+ global $KRED_ISO639_ML;
1895
+ $KRED_ISO639_ML = 89; // Malayalam
1896
+ global $KRED_ISO639_MN;
1897
+ $KRED_ISO639_MN = 90; // Mongolian
1898
+ global $KRED_ISO639_MO;
1899
+ $KRED_ISO639_MO = 91; // Moldavian
1900
+ global $KRED_ISO639_MR;
1901
+ $KRED_ISO639_MR = 92; // Marathi
1902
+ global $KRED_ISO639_MS;
1903
+ $KRED_ISO639_MS = 93; // Malay
1904
+ global $KRED_ISO639_MT;
1905
+ $KRED_ISO639_MT = 94; // Maltese
1906
+ global $KRED_ISO639_MY;
1907
+ $KRED_ISO639_MY = 95; // Burmese
1908
+ global $KRED_ISO639_NA;
1909
+ $KRED_ISO639_NA = 96; // Nauru
1910
+ global $KRED_ISO639_NB;
1911
+ $KRED_ISO639_NB = 97; // Norwegian Bokm�l
1912
+ global $KRED_ISO639_ND;
1913
+ $KRED_ISO639_ND = 98; // Ndebele, North
1914
+ global $KRED_ISO639_NE;
1915
+ $KRED_ISO639_NE = 99; // Nepali
1916
+ global $KRED_ISO639_NG;
1917
+ $KRED_ISO639_NG = 100; // Ndonga
1918
+ global $KRED_ISO639_NL;
1919
+ $KRED_ISO639_NL = 101; // Dutch
1920
+ global $KRED_ISO639_NN;
1921
+ $KRED_ISO639_NN = 102; // Norwegian Nynorsk
1922
+ global $KRED_ISO639_NO;
1923
+ $KRED_ISO639_NO = 103; // Norwegian
1924
+ global $KRED_ISO639_NR;
1925
+ $KRED_ISO639_NR = 104; // Ndebele, South
1926
+ global $KRED_ISO639_NV;
1927
+ $KRED_ISO639_NV = 105; // Navajo
1928
+ global $KRED_ISO639_NY;
1929
+ $KRED_ISO639_NY = 106; // Chichewa; Nyanja
1930
+ global $KRED_ISO639_OC;
1931
+ $KRED_ISO639_OC = 107; // Occitan; Proven�al
1932
+ global $KRED_ISO639_OM;
1933
+ $KRED_ISO639_OM = 108; // (Afan) Oromo
1934
+ global $KRED_ISO639_OR;
1935
+ $KRED_ISO639_OR = 109; // Oriya
1936
+ global $KRED_ISO639_OS;
1937
+ $KRED_ISO639_OS = 110; // Ossetian; Ossetic
1938
+ global $KRED_ISO639_PA;
1939
+ $KRED_ISO639_PA = 111; // Panjabi; Punjabi
1940
+ global $KRED_ISO639_PI;
1941
+ $KRED_ISO639_PI = 112; // Pali
1942
+ global $KRED_ISO639_PL;
1943
+ $KRED_ISO639_PL = 113; // Polish
1944
+ global $KRED_ISO639_PS;
1945
+ $KRED_ISO639_PS = 114; // Pashto, Pushto
1946
+ global $KRED_ISO639_PT;
1947
+ $KRED_ISO639_PT = 115; // Portuguese
1948
+ global $KRED_ISO639_QU;
1949
+ $KRED_ISO639_QU = 116; // Quechua
1950
+ global $KRED_ISO639_RM;
1951
+ $KRED_ISO639_RM = 117; // Rhaeto-Romance
1952
+ global $KRED_ISO639_RN;
1953
+ $KRED_ISO639_RN = 118; // Rundi; Kirundi
1954
+ global $KRED_ISO639_RO;
1955
+ $KRED_ISO639_RO = 119; // Romanian
1956
+ global $KRED_ISO639_RU;
1957
+ $KRED_ISO639_RU = 120; // Russian
1958
+ global $KRED_ISO639_RW;
1959
+ $KRED_ISO639_RW = 121; // Kinyarwanda
1960
+ global $KRED_ISO639_SA;
1961
+ $KRED_ISO639_SA = 122; // Sanskrit
1962
+ global $KRED_ISO639_SC;
1963
+ $KRED_ISO639_SC = 123; // Sardinian
1964
+ global $KRED_ISO639_SD;
1965
+ $KRED_ISO639_SD = 124; // Sindhi
1966
+ global $KRED_ISO639_SE;
1967
+ $KRED_ISO639_SE = 125; // Northern Sami
1968
+ global $KRED_ISO639_SG;
1969
+ $KRED_ISO639_SG = 126; // Sango; Sangro
1970
+ global $KRED_ISO639_SI;
1971
+ $KRED_ISO639_SI = 127; // Sinhalese
1972
+ global $KRED_ISO639_SK;
1973
+ $KRED_ISO639_SK = 128; // Slovak
1974
+ global $KRED_ISO639_SL;
1975
+ $KRED_ISO639_SL = 129; // Slovenian
1976
+ global $KRED_ISO639_SM;
1977
+ $KRED_ISO639_SM = 130; // Samoan
1978
+ global $KRED_ISO639_SN;
1979
+ $KRED_ISO639_SN = 131; // Shona
1980
+ global $KRED_ISO639_SO;
1981
+ $KRED_ISO639_SO = 132; // Somali
1982
+ global $KRED_ISO639_SQ;
1983
+ $KRED_ISO639_SQ = 133; // Albanian
1984
+ global $KRED_ISO639_SR;
1985
+ $KRED_ISO639_SR = 134; // Serbian
1986
+ global $KRED_ISO639_SS;
1987
+ $KRED_ISO639_SS = 135; // Swati; Siswati
1988
+ global $KRED_ISO639_ST;
1989
+ $KRED_ISO639_ST = 136; // Sesotho; Sotho, Southern
1990
+ global $KRED_ISO639_SU;
1991
+ $KRED_ISO639_SU = 137; // Sundanese
1992
+ global $KRED_ISO639_SV;
1993
+ $KRED_ISO639_SV = 138; // Swedish
1994
+ global $KRED_ISO639_SW;
1995
+ $KRED_ISO639_SW = 139; // Swahili
1996
+ global $KRED_ISO639_TA;
1997
+ $KRED_ISO639_TA = 140; // Tamil
1998
+ global $KRED_ISO639_TE;
1999
+ $KRED_ISO639_TE = 141; // Telugu
2000
+ global $KRED_ISO639_TG;
2001
+ $KRED_ISO639_TG = 142; // Tajik
2002
+ global $KRED_ISO639_TH;
2003
+ $KRED_ISO639_TH = 143; // Thai
2004
+ global $KRED_ISO639_TI;
2005
+ $KRED_ISO639_TI = 144; // Tigrinya
2006
+ global $KRED_ISO639_TK;
2007
+ $KRED_ISO639_TK = 145; // Turkmen
2008
+ global $KRED_ISO639_TL;
2009
+ $KRED_ISO639_TL = 146; // Tagalog
2010
+ global $KRED_ISO639_TN;
2011
+ $KRED_ISO639_TN = 147; // Tswana; Setswana
2012
+ global $KRED_ISO639_TO;
2013
+ $KRED_ISO639_TO = 148; // Tonga (?)
2014
+ global $KRED_ISO639_TR;
2015
+ $KRED_ISO639_TR = 149; // Turkish
2016
+ global $KRED_ISO639_TS;
2017
+ $KRED_ISO639_TS = 150; // Tsonga
2018
+ global $KRED_ISO639_TT;
2019
+ $KRED_ISO639_TT = 151; // Tatar
2020
+ global $KRED_ISO639_TW;
2021
+ $KRED_ISO639_TW = 152; // Twi
2022
+ global $KRED_ISO639_TY;
2023
+ $KRED_ISO639_TY = 153; // Tahitian
2024
+ global $KRED_ISO639_UG;
2025
+ $KRED_ISO639_UG = 154; // Uighur
2026
+ global $KRED_ISO639_UK;
2027
+ $KRED_ISO639_UK = 155; // Ukrainian
2028
+ global $KRED_ISO639_UR;
2029
+ $KRED_ISO639_UR = 156; // Urdu
2030
+ global $KRED_ISO639_UZ;
2031
+ $KRED_ISO639_UZ = 157; // Uzbek
2032
+ global $KRED_ISO639_VI;
2033
+ $KRED_ISO639_VI = 158; // Vietnamese
2034
+ global $KRED_ISO639_VO;
2035
+ $KRED_ISO639_VO = 159; // Volapuk
2036
+ global $KRED_ISO639_WA;
2037
+ $KRED_ISO639_WA = 160; // Walloon
2038
+ global $KRED_ISO639_WO;
2039
+ $KRED_ISO639_WO = 161; // Wolof
2040
+ global $KRED_ISO639_XH;
2041
+ $KRED_ISO639_XH = 162; // Xhosa
2042
+ global $KRED_ISO639_YI;
2043
+ $KRED_ISO639_YI = 163; // Yiddish (formerly ji)
2044
+ global $KRED_ISO639_YO;
2045
+ $KRED_ISO639_YO = 164; // Yoruba
2046
+ global $KRED_ISO639_ZA;
2047
+ $KRED_ISO639_ZA = 165; // Zhuang
2048
+ global $KRED_ISO639_ZH;
2049
+ $KRED_ISO639_ZH = 166; // Chinese
2050
+ global $KRED_ISO639_ZU;
2051
+ $KRED_ISO639_ZU = 167; // Zulu
2052
+
2053
+
2054
+ /*
2055
+ * Do an xmlrpc call to Kreditor.
2056
+ */
2057
+
2058
+ function kred_call($function, $paramList, &$result, $eid, $secret) {
2059
+ global $PROTO_VSN;
2060
+ global $CLIENT_VSN;
2061
+ global $XMLRPC_LIB;
2062
+ global $KREDITOR_PORT;
2063
+ global $KREDITOR_HOST;
2064
+
2065
+ $timestart = @microtime(true);
2066
+
2067
+ $return = '';
2068
+ $params = array($PROTO_VSN, $CLIENT_VSN);
2069
+
2070
+ while (list(, $v) = each($paramList)) {
2071
+ $params[] = $v;
2072
+ }
2073
+
2074
+ switch ($XMLRPC_LIB) {
2075
+ case "EPI":
2076
+ $xmlRequest = xmlrpc_encode_request($function, $params);
2077
+ $selectDateTime = @microtime(true);
2078
+ $xmlResponse = xmlrpc_call($KREDITOR_HOST, $KREDITOR_PORT, $xmlRequest);
2079
+ $xmlResponse =
2080
+ substr($xmlResponse, strpos($xmlResponse, "\r\n\r\n") + 4);
2081
+ $response = xmlrpc_decode($xmlResponse);
2082
+
2083
+ if ($response == NULL) {
2084
+ // xmlrpc_decode may not handle faultCode/faultString
2085
+ if (preg_match("<methodResponse><fault><value><struct><member><name>faultCode</name><value><int>(-?[0-9]+)</int></value></member><member><name>faultString</name><value><string>([^<]*)</string></value></member></struct></value></fault></methodResponse>", $xmlResponse, $regs)) {
2086
+ $result = $regs[2];
2087
+ $return = $regs[1];
2088
+ } else {
2089
+ $result = $xmlResponse;
2090
+ $return = -99;
2091
+ }
2092
+ } else
2093
+ if (is_array($response)) {
2094
+ $result = $response["faultString"];
2095
+ $return = $response["faultCode"];
2096
+ } else {
2097
+ $result = $response;
2098
+ $return = 0;
2099
+ }
2100
+
2101
+ case "KPEAR":
2102
+ $parameterArray = array(XML_RPC_encode($params));
2103
+ $message = new XML_RPC_Message($function, $parameterArray);
2104
+ $message->setSendEncoding("ISO-8859-1");
2105
+ $client = new XML_RPC_Client("/", $KREDITOR_HOST, $KREDITOR_PORT);
2106
+ //$client->setDebug(1);
2107
+ $selectDateTime = @microtime(true);
2108
+ $response = $client->send($message);
2109
+
2110
+ if (is_int($response) && ($response == 0)) {
2111
+ $result = $client->errstr;
2112
+ $return = -99;
2113
+ } else
2114
+ $faultCode = $response->faultCode();
2115
+
2116
+ if ($faultCode != 0) {
2117
+ $result = $response->faultString();
2118
+ $return = $faultCode;
2119
+ } else {
2120
+ $result = XML_RPC_decode($response->value());
2121
+ $return = 0;
2122
+ }
2123
+
2124
+ break;
2125
+ default:
2126
+
2127
+ $selectDateTime = @microtime(true);
2128
+ $result = "Unknown XMLRPC library: " . $XMLRPC_LIB;
2129
+ $return = -99;
2130
+
2131
+ break;
2132
+ }
2133
+
2134
+ $timeend = @microtime(true);
2135
+
2136
+ $time = (int) (($selectDateTime - $timestart)*1000);
2137
+ $selectTime = (int) (($timeend - $timestart)*1000);
2138
+
2139
+ $Url = $KREDITOR_HOST . ":" . $KREDITOR_PORT;
2140
+ @send_stat($eid, $function, $time, $selectTime, $return, $Url, $secret);
2141
+
2142
+ return $return;
2143
+ }
2144
+
2145
+ /*
2146
+ * API: activate_invoice
2147
+ */
2148
+
2149
+ function activate_invoice($eid, $invno, $secret, &$result) {
2150
+ our_settype_integer($eid);
2151
+ our_settype_string($invno);
2152
+ our_settype_string($secret);
2153
+ $digestSecret = invoice_digest($eid, $invno, $secret);
2154
+ $paramList = array($eid, $invno, $digestSecret);
2155
+ return kred_call("activate_invoice", $paramList, $result, $eid, $secret);
2156
+ }
2157
+
2158
+ /*
2159
+ * API: activate_part
2160
+ */
2161
+ function mk_artno($qty, $artno) {
2162
+ our_settype_integer($qty);
2163
+ our_settype_string($artno);
2164
+ return array("artno" => $artno, "qty" => $qty);
2165
+ }
2166
+
2167
+ function activate_part($eid, $invno, $artnos, $secret, &$result) {
2168
+ our_settype_integer($eid);
2169
+ our_settype_string($invno);
2170
+ our_settype_string($secret);
2171
+ $digestSecret = activate_part_digest($eid, $invno, $artnos, $secret);
2172
+ $paramList = array($eid, $invno, $artnos, $digestSecret);
2173
+ return kred_call("activate_part", $paramList, $result, $eid, $secret);
2174
+ }
2175
+
2176
+ /*
2177
+ * API: invoice_part_amount
2178
+ */
2179
+ function invoice_part_amount($eid, $invno, $artnos, $secret, &$result) {
2180
+ our_settype_integer($eid);
2181
+ our_settype_string($invno);
2182
+ our_settype_string($secret);
2183
+ our_settype_integer($amount);
2184
+ $digestSecret = activate_part_digest($eid, $invno, $artnos, $secret);
2185
+ $paramList = array($eid, $invno, $artnos, $digestSecret);
2186
+ return kred_call("invoice_part_amount", $paramList, $result, $eid, $secret);
2187
+ }
2188
+
2189
+ /*
2190
+ * API: send_invoice
2191
+ */
2192
+
2193
+ function send_invoice($eid, $invno, $secret, &$result) {
2194
+ our_settype_integer($eid);
2195
+ our_settype_string($invno);
2196
+ our_settype_string($secret);
2197
+ $digestSecret = invoice_digest($eid, $invno, $secret);
2198
+ $paramList = array($eid, $invno, $digestSecret);
2199
+ return kred_call("send_invoice", $paramList, $result, $eid, $secret);
2200
+ }
2201
+
2202
+ /*
2203
+ * API: email_invoice
2204
+ */
2205
+
2206
+ function email_invoice($eid, $invno, $secret, &$result) {
2207
+ our_settype_integer($eid);
2208
+ our_settype_string($invno);
2209
+ our_settype_string($secret);
2210
+ $digestSecret = invoice_digest($eid, $invno, $secret);
2211
+ $paramList = array($eid, $invno, $digestSecret);
2212
+ return kred_call("email_invoice", $paramList, $result, $eid, $secret);
2213
+ }
2214
+
2215
+ /*
2216
+ * API: add_invoice
2217
+ */
2218
+
2219
+ function mk_goods($qty, $artno, $title, $price, $vat, $discount) {
2220
+ our_settype_integer($qty);
2221
+ our_settype_string($artno);
2222
+ our_settype_string($title);
2223
+ our_settype_integer($price);
2224
+ settype($vat, "double");
2225
+ settype($discount, "double");
2226
+ return array("goods" => array("artno" => $artno,
2227
+ "title" => $title,
2228
+ "price" => $price,
2229
+ "vat" => $vat,
2230
+ "discount" => $discount),
2231
+ "qty" => $qty);
2232
+ }
2233
+
2234
+ function mk_goods_flags($qty, $artno, $title, $price, $vat, $discount, $flags){
2235
+ our_settype_integer($qty);
2236
+ our_settype_integer($flags);
2237
+ our_settype_string($artno);
2238
+ our_settype_string($title);
2239
+ our_settype_integer($price);
2240
+ settype($vat, "double");
2241
+ settype($discount, "double");
2242
+ return array("goods" => array("artno" => $artno,
2243
+ "title" => $title,
2244
+ "price" => $price,
2245
+ "vat" => $vat,
2246
+ "discount" => $discount,
2247
+ "flags" => $flags),
2248
+ "qty" => $qty);
2249
+ }
2250
+
2251
+ function mk_addr_se($careof, $street, $postno, $city, $telno, $cellno, $email){
2252
+ global $KRED_ISO3166_SE;
2253
+ return mk_addr($careof, $street, $postno, $city, $KRED_ISO3166_SE, $telno,
2254
+ $cellno, $email);
2255
+ }
2256
+
2257
+ function mk_addr_no($careof, $street, $postno, $city, $telno, $cellno, $email){
2258
+ global $KRED_ISO3166_NO;
2259
+ return mk_addr($careof, $street, $postno, $city, $KRED_ISO3166_NO, $telno,
2260
+ $cellno, $email);
2261
+ }
2262
+
2263
+
2264
+ function mk_addr_dk($careof, $street, $postno, $city, $telno, $cellno, $email){
2265
+ global $KRED_ISO3166_DK;
2266
+ return mk_addr($careof, $street, $postno, $city, $KRED_ISO3166_DK, $telno,
2267
+ $cellno, $email);
2268
+ }
2269
+
2270
+ function mk_addr_fi($careof, $street, $postno, $city, $telno, $cellno, $email){
2271
+ global $KRED_ISO3166_FI;
2272
+ return mk_addr($careof, $street, $postno, $city, $KRED_ISO3166_FI, $telno,
2273
+ $cellno, $email);
2274
+ }
2275
+
2276
+ function mk_addr($careof, $street, $postno, $city, $country, $telno, $cellno,
2277
+ $email, $house_number = '', $house_extension = '') {
2278
+ our_settype_string($careof);
2279
+ our_settype_string($street);
2280
+ if($country != 154)
2281
+ our_settype_integer($postno);
2282
+ else
2283
+ our_settype_string($postno);
2284
+
2285
+ our_settype_string($city);
2286
+ our_settype_integer($country);
2287
+ our_settype_string($telno);
2288
+ our_settype_string($cellno);
2289
+ our_settype_string($email);
2290
+ our_settype_string($house_number);
2291
+ our_settype_string($house_extension);
2292
+
2293
+ return array("careof" => $careof,
2294
+ "street" => $street,
2295
+ "postno" => $postno,
2296
+ "city" => $city,
2297
+ "country" => $country,
2298
+ "telno" => $telno,
2299
+ "cellno" => $cellno,
2300
+ "email" => $email,
2301
+ "house_number" => $house_number,
2302
+ "house_extension" => $house_extension);
2303
+ }
2304
+
2305
+ function add_invoice_se($eid, $estoreUser, $secret, $estoreOrderNo, $goodsList,
2306
+ $shipmentfee, $shipmenttype, $handlingfee, $pno, $fname,
2307
+ $lname, $addr, $passwd, $clientIp, $newPasswd, $flags,
2308
+ $comment, $ready_date, $rand_string,
2309
+ &$result) {
2310
+ global $PNO_SE, $KRED_SEK, $KRED_ISO3166_SE, $KRED_ISO639_SV;
2311
+ return add_invoice($eid, $estoreUser, $secret, $estoreOrderNo,
2312
+ $goodsList, $shipmentfee, $shipmenttype, $handlingfee,
2313
+ $pno, $fname, $lname, $addr, $passwd, $clientIp,
2314
+ $newPasswd, $flags, $comment, $ready_date, $rand_string,
2315
+ $KRED_SEK, $KRED_ISO3166_SE, $KRED_ISO639_SV, $PNO_SE,
2316
+ $result);
2317
+ }
2318
+
2319
+ function add_invoice_no($eid, $estoreUser, $secret, $estoreOrderNo, $goodsList,
2320
+ $shipmentfee, $shipmenttype, $handlingfee, $pno, $fname,
2321
+ $lname, $addr, $passwd, $clientIp, $newPasswd, $flags,
2322
+ $comment, $ready_date, $rand_string, &$result) {
2323
+ global $PNO_NO, $KRED_NOK, $KRED_ISO3166_NO, $KRED_ISO639_NB;
2324
+ return add_invoice($eid, $estoreUser, $secret, $estoreOrderNo,
2325
+ $goodsList, $shipmentfee, $shipmenttype, $handlingfee,
2326
+ $pno, $fname, $lname, $addr, $passwd, $clientIp,
2327
+ $newPasswd, $flags, $comment, $ready_date, $rand_string,
2328
+ $KRED_NOK, $KRED_ISO3166_NO, $KRED_ISO639_NB, $PNO_NO,
2329
+ $result);
2330
+ }
2331
+
2332
+
2333
+ function add_invoice_dk($eid, $estoreUser, $secret, $estoreOrderNo, $goodsList,
2334
+ $shipmentfee, $shipmenttype, $handlingfee, $pno, $fname,
2335
+ $lname, $addr, $passwd, $clientIp, $newPasswd, $flags,
2336
+ $comment, $ready_date, $rand_string, &$result) {
2337
+ global $PNO_DK, $KRED_DKK, $KRED_ISO3166_DK, $KRED_ISO639_DA;
2338
+ return add_invoice($eid, $estoreUser, $secret, $estoreOrderNo,
2339
+ $goodsList, $shipmentfee, $shipmenttype, $handlingfee,
2340
+ $pno, $fname, $lname, $addr, $passwd, $clientIp,
2341
+ $newPasswd, $flags, $comment, $ready_date, $rand_string,
2342
+ $KRED_DKK, $KRED_ISO3166_DK, $KRED_ISO639_DA, $PNO_DK,
2343
+ $result);
2344
+ }
2345
+
2346
+ function add_invoice_fi($eid, $estoreUser, $secret, $estoreOrderNo, $goodsList,
2347
+ $shipmentfee, $shipmenttype, $handlingfee, $pno, $fname,
2348
+ $lname, $addr, $passwd, $clientIp, $newPasswd, $flags,
2349
+ $comment, $ready_date, $rand_string, &$result) {
2350
+ global $PNO_FI, $KRED_EUR, $KRED_ISO3166_FI, $KRED_ISO639_FI;
2351
+ return add_invoice($eid, $estoreUser, $secret, $estoreOrderNo,
2352
+ $goodsList, $shipmentfee, $shipmenttype, $handlingfee,
2353
+ $pno, $fname, $lname, $addr, $passwd, $clientIp,
2354
+ $newPasswd, $flags, $comment, $ready_date, $rand_string,
2355
+ $KRED_EUR, $KRED_ISO3166_FI, $KRED_ISO639_FI, $PNO_FI,
2356
+ $result);
2357
+ }
2358
+
2359
+ function add_invoice($eid, $estoreUser, $secret, $estoreOrderNo, $goodsList,
2360
+ $shipmentfee, $shipmenttype, $handlingfee, $pno, $fname,
2361
+ $lname, $addr, $passwd, $clientIp, $newPasswd, $flags,
2362
+ $comment, $ready_date, $rand_string, $currency, $country,
2363
+ $language, $pno_encoding, &$result) {
2364
+ $pclass = -1;
2365
+ $ysalary = 0;
2366
+ return add_transaction($eid, $estoreUser, $secret, $estoreOrderNo,
2367
+ $goodsList, $shipmentfee, $shipmenttype,
2368
+ $handlingfee, $pno, $fname, $lname, $addr, $passwd,
2369
+ $clientIp, $newPasswd, $flags, $comment,
2370
+ $ready_date, $rand_string, $currency, $country,
2371
+ $language, $pno_encoding, $pclass, $ysalary,
2372
+ $result);
2373
+ }
2374
+
2375
+ function add_transaction_se($eid, $estoreUser, $secret, $estoreOrderNo,
2376
+ $goodsList, $shipmentfee, $shipmenttype,
2377
+ $handlingfee, $pno, $fname, $lname, $addr, $passwd,
2378
+ $clientIp, $newPasswd, $flags, $comment,
2379
+ $ready_date, $rand_string, $pclass, $ysalary,
2380
+ &$result) {
2381
+ global $PNO_SE, $KRED_SEK, $KRED_ISO3166_SE, $KRED_ISO639_SV;
2382
+ return add_transaction($eid, $estoreUser, $secret, $estoreOrderNo,
2383
+ $goodsList, $shipmentfee, $shipmenttype,
2384
+ $handlingfee, $pno, $fname, $lname, $addr, $passwd,
2385
+ $clientIp, $newPasswd, $flags, $comment,
2386
+ $ready_date, $rand_string, $KRED_SEK,
2387
+ $KRED_ISO3166_SE, $KRED_ISO639_SV, $PNO_SE, $pclass,
2388
+ $ysalary, $result);
2389
+ }
2390
+
2391
+ function add_transaction_no($eid, $estoreUser, $secret, $estoreOrderNo,
2392
+ $goodsList, $shipmentfee, $shipmenttype,
2393
+ $handlingfee, $pno, $fname, $lname, $addr, $passwd,
2394
+ $clientIp, $newPasswd, $flags, $comment,
2395
+ $ready_date, $rand_string, $pclass, $ysalary,
2396
+ &$result) {
2397
+ global $PNO_NO, $KRED_NOK, $KRED_ISO3166_NO, $KRED_ISO639_NB;
2398
+ return add_transaction($eid, $estoreUser, $secret, $estoreOrderNo,
2399
+ $goodsList, $shipmentfee, $shipmenttype,
2400
+ $handlingfee, $pno, $fname, $lname, $addr, $passwd,
2401
+ $clientIp, $newPasswd, $flags, $comment,
2402
+ $ready_date, $rand_string, $KRED_NOK,
2403
+ $KRED_ISO3166_NO, $KRED_ISO639_NB, $PNO_NO, $pclass,
2404
+ $ysalary, $result);
2405
+ }
2406
+
2407
+
2408
+ function add_transaction_dk($eid, $estoreUser, $secret, $estoreOrderNo,
2409
+ $goodsList, $shipmentfee, $shipmenttype,
2410
+ $handlingfee, $pno, $fname, $lname, $addr, $passwd,
2411
+ $clientIp, $newPasswd, $flags, $comment,
2412
+ $ready_date, $rand_string, $pclass, $ysalary,
2413
+ &$result) {
2414
+ global $PNO_DK, $KRED_DKK, $KRED_ISO3166_DK, $KRED_ISO639_DA;
2415
+ return add_transaction($eid, $estoreUser, $secret, $estoreOrderNo,
2416
+ $goodsList, $shipmentfee, $shipmenttype,
2417
+ $handlingfee, $pno, $fname, $lname, $addr, $passwd,
2418
+ $clientIp, $newPasswd, $flags, $comment,
2419
+ $ready_date, $rand_string, $KRED_DKK,
2420
+ $KRED_ISO3166_DK, $KRED_ISO639_DA, $PNO_DK, $pclass,
2421
+ $ysalary, $result);
2422
+ }
2423
+
2424
+ function add_transaction_fi($eid, $estoreUser, $secret, $estoreOrderNo,
2425
+ $goodsList, $shipmentfee, $shipmenttype,
2426
+ $handlingfee, $pno, $fname, $lname, $addr, $passwd,
2427
+ $clientIp, $newPasswd, $flags, $comment,
2428
+ $ready_date, $rand_string, $pclass, $ysalary,
2429
+ &$result) {
2430
+ global $PNO_FI, $KRED_EUR, $KRED_ISO3166_FI, $KRED_ISO639_FI;
2431
+ return add_transaction($eid, $estoreUser, $secret, $estoreOrderNo,
2432
+ $goodsList, $shipmentfee, $shipmenttype,
2433
+ $handlingfee, $pno, $fname, $lname, $addr, $passwd,
2434
+ $clientIp, $newPasswd, $flags, $comment,
2435
+ $ready_date, $rand_string, $KRED_EUR,
2436
+ $KRED_ISO3166_FI, $KRED_ISO639_FI, $PNO_FI, $pclass,
2437
+ $ysalary, $result);
2438
+ }
2439
+
2440
+ function add_transaction($eid, $estoreUser, $secret, $estoreOrderNo,$goodsList,
2441
+ $shipmentfee, $shipmenttype, $handlingfee, $pno,
2442
+ $fname, $lname, $addr, $passwd, $clientIp, $newPasswd,
2443
+ $flags, $comment, $ready_date, $rand_string,
2444
+ $currency, $country, $language, $pno_encoding,
2445
+ $pclass, $ysalary, &$result) {
2446
+ our_settype_integer($eid);
2447
+ our_settype_string($estoreUser);
2448
+ our_settype_string($secret);
2449
+ our_settype_string($estoreOrderNo);
2450
+ our_settype_integer($shipmentfee);
2451
+ our_settype_integer($shipmenttype);
2452
+ our_settype_integer($handlingfee);
2453
+ our_strip_string($pno);
2454
+ our_settype_string($fname);
2455
+ our_settype_string($lname);
2456
+ our_settype_string($passwd);
2457
+ our_settype_string($clientIp);
2458
+ our_settype_string($newPasswd);
2459
+ our_settype_integer($flags);
2460
+ settype($comment, "string");
2461
+ our_settype_string($ready_date);
2462
+ our_settype_integer($currency);
2463
+ our_settype_integer($country);
2464
+ our_settype_integer($language);
2465
+ our_settype_integer($pno_encoding);
2466
+ our_settype_integer($pclass);
2467
+ our_settype_integer($ysalary);
2468
+ $digestSecret = add_invoice_digest($goodsList, $secret);
2469
+ $paramList =
2470
+ array($eid, $estoreUser, $digestSecret,
2471
+ $estoreOrderNo, $goodsList, $shipmentfee, $shipmenttype,
2472
+ $handlingfee, $pno, $fname, $lname, $addr, $passwd, $clientIp,
2473
+ $newPasswd, $flags, $comment, $ready_date, $rand_string,
2474
+ $currency, $country, $language, $pno_encoding, $pclass, $ysalary);
2475
+ return kred_call("add_invoice", $paramList, $result, $eid, $secret);
2476
+ }
2477
+
2478
+ /*
2479
+ * API: invoice_address
2480
+ */
2481
+
2482
+ function invoice_address($eid, $invno, $secret, &$result) {
2483
+ our_settype_integer($eid);
2484
+ our_settype_string($invno);
2485
+ our_settype_string($secret);
2486
+ $digestSecret = invoice_digest($eid, $invno, $secret);
2487
+ $paramList = array($eid, $invno, $digestSecret);
2488
+ return kred_call("invoice_address", $paramList, $result, $eid, $secret);
2489
+ }
2490
+
2491
+ /*
2492
+ * API: get_addresses
2493
+ */
2494
+
2495
+ function get_addresses($eid, $pno, $secret, $pnoencoding, $type, &$result) {
2496
+ our_settype_integer($eid);
2497
+ our_strip_string($pno);
2498
+ our_settype_string($secret);
2499
+ our_settype_integer($pnoencoding);
2500
+ our_settype_integer($type);
2501
+ $digestSecret = invoice_digest($eid, $pno, $secret);
2502
+ $paramList = array($pno, $eid, $digestSecret, $pnoencoding, $type);
2503
+ return kred_call("get_addresses", $paramList, $result, $eid, $secret);
2504
+ }
2505
+
2506
+ /*
2507
+ * API: invoice_amount
2508
+ */
2509
+
2510
+ function invoice_amount($eid, $invno, $secret, &$result) {
2511
+ our_settype_integer($eid);
2512
+ our_settype_string($invno);
2513
+ our_settype_string($secret);
2514
+ $digestSecret = invoice_digest($eid, $invno, $secret);
2515
+ $paramList = array($eid, $invno, $digestSecret);
2516
+ return kred_call("invoice_amount", $paramList, $result, $eid, $secret);
2517
+ }
2518
+
2519
+ /*
2520
+ * API: delete_invoice
2521
+ */
2522
+
2523
+ function delete_invoice($eid, $invno, $secret, &$result) {
2524
+ our_settype_integer($eid);
2525
+ our_settype_string($invno);
2526
+ our_settype_string($secret);
2527
+ $digestSecret = invoice_digest($eid, $invno, $secret);
2528
+ $paramList = array($eid, $invno, $digestSecret);
2529
+ return kred_call("delete_invoice", $paramList, $result, $eid, $secret);
2530
+ }
2531
+
2532
+ /**
2533
+ *
2534
+ * @param int $eid Store id.
2535
+ * @param string $function the name of the function that is sent
2536
+ * @param string $time ???
2537
+ * @param string $selectTime ???
2538
+ * @param string $Status Transaction Result
2539
+ * @param string $Url the URL that is contact with in the transaction moment, beta-test.klarna.com or payment.klarna.com
2540
+ * @param string $secret Shared secret used to confirm the integrity of the store.
2541
+ */
2542
+ function send_stat($eid, $function, $time, $selectTime, $Status, $Url, $secret) {
2543
+ $client_sendstats_host = 'udp://clientstat.kreditor.se';
2544
+ $client_sendstats_port = '80';
2545
+
2546
+
2547
+ $fp = @fsockopen($client_sendstats_host, $client_sendstats_port, $errno, $errstr, 1500);
2548
+
2549
+ if ($fp) {
2550
+
2551
+ $data = "";
2552
+ $checksum = "";
2553
+ $data .= $eid . '|';
2554
+ $checksum .= $eid . '|';
2555
+ $data .= $function . '|';
2556
+ $checksum .= $function . '|';
2557
+ $data .= $time . '|';
2558
+ $checksum .= $time . '|';
2559
+ $data .= $selectTime . '|';
2560
+ $checksum .= $selectTime . '|';
2561
+ $data .= $Status . '|';
2562
+ $checksum .= $Status . '|';
2563
+ $data .= $Url . '|';
2564
+ $checksum .= $Url . '|';
2565
+ $checksum .= $secret;
2566
+ $digest = md5_base64($checksum);
2567
+ $data .= $digest;
2568
+
2569
+ @fwrite($fp, $data);
2570
+ @fclose($fp);
2571
+ }
2572
+ }
2573
+
2574
+ /*
2575
+ * API: strerror
2576
+ */
2577
+
2578
+ function strerror($reason) {
2579
+ switch ($reason) {
2580
+ case "unknown_estore":
2581
+ case "estore_blacklisted":
2582
+ case "invalid_estore_secret":
2583
+ case "customer_blacklisted":
2584
+ return "N�got har g�tt snett i kommunikationen mellan butiken och Kreditor, som sk�ter v�r fakturering. Kontakta Kreditor (http://www.faktureramig.se) f�r mer information eller v�lj ett annat s�tt att betala.";
2585
+ case "customer_not_accepted":
2586
+ return "Kreditor, som sk�ter v�r fakturering, har inte registrerat inbetalningar p� alla Era f�rfallna fakturor. Kontakta Kreditor (http://www.faktureramig.se) f�r mer information eller v�lj ett annat s�tt att betala.";
2587
+ case "bad_customer_password":
2588
+ return "Du har angivit ett felaktigt l�senord.";
2589
+ case "dead":
2590
+ case "no_such_person":
2591
+ case "pno":
2592
+ case "invalid_pno":
2593
+ return "Du har angivit ett ogiltigt personnummer.";
2594
+ case "under_aged":
2595
+ case "customer_not_18":
2596
+ return "Du m�ste vara �ver 18 �r f�r att f� handla mot faktura.";
2597
+ case "estore_overrun":
2598
+ case "customer_credit_overrun":
2599
+ return "Tyv�rr erk�nner Kreditor, som sk�ter v�r fakturering, att man endast har ett visst maxbelopp i utest�ende betalningar. V�nligen kontakta Kreditor (http://www.faktureramig.se) f�r mer information eller v�lj ett annat s�tt att betala.";
2600
+ case "blocked":
2601
+ case "unpaid_bills":
2602
+ return "Tyv�rr kunde inte Kreditor som sk�ter v�r fakturering godk�nna k�pet efter kreditkontroll. V�nligen kontakta Kreditor (http://www.faktureramig.se) f�r mer information eller v�lj ett annat s�tt att betala.";
2603
+ case "bad_name":
2604
+ return "Du har angivit ett namn som inte st�mmer �verens med ert personnummer. V�nligen korrigera informationen eller v�lj ett annat s�tt att betala.";
2605
+ case "foreign_addr":
2606
+ case "bad_addr":
2607
+ return"Du har angivit en adress som inte st�mmer �verens med ert personnummer. V�nligen korrigera informationen eller v�lj ett annat s�tt att betala.";
2608
+ case "postno":
2609
+ case "bad_postno":
2610
+ return "Du har angivit ett ogiltigt postnummer.";
2611
+ case "no_such_subscription":
2612
+ return "This error means that an operation such as freeze refered to a customer subscription that doesn't exist";
2613
+ case "not_unique_subscription_no":
2614
+ return "The estore must provide estore order numbers that are unique for that estore, if they don't this error is returned from the XML-RPC operations";;
2615
+ case "terminated":
2616
+ return "It's not possible to i.e freeze a terminated subscription";
2617
+ case "already_set":
2618
+ return "It's not possible to i.e freeze a frozen subscription";
2619
+ case "need_email_addr":
2620
+ return "This error may be returned when the subscription is created and (a) the subscription type requires auth by email and (b) the XML-RPC from the estore that tries to create the subscription doesn't have a valid email addr in the email field";
2621
+
2622
+ default:
2623
+ return "N�got har g�tt snett i kommunikationen mellan butiken och Kreditor, som sk�ter v�r fakturering. Kontakta Kreditor (http://www.faktureramig.se) f�r mer information eller v�lj ett annat s�tt att betala (Felkod: " .
2624
+ $reason . ").";
2625
+ }
2626
+ }
2627
+
2628
+ /*
2629
+ * API: update_charge_amount
2630
+ */
2631
+
2632
+ function update_charge_amount($eid, $invno, $secret, $type, $newAmount,
2633
+ &$result) {
2634
+ our_settype_integer($eid);
2635
+ our_settype_string($invno);
2636
+ our_settype_string($secret);
2637
+ our_settype_integer($type);
2638
+ our_settype_integer($newAmount);
2639
+ $digestSecret =
2640
+ update_charge_amount_digest($invno, $type, $newAmount, $secret);
2641
+ $paramList = array($eid, $digestSecret,
2642
+ $invno, $type, $newAmount);
2643
+ return kred_call("update_charge_amount", $paramList, $result, $eid, $secret);
2644
+ }
2645
+
2646
+ /*
2647
+ * API: update_goods_qty
2648
+ */
2649
+
2650
+ function update_goods_qty($eid, $invno, $secret, $artno, $newQty, &$result) {
2651
+ our_settype_integer($eid);
2652
+ our_settype_string($invno);
2653
+ our_settype_string($secret);
2654
+ our_settype_string($artno);
2655
+ our_settype_integer($newQty);
2656
+ $digestSecret = update_goods_qty_digest($invno, $artno, $newQty, $secret);
2657
+ $paramList = array($eid, $digestSecret, $invno, $artno, $newQty);
2658
+ return kred_call("update_goods_qty", $paramList, $result, $eid, $secret);
2659
+ }
2660
+
2661
+ /*
2662
+ * API: update_orderno
2663
+ */
2664
+
2665
+ function update_orderno($eid, $invno, $secret, $estoreOrderNo, &$result) {
2666
+ our_settype_integer($eid);
2667
+ our_settype_string($secret);
2668
+ our_settype_string($invno);
2669
+ our_settype_string($estoreOrderNo);
2670
+ $digestSecret = update_orderno_digest($invno, $estoreOrderNo, $secret);
2671
+ $paramList = array($eid, $digestSecret, $invno, $estoreOrderNo);
2672
+ return kred_call("update_orderno", $paramList, $result, $eid, $secret);
2673
+ }
2674
+
2675
+
2676
+ /*
2677
+ * API: update_notes
2678
+ */
2679
+
2680
+ function update_notes($eid, $invno, $secret, $notes, &$result) {
2681
+ our_settype_integer($eid);
2682
+ our_settype_string($secret);
2683
+ our_settype_string($invno);
2684
+ our_settype_string($notes);
2685
+ $digestSecret = update_notes_digest($invno, $notes, $secret);
2686
+ $paramList = array($eid, $digestSecret, $invno, $notes);
2687
+ return kred_call("update_notes", $paramList, $result, $eid, $secret);
2688
+ }
2689
+
2690
+ /*
2691
+ * API: update_email
2692
+ */
2693
+
2694
+ function update_email($eid, $secret, $pno, $email, &$result) {
2695
+ our_settype_integer($eid);
2696
+ our_settype_string($secret);
2697
+ our_strip_string($pno);
2698
+ our_settype_string($email);
2699
+ $digestSecret = update_notes_digest($pno, $email, $secret);
2700
+ $paramList = array($eid, $digestSecret, $pno, $email);
2701
+ return kred_call("update_email", $paramList, $result, $eid, $secret);
2702
+ }
2703
+
2704
+
2705
+ /*
2706
+ * API: periodic_cost
2707
+ */
2708
+ function periodic_cost($eid, $sum, $pclass, $country, $flags, $secret,
2709
+ &$result){
2710
+ $months = get_months($pclass);
2711
+ $monthfee = get_month_fee($pclass);
2712
+ $startfee = get_start_fee($pclass);
2713
+ $rate = get_rate($pclass);
2714
+ $result = periodic_cost2($sum, $months, $monthfee, $startfee, $rate);
2715
+ return 0;
2716
+ }
2717
+
2718
+ function periodic_cost2($sum, $months, $monthfee, $startfee, $rate){
2719
+ $dailyrate = daily_rate($rate);
2720
+ $monthpayment = calc_monthpayment($sum + $startfee, $dailyrate, $months);
2721
+ return round($monthpayment + $monthfee);
2722
+ }
2723
+
2724
+ function daily_rate($rate){
2725
+ return pow((($rate / 10000) + 1), (1 / 365.25));
2726
+ }
2727
+
2728
+
2729
+ function calc_monthpayment($sum, $dailyrate, $months){
2730
+ $dates = 0;
2731
+ $totdates = (($months - 1) * 30);
2732
+ $denom = calc_denom($dailyrate, $totdates);
2733
+ $totdates = $totdates + 60;
2734
+ return ((pow($dailyrate, $totdates) * $sum) / $denom);
2735
+ }
2736
+
2737
+ function calc_denom($dailyrate, $totdates){
2738
+ $sum = 1;
2739
+ $startdates = 0;
2740
+ while ($totdates > $startdates){
2741
+ $startdates = $startdates + 30;
2742
+ $sum = ($sum + pow($dailyrate, $startdates));
2743
+ }
2744
+ return $sum;
2745
+ }
2746
+
2747
+ function periodic_cost_rpc($eid, $sum, $pclass, $currency, $flags, $secret,
2748
+ &$result){
2749
+ our_settype_integer($eid);
2750
+ our_settype_integer($sum);
2751
+ our_settype_integer($pclass);
2752
+ our_settype_integer($currency);
2753
+ our_settype_integer($flags);
2754
+ $digestSecret = periodic_cost_digest($eid, $sum, $pclass, $secret);
2755
+ $paramList = array($eid, $sum, $pclass, $currency, $flags, $digestSecret);
2756
+ return kred_call("periodic_cost", $paramList, $result, $eid, $secret);
2757
+
2758
+ }
2759
+
2760
+
2761
+ /*
2762
+ * Digests
2763
+ */
2764
+
2765
+ function invoice_digest($eid, $invno, $secret) {
2766
+ $string = $eid . ":" . $invno . ":" . $secret;
2767
+ return md5_base64($string);
2768
+ }
2769
+
2770
+ function activate_part_digest($eid, $invno, $artnos, $secret) {
2771
+ $string = $eid . ":" . $invno . ":";
2772
+
2773
+ foreach ($artnos as $artno)
2774
+ $string .= $artno["artno"] . ":". $artno["qty"] . ":";
2775
+
2776
+ return md5_base64($string . $secret);
2777
+
2778
+ }
2779
+
2780
+ function add_invoice_digest($goodsList, $secret) {
2781
+ $string = "";
2782
+
2783
+ foreach ($goodsList as $goods)
2784
+ $string .= $goods["goods"]["title"] . ":";
2785
+
2786
+ return md5_base64($string . $secret);
2787
+ }
2788
+
2789
+ function subscription_digest($sid, $estoreSubscNo, $secret) {
2790
+ $string = $sid . ":" . $estoreSubscNo . ":" . $secret;
2791
+ return md5_base64($string);
2792
+ }
2793
+
2794
+ function update_charge_amount_digest($invno, $type, $newAmount, $secret) {
2795
+ $string = $invno . ":" . $type . ":" . $newAmount . ":" . $secret;
2796
+ return md5_base64($string);
2797
+ }
2798
+
2799
+ function update_goods_qty_digest($invno, $artno, $newQty, $secret) {
2800
+ $string = $invno . ":" . $artno . ":" . $newQty . ":" . $secret;
2801
+ return md5_base64($string);
2802
+ }
2803
+
2804
+ function update_orderno_digest($invno, $orderno, $secret) {
2805
+ $string = $invno . ":" . $orderno . ":" . $secret;
2806
+ return md5_base64($string);
2807
+ }
2808
+
2809
+ function update_notes_digest($invno, $notes, $secret) {
2810
+ $string = $invno . ":" . $notes . ":" . $secret;
2811
+ return md5_base64($string);
2812
+ }
2813
+
2814
+ function periodic_cost_digest($eid, $sum, $pclass, $secret){
2815
+ $string = $eid . ":" . $sum . ":" . $pclass . ":" . $secret;
2816
+ return md5_base64($string);
2817
+ }
2818
+
2819
+ function md5_base64($data) {
2820
+ return base64_encode(pack("H*", md5($data)));
2821
+ }
2822
+
2823
+
2824
+ /*
2825
+ * EPI XMLRPC call
2826
+ */
2827
+
2828
+ function xmlrpc_call($host, $port, $request) {
2829
+ $fp = fsockopen($host, $port, $errno, $errstr, 30);
2830
+ $query = "POST / HTTP/1.0\r\nUser-Agent: Kreditor PHP Client\r\nHost: " . $host."\nConnection: close\r\nContent-Type: text/xml\r\nContent-Length: " . strlen($request) . "\r\n\r\n" . $request;
2831
+
2832
+ if (!fputs($fp, $query, strlen($query))) {
2833
+ $errstr = "Write error";
2834
+ return 0;
2835
+ }
2836
+
2837
+ $contents = "";
2838
+
2839
+ while (!feof($fp))
2840
+ $contents .= fgets($fp);
2841
+
2842
+ fclose($fp);
2843
+ return $contents;
2844
+ }
2845
+
2846
+ /*
2847
+ * Utilities
2848
+ */
2849
+
2850
+ function our_settype_integer(&$x) {
2851
+ if (is_double($x)) {
2852
+ $x = round($x)+(($x>0)?0.00000001:-0.00000001);
2853
+ } else if (is_float($x)) {
2854
+ $x = round($x)+(($x>0)?0.00000001:-0.00000001);
2855
+ } else if (is_string($x)) {
2856
+ $x = preg_replace("/[ \n\r\t\e]/", "", $x);
2857
+ }
2858
+
2859
+ settype($x, "integer");
2860
+ }
2861
+
2862
+ function our_strip_string(&$x) {
2863
+ $x = str_replace(array(" ","-"), "", $x);
2864
+ }
2865
+
2866
+ function our_settype_string(&$x){
2867
+ settype($x, "string");
2868
+ $res = "";
2869
+ $length = strlen($x);
2870
+ for($i = 0; $i < $length; $i++){
2871
+ if($x[$i] >= " "){
2872
+ $res .= $x[$i];
2873
+ }else{
2874
+ $res .= " ";
2875
+ }
2876
+ }
2877
+ $x = $res;
2878
+ }
2879
+
2880
+ function check_params($function, $paramList) {
2881
+ }
2882
+
2883
+ /**
2884
+ * PHP implementation of the XML-RPC protocol
2885
+ *
2886
+ * This is a PEAR-ified version of Useful inc's XML-RPC for PHP.
2887
+ * It has support for HTTP transport, proxies and authentication.
2888
+ *
2889
+ * PHP versions 4 and 5
2890
+ *
2891
+ * LICENSE: License is granted to use or modify this software
2892
+ * ("XML-RPC for PHP") for commercial or non-commercial use provided the
2893
+ * copyright of the author is preserved in any distributed or derivative work.
2894
+ *
2895
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESSED OR
2896
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2897
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2898
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2899
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2900
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2901
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2902
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2903
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2904
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2905
+ *
2906
+ * @category Web Services
2907
+ * @package XML_RPC
2908
+ * @author Edd Dumbill <edd@usefulinc.com>
2909
+ * @author Stig Bakken <stig@php.net>
2910
+ * @author Martin Jansen <mj@php.net>
2911
+ * @author Daniel Convissor <danielc@php.net>
2912
+ * @copyright 1999-2001 Edd Dumbill, 2001-2005 The PHP Group
2913
+ * @version CVS: $Id: kreditor.php.src 12388 2008-06-03 08:07:05Z mikael $
2914
+ * @link http://pear.php.net/package/XML_RPC
2915
+ */
2916
+
2917
+
2918
+ if (!function_exists('xml_parser_create')) {
2919
+ PEAR::loadExtension('xml');
2920
+ }
2921
+
2922
+ /**#@+
2923
+ * Error constants
2924
+ */
2925
+ /**
2926
+ * Parameter values don't match parameter types
2927
+ */
2928
+ define('XML_RPC_ERROR_INVALID_TYPE', 101);
2929
+ /**
2930
+ * Parameter declared to be numeric but the values are not
2931
+ */
2932
+ define('XML_RPC_ERROR_NON_NUMERIC_FOUND', 102);
2933
+ /**
2934
+ * Communication error
2935
+ */
2936
+ define('XML_RPC_ERROR_CONNECTION_FAILED', 103);
2937
+ /**
2938
+ * The array or struct has already been started
2939
+ */
2940
+ define('XML_RPC_ERROR_ALREADY_INITIALIZED', 104);
2941
+ /**
2942
+ * Incorrect parameters submitted
2943
+ */
2944
+ define('XML_RPC_ERROR_INCORRECT_PARAMS', 105);
2945
+ /**
2946
+ * Programming error by developer
2947
+ */
2948
+ define('XML_RPC_ERROR_PROGRAMMING', 106);
2949
+ /**#@-*/
2950
+
2951
+
2952
+ /**
2953
+ * Data types
2954
+ * @global string $GLOBALS['XML_RPC_I4']
2955
+ */
2956
+ $GLOBALS['XML_RPC_I4'] = 'i4';
2957
+
2958
+ /**
2959
+ * Data types
2960
+ * @global string $GLOBALS['XML_RPC_Int']
2961
+ */
2962
+ $GLOBALS['XML_RPC_Int'] = 'int';
2963
+
2964
+ /**
2965
+ * Data types
2966
+ * @global string $GLOBALS['XML_RPC_Boolean']
2967
+ */
2968
+ $GLOBALS['XML_RPC_Boolean'] = 'boolean';
2969
+
2970
+ /**
2971
+ * Data types
2972
+ * @global string $GLOBALS['XML_RPC_Double']
2973
+ */
2974
+ $GLOBALS['XML_RPC_Double'] = 'double';
2975
+
2976
+ /**
2977
+ * Data types
2978
+ * @global string $GLOBALS['XML_RPC_String']
2979
+ */
2980
+ $GLOBALS['XML_RPC_String'] = 'string';
2981
+
2982
+ /**
2983
+ * Data types
2984
+ * @global string $GLOBALS['XML_RPC_DateTime']
2985
+ */
2986
+ $GLOBALS['XML_RPC_DateTime'] = 'dateTime.iso8601';
2987
+
2988
+ /**
2989
+ * Data types
2990
+ * @global string $GLOBALS['XML_RPC_Base64']
2991
+ */
2992
+ $GLOBALS['XML_RPC_Base64'] = 'base64';
2993
+
2994
+ /**
2995
+ * Data types
2996
+ * @global string $GLOBALS['XML_RPC_Array']
2997
+ */
2998
+ $GLOBALS['XML_RPC_Array'] = 'array';
2999
+
3000
+ /**
3001
+ * Data types
3002
+ * @global string $GLOBALS['XML_RPC_Struct']
3003
+ */
3004
+ $GLOBALS['XML_RPC_Struct'] = 'struct';
3005
+
3006
+
3007
+ /**
3008
+ * Data type meta-types
3009
+ * @global array $GLOBALS['XML_RPC_Types']
3010
+ */
3011
+ $GLOBALS['XML_RPC_Types'] = array(
3012
+ $GLOBALS['XML_RPC_I4'] => 1,
3013
+ $GLOBALS['XML_RPC_Int'] => 1,
3014
+ $GLOBALS['XML_RPC_Boolean'] => 1,
3015
+ $GLOBALS['XML_RPC_String'] => 1,
3016
+ $GLOBALS['XML_RPC_Double'] => 1,
3017
+ $GLOBALS['XML_RPC_DateTime'] => 1,
3018
+ $GLOBALS['XML_RPC_Base64'] => 1,
3019
+ $GLOBALS['XML_RPC_Array'] => 2,
3020
+ $GLOBALS['XML_RPC_Struct'] => 3,
3021
+ );
3022
+
3023
+
3024
+ /**
3025
+ * Error message numbers
3026
+ * @global array $GLOBALS['XML_RPC_err']
3027
+ */
3028
+ $GLOBALS['XML_RPC_err'] = array(
3029
+ 'unknown_method' => 1,
3030
+ 'invalid_return' => 2,
3031
+ 'incorrect_params' => 3,
3032
+ 'introspect_unknown' => 4,
3033
+ 'http_error' => 5,
3034
+ 'not_response_object' => 6,
3035
+ 'invalid_request' => 7,
3036
+ );
3037
+
3038
+ /**
3039
+ * Error message strings
3040
+ * @global array $GLOBALS['XML_RPC_str']
3041
+ */
3042
+ $GLOBALS['XML_RPC_str'] = array(
3043
+ 'unknown_method' => 'Unknown method',
3044
+ 'invalid_return' => 'Invalid return payload: enable debugging to examine incoming payload',
3045
+ 'incorrect_params' => 'Incorrect parameters passed to method',
3046
+ 'introspect_unknown' => 'Can\'t introspect: method unknown',
3047
+ 'http_error' => 'Didn\'t receive 200 OK from remote server.',
3048
+ 'not_response_object' => 'The requested method didn\'t return an XML_RPC_Response object.',
3049
+ 'invalid_request' => 'Invalid request payload',
3050
+ );
3051
+
3052
+
3053
+ /**
3054
+ * Default XML encoding (ISO-8859-1, UTF-8 or US-ASCII)
3055
+ * @global string $GLOBALS['XML_RPC_defencoding']
3056
+ */
3057
+ $GLOBALS['XML_RPC_defencoding'] = 'UTF-8';
3058
+
3059
+ /**
3060
+ * User error codes start at 800
3061
+ * @global int $GLOBALS['XML_RPC_erruser']
3062
+ */
3063
+ $GLOBALS['XML_RPC_erruser'] = 800;
3064
+
3065
+ /**
3066
+ * XML parse error codes start at 100
3067
+ * @global int $GLOBALS['XML_RPC_errxml']
3068
+ */
3069
+ $GLOBALS['XML_RPC_errxml'] = 100;
3070
+
3071
+
3072
+ /**
3073
+ * Compose backslashes for escaping regexp
3074
+ * @global string $GLOBALS['XML_RPC_backslash']
3075
+ */
3076
+ $GLOBALS['XML_RPC_backslash'] = chr(92) . chr(92);
3077
+
3078
+
3079
+ /**
3080
+ * Valid parents of XML elements
3081
+ * @global array $GLOBALS['XML_RPC_valid_parents']
3082
+ */
3083
+ $GLOBALS['XML_RPC_valid_parents'] = array(
3084
+ 'BOOLEAN' => array('VALUE'),
3085
+ 'I4' => array('VALUE'),
3086
+ 'INT' => array('VALUE'),
3087
+ 'STRING' => array('VALUE'),
3088
+ 'DOUBLE' => array('VALUE'),
3089
+ 'DATETIME.ISO8601' => array('VALUE'),
3090
+ 'BASE64' => array('VALUE'),
3091
+ 'ARRAY' => array('VALUE'),
3092
+ 'STRUCT' => array('VALUE'),
3093
+ 'PARAM' => array('PARAMS'),
3094
+ 'METHODNAME' => array('METHODCALL'),
3095
+ 'PARAMS' => array('METHODCALL', 'METHODRESPONSE'),
3096
+ 'MEMBER' => array('STRUCT'),
3097
+ 'NAME' => array('MEMBER'),
3098
+ 'DATA' => array('ARRAY'),
3099
+ 'FAULT' => array('METHODRESPONSE'),
3100
+ 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT'),
3101
+ );
3102
+
3103
+
3104
+ /**
3105
+ * Stores state during parsing
3106
+ *
3107
+ * quick explanation of components:
3108
+ * + ac = accumulates values
3109
+ * + qt = decides if quotes are needed for evaluation
3110
+ * + cm = denotes struct or array (comma needed)
3111
+ * + isf = indicates a fault
3112
+ * + lv = indicates "looking for a value": implements the logic
3113
+ * to allow values with no types to be strings
3114
+ * + params = stores parameters in method calls
3115
+ * + method = stores method name
3116
+ *
3117
+ * @global array $GLOBALS['XML_RPC_xh']
3118
+ */
3119
+ $GLOBALS['XML_RPC_xh'] = array();
3120
+
3121
+
3122
+ /**
3123
+ * Start element handler for the XML parser
3124
+ *
3125
+ * @return void
3126
+ */
3127
+ function XML_RPC_se($parser_resource, $name, $attrs)
3128
+ {
3129
+ global $XML_RPC_xh, $XML_RPC_DateTime, $XML_RPC_String, $XML_RPC_valid_parents;
3130
+ $parser = (int) $parser_resource;
3131
+
3132
+ // if invalid xmlrpc already detected, skip all processing
3133
+ if ($XML_RPC_xh[$parser]['isf'] >= 2) {
3134
+ return;
3135
+ }
3136
+
3137
+ // check for correct element nesting
3138
+ // top level element can only be of 2 types
3139
+ if (count($XML_RPC_xh[$parser]['stack']) == 0) {
3140
+ if ($name != 'METHODRESPONSE' && $name != 'METHODCALL') {
3141
+ $XML_RPC_xh[$parser]['isf'] = 2;
3142
+ $XML_RPC_xh[$parser]['isf_reason'] = 'missing top level xmlrpc element';
3143
+ return;
3144
+ }
3145
+ } else {
3146
+ // not top level element: see if parent is OK
3147
+ if (!in_array($XML_RPC_xh[$parser]['stack'][0], $XML_RPC_valid_parents[$name])) {
3148
+ $name = preg_replace('[^a-zA-Z0-9._-]', '', $name);
3149
+ $XML_RPC_xh[$parser]['isf'] = 2;
3150
+ $XML_RPC_xh[$parser]['isf_reason'] = "xmlrpc element $name cannot be child of {$XML_RPC_xh[$parser]['stack'][0]}";
3151
+ return;
3152
+ }
3153
+ }
3154
+
3155
+ switch ($name) {
3156
+ case 'STRUCT':
3157
+ $XML_RPC_xh[$parser]['cm']++;
3158
+
3159
+ // turn quoting off
3160
+ $XML_RPC_xh[$parser]['qt'] = 0;
3161
+
3162
+ $cur_val = array();
3163
+ $cur_val['value'] = array();
3164
+ $cur_val['members'] = 1;
3165
+ array_unshift($XML_RPC_xh[$parser]['valuestack'], $cur_val);
3166
+ break;
3167
+
3168
+ case 'ARRAY':
3169
+ $XML_RPC_xh[$parser]['cm']++;
3170
+
3171
+ // turn quoting off
3172
+ $XML_RPC_xh[$parser]['qt'] = 0;
3173
+
3174
+ $cur_val = array();
3175
+ $cur_val['value'] = array();
3176
+ $cur_val['members'] = 0;
3177
+ array_unshift($XML_RPC_xh[$parser]['valuestack'], $cur_val);
3178
+ break;
3179
+
3180
+ case 'NAME':
3181
+ $XML_RPC_xh[$parser]['ac'] = '';
3182
+ break;
3183
+
3184
+ case 'FAULT':
3185
+ $XML_RPC_xh[$parser]['isf'] = 1;
3186
+ break;
3187
+
3188
+ case 'PARAM':
3189
+ $XML_RPC_xh[$parser]['valuestack'] = array();
3190
+ break;
3191
+
3192
+ case 'VALUE':
3193
+ $XML_RPC_xh[$parser]['lv'] = 1;
3194
+ $XML_RPC_xh[$parser]['vt'] = $XML_RPC_String;
3195
+ $XML_RPC_xh[$parser]['ac'] = '';
3196
+ $XML_RPC_xh[$parser]['qt'] = 0;
3197
+ // look for a value: if this is still 1 by the
3198
+ // time we reach the first data segment then the type is string
3199
+ // by implication and we need to add in a quote
3200
+ break;
3201
+
3202
+ case 'I4':
3203
+ case 'INT':
3204
+ case 'STRING':
3205
+ case 'BOOLEAN':
3206
+ case 'DOUBLE':
3207
+ case 'DATETIME.ISO8601':
3208
+ case 'BASE64':
3209
+ $XML_RPC_xh[$parser]['ac'] = ''; // reset the accumulator
3210
+
3211
+ if ($name == 'DATETIME.ISO8601' || $name == 'STRING') {
3212
+ $XML_RPC_xh[$parser]['qt'] = 1;
3213
+
3214
+ if ($name == 'DATETIME.ISO8601') {
3215
+ $XML_RPC_xh[$parser]['vt'] = $XML_RPC_DateTime;
3216
+ }
3217
+
3218
+ } elseif ($name == 'BASE64') {
3219
+ $XML_RPC_xh[$parser]['qt'] = 2;
3220
+ } else {
3221
+ // No quoting is required here -- but
3222
+ // at the end of the element we must check
3223
+ // for data format errors.
3224
+ $XML_RPC_xh[$parser]['qt'] = 0;
3225
+ }
3226
+ break;
3227
+
3228
+ case 'MEMBER':
3229
+ $XML_RPC_xh[$parser]['ac'] = '';
3230
+ break;
3231
+
3232
+ case 'DATA':
3233
+ case 'METHODCALL':
3234
+ case 'METHODNAME':
3235
+ case 'METHODRESPONSE':
3236
+ case 'PARAMS':
3237
+ // valid elements that add little to processing
3238
+ break;
3239
+ }
3240
+
3241
+
3242
+ // Save current element to stack
3243
+ array_unshift($XML_RPC_xh[$parser]['stack'], $name);
3244
+
3245
+ if ($name != 'VALUE') {
3246
+ $XML_RPC_xh[$parser]['lv'] = 0;
3247
+ }
3248
+ }
3249
+
3250
+ /**
3251
+ * End element handler for the XML parser
3252
+ *
3253
+ * @return void
3254
+ */
3255
+ function XML_RPC_ee($parser_resource, $name)
3256
+ {
3257
+ global $XML_RPC_xh, $XML_RPC_Types, $XML_RPC_String;
3258
+ $parser = (int) $parser_resource;
3259
+
3260
+ if ($XML_RPC_xh[$parser]['isf'] >= 2) {
3261
+ return;
3262
+ }
3263
+
3264
+ // push this element from stack
3265
+ // NB: if XML validates, correct opening/closing is guaranteed and
3266
+ // we do not have to check for $name == $curr_elem.
3267
+ // we also checked for proper nesting at start of elements...
3268
+ $curr_elem = array_shift($XML_RPC_xh[$parser]['stack']);
3269
+
3270
+ switch ($name) {
3271
+ case 'STRUCT':
3272
+ case 'ARRAY':
3273
+ $cur_val = array_shift($XML_RPC_xh[$parser]['valuestack']);
3274
+ $XML_RPC_xh[$parser]['value'] = $cur_val['value'];
3275
+ $XML_RPC_xh[$parser]['vt'] = strtolower($name);
3276
+ $XML_RPC_xh[$parser]['cm']--;
3277
+ break;
3278
+
3279
+ case 'NAME':
3280
+ $XML_RPC_xh[$parser]['valuestack'][0]['name'] = $XML_RPC_xh[$parser]['ac'];
3281
+ break;
3282
+
3283
+ case 'BOOLEAN':
3284
+ // special case here: we translate boolean 1 or 0 into PHP
3285
+ // constants true or false
3286
+ if ($XML_RPC_xh[$parser]['ac'] == '1') {
3287
+ $XML_RPC_xh[$parser]['ac'] = 'true';
3288
+ } else {
3289
+ $XML_RPC_xh[$parser]['ac'] = 'false';
3290
+ }
3291
+
3292
+ $XML_RPC_xh[$parser]['vt'] = strtolower($name);
3293
+ // Drop through intentionally.
3294
+
3295
+ case 'I4':
3296
+ case 'INT':
3297
+ case 'STRING':
3298
+ case 'DOUBLE':
3299
+ case 'DATETIME.ISO8601':
3300
+ case 'BASE64':
3301
+ if ($XML_RPC_xh[$parser]['qt'] == 1) {
3302
+ // we use double quotes rather than single so backslashification works OK
3303
+ $XML_RPC_xh[$parser]['value'] = $XML_RPC_xh[$parser]['ac'];
3304
+ } elseif ($XML_RPC_xh[$parser]['qt'] == 2) {
3305
+ $XML_RPC_xh[$parser]['value'] = base64_decode($XML_RPC_xh[$parser]['ac']);
3306
+ } elseif ($name == 'BOOLEAN') {
3307
+ $XML_RPC_xh[$parser]['value'] = $XML_RPC_xh[$parser]['ac'];
3308
+ } else {
3309
+ // we have an I4, INT or a DOUBLE
3310
+ // we must check that only 0123456789-.<space> are characters here
3311
+ if (!ereg("^[+-]?[0123456789 \t\.]+$", $XML_RPC_xh[$parser]['ac'])) {
3312
+ XML_RPC_Base::raiseError('Non-numeric value received in INT or DOUBLE',
3313
+ XML_RPC_ERROR_NON_NUMERIC_FOUND);
3314
+ $XML_RPC_xh[$parser]['value'] = XML_RPC_ERROR_NON_NUMERIC_FOUND;
3315
+ } else {
3316
+ // it's ok, add it on
3317
+ $XML_RPC_xh[$parser]['value'] = $XML_RPC_xh[$parser]['ac'];
3318
+ }
3319
+ }
3320
+
3321
+ $XML_RPC_xh[$parser]['ac'] = '';
3322
+ $XML_RPC_xh[$parser]['qt'] = 0;
3323
+ $XML_RPC_xh[$parser]['lv'] = 3; // indicate we've found a value
3324
+ break;
3325
+
3326
+ case 'VALUE':
3327
+ if ($XML_RPC_xh[$parser]['vt'] == $XML_RPC_String) {
3328
+ if (strlen($XML_RPC_xh[$parser]['ac']) > 0) {
3329
+ $XML_RPC_xh[$parser]['value'] = $XML_RPC_xh[$parser]['ac'];
3330
+ } elseif ($XML_RPC_xh[$parser]['lv'] == 1) {
3331
+ // The <value> element was empty.
3332
+ $XML_RPC_xh[$parser]['value'] = '';
3333
+ }
3334
+ }
3335
+
3336
+ $temp = new XML_RPC_Value($XML_RPC_xh[$parser]['value'], $XML_RPC_xh[$parser]['vt']);
3337
+
3338
+ $cur_val = array_shift($XML_RPC_xh[$parser]['valuestack']);
3339
+ if (is_array($cur_val)) {
3340
+ if ($cur_val['members']==0) {
3341
+ $cur_val['value'][] = $temp;
3342
+ } else {
3343
+ $XML_RPC_xh[$parser]['value'] = $temp;
3344
+ }
3345
+ array_unshift($XML_RPC_xh[$parser]['valuestack'], $cur_val);
3346
+ } else {
3347
+ $XML_RPC_xh[$parser]['value'] = $temp;
3348
+ }
3349
+ break;
3350
+
3351
+ case 'MEMBER':
3352
+ $XML_RPC_xh[$parser]['ac'] = '';
3353
+ $XML_RPC_xh[$parser]['qt'] = 0;
3354
+
3355
+ $cur_val = array_shift($XML_RPC_xh[$parser]['valuestack']);
3356
+ if (is_array($cur_val)) {
3357
+ if ($cur_val['members']==1) {
3358
+ $cur_val['value'][$cur_val['name']] = $XML_RPC_xh[$parser]['value'];
3359
+ }
3360
+ array_unshift($XML_RPC_xh[$parser]['valuestack'], $cur_val);
3361
+ }
3362
+ break;
3363
+
3364
+ case 'DATA':
3365
+ $XML_RPC_xh[$parser]['ac'] = '';
3366
+ $XML_RPC_xh[$parser]['qt'] = 0;
3367
+ break;
3368
+
3369
+ case 'PARAM':
3370
+ $XML_RPC_xh[$parser]['params'][] = $XML_RPC_xh[$parser]['value'];
3371
+ break;
3372
+
3373
+ case 'METHODNAME':
3374
+ case 'RPCMETHODNAME':
3375
+ $XML_RPC_xh[$parser]['method'] = ereg_replace("^[\n\r\t ]+", '',
3376
+ $XML_RPC_xh[$parser]['ac']);
3377
+ break;
3378
+ }
3379
+
3380
+ // if it's a valid type name, set the type
3381
+ if (isset($XML_RPC_Types[strtolower($name)])) {
3382
+ $XML_RPC_xh[$parser]['vt'] = strtolower($name);
3383
+ }
3384
+ }
3385
+
3386
+ /**
3387
+ * Character data handler for the XML parser
3388
+ *
3389
+ * @return void
3390
+ */
3391
+ function XML_RPC_cd($parser_resource, $data)
3392
+ {
3393
+ global $XML_RPC_xh, $XML_RPC_backslash;
3394
+ $parser = (int) $parser_resource;
3395
+
3396
+ if ($XML_RPC_xh[$parser]['lv'] != 3) {
3397
+ // "lookforvalue==3" means that we've found an entire value
3398
+ // and should discard any further character data
3399
+
3400
+ if ($XML_RPC_xh[$parser]['lv'] == 1) {
3401
+ // if we've found text and we're just in a <value> then
3402
+ // turn quoting on, as this will be a string
3403
+ $XML_RPC_xh[$parser]['qt'] = 1;
3404
+ // and say we've found a value
3405
+ $XML_RPC_xh[$parser]['lv'] = 2;
3406
+ }
3407
+
3408
+ // replace characters that eval would
3409
+ // do special things with
3410
+ if (!isset($XML_RPC_xh[$parser]['ac'])) {
3411
+ $XML_RPC_xh[$parser]['ac'] = '';
3412
+ }
3413
+ $XML_RPC_xh[$parser]['ac'] .= $data;
3414
+ }
3415
+ }
3416
+
3417
+ /**
3418
+ * The common methods and properties for all of the XML_RPC classes
3419
+ *
3420
+ * @category Web Services
3421
+ * @package XML_RPC
3422
+ * @author Edd Dumbill <edd@usefulinc.com>
3423
+ * @author Stig Bakken <stig@php.net>
3424
+ * @author Martin Jansen <mj@php.net>
3425
+ * @author Daniel Convissor <danielc@php.net>
3426
+ * @copyright 1999-2001 Edd Dumbill, 2001-2005 The PHP Group
3427
+ * @version Release: @package_version@
3428
+ * @link http://pear.php.net/package/XML_RPC
3429
+ */
3430
+ class XML_RPC_Base {
3431
+
3432
+ /**
3433
+ * PEAR Error handling
3434
+ *
3435
+ * @return object PEAR_Error object
3436
+ */
3437
+ function raiseError($msg, $code)
3438
+ {
3439
+ include_once 'PEAR.php';
3440
+ if (is_object(@$this)) {
3441
+ return PEAR::raiseError(get_class($this) . ': ' . $msg, $code);
3442
+ } else {
3443
+ return PEAR::raiseError('XML_RPC: ' . $msg, $code);
3444
+ }
3445
+ }
3446
+
3447
+ /**
3448
+ * Tell whether something is a PEAR_Error object
3449
+ *
3450
+ * @param mixed $value the item to check
3451
+ *
3452
+ * @return bool whether $value is a PEAR_Error object or not
3453
+ *
3454
+ * @access public
3455
+ */
3456
+ function isError($value)
3457
+ {
3458
+ return is_a($value, 'PEAR_Error');
3459
+ }
3460
+ }
3461
+
3462
+ /**
3463
+ * The methods and properties for submitting XML RPC requests
3464
+ *
3465
+ * @category Web Services
3466
+ * @package XML_RPC
3467
+ * @author Edd Dumbill <edd@usefulinc.com>
3468
+ * @author Stig Bakken <stig@php.net>
3469
+ * @author Martin Jansen <mj@php.net>
3470
+ * @author Daniel Convissor <danielc@php.net>
3471
+ * @copyright 1999-2001 Edd Dumbill, 2001-2005 The PHP Group
3472
+ * @version Release: @package_version@
3473
+ * @link http://pear.php.net/package/XML_RPC
3474
+ */
3475
+ class XML_RPC_Client extends XML_RPC_Base {
3476
+
3477
+ /**
3478
+ * The path and name of the RPC server script you want the request to go to
3479
+ * @var string
3480
+ */
3481
+ var $path = '';
3482
+
3483
+ /**
3484
+ * The name of the remote server to connect to
3485
+ * @var string
3486
+ */
3487
+ var $server = '';
3488
+
3489
+ /**
3490
+ * The protocol to use in contacting the remote server
3491
+ * @var string
3492
+ */
3493
+ var $protocol = 'http://';
3494
+
3495
+ /**
3496
+ * The port for connecting to the remote server
3497
+ *
3498
+ * The default is 80 for http:// connections
3499
+ * and 443 for https:// and ssl:// connections.
3500
+ *
3501
+ * @var integer
3502
+ */
3503
+ var $port = 80;
3504
+
3505
+ /**
3506
+ * A user name for accessing the RPC server
3507
+ * @var string
3508
+ * @see XML_RPC_Client::setCredentials()
3509
+ */
3510
+ var $username = '';
3511
+
3512
+ /**
3513
+ * A password for accessing the RPC server
3514
+ * @var string
3515
+ * @see XML_RPC_Client::setCredentials()
3516
+ */
3517
+ var $password = '';
3518
+
3519
+ /**
3520
+ * The name of the proxy server to use, if any
3521
+ * @var string
3522
+ */
3523
+ var $proxy = '';
3524
+
3525
+ /**
3526
+ * The protocol to use in contacting the proxy server, if any
3527
+ * @var string
3528
+ */
3529
+ var $proxy_protocol = 'http://';
3530
+
3531
+ /**
3532
+ * The port for connecting to the proxy server
3533
+ *
3534
+ * The default is 8080 for http:// connections
3535
+ * and 443 for https:// and ssl:// connections.
3536
+ *
3537
+ * @var integer
3538
+ */
3539
+ var $proxy_port = 8080;
3540
+
3541
+ /**
3542
+ * A user name for accessing the proxy server
3543
+ * @var string
3544
+ */
3545
+ var $proxy_user = '';
3546
+
3547
+ /**
3548
+ * A password for accessing the proxy server
3549
+ * @var string
3550
+ */
3551
+ var $proxy_pass = '';
3552
+
3553
+ /**
3554
+ * The error number, if any
3555
+ * @var integer
3556
+ */
3557
+ var $errno = 0;
3558
+
3559
+ /**
3560
+ * The error message, if any
3561
+ * @var string
3562
+ */
3563
+ var $errstr = '';
3564
+
3565
+ /**
3566
+ * The current debug mode (1 = on, 0 = off)
3567
+ * @var integer
3568
+ */
3569
+ var $debug = 0;
3570
+
3571
+ /**
3572
+ * The HTTP headers for the current request.
3573
+ * @var string
3574
+ */
3575
+ var $headers = '';
3576
+
3577
+
3578
+ /**
3579
+ * Sets the object's properties
3580
+ *
3581
+ * @param string $path the path and name of the RPC server script
3582
+ * you want the request to go to
3583
+ * @param string $server the URL of the remote server to connect to.
3584
+ * If this parameter doesn't specify a
3585
+ * protocol and $port is 443, ssl:// is
3586
+ * assumed.
3587
+ * @param integer $port a port for connecting to the remote server.
3588
+ * Defaults to 80 for http:// connections and
3589
+ * 443 for https:// and ssl:// connections.
3590
+ * @param string $proxy the URL of the proxy server to use, if any.
3591
+ * If this parameter doesn't specify a
3592
+ * protocol and $port is 443, ssl:// is
3593
+ * assumed.
3594
+ * @param integer $proxy_port a port for connecting to the remote server.
3595
+ * Defaults to 8080 for http:// connections and
3596
+ * 443 for https:// and ssl:// connections.
3597
+ * @param string $proxy_user a user name for accessing the proxy server
3598
+ * @param string $proxy_pass a password for accessing the proxy server
3599
+ *
3600
+ * @return void
3601
+ */
3602
+ function XML_RPC_Client($path, $server, $port = 0,
3603
+ $proxy = '', $proxy_port = 0,
3604
+ $proxy_user = '', $proxy_pass = '')
3605
+ {
3606
+ $this->path = $path;
3607
+ $this->proxy_user = $proxy_user;
3608
+ $this->proxy_pass = $proxy_pass;
3609
+
3610
+ preg_match('@^(http://|https://|ssl://)?(.*)$@', $server, $match);
3611
+ if ($match[1] == '') {
3612
+ if ($port == 443) {
3613
+ $this->server = $match[2];
3614
+ $this->protocol = 'ssl://';
3615
+ $this->port = 443;
3616
+ } else {
3617
+ $this->server = $match[2];
3618
+ if ($port) {
3619
+ $this->port = $port;
3620
+ }
3621
+ }
3622
+ } elseif ($match[1] == 'http://') {
3623
+ $this->server = $match[2];
3624
+ if ($port) {
3625
+ $this->port = $port;
3626
+ }
3627
+ } else {
3628
+ $this->server = $match[2];
3629
+ $this->protocol = 'ssl://';
3630
+ if ($port) {
3631
+ $this->port = $port;
3632
+ } else {
3633
+ $this->port = 443;
3634
+ }
3635
+ }
3636
+
3637
+ if ($proxy) {
3638
+ preg_match('@^(http://|https://|ssl://)?(.*)$@', $proxy, $match);
3639
+ if ($match[1] == '') {
3640
+ if ($proxy_port == 443) {
3641
+ $this->proxy = $match[2];
3642
+ $this->proxy_protocol = 'ssl://';
3643
+ $this->proxy_port = 443;
3644
+ } else {
3645
+ $this->proxy = $match[2];
3646
+ if ($proxy_port) {
3647
+ $this->proxy_port = $proxy_port;
3648
+ }
3649
+ }
3650
+ } elseif ($match[1] == 'http://') {
3651
+ $this->proxy = $match[2];
3652
+ if ($proxy_port) {
3653
+ $this->proxy_port = $proxy_port;
3654
+ }
3655
+ } else {
3656
+ $this->proxy = $match[2];
3657
+ $this->proxy_protocol = 'ssl://';
3658
+ if ($proxy_port) {
3659
+ $this->proxy_port = $proxy_port;
3660
+ } else {
3661
+ $this->proxy_port = 443;
3662
+ }
3663
+ }
3664
+ }
3665
+ }
3666
+
3667
+ /**
3668
+ * Change the current debug mode
3669
+ *
3670
+ * @param int $in where 1 = on, 0 = off
3671
+ *
3672
+ * @return void
3673
+ */
3674
+ function setDebug($in)
3675
+ {
3676
+ if ($in) {
3677
+ $this->debug = 1;
3678
+ } else {
3679
+ $this->debug = 0;
3680
+ }
3681
+ }
3682
+
3683
+ /**
3684
+ * Set username and password properties for connecting to the RPC server
3685
+ *
3686
+ * @param string $u the user name
3687
+ * @param string $p the password
3688
+ *
3689
+ * @return void
3690
+ *
3691
+ * @see XML_RPC_Client::$username, XML_RPC_Client::$password
3692
+ */
3693
+ function setCredentials($u, $p)
3694
+ {
3695
+ $this->username = $u;
3696
+ $this->password = $p;
3697
+ }
3698
+
3699
+ /**
3700
+ * Transmit the RPC request via HTTP 1.0 protocol
3701
+ *
3702
+ * @param object $msg the XML_RPC_Message object
3703
+ * @param int $timeout how many seconds to wait for the request
3704
+ *
3705
+ * @return object an XML_RPC_Response object. 0 is returned if any
3706
+ * problems happen.
3707
+ *
3708
+ * @see XML_RPC_Message, XML_RPC_Client::XML_RPC_Client(),
3709
+ * XML_RPC_Client::setCredentials()
3710
+ */
3711
+ function send($msg, $timeout = 0)
3712
+ {
3713
+ if (!is_a($msg, 'XML_RPC_Message')) {
3714
+ $this->errstr = 'send()\'s $msg parameter must be an'
3715
+ . ' XML_RPC_Message object.';
3716
+ $this->raiseError($this->errstr, XML_RPC_ERROR_PROGRAMMING);
3717
+ return 0;
3718
+ }
3719
+ $msg->debug = $this->debug;
3720
+ return $this->sendPayloadHTTP10($msg, $this->server, $this->port,
3721
+ $timeout, $this->username,
3722
+ $this->password);
3723
+ }
3724
+
3725
+ /**
3726
+ * Transmit the RPC request via HTTP 1.0 protocol
3727
+ *
3728
+ * Requests should be sent using XML_RPC_Client send() rather than
3729
+ * calling this method directly.
3730
+ *
3731
+ * @param object $msg the XML_RPC_Message object
3732
+ * @param string $server the server to send the request to
3733
+ * @param int $port the server port send the request to
3734
+ * @param int $timeout how many seconds to wait for the request
3735
+ * before giving up
3736
+ * @param string $username a user name for accessing the RPC server
3737
+ * @param string $password a password for accessing the RPC server
3738
+ *
3739
+ * @return object an XML_RPC_Response object. 0 is returned if any
3740
+ * problems happen.
3741
+ *
3742
+ * @access protected
3743
+ * @see XML_RPC_Client::send()
3744
+ */
3745
+ function sendPayloadHTTP10($msg, $server, $port, $timeout = 0,
3746
+ $username = '', $password = '')
3747
+ {
3748
+ /*
3749
+ * If we're using a proxy open a socket to the proxy server
3750
+ * instead to the xml-rpc server
3751
+ */
3752
+ if ($this->proxy) {
3753
+ if ($this->proxy_protocol == 'http://') {
3754
+ $protocol = '';
3755
+ } else {
3756
+ $protocol = $this->proxy_protocol;
3757
+ }
3758
+ if ($timeout > 0) {
3759
+ $fp = @fsockopen($protocol . $this->proxy, $this->proxy_port,
3760
+ $this->errno, $this->errstr, $timeout);
3761
+ } else {
3762
+ $fp = @fsockopen($protocol . $this->proxy, $this->proxy_port,
3763
+ $this->errno, $this->errstr);
3764
+ }
3765
+ } else {
3766
+ if ($this->protocol == 'http://') {
3767
+ $protocol = '';
3768
+ } else {
3769
+ $protocol = $this->protocol;
3770
+ }
3771
+ if ($timeout > 0) {
3772
+ $fp = @fsockopen($protocol . $server, $port,
3773
+ $this->errno, $this->errstr, $timeout);
3774
+ } else {
3775
+ $fp = @fsockopen($protocol . $server, $port,
3776
+ $this->errno, $this->errstr);
3777
+ }
3778
+ }
3779
+
3780
+ /*
3781
+ * Just raising the error without returning it is strange,
3782
+ * but keep it here for backwards compatibility.
3783
+ */
3784
+ if (!$fp && $this->proxy) {
3785
+ $this->raiseError('Connection to proxy server '
3786
+ . $this->proxy . ':' . $this->proxy_port
3787
+ . ' failed. ' . $this->errstr,
3788
+ XML_RPC_ERROR_CONNECTION_FAILED);
3789
+ return 0;
3790
+ } elseif (!$fp) {
3791
+ $this->raiseError('Connection to RPC server '
3792
+ . $server . ':' . $port
3793
+ . ' failed. ' . $this->errstr,
3794
+ XML_RPC_ERROR_CONNECTION_FAILED);
3795
+ return 0;
3796
+ }
3797
+
3798
+ if ($timeout) {
3799
+ /*
3800
+ * Using socket_set_timeout() because stream_set_timeout()
3801
+ * was introduced in 4.3.0, but we need to support 4.2.0.
3802
+ */
3803
+ socket_set_timeout($fp, $timeout);
3804
+ }
3805
+
3806
+ // Pre-emptive BC hacks for fools calling sendPayloadHTTP10() directly
3807
+ if ($username != $this->username) {
3808
+ $this->setCredentials($username, $password);
3809
+ }
3810
+
3811
+ // Only create the payload if it was not created previously
3812
+ if (empty($msg->payload)) {
3813
+ $msg->createPayload();
3814
+ }
3815
+ $this->createHeaders($msg);
3816
+
3817
+ $op = $this->headers . "\r\n\r\n";
3818
+ $op .= $msg->payload;
3819
+
3820
+ if (!fputs($fp, $op, strlen($op))) {
3821
+ $this->errstr = 'Write error';
3822
+ return 0;
3823
+ }
3824
+ $resp = $msg->parseResponseFile($fp);
3825
+
3826
+ $meta = socket_get_status($fp);
3827
+ if ($meta['timed_out']) {
3828
+ fclose($fp);
3829
+ $this->errstr = 'RPC server did not send response before timeout.';
3830
+ $this->raiseError($this->errstr, XML_RPC_ERROR_CONNECTION_FAILED);
3831
+ return 0;
3832
+ }
3833
+
3834
+ fclose($fp);
3835
+ return $resp;
3836
+ }
3837
+
3838
+ /**
3839
+ * Determines the HTTP headers and puts it in the $headers property
3840
+ *
3841
+ * @param object $msg the XML_RPC_Message object
3842
+ *
3843
+ * @return boolean TRUE if okay, FALSE if the message payload isn't set.
3844
+ *
3845
+ * @access protected
3846
+ */
3847
+ function createHeaders($msg)
3848
+ {
3849
+ if (empty($msg->payload)) {
3850
+ return false;
3851
+ }
3852
+ if ($this->proxy) {
3853
+ $this->headers = 'POST ' . $this->protocol . $this->server;
3854
+ if ($this->proxy_port) {
3855
+ $this->headers .= ':' . $this->port;
3856
+ }
3857
+ } else {
3858
+ $this->headers = 'POST ';
3859
+ }
3860
+ $this->headers .= $this->path. " HTTP/1.0\r\n";
3861
+
3862
+ $this->headers .= "User-Agent: PEAR XML_RPC\r\n";
3863
+ $this->headers .= 'Host: ' . $this->server . "\r\n";
3864
+
3865
+ if ($this->proxy && $this->proxy_user) {
3866
+ $this->headers .= 'Proxy-Authorization: Basic '
3867
+ . base64_encode("$this->proxy_user:$this->proxy_pass")
3868
+ . "\r\n";
3869
+ }
3870
+
3871
+ // thanks to Grant Rauscher <grant7@firstworld.net> for this
3872
+ if ($this->username) {
3873
+ $this->headers .= 'Authorization: Basic '
3874
+ . base64_encode("$this->username:$this->password")
3875
+ . "\r\n";
3876
+ }
3877
+
3878
+ $this->headers .= "Content-Type: text/xml\r\n";
3879
+ $this->headers .= 'Content-Length: ' . strlen($msg->payload);
3880
+ return true;
3881
+ }
3882
+ }
3883
+
3884
+ /**
3885
+ * The methods and properties for interpreting responses to XML RPC requests
3886
+ *
3887
+ * @category Web Services
3888
+ * @package XML_RPC
3889
+ * @author Edd Dumbill <edd@usefulinc.com>
3890
+ * @author Stig Bakken <stig@php.net>
3891
+ * @author Martin Jansen <mj@php.net>
3892
+ * @author Daniel Convissor <danielc@php.net>
3893
+ * @copyright 1999-2001 Edd Dumbill, 2001-2005 The PHP Group
3894
+ * @version Release: @package_version@
3895
+ * @link http://pear.php.net/package/XML_RPC
3896
+ */
3897
+ class XML_RPC_Response extends XML_RPC_Base
3898
+ {
3899
+ var $xv;
3900
+ var $fn;
3901
+ var $fs;
3902
+ var $hdrs;
3903
+
3904
+ /**
3905
+ * @return void
3906
+ */
3907
+ function XML_RPC_Response($val, $fcode = 0, $fstr = '')
3908
+ {
3909
+ if ($fcode != 0) {
3910
+ $this->fn = $fcode;
3911
+ $this->fs = htmlspecialchars($fstr);
3912
+ } else {
3913
+ $this->xv = $val;
3914
+ }
3915
+ }
3916
+
3917
+ /**
3918
+ * @return int the error code
3919
+ */
3920
+ function faultCode()
3921
+ {
3922
+ if (isset($this->fn)) {
3923
+ return $this->fn;
3924
+ } else {
3925
+ return 0;
3926
+ }
3927
+ }
3928
+
3929
+ /**
3930
+ * @return string the error string
3931
+ */
3932
+ function faultString()
3933
+ {
3934
+ return $this->fs;
3935
+ }
3936
+
3937
+ /**
3938
+ * @return mixed the value
3939
+ */
3940
+ function value()
3941
+ {
3942
+ return $this->xv;
3943
+ }
3944
+
3945
+ /**
3946
+ * @return string the error message in XML format
3947
+ */
3948
+ function serialize()
3949
+ {
3950
+ $rs = "<methodResponse>\n";
3951
+ if ($this->fn) {
3952
+ $rs .= "<fault>
3953
+ <value>
3954
+ <struct>
3955
+ <member>
3956
+ <name>faultCode</name>
3957
+ <value><int>" . $this->fn . "</int></value>
3958
+ </member>
3959
+ <member>
3960
+ <name>faultString</name>
3961
+ <value><string>" . $this->fs . "</string></value>
3962
+ </member>
3963
+ </struct>
3964
+ </value>
3965
+ </fault>";
3966
+ } else {
3967
+ $rs .= "<params>\n<param>\n" . $this->xv->serialize() .
3968
+ "</param>\n</params>";
3969
+ }
3970
+ $rs .= "\n</methodResponse>";
3971
+ return $rs;
3972
+ }
3973
+ }
3974
+
3975
+ /**
3976
+ * The methods and properties for composing XML RPC messages
3977
+ *
3978
+ * @category Web Services
3979
+ * @package XML_RPC
3980
+ * @author Edd Dumbill <edd@usefulinc.com>
3981
+ * @author Stig Bakken <stig@php.net>
3982
+ * @author Martin Jansen <mj@php.net>
3983
+ * @author Daniel Convissor <danielc@php.net>
3984
+ * @copyright 1999-2001 Edd Dumbill, 2001-2005 The PHP Group
3985
+ * @version Release: @package_version@
3986
+ * @link http://pear.php.net/package/XML_RPC
3987
+ */
3988
+ class XML_RPC_Message extends XML_RPC_Base
3989
+ {
3990
+ /**
3991
+ * The current debug mode (1 = on, 0 = off)
3992
+ * @var integer
3993
+ */
3994
+ var $debug = 0;
3995
+
3996
+ /**
3997
+ * The encoding to be used for outgoing messages
3998
+ *
3999
+ * Defaults to the value of <var>$GLOBALS['XML_RPC_defencoding']</var>
4000
+ *
4001
+ * @var string
4002
+ * @see XML_RPC_Message::setSendEncoding(),
4003
+ * $GLOBALS['XML_RPC_defencoding'], XML_RPC_Message::xml_header()
4004
+ */
4005
+ var $send_encoding = '';
4006
+
4007
+ /**
4008
+ * The method presently being evaluated
4009
+ * @var string
4010
+ */
4011
+ var $methodname = '';
4012
+
4013
+ /**
4014
+ * @var array
4015
+ */
4016
+ var $params = array();
4017
+
4018
+ /**
4019
+ * The XML message being generated
4020
+ * @var string
4021
+ */
4022
+ var $payload = '';
4023
+
4024
+ /**
4025
+ * @return void
4026
+ */
4027
+ function XML_RPC_Message($meth, $pars = 0)
4028
+ {
4029
+ $this->methodname = $meth;
4030
+ if (is_array($pars) && sizeof($pars) > 0) {
4031
+ for ($i = 0; $i < sizeof($pars); $i++) {
4032
+ $this->addParam($pars[$i]);
4033
+ }
4034
+ }
4035
+ }
4036
+
4037
+ /**
4038
+ * Produces the XML declaration including the encoding attribute
4039
+ *
4040
+ * The encoding is determined by this class' <var>$send_encoding</var>
4041
+ * property. If the <var>$send_encoding</var> property is not set, use
4042
+ * <var>$GLOBALS['XML_RPC_defencoding']</var>.
4043
+ *
4044
+ * @return string the XML declaration and <methodCall> element
4045
+ *
4046
+ * @see XML_RPC_Message::setSendEncoding(),
4047
+ * XML_RPC_Message::$send_encoding, $GLOBALS['XML_RPC_defencoding']
4048
+ */
4049
+ function xml_header()
4050
+ {
4051
+ global $XML_RPC_defencoding;
4052
+ if (!$this->send_encoding) {
4053
+ $this->send_encoding = $XML_RPC_defencoding;
4054
+ }
4055
+ return '<?xml version="1.0" encoding="' . $this->send_encoding . '"?>'
4056
+ . "\n<methodCall>\n";
4057
+ }
4058
+
4059
+ /**
4060
+ * @return string the closing </methodCall> tag
4061
+ */
4062
+ function xml_footer()
4063
+ {
4064
+ return "</methodCall>\n";
4065
+ }
4066
+
4067
+ /**
4068
+ * @return void
4069
+ *
4070
+ * @uses XML_RPC_Message::xml_header(), XML_RPC_Message::xml_footer()
4071
+ */
4072
+ function createPayload()
4073
+ {
4074
+ $this->payload = $this->xml_header();
4075
+ $this->payload .= '<methodName>' . $this->methodname . "</methodName>\n";
4076
+ $this->payload .= "<params>\n";
4077
+ for ($i = 0; $i < sizeof($this->params); $i++) {
4078
+ $p = $this->params[$i];
4079
+ $this->payload .= "<param>\n" . $p->serialize() . "</param>\n";
4080
+ }
4081
+ $this->payload .= "</params>\n";
4082
+ $this->payload .= $this->xml_footer();
4083
+ $this->payload = ereg_replace("[\r\n]+", "\r\n", $this->payload);
4084
+ }
4085
+
4086
+ /**
4087
+ * @return string the name of the method
4088
+ */
4089
+ function method($meth = '')
4090
+ {
4091
+ if ($meth != '') {
4092
+ $this->methodname = $meth;
4093
+ }
4094
+ return $this->methodname;
4095
+ }
4096
+
4097
+ /**
4098
+ * @return string the payload
4099
+ */
4100
+ function serialize()
4101
+ {
4102
+ $this->createPayload();
4103
+ return $this->payload;
4104
+ }
4105
+
4106
+ /**
4107
+ * @return void
4108
+ */
4109
+ function addParam($par)
4110
+ {
4111
+ $this->params[] = $par;
4112
+ }
4113
+
4114
+ /**
4115
+ * Obtains an XML_RPC_Value object for the given parameter
4116
+ *
4117
+ * @param int $i the index number of the parameter to obtain
4118
+ *
4119
+ * @return object the XML_RPC_Value object.
4120
+ * If the parameter doesn't exist, an XML_RPC_Response object.
4121
+ *
4122
+ * @since Returns XML_RPC_Response object on error since Release 1.3.0
4123
+ */
4124
+ function getParam($i)
4125
+ {
4126
+ global $XML_RPC_err, $XML_RPC_str;
4127
+
4128
+ if (isset($this->params[$i])) {
4129
+ return $this->params[$i];
4130
+ } else {
4131
+ $this->raiseError('The submitted request did not contain this parameter',
4132
+ XML_RPC_ERROR_INCORRECT_PARAMS);
4133
+ return new XML_RPC_Response(0, $XML_RPC_err['incorrect_params'],
4134
+ $XML_RPC_str['incorrect_params']);
4135
+ }
4136
+ }
4137
+
4138
+ /**
4139
+ * @return int the number of parameters
4140
+ */
4141
+ function getNumParams()
4142
+ {
4143
+ return sizeof($this->params);
4144
+ }
4145
+
4146
+ /**
4147
+ * Sets the XML declaration's encoding attribute
4148
+ *
4149
+ * @param string $type the encoding type (ISO-8859-1, UTF-8 or US-ASCII)
4150
+ *
4151
+ * @return void
4152
+ *
4153
+ * @see XML_RPC_Message::$send_encoding, XML_RPC_Message::xml_header()
4154
+ * @since Method available since Release 1.2.0
4155
+ */
4156
+ function setSendEncoding($type)
4157
+ {
4158
+ $this->send_encoding = $type;
4159
+ }
4160
+
4161
+ /**
4162
+ * Determine the XML's encoding via the encoding attribute
4163
+ * in the XML declaration
4164
+ *
4165
+ * If the encoding parameter is not set or is not ISO-8859-1, UTF-8
4166
+ * or US-ASCII, $XML_RPC_defencoding will be returned.
4167
+ *
4168
+ * @param string $data the XML that will be parsed
4169
+ *
4170
+ * @return string the encoding to be used
4171
+ *
4172
+ * @link http://php.net/xml_parser_create
4173
+ * @since Method available since Release 1.2.0
4174
+ */
4175
+ function getEncoding($data)
4176
+ {
4177
+ global $XML_RPC_defencoding;
4178
+
4179
+ if (preg_match('/<\?xml[^>]*\s*encoding\s*=\s*[\'"]([^"\']*)[\'"]/i',
4180
+ $data, $match))
4181
+ {
4182
+ $match[1] = trim(strtoupper($match[1]));
4183
+ switch ($match[1]) {
4184
+ case 'ISO-8859-1':
4185
+ case 'UTF-8':
4186
+ case 'US-ASCII':
4187
+ return $match[1];
4188
+ break;
4189
+
4190
+ default:
4191
+ return $XML_RPC_defencoding;
4192
+ }
4193
+ } else {
4194
+ return $XML_RPC_defencoding;
4195
+ }
4196
+ }
4197
+
4198
+ /**
4199
+ * @return object a new XML_RPC_Response object
4200
+ */
4201
+ function parseResponseFile($fp)
4202
+ {
4203
+ $ipd = '';
4204
+ while ($data = @fread($fp, 8192)) {
4205
+ $ipd .= $data;
4206
+ }
4207
+ return $this->parseResponse($ipd);
4208
+ }
4209
+
4210
+ /**
4211
+ * @return object a new XML_RPC_Response object
4212
+ */
4213
+ function parseResponse($data = '')
4214
+ {
4215
+ global $XML_RPC_xh, $XML_RPC_err, $XML_RPC_str, $XML_RPC_defencoding;
4216
+
4217
+ $encoding = $this->getEncoding($data);
4218
+ $parser_resource = xml_parser_create($encoding);
4219
+ $parser = (int) $parser_resource;
4220
+
4221
+ $XML_RPC_xh = array();
4222
+ $XML_RPC_xh[$parser] = array();
4223
+
4224
+ $XML_RPC_xh[$parser]['cm'] = 0;
4225
+ $XML_RPC_xh[$parser]['isf'] = 0;
4226
+ $XML_RPC_xh[$parser]['ac'] = '';
4227
+ $XML_RPC_xh[$parser]['qt'] = '';
4228
+ $XML_RPC_xh[$parser]['stack'] = array();
4229
+ $XML_RPC_xh[$parser]['valuestack'] = array();
4230
+
4231
+ xml_parser_set_option($parser_resource, XML_OPTION_CASE_FOLDING, true);
4232
+ xml_set_element_handler($parser_resource, 'XML_RPC_se', 'XML_RPC_ee');
4233
+ xml_set_character_data_handler($parser_resource, 'XML_RPC_cd');
4234
+
4235
+ $hdrfnd = 0;
4236
+ if ($this->debug) {
4237
+ print "\n<pre>---GOT---\n";
4238
+ print isset($_SERVER['SERVER_PROTOCOL']) ? htmlspecialchars($data) : $data;
4239
+ print "\n---END---</pre>\n";
4240
+ }
4241
+
4242
+ // See if response is a 200 or a 100 then a 200, else raise error.
4243
+ // But only do this if we're using the HTTP protocol.
4244
+ if (ereg('^HTTP', $data) &&
4245
+ !ereg('^HTTP/[0-9\.]+ 200 ', $data) &&
4246
+ !preg_match('@^HTTP/[0-9\.]+ 10[0-9]([A-Za-z ]+)?[\r\n]+HTTP/[0-9\.]+ 200@', $data))
4247
+ {
4248
+ $errstr = substr($data, 0, strpos($data, "\n") - 1);
4249
+ error_log('HTTP error, got response: ' . $errstr);
4250
+ $r = new XML_RPC_Response(0, $XML_RPC_err['http_error'],
4251
+ $XML_RPC_str['http_error'] . ' (' .
4252
+ $errstr . ')');
4253
+ xml_parser_free($parser_resource);
4254
+ return $r;
4255
+ }
4256
+
4257
+ // gotta get rid of headers here
4258
+ if (!$hdrfnd && ($brpos = strpos($data,"\r\n\r\n"))) {
4259
+ $XML_RPC_xh[$parser]['ha'] = substr($data, 0, $brpos);
4260
+ $data = substr($data, $brpos + 4);
4261
+ $hdrfnd = 1;
4262
+ }
4263
+
4264
+ /*
4265
+ * be tolerant of junk after methodResponse
4266
+ * (e.g. javascript automatically inserted by free hosts)
4267
+ * thanks to Luca Mariano <luca.mariano@email.it>
4268
+ */
4269
+ $data = substr($data, 0, strpos($data, "</methodResponse>") + 17);
4270
+
4271
+ if (!xml_parse($parser_resource, $data, sizeof($data))) {
4272
+ // thanks to Peter Kocks <peter.kocks@baygate.com>
4273
+ if (xml_get_current_line_number($parser_resource) == 1) {
4274
+ $errstr = 'XML error at line 1, check URL';
4275
+ } else {
4276
+ $errstr = sprintf('XML error: %s at line %d',
4277
+ xml_error_string(xml_get_error_code($parser_resource)),
4278
+ xml_get_current_line_number($parser_resource));
4279
+ }
4280
+ error_log($errstr);
4281
+ $r = new XML_RPC_Response(0, $XML_RPC_err['invalid_return'],
4282
+ $XML_RPC_str['invalid_return']);
4283
+ xml_parser_free($parser_resource);
4284
+ return $r;
4285
+ }
4286
+
4287
+ xml_parser_free($parser_resource);
4288
+
4289
+ if ($this->debug) {
4290
+ print "\n<pre>---PARSED---\n";
4291
+ var_dump($XML_RPC_xh[$parser]['value']);
4292
+ print "---END---</pre>\n";
4293
+ }
4294
+
4295
+ if ($XML_RPC_xh[$parser]['isf'] > 1) {
4296
+ $r = new XML_RPC_Response(0, $XML_RPC_err['invalid_return'],
4297
+ $XML_RPC_str['invalid_return'].' '.$XML_RPC_xh[$parser]['isf_reason']);
4298
+ } elseif (!is_object($XML_RPC_xh[$parser]['value'])) {
4299
+ // then something odd has happened
4300
+ // and it's time to generate a client side error
4301
+ // indicating something odd went on
4302
+ $r = new XML_RPC_Response(0, $XML_RPC_err['invalid_return'],
4303
+ $XML_RPC_str['invalid_return']);
4304
+ } else {
4305
+ $v = $XML_RPC_xh[$parser]['value'];
4306
+ $allOK=1;
4307
+ if ($XML_RPC_xh[$parser]['isf']) {
4308
+ $f = $v->structmem('faultCode');
4309
+ $fs = $v->structmem('faultString');
4310
+ $r = new XML_RPC_Response($v, $f->scalarval(),
4311
+ $fs->scalarval());
4312
+ } else {
4313
+ $r = new XML_RPC_Response($v);
4314
+ }
4315
+ }
4316
+ $r->hdrs = split("\r?\n", $XML_RPC_xh[$parser]['ha'][1]);
4317
+ return $r;
4318
+ }
4319
+ }
4320
+
4321
+ /**
4322
+ * The methods and properties that represent data in XML RPC format
4323
+ *
4324
+ * @category Web Services
4325
+ * @package XML_RPC
4326
+ * @author Edd Dumbill <edd@usefulinc.com>
4327
+ * @author Stig Bakken <stig@php.net>
4328
+ * @author Martin Jansen <mj@php.net>
4329
+ * @author Daniel Convissor <danielc@php.net>
4330
+ * @copyright 1999-2001 Edd Dumbill, 2001-2005 The PHP Group
4331
+ * @version Release: @package_version@
4332
+ * @link http://pear.php.net/package/XML_RPC
4333
+ */
4334
+ class XML_RPC_Value extends XML_RPC_Base
4335
+ {
4336
+ var $me = array();
4337
+ var $mytype = 0;
4338
+
4339
+ /**
4340
+ * @return void
4341
+ */
4342
+ function XML_RPC_Value($val = -1, $type = '')
4343
+ {
4344
+ global $XML_RPC_Types;
4345
+ $this->me = array();
4346
+ $this->mytype = 0;
4347
+ if ($val != -1 || $type != '') {
4348
+ if ($type == '') {
4349
+ $type = 'string';
4350
+ }
4351
+ if (!array_key_exists($type, $XML_RPC_Types)) {
4352
+ // XXX
4353
+ // need some way to report this error
4354
+ } elseif ($XML_RPC_Types[$type] == 1) {
4355
+ $this->addScalar($val, $type);
4356
+ } elseif ($XML_RPC_Types[$type] == 2) {
4357
+ $this->addArray($val);
4358
+ } elseif ($XML_RPC_Types[$type] == 3) {
4359
+ $this->addStruct($val);
4360
+ }
4361
+ }
4362
+ }
4363
+
4364
+ /**
4365
+ * @return int returns 1 if successful or 0 if there are problems
4366
+ */
4367
+ function addScalar($val, $type = 'string')
4368
+ {
4369
+ global $XML_RPC_Types, $XML_RPC_Boolean;
4370
+
4371
+ if ($this->mytype == 1) {
4372
+ $this->raiseError('Scalar can have only one value',
4373
+ XML_RPC_ERROR_INVALID_TYPE);
4374
+ return 0;
4375
+ }
4376
+ $typeof = $XML_RPC_Types[$type];
4377
+ if ($typeof != 1) {
4378
+ $this->raiseError("Not a scalar type (${typeof})",
4379
+ XML_RPC_ERROR_INVALID_TYPE);
4380
+ return 0;
4381
+ }
4382
+
4383
+ if ($type == $XML_RPC_Boolean) {
4384
+ if (strcasecmp($val, 'true') == 0
4385
+ || $val == 1
4386
+ || ($val == true && strcasecmp($val, 'false')))
4387
+ {
4388
+ $val = 1;
4389
+ } else {
4390
+ $val = 0;
4391
+ }
4392
+ }
4393
+
4394
+ if ($this->mytype == 2) {
4395
+ // we're adding to an array here
4396
+ $ar = $this->me['array'];
4397
+ $ar[] = new XML_RPC_Value($val, $type);
4398
+ $this->me['array'] = $ar;
4399
+ } else {
4400
+ // a scalar, so set the value and remember we're scalar
4401
+ $this->me[$type] = $val;
4402
+ $this->mytype = $typeof;
4403
+ }
4404
+ return 1;
4405
+ }
4406
+
4407
+ /**
4408
+ * @return int returns 1 if successful or 0 if there are problems
4409
+ */
4410
+ function addArray($vals)
4411
+ {
4412
+ global $XML_RPC_Types;
4413
+ if ($this->mytype != 0) {
4414
+ $this->raiseError(
4415
+ 'Already initialized as a [' . $this->kindOf() . ']',
4416
+ XML_RPC_ERROR_ALREADY_INITIALIZED);
4417
+ return 0;
4418
+ }
4419
+ $this->mytype = $XML_RPC_Types['array'];
4420
+ $this->me['array'] = $vals;
4421
+ return 1;
4422
+ }
4423
+
4424
+ /**
4425
+ * @return int returns 1 if successful or 0 if there are problems
4426
+ */
4427
+ function addStruct($vals)
4428
+ {
4429
+ global $XML_RPC_Types;
4430
+ if ($this->mytype != 0) {
4431
+ $this->raiseError(
4432
+ 'Already initialized as a [' . $this->kindOf() . ']',
4433
+ XML_RPC_ERROR_ALREADY_INITIALIZED);
4434
+ return 0;
4435
+ }
4436
+ $this->mytype = $XML_RPC_Types['struct'];
4437
+ $this->me['struct'] = $vals;
4438
+ return 1;
4439
+ }
4440
+
4441
+ /**
4442
+ * @return void
4443
+ */
4444
+ function dump($ar)
4445
+ {
4446
+ reset($ar);
4447
+ foreach ($ar as $key => $val) {
4448
+ echo "$key => $val<br />";
4449
+ if ($key == 'array') {
4450
+ foreach ($val as $key2 => $val2) {
4451
+ echo "-- $key2 => $val2<br />";
4452
+ }
4453
+ }
4454
+ }
4455
+ }
4456
+
4457
+ /**
4458
+ * @return string the data type of the current value
4459
+ */
4460
+ function kindOf()
4461
+ {
4462
+ switch ($this->mytype) {
4463
+ case 3:
4464
+ return 'struct';
4465
+
4466
+ case 2:
4467
+ return 'array';
4468
+
4469
+ case 1:
4470
+ return 'scalar';
4471
+
4472
+ default:
4473
+ return 'undef';
4474
+ }
4475
+ }
4476
+
4477
+ /**
4478
+ * @return string the data in XML format
4479
+ */
4480
+ function serializedata($typ, $val)
4481
+ {
4482
+ $rs = '';
4483
+ global $XML_RPC_Types, $XML_RPC_Base64, $XML_RPC_String, $XML_RPC_Boolean;
4484
+ if (!array_key_exists($typ, $XML_RPC_Types)) {
4485
+ // XXX
4486
+ // need some way to report this error
4487
+ return;
4488
+ }
4489
+ switch ($XML_RPC_Types[$typ]) {
4490
+ case 3:
4491
+ // struct
4492
+ $rs .= "<struct>\n";
4493
+ reset($val);
4494
+ foreach ($val as $key2 => $val2) {
4495
+ $rs .= "<member><name>${key2}</name>\n";
4496
+ $rs .= $this->serializeval($val2);
4497
+ $rs .= "</member>\n";
4498
+ }
4499
+ $rs .= '</struct>';
4500
+ break;
4501
+
4502
+ case 2:
4503
+ // array
4504
+ $rs .= "<array>\n<data>\n";
4505
+ for ($i = 0; $i < sizeof($val); $i++) {
4506
+ $rs .= $this->serializeval($val[$i]);
4507
+ }
4508
+ $rs .= "</data>\n</array>";
4509
+ break;
4510
+
4511
+ case 1:
4512
+ switch ($typ) {
4513
+ case $XML_RPC_Base64:
4514
+ $rs .= "<${typ}>" . base64_encode($val) . "</${typ}>";
4515
+ break;
4516
+ case $XML_RPC_Boolean:
4517
+ $rs .= "<${typ}>" . ($val ? '1' : '0') . "</${typ}>";
4518
+ break;
4519
+ case $XML_RPC_String:
4520
+ $rs .= "<${typ}>" . htmlspecialchars($val). "</${typ}>";
4521
+ break;
4522
+ default:
4523
+ $rs .= "<${typ}>${val}</${typ}>";
4524
+ }
4525
+ }
4526
+ return $rs;
4527
+ }
4528
+
4529
+ /**
4530
+ * @return string the data in XML format
4531
+ */
4532
+ function serialize()
4533
+ {
4534
+ return $this->serializeval($this);
4535
+ }
4536
+
4537
+ /**
4538
+ * @return string the data in XML format
4539
+ */
4540
+ function serializeval($o)
4541
+ {
4542
+ if (!is_object($o) || empty($o->me) || !is_array($o->me)) {
4543
+ return '';
4544
+ }
4545
+ $ar = $o->me;
4546
+ reset($ar);
4547
+ list($typ, $val) = each($ar);
4548
+ return '<value>' . $this->serializedata($typ, $val) . "</value>\n";
4549
+ }
4550
+
4551
+ /**
4552
+ * @return mixed the contents of the element requested
4553
+ */
4554
+ function structmem($m)
4555
+ {
4556
+ return $this->me['struct'][$m];
4557
+ }
4558
+
4559
+ /**
4560
+ * @return void
4561
+ */
4562
+ function structreset()
4563
+ {
4564
+ reset($this->me['struct']);
4565
+ }
4566
+
4567
+ /**
4568
+ * @return the key/value pair of the struct's current element
4569
+ */
4570
+ function structeach()
4571
+ {
4572
+ return each($this->me['struct']);
4573
+ }
4574
+
4575
+ /**
4576
+ * @return mixed the current value
4577
+ */
4578
+ function getval()
4579
+ {
4580
+ // UNSTABLE
4581
+ global $XML_RPC_BOOLEAN, $XML_RPC_Base64;
4582
+
4583
+ reset($this->me);
4584
+ $b = current($this->me);
4585
+
4586
+ // contributed by I Sofer, 2001-03-24
4587
+ // add support for nested arrays to scalarval
4588
+ // i've created a new method here, so as to
4589
+ // preserve back compatibility
4590
+
4591
+ if (is_array($b)) {
4592
+ foreach ($b as $id => $cont) {
4593
+ $b[$id] = $cont->scalarval();
4594
+ }
4595
+ }
4596
+
4597
+ // add support for structures directly encoding php objects
4598
+ if (is_object($b)) {
4599
+ $t = get_object_vars($b);
4600
+ foreach ($t as $id => $cont) {
4601
+ $t[$id] = $cont->scalarval();
4602
+ }
4603
+ foreach ($t as $id => $cont) {
4604
+ $b->$id = $cont;
4605
+ }
4606
+ }
4607
+
4608
+ // end contrib
4609
+ return $b;
4610
+ }
4611
+
4612
+ /**
4613
+ * @return mixed
4614
+ */
4615
+ function scalarval()
4616
+ {
4617
+ global $XML_RPC_Boolean, $XML_RPC_Base64;
4618
+ reset($this->me);
4619
+ return current($this->me);
4620
+ }
4621
+
4622
+ /**
4623
+ * @return string
4624
+ */
4625
+ function scalartyp()
4626
+ {
4627
+ global $XML_RPC_I4, $XML_RPC_Int;
4628
+ reset($this->me);
4629
+ $a = key($this->me);
4630
+ if ($a == $XML_RPC_I4) {
4631
+ $a = $XML_RPC_Int;
4632
+ }
4633
+ return $a;
4634
+ }
4635
+
4636
+ /**
4637
+ * @return mixed the struct's current element
4638
+ */
4639
+ function arraymem($m)
4640
+ {
4641
+ return $this->me['array'][$m];
4642
+ }
4643
+
4644
+ /**
4645
+ * @return int the number of elements in the array
4646
+ */
4647
+ function arraysize()
4648
+ {
4649
+ reset($this->me);
4650
+ list($a, $b) = each($this->me);
4651
+ return sizeof($b);
4652
+ }
4653
+
4654
+ /**
4655
+ * Determines if the item submitted is an XML_RPC_Value object
4656
+ *
4657
+ * @param mixed $val the variable to be evaluated
4658
+ *
4659
+ * @return bool TRUE if the item is an XML_RPC_Value object
4660
+ *
4661
+ * @static
4662
+ * @since Method available since Release 1.3.0
4663
+ */
4664
+ function isValue($val)
4665
+ {
4666
+ return (strtolower(get_class($val)) == 'xml_rpc_value');
4667
+ }
4668
+ }
4669
+
4670
+ /**
4671
+ * Return an ISO8601 encoded string
4672
+ *
4673
+ * While timezones ought to be supported, the XML-RPC spec says:
4674
+ *
4675
+ * "Don't assume a timezone. It should be specified by the server in its
4676
+ * documentation what assumptions it makes about timezones."
4677
+ *
4678
+ * This routine always assumes localtime unless $utc is set to 1, in which
4679
+ * case UTC is assumed and an adjustment for locale is made when encoding.
4680
+ *
4681
+ * @return string the formatted date
4682
+ */
4683
+ function XML_RPC_iso8601_encode($timet, $utc = 0)
4684
+ {
4685
+ if (!$utc) {
4686
+ $t = strftime('%Y%m%dT%H:%M:%S', $timet);
4687
+ } else {
4688
+ if (function_exists('gmstrftime')) {
4689
+ // gmstrftime doesn't exist in some versions
4690
+ // of PHP
4691
+ $t = gmstrftime('%Y%m%dT%H:%M:%S', $timet);
4692
+ } else {
4693
+ $t = strftime('%Y%m%dT%H:%M:%S', $timet - date('Z'));
4694
+ }
4695
+ }
4696
+ return $t;
4697
+ }
4698
+
4699
+ /**
4700
+ * Convert a datetime string into a Unix timestamp
4701
+ *
4702
+ * While timezones ought to be supported, the XML-RPC spec says:
4703
+ *
4704
+ * "Don't assume a timezone. It should be specified by the server in its
4705
+ * documentation what assumptions it makes about timezones."
4706
+ *
4707
+ * This routine always assumes localtime unless $utc is set to 1, in which
4708
+ * case UTC is assumed and an adjustment for locale is made when encoding.
4709
+ *
4710
+ * @return int the unix timestamp of the date submitted
4711
+ */
4712
+ function XML_RPC_iso8601_decode($idate, $utc = 0)
4713
+ {
4714
+ $t = 0;
4715
+ if (ereg('([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})', $idate, $regs)) {
4716
+ if ($utc) {
4717
+ $t = gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
4718
+ } else {
4719
+ $t = mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
4720
+ }
4721
+ }
4722
+ return $t;
4723
+ }
4724
+
4725
+ /**
4726
+ * Converts an XML_RPC_Value object into native PHP types
4727
+ *
4728
+ * @param object $XML_RPC_val the XML_RPC_Value object to decode
4729
+ *
4730
+ * @return mixed the PHP values
4731
+ */
4732
+ function XML_RPC_decode($XML_RPC_val)
4733
+ {
4734
+ $kind = $XML_RPC_val->kindOf();
4735
+
4736
+ if ($kind == 'scalar') {
4737
+ return $XML_RPC_val->scalarval();
4738
+
4739
+ } elseif ($kind == 'array') {
4740
+ $size = $XML_RPC_val->arraysize();
4741
+ $arr = array();
4742
+ for ($i = 0; $i < $size; $i++) {
4743
+ $arr[] = XML_RPC_decode($XML_RPC_val->arraymem($i));
4744
+ }
4745
+ return $arr;
4746
+
4747
+ } elseif ($kind == 'struct') {
4748
+ $XML_RPC_val->structreset();
4749
+ $arr = array();
4750
+ while (list($key, $value) = $XML_RPC_val->structeach()) {
4751
+ $arr[$key] = XML_RPC_decode($value);
4752
+ }
4753
+ return $arr;
4754
+ }
4755
+ }
4756
+
4757
+ /**
4758
+ * Converts native PHP types into an XML_RPC_Value object
4759
+ *
4760
+ * @param mixed $php_val the PHP value or variable you want encoded
4761
+ *
4762
+ * @return object the XML_RPC_Value object
4763
+ */
4764
+ function XML_RPC_encode($php_val)
4765
+ {
4766
+ global $XML_RPC_Boolean, $XML_RPC_Int, $XML_RPC_Double, $XML_RPC_String,
4767
+ $XML_RPC_Array, $XML_RPC_Struct, $XML_RPC_DateTime;
4768
+
4769
+ $type = gettype($php_val);
4770
+ $XML_RPC_val = new XML_RPC_Value;
4771
+
4772
+ switch ($type) {
4773
+ case 'array':
4774
+ if (empty($php_val)) {
4775
+ $XML_RPC_val->addArray($php_val);
4776
+ break;
4777
+ }
4778
+ $tmp = array_diff(array_keys($php_val), range(0, count($php_val)-1));
4779
+ if (empty($tmp)) {
4780
+ $arr = array();
4781
+ foreach ($php_val as $k => $v) {
4782
+ $arr[$k] = XML_RPC_encode($v);
4783
+ }
4784
+ $XML_RPC_val->addArray($arr);
4785
+ break;
4786
+ }
4787
+ // fall though if it's not an enumerated array
4788
+
4789
+ case 'object':
4790
+ $arr = array();
4791
+ foreach ($php_val as $k => $v) {
4792
+ $arr[$k] = XML_RPC_encode($v);
4793
+ }
4794
+ $XML_RPC_val->addStruct($arr);
4795
+ break;
4796
+
4797
+ case 'integer':
4798
+ $XML_RPC_val->addScalar($php_val, $XML_RPC_Int);
4799
+ break;
4800
+
4801
+ case 'double':
4802
+ $XML_RPC_val->addScalar($php_val, $XML_RPC_Double);
4803
+ break;
4804
+
4805
+ case 'string':
4806
+ case 'NULL':
4807
+ if(ereg('^[0-9]{8}\T{1}[0-9]{2}\:[0-9]{2}\:[0-9]{2}$', $php_val)) {
4808
+ $XML_RPC_val->addScalar($php_val, $XML_RPC_DateTime);
4809
+ } else {
4810
+ $XML_RPC_val->addScalar($php_val, $XML_RPC_String);
4811
+ }
4812
+ break;
4813
+
4814
+ case 'boolean':
4815
+ // Add support for encoding/decoding of booleans, since they
4816
+ // are supported in PHP
4817
+ // by <G_Giunta_2001-02-29>
4818
+ $XML_RPC_val->addScalar($php_val, $XML_RPC_Boolean);
4819
+ break;
4820
+
4821
+ case 'unknown type':
4822
+ default:
4823
+ $XML_RPC_val = false;
4824
+ }
4825
+ return $XML_RPC_val;
4826
+ }
4827
+
4828
+ /*
4829
+ * Local variables:
4830
+ * tab-width: 4
4831
+ * c-basic-offset: 4
4832
+ * c-hanging-comment-ender-p: nil
4833
+ * End:
4834
+ */
4835
+ ?>
app/code/local/Kreditor/Kreditor/Model/Api/pclasses.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ function get_months($pclass){
5
+ switch ($pclass) {
6
+ case 1:
7
+ return 24;
8
+ break;
9
+ case 100:
10
+ return 24;
11
+ break;
12
+ }
13
+ }
14
+
15
+ function get_month_fee($pclass){
16
+ switch ($pclass) {
17
+ case 1:
18
+ return 2900;
19
+ break;
20
+ case 100:
21
+ return 2900;
22
+ break;
23
+ }
24
+ }
25
+
26
+ function get_start_fee($pclass){
27
+ switch ($pclass) {
28
+ case 1:
29
+ return 29500;
30
+ break;
31
+ case 100:
32
+ return 29500;
33
+ break;
34
+ }
35
+ }
36
+
37
+ function get_rate($pclass){
38
+ switch ($pclass) {
39
+ case 1:
40
+ return 0;
41
+ break;
42
+ case 100:
43
+ return 0;
44
+ break;
45
+ }
46
+ }
47
+ ?>
app/code/local/Kreditor/Kreditor/Model/Convert/Order.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+
32
+ class Kreditor_Kreditor_Model_Convert_Order extends Mage_Sales_Model_Convert_Order {
33
+
34
+ /**
35
+ * Convert order payment to quote payment
36
+ *
37
+ * @param Mage_Sales_Model_Order_Payment $payment
38
+ * @return Mage_Sales_Model_Quote_Payment
39
+ */
40
+ public function paymentToQuotePayment(Mage_Sales_Model_Order_Payment $payment, $quotePayment=null) {
41
+ $quotePayment = parent::paymentToQuotePayment($payment, $quotePayment);
42
+
43
+ $quotePayment->setKreditorPno($payment->getKreditorPno())
44
+ ->setKreditorSalary($payment->getKreditorSalary())
45
+ ->setKreditorPayopt($payment->getKreditorPayopt())
46
+ ->setKreditorInvoicefee($payment->getKreditorInvoicefee())
47
+ ->setKreditorGender($payment->getKreditorGender())
48
+ ->setKreditorStreet($payment->getKreditorStreet())
49
+ ->setKreditorHouseNumber($payment->getKreditorHouseNumber())
50
+ ->setKreditorHouseExtension($payment->getKreditorHouseExtension());
51
+ return $quotePayment;
52
+ }
53
+ }
app/code/local/Kreditor/Kreditor/Model/Convert/Quote.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_Model_Convert_Quote extends Mage_Sales_Model_Convert_Quote {
32
+
33
+ /**
34
+ * Convert quote payment to order payment
35
+ *
36
+ * @param Mage_Sales_Model_Quote_Payment $payment
37
+ * @return Mage_Sales_Model_Quote_Payment
38
+ */
39
+ public function paymentToOrderPayment(Mage_Sales_Model_Quote_Payment $payment) {
40
+
41
+ $orderPayment = parent::paymentToOrderPayment($payment);
42
+ $orderPayment->setKreditorPno($payment->getKreditorPno())
43
+ ->setKreditorSalary($payment->getKreditorSalary())
44
+ ->setKreditorPayopt($payment->getKreditorPayopt())
45
+ ->setKreditorInvoicefee($payment->getKreditorInvoicefee())
46
+ ->setKreditorGender($payment->getKreditorGender())
47
+ ->setKreditorStreet($payment->getKreditorStreet())
48
+ ->setKreditorHouseNumber($payment->getKreditorHouseNumber())
49
+ ->setKreditorHouseExtension($payment->getKreditorHouseExtension());
50
+ return $orderPayment;
51
+ }
52
+
53
+ }
app/code/local/Kreditor/Kreditor/Model/Entity/Setup.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_Model_Entity_Setup extends Mage_Eav_Model_Entity_Setup {
32
+
33
+ }
app/code/local/Kreditor/Kreditor/Model/Method/Invoice.php ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_Model_Method_Invoice extends Kreditor_Kreditor_Model_Method_Shared {
32
+
33
+ protected $_canUseForMultishipping = false;
34
+ protected $_canAuthorize = true;
35
+
36
+ protected $_code = 'kreditor_invoice';
37
+ protected $_formBlockType = 'kreditor/form_invoice';
38
+ protected $_infoBlockType = 'kreditor/info_invoice';
39
+
40
+ /**
41
+ * Assign data to info model instance
42
+ *
43
+ * @param mixed $data
44
+ * @return Mage_Payment_Model_Method_Purchaseorder
45
+ */
46
+ public function assignData($data) {
47
+ if(!($data instanceof Varien_Object)) {
48
+ $data = new Varien_Object($data);
49
+ }
50
+
51
+ $info = $this->getInfoInstance();
52
+
53
+ $data->setKreditorPayopt(-1);
54
+ $info->setKreditorPayopt(-1);
55
+ $info->setKreditorPno(Mage::helper('kreditor')->replace_non_klarna_characters($data->getKreditorInvoicePno()));
56
+
57
+
58
+ if($data->getkreditorInvoiceGender() != null)
59
+ $info->setKreditorGender(($data->getKreditorInvoiceGender() == 'male' ? '1' : '0'));
60
+ $info->setKreditorStreet($data->getKreditorInvoiceStreet());
61
+ $info->setKreditorHouseNumber($data->getKreditorInvoiceHouseNumber());
62
+ $info->setKreditorHouseExtension($data->getKreditorInvoiceHouseExtension());
63
+
64
+ if(empty($salary)) {
65
+ $data->setKreditorSalary(0);
66
+ }
67
+
68
+
69
+
70
+ // xxx Save the invoice fee if we are shopping with invoice
71
+ if($data->getKreditorPayopt() == -1) {
72
+
73
+ if(Mage::getStoreConfig('advanced/klarna/invoice_fee_incvat') == 1 && $this->getShippingCountry() == "SE")
74
+ $info->setKreditorInvoicefee(Mage::helper('kreditor')->round_up($this->_getInvoiceFee()*($this->getVAT()/100+1), 2));
75
+ else
76
+ $info->setKreditorInvoicefee($this->_getInvoiceFee());
77
+ }
78
+
79
+ return $this;
80
+ }
81
+
82
+ public function _getInvoiceFee() {
83
+ $countryID = $this->getShippingCountry();
84
+ switch($countryID) {
85
+ case 'SE': return $this->getConfigData('invoice_fee_se');
86
+ case 'NO': return $this->getConfigData('invoice_fee_no');
87
+ case 'DK': return $this->getConfigData('invoice_fee_dk');
88
+ case 'FI': return $this->getConfigData('invoice_fee_fi');
89
+ case 'DE': return $this->getConfigData('invoice_fee_de');
90
+ case 'NL': return $this->getConfigData('invoice_fee_nl');
91
+ default: return '';
92
+ }
93
+ }
94
+
95
+ // xxx This method sets the title of the payment option based on the current locale
96
+ public function getTitle(){
97
+ $countryId = $this->getShippingCountry();
98
+ switch($countryId) {
99
+ case 'SE': return "Faktura - Betala 14 dagar efter leverans";
100
+ case 'NO': return "Faktura - Betale om 14 dager";
101
+ case 'DK': return "Faktura - Betale om 14 dage";
102
+ case 'FI': return "Lasku - 14 päivää maksuaikaa";
103
+ case 'DE': return "Rechnung - Zahlung innerhalb von 14 Tagen";
104
+ case 'NL': return "Factuur - Betaal binnen 14 dagen";
105
+ default: return 'Invoice - Pay within 14 days';
106
+ }
107
+ }
108
+
109
+ public function getLogoUrl() {
110
+
111
+ $countryId = $this->getShippingCountry();
112
+ switch($countryId) {
113
+ case 'SE': return 'images/kreditor/invoice/logo.png';
114
+ case 'NO': return "images/kreditor/invoice/klarna.png";
115
+ case 'NO': return "images/kreditor/invoice/klarna.png";
116
+ case 'DK': return 'images/kreditor/invoice/klarna.png';
117
+ case 'FI': return 'images/kreditor/invoice/logo_fi.png';
118
+ case 'DE': return 'images/kreditor/invoice/logo_de.png';
119
+ case 'NL': return 'images/kreditor/invoice/logo_nl.png';
120
+ default: return "images/kreditor/invoice/klarna.png";
121
+ }
122
+ }
123
+
124
+ public function authorize(Varien_Object $payment, $amount) {
125
+
126
+ $api = $this->getApi();
127
+ $invoicenr = $api->tryAuthorize(array('payment' => $payment, 'invoicefee' => $this->_getInvoiceFee()));
128
+ $payment->setLastTransId($invoicenr);
129
+
130
+ return $this;
131
+ }
132
+
133
+ public function isAvailable($quote = null) {
134
+ if(is_null($quote)) {
135
+ return false;
136
+ }
137
+
138
+ $totals = $quote->getTotals();
139
+ if(!isset($totals['grand_total'])) {
140
+ return false;
141
+ }
142
+ $grandTotal = $totals['grand_total'];
143
+
144
+ // do not allow this payment to be available if total is below customer configurable value.
145
+ $allowedMin = $this->getMinimumOrderCost(Mage::app()->getStore()->getCurrentCurrencyCode());
146
+
147
+ if(Mage::app()->getStore()->roundPrice($grandTotal->getValue()) <= $allowedMin) {
148
+ return false;
149
+ }
150
+
151
+ $maximum_order_limit_nl = (int)Mage::getStoreConfig('advanced/klarna/maximum_order_amount_nl');
152
+ $maximum_order_limit_de = (int)Mage::getStoreConfig('advanced/klarna/maximum_order_amount_de');
153
+
154
+ if($maximum_order_limit_nl != -1 && $totals['grand_total']->getValue() > $maximum_order_limit_nl && $this->getShippingCountry() == 'NL')
155
+ return false;
156
+
157
+ if($maximum_order_limit_de != -1 && $totals['grand_total']->getValue() > $maximum_order_limit_de && $this->getShippingCountry() == 'DE')
158
+ return false;
159
+
160
+ return true;
161
+ }
162
+
163
+ public function getVAT()
164
+ {
165
+ $quote = $this->getCheckout()->getQuote();
166
+ $billing = $quote->getShippingAddress();
167
+ if(!$quote->getSubtotalWithDiscount() == 0)
168
+ return round((($quote->getGrandTotal()-$billing->getShippingAmount()-$billing->getShippingTaxAmount())/$quote->getSubtotalWithDiscount()-1)*100,2);
169
+
170
+ return 0;
171
+ }
172
+
173
+
174
+ }
app/code/local/Kreditor/Kreditor/Model/Method/Partpayment.php ADDED
@@ -0,0 +1,268 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_Model_Method_Partpayment extends Kreditor_Kreditor_Model_Method_Shared {
32
+
33
+ protected $_canUseForMultishipping = false;
34
+ protected $_canAuthorize = true;
35
+
36
+ protected $_code = 'kreditor_partpayment';
37
+ protected $_formBlockType = 'kreditor/form_partpayment';
38
+ protected $_infoBlockType = 'kreditor/info_partpayment';
39
+
40
+ protected $_minimumCostPerMonth = 50;
41
+ protected $_minimumCostPerMonthForEuro = 9;
42
+ protected $_minimumOrderCost = 200;
43
+ protected $_minimumOrderCostForEuro = 20;
44
+
45
+ /**
46
+ * Assign data to info model instance
47
+ *
48
+ * @param mixed $data
49
+ * @return Mage_Payment_Model_Method_Purchaseorder
50
+ */
51
+ public function assignData($data) {
52
+ if(!($data instanceof Varien_Object)) {
53
+ $data = new Varien_Object($data);
54
+ }
55
+
56
+ $info = $this->getInfoInstance();
57
+ $info->setKreditorPno(Mage::helper('kreditor')->replace_non_klarna_characters($data->getKreditorPartpaymentPno()));
58
+ $info->setKreditorSalary($data->getKreditorPartpaymentYearSalary());
59
+ $info->setKreditorPayopt($data->getKreditorPayopt());
60
+
61
+ if($data->getKreditorPartpaymentGender() != null)
62
+ $info->setKreditorGender(($data->getKreditorPartpaymentGender() == 'male' ? '1' : '0'));
63
+
64
+ $info->setKreditorStreet($data->getKreditorPartpaymentStreet());
65
+ $info->setKreditorHouseNumber($data->getKreditorPartpaymentHouseNumber());
66
+ $info->setKreditorHouseExtension($data->getKreditorPartpaymentHouseExtension());
67
+
68
+ return $this;
69
+ }
70
+
71
+ // This method sets the title of the payment option based on
72
+ // shipping country
73
+ public function getTitle() {
74
+
75
+ $options = $this->getPayOptions();
76
+ $key = array_keys($options);
77
+ $key = $key[0];
78
+ $last_cost = $options[$key]->getCostPerMonth();
79
+ $min_cost = 0;
80
+ // Get the option with the lowest monthly cost
81
+ foreach($options as $pclass) {
82
+ if($last_cost > $pclass->getCostPerMonth() && $pclass->getType() != 2 || $last_cost == 0) {
83
+ $last_cost = $pclass->getCostPerMonth();
84
+ }
85
+ }
86
+
87
+ // Format the price
88
+
89
+ if($last_cost > 0)
90
+ $lowest_price_styled = Mage::helper('checkout')->formatPrice(round($last_cost/100, 2));
91
+
92
+ $countryId = $this->getShippingCountry();
93
+ switch($countryId) {
94
+ case 'SE': return "Delbetalning - Klarna " . ($last_cost > 0 ? "från " . $lowest_price_styled . '/mån' : '');
95
+ case 'NO': return "Delbetaling via Klarna " . ($last_cost > 0 ? "- Betal fra " . $lowest_price_styled . ' i måneden' : '');
96
+ case 'DK': return "Delbetaling - Klarna " . ($last_cost > 0 ? "fra " . $lowest_price_styled . ' per måned' : '');
97
+ case 'FI': return "Osamaksu - Klarna " . ($last_cost > 0 ? "alk " . $lowest_price_styled . '/kk' : '');
98
+ case 'DE': return "Ratenkauf " . ($last_cost > 0 ? "ab " . $lowest_price_styled : '');
99
+ case 'NL': return "Gespreide betaling - Klarna " . ($last_cost > 0 ? "vanaf " . $lowest_price_styled . '/maand' : '');
100
+ default: return "Part payment - Klarna";
101
+ }
102
+ }
103
+
104
+
105
+
106
+ public function isAvailable($quote = null) {
107
+
108
+ if(is_null($quote)) {
109
+ return false;
110
+ }
111
+
112
+ $totals = $quote->getTotals();
113
+ if(!isset($totals['grand_total'])) {
114
+ return false;
115
+ }
116
+
117
+ $grandTotal = $totals['grand_total'];
118
+
119
+ // do not allow this payment to be available if total is below customer configurable value.
120
+ $allowedMin = $this->getMinimumOrderCost(Mage::app()->getStore()->getCurrentCurrencyCode());
121
+
122
+ if(Mage::app()->getStore()->roundPrice($grandTotal->getValue()) <= $allowedMin) {
123
+ return false;
124
+ }
125
+
126
+
127
+
128
+ $maximum_order_limit_nl = (int)Mage::getStoreConfig('advanced/klarna/maximum_order_amount_nl');
129
+ $maximum_order_limit_de = (int)Mage::getStoreConfig('advanced/klarna/maximum_order_amount_de');
130
+
131
+ if($maximum_order_limit_nl != -1 && $totals['grand_total']->getValue() > $maximum_order_limit_nl && $this->getShippingCountry() == 'NL')
132
+ return false;
133
+
134
+ if($maximum_order_limit_de != -1 && $totals['grand_total']->getValue() > $maximum_order_limit_de && $this->getShippingCountry() == 'DE')
135
+ return false;
136
+
137
+ $options = $this->getPayOptions();
138
+
139
+ if(empty($options)) return false;
140
+
141
+ return true;
142
+ }
143
+
144
+ public function getPayOptions($checkout = false) {
145
+
146
+ $currency = Mage::app()->getStore()->getCurrentCurrencyCode();
147
+ $totals = $this->getCheckout()->getQuote()->getTotals();
148
+ $grandTotal = $totals['grand_total']->getValue();
149
+
150
+ if($grandTotal == 0 && isset($this['info_instance']))
151
+ $grandTotal = $this->getInfoInstance()->getAmountOrdered();
152
+
153
+ $pclassModel = Mage::getModel('kreditor/api_pclass');
154
+ $pclassCollection = $pclassModel->getCollection()
155
+ ->addCurrencyFilter($currency)
156
+ ->addMinAmountFilter($grandTotal * 100)
157
+ ->addStoreViewFilter(Mage::app()->getStore()->getId())
158
+ ->addCountryFilter($this->getKlarnaCountryCode($this->getShippingCountry()));
159
+
160
+ $api = $this->getApi();
161
+ $costPerMonth = 0;
162
+ $options = array();
163
+
164
+ foreach($pclassCollection as $pclassItem) {
165
+
166
+ if($pclassItem->getType() == 2)
167
+ $costPerMonth = 0;
168
+ else
169
+ $api->calc_monthly_cost($grandTotal*100, $pclassItem->getPclassId(), 0, $pclassItem->getCountry(), $costPerMonth);
170
+
171
+ if(($costPerMonth >= $this->getMinAmount() || $pclassItem->getType() == 1 || $pclassItem->getType() == 2))
172
+ {
173
+
174
+ $pclassItem->setCostPerMonth($costPerMonth);
175
+ $options[] = $pclassItem;
176
+ }
177
+
178
+ }
179
+
180
+
181
+
182
+ $vals = array();
183
+ $account = array();
184
+
185
+ foreach($options as $pclass)
186
+ {
187
+
188
+ if($pclass->getType() == 0 || !$checkout) {
189
+ $vals[$pclass->getCostPerMonth() . $pclass->getId()] = $pclass;
190
+
191
+ }
192
+ else
193
+ $account[$pclass->getCostPerMonth() . $pclass->getId()] = $pclass;
194
+ }
195
+
196
+ ksort($vals);
197
+
198
+ if(!empty ($account))
199
+ {
200
+ ksort($account);
201
+ $vals = array_merge($account, $vals);
202
+ }
203
+
204
+ return $vals;
205
+ }
206
+
207
+ // Return the min amount that we are allowed to shop for
208
+ // This only applys to campaigns
209
+ private function getMinAmount() {
210
+
211
+ switch($this->getShippingCountry()) {
212
+ case 'SE':
213
+ return 5000;
214
+ case 'NO':
215
+ return 9500;
216
+ case 'DK':
217
+ return 8900;
218
+ case 'FI':
219
+ return 895;
220
+ case 'DE':
221
+ case 'NL':
222
+ return 695;
223
+ }
224
+
225
+ }
226
+
227
+ public function getShowSalary()
228
+ {
229
+ return $this->getCheckout()->getQuote()->getShippingAddress();
230
+
231
+ }
232
+ public function getLogoUrl() {
233
+
234
+ $countryId = $this->getShippingCountry();
235
+ switch($countryId) {
236
+ case 'SE': return 'images/kreditor/partpayment/logo.png';
237
+ case 'NO': return 'images/kreditor/partpayment/logo.png';
238
+ case 'DK': return 'images/kreditor/partpayment/logo.png';
239
+ case 'FI': return 'images/kreditor/partpayment/logo_fi.png';
240
+ case 'DE': return 'images/kreditor/partpayment/logo_de.png';
241
+ case 'NL': return 'images/kreditor/partpayment/logo_nl.png';
242
+ default: return "images/kreditor/partpayment/logo.png";
243
+ }
244
+ }
245
+
246
+ private function getKlarnaCountryCode($countryId) {
247
+ switch($countryId) {
248
+ case 'SE': return 209;
249
+ case 'NO': return 164;
250
+ case 'DK': return 59;
251
+ case 'FI': return 73;
252
+ case 'DE': return 81;
253
+ case 'NL': return 154;
254
+ }
255
+
256
+ }
257
+
258
+ public function authorize(Varien_Object $payment, $amount) {
259
+ $api = $this->getApi();
260
+
261
+ $invoicenr = $api->tryAuthorize(array('payment' => $payment, 'invoicefee' => 0));
262
+
263
+ $payment->setLastTransId($invoicenr);
264
+
265
+
266
+ return $this;
267
+ }
268
+ }
app/code/local/Kreditor/Kreditor/Model/Method/Shared.php ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_Model_Method_Shared extends Mage_Payment_Model_Method_Abstract {
32
+
33
+ protected $_canUseForMultishipping = false;
34
+ protected $_canAuthorize = true;
35
+
36
+ protected $_code = 'kreditor_shared';
37
+
38
+ protected $_allowCurrencyCode = array('SEK', 'NOK', 'DKK', 'EUR');
39
+ protected $_allowCountryCode = array('SE', 'NO', 'DK', 'FI', 'DE', 'NL');
40
+
41
+ public function canUseForCountry($country) {
42
+ if($this->getConfigData('allowspecific') == 1) {
43
+ $availableCountries = explode(',', $this->getConfigData('specificcountry'));
44
+ if(!in_array($country, $availableCountries)) {
45
+ return false;
46
+ }
47
+ } else {
48
+ if(!in_array($country, $this->_allowCountryCode)) {
49
+ return false;
50
+ }
51
+ if(!$this->currencyMatch($country)) {
52
+ return false;
53
+ }
54
+ }
55
+ return true;
56
+ }
57
+
58
+ public function currencyMatch($country) {
59
+ $currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
60
+
61
+ switch($country) {
62
+ case 'SE': return ($currency_code == 'SEK');
63
+ case 'NO': return ($currency_code == 'NOK');
64
+ case 'DK': return ($currency_code == 'DKK');
65
+ case 'FI':
66
+ case 'NL':
67
+ case 'DE':
68
+ return ($currency_code == 'EUR');
69
+ default: return false;
70
+ }
71
+ }
72
+
73
+ /**
74
+ * Get checkout session namespace
75
+ * @return Mage_Checkout_Model_Session
76
+ */
77
+ public function getCheckout() {
78
+ return Mage::getSingleton('checkout/session');
79
+ }
80
+
81
+ public function getMerchantId() {
82
+ return $this->getConfigData('merchant_id');
83
+ }
84
+
85
+ public function getSecurityKey() {
86
+ return $this->getConfigData('security_key');
87
+ }
88
+
89
+ public function getApi() {
90
+ $api = Mage::getSingleton('kreditor/api_kreditor');
91
+ $api->setMerchantId($this->getConfigData('merchant_id'));
92
+ $api->setSecurityKey($this->getConfigData('security_key'));
93
+ $api->setTransactionMode($this->getConfigData('transaction_mode'));
94
+ return $api;
95
+ }
96
+
97
+ public function getBillingCountry() {
98
+ return $this->getCheckout()
99
+ ->getQuote()
100
+ ->getBillingAddress()
101
+ ->getCountryId();
102
+ }
103
+
104
+ public function getShippingCountry() {
105
+ return $this->getCheckout()
106
+ ->getQuote()
107
+ ->getShippingAddress()
108
+ ->getCountryId();
109
+ }
110
+
111
+ public function getShippingAddress() {
112
+ return $this->getCheckout()
113
+ ->getQuote()
114
+ ->getShippingAddress();
115
+ }
116
+
117
+
118
+ /**
119
+ * Address returned from getAddressFromKreditor
120
+ *
121
+ * @param array $data
122
+ * @param boolean $isCompany
123
+ */
124
+ public function updateAdresses($data, $phone, $isCompany = false) {
125
+ /*
126
+ * $data should be:
127
+ * 0: firstname
128
+ * 1: lastname
129
+ * 2: street
130
+ * 3: postcode
131
+ * 4: city:
132
+ * 5: kreditors country code.
133
+ */
134
+
135
+ $billing = $this->getCheckout()->getQuote()->getBillingAddress();
136
+ $shipping = $this->getCheckout()->getQuote()->getShippingAddress();
137
+ if($isCompany) {
138
+ $shipping->setCompany(($data[0]));
139
+ } else {
140
+ $shipping->setFirstname(($data[0]));
141
+ $shipping->setLastname(($data[1]));
142
+ }
143
+ $shipping->setStreet(($data[2]));
144
+ $shipping->setPostcode(($data[3]));
145
+ $shipping->setCity(($data[4]));
146
+ // xxx Set the phone number that the user specified
147
+ $shipping->setTelephone(($phone));
148
+ $shipping->save();
149
+ $billing->importCustomerAddress($shipping->exportCustomerAddress());
150
+ }
151
+
152
+ public function validate() {
153
+ parent::validate();
154
+
155
+ $checkout = $this->getCheckout();
156
+ $currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
157
+
158
+ if(!in_array($currency_code, $this->_allowCurrencyCode)) {
159
+ Mage::throwException(Mage::helper('kreditor')->__('Selected currency is not compatible with Kreditor'));
160
+ }
161
+
162
+ $info = $this->getInfoInstance();
163
+ $pno_number = $info->getKreditorPno();
164
+
165
+
166
+ $infoArr = array('firstname', 'lastname', 'street', 'city', 'postcode', 'country_id', 'telephone', 'company');
167
+ $bAddress = $checkout->getQuote()->getBillingAddress()->toArray();
168
+
169
+ $sAdress = $checkout->getQuote()->getShippingAddress()->toArray();
170
+
171
+
172
+ $this->getCheckout()->getQuote()->getShippingAddress()->setTelephone(utf8_encode($_POST['payment'][$_POST['payment']['method'] . '_cellno']));
173
+ $this->getCheckout()->getQuote()->getBillingAddress()->importCustomerAddress($this->getCheckout()->getQuote()->getShippingAddress()->exportCustomerAddress());
174
+
175
+
176
+
177
+ $api = $this->getApi();
178
+
179
+ if($currency_code == 'SEK') {
180
+ $address = explode("|", $_POST['payment'][$_POST['payment']['method'] . '_shippingaddress']);
181
+ if($address == 'pno') {
182
+ Mage::throwException(Mage::helper('kreditor')->__('Please enter a valid SSN/Orgnr.'));
183
+ } else {
184
+ // check if it is a company
185
+ // if the firstname is empty then we can treat it as a company
186
+ // @todo clean up the if stmt below. its a quick fix and very ugly
187
+ if(is_array($address)) {
188
+ $firstNameField = trim($address[0]);
189
+ if(empty($firstNameField)) {
190
+ $info->setIsCompany(true);
191
+ if(empty($bAddress['company'])) { // user prodived org-nr but left company field blank
192
+ // check if we are allowed to update the billing/shipping information
193
+ if($this->getConfigData('update_address')) {
194
+ $this->updateAdresses($address, $_POST['payment'][$_POST['payment']['method'] . '_cellno'], true);
195
+ } else {
196
+ Mage::throwException(Mage::helper('kreditor')->__('Please go back and fill in your company name.'));
197
+ }
198
+ } else {
199
+ if($this->getConfigData('update_address')) {
200
+ $this->updateAdresses($address, $_POST['payment'][$_POST['payment']['method'] . '_cellno'],true);
201
+ }
202
+ }
203
+ } else {
204
+ $info->setIsCompany(false);
205
+ if($this->getConfigData('update_address')) {
206
+ $this->updateAdresses($address, $_POST['payment'][$_POST['payment']['method'] . '_cellno']);
207
+ }
208
+ }
209
+ } else
210
+ Mage::throwException("Vänligen ange en address.");
211
+ }
212
+ } else
213
+ {
214
+ $shippingcountry = $this->getShippingCountry();
215
+ if($shippingcountry == 'DE' || $shippingcountry == 'NL')
216
+ $street = $info->getKreditorStreet() . ' ' . $info->getKreditorHouseNumber() . ' ' . $info->getKreditorHouseExtension();
217
+ else
218
+ $street = $this->getCheckout()->getQuote()->getShippingAddress()->getStreet();
219
+
220
+ // xxx Set the phone number and street to the one that the user provided
221
+ $this->getCheckout()->getQuote()->getBillingAddress()->setTelephone(utf8_encode($_POST['payment'][$_POST['payment']['method'] . '_cellno']))->setStreet($street);
222
+ $this->getCheckout()->getQuote()->getShippingAddress()->setTelephone(utf8_encode($_POST['payment'][$_POST['payment']['method'] . '_cellno']))->setStreet($street);
223
+ }
224
+ return $this;
225
+ }
226
+
227
+ public function getMinimumOrderCost($currency) {
228
+ $allowedMin = $this->getConfigData('minimum_order_cost_'.strtolower($currency));
229
+ if(!is_numeric($allowedMin)) { $allowedMin = 0; }
230
+
231
+ return $allowedMin;
232
+ }
233
+ }
app/code/local/Kreditor/Kreditor/Model/Mysql4/Api/Pclass.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_Model_Mysql4_Api_Pclass extends Mage_Core_Model_Mysql4_Abstract {
32
+ protected function _construct() {
33
+ $this->_init('kreditor/api_pclass', 'id');
34
+ }
35
+ }
app/code/local/Kreditor/Kreditor/Model/Mysql4/Api/Pclass/Collection.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+
32
+ class Kreditor_Kreditor_Model_Mysql4_Api_Pclass_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
33
+ public function _construct() {
34
+ parent::_construct();
35
+ $this->_init('kreditor/api_pclass');
36
+ }
37
+
38
+ public function addCurrencyFilter($currency) {
39
+ $this->getSelect()->where('currency = ?', $currency);
40
+ return $this;
41
+ }
42
+
43
+ public function addMinAmountFilter($minamount) {
44
+ $this->getSelect()->where('minamount < ?', $minamount);
45
+ return $this;
46
+ }
47
+
48
+ public function addMinAmountOrderFilter() {
49
+ $this->setOrder('minamount');
50
+ return $this;
51
+ }
52
+
53
+ public function addStoreViewFilter($storeid) {
54
+ $this->getSelect()->where('storeid = ?', $storeid);
55
+ return $this;
56
+ }
57
+
58
+ public function addCountryFilter($country) {
59
+ $this->getSelect()->where('country = ?', $country);
60
+ return $this;
61
+ }
62
+
63
+
64
+ }
app/code/local/Kreditor/Kreditor/Model/Sales/Order.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_Model_Sales_Order extends Mage_Sales_Model_Order {
32
+
33
+ /**
34
+ * Place order
35
+ *
36
+ * @return Mage_Sales_Model_Order
37
+ */
38
+
39
+ // xxx In this method can we change the values before they are stored in the database.
40
+ public function place() {
41
+
42
+ $helper = Mage::helper('kreditor');
43
+ // xxx Get the payment method
44
+ $paymentmethod = $this->getPayment()->getMethod();
45
+ // xxx Check if we are using Klarna Invoice
46
+ if($paymentmethod == "kreditor_invoice" || $paymentmethod == "kreditor_partpayment")
47
+ {
48
+ // xxx Get the invoice fee
49
+ $invoicefee = 0;
50
+ if($paymentmethod == "kreditor_invoice")
51
+ $invoicefee = str_replace(',','.',$helper->getInvoiceFee($this));
52
+
53
+ // xxx Get the new calculated tax
54
+ $tax = $helper->calculateShippingAndHandlingVAT($this);
55
+
56
+ // xxx The original tax
57
+ $orgtax = $this->getTaxAmount();
58
+
59
+ // xxx Get shipping
60
+ $orgshippingcost = $this->getShippingAmount();
61
+ // xxx get the shipping tax amount from the billing address
62
+ $totalshippingtax = $this->getShippingTaxAmount();
63
+
64
+ $incvat = Mage::getStoreConfig('advanced/klarna/invoice_fee_incvat');
65
+
66
+ if(($incvat == 0) || empty($incvat))
67
+ $incvat = 0;
68
+ else
69
+ $incvat = 1;
70
+
71
+ // xxx Calculate the taxes
72
+ if($incvat) {
73
+ $invoicefeetax = ($invoicefee*($tax['TaxPercent']/100+1) - $invoicefee);
74
+ $shippingfeetax = ($this->getShippingAmount()*($tax['TaxPercent']/100+1))-$this->getShippingAmount();
75
+ } else {
76
+ $invoicefeetax = ($invoicefee - ($invoicefee/($tax['TaxPercent']/100+1)));
77
+ $shippingfeetax = ($this->getShippingAmount()+$totalshippingtax - (($this->getShippingAmount()+$totalshippingtax)/($tax['TaxPercent']/100+1)));
78
+ }
79
+
80
+
81
+ // xxx Do the calculations here that are specific for sweden (special tax for invoice cost and shipping cost)
82
+ if($this->getShippingAddress()->getCountryId() == "SE")
83
+ {
84
+ if(!$incvat)
85
+ $this->setShippingAmount(round(($this->getShippingAmount()+$totalshippingtax)/($tax['TaxPercent']/100+1),2));
86
+
87
+ $this->setShippingTaxAmount(round($shippingfeetax,2));
88
+ $this->setTaxAmount(round($this->getTaxAmount(),2) - round($totalshippingtax,2) + $helper->round_up($invoicefeetax,2) + round($shippingfeetax,2));
89
+
90
+ if(!$incvat)
91
+ $this->setGrandTotal($this->getGrandTotal()+round($invoicefee, 2));
92
+ else
93
+ $this->setGrandTotal(round($this->getGrandTotal() - round($totalshippingtax,2) -round($orgshippingcost,2) + round($this->getShippingAmount(), 2) + round($this->getShippingTaxAmount(), 2) + round($invoicefee, 2) + $helper->round_up($invoicefeetax,2), 2));
94
+
95
+ // xxx The convert rate between store currency and base currency
96
+ $convertrate = $this->getBaseToOrderRate();
97
+ // xxx Set all the new base values
98
+ $this->setBaseShippingAmount(round($this->getShippingAmount()/$convertrate,2));
99
+ $this->setBaseShippingTaxAmount(round($this->getShippingTaxAmount()/$convertrate,2));
100
+ $this->setBaseTaxAmount(round($this->getTaxAmount()/$convertrate,2));
101
+ $this->setBaseShippingAmount(round($this->getShippingAmount()/$convertrate,2));
102
+ $this->setBaseGrandTotal(round($this->getGrandTotal()/$convertrate,2));
103
+
104
+ }
105
+ // Or if the country isnt sweden
106
+ else
107
+ {
108
+ // xxx The convert rate between store currency and base currency
109
+ $convertrate = $this->getBaseToOrderRate();
110
+
111
+ // xxx Calculate the handlingvat and replace , with . if there are any
112
+ $handlingvat = str_replace(',','.',$helper->getHandlingVAT($this))/100+1;
113
+ // xxx Set the new tax amount to include the invoice fee tax
114
+ $this->setTaxAmount($this->getTaxAmount() + round($invoicefee-($invoicefee/$handlingvat),2));
115
+ // xxx Set the new grand total to include the invoice fee
116
+ $this->setGrandTotal($this->getGrandTotal() - $orgtax + $this->getTaxAmount() + round(($invoicefee/$handlingvat),2));
117
+
118
+ $this->setBaseTaxAmount(round($this->getTaxAmount()/$convertrate,2));
119
+ $this->setBaseGrandTotal(round($this->getGrandTotal()/$convertrate, 2));
120
+
121
+ }
122
+
123
+ Mage::dispatchEvent('sales_order_place_before', array('order'=>$this));
124
+ $this->_placePayment();
125
+ Mage::dispatchEvent('sales_order_place_after', array('order'=>$this));
126
+
127
+ return $this;
128
+ } else
129
+ return parent::place();
130
+ }
131
+
132
+
133
+
134
+
135
+ }
app/code/local/Kreditor/Kreditor/Model/Sales/Order/Invoice/Total/Invoicefee.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_Model_Sales_Order_Invoice_Total_Invoicefee extends Mage_Sales_Model_Order_Invoice_Total_Abstract
32
+ {
33
+
34
+ public function collect(Mage_Sales_Model_Order_Invoice $invoice)
35
+ {
36
+ // xxx Only show this if the payment method is klarna invoice
37
+ if($invoice->getOrder()->getPayment()->getMethod() == "kreditor_invoice")
38
+ {
39
+ $incvat = Mage::getStoreConfig('advanced/klarna/invoice_fee_incvat');
40
+
41
+ $country = (string)$invoice->getOrder()->getShippingAddress()->getCountryId();
42
+ // xxx Remove the comma sign and replace it with a dot
43
+ $invoicefee = str_replace(',','.',$invoice->getOrder()->getPayment()->getKreditorInvoicefee());
44
+
45
+ if($country == 'SE') {
46
+ $tax = Mage::helper('kreditor')->calculateShippingAndHandlingVAT($invoice->getOrder());
47
+ // xxx Calculate the taxes
48
+ $invoicefeetax = Mage::helper('kreditor')->round_up($invoicefee - ($invoicefee/($tax['TaxPercent']/100+1)),2);
49
+ } else
50
+ $invoicefeetax = round($invoicefee-($invoicefee/(str_replace(',','.',Mage::helper('kreditor')->getHandlingVAT($invoice->getOrder()))/100+1)),2);
51
+
52
+ // xxx Add the invoice fee tax to the tax total
53
+ $invoice->setTaxAmount($invoice->getTaxAmount()+$invoicefeetax);
54
+ $invoice->setBaseTaxAmount($invoice->getBaseTaxAmount()+($invoicefeetax/$invoice->getBaseToOrderRate()));
55
+ // xxx Add the invoice fee to the grand total
56
+ $invoice->setGrandTotal($invoice->getGrandTotal()+$invoicefee);
57
+ $invoice->setBaseGrandTotal($invoice->getGrandTotal()/$invoice->getBaseToOrderRate());
58
+
59
+
60
+
61
+ }
62
+
63
+ return $this;
64
+ }
65
+ }
app/code/local/Kreditor/Kreditor/Model/Sales/Quote.php ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_Model_Sales_Quote extends Mage_Sales_Model_Quote
32
+ {
33
+
34
+
35
+ /**
36
+ * Get all quote totals (sorted by priority)
37
+ *
38
+ * @return array
39
+ */
40
+ public function getTotals()
41
+ {
42
+ // xxx First run the original method and fetch the result
43
+ $sortedTotals = parent::getTotals();
44
+ $helper = Mage::helper('kreditor');
45
+ // xxx Add the invoice cost to the grand total
46
+ if($this->getPayment()->getMethod() == "kreditor_invoice" || $this->getPayment()->getMethod() == "kreditor_partpayment")
47
+ {
48
+ // xxx Calculate the new tax for invoice fee and shipping based on the total order and
49
+ // the different taxes there may be
50
+ $tax = str_replace(',','.',$helper->calculateShippingAndHandlingVAT($this));
51
+
52
+ $totalshippingtax = 0;
53
+
54
+
55
+ $invoicefee = 0;
56
+ // xxx Get the invoice fee in case its the purchase is made by invoice
57
+ if($this->getPayment()->getMethod() == "kreditor_invoice")
58
+ $invoicefee = str_replace(',','.',$helper->getInvoiceFee($this));
59
+ $shippingfee = 0;
60
+
61
+ if(isset($sortedTotals["shipping"]))
62
+ $shippingfee = $sortedTotals["shipping"]->getValue();
63
+
64
+ $invoicefeetax = 0;
65
+ $shippingfeetax = 0;
66
+
67
+ $incvat = Mage::getStoreConfig('advanced/klarna/invoice_fee_incvat');
68
+
69
+ if(($incvat == 0) || empty($incvat))
70
+ $incvat = 0;
71
+ else
72
+ $incvat = 1;
73
+
74
+ // xxx Get the original tax
75
+ if(isset($sortedTotals["tax"]))
76
+ $orgtax = $sortedTotals['tax']->getValue();
77
+ else
78
+ $orgtax = 0;
79
+
80
+ // xxx Try to get the shipping tax amount from the billing address
81
+ $billingaddressshippingtax = $this->getBillingAddress()->getShippingTaxAmount();
82
+
83
+ // xxx Get the total shippingtax as this one has to be recalculated.
84
+ if($billingaddressshippingtax != 0)
85
+ $totalshippingtax = $billingaddressshippingtax;
86
+ else
87
+ $totalshippingtax = $this->getShippingAddress()->getShippingTaxAmount();
88
+
89
+ // xxx These calculations are only applicable to sweden today
90
+ if($this->getBillingAddress()->getCountryId() == "SE")
91
+ {
92
+ // xxx Calculate the taxes
93
+ if($incvat) {
94
+ $invoicefeetax = ($invoicefee*($tax['TaxPercent']/100+1) - $invoicefee);
95
+ $shippingfeetax = ($shippingfee*($tax['TaxPercent']/100+1))-$shippingfee;
96
+ } else {
97
+ $invoicefeetax = ($invoicefee - ($invoicefee/($tax['TaxPercent']/100+1)));
98
+ $shippingfeetax = ($shippingfee+$totalshippingtax - (($shippingfee+$totalshippingtax)/($tax['TaxPercent']/100+1)));
99
+ }
100
+ if($this->getPayment()->getMethod() == "kreditor_partpayment")
101
+ $invoicefeetax = 0;
102
+
103
+ // xxx Print the invoice fee. Can be shown without tax by adding - $invoicefeetax
104
+ if(isset($sortedTotals['kreditor']))
105
+ if($incvat)
106
+ $sortedTotals['kreditor']->setValue(($invoicefee));
107
+ else
108
+ $sortedTotals['kreditor']->setValue(($invoicefee/($tax['TaxPercent']/100+1)));
109
+
110
+ // xxx Set the cost for shipping to incl. vat To remove VAT., simply add - $shippingfeetax
111
+ if(isset($sortedTotals['shipping'])) {
112
+ $shippingdiff = 0;
113
+ // xxx If we have chosen to add new tax to shipping instead of calc a new ex. vat price
114
+ if(!$incvat) {
115
+ $sortedTotals["shipping"]->setValue(($shippingfee+$totalshippingtax)/($tax['TaxPercent']/100+1));
116
+ $shippingdiff = ($shippingfee+$totalshippingtax) - $sortedTotals["shipping"]->getValue();
117
+ }
118
+ }
119
+
120
+ // xxx Add the tax for the invoice fee and handling fee to the total
121
+ $newtax = 0;
122
+
123
+ if(isset($sortedTotals['tax']))
124
+ {
125
+ $sortedTotals['tax']->setValue(round($sortedTotals['tax']->getValue(),2) - round($totalshippingtax,2) + $helper->round_up($invoicefeetax,2) + round($shippingfeetax,2));
126
+ $newtax = $sortedTotals['tax']->getValue();
127
+ }
128
+
129
+ $grandtotal = 0;
130
+ foreach($sortedTotals as $total)
131
+ {
132
+ if($total->getCode() != 'grand_total' && is_numeric($total->getValue()))
133
+ {
134
+ $grandtotal += round($total->getValue(),2);
135
+ $total->setValue(round($total->getValue(), 2));
136
+ }
137
+ }
138
+ //$sortedTotals['grand_total']->setValue($sortedTotals['grand_total']->getValue() - $totalshippingtax -$shippingfee + $sortedTotals['shipping']->getValue() + $shippingfeetax + $invoicefee + $invoicefeetax);
139
+ // xxx Set the new correct grand total
140
+ if(isset($sortedTotals['grand_total']))
141
+ $sortedTotals['grand_total']->setValue(round($grandtotal, 2));
142
+
143
+ }
144
+ else
145
+ {
146
+ $newtax = 0;
147
+ // xxx Set the invoice fee
148
+ if(isset($sortedTotals['kreditor']))
149
+ $sortedTotals['kreditor']->setValue(($invoicefee));
150
+ // xxx For non swedes we simply add the invoice tax to the tax
151
+ if(isset($sortedTotals["tax"]))
152
+ {
153
+ $sortedTotals['tax']->setValue($sortedTotals['tax']->getValue() + round($invoicefee-($invoicefee/(str_replace(',','.',$helper->getHandlingVAT($this))/100+1)),2));
154
+ $newtax = $sortedTotals['tax']->getValue();
155
+ }
156
+ // If tax isnt set we add the invoicefee tax to the total anyway
157
+ else
158
+ $newtax = round($invoicefee-($invoicefee/(str_replace(',','.',$helper->getHandlingVAT($this))/100+1)),2);
159
+ // xxx If they are not shipping to sweden we add another grand total
160
+
161
+ if(isset($sortedTotals["grand_total"]))
162
+ $sortedTotals['grand_total']->setValue($sortedTotals['grand_total']->getValue() + (round($invoicefee-($invoicefee - ($invoicefee/($helper->getHandlingVAT($this)/100+1))),2)) + $newtax - $orgtax);
163
+ }
164
+ }
165
+
166
+ return $sortedTotals;
167
+ }
168
+
169
+ public static function getUpdateValues($t)
170
+ {
171
+
172
+ return array();
173
+ }
174
+ }
app/code/local/Kreditor/Kreditor/Model/Sales/Quote/Address/Total/Invoicefee.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_Model_Sales_Quote_Address_Total_Invoicefee extends Mage_Sales_Model_Quote_Address_Total_Abstract
32
+ {
33
+
34
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
35
+ {
36
+ // xxx Only show this if the payment method is klarna invoice
37
+ if($address->getQuote()->getPayment()->getMethod() == "kreditor_invoice")
38
+ {
39
+ $address->addTotal(array(
40
+ 'code'=>$this->getCode(),
41
+ 'title'=>Mage::helper('sales')->__('Invoice fee'),
42
+ 'value'=>0
43
+ ));
44
+ }
45
+
46
+ return $this;
47
+ }
48
+ }
app/code/local/Kreditor/Kreditor/Model/Sales/Total/Invoicefee.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_Model_Sales_Total_Invoicefee extends Mage_Sales_Model_Quote_Address_Total_Abstract
32
+ {
33
+
34
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
35
+ {
36
+ // xxx Only show this if the payment method is klarna invoice
37
+ if($address->getQuote()->getPayment()->getMethod() == "kreditor_invoice")
38
+ {
39
+ $address->addTotal(array(
40
+ 'code'=>$this->getCode(),
41
+ 'title'=>Mage::helper('sales')->__('Invoice fee'),
42
+ 'value'=>0
43
+ ));
44
+ }
45
+
46
+ return $this;
47
+ }
48
+ }
app/code/local/Kreditor/Kreditor/Model/Source/Invoicecountry.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_Model_Source_Invoicecountry {
32
+
33
+ protected $_options;
34
+
35
+ public function toOptionArray($isMultiSelect = false) {
36
+ if(!$this->_options) {
37
+ $this->_options = Mage::getResourceModel('directory/country_collection')->loadData()->toOptionArray(false);
38
+ }
39
+
40
+ $options = $this->_options;
41
+ if(!$isMultiSelect) {
42
+ array_unshift($options, array('value'=>'', 'label'=> Mage::helper('adminhtml')->__('--Please Select--')));
43
+ }
44
+
45
+ foreach($options as $k => $opt) {
46
+ if(!in_array($opt['value'], array('SE', 'DK', 'NO', 'FI', 'DE', 'NL'))) unset($options[$k]);
47
+ }
48
+
49
+ return $options;
50
+ }
51
+ }
app/code/local/Kreditor/Kreditor/Model/Source/Partpaymentcountry.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_Model_Source_Partpaymentcountry {
32
+
33
+ protected $_options;
34
+
35
+ public function toOptionArray($isMultiSelect = false) {
36
+ if(!$this->_options) {
37
+ $this->_options = Mage::getResourceModel('directory/country_collection')->loadData()->toOptionArray(false);
38
+ }
39
+
40
+ $options = $this->_options;
41
+ if(!$isMultiSelect) {
42
+ array_unshift($options, array('value'=>'', 'label'=> Mage::helper('adminhtml')->__('--Please Select--')));
43
+ }
44
+
45
+ foreach($options as $k => $opt) {
46
+ if(!in_array($opt['value'], array('SE', 'DK', 'NO', 'FI', 'DE', 'NL'))) unset($options[$k]);
47
+ }
48
+
49
+ return $options;
50
+ }
51
+ }
app/code/local/Kreditor/Kreditor/Model/Source/TransactionMode.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_Model_Source_TransactionMode {
32
+ public function toOptionArray() {
33
+ $modes = array();
34
+ foreach (Mage::getConfig()->getNode('global/payment/transaction/modes')->asArray() as $data) {
35
+ $modes[$data['code']] = $data['name'];
36
+ }
37
+
38
+ $options = array(); ;
39
+ foreach ($modes as $code => $name) {
40
+ $options[] = array(
41
+ 'value' => $code,
42
+ 'label' => $name
43
+ );
44
+ }
45
+
46
+ return $options;
47
+ }
48
+ }
app/code/local/Kreditor/Kreditor/controllers/AddressController.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_AddressController extends Mage_Core_Controller_Front_Action {
32
+
33
+ public function getAddressesAction() {
34
+ $api = Mage::getSingleton('kreditor/api_kreditor');
35
+ $api->setMerchantId(Mage::getStoreConfig('payment/' . $this->getRequest()->getParam('type') . '/merchant_id'));
36
+ $api->setSecurityKey(Mage::getStoreConfig('payment/' . $this->getRequest()->getParam('type') . '/security_key'));
37
+
38
+ // xxx We start to call this with pno as 0 just to set the address to the one we already selected
39
+ if($this->getRequest()->getPost('pno') != "0")
40
+ $addresses = $api->getAddressFromKreditor($this->getRequest()->getPost('pno'), Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getCountryId());
41
+ else
42
+ $addresses = null;
43
+
44
+ if(!is_array($addresses)) {
45
+ $addresses = null;
46
+ }
47
+ Mage::register("addresses", $addresses);
48
+ $this->loadLayout()->renderLayout();
49
+ }
50
+
51
+ }
app/code/local/Kreditor/Kreditor/controllers/PclassController.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ class Kreditor_Kreditor_PclassController extends Mage_Adminhtml_Controller_Action {
32
+ public function indexAction() {
33
+ $this->loadLayout();
34
+ $this->_setActiveMenu('system/kreditor');
35
+ $this->renderLayout();
36
+ }
37
+
38
+ public function fetchPclassesAction() {
39
+ try {
40
+ try {
41
+ $model = Mage::getModel('kreditor/api_pclass');
42
+ } catch(Exception $e) {
43
+ Mage::throwException(Mage::helper('kreditor')->__('Unable to initialize import model'));
44
+ }
45
+
46
+ $model->updatePclasses();
47
+
48
+ } catch(Exception $e) {
49
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
50
+ }
51
+ $this->_redirect('*/*/');
52
+ }
53
+ }
54
+ ?>
app/code/local/Kreditor/Kreditor/etc/config.xml ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <modules>
5
+ <Kreditor_Kreditor>
6
+ <version>1.20.3</version>
7
+ </Kreditor_Kreditor>
8
+ </modules>
9
+ <admin>
10
+ <routers>
11
+ <kreditor>
12
+ <use>admin</use>
13
+ <args>
14
+ <module>Kreditor_Kreditor</module>
15
+ <frontName>kreditor</frontName>
16
+ </args>
17
+ </kreditor>
18
+ </routers>
19
+ </admin>
20
+ <adminhtml>
21
+ <translate>
22
+ <modules>
23
+ <Kreditor_Kreditor>
24
+ <files>
25
+ <default>Kreditor_Kreditor.csv</default>
26
+ </files>
27
+ </Kreditor_Kreditor>
28
+ </modules>
29
+ </translate>
30
+ <menu>
31
+ <system>
32
+ <children>
33
+ <kreditor translate="title" module="kreditor">
34
+ <title>Klarna</title>
35
+ <sort_order>9999</sort_order>
36
+ <children>
37
+ <kreditor_pclass translate="title" module="kreditor">
38
+ <title>Pclasses</title>
39
+ <action>kreditor/pclass</action>
40
+ </kreditor_pclass>
41
+ </children>
42
+ </kreditor>
43
+ </children>
44
+ </system>
45
+ </menu>
46
+ <acl>
47
+ <resources>
48
+ <all>
49
+ <title>Allow Everything</title>
50
+ </all>
51
+ <admin>
52
+ <children>
53
+ <Kreditor_Kreditor>
54
+ <title>Kreditor Module</title>
55
+ <sort_order>10</sort_order>
56
+ </Kreditor_Kreditor>
57
+ </children>
58
+ </admin>
59
+ </resources>
60
+ </acl>
61
+ <layout>
62
+ <updates>
63
+ <kreditor>
64
+ <file>kreditor.xml</file>
65
+ </kreditor>
66
+ </updates>
67
+ </layout>
68
+ </adminhtml>
69
+ <frontend>
70
+ <translate>
71
+ <modules>
72
+ <Kreditor_Kreditor>
73
+ <files>
74
+ <default>Kreditor_Kreditor.csv</default>
75
+ </files>
76
+ </Kreditor_Kreditor>
77
+ </modules>
78
+ </translate>
79
+ <layout>
80
+ <updates>
81
+ <kreditor>
82
+ <file>kreditor.xml</file>
83
+ </kreditor>
84
+ </updates>
85
+ </layout>
86
+ </frontend>
87
+ <global>
88
+ <models>
89
+ <kreditor>
90
+ <class>Kreditor_Kreditor_Model</class>
91
+ <resourceModel>kreditor_mysql4</resourceModel>
92
+ </kreditor>
93
+ <kreditor_mysql4>
94
+ <class>Kreditor_Kreditor_Model_Mysql4</class>
95
+ <entities>
96
+ <api_pclass>
97
+ <table>kreditor_api_pclass</table>
98
+ </api_pclass>
99
+ </entities>
100
+ </kreditor_mysql4>
101
+ <sales>
102
+ <rewrite>
103
+ <convert_order>Kreditor_Kreditor_Model_Convert_Order</convert_order>
104
+ <convert_quote>Kreditor_Kreditor_Model_Convert_Quote</convert_quote>
105
+ <order>Kreditor_Kreditor_Model_Sales_Order</order>
106
+ <quote>Kreditor_Kreditor_Model_Sales_Quote</quote>
107
+ </rewrite>
108
+ </sales>
109
+ </models>
110
+ <blocks>
111
+ <catalog>
112
+ <rewrite>
113
+ <product_price>Kreditor_Kreditor_Block_Product_Price</product_price>
114
+ </rewrite>
115
+ </catalog>
116
+ <sales>
117
+ <rewrite>
118
+ <order_items>Kreditor_Kreditor_Block_Sales_Order_Items</order_items>
119
+ <order_invoice_items>Kreditor_Kreditor_Block_Sales_Order_Invoice_Items</order_invoice_items>
120
+ <order_email_items>Kreditor_Kreditor_Block_Sales_Order_Email_Items</order_email_items>
121
+ <order_print_invoice>Kreditor_Kreditor_Block_Sales_Order_Print_Invoice</order_print_invoice>
122
+ <order_print>Kreditor_Kreditor_Block_Sales_Order_Print</order_print>
123
+ <order_email_invoice_items>Kreditor_Kreditor_Block_Sales_Order_Email_Invoice_Items</order_email_invoice_items>
124
+ </rewrite>
125
+ </sales>
126
+ <adminhtml>
127
+ <rewrite>
128
+ <sales_order_invoice_create_items>Kreditor_Kreditor_Block_Adminhtml_Invoice_Create_Items</sales_order_invoice_create_items>
129
+ </rewrite>
130
+ </adminhtml>
131
+ </blocks>
132
+ <sales>
133
+ <quote>
134
+ <totals>
135
+ <kreditor>
136
+ <class>kreditor/sales_quote_address_total_invoicefee</class>
137
+ <before>grand_total</before>
138
+ </kreditor>
139
+ </totals>
140
+ </quote>
141
+ <order_invoice>
142
+ <totals>
143
+ <kreditor>
144
+ <class>kreditor/sales_order_invoice_total_invoicefee</class>
145
+ <before>sub_total</before>
146
+ </kreditor>
147
+ </totals>
148
+ </order_invoice>
149
+ </sales>
150
+ <helpers>
151
+ <kreditor>
152
+ <class>Kreditor_Kreditor_Helper</class>
153
+ </kreditor>
154
+ </helpers>
155
+ <resources>
156
+ <kreditor_setup>
157
+ <setup>
158
+ <module>Kreditor_Kreditor</module>
159
+ <class>Kreditor_Kreditor_Model_Entity_Setup</class>
160
+ </setup>
161
+ <connection>
162
+ <use>core_setup</use>
163
+ </connection>
164
+ </kreditor_setup>
165
+ <kreditor_write>
166
+ <connection>
167
+ <use>core_write</use>
168
+ </connection>
169
+ </kreditor_write>
170
+ <kreditor_read>
171
+ <connection>
172
+ <use>core_read</use>
173
+ </connection>
174
+ </kreditor_read>
175
+ </resources>
176
+ <blocks>
177
+ <kreditor><class>Kreditor_Kreditor_Block</class></kreditor>
178
+ </blocks>
179
+ <payment>
180
+ <transaction>
181
+ <modes>
182
+ <LIVE>
183
+ <code>live</code>
184
+ <name>Live mode</name>
185
+ </LIVE>
186
+ <TEST>
187
+ <code>test</code>
188
+ <name>Test mode</name>
189
+ </TEST>
190
+ </modes>
191
+ </transaction>
192
+ </payment>
193
+ </global>
194
+ <default>
195
+ <payment>
196
+ <kreditor_invoice>
197
+ <model>kreditor/method_invoice</model>
198
+ <title>Klarna Invoice</title>
199
+ <active>1</active>
200
+ <allowspecific>0</allowspecific>
201
+ <order_status>1</order_status>
202
+ <update_address>1</update_address>
203
+ <payment_action>authorize</payment_action>
204
+ </kreditor_invoice>
205
+ <kreditor_partpayment>
206
+ <model>kreditor/method_partpayment</model>
207
+ <title>Klarna Part payment</title>
208
+ <active>1</active>
209
+ <allowspecific>0</allowspecific>
210
+ <order_status>1</order_status>
211
+ <update_address>1</update_address>
212
+ <payment_action>authorize</payment_action>
213
+ </kreditor_partpayment>
214
+ </payment>
215
+ <advanced>
216
+ <klarna>
217
+ <maximum_order_amount_nl>250</maximum_order_amount_nl>
218
+ <maximum_order_amount_de>-1</maximum_order_amount_de>
219
+ <invoice_fee_incvat>0</invoice_fee_incvat>
220
+ <yearly_sal_limit_no>100000</yearly_sal_limit_no>
221
+ </klarna>
222
+ </advanced>
223
+ </default>
224
+ </config>
app/code/local/Kreditor/Kreditor/etc/system.xml ADDED
@@ -0,0 +1,388 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <payment>
5
+ <groups>
6
+ <kreditor_invoice translate="label" module="kreditor">
7
+ <label>Klarna Invoice</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>0</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>1</show_in_store>
13
+ <fields>
14
+ <active translate="label">
15
+ <label>Enabled</label>
16
+ <frontend_type>select</frontend_type>
17
+ <source_model>adminhtml/system_config_source_yesno</source_model>
18
+ <sort_order>1</sort_order>
19
+ <show_in_default>1</show_in_default>
20
+ <show_in_website>1</show_in_website>
21
+ <show_in_store>1</show_in_store>
22
+ </active>
23
+ <order_status translate="label">
24
+ <label>New order status</label>
25
+ <frontend_type>select</frontend_type>
26
+ <source_model>adminhtml/system_config_source_order_status</source_model>
27
+ <sort_order>2</sort_order>
28
+ <show_in_default>1</show_in_default>
29
+ <show_in_website>1</show_in_website>
30
+ <show_in_store>1</show_in_store>
31
+ </order_status>
32
+ <sort_order translate="label">
33
+ <label>Sort order</label>
34
+ <frontend_type>text</frontend_type>
35
+ <sort_order>3</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ <show_in_website>1</show_in_website>
38
+ <show_in_store>1</show_in_store>
39
+ </sort_order>
40
+ <merchant_id translate="label">
41
+ <label>Merchant ID</label>
42
+ <frontend_type>text</frontend_type>
43
+ <sort_order>4</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>1</show_in_store>
47
+ </merchant_id>
48
+ <security_key translate="label">
49
+ <label>Shared secret</label>
50
+ <frontend_type>text</frontend_type>
51
+ <sort_order>5</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>1</show_in_store>
55
+ </security_key>
56
+ <minimum_order_cost_eur translate="label">
57
+ <label>Minimum order amount (EUR)</label>
58
+ <frontend_type>text</frontend_type>
59
+ <sort_order>6</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>1</show_in_store>
63
+ </minimum_order_cost_eur>
64
+ <minimum_order_cost_dkk translate="label">
65
+ <label>Minimum order amount (DKK)</label>
66
+ <frontend_type>text</frontend_type>
67
+ <sort_order>7</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>1</show_in_store>
71
+ </minimum_order_cost_dkk>
72
+ <minimum_order_cost_sek translate="label">
73
+ <label>Minimum order amount (SEK)</label>
74
+ <frontend_type>text</frontend_type>
75
+ <sort_order>8</sort_order>
76
+ <show_in_default>1</show_in_default>
77
+ <show_in_website>1</show_in_website>
78
+ <show_in_store>1</show_in_store>
79
+ </minimum_order_cost_sek>
80
+ <minimum_order_cost_nok translate="label">
81
+ <label>Minimum order amount (NOK)</label>
82
+ <frontend_type>text</frontend_type>
83
+ <sort_order>9</sort_order>
84
+ <show_in_default>1</show_in_default>
85
+ <show_in_website>1</show_in_website>
86
+ <show_in_store>1</show_in_store>
87
+ </minimum_order_cost_nok>
88
+ <invoice_fee_se translate="label">
89
+ <label>Invoice fee (SEK) inc. VAT</label>
90
+ <frontend_type>text</frontend_type>
91
+ <sort_order>10</sort_order>
92
+ <show_in_default>1</show_in_default>
93
+ <show_in_website>1</show_in_website>
94
+ <show_in_store>1</show_in_store>
95
+ </invoice_fee_se>
96
+ <invoice_fee_no translate="label">
97
+ <label>Invoice fee (NOK)</label>
98
+ <frontend_type>text</frontend_type>
99
+ <sort_order>12</sort_order>
100
+ <show_in_default>1</show_in_default>
101
+ <show_in_website>1</show_in_website>
102
+ <show_in_store>1</show_in_store>
103
+ </invoice_fee_no>
104
+ <invoice_fee_no_vat translate="label">
105
+ <label>Invoice fee VAT (NO)</label>
106
+ <frontend_type>text</frontend_type>
107
+ <sort_order>13</sort_order>
108
+ <show_in_default>1</show_in_default>
109
+ <show_in_website>1</show_in_website>
110
+ <show_in_store>1</show_in_store>
111
+ </invoice_fee_no_vat>
112
+ <invoice_fee_dk translate="label">
113
+ <label>Invoice fee (DKK)</label>
114
+ <frontend_type>text</frontend_type>
115
+ <sort_order>14</sort_order>
116
+ <show_in_default>1</show_in_default>
117
+ <show_in_website>1</show_in_website>
118
+ <show_in_store>1</show_in_store>
119
+ </invoice_fee_dk>
120
+ <invoice_fee_dk_vat translate="label">
121
+ <label>Invoice fee VAT (DK)</label>
122
+ <frontend_type>text</frontend_type>
123
+ <sort_order>15</sort_order>
124
+ <show_in_default>1</show_in_default>
125
+ <show_in_website>1</show_in_website>
126
+ <show_in_store>1</show_in_store>
127
+ </invoice_fee_dk_vat>
128
+ <invoice_fee_fi translate="label">
129
+ <label>Invoice fee (EUR/Finland)</label>
130
+ <frontend_type>text</frontend_type>
131
+ <sort_order>16</sort_order>
132
+ <show_in_default>1</show_in_default>
133
+ <show_in_website>1</show_in_website>
134
+ <show_in_store>1</show_in_store>
135
+ </invoice_fee_fi>
136
+ <invoice_fee_fi_vat translate="label">
137
+ <label>Invoice fee VAT (FI)</label>
138
+ <frontend_type>text</frontend_type>
139
+ <sort_order>17</sort_order>
140
+ <show_in_default>1</show_in_default>
141
+ <show_in_website>1</show_in_website>
142
+ <show_in_store>1</show_in_store>
143
+ </invoice_fee_fi_vat>
144
+ <invoice_fee_de translate="label">
145
+ <label>Invoice fee (EUR/Germany)</label>
146
+ <frontend_type>text</frontend_type>
147
+ <sort_order>18</sort_order>
148
+ <show_in_default>1</show_in_default>
149
+ <show_in_website>1</show_in_website>
150
+ <show_in_store>1</show_in_store>
151
+ </invoice_fee_de>
152
+ <invoice_fee_de_vat translate="label">
153
+ <label>Invoice fee VAT (DE)</label>
154
+ <frontend_type>text</frontend_type>
155
+ <sort_order>19</sort_order>
156
+ <show_in_default>1</show_in_default>
157
+ <show_in_website>1</show_in_website>
158
+ <show_in_store>1</show_in_store>
159
+ </invoice_fee_de_vat>
160
+ <invoice_fee_nl translate="label">
161
+ <label>Invoice fee (EUR/Netherlands)</label>
162
+ <frontend_type>text</frontend_type>
163
+ <sort_order>20</sort_order>
164
+ <show_in_default>1</show_in_default>
165
+ <show_in_website>1</show_in_website>
166
+ <show_in_store>1</show_in_store>
167
+ </invoice_fee_nl>
168
+ <invoice_fee_nl_vat translate="label">
169
+ <label>Invoice fee VAT (NL)</label>
170
+ <frontend_type>text</frontend_type>
171
+ <sort_order>21</sort_order>
172
+ <show_in_default>1</show_in_default>
173
+ <show_in_website>1</show_in_website>
174
+ <show_in_store>1</show_in_store>
175
+ </invoice_fee_nl_vat>
176
+ <update_address translate="label">
177
+ <label>Update customer address from Klarna (Sweden only)</label>
178
+ <frontend_type>select</frontend_type>
179
+ <source_model>adminhtml/system_config_source_yesno</source_model>
180
+ <sort_order>22</sort_order>
181
+ <show_in_default>1</show_in_default>
182
+ <show_in_website>1</show_in_website>
183
+ <show_in_store>1</show_in_store>
184
+ </update_address>
185
+ <allowspecific translate="label">
186
+ <label>Payment from applicable countries</label>
187
+ <frontend_type>allowspecific</frontend_type>
188
+ <sort_order>23</sort_order>
189
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
190
+ <show_in_default>1</show_in_default>
191
+ <show_in_website>1</show_in_website>
192
+ <show_in_store>1</show_in_store>
193
+ </allowspecific>
194
+ <specificcountry translate="label">
195
+ <label>Payment from Specific countries</label>
196
+ <frontend_type>multiselect</frontend_type>
197
+ <sort_order>24</sort_order>
198
+ <source_model>kreditor/source_invoicecountry</source_model>
199
+ <show_in_default>1</show_in_default>
200
+ <show_in_website>1</show_in_website>
201
+ <show_in_store>1</show_in_store>
202
+ </specificcountry>
203
+ <transaction_mode translate="label">
204
+ <label>Mode</label>
205
+ <frontend_type>select</frontend_type>
206
+ <source_model>kreditor/source_transactionMode</source_model>
207
+ <sort_order>25</sort_order>
208
+ <show_in_default>1</show_in_default>
209
+ <show_in_website>1</show_in_website>
210
+ <show_in_store>1</show_in_store>
211
+ </transaction_mode>
212
+ </fields>
213
+ </kreditor_invoice>
214
+ <kreditor_partpayment translate="label" module="kreditor">
215
+ <label>Klarna part payment</label>
216
+ <frontend_type>text</frontend_type>
217
+ <sort_order>0</sort_order>
218
+ <show_in_default>1</show_in_default>
219
+ <show_in_website>1</show_in_website>
220
+ <show_in_store>1</show_in_store>
221
+ <fields>
222
+ <active translate="label">
223
+ <label>Enabled</label>
224
+ <frontend_type>select</frontend_type>
225
+ <source_model>adminhtml/system_config_source_yesno</source_model>
226
+ <sort_order>1</sort_order>
227
+ <show_in_default>1</show_in_default>
228
+ <show_in_website>1</show_in_website>
229
+ <show_in_store>1</show_in_store>
230
+ </active>
231
+ <order_status translate="label">
232
+ <label>New order status</label>
233
+ <frontend_type>select</frontend_type>
234
+ <source_model>adminhtml/system_config_source_order_status</source_model>
235
+ <sort_order>2</sort_order>
236
+ <show_in_default>1</show_in_default>
237
+ <show_in_website>1</show_in_website>
238
+ <show_in_store>1</show_in_store>
239
+ </order_status>
240
+ <sort_order translate="label">
241
+ <label>Sort order</label>
242
+ <frontend_type>text</frontend_type>
243
+ <sort_order>3</sort_order>
244
+ <show_in_default>1</show_in_default>
245
+ <show_in_website>1</show_in_website>
246
+ <show_in_store>1</show_in_store>
247
+ </sort_order>
248
+ <merchant_id translate="label">
249
+ <label>Merchant ID</label>
250
+ <frontend_type>text</frontend_type>
251
+ <sort_order>8</sort_order>
252
+ <show_in_default>1</show_in_default>
253
+ <show_in_website>1</show_in_website>
254
+ <show_in_store>1</show_in_store>
255
+ </merchant_id>
256
+ <security_key translate="label">
257
+ <label>Shared secret</label>
258
+ <frontend_type>text</frontend_type>
259
+ <sort_order>9</sort_order>
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
+ </security_key>
264
+ <update_address translate="label">
265
+ <label>Update customer address from Klarna</label>
266
+ <frontend_type>select</frontend_type>
267
+ <source_model>adminhtml/system_config_source_yesno</source_model>
268
+ <sort_order>12</sort_order>
269
+ <show_in_default>1</show_in_default>
270
+ <show_in_website>1</show_in_website>
271
+ <show_in_store>1</show_in_store>
272
+ </update_address>
273
+ <minimum_order_cost_eur translate="label">
274
+ <label>Minimum order amount (EUR)</label>
275
+ <frontend_type>text</frontend_type>
276
+ <sort_order>11</sort_order>
277
+ <show_in_default>1</show_in_default>
278
+ <show_in_website>1</show_in_website>
279
+ <show_in_store>1</show_in_store>
280
+ </minimum_order_cost_eur>
281
+ <minimum_order_cost_dkk translate="label">
282
+ <label>Minimum order amount (DKK)</label>
283
+ <frontend_type>text</frontend_type>
284
+ <sort_order>11</sort_order>
285
+ <show_in_default>1</show_in_default>
286
+ <show_in_website>1</show_in_website>
287
+ <show_in_store>1</show_in_store>
288
+ </minimum_order_cost_dkk>
289
+ <minimum_order_cost_sek translate="label">
290
+ <label>Minimum order amount (SEK)</label>
291
+ <frontend_type>text</frontend_type>
292
+ <sort_order>11</sort_order>
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
+ </minimum_order_cost_sek>
297
+ <minimum_order_cost_nok translate="label">
298
+ <label>Minimum order amount (NOK)</label>
299
+ <frontend_type>text</frontend_type>
300
+ <sort_order>11</sort_order>
301
+ <show_in_default>1</show_in_default>
302
+ <show_in_website>1</show_in_website>
303
+ <show_in_store>1</show_in_store>
304
+ </minimum_order_cost_nok>
305
+ <allowspecific translate="label">
306
+ <label>Payment from applicable countries</label>
307
+ <frontend_type>allowspecific</frontend_type>
308
+ <sort_order>13</sort_order>
309
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
310
+ <show_in_default>1</show_in_default>
311
+ <show_in_website>1</show_in_website>
312
+ <show_in_store>1</show_in_store>
313
+ </allowspecific>
314
+ <specificcountry translate="label">
315
+ <label>Payment from Specific countries</label>
316
+ <frontend_type>multiselect</frontend_type>
317
+ <sort_order>14</sort_order>
318
+ <source_model>kreditor/source_partpaymentcountry</source_model>
319
+ <show_in_default>1</show_in_default>
320
+ <show_in_website>1</show_in_website>
321
+ <show_in_store>1</show_in_store>
322
+ </specificcountry>
323
+ <transaction_mode translate="label">
324
+ <label>Mode</label>
325
+ <frontend_type>select</frontend_type>
326
+ <source_model>kreditor/source_transactionMode</source_model>
327
+ <sort_order>17</sort_order>
328
+ <show_in_default>1</show_in_default>
329
+ <show_in_website>1</show_in_website>
330
+ <show_in_store>1</show_in_store>
331
+ </transaction_mode>
332
+ </fields>
333
+ </kreditor_partpayment>
334
+ </groups>
335
+ </payment>
336
+ <advanced>
337
+ <groups>
338
+ <klarna translate="label">
339
+ <label>Klarna</label>
340
+ <frontend_type>text</frontend_type>
341
+ <sort_order>50</sort_order>
342
+ <show_in_default>1</show_in_default>
343
+ <show_in_website>1</show_in_website>
344
+ <show_in_store>0</show_in_store>
345
+ <fields>
346
+ <maximum_order_amount_nl translate="label">
347
+ <label>Maximum order amount (Netherlands)?</label>
348
+ <comment>Enter a value for which is the maximum order amount that you will
349
+ accept orders from dutch customers with Klarna. NOTE! This value should be entered in Euro.</comment>
350
+ <frontend_type>text</frontend_type>
351
+ <sort_order>0</sort_order>
352
+ <show_in_default>1</show_in_default>
353
+ <show_in_website>0</show_in_website>
354
+ <show_in_store>0</show_in_store>
355
+ </maximum_order_amount_nl>
356
+ <maximum_order_amount_de translate="label">
357
+ <label>Maximum order amount (Germany)?</label>
358
+ <comment>Enter a value for which is the maximum order amount that you will
359
+ accept orders from german customers with Klarna. NOTE! This value should be entered in Euro.</comment>
360
+ <frontend_type>text</frontend_type>
361
+ <sort_order>0</sort_order>
362
+ <show_in_default>1</show_in_default>
363
+ <show_in_website>0</show_in_website>
364
+ <show_in_store>0</show_in_store>
365
+ </maximum_order_amount_de>
366
+ <invoice_fee_incvat translate="label">
367
+ <label>Are shipping fee and invoice fee calculated based on cost without VAT?</label>
368
+ <frontend_type>select</frontend_type>
369
+ <source_model>adminhtml/system_config_source_yesno</source_model>
370
+ <sort_order>0</sort_order>
371
+ <show_in_default>1</show_in_default>
372
+ <show_in_website>1</show_in_website>
373
+ <show_in_store>0</show_in_store>
374
+ </invoice_fee_incvat>
375
+ <yearly_sal_limit_no translate="label">
376
+ <label>Limit for when customer must enter yearly salary (NO)</label>
377
+ <frontend_type>text</frontend_type>
378
+ <sort_order>1</sort_order>
379
+ <show_in_default>1</show_in_default>
380
+ <show_in_website>1</show_in_website>
381
+ <show_in_store>0</show_in_store>
382
+ </yearly_sal_limit_no>
383
+ </fields>
384
+ </klarna>
385
+ </groups>
386
+ </advanced>
387
+ </sections>
388
+ </config>
app/code/local/Kreditor/Kreditor/sql/kreditor_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento Kreditor extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Kreditor
22
+ * @package Kreditor_Kreditor
23
+ * @copyright Copyright (c) 2009 Kreditor Europe AB (http://www.kreditor.se)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ $installer = $this;
28
+
29
+ $installer->startSetup();
30
+
31
+ $installer->getConnection()->addColumn(
32
+ $installer->getTable('sales_flat_quote_payment'),
33
+ 'kreditor_pno',
34
+ 'varchar(255) default \'\'');
35
+
36
+ $installer->getConnection()->addColumn(
37
+ $installer->getTable('sales_flat_quote_payment'),
38
+ 'kreditor_salary',
39
+ 'varchar(255) default \'\'');
40
+
41
+ $installer->getConnection()->addColumn(
42
+ $installer->getTable('sales_flat_quote_payment'),
43
+ 'kreditor_payopt',
44
+ 'varchar(255) default \'\'');
45
+
46
+ $installer->run("
47
+ -- DROP TABLE IF EXISTS `{$this->getTable('kreditor_api_pclass')}`;
48
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('kreditor_api_pclass')}` (
49
+ `id` int(10) unsigned NOT NULL auto_increment,
50
+ `pclass_id` text,
51
+ `description` text,
52
+ `months` int,
53
+ `startfee` int,
54
+ `handlingfee` int,
55
+ `interest` int,
56
+ `minamount` int,
57
+ `maxamount` int default null,
58
+ `currency` varchar(255),
59
+ `disabled` boolean not null default false,
60
+ PRIMARY KEY (`id`)
61
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
62
+
63
+ ");
64
+
65
+ $installer->endSetup();
66
+
67
+
68
+ $installer->addAttribute('quote_payment', 'kreditor_pno', array());
69
+ $installer->addAttribute('quote_payment', 'kreditor_salary', array());
70
+ $installer->addAttribute('quote_payment', 'kreditor_payopt', array());
71
+
72
+ $installer->addAttribute('order_payment', 'kreditor_pno', array());
73
+ $installer->addAttribute('order_payment', 'kreditor_salary', array());
74
+ $installer->addAttribute('order_payment', 'kreditor_payopt', array());
75
+
app/code/local/Kreditor/Kreditor/sql/kreditor_setup/mysql4-upgrade-0.1.0-1.13.15.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento Kreditor extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Kreditor
22
+ * @package Kreditor_Kreditor
23
+ * @copyright Copyright (c) 2009 Kreditor Europe AB (http://www.kreditor.se)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ $installer = $this;
28
+
29
+ $installer->startSetup();
30
+
31
+ $installer->getConnection()->addColumn(
32
+ $installer->getTable('sales_flat_quote_payment'),
33
+ 'kreditor_invoicefee',
34
+ 'varchar(255) default \'\'');
35
+
36
+ $installer->endSetup();
37
+
38
+ $installer->addAttribute('quote_payment', 'kreditor_invoicefee', array());
39
+ $installer->addAttribute('order_payment', 'kreditor_invoicefee', array());
40
+
41
+
app/code/local/Kreditor/Kreditor/sql/kreditor_setup/mysql4-upgrade-1.13.15-1.20.0.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento Kreditor extension
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Kreditor
22
+ * @package Kreditor_Kreditor
23
+ * @copyright Copyright (c) 2009 Kreditor Europe AB (http://www.kreditor.se)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ $installer = $this;
28
+
29
+ $installer->startSetup();
30
+
31
+ $installer->getConnection()->addColumn(
32
+ $installer->getTable('sales_flat_quote_payment'),
33
+ 'kreditor_invoicefee', 'varchar(255) default \'\'',
34
+ 'kreditor_gender', 'varchar(255) default \'\'',
35
+ 'kreditor_street', 'varchar(255) default \'\'',
36
+ 'kreditor_house_number', 'varchar(255) default \'\'',
37
+ 'kreditor_house_extension', 'varchar(255) default \'\'');
38
+
39
+ $installer->run("ALTER TABLE `{$this->getTable('kreditor_api_pclass')}` ADD `storeid` INT");
40
+ $installer->run("ALTER TABLE `{$this->getTable('kreditor_api_pclass')}` ADD `country` INT");
41
+ $installer->run("ALTER TABLE `{$this->getTable('kreditor_api_pclass')}` ADD `type` INT");
42
+
43
+ $installer->endSetup();
44
+
45
+ $installer->addAttribute('quote_payment', 'kreditor_gender', array());
46
+ $installer->addAttribute('order_payment', 'kreditor_gender', array());
47
+
48
+ $installer->addAttribute('quote_payment', 'kreditor_street', array());
49
+ $installer->addAttribute('order_payment', 'kreditor_street', array());
50
+
51
+ $installer->addAttribute('quote_payment', 'kreditor_house_number', array());
52
+ $installer->addAttribute('order_payment', 'kreditor_house_number', array());
53
+
54
+ $installer->addAttribute('quote_payment', 'kreditor_house_extension', array());
55
+ $installer->addAttribute('order_payment', 'kreditor_house_extension', array());
56
+
57
+
app/design/adminhtml/default/default/layout/kreditor.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <kreditor_pclass_index>
4
+ <reference name="content">
5
+ <block type="kreditor/adminhtml_pclass" name="pclass" />
6
+ </reference>
7
+ </kreditor_pclass_index>
8
+ <adminhtml_sales_order_view>
9
+ <block name="sales.order.view.totals.main" as="main">
10
+ <block type="kreditor/adminhtml_sales_order_totals_item" name="kreditor" template="kreditor/sales/order/totals/invoicefee.phtml" />
11
+ </block>
12
+ </adminhtml_sales_order_view>
13
+
14
+ <adminhtml_sales_order_invoice_new>
15
+ <reference name="content">
16
+ <block name="sales.order.view.totals.main" as="main">
17
+ <block type="kreditor/adminhtml_sales_order_totals_item" name="kreditor" template="kreditor/sales/order/totals/invoicefee.phtml" />
18
+ </block>
19
+ </reference>
20
+ </adminhtml_sales_order_invoice_new>
21
+
22
+ <adminhtml_sales_order_invoice_view>
23
+ <reference name="content">
24
+ <block name="sales.order.view.totals.main" as="main">
25
+ <block type="kreditor/adminhtml_sales_order_totals_item" name="kreditor" template="kreditor/sales/order/totals/invoicefee.phtml" />
26
+ </block>
27
+ </reference>
28
+ </adminhtml_sales_order_invoice_view>
29
+ </layout>
app/design/adminhtml/default/default/template/kreditor/form/invoice.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ -->
app/design/adminhtml/default/default/template/kreditor/form/partpayment.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ -->
app/design/adminhtml/default/default/template/kreditor/info/invoice.phtml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ -->
31
+ <?php
32
+ $logoSrc = $this->getLogoSrc();
33
+ if($logoSrc):
34
+ ?>
35
+ <img src="<?php echo $this->getSkinUrl($logoSrc) ?>" alt="logo" /><br />
36
+ <?php
37
+ else:
38
+ ?>
39
+ <p><?php echo $this->getMethod()->getTitle() ?></p>
40
+ <?php endif;
41
+ ?>
42
+ <p><strong><?php echo $this->__('Kreditor invoice number') ?>:</strong> <span class="nowrap"><?php echo $this->htmlEscape($this->getInfo()->getLastTransId()) ?></span></p>
app/design/adminhtml/default/default/template/kreditor/info/partpayment.phtml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ -->
31
+ <?php
32
+ $logoSrc = $this->getLogoSrc();
33
+ $pclassitem = $this->getPayoption();
34
+
35
+ if($logoSrc):
36
+ ?>
37
+ <img src="<?php echo $this->getSkinUrl($logoSrc) ?>" alt="logo" /><br />
38
+ <?php
39
+ else:
40
+ ?>
41
+ <p><?php echo $this->getMethod()->getTitle() ?></p>
42
+ <?php endif;?>
43
+ <p>
44
+ <?php if($pclassitem):?>
45
+ <strong><?php echo $this->__('Chosen part payment')?>:</strong> <span class="nowrap"><?php echo $pclassitem->getStartfee() == 0 ? 'Klarna ' . $this->__('Account') : $pclassitem->getMonths() . ' ' . mb_strtolower($this->__('Months'), 'UTF-8') ?></span>
46
+ <br />
47
+ <strong><?php echo $this->__('Cost per month')?>:</strong> <span class="nowrap"><?php echo $this->helper('checkout')->formatPrice(round($pclassitem->getCostPerMonth() / 100, 2)) ?></span>
48
+ <?php endif;?>
49
+ </p>
app/design/adminhtml/default/default/template/kreditor/pclass.phtml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ -->
31
+ <div class="content-header">
32
+ <table cellspacing="0">
33
+ <tr>
34
+ <td style="width:50%">
35
+ <h3 class="icon-head">
36
+ <?php echo $this->getHeader(); ?>
37
+ </h3>
38
+ </td>
39
+ <td class="form-buttons">
40
+ <form action="<?php echo $this->getUpdateFormAction() ?>" method="post" id="updatepclassform">
41
+ <?php echo $this->getBlockHtml('formkey')?>
42
+ <?php echo $this->getUpdateButtonHtml(); ?>
43
+ </form>
44
+ </td>
45
+ </tr>
46
+ </table>
47
+ </div>
48
+ <?php echo $this->getPclassesMatrixHtml() ?>
app/design/adminhtml/default/default/template/kreditor/pclass/matrix.phtml ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ -->
31
+ <?php
32
+ $_pclassCollection = $this->getPclassCollection();
33
+ ?>
34
+ <form name="pclassform" id="pclassform" method="post" action="<?php echo $this->getPclassFormAction(); ?>">
35
+ <div class="grid">
36
+ <table cellspacing="0">
37
+ <thead>
38
+ <tr class="headings">
39
+ <th class="a-right"><?php echo $this->__('Pclass'); ?></th>
40
+ <th class="a-right"><?php echo $this->__('Description'); ?></th>
41
+ <th class="a-right"><?php echo $this->__('Months'); ?></th>
42
+ <th class="a-right"><?php echo $this->__('Starting fee'); ?></th>
43
+ <th class="a-right"><?php echo $this->__('Handling fee'); ?></th>
44
+ <th class="a-right"><?php echo $this->__('Interest'); ?></th>
45
+ <th class="a-right"><?php echo $this->__('Minimum amount'); ?></th>
46
+ <th class="a-right"><?php echo $this->__('Currency'); ?></th>
47
+ <th class="a-right"><?php echo $this->__('Store view'); ?></th>
48
+ </tr>
49
+ </thead>
50
+ <?php foreach($_pclassCollection as $pitem): ?>
51
+ <tr>
52
+ <td class="a-right"><strong><?php echo $pitem->getPclassId(); ?></strong></td>
53
+ <td class="a-right"><?php echo $pitem->getDescription(); ?></td>
54
+ <td class="a-right"><?php echo $pitem->getMonths(); ?></td>
55
+ <td class="a-right"><?php echo $pitem->getStartfeePretty() . ' ' . $pitem->getCurrency(); ?></td>
56
+ <td class="a-right"><?php echo $pitem->getHandlingfeePretty() . ' ' . $pitem->getCurrency(); ?></td>
57
+ <td class="a-right"><?php echo $pitem->getInterestPretty() . ' %'; ?></td>
58
+ <td class="a-right"><?php echo $pitem->getMinamountPretty() . ' ' . $pitem->getCurrency(); ?></td>
59
+ <td class="a-right"><?php echo $pitem->getCurrency(); ?></td>
60
+ <td class="a-right"><?php echo Mage::app()->getStore($pitem->getStoreid())->getName(); ?></td>
61
+ </tr>
62
+ <?php endforeach; ?>
63
+ </table>
64
+ </div>
65
+ </form>
66
+ <script type="text/javascript">
67
+ pclassForm = new varienForm('pclassform');
68
+ </script>
app/design/adminhtml/default/default/template/kreditor/sales/order/totals/invoicefee.phtml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ -->
31
+ <?php
32
+ if($this->getOrder()->getPayment()->getMethod() == 'kreditor_invoice') {
33
+ ?>
34
+ <tr>
35
+ <td class="label"><?php echo $this->__('Invoice fee'); ?></td>
36
+ <td><?php echo $this->helper('checkout')->formatPrice($this->getOrder()->getPayment()->getKreditorInvoicefee()); ?></td>
37
+ </tr>
38
+ <?php
39
+ }
40
+ ?>
41
+
42
+
app/design/frontend/default/default/layout/kreditor.xml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <kreditor_address_getaddresses>
4
+ <block type="kreditor/address_list" name="root" output="toHtml" template="kreditor/address/list.phtml"/>
5
+ </kreditor_address_getaddresses>
6
+ <default>
7
+ <reference name="head">
8
+ <action method="addJs"><script>klarna.js</script></action>
9
+ </reference>
10
+ </default>
11
+ </layout>
app/design/frontend/default/default/template/kreditor/address/list.phtml ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ $addresses = Mage::registry("addresses");
32
+ Mage::unregister("addresses");
33
+ $shippingaddress = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress();
34
+ $saddress = array(array($shippingaddress['firstname'], $shippingaddress['lastname'], $shippingaddress['street'], $shippingaddress['postcode'], $shippingaddress['city'], $shippingaddress['country_id']));
35
+ $billingaddress = Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress();
36
+ $baddress = array(array($billingaddress['firstname'], $billingaddress['lastname'], $billingaddress['street'], $billingaddress['postcode'], $billingaddress['city'], $billingaddress['country_id']));
37
+ if($addresses) {
38
+
39
+ $saddress = $addresses;
40
+ } else {
41
+ echo $this->__('Please enter a valid SSN');
42
+ return;
43
+ }
44
+
45
+ // Only print the address if there is only one.
46
+ if(count($saddress) == 1) {
47
+ echo ('<input type="hidden" name="payment[' . $_GET['type'] . '_shippingaddress]" value="' . utf8_encode($saddress[0][0]) . '|' . utf8_encode($saddress[0][1]) . '|' . utf8_encode($saddress[0][2]) . '|' . utf8_encode($saddress[0][3]) . '|' . utf8_encode($saddress[0][4]) . '|' . utf8_encode($saddress[0][5]) . '">');
48
+ echo '<strong>' . Mage::helper('kreditor')->__("Shipping address") . ': </strong>' . utf8_encode($saddress[0][0]) . " " . utf8_encode($saddress[0][1]) . ", " . utf8_encode($saddress[0][2]) . ", " . utf8_encode($saddress[0][3]) . " " . utf8_encode($saddress[0][4]);
49
+ return;
50
+
51
+ }
52
+ ?>
53
+ <style>
54
+ .address-table {
55
+ border: none;
56
+ }
57
+ .address-table td {
58
+ padding: 3px;
59
+ }
60
+
61
+ </style>
62
+ <table class="address-table">
63
+ <tr>
64
+ <td><label for="select-shipping"><?php echo Mage::helper('kreditor')->__("Shipping address") ?>:</label>&nbsp;</td>
65
+ <td>
66
+ <select id="select-shipping" name="payment[<?php echo $_GET['type'] ?>_shippingaddress]">
67
+ <?php foreach ($saddress as $address): ?>
68
+ <option value="<?php echo utf8_encode($address[0]) . '|' . utf8_encode($address[1]) . '|' . utf8_encode($address[2]) . '|' . utf8_encode($address[3]) . '|' . utf8_encode($address[4]) . '|' . utf8_encode($address[5]); ?>">
69
+ <?php echo utf8_encode($address[0]) . " " . utf8_encode($address[1]) . ", " . utf8_encode($address[2]) . ", " . utf8_encode($address[3]) . " " . utf8_encode($address[4]); ?>
70
+ </option>
71
+ <?php endforeach; ?>
72
+ </select>
73
+ </td>
74
+
75
+ </tr>
76
+ </table>
77
+
app/design/frontend/default/default/template/kreditor/form/invoice.phtml ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ ?>
31
+ <?php
32
+ $logoSrc = $this->getLogoSrc();
33
+ $_code=$this->getMethodCode();
34
+ $termsUrl = $this->getTermsUrl();
35
+ $invoiceFee = $this->getInvoiceFee();
36
+ $testmode = $this->isTestMode();
37
+ if($this->isGerman() || $this->isDutch()) {
38
+ $street = $this->getMethod()->getShippingAddress()->getStreet();
39
+ $helper = Mage::helper('kreditor');
40
+ $parts = $helper->getStreetParts($street[0]);
41
+ }
42
+
43
+
44
+
45
+ ?>
46
+ <fieldset class="form-list">
47
+
48
+ <script type="text/javascript">
49
+ klarna.setUrl('<?php echo $this->getUrl('kreditor/address/getAddresses') ?>');
50
+ </script>
51
+
52
+ <?php if($logoSrc): ?>
53
+ <div style="padding:10px 15px 5px; position:relative">
54
+ <label for="p_method_<?php echo $_code?>">
55
+ <img id="kred_logo<?php echo $_code;?>" src="<?php echo $this->getSkinUrl($logoSrc) ?>" alt="logo" style="cursor: pointer"/><br />
56
+ </label>
57
+ <div id="logo-tool-tip<?php echo $_code?>" style="bottom:1px; right:1px; width: 450px; padding:0px; overflow:hidden; z-index: 99999; display: none;">
58
+ <div class="block-content" style="padding:0px;">
59
+ <iframe src="<?php echo $termsUrl;?>" style="border: none; width:100%; height:410px;;">
60
+ </iframe>
61
+ </div>
62
+ </div>
63
+ </div>
64
+ <?php endif; ?>
65
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
66
+ <?php
67
+
68
+ echo('<a href="#" id="kred_link' . $_code . '" onclick="Effect.toggle(\'logo-tool-tip' . $_code . '\', \'appear\', {duration:0.5});return false;">' . $this->__('Terms') . '</a>');
69
+ ?>
70
+ <?php if($testmode) { ?>
71
+ <div style="border: solid 3px red; background-color: white; padding: 5px; margin: 5px; clear: both;">
72
+ <h2 style="color: red;">
73
+ <strong><?php echo $this->__("Test mode"); ?></strong> <?php echo ('<a href="#" onclick="$(\'klarna_read_more_pp\').toggle();">' . $this->__('Read more / Read less') . '</a>'); ?>
74
+ </h2>
75
+ <p>
76
+ <?php echo($this->__('Please observe. Module is in test mode and no real invoices will be created!')); ?>
77
+ </p>
78
+ <div id="klarna_read_more_pp" style="display:none;">
79
+ <p>
80
+ <?php echo($this->__('The module is currently set to work in test mode. This means that all purchases that
81
+ are made through this payment option will be handled as test purchases and will not generate real
82
+ invoices at Klarna. You need to disable this in the payment options before going live. Remember that
83
+ you also need to remove test mode in Klarna Online before you can start generating real invoices
84
+ through Klarna.<br /><br />Please refer to <a href="http://integration.klarna.com" target="_blank">our integration guide</a>
85
+ for more information.')); ?>
86
+ </p>
87
+ </div>
88
+ </div>
89
+ <?php } ?>
90
+ <li>
91
+ <h4><?php echo $this->__('Enter your payment information'); ?></h4>
92
+ <div class="input-box">
93
+ <?php if($this->showGenderOption()): ?>
94
+
95
+ <label for=""><?php echo $this->__('Gender'); ?></label>
96
+ <div class="input-box">
97
+ <input type="radio" name="payment[kreditor_invoice_gender]" value="male" id="id_kreditor_gender_male" class="radio" />
98
+ <label style="float: none;" for="id_kreditor_gender_male"><?php echo $this->__('Male'); ?></label>
99
+ &nbsp;&nbsp;
100
+ <input type="radio" name="payment[kreditor_invoice_gender]" value="female" id="id_kreditor_gender_female" class="radio validate-one-required-by-name" />
101
+ <label style="float: none;" for="id_kreditor_gender_female"><?php echo $this->__('Female'); ?></label>
102
+ </div>
103
+
104
+ <?php endif ?>
105
+ <label for="kreditor_pno"><?php echo $this->__('SSN/Orgnr') ?> <span class="required">*</span></label><br />
106
+ <input type="text" id="invoice_kreditor_pno" name="payment[kreditor_invoice_pno]" onblur="klarna.getAddressesInvoice($F('invoice_kreditor_pno')); return false;" title="<?php echo $this->__("SSN/Orgnr") ?>" class="required-entry input-text" value="<?php echo $this->htmlEscape($this->getInfoData('kreditor_pno')) ?>"/>
107
+ <?php echo $this->__('Birthdate hint'); ?><br />
108
+ <label for="kreditor_cellno"><?php echo $this->__('cellno') ?> <span class="required">*</span></label><br />
109
+ <input type="text" id="invoice_kreditor_cellno" name="payment[kreditor_invoice_cellno]" title="<?php echo $this->__("cellno") ?>" value="<?php echo $this->getPhoneNumber(); ?>" class="required-entry input-text" value=""/>
110
+ <br />
111
+ <?php if(!empty($invoiceFee) && $invoiceFee != 0): ?>
112
+ <?php $tax = $this->getMethod()->getVAT(); ?>
113
+ <?php echo '<strong>' . $this->__('Invoice fee') . ':</strong> ' . $this->helper('checkout')->formatPrice(Mage::getStoreConfig('advanced/klarna/invoice_fee_incvat') == 0 || $this->getMethod()->getShippingCountry() != 'SE' ? $invoiceFee : Mage::helper('kreditor')->round_up($invoiceFee*($tax/100+1),2))?>
114
+ <?php endif;?>
115
+ </div>
116
+ </li>
117
+ <?php if($this->isGerman() || $this->isDutch()): ?>
118
+ <li>
119
+ <label class="required" for="klarna_street"><?php echo $this->__('Street') . " / " . $this->__('House number') . ($this->isDutch() ? " / " . $this->__('House extension') : ''); ?></label>
120
+ <div class="input-box" style="width: 100%">
121
+ <input type="text" name="payment[kreditor_invoice_street]" value="<?php echo $parts['street'] ?>" id="klarna_street" class="input-text required-entry" />
122
+ <input type="text" name="payment[kreditor_invoice_house_number]" value="<?php echo $parts['house_number'] ?>" id="klarna_house_number" class="input-text" style="width: 50px;" />
123
+ <?php if($this->isDutch()): ?>
124
+ <input type="text" name="payment[kreditor_invoice_house_extension]" value="<?php echo $parts['house_extension'] ?>" id="klarna_house_extension" class="input-text" style="width: 35px;" />
125
+ <?php endif; ?>
126
+ </div>
127
+ </li>
128
+ <?php endif; ?>
129
+
130
+ <?php if($this->addressUpdate()):?>
131
+ <div class="tool-tip" style="position: relative; padding: 5px 10px" class="tool-tip">
132
+
133
+ <div id="loadingmask-invoice" style="display: none;">
134
+ <div class="loader" style="text-align: center;" id="loading-mask-loader">
135
+ <img src="<?php echo str_replace("index.php/","",$this->getUrl()) ?>skin/adminhtml/default/default/images/ajax-loader-tr.gif" alt="<?php echo Mage::helper("kreditor")->__('Retreiving your addresses...') ?>"/>&nbsp;<?php echo Mage::helper("kreditor")->__('Retreiving your addresses...') ?>
136
+ </div>
137
+ </div>
138
+ <?php if($this->addressUpdate()):?>
139
+ <div id="output-div-invoice" style="font-size: 11pt;">
140
+ </div>
141
+ <?php endif;?>
142
+ </div>
143
+ <?php endif; ?>
144
+ <?php if($this->showSalaryBox()): ?>
145
+ <li>
146
+ <div class="input-box">
147
+ <label for="year_salary"><?php echo $this->__('Annual income') ?> <span class="required">*</span></label><br />
148
+ <input type="text" id="year_salary" name="payment[kreditor_invoice_year_salary]" title="<?php echo $this->__("Annual income") ?>" class="required-entry input-text validate-digits" value="<?php echo $this->htmlEscape($this->getInfoData('year_salary')) ?>"/>
149
+ </div>
150
+ </li>
151
+ <?php endif; ?>
152
+ <div style="color: red; background-color: white; font-size: 11pt; font-weight: bold; border: 1px solid black; margin: 3px;">
153
+ <p style="position: relative; padding: 5px 10px; ">
154
+ <?php echo $this->__('Please note that the invoice from Klarna will be sent to your shipping address and your billing address will be set to the same as your shipping address.')?>
155
+ </p>
156
+ </div>
157
+ </ul>
158
+ </fieldset>
app/design/frontend/default/default/template/kreditor/form/partpayment.phtml ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ ?>
31
+ <?php
32
+ $logoSrc = $this->getLogoSrc();
33
+ $_code=$this->getMethodCode();
34
+ $termsUrl = $this->getTermsUrl();
35
+ $options = $this->getPartpayOptions();
36
+ $currency = $this->getCurrency();
37
+ $testmode = $this->isTestMode();
38
+ $totals = $this->getMethod()->getCheckout()->getQuote()->getTotals();
39
+ $api = Mage::getSingleton('kreditor/api_kreditor');
40
+
41
+ if($this->isGerman() || $this->isDutch()) {
42
+ $street = $this->getMethod()->getShippingAddress()->getStreet();
43
+ $helper = Mage::helper('kreditor');
44
+ $parts = $helper->getStreetParts($street[0]);
45
+ }
46
+ ?>
47
+
48
+ <fieldset class="form-list">
49
+ <script type="text/javascript">
50
+ klarna.setUrl('<?php echo $this->getUrl('kreditor/address/getAddresses') ?>');
51
+ </script>
52
+ <?php if($logoSrc): ?>
53
+ <div style="padding:10px 15px 5px; position:relative">
54
+ <label for="p_method_<?php echo $_code?>">
55
+ <img id="kred_logo<?php echo $_code;?>" src="<?php echo $this->getSkinUrl($logoSrc) ?>" alt="logo" style="cursor: pointer"/><br />
56
+ </label>
57
+ <div id="logo-tool-tip<?php echo $_code?>" style="bottom:1px; right:1px; width: 450px; padding:0px; overflow:hidden; z-index: 99999; display: none;">
58
+ <div class="block-content" style="padding:0px;">
59
+ <iframe src="<?php echo $termsUrl;?>" style="border: none; width:100%; height:410px;">
60
+ </iframe>
61
+ </div>
62
+ </div>
63
+ </div>
64
+ <?php endif; ?>
65
+ <?php if($testmode) { ?>
66
+ <div style="border: solid 3px red; background-color: white; padding: 5px; margin: 5px; clear: both;">
67
+ <h2 style="color: red;">
68
+ <strong><?php echo $this->__("Test mode"); ?></strong> <?php echo ('<a href="#" onclick="$(\'klarna_read_more_pp\').toggle();">' . $this->__('Read more / Read less') . '</a>'); ?>
69
+ </h2>
70
+ <p>
71
+ <?php echo($this->__('Please observe. Module is in test mode and no real invoices will be created!')); ?>
72
+ </p>
73
+ <div id="klarna_read_more_pp" style="display:none;">
74
+ <p>
75
+ <?php echo($this->__('The module is currently set to work in test mode. This means that all purchases that
76
+ are made through this payment option will be handled as test purchases and will not generate real
77
+ invoices at Klarna. You need to disable this in the payment options before going live. Remember that
78
+ you also need to remove test mode in Klarna Online before you can start generating real invoices
79
+ through Klarna.<br /><br />Please refer to <a href="http://integration.klarna.com" target="_blank">our integration guide</a>
80
+ for more information.')); ?>
81
+ </p>
82
+ </div>
83
+ </div>
84
+ <?php } ?>
85
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
86
+ <?php
87
+ if(!$this->isDutch())
88
+ echo('<a href="#" id="kred_link' . $_code . '" onclick="Effect.toggle(\'logo-tool-tip' . $_code . '\', \'appear\', {duration:0.5});return false;">' . $this->__('Terms') . '</a>');
89
+ ?>
90
+ <li>
91
+ <h4><?php echo $this->__('Select a payment period below'); ?></h4>
92
+ <div class="input-box">
93
+ <table>
94
+ <?php
95
+ $cArr = count($options); $nArr = 0;
96
+
97
+ foreach($options as $option):
98
+ $nArr++;
99
+ $otherOpts = $nArr == 1 ? 'checked="checked"' : '';
100
+ $optid = $option->getPclassId();
101
+ ?>
102
+ <tr>
103
+ <td style="width: 20px"><?php echo "<input type=\"radio\" name=\"payment[kreditor_payopt]\" value=\"$optid\" id=\"payopt_$optid\" $otherOpts /> ";?></td>
104
+ <td style="padding-bottom: 5px">
105
+ <?php
106
+ echo "<label for=\"payopt_$optid\">";
107
+ echo $option->getDescription();
108
+ echo "</label>";
109
+ if($option->getType() < 2) {
110
+ echo "(" . $this->__('Approx.') . " {$this->helper('checkout')->formatPrice(round($option->getCostPerMonth() / 100, 2))} / " . $this->__('month') . ")<br />";
111
+ echo $this->__('Starting fee') . ": {$this->helper('checkout')->formatPrice(round($option->getStartfeePretty(), 2))} | {$this->__('Handling fee')}: {$this->helper('checkout')->formatPrice(round($option->getHandlingfeePretty(), 2))} | {$this->__('Interest')}: {$option->getInterestPretty()}% <br />";
112
+
113
+ if($option->getCountry() == 164 && $option->getType() < 2) {
114
+ $result = null;
115
+ $result = $api->total_credit_purchase_cost($totals['grand_total']->getValue()*100, $option->getInterest()/100, $option->getHandlingfee(), $option->getMinamount(), $option->getMonths(), $option->getStartfee(), $option->getType() == 1);
116
+ echo($this->__('Total credit purchase cost') . ': ' . $this->helper('checkout')->formatPrice(ceil($result/100)));
117
+ }
118
+ }
119
+ ?>
120
+ </td>
121
+ </tr>
122
+ <?php endforeach;?>
123
+ </table>
124
+ </div>
125
+ </li>
126
+ <li>
127
+ <h4><?php echo $this->__('Enter your payment information'); ?></h4>
128
+ <div class="input-box">
129
+ <?php if($this->showGenderOption()): ?>
130
+
131
+ <label for=""><?php echo $this->__('Gender'); ?></label>
132
+ <div class="input-box">
133
+ <input type="radio" name="payment[kreditor_partpayment_gender]" value="male" id="id_kreditor_gender_male" class="radio" />
134
+ <label style="float: none;" for="id_kreditor_gender_male"><?php echo $this->__('Male'); ?></label>
135
+ &nbsp;&nbsp;
136
+ <input type="radio" name="payment[kreditor_partpayment_gender]" value="female" id="id_kreditor_gender_female" class="radio validate-one-required-by-name" />
137
+ <label style="float: none;" for="id_kreditor_gender_female"><?php echo $this->__('Female'); ?></label>
138
+ </div>
139
+
140
+ <?php endif ?>
141
+
142
+ <label for="kreditor_pno"><?php echo $this->__('SSN/Orgnr') ?> <span class="required">*</span></label><br />
143
+ <input type="text" id="partpayment_kreditor_pno" name="payment[kreditor_partpayment_pno]" onblur="klarna.getAddressesPartpayment($F('partpayment_kreditor_pno')); return false;" title="<?php echo $this->__("SSN/Orgnr") ?>" class="required-entry input-text" />
144
+ <?php echo $this->__('Birthdate hint'); ?><br />
145
+
146
+
147
+ <label for="kreditor_cellno"><?php echo $this->__('cellno') ?> <span class="required">*</span></label><br />
148
+ <input type="text" id="kreditor_cellno" name="payment[kreditor_partpayment_cellno]" title="<?php echo $this->__("cellno") ?>" class="required-entry input-text" value="<?php echo $this->htmlEscape($this->getInfoData('kreditor_cellno')) ?>"/>
149
+ <br />
150
+ </div>
151
+ </li>
152
+ <?php if($this->isGerman() || $this->isDutch()): ?>
153
+ <li>
154
+ <label class="required" for="klarna_street"><?php echo $this->__('Street') . " / " . $this->__('House number') . ($this->isDutch() ? " / " . $this->__('House extension') : ''); ?></label>
155
+ <div class="input-box" style="width: 100%">
156
+ <input type="text" name="payment[kreditor_partpayment_street]" value="<?php echo $parts['street']; ?>" id="klarna_street" class="input-text required-entry" />
157
+ <input type="text" name="payment[kreditor_partpayment_house_number]" value="<?php echo $parts['house_number']; ?>" id="klarna_house_number" class="input-text" style="width: 50px;" />
158
+ <?php if($this->isDutch()): ?>
159
+ <input type="text" name="payment[kreditor_partpayment_house_extension]" value="<?php echo $parts['house_extension']; ?>" id="klarna_house_extension" class="input-text" style="width: 35px;" />
160
+ <?php endif; ?>
161
+ </div>
162
+ </li>
163
+ <?php endif; ?>
164
+
165
+ <?php if($this->addressUpdate()):?>
166
+ <div class="tool-tip" style="position: relative; padding: 5px 10px" class="tool-tip">
167
+
168
+ <div id="loadingmask-partpayment" style="display: none;">
169
+ <div class="loader" style="text-align: center;" id="loading-mask-loader">
170
+ <img src="<?php echo str_replace("index.php/","",$this->getUrl()) ?>skin/adminhtml/default/default/images/ajax-loader-tr.gif" alt="<?php echo Mage::helper("kreditor")->__('Retreiving your addresses...') ?>"/>&nbsp;<?php echo Mage::helper("kreditor")->__('Retreiving your addresses...') ?>
171
+ </div> </div>
172
+ <?php if($this->addressUpdate()):?>
173
+ <div id="output-div-partpayment" style="font-size: 11pt;">
174
+ <strong><?php echo $this->__('Shipping address'); ?></strong><input type="hidden" class="required-entry" />
175
+ </div>
176
+ <?php endif;?>
177
+ </div>
178
+ <?php endif; ?>
179
+ <?php if($this->showSalaryBox()): ?>
180
+ <li>
181
+ <div class="input-box">
182
+ <label for="year_salary"><?php echo $this->__('Annual income') ?> <span class="required">*</span></label><br />
183
+ <input type="text" id="year_salary" name="payment[kreditor_partpayment_year_salary]" title="<?php echo $this->__("Annual income") ?>" class="required-entry input-text validate-digits" value="<?php echo $this->htmlEscape($this->getInfoData('year_salary')) ?>"/>
184
+ </div>
185
+ </li>
186
+ <?php endif; ?>
187
+
188
+ <div style="color: red; background-color: white; font-size: 11pt; font-weight: bold; border: 1px solid black; margin: 3px;">
189
+ <p style="position: relative; padding: 5px 10px; ">
190
+ <?php echo $this->__('Please note that the invoice from Klarna will be sent to your shipping address and your billing address will be set to the same as your shipping address.')?>
191
+ </p>
192
+ </div>
193
+
194
+ <?php if($termsUrl && $this->isDutch()):?>
195
+ <li>
196
+ <div class="input-box">
197
+ <input type="checkbox" id="pp_accept_terms" name="payment[pp_terms]" title="<?php echo $this->__('Terms'); ?>" class="required-entry" />
198
+ <label><?php echo $this->__('I accept the ')?> <a target="_blank" href="<?php echo $termsUrl?>"><?php echo $this->__('terms')?></a><span class="required">*</span></label><br />
199
+ </div>
200
+ </li>
201
+ <?php endif;?>
202
+ </ul>
203
+ </fieldset>
app/design/frontend/default/default/template/kreditor/info/invoice.phtml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ -->
31
+ <?php
32
+ $logoSrc = $this->getLogoSrc();
33
+ if($logoSrc):
34
+ ?>
35
+ <img src="<?php echo $this->getSkinUrl($logoSrc) ?>" alt="logo" /><br />
36
+ <?php
37
+ else:
38
+ ?>
39
+ <p><?php echo $this->getMethod()->getTitle() ?></p>
40
+ <?php endif;
41
+ ?>
42
+ <?php if($this->getInfo()->getLastTransId()) { ?>
43
+ <p><strong><?php echo $this->__('Kreditor invoice number') ?>:</strong> <span class="nowrap"><?php echo $this->htmlEscape($this->getInfo()->getLastTransId()) ?></span></p>
44
+ <?php } ?>
app/design/frontend/default/default/template/kreditor/info/partpayment.phtml ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ -->
31
+ <?php
32
+ $logoSrc = $this->getLogoSrc();
33
+ $pclassitem = $this->getPayoption();
34
+
35
+ if($logoSrc):
36
+ ?>
37
+ <img src="<?php echo $this->getSkinUrl($logoSrc) ?>" alt="logo" /><br />
38
+ <?php
39
+ else:
40
+ ?>
41
+ <p><?php echo $this->getMethod()->getTitle() ?></p>
42
+ <?php endif;?>
43
+ <p>
44
+ <?php if($pclassitem) {
45
+ if($pclassitem->getMonths() > 0) {
46
+ ?>
47
+
48
+
49
+ <strong><?php echo $this->__('Chosen part payment')?>:</strong> <span class="nowrap"><?php echo $pclassitem->getStartfee() == 0 ? 'Klarna ' . $this->__('Account') : $pclassitem->getMonths() . ' ' . mb_strtolower($this->__('Months'), 'UTF-8') ?></span>
50
+ <br />
51
+ <strong><?php echo $this->__('Cost per month')?>:</strong> <span class="nowrap"><?php echo $this->helper('checkout')->formatPrice(round($pclassitem->getCostPerMonth() / 100, 2)) ?></span>
52
+ <?php }
53
+
54
+ else {
55
+ echo($pclassitem->getDescription());
56
+ }
57
+
58
+ }?>
59
+ </p>
60
+ <?php if($this->getInfo()->getLastTransId()) { ?>
61
+ <p><strong><?php echo $this->__('Kreditor invoice number') ?>:</strong> <span class="nowrap"><?php echo $this->htmlEscape($this->getInfo()->getLastTransId()) ?></span></p>
62
+ <?php } ?>
app/design/frontend/default/default/template/kreditor/order/email_invoice_items.phtml ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ -->
31
+ <?php $_invoice = $this->getInvoice() ?>
32
+ <?php $_order = $this->getOrder() ?>
33
+ <?php if ($_invoice && $_order): ?>
34
+ <table cellspacing="0" cellpadding="0" border="0" width="100%" style="border:1px solid #bebcb7; background:#f8f7f5;">
35
+ <thead>
36
+ <tr>
37
+ <th align="left" bgcolor="#d9e5ee" style="padding:3px 9px"><?php echo $this->__('Item') ?></th>
38
+ <th align="left" bgcolor="#d9e5ee" style="padding:3px 9px"><?php echo $this->__('Sku') ?></th>
39
+ <th align="center" bgcolor="#d9e5ee" style="padding:3px 9px"><?php echo $this->__('Qty') ?></th>
40
+ <th align="right" bgcolor="#d9e5ee" style="padding:3px 9px"><?php echo $this->__('Subtotal') ?></th>
41
+ </tr>
42
+ </thead>
43
+
44
+ <?php $i=0; foreach ($_invoice->getAllItems() as $_item): ?>
45
+ <?php if($_item->getOrderItem()->getParentItem()) continue; else $i++; ?>
46
+ <tbody<?php echo $i%2 ? ' bgcolor="#eeeded"' : '' ?>>
47
+ <?php echo $this->getItemHtml($_item) ?>
48
+ </tbody>
49
+ <?php endforeach; ?>
50
+
51
+ <tfoot>
52
+ <?php if ($_order->getPayment()->getMethod() == "kreditor_invoice"): ?>
53
+ <tr>
54
+ <td colspan="3" align="right" style="padding:3px 9px"><?php echo $this->__('Invoice fee'); ?></td>
55
+ <td align="right" style="padding:3px 9px"><?php echo $_order->formatPrice($_order->getPayment()->getKreditorInvoicefee()); ?></td>
56
+ </tr>
57
+ <?php endif; ?>
58
+ <tr>
59
+ <td colspan="3" align="right" style="padding:3px 9px"><?php echo $this->__('Subtotal') ?></td>
60
+ <td align="right" style="padding:3px 9px"><?php echo $_order->formatPrice($_invoice->getSubtotal()) ?></td>
61
+ </tr>
62
+ <?php if ($_invoice->getDiscountAmount() > 0): ?>
63
+ <tr>
64
+ <td colspan="3" align="right" style="padding:3px 9px"><?php echo $this->__('Discount%s', $_order->getCouponCode() ? ' ('.$_order->getCouponCode().')' : '') ?></td>
65
+ <td align="right" style="padding:3px 9px"><?php echo $_order->formatPrice(0.00 - $_invoice->getDiscountAmount()) ?></td>
66
+ </tr>
67
+ <?php endif; ?>
68
+ <?php if ($_invoice->getShippingAmount()): ?>
69
+ <tr>
70
+ <td colspan="3" align="right" style="padding:3px 9px"><?php echo $this->__('Shipping & Handling') ?></td>
71
+ <td align="right" style="padding:3px 9px"><?php echo $_order->formatPrice($_invoice->getShippingAmount()) ?></td>
72
+ </tr>
73
+ <?php endif; ?>
74
+ <?php if (($_invoice->getTaxAmount() > 0)||(Mage::helper('tax')->displayZeroTax())): ?>
75
+ <tr>
76
+ <td colspan="3" align="right" style="padding:3px 9px"><?php echo $this->__('Tax') ?></td>
77
+ <td align="right" style="padding:3px 9px"><?php echo $_order->formatPrice($_invoice->getTaxAmount()) ?></td>
78
+ </tr>
79
+ <?php endif; ?>
80
+ <tr bgcolor="#DEE5E8">
81
+ <td colspan="3" align="right" style="padding:3px 9px"><strong><big><?php echo $this->__('Grand Total') ?></big></strong></td>
82
+ <td align="right" style="padding:6px 9px"><strong><big><?php echo $_order->formatPrice($_invoice->getGrandTotal()) ?></big></strong></td>
83
+ </tr>
84
+ </tfoot>
85
+ </table>
86
+ <?php endif; ?>
app/design/frontend/default/default/template/kreditor/order/email_items.phtml ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ -->
31
+ <?php $_order = $this->getOrder() ?>
32
+ <table cellspacing="0" cellpadding="0" border="0" width="100%" style="border:1px solid #bebcb7; background:#f8f7f5;">
33
+ <thead>
34
+ <tr>
35
+ <th align="left" bgcolor="#d9e5ee" style="padding:3px 9px"><?php echo $this->__('Item') ?></th>
36
+ <th align="left" bgcolor="#d9e5ee" style="padding:3px 9px"><?php echo $this->__('Sku') ?></th>
37
+ <th align="center" bgcolor="#d9e5ee" style="padding:3px 9px"><?php echo $this->__('Qty') ?></th>
38
+ <th align="right" bgcolor="#d9e5ee" style="padding:3px 9px"><?php echo $this->__('Subtotal') ?></th>
39
+ </tr>
40
+ </thead>
41
+
42
+ <?php $i=0; foreach ($_order->getAllItems() as $_item): ?>
43
+ <?php if($_item->getParentItem()) continue; else $i++; ?>
44
+ <tbody<?php echo $i%2 ? ' bgcolor="#eeeded"' : '' ?>>
45
+ <?php echo $this->getItemHtml($_item) ?>
46
+ </tbody>
47
+ <?php endforeach; ?>
48
+
49
+ <tfoot>
50
+ <?php if ($_order->getPayment()->getMethod() == "kreditor_invoice"): ?>
51
+ <tr>
52
+ <td colspan="3" align="right" style="padding:3px 9px"><?php echo $this->__('Invoice fee'); ?></td>
53
+ <td align="right" style="padding:3px 9px"><?php echo $_order->formatPrice($_order->getPayment()->getKreditorInvoicefee()); ?></td>
54
+ </tr>
55
+ <?php endif; ?>
56
+ <?php if($_order->getGiftMessageId() && $_giftMessage = $this->helper('giftmessage/message')->getGiftMessage($_order->getGiftMessageId())): ?>
57
+ <tr>
58
+ <td colspan="4" align="left" style="padding:3px 9px">
59
+ <strong><?php echo $this->__('Gift Message for this Order') ?></strong>
60
+ <br /><?php echo $this->__('From:'); ?> <?php echo $this->htmlEscape($_giftMessage->getSender()) ?>
61
+ <br /><?php echo $this->__('To:'); ?> <?php echo $this->htmlEscape($_giftMessage->getRecipient()) ?>
62
+ <br /><?php echo $this->__('Message:'); ?><br /> <?php echo $this->htmlEscape($_giftMessage->getMessage()) ?>
63
+ </td>
64
+ </tr>
65
+ <?php endif; ?>
66
+ <tr>
67
+ <td colspan="3" align="right" style="padding:3px 9px"><?php echo $this->__('Subtotal') ?></td>
68
+ <td align="right" style="padding:3px 9px"><?php echo $_order->formatPrice($_order->getSubtotal()) ?></td>
69
+ </tr>
70
+ <?php if ($_order->getDiscountAmount() > 0): ?>
71
+ <tr>
72
+ <td colspan="3" align="right" style="padding:3px 9px"><?php echo $this->__('Discount '.($_order->getCouponCode()?'('.$_order->getCouponCode().')':'')) ?></td>
73
+ <td align="right" style="padding:3px 9px"><?php echo $_order->formatPrice(0.00 - $_order->getDiscountAmount()) ?></td>
74
+ </tr>
75
+ <?php endif; ?>
76
+ <?php if ($_order->getShippingAmount() || $_order->getShippingDescription()): ?>
77
+ <tr>
78
+ <td colspan="3" align="right" style="padding:3px 9px"><?php echo $this->__('Shipping & Handling') ?></td>
79
+ <td align="right" style="padding:3px 9px"><?php echo $_order->formatPrice($_order->getShippingAmount()) ?></td>
80
+ </tr>
81
+ <?php endif; ?>
82
+ <?php if (($_order->getTaxAmount() > 0)||(Mage::helper('tax')->displayZeroTax())): ?>
83
+ <tr>
84
+ <td colspan="3" align="right" style="padding:3px 9px"><?php echo $this->__('Tax') ?></td>
85
+ <td align="right" style="padding:3px 9px"><?php echo $_order->formatPrice($_order->getTaxAmount()) ?></td>
86
+ </tr>
87
+ <?php endif; ?>
88
+ <tr bgcolor="#DEE5E8">
89
+ <td colspan="3" align="right" style="padding:3px 9px"><strong><big><?php echo $this->__('Grand Total') ?></big></strong></td>
90
+ <td align="right" style="padding:6px 9px"><strong><big><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></big></strong></td>
91
+ </tr>
92
+ </tfoot>
93
+
94
+ </table>
app/design/frontend/default/default/template/kreditor/order/invoice_items.phtml ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ -->
31
+ <?php $_order = $this->getOrder() ?>
32
+ <p class="a-right"><a href="<?php echo $this->getPrintAllInvoicesUrl($_order) ?>" onclick="this.target='_blank'"><strong><?php echo $this->__('Print All Invoices') ?></strong></a></p>
33
+ <?php foreach ($_order->getInvoiceCollection() as $_invoice): ?>
34
+ <div class="head-alt2">
35
+ <h3 class="title"><?php echo $this->__('Invoice #') ?><?php echo $_invoice->getIncrementId(); ?></h3>
36
+ <a href="<?php echo $this->getPrintInvoiceUrl($_invoice) ?>" onclick="this.target='_blank'"><?php echo $this->__('Print Invoice') ?></a>
37
+ </div>
38
+ <h4><?php echo $this->__('Items Invoiced') ?></h4>
39
+ <table cellspacing="0" class="data-table" id="my-invoice-table-<?php echo $_invoice->getId(); ?>">
40
+ <col />
41
+ <col width="25%" />
42
+ <col width="1" />
43
+ <col width="1" />
44
+ <col width="1" />
45
+ <thead>
46
+ <tr>
47
+ <th><?php echo $this->__('Product Name') ?></th>
48
+ <th><?php echo $this->__('SKU') ?></th>
49
+ <th class="a-right"><?php echo $this->__('Price') ?></th>
50
+ <th class="a-center"><span class="nobr"><?php echo $this->__('Qty Invoiced') ?></span></th>
51
+ <th class="a-right"><?php echo $this->__('Subtotal') ?></th>
52
+ </tr>
53
+ </thead>
54
+ <tfoot>
55
+ <?php if ($_order->getPayment()->getMethod() == "kreditor_invoice"): ?>
56
+ <tr>
57
+ <td colspan="4" class="a-right"><?php echo $this->__('Invoice fee'); ?></td>
58
+ <td class="last a-right"><?php echo $_order->formatPrice($_order->getPayment()->getKreditorInvoicefee()); ?></td>
59
+ </tr>
60
+ <?php endif; ?>
61
+ <tr>
62
+ <td colspan="4" class="a-right"><?php echo $this->__('Order Subtotal') ?></td>
63
+ <td class="last a-right"><?php echo $_order->formatPrice($_invoice->getSubtotal()) ?></td>
64
+ </tr>
65
+ <?php if ($_invoice->getDiscountAmount() > 0): ?>
66
+ <tr>
67
+ <td colspan="4" class="a-right"><?php echo $this->__('Discount :') ?></td>
68
+ <td class="last a-right"><?php echo $_order->formatPrice(0.00 - $_invoice->getDiscountAmount()) ?></td>
69
+ </tr>
70
+ <?php endif; ?>
71
+ <?php if (($_invoice->getTaxAmount() > 0)||(Mage::helper('tax')->displayZeroTax())): ?>
72
+ <tr>
73
+ <td colspan="4" class="a-right"><?php echo $this->__('Tax') ?></td>
74
+ <td class="last a-right"><?php echo $_order->formatPrice($_invoice->getTaxAmount()) ?></td>
75
+ </tr>
76
+ <?php endif; ?>
77
+ <?php if ($_invoice->getShippingAmount() || $_invoice->getShippingDescription()): ?>
78
+ <tr>
79
+ <td colspan="4" class="a-right"><?php echo $this->__('Shipping & Handling') ?></td>
80
+ <td class="last a-right"><?php echo $_order->formatPrice($_invoice->getShippingAmount()) ?></td>
81
+ </tr>
82
+ <?php endif; ?>
83
+ <tr>
84
+ <td colspan="4" class="a-right"><?php echo $this->__('Grand Total') ?></td>
85
+ <td class="last a-right"><?php echo $_order->formatPrice($_invoice->getGrandTotal()) ?></td>
86
+ </tr>
87
+ </tfoot>
88
+ <?php $_items = $_invoice->getAllItems(); ?>
89
+ <?php $_count = count($_items) ?>
90
+ <?php foreach ($_items as $_item): ?>
91
+ <?php if ($_item->getOrderItem()->getParentItem()) continue; ?>
92
+ <tbody>
93
+ <?php echo $this->getItemHtml($_item) ?>
94
+ </tbody>
95
+ <?php endforeach; ?>
96
+ </table>
97
+ <script type="text/javascript">decorateTable('my-invoice-table-<?php echo $_invoice->getId(); ?>', {'tbody' : ['odd', 'even'], 'tbody tr' : ['first', 'last']})</script>
98
+ <?php endforeach; ?>
app/design/frontend/default/default/template/kreditor/order/items.phtml ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ -->
31
+ <?php $_order = $this->getOrder() ?>
32
+ <table cellspacing="0" class="data-table" id="my-orders-table">
33
+ <col />
34
+ <col width="25%" />
35
+ <col width="1" />
36
+ <col width="1" />
37
+ <col width="1" />
38
+ <thead>
39
+ <tr>
40
+ <th><?php echo $this->__('Product Name') ?></th>
41
+ <th><?php echo $this->__('SKU') ?></th>
42
+ <th class="a-right"><?php echo $this->__('Price') ?></th>
43
+ <th class="a-center"><?php echo $this->__('Qty') ?></th>
44
+ <th class="a-right"><?php echo $this->__('Subtotal') ?></th>
45
+ </tr>
46
+ <!-- tr>
47
+ <?php if ($this->helper('tax')->displayCartBothPrices() || $this->helper('tax')->displayCartPriceExclTax()): ?>
48
+ <th class="a-center"><?php echo $this->__('Excl. Tax') ?></th>
49
+ <?php endif; ?>
50
+ <?php if ($this->helper('tax')->displayCartBothPrices() || $this->helper('tax')->displayCartPriceInclTax()): ?>
51
+ <th class="a-center"><?php echo $this->__('Incl. Tax') ?></th>
52
+ <?php endif; ?>
53
+ <th class="a-center" width="6%"><?php echo $this->__('Ordered') ?></th>
54
+ <?php if (!$_order->getIsVirtual()): ?><th class="a-center" width="6%"><?php echo $this->__('Shipped') ?></th><?php endif; ?>
55
+ <th class="a-center" width="6%"><?php echo $this->__('Canceled') ?></th>
56
+ <?php if ($this->helper('tax')->displayCartBothPrices() || $this->helper('tax')->displayCartPriceExclTax()): ?>
57
+ <th class="a-center"><?php echo $this->__('Excl. Tax') ?></th>
58
+ <?php endif; ?>
59
+ <?php if ($this->helper('tax')->displayCartBothPrices() || $this->helper('tax')->displayCartPriceInclTax()): ?>
60
+ <th class="a-center"><?php echo $this->__('Incl. Tax') ?></th>
61
+ <?php endif; ?>
62
+ </tr -->
63
+ </thead>
64
+ <?php $colspan = 4; ?>
65
+ <tfoot>
66
+
67
+ <?php if ($_order->getPayment()->getMethod() == "kreditor_invoice"): ?>
68
+ <tr>
69
+ <td colspan="<?php echo $colspan; ?>" class="a-right"><?php echo $this->__('Invoice fee'); ?></td>
70
+ <td class="last a-right"><?php echo $_order->formatPrice($_order->getPayment()->getKreditorInvoicefee()); ?></td>
71
+ </tr>
72
+ <?php endif; ?>
73
+ <tr>
74
+ <td colspan="<?php echo $colspan; ?>" class="a-right"><?php echo $this->__('Order Subtotal') ?></td>
75
+ <td class="last a-right"><?php echo $_order->formatPrice($_order->getSubtotal()) ?></td>
76
+ </tr>
77
+ <?php if ($_order->getDiscountAmount() > 0): ?>
78
+ <tr>
79
+ <td colspan="<?php echo $colspan; ?>" class="a-right"><?php echo $this->__('Discount '.($_order->getCouponCode()?'('.$_order->getCouponCode().')':'')) ?></td>
80
+ <td class="last a-right"><?php echo $_order->formatPrice(0.00 - $_order->getDiscountAmount()) ?></td>
81
+ </tr>
82
+ <?php endif; ?>
83
+ <?php //if ($_order->getTaxAmount() > 0): ?>
84
+ <?php if (($_order->getTaxAmount() > 0)||(Mage::helper('tax')->displayZeroTax())): ?>
85
+ <?php echo $this->getChildHtml('tax'); ?>
86
+ <?php endif; ?>
87
+ <?php if ($_order->getShippingAmount() || $_order->getShippingDescription()): ?>
88
+ <tr>
89
+ <td colspan="<?php echo $colspan; ?>" class="a-right"><?php echo $this->__('Shipping & Handling') ?></td>
90
+ <td class="last a-right"><?php echo $_order->formatPrice($_order->getShippingAmount()) ?></td>
91
+ </tr>
92
+ <?php endif; ?>
93
+ <tr>
94
+ <td colspan="<?php echo $colspan; ?>" class="a-right"><?php echo $this->__('Grand Total') ?></td>
95
+ <td class="last a-right"><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></td>
96
+ </tr>
97
+ <?php if ($_order->isCurrencyDifferent()): ?>
98
+ <tr>
99
+ <td colspan="<?php echo $colspan; ?>" class="a-right"><?php echo $this->__('Grand Total to be charged') ?></td>
100
+ <td class="last a-right"><?php echo $_order->formatBasePrice($_order->getBaseGrandTotal()) ?></td>
101
+ </tr>
102
+ <?php endif; ?>
103
+ </tfoot>
104
+ <?php $_items = $_order->getItemsCollection(); ?>
105
+ <?php $_index = 0; ?>
106
+ <?php $_count = $_items->count(); ?>
107
+ <?php foreach ($_items as $_item): ?>
108
+ <?php if ($_item->getParentItem()) continue; ?>
109
+ <tbody>
110
+ <?php echo $this->getItemHtml($_item) ?>
111
+ <?php if($this->helper('giftmessage/message')->getIsMessagesAvailable('order_item', $_item) && $_item->getGiftMessageId()): ?>
112
+ <tr class="border<?php echo ($_index++ > $_count ?' last':'') ?>" id="order-item-gift-message-<?php echo $_item->getId() ?>" style="display:none;">
113
+ <?php $_giftMessage=$this->helper('giftmessage/message')->getGiftMessageForEntity($_item); ?>
114
+ <td class="giftmessage-row last" colspan="7">
115
+ <ul class="giftmessage-content">
116
+ <li><label><?php echo $this->__('From') ?></label> <?php echo $this->htmlEscape($_giftMessage->getRecipient()) ?></li>
117
+ <li><label><?php echo $this->__('To') ?></label> <?php echo $this->htmlEscape($_giftMessage->getSender()) ?></li>
118
+ <li><?php echo $this->helper('giftmessage/message')->getEscapedGiftMessage($_item) ?></li>
119
+ </ul>
120
+ <div class="giftmessage-close"><a href="#" onclick="return giftMessageToogle('<?php echo $_item->getId() ?>');"><img src="<?php echo $this->getSkinUrl('images/gift-message-close.gif') ?>" alt="" /></a></div>
121
+ </td>
122
+ </tr>
123
+ <?php endif ?>
124
+ </tbody>
125
+ <?php endforeach; ?>
126
+ </table>
127
+ <script type="text/javascript">decorateTable('my-orders-table', {'tbody' : ['odd', 'even'], 'tbody tr' : ['first', 'last']})</script>
app/design/frontend/default/default/template/kreditor/order/print_invoice.phtml ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ -->
31
+ <?php $_order = $this->getOrder() ?>
32
+ <!--<div class="page-head button-level">
33
+ <h2><?php echo $this->__('Invoices') ?></h2>
34
+ <button class="form-button"><span><?php echo $this->__('Print All Invoices') ?></span></button>
35
+ </div>-->
36
+ <h3><?php echo $this->__('Order #%s', $_order->getRealOrderId()) ?></h3>
37
+ <p><?php echo $this->__('Order Date: %s', $this->formatDate($_order->getCreatedAtStoreDate(), 'long')) ?></p>
38
+ <?php $_invoice = $this->getInvoice() ?>
39
+ <?php if($_invoice): ?>
40
+ <?php $_invoices = array($_invoice); ?>
41
+ <?php else: ?>
42
+ <?php $_invoices = $_order->getInvoiceCollection() ?>
43
+ <?php endif; ?>
44
+ <?php foreach ($_invoices as $_invoice): ?>
45
+ <div class="divider"></div>
46
+ <div class="head">
47
+ <h3><?php echo $this->__('Invoice #%s', $_invoice->getIncrementId()) ?></h3>
48
+ <!--<a href="#"><?php echo $this->__('Print Invoice') ?></a>-->
49
+ </div>
50
+ <div class="col2-set">
51
+ <div class="col-1">
52
+ <?php if (!$_order->getIsVirtual()): ?>
53
+ <h4><?php echo $this->__('Shipping Address') ?></h4>
54
+ <?php $_shipping = $_invoice->getShippingAddress() ?>
55
+ <address><?php echo $_shipping->format('html') ?></address>
56
+ </div>
57
+ <div class="col-2">
58
+ <?php endif; ?>
59
+ <h4><?php echo $this->__('Billing Address') ?></h4>
60
+ <?php $_billing = $_invoice->getbillingAddress() ?>
61
+ <address><?php echo $_order->getBillingAddress()->format('html') ?></address>
62
+ </div>
63
+ <?php if (!$_order->getIsVirtual()): ?>
64
+ </div>
65
+ <br />
66
+ <div class="col2-set">
67
+ <div class="col-1">
68
+ <h4><?php echo $this->__('Shipping Method') ?></h4>
69
+ <?php echo $_order->getShippingDescription() ?>
70
+ </div>
71
+ <?php endif; ?>
72
+ <div class="col-2">
73
+ <h4><?php echo $this->__('Payment Method') ?></h4>
74
+ <?php echo $this->getPaymentInfoHtml() ?>
75
+ </div>
76
+ </div>
77
+ <br />
78
+ <h4><?php echo $this->__('Items Invoiced') ?></h4>
79
+ <table cellspacing="0" class="data-table print" id="my-invoice-table-<?php echo $_invoice->getId(); ?>">
80
+ <col />
81
+ <col width="25%" />
82
+ <col width="1" />
83
+ <col width="1" />
84
+ <col width="1" />
85
+ <thead>
86
+ <tr>
87
+ <th><?php echo $this->__('Product Name') ?></th>
88
+ <th><?php echo $this->__('SKU') ?></th>
89
+ <th class="a-right"><?php echo $this->__('Price') ?></th>
90
+ <th class="a-center"><span class="nobr"><?php echo $this->__('Qty Invoiced') ?></span></th>
91
+ <th class="a-right last"><?php echo $this->__('Subtotal') ?></th>
92
+ </tr>
93
+ </thead>
94
+ <?php $colspan = 4; ?>
95
+ <tfoot>
96
+ <?php if ($_order->getPayment()->getMethod() == "kreditor_invoice"): ?>
97
+ <tr>
98
+ <td colspan="<?php echo $colspan; ?>" class="a-right"><?php echo $this->__('Invoice fee'); ?></td>
99
+ <td class="last a-right"><?php echo $_order->formatPrice($_order->getPayment()->getKreditorInvoicefee()); ?></td>
100
+ </tr>
101
+ <?php endif; ?>
102
+ <?php if($_invoice->getSubtotal() != $_invoice->getGrandTotal()): ?>
103
+ <tr>
104
+ <td colspan="<?php echo $colspan; ?>" class="a-right"><?php echo $this->__('Order Subtotal') ?></td>
105
+ <td class="last a-right"><?php echo $_order->formatPrice($_invoice->getSubtotal()) ?></td>
106
+ </tr>
107
+ <?php endif; ?>
108
+ <?php if ($_invoice->getDiscountAmount() > 0): ?>
109
+ <tr>
110
+ <td colspan="<?php echo $colspan; ?>" class="a-right"><?php echo $this->__('Discount :') ?></td>
111
+ <td class="last a-right"><?php echo $_order->formatPrice(0.00 - $_invoice->getDiscountAmount()) ?></td>
112
+ </tr>
113
+ <?php endif; ?>
114
+ <?php if ($_invoice->getTaxAmount() > 0): ?>
115
+ <tr>
116
+ <td colspan="<?php echo $colspan; ?>" class="a-right"><?php echo $this->__('Tax') ?></td>
117
+ <td class="last a-right"><?php echo $_order->formatPrice($_invoice->getTaxAmount()) ?></td>
118
+ </tr>
119
+ <?php endif; ?>
120
+ <?php if ($_invoice->getShippingAmount()*1 || $_invoice->getShippingDescription()): ?>
121
+ <tr>
122
+ <td colspan="<?php echo $colspan; ?>" class="a-right"><?php echo $this->__('Shipping & Handling') ?></td>
123
+ <td class="last a-right"><?php echo $_order->formatPrice($_invoice->getShippingAmount()) ?></td>
124
+ </tr>
125
+ <?php endif; ?>
126
+ <tr>
127
+ <td colspan="<?php echo $colspan; ?>" class="a-right"><?php echo $this->__('Grand Total') ?></td>
128
+ <td class="last a-right"><?php echo $_order->formatPrice($_invoice->getGrandTotal()) ?></td>
129
+ </tr>
130
+ </tfoot>
131
+ <?php $_items = $_invoice->getItemsCollection(); ?>
132
+ <?php $_count = $_items->count(); ?>
133
+ <?php foreach ($_items as $_item): ?>
134
+ <?php if ($_item->getOrderItem()->getParentItem()) continue; ?>
135
+ <tbody>
136
+ <?php echo $this->getItemHtml($_item) ?>
137
+ </tbody>
138
+ <?php endforeach; ?>
139
+ </table>
140
+ <script type="text/javascript">decorateTable('my-invoice-table-<?php echo $_invoice->getId(); ?>', {'tbody' : ['odd', 'even'], 'tbody tr' : ['first', 'last']})</script>
141
+ <?php endforeach; ?>
142
+ <script type="text/javascript">window.print();</script>
app/design/frontend/default/default/template/kreditor/order/print_order.phtml ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+ -->
31
+ <?php $_order = $this->getOrder() ?>
32
+ <h3><?php echo $this->__('Order #%s', $_order->getRealOrderId()) ?></h3>
33
+ <p><?php echo $this->__('Order Date: %s', $this->formatDate($_order->getCreatedAtStoreDate(), 'long')) ?></p>
34
+ <div class="divider"></div>
35
+ <div class="col2-set">
36
+ <?php if (!$_order->getIsVirtual()): ?>
37
+ <div class="col-1">
38
+ <h4><?php echo $this->__('Shipping Address') ?></h4>
39
+ <address><?php echo $_order->getShippingAddress()->format('html') ?></address>
40
+ </div>
41
+ <div class="col-2">
42
+ <?php else: ?>
43
+ <div class="col-1">
44
+ <?php endif; ?>
45
+ <h4><?php echo $this->__('Billing Address') ?></h4>
46
+ <address><?php echo $_order->getBillingAddress()->format('html') ?></address>
47
+ </div>
48
+ <?php if (!$_order->getIsVirtual()): ?>
49
+ </div>
50
+ <br />
51
+ <div class="col2-set">
52
+ <div class="col-1">
53
+ <h4><?php echo $this->__('Shipping Method') ?></h4>
54
+ <?php echo $_order->getShippingDescription() ?>
55
+ </div>
56
+ <?php endif; ?>
57
+ <div class="col-2">
58
+ <h4><?php echo $this->__('Payment Method') ?></h4>
59
+ <?php echo $this->getPaymentInfoHtml() ?>
60
+ </div>
61
+ </div>
62
+ <br />
63
+ <h4><?php echo $this->__('Items Ordered') ?></h4>
64
+ <table cellspacing="0" class="data-table print" id="my-orders-table">
65
+ <col />
66
+ <col width="25%" />
67
+ <col width="1" />
68
+ <col width="1" />
69
+ <col width="1" />
70
+ <thead>
71
+ <tr>
72
+ <th><?php echo $this->__('Product Name') ?></th>
73
+ <th><?php echo $this->__('SKU') ?></th>
74
+ <th class="a-right"><?php echo $this->__('Price') ?></th>
75
+ <th class="a-center"><?php echo $this->__('Qty') ?></th>
76
+ <th class="a-right last"><?php echo $this->__('Subtotal') ?></th>
77
+ </tr>
78
+ </thead>
79
+ <?php $colspan = 4; ?>
80
+ <tfoot>
81
+ <?php if ($_order->getPayment()->getMethod() == "kreditor_invoice"): ?>
82
+ <tr>
83
+ <td colspan="<?php echo $colspan; ?>" class="a-right"><?php echo $this->__('Invoice fee'); ?></td>
84
+ <td class="last a-right"><?php echo $_order->formatPrice($_order->getPayment()->getKreditorInvoicefee()); ?></td>
85
+ </tr>
86
+ <?php endif; ?>
87
+
88
+ <tr>
89
+ <td colspan="<?php echo $colspan; ?> " class="a-right"><?php echo $this->__('Order Subtotal') ?></td>
90
+ <td class="last a-right"><?php echo $_order->formatPrice($_order->getSubtotal()) ?></td>
91
+ </tr>
92
+ <?php if ($_order->getDiscountAmount() > 0): ?>
93
+ <tr>
94
+ <td colspan="<?php echo $colspan; ?>" class="a-right"><?php echo $this->__('Discount :') ?></td>
95
+ <td class="last a-right"><?php echo $_order->formatPrice(0.00 - $_order->getDiscountAmount()) ?></td>
96
+ </tr>
97
+ <?php endif; ?>
98
+ <?php if ($_order->getTaxAmount() > 0): ?>
99
+ <?php echo $this->getChildHtml('tax'); ?>
100
+ <?php endif; ?>
101
+ <?php if (!$_order->getIsVirtual() && ($_order->getShippingAmount()*1 || $_order->getShippingDescription())): ?>
102
+ <tr>
103
+ <td colspan="<?php echo $colspan; ?>" class="a-right"><?php echo $this->__('Shipping & Handling') ?></td>
104
+ <td class="last a-right"><?php echo $_order->formatPrice($_order->getShippingAmount()) ?></td>
105
+ </tr>
106
+ <?php endif; ?>
107
+ <tr>
108
+ <td colspan="<?php echo $colspan; ?>" class="a-right"><?php echo $this->__('Grand Total') ?></td>
109
+ <td class="last a-right"><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></td>
110
+ </tr>
111
+ </tfoot>
112
+ <?php $_items = $_order->getItemsCollection(); ?>
113
+ <?php $_count = $_items->count(); ?>
114
+ <?php foreach ($_items as $_item): ?>
115
+ <?php if ($_item->getParentItem()) continue; ?>
116
+ <tbody>
117
+ <?php echo $this->getItemHtml($_item) ?>
118
+ </tbody>
119
+ <?php endforeach; ?>
120
+ </table>
121
+ <script type="text/javascript">decorateTable('my-orders-table', {'tbody' : ['odd', 'even'], 'tbody tr' : ['first', 'last']})</script>
122
+ <script type="text/javascript">window.print();</script>
app/design/frontend/default/default/template/kreditor/product/price.phtml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2010 KLARNA AB. All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification, are
6
+ * permitted provided that the following conditions are met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ * conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ * of conditions and the following disclaimer in the documentation and/or other materials
13
+ * provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY KLARNA AB "AS IS" AND ANY EXPRESS OR IMPLIED
16
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KLARNA AB OR
18
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ *
25
+ * The views and conclusions contained in the software and documentation are those of the
26
+ * authors and should not be interpreted as representing official policies, either expressed
27
+ * or implied, of KLARNA AB.
28
+ *
29
+ */
30
+
31
+ $block = $this->getLayout()->getBlock('klarna_price_block');
32
+ $formattedtext = $block ? $this->__('Partpayment from') : $this->__('Partpayment from search');
33
+ $tcpc = 0;
34
+
35
+ if(!$block && ($this->getLang() == 'nl' || $this->getLang() == 'no'))
36
+ return;
37
+ ?>
38
+ <div class="klarna_pp_text"><?=sprintf($formattedtext, '<span style="color: red; font-weight: bold;" class="klarna_pp_cost">' . $this->getMonthlycost() . '</span>');?></div>
39
+ <?php
40
+
41
+ // Only display the link to the term and the image.
42
+ if($this->getLang() == 'nl') {
43
+ echo('<img src="' . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . 'frontend/default/default/images/kreditor/partpayment/dutch_credit.jpg" style="margin-top: 5px; margin-bottom: 10px;" alt="Klarna" />');
44
+ echo('<br /><a href="https://klarna.com/pdf/kredietprospectus_klarna_account_juli_2010.pdf" target="_blank">Kredietprospectus</a>');
45
+ return;
46
+ } elseif($this->getLang() == 'no') {
47
+ $tcpcapr = $this->getTotalCreditPurchaseCost();
48
+ $tcpc = Mage::helper('checkout')->formatPrice(ceil($tcpcapr['tcpc']/100));
49
+ $apr = $tcpcapr['apr'];
50
+ echo Mage::helper('kreditor')->__('Total credit purchase cost') . ': ' . $tcpc . '<br />';
51
+ //echo $this->__('True yield') . ': ' . round($apr/100, 2) . '%<br />';
52
+ }
53
+ // xxx Only display the link on product pages
54
+ if(!$block) return;
55
+ ?>
56
+ <script type="text/javascript" src="https://integration.klarna.com/js/klarnapart.js"></script>
57
+ <script type="text/javascript">
58
+ addKlarnaPartPaymentEvent(function() { InitKlarnaPartPaymentElements('<?=$this->getNameInLayout()?>', <?=Mage::getStoreConfig('payment/kreditor_partpayment/merchant_id')?>, '<?=$this->getLang()?>', <?=$this->getSum()?>); });
59
+ </script>
60
+ <a href="#" id="<?=$this->getNameInLayout()?>" class="klarna_pp_link" onclick="ShowKlarnaPartPaymentPopup();return false;"></a>
61
+
62
+
63
+
app/etc/modules/Kreditor_Kreditor.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Kreditor_Kreditor>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Kreditor_Kreditor>
8
+ </modules>
9
+ </config>
app/locale/da_DK/Kreditor_Kreditor.csv ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Manage Kreditor Pclasses","Manage Klarna Pclasses"
2
+ "Unsupported currency","Valuta ej understöttet"
3
+ "Unable to initialize import model","Ikke muligt at implementere import model"
4
+ "Selected payment type is not allowed for billing country.","Den valgte betalingsmetode er ikke tilladt"
5
+ "Selected currency code is not compatible with Kreditor","Den valgte valuta er ikke kompatibel med Klarna"
6
+ "This currency is not compatible with your country.","Den valgte valuta kan ikke benyttes i dit land"
7
+ "The country code is either invalid or not permitted","Lande kode er enten forkert eller ikke tilladt"
8
+ "Handling fee","Administrativ afgift"
9
+ "Shipping fee","Fragt gebyr"
10
+ "Something went wrong in the communication to Kreditor. Please try again later.","Noget i kommunikationen til Klarna gik galt. Pröv venligst igen senere"
11
+ "A error occured. Please contact customer support.","Der er sket en fejl. Kontakt venligst kundeservice"""
12
+ "Missing Kreditor Partpayment merchant id/secret key","Mangler dit Klarna merchant ID/shared secret"
13
+ "Selected currency is not compatible with Kreditor","Valgte valuta er ikke kompatibel med Klarna"
14
+ "Your shipping and billing address must be the same to use the Kreditor payment.","Faktura adresse og leveringsadresse skal være den samme"
15
+ "Please enter a valid SSN/Orgnr.","Venligst indtast gyldigt CVR nummer"
16
+ "Please go back and fill in your company name.","Venligst gå tilbage og indtast dit firmanavn"
17
+ "Enter your payment information","Indtast betalingsinformation"
18
+ "SSN/Orgnr","CVR nummer"
19
+ "Invoice fee","Faktura gebyr"
20
+ "Annual income","Års inkomst"
21
+ "Note","Notat"
22
+ "Your shipping and billing information will be updated with information from Kreditor.","Din levering og faktura adresse bliver opdateret af Klarna"
23
+ "Select a payment period below","Välg din betalingsmetode nedenstående/under"
24
+ "Months","Måneder"
25
+ "month","Måned"
26
+ "Approx.","Cirka"
27
+ "Starting fee","Oprettelses afgift"
28
+ "Interest","Rente"
29
+ "Terms","Vilkår"
30
+ "terms","vilkår"
31
+ "I accept the ","Jeg acceptere "
32
+ "Cost per month","Omkostninger pr. Måned"
33
+ "Account","Konto"
34
+ "Part payment", "Delbetaling - Klarna"
35
+ "cellno", "Mobiltelefonnummer"
36
+ "Partpayment from", "Delbetala fra %s/månad"
37
+ "Partpayment from search", "Fra %s/månad"
38
+ "Chosen part payment", "Vald delbetaling"
39
+ "Kreditor invoice number", "Fakturanummer fra Klarna"
40
+ "Shipping address", "Leveranse adresse"
41
+ "Please select your shipping address", "Venligst vælg leveranse adresse"
42
+ "Change billing address", "Skift Faktureringsadresse"
43
+ "Billing address", "Faktureringsadresse"
44
+ "Estore order number", "Butikkens ordrenummer"
45
+ "Cancelled reservation" "Fjernede reservation"
46
+ "Status", "Status"
47
+ "An error occurred", "Der opstod en fejl"
48
+ "Reservation", "Din reservation"
49
+ "Invoice number", "Fakturanummer"
50
+ "Link to invoice", "Link til Faktura"
51
+ "View invoice", "Vis Faktura"
52
+ "Retreiving your addresses...", "Henter dine adresser"
53
+ "Activated reservations", "Aktiverede reservationer"
54
+ "Cancelled reservations", "Annulleret reservationer"
55
+ "Activate reservation", "Aktivere reservationer"
56
+ "Cancel reservation", "Annuller reservationer"
57
+ "Klarna reservation number", "Reservationsnummer fra Klarna"
58
+ "Get my addresses", "Hent mine adresser"
59
+ "Please select the shipping address to use with Klarna", "Venligst vælg den leveringsadresse som du vil at Klarna skal bruge."
60
+ "Test mode", "Testtilstand"
61
+ "Read more / Read less", "Læs mere / Læs mindre"
62
+ "Please observe. Module is in test mode and no real invoices will be created!", "OBS! Modulet er i testtilstand og der vil ikke blive skabt en rigtig faktura."
63
+ "The module is currently set to work in test mode. This means that all purchases that
64
+ are made through this payment option will be handled as test purchases and will not generate real
65
+ invoices at Klarna. You need to disable this in the payment options before going live. Remember that
66
+ you also need to remove test mode in Klarna Online before you can start generating real invoices
67
+ through Klarna.<br /><br />Please refer to <a href=""http://integration.klarna.com"" target=""_blank"">our integration guide</a>
68
+ for more information.", "Modulet er sat til at arbejde i testtilstand. Det betyder at alle køb gennemført gennem dette betalingsalternativ vil blive behandlet som et testkøb og ikke vil skabe en rigtig faktura hos Klarna. Du skal deaktivere dette i betalingsmulighederne før du går live. Husk at du også skal fjerne testtilstand i Klarna Online før du kan skabe rigtige faktura gennem Klarna.<br /><br />Anvend venligst vores <a href=""http://integration.klarna.com"" target=""_blank"">integrations guide</a> for yderligere information."
69
+ "Please note that the invoice from Klarna will be sent to your shipping address and your billing address will be set to the same as your shipping address.", "Vær opmærksom på at din faktura bliver sendt til din leverance adresse og at din faktura adresse bliver opdateret til den samme som leverance adressen."
70
+ "Birthdate hint", "DD-MM-ÅÅ-NNNN"
71
+ "Total credit purchase cost", "Total kredit omkostning"
app/locale/de_DE/Kreditor_Kreditor.csv ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Manage Kreditor Pclasses","Klarnas Pclasses bearbeiten"
2
+ "Unsupported currency","Diese W&auml;hrung wird nicht unterst&uuml;tzt"
3
+ "Unable to initialize import model","Konnte die Importierung nicht beginnen"
4
+ "Selected payment type is not allowed for billing country.","Diese Zahlungsart ist nicht in dem Land zugelassen, dass Sie als Fakturierungsland ausgew&auml;hlt haben."
5
+ "Selected currency code is not compatible with Kreditor","Dieser W&auml;hrungscode ist nicht kompatibel mit Klarna"
6
+ "This currency is not compatible with your country.","Diese W&auml;hrung ist nicht kompatibel mit dem gew&auml;hlten Land."
7
+ "The country code is either invalid or not permitted","Der L&auml;ndercode ist entweder falsch oder ung&uuml;ltig."
8
+ "Handling fee","Verwaltungsgeb&uuml;hr"
9
+ "Shipping fee","Versandkosten"
10
+ "Something went wrong in the communication to Kreditor. Please try again later.","Bei der Kommunikation mit Klarna ist ein Fehler aufgetreten. Bitte versuchen Sie es sp&auml;ter noch einmal."
11
+ "A error occured. Please contact customer support.","Ein Fehler ist aufgetreten. Bitte kontaktieren Sie unseren Kundendienst."
12
+ "Missing Kreditor Partpayment merchant id/secret key","Shop-Id/shared secret fehlen f&uuml;r der Ratenkauf."
13
+ "Selected currency is not compatible with Kreditor","Diese W&auml;hrung ist nicht kompatibel mit Klarna."
14
+ "Your shipping and billing address must be the same to use the Kreditor payment.","Die Liefer- und Rechnungsadresse m&uuml;ssen identisch sein, um Klarnas Dienstleistungen in Anspruch nehmen zu k&ouml;nnen."
15
+ "Please enter a valid SSN/Orgnr.","Var v&auml;nlig ange giltig person- /org. Nummer."
16
+ "Please go back and fill in your company name.","Bitte gehen Sie einen Schritt zur&uuml;ck und f&uuml;llen Sie den Namen Ihres Unternehmens aus."
17
+ "Enter your payment information","<br />F&uuml;llen Sie Ihre Zahlungsinformationen aus"
18
+ "Gender","Geschlecht"
19
+ "Street/Housenum","Strasse/Hausnummer"
20
+ "Street","Strasse"
21
+ "House number","Hausnummer"
22
+ "Male","Mann"
23
+ "Female","Frau"
24
+ "SSN/Orgnr","Geburtsdatum"
25
+ "Invoice fee","Rechnungsgeb&uuml;hr"
26
+ "Annual income","Jahreseinkommen"
27
+ "Note","Achtung!"
28
+ "Select a payment period below","W&auml;hlen Sie eine der untenstehenden Zahlungsperioden."
29
+ "Months","Monate"
30
+ "month","Monat"
31
+ "Approx.","Ca."
32
+ "Starting fee","Bearbeitungsgeb&uuml;hr"
33
+ "Interest","Zinsen"
34
+ "Terms","Bedingungen"
35
+ "terms","Bedingungen"
36
+ "I accept the ","Ich akzeptiere die"
37
+ "Cost per month","monatliche Kosten"
38
+ "Account","Konto"
39
+ "Part payment","Ratenkauf - Klarna"
40
+ "cellno","Mobiltelefonnummer"
41
+ "Invoice fee","Rechnungsgeb&uuml;hr"
42
+ "Manage Klarna Pclasses","Pclasses bearbeiten"
43
+ "Partpayment from","Ratenkauf ab %s/Monat"
44
+ "Partpayment from search","Ab %s/Monat"
45
+ "Chosen part payment","Gew&auml;hlter Ratenkauf"
46
+ "Invoice fee. excl. VAT","Rechnungsgeb&uuml;hr zzgl. MwSt."
47
+ "Kreditor invoice number","Klarnas Rechnungsnummer"
48
+ "Shipping address","Lieferadresse"
49
+ "Please select your shipping address","Bitte w&auml;hlen Sie eine Lieferadresse"
50
+ "Change billing address","Rechnungsadresse &auml;ndern"
51
+ "Billing address","Rechnungsadresse"
52
+ "Estore order number","Bestellnummer des Shops"
53
+ "Cancelled reservation" "Gel&ouml;schte Reservierung"
54
+ "Status","Status"
55
+ "An error occurred","Ein Fehler ist aufgetreten"
56
+ "Reservation","Reservierung"
57
+ "Invoice number","Rechnungsnummer"
58
+ "Link to invoice","Link zur Rechnung"
59
+ "View invoice","Rechnung anzeigen"
60
+ "Retreiving your addresses...","Ihre Adressen werden geladen"
61
+ "Activated reservations","Aktivierte Reservierungen"
62
+ "Cancelled reservations","Stornierte Reservierungen"
63
+ "Activate reservation","Reservierungen aktivieren"
64
+ "Cancel reservation","Reservierungen stornieren"
65
+ "Klarna reservation number","Reservierungsnummer von Klarna"
66
+ "Get my addresses","Meine Adressen anzeigen"
67
+ "Please select the shipping address to use with Klarna","Bitte w&auml;hlen Sie die Lieferadresse, die Sie f&uuml;r Klarnas Service verwenden m&ouml;chten"
68
+ "Test mode", "Testphase"
69
+ "Read more / Read less", "Mehr lesen / Weniger lesen"
70
+ "Please observe. Module is in test mode and no real invoices will be created!", "Bitte beachten! Das Modul ist in der Testphase und es können keine echten Rechnungen erstellt werden."
71
+ "The module is currently set to work in test mode. This means that all purchases that
72
+ are made through this payment option will be handled as test purchases and will not generate real
73
+ invoices at Klarna. You need to disable this in the payment options before going live. Remember that
74
+ you also need to remove test mode in Klarna Online before you can start generating real invoices
75
+ through Klarna.<br /><br />Please refer to <a href=""http://integration.klarna.com"" target=""_blank"">our integration guide</a>
76
+ for more information.", "Dies bedeutet, dass alle Einkäufe, die über diese Bezahloption getätigt werden,
77
+ als Testeinkäufe gehandhabt werden, und bei Klarna keine echten Rechnungen generiert werden. Es ist
78
+ notwendig, dass Sie dies in den Bezahloptionen deaktivieren, bevor Sie live gehen. Denken Sie
79
+ auch daran, dass die Testphase in Klarna Online abgeschalten werden muss, bevor Sie damit beginnen
80
+ können, echte Rechnungen durch Klarna zu erstellen.
81
+ <br /><br />Bitte wenden Sie sich an unseren <a href=""http://integration.klarna.com"" target=""_blank"">Integrations-Service</a> für mehr Information."
82
+ "Please note that the invoice from Klarna will be sent to your shipping address and your billing address will be set to the same as your shipping address.", "Bitte beachten Sie das Klarna die Rechnung an Ihre Lieferadresse versendet. Als Rechnungsadresse wird die Versandadresse verwendet."
83
+ "Birthdate hint", "TT-MM-JJJJ"
84
+ "Total credit purchase cost", "Gesamte Kosten des Kredits"
app/locale/en_US/Kreditor_Kreditor.csv ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Manage Kreditor Pclasses", "Manage Kreditor Pclasses"
2
+ "Unsupported currency", "Unsupported currency"
3
+ "Unable to initialize import model", "Unable to initialize import model"
4
+ "Selected payment type is not allowed for billing country.", "Selected payment type is not allowed for billing country."
5
+ "Selected currency code is not compatible with Kreditor", "Selected currency code is not compatible with Kreditor"
6
+ "This currency is not compatible with your country.", "This currency is not compatible with your country."
7
+ "The country code is either invalid or not permitted", "The country code is either invalid or not permitted"
8
+ "Handling fee", "Handling fee"
9
+ "Shipping fee", "Shipping fee"
10
+ "Something went wrong in the communication to Kreditor. Please try again later.", "Something went wrong in the communication to Kreditor. Please try again later."
11
+ "A error occured. Please contact customer support.", "A error occured. Please contact customer support."
12
+ "Missing Kreditor Partpayment merchant id/secret key", "Missing Kreditor Partpayment merchant id/secret key"
13
+ "Selected currency is not compatible with Kreditor", "Selected currency is not compatible with Kreditor"
14
+ "Your shipping and billing address must be the same to use the Kreditor payment.", "Your shipping and billing address must be the same to use the Kreditor payment."
15
+ "Please enter a valid SSN/Orgnr.", "Please enter a valid SSN/Orgnr."
16
+ "Please go back and fill in your company name.", "Please go back and fill in your company name."
17
+ "Enter your payment information", "Enter your payment information"
18
+ "SSN/Orgnr", "SSN/Orgnr"
19
+ "Invoice fee", "Invoice fee"
20
+ "Annual income", "Annual income"
21
+ "Note", "Note"
22
+ "Your shipping and billing information will be updated with information from Kreditor.", "Your shipping and billing information will be updated with information from Kreditor."
23
+ "Select a payment period below", "Select a payment period below"
24
+ "Months", "Months"
25
+ "month", "month"
26
+ "Approx.", "Approx."
27
+ "Starting fee", "Starting fee"
28
+ "Interest", "Interest"
29
+ "Terms", "Terms"
30
+ "terms", "terms"
31
+ "I accept the ", "I accept the "
32
+ "Cost per month", "Cost per month"
33
+ "Account", "Account"
34
+ "Part payment", "Part payment - Klarna"
35
+ "cellno", "Cell phone"
36
+ "Invoice fee", "Invoice fee"
37
+ "Partpayment from", "Part payment from %s/month"
38
+ "Partpayment from search", "From %s/month"
39
+ "Chosen part payment", "Chosen part payment"
40
+ "Kreditor invoice number", "Klarna invoice number"
app/locale/fi_FI/Kreditor_Kreditor.csv ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Manage Kreditor Pclasses","Hallinnoi Klarnan Pclasses-arvoja"
2
+ "Unsupported currency","Anna maksutiedot"
3
+ "Unable to initialize import model","Mallin siirtämisen aloittaminen estynyt."
4
+ "Selected payment type is not allowed for billing country.","Valittu maksutapa ei ole sallittu ."
5
+ "Selected currency code is not compatible with Kreditor","Valittu valuuttakoodi ei ole Klarnan kanssa yhteensopiva"
6
+ "This currency is not compatible with your country.","Valuutta ei ole käytössä maassasi."
7
+ "The country code is either invalid or not permitted","Maakoodi on joko väärä tai kielletty"
8
+ "Handling fee","Käsittelymaksu"
9
+ "Shipping fee","Toimitusmaksu"
10
+ "Something went wrong in the communication to Kreditor. Please try again later.","Jokin epäonnistui kommunikoinnissa Klarnan kanssa. Ole hyvä ja yritä myöhemmin uudelleen."
11
+ "An error occured. Please contact customer support.","Tapahtui virhe. Ota yhteys asiakastukeen"
12
+ "Missing Kreditor Partpayment merchant id/secret key"," Klarnan osamaksun kauppa id/jaettu salalause puuttuu"
13
+ "Selected currency is not compatible with Kreditor","Valittu valuutta ei ole yhteensopiva Klarnan kanssa"
14
+ "Your shipping and billing address must be the same to use the Kreditor payment.","Toimitusosoitteen ja laskutusosoitteen on oltava samat maksaessasi Klarnan maksuvaihtoehdoilla."
15
+ "Please enter a valid SSN/Orgnr.","Ole hyvä ja anna henkilötunnus tai y-tunnus."
16
+ "Please go back and fill in your company name.","Palaa alkuun ja täytä yrityksen nimi."
17
+ "Enter your payment information","Anna maksutiedot"
18
+ "SSN/Orgnr","Henkilötunnus/Y-tunnus"
19
+ "Invoice fee","Laskutuslisä"
20
+ "Annual income","Vuositulot"
21
+ "Note","HUOM"
22
+ "Your shipping and billing information will be updated with information from Kreditor.","Toimitus- ja laskutustietosi päivitetään Klarnan tiedoilla. "
23
+ "Select a payment period below","Valitse alhaalta maksuaikataulu"
24
+ "Months","Kuukausia"
25
+ "month","kuukausi"
26
+ "Approx.","Noin"
27
+ "Starting fee","Tilinavausmaksu"
28
+ "Interest","Korko"
29
+ "Terms","Ehdot"
30
+ "terms","ehdot"
31
+ "I accept the ","Hyväksyn "
32
+ "Cost per month","Kulut per kuukausi"
33
+ "Account","Tili"
34
+ "Part payment", "Osamaksu - Klarna"
35
+ "cellno", "Matkapuhelinnumero"
36
+ "Partpayment from", "Jaa maksu osiin alk. %s/kk"
37
+ "Partpayment from search", "alk. %s/kk"
38
+ "Chosen part payment", "Valittu osamaksu"
39
+ "Invoice fee ex. VAT", "Laskutuslisä ilman ALV:tä"
40
+ "Kreditor invoice number", "Klarna laskunumero"
41
+ "Shipping address", "Toimitusosoite"
42
+ "Please select your shipping address", "Valitse ystävällisesti toimitusosoite"
43
+ "Change billing address", "Vaihda laskutusosoite"
44
+ "Billing address", "Laskutusosoite"
45
+ "Estore order number", "Kaupan tilausnumero"
46
+ "Cancelled reservation" "Poistetut varaukset"
47
+ "Status", "Tila"
48
+ "An error occurred", "Virhe"
49
+ "Reservation", "Varaus"
50
+ "Invoice number", "Laskunumero"
51
+ "Link to invoice", "Linkki laskuun"
52
+ "View invoice", "Näytä lasku"
53
+ "Retreiving your addresses...", "Hae osoitteesi"
54
+ "Activated reservations", "Aktiiviset varaukset"
55
+ "Cancelled reservations", "Peruutetut varaukset"
56
+ "Activate reservation", "Aktivoi varaukset"
57
+ "Cancel reservation", "Peruuta varaukset"
58
+ "Klarna reservation number", "Klarnan antama varausnumero"
59
+ "Get my addresses", "Hae osoitteeni"
60
+ "Please select the shipping address to use with Klarna", "Valitse ystävällisesti pudotusvalikosta toimitusosoite, jota haluat käyttää Klarnan maksutavoilla maksaessasi"
61
+ "Test mode", "Testitila"
62
+ "Read more / Read less", "Lue lisää / Piilota"
63
+ "Please observe. Module is in test mode and no real invoices will be created!", "Huomaa, että moduuli on testitilassa eikä oikeita laskuja luoda."
64
+ "The module is currently set to work in test mode. This means that all purchases that
65
+ are made through this payment option will be handled as test purchases and will not generate real
66
+ invoices at Klarna. You need to disable this in the payment options before going live. Remember that
67
+ you also need to remove test mode in Klarna Online before you can start generating real invoices
68
+ through Klarna.<br /><br />Please refer to <a href=""http://integration.klarna.com"" target=""_blank"">our integration guide</a>
69
+ for more information.", "Moduuli on tällä hetkellä asetettu toimimaan testitilassa. Tämä tarkoittaa sitä, että kaikki kyseisen maksutavan kautta tehdyt ostokset käsitellään testitilauksina, eikä niistä luoda oikeita laskuja Klarnassa. Sinun tulee poistaa moduuli testitilasta ennen maksutavan käyttöönottoa. Muista, että testitila tulee poistaa myös Klarna Onlinesta, ennen kuin voit luoda oikeita laskuja Klarnan kautta. <br /><br />Lisätietoja löydät <a href=""http://integration.klarna.com"" target=""_blank"">integrointioppaastamme</a>"
70
+ "Please note that the invoice from Klarna will be sent to your shipping address and your billing address will be set to the same as your shipping address.", "Huomaa, että Klarnan lasku lähetetään ilmoittamaasi toimitusosoitteeseen, joka tullaan asettamaan myös laskutusosoitteeksesi."
71
+ "Birthdate hint", "PPKKVV-NNNN"
72
+ "Total credit purchase cost", "Luottohinta"
app/locale/nb_NO/Kreditor_Kreditor.csv ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Manage Kreditor Pclasses","Håndter Klarna Pclasses"
2
+ "Unsupported currency","Valutaen støttes ikke"
3
+ "Unable to initialize import model","Kunne ikke starte importeringen"
4
+ "Selected payment type is not allowed for billing country.","Den valgte betalingstypen kan ikke brukes i faktureringslandet."
5
+ "Selected currency code is not compatible with Kreditor","Den valgte valutakoden kan ikke brukes med Klarna"
6
+ "This currency is not compatible with your country.","Denne valutaen kan ikke brukes i ditt land."
7
+ "The country code is either invalid or not permitted","Landskoden er enten feil eller ikke tillatt."
8
+ "Handling fee","Håndteringsavgift"
9
+ "Shipping fee","Forsendelsesavgift"
10
+ "Something went wrong in the communication to Kreditor. Please try again later.","Noe gikk feil i oppkoblingen mot Klarna. Forsøk igjen senere."
11
+ "A error occured. Please contact customer support.","Det oppsto en feil. Vennligst kontakt kundeservice."
12
+ "Missing Kreditor Partpayment merchant id/secret key","Mangler Klarna butikk-ID/hemmelig nøkkel"
13
+ "Selected currency is not compatible with Kreditor","Den valgte valutaen kan ikke brukes med Klarna"
14
+ "Your shipping and billing address must be the same to use the Kreditor payment.","Din leverings- og faktureringsadresse må være den samme for å betale via Klarna."
15
+ "Please enter a valid SSN/Orgnr.","Vennligst oppgi et gyldig person-/org. nr."
16
+ "Please go back and fill in your company name.","Vennligst gå tilbake og fyll i ditt bedriftsnavn."
17
+ "Enter your payment information","Oppgi betalingsinformasjon"
18
+ "SSN/Orgnr","Person-/org. nr"
19
+ "Invoice fee","Fakturagebyr"
20
+ "Annual income","Årlig innkomst"
21
+ "Note","Merk:"
22
+ "Your shipping and billing information will be updated with information from Kreditor.","Din leverings- og faktureringsinformasjon vil oppdateres med informasjonen fra Klarna."
23
+ "Select a payment period below","Velg en betalingsperiode nedenfor."
24
+ "Months","Måneder"
25
+ "month","måned"
26
+ "Approx.","Ca."
27
+ "Starting fee","Oppstartsgebyr"
28
+ "Interest","Rente"
29
+ "Terms","Vilkår"
30
+ "terms","vilkår"
31
+ "I accept the ","Jeg aksepterer "
32
+ "Cost per month","Kostnad per måned"
33
+ "Account","Konto"
34
+ "Part payment", "Delbetaling - Klarna"
35
+ "cellno", "Mobiltelefonnummer"
36
+ "Partpayment from", "Delbetala fra %s/månad"
37
+ "Partpayment from search", "Fra %s/månad"
38
+ "Chosen part payment", "Vald delbetaling"
39
+ "Kreditor invoice number", "Fakturanummer fra Klarna"
40
+ "Shipping address", "Leveringsadresse"
41
+ "Please select your shipping address", "Vennligst velg leveringsadresse"
42
+ "Change billing address", "Endre Faktureringsadresse"
43
+ "Billing address", "Faktureringsadresse"
44
+ "Estore order number", "Butikkens ordrenummer"
45
+ "Cancelled reservation" "Fjernet reservasjon"
46
+ "Status", "Status"
47
+ "An error occurred", "Det oppstod en feil"
48
+ "Reservation", "Din reservasjon"
49
+ "Invoice number", "Fakturanummer"
50
+ "Link to invoice", "Link til Faktura"
51
+ "View invoice", "Se Faktura"
52
+ "Retreiving your addresses...", "Henter adressene"
53
+ "Activated reservations", "Aktiverte reservasjoner"
54
+ "Cancelled reservations", "Annullerte reservasjoner"
55
+ "Activate reservation", "Aktivere reservasjoner"
56
+ "Cancel reservation", "Annullere reservasjoner"
57
+ "Klarna reservation number", "Reserverings nummer fra Klarna"
58
+ "Get my addresses", "Last ned mine adresser"
59
+ "Please select the shipping address to use with Klarna", "Vennligst velg leveringsadressen som du vill att Klarna skal bruke"
60
+ "Test mode", "Testmodus"
61
+ "Read more / Read less", "Les mer / Les mindre"
62
+ "Please observe. Module is in test mode and no real invoices will be created!", "Vær oppmerksom på at modul er i testmodus og ingen reelle fakturaer opprettes!"
63
+ "The module is currently set to work in test mode. This means that all purchases that
64
+ are made through this payment option will be handled as test purchases and will not generate real
65
+ invoices at Klarna. You need to disable this in the payment options before going live. Remember that
66
+ you also need to remove test mode in Klarna Online before you can start generating real invoices
67
+ through Klarna.<br /><br />Please refer to <a href=""http://integration.klarna.com"" target=""_blank"">our integration guide</a>
68
+ for more information.", "Modulen er for tilfellet satt til å fungere i testmodus.
69
+ Dette betyr at alle kjøp som legges gjennom dette betalingsalternativet vil behandles som testkjøp,
70
+ og kommer ikke til å skape reelle fakturaer hos Klarna. Du må endre dette i betalingsalternativene
71
+ før du går live. Husk at du også må fjerne testmodus i Klarna Online før du kan begynne å skape reelle fakturaer gjennom Klarna.
72
+ <br /><br />Vennligst se vår <a href=""http://integration.klarna.com"" target=""_blank"">integrasjonsguide</a> for mer informasjon."
73
+ "Birthdate hint", "DD-MM-ÅÅ-NNNNN"
74
+ "Total credit purchase cost", "Kredittkjøpspris"
75
+ "Please note that the invoice from Klarna will be sent to your shipping address and your billing address will be set to the same as your shipping address.", "Vennligst observer at din faktura sendes til din leveringsadresse samt at din fakturaadresse vil oppdateres til den samme som leveringsadressen."
app/locale/nl_NL/Kreditor_Kreditor.csv ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Manage Kreditor Pclasses","Klarna's Pclasses beheren"
2
+ "Unsupported currency","Deze valuta wordt niet ondersteund"
3
+ "Unable to initialize import model","Kan het invoermodel niet initialiseren"
4
+ "Selected payment type is not allowed for billing country.","Deze betalingswijze is niet toegestaan in het land dat je hebt gekozen als factureringsland.."
5
+ "Selected currency code is not compatible with Kreditor","Deze valuta code is niet compatibel met Klarna"
6
+ "This currency is not compatible with your country.","Deze valuta is niet compatibel met jouw land."
7
+ "The country code is either invalid or not permitted","De landcode is ongeldig of niet toegestaan."
8
+ "Handling fee","Administratiekost"
9
+ "Shipping fee","Verzendkosten"
10
+ "Something went wrong in the communication to Kreditor. Please try again later.","Er is iets misgegaan in de communicatie met Klarna. Probeer het later opnieuw."
11
+ "A error occured. Please contact customer support.","Er is een fout opgetreden. Gelieve contact op te nemen met de klantenservice."
12
+ "Missing Kreditor Partpayment merchant id/secret key","Shop-ID/ Shared secret ontbreekt voor Klarna Account"
13
+ "Selected currency is not compatible with Kreditor","Deze valuta is niet compatibel met Klarna."
14
+ "Your shipping and billing address must be the same to use the Kreditor payment.","Uw lever- en factuuradres moeten identiek zijn om Klarna's services te kunnen gebruiken."
15
+ "Please enter a valid SSN/Orgnr.","Gelieve een geldig persoon-/ organisatienummer in te vullen."
16
+ "Please go back and fill in your company name.","Gelieve 1 stap terug te gaan en uw bedrijfsnaam in te vullen."
17
+ "Enter your payment information","Vul uw betalingsgegevens in"
18
+ "Gender","Geslacht"
19
+ "Street/Housenum", "Straat/Huisnummer"
20
+ "Street", "Straat"
21
+ "House number", "Huisnummer"
22
+ "Male","Man"
23
+ "Female","Vrouw"
24
+ "SSN/Orgnr","Geboortedatum"
25
+ "SSN/Orgnr","Geboortedatum"
26
+ "Invoice fee","Facturatiekost"
27
+ "Annual income","Jaarinkomen"
28
+ "Note","Opgelet!"
29
+ "Your shipping and billing information will be updated with information from Kreditor.","Din leverans- och faktureringsadress kommer att uppdateras genom Klarna."
30
+ "Select a payment period below","Kies één van de onderstaande betalingstermijnen."
31
+ "Months","Maanden"
32
+ "month","Maand"
33
+ "Approx.","Ca."
34
+ "Starting fee","Administratiekost"
35
+ "Interest","Interest"
36
+ "Terms","Voorwaarden"
37
+ "terms","voorwaarden"
38
+ "I accept the ","Ik ga akkoord met de"
39
+ "Cost per month","Maandelijkse kosten"
40
+ "Account","Konto"
41
+ "Part payment", "Klarna Account"
42
+ "cellno", "Mobiel nummer"
43
+ "Invoice fee", "Facturatiekost"
44
+ "Manage Klarna Pclasses", "Pclasses beheren"
45
+ "Partpayment from", "Deelbetaling vanaf %s/Maand"
46
+ "Partpayment from search", "Vanaf %s/Maand"
47
+ "Chosen part payment", "Geselecteerde deelbetaling"
48
+ "Invoice fee. excl. VAT", "Facturatiekost excl. BTW"
49
+ "Kreditor invoice number", "Klarna's factuurnummer"
50
+ "Shipping address", "Verzendadres"
51
+ "Please select your shipping address", "Gelieve uw verzendadres te selecteren"
52
+ "Change billing address", "Factuuradres veranderen"
53
+ "Billing address", "Factuuradres"
54
+ "Estore order number", "Bestelnummer webshop"
55
+ "Cancelled reservation", "Geannuleerde reservatie"
56
+ "Status", "Status"
57
+ "An error occurred", "Er is een fout opgetreden"
58
+ "Reservation", "Reservatie"
59
+ "Invoice number", "factuurnummer"
60
+ "Link to invoice", "Link naar de factuur"
61
+ "View invoice", "Bekijk de factuur"
62
+ "Retreiving your addresses...", "Uw adressen worden opgehaald..."
63
+ "Activated reservations", "Geactiveerde reservaties"
64
+ "Cancelled reservations", "Geannuleerde reservaties"
65
+ "Activate reservation", "Activeer reservatie"
66
+ "Cancel reservation", "Annuleer reservatie"
67
+ "Klarna reservation number", "Klarna reservatie nummer"
68
+ "Get my addresses", "Haal mijn adressen op"
69
+ "Please select the shipping address to use with Klarna", "Gelieve het door Klarna te gebruiken verzendadres te selecteren"
70
+ "House extension", "Toevoeging"
71
+ "Please note that the invoice from Klarna will be sent to your shipping address and your billing address will be set to the same as your shipping address.", "Let u er op dat de Factuur van Klarna naar het afleveradres gestuurd wordt en dat het factuuradres hetzelfde zal worden als het afleveradres."
72
+ "Birthdate hint", "DD-MM-JJJJ"
73
+ "Total credit purchase cost", "Totaal kredietkosten"
74
+
75
+
76
+
77
+
app/locale/nn_NO/Kreditor_Kreditor.csv ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Manage Kreditor Pclasses","Håndter Klarna Pclasses"
2
+ "Unsupported currency","Valutaen støttes ikke"
3
+ "Unable to initialize import model","Kunne ikke starte importeringen"
4
+ "Selected payment type is not allowed for billing country.","Den valgte betalingstypen kan ikke brukes i faktureringslandet."
5
+ "Selected currency code is not compatible with Kreditor","Den valgte valutakoden kan ikke brukes med Klarna"
6
+ "This currency is not compatible with your country.","Denne valutaen kan ikke brukes i ditt land."
7
+ "The country code is either invalid or not permitted","Landskoden er enten feil eller ikke tillatt."
8
+ "Handling fee","Håndteringsavgift"
9
+ "Shipping fee","Forsendelsesavgift"
10
+ "Something went wrong in the communication to Kreditor. Please try again later.","Noe gikk feil i oppkoblingen mot Klarna. Forsøk igjen senere."
11
+ "A error occured. Please contact customer support.","Det oppsto en feil. Vennligst kontakt kundeservice."
12
+ "Missing Kreditor Partpayment merchant id/secret key","Mangler Klarna butikk-ID/hemmelig nøkkel"
13
+ "Selected currency is not compatible with Kreditor","Den valgte valutaen kan ikke brukes med Klarna"
14
+ "Your shipping and billing address must be the same to use the Kreditor payment.","Din leverings- og faktureringsadresse må være den samme for å betale via Klarna."
15
+ "Please enter a valid SSN/Orgnr.","Vennligst oppgi et gyldig person-/org. nr."
16
+ "Please go back and fill in your company name.","Vennligst gå tilbake og fyll i ditt bedriftsnavn."
17
+ "Enter your payment information","Oppgi betalingsinformasjon"
18
+ "SSN/Orgnr","Person-/org. nr"
19
+ "Invoice fee","Fakturagebyr"
20
+ "Annual income","Årlig innkomst"
21
+ "Note","Merk:"
22
+ "Your shipping and billing information will be updated with information from Kreditor.","Din leverings- og faktureringsinformasjon vil oppdateres med informasjonen fra Klarna."
23
+ "Select a payment period below","Velg en betalingsperiode nedenfor."
24
+ "Months","Måneder"
25
+ "month","måned"
26
+ "Approx.","Ca."
27
+ "Starting fee","Oppstartsgebyr"
28
+ "Interest","Rente"
29
+ "Terms","Vilkår"
30
+ "terms","vilkår"
31
+ "I accept the ","Jeg aksepterer "
32
+ "Cost per month","Kostnad per måned"
33
+ "Account","Konto"
34
+ "Part payment", "Delbetaling - Klarna"
35
+ "cellno", "Mobiltelefonnummer"
36
+ "Partpayment from", "Delbetala fra %s/månad"
37
+ "Partpayment from search", "Fra %s/månad"
38
+ "Chosen part payment", "Vald delbetaling"
39
+ "Kreditor invoice number", "Fakturanummer fra Klarna"
40
+ "Shipping address", "Leveringsadresse"
41
+ "Please select your shipping address", "Vennligst velg leveringsadresse"
42
+ "Change billing address", "Endre Faktureringsadresse"
43
+ "Billing address", "Faktureringsadresse"
44
+ "Estore order number", "Butikkens ordrenummer"
45
+ "Cancelled reservation" "Fjernet reservasjon"
46
+ "Status", "Status"
47
+ "An error occurred", "Det oppstod en feil"
48
+ "Reservation", "Din reservasjon"
49
+ "Invoice number", "Fakturanummer"
50
+ "Link to invoice", "Link til Faktura"
51
+ "View invoice", "Se Faktura"
52
+ "Retreiving your addresses...", "Henter adressene"
53
+ "Activated reservations", "Aktiverte reservasjoner"
54
+ "Cancelled reservations", "Annullerte reservasjoner"
55
+ "Activate reservation", "Aktivere reservasjoner"
56
+ "Cancel reservation", "Annullere reservasjoner"
57
+ "Klarna reservation number", "Reserverings nummer fra Klarna"
58
+ "Get my addresses", "Last ned mine adresser"
59
+ "Please select the shipping address to use with Klarna", "Vennligst velg leveringsadressen som du vill att Klarna skal bruke"
60
+ "Test mode", "Testmodus"
61
+ "Read more / Read less", "Les mer / Les mindre"
62
+ "Please observe. Module is in test mode and no real invoices will be created!", "Vær oppmerksom på at modul er i testmodus og ingen reelle fakturaer opprettes!"
63
+ "The module is currently set to work in test mode. This means that all purchases that
64
+ are made through this payment option will be handled as test purchases and will not generate real
65
+ invoices at Klarna. You need to disable this in the payment options before going live. Remember that
66
+ you also need to remove test mode in Klarna Online before you can start generating real invoices
67
+ through Klarna.<br /><br />Please refer to <a href=""http://integration.klarna.com"" target=""_blank"">our integration guide</a>
68
+ for more information.", "Modulen er for tilfellet satt til å fungere i testmodus.
69
+ Dette betyr at alle kjøp som legges gjennom dette betalingsalternativet vil behandles som testkjøp,
70
+ og kommer ikke til å skape reelle fakturaer hos Klarna. Du må endre dette i betalingsalternativene
71
+ før du går live. Husk at du også må fjerne testmodus i Klarna Online før du kan begynne å skape reelle fakturaer gjennom Klarna.
72
+ <br /><br />Vennligst se vår <a href=""http://integration.klarna.com"" target=""_blank"">integrasjonsguide</a> for mer informasjon."
73
+ "Birthdate hint", "DD-MM-ÅÅ-NNNNN"
74
+ "Total credit purchase cost", "Kredittkjøpspris"
75
+ "Please note that the invoice from Klarna will be sent to your shipping address and your billing address will be set to the same as your shipping address.", "Vennligst observer at din faktura sendes til din leveringsadresse samt at din fakturaadresse vil oppdateres til den samme som leveringsadressen."
app/locale/sv_SE/Kreditor_Kreditor.csv ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Manage Kreditor Pclasses","Hantera Klarnas pclasser"
2
+ "Unsupported currency","Valutan stöds inte"
3
+ "Unable to initialize import model","Kunde inte påbörja importeringen"
4
+ "Selected payment type is not allowed for billing country.","Betalsättet är inte tillgängligt i landet som du har valt som faktureringsland."
5
+ "Selected currency code is not compatible with Kreditor","Valutakoden är inte kompatibelt med Klarna"
6
+ "This currency is not compatible with your country.","Valutan är inte kompatibel med det valda landet."
7
+ "The country code is either invalid or not permitted","Landskoden är antingen fel eller inte giltig."
8
+ "Handling fee","Expeditionsavgift"
9
+ "Shipping fee","Fraktkostnad"
10
+ "Something went wrong in the communication to Kreditor. Please try again later.","Ett problem har uppstått i kommunikationen med Klarna. Var god försök igen senare"
11
+ "A error occured. Please contact customer support.","Det har uppstått ett fel. Var god kontakta kundtjänst."
12
+ "Missing Kreditor Partpayment merchant id/secret key","Butiks-id/delad hemlighet saknas för delbetalningen"
13
+ "Selected currency is not compatible with Kreditor","Valutan är inte kompatibel med Klarna"
14
+ "Your shipping and billing address must be the same to use the Kreditor payment.","Leverans- och faktureringsadressen måste vara samma för att kunna använda Kreditors tjänster."
15
+ "Please enter a valid SSN/Orgnr.","Var vänlig ange giltig person- /org. Nummer."
16
+ "Please go back and fill in your company name.","Var god och gå tillbaka för att fylla i ditt företagsnamn."
17
+ "Enter your payment information","Fyll i din betalinformation"
18
+ "SSN/Orgnr","Person- /org. Nummer"
19
+ "Invoice fee","Faktureringsavgift"
20
+ "Annual income","Årsinkomst"
21
+ "Note","OBS!"
22
+ "Your shipping and billing information will be updated with information from Kreditor.","Din leverans- och faktureringsadress kommer att uppdateras genom Klarna."
23
+ "Select a payment period below","Välj betalningstid nedan"
24
+ "Months","Månader"
25
+ "month","månad"
26
+ "Approx.","Ca"
27
+ "Starting fee","Uppläggningsavgift"
28
+ "Interest","Ränta"
29
+ "Terms","Villkor"
30
+ "terms","villkoren"
31
+ "I accept the ","Jag godkänner"
32
+ "Cost per month","Kostnad per månad"
33
+ "Account","Konto"
34
+ "Part payment", "Delbetalning - Klarna"
35
+ "cellno", "Mobiltelefonnummer"
36
+ "Invoice fee", "Fakturaavgift"
37
+ "Manage Klarna Pclasses", "Hantera Pclasses"
38
+ "Partpayment from", "Delbetala från %s/månad"
39
+ "Partpayment from search", "Från %s/månad"
40
+ "Chosen part payment", "Vald delbetalning"
41
+ "Invoice fee. excl. VAT", "Fakturaavgift exkl. moms"
42
+ "Kreditor invoice number", "Fakturanummer från Klarna"
43
+ "Shipping address", "Leveransadress"
44
+ "Please select your shipping address", "Var vänlig och välj leveransadress"
45
+ "Change billing address", "Ändra faktureringsadress"
46
+ "Billing address", "Faktureringsadress"
47
+ "Estore order number", "Butikens ordernummer"
48
+ "Cancelled reservation" "Borttagen reservation"
49
+ "Status", "Status"
50
+ "An error occurred", "Ett fel uppstod"
51
+ "Reservation", "Reservation"
52
+ "Invoice number", "Fakturanummer"
53
+ "Link to invoice", "Länk till faktura"
54
+ "View invoice", "Visa faktura"
55
+ "Retreiving your addresses...", "Hämtar dina adresser"
56
+ "Activated reservations", "Aktiverade reservationer"
57
+ "Cancelled reservations", "Annullerade reservationer"
58
+ "Activate reservation", "Aktivera reservationer"
59
+ "Cancel reservation", "Annullera reservationer"
60
+ "Klarna reservation number", "Reservationsnummer från Klarna"
61
+ "Get my addresses", "Hämta mina adresser"
62
+ "Please select the shipping address to use with Klarna", "Var vänlig och välj den leveransadress som du vill använda med Klarna"
63
+ "Test mode", "Testläge"
64
+ "Read more / Read less", "Läs mer / Läs mindre"
65
+ "Please observe. Module is in test mode and no real invoices will be created!", "OBS! Modulen är i testläge och inga riktiga fakturor kommer att skapas."
66
+ "The module is currently set to work in test mode. This means that all purchases that
67
+ are made through this payment option will be handled as test purchases and will not generate real
68
+ invoices at Klarna. You need to disable this in the payment options before going live. Remember that
69
+ you also need to remove test mode in Klarna Online before you can start generating real invoices
70
+ through Klarna.<br /><br />Please refer to <a href=""http://integration.klarna.com"" target=""_blank"">our integration guide</a>
71
+ for more information.", "Modulen är för närvarande ställd i testläge. Detta innebär att alla köp med detta betalsätt
72
+ kommer att flaggas som testköp och inte generera några riktiga fakturor hos Klarna. För att åtgärda detta måste du slå av detta läge i inställningarna för modulen.
73
+ Glöm ej att du även måste slå av testläget i Klarna Online för att det ska skapas riktiga fakturor.
74
+ <br /><br />Se vår <a href=""http://integration.klarna.com"" target=""_blank"">integrationsguide</a> för mer information."
75
+ "Please enter a valid SSN", "Vänligen ange ett giltigt personnummer."
76
+ "Please note that the invoice from Klarna will be sent to your shipping address and your billing address will be set to the same as your shipping address.", "Vänligen notera att din faktura kommer att skickas till din leveransadress samt att din fakturaadress kommer att uppdateras till samma som din leveransadress."
77
+ "Birthdate hint", "ÅÅ-MM-DD-NNNN"
78
+ "Total credit purchase cost", "Total kreditköpskostnad"
package.xml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Klarna_KlarnaPaymentModule_CE_13</name>
4
+ <version>1.2.4</version>
5
+ <stability>stable</stability>
6
+ <license>SBSD</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Klarna module for invoice and part payment</summary>
10
+ <description>Klarna (former Kreditor) payment module for invoice and part payments. This module works with both invoice and part payments in Sweden, Finland and Denmark and in Norway with invoice. To use this module requires that you have a contract with Klarna.</description>
11
+ <notes>1.2.4
12
+ ---------------------------------
13
+ * Fixed an issue with get_addresses and guest checkout
14
+ ===================</notes>
15
+ <authors><author><name>Daniel Hansen</name><user>auto-converted</user><email>ms.modules@klarna.com</email></author></authors>
16
+ <date>2011-03-28</date>
17
+ <time>12:37:39</time>
18
+ <contents><target name="mage"><dir name="app"><dir name="code"><dir name="local"><dir name="Kreditor"><dir name="Kreditor"><dir name="Block"><dir name="Address"><file name="List.php" hash="2414ae905e2d7a026f4ecb2a647d5e7e"/></dir><dir name="Adminhtml"><dir name="Invoice"><dir name="Create"><file name="Items.php" hash="55af87d33e077c6a524bfceb6f650400"/></dir></dir><dir name="Pclass"><file name="Matrix.php" hash="a6a1d06e98a0e7347b38fb3dbfe69937"/></dir><dir name="Sales"><dir name="Order"><dir name="Totals"><file name="Item.php" hash="3f8fec1b142d37fa013ab3b01c2d096b"/></dir></dir></dir><file name="Pclass.php" hash="006deccd4dcd6309de8b2973bb8581b9"/></dir><dir name="Form"><file name="Invoice.php" hash="53067a5ee752170644b70d4bb303cd9d"/><file name="Partpayment.php" hash="c7eabc46678ea1b0568adf0c5ebc63b8"/></dir><dir name="Info"><file name="Invoice.php" hash="6de77f5d2061e02a91c87db7be6e757b"/><file name="Partpayment.php" hash="a3510245fb14fcc4b7fa4de380a68888"/></dir><dir name="Product"><file name="Price.php" hash="8d1afc8e9d93a00572340a97868ef95f"/></dir><dir name="Sales"><dir name="Order"><dir name="Email"><dir name="Invoice"><file name="Items.php" hash="dbbabbcad02b1f92ad2e1312f8a413fe"/></dir><file name="Items.php" hash="9877744793d6bc1007fc7f4e7fb94f7a"/></dir><dir name="Invoice"><file name="Items.php" hash="fddbdd292fc8f74b97dfae0805321524"/></dir><dir name="Print"><file name="Invoice.php" hash="55b15b09600329b06064008a31b55e6c"/></dir><file name="Items.php" hash="7b972dce93a7c376a291e9cb60a56bb0"/><file name="Print.php" hash="7b9a87bdeaccc95f6cbaafee05e2cf57"/></dir></dir></dir><dir name="controllers"><file name="AddressController.php" hash="0ad739351826f019ef1a2df3f642d8bc"/><file name="PclassController.php" hash="b3e2726ecc8bb92441335a372e620b43"/></dir><dir name="etc"><file name="config.xml" hash="0f22c16a38de21dd6a084bf51f58d44c"/><file name="system.xml" hash="9a251d82082214b0a43ca304c5922de9"/></dir><dir name="Helper"><file name="Data.php" hash="8858b75e89b060f8498a6c70a64c21ff"/></dir><dir name="Model"><dir name="Api"><file name="Kreditor.php" hash="a53737a22c517625a65a0af70648ff36"/><file name="kreditor_no_pear.php" hash="4a3270895791c1cdfbbba15a0cda65c1"/><file name="Pclass.php" hash="22470e4d16ff42034dca82028e7d9ef3"/><file name="pclasses.php" hash="5db04fcfba9059a15df8c1e16d9ab479"/></dir><dir name="Convert"><file name="Order.php" hash="bbb0c1011f70d0b7450515d729ce352a"/><file name="Quote.php" hash="0cb5639a6f39b0bec200c9749a16833d"/></dir><dir name="Entity"><file name="Setup.php" hash="e79c01fb3c8b97373d4cf31a65dab448"/></dir><dir name="Method"><file name="Invoice.php" hash="88589812a702e5ad76f0b9e96a8359b0"/><file name="Partpayment.php" hash="388dac45319d8536c7c70dc0738f82bb"/><file name="Shared.php" hash="32548a65d8aa680e87cef4021d753b5e"/></dir><dir name="Mysql4"><dir name="Api"><dir name="Pclass"><file name="Collection.php" hash="7b62bfe7a233fca28dbb9e7b0109cc4e"/></dir><file name="Pclass.php" hash="6592dbb559c69c1b669ae40e0828ecd3"/></dir></dir><dir name="Sales"><dir name="Order"><dir name="Invoice"><dir name="Total"><file name="Invoicefee.php" hash="243477287e0509e3b140446bc558d2c1"/></dir></dir></dir><dir name="Quote"><dir name="Address"><dir name="Total"><file name="Invoicefee.php" hash="6b67b652e2fb93829357f95999e10b85"/></dir></dir></dir><dir name="Total"><file name="Invoicefee.php" hash="1b2b2c73ab5aac18f4bc7ae0165c20cb"/></dir><file name="Order.php" hash="57e871f1fddedd3d621af810199aee4e"/><file name="Quote.php" hash="269ac430674eb49022687e4e4bd4abec"/></dir><dir name="Source"><file name="Invoicecountry.php" hash="5a84069aaac6f520b8faf120954a3f49"/><file name="Partpaymentcountry.php" hash="b55f1129eaeaa41c086cb712b012344c"/><file name="TransactionMode.php" hash="2f7bc80b9ffd3c8951f4054a65ba4058"/></dir></dir><dir name="sql"><dir name="kreditor_setup"><file name="mysql4-install-0.1.0.php" hash="f58a5427e753a8f933bc15c54da3ade1"/><file name="mysql4-upgrade-0.1.0-1.13.15.php" hash="4a3d52d71994d0d74a993c6e7fa59d46"/><file name="mysql4-upgrade-1.13.15-1.20.0.php" hash="2ad0bcf88c745c3c1c135f28dfe5ad65"/></dir></dir></dir></dir></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="kreditor.xml" hash="e97d5f117e2a8ea456fa5867659f6f8d"/></dir><dir name="template"><dir name="kreditor"><dir name="form"><file name="invoice.phtml" hash="36c230b7c294279db70030e11541444a"/><file name="partpayment.phtml" hash="36c230b7c294279db70030e11541444a"/></dir><dir name="info"><file name="invoice.phtml" hash="f09ac94be58efc496f735e818897169d"/><file name="partpayment.phtml" hash="33251dcbdfdb7090b814f5d8040d2f8a"/></dir><dir name="pclass"><file name="matrix.phtml" hash="b0e0d9fd0b8f012acd4696893371f759"/></dir><dir name="sales"><dir name="order"><dir name="totals"><file name="invoicefee.phtml" hash="a12bf50824d3bc393a8a181375553585"/></dir></dir></dir><file name="pclass.phtml" hash="fd2679c8ea5161f4667261fbb89ceaa4"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="kreditor.xml" hash="34d7759fad4a3a75dd9d9ce00400c4d7"/></dir><dir name="template"><dir name="kreditor"><dir name="address"><file name="list.phtml" hash="ed6e78c467504541444dc354e40c0e9c"/></dir><dir name="form"><file name="invoice.phtml" hash="4ecccdcad07a76169b13143fba93aa6d"/><file name="partpayment.phtml" hash="194cc116e1cee117a3243fbd5ab0938e"/></dir><dir name="info"><file name="invoice.phtml" hash="c5ae7dfabc80e03f1ec3368a4f53c9fb"/><file name="partpayment.phtml" hash="559abcfb95250aa18a319b102837b2ea"/></dir><dir name="order"><file name="email_invoice_items.phtml" hash="b24713c795fe43cb639a4978ec8236ab"/><file name="email_items.phtml" hash="623acdc2b8ff94b85503288e4ff3f4fc"/><file name="invoice_items.phtml" hash="df6dfcb78655ca83208afe3db1b9ca53"/><file name="items.phtml" hash="657667cef51d8f9f6e19b7f35a4679ad"/><file name="print_invoice.phtml" hash="38a4f944187086059f1f52042ce2358a"/><file name="print_order.phtml" hash="27efde0e851dc127e2ace9245c079547"/></dir><dir name="product"><file name="price.phtml" hash="33d3f991c4f99b51a17c6ee10e708822"/></dir></dir></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Kreditor_Kreditor.xml" hash="f6f6e7c0f82fb6b792a1058a437ad464"/></dir></dir><dir name="locale"><dir name="da_DK"><file name="Kreditor_Kreditor.csv" hash="0d04572b51bfaa49814bca98bd541222"/></dir><dir name="de_DE"><file name="Kreditor_Kreditor.csv" hash="ce4e55172229453046aa6d5f190b5d46"/></dir><dir name="en_US"><file name="Kreditor_Kreditor.csv" hash="4fa226ba286cb100cb130ff322f884be"/></dir><dir name="fi_FI"><file name="Kreditor_Kreditor.csv" hash="ad02c6e9e224be53975a4011db45648c"/></dir><dir name="nb_NO"><file name="Kreditor_Kreditor.csv" hash="8433462c68b5910e7f7fdc054edc3480"/></dir><dir name="nl_NL"><file name="Kreditor_Kreditor.csv" hash="6cfdb4b53f5096029ac1d8f0fb1b7be5"/></dir><dir name="nn_NO"><file name="Kreditor_Kreditor.csv" hash="8433462c68b5910e7f7fdc054edc3480"/></dir><dir name="sv_SE"><file name="Kreditor_Kreditor.csv" hash="5bac04db711dc98d0a332d11e2859180"/></dir></dir></dir><dir name="skin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="kreditor"><dir name="invoice"><file name="klarna.png" hash="f24c964234b7c30399f854e4a6af4a08"/><file name="logo.png" hash="91c3c941e628a0ad79994e316a1ca725"/><file name="logo_de.gif" hash="2c7b69fcc4bf9953db7f31517db064f1"/><file name="logo_fi.png" hash="5dd18840c2c2531c6d6a726c9fb0cea2"/><file name="logo_no.gif" hash="91c3c941e628a0ad79994e316a1ca725"/><file name="logo_se.gif" hash="91c3c941e628a0ad79994e316a1ca725"/><file name="Thumbs.db" hash="a806ebaddd564b4574617bbb822f3b3e"/></dir><dir name="partpayment"><file name="logo.png" hash="f24c964234b7c30399f854e4a6af4a08"/><file name="logo_de.png" hash="cbfda4edbc5660cbaa9c6fc38259a034"/><file name="logo_fi.png" hash="7d14d7fb95050471ad8436afa27e93e3"/><file name="logo_se.gif" hash="d3be4f0fc8de16380c498f7819f5bd01"/><file name="Thumbs.db" hash="8bfa9daf86186d9a64b840c1af9bc6ab"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="images"><dir name="kreditor"><dir name="invoice"><file name="klarna.png" hash="91c3c941e628a0ad79994e316a1ca725"/><file name="logo.png" hash="91c3c941e628a0ad79994e316a1ca725"/><file name="logo_de.png" hash="2c7b69fcc4bf9953db7f31517db064f1"/><file name="logo_fi.png" hash="5dd18840c2c2531c6d6a726c9fb0cea2"/><file name="logo_nl.png" hash="55479d0b581d2aee68b18c0f75099b98"/></dir><dir name="partpayment"><file name="dutch_credit.jpg" hash="620adf3aeebf2f6ac7ccfa6e0fba39fe"/><file name="logo.png" hash="d3be4f0fc8de16380c498f7819f5bd01"/><file name="logo_de.png" hash="cbfda4edbc5660cbaa9c6fc38259a034"/><file name="logo_fi.png" hash="7d14d7fb95050471ad8436afa27e93e3"/><file name="logo_nl.png" hash="0be858250eccaf1ba45ee5aa639d3595"/></dir><file name="test_mode.png" hash="1799a90ad25b1f2215c79eac8f8c3dd1"/></dir></dir></dir></dir></dir></dir></target></contents>
19
+ <compatible/>
20
+ <dependencies/>
21
+ </package>
skin/adminhtml/default/default/images/kreditor/invoice/Thumbs.db ADDED
Binary file
skin/adminhtml/default/default/images/kreditor/invoice/klarna.png ADDED
Binary file
skin/adminhtml/default/default/images/kreditor/invoice/logo.png ADDED
Binary file
skin/adminhtml/default/default/images/kreditor/invoice/logo_de.gif ADDED
Binary file
skin/adminhtml/default/default/images/kreditor/invoice/logo_fi.png ADDED
Binary file
skin/adminhtml/default/default/images/kreditor/invoice/logo_no.gif ADDED
Binary file
skin/adminhtml/default/default/images/kreditor/invoice/logo_se.gif ADDED
Binary file
skin/adminhtml/default/default/images/kreditor/partpayment/Thumbs.db ADDED
Binary file
skin/adminhtml/default/default/images/kreditor/partpayment/logo.png ADDED
Binary file
skin/adminhtml/default/default/images/kreditor/partpayment/logo_de.png ADDED
Binary file
skin/adminhtml/default/default/images/kreditor/partpayment/logo_fi.png ADDED
Binary file
skin/adminhtml/default/default/images/kreditor/partpayment/logo_se.gif ADDED
Binary file
skin/frontend/default/default/images/kreditor/invoice/klarna.png ADDED
Binary file
skin/frontend/default/default/images/kreditor/invoice/logo.png ADDED
Binary file
skin/frontend/default/default/images/kreditor/invoice/logo_de.png ADDED
Binary file
skin/frontend/default/default/images/kreditor/invoice/logo_fi.png ADDED
Binary file
skin/frontend/default/default/images/kreditor/invoice/logo_nl.png ADDED
Binary file
skin/frontend/default/default/images/kreditor/partpayment/dutch_credit.jpg ADDED
Binary file
skin/frontend/default/default/images/kreditor/partpayment/logo.png ADDED
Binary file
skin/frontend/default/default/images/kreditor/partpayment/logo_de.png ADDED
Binary file
skin/frontend/default/default/images/kreditor/partpayment/logo_fi.png ADDED
Binary file
skin/frontend/default/default/images/kreditor/partpayment/logo_nl.png ADDED
Binary file
skin/frontend/default/default/images/kreditor/test_mode.png ADDED
Binary file