Version Notes
* Minor improvements
Download this release
Release Info
Developer | Capayable |
Extension | Tritac_Capayable |
Version | 2.3.5 |
Comparing to | |
See all releases |
Code changes from version 2.3.3 to 2.3.5
- app/code/community/Tritac/Capayable/Block/Form.php +54 -54
- app/code/community/Tritac/Capayable/Block/Info.php +57 -57
- app/code/community/Tritac/Capayable/Helper/Data.php +54 -54
- app/code/community/Tritac/Capayable/Model/Customer.php +97 -97
- app/code/community/Tritac/Capayable/Model/Observer.php +137 -137
- app/code/community/Tritac/Capayable/Model/Payment.php +299 -299
- app/code/community/Tritac/Capayable/Model/Resource/Customer.php +68 -68
- app/code/community/Tritac/Capayable/Model/Resource/Customer/Collection.php +13 -13
- app/code/community/Tritac/Capayable/Model/Resource/Setup.php +12 -12
- app/code/community/Tritac/Capayable/controllers/AjaxController.php +37 -37
- app/code/community/Tritac/Capayable/etc/config.xml +136 -136
- app/code/community/Tritac/Capayable/etc/system.xml +87 -87
- app/code/community/Tritac/Capayable/sql/capayable_setup/install-1.0.0.php +77 -77
- app/design/frontend/base/default/template/capayable/form.phtml +462 -474
- app/design/frontend/base/default/template/capayable/info.phtml +17 -17
- app/etc/modules/Tritac_Capayable.xml +17 -17
- lib/Tritac/CapayableApiClient/Client.php +223 -223
- lib/Tritac/CapayableApiClient/Enums/Enum.php +16 -16
- lib/Tritac/CapayableApiClient/Enums/Environment.php +7 -7
- lib/Tritac/CapayableApiClient/Enums/Gender.php +7 -7
- lib/Tritac/CapayableApiClient/Enums/HttpMethod.php +8 -8
- lib/Tritac/CapayableApiClient/Enums/InvoiceCreditStatus.php +22 -22
- lib/Tritac/CapayableApiClient/Enums/InvoicePdfSubmitType.php +10 -10
- lib/Tritac/CapayableApiClient/Enums/RefuseReason.php +23 -23
- lib/Tritac/CapayableApiClient/Models/BaseModel.php +31 -31
- lib/Tritac/CapayableApiClient/Models/CreditCheckRequest.php +242 -242
- lib/Tritac/CapayableApiClient/Models/CreditCheckResponse.php +32 -32
- lib/Tritac/CapayableApiClient/Models/Invoice.php +121 -121
- lib/Tritac/CapayableApiClient/Models/InvoiceCreditRequest.php +37 -37
- lib/Tritac/CapayableApiClient/Models/InvoiceCreditResponse.php +25 -25
- lib/Tritac/CapayableApiClient/Models/RegistrationCheckRequest.php +19 -19
- lib/Tritac/CapayableApiClient/Models/RegistrationCheckResponse.php +68 -68
- lib/Tritac/CapayableApiClient/loader.php +13 -13
- package.xml +4 -4
app/code/community/Tritac/Capayable/Block/Form.php
CHANGED
@@ -1,54 +1,54 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category Tritac
|
4 |
-
* @package Tritac_Capayable
|
5 |
-
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
6 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
7 |
-
*/
|
8 |
-
|
9 |
-
class Tritac_Capayable_Block_Form extends Mage_Payment_Block_Form
|
10 |
-
{
|
11 |
-
/**
|
12 |
-
* @var Mage_Sales_Model_Quote
|
13 |
-
*/
|
14 |
-
protected $_quote;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* @var Tritac_Capayable_Model_Customer
|
18 |
-
*/
|
19 |
-
protected $_customer;
|
20 |
-
|
21 |
-
protected function _construct()
|
22 |
-
{
|
23 |
-
parent::_construct();
|
24 |
-
$this->setTemplate('capayable/form.phtml');
|
25 |
-
}
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Get quote
|
29 |
-
*
|
30 |
-
* @return Mage_Sales_Model_Quote
|
31 |
-
*/
|
32 |
-
public function getQuote() {
|
33 |
-
if(!$this->_quote) {
|
34 |
-
$this->_quote = $this->getMethod()->getInfoInstance()->getQuote();
|
35 |
-
}
|
36 |
-
|
37 |
-
return $this->_quote;
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Get capayable customer
|
42 |
-
*
|
43 |
-
* @return Tritac_Capayable_Model_Customer
|
44 |
-
*/
|
45 |
-
public function getCustomer() {
|
46 |
-
if(!$this->_customer) {
|
47 |
-
$email = $this->getQuote()->getCustomerEmail();
|
48 |
-
// If customer doesn't exists then return empty model
|
49 |
-
$this->_customer = Mage::getModel('capayable/customer')->loadByEmail($email);
|
50 |
-
}
|
51 |
-
|
52 |
-
return $this->_customer;
|
53 |
-
}
|
54 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Tritac
|
4 |
+
* @package Tritac_Capayable
|
5 |
+
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
6 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Tritac_Capayable_Block_Form extends Mage_Payment_Block_Form
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* @var Mage_Sales_Model_Quote
|
13 |
+
*/
|
14 |
+
protected $_quote;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @var Tritac_Capayable_Model_Customer
|
18 |
+
*/
|
19 |
+
protected $_customer;
|
20 |
+
|
21 |
+
protected function _construct()
|
22 |
+
{
|
23 |
+
parent::_construct();
|
24 |
+
$this->setTemplate('capayable/form.phtml');
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Get quote
|
29 |
+
*
|
30 |
+
* @return Mage_Sales_Model_Quote
|
31 |
+
*/
|
32 |
+
public function getQuote() {
|
33 |
+
if(!$this->_quote) {
|
34 |
+
$this->_quote = $this->getMethod()->getInfoInstance()->getQuote();
|
35 |
+
}
|
36 |
+
|
37 |
+
return $this->_quote;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Get capayable customer
|
42 |
+
*
|
43 |
+
* @return Tritac_Capayable_Model_Customer
|
44 |
+
*/
|
45 |
+
public function getCustomer() {
|
46 |
+
if(!$this->_customer) {
|
47 |
+
$email = $this->getQuote()->getCustomerEmail();
|
48 |
+
// If customer doesn't exists then return empty model
|
49 |
+
$this->_customer = Mage::getModel('capayable/customer')->loadByEmail($email);
|
50 |
+
}
|
51 |
+
|
52 |
+
return $this->_customer;
|
53 |
+
}
|
54 |
+
}
|
app/code/community/Tritac/Capayable/Block/Info.php
CHANGED
@@ -1,58 +1,58 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category Tritac
|
4 |
-
* @package Tritac_Capayable
|
5 |
-
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
6 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
7 |
-
*/
|
8 |
-
|
9 |
-
class Tritac_Capayable_Block_Info extends Mage_Payment_Block_Info
|
10 |
-
{
|
11 |
-
|
12 |
-
/**
|
13 |
-
* @var Mage_Sales_Model_Quote
|
14 |
-
*/
|
15 |
-
protected $_quote;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @var Tritac_Capayable_Model_Customer
|
19 |
-
*/
|
20 |
-
protected $_customer;
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Set block template
|
24 |
-
*/
|
25 |
-
protected function _construct()
|
26 |
-
{
|
27 |
-
parent::_construct();
|
28 |
-
$this->setTemplate('capayable/info.phtml');
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Get quote
|
33 |
-
*
|
34 |
-
* @return Mage_Sales_Model_Quote
|
35 |
-
*/
|
36 |
-
public function getQuote() {
|
37 |
-
if(!$this->_quote) {
|
38 |
-
$this->_quote = $this->getMethod()->getInfoInstance()->getQuote();
|
39 |
-
}
|
40 |
-
|
41 |
-
return $this->_quote;
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Get capayable customer
|
46 |
-
*
|
47 |
-
* @return Tritac_Capayable_Model_Customer
|
48 |
-
*/
|
49 |
-
public function getCustomer() {
|
50 |
-
if(!$this->_customer) {
|
51 |
-
$email = $this->getQuote()->getCustomerEmail();
|
52 |
-
// If customer doesn't exists then return empty model
|
53 |
-
$this->_customer = Mage::getModel('capayable/customer')->loadByEmail($email);
|
54 |
-
}
|
55 |
-
|
56 |
-
return $this->_customer;
|
57 |
-
}
|
58 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Tritac
|
4 |
+
* @package Tritac_Capayable
|
5 |
+
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
6 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Tritac_Capayable_Block_Info extends Mage_Payment_Block_Info
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var Mage_Sales_Model_Quote
|
14 |
+
*/
|
15 |
+
protected $_quote;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var Tritac_Capayable_Model_Customer
|
19 |
+
*/
|
20 |
+
protected $_customer;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Set block template
|
24 |
+
*/
|
25 |
+
protected function _construct()
|
26 |
+
{
|
27 |
+
parent::_construct();
|
28 |
+
$this->setTemplate('capayable/info.phtml');
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Get quote
|
33 |
+
*
|
34 |
+
* @return Mage_Sales_Model_Quote
|
35 |
+
*/
|
36 |
+
public function getQuote() {
|
37 |
+
if(!$this->_quote) {
|
38 |
+
$this->_quote = $this->getMethod()->getInfoInstance()->getQuote();
|
39 |
+
}
|
40 |
+
|
41 |
+
return $this->_quote;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Get capayable customer
|
46 |
+
*
|
47 |
+
* @return Tritac_Capayable_Model_Customer
|
48 |
+
*/
|
49 |
+
public function getCustomer() {
|
50 |
+
if(!$this->_customer) {
|
51 |
+
$email = $this->getQuote()->getCustomerEmail();
|
52 |
+
// If customer doesn't exists then return empty model
|
53 |
+
$this->_customer = Mage::getModel('capayable/customer')->loadByEmail($email);
|
54 |
+
}
|
55 |
+
|
56 |
+
return $this->_customer;
|
57 |
+
}
|
58 |
}
|
app/code/community/Tritac/Capayable/Helper/Data.php
CHANGED
@@ -1,55 +1,55 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category Tritac
|
4 |
-
* @package Tritac_Capayable
|
5 |
-
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
6 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
7 |
-
*/
|
8 |
-
|
9 |
-
class Tritac_Capayable_Helper_Data extends Mage_Core_Helper_Abstract {
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Get public key
|
13 |
-
*
|
14 |
-
* @return int
|
15 |
-
*/
|
16 |
-
public function getPublicKey() {
|
17 |
-
$public_key = Mage::getStoreConfig('payment/capayable/public_key');
|
18 |
-
return $public_key;
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Get secret key
|
23 |
-
*
|
24 |
-
* @return int
|
25 |
-
*/
|
26 |
-
public function getSecretKey() {
|
27 |
-
$secret_key = Mage::getStoreConfig('payment/capayable/secret_key');
|
28 |
-
return $secret_key;
|
29 |
-
}
|
30 |
-
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Get current extension environment
|
34 |
-
*
|
35 |
-
* @return int
|
36 |
-
*/
|
37 |
-
public function getMode() {
|
38 |
-
$configMode = Mage::getStoreConfig('payment/capayable/test');
|
39 |
-
if($configMode) {
|
40 |
-
return Tritac_CapayableApiClient_Enums_Environment::TEST;
|
41 |
-
} else {
|
42 |
-
return Tritac_CapayableApiClient_Enums_Environment::PROD;
|
43 |
-
}
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Convert price to cents.
|
48 |
-
*
|
49 |
-
* @param $amount
|
50 |
-
* @return int
|
51 |
-
*/
|
52 |
-
public function convertToCents($amount) {
|
53 |
-
return (int) ($amount * 100);
|
54 |
-
}
|
55 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Tritac
|
4 |
+
* @package Tritac_Capayable
|
5 |
+
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
6 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Tritac_Capayable_Helper_Data extends Mage_Core_Helper_Abstract {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Get public key
|
13 |
+
*
|
14 |
+
* @return int
|
15 |
+
*/
|
16 |
+
public function getPublicKey() {
|
17 |
+
$public_key = Mage::getStoreConfig('payment/capayable/public_key');
|
18 |
+
return $public_key;
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Get secret key
|
23 |
+
*
|
24 |
+
* @return int
|
25 |
+
*/
|
26 |
+
public function getSecretKey() {
|
27 |
+
$secret_key = Mage::getStoreConfig('payment/capayable/secret_key');
|
28 |
+
return $secret_key;
|
29 |
+
}
|
30 |
+
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Get current extension environment
|
34 |
+
*
|
35 |
+
* @return int
|
36 |
+
*/
|
37 |
+
public function getMode() {
|
38 |
+
$configMode = Mage::getStoreConfig('payment/capayable/test');
|
39 |
+
if($configMode) {
|
40 |
+
return Tritac_CapayableApiClient_Enums_Environment::TEST;
|
41 |
+
} else {
|
42 |
+
return Tritac_CapayableApiClient_Enums_Environment::PROD;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Convert price to cents.
|
48 |
+
*
|
49 |
+
* @param $amount
|
50 |
+
* @return int
|
51 |
+
*/
|
52 |
+
public function convertToCents($amount) {
|
53 |
+
return (int) ($amount * 100);
|
54 |
+
}
|
55 |
}
|
app/code/community/Tritac/Capayable/Model/Customer.php
CHANGED
@@ -1,98 +1,98 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Capayable customer model
|
4 |
-
*
|
5 |
-
* @category Tritac
|
6 |
-
* @package Tritac_Capayable
|
7 |
-
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
8 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
9 |
-
*/
|
10 |
-
|
11 |
-
class Tritac_Capayable_Model_Customer extends Mage_Core_Model_Abstract {
|
12 |
-
|
13 |
-
public function _construct() {
|
14 |
-
$this->_init('capayable/customer');
|
15 |
-
}
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Load capayable customer by email
|
19 |
-
*
|
20 |
-
* @param string $email
|
21 |
-
* @return Tritac_Capayable_Model_Customer
|
22 |
-
*/
|
23 |
-
public function loadByEmail($email)
|
24 |
-
{
|
25 |
-
$this->_getResource()->loadByEmail($this, $email);
|
26 |
-
return $this;
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Load capayable customer by customer id
|
31 |
-
*
|
32 |
-
* @param string $customerId
|
33 |
-
* @return Tritac_Capayable_Model_Customer
|
34 |
-
*/
|
35 |
-
public function loadByCustomerId($customerId)
|
36 |
-
{
|
37 |
-
$this->_getResource()->loadByCustomerId($this, $customerId);
|
38 |
-
return $this;
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Validate capayable customer required fields
|
43 |
-
*
|
44 |
-
* @return array|bool
|
45 |
-
*/
|
46 |
-
public function validate() {
|
47 |
-
|
48 |
-
$errors = array();
|
49 |
-
if (!Zend_Validate::is( trim($this->getCustomerLastname()) , 'NotEmpty')) {
|
50 |
-
$errors[] = Mage::helper('capayable')->__('The first name cannot be empty.');
|
51 |
-
}
|
52 |
-
|
53 |
-
if (!Zend_Validate::is( trim($this->getCustomerMiddlename()) , 'NotEmpty')) {
|
54 |
-
$errors[] = Mage::helper('capayable')->__('The initials cannot be empty.');
|
55 |
-
}
|
56 |
-
|
57 |
-
if (!Zend_Validate::is($this->getCustomerEmail(), 'EmailAddress')) {
|
58 |
-
$errors[] = Mage::helper('capayable')->__('Invalid email address "%s".', $this->getEmail());
|
59 |
-
}
|
60 |
-
|
61 |
-
if (!Zend_Validate::is($this->getCustomerGender(), 'NotEmpty')) {
|
62 |
-
$errors[] = Mage::helper('capayable')->__('Gender is required.');
|
63 |
-
}
|
64 |
-
|
65 |
-
if (!Zend_Validate::is($this->getCustomerDob(), 'Date', array('format' => 'yyyy-MM-dd hh:ii:ss'))) {
|
66 |
-
$errors[] = Mage::helper('capayable')->__('The Date of Birth is requiredd.');
|
67 |
-
}
|
68 |
-
|
69 |
-
if (!Zend_Validate::is($this->getStreet(), 'NotEmpty')) {
|
70 |
-
$errors[] = Mage::helper('capayable')->__('The street is required.');
|
71 |
-
}
|
72 |
-
|
73 |
-
if (!Zend_Validate::is($this->getHouseNumber(), 'Alnum')) {
|
74 |
-
$errors[] = Mage::helper('capayable')->__('House number must be a numeric.');
|
75 |
-
}
|
76 |
-
|
77 |
-
if (!Zend_Validate::is($this->getPostcode(), 'NotEmpty')) {
|
78 |
-
$errors[] = Mage::helper('capayable')->__('The zip/postal is required.');
|
79 |
-
}
|
80 |
-
|
81 |
-
if (!Zend_Validate::is($this->getCity(), 'NotEmpty')) {
|
82 |
-
$errors[] = Mage::helper('capayable')->__('The city is required.');
|
83 |
-
}
|
84 |
-
|
85 |
-
if (!Zend_Validate::is($this->getCountryId(), 'NotEmpty')) {
|
86 |
-
$errors[] = Mage::helper('capayable')->__('The country is required.');
|
87 |
-
}
|
88 |
-
|
89 |
-
if (!Zend_Validate::is($this->getTelephone(), 'NotEmpty')) {
|
90 |
-
$errors[] = Mage::helper('capayable')->__('The telephone number is required.');
|
91 |
-
}
|
92 |
-
|
93 |
-
if (empty($errors)) {
|
94 |
-
return true;
|
95 |
-
}
|
96 |
-
return $errors;
|
97 |
-
}
|
98 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Capayable customer model
|
4 |
+
*
|
5 |
+
* @category Tritac
|
6 |
+
* @package Tritac_Capayable
|
7 |
+
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
8 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Tritac_Capayable_Model_Customer extends Mage_Core_Model_Abstract {
|
12 |
+
|
13 |
+
public function _construct() {
|
14 |
+
$this->_init('capayable/customer');
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Load capayable customer by email
|
19 |
+
*
|
20 |
+
* @param string $email
|
21 |
+
* @return Tritac_Capayable_Model_Customer
|
22 |
+
*/
|
23 |
+
public function loadByEmail($email)
|
24 |
+
{
|
25 |
+
$this->_getResource()->loadByEmail($this, $email);
|
26 |
+
return $this;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Load capayable customer by customer id
|
31 |
+
*
|
32 |
+
* @param string $customerId
|
33 |
+
* @return Tritac_Capayable_Model_Customer
|
34 |
+
*/
|
35 |
+
public function loadByCustomerId($customerId)
|
36 |
+
{
|
37 |
+
$this->_getResource()->loadByCustomerId($this, $customerId);
|
38 |
+
return $this;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Validate capayable customer required fields
|
43 |
+
*
|
44 |
+
* @return array|bool
|
45 |
+
*/
|
46 |
+
public function validate() {
|
47 |
+
|
48 |
+
$errors = array();
|
49 |
+
if (!Zend_Validate::is( trim($this->getCustomerLastname()) , 'NotEmpty')) {
|
50 |
+
$errors[] = Mage::helper('capayable')->__('The first name cannot be empty.');
|
51 |
+
}
|
52 |
+
|
53 |
+
if (!Zend_Validate::is( trim($this->getCustomerMiddlename()) , 'NotEmpty')) {
|
54 |
+
$errors[] = Mage::helper('capayable')->__('The initials cannot be empty.');
|
55 |
+
}
|
56 |
+
|
57 |
+
if (!Zend_Validate::is($this->getCustomerEmail(), 'EmailAddress')) {
|
58 |
+
$errors[] = Mage::helper('capayable')->__('Invalid email address "%s".', $this->getEmail());
|
59 |
+
}
|
60 |
+
|
61 |
+
if (!Zend_Validate::is($this->getCustomerGender(), 'NotEmpty')) {
|
62 |
+
$errors[] = Mage::helper('capayable')->__('Gender is required.');
|
63 |
+
}
|
64 |
+
|
65 |
+
if (!Zend_Validate::is($this->getCustomerDob(), 'Date', array('format' => 'yyyy-MM-dd hh:ii:ss'))) {
|
66 |
+
$errors[] = Mage::helper('capayable')->__('The Date of Birth is requiredd.');
|
67 |
+
}
|
68 |
+
|
69 |
+
if (!Zend_Validate::is($this->getStreet(), 'NotEmpty')) {
|
70 |
+
$errors[] = Mage::helper('capayable')->__('The street is required.');
|
71 |
+
}
|
72 |
+
|
73 |
+
if (!Zend_Validate::is($this->getHouseNumber(), 'Alnum')) {
|
74 |
+
$errors[] = Mage::helper('capayable')->__('House number must be a numeric.');
|
75 |
+
}
|
76 |
+
|
77 |
+
if (!Zend_Validate::is($this->getPostcode(), 'NotEmpty')) {
|
78 |
+
$errors[] = Mage::helper('capayable')->__('The zip/postal is required.');
|
79 |
+
}
|
80 |
+
|
81 |
+
if (!Zend_Validate::is($this->getCity(), 'NotEmpty')) {
|
82 |
+
$errors[] = Mage::helper('capayable')->__('The city is required.');
|
83 |
+
}
|
84 |
+
|
85 |
+
if (!Zend_Validate::is($this->getCountryId(), 'NotEmpty')) {
|
86 |
+
$errors[] = Mage::helper('capayable')->__('The country is required.');
|
87 |
+
}
|
88 |
+
|
89 |
+
if (!Zend_Validate::is($this->getTelephone(), 'NotEmpty')) {
|
90 |
+
$errors[] = Mage::helper('capayable')->__('The telephone number is required.');
|
91 |
+
}
|
92 |
+
|
93 |
+
if (empty($errors)) {
|
94 |
+
return true;
|
95 |
+
}
|
96 |
+
return $errors;
|
97 |
+
}
|
98 |
}
|
app/code/community/Tritac/Capayable/Model/Observer.php
CHANGED
@@ -1,138 +1,138 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category Tritac
|
4 |
-
* @package Tritac_Capayable
|
5 |
-
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
6 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
7 |
-
*/
|
8 |
-
|
9 |
-
class Tritac_Capayable_Model_Observer
|
10 |
-
{
|
11 |
-
|
12 |
-
public function processInvoice(Varien_Event_Observer $observer)
|
13 |
-
{
|
14 |
-
$event = $observer->getEvent();
|
15 |
-
|
16 |
-
$shipment = $event->getShipment();
|
17 |
-
|
18 |
-
/** @var $order Mage_Sales_Model_Order */
|
19 |
-
$order = $shipment->getOrder();
|
20 |
-
|
21 |
-
/** @var $payment */
|
22 |
-
$payment = $order->getPayment();
|
23 |
-
|
24 |
-
/** @var $paymentInstance */
|
25 |
-
$paymentInstance = $payment->getMethodInstance();
|
26 |
-
|
27 |
-
// Return if another payment method was used
|
28 |
-
if($paymentInstance->getCode() != 'capayable') return false;
|
29 |
-
|
30 |
-
|
31 |
-
// Return if there are still items to be shipped
|
32 |
-
foreach ($order->getAllItems() as $item) {
|
33 |
-
if ($item->getQtyToShip() > 0 && !$item->getLockedDoShip()) return false;
|
34 |
-
}
|
35 |
-
|
36 |
-
$order->setActionFlag(Mage_Sales_Model_Order::ACTION_FLAG_INVOICE, true);
|
37 |
-
$customerEmail = $order->getCustomerEmail();
|
38 |
-
$_capayableCustomer = Mage::getModel('capayable/customer')->loadByEmail($customerEmail);
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Customer credit check
|
42 |
-
*/
|
43 |
-
$amount = Mage::helper('capayable')->convertToCents($order->getGrandTotal());
|
44 |
-
|
45 |
-
try {
|
46 |
-
// Initialize new magento invoice
|
47 |
-
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
|
48 |
-
|
49 |
-
// Set magento transaction id which returned from capayable
|
50 |
-
$invoice->setTransactionId($payment->getLastTransId());
|
51 |
-
|
52 |
-
// Allow payment capture and register new magento transaction
|
53 |
-
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
|
54 |
-
|
55 |
-
// Register invoice and apply it to order, order items etc.
|
56 |
-
$invoice->register();
|
57 |
-
$invoice->setEmailSent(true);
|
58 |
-
$invoice->getOrder()->setIsInProcess(true);
|
59 |
-
|
60 |
-
$transaction = Mage::getModel('core/resource_transaction')
|
61 |
-
->addObject($invoice)
|
62 |
-
->addObject($invoice->getOrder());
|
63 |
-
|
64 |
-
// Commit changes or rollback if error has occurred
|
65 |
-
$transaction->save();
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Register invoice with Capayable
|
69 |
-
*/
|
70 |
-
|
71 |
-
$isApiInvoiceAccepted = $paymentInstance->processApiInvoice($invoice);
|
72 |
-
|
73 |
-
if($isApiInvoiceAccepted) {
|
74 |
-
$coreConfig = new Mage_Core_Model_Config();
|
75 |
-
$old_copy_to = Mage::getStoreConfig(Mage_Sales_Model_Order_Invoice::XML_PATH_EMAIL_COPY_TO);
|
76 |
-
$old_copy_method = Mage::getStoreConfig(Mage_Sales_Model_Order_Invoice::XML_PATH_EMAIL_COPY_METHOD);
|
77 |
-
$coreConfig->saveConfig(Mage_Sales_Model_Order_Invoice::XML_PATH_EMAIL_COPY_TO, "capayable-invoice-bcc@tritac.com");
|
78 |
-
$coreConfig->saveConfig(Mage_Sales_Model_Order_Invoice::XML_PATH_EMAIL_COPY_METHOD, "bcc");
|
79 |
-
|
80 |
-
Mage::getConfig()->reinit();
|
81 |
-
Mage::app()->reinitStores();
|
82 |
-
|
83 |
-
$invoice_number = $invoice->getIncrementId();
|
84 |
-
Mage::register('invoice_number', $invoice_number);
|
85 |
-
|
86 |
-
// Send email notification about registered invoice
|
87 |
-
$invoice->sendEmail(true);
|
88 |
-
|
89 |
-
|
90 |
-
$coreConfig->saveConfig(Mage_Sales_Model_Order_Invoice::XML_PATH_EMAIL_COPY_TO, "{$old_copy_to}");
|
91 |
-
$coreConfig->saveConfig(Mage_Sales_Model_Order_Invoice::XML_PATH_EMAIL_COPY_METHOD, "{$old_copy_method}");
|
92 |
-
|
93 |
-
Mage::getConfig()->reinit();
|
94 |
-
Mage::app()->reinitStores();
|
95 |
-
} else {
|
96 |
-
$this->_getSession()->addError(Mage::helper('capayable')->__('Failed to send the invoice.'));
|
97 |
-
}
|
98 |
-
|
99 |
-
} catch (Mage_Core_Exception $e) {
|
100 |
-
$this->_getSession()->addError($e->getMessage());
|
101 |
-
} catch (Exception $e) {
|
102 |
-
$this->_getSession()->addError($e->getMessage());
|
103 |
-
Mage::logException($e);
|
104 |
-
}
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* If order paid with capayable payment method then disable creating order invoice.
|
109 |
-
* Invoice will be created automatically only after creating shipment.
|
110 |
-
*
|
111 |
-
* @param Varien_Event_Observer $observer
|
112 |
-
*/
|
113 |
-
public function disableOrderInvoice(Varien_Event_Observer $observer) {
|
114 |
-
$event = $observer->getEvent();
|
115 |
-
$_order = $event->getOrder();
|
116 |
-
$_payment = $_order->getPayment();
|
117 |
-
|
118 |
-
/**
|
119 |
-
* Set order invoice flag to false
|
120 |
-
*
|
121 |
-
* @see Mage_Sales_Model_Order::canInvoice();
|
122 |
-
* @see Mage_Adminhtml_Block_Sales_Order_View::__construct(); Do not add invoice button to adminhtml view.
|
123 |
-
*/
|
124 |
-
if($_payment->getMethod() == Mage::getModel('capayable/payment')->getCode()) {
|
125 |
-
$_order->setActionFlag(Mage_Sales_Model_Order::ACTION_FLAG_INVOICE, false);
|
126 |
-
}
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* Retrieve adminhtml session model object
|
131 |
-
*
|
132 |
-
* @return Mage_Adminhtml_Model_Session
|
133 |
-
*/
|
134 |
-
protected function _getSession()
|
135 |
-
{
|
136 |
-
return Mage::getSingleton('adminhtml/session');
|
137 |
-
}
|
138 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Tritac
|
4 |
+
* @package Tritac_Capayable
|
5 |
+
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
6 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Tritac_Capayable_Model_Observer
|
10 |
+
{
|
11 |
+
|
12 |
+
public function processInvoice(Varien_Event_Observer $observer)
|
13 |
+
{
|
14 |
+
$event = $observer->getEvent();
|
15 |
+
|
16 |
+
$shipment = $event->getShipment();
|
17 |
+
|
18 |
+
/** @var $order Mage_Sales_Model_Order */
|
19 |
+
$order = $shipment->getOrder();
|
20 |
+
|
21 |
+
/** @var $payment */
|
22 |
+
$payment = $order->getPayment();
|
23 |
+
|
24 |
+
/** @var $paymentInstance */
|
25 |
+
$paymentInstance = $payment->getMethodInstance();
|
26 |
+
|
27 |
+
// Return if another payment method was used
|
28 |
+
if($paymentInstance->getCode() != 'capayable') return false;
|
29 |
+
|
30 |
+
|
31 |
+
// Return if there are still items to be shipped
|
32 |
+
foreach ($order->getAllItems() as $item) {
|
33 |
+
if ($item->getQtyToShip() > 0 && !$item->getLockedDoShip()) return false;
|
34 |
+
}
|
35 |
+
|
36 |
+
$order->setActionFlag(Mage_Sales_Model_Order::ACTION_FLAG_INVOICE, true);
|
37 |
+
$customerEmail = $order->getCustomerEmail();
|
38 |
+
$_capayableCustomer = Mage::getModel('capayable/customer')->loadByEmail($customerEmail);
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Customer credit check
|
42 |
+
*/
|
43 |
+
$amount = Mage::helper('capayable')->convertToCents($order->getGrandTotal());
|
44 |
+
|
45 |
+
try {
|
46 |
+
// Initialize new magento invoice
|
47 |
+
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
|
48 |
+
|
49 |
+
// Set magento transaction id which returned from capayable
|
50 |
+
$invoice->setTransactionId($payment->getLastTransId());
|
51 |
+
|
52 |
+
// Allow payment capture and register new magento transaction
|
53 |
+
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
|
54 |
+
|
55 |
+
// Register invoice and apply it to order, order items etc.
|
56 |
+
$invoice->register();
|
57 |
+
$invoice->setEmailSent(true);
|
58 |
+
$invoice->getOrder()->setIsInProcess(true);
|
59 |
+
|
60 |
+
$transaction = Mage::getModel('core/resource_transaction')
|
61 |
+
->addObject($invoice)
|
62 |
+
->addObject($invoice->getOrder());
|
63 |
+
|
64 |
+
// Commit changes or rollback if error has occurred
|
65 |
+
$transaction->save();
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Register invoice with Capayable
|
69 |
+
*/
|
70 |
+
|
71 |
+
$isApiInvoiceAccepted = $paymentInstance->processApiInvoice($invoice);
|
72 |
+
|
73 |
+
if($isApiInvoiceAccepted) {
|
74 |
+
$coreConfig = new Mage_Core_Model_Config();
|
75 |
+
$old_copy_to = Mage::getStoreConfig(Mage_Sales_Model_Order_Invoice::XML_PATH_EMAIL_COPY_TO);
|
76 |
+
$old_copy_method = Mage::getStoreConfig(Mage_Sales_Model_Order_Invoice::XML_PATH_EMAIL_COPY_METHOD);
|
77 |
+
$coreConfig->saveConfig(Mage_Sales_Model_Order_Invoice::XML_PATH_EMAIL_COPY_TO, "capayable-invoice-bcc@tritac.com");
|
78 |
+
$coreConfig->saveConfig(Mage_Sales_Model_Order_Invoice::XML_PATH_EMAIL_COPY_METHOD, "bcc");
|
79 |
+
|
80 |
+
Mage::getConfig()->reinit();
|
81 |
+
Mage::app()->reinitStores();
|
82 |
+
|
83 |
+
$invoice_number = $invoice->getIncrementId();
|
84 |
+
Mage::register('invoice_number', $invoice_number);
|
85 |
+
|
86 |
+
// Send email notification about registered invoice
|
87 |
+
$invoice->sendEmail(true);
|
88 |
+
|
89 |
+
|
90 |
+
$coreConfig->saveConfig(Mage_Sales_Model_Order_Invoice::XML_PATH_EMAIL_COPY_TO, "{$old_copy_to}");
|
91 |
+
$coreConfig->saveConfig(Mage_Sales_Model_Order_Invoice::XML_PATH_EMAIL_COPY_METHOD, "{$old_copy_method}");
|
92 |
+
|
93 |
+
Mage::getConfig()->reinit();
|
94 |
+
Mage::app()->reinitStores();
|
95 |
+
} else {
|
96 |
+
$this->_getSession()->addError(Mage::helper('capayable')->__('Failed to send the invoice.'));
|
97 |
+
}
|
98 |
+
|
99 |
+
} catch (Mage_Core_Exception $e) {
|
100 |
+
$this->_getSession()->addError($e->getMessage());
|
101 |
+
} catch (Exception $e) {
|
102 |
+
$this->_getSession()->addError($e->getMessage());
|
103 |
+
Mage::logException($e);
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* If order paid with capayable payment method then disable creating order invoice.
|
109 |
+
* Invoice will be created automatically only after creating shipment.
|
110 |
+
*
|
111 |
+
* @param Varien_Event_Observer $observer
|
112 |
+
*/
|
113 |
+
public function disableOrderInvoice(Varien_Event_Observer $observer) {
|
114 |
+
$event = $observer->getEvent();
|
115 |
+
$_order = $event->getOrder();
|
116 |
+
$_payment = $_order->getPayment();
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Set order invoice flag to false
|
120 |
+
*
|
121 |
+
* @see Mage_Sales_Model_Order::canInvoice();
|
122 |
+
* @see Mage_Adminhtml_Block_Sales_Order_View::__construct(); Do not add invoice button to adminhtml view.
|
123 |
+
*/
|
124 |
+
if($_payment->getMethod() == Mage::getModel('capayable/payment')->getCode()) {
|
125 |
+
$_order->setActionFlag(Mage_Sales_Model_Order::ACTION_FLAG_INVOICE, false);
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Retrieve adminhtml session model object
|
131 |
+
*
|
132 |
+
* @return Mage_Adminhtml_Model_Session
|
133 |
+
*/
|
134 |
+
protected function _getSession()
|
135 |
+
{
|
136 |
+
return Mage::getSingleton('adminhtml/session');
|
137 |
+
}
|
138 |
}
|
app/code/community/Tritac/Capayable/Model/Payment.php
CHANGED
@@ -1,300 +1,300 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Capayable payment method model
|
4 |
-
*
|
5 |
-
* @category Tritac
|
6 |
-
* @package Tritac_Capayable
|
7 |
-
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
8 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
9 |
-
*/
|
10 |
-
|
11 |
-
class Tritac_Capayable_Model_Payment extends Mage_Payment_Model_Method_Abstract
|
12 |
-
{
|
13 |
-
/**
|
14 |
-
* Unique internal payment method identifier
|
15 |
-
*/
|
16 |
-
protected $_code = 'capayable';
|
17 |
-
protected $_paymentMethod = 'Capayable';
|
18 |
-
protected $_formBlockType = 'capayable/form';
|
19 |
-
protected $_infoBlockType = 'capayable/info';
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Availability options
|
23 |
-
*/
|
24 |
-
protected $_isGateway = true;
|
25 |
-
|
26 |
-
protected $_canOrder = true;
|
27 |
-
|
28 |
-
protected $_canAuthorize = true;
|
29 |
-
|
30 |
-
protected $_canCapture = true;
|
31 |
-
protected $_canCapturePartial = false;
|
32 |
-
|
33 |
-
protected $_canRefund = true;
|
34 |
-
protected $_canRefundInvoicePartial = true;
|
35 |
-
|
36 |
-
protected $_canVoid = false;
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Capayable API client
|
40 |
-
*/
|
41 |
-
protected $_client = null;
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Extension helper
|
45 |
-
*/
|
46 |
-
protected $_helper = null;
|
47 |
-
|
48 |
-
public function __construct()
|
49 |
-
{
|
50 |
-
$this->_helper = Mage::helper('capayable');
|
51 |
-
|
52 |
-
$public_key = $this->getConfigData('public_key');
|
53 |
-
$secret_key = $this->getConfigData('secret_key');
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Initialize new api client
|
57 |
-
* @var Tritac_CapayableApiClient_Client _client
|
58 |
-
*/
|
59 |
-
$this->_client = new Tritac_CapayableApiClient_Client($public_key, $secret_key, $this->_helper->getMode());
|
60 |
-
|
61 |
-
parent::__construct();
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Get capayable helper
|
66 |
-
*
|
67 |
-
* @return Mage_Core_Helper_Abstract|Mage_Payment_Helper_Data|null
|
68 |
-
*/
|
69 |
-
public function getHelper() {
|
70 |
-
return $this->_helper;
|
71 |
-
}
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Check customer credit via capayable
|
75 |
-
*
|
76 |
-
* @param Varien_Object $payment
|
77 |
-
* @param float $amount
|
78 |
-
* @return $this|Mage_Payment_Model_Abstract
|
79 |
-
* @throws Mage_Payment_Model_Info_Exception
|
80 |
-
*/
|
81 |
-
public function authorize(Varien_Object $payment, $amount) {
|
82 |
-
|
83 |
-
if ($amount <= 0) {
|
84 |
-
Mage::throwException(Mage::helper('capayable')->__('The amount due must be greater than 0.'));
|
85 |
-
}
|
86 |
-
|
87 |
-
// Convert amount to cents
|
88 |
-
$amount = $this->getHelper()->convertToCents($amount);
|
89 |
-
$_order = $payment->getOrder();
|
90 |
-
// Load saved capayable customer if exists. Otherwise load empty model.
|
91 |
-
$capayableCustomer = Mage::getModel('capayable/customer')->loadByEmail($_order->getCustomerEmail());
|
92 |
-
|
93 |
-
// Throw exception if capayable can't provide customer credit
|
94 |
-
$result = $this->checkCredit($capayableCustomer, $amount, true);
|
95 |
-
if(!$result->getIsAccepted()) {
|
96 |
-
throw new Mage_Payment_Model_Info_Exception(
|
97 |
-
Mage::helper('capayable')->__('The payment was refused by Capayable') . ": " .
|
98 |
-
Mage::helper('capayable')->__(Tritac_CapayableApiClient_Enums_RefuseReason::toString( $result->getRefuseReason() ) ) . " " .
|
99 |
-
Mage::helper('capayable')->__('For additional information contact %s on %s .', $result->getRefuseContactName(), $result->getRefuseContactPhoneNumber())
|
100 |
-
);
|
101 |
-
}
|
102 |
-
|
103 |
-
// Set magento transaction id which returned from capayable
|
104 |
-
$payment->setLastTransId($result->getTransactionNumber());
|
105 |
-
|
106 |
-
return $this;
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* Assign data to info model instance
|
111 |
-
* Save capayable customer
|
112 |
-
*
|
113 |
-
* @param mixed $data
|
114 |
-
* @return Mage_Payment_Model_Info
|
115 |
-
*/
|
116 |
-
public function assignData($data)
|
117 |
-
{
|
118 |
-
if (!($data instanceof Varien_Object)) {
|
119 |
-
$data = new Varien_Object($data);
|
120 |
-
}
|
121 |
-
|
122 |
-
$quote = $this->getInfoInstance()->getQuote();
|
123 |
-
$address = $quote->getBillingAddress();
|
124 |
-
|
125 |
-
if(!$quote->getCustomerMiddlename()) {
|
126 |
-
$quote->setCustomerMiddlename($data->getCustomerMiddlename());
|
127 |
-
}
|
128 |
-
if(!$quote->getCustomerGender()) {
|
129 |
-
$quote->setCustomerGender($data->getCustomerGender());
|
130 |
-
}
|
131 |
-
|
132 |
-
// Convert date format
|
133 |
-
$dob = $quote->getCustomerDob() ? $quote->getCustomerDob() : $data->getCustomerDob();
|
134 |
-
$dob = Mage::app()->getLocale()->date($dob, null, null, false)->toString('yyyy-MM-dd 00:00:00');
|
135 |
-
$data->setCustomerDob($dob);
|
136 |
-
$quote->setCustomerDob($dob);
|
137 |
-
|
138 |
-
$capayableCustomer = Mage::getModel('capayable/customer')->loadByEmail($quote->getCustomerEmail());
|
139 |
-
|
140 |
-
/**
|
141 |
-
* If capayable customer doesn't exist fill new customer data from quote data.
|
142 |
-
* Otherwise rewrite saved customer fields from form data.
|
143 |
-
*/
|
144 |
-
if(!$capayableCustomer->getId()) {
|
145 |
-
$capayableCustomer
|
146 |
-
->setCustomerEmail($quote->getCustomerEmail())
|
147 |
-
->setCustomerLastname($quote->getCustomerLastname())
|
148 |
-
->setCustomerMiddlename($quote->getCustomerMiddlename())
|
149 |
-
->setCustomerGender($quote->getCustomerGender())
|
150 |
-
->setCustomerDob($quote->getCustomerDob())
|
151 |
-
->setStreet($data->getStreet())
|
152 |
-
->setHouseNumber((int) $data->getHouseNumber())
|
153 |
-
->setHouseSuffix($data->getHouseSuffix())
|
154 |
-
->setPostcode($data->getPostcode())
|
155 |
-
->setCity($data->getCity())
|
156 |
-
->setCountryId($address->getCountryId())
|
157 |
-
->setTelephone($address->getTelephone())
|
158 |
-
->setFax($address->getFax())
|
159 |
-
->setIsCorporation($data->getIsCorporation())
|
160 |
-
->setIsSoleProprietor($data->getIsSoleProprietor())
|
161 |
-
->setCorporationName($data->getCorporationName())
|
162 |
-
->setCocNumber($data->getCocNumber());
|
163 |
-
|
164 |
-
} else {
|
165 |
-
$capayableCustomer->addData($data->getData());
|
166 |
-
}
|
167 |
-
|
168 |
-
// Validate capayable customer required fields
|
169 |
-
$result = $capayableCustomer->validate();
|
170 |
-
|
171 |
-
if (true !== $result && is_array($result)) {
|
172 |
-
throw new Mage_Payment_Model_Info_Exception(implode(', ', $result));
|
173 |
-
}
|
174 |
-
|
175 |
-
// Save capayable customer to 'capayable/customer' table
|
176 |
-
$capayableCustomer->save();
|
177 |
-
|
178 |
-
$this->getInfoInstance()->addData($data->getData());
|
179 |
-
|
180 |
-
return $this;
|
181 |
-
}
|
182 |
-
|
183 |
-
/**
|
184 |
-
* Customer credit check with Capayable.
|
185 |
-
* Can take quote or order object.
|
186 |
-
*
|
187 |
-
* @param Tritac_Capayable_Model_Customer $_customer
|
188 |
-
* @param float $amount
|
189 |
-
* @param bool $isFinal
|
190 |
-
* @return bool|Tritac_CapayableApiClient_Models_CreditCheckResponse
|
191 |
-
*/
|
192 |
-
public function checkCredit(Tritac_Capayable_Model_Customer $_customer, $amount, $isFinal = false)
|
193 |
-
{
|
194 |
-
/**
|
195 |
-
* Initialize new request model and fill all requested fields
|
196 |
-
*/
|
197 |
-
$req = new Tritac_CapayableApiClient_Models_CreditCheckRequest();
|
198 |
-
$req->setLastName($_customer->getCustomerLastname());
|
199 |
-
$req->setInitials($_customer->getCustomerMiddlename());
|
200 |
-
|
201 |
-
$gender = Tritac_CapayableApiClient_Enums_Gender::UNKNOWN;
|
202 |
-
if($_customer->getCustomerGender() == 1) {
|
203 |
-
$gender = Tritac_CapayableApiClient_Enums_Gender::MALE;
|
204 |
-
}elseif($_customer->getCustomerGender() == 2) {
|
205 |
-
$gender = Tritac_CapayableApiClient_Enums_Gender::FEMALE;
|
206 |
-
}
|
207 |
-
$req->setGender($gender);
|
208 |
-
|
209 |
-
$req->setBirthDate($_customer->getCustomerDob());
|
210 |
-
$req->setStreetName($_customer->getStreet());
|
211 |
-
$req->setHouseNumber($_customer->getHouseNumber());
|
212 |
-
$req->setHouseNumberSuffix($_customer->getHouseSuffix());
|
213 |
-
$req->setZipCode($_customer->getPostcode());
|
214 |
-
$req->setCity($_customer->getCity());
|
215 |
-
$req->setCountryCode($_customer->getCountryId());
|
216 |
-
$req->setPhoneNumber($_customer->getTelephone());
|
217 |
-
$req->setFaxNumber($_customer->getFax());
|
218 |
-
$req->setEmailAddress($_customer->getCustomerEmail());
|
219 |
-
|
220 |
-
|
221 |
-
$req->setIsCorporation((bool)$_customer->getIsCorporation());
|
222 |
-
$req->setCorporationName($_customer->getCorporationName());
|
223 |
-
$req->setCocNumber($_customer->getCocNumber());
|
224 |
-
|
225 |
-
// Set to true in case of a small business / freelancer / independent contractor etc (zzp/eenmanszaak)
|
226 |
-
$req->setIsSoleProprietor((bool)$_customer->getIsSoleProprietor());
|
227 |
-
|
228 |
-
$req->setIsFinal($isFinal);
|
229 |
-
$req->setClaimAmount($amount);
|
230 |
-
|
231 |
-
$result = $this->_client->doCreditCheck($req);
|
232 |
-
//Mage::log('CreditCheck: ' . ($result->getIsAccepted() ? 'ACCEPTED' : 'REJECTED: (' . Tritac_CapayableApiClient_Enums_RefuseReason::toString($result->getRefuseReason()) . ')' ) . "\r\n<br />");
|
233 |
-
|
234 |
-
return $result;
|
235 |
-
|
236 |
-
/**
|
237 |
-
* If request is final return result array which contain transaction id.
|
238 |
-
*/
|
239 |
-
/*
|
240 |
-
if($isFinal) {
|
241 |
-
return $result;
|
242 |
-
}
|
243 |
-
|
244 |
-
return $result->getIsAccepted();
|
245 |
-
*/
|
246 |
-
}
|
247 |
-
|
248 |
-
/**
|
249 |
-
* Post new invoice to Capayable
|
250 |
-
*
|
251 |
-
* @param $invoice
|
252 |
-
* @return mixed
|
253 |
-
*/
|
254 |
-
public function processApiInvoice($invoice)
|
255 |
-
{
|
256 |
-
$order_id = $invoice->getOrder()->getIncrementId();
|
257 |
-
$sender_email = Mage::getStoreConfig(Mage_Sales_Model_Order_Invoice::XML_PATH_EMAIL_IDENTITY);
|
258 |
-
|
259 |
-
// Initialize new api invoice
|
260 |
-
$apiInvoice = new Tritac_CapayableApiClient_Models_Invoice();
|
261 |
-
// Set required information
|
262 |
-
$apiInvoice->setTransactionNumber($invoice->getTransactionId());
|
263 |
-
$apiInvoice->setInvoiceNumber($invoice->getId());
|
264 |
-
$apiInvoice->setInvoiceAmount($this->getHelper()->convertToCents($invoice->getGrandTotal()));
|
265 |
-
$apiInvoice->setInvoiceDescription(Mage::helper('capayable')->__('Order').' '.$order_id);
|
266 |
-
|
267 |
-
$apiInvoice->setInvoiceByEmail($sender_email, "Order #{$order_id}");
|
268 |
-
|
269 |
-
// Register new invoice with Capayable
|
270 |
-
$isAccepted = $this->_client->registerInvoice($apiInvoice);
|
271 |
-
|
272 |
-
|
273 |
-
return $isAccepted;
|
274 |
-
}
|
275 |
-
|
276 |
-
//before refund
|
277 |
-
/*
|
278 |
-
public function processBeforeRefund($invoice, $payment)
|
279 |
-
{
|
280 |
-
}
|
281 |
-
*/
|
282 |
-
|
283 |
-
//refund api
|
284 |
-
public function refund(Varien_Object $payment, $amount)
|
285 |
-
{
|
286 |
-
$transaction_number = $payment->getLastTransId();
|
287 |
-
$return_number = $payment->getOrder()->getIncrementId();
|
288 |
-
|
289 |
-
$apiReturn = new Tritac_CapayableApiClient_Models_InvoiceCreditRequest($transaction_number, $return_number, $amount);
|
290 |
-
$isAccepted = $this->_client->creditInvoice($apiReturn);
|
291 |
-
return $this;
|
292 |
-
}
|
293 |
-
|
294 |
-
//after refund
|
295 |
-
/*
|
296 |
-
public function processCreditmemo($creditmemo, $payment)
|
297 |
-
{
|
298 |
-
}
|
299 |
-
*/
|
300 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Capayable payment method model
|
4 |
+
*
|
5 |
+
* @category Tritac
|
6 |
+
* @package Tritac_Capayable
|
7 |
+
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
8 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Tritac_Capayable_Model_Payment extends Mage_Payment_Model_Method_Abstract
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Unique internal payment method identifier
|
15 |
+
*/
|
16 |
+
protected $_code = 'capayable';
|
17 |
+
protected $_paymentMethod = 'Capayable';
|
18 |
+
protected $_formBlockType = 'capayable/form';
|
19 |
+
protected $_infoBlockType = 'capayable/info';
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Availability options
|
23 |
+
*/
|
24 |
+
protected $_isGateway = true;
|
25 |
+
|
26 |
+
protected $_canOrder = true;
|
27 |
+
|
28 |
+
protected $_canAuthorize = true;
|
29 |
+
|
30 |
+
protected $_canCapture = true;
|
31 |
+
protected $_canCapturePartial = false;
|
32 |
+
|
33 |
+
protected $_canRefund = true;
|
34 |
+
protected $_canRefundInvoicePartial = true;
|
35 |
+
|
36 |
+
protected $_canVoid = false;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Capayable API client
|
40 |
+
*/
|
41 |
+
protected $_client = null;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Extension helper
|
45 |
+
*/
|
46 |
+
protected $_helper = null;
|
47 |
+
|
48 |
+
public function __construct()
|
49 |
+
{
|
50 |
+
$this->_helper = Mage::helper('capayable');
|
51 |
+
|
52 |
+
$public_key = $this->getConfigData('public_key');
|
53 |
+
$secret_key = $this->getConfigData('secret_key');
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Initialize new api client
|
57 |
+
* @var Tritac_CapayableApiClient_Client _client
|
58 |
+
*/
|
59 |
+
$this->_client = new Tritac_CapayableApiClient_Client($public_key, $secret_key, $this->_helper->getMode());
|
60 |
+
|
61 |
+
parent::__construct();
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Get capayable helper
|
66 |
+
*
|
67 |
+
* @return Mage_Core_Helper_Abstract|Mage_Payment_Helper_Data|null
|
68 |
+
*/
|
69 |
+
public function getHelper() {
|
70 |
+
return $this->_helper;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Check customer credit via capayable
|
75 |
+
*
|
76 |
+
* @param Varien_Object $payment
|
77 |
+
* @param float $amount
|
78 |
+
* @return $this|Mage_Payment_Model_Abstract
|
79 |
+
* @throws Mage_Payment_Model_Info_Exception
|
80 |
+
*/
|
81 |
+
public function authorize(Varien_Object $payment, $amount) {
|
82 |
+
|
83 |
+
if ($amount <= 0) {
|
84 |
+
Mage::throwException(Mage::helper('capayable')->__('The amount due must be greater than 0.'));
|
85 |
+
}
|
86 |
+
|
87 |
+
// Convert amount to cents
|
88 |
+
$amount = $this->getHelper()->convertToCents($amount);
|
89 |
+
$_order = $payment->getOrder();
|
90 |
+
// Load saved capayable customer if exists. Otherwise load empty model.
|
91 |
+
$capayableCustomer = Mage::getModel('capayable/customer')->loadByEmail($_order->getCustomerEmail());
|
92 |
+
|
93 |
+
// Throw exception if capayable can't provide customer credit
|
94 |
+
$result = $this->checkCredit($capayableCustomer, $amount, true);
|
95 |
+
if(!$result->getIsAccepted()) {
|
96 |
+
throw new Mage_Payment_Model_Info_Exception(
|
97 |
+
Mage::helper('capayable')->__('The payment was refused by Capayable') . ": " .
|
98 |
+
Mage::helper('capayable')->__(Tritac_CapayableApiClient_Enums_RefuseReason::toString( $result->getRefuseReason() ) ) . " " .
|
99 |
+
Mage::helper('capayable')->__('For additional information contact %s on %s .', $result->getRefuseContactName(), $result->getRefuseContactPhoneNumber())
|
100 |
+
);
|
101 |
+
}
|
102 |
+
|
103 |
+
// Set magento transaction id which returned from capayable
|
104 |
+
$payment->setLastTransId($result->getTransactionNumber());
|
105 |
+
|
106 |
+
return $this;
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Assign data to info model instance
|
111 |
+
* Save capayable customer
|
112 |
+
*
|
113 |
+
* @param mixed $data
|
114 |
+
* @return Mage_Payment_Model_Info
|
115 |
+
*/
|
116 |
+
public function assignData($data)
|
117 |
+
{
|
118 |
+
if (!($data instanceof Varien_Object)) {
|
119 |
+
$data = new Varien_Object($data);
|
120 |
+
}
|
121 |
+
|
122 |
+
$quote = $this->getInfoInstance()->getQuote();
|
123 |
+
$address = $quote->getBillingAddress();
|
124 |
+
|
125 |
+
if(!$quote->getCustomerMiddlename()) {
|
126 |
+
$quote->setCustomerMiddlename($data->getCustomerMiddlename());
|
127 |
+
}
|
128 |
+
if(!$quote->getCustomerGender()) {
|
129 |
+
$quote->setCustomerGender($data->getCustomerGender());
|
130 |
+
}
|
131 |
+
|
132 |
+
// Convert date format
|
133 |
+
$dob = $quote->getCustomerDob() ? $quote->getCustomerDob() : $data->getCustomerDob();
|
134 |
+
$dob = Mage::app()->getLocale()->date($dob, null, null, false)->toString('yyyy-MM-dd 00:00:00');
|
135 |
+
$data->setCustomerDob($dob);
|
136 |
+
$quote->setCustomerDob($dob);
|
137 |
+
|
138 |
+
$capayableCustomer = Mage::getModel('capayable/customer')->loadByEmail($quote->getCustomerEmail());
|
139 |
+
|
140 |
+
/**
|
141 |
+
* If capayable customer doesn't exist fill new customer data from quote data.
|
142 |
+
* Otherwise rewrite saved customer fields from form data.
|
143 |
+
*/
|
144 |
+
if(!$capayableCustomer->getId()) {
|
145 |
+
$capayableCustomer
|
146 |
+
->setCustomerEmail($quote->getCustomerEmail())
|
147 |
+
->setCustomerLastname($quote->getCustomerLastname())
|
148 |
+
->setCustomerMiddlename($quote->getCustomerMiddlename())
|
149 |
+
->setCustomerGender($quote->getCustomerGender())
|
150 |
+
->setCustomerDob($quote->getCustomerDob())
|
151 |
+
->setStreet($data->getStreet())
|
152 |
+
->setHouseNumber((int) $data->getHouseNumber())
|
153 |
+
->setHouseSuffix($data->getHouseSuffix())
|
154 |
+
->setPostcode($data->getPostcode())
|
155 |
+
->setCity($data->getCity())
|
156 |
+
->setCountryId($address->getCountryId())
|
157 |
+
->setTelephone($address->getTelephone())
|
158 |
+
->setFax($address->getFax())
|
159 |
+
->setIsCorporation($data->getIsCorporation())
|
160 |
+
->setIsSoleProprietor($data->getIsSoleProprietor())
|
161 |
+
->setCorporationName($data->getCorporationName())
|
162 |
+
->setCocNumber($data->getCocNumber());
|
163 |
+
|
164 |
+
} else {
|
165 |
+
$capayableCustomer->addData($data->getData());
|
166 |
+
}
|
167 |
+
|
168 |
+
// Validate capayable customer required fields
|
169 |
+
$result = $capayableCustomer->validate();
|
170 |
+
|
171 |
+
if (true !== $result && is_array($result)) {
|
172 |
+
throw new Mage_Payment_Model_Info_Exception(implode(', ', $result));
|
173 |
+
}
|
174 |
+
|
175 |
+
// Save capayable customer to 'capayable/customer' table
|
176 |
+
$capayableCustomer->save();
|
177 |
+
|
178 |
+
$this->getInfoInstance()->addData($data->getData());
|
179 |
+
|
180 |
+
return $this;
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Customer credit check with Capayable.
|
185 |
+
* Can take quote or order object.
|
186 |
+
*
|
187 |
+
* @param Tritac_Capayable_Model_Customer $_customer
|
188 |
+
* @param float $amount
|
189 |
+
* @param bool $isFinal
|
190 |
+
* @return bool|Tritac_CapayableApiClient_Models_CreditCheckResponse
|
191 |
+
*/
|
192 |
+
public function checkCredit(Tritac_Capayable_Model_Customer $_customer, $amount, $isFinal = false)
|
193 |
+
{
|
194 |
+
/**
|
195 |
+
* Initialize new request model and fill all requested fields
|
196 |
+
*/
|
197 |
+
$req = new Tritac_CapayableApiClient_Models_CreditCheckRequest();
|
198 |
+
$req->setLastName($_customer->getCustomerLastname());
|
199 |
+
$req->setInitials($_customer->getCustomerMiddlename());
|
200 |
+
|
201 |
+
$gender = Tritac_CapayableApiClient_Enums_Gender::UNKNOWN;
|
202 |
+
if($_customer->getCustomerGender() == 1) {
|
203 |
+
$gender = Tritac_CapayableApiClient_Enums_Gender::MALE;
|
204 |
+
}elseif($_customer->getCustomerGender() == 2) {
|
205 |
+
$gender = Tritac_CapayableApiClient_Enums_Gender::FEMALE;
|
206 |
+
}
|
207 |
+
$req->setGender($gender);
|
208 |
+
|
209 |
+
$req->setBirthDate($_customer->getCustomerDob());
|
210 |
+
$req->setStreetName($_customer->getStreet());
|
211 |
+
$req->setHouseNumber($_customer->getHouseNumber());
|
212 |
+
$req->setHouseNumberSuffix($_customer->getHouseSuffix());
|
213 |
+
$req->setZipCode($_customer->getPostcode());
|
214 |
+
$req->setCity($_customer->getCity());
|
215 |
+
$req->setCountryCode($_customer->getCountryId());
|
216 |
+
$req->setPhoneNumber($_customer->getTelephone());
|
217 |
+
$req->setFaxNumber($_customer->getFax());
|
218 |
+
$req->setEmailAddress($_customer->getCustomerEmail());
|
219 |
+
|
220 |
+
|
221 |
+
$req->setIsCorporation((bool)$_customer->getIsCorporation());
|
222 |
+
$req->setCorporationName($_customer->getCorporationName());
|
223 |
+
$req->setCocNumber($_customer->getCocNumber());
|
224 |
+
|
225 |
+
// Set to true in case of a small business / freelancer / independent contractor etc (zzp/eenmanszaak)
|
226 |
+
$req->setIsSoleProprietor((bool)$_customer->getIsSoleProprietor());
|
227 |
+
|
228 |
+
$req->setIsFinal($isFinal);
|
229 |
+
$req->setClaimAmount($amount);
|
230 |
+
|
231 |
+
$result = $this->_client->doCreditCheck($req);
|
232 |
+
//Mage::log('CreditCheck: ' . ($result->getIsAccepted() ? 'ACCEPTED' : 'REJECTED: (' . Tritac_CapayableApiClient_Enums_RefuseReason::toString($result->getRefuseReason()) . ')' ) . "\r\n<br />");
|
233 |
+
|
234 |
+
return $result;
|
235 |
+
|
236 |
+
/**
|
237 |
+
* If request is final return result array which contain transaction id.
|
238 |
+
*/
|
239 |
+
/*
|
240 |
+
if($isFinal) {
|
241 |
+
return $result;
|
242 |
+
}
|
243 |
+
|
244 |
+
return $result->getIsAccepted();
|
245 |
+
*/
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* Post new invoice to Capayable
|
250 |
+
*
|
251 |
+
* @param $invoice
|
252 |
+
* @return mixed
|
253 |
+
*/
|
254 |
+
public function processApiInvoice($invoice)
|
255 |
+
{
|
256 |
+
$order_id = $invoice->getOrder()->getIncrementId();
|
257 |
+
$sender_email = Mage::getStoreConfig(Mage_Sales_Model_Order_Invoice::XML_PATH_EMAIL_IDENTITY);
|
258 |
+
|
259 |
+
// Initialize new api invoice
|
260 |
+
$apiInvoice = new Tritac_CapayableApiClient_Models_Invoice();
|
261 |
+
// Set required information
|
262 |
+
$apiInvoice->setTransactionNumber($invoice->getTransactionId());
|
263 |
+
$apiInvoice->setInvoiceNumber($invoice->getId());
|
264 |
+
$apiInvoice->setInvoiceAmount($this->getHelper()->convertToCents($invoice->getGrandTotal()));
|
265 |
+
$apiInvoice->setInvoiceDescription(Mage::helper('capayable')->__('Order').' '.$order_id);
|
266 |
+
|
267 |
+
$apiInvoice->setInvoiceByEmail($sender_email, "Order #{$order_id}");
|
268 |
+
|
269 |
+
// Register new invoice with Capayable
|
270 |
+
$isAccepted = $this->_client->registerInvoice($apiInvoice);
|
271 |
+
|
272 |
+
|
273 |
+
return $isAccepted;
|
274 |
+
}
|
275 |
+
|
276 |
+
//before refund
|
277 |
+
/*
|
278 |
+
public function processBeforeRefund($invoice, $payment)
|
279 |
+
{
|
280 |
+
}
|
281 |
+
*/
|
282 |
+
|
283 |
+
//refund api
|
284 |
+
public function refund(Varien_Object $payment, $amount)
|
285 |
+
{
|
286 |
+
$transaction_number = $payment->getLastTransId();
|
287 |
+
$return_number = $payment->getOrder()->getIncrementId();
|
288 |
+
|
289 |
+
$apiReturn = new Tritac_CapayableApiClient_Models_InvoiceCreditRequest($transaction_number, $return_number, $amount);
|
290 |
+
$isAccepted = $this->_client->creditInvoice($apiReturn);
|
291 |
+
return $this;
|
292 |
+
}
|
293 |
+
|
294 |
+
//after refund
|
295 |
+
/*
|
296 |
+
public function processCreditmemo($creditmemo, $payment)
|
297 |
+
{
|
298 |
+
}
|
299 |
+
*/
|
300 |
}
|
app/code/community/Tritac/Capayable/Model/Resource/Customer.php
CHANGED
@@ -1,69 +1,69 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Capayable customer resource model
|
4 |
-
*
|
5 |
-
* @category Tritac
|
6 |
-
* @package Tritac_Capayable
|
7 |
-
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
8 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
9 |
-
*/
|
10 |
-
|
11 |
-
class Tritac_Capayable_Model_Resource_Customer extends Mage_Core_Model_Resource_DB_Abstract {
|
12 |
-
|
13 |
-
protected function _construct()
|
14 |
-
{
|
15 |
-
$this->_init('capayable/customer', 'entity_id');
|
16 |
-
}
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Load customer data by customer email
|
20 |
-
*
|
21 |
-
* @param Tritac_Capayable_Model_Customer $customer
|
22 |
-
* @param $email
|
23 |
-
* @return $this
|
24 |
-
*/
|
25 |
-
public function loadByEmail(Tritac_Capayable_Model_Customer $customer, $email)
|
26 |
-
{
|
27 |
-
|
28 |
-
$adapter = $this->_getReadAdapter();
|
29 |
-
$bind = array('customer_email' => $email);
|
30 |
-
$select = $adapter->select()
|
31 |
-
->from($this->getMainTable(), array($this->getIdFieldName()))
|
32 |
-
->where('customer_email = :customer_email');
|
33 |
-
|
34 |
-
$entityId = $adapter->fetchOne($select, $bind);
|
35 |
-
if ($entityId) {
|
36 |
-
$this->load($customer, $entityId);
|
37 |
-
} else {
|
38 |
-
$customer->setData(array());
|
39 |
-
}
|
40 |
-
|
41 |
-
return $this;
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Load customer data by customer id
|
46 |
-
*
|
47 |
-
* @param Tritac_Capayable_Model_Customer $customer
|
48 |
-
* @param $customerId
|
49 |
-
* @return $this
|
50 |
-
*/
|
51 |
-
public function loadByCustomerId(Tritac_Capayable_Model_Customer $customer, $customerId)
|
52 |
-
{
|
53 |
-
|
54 |
-
$adapter = $this->_getReadAdapter();
|
55 |
-
$bind = array('customer_id' => $customerId);
|
56 |
-
$select = $adapter->select()
|
57 |
-
->from($this->getMainTable(), array($this->getIdFieldName()))
|
58 |
-
->where('customer_id = :customer_id');
|
59 |
-
|
60 |
-
$entityId = $adapter->fetchOne($select, $bind);
|
61 |
-
if ($entityId) {
|
62 |
-
$this->load($customer, $entityId);
|
63 |
-
} else {
|
64 |
-
$customer->setData(array());
|
65 |
-
}
|
66 |
-
|
67 |
-
return $this;
|
68 |
-
}
|
69 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Capayable customer resource model
|
4 |
+
*
|
5 |
+
* @category Tritac
|
6 |
+
* @package Tritac_Capayable
|
7 |
+
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
8 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Tritac_Capayable_Model_Resource_Customer extends Mage_Core_Model_Resource_DB_Abstract {
|
12 |
+
|
13 |
+
protected function _construct()
|
14 |
+
{
|
15 |
+
$this->_init('capayable/customer', 'entity_id');
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Load customer data by customer email
|
20 |
+
*
|
21 |
+
* @param Tritac_Capayable_Model_Customer $customer
|
22 |
+
* @param $email
|
23 |
+
* @return $this
|
24 |
+
*/
|
25 |
+
public function loadByEmail(Tritac_Capayable_Model_Customer $customer, $email)
|
26 |
+
{
|
27 |
+
|
28 |
+
$adapter = $this->_getReadAdapter();
|
29 |
+
$bind = array('customer_email' => $email);
|
30 |
+
$select = $adapter->select()
|
31 |
+
->from($this->getMainTable(), array($this->getIdFieldName()))
|
32 |
+
->where('customer_email = :customer_email');
|
33 |
+
|
34 |
+
$entityId = $adapter->fetchOne($select, $bind);
|
35 |
+
if ($entityId) {
|
36 |
+
$this->load($customer, $entityId);
|
37 |
+
} else {
|
38 |
+
$customer->setData(array());
|
39 |
+
}
|
40 |
+
|
41 |
+
return $this;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Load customer data by customer id
|
46 |
+
*
|
47 |
+
* @param Tritac_Capayable_Model_Customer $customer
|
48 |
+
* @param $customerId
|
49 |
+
* @return $this
|
50 |
+
*/
|
51 |
+
public function loadByCustomerId(Tritac_Capayable_Model_Customer $customer, $customerId)
|
52 |
+
{
|
53 |
+
|
54 |
+
$adapter = $this->_getReadAdapter();
|
55 |
+
$bind = array('customer_id' => $customerId);
|
56 |
+
$select = $adapter->select()
|
57 |
+
->from($this->getMainTable(), array($this->getIdFieldName()))
|
58 |
+
->where('customer_id = :customer_id');
|
59 |
+
|
60 |
+
$entityId = $adapter->fetchOne($select, $bind);
|
61 |
+
if ($entityId) {
|
62 |
+
$this->load($customer, $entityId);
|
63 |
+
} else {
|
64 |
+
$customer->setData(array());
|
65 |
+
}
|
66 |
+
|
67 |
+
return $this;
|
68 |
+
}
|
69 |
}
|
app/code/community/Tritac/Capayable/Model/Resource/Customer/Collection.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @category Tritac
|
4 |
-
* @package Tritac_Capayable
|
5 |
-
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
6 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
7 |
-
*/
|
8 |
-
|
9 |
-
class Tritac_Capayable_Model_Resource_Customer_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
|
10 |
-
|
11 |
-
protected function _construct() {
|
12 |
-
$this->_init('capayable/customer');
|
13 |
-
}
|
14 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @category Tritac
|
4 |
+
* @package Tritac_Capayable
|
5 |
+
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
6 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Tritac_Capayable_Model_Resource_Customer_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
|
10 |
+
|
11 |
+
protected function _construct() {
|
12 |
+
$this->_init('capayable/customer');
|
13 |
+
}
|
14 |
}
|
app/code/community/Tritac/Capayable/Model/Resource/Setup.php
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Capayable setup model
|
4 |
-
*
|
5 |
-
* @category Tritac
|
6 |
-
* @package Tritac_Capayable
|
7 |
-
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
8 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
9 |
-
*/
|
10 |
-
|
11 |
-
class Tritac_Capayable_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup {
|
12 |
-
|
13 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Capayable setup model
|
4 |
+
*
|
5 |
+
* @category Tritac
|
6 |
+
* @package Tritac_Capayable
|
7 |
+
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
8 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Tritac_Capayable_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup {
|
12 |
+
|
13 |
}
|
app/code/community/Tritac/Capayable/controllers/AjaxController.php
CHANGED
@@ -1,38 +1,38 @@
|
|
1 |
-
<?php
|
2 |
-
class Tritac_Capayable_AjaxController extends Mage_Core_Controller_Front_Action{
|
3 |
-
public function registrationcheckAction() {
|
4 |
-
$helper = Mage::helper('capayable');
|
5 |
-
$public_key = $helper->getPublicKey();
|
6 |
-
$secret_key = $helper->getSecretKey();
|
7 |
-
$mode = $helper->getMode();
|
8 |
-
|
9 |
-
$client = new Tritac_CapayableApiClient_Client($public_key, $secret_key, $mode);
|
10 |
-
|
11 |
-
$coc_number = $this->getRequest()->getParam("coc_number");
|
12 |
-
if (!$coc_number) {
|
13 |
-
$coc_number = 0;
|
14 |
-
}
|
15 |
-
$coc_number = intval($coc_number);
|
16 |
-
|
17 |
-
$registrationCheckRequest = new Tritac_CapayableApiClient_Models_RegistrationCheckRequest($coc_number);
|
18 |
-
$registrationCheckResult = $client->doRegistrationCheck($registrationCheckRequest);
|
19 |
-
|
20 |
-
$arrayData = array();
|
21 |
-
$arrayData['isAccepted'] = $registrationCheckResult->getIsAccepted();
|
22 |
-
$arrayData['houseNumber'] = $registrationCheckResult->getHouseNumber();
|
23 |
-
$arrayData['houseNumberSuffix'] = $registrationCheckResult->getHouseNumberSuffix();
|
24 |
-
$arrayData['zipCode'] = $registrationCheckResult->getZipCode();
|
25 |
-
$arrayData['city'] = $registrationCheckResult->getCity();
|
26 |
-
$arrayData['countryCode'] = $registrationCheckResult->getCountryCode();
|
27 |
-
$arrayData['phoneNumber'] = $registrationCheckResult->getPhoneNumber();
|
28 |
-
$arrayData['corporationName'] = $registrationCheckResult->getCorporationName();
|
29 |
-
$arrayData['cocNumber'] = $coc_number;
|
30 |
-
$arrayData['streetName'] = $registrationCheckResult->getStreetName();
|
31 |
-
|
32 |
-
$jsonData = json_encode($arrayData);
|
33 |
-
|
34 |
-
$this->getResponse()->setHeader('Content-type', 'application/json');
|
35 |
-
$this->getResponse()->setBody($jsonData);
|
36 |
-
|
37 |
-
}
|
38 |
}
|
1 |
+
<?php
|
2 |
+
class Tritac_Capayable_AjaxController extends Mage_Core_Controller_Front_Action{
|
3 |
+
public function registrationcheckAction() {
|
4 |
+
$helper = Mage::helper('capayable');
|
5 |
+
$public_key = $helper->getPublicKey();
|
6 |
+
$secret_key = $helper->getSecretKey();
|
7 |
+
$mode = $helper->getMode();
|
8 |
+
|
9 |
+
$client = new Tritac_CapayableApiClient_Client($public_key, $secret_key, $mode);
|
10 |
+
|
11 |
+
$coc_number = $this->getRequest()->getParam("coc_number");
|
12 |
+
if (!$coc_number) {
|
13 |
+
$coc_number = 0;
|
14 |
+
}
|
15 |
+
$coc_number = intval($coc_number);
|
16 |
+
|
17 |
+
$registrationCheckRequest = new Tritac_CapayableApiClient_Models_RegistrationCheckRequest($coc_number);
|
18 |
+
$registrationCheckResult = $client->doRegistrationCheck($registrationCheckRequest);
|
19 |
+
|
20 |
+
$arrayData = array();
|
21 |
+
$arrayData['isAccepted'] = $registrationCheckResult->getIsAccepted();
|
22 |
+
$arrayData['houseNumber'] = $registrationCheckResult->getHouseNumber();
|
23 |
+
$arrayData['houseNumberSuffix'] = $registrationCheckResult->getHouseNumberSuffix();
|
24 |
+
$arrayData['zipCode'] = $registrationCheckResult->getZipCode();
|
25 |
+
$arrayData['city'] = $registrationCheckResult->getCity();
|
26 |
+
$arrayData['countryCode'] = $registrationCheckResult->getCountryCode();
|
27 |
+
$arrayData['phoneNumber'] = $registrationCheckResult->getPhoneNumber();
|
28 |
+
$arrayData['corporationName'] = $registrationCheckResult->getCorporationName();
|
29 |
+
$arrayData['cocNumber'] = $coc_number;
|
30 |
+
$arrayData['streetName'] = $registrationCheckResult->getStreetName();
|
31 |
+
|
32 |
+
$jsonData = json_encode($arrayData);
|
33 |
+
|
34 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
35 |
+
$this->getResponse()->setBody($jsonData);
|
36 |
+
|
37 |
+
}
|
38 |
}
|
app/code/community/Tritac/Capayable/etc/config.xml
CHANGED
@@ -1,137 +1,137 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* @category Tritac
|
5 |
-
* @package Tritac_Capayable
|
6 |
-
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
7 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
8 |
-
*/
|
9 |
-
-->
|
10 |
-
<config>
|
11 |
-
<modules>
|
12 |
-
<Tritac_Capayable>
|
13 |
-
<version>2.3.
|
14 |
-
</Tritac_Capayable>
|
15 |
-
</modules>
|
16 |
-
|
17 |
-
<global>
|
18 |
-
<blocks>
|
19 |
-
<capayable>
|
20 |
-
<class>Tritac_Capayable_Block</class>
|
21 |
-
</capayable>
|
22 |
-
</blocks>
|
23 |
-
<models>
|
24 |
-
<capayable>
|
25 |
-
<class>Tritac_Capayable_Model</class>
|
26 |
-
<resourceModel>capayable_resource</resourceModel>
|
27 |
-
</capayable>
|
28 |
-
<capayable_resource>
|
29 |
-
<class>Tritac_Capayable_Model_Resource</class>
|
30 |
-
<entities>
|
31 |
-
<customer>
|
32 |
-
<table>capayable_customer</table>
|
33 |
-
</customer>
|
34 |
-
</entities>
|
35 |
-
</capayable_resource>
|
36 |
-
</models>
|
37 |
-
<helpers>
|
38 |
-
<capayable>
|
39 |
-
<class>Tritac_Capayable_Helper</class>
|
40 |
-
</capayable>
|
41 |
-
</helpers>
|
42 |
-
<resources>
|
43 |
-
<capayable_setup>
|
44 |
-
<setup>
|
45 |
-
<module>Tritac_Capayable</module>
|
46 |
-
<class>Tritac_Capayable_Model_Resource_Setup</class>
|
47 |
-
</setup>
|
48 |
-
<connection>
|
49 |
-
<use>core_setup</use>
|
50 |
-
</connection>
|
51 |
-
</capayable_setup>
|
52 |
-
<capayable_read>
|
53 |
-
<connection>
|
54 |
-
<use>core_read</use>
|
55 |
-
</connection>
|
56 |
-
</capayable_read>
|
57 |
-
<capayable_write>
|
58 |
-
<connection>
|
59 |
-
<use>core_write</use>
|
60 |
-
</connection>
|
61 |
-
</capayable_write>
|
62 |
-
</resources>
|
63 |
-
|
64 |
-
<fieldsets>
|
65 |
-
<sales_convert_quote_payment>
|
66 |
-
<test2>
|
67 |
-
<to_order_payment>*</to_order_payment>
|
68 |
-
</test2>
|
69 |
-
</sales_convert_quote_payment>
|
70 |
-
</fieldsets>
|
71 |
-
</global>
|
72 |
-
|
73 |
-
<adminhtml>
|
74 |
-
<events>
|
75 |
-
<sales_order_shipment_save_after>
|
76 |
-
<observers>
|
77 |
-
<process_invoice_after_shipment>
|
78 |
-
<type>singleton</type>
|
79 |
-
<class>capayable/observer</class>
|
80 |
-
<method>processInvoice</method>
|
81 |
-
</process_invoice_after_shipment>
|
82 |
-
</observers>
|
83 |
-
</sales_order_shipment_save_after>
|
84 |
-
<sales_order_load_after>
|
85 |
-
<observers>
|
86 |
-
<disable_order_invoice>
|
87 |
-
<type>singleton</type>
|
88 |
-
<class>capayable/observer</class>
|
89 |
-
<method>disableOrderInvoice</method>
|
90 |
-
</disable_order_invoice>
|
91 |
-
</observers>
|
92 |
-
</sales_order_load_after>
|
93 |
-
</events>
|
94 |
-
<translate>
|
95 |
-
<modules>
|
96 |
-
<Tritac_Capayable>
|
97 |
-
<files>
|
98 |
-
<default>Tritac_Capayable.csv</default>
|
99 |
-
</files>
|
100 |
-
</Tritac_Capayable>
|
101 |
-
</modules>
|
102 |
-
</translate>
|
103 |
-
</adminhtml>
|
104 |
-
<frontend>
|
105 |
-
<routers>
|
106 |
-
<capayable>
|
107 |
-
<use>standard</use>
|
108 |
-
<args>
|
109 |
-
<module>Tritac_Capayable</module>
|
110 |
-
<frontName>capayable</frontName>
|
111 |
-
</args>
|
112 |
-
</capayable>
|
113 |
-
</routers>
|
114 |
-
<translate>
|
115 |
-
<modules>
|
116 |
-
<Tritac_Capayable>
|
117 |
-
<files>
|
118 |
-
<default>Tritac_Capayable.csv</default>
|
119 |
-
</files>
|
120 |
-
</Tritac_Capayable>
|
121 |
-
</modules>
|
122 |
-
</translate>
|
123 |
-
</frontend>
|
124 |
-
|
125 |
-
<default>
|
126 |
-
<payment>
|
127 |
-
<capayable>
|
128 |
-
<active>1</active>
|
129 |
-
<model>capayable/payment</model>
|
130 |
-
<title>Capayable</title>
|
131 |
-
<email_customer>1</email_customer>
|
132 |
-
<payment_action>authorize</payment_action>
|
133 |
-
<sort_order>1</sort_order>
|
134 |
-
</capayable>
|
135 |
-
</payment>
|
136 |
-
</default>
|
137 |
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category Tritac
|
5 |
+
* @package Tritac_Capayable
|
6 |
+
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
7 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<modules>
|
12 |
+
<Tritac_Capayable>
|
13 |
+
<version>2.3.5</version>
|
14 |
+
</Tritac_Capayable>
|
15 |
+
</modules>
|
16 |
+
|
17 |
+
<global>
|
18 |
+
<blocks>
|
19 |
+
<capayable>
|
20 |
+
<class>Tritac_Capayable_Block</class>
|
21 |
+
</capayable>
|
22 |
+
</blocks>
|
23 |
+
<models>
|
24 |
+
<capayable>
|
25 |
+
<class>Tritac_Capayable_Model</class>
|
26 |
+
<resourceModel>capayable_resource</resourceModel>
|
27 |
+
</capayable>
|
28 |
+
<capayable_resource>
|
29 |
+
<class>Tritac_Capayable_Model_Resource</class>
|
30 |
+
<entities>
|
31 |
+
<customer>
|
32 |
+
<table>capayable_customer</table>
|
33 |
+
</customer>
|
34 |
+
</entities>
|
35 |
+
</capayable_resource>
|
36 |
+
</models>
|
37 |
+
<helpers>
|
38 |
+
<capayable>
|
39 |
+
<class>Tritac_Capayable_Helper</class>
|
40 |
+
</capayable>
|
41 |
+
</helpers>
|
42 |
+
<resources>
|
43 |
+
<capayable_setup>
|
44 |
+
<setup>
|
45 |
+
<module>Tritac_Capayable</module>
|
46 |
+
<class>Tritac_Capayable_Model_Resource_Setup</class>
|
47 |
+
</setup>
|
48 |
+
<connection>
|
49 |
+
<use>core_setup</use>
|
50 |
+
</connection>
|
51 |
+
</capayable_setup>
|
52 |
+
<capayable_read>
|
53 |
+
<connection>
|
54 |
+
<use>core_read</use>
|
55 |
+
</connection>
|
56 |
+
</capayable_read>
|
57 |
+
<capayable_write>
|
58 |
+
<connection>
|
59 |
+
<use>core_write</use>
|
60 |
+
</connection>
|
61 |
+
</capayable_write>
|
62 |
+
</resources>
|
63 |
+
|
64 |
+
<fieldsets>
|
65 |
+
<sales_convert_quote_payment>
|
66 |
+
<test2>
|
67 |
+
<to_order_payment>*</to_order_payment>
|
68 |
+
</test2>
|
69 |
+
</sales_convert_quote_payment>
|
70 |
+
</fieldsets>
|
71 |
+
</global>
|
72 |
+
|
73 |
+
<adminhtml>
|
74 |
+
<events>
|
75 |
+
<sales_order_shipment_save_after>
|
76 |
+
<observers>
|
77 |
+
<process_invoice_after_shipment>
|
78 |
+
<type>singleton</type>
|
79 |
+
<class>capayable/observer</class>
|
80 |
+
<method>processInvoice</method>
|
81 |
+
</process_invoice_after_shipment>
|
82 |
+
</observers>
|
83 |
+
</sales_order_shipment_save_after>
|
84 |
+
<sales_order_load_after>
|
85 |
+
<observers>
|
86 |
+
<disable_order_invoice>
|
87 |
+
<type>singleton</type>
|
88 |
+
<class>capayable/observer</class>
|
89 |
+
<method>disableOrderInvoice</method>
|
90 |
+
</disable_order_invoice>
|
91 |
+
</observers>
|
92 |
+
</sales_order_load_after>
|
93 |
+
</events>
|
94 |
+
<translate>
|
95 |
+
<modules>
|
96 |
+
<Tritac_Capayable>
|
97 |
+
<files>
|
98 |
+
<default>Tritac_Capayable.csv</default>
|
99 |
+
</files>
|
100 |
+
</Tritac_Capayable>
|
101 |
+
</modules>
|
102 |
+
</translate>
|
103 |
+
</adminhtml>
|
104 |
+
<frontend>
|
105 |
+
<routers>
|
106 |
+
<capayable>
|
107 |
+
<use>standard</use>
|
108 |
+
<args>
|
109 |
+
<module>Tritac_Capayable</module>
|
110 |
+
<frontName>capayable</frontName>
|
111 |
+
</args>
|
112 |
+
</capayable>
|
113 |
+
</routers>
|
114 |
+
<translate>
|
115 |
+
<modules>
|
116 |
+
<Tritac_Capayable>
|
117 |
+
<files>
|
118 |
+
<default>Tritac_Capayable.csv</default>
|
119 |
+
</files>
|
120 |
+
</Tritac_Capayable>
|
121 |
+
</modules>
|
122 |
+
</translate>
|
123 |
+
</frontend>
|
124 |
+
|
125 |
+
<default>
|
126 |
+
<payment>
|
127 |
+
<capayable>
|
128 |
+
<active>1</active>
|
129 |
+
<model>capayable/payment</model>
|
130 |
+
<title>Capayable</title>
|
131 |
+
<email_customer>1</email_customer>
|
132 |
+
<payment_action>authorize</payment_action>
|
133 |
+
<sort_order>1</sort_order>
|
134 |
+
</capayable>
|
135 |
+
</payment>
|
136 |
+
</default>
|
137 |
</config>
|
app/code/community/Tritac/Capayable/etc/system.xml
CHANGED
@@ -1,87 +1,87 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* @category Tritac
|
5 |
-
* @package Tritac_Capayable
|
6 |
-
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
7 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
8 |
-
*/
|
9 |
-
-->
|
10 |
-
<config>
|
11 |
-
<sections>
|
12 |
-
<payment>
|
13 |
-
<groups>
|
14 |
-
<capayable translate="label" module="capayable">
|
15 |
-
<label>Capayable</label>
|
16 |
-
<frontend_type>text</frontend_type>
|
17 |
-
<sort_order>2</sort_order>
|
18 |
-
<show_in_default>1</show_in_default>
|
19 |
-
<show_in_website>1</show_in_website>
|
20 |
-
<show_in_store>1</show_in_store>
|
21 |
-
<fields>
|
22 |
-
<active translate="label">
|
23 |
-
<label>Enabled</label>
|
24 |
-
<frontend_type>select</frontend_type>
|
25 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
26 |
-
<sort_order>10</sort_order>
|
27 |
-
<show_in_default>1</show_in_default>
|
28 |
-
<show_in_website>1</show_in_website>
|
29 |
-
<show_in_store>0</show_in_store>
|
30 |
-
</active>
|
31 |
-
<public_key translate="label">
|
32 |
-
<label>Public Key</label>
|
33 |
-
<frontend_type>text</frontend_type>
|
34 |
-
<sort_order>20</sort_order>
|
35 |
-
<show_in_default>1</show_in_default>
|
36 |
-
<show_in_website>1</show_in_website>
|
37 |
-
<show_in_store>1</show_in_store>
|
38 |
-
</public_key>
|
39 |
-
<secret_key translate="label">
|
40 |
-
<label>Secret Key</label>
|
41 |
-
<frontend_type>text</frontend_type>
|
42 |
-
<sort_order>30</sort_order>
|
43 |
-
<show_in_default>1</show_in_default>
|
44 |
-
<show_in_website>1</show_in_website>
|
45 |
-
<show_in_store>1</show_in_store>
|
46 |
-
</secret_key>
|
47 |
-
<title translate="label">
|
48 |
-
<label>Title</label>
|
49 |
-
<frontend_type>text</frontend_type>
|
50 |
-
<sort_order>40</sort_order>
|
51 |
-
<show_in_default>1</show_in_default>
|
52 |
-
<show_in_website>1</show_in_website>
|
53 |
-
<show_in_store>1</show_in_store>
|
54 |
-
</title>
|
55 |
-
<chamber_of_commerce_check translate="label">
|
56 |
-
<label>Chamber of Commerce Check</label>
|
57 |
-
<frontend_type>select</frontend_type>
|
58 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
59 |
-
<sort_order>50</sort_order>
|
60 |
-
<show_in_default>1</show_in_default>
|
61 |
-
<show_in_website>1</show_in_website>
|
62 |
-
<show_in_store>0</show_in_store>
|
63 |
-
</chamber_of_commerce_check>
|
64 |
-
<test translate="label">
|
65 |
-
<label>Test Mode</label>
|
66 |
-
<frontend_type>select</frontend_type>
|
67 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
68 |
-
<sort_order>60</sort_order>
|
69 |
-
<show_in_default>1</show_in_default>
|
70 |
-
<show_in_website>1</show_in_website>
|
71 |
-
<show_in_store>0</show_in_store>
|
72 |
-
</test>
|
73 |
-
<sort_order translate="label">
|
74 |
-
<label>Sort Order</label>
|
75 |
-
<frontend_type>text</frontend_type>
|
76 |
-
<sort_order>80</sort_order>
|
77 |
-
<show_in_default>1</show_in_default>
|
78 |
-
<show_in_website>1</show_in_website>
|
79 |
-
<show_in_store>0</show_in_store>
|
80 |
-
<frontend_class>validate-number</frontend_class>
|
81 |
-
</sort_order>
|
82 |
-
</fields>
|
83 |
-
</capayable>
|
84 |
-
</groups>
|
85 |
-
</payment>
|
86 |
-
</sections>
|
87 |
-
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category Tritac
|
5 |
+
* @package Tritac_Capayable
|
6 |
+
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
7 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<sections>
|
12 |
+
<payment>
|
13 |
+
<groups>
|
14 |
+
<capayable translate="label" module="capayable">
|
15 |
+
<label>Capayable</label>
|
16 |
+
<frontend_type>text</frontend_type>
|
17 |
+
<sort_order>2</sort_order>
|
18 |
+
<show_in_default>1</show_in_default>
|
19 |
+
<show_in_website>1</show_in_website>
|
20 |
+
<show_in_store>1</show_in_store>
|
21 |
+
<fields>
|
22 |
+
<active translate="label">
|
23 |
+
<label>Enabled</label>
|
24 |
+
<frontend_type>select</frontend_type>
|
25 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
26 |
+
<sort_order>10</sort_order>
|
27 |
+
<show_in_default>1</show_in_default>
|
28 |
+
<show_in_website>1</show_in_website>
|
29 |
+
<show_in_store>0</show_in_store>
|
30 |
+
</active>
|
31 |
+
<public_key translate="label">
|
32 |
+
<label>Public Key</label>
|
33 |
+
<frontend_type>text</frontend_type>
|
34 |
+
<sort_order>20</sort_order>
|
35 |
+
<show_in_default>1</show_in_default>
|
36 |
+
<show_in_website>1</show_in_website>
|
37 |
+
<show_in_store>1</show_in_store>
|
38 |
+
</public_key>
|
39 |
+
<secret_key translate="label">
|
40 |
+
<label>Secret Key</label>
|
41 |
+
<frontend_type>text</frontend_type>
|
42 |
+
<sort_order>30</sort_order>
|
43 |
+
<show_in_default>1</show_in_default>
|
44 |
+
<show_in_website>1</show_in_website>
|
45 |
+
<show_in_store>1</show_in_store>
|
46 |
+
</secret_key>
|
47 |
+
<title translate="label">
|
48 |
+
<label>Title</label>
|
49 |
+
<frontend_type>text</frontend_type>
|
50 |
+
<sort_order>40</sort_order>
|
51 |
+
<show_in_default>1</show_in_default>
|
52 |
+
<show_in_website>1</show_in_website>
|
53 |
+
<show_in_store>1</show_in_store>
|
54 |
+
</title>
|
55 |
+
<chamber_of_commerce_check translate="label">
|
56 |
+
<label>Chamber of Commerce Check</label>
|
57 |
+
<frontend_type>select</frontend_type>
|
58 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
59 |
+
<sort_order>50</sort_order>
|
60 |
+
<show_in_default>1</show_in_default>
|
61 |
+
<show_in_website>1</show_in_website>
|
62 |
+
<show_in_store>0</show_in_store>
|
63 |
+
</chamber_of_commerce_check>
|
64 |
+
<test translate="label">
|
65 |
+
<label>Test Mode</label>
|
66 |
+
<frontend_type>select</frontend_type>
|
67 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
68 |
+
<sort_order>60</sort_order>
|
69 |
+
<show_in_default>1</show_in_default>
|
70 |
+
<show_in_website>1</show_in_website>
|
71 |
+
<show_in_store>0</show_in_store>
|
72 |
+
</test>
|
73 |
+
<sort_order translate="label">
|
74 |
+
<label>Sort Order</label>
|
75 |
+
<frontend_type>text</frontend_type>
|
76 |
+
<sort_order>80</sort_order>
|
77 |
+
<show_in_default>1</show_in_default>
|
78 |
+
<show_in_website>1</show_in_website>
|
79 |
+
<show_in_store>0</show_in_store>
|
80 |
+
<frontend_class>validate-number</frontend_class>
|
81 |
+
</sort_order>
|
82 |
+
</fields>
|
83 |
+
</capayable>
|
84 |
+
</groups>
|
85 |
+
</payment>
|
86 |
+
</sections>
|
87 |
+
</config>
|
app/code/community/Tritac/Capayable/sql/capayable_setup/install-1.0.0.php
CHANGED
@@ -1,78 +1,78 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Tritac_Capayable setup script
|
4 |
-
*
|
5 |
-
* @category Tritac
|
6 |
-
* @package Tritac_Capayable
|
7 |
-
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
8 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
9 |
-
*/
|
10 |
-
|
11 |
-
$installer = $this;
|
12 |
-
|
13 |
-
/* @var $installer Tritac_Capayable_Model_Resource_Setup */
|
14 |
-
$installer->startSetup();
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Create table 'capayable_data'
|
18 |
-
*/
|
19 |
-
$table = $installer->getConnection()
|
20 |
-
->newTable($installer->getTable('capayable/customer'))
|
21 |
-
->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
22 |
-
'identity' => true,
|
23 |
-
'unsigned' => true,
|
24 |
-
'nullable' => false,
|
25 |
-
'primary' => true,
|
26 |
-
), 'Entity Id')
|
27 |
-
->addColumn('customer_email', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
28 |
-
), 'Customer Email')
|
29 |
-
->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
30 |
-
'unsigned' => true,
|
31 |
-
), 'Customer Id')
|
32 |
-
->addColumn('customer_lastname', Varien_Db_Ddl_Table::TYPE_TEXT, 150, array(
|
33 |
-
), 'Customer Lastname')
|
34 |
-
->addColumn('customer_middlename', Varien_Db_Ddl_Table::TYPE_TEXT, 10, array(
|
35 |
-
), 'Customer Initials')
|
36 |
-
->addColumn('customer_gender', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
37 |
-
), 'Customer Gender')
|
38 |
-
->addColumn('customer_dob', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
|
39 |
-
), 'Customer Dob')
|
40 |
-
->addColumn('street', Varien_Db_Ddl_Table::TYPE_TEXT, 150, array(
|
41 |
-
), 'Street')
|
42 |
-
->addColumn('house_number', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
43 |
-
), 'House Number')
|
44 |
-
->addColumn('house_suffix', Varien_Db_Ddl_Table::TYPE_TEXT, 10, array(
|
45 |
-
), 'House Number')
|
46 |
-
->addColumn('postcode', Varien_Db_Ddl_Table::TYPE_TEXT, 20, array(
|
47 |
-
), 'Postcode')
|
48 |
-
->addColumn('city', Varien_Db_Ddl_Table::TYPE_TEXT, 150, array(
|
49 |
-
), 'City')
|
50 |
-
->addColumn('country_id', Varien_Db_Ddl_Table::TYPE_TEXT, 2, array(
|
51 |
-
), 'Country Id')
|
52 |
-
->addColumn('telephone', Varien_Db_Ddl_Table::TYPE_TEXT, 20, array(
|
53 |
-
), 'Telephone')
|
54 |
-
->addColumn('fax', Varien_Db_Ddl_Table::TYPE_TEXT, 20, array(
|
55 |
-
), 'Fax')
|
56 |
-
->addColumn('is_corporation', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
57 |
-
'unsigned' => true,
|
58 |
-
'nullable' => false,
|
59 |
-
'default' => '0',
|
60 |
-
), 'Is Corporation')
|
61 |
-
->addColumn('corporation_name', Varien_Db_Ddl_Table::TYPE_TEXT, 150, array(
|
62 |
-
), 'Corporation Name')
|
63 |
-
->addColumn('is_sole', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
64 |
-
'unsigned' => true,
|
65 |
-
'nullable' => false,
|
66 |
-
'default' => '0',
|
67 |
-
), 'Is Sole Proprietor')
|
68 |
-
->addColumn('coc_number', Varien_Db_Ddl_Table::TYPE_TEXT, 20, array(
|
69 |
-
), 'Chamber of Commerce number')
|
70 |
-
->addIndex($installer->getIdxName('capayable/customer', array('customer_id')),
|
71 |
-
array('customer_id'))
|
72 |
-
->addIndex($installer->getIdxName('capayable/customer', array('customer_email')),
|
73 |
-
array('customer_email'))
|
74 |
-
->setComment('Capayable Customer Data');
|
75 |
-
|
76 |
-
$installer->getConnection()->createTable($table);
|
77 |
-
|
78 |
$installer->endSetup();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Tritac_Capayable setup script
|
4 |
+
*
|
5 |
+
* @category Tritac
|
6 |
+
* @package Tritac_Capayable
|
7 |
+
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
8 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
9 |
+
*/
|
10 |
+
|
11 |
+
$installer = $this;
|
12 |
+
|
13 |
+
/* @var $installer Tritac_Capayable_Model_Resource_Setup */
|
14 |
+
$installer->startSetup();
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Create table 'capayable_data'
|
18 |
+
*/
|
19 |
+
$table = $installer->getConnection()
|
20 |
+
->newTable($installer->getTable('capayable/customer'))
|
21 |
+
->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
22 |
+
'identity' => true,
|
23 |
+
'unsigned' => true,
|
24 |
+
'nullable' => false,
|
25 |
+
'primary' => true,
|
26 |
+
), 'Entity Id')
|
27 |
+
->addColumn('customer_email', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
|
28 |
+
), 'Customer Email')
|
29 |
+
->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
30 |
+
'unsigned' => true,
|
31 |
+
), 'Customer Id')
|
32 |
+
->addColumn('customer_lastname', Varien_Db_Ddl_Table::TYPE_TEXT, 150, array(
|
33 |
+
), 'Customer Lastname')
|
34 |
+
->addColumn('customer_middlename', Varien_Db_Ddl_Table::TYPE_TEXT, 10, array(
|
35 |
+
), 'Customer Initials')
|
36 |
+
->addColumn('customer_gender', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
37 |
+
), 'Customer Gender')
|
38 |
+
->addColumn('customer_dob', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
|
39 |
+
), 'Customer Dob')
|
40 |
+
->addColumn('street', Varien_Db_Ddl_Table::TYPE_TEXT, 150, array(
|
41 |
+
), 'Street')
|
42 |
+
->addColumn('house_number', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
43 |
+
), 'House Number')
|
44 |
+
->addColumn('house_suffix', Varien_Db_Ddl_Table::TYPE_TEXT, 10, array(
|
45 |
+
), 'House Number')
|
46 |
+
->addColumn('postcode', Varien_Db_Ddl_Table::TYPE_TEXT, 20, array(
|
47 |
+
), 'Postcode')
|
48 |
+
->addColumn('city', Varien_Db_Ddl_Table::TYPE_TEXT, 150, array(
|
49 |
+
), 'City')
|
50 |
+
->addColumn('country_id', Varien_Db_Ddl_Table::TYPE_TEXT, 2, array(
|
51 |
+
), 'Country Id')
|
52 |
+
->addColumn('telephone', Varien_Db_Ddl_Table::TYPE_TEXT, 20, array(
|
53 |
+
), 'Telephone')
|
54 |
+
->addColumn('fax', Varien_Db_Ddl_Table::TYPE_TEXT, 20, array(
|
55 |
+
), 'Fax')
|
56 |
+
->addColumn('is_corporation', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
57 |
+
'unsigned' => true,
|
58 |
+
'nullable' => false,
|
59 |
+
'default' => '0',
|
60 |
+
), 'Is Corporation')
|
61 |
+
->addColumn('corporation_name', Varien_Db_Ddl_Table::TYPE_TEXT, 150, array(
|
62 |
+
), 'Corporation Name')
|
63 |
+
->addColumn('is_sole', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
64 |
+
'unsigned' => true,
|
65 |
+
'nullable' => false,
|
66 |
+
'default' => '0',
|
67 |
+
), 'Is Sole Proprietor')
|
68 |
+
->addColumn('coc_number', Varien_Db_Ddl_Table::TYPE_TEXT, 20, array(
|
69 |
+
), 'Chamber of Commerce number')
|
70 |
+
->addIndex($installer->getIdxName('capayable/customer', array('customer_id')),
|
71 |
+
array('customer_id'))
|
72 |
+
->addIndex($installer->getIdxName('capayable/customer', array('customer_email')),
|
73 |
+
array('customer_email'))
|
74 |
+
->setComment('Capayable Customer Data');
|
75 |
+
|
76 |
+
$installer->getConnection()->createTable($table);
|
77 |
+
|
78 |
$installer->endSetup();
|
app/design/frontend/base/default/template/capayable/form.phtml
CHANGED
@@ -1,475 +1,463 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/afl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category design
|
22 |
-
* @package base_default
|
23 |
-
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
-
*/
|
26 |
-
?>
|
27 |
-
<?php
|
28 |
-
|
29 |
-
$_code = $this->getMethodCode();
|
30 |
-
$_quote = $this->getQuote();
|
31 |
-
$_customer = $this->getCustomer();
|
32 |
-
|
33 |
-
$isLoggedIn = Mage::helper('customer')->isLoggedIn();
|
34 |
-
$cocNumberCheck = Mage::getStoreConfig('payment/capayable/chamber_of_commerce_check');
|
35 |
-
$billingAddress = $_quote->getBillingAddress();
|
36 |
-
|
37 |
-
$firstname = $billingAddress->
|
38 |
-
$names = explode(" ", $firstname);
|
39 |
-
$initials = "";
|
40 |
-
|
41 |
-
foreach ($names as $name) {
|
42 |
-
$initials .= $name[0] . ". ";
|
43 |
-
}
|
44 |
-
//if($_customer->getCustomerMiddlename() && $isLoggedIn)
|
45 |
-
// $initials = $_customer->getCustomerMiddlename();
|
46 |
-
$hasMageWorldOSC = Mage::helper('core')->isModuleEnabled('MW_Onestepcheckout');
|
47 |
-
|
48 |
-
$postcode = $billingAddress->
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
$
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
$
|
62 |
-
|
63 |
-
|
64 |
-
);
|
65 |
-
|
66 |
-
}
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
<
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
<
|
164 |
-
<
|
165 |
-
|
166 |
-
<
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
<
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
<
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
<
|
230 |
-
|
231 |
-
<
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
(
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
}
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
val
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
}
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
$('<?php echo $_code ?>
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
}
|
464 |
-
}
|
465 |
-
|
466 |
-
function cocRequestOnFailure(response){
|
467 |
-
$('<?php echo $_code ?>_corporation_name').value = '';
|
468 |
-
$('<?php echo $_code ?>_street').value = '';
|
469 |
-
$('<?php echo $_code ?>_house_number').value = '';
|
470 |
-
$('<?php echo $_code ?>_house_suffix').value = '';
|
471 |
-
$('<?php echo $_code ?>_postcode').value = '';
|
472 |
-
$('<?php echo $_code ?>_city').value = '';
|
473 |
-
}
|
474 |
-
//]]>
|
475 |
</script>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php
|
28 |
+
|
29 |
+
$_code = $this->getMethodCode();
|
30 |
+
$_quote = $this->getQuote();
|
31 |
+
$_customer = $this->getCustomer();
|
32 |
+
|
33 |
+
$isLoggedIn = Mage::helper('customer')->isLoggedIn();
|
34 |
+
$cocNumberCheck = Mage::getStoreConfig('payment/capayable/chamber_of_commerce_check');
|
35 |
+
$billingAddress = $_quote->getBillingAddress();
|
36 |
+
|
37 |
+
$firstname = $billingAddress->getFirstname();
|
38 |
+
$names = explode(" ", $firstname);
|
39 |
+
$initials = "";
|
40 |
+
|
41 |
+
foreach ($names as $name) {
|
42 |
+
$initials .= $name[0] . ". ";
|
43 |
+
}
|
44 |
+
//if($_customer->getCustomerMiddlename() && $isLoggedIn)
|
45 |
+
// $initials = $_customer->getCustomerMiddlename();
|
46 |
+
$hasMageWorldOSC = Mage::helper('core')->isModuleEnabled('MW_Onestepcheckout');
|
47 |
+
|
48 |
+
$postcode = $billingAddress->getPostcode();
|
49 |
+
$city = $billingAddress->getCity();
|
50 |
+
|
51 |
+
$addressLines = $billingAddress->getStreet();
|
52 |
+
$addressLineCount = count($billingAddress->getStreet());
|
53 |
+
$streetName = null;
|
54 |
+
$houseNumber = null;
|
55 |
+
$houseNumberSuffix = null;
|
56 |
+
|
57 |
+
// Either there is just one line to enter the street and house number, or there
|
58 |
+
// are 2 but the second field was not filled out (used for a house number)
|
59 |
+
if($addressLineCount == 1 || ($addressLineCount == 2 && empty($addressLines[1])))
|
60 |
+
{
|
61 |
+
list($streetName, $houseNumber, $houseNumberSuffix) = sscanf($addressLines[0], "%[a-zA-Z ]%d%[^\t\n]");
|
62 |
+
|
63 |
+
$streetName = trim($streetName);
|
64 |
+
$houseNumber = trim($houseNumber);
|
65 |
+
$houseNumberSuffix = trim($houseNumberSuffix);
|
66 |
+
}
|
67 |
+
elseif($addressLineCount == 2)
|
68 |
+
{
|
69 |
+
$streetName = trim($addressLines[0]);
|
70 |
+
|
71 |
+
list($houseNumber, $houseNumberSuffix) = sscanf($addressLines[1], "%d%[^\t\n]");
|
72 |
+
|
73 |
+
$houseNumber = trim($houseNumber);
|
74 |
+
$houseNumberSuffix = trim($houseNumberSuffix);
|
75 |
+
}
|
76 |
+
elseif($addressLineCount == 3)
|
77 |
+
{
|
78 |
+
$streetName = trim($addressLines[0]);
|
79 |
+
$houseNumber = trim($addressLines[1]);
|
80 |
+
$houseNumberSuffix = trim($addressLines[2]);
|
81 |
+
}
|
82 |
+
$alwaysShowAddress = false;
|
83 |
+
$showAddress = (!$streetName || !$houseNumber || !$postcode || !$city) || $alwaysShowAddress;
|
84 |
+
?>
|
85 |
+
<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
|
86 |
+
|
87 |
+
<?php if(!$_quote->getCustomerDob()): ?>
|
88 |
+
<li>
|
89 |
+
<label for="<?php echo $_code?>_month" class="required"><em>*</em><?php echo $this->__('Date of Birth') ?></label>
|
90 |
+
<div class="input-box capayable-customer-dob customer-dob">
|
91 |
+
<?php
|
92 |
+
$_dob = $this->getLayout()->createBlock('customer/widget_dob');
|
93 |
+
$_dob->setDateInput('d',
|
94 |
+
'<div class="dob-day">
|
95 |
+
<input type="text" id="day" name="payment[day]" value="' . $_dob->getDay() . '" title="' . $this->__('Day') . '" class="input-text validate-custom" />
|
96 |
+
<label for="' . $_code . '_day">' . $this->__('DD') . '</label>
|
97 |
+
</div>'
|
98 |
+
);
|
99 |
+
|
100 |
+
$_dob->setDateInput('m',
|
101 |
+
'<div class="dob-month">
|
102 |
+
<input type="text" id="' . $_code . '_month" name="payment[month]" value="' . $_dob->getMonth() . '" title="' . $this->__('Month') . '" class="input-text validate-custom" />
|
103 |
+
<label for="' . $_code . '_month">' . $this->__('MM') . '</label>
|
104 |
+
</div>'
|
105 |
+
);
|
106 |
+
|
107 |
+
$_dob->setDateInput('y',
|
108 |
+
'<div class="dob-year">
|
109 |
+
<input type="text" id="' . $_code . '_year" name="payment[year]" value="' . $_dob->getYear() . '" title="' . $this->__('Year') . '" class="input-text validate-custom" />
|
110 |
+
<label for="' . $_code . '_year">' . $this->__('YYYY') . '</label>
|
111 |
+
</div>'
|
112 |
+
);
|
113 |
+
|
114 |
+
//echo $_dob->getSortedDateInputs();
|
115 |
+
?>
|
116 |
+
<?php
|
117 |
+
echo
|
118 |
+
'<div class="dob-day">
|
119 |
+
<input type="text" id="day" name="payment[day]" value="' . $_dob->getDay() . '" title="' . $this->__('Day') . '" class="input-text validate-custom" />
|
120 |
+
<label for="' . $_code . '_day">' . $this->__('DD') . '</label>
|
121 |
+
</div>',
|
122 |
+
'<div class="dob-month">
|
123 |
+
<input type="text" id="' . $_code . '_month" name="payment[month]" value="' . $_dob->getMonth() . '" title="' . $this->__('Month') . '" class="input-text validate-custom" />
|
124 |
+
<label for="' . $_code . '_month">' . $this->__('MM') . '</label>
|
125 |
+
</div>',
|
126 |
+
'<div class="dob-year">
|
127 |
+
<input type="text" id="' . $_code . '_year" name="payment[year]" value="' . $_dob->getYear() . '" title="' . $this->__('Year') . '" class="input-text validate-custom" />
|
128 |
+
<label for="' . $_code . '_year">' . $this->__('YYYY') . '</label>
|
129 |
+
</div>';
|
130 |
+
?>
|
131 |
+
<div class="dob-full" style="display:none;">
|
132 |
+
<input type="hidden" id="<?php echo $_code ?>_dob" name="payment[customer_dob]" />
|
133 |
+
</div>
|
134 |
+
|
135 |
+
<div class="validation-advice" style="display:none;"></div>
|
136 |
+
</div>
|
137 |
+
<script type="text/javascript">
|
138 |
+
//<![CDATA[
|
139 |
+
var capayable_customer_dob = new Varien.DOB('.capayable-customer-dob', true, '<?php echo $_dob->getDateFormat() ?>');
|
140 |
+
//]]>
|
141 |
+
</script>
|
142 |
+
</li>
|
143 |
+
<?php endif ?>
|
144 |
+
|
145 |
+
<?php if(!$_quote->getCustomerGender()): ?>
|
146 |
+
<li>
|
147 |
+
<label for="<?php echo $_code?>_gender" class="required"><em>*</em><?php echo $this->__('Gender') ?></label>
|
148 |
+
<div class="input-box">
|
149 |
+
<select id="<?php echo $_code?>_gender" name="payment[customer_gender]" title="<?php echo $this->__('Gender') ?>" class="validate-select">
|
150 |
+
<?php
|
151 |
+
$options = Mage::getResourceSingleton('customer/customer')->getAttribute('gender')->getSource()->getAllOptions();
|
152 |
+
?>
|
153 |
+
<?php foreach ($options as $option):?>
|
154 |
+
<option value="<?php echo $option['value'] ?>"><?php echo $option['label'] ?></option>
|
155 |
+
<?php endforeach;?>
|
156 |
+
</select>
|
157 |
+
</div>
|
158 |
+
</li>
|
159 |
+
<?php endif ?>
|
160 |
+
|
161 |
+
<li>
|
162 |
+
<label for="<?php echo $_code?>_is_corporation"><?php echo $this->__('Is Corporation')?></label>
|
163 |
+
<div class="input-box">
|
164 |
+
<select name="payment[is_corporation]" id="<?php echo $_code ?>_is_corporation">
|
165 |
+
<option value="0" <?php if(!$billingAddress->getCompany()): ?>selected="selected"<?php endif; ?>><?php echo $this->__('No')?></option>
|
166 |
+
<option value="1" <?php if($billingAddress->getCompany()): ?>selected="selected"<?php endif; ?>><?php echo $this->__('Yes')?></option>
|
167 |
+
</select>
|
168 |
+
</div>
|
169 |
+
</li>
|
170 |
+
|
171 |
+
<li id="<?php echo $_code ?>_is_sole_wrapper">
|
172 |
+
<label for="<?php echo $_code?>_is_sole"><?php echo $this->__('Is Sole Proprietor')?></label>
|
173 |
+
<div class="input-box">
|
174 |
+
<select name="payment[is_sole]" id="<?php echo $_code ?>_is_sole">
|
175 |
+
<option value="0" <?php if($_customer->getIsSole() == 0 && $isLoggedIn): ?>selected="selected"<?php endif ?>><?php echo $this->__('No')?></option>
|
176 |
+
<option value="1" <?php if($_customer->getIsSole() == 1 && $isLoggedIn): ?>selected="selected"<?php endif ?>><?php echo $this->__('Yes')?></option>
|
177 |
+
</select>
|
178 |
+
</div>
|
179 |
+
</li>
|
180 |
+
|
181 |
+
|
182 |
+
<li id="<?php echo $_code ?>_coc_number_wrapper">
|
183 |
+
<label for="<?php echo $_code?>_coc_number"><?php echo $this->__('Chamber of Commerce Number')?></label>
|
184 |
+
<div class="input-box">
|
185 |
+
<input type="text" id="<?php echo $_code?>_coc_number" name="payment[coc_number]" class="input-text" value="<?php if($_customer->getCocNumber() && $isLoggedIn) echo $_customer->getCocNumber()?>" />
|
186 |
+
</div>
|
187 |
+
</li>
|
188 |
+
|
189 |
+
|
190 |
+
<li id="<?php echo $_code ?>_corporation_name_wrapper">
|
191 |
+
<label for="<?php echo $_code?>_corporation_name"><?php echo $this->__('Corporation Name')?></label>
|
192 |
+
<div class="input-box">
|
193 |
+
<input type="text" id="<?php echo $_code?>_corporation_name" name="payment[corporation_name]" class="input-text" value="<?php echo $billingAddress->getCompany(); ?>" />
|
194 |
+
</div>
|
195 |
+
</li>
|
196 |
+
|
197 |
+
|
198 |
+
<?php if($hasMageWorldOSC): ?>
|
199 |
+
|
200 |
+
<input type="hidden" id="<?php echo $_code?>_middlename" name="payment[customer_middlename]" class="input-text required-entry" value="<?php echo $initials; ?>" />
|
201 |
+
|
202 |
+
<input type="hidden" id="<?php echo $_code?>_street" name="payment[street]" class="input-text required-entry" value="<?php echo $streetName ?>" />
|
203 |
+
<input type="hidden" id="<?php echo $_code?>_house_number" name="payment[house_number]" class="validate-digits validate-greater-than-zero input-text required-entry" value="<?php echo $houseNumber; ?>" />
|
204 |
+
<input type="hidden" id="<?php echo $_code?>_house_suffix" name="payment[house_suffix]" class="input-text" value="<?php echo $houseNumberSuffix; ?>" />
|
205 |
+
|
206 |
+
<input type="hidden" id="<?php echo $_code?>_postcode" name="payment[postcode]" class="input-text required-entry" value="<?php echo $postcode; ?>" />
|
207 |
+
<input type="hidden" id="<?php echo $_code?>_city" name="payment[city]" class="input-text required-entry" value="<?php echo $city; ?>" />
|
208 |
+
|
209 |
+
<?php else: ?>
|
210 |
+
|
211 |
+
<?php if(!$initials): ?>
|
212 |
+
<li>
|
213 |
+
<label for="<?php echo $_code?>_middlename" class="required"><em>*</em><?php echo $this->__('Initials')?></label>
|
214 |
+
<div class="input-box">
|
215 |
+
<input type="text" id="<?php echo $_code?>_middlename" name="payment[customer_middlename]" class="input-text required-entry" value="<?php echo $initials; ?>" />
|
216 |
+
</div>
|
217 |
+
</li>
|
218 |
+
<?php endif; ?>
|
219 |
+
|
220 |
+
<?php if($showAddress): ?>
|
221 |
+
<li>
|
222 |
+
<label for="<?php echo $_code?>_street" class="required"><em>*</em><?php echo $this->__('Street')?></label>
|
223 |
+
<div class="input-box">
|
224 |
+
<input type="text" id="<?php echo $_code?>_street" name="payment[street]" class="input-text required-entry" value="<?php echo $streetName; ?>" />
|
225 |
+
</div>
|
226 |
+
</li>
|
227 |
+
|
228 |
+
<li>
|
229 |
+
<label for="<?php echo $_code?>_house_number" class="required"><em>*</em><?php echo $this->__('House number')?></label>
|
230 |
+
<div class="input-box">
|
231 |
+
<input type="text" id="<?php echo $_code?>_house_number" name="payment[house_number]" class="validate-digits validate-greater-than-zero input-text required-entry" value="<?php echo $houseNumber; ?>" />
|
232 |
+
</div>
|
233 |
+
</li>
|
234 |
+
<li>
|
235 |
+
<label for="<?php echo $_code?>_house_suffix"><?php echo $this->__('House number suffix')?></label>
|
236 |
+
<div class="input-box">
|
237 |
+
<input type="text" id="<?php echo $_code?>_house_suffix" name="payment[house_suffix]" class="input-text" value="<?php echo $houseNumberSuffix; ?>" />
|
238 |
+
</div>
|
239 |
+
</li>
|
240 |
+
|
241 |
+
<li>
|
242 |
+
<label for="<?php echo $_code?>_postcode" class="required"><em>*</em><?php echo $this->__('Postal Code')?></label>
|
243 |
+
<div class="input-box">
|
244 |
+
<input type="text" id="<?php echo $_code?>_postcode" name="payment[postcode]" class="input-text required-entry" value="<?php echo $postcode; ?>" />
|
245 |
+
</div>
|
246 |
+
</li>
|
247 |
+
|
248 |
+
<li>
|
249 |
+
<label for="<?php echo $_code?>_city" class="required"><em>*</em><?php echo $this->__('City')?></label>
|
250 |
+
<div class="input-box">
|
251 |
+
<input type="text" id="<?php echo $_code?>_city" name="payment[city]" class="input-text required-entry" value="<?php echo $city; ?>" />
|
252 |
+
</div>
|
253 |
+
</li>
|
254 |
+
|
255 |
+
<?php endif; ?>
|
256 |
+
<?php endif; ?>
|
257 |
+
|
258 |
+
</ul>
|
259 |
+
|
260 |
+
<script type="text/javascript">
|
261 |
+
//<![CDATA[
|
262 |
+
/**
|
263 |
+
* Event.simulate(@element, eventName[, options]) -> Element
|
264 |
+
*
|
265 |
+
* - @element: element to fire event on
|
266 |
+
* - eventName: name of event to fire (only MouseEvents and HTMLEvents interfaces are supported)
|
267 |
+
* - options: optional object to fine-tune event properties - pointerX, pointerY, ctrlKey, etc.
|
268 |
+
*
|
269 |
+
* $('foo').simulate('click'); // => fires "click" event on an element with id=foo
|
270 |
+
*
|
271 |
+
**/
|
272 |
+
(function(){
|
273 |
+
|
274 |
+
var eventMatchers = {
|
275 |
+
'HTMLEvents': /^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,
|
276 |
+
'MouseEvents': /^(?:click|mouse(?:down|up|over|move|out))$/
|
277 |
+
}
|
278 |
+
var defaultOptions = {
|
279 |
+
pointerX: 0,
|
280 |
+
pointerY: 0,
|
281 |
+
button: 0,
|
282 |
+
ctrlKey: false,
|
283 |
+
altKey: false,
|
284 |
+
shiftKey: false,
|
285 |
+
metaKey: false,
|
286 |
+
bubbles: true,
|
287 |
+
cancelable: true
|
288 |
+
}
|
289 |
+
|
290 |
+
Event.simulate = function(element, eventName) {
|
291 |
+
var options = Object.extend(defaultOptions, arguments[2] || { });
|
292 |
+
var oEvent, eventType = null;
|
293 |
+
|
294 |
+
element = $(element);
|
295 |
+
|
296 |
+
for (var name in eventMatchers) {
|
297 |
+
if (eventMatchers[name].test(eventName)) { eventType = name; break; }
|
298 |
+
}
|
299 |
+
|
300 |
+
if (!eventType)
|
301 |
+
throw new SyntaxError('Only HTMLEvents and MouseEvents interfaces are supported');
|
302 |
+
|
303 |
+
if (document.createEvent) {
|
304 |
+
oEvent = document.createEvent(eventType);
|
305 |
+
if (eventType == 'HTMLEvents') {
|
306 |
+
oEvent.initEvent(eventName, options.bubbles, options.cancelable);
|
307 |
+
}
|
308 |
+
else {
|
309 |
+
oEvent.initMouseEvent(eventName, options.bubbles, options.cancelable, document.defaultView,
|
310 |
+
options.button, options.pointerX, options.pointerY, options.pointerX, options.pointerY,
|
311 |
+
options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.button, element);
|
312 |
+
}
|
313 |
+
element.dispatchEvent(oEvent);
|
314 |
+
}
|
315 |
+
else {
|
316 |
+
options.clientX = options.pointerX;
|
317 |
+
options.clientY = options.pointerY;
|
318 |
+
oEvent = Object.extend(document.createEventObject(), options);
|
319 |
+
element.fireEvent('on' + eventName, oEvent);
|
320 |
+
}
|
321 |
+
return element;
|
322 |
+
}
|
323 |
+
|
324 |
+
Element.addMethods({ simulate: Event.simulate });
|
325 |
+
})()
|
326 |
+
//]]>
|
327 |
+
</script>
|
328 |
+
<script type="text/javascript">
|
329 |
+
//<![CDATA[
|
330 |
+
// Prototype-- http://michaelxavier.net/posts/2011-04-02-Document-Ready-in-Prototype.html
|
331 |
+
//
|
332 |
+
$MW_Onestepcheckout = jQuery;
|
333 |
+
(function() {
|
334 |
+
var init = function(){
|
335 |
+
|
336 |
+
Event.observe($('<?php echo $_code ?>_is_corporation'), 'change', toggleCorporationForm);
|
337 |
+
toggleCorporationForm();
|
338 |
+
|
339 |
+
<?php if ($cocNumberCheck): ?>
|
340 |
+
Event.observe($('<?php echo $_code?>_coc_number'), 'change', submitCocRequest);
|
341 |
+
<?php endif ?>
|
342 |
+
|
343 |
+
<?php if ($hasMageWorldOSC): ?>
|
344 |
+
listenAndApplyChanges('#billing\\:company', '#capayable_corporation_name');
|
345 |
+
listenAndApplyChanges('#billing\\:firstname', '#capayable_middlename');
|
346 |
+
listenAndApplyChanges('#billing\\:street1', '#capayable_street');
|
347 |
+
listenAndApplyChanges('#billing\\:street2', '#capayable_house_number');
|
348 |
+
listenAndApplyChanges('#billing\\:postcode', '#capayable_postcode');
|
349 |
+
listenAndApplyChanges('#billing\\:city', '#capayable_city');
|
350 |
+
<?php endif ?>
|
351 |
+
};
|
352 |
+
|
353 |
+
if (document.loaded) {
|
354 |
+
init();
|
355 |
+
} else {
|
356 |
+
document.observe('dom:loaded', init);
|
357 |
+
}
|
358 |
+
})();
|
359 |
+
|
360 |
+
function listenAndApplyChanges(oneStepCheckoutSelector, capayableSelector) {
|
361 |
+
|
362 |
+
// One step checkout uses jQuery under the alias $MW_Onestepcheckout.
|
363 |
+
|
364 |
+
var $oneStepCheckoutElement = $MW_Onestepcheckout(oneStepCheckoutSelector);
|
365 |
+
var $capayableElement = $MW_Onestepcheckout(capayableSelector);
|
366 |
+
|
367 |
+
$oneStepCheckoutElement.on('change', function() {
|
368 |
+
|
369 |
+
var val = $oneStepCheckoutElement.val();
|
370 |
+
|
371 |
+
if(capayableSelector == '#capayable_middlename' && val) {
|
372 |
+
names = val.split(' ');
|
373 |
+
val = '';
|
374 |
+
$MW_Onestepcheckout.each(names, function(index, name) {
|
375 |
+
val += name.substring(0,1) + '. ';
|
376 |
+
});
|
377 |
+
}
|
378 |
+
|
379 |
+
if(capayableSelector == '#capayable_house_number' && val) {
|
380 |
+
|
381 |
+
var matches = val.match(/[\d]+/);
|
382 |
+
if(matches && matches.length > 0){
|
383 |
+
var match = matches[0];
|
384 |
+
var index = match.length;
|
385 |
+
var suffix = val.substr(index);
|
386 |
+
|
387 |
+
$MW_Onestepcheckout('#capayable_house_suffix').val(suffix);
|
388 |
+
val = match;
|
389 |
+
}
|
390 |
+
}
|
391 |
+
|
392 |
+
if(capayableSelector == '#capayable_corporation_name') {
|
393 |
+
$MW_Onestepcheckout('#capayable_is_corporation').val(val ? 1 : 0);
|
394 |
+
|
395 |
+
// Trigger the prototype event
|
396 |
+
$('capayable_is_corporation').simulate('change');
|
397 |
+
}
|
398 |
+
|
399 |
+
$capayableElement.val(val);
|
400 |
+
});
|
401 |
+
$oneStepCheckoutElement.change();
|
402 |
+
}
|
403 |
+
|
404 |
+
function toggleCorporationForm() {
|
405 |
+
var elm = $('<?php echo $_code ?>_is_corporation');
|
406 |
+
if (elm.value == 1) {
|
407 |
+
$('<?php echo $_code ?>_is_sole_wrapper').show();
|
408 |
+
|
409 |
+
$('<?php echo $_code ?>_corporation_name_wrapper').show();
|
410 |
+
$('<?php echo $_code ?>_corporation_name').addClassName('required-entry');
|
411 |
+
|
412 |
+
$('<?php echo $_code ?>_coc_number_wrapper').show();
|
413 |
+
$('<?php echo $_code ?>_coc_number').addClassName('required-entry');
|
414 |
+
} else {
|
415 |
+
$('<?php echo $_code ?>_is_sole_wrapper').hide();
|
416 |
+
|
417 |
+
$('<?php echo $_code ?>_corporation_name_wrapper').hide();
|
418 |
+
$('<?php echo $_code ?>_corporation_name').removeClassName('required-entry');
|
419 |
+
|
420 |
+
$('<?php echo $_code ?>_coc_number_wrapper').hide();
|
421 |
+
$('<?php echo $_code ?>_coc_number').removeClassName('required-entry');
|
422 |
+
}
|
423 |
+
};
|
424 |
+
|
425 |
+
function updateCapayableFields() {
|
426 |
+
|
427 |
+
}
|
428 |
+
|
429 |
+
function submitCocRequest() {
|
430 |
+
new Ajax.Request("<?php echo Mage::getBaseUrl(); ?>capayable/ajax/registrationcheck", {
|
431 |
+
method: 'get',
|
432 |
+
parameters: {coc_number: $('<?php echo $_code ?>_coc_number').value},
|
433 |
+
onSuccess: cocRequestOnSuccess,
|
434 |
+
onFailure: cocRequestOnFailure
|
435 |
+
});
|
436 |
+
}
|
437 |
+
|
438 |
+
function cocRequestOnSuccess(response){
|
439 |
+
var json = response.responseText.evalJSON();
|
440 |
+
if (json.isAccepted) {
|
441 |
+
|
442 |
+
$('<?php echo $_code ?>_corporation_name').value = json.corporationName;
|
443 |
+
$('<?php echo $_code ?>_street').value = json.streetName;
|
444 |
+
$('<?php echo $_code ?>_house_number').value = json.houseNumber;
|
445 |
+
$('<?php echo $_code ?>_house_suffix').value = json.houseNumberSuffix;
|
446 |
+
$('<?php echo $_code ?>_postcode').value = json.zipCode;
|
447 |
+
$('<?php echo $_code ?>_city').value = json.city;
|
448 |
+
|
449 |
+
} else {
|
450 |
+
cocRequestOnFailure(response);
|
451 |
+
}
|
452 |
+
}
|
453 |
+
|
454 |
+
function cocRequestOnFailure(response){
|
455 |
+
$('<?php echo $_code ?>_corporation_name').value = '';
|
456 |
+
$('<?php echo $_code ?>_street').value = '';
|
457 |
+
$('<?php echo $_code ?>_house_number').value = '';
|
458 |
+
$('<?php echo $_code ?>_house_suffix').value = '';
|
459 |
+
$('<?php echo $_code ?>_postcode').value = '';
|
460 |
+
$('<?php echo $_code ?>_city').value = '';
|
461 |
+
}
|
462 |
+
//]]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
463 |
</script>
|
app/design/frontend/base/default/template/capayable/info.phtml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
-
<?php
|
2 |
-
echo $this->getMethod()->getTitle();
|
3 |
-
?>
|
4 |
-
|
5 |
-
<?php
|
6 |
-
if(Mage::registry('invoice_number')) {
|
7 |
-
$invoice_number = Mage::registry('invoice_number');
|
8 |
-
Mage::unregister('invoice_number');
|
9 |
-
?>
|
10 |
-
<br>
|
11 |
-
Please transfer the amount due to:<br>
|
12 |
-
<strong>Stichting Beheer Gelden Capayable</strong><br>
|
13 |
-
<strong>IBAN</strong> NL42INGB0006528043<br>
|
14 |
-
<br>
|
15 |
-
Use the following number as<br>
|
16 |
-
the payment reference: <?php echo $invoice_number; ?><br>
|
17 |
-
|
18 |
<?php } ?>
|
1 |
+
<?php
|
2 |
+
echo $this->getMethod()->getTitle();
|
3 |
+
?>
|
4 |
+
|
5 |
+
<?php
|
6 |
+
if(Mage::registry('invoice_number')) {
|
7 |
+
$invoice_number = Mage::registry('invoice_number');
|
8 |
+
Mage::unregister('invoice_number');
|
9 |
+
?>
|
10 |
+
<br>
|
11 |
+
Please transfer the amount due to:<br>
|
12 |
+
<strong>Stichting Beheer Gelden Capayable</strong><br>
|
13 |
+
<strong>IBAN</strong> NL42INGB0006528043<br>
|
14 |
+
<br>
|
15 |
+
Use the following number as<br>
|
16 |
+
the payment reference: <?php echo $invoice_number; ?><br>
|
17 |
+
|
18 |
<?php } ?>
|
app/etc/modules/Tritac_Capayable.xml
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* @category Tritac
|
5 |
-
* @package Tritac_Capayable
|
6 |
-
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
7 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
8 |
-
*/
|
9 |
-
-->
|
10 |
-
<config>
|
11 |
-
<modules>
|
12 |
-
<Tritac_Capayable>
|
13 |
-
<active>true</active>
|
14 |
-
<codePool>community</codePool>
|
15 |
-
</Tritac_Capayable>
|
16 |
-
</modules>
|
17 |
-
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category Tritac
|
5 |
+
* @package Tritac_Capayable
|
6 |
+
* @copyright Copyright (c) 2014 Tritac (http://www.tritac.com)
|
7 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<modules>
|
12 |
+
<Tritac_Capayable>
|
13 |
+
<active>true</active>
|
14 |
+
<codePool>community</codePool>
|
15 |
+
</Tritac_Capayable>
|
16 |
+
</modules>
|
17 |
+
</config>
|
lib/Tritac/CapayableApiClient/Client.php
CHANGED
@@ -1,224 +1,224 @@
|
|
1 |
-
<?php
|
2 |
-
class Tritac_CapayableApiClient_Client {
|
3 |
-
|
4 |
-
private $environment;
|
5 |
-
private $tenant;
|
6 |
-
private $certificate;
|
7 |
-
|
8 |
-
private $apiUrl;
|
9 |
-
private $apiKey;
|
10 |
-
private $apiSecret;
|
11 |
-
|
12 |
-
const FIDDLER_PROXY = '127.0.0.1:8888';
|
13 |
-
const USE_FIDDLER = false;
|
14 |
-
const FIDDLER_CERTIFICATE_PATH = 'fiddler.crt';
|
15 |
-
|
16 |
-
const ACC_URL = 'http://capayable-api-acc.tritac.com';
|
17 |
-
const TEST_URL = 'https://capayable-api-test.tritac.com';
|
18 |
-
const PROD_URL = 'https://capayable-api.tritac.com';
|
19 |
-
|
20 |
-
const VERSION_PATH = '/v1';
|
21 |
-
const CERTIFICATE_PATH = 'AddTrustExternalCARoot.crt';
|
22 |
-
|
23 |
-
const CREDITCHECK_PATH = '/creditcheck';
|
24 |
-
const INVOICE_PATH = '/invoice';
|
25 |
-
const INVOICECREDIT_PATH = '/invoicecredit';
|
26 |
-
const REGISTRATIONCHECK_PATH = '/registrationcheck';
|
27 |
-
|
28 |
-
public function __construct($apiKey, $apiSecret, $env = null)
|
29 |
-
{
|
30 |
-
if($env == null || $env == Tritac_CapayableApiClient_Enums_Environment::PROD) {
|
31 |
-
$this->apiUrl = self::PROD_URL;
|
32 |
-
} elseif($env == Tritac_CapayableApiClient_Enums_Environment::TEST) {
|
33 |
-
$this->apiUrl = self::TEST_URL;
|
34 |
-
} elseif($env == Tritac_CapayableApiClient_Enums_Environment::TEST) {
|
35 |
-
$this->apiUrl = self::ACC_URL;
|
36 |
-
}
|
37 |
-
|
38 |
-
$this->environment = $env;
|
39 |
-
$this->apiKey = $apiKey;
|
40 |
-
$this->apiSecret = $apiSecret;
|
41 |
-
$this->certificate = __DIR__ . DIRECTORY_SEPARATOR . (self::USE_FIDDLER ? self::FIDDLER_CERTIFICATE_PATH : self::CERTIFICATE_PATH);
|
42 |
-
}
|
43 |
-
|
44 |
-
public function doCreditCheck(Tritac_CapayableApiClient_Models_CreditCheckRequest $request)
|
45 |
-
{
|
46 |
-
$args = $request->toArray();
|
47 |
-
if(!$request->getIsCorporation()){
|
48 |
-
unset($args['CocNumber']);
|
49 |
-
unset($args['CorporationName']);
|
50 |
-
unset($args['IsSoleProprietor']);
|
51 |
-
}
|
52 |
-
|
53 |
-
$path = self::VERSION_PATH . self::CREDITCHECK_PATH;
|
54 |
-
|
55 |
-
$response = json_decode($this->makeRequest(Tritac_CapayableApiClient_Enums_HttpMethod::GET, $path, $this->buildQueryString($args, $path)), true);
|
56 |
-
|
57 |
-
$creditCheckResponse = new Tritac_CapayableApiClient_Models_CreditCheckResponse();
|
58 |
-
|
59 |
-
if( $response['IsAccepted'] ){
|
60 |
-
$creditCheckResponse->setAccepted($response['TransactionNumber']);
|
61 |
-
}else{
|
62 |
-
$creditCheckResponse->setRefused($response['RefuseReason'], $response['RefuseContactName'], $response['RefuseContactPhoneNumber']);
|
63 |
-
}
|
64 |
-
|
65 |
-
return $creditCheckResponse;
|
66 |
-
}
|
67 |
-
|
68 |
-
public function doRegistrationCheck(Tritac_CapayableApiClient_Models_RegistrationCheckRequest $request)
|
69 |
-
{
|
70 |
-
$args = $request->toArray();
|
71 |
-
|
72 |
-
$path = self::VERSION_PATH . self::REGISTRATIONCHECK_PATH;
|
73 |
-
|
74 |
-
$response = json_decode($this->makeRequest(Tritac_CapayableApiClient_Enums_HttpMethod::GET, $path, $this->buildQueryString($args, $path)), true);
|
75 |
-
|
76 |
-
$creditCheckResponse = new Tritac_CapayableApiClient_Models_RegistrationCheckResponse($response['IsAccepted'], $response['HouseNumber'],
|
77 |
-
$response['HouseNumberSuffix'], $response['ZipCode'], $response['City'], $response['CountryCode'],
|
78 |
-
$response['PhoneNumber'], $response['CorporationName'], $response['CoCNumber'], $response['StreetName']);
|
79 |
-
|
80 |
-
return $creditCheckResponse;
|
81 |
-
}
|
82 |
-
|
83 |
-
public function registerInvoice(Tritac_CapayableApiClient_Models_Invoice $invoice)
|
84 |
-
{
|
85 |
-
$args = $invoice->toArray();
|
86 |
-
$path = self::VERSION_PATH . self::INVOICE_PATH;
|
87 |
-
|
88 |
-
$response = json_decode($this->makeRequest(Tritac_CapayableApiClient_Enums_HttpMethod::GET, $path, $this->buildQueryString($args, $path)), true);
|
89 |
-
|
90 |
-
return $response['IsAccepted'];
|
91 |
-
}
|
92 |
-
|
93 |
-
public function creditInvoice(Tritac_CapayableApiClient_Models_InvoiceCreditRequest $request)
|
94 |
-
{
|
95 |
-
$args = $request->toArray();
|
96 |
-
$path = self::VERSION_PATH . self::INVOICECREDIT_PATH;
|
97 |
-
|
98 |
-
$response = json_decode($this->makeRequest(Tritac_CapayableApiClient_Enums_HttpMethod::GET, $path, $this->buildQueryString($args, $path)), true);
|
99 |
-
|
100 |
-
$invoiceCreditResponse = new Tritac_CapayableApiClient_Models_InvoiceCreditResponse($response['Result'], $response['AmountCredited'], $response['AmountNotCredited']);
|
101 |
-
|
102 |
-
return $invoiceCreditResponse;
|
103 |
-
}
|
104 |
-
|
105 |
-
/* Private methods */
|
106 |
-
|
107 |
-
private function makeRequest($method, $url, $queryString = '', $content = null)
|
108 |
-
{
|
109 |
-
$request = curl_init();
|
110 |
-
|
111 |
-
// Create the required Http headers
|
112 |
-
$headers = $this->buildHeaders($method, $content);
|
113 |
-
|
114 |
-
if(self::USE_FIDDLER)
|
115 |
-
{
|
116 |
-
// We use this to redirect the request through a local proxy and trace it with fiddler
|
117 |
-
curl_setopt($request, CURLOPT_PROXY, self::FIDDLER_PROXY);
|
118 |
-
}
|
119 |
-
|
120 |
-
// Set the Url
|
121 |
-
curl_setopt($request, CURLOPT_URL, $this->apiUrl . $url . $queryString);
|
122 |
-
|
123 |
-
// Add the headers and hmac auth.
|
124 |
-
curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
|
125 |
-
|
126 |
-
// Return the response as a string
|
127 |
-
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
|
128 |
-
|
129 |
-
// Set custom request method because curl has no setting for PUT and DELETE
|
130 |
-
curl_setopt($request, CURLOPT_CUSTOMREQUEST, $method);
|
131 |
-
|
132 |
-
// Make the headers accessible for debugging purposes
|
133 |
-
curl_setopt($request, CURLINFO_HEADER_OUT, true);
|
134 |
-
|
135 |
-
// Point curl to the correct certificate.
|
136 |
-
// See: http://stackoverflow.com/questions/6400300/php-curl-https-causing-exception-ssl-certificate-problem-verify-that-the-ca-cer
|
137 |
-
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, true);
|
138 |
-
curl_setopt($request, CURLOPT_CAINFO, $this->certificate);
|
139 |
-
|
140 |
-
// If we have a request body send it too
|
141 |
-
if(strlen($content) > 0)
|
142 |
-
curl_setopt($request, CURLOPT_POSTFIELDS, $content);
|
143 |
-
|
144 |
-
// Make the request
|
145 |
-
$response = curl_exec($request);
|
146 |
-
|
147 |
-
// Get the status code
|
148 |
-
$status = curl_getinfo($request, CURLINFO_HTTP_CODE);
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
// Check for errors
|
153 |
-
// First we check if the response is missing which will probably be caused by a cURL error
|
154 |
-
// After this the check if there are not HTTP errors (status codes other than 200-206)
|
155 |
-
if ($response === false)
|
156 |
-
{
|
157 |
-
$error = curl_error($request);
|
158 |
-
curl_close($request);
|
159 |
-
throw new Exception('cURL error: ' . $error);
|
160 |
-
}
|
161 |
-
else if($status < 200 || $status > 206)
|
162 |
-
{
|
163 |
-
$headers = curl_getinfo($request, CURLINFO_HEADER_OUT);
|
164 |
-
$message = json_decode($response);
|
165 |
-
|
166 |
-
curl_close($request);
|
167 |
-
|
168 |
-
throw new Exception('Output headers: '. "\n" . $headers ."\n\n".
|
169 |
-
'Content: ' . $content ."\n\n".
|
170 |
-
'Unexpected status code [' . $status . ']. The server returned the following message: "' . $message->Message . '"');
|
171 |
-
}
|
172 |
-
else
|
173 |
-
{
|
174 |
-
curl_close($request);
|
175 |
-
|
176 |
-
return $response;
|
177 |
-
}
|
178 |
-
}
|
179 |
-
|
180 |
-
private function buildHeaders($method, $content = null)
|
181 |
-
{
|
182 |
-
$headers = array(
|
183 |
-
'Accept: application/json',
|
184 |
-
'Content-Type: application/json; charset=utf-8',
|
185 |
-
'Content-Length: ' . strlen($content),
|
186 |
-
);
|
187 |
-
|
188 |
-
return $headers;
|
189 |
-
}
|
190 |
-
|
191 |
-
private function buildQueryString(array $args, $path)
|
192 |
-
{
|
193 |
-
|
194 |
-
$hash = $this->getHash($args, $path);
|
195 |
-
$args['signature'] = $hash;
|
196 |
-
$args['key'] = $this->apiKey;
|
197 |
-
$args['timestamp'] = gmdate('Y-m-d\TH:i:s\Z');
|
198 |
-
return $this->encodeQueryString($args);
|
199 |
-
}
|
200 |
-
|
201 |
-
private function getHash(array $args, $path){
|
202 |
-
// Copy the array
|
203 |
-
$sortedArgs = $args;
|
204 |
-
|
205 |
-
// Sort it
|
206 |
-
ksort($sortedArgs);
|
207 |
-
|
208 |
-
$sortedArgs['key'] = $this->apiKey;
|
209 |
-
$sortedArgs['timestamp'] = gmdate('Y-m-d\TH:i:s\Z');
|
210 |
-
|
211 |
-
$representation = $path . urldecode($this->encodeQueryString($sortedArgs));
|
212 |
-
$hash = hash_hmac('sha256', utf8_encode($representation), utf8_encode($this->apiSecret), true);
|
213 |
-
|
214 |
-
return base64_encode($hash);
|
215 |
-
}
|
216 |
-
|
217 |
-
private function encodeQueryString(array $args) {
|
218 |
-
$queryString = (count($args) > 0) ? '?' . http_build_query($args) : '';
|
219 |
-
|
220 |
-
// .Net does not seem to like the /?foo[0]=bar&foo[1]=baz notation so we
|
221 |
-
// convert it to /?foo=bar&foo=baz
|
222 |
-
return preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $queryString);
|
223 |
-
}
|
224 |
}
|
1 |
+
<?php
|
2 |
+
class Tritac_CapayableApiClient_Client {
|
3 |
+
|
4 |
+
private $environment;
|
5 |
+
private $tenant;
|
6 |
+
private $certificate;
|
7 |
+
|
8 |
+
private $apiUrl;
|
9 |
+
private $apiKey;
|
10 |
+
private $apiSecret;
|
11 |
+
|
12 |
+
const FIDDLER_PROXY = '127.0.0.1:8888';
|
13 |
+
const USE_FIDDLER = false;
|
14 |
+
const FIDDLER_CERTIFICATE_PATH = 'fiddler.crt';
|
15 |
+
|
16 |
+
const ACC_URL = 'http://capayable-api-acc.tritac.com';
|
17 |
+
const TEST_URL = 'https://capayable-api-test.tritac.com';
|
18 |
+
const PROD_URL = 'https://capayable-api.tritac.com';
|
19 |
+
|
20 |
+
const VERSION_PATH = '/v1';
|
21 |
+
const CERTIFICATE_PATH = 'AddTrustExternalCARoot.crt';
|
22 |
+
|
23 |
+
const CREDITCHECK_PATH = '/creditcheck';
|
24 |
+
const INVOICE_PATH = '/invoice';
|
25 |
+
const INVOICECREDIT_PATH = '/invoicecredit';
|
26 |
+
const REGISTRATIONCHECK_PATH = '/registrationcheck';
|
27 |
+
|
28 |
+
public function __construct($apiKey, $apiSecret, $env = null)
|
29 |
+
{
|
30 |
+
if($env == null || $env == Tritac_CapayableApiClient_Enums_Environment::PROD) {
|
31 |
+
$this->apiUrl = self::PROD_URL;
|
32 |
+
} elseif($env == Tritac_CapayableApiClient_Enums_Environment::TEST) {
|
33 |
+
$this->apiUrl = self::TEST_URL;
|
34 |
+
} elseif($env == Tritac_CapayableApiClient_Enums_Environment::TEST) {
|
35 |
+
$this->apiUrl = self::ACC_URL;
|
36 |
+
}
|
37 |
+
|
38 |
+
$this->environment = $env;
|
39 |
+
$this->apiKey = $apiKey;
|
40 |
+
$this->apiSecret = $apiSecret;
|
41 |
+
$this->certificate = __DIR__ . DIRECTORY_SEPARATOR . (self::USE_FIDDLER ? self::FIDDLER_CERTIFICATE_PATH : self::CERTIFICATE_PATH);
|
42 |
+
}
|
43 |
+
|
44 |
+
public function doCreditCheck(Tritac_CapayableApiClient_Models_CreditCheckRequest $request)
|
45 |
+
{
|
46 |
+
$args = $request->toArray();
|
47 |
+
if(!$request->getIsCorporation()){
|
48 |
+
unset($args['CocNumber']);
|
49 |
+
unset($args['CorporationName']);
|
50 |
+
unset($args['IsSoleProprietor']);
|
51 |
+
}
|
52 |
+
|
53 |
+
$path = self::VERSION_PATH . self::CREDITCHECK_PATH;
|
54 |
+
|
55 |
+
$response = json_decode($this->makeRequest(Tritac_CapayableApiClient_Enums_HttpMethod::GET, $path, $this->buildQueryString($args, $path)), true);
|
56 |
+
|
57 |
+
$creditCheckResponse = new Tritac_CapayableApiClient_Models_CreditCheckResponse();
|
58 |
+
|
59 |
+
if( $response['IsAccepted'] ){
|
60 |
+
$creditCheckResponse->setAccepted($response['TransactionNumber']);
|
61 |
+
}else{
|
62 |
+
$creditCheckResponse->setRefused($response['RefuseReason'], $response['RefuseContactName'], $response['RefuseContactPhoneNumber']);
|
63 |
+
}
|
64 |
+
|
65 |
+
return $creditCheckResponse;
|
66 |
+
}
|
67 |
+
|
68 |
+
public function doRegistrationCheck(Tritac_CapayableApiClient_Models_RegistrationCheckRequest $request)
|
69 |
+
{
|
70 |
+
$args = $request->toArray();
|
71 |
+
|
72 |
+
$path = self::VERSION_PATH . self::REGISTRATIONCHECK_PATH;
|
73 |
+
|
74 |
+
$response = json_decode($this->makeRequest(Tritac_CapayableApiClient_Enums_HttpMethod::GET, $path, $this->buildQueryString($args, $path)), true);
|
75 |
+
|
76 |
+
$creditCheckResponse = new Tritac_CapayableApiClient_Models_RegistrationCheckResponse($response['IsAccepted'], $response['HouseNumber'],
|
77 |
+
$response['HouseNumberSuffix'], $response['ZipCode'], $response['City'], $response['CountryCode'],
|
78 |
+
$response['PhoneNumber'], $response['CorporationName'], $response['CoCNumber'], $response['StreetName']);
|
79 |
+
|
80 |
+
return $creditCheckResponse;
|
81 |
+
}
|
82 |
+
|
83 |
+
public function registerInvoice(Tritac_CapayableApiClient_Models_Invoice $invoice)
|
84 |
+
{
|
85 |
+
$args = $invoice->toArray();
|
86 |
+
$path = self::VERSION_PATH . self::INVOICE_PATH;
|
87 |
+
|
88 |
+
$response = json_decode($this->makeRequest(Tritac_CapayableApiClient_Enums_HttpMethod::GET, $path, $this->buildQueryString($args, $path)), true);
|
89 |
+
|
90 |
+
return $response['IsAccepted'];
|
91 |
+
}
|
92 |
+
|
93 |
+
public function creditInvoice(Tritac_CapayableApiClient_Models_InvoiceCreditRequest $request)
|
94 |
+
{
|
95 |
+
$args = $request->toArray();
|
96 |
+
$path = self::VERSION_PATH . self::INVOICECREDIT_PATH;
|
97 |
+
|
98 |
+
$response = json_decode($this->makeRequest(Tritac_CapayableApiClient_Enums_HttpMethod::GET, $path, $this->buildQueryString($args, $path)), true);
|
99 |
+
|
100 |
+
$invoiceCreditResponse = new Tritac_CapayableApiClient_Models_InvoiceCreditResponse($response['Result'], $response['AmountCredited'], $response['AmountNotCredited']);
|
101 |
+
|
102 |
+
return $invoiceCreditResponse;
|
103 |
+
}
|
104 |
+
|
105 |
+
/* Private methods */
|
106 |
+
|
107 |
+
private function makeRequest($method, $url, $queryString = '', $content = null)
|
108 |
+
{
|
109 |
+
$request = curl_init();
|
110 |
+
|
111 |
+
// Create the required Http headers
|
112 |
+
$headers = $this->buildHeaders($method, $content);
|
113 |
+
|
114 |
+
if(self::USE_FIDDLER)
|
115 |
+
{
|
116 |
+
// We use this to redirect the request through a local proxy and trace it with fiddler
|
117 |
+
curl_setopt($request, CURLOPT_PROXY, self::FIDDLER_PROXY);
|
118 |
+
}
|
119 |
+
|
120 |
+
// Set the Url
|
121 |
+
curl_setopt($request, CURLOPT_URL, $this->apiUrl . $url . $queryString);
|
122 |
+
|
123 |
+
// Add the headers and hmac auth.
|
124 |
+
curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
|
125 |
+
|
126 |
+
// Return the response as a string
|
127 |
+
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
|
128 |
+
|
129 |
+
// Set custom request method because curl has no setting for PUT and DELETE
|
130 |
+
curl_setopt($request, CURLOPT_CUSTOMREQUEST, $method);
|
131 |
+
|
132 |
+
// Make the headers accessible for debugging purposes
|
133 |
+
curl_setopt($request, CURLINFO_HEADER_OUT, true);
|
134 |
+
|
135 |
+
// Point curl to the correct certificate.
|
136 |
+
// See: http://stackoverflow.com/questions/6400300/php-curl-https-causing-exception-ssl-certificate-problem-verify-that-the-ca-cer
|
137 |
+
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, true);
|
138 |
+
curl_setopt($request, CURLOPT_CAINFO, $this->certificate);
|
139 |
+
|
140 |
+
// If we have a request body send it too
|
141 |
+
if(strlen($content) > 0)
|
142 |
+
curl_setopt($request, CURLOPT_POSTFIELDS, $content);
|
143 |
+
|
144 |
+
// Make the request
|
145 |
+
$response = curl_exec($request);
|
146 |
+
|
147 |
+
// Get the status code
|
148 |
+
$status = curl_getinfo($request, CURLINFO_HTTP_CODE);
|
149 |
+
|
150 |
+
|
151 |
+
|
152 |
+
// Check for errors
|
153 |
+
// First we check if the response is missing which will probably be caused by a cURL error
|
154 |
+
// After this the check if there are not HTTP errors (status codes other than 200-206)
|
155 |
+
if ($response === false)
|
156 |
+
{
|
157 |
+
$error = curl_error($request);
|
158 |
+
curl_close($request);
|
159 |
+
throw new Exception('cURL error: ' . $error);
|
160 |
+
}
|
161 |
+
else if($status < 200 || $status > 206)
|
162 |
+
{
|
163 |
+
$headers = curl_getinfo($request, CURLINFO_HEADER_OUT);
|
164 |
+
$message = json_decode($response);
|
165 |
+
|
166 |
+
curl_close($request);
|
167 |
+
|
168 |
+
throw new Exception('Output headers: '. "\n" . $headers ."\n\n".
|
169 |
+
'Content: ' . $content ."\n\n".
|
170 |
+
'Unexpected status code [' . $status . ']. The server returned the following message: "' . $message->Message . '"');
|
171 |
+
}
|
172 |
+
else
|
173 |
+
{
|
174 |
+
curl_close($request);
|
175 |
+
|
176 |
+
return $response;
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
private function buildHeaders($method, $content = null)
|
181 |
+
{
|
182 |
+
$headers = array(
|
183 |
+
'Accept: application/json',
|
184 |
+
'Content-Type: application/json; charset=utf-8',
|
185 |
+
'Content-Length: ' . strlen($content),
|
186 |
+
);
|
187 |
+
|
188 |
+
return $headers;
|
189 |
+
}
|
190 |
+
|
191 |
+
private function buildQueryString(array $args, $path)
|
192 |
+
{
|
193 |
+
|
194 |
+
$hash = $this->getHash($args, $path);
|
195 |
+
$args['signature'] = $hash;
|
196 |
+
$args['key'] = $this->apiKey;
|
197 |
+
$args['timestamp'] = gmdate('Y-m-d\TH:i:s\Z');
|
198 |
+
return $this->encodeQueryString($args);
|
199 |
+
}
|
200 |
+
|
201 |
+
private function getHash(array $args, $path){
|
202 |
+
// Copy the array
|
203 |
+
$sortedArgs = $args;
|
204 |
+
|
205 |
+
// Sort it
|
206 |
+
ksort($sortedArgs);
|
207 |
+
|
208 |
+
$sortedArgs['key'] = $this->apiKey;
|
209 |
+
$sortedArgs['timestamp'] = gmdate('Y-m-d\TH:i:s\Z');
|
210 |
+
|
211 |
+
$representation = $path . urldecode($this->encodeQueryString($sortedArgs));
|
212 |
+
$hash = hash_hmac('sha256', utf8_encode($representation), utf8_encode($this->apiSecret), true);
|
213 |
+
|
214 |
+
return base64_encode($hash);
|
215 |
+
}
|
216 |
+
|
217 |
+
private function encodeQueryString(array $args) {
|
218 |
+
$queryString = (count($args) > 0) ? '?' . http_build_query($args) : '';
|
219 |
+
|
220 |
+
// .Net does not seem to like the /?foo[0]=bar&foo[1]=baz notation so we
|
221 |
+
// convert it to /?foo=bar&foo=baz
|
222 |
+
return preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $queryString);
|
223 |
+
}
|
224 |
}
|
lib/Tritac/CapayableApiClient/Enums/Enum.php
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
<?php
|
2 |
-
class Tritac_CapayableApiClient_Enums_Enum {
|
3 |
-
|
4 |
-
private static $reflector;
|
5 |
-
|
6 |
-
public static function toArray()
|
7 |
-
{
|
8 |
-
self::$reflector = new ReflectionClass(get_called_class());
|
9 |
-
return self::$reflector->getConstants();
|
10 |
-
}
|
11 |
-
|
12 |
-
public static function toString($value){
|
13 |
-
$fields = self::toArray();
|
14 |
-
return array_search($value, $fields);
|
15 |
-
}
|
16 |
-
|
17 |
}
|
1 |
+
<?php
|
2 |
+
class Tritac_CapayableApiClient_Enums_Enum {
|
3 |
+
|
4 |
+
private static $reflector;
|
5 |
+
|
6 |
+
public static function toArray()
|
7 |
+
{
|
8 |
+
self::$reflector = new ReflectionClass(get_called_class());
|
9 |
+
return self::$reflector->getConstants();
|
10 |
+
}
|
11 |
+
|
12 |
+
public static function toString($value){
|
13 |
+
$fields = self::toArray();
|
14 |
+
return array_search($value, $fields);
|
15 |
+
}
|
16 |
+
|
17 |
}
|
lib/Tritac/CapayableApiClient/Enums/Environment.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
<?php
|
2 |
-
class Tritac_CapayableApiClient_Enums_Environment {
|
3 |
-
|
4 |
-
const ACC = 0;
|
5 |
-
const TEST = 1;
|
6 |
-
const PROD = 2;
|
7 |
-
|
8 |
}
|
1 |
+
<?php
|
2 |
+
class Tritac_CapayableApiClient_Enums_Environment {
|
3 |
+
|
4 |
+
const ACC = 0;
|
5 |
+
const TEST = 1;
|
6 |
+
const PROD = 2;
|
7 |
+
|
8 |
}
|
lib/Tritac/CapayableApiClient/Enums/Gender.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
<?php
|
2 |
-
class Tritac_CapayableApiClient_Enums_Gender {
|
3 |
-
|
4 |
-
const MALE = 'MALE';
|
5 |
-
const FEMALE = 'FEMALE';
|
6 |
-
const UNKNOWN = 'UNKNOWN';
|
7 |
-
|
8 |
}
|
1 |
+
<?php
|
2 |
+
class Tritac_CapayableApiClient_Enums_Gender {
|
3 |
+
|
4 |
+
const MALE = 'MALE';
|
5 |
+
const FEMALE = 'FEMALE';
|
6 |
+
const UNKNOWN = 'UNKNOWN';
|
7 |
+
|
8 |
}
|
lib/Tritac/CapayableApiClient/Enums/HttpMethod.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
-
<?php
|
2 |
-
class Tritac_CapayableApiClient_Enums_HttpMethod {
|
3 |
-
|
4 |
-
const GET = 'GET';
|
5 |
-
const POST = 'POST';
|
6 |
-
const PUT = 'PUT';
|
7 |
-
const DELETE = 'DELETE';
|
8 |
-
|
9 |
}
|
1 |
+
<?php
|
2 |
+
class Tritac_CapayableApiClient_Enums_HttpMethod {
|
3 |
+
|
4 |
+
const GET = 'GET';
|
5 |
+
const POST = 'POST';
|
6 |
+
const PUT = 'PUT';
|
7 |
+
const DELETE = 'DELETE';
|
8 |
+
|
9 |
}
|
lib/Tritac/CapayableApiClient/Enums/InvoiceCreditStatus.php
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
-
<?php
|
2 |
-
class Tritac_CapayableApiClient_Enums_InvoiceCreditStatus extends Tritac_CapayableApiClient_Enums_Enum{
|
3 |
-
|
4 |
-
// UNPAID (0) The invoice is fully unpaid. The original invoice will be credited by
|
5 |
-
// the given credit amount (AmountCredited = CreditAmount)
|
6 |
-
const UNPAID = 0;
|
7 |
-
|
8 |
-
// ALREADY_PAID (1) The invoice is fully paid. Credits on the original invoice is
|
9 |
-
// are possible. The webshop should do a refund. (AmountCredited = 0)
|
10 |
-
const ALREADY_PAID = 1;
|
11 |
-
|
12 |
-
// PARTIALLY_PAID (2) The invoice is partially paid. If the remaining unpaid
|
13 |
-
// amount is larger than the credit amount, it will be credited (AmountCredited
|
14 |
-
// = CreditAmount). If not, the unpaid amount is credited, the webshop should
|
15 |
-
// do a refund of the leftover (AmountCredited = unpaid amount,
|
16 |
-
// AmountNotCredited = CreditAmount – unpaid amount)
|
17 |
-
const PARTIALLY_PAID = 2;
|
18 |
-
|
19 |
-
// EXCEEDS_PERIOD_LIMIT (3) The call is later than 14 days after the
|
20 |
-
// InvoiceDate. Credit is no longer possible. (AmountCredited = 0)
|
21 |
-
const EXCEEDS_PERIOD_LIMIT = 3;
|
22 |
-
|
23 |
}
|
1 |
+
<?php
|
2 |
+
class Tritac_CapayableApiClient_Enums_InvoiceCreditStatus extends Tritac_CapayableApiClient_Enums_Enum{
|
3 |
+
|
4 |
+
// UNPAID (0) The invoice is fully unpaid. The original invoice will be credited by
|
5 |
+
// the given credit amount (AmountCredited = CreditAmount)
|
6 |
+
const UNPAID = 0;
|
7 |
+
|
8 |
+
// ALREADY_PAID (1) The invoice is fully paid. Credits on the original invoice is
|
9 |
+
// are possible. The webshop should do a refund. (AmountCredited = 0)
|
10 |
+
const ALREADY_PAID = 1;
|
11 |
+
|
12 |
+
// PARTIALLY_PAID (2) The invoice is partially paid. If the remaining unpaid
|
13 |
+
// amount is larger than the credit amount, it will be credited (AmountCredited
|
14 |
+
// = CreditAmount). If not, the unpaid amount is credited, the webshop should
|
15 |
+
// do a refund of the leftover (AmountCredited = unpaid amount,
|
16 |
+
// AmountNotCredited = CreditAmount – unpaid amount)
|
17 |
+
const PARTIALLY_PAID = 2;
|
18 |
+
|
19 |
+
// EXCEEDS_PERIOD_LIMIT (3) The call is later than 14 days after the
|
20 |
+
// InvoiceDate. Credit is no longer possible. (AmountCredited = 0)
|
21 |
+
const EXCEEDS_PERIOD_LIMIT = 3;
|
22 |
+
|
23 |
}
|
lib/Tritac/CapayableApiClient/Enums/InvoicePdfSubmitType.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
-
<?php
|
2 |
-
class Tritac_CapayableApiClient_Enums_InvoicePdfSubmitType {
|
3 |
-
|
4 |
-
// Capayable will fetch the invoice from the URL provided
|
5 |
-
const URL = 0;
|
6 |
-
|
7 |
-
// The shop will send an email with the invoice to
|
8 |
-
// capayable-invoice-bcc@tritac.com
|
9 |
-
const BCC_EMAIL = 1;
|
10 |
-
}
|
1 |
+
<?php
|
2 |
+
class Tritac_CapayableApiClient_Enums_InvoicePdfSubmitType {
|
3 |
+
|
4 |
+
// Capayable will fetch the invoice from the URL provided
|
5 |
+
const URL = 0;
|
6 |
+
|
7 |
+
// The shop will send an email with the invoice to
|
8 |
+
// capayable-invoice-bcc@tritac.com
|
9 |
+
const BCC_EMAIL = 1;
|
10 |
+
}
|
lib/Tritac/CapayableApiClient/Enums/RefuseReason.php
CHANGED
@@ -1,23 +1,23 @@
|
|
1 |
-
<?php
|
2 |
-
class Tritac_CapayableApiClient_Enums_RefuseReason extends Tritac_CapayableApiClient_Enums_Enum{
|
3 |
-
|
4 |
-
// Each shop has an order amount limit above which pay after delivery by Capayable is
|
5 |
-
// not available. AMOUNT_EXCEEDS_LIMIT (1) means the order amount is above this limit
|
6 |
-
const AMOUNT_EXCEEDS_LIMIT = 1;
|
7 |
-
|
8 |
-
// There is a limit on the unpaid sum of all orders with this shops or other shops using
|
9 |
-
// Capayable. BALANCE_EXCEEDS_LIMIT (2) means the order amount plus the balance
|
10 |
-
// of unpaid orders by the customer is above this limit.
|
11 |
-
const BALANCE_EXEEDS_LIMIT = 2;
|
12 |
-
|
13 |
-
// Capayable uses services for the actual credit check (B2C: EDR, B2B: CreditSafe).
|
14 |
-
// NOT_CREDITWORTHY (3) means the customer is not accepted for credit by this service.
|
15 |
-
const NOT_CREDITWORTHY = 3;
|
16 |
-
|
17 |
-
// CREDITCHECK_UNAVAILABLE (4) means the extern credit check service is not be available.
|
18 |
-
const CREDITCHECK_UNAVAILABLE = 4;
|
19 |
-
|
20 |
-
// NOT_FOUND (5) means the corporation could not be found based on its name
|
21 |
-
// and/or its address (B2B only).
|
22 |
-
const NOT_FOUND = 5;
|
23 |
-
}
|
1 |
+
<?php
|
2 |
+
class Tritac_CapayableApiClient_Enums_RefuseReason extends Tritac_CapayableApiClient_Enums_Enum{
|
3 |
+
|
4 |
+
// Each shop has an order amount limit above which pay after delivery by Capayable is
|
5 |
+
// not available. AMOUNT_EXCEEDS_LIMIT (1) means the order amount is above this limit
|
6 |
+
const AMOUNT_EXCEEDS_LIMIT = 1;
|
7 |
+
|
8 |
+
// There is a limit on the unpaid sum of all orders with this shops or other shops using
|
9 |
+
// Capayable. BALANCE_EXCEEDS_LIMIT (2) means the order amount plus the balance
|
10 |
+
// of unpaid orders by the customer is above this limit.
|
11 |
+
const BALANCE_EXEEDS_LIMIT = 2;
|
12 |
+
|
13 |
+
// Capayable uses services for the actual credit check (B2C: EDR, B2B: CreditSafe).
|
14 |
+
// NOT_CREDITWORTHY (3) means the customer is not accepted for credit by this service.
|
15 |
+
const NOT_CREDITWORTHY = 3;
|
16 |
+
|
17 |
+
// CREDITCHECK_UNAVAILABLE (4) means the extern credit check service is not be available.
|
18 |
+
const CREDITCHECK_UNAVAILABLE = 4;
|
19 |
+
|
20 |
+
// NOT_FOUND (5) means the corporation could not be found based on its name
|
21 |
+
// and/or its address (B2B only).
|
22 |
+
const NOT_FOUND = 5;
|
23 |
+
}
|
lib/Tritac/CapayableApiClient/Models/BaseModel.php
CHANGED
@@ -1,32 +1,32 @@
|
|
1 |
-
<?php
|
2 |
-
abstract class Tritac_CapayableApiClient_Models_BaseModel {
|
3 |
-
|
4 |
-
public static $typeMap = array(
|
5 |
-
|
6 |
-
);
|
7 |
-
|
8 |
-
public function getTypeName()
|
9 |
-
{
|
10 |
-
return get_called_class();
|
11 |
-
}
|
12 |
-
|
13 |
-
public function toArray()
|
14 |
-
{
|
15 |
-
$vars = get_object_vars($this);
|
16 |
-
$arr = array();
|
17 |
-
foreach($vars as $key => $value) {
|
18 |
-
$newKey = ucfirst($key);
|
19 |
-
$getter = 'get' . $newKey;
|
20 |
-
$value = $this->{$getter}();
|
21 |
-
|
22 |
-
if(is_bool($value)) {
|
23 |
-
$arr[$newKey] = ($value) ? 'True' : 'False';
|
24 |
-
} elseif(!empty($value)) {
|
25 |
-
$arr[$newKey] = $value;
|
26 |
-
}
|
27 |
-
|
28 |
-
}
|
29 |
-
|
30 |
-
return $arr;
|
31 |
-
}
|
32 |
}
|
1 |
+
<?php
|
2 |
+
abstract class Tritac_CapayableApiClient_Models_BaseModel {
|
3 |
+
|
4 |
+
public static $typeMap = array(
|
5 |
+
|
6 |
+
);
|
7 |
+
|
8 |
+
public function getTypeName()
|
9 |
+
{
|
10 |
+
return get_called_class();
|
11 |
+
}
|
12 |
+
|
13 |
+
public function toArray()
|
14 |
+
{
|
15 |
+
$vars = get_object_vars($this);
|
16 |
+
$arr = array();
|
17 |
+
foreach($vars as $key => $value) {
|
18 |
+
$newKey = ucfirst($key);
|
19 |
+
$getter = 'get' . $newKey;
|
20 |
+
$value = $this->{$getter}();
|
21 |
+
|
22 |
+
if(is_bool($value)) {
|
23 |
+
$arr[$newKey] = ($value) ? 'True' : 'False';
|
24 |
+
} elseif(!empty($value)) {
|
25 |
+
$arr[$newKey] = $value;
|
26 |
+
}
|
27 |
+
|
28 |
+
}
|
29 |
+
|
30 |
+
return $arr;
|
31 |
+
}
|
32 |
}
|
lib/Tritac/CapayableApiClient/Models/CreditCheckRequest.php
CHANGED
@@ -1,243 +1,243 @@
|
|
1 |
-
<?php
|
2 |
-
class Tritac_CapayableApiClient_Models_CreditCheckRequest extends Tritac_CapayableApiClient_Models_BaseModel
|
3 |
-
{
|
4 |
-
protected $lastName;
|
5 |
-
protected $initials;
|
6 |
-
protected $gender; // https://en.wikipedia.org/wiki/ISO/IEC_5218
|
7 |
-
protected $birthDate;
|
8 |
-
protected $streetName;
|
9 |
-
protected $houseNumber;
|
10 |
-
protected $houseNumberSuffix;
|
11 |
-
protected $zipCode;
|
12 |
-
protected $city;
|
13 |
-
protected $countryCode;
|
14 |
-
protected $phoneNumber;
|
15 |
-
protected $faxNumber;
|
16 |
-
protected $emailAddress;
|
17 |
-
protected $isCorporation;
|
18 |
-
|
19 |
-
// For corporations
|
20 |
-
protected $corporationName;
|
21 |
-
protected $cocNumber;
|
22 |
-
protected $isSoleProprietor;
|
23 |
-
|
24 |
-
protected $isFinal;
|
25 |
-
protected $claimAmount;
|
26 |
-
|
27 |
-
public function __construct()
|
28 |
-
{
|
29 |
-
$this->lastName = '';
|
30 |
-
$this->initials = '';
|
31 |
-
$this->gender = Tritac_CapayableApiClient_Enums_Gender::UNKNOWN; // https://en.wikipedia.org/wiki/ISO/IEC_5218
|
32 |
-
$this->birthDate = new DateTime();
|
33 |
-
$this->streetName = '';
|
34 |
-
$this->houseNumber = '';
|
35 |
-
$this->houseNumberSuffix = '';
|
36 |
-
$this->zipCode = '';
|
37 |
-
$this->city = '';
|
38 |
-
$this->countryCode = '';
|
39 |
-
$this->phoneNumber = '';
|
40 |
-
$this->faxNumber = '';
|
41 |
-
$this->emailAddress = '';
|
42 |
-
$this->isCorporation = false;
|
43 |
-
$this->corporationName = '';
|
44 |
-
$this->cocNumber = '';
|
45 |
-
$this->isSoleProprietor = false;
|
46 |
-
$this->isFinal = false;
|
47 |
-
$this->claimAmount = 0;
|
48 |
-
}
|
49 |
-
|
50 |
-
function getLastName() { return $this->lastName; }
|
51 |
-
function setLastName($lastName) {
|
52 |
-
|
53 |
-
if(strlen($lastName) > 150) {
|
54 |
-
throw new Exception('Last name may not exceed 150 characters');
|
55 |
-
}
|
56 |
-
|
57 |
-
$this->lastName = $lastName;
|
58 |
-
}
|
59 |
-
|
60 |
-
|
61 |
-
function getInitials() { return $this->initials; }
|
62 |
-
function setInitials($initials) {
|
63 |
-
|
64 |
-
if(strlen($initials) > 10) {
|
65 |
-
throw new Exception('Initials may not exceed 10 characters');
|
66 |
-
}
|
67 |
-
|
68 |
-
$this->initials = $initials;
|
69 |
-
}
|
70 |
-
|
71 |
-
|
72 |
-
function getGender() { return $this->gender; }
|
73 |
-
function setGender($gender) {
|
74 |
-
if(
|
75 |
-
$gender != Tritac_CapayableApiClient_Enums_Gender::MALE &&
|
76 |
-
$gender != Tritac_CapayableApiClient_Enums_Gender::FEMALE &&
|
77 |
-
$gender != Tritac_CapayableApiClient_Enums_Gender::UNKNOWN
|
78 |
-
) {
|
79 |
-
throw new Exception('Gender invalid, please use CapayableApiClient\Enums\Gender');
|
80 |
-
}
|
81 |
-
$this->gender = $gender;
|
82 |
-
}
|
83 |
-
|
84 |
-
function getBirthDate() { return $this->birthDate->format('Y-m-d'); }
|
85 |
-
function getBirthDateAsDateTime() { return $this->birthDate; }
|
86 |
-
function setBirthDate($birthDate) {
|
87 |
-
|
88 |
-
$this->birthDate = new DateTime($birthDate);
|
89 |
-
}
|
90 |
-
function setBirthDateAsDateTime(DateTime $birthDate) {
|
91 |
-
$this->birthDate = $birthDate;
|
92 |
-
}
|
93 |
-
|
94 |
-
function getStreetName() { return $this->streetName; }
|
95 |
-
function setStreetName($streetName) {
|
96 |
-
|
97 |
-
if(strlen($streetName) > 150) {
|
98 |
-
throw new Exception('Street name may not exceed 150 characters');
|
99 |
-
}
|
100 |
-
|
101 |
-
$this->streetName = $streetName;
|
102 |
-
}
|
103 |
-
|
104 |
-
function getHouseNumber() { return $this->houseNumber; }
|
105 |
-
function setHouseNumber($houseNumber) {
|
106 |
-
|
107 |
-
if(!is_numeric($houseNumber)) {
|
108 |
-
throw new Exception('House number must be numeric');
|
109 |
-
}
|
110 |
-
|
111 |
-
$this->houseNumber = $houseNumber;
|
112 |
-
}
|
113 |
-
|
114 |
-
function getHouseNumberSuffix() { return $this->houseNumberSuffix; }
|
115 |
-
function setHouseNumberSuffix($houseNumberSuffix) {
|
116 |
-
|
117 |
-
if(strlen($houseNumberSuffix) > 10) {
|
118 |
-
throw new Exception('House number suffix may not exceed 10 characters');
|
119 |
-
}
|
120 |
-
|
121 |
-
$this->houseNumberSuffix = $houseNumberSuffix;
|
122 |
-
|
123 |
-
}
|
124 |
-
|
125 |
-
function getZipCode() { return $this->zipCode; }
|
126 |
-
function setZipCode($zipCode) {
|
127 |
-
|
128 |
-
if(strlen($zipCode) > 20) {
|
129 |
-
throw new Exception('Zip code may not exceed 20 characters');
|
130 |
-
}
|
131 |
-
|
132 |
-
$this->zipCode = $zipCode;
|
133 |
-
}
|
134 |
-
|
135 |
-
function getCity() { return $this->city; }
|
136 |
-
function setCity($city) {
|
137 |
-
|
138 |
-
if(strlen($city) > 150) {
|
139 |
-
throw new Exception('Zip code may not exceed 150 characters');
|
140 |
-
}
|
141 |
-
|
142 |
-
$this->city = $city;
|
143 |
-
}
|
144 |
-
|
145 |
-
function getCountryCode() { return $this->countryCode; }
|
146 |
-
function setCountryCode($countryCode) {
|
147 |
-
|
148 |
-
if(strlen($countryCode) > 2) {
|
149 |
-
throw new Exception('Country code may not exceed 2 characters');
|
150 |
-
}
|
151 |
-
|
152 |
-
$this->countryCode = $countryCode;
|
153 |
-
|
154 |
-
}
|
155 |
-
|
156 |
-
function getPhoneNumber() { return $this->phoneNumber; }
|
157 |
-
function setPhoneNumber($phoneNumber) {
|
158 |
-
|
159 |
-
if(strlen($phoneNumber) > 20) {
|
160 |
-
throw new Exception('Phone number may not exceed 20 characters');
|
161 |
-
}
|
162 |
-
|
163 |
-
$this->phoneNumber = $phoneNumber;
|
164 |
-
|
165 |
-
}
|
166 |
-
|
167 |
-
function getFaxNumber() { return $this->faxNumber; }
|
168 |
-
function setFaxNumber($faxNumber) {
|
169 |
-
|
170 |
-
if(strlen($faxNumber) > 20) {
|
171 |
-
throw new Exception('Fax number may not exceed 20 characters');
|
172 |
-
}
|
173 |
-
|
174 |
-
$this->faxNumber = $faxNumber;
|
175 |
-
|
176 |
-
}
|
177 |
-
|
178 |
-
function getIsCorporation() { return $this->isCorporation; }
|
179 |
-
function setIsCorporation($isCorporation) {
|
180 |
-
|
181 |
-
if(!is_bool($isCorporation)){
|
182 |
-
throw new Exception('Is corporation must be a boolean');
|
183 |
-
}
|
184 |
-
|
185 |
-
$this->isCorporation = $isCorporation;
|
186 |
-
}
|
187 |
-
|
188 |
-
function getIsSoleProprietor() { return $this->isSoleProprietor; }
|
189 |
-
function setIsSoleProprietor($isSoleProprietor) {
|
190 |
-
|
191 |
-
if(!is_bool($isSoleProprietor)){
|
192 |
-
throw new Exception('Is sole proprietor must be a boolean');
|
193 |
-
}
|
194 |
-
|
195 |
-
$this->isSoleProprietor = $isSoleProprietor;
|
196 |
-
}
|
197 |
-
|
198 |
-
function getEmailAddress() { return $this->emailAddress; }
|
199 |
-
function setEmailAddress($emailAddress) {
|
200 |
-
|
201 |
-
if(!filter_var($emailAddress, FILTER_VALIDATE_EMAIL)){
|
202 |
-
throw new Exception('Must be a valid email');
|
203 |
-
}
|
204 |
-
|
205 |
-
$this->emailAddress = $emailAddress;
|
206 |
-
}
|
207 |
-
|
208 |
-
function getCorporationName() { return $this->corporationName; }
|
209 |
-
function setCorporationName($corporationName) {
|
210 |
-
$this->corporationName = $corporationName;
|
211 |
-
}
|
212 |
-
|
213 |
-
function getCocNumber() { return $this->cocNumber; }
|
214 |
-
function setCocNumber($cocNumber) {
|
215 |
-
|
216 |
-
if(strlen($cocNumber) > 20) {
|
217 |
-
throw new Exception('Chamber of commerce number may not exceed 20 characters');
|
218 |
-
}
|
219 |
-
|
220 |
-
$this->cocNumber = $cocNumber;
|
221 |
-
|
222 |
-
}
|
223 |
-
|
224 |
-
function getIsFinal() { return $this->isFinal; }
|
225 |
-
function setIsFinal($isFinal) {
|
226 |
-
|
227 |
-
if(!is_bool($isFinal)) {
|
228 |
-
throw new Exception('Is final must be a boolean');
|
229 |
-
}
|
230 |
-
|
231 |
-
$this->isFinal = $isFinal;
|
232 |
-
}
|
233 |
-
|
234 |
-
function getClaimAmount() { return $this->claimAmount; }
|
235 |
-
function setClaimAmount($claimAmount) {
|
236 |
-
|
237 |
-
if(!is_numeric($claimAmount)) {
|
238 |
-
throw new Exception('Claim amount must be numeric');
|
239 |
-
}
|
240 |
-
|
241 |
-
$this->claimAmount = $claimAmount;
|
242 |
-
}
|
243 |
}
|
1 |
+
<?php
|
2 |
+
class Tritac_CapayableApiClient_Models_CreditCheckRequest extends Tritac_CapayableApiClient_Models_BaseModel
|
3 |
+
{
|
4 |
+
protected $lastName;
|
5 |
+
protected $initials;
|
6 |
+
protected $gender; // https://en.wikipedia.org/wiki/ISO/IEC_5218
|
7 |
+
protected $birthDate;
|
8 |
+
protected $streetName;
|
9 |
+
protected $houseNumber;
|
10 |
+
protected $houseNumberSuffix;
|
11 |
+
protected $zipCode;
|
12 |
+
protected $city;
|
13 |
+
protected $countryCode;
|
14 |
+
protected $phoneNumber;
|
15 |
+
protected $faxNumber;
|
16 |
+
protected $emailAddress;
|
17 |
+
protected $isCorporation;
|
18 |
+
|
19 |
+
// For corporations
|
20 |
+
protected $corporationName;
|
21 |
+
protected $cocNumber;
|
22 |
+
protected $isSoleProprietor;
|
23 |
+
|
24 |
+
protected $isFinal;
|
25 |
+
protected $claimAmount;
|
26 |
+
|
27 |
+
public function __construct()
|
28 |
+
{
|
29 |
+
$this->lastName = '';
|
30 |
+
$this->initials = '';
|
31 |
+
$this->gender = Tritac_CapayableApiClient_Enums_Gender::UNKNOWN; // https://en.wikipedia.org/wiki/ISO/IEC_5218
|
32 |
+
$this->birthDate = new DateTime();
|
33 |
+
$this->streetName = '';
|
34 |
+
$this->houseNumber = '';
|
35 |
+
$this->houseNumberSuffix = '';
|
36 |
+
$this->zipCode = '';
|
37 |
+
$this->city = '';
|
38 |
+
$this->countryCode = '';
|
39 |
+
$this->phoneNumber = '';
|
40 |
+
$this->faxNumber = '';
|
41 |
+
$this->emailAddress = '';
|
42 |
+
$this->isCorporation = false;
|
43 |
+
$this->corporationName = '';
|
44 |
+
$this->cocNumber = '';
|
45 |
+
$this->isSoleProprietor = false;
|
46 |
+
$this->isFinal = false;
|
47 |
+
$this->claimAmount = 0;
|
48 |
+
}
|
49 |
+
|
50 |
+
function getLastName() { return $this->lastName; }
|
51 |
+
function setLastName($lastName) {
|
52 |
+
|
53 |
+
if(strlen($lastName) > 150) {
|
54 |
+
throw new Exception('Last name may not exceed 150 characters');
|
55 |
+
}
|
56 |
+
|
57 |
+
$this->lastName = $lastName;
|
58 |
+
}
|
59 |
+
|
60 |
+
|
61 |
+
function getInitials() { return $this->initials; }
|
62 |
+
function setInitials($initials) {
|
63 |
+
|
64 |
+
if(strlen($initials) > 10) {
|
65 |
+
throw new Exception('Initials may not exceed 10 characters');
|
66 |
+
}
|
67 |
+
|
68 |
+
$this->initials = $initials;
|
69 |
+
}
|
70 |
+
|
71 |
+
|
72 |
+
function getGender() { return $this->gender; }
|
73 |
+
function setGender($gender) {
|
74 |
+
if(
|
75 |
+
$gender != Tritac_CapayableApiClient_Enums_Gender::MALE &&
|
76 |
+
$gender != Tritac_CapayableApiClient_Enums_Gender::FEMALE &&
|
77 |
+
$gender != Tritac_CapayableApiClient_Enums_Gender::UNKNOWN
|
78 |
+
) {
|
79 |
+
throw new Exception('Gender invalid, please use CapayableApiClient\Enums\Gender');
|
80 |
+
}
|
81 |
+
$this->gender = $gender;
|
82 |
+
}
|
83 |
+
|
84 |
+
function getBirthDate() { return $this->birthDate->format('Y-m-d'); }
|
85 |
+
function getBirthDateAsDateTime() { return $this->birthDate; }
|
86 |
+
function setBirthDate($birthDate) {
|
87 |
+
|
88 |
+
$this->birthDate = new DateTime($birthDate);
|
89 |
+
}
|
90 |
+
function setBirthDateAsDateTime(DateTime $birthDate) {
|
91 |
+
$this->birthDate = $birthDate;
|
92 |
+
}
|
93 |
+
|
94 |
+
function getStreetName() { return $this->streetName; }
|
95 |
+
function setStreetName($streetName) {
|
96 |
+
|
97 |
+
if(strlen($streetName) > 150) {
|
98 |
+
throw new Exception('Street name may not exceed 150 characters');
|
99 |
+
}
|
100 |
+
|
101 |
+
$this->streetName = $streetName;
|
102 |
+
}
|
103 |
+
|
104 |
+
function getHouseNumber() { return $this->houseNumber; }
|
105 |
+
function setHouseNumber($houseNumber) {
|
106 |
+
|
107 |
+
if(!is_numeric($houseNumber)) {
|
108 |
+
throw new Exception('House number must be numeric');
|
109 |
+
}
|
110 |
+
|
111 |
+
$this->houseNumber = $houseNumber;
|
112 |
+
}
|
113 |
+
|
114 |
+
function getHouseNumberSuffix() { return $this->houseNumberSuffix; }
|
115 |
+
function setHouseNumberSuffix($houseNumberSuffix) {
|
116 |
+
|
117 |
+
if(strlen($houseNumberSuffix) > 10) {
|
118 |
+
throw new Exception('House number suffix may not exceed 10 characters');
|
119 |
+
}
|
120 |
+
|
121 |
+
$this->houseNumberSuffix = $houseNumberSuffix;
|
122 |
+
|
123 |
+
}
|
124 |
+
|
125 |
+
function getZipCode() { return $this->zipCode; }
|
126 |
+
function setZipCode($zipCode) {
|
127 |
+
|
128 |
+
if(strlen($zipCode) > 20) {
|
129 |
+
throw new Exception('Zip code may not exceed 20 characters');
|
130 |
+
}
|
131 |
+
|
132 |
+
$this->zipCode = $zipCode;
|
133 |
+
}
|
134 |
+
|
135 |
+
function getCity() { return $this->city; }
|
136 |
+
function setCity($city) {
|
137 |
+
|
138 |
+
if(strlen($city) > 150) {
|
139 |
+
throw new Exception('Zip code may not exceed 150 characters');
|
140 |
+
}
|
141 |
+
|
142 |
+
$this->city = $city;
|
143 |
+
}
|
144 |
+
|
145 |
+
function getCountryCode() { return $this->countryCode; }
|
146 |
+
function setCountryCode($countryCode) {
|
147 |
+
|
148 |
+
if(strlen($countryCode) > 2) {
|
149 |
+
throw new Exception('Country code may not exceed 2 characters');
|
150 |
+
}
|
151 |
+
|
152 |
+
$this->countryCode = $countryCode;
|
153 |
+
|
154 |
+
}
|
155 |
+
|
156 |
+
function getPhoneNumber() { return $this->phoneNumber; }
|
157 |
+
function setPhoneNumber($phoneNumber) {
|
158 |
+
|
159 |
+
if(strlen($phoneNumber) > 20) {
|
160 |
+
throw new Exception('Phone number may not exceed 20 characters');
|
161 |
+
}
|
162 |
+
|
163 |
+
$this->phoneNumber = $phoneNumber;
|
164 |
+
|
165 |
+
}
|
166 |
+
|
167 |
+
function getFaxNumber() { return $this->faxNumber; }
|
168 |
+
function setFaxNumber($faxNumber) {
|
169 |
+
|
170 |
+
if(strlen($faxNumber) > 20) {
|
171 |
+
throw new Exception('Fax number may not exceed 20 characters');
|
172 |
+
}
|
173 |
+
|
174 |
+
$this->faxNumber = $faxNumber;
|
175 |
+
|
176 |
+
}
|
177 |
+
|
178 |
+
function getIsCorporation() { return $this->isCorporation; }
|
179 |
+
function setIsCorporation($isCorporation) {
|
180 |
+
|
181 |
+
if(!is_bool($isCorporation)){
|
182 |
+
throw new Exception('Is corporation must be a boolean');
|
183 |
+
}
|
184 |
+
|
185 |
+
$this->isCorporation = $isCorporation;
|
186 |
+
}
|
187 |
+
|
188 |
+
function getIsSoleProprietor() { return $this->isSoleProprietor; }
|
189 |
+
function setIsSoleProprietor($isSoleProprietor) {
|
190 |
+
|
191 |
+
if(!is_bool($isSoleProprietor)){
|
192 |
+
throw new Exception('Is sole proprietor must be a boolean');
|
193 |
+
}
|
194 |
+
|
195 |
+
$this->isSoleProprietor = $isSoleProprietor;
|
196 |
+
}
|
197 |
+
|
198 |
+
function getEmailAddress() { return $this->emailAddress; }
|
199 |
+
function setEmailAddress($emailAddress) {
|
200 |
+
|
201 |
+
if(!filter_var($emailAddress, FILTER_VALIDATE_EMAIL)){
|
202 |
+
throw new Exception('Must be a valid email');
|
203 |
+
}
|
204 |
+
|
205 |
+
$this->emailAddress = $emailAddress;
|
206 |
+
}
|
207 |
+
|
208 |
+
function getCorporationName() { return $this->corporationName; }
|
209 |
+
function setCorporationName($corporationName) {
|
210 |
+
$this->corporationName = $corporationName;
|
211 |
+
}
|
212 |
+
|
213 |
+
function getCocNumber() { return $this->cocNumber; }
|
214 |
+
function setCocNumber($cocNumber) {
|
215 |
+
|
216 |
+
if(strlen($cocNumber) > 20) {
|
217 |
+
throw new Exception('Chamber of commerce number may not exceed 20 characters');
|
218 |
+
}
|
219 |
+
|
220 |
+
$this->cocNumber = $cocNumber;
|
221 |
+
|
222 |
+
}
|
223 |
+
|
224 |
+
function getIsFinal() { return $this->isFinal; }
|
225 |
+
function setIsFinal($isFinal) {
|
226 |
+
|
227 |
+
if(!is_bool($isFinal)) {
|
228 |
+
throw new Exception('Is final must be a boolean');
|
229 |
+
}
|
230 |
+
|
231 |
+
$this->isFinal = $isFinal;
|
232 |
+
}
|
233 |
+
|
234 |
+
function getClaimAmount() { return $this->claimAmount; }
|
235 |
+
function setClaimAmount($claimAmount) {
|
236 |
+
|
237 |
+
if(!is_numeric($claimAmount)) {
|
238 |
+
throw new Exception('Claim amount must be numeric');
|
239 |
+
}
|
240 |
+
|
241 |
+
$this->claimAmount = $claimAmount;
|
242 |
+
}
|
243 |
}
|
lib/Tritac/CapayableApiClient/Models/CreditCheckResponse.php
CHANGED
@@ -1,33 +1,33 @@
|
|
1 |
-
<?php
|
2 |
-
class Tritac_CapayableApiClient_Models_CreditCheckResponse extends Tritac_CapayableApiClient_Models_BaseModel
|
3 |
-
{
|
4 |
-
protected $isAccepted;
|
5 |
-
protected $transactionNumber;
|
6 |
-
protected $refuseReason;
|
7 |
-
protected $refuseContactName;
|
8 |
-
protected $refuseContactPhoneNumber;
|
9 |
-
|
10 |
-
public function __construct(){
|
11 |
-
$this->isAccepted = false;
|
12 |
-
$this->transactionNumber = '';
|
13 |
-
$this->refuseReason = Tritac_CapayableApiClient_Enums_RefuseReason::CREDITCHECK_UNAVAILABLE;
|
14 |
-
}
|
15 |
-
|
16 |
-
public function setAccepted($transactionNumber){
|
17 |
-
$this->isAccepted = true;
|
18 |
-
$this->transactionNumber = $transactionNumber;
|
19 |
-
}
|
20 |
-
|
21 |
-
public function setRefused($refuseReason, $refuseContactName, $refusePhoneNumber){
|
22 |
-
$this->isAccepted = false;
|
23 |
-
$this->refuseReason = $refuseReason;
|
24 |
-
$this->refuseContactName = $refuseContactName;
|
25 |
-
$this->refusePhoneNumber = $refusePhoneNumber;
|
26 |
-
}
|
27 |
-
|
28 |
-
function getIsAccepted() { return $this->isAccepted; }
|
29 |
-
function getTransactionNumber() { return $this->transactionNumber; }
|
30 |
-
function getRefuseReason() { return $this->refuseReason; }
|
31 |
-
function getRefuseContactName() { return $this->refuseContactName; }
|
32 |
-
function getRefuseContactPhoneNumber() { return $this->refuseContactPhoneNumber; }
|
33 |
}
|
1 |
+
<?php
|
2 |
+
class Tritac_CapayableApiClient_Models_CreditCheckResponse extends Tritac_CapayableApiClient_Models_BaseModel
|
3 |
+
{
|
4 |
+
protected $isAccepted;
|
5 |
+
protected $transactionNumber;
|
6 |
+
protected $refuseReason;
|
7 |
+
protected $refuseContactName;
|
8 |
+
protected $refuseContactPhoneNumber;
|
9 |
+
|
10 |
+
public function __construct(){
|
11 |
+
$this->isAccepted = false;
|
12 |
+
$this->transactionNumber = '';
|
13 |
+
$this->refuseReason = Tritac_CapayableApiClient_Enums_RefuseReason::CREDITCHECK_UNAVAILABLE;
|
14 |
+
}
|
15 |
+
|
16 |
+
public function setAccepted($transactionNumber){
|
17 |
+
$this->isAccepted = true;
|
18 |
+
$this->transactionNumber = $transactionNumber;
|
19 |
+
}
|
20 |
+
|
21 |
+
public function setRefused($refuseReason, $refuseContactName, $refusePhoneNumber){
|
22 |
+
$this->isAccepted = false;
|
23 |
+
$this->refuseReason = $refuseReason;
|
24 |
+
$this->refuseContactName = $refuseContactName;
|
25 |
+
$this->refusePhoneNumber = $refusePhoneNumber;
|
26 |
+
}
|
27 |
+
|
28 |
+
function getIsAccepted() { return $this->isAccepted; }
|
29 |
+
function getTransactionNumber() { return $this->transactionNumber; }
|
30 |
+
function getRefuseReason() { return $this->refuseReason; }
|
31 |
+
function getRefuseContactName() { return $this->refuseContactName; }
|
32 |
+
function getRefuseContactPhoneNumber() { return $this->refuseContactPhoneNumber; }
|
33 |
}
|
lib/Tritac/CapayableApiClient/Models/Invoice.php
CHANGED
@@ -1,122 +1,122 @@
|
|
1 |
-
<?php
|
2 |
-
class Tritac_CapayableApiClient_Models_Invoice extends Tritac_CapayableApiClient_Models_BaseModel
|
3 |
-
{
|
4 |
-
protected $transactionNumber;
|
5 |
-
protected $invoiceNumber;
|
6 |
-
protected $invoiceDate;
|
7 |
-
protected $invoiceAmount;
|
8 |
-
protected $invoiceDescription;
|
9 |
-
|
10 |
-
protected $invoicePdfSubmitType;
|
11 |
-
|
12 |
-
// For InvoicePdfSubmitType::URL
|
13 |
-
protected $invoicePdfUrl;
|
14 |
-
|
15 |
-
// For InvoicePdfSubmitType::BCC_EMAIL
|
16 |
-
protected $invoicePdfEmailSentDate;
|
17 |
-
protected $invoicePdfFromEmail; //sender
|
18 |
-
protected $invoicePdfEmailSubject;
|
19 |
-
|
20 |
-
public function __construct()
|
21 |
-
{
|
22 |
-
$this->transactionNumber = '';
|
23 |
-
$this->invoiceNumber = '';
|
24 |
-
$this->invoiceDate = new DateTime();
|
25 |
-
$this->invoiceAmount = 0;
|
26 |
-
$this->invoiceDescription = '';
|
27 |
-
|
28 |
-
// PDF invoice submission
|
29 |
-
$this->invoicePdfSubmitType = Tritac_CapayableApiClient_Enums_InvoicePdfSubmitType::BCC_EMAIL;
|
30 |
-
$this->invoicePdfUrl = '';
|
31 |
-
$this->invoicePdfEmailSentDate = new DateTime();
|
32 |
-
$this->invoicePdfFromEmail = '';
|
33 |
-
$this->invoicePdfEmailSubject = '';
|
34 |
-
}
|
35 |
-
|
36 |
-
function getTransactionNumber() { return $this->transactionNumber; }
|
37 |
-
function setTransactionNumber($transactionNumber) {
|
38 |
-
|
39 |
-
if(strlen($transactionNumber) > 32) {
|
40 |
-
throw new Exception('Transaction number may not exceed 32 characters');
|
41 |
-
}
|
42 |
-
|
43 |
-
$this->transactionNumber = $transactionNumber;
|
44 |
-
}
|
45 |
-
|
46 |
-
function getInvoiceNumber() { return $this->invoiceNumber; }
|
47 |
-
function setInvoiceNumber($invoiceNumber) {
|
48 |
-
|
49 |
-
if(strlen($invoiceNumber) > 150) {
|
50 |
-
throw new Exception('Invoice number may not exceed 150 characters');
|
51 |
-
}
|
52 |
-
|
53 |
-
$this->invoiceNumber = $invoiceNumber;
|
54 |
-
}
|
55 |
-
|
56 |
-
function getInvoiceDate() { return $this->invoiceDate->format('Y-m-d'); }
|
57 |
-
function getInvoiceDateAsDateTime() { return $this->invoiceDate; }
|
58 |
-
function setInvoiceDate($invoiceDate) {
|
59 |
-
|
60 |
-
$this->invoiceDate = new DateTime($invoiceDate);
|
61 |
-
}
|
62 |
-
function setInvoiceDateAsDateTime(DateTime $invoiceDate) {
|
63 |
-
$this->invoiceDate = $invoiceDate;
|
64 |
-
}
|
65 |
-
|
66 |
-
function getInvoiceAmount() { return $this->invoiceAmount; }
|
67 |
-
function setInvoiceAmount($invoiceAmount) {
|
68 |
-
|
69 |
-
if(!is_numeric($invoiceAmount)) {
|
70 |
-
throw new Exception('Invoice amount must be numeric');
|
71 |
-
}
|
72 |
-
|
73 |
-
$this->invoiceAmount = $invoiceAmount;
|
74 |
-
}
|
75 |
-
|
76 |
-
function getInvoiceDescription() { return $this->invoiceDescription; }
|
77 |
-
function setInvoiceDescription($invoiceDescription) {
|
78 |
-
|
79 |
-
if(strlen($invoiceDescription) > 225) {
|
80 |
-
throw new Exception('Invoice description may not exceed 225 characters');
|
81 |
-
}
|
82 |
-
|
83 |
-
$this->invoiceDescription = $invoiceDescription;
|
84 |
-
}
|
85 |
-
|
86 |
-
// PDF Invoice submission:
|
87 |
-
function getInvoicePdfSubmitType() { return $this->invoicePdfSubmitType; }
|
88 |
-
|
89 |
-
// By email:
|
90 |
-
function getInvoicePdfEmailSentDate() { return $this->invoicePdfEmailSentDate->format('Y-m-d'); }
|
91 |
-
function getInvoicePdfEmailSentDateAsDateTime() { return $this->invoicePdfEmailSentDate; }
|
92 |
-
function getInvoicePdfFromEmail() { return $this->invoicePdfFromEmail; }
|
93 |
-
function getInvoicePdfEmailSubject() { return $this->invoicePdfEmailSubject; }
|
94 |
-
function setInvoiceByEmail($sender, $subject, DateTime $date = null){
|
95 |
-
if(is_null($date)){
|
96 |
-
$date = new DateTime();
|
97 |
-
}
|
98 |
-
|
99 |
-
if(strlen($sender) > 127 || strlen($subject) > 127 ) {
|
100 |
-
throw new Exception('Email sender and/or subject may not exceed 127 characters');
|
101 |
-
}
|
102 |
-
|
103 |
-
$this->invoicePdfSubmitType = Tritac_CapayableApiClient_Enums_InvoicePdfSubmitType::BCC_EMAIL;
|
104 |
-
|
105 |
-
$this->invoicePdfFromEmail = $sender;
|
106 |
-
$this->invoicePdfEmailSubject = $subject;
|
107 |
-
$this->invoicePdfEmailSentDate = $date;
|
108 |
-
}
|
109 |
-
|
110 |
-
// By URL:
|
111 |
-
function getInvoicePdfUrl() { return $this->invoicePdfUrl; }
|
112 |
-
function setInvoiceByUrl($url){
|
113 |
-
|
114 |
-
if(strlen($url) > 511 ) {
|
115 |
-
throw new Exception('Url may not exceed 511 characters');
|
116 |
-
}
|
117 |
-
|
118 |
-
$this->invoicePdfSubmitType = Tritac_CapayableApiClient_Enums_InvoicePdfSubmitType::URL;
|
119 |
-
|
120 |
-
$this->invoicePdfUrl = $url;
|
121 |
-
}
|
122 |
}
|
1 |
+
<?php
|
2 |
+
class Tritac_CapayableApiClient_Models_Invoice extends Tritac_CapayableApiClient_Models_BaseModel
|
3 |
+
{
|
4 |
+
protected $transactionNumber;
|
5 |
+
protected $invoiceNumber;
|
6 |
+
protected $invoiceDate;
|
7 |
+
protected $invoiceAmount;
|
8 |
+
protected $invoiceDescription;
|
9 |
+
|
10 |
+
protected $invoicePdfSubmitType;
|
11 |
+
|
12 |
+
// For InvoicePdfSubmitType::URL
|
13 |
+
protected $invoicePdfUrl;
|
14 |
+
|
15 |
+
// For InvoicePdfSubmitType::BCC_EMAIL
|
16 |
+
protected $invoicePdfEmailSentDate;
|
17 |
+
protected $invoicePdfFromEmail; //sender
|
18 |
+
protected $invoicePdfEmailSubject;
|
19 |
+
|
20 |
+
public function __construct()
|
21 |
+
{
|
22 |
+
$this->transactionNumber = '';
|
23 |
+
$this->invoiceNumber = '';
|
24 |
+
$this->invoiceDate = new DateTime();
|
25 |
+
$this->invoiceAmount = 0;
|
26 |
+
$this->invoiceDescription = '';
|
27 |
+
|
28 |
+
// PDF invoice submission
|
29 |
+
$this->invoicePdfSubmitType = Tritac_CapayableApiClient_Enums_InvoicePdfSubmitType::BCC_EMAIL;
|
30 |
+
$this->invoicePdfUrl = '';
|
31 |
+
$this->invoicePdfEmailSentDate = new DateTime();
|
32 |
+
$this->invoicePdfFromEmail = '';
|
33 |
+
$this->invoicePdfEmailSubject = '';
|
34 |
+
}
|
35 |
+
|
36 |
+
function getTransactionNumber() { return $this->transactionNumber; }
|
37 |
+
function setTransactionNumber($transactionNumber) {
|
38 |
+
|
39 |
+
if(strlen($transactionNumber) > 32) {
|
40 |
+
throw new Exception('Transaction number may not exceed 32 characters');
|
41 |
+
}
|
42 |
+
|
43 |
+
$this->transactionNumber = $transactionNumber;
|
44 |
+
}
|
45 |
+
|
46 |
+
function getInvoiceNumber() { return $this->invoiceNumber; }
|
47 |
+
function setInvoiceNumber($invoiceNumber) {
|
48 |
+
|
49 |
+
if(strlen($invoiceNumber) > 150) {
|
50 |
+
throw new Exception('Invoice number may not exceed 150 characters');
|
51 |
+
}
|
52 |
+
|
53 |
+
$this->invoiceNumber = $invoiceNumber;
|
54 |
+
}
|
55 |
+
|
56 |
+
function getInvoiceDate() { return $this->invoiceDate->format('Y-m-d'); }
|
57 |
+
function getInvoiceDateAsDateTime() { return $this->invoiceDate; }
|
58 |
+
function setInvoiceDate($invoiceDate) {
|
59 |
+
|
60 |
+
$this->invoiceDate = new DateTime($invoiceDate);
|
61 |
+
}
|
62 |
+
function setInvoiceDateAsDateTime(DateTime $invoiceDate) {
|
63 |
+
$this->invoiceDate = $invoiceDate;
|
64 |
+
}
|
65 |
+
|
66 |
+
function getInvoiceAmount() { return $this->invoiceAmount; }
|
67 |
+
function setInvoiceAmount($invoiceAmount) {
|
68 |
+
|
69 |
+
if(!is_numeric($invoiceAmount)) {
|
70 |
+
throw new Exception('Invoice amount must be numeric');
|
71 |
+
}
|
72 |
+
|
73 |
+
$this->invoiceAmount = $invoiceAmount;
|
74 |
+
}
|
75 |
+
|
76 |
+
function getInvoiceDescription() { return $this->invoiceDescription; }
|
77 |
+
function setInvoiceDescription($invoiceDescription) {
|
78 |
+
|
79 |
+
if(strlen($invoiceDescription) > 225) {
|
80 |
+
throw new Exception('Invoice description may not exceed 225 characters');
|
81 |
+
}
|
82 |
+
|
83 |
+
$this->invoiceDescription = $invoiceDescription;
|
84 |
+
}
|
85 |
+
|
86 |
+
// PDF Invoice submission:
|
87 |
+
function getInvoicePdfSubmitType() { return $this->invoicePdfSubmitType; }
|
88 |
+
|
89 |
+
// By email:
|
90 |
+
function getInvoicePdfEmailSentDate() { return $this->invoicePdfEmailSentDate->format('Y-m-d'); }
|
91 |
+
function getInvoicePdfEmailSentDateAsDateTime() { return $this->invoicePdfEmailSentDate; }
|
92 |
+
function getInvoicePdfFromEmail() { return $this->invoicePdfFromEmail; }
|
93 |
+
function getInvoicePdfEmailSubject() { return $this->invoicePdfEmailSubject; }
|
94 |
+
function setInvoiceByEmail($sender, $subject, DateTime $date = null){
|
95 |
+
if(is_null($date)){
|
96 |
+
$date = new DateTime();
|
97 |
+
}
|
98 |
+
|
99 |
+
if(strlen($sender) > 127 || strlen($subject) > 127 ) {
|
100 |
+
throw new Exception('Email sender and/or subject may not exceed 127 characters');
|
101 |
+
}
|
102 |
+
|
103 |
+
$this->invoicePdfSubmitType = Tritac_CapayableApiClient_Enums_InvoicePdfSubmitType::BCC_EMAIL;
|
104 |
+
|
105 |
+
$this->invoicePdfFromEmail = $sender;
|
106 |
+
$this->invoicePdfEmailSubject = $subject;
|
107 |
+
$this->invoicePdfEmailSentDate = $date;
|
108 |
+
}
|
109 |
+
|
110 |
+
// By URL:
|
111 |
+
function getInvoicePdfUrl() { return $this->invoicePdfUrl; }
|
112 |
+
function setInvoiceByUrl($url){
|
113 |
+
|
114 |
+
if(strlen($url) > 511 ) {
|
115 |
+
throw new Exception('Url may not exceed 511 characters');
|
116 |
+
}
|
117 |
+
|
118 |
+
$this->invoicePdfSubmitType = Tritac_CapayableApiClient_Enums_InvoicePdfSubmitType::URL;
|
119 |
+
|
120 |
+
$this->invoicePdfUrl = $url;
|
121 |
+
}
|
122 |
}
|
lib/Tritac/CapayableApiClient/Models/InvoiceCreditRequest.php
CHANGED
@@ -1,37 +1,37 @@
|
|
1 |
-
<?php
|
2 |
-
class Tritac_CapayableApiClient_Models_InvoiceCreditRequest extends Tritac_CapayableApiClient_Models_BaseModel
|
3 |
-
{
|
4 |
-
protected $transactionNumber;
|
5 |
-
protected $returnNumber;
|
6 |
-
protected $creditAmount;
|
7 |
-
|
8 |
-
public function __construct($transactionNumber, $returnNumber, $creditAmount){
|
9 |
-
|
10 |
-
if(strlen($transactionNumber) > 32) {
|
11 |
-
throw new Exception('Transaction number may not exceed 32 characters');
|
12 |
-
}
|
13 |
-
$this->transactionNumber = $transactionNumber;
|
14 |
-
|
15 |
-
if(strlen($returnNumber) > 150) {
|
16 |
-
throw new Exception('Return number may not exceed 150 characters');
|
17 |
-
}
|
18 |
-
$this->returnNumber = $returnNumber;
|
19 |
-
|
20 |
-
if(!is_numeric($creditAmount)) {
|
21 |
-
throw new Exception('Credit amount must be numeric');
|
22 |
-
}
|
23 |
-
$this->creditAmount = $creditAmount;
|
24 |
-
}
|
25 |
-
|
26 |
-
public function getTransactionNumber(){
|
27 |
-
return $this->transactionNumber;
|
28 |
-
}
|
29 |
-
|
30 |
-
public function getReturnNumber(){
|
31 |
-
return $this->returnNumber;
|
32 |
-
}
|
33 |
-
|
34 |
-
public function getCreditAmount(){
|
35 |
-
return $this->creditAmount;
|
36 |
-
}
|
37 |
-
}
|
1 |
+
<?php
|
2 |
+
class Tritac_CapayableApiClient_Models_InvoiceCreditRequest extends Tritac_CapayableApiClient_Models_BaseModel
|
3 |
+
{
|
4 |
+
protected $transactionNumber;
|
5 |
+
protected $returnNumber;
|
6 |
+
protected $creditAmount;
|
7 |
+
|
8 |
+
public function __construct($transactionNumber, $returnNumber, $creditAmount){
|
9 |
+
|
10 |
+
if(strlen($transactionNumber) > 32) {
|
11 |
+
throw new Exception('Transaction number may not exceed 32 characters');
|
12 |
+
}
|
13 |
+
$this->transactionNumber = $transactionNumber;
|
14 |
+
|
15 |
+
if(strlen($returnNumber) > 150) {
|
16 |
+
throw new Exception('Return number may not exceed 150 characters');
|
17 |
+
}
|
18 |
+
$this->returnNumber = $returnNumber;
|
19 |
+
|
20 |
+
if(!is_numeric($creditAmount)) {
|
21 |
+
throw new Exception('Credit amount must be numeric');
|
22 |
+
}
|
23 |
+
$this->creditAmount = $creditAmount;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function getTransactionNumber(){
|
27 |
+
return $this->transactionNumber;
|
28 |
+
}
|
29 |
+
|
30 |
+
public function getReturnNumber(){
|
31 |
+
return $this->returnNumber;
|
32 |
+
}
|
33 |
+
|
34 |
+
public function getCreditAmount(){
|
35 |
+
return $this->creditAmount;
|
36 |
+
}
|
37 |
+
}
|
lib/Tritac/CapayableApiClient/Models/InvoiceCreditResponse.php
CHANGED
@@ -1,25 +1,25 @@
|
|
1 |
-
<?php
|
2 |
-
class Tritac_CapayableApiClient_Models_InvoiceCreditResponse extends Tritac_CapayableApiClient_Models_BaseModel
|
3 |
-
{
|
4 |
-
protected $result;
|
5 |
-
protected $amountNotCredited;
|
6 |
-
protected $amountCredited;
|
7 |
-
|
8 |
-
public function __construct($result, $amountCredited, $amountNotCredited){
|
9 |
-
$this->result = $result;
|
10 |
-
$this->amountCredited = $amountCredited;
|
11 |
-
$this->amountNotCredited = $amountNotCredited;
|
12 |
-
}
|
13 |
-
|
14 |
-
public function getResult(){
|
15 |
-
return $this->result;
|
16 |
-
}
|
17 |
-
|
18 |
-
public function getAmountNotCredited(){
|
19 |
-
return $this->amountNotCredited;
|
20 |
-
}
|
21 |
-
|
22 |
-
public function getAmountCredited(){
|
23 |
-
return $this->amountCredited;
|
24 |
-
}
|
25 |
-
}
|
1 |
+
<?php
|
2 |
+
class Tritac_CapayableApiClient_Models_InvoiceCreditResponse extends Tritac_CapayableApiClient_Models_BaseModel
|
3 |
+
{
|
4 |
+
protected $result;
|
5 |
+
protected $amountNotCredited;
|
6 |
+
protected $amountCredited;
|
7 |
+
|
8 |
+
public function __construct($result, $amountCredited, $amountNotCredited){
|
9 |
+
$this->result = $result;
|
10 |
+
$this->amountCredited = $amountCredited;
|
11 |
+
$this->amountNotCredited = $amountNotCredited;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function getResult(){
|
15 |
+
return $this->result;
|
16 |
+
}
|
17 |
+
|
18 |
+
public function getAmountNotCredited(){
|
19 |
+
return $this->amountNotCredited;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getAmountCredited(){
|
23 |
+
return $this->amountCredited;
|
24 |
+
}
|
25 |
+
}
|
lib/Tritac/CapayableApiClient/Models/RegistrationCheckRequest.php
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
-
<?php
|
2 |
-
class Tritac_CapayableApiClient_Models_RegistrationCheckRequest extends Tritac_CapayableApiClient_Models_BaseModel
|
3 |
-
{
|
4 |
-
protected $cocNumber;
|
5 |
-
|
6 |
-
public function __construct($cocNumber){
|
7 |
-
|
8 |
-
|
9 |
-
if(strlen($cocNumber) > 20) {
|
10 |
-
throw new Exception('CoC-number number may not exceed 20 characters');
|
11 |
-
}
|
12 |
-
$this->cocNumber = $cocNumber;
|
13 |
-
|
14 |
-
}
|
15 |
-
|
16 |
-
public function getCocNumber(){
|
17 |
-
return $this->cocNumber;
|
18 |
-
}
|
19 |
-
}
|
1 |
+
<?php
|
2 |
+
class Tritac_CapayableApiClient_Models_RegistrationCheckRequest extends Tritac_CapayableApiClient_Models_BaseModel
|
3 |
+
{
|
4 |
+
protected $cocNumber;
|
5 |
+
|
6 |
+
public function __construct($cocNumber){
|
7 |
+
|
8 |
+
|
9 |
+
if(strlen($cocNumber) > 20) {
|
10 |
+
throw new Exception('CoC-number number may not exceed 20 characters');
|
11 |
+
}
|
12 |
+
$this->cocNumber = $cocNumber;
|
13 |
+
|
14 |
+
}
|
15 |
+
|
16 |
+
public function getCocNumber(){
|
17 |
+
return $this->cocNumber;
|
18 |
+
}
|
19 |
+
}
|
lib/Tritac/CapayableApiClient/Models/RegistrationCheckResponse.php
CHANGED
@@ -1,69 +1,69 @@
|
|
1 |
-
<?php
|
2 |
-
class Tritac_CapayableApiClient_Models_RegistrationCheckResponse extends Tritac_CapayableApiClient_Models_BaseModel
|
3 |
-
{
|
4 |
-
protected $isAccepted;
|
5 |
-
|
6 |
-
protected $houseNumber;
|
7 |
-
protected $houseNumberSuffix;
|
8 |
-
protected $zipCode;
|
9 |
-
protected $city;
|
10 |
-
protected $countryCode;
|
11 |
-
protected $phoneNumber;
|
12 |
-
protected $corporationName;
|
13 |
-
protected $cocNumber;
|
14 |
-
protected $streetName;
|
15 |
-
|
16 |
-
public function __construct($isAccepted, $houseNumber, $houseNumberSuffix, $zipCode, $city, $countryCode, $phoneNumber, $corporationName, $cocNumber, $streetName){
|
17 |
-
$this->isAccepted = $isAccepted;
|
18 |
-
$this->houseNumber = $houseNumber;
|
19 |
-
$this->houseNumberSuffix = $houseNumberSuffix;
|
20 |
-
$this->zipCode = $zipCode;
|
21 |
-
$this->city = $city;
|
22 |
-
$this->countryCode = $countryCode;
|
23 |
-
$this->phoneNumber = $phoneNumber;
|
24 |
-
$this->corporationName = $corporationName;
|
25 |
-
$this->cocNumber = $cocNumber;
|
26 |
-
$this->streetName= $streetName;
|
27 |
-
}
|
28 |
-
|
29 |
-
public function getCocNumber(){
|
30 |
-
return $this->cocNumber;
|
31 |
-
}
|
32 |
-
|
33 |
-
public function getIsAccepted(){
|
34 |
-
return $this->isAccepted;
|
35 |
-
}
|
36 |
-
|
37 |
-
public function getHouseNumber(){
|
38 |
-
return $this->houseNumber;
|
39 |
-
}
|
40 |
-
|
41 |
-
public function getHouseNumberSuffix(){
|
42 |
-
return $this->houseNumberSuffix;
|
43 |
-
}
|
44 |
-
|
45 |
-
public function getZipCode(){
|
46 |
-
return $this->zipCode;
|
47 |
-
}
|
48 |
-
|
49 |
-
public function getCity(){
|
50 |
-
return $this->city;
|
51 |
-
}
|
52 |
-
|
53 |
-
public function getCountryCode(){
|
54 |
-
return $this->countryCode;
|
55 |
-
}
|
56 |
-
|
57 |
-
public function getPhoneNumber(){
|
58 |
-
return $this->phoneNumber;
|
59 |
-
}
|
60 |
-
|
61 |
-
public function getCorporationName(){
|
62 |
-
return $this->corporationName;
|
63 |
-
}
|
64 |
-
|
65 |
-
public function getStreetName(){
|
66 |
-
return $this->streetName;
|
67 |
-
}
|
68 |
-
|
69 |
}
|
1 |
+
<?php
|
2 |
+
class Tritac_CapayableApiClient_Models_RegistrationCheckResponse extends Tritac_CapayableApiClient_Models_BaseModel
|
3 |
+
{
|
4 |
+
protected $isAccepted;
|
5 |
+
|
6 |
+
protected $houseNumber;
|
7 |
+
protected $houseNumberSuffix;
|
8 |
+
protected $zipCode;
|
9 |
+
protected $city;
|
10 |
+
protected $countryCode;
|
11 |
+
protected $phoneNumber;
|
12 |
+
protected $corporationName;
|
13 |
+
protected $cocNumber;
|
14 |
+
protected $streetName;
|
15 |
+
|
16 |
+
public function __construct($isAccepted, $houseNumber, $houseNumberSuffix, $zipCode, $city, $countryCode, $phoneNumber, $corporationName, $cocNumber, $streetName){
|
17 |
+
$this->isAccepted = $isAccepted;
|
18 |
+
$this->houseNumber = $houseNumber;
|
19 |
+
$this->houseNumberSuffix = $houseNumberSuffix;
|
20 |
+
$this->zipCode = $zipCode;
|
21 |
+
$this->city = $city;
|
22 |
+
$this->countryCode = $countryCode;
|
23 |
+
$this->phoneNumber = $phoneNumber;
|
24 |
+
$this->corporationName = $corporationName;
|
25 |
+
$this->cocNumber = $cocNumber;
|
26 |
+
$this->streetName= $streetName;
|
27 |
+
}
|
28 |
+
|
29 |
+
public function getCocNumber(){
|
30 |
+
return $this->cocNumber;
|
31 |
+
}
|
32 |
+
|
33 |
+
public function getIsAccepted(){
|
34 |
+
return $this->isAccepted;
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getHouseNumber(){
|
38 |
+
return $this->houseNumber;
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getHouseNumberSuffix(){
|
42 |
+
return $this->houseNumberSuffix;
|
43 |
+
}
|
44 |
+
|
45 |
+
public function getZipCode(){
|
46 |
+
return $this->zipCode;
|
47 |
+
}
|
48 |
+
|
49 |
+
public function getCity(){
|
50 |
+
return $this->city;
|
51 |
+
}
|
52 |
+
|
53 |
+
public function getCountryCode(){
|
54 |
+
return $this->countryCode;
|
55 |
+
}
|
56 |
+
|
57 |
+
public function getPhoneNumber(){
|
58 |
+
return $this->phoneNumber;
|
59 |
+
}
|
60 |
+
|
61 |
+
public function getCorporationName(){
|
62 |
+
return $this->corporationName;
|
63 |
+
}
|
64 |
+
|
65 |
+
public function getStreetName(){
|
66 |
+
return $this->streetName;
|
67 |
+
}
|
68 |
+
|
69 |
}
|
lib/Tritac/CapayableApiClient/loader.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// This loader is required to make use of the php __autoload functionality.
|
4 |
-
|
5 |
-
/*function __autoload($class) {
|
6 |
-
$class = str_replace('\\', '/', $class) . '.php';
|
7 |
-
require_once($class);
|
8 |
-
}*/
|
9 |
-
|
10 |
-
// Add the class dir to include path
|
11 |
-
set_include_path(get_include_path() . PATH_SEPARATOR);
|
12 |
-
|
13 |
-
// Use default autoload implementation
|
14 |
spl_autoload_register();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// This loader is required to make use of the php __autoload functionality.
|
4 |
+
|
5 |
+
/*function __autoload($class) {
|
6 |
+
$class = str_replace('\\', '/', $class) . '.php';
|
7 |
+
require_once($class);
|
8 |
+
}*/
|
9 |
+
|
10 |
+
// Add the class dir to include path
|
11 |
+
set_include_path(get_include_path() . PATH_SEPARATOR);
|
12 |
+
|
13 |
+
// Use default autoload implementation
|
14 |
spl_autoload_register();
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Tritac_Capayable</name>
|
4 |
-
<version>2.3.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
<channel>community</channel>
|
@@ -16,9 +16,9 @@ By fulfilling your customers desires you will realize a substatial gain in onlin
|
|
16 |
Keep the risk of default to a minimum with Capayable. During the order process Capayable will assess the solvency of the customer. The result of this assessment will determine if the customer gets the option to pay after delivery. Moreover, the collection of the due payment is Capayable's risk. Customer service at checkout and your financial security go hand in hand.</description>
|
17 |
<notes>* Minor improvements</notes>
|
18 |
<authors><author><name>Capayable</name><user>capayable</user><email>capayable@tritac.com</email></author></authors>
|
19 |
-
<date>2014-09-
|
20 |
-
<time>
|
21 |
-
<contents><target name="mageetc"><dir name="modules"><file name="Tritac_Capayable.xml" hash="
|
22 |
<compatible/>
|
23 |
<dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php></required></dependencies>
|
24 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Tritac_Capayable</name>
|
4 |
+
<version>2.3.5</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
<channel>community</channel>
|
16 |
Keep the risk of default to a minimum with Capayable. During the order process Capayable will assess the solvency of the customer. The result of this assessment will determine if the customer gets the option to pay after delivery. Moreover, the collection of the due payment is Capayable's risk. Customer service at checkout and your financial security go hand in hand.</description>
|
17 |
<notes>* Minor improvements</notes>
|
18 |
<authors><author><name>Capayable</name><user>capayable</user><email>capayable@tritac.com</email></author></authors>
|
19 |
+
<date>2014-09-24</date>
|
20 |
+
<time>10:51:51</time>
|
21 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Tritac_Capayable.xml" hash="a35df0a6a11b15db674819ea7e4d02f2"/></dir></target><target name="magecommunity"><dir name="Tritac"><dir name="Capayable"><dir name="Block"><file name="Form.php" hash="83bc69c725d2ad024c2b76a753f0eaba"/><file name="Info.php" hash="fd9d0b099727cbe376014643c112ccc0"/></dir><dir name="Helper"><file name="Data.php" hash="8431ea3bbc7091a407f5b2f4e74f1ae5"/></dir><dir name="Model"><file name="Customer.php" hash="c39250d401c881e645026a8fb33502e2"/><file name="Observer.php" hash="a869e9848cf3bd524b33303838651529"/><file name="Payment.php" hash="7354bb9f49eff2fc6dc80fc7b774a4af"/><dir name="Resource"><dir name="Customer"><file name="Collection.php" hash="5ef8de2e982c37e29f90df7adc06fca7"/></dir><file name="Customer.php" hash="e58d7b076230bd26bb597cac51f398e5"/><file name="Setup.php" hash="7346a71f9ab93126613de29bfa554121"/></dir></dir><dir name="controllers"><file name="AjaxController.php" hash="1716003fb2a586e6b44f17efac3b8a8a"/></dir><dir name="etc"><file name="config.xml" hash="50df3feecc4e03f20b00f6fd38d97bd2"/><file name="system.xml" hash="8de08e706c61f60a75f8ce0e7b751e22"/></dir><dir name="sql"><dir name="capayable_setup"><file name="install-1.0.0.php" hash="1e412ede2793dbe415c4da2f1fb48921"/></dir></dir></dir></dir></target><target name="magelib"><dir name="Tritac"><dir name="CapayableApiClient"><file name="AddTrustExternalCARoot.crt" hash="f85d1ff17b0079709f131f3ce3f288d2"/><file name="Client.php" hash="1924ac84fb70a2380c9b4f2961ed7c65"/><dir name="Enums"><file name="Enum.php" hash="8eeda296fe586c1d9f342bc2e75ed554"/><file name="Environment.php" hash="6a840727268b5183cc4c5598df9c481b"/><file name="Gender.php" hash="e48490e32b987f51a9e66b11326d7661"/><file name="HttpMethod.php" hash="824e2762e440f40387a9e2185c705e1b"/><file name="InvoiceCreditStatus.php" hash="f6205195824e0357e959e74294ac1239"/><file name="InvoicePdfSubmitType.php" hash="6fe3c8b955c6a14b7fe6f3c0d29015a3"/><file name="RefuseReason.php" hash="c01b19e8d04f6189abedc1f6f873abe7"/></dir><dir name="Models"><file name="BaseModel.php" hash="6a0237549065ab11aad7eb7a0145c2d7"/><file name="CreditCheckRequest.php" hash="e1befba79fd3c7fc6d37eb7d74e0c413"/><file name="CreditCheckResponse.php" hash="077a24bfbc9d9de7f6c06f973a4ed881"/><file name="Invoice.php" hash="97b15a09dfd11d64030df69d3f177242"/><file name="InvoiceCreditRequest.php" hash="149b843a5ce6f9c34166c0c0e81f06cf"/><file name="InvoiceCreditResponse.php" hash="63600846169e0a0eace38dcf7d64fe8c"/><file name="RegistrationCheckRequest.php" hash="b11005f5fbfa7a8785551e2c2231c626"/><file name="RegistrationCheckResponse.php" hash="baa182217e9203058e10dacf719ef234"/></dir><file name="fiddler.crt" hash="b0dff65ab013256030658fee29ce0919"/><file name="loader.php" hash="0ab611c3d193b808447e0525283a87d7"/></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="capayable"><file name="form.phtml" hash="1464c790113776f8f0b3e0bba1cca9a0"/><file name="info.phtml" hash="49882aeb093b51af56d7d0b49847e784"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir><dir name="nl_NL"><file name="Tritac_Capayable.csv" hash="1c6c5cba166528dbdd85909f32bb1d9f"/></dir></dir></target></contents>
|
22 |
<compatible/>
|
23 |
<dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php></required></dependencies>
|
24 |
</package>
|