Version Notes
First stable release
Download this release
Release Info
| Developer | SimplePay |
| Extension | SimplePay_Payments |
| Version | 1.0.0 |
| Comparing to | |
| See all releases | |
Version 1.0.0
- app/code/community/SimplePay/Payments/Block/Payment.php +58 -0
- app/code/community/SimplePay/Payments/Helper/Data.php +37 -0
- app/code/community/SimplePay/Payments/Model/Brands.php +32 -0
- app/code/community/SimplePay/Payments/Model/Config.php +210 -0
- app/code/community/SimplePay/Payments/Model/Payment.php +69 -0
- app/code/community/SimplePay/Payments/controllers/PaymentController.php +317 -0
- app/code/community/SimplePay/Payments/etc/config.xml +73 -0
- app/code/community/SimplePay/Payments/etc/system.xml +137 -0
- app/design/frontend/base/default/layout/simplepay.xml +32 -0
- app/design/frontend/base/default/template/simplepay/pay.phtml +39 -0
- app/etc/modules/SimplePay_Payments.xml +13 -0
- package.xml +18 -0
- skin/frontend/base/default/css/simplepay.css +18 -0
app/code/community/SimplePay/Payments/Block/Payment.php
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Payment Block
|
| 5 |
+
*
|
| 6 |
+
* @category Block
|
| 7 |
+
* @package SimplePay_Payments
|
| 8 |
+
* @author SimplePay
|
| 9 |
+
*/
|
| 10 |
+
class SimplePay_Payments_Block_Payment extends Mage_Core_Block_Template
|
| 11 |
+
{
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* Get checkout session namespace
|
| 15 |
+
*
|
| 16 |
+
* @return Mage_Checkout_Model_Session
|
| 17 |
+
*/
|
| 18 |
+
protected function _getCheckout()
|
| 19 |
+
{
|
| 20 |
+
return Mage::getSingleton('checkout/session');
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* Get SimplePay config
|
| 25 |
+
*
|
| 26 |
+
* @return SimplePay_Payments_Model_Config
|
| 27 |
+
*/
|
| 28 |
+
public function getConfig()
|
| 29 |
+
{
|
| 30 |
+
return Mage::getSingleton('simplepay/config');
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
protected function getPaymentModel()
|
| 34 |
+
{
|
| 35 |
+
return Mage::getSingleton('simplepay/payment');
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
public function getFormUrl($storeId = 0)
|
| 39 |
+
{
|
| 40 |
+
return $this->getConfig()->getFormUrl($storeId);
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
public function getResponseUrl()
|
| 44 |
+
{
|
| 45 |
+
return $this->getConfig()->getResponseUrl();
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
public function getCancelUrl()
|
| 49 |
+
{
|
| 50 |
+
return $this->getConfig()->getCancelUrl();
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
public function getAcceptedBrandsForForm($storeId = 0)
|
| 54 |
+
{
|
| 55 |
+
return $this->getConfig()->getAcceptedBrandsForForm();
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
}
|
app/code/community/SimplePay/Payments/Helper/Data.php
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Helper
|
| 5 |
+
*
|
| 6 |
+
* @category Helper
|
| 7 |
+
* @package SimplePay_Payments
|
| 8 |
+
* @author SimplePay
|
| 9 |
+
*/
|
| 10 |
+
class SimplePay_Payments_Helper_Data extends Mage_Core_Helper_Abstract
|
| 11 |
+
{
|
| 12 |
+
|
| 13 |
+
// Brand name to values array
|
| 14 |
+
protected $brandNames = array(
|
| 15 |
+
'American Express' => 'AMEX',
|
| 16 |
+
'Diners' => 'DINERS',
|
| 17 |
+
'JCB' => 'JCB',
|
| 18 |
+
'MasterCard' => 'MASTER',
|
| 19 |
+
'Visa' => 'VISA',
|
| 20 |
+
);
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Returns config model
|
| 24 |
+
*
|
| 25 |
+
* @return SimplePay_Payments_Model_Config
|
| 26 |
+
*/
|
| 27 |
+
public function getConfig()
|
| 28 |
+
{
|
| 29 |
+
return Mage::getSingleton('simplepay/config');
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
public function brandToValue($brand)
|
| 33 |
+
{
|
| 34 |
+
return $this->brandNames[$brand];
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
}
|
app/code/community/SimplePay/Payments/Model/Brands.php
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Brands
|
| 5 |
+
*/
|
| 6 |
+
class SimplePay_Payments_Model_Brands
|
| 7 |
+
{
|
| 8 |
+
/**
|
| 9 |
+
* @return array
|
| 10 |
+
*/
|
| 11 |
+
public function toOptionArray()
|
| 12 |
+
{
|
| 13 |
+
$options = array();
|
| 14 |
+
|
| 15 |
+
$brands = Mage::getModel('simplepay/config')->getAllBrands();
|
| 16 |
+
|
| 17 |
+
$translatedBrands = array();
|
| 18 |
+
|
| 19 |
+
foreach ($brands as $brand) {
|
| 20 |
+
$translatedBrands[$brand] = Mage::helper('simplepay')->brandToValue($brand);
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
foreach ($translatedBrands as $label => $value) {
|
| 24 |
+
$options[] = array(
|
| 25 |
+
'label' => $label,
|
| 26 |
+
'value' => $value,
|
| 27 |
+
);
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
return $options;
|
| 31 |
+
}
|
| 32 |
+
}
|
app/code/community/SimplePay/Payments/Model/Config.php
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Config Model
|
| 5 |
+
*
|
| 6 |
+
* @category Model
|
| 7 |
+
* @package SimplePay_Payments
|
| 8 |
+
* @author SimplePay
|
| 9 |
+
*/
|
| 10 |
+
class SimplePay_Payments_Model_Config extends Mage_Payment_Model_Config
|
| 11 |
+
{
|
| 12 |
+
const SIMPLEPAY_PATH = 'payment_services/simplepay/';
|
| 13 |
+
const SIMPLEPAY_CONTROLLER_ROUTE = 'simplepay/payment/';
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Token generation URLs
|
| 17 |
+
*/
|
| 18 |
+
const TOKEN_URL = 'https://simplepays.com/frontend/GenerateToken';
|
| 19 |
+
const TOKEN_TEST_URL = 'https://test.simplepays.com/frontend/GenerateToken';
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* Payment form URLs
|
| 23 |
+
*/
|
| 24 |
+
const FORM_URL = 'https://simplepays.com/frontend/widget/v3/widget.js?language=en&style=card';
|
| 25 |
+
const FORM_TEST_URL = 'https://test.simplepays.com/frontend/widget/v3/widget.js?language=en&style=card';
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Transaction status URLs
|
| 29 |
+
*/
|
| 30 |
+
const STATUS_URL = 'https://simplepays.com/frontend/GetStatus;jsessionid=';
|
| 31 |
+
const STATUS_TEST_URL = 'https://test.simplepays.com/frontend/GetStatus;jsessionid=';
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* Return SimplePay config information
|
| 35 |
+
*
|
| 36 |
+
* @param string $path
|
| 37 |
+
* @param int $storeId
|
| 38 |
+
* @return Simple_Xml
|
| 39 |
+
*/
|
| 40 |
+
public function getConfigData($path, $storeId = null)
|
| 41 |
+
{
|
| 42 |
+
if (!empty($path)) {
|
| 43 |
+
return Mage::getStoreConfig(self::SIMPLEPAY_PATH . $path, $storeId);
|
| 44 |
+
}
|
| 45 |
+
return false;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* Return security sender from config
|
| 50 |
+
*
|
| 51 |
+
* @param int $storeId
|
| 52 |
+
* @return string
|
| 53 |
+
*/
|
| 54 |
+
public function getSecuritySender($storeId = null)
|
| 55 |
+
{
|
| 56 |
+
return Mage::helper('core')->decrypt($this->getConfigData('security_sender', $storeId));
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* Return transaction channel from config
|
| 61 |
+
*
|
| 62 |
+
* @param int $storeId
|
| 63 |
+
* @return string
|
| 64 |
+
*/
|
| 65 |
+
public function getTransactionChannel($storeId = null)
|
| 66 |
+
{
|
| 67 |
+
return Mage::helper('core')->decrypt($this->getConfigData('transaction_channel', $storeId));
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
* Return transaction mode from config
|
| 72 |
+
*
|
| 73 |
+
* @param int $storeId
|
| 74 |
+
* @return string
|
| 75 |
+
*/
|
| 76 |
+
public function getTransactionMode($storeId = null)
|
| 77 |
+
{
|
| 78 |
+
return Mage::helper('core')->decrypt($this->getConfigData('transaction_mode', $storeId));
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
/**
|
| 82 |
+
* Return user login from config
|
| 83 |
+
*
|
| 84 |
+
* @param int $storeId
|
| 85 |
+
* @return string
|
| 86 |
+
*/
|
| 87 |
+
public function getUserLogin($storeId = null)
|
| 88 |
+
{
|
| 89 |
+
return Mage::helper('core')->decrypt($this->getConfigData('user_login', $storeId));
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
/**
|
| 93 |
+
* Return user pwd from config
|
| 94 |
+
*
|
| 95 |
+
* @param int $storeId
|
| 96 |
+
* @return string
|
| 97 |
+
*/
|
| 98 |
+
public function getUserPwd($storeId = null)
|
| 99 |
+
{
|
| 100 |
+
return Mage::helper('core')->decrypt($this->getConfigData('user_pwd', $storeId));
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
/**
|
| 104 |
+
* Return user pwd from config
|
| 105 |
+
*
|
| 106 |
+
* @param int $storeId
|
| 107 |
+
* @return string
|
| 108 |
+
*/
|
| 109 |
+
public function getPaymentType($storeId = null)
|
| 110 |
+
{
|
| 111 |
+
return Mage::helper('core')->decrypt($this->getConfigData('payment_type', $storeId));
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
/**
|
| 115 |
+
* Check whether in test mode or not
|
| 116 |
+
*
|
| 117 |
+
* @return boolean
|
| 118 |
+
*/
|
| 119 |
+
public function inTestMode($storeId = null)
|
| 120 |
+
{
|
| 121 |
+
return $this->getConfigData('test_mode_flag', $storeId);
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
public function getTokenUrl($storeId = 0)
|
| 125 |
+
{
|
| 126 |
+
if ($this->inTestMode($storeId)) {
|
| 127 |
+
return self::TOKEN_TEST_URL;
|
| 128 |
+
} else {
|
| 129 |
+
return self::TOKEN_URL;
|
| 130 |
+
}
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
public function getFormUrl($storeId = 0)
|
| 134 |
+
{
|
| 135 |
+
if ($this->inTestMode($storeId)) {
|
| 136 |
+
return self::FORM_TEST_URL;
|
| 137 |
+
} else {
|
| 138 |
+
return self::FORM_URL;
|
| 139 |
+
}
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
public function getStatusUrl($storeId = 0)
|
| 143 |
+
{
|
| 144 |
+
if ($this->inTestMode($storeId)) {
|
| 145 |
+
return self::STATUS_TEST_URL;
|
| 146 |
+
} else {
|
| 147 |
+
return self::STATUS_URL;
|
| 148 |
+
}
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
/**
|
| 152 |
+
* Returns the accepted brands
|
| 153 |
+
*/
|
| 154 |
+
public function getAcceptedBrands()
|
| 155 |
+
{
|
| 156 |
+
return Mage::getStoreConfig('payment/simplepay/brands');
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
/**
|
| 160 |
+
* Return all accepted brands
|
| 161 |
+
*/
|
| 162 |
+
public function getAllBrands()
|
| 163 |
+
{
|
| 164 |
+
return explode(',', Mage::getStoreConfig('payment/simplepay/availableBrands'));
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
public function getAcceptedBrandsForForm()
|
| 168 |
+
{
|
| 169 |
+
return implode(' ', explode(',', $this->getAcceptedBrands()));
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
/**
|
| 173 |
+
* Return URL to redirect after placing an order
|
| 174 |
+
*
|
| 175 |
+
* @return string
|
| 176 |
+
*/
|
| 177 |
+
public function getPaymentRedirectUrl()
|
| 178 |
+
{
|
| 179 |
+
return Mage::getUrl(
|
| 180 |
+
self::SIMPLEPAY_CONTROLLER_ROUTE . 'pay',
|
| 181 |
+
array('_secure' => true, '_nosid' => true)
|
| 182 |
+
);
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
/**
|
| 186 |
+
* Return URL to return to after submitting the payment form
|
| 187 |
+
*
|
| 188 |
+
* @return string
|
| 189 |
+
*/
|
| 190 |
+
public function getResponseUrl()
|
| 191 |
+
{
|
| 192 |
+
return Mage::getUrl(
|
| 193 |
+
self::SIMPLEPAY_CONTROLLER_ROUTE . 'response',
|
| 194 |
+
array('_secure' => true, '_nosid' => true)
|
| 195 |
+
);
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
/**
|
| 199 |
+
* Return the cancel URL
|
| 200 |
+
*
|
| 201 |
+
* @return string
|
| 202 |
+
*/
|
| 203 |
+
public function getCancelUrl()
|
| 204 |
+
{
|
| 205 |
+
return Mage::getUrl(
|
| 206 |
+
self::SIMPLEPAY_CONTROLLER_ROUTE . 'cancel',
|
| 207 |
+
array('_secure' => true, '_nosid' => true)
|
| 208 |
+
);
|
| 209 |
+
}
|
| 210 |
+
}
|
app/code/community/SimplePay/Payments/Model/Payment.php
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Payment Model
|
| 5 |
+
*
|
| 6 |
+
* @category Model
|
| 7 |
+
* @package SimplePay_Payments
|
| 8 |
+
* @author SimplePay
|
| 9 |
+
*/
|
| 10 |
+
class SimplePay_Payments_Model_Payment extends Mage_Payment_Model_Method_Abstract
|
| 11 |
+
{
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* Unique internal payment method identifier
|
| 15 |
+
*/
|
| 16 |
+
protected $_code = 'simplepay';
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* Availability options
|
| 20 |
+
*/
|
| 21 |
+
protected $_isGateway = true;
|
| 22 |
+
protected $_canAuthorize = false;
|
| 23 |
+
protected $_canCapture = false;
|
| 24 |
+
protected $_canCapturePartial = false;
|
| 25 |
+
protected $_canRefund = false;
|
| 26 |
+
protected $_canRefundInvoicePartial = false;
|
| 27 |
+
protected $_canVoid = false;
|
| 28 |
+
protected $_canUseInternal = false;
|
| 29 |
+
protected $_canUseCheckout = true;
|
| 30 |
+
protected $_canUseForMultishipping = false;
|
| 31 |
+
protected $_canSaveCc = false;
|
| 32 |
+
protected $_canFetchTransactionInfo = false;
|
| 33 |
+
|
| 34 |
+
protected function getConfig()
|
| 35 |
+
{
|
| 36 |
+
return Mage::getModel('simplepay/config');
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
public function getTokenUrl($storeId = 0)
|
| 40 |
+
{
|
| 41 |
+
return $this->getConfig()->getTokenUrl($storeId);
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
public function getFormUrl($storeId = 0)
|
| 45 |
+
{
|
| 46 |
+
return $this->getConfig()->getFormUrl($storeId);
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
public function getStatusUrl($storeId = 0)
|
| 50 |
+
{
|
| 51 |
+
return $this->getConfig()->getStatusUrl($storeId);
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
public function getAcceptedBrandsForForm()
|
| 55 |
+
{
|
| 56 |
+
return $this->getConfig()->getAcceptedBrandsForForm();
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* Redirect URL to payment form
|
| 61 |
+
*
|
| 62 |
+
* @return string
|
| 63 |
+
*/
|
| 64 |
+
public function getOrderPlaceRedirectUrl()
|
| 65 |
+
{
|
| 66 |
+
return $this->getConfig()->getPaymentRedirectUrl();
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
}
|
app/code/community/SimplePay/Payments/controllers/PaymentController.php
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Payment Controller
|
| 5 |
+
*
|
| 6 |
+
* @category Controller
|
| 7 |
+
* @package SimplePay_Payments
|
| 8 |
+
* @author SimplePay
|
| 9 |
+
*/
|
| 10 |
+
class SimplePay_Payments_PaymentController extends Mage_Core_Controller_Front_Action {
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* Get checkout session namespace
|
| 14 |
+
*
|
| 15 |
+
* @return Mage_Checkout_Model_Session
|
| 16 |
+
*/
|
| 17 |
+
protected function _getCheckout()
|
| 18 |
+
{
|
| 19 |
+
return Mage::getSingleton('checkout/session');
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
protected function getConfig()
|
| 23 |
+
{
|
| 24 |
+
return Mage::getSingleton('simplepay/config');
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
protected function getPaymentModel()
|
| 28 |
+
{
|
| 29 |
+
return Mage::getSingleton('simplepay/payment');
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
protected function generatePaymentToken($storeId = 0)
|
| 33 |
+
{
|
| 34 |
+
|
| 35 |
+
// Get the token generation URL
|
| 36 |
+
$tokenUrl = $this->getConfig()->getTokenUrl($storeId);
|
| 37 |
+
|
| 38 |
+
// Get the order ID from the session data
|
| 39 |
+
$lastIncrementId = $this->_getCheckout()->getLastRealOrderId();
|
| 40 |
+
|
| 41 |
+
if ($lastIncrementId) {
|
| 42 |
+
|
| 43 |
+
// Load the order using the order ID
|
| 44 |
+
$order = Mage::getModel('sales/order');
|
| 45 |
+
$order->loadByIncrementId($lastIncrementId);
|
| 46 |
+
|
| 47 |
+
// Prepare the data for generating a payment token
|
| 48 |
+
$data = array(
|
| 49 |
+
'SECURITY.SENDER' => $this->getConfig()->getSecuritySender($storeId),
|
| 50 |
+
'TRANSACTION.CHANNEL' => $this->getConfig()->getTransactionChannel($storeId),
|
| 51 |
+
'TRANSACTION.MODE' => $this->getConfig()->getTransactionMode($storeId),
|
| 52 |
+
'USER.LOGIN' => $this->getConfig()->getUserLogin($storeId),
|
| 53 |
+
'USER.PWD' => $this->getConfig()->getUserPwd($storeId),
|
| 54 |
+
'PAYMENT.TYPE' => $this->getConfig()->getPaymentType($storeId),
|
| 55 |
+
'PRESENTATION.AMOUNT' => $order->getGrandTotal(),
|
| 56 |
+
'PRESENTATION.CURRENCY' => $order->getOrderCurrencyCode(),
|
| 57 |
+
'IDENTIFICATION.INVOICEID' => $lastIncrementId,
|
| 58 |
+
);
|
| 59 |
+
|
| 60 |
+
$options = array(
|
| 61 |
+
'http' => array(
|
| 62 |
+
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
|
| 63 |
+
'method' => 'POST',
|
| 64 |
+
'content' => http_build_query($data),
|
| 65 |
+
)
|
| 66 |
+
);
|
| 67 |
+
|
| 68 |
+
$context = stream_context_create($options);
|
| 69 |
+
$response = file_get_contents($tokenUrl, false, $context);
|
| 70 |
+
|
| 71 |
+
// Check if the response is valid, return null if no response was received
|
| 72 |
+
if ($response === false) {
|
| 73 |
+
return null;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
$resultJson = json_decode($response, true);
|
| 77 |
+
|
| 78 |
+
// Return the payment token
|
| 79 |
+
if (isset($resultJson['transaction']['token'])) {
|
| 80 |
+
return $resultJson['transaction']['token'];
|
| 81 |
+
}
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
// Did not find an order ID in the session data, return null
|
| 85 |
+
return null;
|
| 86 |
+
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
/**
|
| 90 |
+
* Called when an order is submitted, generates the payment form
|
| 91 |
+
*/
|
| 92 |
+
public function payAction()
|
| 93 |
+
{
|
| 94 |
+
|
| 95 |
+
$lastIncrementId = $this->_getCheckout()->getLastRealOrderId();
|
| 96 |
+
|
| 97 |
+
if ($lastIncrementId) {
|
| 98 |
+
|
| 99 |
+
$order = Mage::getModel('sales/order');
|
| 100 |
+
$order->loadByIncrementId($lastIncrementId);
|
| 101 |
+
|
| 102 |
+
// Get a new payment token
|
| 103 |
+
$paymentToken = $this->generatePaymentToken($order->getStoreId());
|
| 104 |
+
|
| 105 |
+
// Check if a payment token was generated
|
| 106 |
+
if (is_null($paymentToken)) {
|
| 107 |
+
$this->_getCheckout()->addError('Could not connect to payment server, please try again later.');
|
| 108 |
+
$this->_redirect('checkout/cart');
|
| 109 |
+
return;
|
| 110 |
+
} else {
|
| 111 |
+
// Store the payment token in the payment model for later access
|
| 112 |
+
$this->getPaymentModel()->setData('paymentToken', $paymentToken);
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
// Update the order status
|
| 116 |
+
if ($order->getState() == Mage_Sales_Model_Order::STATE_NEW) {
|
| 117 |
+
|
| 118 |
+
if ($order->getId()) {
|
| 119 |
+
$order->setState(
|
| 120 |
+
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT
|
| 121 |
+
);
|
| 122 |
+
$order->save();
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
} else {
|
| 128 |
+
// No order ID was found, redirect to the home page
|
| 129 |
+
$this->_redirect('/');
|
| 130 |
+
return;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
// Load the payment page
|
| 134 |
+
$this->loadLayout();
|
| 135 |
+
$this->renderLayout();
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
/**
|
| 139 |
+
* Called when a user cancels an order
|
| 140 |
+
*/
|
| 141 |
+
public function cancelAction() {
|
| 142 |
+
|
| 143 |
+
$lastIncrementId = $this->_getCheckout()->getLastRealOrderId();
|
| 144 |
+
|
| 145 |
+
if ($lastIncrementId) {
|
| 146 |
+
|
| 147 |
+
$order = Mage::getModel('sales/order');
|
| 148 |
+
$order->loadByIncrementId($lastIncrementId);
|
| 149 |
+
|
| 150 |
+
if ($order->getId()) {
|
| 151 |
+
$order->setState(
|
| 152 |
+
Mage_Sales_Model_Order::STATE_CANCELED,
|
| 153 |
+
true,
|
| 154 |
+
'This order was cancelled before a payment was made.'
|
| 155 |
+
);
|
| 156 |
+
$order->cancel();
|
| 157 |
+
$order->save();
|
| 158 |
+
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
// Display a message
|
| 164 |
+
Mage::getSingleton('core/session')->addNotice('Order cancelled.');
|
| 165 |
+
// Redirect to the shopping cart
|
| 166 |
+
$this->_redirect('checkout/cart', array('_secure' => true));
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
/**
|
| 170 |
+
* Called after submitting the payment form
|
| 171 |
+
* Check the returned token to see if the payment was successful
|
| 172 |
+
*/
|
| 173 |
+
public function responseAction()
|
| 174 |
+
{
|
| 175 |
+
$token = Mage::app()->getRequest()->getParam('token');
|
| 176 |
+
|
| 177 |
+
// If the token is not present, redirect to the home page
|
| 178 |
+
if (is_null($token)) {
|
| 179 |
+
$this->_redirect('/');
|
| 180 |
+
return;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
$lastIncrementId = $this->_getCheckout()->getLastRealOrderId();
|
| 184 |
+
|
| 185 |
+
if ($lastIncrementId) {
|
| 186 |
+
|
| 187 |
+
$order = Mage::getModel('sales/order');
|
| 188 |
+
$order->loadByIncrementId($lastIncrementId);
|
| 189 |
+
|
| 190 |
+
$statusUrl = $this->getConfig()->getStatusUrl($order->getStoreId()) . $token;
|
| 191 |
+
|
| 192 |
+
// Check the status of the payment
|
| 193 |
+
$ch = curl_init();
|
| 194 |
+
curl_setopt($ch, CURLOPT_URL, $statusUrl);
|
| 195 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
| 196 |
+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
| 197 |
+
$resultPayment = curl_exec($ch);
|
| 198 |
+
curl_close($ch);
|
| 199 |
+
|
| 200 |
+
// Check if the response is valid
|
| 201 |
+
if ($resultPayment === false) {
|
| 202 |
+
// Could not get a response from the payment server
|
| 203 |
+
|
| 204 |
+
// Set the order as payment review
|
| 205 |
+
$order->setState(
|
| 206 |
+
Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW,
|
| 207 |
+
true,
|
| 208 |
+
'Could not contact payment server to check payment status.'
|
| 209 |
+
);
|
| 210 |
+
$order->save();
|
| 211 |
+
|
| 212 |
+
// Redirect to the checkout failure page
|
| 213 |
+
$this->_redirect('checkout/onepage/failure', array('_secure' => true));
|
| 214 |
+
return;
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
$resultJson = json_decode($resultPayment, true);
|
| 218 |
+
|
| 219 |
+
// Check if the payment was successful
|
| 220 |
+
if (isset($resultJson['errorMessage']) ||
|
| 221 |
+
(isset($resultJson['transaction']) && $resultJson['transaction']['processing']['result'] === 'NOK'))
|
| 222 |
+
{
|
| 223 |
+
|
| 224 |
+
// Payment was unsuccessful
|
| 225 |
+
// Display an error message to the user
|
| 226 |
+
// Also list the error in the order comments
|
| 227 |
+
$errorMsg = 'Payment unsuccessful.';
|
| 228 |
+
|
| 229 |
+
// Append an error message if set
|
| 230 |
+
if (isset($resultJson['errorMessage'])) {
|
| 231 |
+
|
| 232 |
+
$errorMsg .= '<br>Error: ' . $resultJson['errorMessage'];
|
| 233 |
+
|
| 234 |
+
} else if (isset($resultJson['transaction']['processing']['return']['message'])) {
|
| 235 |
+
|
| 236 |
+
$errorMsg .= '<br>Error: ' . $resultJson['transaction']['processing']['return']['message'];
|
| 237 |
+
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
Mage::getSingleton('core/session')->addError($errorMsg);
|
| 241 |
+
|
| 242 |
+
$order->setState(
|
| 243 |
+
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
|
| 244 |
+
true,
|
| 245 |
+
$errorMsg
|
| 246 |
+
);
|
| 247 |
+
$order->save();
|
| 248 |
+
|
| 249 |
+
// Redirect back to the payment page to retry payment
|
| 250 |
+
$this->_redirect('*/*/pay', array('_secure' => true));
|
| 251 |
+
return;
|
| 252 |
+
|
| 253 |
+
} else if (isset($resultJson['transaction']) &&
|
| 254 |
+
isset($resultJson['transaction']['processing']['result']) &&
|
| 255 |
+
$resultJson['transaction']['processing']['result'] === 'ACK')
|
| 256 |
+
{
|
| 257 |
+
|
| 258 |
+
// Payment was successful
|
| 259 |
+
|
| 260 |
+
// Prepare a success message
|
| 261 |
+
$successMsg = 'Payment has been authorised.';
|
| 262 |
+
|
| 263 |
+
// Append the transaction ID
|
| 264 |
+
if (isset($resultJson['transaction']['identification']['uniqueId'])) {
|
| 265 |
+
$successMsg .= '<br>Transaction ID: ' . $resultJson['transaction']['identification']['uniqueId'];
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
// Append the response message
|
| 269 |
+
if (isset($resultJson['transaction']['processing']['return']['message'])) {
|
| 270 |
+
$successMsg .= '<br>Response: ' . $resultJson['transaction']['processing']['return']['message'];
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
// Update the order
|
| 274 |
+
$order->setState(
|
| 275 |
+
Mage_Sales_Model_Order::STATE_PROCESSING,
|
| 276 |
+
true,
|
| 277 |
+
$successMsg
|
| 278 |
+
);
|
| 279 |
+
$order->save();
|
| 280 |
+
|
| 281 |
+
// Send an order email to the customer
|
| 282 |
+
$order->sendNewOrderEmail();
|
| 283 |
+
$order->setEmailSent(true);
|
| 284 |
+
|
| 285 |
+
// Set the last completed order
|
| 286 |
+
$this->_getCheckout()->setLastSuccessQuoteId($order->getQuoteId());
|
| 287 |
+
|
| 288 |
+
// Redirect to the checkout success page
|
| 289 |
+
$this->_redirect('checkout/onepage/success', array('_secure' => true));
|
| 290 |
+
return;
|
| 291 |
+
|
| 292 |
+
} else {
|
| 293 |
+
|
| 294 |
+
// Unknown transaction status
|
| 295 |
+
|
| 296 |
+
// Set the order as payment review
|
| 297 |
+
$order->setState(
|
| 298 |
+
Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW,
|
| 299 |
+
true,
|
| 300 |
+
'Could not verify payment.'
|
| 301 |
+
);
|
| 302 |
+
$order->save();
|
| 303 |
+
|
| 304 |
+
// Redirect to the checkout failure page
|
| 305 |
+
$this->_redirect('checkout/onepage/failure', array('_secure' => true));
|
| 306 |
+
return;
|
| 307 |
+
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
// No order ID was found, redirect to home page
|
| 313 |
+
$this->_redirect('/');
|
| 314 |
+
return;
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
}
|
app/code/community/SimplePay/Payments/etc/config.xml
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<SimplePay_Payments>
|
| 5 |
+
<version>1.0.0</version>
|
| 6 |
+
</SimplePay_Payments>
|
| 7 |
+
</modules>
|
| 8 |
+
<global>
|
| 9 |
+
<helpers>
|
| 10 |
+
<simplepay>
|
| 11 |
+
<class>SimplePay_Payments_Helper</class>
|
| 12 |
+
</simplepay>
|
| 13 |
+
</helpers>
|
| 14 |
+
<models>
|
| 15 |
+
<simplepay>
|
| 16 |
+
<class>SimplePay_Payments_Model</class>
|
| 17 |
+
<resourceModel>simplepay_resource</resourceModel>
|
| 18 |
+
</simplepay>
|
| 19 |
+
<simplepay_resource>
|
| 20 |
+
<class>SimplePay_Payments_Model_Resource</class>
|
| 21 |
+
<entities>
|
| 22 |
+
<alias>
|
| 23 |
+
<table>simplepay</table>
|
| 24 |
+
</alias>
|
| 25 |
+
</entities>
|
| 26 |
+
</simplepay_resource>
|
| 27 |
+
</models>
|
| 28 |
+
<blocks>
|
| 29 |
+
<simplepay>
|
| 30 |
+
<class>SimplePay_Payments_Block</class>
|
| 31 |
+
</simplepay>
|
| 32 |
+
</blocks>
|
| 33 |
+
</global>
|
| 34 |
+
|
| 35 |
+
<default>
|
| 36 |
+
<payment_services>
|
| 37 |
+
<simplepay>
|
| 38 |
+
<title>SimplePay</title>
|
| 39 |
+
<model>simplepay/payment</model>
|
| 40 |
+
<payment_action>authorize</payment_action>
|
| 41 |
+
<enable_test_mode>1</enable_test_mode>
|
| 42 |
+
</simplepay>
|
| 43 |
+
</payment_services>
|
| 44 |
+
<payment>
|
| 45 |
+
<simplepay>
|
| 46 |
+
<active>0</active>
|
| 47 |
+
<title>Credit Card (SimplePay)</title>
|
| 48 |
+
<model>simplepay/payment</model>
|
| 49 |
+
<order_status>pending</order_status>
|
| 50 |
+
<availableBrands>MasterCard,Visa,American Express,Diners,JCB</availableBrands>
|
| 51 |
+
</simplepay>
|
| 52 |
+
</payment>
|
| 53 |
+
</default>
|
| 54 |
+
|
| 55 |
+
<frontend>
|
| 56 |
+
<layout>
|
| 57 |
+
<updates>
|
| 58 |
+
<simplepay>
|
| 59 |
+
<file>simplepay.xml</file>
|
| 60 |
+
</simplepay>
|
| 61 |
+
</updates>
|
| 62 |
+
</layout>
|
| 63 |
+
<routers>
|
| 64 |
+
<simplepay>
|
| 65 |
+
<use>standard</use>
|
| 66 |
+
<args>
|
| 67 |
+
<module>SimplePay_Payments</module>
|
| 68 |
+
<frontName>simplepay</frontName>
|
| 69 |
+
</args>
|
| 70 |
+
</simplepay>
|
| 71 |
+
</routers>
|
| 72 |
+
</frontend>
|
| 73 |
+
</config>
|
app/code/community/SimplePay/Payments/etc/system.xml
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<sections>
|
| 4 |
+
<payment_services>
|
| 5 |
+
<label>Payment Services</label>
|
| 6 |
+
<tab>sales</tab>
|
| 7 |
+
<frontend_type>text</frontend_type>
|
| 8 |
+
<sort_order>450</sort_order>
|
| 9 |
+
<show_in_default>1</show_in_default>
|
| 10 |
+
<show_in_website>1</show_in_website>
|
| 11 |
+
<show_in_store>1</show_in_store>
|
| 12 |
+
<groups>
|
| 13 |
+
<simplepay translate="label" module="simplepay">
|
| 14 |
+
<label>SimplePay</label>
|
| 15 |
+
<frontend_type>text</frontend_type>
|
| 16 |
+
<sort_order>1</sort_order>
|
| 17 |
+
<show_in_default>1</show_in_default>
|
| 18 |
+
<show_in_website>1</show_in_website>
|
| 19 |
+
<show_in_store>1</show_in_store>
|
| 20 |
+
<fields>
|
| 21 |
+
<security_sender translate="label">
|
| 22 |
+
<label>Security Sender</label>
|
| 23 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
| 24 |
+
<frontend_type>text</frontend_type>
|
| 25 |
+
<sort_order>30</sort_order>
|
| 26 |
+
<show_in_default>1</show_in_default>
|
| 27 |
+
<show_in_website>1</show_in_website>
|
| 28 |
+
<show_in_store>1</show_in_store>
|
| 29 |
+
</security_sender>
|
| 30 |
+
<transaction_channel translate="label">
|
| 31 |
+
<label>Transaction Channel</label>
|
| 32 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
| 33 |
+
<frontend_type>text</frontend_type>
|
| 34 |
+
<sort_order>40</sort_order>
|
| 35 |
+
<show_in_default>1</show_in_default>
|
| 36 |
+
<show_in_website>1</show_in_website>
|
| 37 |
+
<show_in_store>1</show_in_store>
|
| 38 |
+
</transaction_channel>
|
| 39 |
+
<transaction_mode translate="label">
|
| 40 |
+
<label>Transaction Mode</label>
|
| 41 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
| 42 |
+
<frontend_type>text</frontend_type>
|
| 43 |
+
<sort_order>50</sort_order>
|
| 44 |
+
<show_in_default>1</show_in_default>
|
| 45 |
+
<show_in_website>1</show_in_website>
|
| 46 |
+
<show_in_store>1</show_in_store>
|
| 47 |
+
</transaction_mode>
|
| 48 |
+
<user_login translate="label">
|
| 49 |
+
<label>User Login</label>
|
| 50 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
| 51 |
+
<frontend_type>text</frontend_type>
|
| 52 |
+
<sort_order>60</sort_order>
|
| 53 |
+
<show_in_default>1</show_in_default>
|
| 54 |
+
<show_in_website>1</show_in_website>
|
| 55 |
+
<show_in_store>1</show_in_store>
|
| 56 |
+
</user_login>
|
| 57 |
+
<user_pwd translate="label">
|
| 58 |
+
<label>User Password</label>
|
| 59 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
| 60 |
+
<frontend_type>text</frontend_type>
|
| 61 |
+
<sort_order>70</sort_order>
|
| 62 |
+
<show_in_default>1</show_in_default>
|
| 63 |
+
<show_in_website>1</show_in_website>
|
| 64 |
+
<show_in_store>1</show_in_store>
|
| 65 |
+
</user_pwd>
|
| 66 |
+
<payment_type translate="label">
|
| 67 |
+
<label>Payment Type</label>
|
| 68 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
| 69 |
+
<frontend_type>text</frontend_type>
|
| 70 |
+
<sort_order>80</sort_order>
|
| 71 |
+
<show_in_default>1</show_in_default>
|
| 72 |
+
<show_in_website>1</show_in_website>
|
| 73 |
+
<show_in_store>1</show_in_store>
|
| 74 |
+
</payment_type>
|
| 75 |
+
<test_mode_flag translate="label">
|
| 76 |
+
<label>Test Mode</label>
|
| 77 |
+
<frontend_type>select</frontend_type>
|
| 78 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 79 |
+
<sort_order>200</sort_order>
|
| 80 |
+
<show_in_default>1</show_in_default>
|
| 81 |
+
<show_in_website>1</show_in_website>
|
| 82 |
+
<show_in_store>0</show_in_store>
|
| 83 |
+
</test_mode_flag>
|
| 84 |
+
</fields>
|
| 85 |
+
</simplepay>
|
| 86 |
+
</groups>
|
| 87 |
+
</payment_services>
|
| 88 |
+
<payment>
|
| 89 |
+
<groups>
|
| 90 |
+
<simplepay translate="label">
|
| 91 |
+
<label>SimplePay</label>
|
| 92 |
+
<sort_order>40</sort_order>
|
| 93 |
+
<show_in_default>1</show_in_default>
|
| 94 |
+
<show_in_website>1</show_in_website>
|
| 95 |
+
<show_in_store>1</show_in_store>
|
| 96 |
+
<fields>
|
| 97 |
+
<active translate="label">
|
| 98 |
+
<label>Enabled</label>
|
| 99 |
+
<frontend_type>select</frontend_type>
|
| 100 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 101 |
+
<sort_order>0</sort_order>
|
| 102 |
+
<show_in_default>1</show_in_default>
|
| 103 |
+
<show_in_website>1</show_in_website>
|
| 104 |
+
<show_in_store>0</show_in_store>
|
| 105 |
+
</active>
|
| 106 |
+
<title translate="label">
|
| 107 |
+
<label>Title</label>
|
| 108 |
+
<frontend_type>text</frontend_type>
|
| 109 |
+
<sort_order>10</sort_order>
|
| 110 |
+
<show_in_default>1</show_in_default>
|
| 111 |
+
<show_in_website>1</show_in_website>
|
| 112 |
+
<show_in_store>1</show_in_store>
|
| 113 |
+
<validate>required-entry</validate>
|
| 114 |
+
</title>
|
| 115 |
+
<sort_order translate="label">
|
| 116 |
+
<label>Sort Order</label>
|
| 117 |
+
<frontend_type>text</frontend_type>
|
| 118 |
+
<sort_order>20</sort_order>
|
| 119 |
+
<show_in_default>1</show_in_default>
|
| 120 |
+
<show_in_website>1</show_in_website>
|
| 121 |
+
<show_in_store>1</show_in_store>
|
| 122 |
+
</sort_order>
|
| 123 |
+
<brands translate="label">
|
| 124 |
+
<label>Accepted Brands</label>
|
| 125 |
+
<frontend_type>multiselect</frontend_type>
|
| 126 |
+
<sort_order>30</sort_order>
|
| 127 |
+
<source_model>simplepay/brands</source_model>
|
| 128 |
+
<show_in_default>1</show_in_default>
|
| 129 |
+
<show_in_website>1</show_in_website>
|
| 130 |
+
<show_in_store>1</show_in_store>
|
| 131 |
+
</brands>
|
| 132 |
+
</fields>
|
| 133 |
+
</simplepay>
|
| 134 |
+
</groups>
|
| 135 |
+
</payment>
|
| 136 |
+
</sections>
|
| 137 |
+
</config>
|
app/design/frontend/base/default/layout/simplepay.xml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<layout version="1.0.0">
|
| 3 |
+
<simplepay_payment_pay>
|
| 4 |
+
<reference name="head">
|
| 5 |
+
<action method="addCss">
|
| 6 |
+
<stylesheet>css/simplepay.css</stylesheet>
|
| 7 |
+
</action>
|
| 8 |
+
</reference>
|
| 9 |
+
<remove name="right"/>
|
| 10 |
+
<remove name="left"/>
|
| 11 |
+
<remove name="catalog.topnav"/>
|
| 12 |
+
<reference name="header">
|
| 13 |
+
<remove name="top.links"/>
|
| 14 |
+
<remove name="top.search"/>
|
| 15 |
+
<remove name="store_language"/>
|
| 16 |
+
<remove name="top.container"/>
|
| 17 |
+
</reference>
|
| 18 |
+
<reference name="footer">
|
| 19 |
+
<remove name="cms_footer_links"/>
|
| 20 |
+
<remove name="footer_links"/>
|
| 21 |
+
<remove name="store_switcher"/>
|
| 22 |
+
</reference>
|
| 23 |
+
<reference name="root">
|
| 24 |
+
<action method="setTemplate">
|
| 25 |
+
<template>page/1column.phtml</template>
|
| 26 |
+
</action>
|
| 27 |
+
</reference>
|
| 28 |
+
<reference name="content">
|
| 29 |
+
<block type="simplepay/payment" name="simplepay_pay" template="simplepay/pay.phtml"/>
|
| 30 |
+
</reference>
|
| 31 |
+
</simplepay_payment_pay>
|
| 32 |
+
</layout>
|
app/design/frontend/base/default/template/simplepay/pay.phtml
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Payment View
|
| 5 |
+
*
|
| 6 |
+
* @category View
|
| 7 |
+
* @package SimplePay_Payments
|
| 8 |
+
* @author SimplePay
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
// Retrieve the order
|
| 12 |
+
$orderId = $this->_getCheckout()->getLastRealOrderId();
|
| 13 |
+
$order = Mage::getModel('sales/order');
|
| 14 |
+
$order->loadByIncrementId($orderId);
|
| 15 |
+
|
| 16 |
+
?>
|
| 17 |
+
|
| 18 |
+
<div class="simplepay-payment-container">
|
| 19 |
+
|
| 20 |
+
<script type="text/javascript" src="<?php echo $this->getFormUrl($order->getStoreId()) ?>"></script>
|
| 21 |
+
|
| 22 |
+
<div class="simplepay-payment-text">
|
| 23 |
+
<p>Please pay for your order using the form below.</p>
|
| 24 |
+
</div>
|
| 25 |
+
|
| 26 |
+
<div class="simplepay-payment-form">
|
| 27 |
+
|
| 28 |
+
<form action="<?php echo $this->getResponseUrl() ?>"
|
| 29 |
+
id="<?php echo $this->getPaymentModel()->getData('paymentToken') ?>">
|
| 30 |
+
<?php echo $this->getAcceptedBrandsForForm() ?>
|
| 31 |
+
</form>
|
| 32 |
+
|
| 33 |
+
</div>
|
| 34 |
+
|
| 35 |
+
<div class="simplepay-payment-cancel">
|
| 36 |
+
<a href="<?php echo $this->getCancelUrl() ?>">Cancel</a>
|
| 37 |
+
</div>
|
| 38 |
+
|
| 39 |
+
</div>
|
app/etc/modules/SimplePay_Payments.xml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<SimplePay_Payments>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>community</codePool>
|
| 7 |
+
<depends>
|
| 8 |
+
<Mage_Sales/>
|
| 9 |
+
<Mage_Payment/>
|
| 10 |
+
</depends>
|
| 11 |
+
</SimplePay_Payments>
|
| 12 |
+
</modules>
|
| 13 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>SimplePay_Payments</name>
|
| 4 |
+
<version>1.0.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://opensource.org/licenses/mit-license.html">MIT</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Accept payments using SimplePay.</summary>
|
| 10 |
+
<description>Accept payments using SimplePay.</description>
|
| 11 |
+
<notes>First stable release</notes>
|
| 12 |
+
<authors><author><name>SimplePay</name><user>simplepay</user><email>glenm@simplepay.com.au</email></author></authors>
|
| 13 |
+
<date>2013-11-06</date>
|
| 14 |
+
<time>04:53:35</time>
|
| 15 |
+
<contents><target name="magecommunity"><dir name="SimplePay"><dir name="Payments"><dir name="Block"><file name="Payment.php" hash="2649d5d95b0f2d78aeaef26b8295a92d"/></dir><dir name="Helper"><file name="Data.php" hash="f616e5862cc3f86da89e2650f2917aa1"/></dir><dir name="Model"><file name="Brands.php" hash="503fbf04f874089d1750c1e50171d0ab"/><file name="Config.php" hash="d709d80ae2074a1a1f08237f0a487321"/><file name="Payment.php" hash="83a36460d51d13e6b0699cc4716ce679"/></dir><dir name="controllers"><file name="PaymentController.php" hash="4393a5cdb47a60eb62742578bedd6c08"/></dir><dir name="etc"><file name="config.xml" hash="260a26eb6cf2519ddd4995d4a6b50931"/><file name="system.xml" hash="b7d39a5fb50628a6bb0629f1cf275634"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="simplepay.xml" hash="af565e90e944b87b4b4bc12e21d996ff"/></dir><dir name="template"><dir name="simplepay"><file name="pay.phtml" hash="598f185ca2c340a3d6087051317b19c5"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="SimplePay_Payments.xml" hash="f5776cc64ab1ef8e3dc093852dd0e3a1"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="simplepay.css" hash="f198c7cf0e69b740a2eb2595f434832a"/></dir></dir></dir></dir></target></contents>
|
| 16 |
+
<compatible/>
|
| 17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>Mage_Sales</name><channel>core</channel><min></min><max></max></package><package><name>Mage_Payment</name><channel>core</channel><min></min><max></max></package><extension><name>curl</name><min></min><max></max></extension></required></dependencies>
|
| 18 |
+
</package>
|
skin/frontend/base/default/css/simplepay.css
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.simplepay-payment-container {
|
| 2 |
+
margin-top: 40px;
|
| 3 |
+
}
|
| 4 |
+
|
| 5 |
+
.simplepay-payment-container .simplepay-payment-text {
|
| 6 |
+
text-align: center;
|
| 7 |
+
font-size: 16px;
|
| 8 |
+
font-weight: bold;
|
| 9 |
+
margin-bottom: 40px;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
.simplepay-payment-container .simplepay-payment-form form {
|
| 13 |
+
display: block;
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
.simplepay-payment-container .simplepay-payment-cancel {
|
| 17 |
+
margin-left: 240px;
|
| 18 |
+
}
|
