Version Notes
Initial release.
Download this release
Release Info
| Developer | BorderJump |
| Extension | BorderPay |
| Version | 1.0.0 |
| Comparing to | |
| See all releases | |
Version 1.0.0
- app/code/local/BorderJump/BorderPay/Block/Adminhtml/Version.php +7 -0
- app/code/local/BorderJump/BorderPay/Block/Cart/Totals.php +18 -0
- app/code/local/BorderJump/BorderPay/Block/Form/Dynamic.php +31 -0
- app/code/local/BorderJump/BorderPay/Block/Info/Dynamic.php +6 -0
- app/code/local/BorderJump/BorderPay/Helper/Data.php +6 -0
- app/code/local/BorderJump/BorderPay/Helper/Response.php +63 -0
- app/code/local/BorderJump/BorderPay/Model/Currency/Import/BorderPay.php +36 -0
- app/code/local/BorderJump/BorderPay/Model/Method/Borderpay.php +586 -0
- app/code/local/BorderJump/BorderPay/Model/Mysql4/Payment.php +9 -0
- app/code/local/BorderJump/BorderPay/Model/Observer.php +125 -0
- app/code/local/BorderJump/BorderPay/Model/Order/Pdf/Invoice.php +122 -0
- app/code/local/BorderJump/BorderPay/Model/Order/Pdf/Items/Invoice/Default.php +92 -0
- app/code/local/BorderJump/BorderPay/Model/Payment.php +31 -0
- app/code/local/BorderJump/BorderPay/controllers/OnepageController.php +194 -0
- app/code/local/BorderJump/BorderPay/etc/config.xml +133 -0
- app/code/local/BorderJump/BorderPay/etc/system.xml +105 -0
- app/code/local/BorderJump/BorderPay/sql/borderpay_setup/mysql4-install-0.1.0.php +18 -0
- app/code/local/BorderJump/Xternal/Block/Html/Head.php +116 -0
- app/code/local/BorderJump/Xternal/etc/config.xml +32 -0
- app/design/frontend/base/default/layout/borderpay.xml +37 -0
- app/design/frontend/base/default/template/borderpay/checkout/firecheckout/extension.phtml +112 -0
- app/design/frontend/base/default/template/borderpay/checkout/onepage/error.phtml +4 -0
- app/design/frontend/base/default/template/borderpay/checkout/onepage/extension.phtml +176 -0
- app/design/frontend/base/default/template/borderpay/checkout/onepage/review/totals.phtml +17 -0
- app/design/frontend/base/default/template/borderpay/payment/form/dynamic.phtml +145 -0
- app/etc/modules/BorderJump_BorderPay.xml +28 -0
- app/etc/modules/BorderJump_Xternal.xml +9 -0
- package.xml +18 -0
- skin/frontend/default/default/js/snare_settings.js +192 -0
app/code/local/BorderJump/BorderPay/Block/Adminhtml/Version.php
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class BorderJump_BorderPay_Block_Adminhtml_Version extends Mage_Adminhtml_Block_System_Config_Form_Field
|
| 3 |
+
{
|
| 4 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
|
| 5 |
+
return (string) Mage::getConfig()->getNode()->modules->BorderJump_BorderPay->version;
|
| 6 |
+
}
|
| 7 |
+
}
|
app/code/local/BorderJump/BorderPay/Block/Cart/Totals.php
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class BorderJump_BorderPay_Block_Cart_Totals extends Mage_Checkout_Block_Cart_Totals
|
| 3 |
+
{
|
| 4 |
+
public function displayGrandtotal()
|
| 5 |
+
{
|
| 6 |
+
Mage::getSingleton('core/session', array('name' => 'frontend'));
|
| 7 |
+
$payment = Mage::getSingleton('checkout/session')->getQuote()->getPayment();
|
| 8 |
+
if ($payment->getMethodInstance()->getCode() != 'borderpay') {
|
| 9 |
+
return $this->displayBaseGrandtotal();
|
| 10 |
+
}
|
| 11 |
+
$firstTotal = reset($this->_totals);
|
| 12 |
+
if ($firstTotal) {
|
| 13 |
+
$total = $firstTotal->getAddress()->getGrandTotal();
|
| 14 |
+
return Mage::app()->getStore()->getCurrentCurrency()->format($total, array(), true);
|
| 15 |
+
}
|
| 16 |
+
return '-';
|
| 17 |
+
}
|
| 18 |
+
}
|
app/code/local/BorderJump/BorderPay/Block/Form/Dynamic.php
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class BorderJump_BorderPay_Block_Form_Dynamic extends Mage_Payment_Block_Form_Ccsave {
|
| 4 |
+
protected function _construct() {
|
| 5 |
+
parent::_construct();
|
| 6 |
+
$this->setTemplate('borderpay/payment/form/dynamic.phtml');
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
public function getCcAvailableTypes() {
|
| 10 |
+
return array(
|
| 11 |
+
'amex' => 'American Express',
|
| 12 |
+
'visa' => 'Visa',
|
| 13 |
+
'master' => 'MasterCard',
|
| 14 |
+
'discover' => 'Discover',
|
| 15 |
+
'diners_club' => 'Diner\'s Club',
|
| 16 |
+
'jcb' => 'JCB'
|
| 17 |
+
);
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
public function getPaymentMethods($country_code = null, $currency_code = null) {
|
| 21 |
+
$response = $this->getMethod()->apiMerchantPaymentServices();
|
| 22 |
+
if ($response) {
|
| 23 |
+
$services = array();
|
| 24 |
+
foreach ($response as $service_data) {
|
| 25 |
+
$service = $service_data['service'];
|
| 26 |
+
$services[$service['name']] = $service['payment_service_id'];
|
| 27 |
+
}
|
| 28 |
+
return $services;
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
+
}
|
app/code/local/BorderJump/BorderPay/Block/Info/Dynamic.php
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class BorderJump_BorderPay_Block_Info_Dynamic extends Mage_Payment_Block_Info
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
}
|
app/code/local/BorderJump/BorderPay/Helper/Data.php
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class BorderJump_BorderPay_Helper_Data extends Mage_Shipping_Helper_Data
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
}
|
app/code/local/BorderJump/BorderPay/Helper/Response.php
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class BorderJump_BorderPay_Helper_Response extends Mage_Core_Helper_Abstract
|
| 4 |
+
{
|
| 5 |
+
private function _checkResponse($response, $field=null) {
|
| 6 |
+
if ( ! is_array($response)) {
|
| 7 |
+
return false;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
if ($field) {
|
| 11 |
+
if ( ! isset($response[$field])) {
|
| 12 |
+
return false;
|
| 13 |
+
}
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
return true;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
public function isEnrolled($response) {
|
| 20 |
+
$field = 'enrolled';
|
| 21 |
+
if ( ! $this->_checkResponse($response, $field)) {
|
| 22 |
+
return false;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
$enrolled = $response[$field];
|
| 26 |
+
return $enrolled == 1;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
// gets order status from an API response.
|
| 30 |
+
public function getStatus($response) {
|
| 31 |
+
$fields = array('status', 'PAResStatus');
|
| 32 |
+
$field = null;
|
| 33 |
+
foreach ($fields as $_field) {
|
| 34 |
+
if ($this->_checkResponse($response, $_field)) {
|
| 35 |
+
$field = $_field;
|
| 36 |
+
break;
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
if ($field == null) {
|
| 41 |
+
return false;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
$status = $response[$field];
|
| 45 |
+
$returnStatus = null;
|
| 46 |
+
|
| 47 |
+
$statusCategories = array(
|
| 48 |
+
'pending' => array('pending', 'P'),
|
| 49 |
+
'approved' => array('authorized', 'approved', 'captured', 'complete', 'Y'),
|
| 50 |
+
'declined' => array('declined'),
|
| 51 |
+
'cancelled' => array('cancelled', 'canceled', 'X'),
|
| 52 |
+
);
|
| 53 |
+
|
| 54 |
+
foreach ($statusCategories as $k => $statuses) {
|
| 55 |
+
if (in_array($status, $statuses)) {
|
| 56 |
+
$status = $k;
|
| 57 |
+
break;
|
| 58 |
+
}
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
return $status;
|
| 62 |
+
}
|
| 63 |
+
}
|
app/code/local/BorderJump/BorderPay/Model/Currency/Import/BorderPay.php
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class BorderJump_BorderPay_Model_Currency_Import_BorderPay extends Mage_Directory_Model_Currency_Import_Abstract
|
| 4 |
+
{
|
| 5 |
+
protected $_messages = array();
|
| 6 |
+
|
| 7 |
+
protected function _convert($currencyFrom, $currencyTo, $retry=0)
|
| 8 |
+
{
|
| 9 |
+
$borderpay = Mage::getSingleton('borderpay/method_borderpay');
|
| 10 |
+
$apiClient = Mage::getModel('apiclient/apiclient', $borderpay->getConfigData('api_url'));
|
| 11 |
+
$apiClient->setKey($borderpay->getConfigData('api_key'));
|
| 12 |
+
$apiClient->setSecret($borderpay->getConfigData('api_secret'));
|
| 13 |
+
|
| 14 |
+
try {
|
| 15 |
+
$method = "/merchant/currency/convert";
|
| 16 |
+
$query = array(
|
| 17 |
+
'to' => $currencyTo,
|
| 18 |
+
'from' => $currencyFrom
|
| 19 |
+
);
|
| 20 |
+
$response = $apiClient->call($method, 'POST', $query);
|
| 21 |
+
|
| 22 |
+
if( ! $response) {
|
| 23 |
+
$this->_messages[] = Mage::helper('directory')->__('Cannot retrieve rate from BorderPay.');
|
| 24 |
+
return null;
|
| 25 |
+
}
|
| 26 |
+
return (float) $response;
|
| 27 |
+
}
|
| 28 |
+
catch (Exception $e) {
|
| 29 |
+
if( $retry == 0 ) {
|
| 30 |
+
$this->_convert($currencyFrom, $currencyTo, 1);
|
| 31 |
+
} else {
|
| 32 |
+
$this->_messages[] = Mage::helper('directory')->__('Cannot retrieve rate from BorderPay.');
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
}
|
app/code/local/BorderJump/BorderPay/Model/Method/Borderpay.php
ADDED
|
@@ -0,0 +1,586 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class BorderJump_BorderPay_Model_Method_BorderPay extends Mage_Payment_Model_Method_Abstract
|
| 4 |
+
{
|
| 5 |
+
protected $apiClient = null;
|
| 6 |
+
protected $_code = 'borderpay';
|
| 7 |
+
protected $_canSaveCc = true;
|
| 8 |
+
protected $_canAuthorize = true;
|
| 9 |
+
protected $_formBlockType = 'BorderJump_BorderPay_Block_Form_Dynamic';
|
| 10 |
+
protected $_infoBlockType = 'BorderJump_BorderPay_Block_Info_Dynamic';
|
| 11 |
+
|
| 12 |
+
//~ public function validate() {
|
| 13 |
+
//~ $response = $this->apiMerchantOrderAuth();
|
| 14 |
+
//~ if ($response['PAResStatus'] == 'Y') {
|
| 15 |
+
//~ return $this;
|
| 16 |
+
//~ } else {
|
| 17 |
+
//~ Mage::throwException('There was an error validating your payment. Please contact customer support.');
|
| 18 |
+
//~ }
|
| 19 |
+
//~ }
|
| 20 |
+
|
| 21 |
+
private function _getIpAddress()
|
| 22 |
+
{
|
| 23 |
+
$ip = '';
|
| 24 |
+
if (!empty($_SERVER['HTTP_CLIENT_IP'])){
|
| 25 |
+
$ip=$_SERVER['HTTP_CLIENT_IP'];
|
| 26 |
+
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
| 27 |
+
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
|
| 28 |
+
} else {
|
| 29 |
+
$ip=$_SERVER['REMOTE_ADDR'];
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
return $ip;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
// We're overriding this method to use the shipping address rather than the billing address.
|
| 36 |
+
public function canUseForCountry($country) {
|
| 37 |
+
// allowspecific == 1 means that it can only be used in certain countries
|
| 38 |
+
if ($this->getConfigData('sallowspecific') == 1) {
|
| 39 |
+
Mage::getSingleton('core/session', array('name' => 'frontend'));
|
| 40 |
+
$session = Mage::getSingleton('checkout/session');
|
| 41 |
+
$country = $session->getQuote()->getShippingAddress()->getCountry();
|
| 42 |
+
|
| 43 |
+
$availableCountries = explode(',', $this->getConfigData('specificcountry'));
|
| 44 |
+
if (!in_array($country, $availableCountries)) {
|
| 45 |
+
return false;
|
| 46 |
+
}
|
| 47 |
+
}
|
| 48 |
+
return true;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
public function saveAddresses() {
|
| 52 |
+
Mage::getSingleton('core/session', array('name' => 'frontend'));
|
| 53 |
+
$session = Mage::getSingleton('checkout/session');
|
| 54 |
+
$billing = $session->getQuote()->getBillingAddress()->getData();
|
| 55 |
+
$shipping = $session->getQuote()->getShippingAddress()->getData();
|
| 56 |
+
|
| 57 |
+
$billing['address'] = $billing['street'];
|
| 58 |
+
$shipping['address'] = $shipping['street'];
|
| 59 |
+
$session->setBorderpayBillingAddress($billing);
|
| 60 |
+
$session->setBorderpayShippingAddress($shipping);
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
public function validate() {
|
| 64 |
+
parent::validate();
|
| 65 |
+
return $this;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
public function getCcAvailableTypes() {
|
| 69 |
+
return array(
|
| 70 |
+
'American Express' => 'amex',
|
| 71 |
+
'Visa' => 'visa',
|
| 72 |
+
'MasterCard' => 'master',
|
| 73 |
+
'Discover' => 'discover',
|
| 74 |
+
'Diner\'s Club' => 'diners_club',
|
| 75 |
+
'JCB' => 'jcb'
|
| 76 |
+
);
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
public function apiMerchantPaymentServices() {
|
| 80 |
+
$currencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
|
| 81 |
+
$currencyNum = $this->getIso4217CurrencyCode($currencyCode);
|
| 82 |
+
|
| 83 |
+
$address = Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress();
|
| 84 |
+
#$billing_address = $customer->getDefaultBillingAddress();
|
| 85 |
+
if ($address) {
|
| 86 |
+
|
| 87 |
+
$countryCode = $address->getCountry();
|
| 88 |
+
|
| 89 |
+
$apiClient = Mage::getModel('apiclient/apiclient', $this->getConfigData('api_url'));
|
| 90 |
+
$apiClient->setKey($this->getConfigData('api_key'));
|
| 91 |
+
$apiClient->setSecret($this->getConfigData('api_secret'));
|
| 92 |
+
|
| 93 |
+
$query = array(
|
| 94 |
+
'currency_num' => $currencyNum,
|
| 95 |
+
'country_code' => $countryCode
|
| 96 |
+
);
|
| 97 |
+
$response = $apiClient->call('/merchant/payment-services/', 'POST', $query);
|
| 98 |
+
|
| 99 |
+
return $response;
|
| 100 |
+
} else {
|
| 101 |
+
return false;
|
| 102 |
+
}
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
private function _getPendingOrders() {
|
| 106 |
+
$orders = Mage::getModel('sales/order')->getCollection();
|
| 107 |
+
$orders->addAttributeToFilter('status', array('eq' => 'pending'));
|
| 108 |
+
$orders->getSelect();
|
| 109 |
+
return $orders;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
public function updateAllPendingOrders($real=false)
|
| 113 |
+
{
|
| 114 |
+
if (! $real) {
|
| 115 |
+
print 'Dry run...<br /><br />';
|
| 116 |
+
}
|
| 117 |
+
$orders = $this->_getPendingOrders();
|
| 118 |
+
$borderpayOrders = array();
|
| 119 |
+
|
| 120 |
+
$orderNumbers = array();
|
| 121 |
+
foreach ($orders as $order) {
|
| 122 |
+
$payment = $order->getPayment();
|
| 123 |
+
$bpPayment = Mage::getModel('borderpay/payment')->loadByMagePayment($payment);
|
| 124 |
+
|
| 125 |
+
// We don't care if it's not a borderpay order
|
| 126 |
+
if (strtolower($payment->getMethodInstance()->getCode()) != 'borderpay') {
|
| 127 |
+
if (! $real) {
|
| 128 |
+
print 'Skipping order #' . $order->getIncrementId() .': does not appear to be a borderpay order.<br />';
|
| 129 |
+
}
|
| 130 |
+
continue;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
// We don't care if it doesn't have borderpay data
|
| 134 |
+
if (! $bpPayment) {
|
| 135 |
+
if (! $real) {
|
| 136 |
+
print 'Skipping order #' . $order->getIncrementId() .': no borderpay data.<br />';
|
| 137 |
+
}
|
| 138 |
+
continue;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
// We can't do anything if there's no order number
|
| 142 |
+
if (! $bpPayment->getOrderNumber()) {
|
| 143 |
+
if (! $real) {
|
| 144 |
+
print 'Skipping order #' . $order->getIncrementId() .': no order number.<br />';
|
| 145 |
+
}
|
| 146 |
+
continue;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
// We don't care if it's already been processed through borderpay
|
| 150 |
+
if ($bpPayment->getProcessed()) {
|
| 151 |
+
|
| 152 |
+
if (! $real) {
|
| 153 |
+
print 'Skipping order #' . $order->getIncrementId() .': already processed.<br />';
|
| 154 |
+
}
|
| 155 |
+
continue;
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
if (! $real) {
|
| 159 |
+
print 'Bingo! Would update order #' . $order->getIncrementId() . '<br />';
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
$orderNumbers[] = $bpPayment->getOrderNumber();
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
if (! $real) {
|
| 166 |
+
print '<br />request...<br />';
|
| 167 |
+
var_dump($orderNumbers);
|
| 168 |
+
}
|
| 169 |
+
$response = $this->apiMerchantOrderShipmentStatuses($orderNumbers);
|
| 170 |
+
if (! $real) {
|
| 171 |
+
print '<br />response...<br />';
|
| 172 |
+
var_dump($response);
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
foreach ($response as $r) {
|
| 176 |
+
$number = $r['order_number'];
|
| 177 |
+
$status = $r['shipment_status'];
|
| 178 |
+
$comment = $r['status_comment'];
|
| 179 |
+
$bpPayment = Mage::getModel('borderpay/payment')->loadByOrderNumber($number);
|
| 180 |
+
$order = $bpPayment->getMageOrder();
|
| 181 |
+
|
| 182 |
+
if (! $real) {
|
| 183 |
+
print $order->getIncrementId() . "($number): $status";
|
| 184 |
+
continue;
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
if ($status == 'authorized') {
|
| 188 |
+
$bpPayment->setProcessed(1);
|
| 189 |
+
$bpPayment->save();
|
| 190 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true);
|
| 191 |
+
$order->save();
|
| 192 |
+
} elseif ($status == 'declined') {
|
| 193 |
+
$bpPayment->setProcessed(1);
|
| 194 |
+
$bpPayment->save();
|
| 195 |
+
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, 'payment declined by BorderJump', true);
|
| 196 |
+
$order->save();
|
| 197 |
+
} elseif ($status == 'pending') {
|
| 198 |
+
// do nothing
|
| 199 |
+
}
|
| 200 |
+
}
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
public function updatePendingOrder($id) {
|
| 204 |
+
// stub
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
public function apiMerchantOrderShipmentStatuses($orderNumbers) {
|
| 208 |
+
if (! isset($orderNumbers['order_numbers'])) {
|
| 209 |
+
$request = array('order_numbers' => $orderNumbers);
|
| 210 |
+
} else {
|
| 211 |
+
$request = $orderNumbers;
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
Mage::log('BEGINNING merchant/order/shipment_statuses');
|
| 215 |
+
Mage::log($request);
|
| 216 |
+
|
| 217 |
+
$borderpay = Mage::getSingleton('borderpay/method_borderpay');
|
| 218 |
+
$apiClient = Mage::getModel('apiclient/apiclient', $this->getConfigData('api_url'));
|
| 219 |
+
$apiClient->setKey($borderpay->getConfigData('api_key'));
|
| 220 |
+
$apiClient->setSecret($borderpay->getConfigData('api_secret'));
|
| 221 |
+
|
| 222 |
+
$path = '/merchant/order/shipment_statuses';
|
| 223 |
+
|
| 224 |
+
$response = $apiClient->call($path, 'POST', $request);
|
| 225 |
+
|
| 226 |
+
Mage::log($response);
|
| 227 |
+
Mage::log('ENDING merchant/order/shipment_statuses');
|
| 228 |
+
return $response;
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
public function apiMerchantOrderStatus($orderNumber) {
|
| 232 |
+
Mage::log('BEGINNING merchant/order/status');
|
| 233 |
+
|
| 234 |
+
$borderpay = Mage::getSingleton('borderpay/method_borderpay');
|
| 235 |
+
$apiClient = Mage::getModel('apiclient/apiclient', $this->getConfigData('api_url'));
|
| 236 |
+
$apiClient->setKey($borderpay->getConfigData('api_key'));
|
| 237 |
+
$apiClient->setSecret($borderpay->getConfigData('api_secret'));
|
| 238 |
+
|
| 239 |
+
$path = '/merchant/order/status';
|
| 240 |
+
$params = "order_number=$orderNumber";
|
| 241 |
+
//~ $response = $apiClient->call("/merchant/order/status", 'GET', $request);
|
| 242 |
+
$response = $apiClient->call("$path?$params", 'GET', array());
|
| 243 |
+
|
| 244 |
+
Mage::log($response);
|
| 245 |
+
Mage::log('ENDING merchant/order/status');
|
| 246 |
+
return $response;
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
public function apiMerchantOrderAuth() {
|
| 250 |
+
Mage::getSingleton('core/session', array('name' => 'frontend'));
|
| 251 |
+
Mage::log('BEGINNING merchant/order/auth');
|
| 252 |
+
|
| 253 |
+
$post = Mage::app()->getRequest()->getPost();
|
| 254 |
+
$session = Mage::getSingleton('checkout/session');
|
| 255 |
+
|
| 256 |
+
if (isset($post['PaRes']) && $post['PaRes']) {
|
| 257 |
+
$payload = $post['PaRes'];
|
| 258 |
+
} else {
|
| 259 |
+
Mage::log('AUTH ERROR: could not get payload');
|
| 260 |
+
return false;
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
if ($session->getBorderpayTransactionId()) {
|
| 264 |
+
$transactionId = $session->getBorderpayTransactionId();
|
| 265 |
+
} else {
|
| 266 |
+
Mage::log('AUTH ERROR: could not get transaction ID');
|
| 267 |
+
return false;
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
if ($session->getBorderpayTransactionType()) {
|
| 271 |
+
$transactionType = $session->getBorderpayTransactionType();
|
| 272 |
+
} else {
|
| 273 |
+
Mage::log('AUTH ERROR: could not get transaction type');
|
| 274 |
+
return false;
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
$query = array(
|
| 278 |
+
'PAResPayload' => $payload,
|
| 279 |
+
'transaction_id' => $transactionId,
|
| 280 |
+
'transaction_type' => $transactionType
|
| 281 |
+
);
|
| 282 |
+
Mage::log($query);
|
| 283 |
+
|
| 284 |
+
$borderpay = Mage::getSingleton('borderpay/method_borderpay');
|
| 285 |
+
$apiClient = Mage::getModel('apiclient/apiclient', $this->getConfigData('api_url'));
|
| 286 |
+
$apiClient->setKey($borderpay->getConfigData('api_key'));
|
| 287 |
+
$apiClient->setSecret($borderpay->getConfigData('api_secret'));
|
| 288 |
+
|
| 289 |
+
$response = $apiClient->call('/merchant/order/auth', 'POST', $query);
|
| 290 |
+
Mage::log($response);
|
| 291 |
+
Mage::log('ENDING merchant/order/auth');
|
| 292 |
+
return $response;
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
public function createOrderNumber() {
|
| 296 |
+
$number = Mage::getModel('bordership/carrier_bordership')->makeBorderjumpOrderId();
|
| 297 |
+
return $number;
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
private function _getBorderpayCommodities($object) {
|
| 301 |
+
$commodities = array();
|
| 302 |
+
|
| 303 |
+
$items = null;
|
| 304 |
+
if (get_class($object) === 'Mage_Sales_Model_Quote') {
|
| 305 |
+
$items = $object->getAllVisibleItems();
|
| 306 |
+
} else {
|
| 307 |
+
$items = $object->getAllItems();
|
| 308 |
+
}
|
| 309 |
+
$toCurrency = Mage::app()->getStore()->getCurrentCurrencyCode();
|
| 310 |
+
$fromCurrency = Mage::app()->getStore()->getBaseCurrencyCode();
|
| 311 |
+
foreach($items as $item) {
|
| 312 |
+
$product = $item->getProduct();
|
| 313 |
+
$product->load($product->getId());
|
| 314 |
+
|
| 315 |
+
$commodity = array(
|
| 316 |
+
'name' => $item->getName(),
|
| 317 |
+
'sku' => $item->getSku(),
|
| 318 |
+
'description' => $product->getDescription(),
|
| 319 |
+
'unit_price' => sprintf('%01.2f', Mage::helper('directory')->currencyConvert($product->getPrice(), $fromCurrency, $toCurrency)),
|
| 320 |
+
'unit_price_usd' => sprintf('%01.2f', $product->getPrice()),
|
| 321 |
+
'quantity' => $item->getQty()
|
| 322 |
+
);
|
| 323 |
+
$commodities[] = $commodity;
|
| 324 |
+
}
|
| 325 |
+
return $commodities;
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
private function _parseName($name) {
|
| 329 |
+
$session = Mage::getSingleton('checkout/session');
|
| 330 |
+
$quote = $session->getQuote();
|
| 331 |
+
$billing = $quote->getBillingAddress();
|
| 332 |
+
|
| 333 |
+
$nameComponents = array(
|
| 334 |
+
'firstName' => $billing->getFirstname(),
|
| 335 |
+
'lastName' => $billing->getLastname(),
|
| 336 |
+
'middleInitial' => substr($billing->getMiddleName(), 0, 1)
|
| 337 |
+
);
|
| 338 |
+
|
| 339 |
+
if ($name == $billing->getName()) {
|
| 340 |
+
return $nameComponents;
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
if (! $name) {
|
| 344 |
+
return $nameComponents;
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
$nameExploded = explode(' ', trim($name));
|
| 348 |
+
if (count($nameComponents) <= 1) {
|
| 349 |
+
return false;
|
| 350 |
+
} elseif (count($nameComponents) >= 2) {
|
| 351 |
+
$nameComponents['firstName'] = $nameExploded[0];
|
| 352 |
+
$lastName = array_values(array_slice($nameExploded, -1, 1, true));
|
| 353 |
+
$nameComponents['lastName'] = $lastName[0];
|
| 354 |
+
if (count($nameExploded) > 2) {
|
| 355 |
+
$nameComponents['middleInitial'] = substr($nameExploded[1], 0, 1);
|
| 356 |
+
} else {
|
| 357 |
+
$nameComponents['middleInitial'] = '';
|
| 358 |
+
}
|
| 359 |
+
}
|
| 360 |
+
return $nameComponents;
|
| 361 |
+
}
|
| 362 |
+
|
| 363 |
+
public function apiMerchantOrder() {
|
| 364 |
+
Mage::getSingleton('core/session', array('name' => 'frontend'));
|
| 365 |
+
Mage::log('STARTING /merchant/order');
|
| 366 |
+
$borderpay = Mage::getModel('borderpay/method_borderpay');
|
| 367 |
+
$apiClient = Mage::getModel('apiclient/apiclient', $this->getConfigData('api_url'));
|
| 368 |
+
$apiClient->setKey($borderpay->getConfigData('api_key'));
|
| 369 |
+
$apiClient->setSecret($borderpay->getConfigData('api_secret'));
|
| 370 |
+
|
| 371 |
+
$session = Mage::getSingleton('checkout/session');
|
| 372 |
+
$sessionPaymentInfo = $session->getBorderpayPaymentInfo();
|
| 373 |
+
$quote = $session->getQuote();
|
| 374 |
+
$payment = $quote->getPayment();
|
| 375 |
+
$bpPayment = $session->getBorderpayPayment();
|
| 376 |
+
|
| 377 |
+
$billing = $quote->getBillingAddress();
|
| 378 |
+
$shipping = $quote->getShippingAddress();
|
| 379 |
+
$totals = $quote->getTotals();
|
| 380 |
+
$post = Mage::app()->getRequest()->getPost();
|
| 381 |
+
|
| 382 |
+
$orderNumber = $bpPayment->getOrderNumber();
|
| 383 |
+
$session->setBorderpayOrderNumber($orderNumber);
|
| 384 |
+
|
| 385 |
+
if (isset($post['fingerprint']) && $post['fingerprint']) {
|
| 386 |
+
$fingerprint = $post['fingerprint'];
|
| 387 |
+
} elseif (isset($sessionPaymentInfo['fingerprint'])) {
|
| 388 |
+
$fingerprint = $sessionPaymentInfo['fingerprint'];
|
| 389 |
+
} else {
|
| 390 |
+
$fingerprint = '';
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
if (isset($post['payment']) && $post['payment']) {
|
| 394 |
+
$paymentData = $post['payment'];
|
| 395 |
+
} elseif (isset($sessionPaymentInfo['payment'])) {
|
| 396 |
+
$paymentData = $sessionPaymentInfo['payment'];
|
| 397 |
+
} else {
|
| 398 |
+
$paymentData = array(
|
| 399 |
+
'transaction_type' => '',
|
| 400 |
+
'service' => '',
|
| 401 |
+
'cc_type' => '',
|
| 402 |
+
'cc_number' => '',
|
| 403 |
+
'cc_exp_month' => '',
|
| 404 |
+
'cc_exp_year' => '',
|
| 405 |
+
'cc_cid' => ''
|
| 406 |
+
);
|
| 407 |
+
}
|
| 408 |
+
|
| 409 |
+
if (isset($post['payment']['cc_name'])) {
|
| 410 |
+
$nameComponents = $this->_parseName($post['payment']['cc_name']);
|
| 411 |
+
} else {
|
| 412 |
+
$nameComponents = $this->_parseName(null);
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
$query = array(
|
| 416 |
+
'order_number' => $orderNumber,
|
| 417 |
+
'guid' => $orderNumber . '-' . sprintf('%0'.strlen(mt_getrandmax()).'d', mt_rand()),
|
| 418 |
+
'ip_address' => $this->_getIpAddress(),
|
| 419 |
+
|
| 420 |
+
'shipping_amount' => sprintf('%01.2f', $totals['shipping']->getAddress()->getShippingAmount()),
|
| 421 |
+
'shipping_amount_usd' => sprintf('%01.2f', $totals['shipping']->getAddress()->getBaseShippingAmount()),
|
| 422 |
+
'tax_amount' => sprintf('%01.2f', $totals['grand_total']->getAddress()->getTaxAmount()),
|
| 423 |
+
'tax_amount_usd' => sprintf('%01.2f', $totals['grand_total']->getAddress()->getBaseTaxAmount()),
|
| 424 |
+
'subtotal' => sprintf('%01.2f', $totals['subtotal']->getAddress()->getSubtotal()),
|
| 425 |
+
'subtotal_usd' => sprintf('%01.2f', $totals['subtotal']->getAddress()->getBaseSubtotal()),
|
| 426 |
+
'currency_num' => $this->getIso4217CurrencyCode(Mage::app()->getStore()->getCurrentCurrencyCode()),
|
| 427 |
+
|
| 428 |
+
'email_address' => $quote->getCustomer()->getEmail(),
|
| 429 |
+
|
| 430 |
+
'billing' => array(
|
| 431 |
+
'first_name' => $nameComponents['firstName'],
|
| 432 |
+
'last_name' => $nameComponents['lastName'],
|
| 433 |
+
'middle_initial' => $nameComponents['middleInitial'],
|
| 434 |
+
'address' => $billing->getStreet1(),
|
| 435 |
+
'address2' => $billing->getStreet2(),
|
| 436 |
+
'city' => $billing->getCity(),
|
| 437 |
+
'province' => $billing->getRegionCode(),
|
| 438 |
+
'postal_code' => $billing->getPostcode(),
|
| 439 |
+
'country_code' => $billing->getCountryId(),
|
| 440 |
+
'phone' => $billing->getTelephone()
|
| 441 |
+
),
|
| 442 |
+
|
| 443 |
+
'shipping' => array(
|
| 444 |
+
'first_name' => $shipping->getFirstname(),
|
| 445 |
+
'last_name' => $shipping->getLastname(),
|
| 446 |
+
'middle_initial' => $shipping->getMiddleName() ? substr($address->getMiddleName(), 0, 1) : '',
|
| 447 |
+
'address' => $shipping->getStreet1(),
|
| 448 |
+
'address2' => $shipping->getStreet2(),
|
| 449 |
+
'city' => $shipping->getCity(),
|
| 450 |
+
'province' => $shipping->getRegionCode(),
|
| 451 |
+
'postal_code' => $shipping->getPostcode(),
|
| 452 |
+
'country_code' => $shipping->getCountryId(),
|
| 453 |
+
'phone' => $shipping->getTelephone()
|
| 454 |
+
),
|
| 455 |
+
|
| 456 |
+
'commodities' => $this->_getBorderpayCommodities($quote),
|
| 457 |
+
//'!!order_reference_number' => '',
|
| 458 |
+
//'!!tax_indicator_code' => '',
|
| 459 |
+
//'!!alternate_tax_rate' => '',
|
| 460 |
+
|
| 461 |
+
'fingerprint' => $fingerprint,
|
| 462 |
+
'transaction_type' => $paymentData['transaction_type'],
|
| 463 |
+
'payment_service_id' => isset($paymentData['service']) ? $paymentData['service'] : '',
|
| 464 |
+
'cc_type' => isset($paymentData['cc_type']) ? $paymentData['cc_type'] : '',
|
| 465 |
+
'cc_number' => isset($paymentData['cc_number']) ? $paymentData['cc_number'] : '',
|
| 466 |
+
'expiration_month' => isset($paymentData['cc_exp_month']) ? sprintf('%02s', $paymentData['cc_exp_month']) : '',
|
| 467 |
+
'expiration_year' => isset($paymentData['cc_exp_year']) ? $paymentData['cc_exp_year'] : '',
|
| 468 |
+
'cc_verification' => isset($paymentData['cc_cid']) ? $paymentData['cc_cid'] : ''
|
| 469 |
+
);
|
| 470 |
+
|
| 471 |
+
Mage::log($query);
|
| 472 |
+
$response = $apiClient->call('/merchant/order/', 'POST', $query);
|
| 473 |
+
Mage::log($response);
|
| 474 |
+
Mage::log('ENDING /merchant/order');
|
| 475 |
+
return $response;
|
| 476 |
+
}
|
| 477 |
+
|
| 478 |
+
function getIso4217CurrencyCode($currencyCode) {
|
| 479 |
+
$a = array();
|
| 480 |
+
$a['AFA'] = array('Afghan Afghani', '971');
|
| 481 |
+
$a['AWG'] = array('Aruban Florin', '533');
|
| 482 |
+
$a['AUD'] = array('Australian Dollars', '036');
|
| 483 |
+
$a['ARS'] = array('Argentine Peso', '032');
|
| 484 |
+
$a['AZN'] = array('Azerbaijanian Manat', '944');
|
| 485 |
+
$a['BSD'] = array('Bahamian Dollar', '044');
|
| 486 |
+
$a['BDT'] = array('Bangladeshi Taka', '050');
|
| 487 |
+
$a['BBD'] = array('Barbados Dollar', '052');
|
| 488 |
+
$a['BYR'] = array('Belarussian Rouble', '974');
|
| 489 |
+
$a['BOB'] = array('Bolivian Boliviano', '068');
|
| 490 |
+
$a['BRL'] = array('Brazilian Real', '986');
|
| 491 |
+
$a['GBP'] = array('British Pounds Sterling', '826');
|
| 492 |
+
$a['BGN'] = array('Bulgarian Lev', '975');
|
| 493 |
+
$a['KHR'] = array('Cambodia Riel', '116');
|
| 494 |
+
$a['CAD'] = array('Canadian Dollars', '124');
|
| 495 |
+
$a['KYD'] = array('Cayman Islands Dollar', '136');
|
| 496 |
+
$a['CLP'] = array('Chilean Peso', '152');
|
| 497 |
+
$a['CNY'] = array('Chinese Renminbi Yuan', '156');
|
| 498 |
+
$a['COP'] = array('Colombian Peso', '170');
|
| 499 |
+
$a['CRC'] = array('Costa Rican Colon', '188');
|
| 500 |
+
$a['HRK'] = array('Croatia Kuna', '191');
|
| 501 |
+
$a['CPY'] = array('Cypriot Pounds', '196');
|
| 502 |
+
$a['CZK'] = array('Czech Koruna', '203');
|
| 503 |
+
$a['DKK'] = array('Danish Krone', '208');
|
| 504 |
+
$a['DOP'] = array('Dominican Republic Peso', '214');
|
| 505 |
+
$a['XCD'] = array('East Caribbean Dollar', '951');
|
| 506 |
+
$a['EGP'] = array('Egyptian Pound', '818');
|
| 507 |
+
$a['ERN'] = array('Eritrean Nakfa', '232');
|
| 508 |
+
$a['EEK'] = array('Estonia Kroon', '233');
|
| 509 |
+
$a['EUR'] = array('Euro', '978');
|
| 510 |
+
$a['GEL'] = array('Georgian Lari', '981');
|
| 511 |
+
$a['GHC'] = array('Ghana Cedi', '288');
|
| 512 |
+
$a['GIP'] = array('Gibraltar Pound', '292');
|
| 513 |
+
$a['GTQ'] = array('Guatemala Quetzal', '320');
|
| 514 |
+
$a['HNL'] = array('Honduras Lempira', '340');
|
| 515 |
+
$a['HKD'] = array('Hong Kong Dollars', '344');
|
| 516 |
+
$a['HUF'] = array('Hungary Forint', '348');
|
| 517 |
+
$a['ISK'] = array('Icelandic Krona', '352');
|
| 518 |
+
$a['INR'] = array('Indian Rupee', '356');
|
| 519 |
+
$a['IDR'] = array('Indonesia Rupiah', '360');
|
| 520 |
+
$a['ILS'] = array('Israel Shekel', '376');
|
| 521 |
+
$a['JMD'] = array('Jamaican Dollar', '388');
|
| 522 |
+
$a['JPY'] = array('Japanese yen', '392');
|
| 523 |
+
$a['KZT'] = array('Kazakhstan Tenge', '368');
|
| 524 |
+
$a['KES'] = array('Kenyan Shilling', '404');
|
| 525 |
+
$a['KWD'] = array('Kuwaiti Dinar', '414');
|
| 526 |
+
$a['LVL'] = array('Latvia Lat', '428');
|
| 527 |
+
$a['LBP'] = array('Lebanese Pound', '422');
|
| 528 |
+
$a['LTL'] = array('Lithuania Litas', '440');
|
| 529 |
+
$a['MOP'] = array('Macau Pataca', '446');
|
| 530 |
+
$a['MKD'] = array('Macedonian Denar', '807');
|
| 531 |
+
$a['MGA'] = array('Malagascy Ariary', '969');
|
| 532 |
+
$a['MYR'] = array('Malaysian Ringgit', '458');
|
| 533 |
+
$a['MTL'] = array('Maltese Lira', '470');
|
| 534 |
+
$a['BAM'] = array('Marka', '977');
|
| 535 |
+
$a['MUR'] = array('Mauritius Rupee', '480');
|
| 536 |
+
$a['MXN'] = array('Mexican Pesos', '484');
|
| 537 |
+
$a['MZM'] = array('Mozambique Metical', '508');
|
| 538 |
+
$a['NPR'] = array('Nepalese Rupee', '524');
|
| 539 |
+
$a['ANG'] = array('Netherlands Antilles Guilder', '532');
|
| 540 |
+
$a['TWD'] = array('New Taiwanese Dollars', '901');
|
| 541 |
+
$a['NZD'] = array('New Zealand Dollars', '554');
|
| 542 |
+
$a['NIO'] = array('Nicaragua Cordoba', '558');
|
| 543 |
+
$a['NGN'] = array('Nigeria Naira', '566');
|
| 544 |
+
$a['KPW'] = array('North Korean Won', '408');
|
| 545 |
+
$a['NOK'] = array('Norwegian Krone', '578');
|
| 546 |
+
$a['OMR'] = array('Omani Riyal', '512');
|
| 547 |
+
$a['PKR'] = array('Pakistani Rupee', '586');
|
| 548 |
+
$a['PYG'] = array('Paraguay Guarani', '600');
|
| 549 |
+
$a['PEN'] = array('Peru New Sol', '604');
|
| 550 |
+
$a['PHP'] = array('Philippine Pesos', '608');
|
| 551 |
+
$a['QAR'] = array('Qatari Riyal', '634');
|
| 552 |
+
$a['RON'] = array('Romanian New Leu', '946');
|
| 553 |
+
$a['RUB'] = array('Russian Federation Ruble', '643');
|
| 554 |
+
$a['SAR'] = array('Saudi Riyal', '682');
|
| 555 |
+
$a['CSD'] = array('Serbian Dinar', '891');
|
| 556 |
+
$a['SCR'] = array('Seychelles Rupee', '690');
|
| 557 |
+
$a['SGD'] = array('Singapore Dollars', '702');
|
| 558 |
+
$a['SKK'] = array('Slovak Koruna', '703');
|
| 559 |
+
$a['SIT'] = array('Slovenia Tolar', '705');
|
| 560 |
+
$a['ZAR'] = array('South African Rand', '710');
|
| 561 |
+
$a['KRW'] = array('South Korean Won', '410');
|
| 562 |
+
$a['LKR'] = array('Sri Lankan Rupee', '144');
|
| 563 |
+
$a['SRD'] = array('Surinam Dollar', '968');
|
| 564 |
+
$a['SEK'] = array('Swedish Krona', '752');
|
| 565 |
+
$a['CHF'] = array('Swiss Francs', '756');
|
| 566 |
+
$a['TZS'] = array('Tanzanian Shilling', '834');
|
| 567 |
+
$a['THB'] = array('Thai Baht', '764');
|
| 568 |
+
$a['TTD'] = array('Trinidad and Tobago Dollar', '780');
|
| 569 |
+
$a['TRY'] = array('Turkish New Lira', '949');
|
| 570 |
+
$a['AED'] = array('UAE Dirham', '784');
|
| 571 |
+
$a['USD'] = array('US Dollars', '840');
|
| 572 |
+
$a['UGX'] = array('Ugandian Shilling', '800');
|
| 573 |
+
$a['UAH'] = array('Ukraine Hryvna', '980');
|
| 574 |
+
$a['UYU'] = array('Uruguayan Peso', '858');
|
| 575 |
+
$a['UZS'] = array('Uzbekistani Som', '860');
|
| 576 |
+
$a['VEB'] = array('Venezuela Bolivar', '862');
|
| 577 |
+
$a['VND'] = array('Vietnam Dong', '704');
|
| 578 |
+
$a['AMK'] = array('Zambian Kwacha', '894');
|
| 579 |
+
$a['ZWD'] = array('Zimbabwe Dollar', '716');
|
| 580 |
+
if ($a[$currencyCode]) {
|
| 581 |
+
return $a[$currencyCode][1];
|
| 582 |
+
} else {
|
| 583 |
+
return false;
|
| 584 |
+
}
|
| 585 |
+
}
|
| 586 |
+
}
|
app/code/local/BorderJump/BorderPay/Model/Mysql4/Payment.php
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class BorderJump_BorderPay_Model_Mysql4_Payment extends Mage_Core_Model_Mysql4_Abstract
|
| 4 |
+
{
|
| 5 |
+
public function _construct()
|
| 6 |
+
{
|
| 7 |
+
$this->_init('borderpay/payment', 'id');
|
| 8 |
+
}
|
| 9 |
+
}
|
app/code/local/BorderJump/BorderPay/Model/Observer.php
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?
|
| 2 |
+
|
| 3 |
+
class BorderJump_BorderPay_Model_Observer {
|
| 4 |
+
public function __construct() {}
|
| 5 |
+
|
| 6 |
+
private function _getOrderStatus($order) {
|
| 7 |
+
$orderNumber = '';
|
| 8 |
+
|
| 9 |
+
$apiClient = Mage::getModel('apiclient/apiclient', $carrier->getConfigData('api_url'));
|
| 10 |
+
$apiClient->setKey($carrier->getConfigData('api_key'));
|
| 11 |
+
$apiClient->setSecret($carrier->getConfigData('api_secret'));
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
private $_preDispatchHasRun = false;
|
| 15 |
+
public function controller_action_predispatch_checkout_onepage_saveOrder_hook($observer) {
|
| 16 |
+
if ($this->_preDispatchHasRun) {
|
| 17 |
+
$this->_preDispatchHasRun = false;
|
| 18 |
+
return $observer;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
Mage::getSingleton('core/session', array('name' => 'frontend'));
|
| 22 |
+
$result = null;
|
| 23 |
+
$session = Mage::getSingleton('checkout/session');
|
| 24 |
+
if ($session->getBorderpayIsThirdPartyDone()) {
|
| 25 |
+
$session->setBorderpayIsThirdPartyDone();
|
| 26 |
+
return $observer;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
$payment = $session->getQuote()->getPayment();
|
| 30 |
+
$code = $payment->getMethodInstance()->getCode();
|
| 31 |
+
if (strtolower($code) != 'borderpay') {
|
| 32 |
+
return $observer;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
$paymentInfo = $session->getBorderpayPaymentInfo();
|
| 36 |
+
if ($paymentInfo['payment']['service'] != 6) {
|
| 37 |
+
return $observer;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
$request = Mage::app()->getRequest();
|
| 41 |
+
$action = $request->getActionName();
|
| 42 |
+
|
| 43 |
+
$borderpay = Mage::getModel('borderpay/method_borderpay');
|
| 44 |
+
$response = $borderpay->apiMerchantOrder();
|
| 45 |
+
$status = Mage::helper('borderpay/response')->getStatus($response);
|
| 46 |
+
$isEnrolled = Mage::helper('borderpay/response')->isEnrolled($response);
|
| 47 |
+
|
| 48 |
+
if ($isEnrolled) {
|
| 49 |
+
Mage::log('enrolled; saving session stuff');
|
| 50 |
+
$session->setBorderpayTransactionData(array(
|
| 51 |
+
'PaReq' => $response['payload'],
|
| 52 |
+
'ACSUrl' => $response['ACSUrl'],
|
| 53 |
+
'MD' => $response['transaction_id']
|
| 54 |
+
));
|
| 55 |
+
$session->setBorderpayPayload($response['payload']);
|
| 56 |
+
$session->setBorderpayTransactionId($response['transaction_id']);
|
| 57 |
+
$session->setBorderpayTransactionType('CC');
|
| 58 |
+
$session->setBorderpayReturnUrl(Mage::getUrl());
|
| 59 |
+
|
| 60 |
+
Mage::app()->getFrontController()->getAction()->setFlag($action, Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
|
| 61 |
+
$result = array(
|
| 62 |
+
'success' => false,
|
| 63 |
+
'error' => false,
|
| 64 |
+
'redirect' => Mage::getUrl("checkout/onepage/thirdPartySubmit"),
|
| 65 |
+
);
|
| 66 |
+
} else {
|
| 67 |
+
$session->setBorderpayOrderStatus($status);
|
| 68 |
+
$this->_preDispatchHasRun = true;
|
| 69 |
+
return $observer;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
if (! $result) {
|
| 73 |
+
Mage::app()->getFrontController()->getAction()->setFlag($action, Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
|
| 74 |
+
$result = array(
|
| 75 |
+
'success' => false,
|
| 76 |
+
'error' => 'true',
|
| 77 |
+
'error_messages' => 'There was an error placing your order. Please try again later'
|
| 78 |
+
);
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
$response = Mage::app()->getResponse();
|
| 82 |
+
$response->setHttpResponseCode(200);
|
| 83 |
+
$json = Mage::helper('core')->jsonEncode($result);
|
| 84 |
+
$response->setBody($json);
|
| 85 |
+
|
| 86 |
+
$this->_preDispatchHasRun = true;
|
| 87 |
+
return $observer;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
public function sales_order_place_before_hook($observer) {
|
| 91 |
+
Mage::getSingleton('core/session', array('name' => 'frontend'));
|
| 92 |
+
$session = Mage::getSingleton('checkout/session');
|
| 93 |
+
$status = $session->getBorderpayOrderStatus();
|
| 94 |
+
$session->setBorderpayOrderStatus();
|
| 95 |
+
|
| 96 |
+
$order = $observer->getOrder();
|
| 97 |
+
if ($status == 'pending') {
|
| 98 |
+
$order->setState(Mage_Sales_Model_Order::STATE_NEW, true);
|
| 99 |
+
} elseif ($status == 'approved') {
|
| 100 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true);
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
return $observer;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
public function sales_order_place_after_hook($observer) {
|
| 107 |
+
Mage::getSingleton('core/session', array('name' => 'frontend'));
|
| 108 |
+
$session = Mage::getSingleton('checkout/session');
|
| 109 |
+
$order = $observer->getEvent()->getOrder();
|
| 110 |
+
$payment = $order->getPayment();
|
| 111 |
+
$code = $payment->getMethodInstance()->getCode();
|
| 112 |
+
if (strtolower($code) != 'borderpay') {
|
| 113 |
+
return $observer;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
$bpPayment = $session->getBorderpayPayment();
|
| 117 |
+
if ($bpPayment) {
|
| 118 |
+
$bpPayment->setMagePayment($payment);
|
| 119 |
+
$bpPayment->save();
|
| 120 |
+
}
|
| 121 |
+
return $observer;
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
?>
|
app/code/local/BorderJump/BorderPay/Model/Order/Pdf/Invoice.php
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class BorderJump_BorderPay_Model_Order_Pdf_Invoice extends Mage_Sales_Model_Order_Pdf_Abstract
|
| 4 |
+
{
|
| 5 |
+
public function getPdf($invoices = array())
|
| 6 |
+
{
|
| 7 |
+
$this->_beforeGetPdf();
|
| 8 |
+
$this->_initRenderer('invoice');
|
| 9 |
+
|
| 10 |
+
$pdf = new Zend_Pdf();
|
| 11 |
+
$this->_setPdf($pdf);
|
| 12 |
+
$style = new Zend_Pdf_Style();
|
| 13 |
+
$this->_setFontBold($style, 10);
|
| 14 |
+
|
| 15 |
+
foreach ($invoices as $invoice) {
|
| 16 |
+
if ($invoice->getStoreId()) {
|
| 17 |
+
Mage::app()->getLocale()->emulate($invoice->getStoreId());
|
| 18 |
+
Mage::app()->setCurrentStore($invoice->getStoreId());
|
| 19 |
+
}
|
| 20 |
+
$page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
|
| 21 |
+
$pdf->pages[] = $page;
|
| 22 |
+
|
| 23 |
+
$order = $invoice->getOrder();
|
| 24 |
+
|
| 25 |
+
/* Add image */
|
| 26 |
+
$this->insertLogo($page, $invoice->getStore());
|
| 27 |
+
|
| 28 |
+
/* Add address */
|
| 29 |
+
$this->insertAddress($page, $invoice->getStore());
|
| 30 |
+
|
| 31 |
+
/* Add head */
|
| 32 |
+
$this->insertOrder($page, $order, Mage::getStoreConfigFlag(self::XML_PATH_SALES_PDF_INVOICE_PUT_ORDER_ID, $order->getStoreId()));
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
$page->setFillColor(new Zend_Pdf_Color_GrayScale(1));
|
| 36 |
+
$this->_setFontRegular($page);
|
| 37 |
+
$page->drawText(Mage::helper('sales')->__('Invoice # ') . $invoice->getIncrementId(), 35, 780, 'UTF-8');
|
| 38 |
+
|
| 39 |
+
/* Add table */
|
| 40 |
+
$page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92));
|
| 41 |
+
$page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
|
| 42 |
+
$page->setLineWidth(0.5);
|
| 43 |
+
|
| 44 |
+
$page->drawRectangle(25, $this->y, 570, $this->y -15);
|
| 45 |
+
$this->y -=10;
|
| 46 |
+
|
| 47 |
+
/* Add table head */
|
| 48 |
+
$page->setFillColor(new Zend_Pdf_Color_RGB(0.4, 0.4, 0.4));
|
| 49 |
+
$page->drawText(Mage::helper('sales')->__('Products'), 35, $this->y, 'UTF-8');
|
| 50 |
+
$page->drawText(Mage::helper('sales')->__('SKU'), 255, $this->y, 'UTF-8');
|
| 51 |
+
$page->drawText(Mage::helper('sales')->__('Price'), 380, $this->y, 'UTF-8');
|
| 52 |
+
$page->drawText(Mage::helper('sales')->__('Qty'), 430, $this->y, 'UTF-8');
|
| 53 |
+
$page->drawText(Mage::helper('sales')->__('Tax'), 480, $this->y, 'UTF-8');
|
| 54 |
+
$page->drawText(Mage::helper('sales')->__('Subtotal'), 535, $this->y, 'UTF-8');
|
| 55 |
+
|
| 56 |
+
$this->y -=15;
|
| 57 |
+
|
| 58 |
+
$page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
|
| 59 |
+
|
| 60 |
+
/* Add body */
|
| 61 |
+
foreach ($invoice->getAllItems() as $item){
|
| 62 |
+
if ($item->getOrderItem()->getParentItem()) {
|
| 63 |
+
continue;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
if ($this->y < 15) {
|
| 67 |
+
$page = $this->newPage(array('table_header' => true));
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
/* Draw item */
|
| 71 |
+
$page = $this->_drawItem($item, $page, $order);
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
/* Add totals */
|
| 75 |
+
$page = $this->insertTotals($page, $invoice);
|
| 76 |
+
|
| 77 |
+
if ($invoice->getStoreId()) {
|
| 78 |
+
Mage::app()->getLocale()->revert();
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
$this->_afterGetPdf();
|
| 83 |
+
|
| 84 |
+
return $pdf;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
/**
|
| 88 |
+
* Create new page and assign to PDF object
|
| 89 |
+
*
|
| 90 |
+
* @param array $settings
|
| 91 |
+
* @return Zend_Pdf_Page
|
| 92 |
+
*/
|
| 93 |
+
public function newPage(array $settings = array())
|
| 94 |
+
{
|
| 95 |
+
/* Add new table head */
|
| 96 |
+
$page = $this->_getPdf()->newPage(Zend_Pdf_Page::SIZE_A4);
|
| 97 |
+
$this->_getPdf()->pages[] = $page;
|
| 98 |
+
$this->y = 800;
|
| 99 |
+
|
| 100 |
+
if (!empty($settings['table_header'])) {
|
| 101 |
+
$this->_setFontRegular($page);
|
| 102 |
+
$page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92));
|
| 103 |
+
$page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
|
| 104 |
+
$page->setLineWidth(0.5);
|
| 105 |
+
$page->drawRectangle(25, $this->y, 570, $this->y-15);
|
| 106 |
+
$this->y -=10;
|
| 107 |
+
|
| 108 |
+
$page->setFillColor(new Zend_Pdf_Color_RGB(0.4, 0.4, 0.4));
|
| 109 |
+
$page->drawText(Mage::helper('sales')->__('Product'), 35, $this->y, 'UTF-8');
|
| 110 |
+
$page->drawText(Mage::helper('sales')->__('SKU'), 255, $this->y, 'UTF-8');
|
| 111 |
+
$page->drawText(Mage::helper('sales')->__('Price'), 380, $this->y, 'UTF-8');
|
| 112 |
+
$page->drawText(Mage::helper('sales')->__('Qty'), 430, $this->y, 'UTF-8');
|
| 113 |
+
$page->drawText(Mage::helper('sales')->__('Tax'), 480, $this->y, 'UTF-8');
|
| 114 |
+
$page->drawText(Mage::helper('sales')->__('Subtotal'), 535, $this->y, 'UTF-8');
|
| 115 |
+
|
| 116 |
+
$page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
|
| 117 |
+
$this->y -=20;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
return $page;
|
| 121 |
+
}
|
| 122 |
+
}
|
app/code/local/BorderJump/BorderPay/Model/Order/Pdf/Items/Invoice/Default.php
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class BorderJump_BorderPay_Model_Order_Pdf_Items_Invoice_Default extends Mage_Sales_Model_Order_Pdf_Items_Abstract
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* Draw item line
|
| 7 |
+
*
|
| 8 |
+
*/
|
| 9 |
+
public function draw()
|
| 10 |
+
{
|
| 11 |
+
$order = $this->getOrder();
|
| 12 |
+
$item = $this->getItem();
|
| 13 |
+
$pdf = $this->getPdf();
|
| 14 |
+
$page = $this->getPage();
|
| 15 |
+
$lines = array();
|
| 16 |
+
|
| 17 |
+
// draw Product name
|
| 18 |
+
$lines[0] = array(array(
|
| 19 |
+
'text' => Mage::helper('core/string')->str_split($item->getName(), 60, true, true),
|
| 20 |
+
'feed' => 35,
|
| 21 |
+
));
|
| 22 |
+
|
| 23 |
+
// draw SKU
|
| 24 |
+
$lines[0][] = array(
|
| 25 |
+
'text' => Mage::helper('core/string')->str_split($this->getSku($item), 25),
|
| 26 |
+
'feed' => 255
|
| 27 |
+
);
|
| 28 |
+
|
| 29 |
+
// draw QTY
|
| 30 |
+
$lines[0][] = array(
|
| 31 |
+
'text' => $item->getQty()*1,
|
| 32 |
+
'feed' => 435
|
| 33 |
+
);
|
| 34 |
+
|
| 35 |
+
// draw Price
|
| 36 |
+
$lines[0][] = array(
|
| 37 |
+
'text' => $order->formatPriceTxt($item->getPrice())
|
| 38 |
+
. ' / ' . 'altCurrency',
|
| 39 |
+
'feed' => 395,
|
| 40 |
+
'font' => 'bold',
|
| 41 |
+
'align' => 'right'
|
| 42 |
+
);
|
| 43 |
+
|
| 44 |
+
// draw Tax
|
| 45 |
+
$lines[0][] = array(
|
| 46 |
+
'text' => $order->formatPriceTxt($item->getTaxAmount()),
|
| 47 |
+
'feed' => 495,
|
| 48 |
+
'font' => 'bold',
|
| 49 |
+
'align' => 'right'
|
| 50 |
+
);
|
| 51 |
+
|
| 52 |
+
// draw Subtotal
|
| 53 |
+
$lines[0][] = array(
|
| 54 |
+
'text' => $order->formatPriceTxt($item->getRowTotal()),
|
| 55 |
+
'feed' => 565,
|
| 56 |
+
'font' => 'bold',
|
| 57 |
+
'align' => 'right'
|
| 58 |
+
);
|
| 59 |
+
|
| 60 |
+
// custom options
|
| 61 |
+
$options = $this->getItemOptions();
|
| 62 |
+
if ($options) {
|
| 63 |
+
foreach ($options as $option) {
|
| 64 |
+
// draw options label
|
| 65 |
+
$lines[][] = array(
|
| 66 |
+
'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 70, true, true),
|
| 67 |
+
'font' => 'italic',
|
| 68 |
+
'feed' => 35
|
| 69 |
+
);
|
| 70 |
+
|
| 71 |
+
if ($option['value']) {
|
| 72 |
+
$_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']);
|
| 73 |
+
$values = explode(', ', $_printValue);
|
| 74 |
+
foreach ($values as $value) {
|
| 75 |
+
$lines[][] = array(
|
| 76 |
+
'text' => Mage::helper('core/string')->str_split($value, 50, true, true),
|
| 77 |
+
'feed' => 40
|
| 78 |
+
);
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
$lineBlock = array(
|
| 85 |
+
'lines' => $lines,
|
| 86 |
+
'height' => 10
|
| 87 |
+
);
|
| 88 |
+
|
| 89 |
+
$page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
|
| 90 |
+
$this->setPage($page);
|
| 91 |
+
}
|
| 92 |
+
}
|
app/code/local/BorderJump/BorderPay/Model/Payment.php
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class BorderJump_BorderPay_Model_Payment extends Mage_Core_Model_Abstract
|
| 4 |
+
{
|
| 5 |
+
public function _construct()
|
| 6 |
+
{
|
| 7 |
+
parent::_construct();
|
| 8 |
+
$this->_init('borderpay/payment');
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
public function setMagePayment($payment) {
|
| 12 |
+
$this->setPaymentId($payment->getEntityId());
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
public function loadByMagePayment($payment) {
|
| 16 |
+
return $this->load($payment->getEntityId(), 'payment_id');
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
public function loadByOrderNumber($number) {
|
| 20 |
+
return $this->load($number, 'order_number');
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
public function getMagePayment() {
|
| 24 |
+
return Mage::getModel('sales/order_payment')->load($this->getPaymentId());
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
public function getMageOrder() {
|
| 28 |
+
$payment = Mage::getModel('sales/order_payment')->load($this->getPaymentId());
|
| 29 |
+
return Mage::getModel('sales/order')->load($payment->getParentId());
|
| 30 |
+
}
|
| 31 |
+
}
|
app/code/local/BorderJump/BorderPay/controllers/OnepageController.php
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
include_once('Mage/Checkout/controllers/OnepageController.php');
|
| 4 |
+
class BorderJump_BorderPay_OnepageController extends Mage_Checkout_OnepageController {
|
| 5 |
+
|
| 6 |
+
protected function _rewrite() {
|
| 7 |
+
//call the parent rewrite method so every that needs
|
| 8 |
+
//to happen happens
|
| 9 |
+
$original_result = parent::_rewrite();
|
| 10 |
+
|
| 11 |
+
//fire the event ourselve, since magento isn't firing it
|
| 12 |
+
Mage::dispatchEvent(
|
| 13 |
+
'controller_action_predispatch_'.$this->getFullActionName(),
|
| 14 |
+
array('controller_action'=>$this)
|
| 15 |
+
);
|
| 16 |
+
|
| 17 |
+
//return the original result in case another method is relying on it
|
| 18 |
+
return $original_result;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
public function zendTestAction() {
|
| 22 |
+
$query = array(
|
| 23 |
+
'currency_num' => 826,
|
| 24 |
+
'country_code' => 'GBR'
|
| 25 |
+
);
|
| 26 |
+
$borderpay = Mage::getModel('borderpay/method_borderpay');
|
| 27 |
+
$oldApi = Mage::getModel('BorderJump_ApiClient_Model_Apiclient');
|
| 28 |
+
$oldApi->setKey($borderpay->getConfigData('api_key'));
|
| 29 |
+
$oldApi->setSecret($borderpay->getConfigData('api_secret'));
|
| 30 |
+
$client = new Zend_Http_Client('https://sandbox-pay.bjl.bz/merchant/payment-services/');
|
| 31 |
+
$client->setHeaders($oldApi->generateHeader($query));
|
| 32 |
+
$response = $client->request();
|
| 33 |
+
var_dump($response);
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
public function currencyTestAction() {
|
| 37 |
+
$obs = Mage::getModel('directory/observer');
|
| 38 |
+
$obs->scheduledUpdateCurrencyRates(null);
|
| 39 |
+
die('done');
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
public function cronTestAction() {
|
| 43 |
+
$params = Mage::app()->getRequest()->getParams();
|
| 44 |
+
$borderpay = Mage::getSingleton('borderpay/method_borderpay');
|
| 45 |
+
$borderpay->updateAllPendingOrders($params['real']);
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
public function saveAdditionalDataAction() {
|
| 49 |
+
Mage::getSingleton('core/session', array('name' => 'frontend'));
|
| 50 |
+
$session = Mage::getSingleton('checkout/session');
|
| 51 |
+
$post = Mage::app()->getRequest()->getPost();
|
| 52 |
+
$payment = $session->getQuote()->getPayment();
|
| 53 |
+
|
| 54 |
+
$orderNumber = Mage::getModel('borderpay/method_borderpay')->createOrderNumber();
|
| 55 |
+
$sessionData = array(
|
| 56 |
+
'fingerprint' => $post['fingerprint'],
|
| 57 |
+
'order_number' => $orderNumber,
|
| 58 |
+
'payment' => $post['payment']
|
| 59 |
+
);
|
| 60 |
+
|
| 61 |
+
$session->setBorderpayPaymentInfo($sessionData);
|
| 62 |
+
$bpPayment = Mage::getModel('borderpay/payment');
|
| 63 |
+
$bpPayment->setOrderNumber($orderNumber);
|
| 64 |
+
|
| 65 |
+
$session->setBorderpayPayment($bpPayment);
|
| 66 |
+
|
| 67 |
+
echo json_encode(true);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
// creates an html form and submits it to a third party
|
| 71 |
+
public function thirdPartySubmitAction() {
|
| 72 |
+
Mage::getSingleton('core/session', array('name' => 'frontend'));
|
| 73 |
+
$session = Mage::getSingleton('checkout/session');
|
| 74 |
+
$data = $session->getBorderpayTransactionData();
|
| 75 |
+
$action = $data['ACSUrl'];
|
| 76 |
+
echo "<html><body>";
|
| 77 |
+
echo "<form id='submitMe' name='submitMe' method='post' action='$action 'style='visibility: hidden'>";
|
| 78 |
+
foreach ($data as $k => $v) {
|
| 79 |
+
echo "<input name='$k' value='$v' />";
|
| 80 |
+
}
|
| 81 |
+
echo '<input name="TermUrl" value="' . Mage::getUrl("checkout/onepage/authorizePayment") . '">';
|
| 82 |
+
echo '<input type="submit" />';
|
| 83 |
+
echo '</form>';
|
| 84 |
+
echo "
|
| 85 |
+
<script>
|
| 86 |
+
window.onload = function() {
|
| 87 |
+
document.submitMe.submit();
|
| 88 |
+
};
|
| 89 |
+
</script>
|
| 90 |
+
";
|
| 91 |
+
echo "</body></html>";
|
| 92 |
+
$session->setBorderpayIsThirdPartyDone(true);
|
| 93 |
+
$session->setBorderpayTransactionData();
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
public function submitPaymentAction() {
|
| 97 |
+
Mage::getSingleton('core/session', array('name' => 'frontend'));
|
| 98 |
+
$post = Mage::app()->getRequest()->getPost();
|
| 99 |
+
$borderpay = Mage::getSingleton('borderpay/method_borderpay');
|
| 100 |
+
$response = $borderpay->apiMerchantOrder();
|
| 101 |
+
$session = Mage::getSingleton('checkout/session');
|
| 102 |
+
|
| 103 |
+
if (isset($response['transaction_id']) && $response['transaction_id']) {
|
| 104 |
+
$session->setBorderpayTransactionId($response['transaction_id']);
|
| 105 |
+
}
|
| 106 |
+
if (isset($post['payment']['transaction_type']) && $post['payment']['transaction_type']) {
|
| 107 |
+
$session->setBorderpayTransactionType($post['payment']['transaction_type']);
|
| 108 |
+
}
|
| 109 |
+
echo json_encode($response);
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
public function authorizePaymentAction() {
|
| 113 |
+
Mage::getSingleton('core/session', array('name' => 'frontend'));
|
| 114 |
+
$session = Mage::getSingleton('checkout/session');
|
| 115 |
+
$borderpay = Mage::getSingleton('borderpay/method_borderpay');
|
| 116 |
+
$response = $borderpay->apiMerchantOrderAuth();
|
| 117 |
+
if ($response) {
|
| 118 |
+
$status = Mage::helper('borderpay/response')->getStatus($response);
|
| 119 |
+
|
| 120 |
+
// approved
|
| 121 |
+
if ($status === 'approved' || $status === 'pending') {
|
| 122 |
+
$checkout = Mage::getSingleton('checkout/type_onepage');
|
| 123 |
+
|
| 124 |
+
// save custom session addresses if they exist. magento
|
| 125 |
+
// is flaky about saving them to its session properly.
|
| 126 |
+
if ($session->getBorderpayShippingAddress()) {
|
| 127 |
+
$checkout->saveShipping($session->getBorderpayShippingAddress());
|
| 128 |
+
}
|
| 129 |
+
if ($session->getBorderpayBillingAddress()) {
|
| 130 |
+
$checkout->saveBilling($session->getBorderpayBillingAddress());
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
$checkout->saveShippingMethod($session->getQuote()->getShippingAddress()->getShippingMethod());
|
| 134 |
+
|
| 135 |
+
$checkout->savePayment(array('method' => 'borderpay'));
|
| 136 |
+
$checkout->saveOrder();
|
| 137 |
+
|
| 138 |
+
$session->setBorderpayTransactionId();
|
| 139 |
+
$session->setBorderpayTransactionType();
|
| 140 |
+
$session->setBorderpayPaymentInfo();
|
| 141 |
+
|
| 142 |
+
foreach ($session->getQuote()->getItemsCollection() as $item) {
|
| 143 |
+
Mage::getSingleton('checkout/cart')->removeItem($item->getId())->save();
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
$this->_redirect('checkout/onepage/success', array('_secure' => true));
|
| 147 |
+
|
| 148 |
+
// declined
|
| 149 |
+
} elseif ($status === 'declined') {
|
| 150 |
+
$this->loadLayout();
|
| 151 |
+
$block = $this->getLayout()->createBlock(
|
| 152 |
+
'Mage_Core_Block_Template',
|
| 153 |
+
'borderpay.error',
|
| 154 |
+
array('template' => 'borderpay/checkout/onepage/error.phtml')
|
| 155 |
+
);
|
| 156 |
+
$this->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');
|
| 157 |
+
$this->getLayout()->getBlock('content')->append($block);
|
| 158 |
+
$this->renderLayout();
|
| 159 |
+
|
| 160 |
+
// customer cancelled transaction
|
| 161 |
+
} elseif ($status === 'cancelled') {
|
| 162 |
+
$this->_redirect('checkout/onepage');
|
| 163 |
+
}
|
| 164 |
+
} else {
|
| 165 |
+
$this->_redirect('checkout/onepage');
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
// clear out the session variables in any case
|
| 169 |
+
$session->setBorderpayTransactionId();
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
public function apiMerchantOrderAction() {
|
| 173 |
+
$borderpay = Mage::getSingleton('borderpay/method_borderpay');
|
| 174 |
+
$response = $borderpay->apiMerchantOrder();
|
| 175 |
+
echo json_encode($response);
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
public function apiMerchantOrderAuthAction() {
|
| 179 |
+
$borderpay = Mage::getSingleton('borderpay/method_borderpay');
|
| 180 |
+
$response = $borderpay->apiMerchantOrderAuth();
|
| 181 |
+
echo json_encode($response);
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
public function saveAddressesAction() {
|
| 185 |
+
$session = Mage::getSingleton('checkout/session');
|
| 186 |
+
$billing = $session->getQuote()->getBillingAddress()->getData();
|
| 187 |
+
$shipping = $session->getQuote()->getShippingAddress()->getData();
|
| 188 |
+
|
| 189 |
+
$billing['address'] = $billing['street'];
|
| 190 |
+
$shipping['address'] = $shipping['street'];
|
| 191 |
+
$session->setBorderpayBillingAddress($billing);
|
| 192 |
+
$session->setBorderpayShippingAddress($shipping);
|
| 193 |
+
}
|
| 194 |
+
}
|
app/code/local/BorderJump/BorderPay/etc/config.xml
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<crontab>
|
| 4 |
+
<jobs>
|
| 5 |
+
<borderjump_borderpay>
|
| 6 |
+
<schedule><cron_expr>0 * * * *</cron_expr></schedule>
|
| 7 |
+
<run><model>borderpay/method_borderpay::checkPendingOrders</model></run>
|
| 8 |
+
</borderjump_borderpay>
|
| 9 |
+
</jobs>
|
| 10 |
+
</crontab>
|
| 11 |
+
<modules>
|
| 12 |
+
<BorderJump_BorderPay>
|
| 13 |
+
<version>1.0.0</version>
|
| 14 |
+
</BorderJump_BorderPay>
|
| 15 |
+
</modules>
|
| 16 |
+
<frontend>
|
| 17 |
+
<routers>
|
| 18 |
+
<checkout>
|
| 19 |
+
<args>
|
| 20 |
+
<modules>
|
| 21 |
+
<BorderJump_BorderPay before="Mage_Checkout">BorderJump_BorderPay</BorderJump_BorderPay>
|
| 22 |
+
</modules>
|
| 23 |
+
</args>
|
| 24 |
+
</checkout>
|
| 25 |
+
</routers>
|
| 26 |
+
<layout>
|
| 27 |
+
<updates>
|
| 28 |
+
<borderpay>
|
| 29 |
+
<file>borderpay.xml</file>
|
| 30 |
+
</borderpay>
|
| 31 |
+
</updates>
|
| 32 |
+
</layout>
|
| 33 |
+
</frontend>
|
| 34 |
+
<global>
|
| 35 |
+
<helpers>
|
| 36 |
+
<borderpay>
|
| 37 |
+
<class>BorderJump_BorderPay_Helper</class>
|
| 38 |
+
</borderpay>
|
| 39 |
+
<shipping>
|
| 40 |
+
<rewrite>
|
| 41 |
+
<data>BorderJump_BorderPay_Helper_Data</data>
|
| 42 |
+
</rewrite>
|
| 43 |
+
</shipping>
|
| 44 |
+
</helpers>
|
| 45 |
+
<blocks>
|
| 46 |
+
<borderpay>
|
| 47 |
+
<class>BorderJump_BorderPay_Block</class>
|
| 48 |
+
</borderpay>
|
| 49 |
+
</blocks>
|
| 50 |
+
<models>
|
| 51 |
+
<borderpay>
|
| 52 |
+
<class>BorderJump_BorderPay_Model</class>
|
| 53 |
+
<resourceModel>borderpay_mysql4</resourceModel>
|
| 54 |
+
</borderpay>
|
| 55 |
+
<sales>
|
| 56 |
+
<rewrite>
|
| 57 |
+
<order_pdf_invoice>BorderJump_BorderPay_Model_Order_Pdf_Invoice</order_pdf_invoice>
|
| 58 |
+
<order_pdf_items_invoice_default>BorderJump_BorderPay_Model_Order_Pdf_Items_Invoice_Default</order_pdf_items_invoice_default>
|
| 59 |
+
</rewrite>
|
| 60 |
+
</sales>
|
| 61 |
+
<borderpay_mysql4>
|
| 62 |
+
<class>BorderJump_BorderPay_Model_Mysql4</class>
|
| 63 |
+
<entities>
|
| 64 |
+
<payment>
|
| 65 |
+
<table>borderpay_payments</table>
|
| 66 |
+
</payment>
|
| 67 |
+
</entities>
|
| 68 |
+
</borderpay_mysql4>
|
| 69 |
+
</models>
|
| 70 |
+
<events>
|
| 71 |
+
<controller_action_predispatch_checkout_onepage_saveOrder>
|
| 72 |
+
<observers>
|
| 73 |
+
<BorderJump_BorderPay_Model_Observer>
|
| 74 |
+
<type>singleton</type>
|
| 75 |
+
<class>BorderJump_BorderPay_Model_Observer</class>
|
| 76 |
+
<method>controller_action_predispatch_checkout_onepage_saveOrder_hook</method>
|
| 77 |
+
</BorderJump_BorderPay_Model_Observer>
|
| 78 |
+
</observers>
|
| 79 |
+
</controller_action_predispatch_checkout_onepage_saveOrder>
|
| 80 |
+
<sales_order_place_before>
|
| 81 |
+
<observers>
|
| 82 |
+
<BorderJump_BorderPay_Model_Observer>
|
| 83 |
+
<type>singleton</type>
|
| 84 |
+
<class>BorderJump_BorderPay_Model_Observer</class>
|
| 85 |
+
<method>sales_order_place_before_hook</method>
|
| 86 |
+
</BorderJump_BorderPay_Model_Observer>
|
| 87 |
+
</observers>
|
| 88 |
+
</sales_order_place_before>
|
| 89 |
+
<sales_order_place_after>
|
| 90 |
+
<observers>
|
| 91 |
+
<BorderJump_BorderPay_Model_Observer>
|
| 92 |
+
<type>singleton</type>
|
| 93 |
+
<class>BorderJump_BorderPay_Model_Observer</class>
|
| 94 |
+
<method>sales_order_place_after_hook</method>
|
| 95 |
+
</BorderJump_BorderPay_Model_Observer>
|
| 96 |
+
</observers>
|
| 97 |
+
</sales_order_place_after>
|
| 98 |
+
</events>
|
| 99 |
+
<resources>
|
| 100 |
+
<borderpay_setup>
|
| 101 |
+
<setup>
|
| 102 |
+
<module>BorderJump_BorderPay</module>
|
| 103 |
+
</setup>
|
| 104 |
+
<connection>
|
| 105 |
+
<use>core_setup</use>
|
| 106 |
+
</connection>
|
| 107 |
+
</borderpay_setup>
|
| 108 |
+
<borderpay_write>
|
| 109 |
+
<connection>
|
| 110 |
+
<use>core_write</use>
|
| 111 |
+
</connection>
|
| 112 |
+
</borderpay_write>
|
| 113 |
+
<borderpay_read>
|
| 114 |
+
<connection>
|
| 115 |
+
<use>core_read</use>
|
| 116 |
+
</connection>
|
| 117 |
+
</borderpay_read>
|
| 118 |
+
</resources>
|
| 119 |
+
</global>
|
| 120 |
+
<default>
|
| 121 |
+
<payment>
|
| 122 |
+
<borderpay>
|
| 123 |
+
<active>0</active>
|
| 124 |
+
<model>borderpay/method_borderpay</model>
|
| 125 |
+
<order_status>pending</order_status>
|
| 126 |
+
<title>International Payment Options</title>
|
| 127 |
+
<cctypes>AE,VI,MC,DI</cctypes>
|
| 128 |
+
<payment_action>authorize</payment_action>
|
| 129 |
+
<allowspecific>0</allowspecific>
|
| 130 |
+
</borderpay>
|
| 131 |
+
</payment>
|
| 132 |
+
</default>
|
| 133 |
+
</config>
|
app/code/local/BorderJump/BorderPay/etc/system.xml
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<sections>
|
| 4 |
+
<!-- payment tab -->
|
| 5 |
+
<payment>
|
| 6 |
+
<groups>
|
| 7 |
+
<borderpay translate="label" module="paygate">
|
| 8 |
+
<label>BorderPay</label>
|
| 9 |
+
<!-- position between other payment methods -->
|
| 10 |
+
<sort_order>670</sort_order>
|
| 11 |
+
<!-- do not show this configuration options in store scope -->
|
| 12 |
+
<show_in_default>1</show_in_default>
|
| 13 |
+
<show_in_website>1</show_in_website>
|
| 14 |
+
<show_in_store>1</show_in_store>
|
| 15 |
+
<fields>
|
| 16 |
+
<version translate="label">
|
| 17 |
+
<label>BorderPay Version</label>
|
| 18 |
+
<frontend_type>select</frontend_type>
|
| 19 |
+
<frontend_model>borderpay/adminhtml_version</frontend_model>
|
| 20 |
+
<sort_order>0</sort_order>
|
| 21 |
+
<show_in_default>1</show_in_default>
|
| 22 |
+
<show_in_website>1</show_in_website>
|
| 23 |
+
<show_in_store>1</show_in_store>
|
| 24 |
+
</version>
|
| 25 |
+
<active translate="label">
|
| 26 |
+
<label>Enabled</label>
|
| 27 |
+
<frontend_type>select</frontend_type>
|
| 28 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 29 |
+
<sort_order>100</sort_order>
|
| 30 |
+
<show_in_default>1</show_in_default>
|
| 31 |
+
<show_in_website>1</show_in_website>
|
| 32 |
+
<show_in_store>0</show_in_store>
|
| 33 |
+
</active>
|
| 34 |
+
<title translate="label">
|
| 35 |
+
<label>Title</label>
|
| 36 |
+
<frontend_type>text</frontend_type>
|
| 37 |
+
<sort_order>200</sort_order>
|
| 38 |
+
<show_in_default>1</show_in_default>
|
| 39 |
+
<show_in_website>1</show_in_website>
|
| 40 |
+
<show_in_store>0</show_in_store>
|
| 41 |
+
</title>
|
| 42 |
+
<sallowspecific translate="label">
|
| 43 |
+
<label>Payment from Applicable Countries</label>
|
| 44 |
+
<frontend_type>select</frontend_type>
|
| 45 |
+
<sort_order>300</sort_order>
|
| 46 |
+
<frontend_class>shipping-applicable-country</frontend_class>
|
| 47 |
+
<source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
|
| 48 |
+
<show_in_default>1</show_in_default>
|
| 49 |
+
<show_in_website>1</show_in_website>
|
| 50 |
+
<show_in_store>0</show_in_store>
|
| 51 |
+
</sallowspecific>
|
| 52 |
+
<specificcountry translate="label">
|
| 53 |
+
<label>Payment from Specific Countries</label>
|
| 54 |
+
<frontend_type>multiselect</frontend_type>
|
| 55 |
+
<sort_order>400</sort_order>
|
| 56 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
| 57 |
+
<show_in_default>1</show_in_default>
|
| 58 |
+
<show_in_website>1</show_in_website>
|
| 59 |
+
<show_in_store>0</show_in_store>
|
| 60 |
+
<can_be_empty>1</can_be_empty>
|
| 61 |
+
</specificcountry>
|
| 62 |
+
<api_key translate="label">
|
| 63 |
+
<label>API Key</label>
|
| 64 |
+
<frontend_type>text</frontend_type>
|
| 65 |
+
<sort_order>500</sort_order>
|
| 66 |
+
<show_in_default>1</show_in_default>
|
| 67 |
+
<show_in_website>1</show_in_website>
|
| 68 |
+
<show_in_store>0</show_in_store>
|
| 69 |
+
<can_be_empty>0</can_be_empty>
|
| 70 |
+
</api_key>
|
| 71 |
+
<api_secret translate="label">
|
| 72 |
+
<label>API Secret</label>
|
| 73 |
+
<frontend_type>text</frontend_type>
|
| 74 |
+
<sort_order>600</sort_order>
|
| 75 |
+
<show_in_default>1</show_in_default>
|
| 76 |
+
<show_in_website>1</show_in_website>
|
| 77 |
+
<show_in_store>0</show_in_store>
|
| 78 |
+
<can_be_empty>0</can_be_empty>
|
| 79 |
+
</api_secret>
|
| 80 |
+
<api_url translate="label">
|
| 81 |
+
<label>API URL</label>
|
| 82 |
+
<frontend_type>text</frontend_type>
|
| 83 |
+
<sort_order>700</sort_order>
|
| 84 |
+
<show_in_default>1</show_in_default>
|
| 85 |
+
<show_in_website>1</show_in_website>
|
| 86 |
+
<show_in_store>0</show_in_store>
|
| 87 |
+
<can_be_empty>0</can_be_empty>
|
| 88 |
+
</api_url>
|
| 89 |
+
<!--
|
| 90 |
+
<use_geolocation translate="label">
|
| 91 |
+
<label>Use 3rd-party Geolocation</label>
|
| 92 |
+
<frontend_type>select</frontend_type>
|
| 93 |
+
<sort_order>800</sort_order>
|
| 94 |
+
<source_model>adminhtml/system_config_source_enabledisable</source_model>
|
| 95 |
+
<show_in_default>1</show_in_default>
|
| 96 |
+
<show_in_website>1</show_in_website>
|
| 97 |
+
<show_in_store>0</show_in_store>
|
| 98 |
+
</use_geolocation>
|
| 99 |
+
-->
|
| 100 |
+
</fields>
|
| 101 |
+
</borderpay>
|
| 102 |
+
</groups>
|
| 103 |
+
</payment>
|
| 104 |
+
</sections>
|
| 105 |
+
</config>
|
app/code/local/BorderJump/BorderPay/sql/borderpay_setup/mysql4-install-0.1.0.php
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$installer = $this;
|
| 3 |
+
$installer->startSetup();
|
| 4 |
+
|
| 5 |
+
$installer->run("
|
| 6 |
+
|
| 7 |
+
DROP TABLE IF EXISTS {$this->getTable('borderpay_payments')};
|
| 8 |
+
CREATE TABLE {$this->getTable('borderpay_payments')} (
|
| 9 |
+
`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
|
| 10 |
+
`payment_id` INT( 111 ) NOT NULL ,
|
| 11 |
+
`order_number` VARCHAR( 255 ) NULL ,
|
| 12 |
+
`processed` TINYINT( 1 ) NULL ,
|
| 13 |
+
PRIMARY KEY ( `id` )
|
| 14 |
+
) ENGINE = InnoDB;
|
| 15 |
+
|
| 16 |
+
");
|
| 17 |
+
|
| 18 |
+
$installer->endSetup();
|
app/code/local/BorderJump/Xternal/Block/Html/Head.php
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mage
|
| 22 |
+
* @package Mage_Page
|
| 23 |
+
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Inchoo Xternal Html page block
|
| 30 |
+
*
|
| 31 |
+
* @category Inchoo
|
| 32 |
+
* @package Inchoo_Xternal
|
| 33 |
+
* @author Vedran Subotic, Inchoo <web@inchoo.net>
|
| 34 |
+
*/
|
| 35 |
+
class BorderJump_Xternal_Block_Html_Head extends Mage_Page_Block_Html_Head
|
| 36 |
+
{
|
| 37 |
+
/**
|
| 38 |
+
* Initialize template
|
| 39 |
+
*
|
| 40 |
+
*/
|
| 41 |
+
protected function _construct()
|
| 42 |
+
{
|
| 43 |
+
$this->setTemplate('page/html/head.phtml');
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* Add HEAD External Item
|
| 49 |
+
*
|
| 50 |
+
* Allowed types:
|
| 51 |
+
* - js
|
| 52 |
+
* - js_css
|
| 53 |
+
* - skin_js
|
| 54 |
+
* - skin_css
|
| 55 |
+
* - rss
|
| 56 |
+
*
|
| 57 |
+
* @param string $type
|
| 58 |
+
* @param string $name
|
| 59 |
+
* @param string $params
|
| 60 |
+
* @param string $if
|
| 61 |
+
* @param string $cond
|
| 62 |
+
* @return Mage_Page_Block_Html_Head
|
| 63 |
+
*/
|
| 64 |
+
public function addExternalItem($type, $name, $params=null, $if=null, $cond=null)
|
| 65 |
+
{
|
| 66 |
+
parent::addItem($type, $name, $params=null, $if=null, $cond=null);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
/**
|
| 70 |
+
* Remove External Item from HEAD entity
|
| 71 |
+
*
|
| 72 |
+
* @param string $type
|
| 73 |
+
* @param string $name
|
| 74 |
+
* @return Mage_Page_Block_Html_Head
|
| 75 |
+
*/
|
| 76 |
+
public function removeExternalItem($type, $name)
|
| 77 |
+
{
|
| 78 |
+
parent::removeItem($type, $name);
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
/**
|
| 82 |
+
* Classify HTML head item and queue it into "lines" array
|
| 83 |
+
*
|
| 84 |
+
* @see self::getCssJsHtml()
|
| 85 |
+
* @param array &$lines
|
| 86 |
+
* @param string $itemIf
|
| 87 |
+
* @param string $itemType
|
| 88 |
+
* @param string $itemParams
|
| 89 |
+
* @param string $itemName
|
| 90 |
+
* @param array $itemThe
|
| 91 |
+
*/
|
| 92 |
+
protected function _separateOtherHtmlHeadElements(&$lines, $itemIf, $itemType, $itemParams, $itemName, $itemThe)
|
| 93 |
+
{
|
| 94 |
+
$params = $itemParams ? ' ' . $itemParams : '';
|
| 95 |
+
$href = $itemName;
|
| 96 |
+
switch ($itemType) {
|
| 97 |
+
case 'rss':
|
| 98 |
+
$lines[$itemIf]['other'][] = sprintf('<link href="%s"%s rel="alternate" type="application/rss+xml" />',
|
| 99 |
+
$href, $params
|
| 100 |
+
);
|
| 101 |
+
break;
|
| 102 |
+
case 'link_rel':
|
| 103 |
+
$lines[$itemIf]['other'][] = sprintf('<link%s href="%s" />', $params, $href);
|
| 104 |
+
break;
|
| 105 |
+
|
| 106 |
+
case 'external_js':
|
| 107 |
+
$lines[$itemIf]['other'][] = sprintf('<script type="text/javascript" src="%s" %s></script>', $href, $params);
|
| 108 |
+
break;
|
| 109 |
+
|
| 110 |
+
case 'external_css':
|
| 111 |
+
$lines[$itemIf]['other'][] = sprintf('<link rel="stylesheet" type="text/css" href="%s" %s/>', $href, $params);
|
| 112 |
+
break;
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
}
|
app/code/local/BorderJump/Xternal/etc/config.xml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<BorderJump_Xternal>
|
| 5 |
+
<version>1.0.0</version>
|
| 6 |
+
</BorderJump_Xternal>
|
| 7 |
+
</modules>
|
| 8 |
+
<global>
|
| 9 |
+
|
| 10 |
+
<blocks>
|
| 11 |
+
<borderjump_externals>
|
| 12 |
+
<class>BorderJump_Xternal_Block</class>
|
| 13 |
+
</borderjump_externals>
|
| 14 |
+
<page>
|
| 15 |
+
<rewrite>
|
| 16 |
+
<html_head>BorderJump_Xternal_Block_Html_Head</html_head>
|
| 17 |
+
</rewrite>
|
| 18 |
+
</page>
|
| 19 |
+
</blocks>
|
| 20 |
+
|
| 21 |
+
</global>
|
| 22 |
+
<frontend>
|
| 23 |
+
<layout>
|
| 24 |
+
<updates>
|
| 25 |
+
<inchoo_xternal module="Inchoo_Xternal">
|
| 26 |
+
<file>borderjump_xternal.xml</file>
|
| 27 |
+
</inchoo_xternal>
|
| 28 |
+
</updates>
|
| 29 |
+
</layout>
|
| 30 |
+
</frontend>
|
| 31 |
+
|
| 32 |
+
</config>
|
app/design/frontend/base/default/layout/borderpay.xml
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
|
| 3 |
+
<layout version="0.1.0">
|
| 4 |
+
<default>
|
| 5 |
+
<reference name="head">
|
| 6 |
+
<action method="addItem"><type>skin_js</type><script>js/snare_settings.js</script></action>
|
| 7 |
+
<action method="addItem"><type>external_js</type><name>https://mpsnare.iesnare.com/snare.js</name></action>
|
| 8 |
+
</reference>
|
| 9 |
+
</default>
|
| 10 |
+
<checkout_onepage_index>
|
| 11 |
+
<reference name="head">
|
| 12 |
+
<action method="addItem"><type>skin_js</type><script>js/jquery-1.7.1.min.noConflict.js</script></action>
|
| 13 |
+
</reference>
|
| 14 |
+
<reference name="content">
|
| 15 |
+
<block output="toHtml" type="core/template" before="-" template="borderpay/checkout/onepage/extension.phtml" name="borderpay.checkout.onepage.extension" />
|
| 16 |
+
</reference>
|
| 17 |
+
</checkout_onepage_index>
|
| 18 |
+
|
| 19 |
+
<firecheckout_index_index>
|
| 20 |
+
<reference name="content">
|
| 21 |
+
<block output="toHtml" type="core/template" before="-" template="borderpay/checkout/onepage/extension.phtml" name="borderpay.checkout.onepage.extension.firecheckout" />
|
| 22 |
+
<block output="toHtml" type="core/template" after="borderpay.checkout.onepage.extension.firecheckout" template="borderpay/checkout/firecheckout/extension.phtml" name="borderpay.checkout.firecheckout.extension" />
|
| 23 |
+
</reference>
|
| 24 |
+
</firecheckout_index_index>
|
| 25 |
+
|
| 26 |
+
<checkout_onepage_review>
|
| 27 |
+
<reference name="root">
|
| 28 |
+
<block type="borderpay/cart_totals" name="checkout.onepage.review.info.totals" as="totals" template="borderpay/checkout/onepage/review/totals.phtml"></block>s
|
| 29 |
+
</reference>
|
| 30 |
+
</checkout_onepage_review>
|
| 31 |
+
|
| 32 |
+
<checkout_multishipping_index>
|
| 33 |
+
<reference name="head">
|
| 34 |
+
<action method="addItem"><type>skin_js</type><script>js/jquery-1.7.1.min.noConflict.js</script></action>
|
| 35 |
+
</reference>
|
| 36 |
+
</checkout_multishipping_index>
|
| 37 |
+
</layout>
|
app/design/frontend/base/default/template/borderpay/checkout/firecheckout/extension.phtml
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script>
|
| 2 |
+
|
| 3 |
+
/*
|
| 4 |
+
* This script is useless without the base borderpay checkout page extension!
|
| 5 |
+
* If you see a variable used here that isn't defined anywhere check there
|
| 6 |
+
* [template dir, probably in base/default]/borderpay/checkout/onepage/extension.phtml
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
function validate() {
|
| 10 |
+
isValid = true;
|
| 11 |
+
if (!checkout.validator.validate()) {
|
| 12 |
+
isValid = false;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
for (i in checkout.sectionsToValidate) {
|
| 16 |
+
if (typeof checkout.sectionsToValidate[i] === 'function') {
|
| 17 |
+
continue;
|
| 18 |
+
}
|
| 19 |
+
if (!checkout.sectionsToValidate[i].validate()) {
|
| 20 |
+
isValid = false;
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
FireCheckout.Messenger.clear('checkout-review-submit');
|
| 24 |
+
$$('#checkout-review-submit .checkout-agreements input[type="checkbox"]').each(function(el) {
|
| 25 |
+
if (!el.checked) {
|
| 26 |
+
FireCheckout.Messenger.add(checkout.acceptAgreementText, 'agreements-wrapper', 'error');
|
| 27 |
+
isValid = false;
|
| 28 |
+
return isValid;
|
| 29 |
+
}
|
| 30 |
+
}.bind(checkout));
|
| 31 |
+
|
| 32 |
+
if (!isValid) {
|
| 33 |
+
// scroll to error
|
| 34 |
+
var validationMessages = $$('.validation-advice, .messages').findAll(function(el) {
|
| 35 |
+
return false
|
| 36 |
+
});
|
| 37 |
+
if (!validationMessages.length) {
|
| 38 |
+
return false;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
var viewportSize = document.viewport.getDimensions();
|
| 42 |
+
var hiddenMessages = [];
|
| 43 |
+
var needToScroll = true;
|
| 44 |
+
|
| 45 |
+
validationMessages.each(function(el) {
|
| 46 |
+
var offset = el.viewportOffset();
|
| 47 |
+
if (offset.top < 0
|
| 48 |
+
|| offset.top > viewportSize.height
|
| 49 |
+
|| offset.left < 0
|
| 50 |
+
|| offset.left > viewportSize.width) {
|
| 51 |
+
|
| 52 |
+
hiddenMessages.push(el);
|
| 53 |
+
} else {
|
| 54 |
+
needToScroll = false;
|
| 55 |
+
}
|
| 56 |
+
});
|
| 57 |
+
|
| 58 |
+
if (needToScroll) {
|
| 59 |
+
Effect.ScrollTo(validationMessages[0], {
|
| 60 |
+
duration: 1,
|
| 61 |
+
offset: -20
|
| 62 |
+
});
|
| 63 |
+
}
|
| 64 |
+
return isValid;
|
| 65 |
+
} else {
|
| 66 |
+
return true;
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
jQuery(document).ready(function($) {
|
| 71 |
+
$orderButton = $('button[title="Place Order"]');
|
| 72 |
+
|
| 73 |
+
// Reroute the submit order button to use our own handler when BorderPay is selected
|
| 74 |
+
$form.find('input[name="payment[method]"]').live('change', function(e) {
|
| 75 |
+
if ($form.find('input[name="payment[method]"]:checked').val() == 'borderpay') {
|
| 76 |
+
$orderButton.unbind('click');
|
| 77 |
+
$orderButton.attr('onclick', null);
|
| 78 |
+
$orderButton.click(firecheckoutDispatch);
|
| 79 |
+
} else {
|
| 80 |
+
$orderButton.unbind('click');
|
| 81 |
+
$orderButton.attr('onclick', 'checkout.save()');
|
| 82 |
+
}
|
| 83 |
+
});
|
| 84 |
+
$form.find('input[name="payment[method]"]').trigger('change');
|
| 85 |
+
|
| 86 |
+
function firecheckoutDispatch() {
|
| 87 |
+
checkout.setLoadWaiting(true);
|
| 88 |
+
if (! validate()) {
|
| 89 |
+
return;
|
| 90 |
+
}
|
| 91 |
+
$('#fingerprint').val($('#ioBlackBox').val());
|
| 92 |
+
var formData = $form.serialize();
|
| 93 |
+
$.ajax({
|
| 94 |
+
type: 'POST',
|
| 95 |
+
url: '<?php echo Mage::getUrl("checkout/onepage/saveAdditionalData"); ?>',
|
| 96 |
+
dataType: 'json',
|
| 97 |
+
data: formData,
|
| 98 |
+
success: function(){
|
| 99 |
+
var paymentService = $('#borderpay_service').val();
|
| 100 |
+
if ( ! paymentService) {
|
| 101 |
+
checkout.setLoadWaiting(false);
|
| 102 |
+
return;
|
| 103 |
+
} else {
|
| 104 |
+
saveOther();
|
| 105 |
+
}
|
| 106 |
+
},
|
| 107 |
+
error: function(){ alert('Internal error.'); }
|
| 108 |
+
});
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
})
|
| 112 |
+
</script>
|
app/design/frontend/base/default/template/borderpay/checkout/onepage/error.phtml
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<p>Your payment could not be authorized. Please click
|
| 2 |
+
<a href="<?php echo Mage::getUrl('checkout/onepage') . '?step=payment'; ?>">here</a>
|
| 3 |
+
to return to checkout or <a href="<?php echo Mage::getUrl('contacts'); ?>">contact us</a>
|
| 4 |
+
if you feel you've received this message in error.</p>
|
app/design/frontend/base/default/template/borderpay/checkout/onepage/extension.phtml
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$post = Mage::app()->getRequest()->getPost();
|
| 3 |
+
$session = Mage::getSingleton('checkout/session');
|
| 4 |
+
|
| 5 |
+
$session->setBorderpayTransactionId();
|
| 6 |
+
$session->setBorderpayTransactionType();
|
| 7 |
+
|
| 8 |
+
$op_block = $this->getLayout()->getBlock('checkout.onepage');
|
| 9 |
+
|
| 10 |
+
$step = Mage::app()->getRequest()->getParam('step');
|
| 11 |
+
$stepCodes = array('billing', 'shipping', 'shipping_method', 'payment', 'review');
|
| 12 |
+
if (($step) && (in_array($step,$stepCodes)) && ($op_block->getActiveStep() == 'billing' || $op_block->getActiveStep() == 'login')) {
|
| 13 |
+
$checkout = Mage::getSingleton('checkout/type_onepage');
|
| 14 |
+
if ($step == 'review') {
|
| 15 |
+
$step = 'payment';
|
| 16 |
+
}
|
| 17 |
+
$billing = $session->getBorderpayBillingAddress();
|
| 18 |
+
$shipping = $session->getBorderpayShippingAddress();
|
| 19 |
+
$checkout->saveBilling($billing,false);
|
| 20 |
+
$checkout->saveShipping($shipping,false);
|
| 21 |
+
|
| 22 |
+
// The above doesn't save the street properly, so we manually do so here
|
| 23 |
+
$checkout->getQuote()->getBillingAddress()->setStreetFull($billing['street']);
|
| 24 |
+
$checkout->getQuote()->getShippingAddress()->setStreetFull($shipping['street']);
|
| 25 |
+
|
| 26 |
+
$checkout->saveShippingMethod($session->getQuote()->getShippingAddress()->getShippingMethod());
|
| 27 |
+
$activestep = $step;
|
| 28 |
+
} else if ($this->getActiveStep()) {
|
| 29 |
+
$activestep = $this->getActiveStep();
|
| 30 |
+
}
|
| 31 |
+
?>
|
| 32 |
+
|
| 33 |
+
<?php if (isset($activestep)): ?>
|
| 34 |
+
<script>
|
| 35 |
+
jQuery(document).ready(function($) {
|
| 36 |
+
checkout.accordion.openSection('opc-<?php echo $activestep; ?>');
|
| 37 |
+
})
|
| 38 |
+
</script>
|
| 39 |
+
<?php endif; ?>
|
| 40 |
+
|
| 41 |
+
<script>
|
| 42 |
+
var hasBorderpayRun = false;
|
| 43 |
+
var $form = jQuery('form#co-payment-form,form#firecheckout-form')
|
| 44 |
+
|
| 45 |
+
var saveOther = function() {
|
| 46 |
+
var formData = $form.serialize();
|
| 47 |
+
jQuery.ajax({
|
| 48 |
+
type: 'POST',
|
| 49 |
+
url: '<?php echo Mage::getUrl("checkout/onepage/submitPayment"); ?>',
|
| 50 |
+
dataType: 'json',
|
| 51 |
+
data: formData,
|
| 52 |
+
success: otherResponseValidate,
|
| 53 |
+
error: function(){ alert('Internal error.'); }
|
| 54 |
+
});
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
var otherResponseValidate = function(data, status){
|
| 58 |
+
if (data.error || status == 'error' || (typeof data.approval_code != 'undefined' && data.approval_code == null)) {
|
| 59 |
+
alert('There was an error validating your payment information. Please contact customer service.');
|
| 60 |
+
} else if (status == 'success') {
|
| 61 |
+
otherPaymentSubmit(data, status);
|
| 62 |
+
} else {
|
| 63 |
+
alert('There was an error validating your payment information. Please contact customer service.');
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
var otherPaymentSubmit = function(data, status) {
|
| 68 |
+
$payment_form = $form;
|
| 69 |
+
returnUrl = '<?php echo Mage::getUrl("checkout/onepage/authorizePayment"); ?>';
|
| 70 |
+
|
| 71 |
+
$payment_form.attr('action', data.ACSUrl);
|
| 72 |
+
$payment_form.attr('method', 'post');
|
| 73 |
+
jQuery('#ACSUrl').val(data.ACSUrl);
|
| 74 |
+
jQuery('#PaReq').val(data.payload);
|
| 75 |
+
jQuery('#MD').val(data.transaction_id);
|
| 76 |
+
jQuery('#TermUrl').val(returnUrl);
|
| 77 |
+
jQuery('#third-party-submit').unbind('click');
|
| 78 |
+
jQuery('#third-party-submit').unbind('submit');
|
| 79 |
+
$payment_form.submit();
|
| 80 |
+
this.setLoadWaiting(false);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
jQuery(document).ready(function($) {
|
| 84 |
+
if (hasBorderpayRun) {
|
| 85 |
+
return;
|
| 86 |
+
}
|
| 87 |
+
hasBorderpayRun = true;
|
| 88 |
+
var paypalDirect = '2';
|
| 89 |
+
var safetypay = '5';
|
| 90 |
+
var planetPayment = '6';
|
| 91 |
+
var $savePaymentButton = $('.button[onclick="payment.save()"]');
|
| 92 |
+
|
| 93 |
+
$form.prepend('<input id="ioBlackBox" type="hidden" name="ioBlackBox"/>');
|
| 94 |
+
|
| 95 |
+
// Check for the BorderPay service change and update the form
|
| 96 |
+
var $ccFormElements = $('ul#payment_cc_form').html();
|
| 97 |
+
$('#borderpay_service').live('change', function(e){
|
| 98 |
+
$payment_form = $('ul#payment_cc_form');
|
| 99 |
+
|
| 100 |
+
var service = $(this).val();
|
| 101 |
+
if (service == planetPayment) {
|
| 102 |
+
$('p#borderpay-external').hide();
|
| 103 |
+
$payment_form.html($ccFormElements);
|
| 104 |
+
$('input, select', $payment_form).attr('disabled', false);
|
| 105 |
+
$payment_form.show();
|
| 106 |
+
$('input#transaction_type').val('CC');
|
| 107 |
+
} else if (service == paypalDirect) {
|
| 108 |
+
$('p#borderpay-external').show();
|
| 109 |
+
$payment_form.hide();
|
| 110 |
+
$payment_form.empty();
|
| 111 |
+
$('input#transaction_type').val('PP');
|
| 112 |
+
} else if (service == safetypay) {
|
| 113 |
+
$('p#borderpay-external').show();
|
| 114 |
+
$payment_form.hide();
|
| 115 |
+
$payment_form.empty();
|
| 116 |
+
$('input#transaction_type').val('SP');
|
| 117 |
+
} else {
|
| 118 |
+
$('p#borderpay-external').hide();
|
| 119 |
+
$payment_form.hide();
|
| 120 |
+
$payment_form.empty();
|
| 121 |
+
$('input#transaction_type').val('');
|
| 122 |
+
}
|
| 123 |
+
});
|
| 124 |
+
|
| 125 |
+
// Reroute the submit payment method to use our own handler when BorderPay is selected
|
| 126 |
+
$form.find('input[name="payment[method]"]').live('change', function(e) {
|
| 127 |
+
if ($form.find('input[name="payment[method]"]:checked').val() == 'borderpay') {
|
| 128 |
+
$savePaymentButton.unbind('click');
|
| 129 |
+
$savePaymentButton.attr('onclick', null);
|
| 130 |
+
$savePaymentButton.click(dispatchPayment);
|
| 131 |
+
} else {
|
| 132 |
+
$savePaymentButton.unbind('click');
|
| 133 |
+
$savePaymentButton.attr('onclick', 'payment.save()');
|
| 134 |
+
}
|
| 135 |
+
});
|
| 136 |
+
$form.find('input[name="payment[method]"]').trigger('change');
|
| 137 |
+
|
| 138 |
+
function dispatchPayment() {
|
| 139 |
+
$('#fingerprint').val($('#ioBlackBox').val());
|
| 140 |
+
checkout.setLoadWaiting('payment');
|
| 141 |
+
var formData = $form.serialize();
|
| 142 |
+
$.ajax({
|
| 143 |
+
type: 'POST',
|
| 144 |
+
url: '<?php echo Mage::getUrl("checkout/onepage/saveAdditionalData"); ?>',
|
| 145 |
+
dataType: 'json',
|
| 146 |
+
data: formData,
|
| 147 |
+
success: function(){
|
| 148 |
+
var paymentService = $('#borderpay_service').val();
|
| 149 |
+
if ( ! paymentService) {
|
| 150 |
+
setLoadWaiting(false);
|
| 151 |
+
return;
|
| 152 |
+
} else if (paymentService == 6) {
|
| 153 |
+
saveCc();
|
| 154 |
+
} else {
|
| 155 |
+
saveOther();
|
| 156 |
+
}
|
| 157 |
+
},
|
| 158 |
+
error: function(){ alert('Internal error.'); }
|
| 159 |
+
});
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
function saveCc() {
|
| 163 |
+
var request = new Ajax.Request(
|
| 164 |
+
payment.saveUrl,
|
| 165 |
+
{
|
| 166 |
+
method: 'post',
|
| 167 |
+
onComplete: payment.onComplete,
|
| 168 |
+
onSuccess: payment.onSave,
|
| 169 |
+
onFailure: checkout.ajaxFailure.bind(checkout),
|
| 170 |
+
parameters: Form.serialize(payment.form)
|
| 171 |
+
}
|
| 172 |
+
);
|
| 173 |
+
return;
|
| 174 |
+
}
|
| 175 |
+
});
|
| 176 |
+
</script>
|
app/design/frontend/base/default/template/borderpay/checkout/onepage/review/totals.phtml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php if ($this->getTotals()): ?>
|
| 2 |
+
<tfoot>
|
| 3 |
+
<?php $_colspan = $this->helper('tax')->displayCartBothPrices() ? 5 : 3; ?>
|
| 4 |
+
<?php echo $this->renderTotals(null, $_colspan); ?>
|
| 5 |
+
<?php echo $this->renderTotals('footer', $_colspan); ?>
|
| 6 |
+
<?php if ($this->needDisplayBaseGrandtotal()):?>
|
| 7 |
+
<tr>
|
| 8 |
+
<td class="a-right" colspan="<?php echo $_colspan; ?>">
|
| 9 |
+
<small><?php echo $this->helper('sales')->__('Your credit card will be charged for') ?></small>
|
| 10 |
+
</td>
|
| 11 |
+
<td class="a-right">
|
| 12 |
+
<small><?php echo $this->displayGrandtotal() ?></small>
|
| 13 |
+
</td>
|
| 14 |
+
</tr>
|
| 15 |
+
<?php endif?>
|
| 16 |
+
</tfoot>
|
| 17 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/borderpay/payment/form/dynamic.phtml
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* @category design
|
| 4 |
+
* @package borderpay
|
| 5 |
+
*/
|
| 6 |
+
?>
|
| 7 |
+
<?php $_code=$this->getMethodCode() ?>
|
| 8 |
+
|
| 9 |
+
<ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
|
| 10 |
+
<li>
|
| 11 |
+
<input type="hidden" name="payment[transaction_type]" id="transaction_type"></input>
|
| 12 |
+
<div class="input-box">
|
| 13 |
+
<label for="<?php echo $_code ?>_service" class="required"><em>*</em>
|
| 14 |
+
<select id="<?php echo $_code ?>_service" name="payment[service]" title="<?php echo $this->__('Payment Service') ?>" class="required-entry">
|
| 15 |
+
<option value=""><?php echo $this->__('-- Select Payment Type --') ?></option>
|
| 16 |
+
<?php $response = $this->getPaymentMethods(); ?>
|
| 17 |
+
<?php if ($response): ?>
|
| 18 |
+
<?php foreach ($response as $k => $service): ?>
|
| 19 |
+
<option value="<?php echo $service; ?>"><?php echo $k; ?></option>
|
| 20 |
+
<?php endforeach; ?>
|
| 21 |
+
<?php endif; ?>
|
| 22 |
+
</select>
|
| 23 |
+
</div>
|
| 24 |
+
</li>
|
| 25 |
+
<li id="third-party-message">
|
| 26 |
+
<input id="ACSUrl" type="hidden" name="ACSUrl"/>
|
| 27 |
+
<input id="MD" type="hidden" name="MD"/>
|
| 28 |
+
<input id="PaReq" type="hidden" name="PaReq"/>
|
| 29 |
+
<input id="TermUrl" type="hidden" name="TermUrl"/>
|
| 30 |
+
<input id="fingerprint" type="hidden" name="fingerprint"/>
|
| 31 |
+
<p id="borderpay-external" style="display:none;">You will be taken to an external page to complete your payment.</p>
|
| 32 |
+
</li>
|
| 33 |
+
<li>
|
| 34 |
+
<ul id="payment_cc_form" style="display:none;">
|
| 35 |
+
<li>
|
| 36 |
+
<?php Mage::getSingleton('core/session', array('name' => 'frontend')); ?>
|
| 37 |
+
<?php $billing = Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress(); ?>
|
| 38 |
+
<label for="<?php echo $_code ?>_cc_name" class="required"><em>*</em><?php echo $this->__('Name on Card') ?></label>
|
| 39 |
+
<div class="input-box">
|
| 40 |
+
<input type="text" id="<?php echo $_code ?>_cc_name" name="payment[cc_name]" title="<?php echo $this->__('Name on Card') ?>" class="input-text" value="<?php echo $billing->getName(); ?>" />
|
| 41 |
+
</div>
|
| 42 |
+
</li>
|
| 43 |
+
<li>
|
| 44 |
+
<label for="<?php echo $_code ?>_cc_type" class="required"><em>*</em><?php echo $this->__('Credit Card Type') ?></label>
|
| 45 |
+
<div class="input-box">
|
| 46 |
+
<select id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" class="required-entry validate-cc-type-select">
|
| 47 |
+
<option value=""><?php echo $this->__('--Please Select--')?></option>
|
| 48 |
+
<?php $_ccType = $this->getInfoData('cc_type') ?>
|
| 49 |
+
<?php foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
|
| 50 |
+
<option value="<?php echo $_typeCode ?>"<?php if($_typeCode==$_ccType): ?> selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
|
| 51 |
+
<?php endforeach ?>
|
| 52 |
+
</select>
|
| 53 |
+
</div>
|
| 54 |
+
</li>
|
| 55 |
+
<li>
|
| 56 |
+
<label for="<?php echo $_code ?>_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
|
| 57 |
+
<div class="input-box">
|
| 58 |
+
<input type="text" id="<?php echo $_code ?>_cc_number" name="payment[cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type" value="" />
|
| 59 |
+
</div>
|
| 60 |
+
</li>
|
| 61 |
+
<li id="<?php echo $_code ?>_cc_type_exp_div">
|
| 62 |
+
<label for="<?php echo $_code ?>_expiration" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
|
| 63 |
+
<div class="input-box">
|
| 64 |
+
<div class="v-fix">
|
| 65 |
+
<select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" class="month validate-cc-exp required-entry">
|
| 66 |
+
<?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
|
| 67 |
+
<?php foreach ($this->getCcMonths() as $k=>$v): ?>
|
| 68 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
| 69 |
+
<?php endforeach ?>
|
| 70 |
+
</select>
|
| 71 |
+
</div>
|
| 72 |
+
<div class="v-fix">
|
| 73 |
+
<?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
|
| 74 |
+
<select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" class="year required-entry">
|
| 75 |
+
<?php foreach ($this->getCcYears() as $k=>$v): ?>
|
| 76 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
| 77 |
+
<?php endforeach ?>
|
| 78 |
+
</select>
|
| 79 |
+
</div>
|
| 80 |
+
</div>
|
| 81 |
+
</li>
|
| 82 |
+
<?php echo $this->getChildHtml() ?>
|
| 83 |
+
<?php if($this->hasVerification()): ?>
|
| 84 |
+
<li id="<?php echo $_code ?>_cc_type_cvv_div">
|
| 85 |
+
<label for="<?php echo $_code ?>_cc_cid" class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
|
| 86 |
+
<div class="input-box">
|
| 87 |
+
<div class="v-fix">
|
| 88 |
+
<input type="text" title="<?php echo $this->__('Card Verification Number') ?>" class="input-text cvv required-entry validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" name="payment[cc_cid]" value="" />
|
| 89 |
+
</div>
|
| 90 |
+
<a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
|
| 91 |
+
</div>
|
| 92 |
+
</li>
|
| 93 |
+
<?php endif; ?>
|
| 94 |
+
|
| 95 |
+
<?php if ($this->hasSsCardType()): ?>
|
| 96 |
+
<li id="<?php echo $_code ?>_cc_type_ss_div">
|
| 97 |
+
<ul class="inner-form">
|
| 98 |
+
<li class="form-alt"><label for="<?php echo $_code ?>_cc_issue" class="required"><em>*</em><?php echo $this->__('Switch/Solo/Maestro Only') ?></label></li>
|
| 99 |
+
<li>
|
| 100 |
+
<label for="<?php echo $_code ?>_cc_issue"><?php echo $this->__('Issue Number') ?>:</label>
|
| 101 |
+
<span class="input-box">
|
| 102 |
+
<input type="text" title="<?php echo $this->__('Issue Number') ?>" class="input-text validate-cc-ukss cvv" id="<?php echo $_code ?>_cc_issue" name="payment[cc_ss_issue]" value="" />
|
| 103 |
+
</span>
|
| 104 |
+
</li>
|
| 105 |
+
<li>
|
| 106 |
+
<label for="<?php echo $_code ?>_start_month"><?php echo $this->__('Start Date') ?>:</label>
|
| 107 |
+
<div class="input-box">
|
| 108 |
+
<div class="v-fix">
|
| 109 |
+
<select id="<?php echo $_code ?>_start_month" name="payment[cc_ss_start_month]" class="validate-cc-ukss month">
|
| 110 |
+
<?php foreach ($this->getCcMonths() as $k=>$v): ?>
|
| 111 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$this->getInfoData('cc_ss_start_month')): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
| 112 |
+
<?php endforeach ?>
|
| 113 |
+
</select>
|
| 114 |
+
</div>
|
| 115 |
+
<div class="v-fix">
|
| 116 |
+
<select id="<?php echo $_code ?>_start_year" name="payment[cc_ss_start_year]" class="validate-cc-ukss year">
|
| 117 |
+
<?php foreach ($this->getSsStartYears() as $k=>$v): ?>
|
| 118 |
+
<option value="<?php echo $k?$k:'' ?>"<?php if($k==$this->getInfoData('cc_ss_start_year')): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
|
| 119 |
+
<?php endforeach ?>
|
| 120 |
+
</select>
|
| 121 |
+
</div>
|
| 122 |
+
</div>
|
| 123 |
+
</li>
|
| 124 |
+
<li class="adv-container"> </li>
|
| 125 |
+
</ul>
|
| 126 |
+
<script type="text/javascript">
|
| 127 |
+
//<![CDATA[
|
| 128 |
+
var SSChecked<?php echo $_code ?> = function() {
|
| 129 |
+
var elm = $('<?php echo $_code ?>_cc_type');
|
| 130 |
+
if (['SS','SM','SO'].indexOf(elm.value) != -1) {
|
| 131 |
+
$('<?php echo $_code ?>_cc_type_ss_div').show();
|
| 132 |
+
} else {
|
| 133 |
+
$('<?php echo $_code ?>_cc_type_ss_div').hide();
|
| 134 |
+
}
|
| 135 |
+
};
|
| 136 |
+
|
| 137 |
+
Event.observe($('<?php echo $_code ?>_cc_type'), 'change', SSChecked<?php echo $_code ?>);
|
| 138 |
+
SSChecked<?php echo $_code ?>();
|
| 139 |
+
//]]>
|
| 140 |
+
</script>
|
| 141 |
+
</li>
|
| 142 |
+
<?php endif; ?>
|
| 143 |
+
</ul>
|
| 144 |
+
</li>
|
| 145 |
+
</ul>
|
app/etc/modules/BorderJump_BorderPay.xml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<config>
|
| 2 |
+
<modules>
|
| 3 |
+
<!-- declare BorderJump_BorderPay module -->
|
| 4 |
+
<BorderJump_BorderPay>
|
| 5 |
+
<!-- this is an active module -->
|
| 6 |
+
<active>true</active>
|
| 7 |
+
<!-- this module will be located in app/code/local code pool -->
|
| 8 |
+
<codePool>local</codePool>
|
| 9 |
+
<!-- specify dependencies for correct module loading order -->
|
| 10 |
+
<depends>
|
| 11 |
+
<Mage_Payment />
|
| 12 |
+
<Mage_Checkout />
|
| 13 |
+
</depends>
|
| 14 |
+
</BorderJump_BorderPay>
|
| 15 |
+
</modules>
|
| 16 |
+
<global>
|
| 17 |
+
<currency>
|
| 18 |
+
<import>
|
| 19 |
+
<services>
|
| 20 |
+
<borderpay>
|
| 21 |
+
<name>BorderPay</name>
|
| 22 |
+
<model>BorderJump_BorderPay_Model_Currency_Import_BorderPay</model>
|
| 23 |
+
</borderpay>
|
| 24 |
+
</services>
|
| 25 |
+
</import>
|
| 26 |
+
</currency>
|
| 27 |
+
</global>
|
| 28 |
+
</config>
|
app/etc/modules/BorderJump_Xternal.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<BorderJump_Xternal>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>local</codePool>
|
| 7 |
+
</BorderJump_Xternal>
|
| 8 |
+
</modules>
|
| 9 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>BorderPay</name>
|
| 4 |
+
<version>1.0.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License version 3.0</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>BorderPay provides international payment processing from BorderJump with localized payment options in a variety of currencies.</summary>
|
| 10 |
+
<description>BorderPay provides international payment processing from BorderJump with localized payment options in a variety of currencies. You must request and install API keys from borderjump.com and properly install and configure the companion BorderShip extension in order to process payments.</description>
|
| 11 |
+
<notes>Initial release.</notes>
|
| 12 |
+
<authors><author><name>BorderJump</name><user>MAG000280056</user><email>clientsupport@borderjump.com</email></author></authors>
|
| 13 |
+
<date>2012-09-21</date>
|
| 14 |
+
<time>00:20:35</time>
|
| 15 |
+
<contents><target name="magelocal"><dir name="BorderJump"><dir name="BorderPay"><dir name="Block"><dir name="Adminhtml"><file name="Version.php" hash="28d43c0a98ef36c4eddf4bae1d9480a5"/></dir><dir name="Cart"><file name="Totals.php" hash="e03961670419b9e8bc996ef1f2b89369"/></dir><dir name="Form"><file name="Dynamic.php" hash="956bb32e742a9c1feba70b556aa4fb9c"/></dir><dir name="Info"><file name="Dynamic.php" hash="593fe4016b56e1abaadb478f7207400b"/></dir></dir><dir name="Helper"><file name="Data.php" hash="508114dd7f9ba40756a3d701087c8b61"/><file name="Response.php" hash="8afc4b3aab52a2866ff45f551076535f"/></dir><dir name="Model"><dir name="Currency"><dir name="Import"><file name="BorderPay.php" hash="87b5f05580d7bce4d1cfab187de9ac7f"/></dir></dir><dir name="Method"><file name="Borderpay.php" hash="6ed58d7a81305538cfe2c7d7b3f10a03"/></dir><dir name="Mysql4"><file name="Payment.php" hash="cd3ef01f08817a322fdd519ac738e21c"/></dir><file name="Observer.php" hash="b4bfaffed53d80a1a26bca0dcbfc9d6d"/><dir name="Order"><dir name="Pdf"><file name="Invoice.php" hash="6ab4c4e56415be195d802bda3f9dfe57"/><dir name="Items"><dir name="Invoice"><file name="Default.php" hash="43722c79dba18a9c39077b45df6cd652"/></dir></dir></dir></dir><file name="Payment.php" hash="f52d0742589620dbb550b6c1014d73ed"/></dir><dir name="controllers"><file name="OnepageController.php" hash="3c1b6b3e77503c9bd6740cce10b81db1"/></dir><dir name="etc"><file name="config.xml" hash="794d07cec0f2f2de5288e73eefd16815"/><file name="system.xml" hash="d38a35aa93a13fcb6b34b6887c3de3fc"/></dir><dir name="sql"><dir name="borderpay_setup"><file name="mysql4-install-0.1.0.php" hash="f878d835bc744c98fb0300f9553cd74e"/></dir></dir></dir><dir name="Xternal"><dir name="Block"><dir name="Html"><file name="Head.php" hash="db4837c71a113e22c4e3d12715e3d04e"/></dir></dir><dir name="etc"><file name="config.xml" hash="f972da298b7bb19a77f89bf7362a9acc"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="borderpay.xml" hash="f4b5d5aa75cf4015d29219ccf035d96c"/></dir><dir name="template"><dir name="borderpay"><dir name="checkout"><dir name="firecheckout"><file name="extension.phtml" hash="602376bdc957b58c9e226a7ea9ac34fa"/></dir><dir name="onepage"><file name="error.phtml" hash="5d2daca7cf2add14797692dfd21bf34a"/><file name="extension.phtml" hash="4e79760428eecbe63dfcdc874cde3341"/><dir name="review"><file name="totals.phtml" hash="91c2ba8ffcb15778bec90716e270c039"/></dir></dir></dir><dir name="payment"><dir name="form"><file name="dynamic.phtml" hash="8b55499276d6764d2f3e14f2982185f0"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="BorderJump_BorderPay.xml" hash="9da4026338967451ab9a9bfd67d7e90c"/><file name="BorderJump_Xternal.xml" hash="f6af1e6e7c14b13b0a05f09569b5db1b"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="js"><file name="snare_settings.js" hash="60a9c121a2d2132e681768c808b09872"/></dir></dir></dir></dir></target></contents>
|
| 16 |
+
<compatible/>
|
| 17 |
+
<dependencies><required><php><min>5.2.0</min><max>5.3.10</max></php></required></dependencies>
|
| 18 |
+
</package>
|
skin/frontend/default/default/js/snare_settings.js
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* General
|
| 2 |
+
***********************************************************************
|
| 3 |
+
* iovation’s JavaScript is configured through a set of parameters
|
| 4 |
+
* defined in a separate script section before inclusion of snare.js.
|
| 5 |
+
* The following sections contains the basic configuration values
|
| 6 |
+
**********************************************************************/
|
| 7 |
+
|
| 8 |
+
/*
|
| 9 |
+
* io_install_flash
|
| 10 |
+
* Type: boolean, optional
|
| 11 |
+
* Default: true
|
| 12 |
+
*
|
| 13 |
+
* Indicates whether or not the user will be prompted to install or
|
| 14 |
+
* upgrade Flash when Flash 8 is not installed. If Flash is already
|
| 15 |
+
* installed, this setting has no effect.
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
var io_install_flash = false;
|
| 19 |
+
|
| 20 |
+
/*
|
| 21 |
+
* io_install_stm
|
| 22 |
+
* Type: boolean, optional
|
| 23 |
+
* Default: true
|
| 24 |
+
*
|
| 25 |
+
* Indicates whether or not the ActiveX ReputationShield™ client should
|
| 26 |
+
* be installed. If the client is already installed, this setting has no
|
| 27 |
+
* effect.
|
| 28 |
+
*/
|
| 29 |
+
|
| 30 |
+
var io_install_stm = false;
|
| 31 |
+
|
| 32 |
+
/* io_exclude_stm
|
| 33 |
+
* Type: numeric, optional
|
| 34 |
+
* Default: 0
|
| 35 |
+
*
|
| 36 |
+
* This variable is a bitmask that indicates which Windows versions the
|
| 37 |
+
* Active X control should not run on. This is useful to avoid warnings
|
| 38 |
+
* in Vista or IE 8 when the control is present, but has not been used
|
| 39 |
+
* in the browser before.
|
| 40 |
+
*
|
| 41 |
+
* The values for the flag are:
|
| 42 |
+
*
|
| 43 |
+
* 1 – Windows 9x (including Windows 3.1, 95, 98 and Me)
|
| 44 |
+
* 2 – Windows CE
|
| 45 |
+
* 4 – Windows XP (including Windows NT, 2000 and 2003)
|
| 46 |
+
* 8 – Vista
|
| 47 |
+
*
|
| 48 |
+
* The values are meant to be combined. A value of 12 (4 + 8) indicates
|
| 49 |
+
* that the control should not run on Windows XP or Vista
|
| 50 |
+
*/
|
| 51 |
+
|
| 52 |
+
var io_exclude_stm = 12;
|
| 53 |
+
|
| 54 |
+
/*
|
| 55 |
+
* io_stm_cab_url
|
| 56 |
+
* Type: string, optional
|
| 57 |
+
* Default: iovation hosted location
|
| 58 |
+
*
|
| 59 |
+
* HTTP location where StmOCX.cab file is hosted. This URL should point
|
| 60 |
+
* to the version of the cab signed with your company certificate.
|
| 61 |
+
*
|
| 62 |
+
* Include #version=2,8,0,0 in the url to ensure the latest version of
|
| 63 |
+
* the client is installed.
|
| 64 |
+
*/
|
| 65 |
+
|
| 66 |
+
//var io_stm_cab_url = null;
|
| 67 |
+
|
| 68 |
+
/*
|
| 69 |
+
* io_bbout_element_id
|
| 70 |
+
* Type: string, optional
|
| 71 |
+
* Default: none
|
| 72 |
+
*
|
| 73 |
+
* The id of the HTML element to populate with the blackbox. If
|
| 74 |
+
* io_bb_callback is specified, this parameter will have no effect.
|
| 75 |
+
*/
|
| 76 |
+
|
| 77 |
+
var io_bbout_element_id = 'ioBlackBox';
|
| 78 |
+
|
| 79 |
+
/*
|
| 80 |
+
* io_bb_callback
|
| 81 |
+
* Type: function, optional
|
| 82 |
+
* Default: Hidden form field update function
|
| 83 |
+
*
|
| 84 |
+
* A JavaScript function that will be called as the blackbox is updated.
|
| 85 |
+
* The blackbox will be updated as each component (Flash, JavaScript,
|
| 86 |
+
* etc) finish their collection process.
|
| 87 |
+
*
|
| 88 |
+
* The function has the following declaration:
|
| 89 |
+
*
|
| 90 |
+
* function io_callback( bb, complete)
|
| 91 |
+
*
|
| 92 |
+
* Where
|
| 93 |
+
*
|
| 94 |
+
* bb – the updated value of the blackbox
|
| 95 |
+
* complete – a Boolean indicating whether all the collection methods
|
| 96 |
+
* have completed.
|
| 97 |
+
*/
|
| 98 |
+
|
| 99 |
+
//var io_bb_callback = null;
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
/* Latency
|
| 103 |
+
***********************************************************************
|
| 104 |
+
* It is important to note that various ReputationShield™ client
|
| 105 |
+
* components require time to download and run. Since the client is
|
| 106 |
+
* designed to run in the background, if a user prematurely submits the
|
| 107 |
+
* page prior to the client completing, a blackbox may not be generated
|
| 108 |
+
* or be incomplete.
|
| 109 |
+
*
|
| 110 |
+
* To address these latency issues, configuration variables are provided
|
| 111 |
+
* to specify a delay prior to the form being submitted when the hidden
|
| 112 |
+
* form field collection method is used. These parameters are optional.
|
| 113 |
+
* If specified, the required fields are necessary. If not specified, or
|
| 114 |
+
* improperly configured, there will be no delay in form submission.
|
| 115 |
+
*
|
| 116 |
+
* If a form is delayed, all form or button event handlers are run after
|
| 117 |
+
* the delay has expired or a blackbox has been generated.
|
| 118 |
+
**********************************************************************/
|
| 119 |
+
|
| 120 |
+
/*
|
| 121 |
+
* io_max_wait
|
| 122 |
+
* Type: integer, required
|
| 123 |
+
*
|
| 124 |
+
* Maximum time to wait (in milliseconds) for a blackbox before
|
| 125 |
+
* submitting the form.
|
| 126 |
+
*/
|
| 127 |
+
|
| 128 |
+
//var io_max_wait = 300;
|
| 129 |
+
|
| 130 |
+
/*
|
| 131 |
+
* io_submit_element_id
|
| 132 |
+
* Type: string, required
|
| 133 |
+
*
|
| 134 |
+
* The id of an HTML submit element. The onclick event for this element
|
| 135 |
+
* will be overridden to disable the control and wait for a blackbox.
|
| 136 |
+
* When either the timeout expires or the blackbox is complete, the
|
| 137 |
+
* control is re-enabled, and the original onclick event handler is
|
| 138 |
+
* called.
|
| 139 |
+
*/
|
| 140 |
+
|
| 141 |
+
//var io_submit_element_id = 'blackbox';
|
| 142 |
+
|
| 143 |
+
/*
|
| 144 |
+
* io_submit_form_id
|
| 145 |
+
* Type: string, optional
|
| 146 |
+
*
|
| 147 |
+
* The id of the HTML form to submit. The onsubmit handler will be
|
| 148 |
+
* overridden to wait for a blackbox before running.
|
| 149 |
+
*
|
| 150 |
+
* If not populated, the form containing io_submit_element_id is
|
| 151 |
+
* submitted and its onsubmit handler will be delayed.
|
| 152 |
+
*/
|
| 153 |
+
|
| 154 |
+
//var io_submit_form_id = '';
|
| 155 |
+
|
| 156 |
+
/*
|
| 157 |
+
* io_disabled_image_url
|
| 158 |
+
* Type: string, optional
|
| 159 |
+
*
|
| 160 |
+
* URL for a disabled button image. Only used when the submit element is
|
| 161 |
+
* an image. The image referenced will be displayed when the user clicks
|
| 162 |
+
* the button to submit the form. If no value is provided, the image is
|
| 163 |
+
* still disabled but not changed.
|
| 164 |
+
*/
|
| 165 |
+
|
| 166 |
+
//var io_disabled_image_url = '';
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
/* Error handling
|
| 170 |
+
***********************************************************************
|
| 171 |
+
* Certain error conditions require that the user be notified. snare.js
|
| 172 |
+
* defines two errors that can be handled. Error handlers are specified
|
| 173 |
+
* in the configuration script by assigning JavaScript to the
|
| 174 |
+
* appropriate variables:
|
| 175 |
+
*
|
| 176 |
+
* >> io_install_stm_error_handler – the ActiveX ReputationShield™
|
| 177 |
+
* client is not installed. The default behavior for this error is to
|
| 178 |
+
* display an alert indicating the control is required. If
|
| 179 |
+
* io_install_stm is false, this handler will not be run.
|
| 180 |
+
*
|
| 181 |
+
* >> io_flash_needs_update_handler – Flash is not installed or the
|
| 182 |
+
* installed version is less than 8.0. The default behavior is to
|
| 183 |
+
* display an alert indicating Flash 7 or higher is required. If
|
| 184 |
+
* io_install_flash is false, this handler will not be run.
|
| 185 |
+
*
|
| 186 |
+
* NOTE: io_last_error is set to the last error encountered in the
|
| 187 |
+
* script. If things do not appear to be working, you can check the
|
| 188 |
+
* value of this variable to look for errors caught while processing.
|
| 189 |
+
**********************************************************************/
|
| 190 |
+
|
| 191 |
+
//var io_install_stm_error_handler = null;
|
| 192 |
+
//var io_flash_needs_update_handler = null;
|
