Version Notes
Zazma payment option
Download this release
Release Info
Developer | Belvg |
Extension | Zazma_Payment |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Belvg/Zazma/Block/Adminhtml/System/Config/Form/Field/Renderer.php +12 -0
- app/code/community/Belvg/Zazma/Block/Payment/Form/Logo.php +24 -0
- app/code/community/Belvg/Zazma/Block/Payment/Form/Zazma.php +22 -0
- app/code/community/Belvg/Zazma/Exception.php +6 -0
- app/code/community/Belvg/Zazma/Helper/Config.php +89 -0
- app/code/community/Belvg/Zazma/Helper/Data.php +8 -0
- app/code/community/Belvg/Zazma/Model/Api.php +109 -0
- app/code/community/Belvg/Zazma/Model/Api/Request.php +175 -0
- app/code/community/Belvg/Zazma/Model/Payment/Zazma.php +124 -0
- app/code/community/Belvg/Zazma/controllers/CheckoutController.php +232 -0
- app/code/community/Belvg/Zazma/etc/config.xml +56 -0
- app/code/community/Belvg/Zazma/etc/system.xml +126 -0
- app/design/frontend/base/default/template/belvg/zazma/payment/form/logo.phtml +2 -0
- app/design/frontend/base/default/template/belvg/zazma/payment/form/zazma.phtml +1 -0
- app/etc/modules/Belvg_Zazma.xml +15 -0
- package.xml +18 -0
app/code/community/Belvg/Zazma/Block/Adminhtml/System/Config/Form/Field/Renderer.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Belvg_Zazma_Block_Adminhtml_System_Config_Form_Field_Renderer extends Mage_Adminhtml_Block_System_Config_Form_Field
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
7 |
+
{
|
8 |
+
$element->setDisabled('disabled');
|
9 |
+
return parent::_getElementHtml($element);
|
10 |
+
}
|
11 |
+
|
12 |
+
}
|
app/code/community/Belvg/Zazma/Block/Payment/Form/Logo.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Belvg_Zazma_Block_Payment_Form_Logo extends Mage_Payment_Block_Form
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Initialize
|
7 |
+
*/
|
8 |
+
protected function _construct()
|
9 |
+
{
|
10 |
+
parent::_construct();
|
11 |
+
$this->setTemplate('belvg/zazma/payment/form/logo.phtml');
|
12 |
+
}
|
13 |
+
|
14 |
+
public function getPaymentLogoSrc()
|
15 |
+
{
|
16 |
+
return Belvg_Zazma_Helper_Data::ZAZMA_LOGO_SRC;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function getPaymentPopupHref()
|
20 |
+
{
|
21 |
+
return Belvg_Zazma_Helper_Data::ZAZMA_POPUP_HREF;
|
22 |
+
}
|
23 |
+
|
24 |
+
}
|
app/code/community/Belvg/Zazma/Block/Payment/Form/Zazma.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Belvg_Zazma_Block_Payment_Form_Zazma extends Mage_Payment_Block_Form
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Initialize
|
8 |
+
*/
|
9 |
+
protected function _construct()
|
10 |
+
{
|
11 |
+
parent::_construct();
|
12 |
+
$mark = Mage::app()->getLayout()->addBlock('zazma/payment_form_logo', 'logo');
|
13 |
+
$this->setTemplate('belvg/zazma/payment/form/zazma.phtml')
|
14 |
+
->setMethodTitle('')->setMethodLabelAfterHtml($mark->toHtml());
|
15 |
+
}
|
16 |
+
|
17 |
+
public function getComment()
|
18 |
+
{
|
19 |
+
return $this->getMethod()->getComment();
|
20 |
+
}
|
21 |
+
|
22 |
+
}
|
app/code/community/Belvg/Zazma/Exception.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Belvg_Zazma_Exception extends Zend_Exception
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/community/Belvg/Zazma/Helper/Config.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Belvg_Zazma_Helper_Config extends Mage_Core_Helper_Data
|
4 |
+
{
|
5 |
+
|
6 |
+
const ZAZMA_MODULE_KEY = 'Belvg_Zazma';
|
7 |
+
const ZAZMA_MODULE_LOG_NAME = 'zazma-payments.log';
|
8 |
+
|
9 |
+
const ZAZMA_LOGO_SRC = 'https://www.zazma.com/images/magento_logo.png';
|
10 |
+
const ZAZMA_POPUP_HREF = 'https://www.zazma.com/site/magento_popup';
|
11 |
+
|
12 |
+
const XML_PATH_ZAZMA_USERNAME = 'payment/zazma/api_user';
|
13 |
+
const XML_PATH_ZAZMA_PASSWORD = 'payment/zazma/api_password';
|
14 |
+
const XML_PATH_ZAZMA_VERIFICATION = 'payment/zazma/verification';
|
15 |
+
const XML_PATH_ZAZMA_SENDBOX = 'payment/zazma/sandbox';
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Get Extension version
|
19 |
+
*
|
20 |
+
* @see Belvg_Zazma_Model_Api
|
21 |
+
* @return string
|
22 |
+
*/
|
23 |
+
public function getExtensionVersion()
|
24 |
+
{
|
25 |
+
return Mage::getConfig()->getModuleConfig(self::ZAZMA_MODULE_KEY)->version;
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Get Magento Edition
|
30 |
+
*
|
31 |
+
* @return string
|
32 |
+
*/
|
33 |
+
public function getEdition()
|
34 |
+
{
|
35 |
+
if (method_exists('Mage', 'getEdition')) {
|
36 |
+
$edition = Mage::getEdition();
|
37 |
+
} else if (class_exists('Enterprise_Cms_Helper_Data')) {
|
38 |
+
$edition = 'Enterprise';
|
39 |
+
} else {
|
40 |
+
$edition = 'Community';
|
41 |
+
}
|
42 |
+
|
43 |
+
return $edition;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Get supplier API username
|
48 |
+
*
|
49 |
+
* @param nixed $store
|
50 |
+
* @return string
|
51 |
+
*/
|
52 |
+
public function getApiUsername($store = '')
|
53 |
+
{
|
54 |
+
return Mage::getStoreConfig(self::XML_PATH_ZAZMA_USERNAME, $store);
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Get supplier API password
|
59 |
+
*
|
60 |
+
* @param nixed $store
|
61 |
+
* @return string
|
62 |
+
*/
|
63 |
+
public function getApiPassword($store = '')
|
64 |
+
{
|
65 |
+
return Mage::getStoreConfig(self::XML_PATH_ZAZMA_PASSWORD, $store);
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Check if method should send user verification request
|
70 |
+
*
|
71 |
+
* @param nixed $store
|
72 |
+
* @return boolean
|
73 |
+
*/
|
74 |
+
public function getNeedVerification($store = '')
|
75 |
+
{
|
76 |
+
return Mage::getStoreConfigFlag(self::XML_PATH_ZAZMA_VERIFICATION, $store);
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Check if method should send user verification request
|
81 |
+
*
|
82 |
+
* @param nixed $store
|
83 |
+
* @return boolean
|
84 |
+
*/
|
85 |
+
public function isSandboxEnabled($store = '')
|
86 |
+
{
|
87 |
+
return Mage::getStoreConfigFlag(self::XML_PATH_ZAZMA_SENDBOX, $store);
|
88 |
+
}
|
89 |
+
}
|
app/code/community/Belvg/Zazma/Helper/Data.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Belvg_Zazma_Helper_Data extends Belvg_Zazma_Helper_Config
|
4 |
+
{
|
5 |
+
|
6 |
+
|
7 |
+
|
8 |
+
}
|
app/code/community/Belvg/Zazma/Model/Api.php
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Belvg_Zazma_Model_Api
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* API version number (api number - ext number)
|
8 |
+
*
|
9 |
+
* @var stirng
|
10 |
+
*/
|
11 |
+
private $_version = NULL;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* API request user angent string
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
private $_userAgent = NULL;
|
18 |
+
private $_headers = array();
|
19 |
+
|
20 |
+
public function __construct()
|
21 |
+
{
|
22 |
+
$this->_version = Mage::helper('zazma')->getExtensionVersion();
|
23 |
+
$this->_userAgent = $this->setUserAgent();
|
24 |
+
$this->_headers = array('Content-type: application/json');
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Get API version (api number - ext number)
|
29 |
+
* @return string
|
30 |
+
*/
|
31 |
+
public function getVersion()
|
32 |
+
{
|
33 |
+
return $this->_version;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Get module User-Agent to use on API requests
|
38 |
+
*
|
39 |
+
* @return string
|
40 |
+
*/
|
41 |
+
protected function getUserAgent()
|
42 |
+
{
|
43 |
+
return $this->_userAgent;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Get headers for the request
|
48 |
+
*
|
49 |
+
* @return string
|
50 |
+
*/
|
51 |
+
protected function getHeaders()
|
52 |
+
{
|
53 |
+
return $this->_headers;
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Create module User-Agent line
|
58 |
+
*
|
59 |
+
* @return string
|
60 |
+
*/
|
61 |
+
protected function setUserAgent()
|
62 |
+
{
|
63 |
+
$edition = Mage::helper('zazma')->getEdition();
|
64 |
+
$ua = sprintf('Zazma/%s (Mage-%s-%s)', $this->getVersion(), $edition, Mage::getVersion());
|
65 |
+
return $ua;
|
66 |
+
}
|
67 |
+
|
68 |
+
public function sendRequest($url, $data, $method)
|
69 |
+
{
|
70 |
+
$response = NULL;
|
71 |
+
|
72 |
+
$ch = curl_init();
|
73 |
+
|
74 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
75 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
76 |
+
|
77 |
+
if ($method == 'POST') {
|
78 |
+
curl_setopt($ch, CURLOPT_POST, TRUE);
|
79 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
|
80 |
+
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
|
81 |
+
} else {
|
82 |
+
$query = http_build_query($data);
|
83 |
+
$url .= '?' . $query;
|
84 |
+
}
|
85 |
+
|
86 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
87 |
+
curl_setopt($ch, CURLOPT_USERAGENT, $this->getUserAgent());
|
88 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->getHeaders());
|
89 |
+
|
90 |
+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
|
91 |
+
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
|
92 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
93 |
+
|
94 |
+
curl_setopt($ch, CURLOPT_HEADER, FALSE);
|
95 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
96 |
+
|
97 |
+
$serverOutput = curl_exec($ch);
|
98 |
+
|
99 |
+
if ($serverOutput) {
|
100 |
+
$response = (array) json_decode($serverOutput);
|
101 |
+
} else {
|
102 |
+
throw Mage::exception(Belvg_Zazma_Helper_Data::ZAZMA_MODULE_KEY, curl_error($ch));
|
103 |
+
}
|
104 |
+
|
105 |
+
curl_close($ch);
|
106 |
+
return $response;
|
107 |
+
}
|
108 |
+
|
109 |
+
}
|
app/code/community/Belvg/Zazma/Model/Api/Request.php
ADDED
@@ -0,0 +1,175 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Belvg_Zazma_Model_Api_Request extends Belvg_Zazma_Model_Api
|
4 |
+
{
|
5 |
+
|
6 |
+
private $_apiUserName = NULL;
|
7 |
+
private $_apiPassword = NULL;
|
8 |
+
|
9 |
+
const ZAZMA_URL_LIVE = 'https://api.zazma.com/';
|
10 |
+
const ZAZMA_URL_SANDBOX = 'https://api.demo.dev.zazma.com/';
|
11 |
+
const ZAZMA_URL_SET_CHECKOUT = 'checkout/SetCheckOut/';
|
12 |
+
const ZAZMA_URL_VERIFY = 'checkout/IsCheckoutSupported/';
|
13 |
+
const ZAZMA_URL_GET_CHECKOUT = 'checkout/GetCheckoutDetails/';
|
14 |
+
const ZAZMA_URL_DO_CHECKOUT = 'checkout/DoCheckoutPayment/';
|
15 |
+
|
16 |
+
public function __construct()
|
17 |
+
{
|
18 |
+
parent::__construct();
|
19 |
+
|
20 |
+
$_helper = Mage::helper('zazma');
|
21 |
+
/* @var $_helper Belvg_Zazma_Helper_Data */
|
22 |
+
|
23 |
+
$this->_apiUserName = $_helper->getApiUsername();
|
24 |
+
$this->_apiPassword = $_helper->getApiPassword();
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Prepare url for the request
|
29 |
+
* @param string $urlKey
|
30 |
+
* @return string
|
31 |
+
*/
|
32 |
+
public function getUrl($urlKey)
|
33 |
+
{
|
34 |
+
$url = self::ZAZMA_URL_LIVE;
|
35 |
+
|
36 |
+
if (Mage::helper('zazma')->isSandboxEnabled()) {
|
37 |
+
$url = self::ZAZMA_URL_SANDBOX;
|
38 |
+
}
|
39 |
+
|
40 |
+
return $url . $urlKey;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Send API request
|
45 |
+
*
|
46 |
+
* @param string $url
|
47 |
+
* @param array $data
|
48 |
+
* @param string $method
|
49 |
+
* @return array
|
50 |
+
* @throws Belvg_Zazma_Exception
|
51 |
+
*/
|
52 |
+
public function sendRequest($url, $data, $method = 'POST')
|
53 |
+
{
|
54 |
+
try {
|
55 |
+
$data['user'] = $this->_apiUserName;
|
56 |
+
$data['pwd'] = $this->_apiPassword;
|
57 |
+
|
58 |
+
$result = parent::sendRequest($url, $data, $method);
|
59 |
+
|
60 |
+
$status = NULL;
|
61 |
+
|
62 |
+
// some zazma requests return "Status", others - "status"
|
63 |
+
if (isset($result['status'])) {
|
64 |
+
$status = $result['status'];
|
65 |
+
}
|
66 |
+
|
67 |
+
if (isset($result['Status'])) {
|
68 |
+
$status = $result['Status'];
|
69 |
+
}
|
70 |
+
|
71 |
+
if ($status == 'Success') {
|
72 |
+
$result['Status'] = $status;
|
73 |
+
return $result;
|
74 |
+
}
|
75 |
+
|
76 |
+
if ($status == 'Error') {
|
77 |
+
if (isset($result['moreInfo'])) {
|
78 |
+
$errors = array();
|
79 |
+
|
80 |
+
foreach ($result['moreInfo'] as $info) {
|
81 |
+
foreach ($info as $error) {
|
82 |
+
$errors[] = $error;
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
if (!empty($errors)) {
|
87 |
+
throw Mage::exception(Belvg_Zazma_Helper_Data::ZAZMA_MODULE_KEY, implode('<br />', $errors));
|
88 |
+
}
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
if ($status == 'Failure') {
|
93 |
+
if (isset($result['Error'])) {
|
94 |
+
$errors = array();
|
95 |
+
foreach ($result['Error'] as $info) {
|
96 |
+
foreach ($info as $error) {
|
97 |
+
$errors[] = $error;
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}
|
101 |
+
if (!empty($errors)) {
|
102 |
+
throw Mage::exception(Belvg_Zazma_Helper_Data::ZAZMA_MODULE_KEY, implode('<br />', $errors));
|
103 |
+
}
|
104 |
+
}
|
105 |
+
} catch (Belvg_Zazma_Exception $ze) {
|
106 |
+
Mage::log($ze->getMessage(), NULL, Belvg_Zazma_Helper_Data::ZAZMA_MODULE_LOG_NAME);
|
107 |
+
$result['error'] = $ze->getMessage();
|
108 |
+
return $result;
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Send order details to zazma.com, prepare redirect url
|
114 |
+
*
|
115 |
+
* @param array $data
|
116 |
+
* @return array
|
117 |
+
*/
|
118 |
+
public function setCheckOut($data)
|
119 |
+
{
|
120 |
+
$url = $this->getUrl(self::ZAZMA_URL_SET_CHECKOUT);
|
121 |
+
return $this->sendRequest($url, $data);
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Validate customer's details
|
126 |
+
*
|
127 |
+
* @param array $data
|
128 |
+
* @return boolean
|
129 |
+
*/
|
130 |
+
public function isCheckoutSupported($data)
|
131 |
+
{
|
132 |
+
$url = $this->getUrl(self::ZAZMA_URL_VERIFY);
|
133 |
+
$result = $this->sendRequest($url, $data, 'GET');
|
134 |
+
|
135 |
+
if (!isset($result['Status'])) {
|
136 |
+
return FALSE;
|
137 |
+
}
|
138 |
+
|
139 |
+
if ($result['Status'] == 'Failure') {
|
140 |
+
return FALSE;
|
141 |
+
}
|
142 |
+
|
143 |
+
return TRUE;
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Check order status and fees
|
148 |
+
*
|
149 |
+
* @param array $data
|
150 |
+
* @return string
|
151 |
+
*/
|
152 |
+
public function getCheckoutDetails($data)
|
153 |
+
{
|
154 |
+
$url = $this->getUrl(self::ZAZMA_URL_GET_CHECKOUT);
|
155 |
+
$result = $this->sendRequest($url, $data, 'GET');
|
156 |
+
|
157 |
+
return $result;
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Finalize order request
|
162 |
+
*
|
163 |
+
* @param type $data
|
164 |
+
* @return type
|
165 |
+
* @TODO CHECK REQUEST METHOD
|
166 |
+
*/
|
167 |
+
public function doCheckoutPayment($data)
|
168 |
+
{
|
169 |
+
$url = $this->getUrl(self::ZAZMA_URL_DO_CHECKOUT);
|
170 |
+
$result = $this->sendRequest($url, $data, 'GET');
|
171 |
+
|
172 |
+
return $result;
|
173 |
+
}
|
174 |
+
|
175 |
+
}
|
app/code/community/Belvg/Zazma/Model/Payment/Zazma.php
ADDED
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Belvg_Zazma_Model_Payment_Zazma extends Mage_Payment_Model_Method_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* unique internal payment method identifier
|
8 |
+
*
|
9 |
+
* @var string [a-z0-9_]
|
10 |
+
*/
|
11 |
+
protected $_code = 'zazma';
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Here are examples of flags that will determine functionality availability
|
15 |
+
* of this module to be used by frontend and backend.
|
16 |
+
*
|
17 |
+
* @see all flags and their defaults in Mage_Payment_Model_Method_Abstract
|
18 |
+
*
|
19 |
+
* It is possible to have a custom dynamic logic by overloading
|
20 |
+
* public function can* for each flag respectively
|
21 |
+
*/
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Is this payment method a gateway (online auth/charge) ?
|
25 |
+
*/
|
26 |
+
protected $_isGateway = TRUE;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Can authorize online?
|
30 |
+
*/
|
31 |
+
protected $_canAuthorize = TRUE;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Can capture funds online?
|
35 |
+
*/
|
36 |
+
protected $_canCapture = TRUE;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Can capture partial amounts online?
|
40 |
+
*/
|
41 |
+
protected $_canCapturePartial = FALSE;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Can refund online?
|
45 |
+
*/
|
46 |
+
protected $_canRefund = FALSE;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Can void transactions online?
|
50 |
+
*/
|
51 |
+
protected $_canVoid = TRUE;
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Can use this payment method in administration panel?
|
55 |
+
*/
|
56 |
+
protected $_canUseInternal = TRUE;
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Can show this payment method as an option on checkout payment page?
|
60 |
+
*/
|
61 |
+
protected $_canUseCheckout = TRUE;
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Is this payment method suitable for multi-shipping checkout?
|
65 |
+
*/
|
66 |
+
protected $_canUseForMultishipping = TRUE;
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Can save credit card information for future processing?
|
70 |
+
*/
|
71 |
+
protected $_canSaveCc = FALSE;
|
72 |
+
|
73 |
+
protected $_formBlockType = 'zazma/payment_form_zazma';
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Here you will need to implement authorize, capture and void public methods
|
77 |
+
*
|
78 |
+
* @see examples of transaction specific public methods such as
|
79 |
+
* authorize, capture and void in Mage_Paygate_Model_Authorizenet
|
80 |
+
* @return string
|
81 |
+
*/
|
82 |
+
public function getOrderPlaceRedirectUrl()
|
83 |
+
{
|
84 |
+
return Mage::getUrl('zazma/checkout/place');
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Check whether payment method can be used
|
89 |
+
*
|
90 |
+
* @param Mage_Sales_Model_Quote|null $quote
|
91 |
+
* @return bool
|
92 |
+
*/
|
93 |
+
public function isAvailable($quote = null)
|
94 |
+
{
|
95 |
+
if (Mage::helper('zazma')->getNeedVerification() && $quote->getBillingAddress()->getEmail()) {
|
96 |
+
$data = array();
|
97 |
+
|
98 |
+
$data['firstName'] = $quote->getCustomerFirstname();
|
99 |
+
$data['lastName'] = $quote->getCustomerLastname();
|
100 |
+
$data['email'] = $quote->getCustomerEmail();
|
101 |
+
$data['subTotal'] = $quote->getSubtotalWithDiscount();
|
102 |
+
$data['address'] = implode(',', $quote->getBillingAddress()->getStreet());
|
103 |
+
$data['city'] = $quote->getBillingAddress()->getCity();
|
104 |
+
$data['zip'] = $quote->getBillingAddress()->getPostcode();
|
105 |
+
$data['companyName'] = $quote->getBillingAddress()->getCompany();
|
106 |
+
$data['telephone'] = $quote->getBillingAddress()->getTelephone();
|
107 |
+
|
108 |
+
$api = Mage::getModel('zazma/api_request');
|
109 |
+
/* @var $api Belvg_Zazma_Model_Api_Request */
|
110 |
+
|
111 |
+
if (!$api->isCheckoutSupported($data)) {
|
112 |
+
return FALSE;
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
return parent::isAvailable($quote);
|
117 |
+
}
|
118 |
+
|
119 |
+
public function getComment()
|
120 |
+
{
|
121 |
+
return $this->getConfigData('comment');
|
122 |
+
}
|
123 |
+
|
124 |
+
}
|
app/code/community/Belvg/Zazma/controllers/CheckoutController.php
ADDED
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Belvg_Zazma_CheckoutController extends Mage_Core_Controller_Front_Action
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Find last Customer's Order,
|
8 |
+
* redirect to Zazma Checkout URL
|
9 |
+
*
|
10 |
+
* @return void
|
11 |
+
*/
|
12 |
+
public function placeAction()
|
13 |
+
{
|
14 |
+
try {
|
15 |
+
// load order
|
16 |
+
$orderIncrementId = $this->_getCheckoutSession()
|
17 |
+
->getLastRealOrderId();
|
18 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
|
19 |
+
/* @var $order Mage_Sales_Model_Order */
|
20 |
+
|
21 |
+
if (!$order->getId()) {
|
22 |
+
Mage::throwException();
|
23 |
+
throw Mage::exception(Belvg_Zazma_Helper_Data::ZAZMA_MODULE_KEY, $this->__('Order not found'));
|
24 |
+
}
|
25 |
+
Mage::register('current_order', $order);
|
26 |
+
|
27 |
+
|
28 |
+
$data = array();
|
29 |
+
$items = array();
|
30 |
+
$qty = 0;
|
31 |
+
|
32 |
+
foreach ($order->getAllItems() as $item) {
|
33 |
+
$items[] = $item->getName();
|
34 |
+
$qty += $item->getQtyOrdered();
|
35 |
+
}
|
36 |
+
$uniqueItems = array_unique($items);
|
37 |
+
$data['item'] = implode(', ', $uniqueItems);
|
38 |
+
$data['orderNumber'] = $orderIncrementId;
|
39 |
+
$data['description'] = $this->__('Order number %s', $orderIncrementId);
|
40 |
+
$data['price'] = $order->getGrandTotal() - $order->getShippingAmount();
|
41 |
+
$data['qty'] = $qty;
|
42 |
+
$data['shipping'] = $order->getShippingAmount();
|
43 |
+
$data['totalRetail'] = $order->getGrandTotal();
|
44 |
+
$data['subTotal'] = $order->getGrandTotal();
|
45 |
+
$data['returnUrl'] = Mage::getUrl('zazma/checkout/success');
|
46 |
+
$data['cancelUrl'] = Mage::getUrl('zazma/checkout/cancel');
|
47 |
+
|
48 |
+
$api = Mage::getModel('zazma/api_request');
|
49 |
+
/* @var $api Belvg_Zazma_Model_Api_Request */
|
50 |
+
|
51 |
+
$result = $api->setCheckOut($data);
|
52 |
+
|
53 |
+
if (isset($result['error'])) {
|
54 |
+
throw Mage::exception(Belvg_Zazma_Helper_Data::ZAZMA_MODULE_KEY, $result['error']);
|
55 |
+
}
|
56 |
+
|
57 |
+
if (isset($result['token'])) {
|
58 |
+
$this->_getCheckoutSession()->setZazmaToken($result['token']);
|
59 |
+
} else {
|
60 |
+
throw Mage::exception(Belvg_Zazma_Helper_Data::ZAZMA_MODULE_KEY, $this->__('Token sting is corrupted, please try later'));
|
61 |
+
}
|
62 |
+
|
63 |
+
if (isset($result['REDIRECT_URL'])) {
|
64 |
+
$this->_redirectUrl($result['REDIRECT_URL']);
|
65 |
+
} else {
|
66 |
+
throw Mage::exception(Belvg_Zazma_Helper_Data::ZAZMA_MODULE_KEY, $this->__('Service is unavailable, please try later'));
|
67 |
+
}
|
68 |
+
} catch (Belvg_Zazma_Exception $exc) {
|
69 |
+
$this->_getCheckoutSession()->addError($exc->getMessage());
|
70 |
+
$this->reorderAction();
|
71 |
+
$this->_redirect('checkout/cart');
|
72 |
+
} catch (Exception $exc) {
|
73 |
+
$this->_getCheckoutSession()->addError($this->__('Unable to check out.'));
|
74 |
+
Mage::logException($exc);
|
75 |
+
$this->_redirect('checkout/cart');
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
public function cancelAction()
|
80 |
+
{
|
81 |
+
try {
|
82 |
+
// load order
|
83 |
+
$orderIncrementId = $this->_getCheckoutSession()
|
84 |
+
->getLastRealOrderId();
|
85 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
|
86 |
+
/* @var $order Mage_Sales_Model_Order */
|
87 |
+
|
88 |
+
if (!$order->getId()) {
|
89 |
+
Mage::throwException();
|
90 |
+
throw Mage::exception(Belvg_Zazma_Helper_Data::ZAZMA_MODULE_KEY, $this->__('Order not found'));
|
91 |
+
}
|
92 |
+
Mage::register('current_order', $order);
|
93 |
+
|
94 |
+
if ($order->canCancel()) {
|
95 |
+
$order->cancel()->save();
|
96 |
+
$this->_getCheckoutSession()->setLastRealOrderId(NULL);
|
97 |
+
$this->_getCheckoutSession()->clear();
|
98 |
+
}
|
99 |
+
$this->_getCheckoutSession()->addError($this->__('Your order was canceled'));
|
100 |
+
$this->reorderAction();
|
101 |
+
$this->_redirect('checkout/cart');
|
102 |
+
} catch (Belvg_Zazma_Exception $exc) {
|
103 |
+
$this->_getCheckoutSession()->addError($exc->getMessage());
|
104 |
+
$this->_redirect('checkout/cart');
|
105 |
+
} catch (Exception $exc) {
|
106 |
+
$this->_getCheckoutSession()->addError($this->__('Order was not found'));
|
107 |
+
Mage::logException($exc);
|
108 |
+
$this->_redirect('checkout/cart');
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
public function successAction()
|
113 |
+
{
|
114 |
+
try {
|
115 |
+
// load order
|
116 |
+
$orderIncrementId = $this->_getCheckoutSession()
|
117 |
+
->getLastRealOrderId();
|
118 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
|
119 |
+
/* @var $order Mage_Sales_Model_Order */
|
120 |
+
|
121 |
+
if (!$order->getId()) {
|
122 |
+
throw Mage::exception(Belvg_Zazma_Helper_Data::ZAZMA_MODULE_KEY, $this->__('Order not found'));
|
123 |
+
}
|
124 |
+
|
125 |
+
$token = $this->getRequest()->getParam('token');
|
126 |
+
|
127 |
+
if ($token !== $this->_getCheckoutSession()->getZazmaToken()) {
|
128 |
+
throw Mage::exception(Belvg_Zazma_Helper_Data::ZAZMA_MODULE_KEY, $this->__('Order not found. Invalid token'));
|
129 |
+
}
|
130 |
+
|
131 |
+
$api = Mage::getModel('zazma/api_request');
|
132 |
+
/* @var $api Belvg_Zazma_Model_Api_Request */
|
133 |
+
|
134 |
+
$data = array('token' => $token);
|
135 |
+
$result = $api->getCheckoutDetails($data);
|
136 |
+
|
137 |
+
if (isset($result['Status']) && $result['Status']) {
|
138 |
+
|
139 |
+
if (isset($result['orderNumber'])) {
|
140 |
+
$zazmaOrderId = $result['orderNumber'];
|
141 |
+
|
142 |
+
if ($zazmaOrderId != $orderIncrementId) {
|
143 |
+
throw Mage::exception(Belvg_Zazma_Helper_Data::ZAZMA_MODULE_KEY, $this->__('Can not retreive order number'));
|
144 |
+
}
|
145 |
+
|
146 |
+
$result = $api->doCheckoutPayment($data);
|
147 |
+
|
148 |
+
if (isset($result['Status']) && $result['Status']) {
|
149 |
+
$this->completeOrder($order);
|
150 |
+
} else {
|
151 |
+
throw Mage::exception(Belvg_Zazma_Helper_Data::ZAZMA_MODULE_KEY, $this->__('Can not complete order'));
|
152 |
+
}
|
153 |
+
} else {
|
154 |
+
throw Mage::exception(Belvg_Zazma_Helper_Data::ZAZMA_MODULE_KEY, $this->__('Can not retreive order number'));
|
155 |
+
}
|
156 |
+
} else {
|
157 |
+
throw Mage::exception(Belvg_Zazma_Helper_Data::ZAZMA_MODULE_KEY, $this->__('Payment was not approver by Zazma.com'));
|
158 |
+
}
|
159 |
+
} catch (Belvg_Zazma_Exception $e) {
|
160 |
+
$this->_getCheckoutSession()->addError($this->__($e->getMessage()));
|
161 |
+
Mage::logException($e);
|
162 |
+
$this->_redirect('checkout/cart');
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Generate invoice for the order, redirect to the success page
|
168 |
+
*
|
169 |
+
* @param Mage_Sales_Model_Order $order
|
170 |
+
*/
|
171 |
+
protected function completeOrder(Mage_Sales_Model_Order $order)
|
172 |
+
{
|
173 |
+
if (!$order->canInvoice()) {
|
174 |
+
throw Mage::exception(Belvg_Zazma_Helper_Data::ZAZMA_MODULE_KEY, $this->__('Cannot create an invoice'));
|
175 |
+
}
|
176 |
+
|
177 |
+
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
|
178 |
+
if (!$invoice->getTotalQty()) {
|
179 |
+
throw Mage::exception(Belvg_Zazma_Helper_Data::ZAZMA_MODULE_KEY, $this->__('Cannot create an invoice without products'));
|
180 |
+
}
|
181 |
+
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
|
182 |
+
$invoice->register();
|
183 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
184 |
+
->addObject($invoice)
|
185 |
+
->addObject($invoice->getOrder());
|
186 |
+
$transactionSave->save();
|
187 |
+
|
188 |
+
$this->_redirect('checkout/onepage/success');
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Get Customer's Checkout session
|
193 |
+
*
|
194 |
+
* @return Mage_Checkout_Model_Session
|
195 |
+
*/
|
196 |
+
private function _getCheckoutSession()
|
197 |
+
{
|
198 |
+
return Mage::getSingleton('checkout/session');
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Action for reorder
|
203 |
+
*/
|
204 |
+
public function reorderAction()
|
205 |
+
{
|
206 |
+
if ($order = Mage::registry('current_order')) {
|
207 |
+
|
208 |
+
$cart = Mage::getSingleton('checkout/cart');
|
209 |
+
$cartTruncated = false;
|
210 |
+
/* @var $cart Mage_Checkout_Model_Cart */
|
211 |
+
|
212 |
+
$items = $order->getItemsCollection();
|
213 |
+
foreach ($items as $item) {
|
214 |
+
try {
|
215 |
+
$cart->addOrderItem($item);
|
216 |
+
} catch (Mage_Core_Exception $e) {
|
217 |
+
if (Mage::getSingleton('checkout/session')->getUseNotice(true)) {
|
218 |
+
Mage::getSingleton('checkout/session')->addNotice($e->getMessage());
|
219 |
+
} else {
|
220 |
+
Mage::getSingleton('checkout/session')->addError($e->getMessage());
|
221 |
+
}
|
222 |
+
} catch (Exception $e) {
|
223 |
+
Mage::getSingleton('checkout/session')->addException($e, Mage::helper('checkout')->__('Cannot add the item to shopping cart.')
|
224 |
+
);
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
$cart->save();
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
}
|
app/code/community/Belvg/Zazma/etc/config.xml
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
<modules>
|
5 |
+
<Bluesnap_Buynow>
|
6 |
+
<version>1.0.0</version>
|
7 |
+
</Bluesnap_Buynow>
|
8 |
+
</modules>
|
9 |
+
<global>
|
10 |
+
<helpers>
|
11 |
+
<zazma>
|
12 |
+
<class>Belvg_Zazma_Helper</class>
|
13 |
+
</zazma>
|
14 |
+
</helpers>
|
15 |
+
<blocks>
|
16 |
+
<zazma>
|
17 |
+
<class>Belvg_Zazma_Block</class>
|
18 |
+
</zazma>
|
19 |
+
</blocks>
|
20 |
+
<models>
|
21 |
+
<zazma>
|
22 |
+
<class>Belvg_Zazma_Model</class>
|
23 |
+
</zazma>
|
24 |
+
</models>
|
25 |
+
</global>
|
26 |
+
|
27 |
+
<frontend>
|
28 |
+
<routers>
|
29 |
+
<zazma>
|
30 |
+
<use>standard</use>
|
31 |
+
<args>
|
32 |
+
<module>Belvg_Zazma</module>
|
33 |
+
<frontName>zazma</frontName>
|
34 |
+
</args>
|
35 |
+
</zazma>
|
36 |
+
</routers>
|
37 |
+
</frontend>
|
38 |
+
|
39 |
+
<default>
|
40 |
+
<payment>
|
41 |
+
<zazma>
|
42 |
+
<active>0</active>
|
43 |
+
<title><![CDATA[Zazma payment method]]></title>
|
44 |
+
<comment><![CDATA[You will be redirected to the secure payment page when you place an order.]]></comment>
|
45 |
+
<api_password backend_model="adminhtml/system_config_backend_encrypted" />
|
46 |
+
<sandbox>0</sandbox>
|
47 |
+
<verification>1</verification>
|
48 |
+
<allowspecific>1</allowspecific>
|
49 |
+
<specificcountry>US</specificcountry>
|
50 |
+
<min_order_total>300</min_order_total>
|
51 |
+
<max_order_total>5000</max_order_total>
|
52 |
+
<model>zazma/payment_zazma</model>
|
53 |
+
</zazma>
|
54 |
+
</payment>
|
55 |
+
</default>
|
56 |
+
</config>
|
app/code/community/Belvg/Zazma/etc/system.xml
ADDED
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
<sections>
|
5 |
+
<payment translate="label" module="payment">
|
6 |
+
<groups>
|
7 |
+
<zazma translate="label" module="zazma">
|
8 |
+
<label>Zazma Payment Method</label>
|
9 |
+
<frontend_type>text</frontend_type>
|
10 |
+
<sort_order>45</sort_order>
|
11 |
+
<show_in_default>1</show_in_default>
|
12 |
+
<show_in_website>1</show_in_website>
|
13 |
+
<show_in_store>1</show_in_store>
|
14 |
+
<fields>
|
15 |
+
<active translate="label">
|
16 |
+
<label>Enabled</label>
|
17 |
+
<frontend_type>select</frontend_type>
|
18 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
19 |
+
<sort_order>1</sort_order>
|
20 |
+
<show_in_default>1</show_in_default>
|
21 |
+
<show_in_website>1</show_in_website>
|
22 |
+
<show_in_store>0</show_in_store>
|
23 |
+
</active>
|
24 |
+
<title translate="label">
|
25 |
+
<label>Title</label>
|
26 |
+
<frontend_type>text</frontend_type>
|
27 |
+
<sort_order>2</sort_order>
|
28 |
+
<show_in_default>1</show_in_default>
|
29 |
+
<show_in_website>1</show_in_website>
|
30 |
+
<show_in_store>1</show_in_store>
|
31 |
+
</title>
|
32 |
+
<comment translate="label">
|
33 |
+
<label>Comment</label>
|
34 |
+
<frontend_type>text</frontend_type>
|
35 |
+
<sort_order>3</sort_order>
|
36 |
+
<show_in_default>1</show_in_default>
|
37 |
+
<show_in_website>1</show_in_website>
|
38 |
+
<show_in_store>1</show_in_store>
|
39 |
+
</comment>
|
40 |
+
<api_user>
|
41 |
+
<label>API Username</label>
|
42 |
+
<frontend_type>text</frontend_type>
|
43 |
+
<sort_order>4</sort_order>
|
44 |
+
<show_in_default>1</show_in_default>
|
45 |
+
<show_in_website>1</show_in_website>
|
46 |
+
<show_in_store>1</show_in_store>
|
47 |
+
</api_user>
|
48 |
+
<api_password>
|
49 |
+
<label>API Password</label>
|
50 |
+
<frontend_type>obscure</frontend_type>
|
51 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
52 |
+
<sort_order>5</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 |
+
</api_password>
|
57 |
+
<sandbox translate="label">
|
58 |
+
<label>Enable Sandbox</label>
|
59 |
+
<frontend_type>select</frontend_type>
|
60 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
61 |
+
<sort_order>6</sort_order>
|
62 |
+
<show_in_default>1</show_in_default>
|
63 |
+
<show_in_website>1</show_in_website>
|
64 |
+
<show_in_store>0</show_in_store>
|
65 |
+
</sandbox>
|
66 |
+
<verification translate="label">
|
67 |
+
<!--label>Enable user verification</label-->
|
68 |
+
<frontend_type>hidden</frontend_type>
|
69 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
70 |
+
<sort_order>7</sort_order>
|
71 |
+
<show_in_default>1</show_in_default>
|
72 |
+
<show_in_website>1</show_in_website>
|
73 |
+
<show_in_store>0</show_in_store>
|
74 |
+
</verification>
|
75 |
+
<allowspecific translate="label">
|
76 |
+
<label>Payment from Applicable Countries</label>
|
77 |
+
<frontend_type>allowspecific</frontend_type>
|
78 |
+
<frontend_model>zazma/adminhtml_system_config_form_field_renderer</frontend_model>
|
79 |
+
<sort_order>50</sort_order>
|
80 |
+
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
|
81 |
+
<show_in_default>1</show_in_default>
|
82 |
+
<show_in_website>1</show_in_website>
|
83 |
+
<show_in_store>0</show_in_store>
|
84 |
+
</allowspecific>
|
85 |
+
<specificcountry translate="label">
|
86 |
+
<label>Payment from Specific Countries</label>
|
87 |
+
<frontend_type>multiselect</frontend_type>
|
88 |
+
<frontend_model>zazma/adminhtml_system_config_form_field_renderer</frontend_model>
|
89 |
+
<sort_order>51</sort_order>
|
90 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
91 |
+
<show_in_default>1</show_in_default>
|
92 |
+
<show_in_website>1</show_in_website>
|
93 |
+
<show_in_store>0</show_in_store>
|
94 |
+
<can_be_empty>1</can_be_empty>
|
95 |
+
</specificcountry>
|
96 |
+
<min_order_total translate="label">
|
97 |
+
<label>Minimum Order Total</label>
|
98 |
+
<frontend_type>text</frontend_type>
|
99 |
+
<sort_order>98</sort_order>
|
100 |
+
<show_in_default>1</show_in_default>
|
101 |
+
<show_in_website>1</show_in_website>
|
102 |
+
<show_in_store>0</show_in_store>
|
103 |
+
</min_order_total>
|
104 |
+
<max_order_total translate="label">
|
105 |
+
<label>Maximum Order Total</label>
|
106 |
+
<frontend_type>text</frontend_type>
|
107 |
+
<sort_order>99</sort_order>
|
108 |
+
<show_in_default>1</show_in_default>
|
109 |
+
<show_in_website>1</show_in_website>
|
110 |
+
<show_in_store>0</show_in_store>
|
111 |
+
</max_order_total>
|
112 |
+
<sort_order translate="label">
|
113 |
+
<label>Sort Order</label>
|
114 |
+
<frontend_type>text</frontend_type>
|
115 |
+
<sort_order>100</sort_order>
|
116 |
+
<show_in_default>1</show_in_default>
|
117 |
+
<show_in_website>1</show_in_website>
|
118 |
+
<show_in_store>0</show_in_store>
|
119 |
+
<frontend_class>validate-number</frontend_class>
|
120 |
+
</sort_order>
|
121 |
+
</fields>
|
122 |
+
</zazma>
|
123 |
+
</groups>
|
124 |
+
</payment>
|
125 |
+
</sections>
|
126 |
+
</config>
|
app/design/frontend/base/default/template/belvg/zazma/payment/form/logo.phtml
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<img src="<?php echo $this->getPaymentLogoSrc()?>" alt="<?php echo Mage::helper('zazma')->__('Acceptance Mark') ?>" class="v-middle"/>
|
2 |
+
<a href="<?php echo $this->getPaymentPopupHref()?>" onclick="javascript:window.open('<?php echo $this->getPaymentPopupHref()?>','olcwhatiszazma','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, ,left=0, top=0, width=400, height=350'); return false;"><?php echo Mage::helper('zazma')->__('How does it work?') ?></a>
|
app/design/frontend/base/default/template/belvg/zazma/payment/form/zazma.phtml
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php echo $this->escapeHtml($this->getComment()) ?>
|
app/etc/modules/Belvg_Zazma.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
<modules>
|
5 |
+
<Belvg_Zazma>
|
6 |
+
<active>true</active>
|
7 |
+
<codePool>community</codePool>
|
8 |
+
<depends>
|
9 |
+
<Mage_Checkout/>
|
10 |
+
</depends>
|
11 |
+
<version>1.0.0</version>
|
12 |
+
</Belvg_Zazma>
|
13 |
+
</modules>
|
14 |
+
</config>
|
15 |
+
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Zazma_Payment</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>OSL 3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Zazma payment option</summary>
|
10 |
+
<description>Zazma payment option</description>
|
11 |
+
<notes>Zazma payment option</notes>
|
12 |
+
<authors><author><name>BelVG LLC</name><user>belvg</user><email>store@belvg.com</email></author></authors>
|
13 |
+
<date>2014-04-30</date>
|
14 |
+
<time>10:00:50</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Belvg"><dir name="Zazma"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Renderer.php" hash="a92fd92df6740ab0ab383f8893938942"/></dir></dir></dir></dir></dir><dir name="Payment"><dir name="Form"><file name="Logo.php" hash="04224064be5e2d8356cda2f48d7b9fe1"/><file name="Zazma.php" hash="503ee28c3d7cc6508b68e55bde93aa41"/></dir></dir></dir><file name="Exception.php" hash="5ac007031082530021684f295764d034"/><dir name="Helper"><file name="Config.php" hash="4020e0fcb4e607eee17087914116ef0d"/><file name="Data.php" hash="e035466620f1a622392e2177bbefdf77"/></dir><dir name="Model"><dir name="Api"><file name="Request.php" hash="2ce21a07aefa205a0db1fb6503780746"/></dir><file name="Api.php" hash="82233e7f3ba4c7b5a369f8bc78a34373"/><dir name="Payment"><file name="Zazma.php" hash="27290de66c90a9aa4470ade00a054792"/></dir></dir><dir name="controllers"><file name="CheckoutController.php" hash="2e86baf24d12e172011b9916846b1cb9"/></dir><dir name="etc"><file name="config.xml" hash="8351a2e3f2b5e8761fc490a570d459f6"/><file name="system.xml" hash="e288302c755eef6ad996881c87a094ca"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="belvg"><dir name="zazma"><dir name="payment"><dir name="form"><file name="logo.phtml" hash="eea3f947528ef5a4aee904606bcde62b"/><file name="zazma.phtml" hash="2c71b6d614a7c20e3be111eecba1d03e"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Belvg_Zazma.xml" hash="5b81891b74606731b8487cb98ee74ecf"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|