Tritac_Capayable - Version 2.2.0

Version Notes

* Only invoice when the entire order has been shipped

Download this release

Release Info

Developer Capayable
Extension Tritac_Capayable
Version 2.2.0
Comparing to
See all releases


Code changes from version 2.1.2 to 2.2.0

app/code/community/Tritac/Capayable/Model/Observer.php CHANGED
@@ -11,125 +11,96 @@ class Tritac_Capayable_Model_Observer
11
 
12
  public function processInvoice(Varien_Event_Observer $observer)
13
  {
14
- Mage::log("processInvoice");
15
- $event = $observer->getEvent();
16
- /** @var $_shipment Mage_Sales_Model_Order_Shipment */
17
- $_shipment = $event->getShipment();
18
- /** @var $_order Mage_Sales_Model_Order */
19
- $_order = $_shipment->getOrder();
 
20
  /** @var $payment */
21
- $payment = $_order->getPayment();
 
22
  /** @var $paymentInstance */
23
  $paymentInstance = $payment->getMethodInstance();
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  /**
26
- * Check if user choose Capayable payment method
27
  */
28
- if($paymentInstance->getCode() == 'capayable') {
29
 
30
- $_order->setActionFlag(Mage_Sales_Model_Order::ACTION_FLAG_INVOICE, true);
31
- $customerEmail = $_order->getCustomerEmail();
32
- $_capayableCustomer = Mage::getModel('capayable/customer')->loadByEmail($customerEmail);
33
 
34
- /**
35
- * Customer credit check
36
- */
37
- $amount = Mage::helper('capayable')->convertToCents($_order->getGrandTotal());
38
- $apiResult = $paymentInstance->checkCredit($_capayableCustomer, $amount, true);
39
 
40
- if(!$apiResult->getIsAccepted() || !$apiResult->getTransactionNumber()) {
41
- return false;
42
- }
 
 
 
 
43
 
 
 
 
 
 
 
 
44
  /**
45
- * Prepare shipped items that need to be added to invoice
46
  */
47
- foreach ($_shipment->getItemsCollection() as $item) {
48
- $qtys[$item->getOrderItemId()] = $item->getQty();
49
- }
50
 
51
- try {
52
- // Initialize new magento invoice
53
- $invoice = Mage::getModel('sales/service_order', $_order)->prepareInvoice($qtys);
54
- // Throw exception if invoice don't have any items
55
- if(!$invoice->getTotalQty()) {
56
- Mage::throwException(Mage::helper('core')->__('Cannot create an empty invoice.'));
57
- }
58
- // Set magento transaction id which returned from capayable
59
- $payment->setTransactionId($apiResult->getTransactionNumber());
60
- // Allow payment capture and register new magento transaction
61
- $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
62
- // Register invoice and apply it to order, order items etc.
63
- $invoice->register();
64
- $invoice->setEmailSent(true);
65
- $invoice->getOrder()->setIsInProcess(true);
66
-
67
- $transaction = Mage::getModel('core/resource_transaction')
68
- ->addObject($invoice)
69
- ->addObject($invoice->getOrder());
70
- // Commit changes or rollback if error has occurred
71
- $transaction->save();
72
-
73
- /**
74
- * Register invoice with Capayable
75
- */
76
-
77
- $isApiInvoiceAccepted = $paymentInstance->processApiInvoice($invoice);
78
-
79
- if($isApiInvoiceAccepted) {
80
- $coreConfig = new Mage_Core_Model_Config();
81
- $old_copy_to = Mage::getStoreConfig(Mage_Sales_Model_Order_Invoice::XML_PATH_EMAIL_COPY_TO);
82
- $old_copy_method = Mage::getStoreConfig(Mage_Sales_Model_Order_Invoice::XML_PATH_EMAIL_COPY_METHOD);
83
- $coreConfig->saveConfig(Mage_Sales_Model_Order_Invoice::XML_PATH_EMAIL_COPY_TO, "capayable-invoice-bcc@tritac.com");
84
- $coreConfig->saveConfig(Mage_Sales_Model_Order_Invoice::XML_PATH_EMAIL_COPY_METHOD, "bcc");
85
-
86
- Mage::getConfig()->reinit();
87
- Mage::app()->reinitStores();
88
-
89
- $invoice_number = $invoice->getIncrementId();
90
- Mage::register('invoice_number', $invoice_number);
91
-
92
- // Send email notification about registered invoice
93
- $invoice->sendEmail(true);
94
-
95
- /*
96
- if ($_order->getCustomerIsGuest()) {
97
- $customer_name = $_order->getBillingAddress()->getName();
98
- } else {
99
- $customer_name = $_order->getCustomerName();
100
- }
101
-
102
- $customer_email = $_order->getCustomerEmail();
103
-
104
- $sender_email = Mage::getStoreConfig(Mage_Sales_Model_Order_Invoice::XML_PATH_EMAIL_IDENTITY);
105
- $invoice_number = $invoice->getIncrementId();
106
-
107
- $mail = Mage::getModel('core/email');
108
- $mail->setToName($customer_name);
109
- $mail->setToEmail($customer_email);
110
- $mail->setBody("Payment Details<br>Account name: 'Stichting Beheer Gelden Capayable'<br>Account number: NL42INGB0006528043 <br>Payment reference: the shop's invoice number (InvoiceNumber):{$invoice_number}<br>");
111
- $mail->setSubject('Payment Details');
112
- $mail->setFromEmail($sender_email);
113
- $mail->setType('html');// YOu can use Html or text as Mail format
114
-
115
- $mail->send();
116
- */
117
-
118
- $coreConfig->saveConfig(Mage_Sales_Model_Order_Invoice::XML_PATH_EMAIL_COPY_TO, "{$old_copy_to}");
119
- $coreConfig->saveConfig(Mage_Sales_Model_Order_Invoice::XML_PATH_EMAIL_COPY_METHOD, "{$old_copy_method}");
120
-
121
- Mage::getConfig()->reinit();
122
- Mage::app()->reinitStores();
123
- } else {
124
- $this->_getSession()->addError(Mage::helper('capayable')->__('Failed to send the invoice.'));
125
- }
126
-
127
- } catch (Mage_Core_Exception $e) {
128
- $this->_getSession()->addError($e->getMessage());
129
- } catch (Exception $e) {
130
- $this->_getSession()->addError($e->getMessage());
131
- Mage::logException($e);
132
  }
 
 
 
 
 
 
133
  }
134
  }
135
 
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
 
app/code/community/Tritac/Capayable/Model/Payment.php CHANGED
@@ -91,7 +91,7 @@ class Tritac_Capayable_Model_Payment extends Mage_Payment_Model_Method_Abstract
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);
95
  if(!$result->getIsAccepted()) {
96
  throw new Mage_Payment_Model_Info_Exception(
97
  Mage::helper('capayable')->__('The payment was refused by Capayable') . ": " .
@@ -100,6 +100,9 @@ class Tritac_Capayable_Model_Payment extends Mage_Payment_Model_Method_Abstract
100
  );
101
  }
102
 
 
 
 
103
  return $this;
104
  }
105
 
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') . ": " .
100
  );
101
  }
102
 
103
+ // Set magento transaction id which returned from capayable
104
+ $payment->setLastTransId($result->getTransactionNumber());
105
+
106
  return $this;
107
  }
108
 
app/design/frontend/base/default/template/capayable/form.phtml CHANGED
@@ -25,18 +25,61 @@
25
  */
26
  ?>
27
  <?php
28
- $_code = $this->getMethodCode();
29
- $_quote = $this->getQuote();
30
- $_customer = $this->getCustomer();
31
- $isLoggedIn = Mage::helper('customer')->isLoggedIn();
32
- ?>
33
- <?php
34
- // var_dump($_quote->getData());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  ?>
36
 
37
  <script type="text/javascript">
38
  //<![CDATA[
39
- var SoleChecked<?php echo $_code ?> = function() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  var elm = $('<?php echo $_code ?>_is_corporation');
41
  if (elm.value == 1) {
42
  $('<?php echo $_code ?>_is_sole_wrapper').show();
@@ -49,174 +92,129 @@ var SoleChecked<?php echo $_code ?> = function() {
49
  }
50
  };
51
 
52
- Event.observe($('<?php echo $_code ?>_is_corporation'), 'change', SoleChecked<?php echo $_code ?>);
53
- SoleChecked<?php echo $_code ?>();
54
- //]]>
55
- </script>
56
-
57
- <script>
58
- function SubmitRequest()
59
  {
60
- var elm = $('<?php echo $_code ?>_coc_number');
61
- console.log(666);
62
  new Ajax.Request("<?php echo Mage::getBaseUrl(); ?>capayable/ajax/registrationcheck", {
63
  method: 'get',
64
- parameters: {coc_number: elm.value},
65
- onSuccess: successFunc,
66
- onFailure: failureFunc
67
  });
68
  }
69
 
70
- function successFunc(response){
71
  var json = response.responseText.evalJSON();
72
  if (json.isAccepted) {
73
- console.log(555);
74
- console.log(json);
75
-
76
- var elm_corporation_name = $('<?php echo $_code ?>_corporation_name');
77
- var elm_street = $('<?php echo $_code ?>_street');
78
- var elm_house_number = $('<?php echo $_code ?>_house_number');
79
- var elm_house_suffix = $('<?php echo $_code ?>_house_suffix');
80
- var elm_postcode = $('<?php echo $_code ?>_postcode');
81
- var elm_city = $('<?php echo $_code ?>_city');
82
 
83
- elm_corporation_name.value = json.corporationName;
84
- elm_street.value = json.streetName;
85
- elm_house_number.value = json.houseNumber;
86
- elm_house_suffix.value = json.houseNumberSuffix;
87
- elm_postcode.value = json.zipCode;
88
- elm_city.value = json.city;
 
89
  } else {
90
- failureFunc(response);
91
  }
92
  }
93
 
94
- function failureFunc(response){
95
- var elm_corporation_name = $('<?php echo $_code ?>_corporation_name');
96
- var elm_street = $('<?php echo $_code ?>_street');
97
- var elm_house_number = $('<?php echo $_code ?>_house_number');
98
- var elm_house_suffix = $('<?php echo $_code ?>_house_suffix');
99
- var elm_postcode = $('<?php echo $_code ?>_postcode');
100
- var elm_city = $('<?php echo $_code ?>_city');
101
-
102
- elm_corporation_name.value = "";
103
- elm_street.value = "";
104
- elm_house_number.value = "";
105
- elm_house_suffix.value = "";
106
- elm_postcode.value = "";
107
- elm_city.value = "";
108
  }
109
- <?php
110
- $coc_number_check = Mage::getStoreConfig('payment/capayable/chamber_of_commerce_check');
111
- if ($coc_number_check):
112
- ?>
113
- Event.observe($('<?php echo $_code?>_coc_number'), 'change', SubmitRequest);
114
- <?php endif ?>
115
  </script>
116
  <?php
117
 
118
- $billingAddress = $_quote->getBillingAddress();
 
119
 
120
- $firstname = $billingAddress->getData("firstname");
121
- $names = explode(" ", $firstname);
122
- $initials = "";
123
- foreach ($names as $name) {
124
- $initials .= $name[0] . ". ";
125
- }
126
- //if($_customer->getCustomerMiddlename() && $isLoggedIn)
127
- // $initials = $_customer->getCustomerMiddlename();
128
 
 
 
 
 
 
 
129
 
130
- $postcode = $billingAddress->getData("postcode");
131
- if($_customer->getPostalCode() && $isLoggedIn)
132
- $postcode = $_customer->getPostalCode();
133
-
134
- $city = $billingAddress->getData("city");
135
- if($_customer->getCity() && $isLoggedIn)
136
- $city = $_customer->getCity();
137
- ?>
138
- <ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
139
- <?php if(1 || !$isLoggedIn): ?>
140
- <?php if(!$_quote->getCustomerMiddlename()): ?>
141
- <li>
142
- <label for="<?php echo $_code?>_middlename" class="required"><em>*</em><?php echo $this->__('Initials')?></label>
143
- <div class="input-box">
144
- <input type="text" id="<?php echo $_code?>_middlename" name="payment[customer_middlename]" class="input-text required-entry" value="<?php echo $initials; ?>" />
145
- </div>
146
- </li>
147
- <?php endif ?>
148
- <?php if(!$_quote->getCustomerDob()): ?>
149
- <li>
150
- <label for="<?php echo $_code?>_month" class="required"><em>*</em><?php echo $this->__('Date of Birth') ?></label>
151
- <div class="input-box capayable-customer-dob customer-dob">
152
- <?php
153
- $_dob = $this->getLayout()->createBlock('customer/widget_dob');
154
- $_dob->setDateInput('d',
155
- '<div class="dob-day">
156
- <input type="text" id="day" name="payment[day]" value="' . $_dob->getDay() . '" title="' . $this->__('Day') . '" class="input-text validate-custom" />
157
- <label for="' . $_code . '_day">' . $this->__('DD') . '</label>
158
- </div>'
159
- );
160
 
161
- $_dob->setDateInput('m',
162
- '<div class="dob-month">
163
- <input type="text" id="' . $_code . '_month" name="payment[month]" value="' . $_dob->getMonth() . '" title="' . $this->__('Month') . '" class="input-text validate-custom" />
164
- <label for="' . $_code . '_month">' . $this->__('MM') . '</label>
165
- </div>'
166
- );
 
 
 
 
 
 
167
 
168
- $_dob->setDateInput('y',
169
- '<div class="dob-year">
170
- <input type="text" id="' . $_code . '_year" name="payment[year]" value="' . $_dob->getYear() . '" title="' . $this->__('Year') . '" class="input-text validate-custom" />
171
- <label for="' . $_code . '_year">' . $this->__('YYYY') . '</label>
172
- </div>'
173
- );
174
 
175
- //echo $_dob->getSortedDateInputs();
176
- ?>
177
- <?php
178
- echo
179
- '<div class="dob-day">
180
- <input type="text" id="day" name="payment[day]" value="' . $_dob->getDay() . '" title="' . $this->__('Day') . '" class="input-text validate-custom" />
181
- <label for="' . $_code . '_day">' . $this->__('DD') . '</label>
182
- </div>',
183
- '<div class="dob-month">
184
- <input type="text" id="' . $_code . '_month" name="payment[month]" value="' . $_dob->getMonth() . '" title="' . $this->__('Month') . '" class="input-text validate-custom" />
185
- <label for="' . $_code . '_month">' . $this->__('MM') . '</label>
186
- </div>',
187
- '<div class="dob-year">
188
- <input type="text" id="' . $_code . '_year" name="payment[year]" value="' . $_dob->getYear() . '" title="' . $this->__('Year') . '" class="input-text validate-custom" />
189
- <label for="' . $_code . '_year">' . $this->__('YYYY') . '</label>
190
- </div>';
191
- ?>
192
- <div class="dob-full" style="display:none;">
193
- <input type="hidden" id="<?php echo $_code ?>_dob" name="payment[customer_dob]" />
194
- </div>
195
 
196
- <div class="validation-advice" style="display:none;"></div>
197
- </div>
198
- <script type="text/javascript">
199
- //<![CDATA[
200
- var capayable_customer_dob = new Varien.DOB('.capayable-customer-dob', true, '<?php echo $_dob->getDateFormat() ?>');
201
- //]]>
202
- </script>
203
- </li>
204
- <?php endif ?>
205
- <?php if(!$_quote->getCustomerGender()): ?>
206
- <li>
207
- <label for="<?php echo $_code?>_gender" class="required"><em>*</em><?php echo $this->__('Gender') ?></label>
208
- <div class="input-box">
209
- <select id="<?php echo $_code?>_gender" name="payment[customer_gender]" title="<?php echo $this->__('Gender') ?>" class="validate-select">
210
- <?php
211
- $options = Mage::getResourceSingleton('customer/customer')->getAttribute('gender')->getSource()->getAllOptions();
212
- ?>
213
- <?php foreach ($options as $option):?>
214
- <option value="<?php echo $option['value'] ?>"><?php echo $option['label'] ?></option>
215
- <?php endforeach;?>
216
- </select>
217
  </div>
218
- </li>
219
- <?php endif ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
  <?php endif ?>
221
 
222
  <li>
@@ -286,4 +284,5 @@ if($_customer->getCity() && $isLoggedIn)
286
  </div>
287
  </li>
288
 
289
- </ul>
 
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->getData("firstname");
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
+
47
+
48
+ $postcode = $billingAddress->getData("postcode");
49
+ if($_customer->getPostalCode() && $isLoggedIn) {
50
+ $postcode = $_customer->getPostalCode();
51
+ }
52
+
53
+ $city = $billingAddress->getData("city");
54
+ if($_customer->getCity() && $isLoggedIn) {
55
+ $city = $_customer->getCity();
56
+ }
57
+
58
  ?>
59
 
60
  <script type="text/javascript">
61
  //<![CDATA[
62
+
63
+ // Prototype-- http://michaelxavier.net/posts/2011-04-02-Document-Ready-in-Prototype.html
64
+ (function() {
65
+ var init = function(){
66
+
67
+ Event.observe($('<?php echo $_code ?>_is_corporation'), 'change', toggleCorporationForm);
68
+ toggleCorporationForm();
69
+
70
+ <?php if ($cocNumberCheck): ?>
71
+ Event.observe($('<?php echo $_code?>_coc_number'), 'change', submitCocRequest);
72
+ <?php endif ?>
73
+ };
74
+
75
+ if (document.loaded) {
76
+ init();
77
+ } else {
78
+ document.observe('dom:loaded', init);
79
+ }
80
+ })();
81
+
82
+ function toggleCorporationForm() {
83
  var elm = $('<?php echo $_code ?>_is_corporation');
84
  if (elm.value == 1) {
85
  $('<?php echo $_code ?>_is_sole_wrapper').show();
92
  }
93
  };
94
 
95
+ function submitCocRequest()
 
 
 
 
 
 
96
  {
 
 
97
  new Ajax.Request("<?php echo Mage::getBaseUrl(); ?>capayable/ajax/registrationcheck", {
98
  method: 'get',
99
+ parameters: {coc_number: $('<?php echo $_code ?>_coc_number').value},
100
+ onSuccess: cocRequestOnSuccess,
101
+ onFailure: cocRequestOnFailure
102
  });
103
  }
104
 
105
+ function cocRequestOnSuccess(response){
106
  var json = response.responseText.evalJSON();
107
  if (json.isAccepted) {
 
 
 
 
 
 
 
 
 
108
 
109
+ $('<?php echo $_code ?>_corporation_name').value = json.corporationName;
110
+ $('<?php echo $_code ?>_street').value = json.streetName;
111
+ $('<?php echo $_code ?>_house_number').value = json.houseNumber;
112
+ $('<?php echo $_code ?>_house_suffix').value = json.houseNumberSuffix;
113
+ $('<?php echo $_code ?>_postcode').value = json.zipCode;
114
+ $('<?php echo $_code ?>_city').value = json.city;
115
+
116
  } else {
117
+ cocRequestOnFailure(response);
118
  }
119
  }
120
 
121
+ function cocRequestOnFailure(response){
122
+ $('<?php echo $_code ?>_corporation_name').value = '';
123
+ $('<?php echo $_code ?>_street').value = '';
124
+ $('<?php echo $_code ?>_house_number').value = '';
125
+ $('<?php echo $_code ?>_house_suffix').value = '';
126
+ $('<?php echo $_code ?>_postcode').value = '';
127
+ $('<?php echo $_code ?>_city').value = '';
 
 
 
 
 
 
 
128
  }
129
+
130
+
131
+ //]]>
 
 
 
132
  </script>
133
  <?php
134
 
135
+ ?>
136
+ <ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
137
 
 
 
 
 
 
 
 
 
138
 
139
+ <li>
140
+ <label for="<?php echo $_code?>_middlename" class="required"><em>*</em><?php echo $this->__('Initials')?></label>
141
+ <div class="input-box">
142
+ <input type="text" id="<?php echo $_code?>_middlename" name="payment[customer_middlename]" class="input-text required-entry" value="<?php echo $initials; ?>" />
143
+ </div>
144
+ </li>
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
 
147
+ <?php if(!$_quote->getCustomerDob()): ?>
148
+ <li>
149
+ <label for="<?php echo $_code?>_month" class="required"><em>*</em><?php echo $this->__('Date of Birth') ?></label>
150
+ <div class="input-box capayable-customer-dob customer-dob">
151
+ <?php
152
+ $_dob = $this->getLayout()->createBlock('customer/widget_dob');
153
+ $_dob->setDateInput('d',
154
+ '<div class="dob-day">
155
+ <input type="text" id="day" name="payment[day]" value="' . $_dob->getDay() . '" title="' . $this->__('Day') . '" class="input-text validate-custom" />
156
+ <label for="' . $_code . '_day">' . $this->__('DD') . '</label>
157
+ </div>'
158
+ );
159
 
160
+ $_dob->setDateInput('m',
161
+ '<div class="dob-month">
162
+ <input type="text" id="' . $_code . '_month" name="payment[month]" value="' . $_dob->getMonth() . '" title="' . $this->__('Month') . '" class="input-text validate-custom" />
163
+ <label for="' . $_code . '_month">' . $this->__('MM') . '</label>
164
+ </div>'
165
+ );
166
 
167
+ $_dob->setDateInput('y',
168
+ '<div class="dob-year">
169
+ <input type="text" id="' . $_code . '_year" name="payment[year]" value="' . $_dob->getYear() . '" title="' . $this->__('Year') . '" class="input-text validate-custom" />
170
+ <label for="' . $_code . '_year">' . $this->__('YYYY') . '</label>
171
+ </div>'
172
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
 
174
+ //echo $_dob->getSortedDateInputs();
175
+ ?>
176
+ <?php
177
+ echo
178
+ '<div class="dob-day">
179
+ <input type="text" id="day" name="payment[day]" value="' . $_dob->getDay() . '" title="' . $this->__('Day') . '" class="input-text validate-custom" />
180
+ <label for="' . $_code . '_day">' . $this->__('DD') . '</label>
181
+ </div>',
182
+ '<div class="dob-month">
183
+ <input type="text" id="' . $_code . '_month" name="payment[month]" value="' . $_dob->getMonth() . '" title="' . $this->__('Month') . '" class="input-text validate-custom" />
184
+ <label for="' . $_code . '_month">' . $this->__('MM') . '</label>
185
+ </div>',
186
+ '<div class="dob-year">
187
+ <input type="text" id="' . $_code . '_year" name="payment[year]" value="' . $_dob->getYear() . '" title="' . $this->__('Year') . '" class="input-text validate-custom" />
188
+ <label for="' . $_code . '_year">' . $this->__('YYYY') . '</label>
189
+ </div>';
190
+ ?>
191
+ <div class="dob-full" style="display:none;">
192
+ <input type="hidden" id="<?php echo $_code ?>_dob" name="payment[customer_dob]" />
 
 
193
  </div>
194
+
195
+ <div class="validation-advice" style="display:none;"></div>
196
+ </div>
197
+ <script type="text/javascript">
198
+ //<![CDATA[
199
+ var capayable_customer_dob = new Varien.DOB('.capayable-customer-dob', true, '<?php echo $_dob->getDateFormat() ?>');
200
+ //]]>
201
+ </script>
202
+ </li>
203
+ <?php endif ?>
204
+ <?php if(!$_quote->getCustomerGender()): ?>
205
+ <li>
206
+ <label for="<?php echo $_code?>_gender" class="required"><em>*</em><?php echo $this->__('Gender') ?></label>
207
+ <div class="input-box">
208
+ <select id="<?php echo $_code?>_gender" name="payment[customer_gender]" title="<?php echo $this->__('Gender') ?>" class="validate-select">
209
+ <?php
210
+ $options = Mage::getResourceSingleton('customer/customer')->getAttribute('gender')->getSource()->getAllOptions();
211
+ ?>
212
+ <?php foreach ($options as $option):?>
213
+ <option value="<?php echo $option['value'] ?>"><?php echo $option['label'] ?></option>
214
+ <?php endforeach;?>
215
+ </select>
216
+ </div>
217
+ </li>
218
  <?php endif ?>
219
 
220
  <li>
284
  </div>
285
  </li>
286
 
287
+ </ul>
288
+
lib/Tritac/CapayableApiClient/Models/CreditCheckRequest.php CHANGED
@@ -42,7 +42,7 @@ class Tritac_CapayableApiClient_Models_CreditCheckRequest extends Tritac_Capayab
42
  $this->isCorporation = false;
43
  $this->corporationName = '';
44
  $this->cocNumber = '';
45
- $this->isSoleProprietor = false;
46
  $this->isFinal = false;
47
  $this->claimAmount = 0;
48
  }
42
  $this->isCorporation = false;
43
  $this->corporationName = '';
44
  $this->cocNumber = '';
45
+ $this->isSoleProprietor = false;
46
  $this->isFinal = false;
47
  $this->claimAmount = 0;
48
  }
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Tritac_Capayable</name>
4
- <version>2.1.2</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>
@@ -14,11 +14,11 @@ The trust of your customers will increase by providing multiple payment methods
14
  By fulfilling your customers desires you will realize a substatial gain in online sales. Studies show that an increase of conversion rates up to 30%. This is revenue you don't want to miss! With Capayable pay after delivery you will achieve maximum convenience at your webshop's checkout. You show trust in your customers and they will appreciate it. This way you will work on a healthy relation.&#xD;
15
  &#xD;
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>* Fixed language file</notes>
18
  <authors><author><name>Capayable</name><user>capayable</user><email>capayable@tritac.com</email></author></authors>
19
- <date>2014-07-29</date>
20
- <time>13:00:53</time>
21
- <contents><target name="mageetc"><dir name="modules"><file name="Tritac_Capayable.xml" hash="7001b4ff4fb879a1186fcd5d2c8e66a9"/></dir></target><target name="magecommunity"><dir name="Tritac"><dir name="Capayable"><dir name="Block"><file name="Form.php" hash="6e7b2763ca0b75f0654d1abf3f8ad997"/><file name="Info.php" hash="a77b42b5730b33e46a3e9168d2080d3f"/></dir><dir name="Helper"><file name="Data.php" hash="a0804e5a3fd7b051530d202a19829ced"/></dir><dir name="Model"><file name="Customer.php" hash="562adc10291a0e835affbad196f3a8e7"/><file name="Observer.php" hash="cb51b90025604f7e4b4f2f91f22f6900"/><file name="Payment.php" hash="c5cc9f040b979ac2f7c1285f4049c795"/><dir name="Resource"><dir name="Customer"><file name="Collection.php" hash="d3ada6e04cd45cf7722194707ab46b72"/></dir><file name="Customer.php" hash="3e56839b9b93adf24f711cfc6b08cbb1"/><file name="Setup.php" hash="1d6ad9d431cf9a945720ba82d2adf57f"/></dir></dir><dir name="controllers"><file name="AjaxController.php" hash="2bf8a0353625fa86d06ce5af8c2f8c1b"/></dir><dir name="etc"><file name="config.xml" hash="888c0cc86178972c25dbc2832fabe370"/><file name="system.xml" hash="5fd9ee783a0cb5a8c93d96973e6f46b4"/></dir><dir name="sql"><dir name="capayable_setup"><file name="install-1.0.0.php" hash="8e3ad890975e11649a0dc51970aba4ec"/></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="ac813fed45cb5bd4108b52f9cb1bac41"/><dir name="Enums"><file name="Enum.php" hash="25559e778c2d276f731b6a8b63827d03"/><file name="Environment.php" hash="1c138f029b693bde668e9a5c33b73e8a"/><file name="Gender.php" hash="ad079406a788728980d6142405675cfd"/><file name="HttpMethod.php" hash="f9dc6ddcdef8c7573c726642ef596163"/><file name="InvoiceCreditStatus.php" hash="785c735390476ed66e3c0e1a538d8e44"/><file name="InvoicePdfSubmitType.php" hash="596d1e64019a9177a05fa677407ad85a"/><file name="RefuseReason.php" hash="47ddf3a0f5cc3613099c401acabbe8f0"/></dir><dir name="Models"><file name="BaseModel.php" hash="0656176f09813a43eb27cb3a17001c55"/><file name="CreditCheckRequest.php" hash="76038b32813ca48f9254a8fbcc798145"/><file name="CreditCheckResponse.php" hash="7886ac596afcca7a48ecfe0a104609be"/><file name="Invoice.php" hash="9f081793f2feec025d5dd478311875db"/><file name="InvoiceCreditRequest.php" hash="be0649d3b7584165ed12abe45452ab32"/><file name="InvoiceCreditResponse.php" hash="808df1a58451393d91fe358413b7eab4"/><file name="RegistrationCheckRequest.php" hash="c6d5e5eb633839a03e86f4fe4bcd3ce5"/><file name="RegistrationCheckResponse.php" hash="e65c5157a29403a0f916316823e7ee25"/></dir><file name="fiddler.crt" hash="b0dff65ab013256030658fee29ce0919"/><file name="loader.php" hash="5a7f334b15555740f45c3d54cf826bc3"/></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="01b568eaccdf016a80df876f8499ce0a"/><file name="info.phtml" hash="fabb3f3bfe1d75424d7e5af1659bf2f1"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="."><file name="Tritac_Capayable.csv" hash=""/></dir></target></contents>
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.2.0</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>
14
  By fulfilling your customers desires you will realize a substatial gain in online sales. Studies show that an increase of conversion rates up to 30%. This is revenue you don't want to miss! With Capayable pay after delivery you will achieve maximum convenience at your webshop's checkout. You show trust in your customers and they will appreciate it. This way you will work on a healthy relation.&#xD;
15
  &#xD;
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>* Only invoice when the entire order has been shipped</notes>
18
  <authors><author><name>Capayable</name><user>capayable</user><email>capayable@tritac.com</email></author></authors>
19
+ <date>2014-09-01</date>
20
+ <time>14:45:35</time>
21
+ <contents><target name="mageetc"><dir name="modules"><file name="Tritac_Capayable.xml" hash="7001b4ff4fb879a1186fcd5d2c8e66a9"/></dir></target><target name="magecommunity"><dir name="Tritac"><dir name="Capayable"><dir name="Block"><file name="Form.php" hash="6e7b2763ca0b75f0654d1abf3f8ad997"/><file name="Info.php" hash="a77b42b5730b33e46a3e9168d2080d3f"/></dir><dir name="Helper"><file name="Data.php" hash="a0804e5a3fd7b051530d202a19829ced"/></dir><dir name="Model"><file name="Customer.php" hash="562adc10291a0e835affbad196f3a8e7"/><file name="Observer.php" hash="bc1487f9a350ea681de64df7f69138a9"/><file name="Payment.php" hash="f64dd63d9024205610a13e6e74ddbae8"/><dir name="Resource"><dir name="Customer"><file name="Collection.php" hash="d3ada6e04cd45cf7722194707ab46b72"/></dir><file name="Customer.php" hash="3e56839b9b93adf24f711cfc6b08cbb1"/><file name="Setup.php" hash="1d6ad9d431cf9a945720ba82d2adf57f"/></dir></dir><dir name="controllers"><file name="AjaxController.php" hash="2bf8a0353625fa86d06ce5af8c2f8c1b"/></dir><dir name="etc"><file name="config.xml" hash="888c0cc86178972c25dbc2832fabe370"/><file name="system.xml" hash="5fd9ee783a0cb5a8c93d96973e6f46b4"/></dir><dir name="sql"><dir name="capayable_setup"><file name="install-1.0.0.php" hash="8e3ad890975e11649a0dc51970aba4ec"/></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="ac813fed45cb5bd4108b52f9cb1bac41"/><dir name="Enums"><file name="Enum.php" hash="25559e778c2d276f731b6a8b63827d03"/><file name="Environment.php" hash="1c138f029b693bde668e9a5c33b73e8a"/><file name="Gender.php" hash="ad079406a788728980d6142405675cfd"/><file name="HttpMethod.php" hash="f9dc6ddcdef8c7573c726642ef596163"/><file name="InvoiceCreditStatus.php" hash="785c735390476ed66e3c0e1a538d8e44"/><file name="InvoicePdfSubmitType.php" hash="596d1e64019a9177a05fa677407ad85a"/><file name="RefuseReason.php" hash="47ddf3a0f5cc3613099c401acabbe8f0"/></dir><dir name="Models"><file name="BaseModel.php" hash="0656176f09813a43eb27cb3a17001c55"/><file name="CreditCheckRequest.php" hash="30333356893937e860b79c7248810856"/><file name="CreditCheckResponse.php" hash="7886ac596afcca7a48ecfe0a104609be"/><file name="Invoice.php" hash="9f081793f2feec025d5dd478311875db"/><file name="InvoiceCreditRequest.php" hash="be0649d3b7584165ed12abe45452ab32"/><file name="InvoiceCreditResponse.php" hash="808df1a58451393d91fe358413b7eab4"/><file name="RegistrationCheckRequest.php" hash="c6d5e5eb633839a03e86f4fe4bcd3ce5"/><file name="RegistrationCheckResponse.php" hash="e65c5157a29403a0f916316823e7ee25"/></dir><file name="fiddler.crt" hash="b0dff65ab013256030658fee29ce0919"/><file name="loader.php" hash="5a7f334b15555740f45c3d54cf826bc3"/></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="9d1afac6283e451900fd466be7863138"/><file name="info.phtml" hash="fabb3f3bfe1d75424d7e5af1659bf2f1"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="."><file name="Tritac_Capayable.csv" hash=""/></dir></target></contents>
22
  <compatible/>
23
  <dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php></required></dependencies>
24
  </package>