Version Notes
First Stable Release Version 0.1.0
Download this release
Release Info
| Developer | Nikul Doshi |
| Extension | ND_Alphabank |
| Version | 0.1.0 |
| Comparing to | |
| See all releases | |
Version 0.1.0
- app/code/local/ND/Alphabank/Block/Checkout/Failure.php +24 -0
- app/code/local/ND/Alphabank/Block/Checkout/Form.php +32 -0
- app/code/local/ND/Alphabank/Block/Checkout/Redirect.php +33 -0
- app/code/local/ND/Alphabank/Block/Checkout/Response.php +29 -0
- app/code/local/ND/Alphabank/Block/Form.php +32 -0
- app/code/local/ND/Alphabank/Block/Info.php +17 -0
- app/code/local/ND/Alphabank/Block/Payment/Info.php +33 -0
- app/code/local/ND/Alphabank/Controller/Abstract.php +95 -0
- app/code/local/ND/Alphabank/Helper/Data.php +5 -0
- app/code/local/ND/Alphabank/Model/Checkout.php +291 -0
- app/code/local/ND/Alphabank/Model/Info.php +494 -0
- app/code/local/ND/Alphabank/Model/System/Config/Source/Transaction.php +32 -0
- app/code/local/ND/Alphabank/controllers/CheckoutController.php +46 -0
- app/code/local/ND/Alphabank/etc/config.xml +75 -0
- app/code/local/ND/Alphabank/etc/system.xml +123 -0
- app/code/local/ND/Alphabank/sql/migsvpc_setup/mysql4-install-0.1.0.php +21 -0
- app/design/frontend/base/default/layout/alphabank.xml +21 -0
- app/design/frontend/base/default/template/alphabank/checkout/form.phtml +19 -0
- app/design/frontend/base/default/template/alphabank/checkout/response.phtml +27 -0
- app/design/frontend/base/default/template/alphabank/form.phtml +17 -0
- app/design/frontend/base/default/template/alphabank/info.phtml +30 -0
- app/etc/modules/ND_Alphabank.xml +12 -0
- package.xml +26 -0
app/code/local/ND/Alphabank/Block/Checkout/Failure.php
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class ND_Alphabank_Block_Checkout_Failure extends Mage_Core_Block_Template
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* Return Error message
|
| 7 |
+
*
|
| 8 |
+
* @return string
|
| 9 |
+
*/
|
| 10 |
+
public function getErrorMessage ()
|
| 11 |
+
{
|
| 12 |
+
$msg = Mage::getSingleton('checkout/session')->getAlphaErrorMessage();
|
| 13 |
+
Mage::getSingleton('checkout/session')->unsMigsErrorMessage();
|
| 14 |
+
return $msg;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* Get continue shopping url
|
| 19 |
+
*/
|
| 20 |
+
public function getContinueShoppingUrl()
|
| 21 |
+
{
|
| 22 |
+
return Mage::getUrl('checkout/cart');
|
| 23 |
+
}
|
| 24 |
+
}
|
app/code/local/ND/Alphabank/Block/Checkout/Form.php
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class ND_Alphabank_Block_Checkout_Form extends Mage_Payment_Block_Form
|
| 4 |
+
{
|
| 5 |
+
protected function _construct()
|
| 6 |
+
{
|
| 7 |
+
parent::_construct();
|
| 8 |
+
$this->setTemplate('alphabank/checkout/form.phtml');
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
public function getCcAvailableTypes()
|
| 12 |
+
{
|
| 13 |
+
return array(
|
| 14 |
+
'VI'=>'VISA', // VISA (VI)
|
| 15 |
+
'MC'=>'MasterCard', // MasterCard (MC)
|
| 16 |
+
'DC'=>'Diners Club', // Diners Club (DC)
|
| 17 |
+
);
|
| 18 |
+
/*$types = $this->_getConfig()->getCcTypes();
|
| 19 |
+
if ($method = $this->getMethod()) {
|
| 20 |
+
$availableTypes = $method->getConfigData('alphabankcctypes');
|
| 21 |
+
if ($availableTypes) {
|
| 22 |
+
$availableTypes = explode(',', $availableTypes);
|
| 23 |
+
foreach ($types as $code=>$name) {
|
| 24 |
+
if (!in_array($code, $availableTypes)) {
|
| 25 |
+
unset($types[$code]);
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
return $types;*/
|
| 31 |
+
}
|
| 32 |
+
}
|
app/code/local/ND/Alphabank/Block/Checkout/Redirect.php
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class ND_Alphabank_Block_Checkout_Redirect extends Mage_Core_Block_Abstract
|
| 4 |
+
{
|
| 5 |
+
protected function _toHtml()
|
| 6 |
+
{
|
| 7 |
+
$checkout = $this->getOrder()->getPayment()->getMethodInstance();
|
| 8 |
+
if(!$checkout->getFormFields()) {
|
| 9 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('core')->__('Some of the information you have provided is incorrect, please do try again.'));
|
| 10 |
+
$url = Mage::getUrl('checkout/cart');
|
| 11 |
+
Mage::app()->getResponse()->setRedirect($url);
|
| 12 |
+
return;
|
| 13 |
+
}
|
| 14 |
+
$form = new Varien_Data_Form();
|
| 15 |
+
$form->setAction($checkout->getCheckoutUrl());
|
| 16 |
+
$form->setId('alphabank_checkout_checkout')
|
| 17 |
+
->setName('alphabank_checkout_checkout')
|
| 18 |
+
->setMethod('POST')
|
| 19 |
+
->setUseContainer(true);
|
| 20 |
+
foreach ($checkout->getFormFields() as $field=>$value) {
|
| 21 |
+
$form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value));
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
$html = '<html><body>';
|
| 25 |
+
$html.= $this->__('You will be redirected to Alpha e-Commerce website in a few seconds ...');
|
| 26 |
+
$html.= $form->toHtml();
|
| 27 |
+
$html.= '<script type="text/javascript">document.getElementById("alphabank_checkout_checkout").submit();</script>';
|
| 28 |
+
$html.= '</body></html>';
|
| 29 |
+
$html = str_replace('<div><input name="form_key" type="hidden" value="'.Mage::getSingleton('core/session')->getFormKey().'" /></div>','',$html);
|
| 30 |
+
|
| 31 |
+
return $html;
|
| 32 |
+
}
|
| 33 |
+
}
|
app/code/local/ND/Alphabank/Block/Checkout/Response.php
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class ND_Alphabank_Block_Checkout_Response extends Mage_Core_Block_Template
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Return Error message
|
| 6 |
+
*
|
| 7 |
+
* @return string
|
| 8 |
+
*/
|
| 9 |
+
protected function _construct()
|
| 10 |
+
{
|
| 11 |
+
parent::_construct();
|
| 12 |
+
$this->setTemplate('alphabank/checkout/response.phtml');
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
public function getErrorMessage ()
|
| 16 |
+
{
|
| 17 |
+
$msg = Mage::getSingleton('checkout/session')->getAlphaErrorMessage();
|
| 18 |
+
Mage::getSingleton('checkout/session')->unsMigsErrorMessage();
|
| 19 |
+
return $msg;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Get continue shopping url
|
| 24 |
+
*/
|
| 25 |
+
public function getContinueShoppingUrl()
|
| 26 |
+
{
|
| 27 |
+
return Mage::getUrl('checkout/cart');
|
| 28 |
+
}
|
| 29 |
+
}
|
app/code/local/ND/Alphabank/Block/Form.php
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class ND_Alphabank_Block_Form extends Mage_Payment_Block_Form_Cc
|
| 4 |
+
{
|
| 5 |
+
protected function _construct()
|
| 6 |
+
{
|
| 7 |
+
parent::_construct();
|
| 8 |
+
$this->setTemplate('alphabank/form.phtml');
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
public function getCcAvailableTypes()
|
| 12 |
+
{
|
| 13 |
+
return array(
|
| 14 |
+
'VI'=>'VISA', // VISA (VI)
|
| 15 |
+
'MC'=>'MasterCard', // MasterCard (MC)
|
| 16 |
+
'DC'=>'Diners Club', // Diners Club (DC)
|
| 17 |
+
);
|
| 18 |
+
$types = $this->_getConfig()->getCcTypes();
|
| 19 |
+
if ($method = $this->getMethod()) {
|
| 20 |
+
$availableTypes = $method->getConfigData('alphabankcctypes');
|
| 21 |
+
if ($availableTypes) {
|
| 22 |
+
$availableTypes = explode(',', $availableTypes);
|
| 23 |
+
foreach ($types as $code=>$name) {
|
| 24 |
+
if (!in_array($code, $availableTypes)) {
|
| 25 |
+
unset($types[$code]);
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
return $types;
|
| 31 |
+
}
|
| 32 |
+
}
|
app/code/local/ND/Alphabank/Block/Info.php
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class ND_Alphabank_Block_Info extends Mage_Payment_Block_Info_Cc
|
| 4 |
+
{
|
| 5 |
+
protected function _construct()
|
| 6 |
+
{
|
| 7 |
+
parent::_construct();
|
| 8 |
+
$this->setTemplate('alphabank/info.phtml');
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
public function toPdf()
|
| 12 |
+
{
|
| 13 |
+
$this->setTemplate('alphabank/pdf/info.phtml');
|
| 14 |
+
return $this->toHtml();
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
}
|
app/code/local/ND/Alphabank/Block/Payment/Info.php
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class ND_Alphabank_Block_Payment_Info extends Mage_Payment_Block_Info_Cc
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* Don't show CC type for non-CC methods
|
| 7 |
+
*
|
| 8 |
+
* @return string|null
|
| 9 |
+
*/
|
| 10 |
+
public function getCcTypeName()
|
| 11 |
+
{
|
| 12 |
+
return parent::getCcTypeName();
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* Prepare Alphabank-specific payment information
|
| 17 |
+
*
|
| 18 |
+
* @param Varien_Object|array $transport
|
| 19 |
+
* return Varien_Object
|
| 20 |
+
*/
|
| 21 |
+
protected function _prepareSpecificInformation($transport = null)
|
| 22 |
+
{
|
| 23 |
+
$transport = parent::_prepareSpecificInformation($transport);
|
| 24 |
+
$payment = $this->getInfo();
|
| 25 |
+
$vpcInfo = Mage::getModel('alphabank/info');
|
| 26 |
+
if (!$this->getIsSecureMode()) {
|
| 27 |
+
$info = $vpcInfo->getPaymentInfo($payment, true);
|
| 28 |
+
} else {
|
| 29 |
+
$info = $vpcInfo->getPublicPaymentInfo($payment, true);
|
| 30 |
+
}
|
| 31 |
+
return $transport->addData($info);
|
| 32 |
+
}
|
| 33 |
+
}
|
app/code/local/ND/Alphabank/Controller/Abstract.php
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
abstract class ND_Alphabank_Controller_Abstract extends Mage_Core_Controller_Front_Action
|
| 3 |
+
{
|
| 4 |
+
protected function _expireAjax()
|
| 5 |
+
{
|
| 6 |
+
if (!$this->getCheckout()->getQuote()->hasItems()) {
|
| 7 |
+
$this->getResponse()->setHeader('HTTP/1.1','403 Session Expired');
|
| 8 |
+
exit;
|
| 9 |
+
}
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* Redirect Block
|
| 14 |
+
* need to be redeclared
|
| 15 |
+
*/
|
| 16 |
+
protected $_redirectBlockType;
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* Get singleton of Checkout Session Model
|
| 20 |
+
*
|
| 21 |
+
* @return Mage_Checkout_Model_Session
|
| 22 |
+
*/
|
| 23 |
+
public function getCheckout()
|
| 24 |
+
{
|
| 25 |
+
return Mage::getSingleton('checkout/session');
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* when customer select ND payment method
|
| 30 |
+
*/
|
| 31 |
+
public function redirectAction()
|
| 32 |
+
{
|
| 33 |
+
$session = $this->getCheckout();
|
| 34 |
+
$session->setMigsQuoteId($session->getQuoteId());
|
| 35 |
+
$session->setMigsRealOrderId($session->getLastRealOrderId());
|
| 36 |
+
|
| 37 |
+
$order = Mage::getModel('sales/order');
|
| 38 |
+
$order->loadByIncrementId($session->getLastRealOrderId());
|
| 39 |
+
$order->addStatusToHistory($order->getStatus(), Mage::helper('core')->__('Customer was redirected to Alphabank e-Commerce.'));
|
| 40 |
+
$order->save();
|
| 41 |
+
|
| 42 |
+
$this->getResponse()->setBody(
|
| 43 |
+
$this->getLayout()
|
| 44 |
+
->createBlock($this->_redirectBlockType)
|
| 45 |
+
->setOrder($order)
|
| 46 |
+
->toHtml()
|
| 47 |
+
);
|
| 48 |
+
|
| 49 |
+
$session->unsQuoteId();
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
/**
|
| 53 |
+
* MIGS returns POST variables to this action
|
| 54 |
+
*/
|
| 55 |
+
public function successAction()
|
| 56 |
+
{
|
| 57 |
+
$status = $this->_checkReturnedPost();
|
| 58 |
+
|
| 59 |
+
$session = $this->getCheckout();
|
| 60 |
+
|
| 61 |
+
$session->unsMigsRealOrderId();
|
| 62 |
+
$session->setQuoteId($session->getMigsQuoteId(true));
|
| 63 |
+
$session->getQuote()->setIsActive(false)->save();
|
| 64 |
+
|
| 65 |
+
$order = Mage::getModel('sales/order');
|
| 66 |
+
$order->load($this->getCheckout()->getLastOrderId());
|
| 67 |
+
if($order->getId()) {
|
| 68 |
+
$order->sendNewOrderEmail();
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
if ($status) {
|
| 72 |
+
$this->_redirect('checkout/onepage/success');
|
| 73 |
+
} else {
|
| 74 |
+
$this->_redirect('*/*/failure');
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* Display failure page if error
|
| 80 |
+
*
|
| 81 |
+
*/
|
| 82 |
+
public function failureAction()
|
| 83 |
+
{
|
| 84 |
+
if (!$this->getCheckout()->getAlphaErrorMessage()) {
|
| 85 |
+
$this->norouteAction();
|
| 86 |
+
return;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
//$this->getCheckout()->clear();
|
| 90 |
+
|
| 91 |
+
$this->loadLayout();
|
| 92 |
+
$this->renderLayout();
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
}
|
app/code/local/ND/Alphabank/Helper/Data.php
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class ND_Alphabank_Helper_Data extends Mage_Core_Helper_Abstract
|
| 4 |
+
{
|
| 5 |
+
}
|
app/code/local/ND/Alphabank/Model/Checkout.php
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class ND_Alphabank_Model_Checkout extends Mage_Payment_Model_Method_Abstract
|
| 4 |
+
{
|
| 5 |
+
protected $_code = 'alphabank_checkout';
|
| 6 |
+
|
| 7 |
+
protected $_isGateway = false;
|
| 8 |
+
protected $_canAuthorize = false;
|
| 9 |
+
protected $_canCapture = true;
|
| 10 |
+
protected $_canCapturePartial = false;
|
| 11 |
+
protected $_canRefund = false;
|
| 12 |
+
protected $_canVoid = false;
|
| 13 |
+
protected $_canUseInternal = false;
|
| 14 |
+
protected $_canUseCheckout = true;
|
| 15 |
+
protected $_canUseForMultishipping = false;
|
| 16 |
+
|
| 17 |
+
protected $_formBlockType = 'alphabank/checkout_form';
|
| 18 |
+
protected $_paymentMethod = 'checkout';
|
| 19 |
+
protected $_infoBlockType = 'alphabank/payment_info';
|
| 20 |
+
|
| 21 |
+
protected $_order;
|
| 22 |
+
|
| 23 |
+
protected $_paymentUrl = '';
|
| 24 |
+
|
| 25 |
+
public function getOrder()
|
| 26 |
+
{
|
| 27 |
+
if (!$this->_order) {
|
| 28 |
+
$paymentInfo = $this->getInfoInstance();
|
| 29 |
+
$this->_order = Mage::getModel('sales/order')
|
| 30 |
+
->loadByIncrementId($paymentInfo->getOrder()->getRealOrderId());
|
| 31 |
+
}
|
| 32 |
+
return $this->_order;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
public function getMerchantId()
|
| 36 |
+
{
|
| 37 |
+
$merchant_id = Mage::getStoreConfig('payment/' . $this->getCode() . '/merchant_id');
|
| 38 |
+
return $merchant_id;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
public function getSecretKey()
|
| 42 |
+
{
|
| 43 |
+
$secret_key = Mage::getStoreConfig('payment/' . $this->getCode() . '/secret_key');
|
| 44 |
+
return $secret_key;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
public function getTransactionType()
|
| 48 |
+
{
|
| 49 |
+
$transaction_type = Mage::getStoreConfig('payment/' . $this->getCode() . '/transaction_type');
|
| 50 |
+
return $transaction_type;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
public function validate()
|
| 54 |
+
{
|
| 55 |
+
$paymentInfo = $this->getInfoInstance();
|
| 56 |
+
if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
|
| 57 |
+
$currency_code = $paymentInfo->getOrder()->getBaseCurrencyCode();
|
| 58 |
+
} else {
|
| 59 |
+
$currency_code = $paymentInfo->getQuote()->getBaseCurrencyCode();
|
| 60 |
+
}
|
| 61 |
+
if($paymentInfo->getLang()!='') {
|
| 62 |
+
$paymentInfo->setAdditionalInformation('lang',$paymentInfo->getLang());
|
| 63 |
+
//Mage::throwException($paymentInfo->getLang());
|
| 64 |
+
}
|
| 65 |
+
return true;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
public function getOrderPlaceRedirectUrl()
|
| 69 |
+
{
|
| 70 |
+
$url = Mage::getUrl('alphabank/' . $this->_paymentMethod . '/redirect');
|
| 71 |
+
if(!$url) {
|
| 72 |
+
$url = 'https://alpha.test.modirum.com/vpos/shophandlermpi';
|
| 73 |
+
}
|
| 74 |
+
return $url;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
public function isTestMode()
|
| 78 |
+
{
|
| 79 |
+
return Mage::getStoreConfig('payment/' . $this->getCode() . '/test_mode');
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
public function getCheckoutUrl()
|
| 83 |
+
{
|
| 84 |
+
if($this->isTestMode()) {
|
| 85 |
+
$url = Mage::getStoreConfig('payment/' . $this->getCode() . '/api_test_url');
|
| 86 |
+
if(!$url) {
|
| 87 |
+
$url = 'https://alpha.test.modirum.com/vpos/shophandlermpi';
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
else {
|
| 91 |
+
$url = Mage::getStoreConfig('payment/' . $this->getCode() . '/api_url');
|
| 92 |
+
if(!$url) {
|
| 93 |
+
$url = 'https://alpha.modirum.com/vpos/shophandlermpi';
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
return $url;
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
public function getFormFields()
|
| 100 |
+
{
|
| 101 |
+
$form_data = "";
|
| 102 |
+
$form_data_array = array();
|
| 103 |
+
$fieldsArr = array();
|
| 104 |
+
$paymentInfo = $this->getInfoInstance();
|
| 105 |
+
$shippingAddress = $this->getOrder()->getShippingAddress();
|
| 106 |
+
$billingAddress = $this->getOrder()->getBillingAddress();
|
| 107 |
+
$additional_information = $paymentInfo->getAdditionalInformation();
|
| 108 |
+
$fieldsArr['mid'] = $this->getMerchantId();
|
| 109 |
+
$form_data_array[1] = $fieldsArr['mid'] ; //Req
|
| 110 |
+
$fieldsArr['lang'] = (!empty($additional_information['lang']))?$additional_information['lang']:'';
|
| 111 |
+
$form_data_array[2] = $fieldsArr['lang']; //Opt
|
| 112 |
+
$fieldsArr['deviceCategory'] = "";
|
| 113 |
+
$form_data_array[3] = $fieldsArr['deviceCategory']; //Opt
|
| 114 |
+
$fieldsArr['orderid'] = $paymentInfo->getOrder()->getRealOrderId();
|
| 115 |
+
$form_data_array[4] = $fieldsArr['orderid']; //Req
|
| 116 |
+
$fieldsArr['orderDesc'] = 'Order by '.$billingAddress->getFirstname().' '.$billingAddress->getLastname();
|
| 117 |
+
$form_data_array[5] = $fieldsArr['orderDesc']; //Opt
|
| 118 |
+
$fieldsArr['orderAmount'] = $this->getOrder()->getGrandTotal();
|
| 119 |
+
$form_data_array[6] = $fieldsArr['orderAmount']; //Req
|
| 120 |
+
$fieldsArr['currency'] = $paymentInfo->getOrder()->getOrderCurrencyCode();
|
| 121 |
+
$form_data_array[7] = $fieldsArr['currency']; //Req
|
| 122 |
+
$fieldsArr['payerEmail'] = $billingAddress->getEmail();
|
| 123 |
+
$form_data_array[8] = $fieldsArr['payerEmail']; //Req
|
| 124 |
+
$fieldsArr['payerPhone'] = $billingAddress->getTelephone();
|
| 125 |
+
$form_data_array[9] = $fieldsArr['payerPhone']; //Opt
|
| 126 |
+
$fieldsArr['billCountry'] = $billingAddress->getCountryId();
|
| 127 |
+
$form_data_array[10] = $fieldsArr['billCountry']; //Opt
|
| 128 |
+
$fieldsArr['billState'] = ($billingAddress->getRegionId()!='')?$billingAddress->getRegionId():$billingAddress->getRegion();
|
| 129 |
+
$form_data_array[11] = $fieldsArr['billState']; //Opt
|
| 130 |
+
$fieldsArr['billZip'] = $billingAddress->getPostcode();
|
| 131 |
+
$form_data_array[12] = $fieldsArr['billZip']; //Opt
|
| 132 |
+
$fieldsArr['billCity'] = $billingAddress->getCity();
|
| 133 |
+
$form_data_array[13] = $fieldsArr['billCity']; //Opt
|
| 134 |
+
$fieldsArr['billAddress'] = (count($billingAddress->getStreet()))?implode(", ",$billingAddress->getStreet()):'';
|
| 135 |
+
$form_data_array[14] = $fieldsArr['billAddress']; //Opt
|
| 136 |
+
$fieldsArr['weight'] = '';
|
| 137 |
+
$form_data_array[15] = $fieldsArr['weight']; //Opt
|
| 138 |
+
$fieldsArr['dimensions'] = '';
|
| 139 |
+
$form_data_array[16] = $fieldsArr['dimensions']; //Opt
|
| 140 |
+
$fieldsArr['shipCountry'] = $shippingAddress->getCountryId();
|
| 141 |
+
$form_data_array[17] = $fieldsArr['shipCountry']; //Opt
|
| 142 |
+
$fieldsArr['shipState'] = ($shippingAddress->getRegionId()!='')?$shippingAddress->getRegionId():$shippingAddress->getRegion();
|
| 143 |
+
$form_data_array[18] = $fieldsArr['shipState']; //Opt
|
| 144 |
+
$fieldsArr['shipZip'] = $shippingAddress->getPostcode();
|
| 145 |
+
$form_data_array[19] = $fieldsArr['shipZip']; //Opt
|
| 146 |
+
$fieldsArr['shipCity'] = $shippingAddress->getCity();
|
| 147 |
+
$form_data_array[20] = $fieldsArr['shipCity']; //Opt
|
| 148 |
+
$fieldsArr['shipAddress'] = (count($shippingAddress->getStreet()))?implode(", ",$shippingAddress->getStreet()):'';
|
| 149 |
+
$form_data_array[21] = $fieldsArr['shipAddress']; //Opt
|
| 150 |
+
$fieldsArr['addFraudScore'] = '';
|
| 151 |
+
$form_data_array[22] = $fieldsArr['addFraudScore']; //Opt
|
| 152 |
+
$fieldsArr['maxPayRetries'] = '';
|
| 153 |
+
$form_data_array[23] = $fieldsArr['maxPayRetries']; //Opt
|
| 154 |
+
$fieldsArr['reject3dsU'] = '';
|
| 155 |
+
$form_data_array[24] = $fieldsArr['reject3dsU']; //Opt
|
| 156 |
+
$fieldsArr['payMethod'] = '';
|
| 157 |
+
$form_data_array[25] = $fieldsArr['payMethod']; //Opt
|
| 158 |
+
$fieldsArr['trType'] = $this->getTransactionType();
|
| 159 |
+
$form_data_array[26] = $fieldsArr['trType']; //Opt
|
| 160 |
+
$fieldsArr['extInstallmentoffset'] = '';
|
| 161 |
+
$form_data_array[27] = $fieldsArr['extInstallmentoffset']; //Opt
|
| 162 |
+
$fieldsArr['extInstallmentperiod'] = '';
|
| 163 |
+
$form_data_array[28] = $fieldsArr['extInstallmentperiod']; //Opt
|
| 164 |
+
$fieldsArr['extRecurringfrequency'] = '';
|
| 165 |
+
$form_data_array[29] = $fieldsArr['extRecurringfrequency']; //Opt
|
| 166 |
+
$fieldsArr['extRecurringenddate'] = '';
|
| 167 |
+
$form_data_array[30] = $fieldsArr['extRecurringenddate']; //Opt
|
| 168 |
+
$fieldsArr['blockScore'] = '';
|
| 169 |
+
$form_data_array[31] = $fieldsArr['blockScore']; //Opt
|
| 170 |
+
$fieldsArr['cssUrl'] = '';
|
| 171 |
+
$form_data_array[32] = $fieldsArr['cssUrl']; //Opt
|
| 172 |
+
$fieldsArr['confirmUrl'] = Mage::getUrl('alphabank/' . $this->_paymentMethod . '/response', array('_secure' => true));
|
| 173 |
+
$form_data_array[33] = $fieldsArr['confirmUrl']; //Req
|
| 174 |
+
$fieldsArr['cancelUrl'] = Mage::getUrl('alphabank/' . $this->_paymentMethod . '/response', array('_secure' => true));
|
| 175 |
+
$form_data_array[34] = $fieldsArr['cancelUrl']; //Req
|
| 176 |
+
$fieldsArr['var1'] = '';
|
| 177 |
+
$form_data_array[35] = $fieldsArr['var1'];
|
| 178 |
+
$fieldsArr['var2'] = '';
|
| 179 |
+
$form_data_array[36] = $fieldsArr['var2'];
|
| 180 |
+
$fieldsArr['var3'] = '';
|
| 181 |
+
$form_data_array[37] = $fieldsArr['var3'];
|
| 182 |
+
$fieldsArr['var4'] = '';
|
| 183 |
+
$form_data_array[38] = $fieldsArr['var4'];
|
| 184 |
+
$fieldsArr['var5'] = '';
|
| 185 |
+
$form_data_array[39] = $fieldsArr['var5'];
|
| 186 |
+
$form_secret = $this->getSecretKey();
|
| 187 |
+
$form_data_array[40] = $form_secret; //Req
|
| 188 |
+
|
| 189 |
+
$form_data = implode("", $form_data_array);
|
| 190 |
+
|
| 191 |
+
$digest = base64_encode(sha1($form_data,true));
|
| 192 |
+
|
| 193 |
+
$fieldsArr['digest'] = $digest;
|
| 194 |
+
|
| 195 |
+
$debugData = array(
|
| 196 |
+
'request' => $fieldsArr
|
| 197 |
+
);
|
| 198 |
+
$this->_debug($debugData);
|
| 199 |
+
|
| 200 |
+
return $fieldsArr;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
/**
|
| 204 |
+
* Get debug flag
|
| 205 |
+
*
|
| 206 |
+
* @return string
|
| 207 |
+
*/
|
| 208 |
+
public function getDebug()
|
| 209 |
+
{
|
| 210 |
+
return Mage::getStoreConfig('payment/' . $this->getCode() . '/debug');
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
public function capture(Varien_Object $payment, $amount)
|
| 214 |
+
{
|
| 215 |
+
$payment->setStatus(self::STATUS_APPROVED)
|
| 216 |
+
->setLastTransId($this->getTransactionId());
|
| 217 |
+
|
| 218 |
+
return $this;
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
public function cancel(Varien_Object $payment)
|
| 222 |
+
{
|
| 223 |
+
$payment->setStatus(self::STATUS_DECLINED)
|
| 224 |
+
->setLastTransId($this->getTransactionId());
|
| 225 |
+
|
| 226 |
+
return $this;
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
public function getRedirectBlockType()
|
| 230 |
+
{
|
| 231 |
+
return $this->_redirectBlockType;
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
public function assignData($data)
|
| 235 |
+
{
|
| 236 |
+
//Mage::throwException(implode(',',$data));
|
| 237 |
+
$result = parent::assignData($data);
|
| 238 |
+
return $result;
|
| 239 |
+
}
|
| 240 |
+
/**
|
| 241 |
+
* Return payment method type string
|
| 242 |
+
*
|
| 243 |
+
* @return string
|
| 244 |
+
*/
|
| 245 |
+
public function getPaymentMethodType()
|
| 246 |
+
{
|
| 247 |
+
return $this->_paymentMethod;
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
public function afterSuccessOrder($response)
|
| 251 |
+
{
|
| 252 |
+
$debugData = array(
|
| 253 |
+
'response' => $response
|
| 254 |
+
);
|
| 255 |
+
$this->_debug($debugData);
|
| 256 |
+
$order = Mage::getModel('sales/order');
|
| 257 |
+
$order->loadByIncrementId($response['orderid']);
|
| 258 |
+
$paymentInst = $order->getPayment()->getMethodInstance();
|
| 259 |
+
$paymentInst->setStatus(self::STATUS_APPROVED)
|
| 260 |
+
->setLastTransId($response['txId'])
|
| 261 |
+
->setTransactionId($response['txId'])
|
| 262 |
+
->setAdditionalInformation(ND_Alphabank_Model_Info::PAYMENT_REFERENCE,$response['paymentRef'])
|
| 263 |
+
->setAdditionalInformation(ND_Alphabank_Model_Info::PAYMENT_METHOD,$response['payMethod'])
|
| 264 |
+
->setAdditionalInformation(ND_Alphabank_Model_Info::RISK_SCORE,$response['riskScore'])
|
| 265 |
+
->setAdditionalInformation(ND_Alphabank_Model_Info::MESSAGE,$response['message']);
|
| 266 |
+
|
| 267 |
+
$order->sendNewOrderEmail();
|
| 268 |
+
if ($order->canInvoice()) {
|
| 269 |
+
$invoice = $order->prepareInvoice();
|
| 270 |
+
|
| 271 |
+
$invoice->register()->capture();
|
| 272 |
+
Mage::getModel('core/resource_transaction')
|
| 273 |
+
->addObject($invoice)
|
| 274 |
+
->addObject($invoice->getOrder())
|
| 275 |
+
->save();
|
| 276 |
+
}
|
| 277 |
+
$transaction = Mage::getModel('sales/order_payment_transaction');
|
| 278 |
+
$transaction->setTxnId($response['txId']);
|
| 279 |
+
$order->getPayment()->setAdditionalInformation(ND_Alphabank_Model_Info::PAYMENT_REFERENCE,$response['paymentRef'])
|
| 280 |
+
->setAdditionalInformation(ND_Alphabank_Model_Info::PAYMENT_METHOD,$response['payMethod'])
|
| 281 |
+
->setAdditionalInformation(ND_Alphabank_Model_Info::RISK_SCORE,$response['riskScore'])
|
| 282 |
+
->setAdditionalInformation(ND_Alphabank_Model_Info::MESSAGE,$response['message']);
|
| 283 |
+
$transaction->setOrderPaymentObject($order->getPayment())
|
| 284 |
+
->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
|
| 285 |
+
$transaction->save();
|
| 286 |
+
$order_status = Mage::helper('core')->__('Payment is successful.');
|
| 287 |
+
|
| 288 |
+
$order->addStatusToHistory(Mage_Sales_Model_Order::STATE_PROCESSING, $order_status);
|
| 289 |
+
$order->save();
|
| 290 |
+
}
|
| 291 |
+
}
|
app/code/local/ND/Alphabank/Model/Info.php
ADDED
|
@@ -0,0 +1,494 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class ND_Alphabank_Model_Info
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Cross-models public exchange keys
|
| 6 |
+
*
|
| 7 |
+
* @var string
|
| 8 |
+
*/
|
| 9 |
+
const PAYMENT_REFERENCE = 'paymentRef';
|
| 10 |
+
const PAYMENT_METHOD = 'payMethod';
|
| 11 |
+
const RISK_SCORE = 'riskScore';
|
| 12 |
+
const MESSAGE = 'message';
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* All payment information map
|
| 16 |
+
*
|
| 17 |
+
* @var array
|
| 18 |
+
*/
|
| 19 |
+
protected $_paymentMap = array(
|
| 20 |
+
self::PAYMENT_REFERENCE => 'paymentRef',
|
| 21 |
+
self::PAYMENT_METHOD => 'payMethod',
|
| 22 |
+
self::RISK_SCORE => 'riskScore',
|
| 23 |
+
self::MESSAGE => 'message',
|
| 24 |
+
);
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* Alphabank payment status possible values
|
| 28 |
+
*
|
| 29 |
+
* @var string
|
| 30 |
+
*/
|
| 31 |
+
const PAYMENTSTATUS_AUTHORIZED = 'AUTHORIZED';
|
| 32 |
+
const PAYMENTSTATUS_CAPTURED = 'CAPTURED';
|
| 33 |
+
const PAYMENTSTATUS_REFUSED = 'REFUSED';
|
| 34 |
+
const PAYMENTSTATUS_CANCELED = 'CANCELED';
|
| 35 |
+
|
| 36 |
+
/**
|
| 37 |
+
* Map of payment information available to customer
|
| 38 |
+
*
|
| 39 |
+
* @var array
|
| 40 |
+
*/
|
| 41 |
+
protected $_paymentPublicMap = array(
|
| 42 |
+
//'',
|
| 43 |
+
);
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* Rendered payment map cache
|
| 47 |
+
*
|
| 48 |
+
* @var array
|
| 49 |
+
*/
|
| 50 |
+
protected $_paymentMapFull = array();
|
| 51 |
+
|
| 52 |
+
/**
|
| 53 |
+
* All available payment info getter
|
| 54 |
+
*
|
| 55 |
+
* @param Mage_Payment_Model_Info $payment
|
| 56 |
+
* @param bool $labelValuesOnly
|
| 57 |
+
* @return array
|
| 58 |
+
*/
|
| 59 |
+
public function getPaymentInfo(Mage_Payment_Model_Info $payment, $labelValuesOnly = false)
|
| 60 |
+
{
|
| 61 |
+
// collect alphabank-specific info
|
| 62 |
+
$result = $this->_getFullInfo(array_values($this->_paymentMap), $payment, $labelValuesOnly);
|
| 63 |
+
|
| 64 |
+
// add last_trans_id
|
| 65 |
+
$label = Mage::helper('payment')->__('Last Transaction ID');
|
| 66 |
+
$value = $payment->getLastTransId();
|
| 67 |
+
if ($labelValuesOnly) {
|
| 68 |
+
$result[$label] = $value;
|
| 69 |
+
} else {
|
| 70 |
+
$result['last_trans_id'] = array('label' => $label, 'value' => $value);
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
return $result;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
* Public payment info getter
|
| 78 |
+
*
|
| 79 |
+
* @param Mage_Payment_Model_Info $payment
|
| 80 |
+
* @param bool $labelValuesOnly
|
| 81 |
+
* @return array
|
| 82 |
+
*/
|
| 83 |
+
public function getPublicPaymentInfo(Mage_Payment_Model_Info $payment, $labelValuesOnly = false)
|
| 84 |
+
{
|
| 85 |
+
return $this->_getFullInfo($this->_paymentPublicMap, $payment, $labelValuesOnly);
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* Grab data from source and map it into payment
|
| 90 |
+
*
|
| 91 |
+
* @param array|Varien_Object|callback $from
|
| 92 |
+
* @param Mage_Payment_Model_Info $payment
|
| 93 |
+
*/
|
| 94 |
+
public function importToPayment($from, Mage_Payment_Model_Info $payment)
|
| 95 |
+
{
|
| 96 |
+
$fullMap = array_merge($this->_paymentMap, $this->_systemMap);
|
| 97 |
+
if (is_object($from)) {
|
| 98 |
+
$from = array($from, 'getDataUsingMethod');
|
| 99 |
+
}
|
| 100 |
+
Varien_Object_Mapper::accumulateByMap($from, array($payment, 'setAdditionalInformation'), $fullMap);
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
/**
|
| 104 |
+
* Grab data from payment and map it into target
|
| 105 |
+
*
|
| 106 |
+
* @param Mage_Payment_Model_Info $payment
|
| 107 |
+
* @param array|Varien_Object|callback $to
|
| 108 |
+
* @param array $map
|
| 109 |
+
* @return array|Varien_Object
|
| 110 |
+
*/
|
| 111 |
+
public function &exportFromPayment(Mage_Payment_Model_Info $payment, $to, array $map = null)
|
| 112 |
+
{
|
| 113 |
+
$fullMap = array_merge($this->_paymentMap, $this->_systemMap);
|
| 114 |
+
Varien_Object_Mapper::accumulateByMap(array($payment, 'getAdditionalInformation'), $to,
|
| 115 |
+
$map ? $map : array_flip($fullMap)
|
| 116 |
+
);
|
| 117 |
+
return $to;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
/**
|
| 121 |
+
* Check whether the payment is in review state
|
| 122 |
+
*
|
| 123 |
+
* @param Mage_Payment_Model_Info $payment
|
| 124 |
+
* @return bool
|
| 125 |
+
*/
|
| 126 |
+
public static function isPaymentReviewRequired(Mage_Payment_Model_Info $payment)
|
| 127 |
+
{
|
| 128 |
+
$paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
|
| 129 |
+
if (self::PAYMENTSTATUS_PENDING === $paymentStatus) {
|
| 130 |
+
$pendingReason = $payment->getAdditionalInformation(self::PENDING_REASON_GLOBAL);
|
| 131 |
+
return !in_array($pendingReason, array('authorization', 'order'));
|
| 132 |
+
}
|
| 133 |
+
return false;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
/**
|
| 137 |
+
* Check whether fraud order review detected and can be reviewed
|
| 138 |
+
*
|
| 139 |
+
* @param Mage_Payment_Model_Info $payment
|
| 140 |
+
* @return bool
|
| 141 |
+
*/
|
| 142 |
+
public static function isFraudReviewAllowed(Mage_Payment_Model_Info $payment)
|
| 143 |
+
{
|
| 144 |
+
return self::isPaymentReviewRequired($payment)
|
| 145 |
+
&& 1 == $payment->getAdditionalInformation(self::IS_FRAUD_GLOBAL);
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
/**
|
| 149 |
+
* Check whether the payment is completed
|
| 150 |
+
*
|
| 151 |
+
* @param Mage_Payment_Model_Info $payment
|
| 152 |
+
* @return bool
|
| 153 |
+
*/
|
| 154 |
+
public static function isPaymentCompleted(Mage_Payment_Model_Info $payment)
|
| 155 |
+
{
|
| 156 |
+
$paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
|
| 157 |
+
return self::PAYMENTSTATUS_COMPLETED === $paymentStatus;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
/**
|
| 161 |
+
* Check whether the payment was processed successfully
|
| 162 |
+
*
|
| 163 |
+
* @param Mage_Payment_Model_Info $payment
|
| 164 |
+
* @return bool
|
| 165 |
+
*/
|
| 166 |
+
public static function isPaymentSuccessful(Mage_Payment_Model_Info $payment)
|
| 167 |
+
{
|
| 168 |
+
$paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
|
| 169 |
+
if (in_array($paymentStatus, array(
|
| 170 |
+
self::PAYMENTSTATUS_COMPLETED, self::PAYMENTSTATUS_INPROGRESS, self::PAYMENTSTATUS_REFUNDED,
|
| 171 |
+
self::PAYMENTSTATUS_REFUNDEDPART, self::PAYMENTSTATUS_UNREVERSED, self::PAYMENTSTATUS_PROCESSED,
|
| 172 |
+
))) {
|
| 173 |
+
return true;
|
| 174 |
+
}
|
| 175 |
+
$pendingReason = $payment->getAdditionalInformation(self::PENDING_REASON_GLOBAL);
|
| 176 |
+
return self::PAYMENTSTATUS_PENDING === $paymentStatus
|
| 177 |
+
&& in_array($pendingReason, array('authorization', 'order'));
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
/**
|
| 181 |
+
* Check whether the payment was processed unsuccessfully or failed
|
| 182 |
+
*
|
| 183 |
+
* @param Mage_Payment_Model_Info $payment
|
| 184 |
+
* @return bool
|
| 185 |
+
*/
|
| 186 |
+
public static function isPaymentFailed(Mage_Payment_Model_Info $payment)
|
| 187 |
+
{
|
| 188 |
+
$paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
|
| 189 |
+
return in_array($paymentStatus, array(
|
| 190 |
+
self::PAYMENTSTATUS_REJECTED
|
| 191 |
+
));
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
/**
|
| 195 |
+
* Explain pending payment reason code
|
| 196 |
+
*
|
| 197 |
+
* @param string $code
|
| 198 |
+
* @return string
|
| 199 |
+
*/
|
| 200 |
+
public static function explainPendingReason($code)
|
| 201 |
+
{
|
| 202 |
+
switch ($code) {
|
| 203 |
+
case 'address':
|
| 204 |
+
return Mage::helper('payment')->__('Customer did not include a confirmed address.');
|
| 205 |
+
case 'authorization':
|
| 206 |
+
case 'order':
|
| 207 |
+
return Mage::helper('payment')->__('The payment is authorized but not settled.');
|
| 208 |
+
case 'echeck':
|
| 209 |
+
return Mage::helper('payment')->__('The payment eCheck is not yet cleared.');
|
| 210 |
+
case 'intl':
|
| 211 |
+
return Mage::helper('payment')->__('Merchant holds a non-U.S. account and does not have a withdrawal mechanism.');
|
| 212 |
+
case 'multi-currency': // break is intentionally omitted
|
| 213 |
+
case 'multi_currency': // break is intentionally omitted
|
| 214 |
+
case 'multicurrency':
|
| 215 |
+
return Mage::helper('payment')->__('The payment curency does not match any of the merchant\'s balances currency.');
|
| 216 |
+
case 'paymentreview':
|
| 217 |
+
return Mage::helper('payment')->__('The payment is pending while it is being reviewed by Alphabank for risk.');
|
| 218 |
+
case 'unilateral':
|
| 219 |
+
return Mage::helper('payment')->__('The payment is pending because it was made to an email address that is not yet registered or confirmed.');
|
| 220 |
+
case 'verify':
|
| 221 |
+
return Mage::helper('payment')->__('The merchant account is not yet verified.');
|
| 222 |
+
case 'upgrade':
|
| 223 |
+
return Mage::helper('payment')->__('The payment was made via credit card. In order to receive funds merchant must upgrade account to Business or Premier status.');
|
| 224 |
+
case 'none': // break is intentionally omitted
|
| 225 |
+
case 'other': // break is intentionally omitted
|
| 226 |
+
default:
|
| 227 |
+
return Mage::helper('payment')->__('Unknown reason. Please contact Alphabank customer service.');
|
| 228 |
+
}
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
/**
|
| 232 |
+
* Explain the refund or chargeback reason code
|
| 233 |
+
*
|
| 234 |
+
* @param $code
|
| 235 |
+
* @return string
|
| 236 |
+
*/
|
| 237 |
+
public static function explainReasonCode($code)
|
| 238 |
+
{
|
| 239 |
+
switch ($code) {
|
| 240 |
+
case 'chargeback':
|
| 241 |
+
return Mage::helper('payment')->__('Chargeback by customer.');
|
| 242 |
+
case 'guarantee':
|
| 243 |
+
return Mage::helper('payment')->__('Customer triggered a money-back guarantee.');
|
| 244 |
+
case 'buyer-complaint':
|
| 245 |
+
return Mage::helper('payment')->__('Customer complaint.');
|
| 246 |
+
case 'refund':
|
| 247 |
+
return Mage::helper('payment')->__('Refund issued by merchant.');
|
| 248 |
+
case 'adjustment_reversal':
|
| 249 |
+
return Mage::helper('payment')->__('Reversal of an adjustment.');
|
| 250 |
+
case 'chargeback_reimbursement':
|
| 251 |
+
return Mage::helper('payment')->__('Reimbursement for a chargeback.');
|
| 252 |
+
case 'chargeback_settlement':
|
| 253 |
+
return Mage::helper('payment')->__('Settlement of a chargeback.');
|
| 254 |
+
case 'none': // break is intentionally omitted
|
| 255 |
+
case 'other':
|
| 256 |
+
default:
|
| 257 |
+
return Mage::helper('payment')->__('Unknown reason. Please contact Alphabank customer service.');
|
| 258 |
+
}
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
/**
|
| 262 |
+
* Whether a reversal/refund can be disputed with Alphabank
|
| 263 |
+
*
|
| 264 |
+
* @param string $code
|
| 265 |
+
* @return bool;
|
| 266 |
+
*/
|
| 267 |
+
public static function isReversalDisputable($code)
|
| 268 |
+
{
|
| 269 |
+
switch ($code) {
|
| 270 |
+
case 'none':
|
| 271 |
+
case 'other':
|
| 272 |
+
case 'chargeback':
|
| 273 |
+
case 'buyer-complaint':
|
| 274 |
+
case 'adjustment_reversal':
|
| 275 |
+
return true;
|
| 276 |
+
case 'guarantee':
|
| 277 |
+
case 'refund':
|
| 278 |
+
case 'chargeback_reimbursement':
|
| 279 |
+
case 'chargeback_settlement':
|
| 280 |
+
default:
|
| 281 |
+
return false;
|
| 282 |
+
}
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
/**
|
| 286 |
+
* Render info item
|
| 287 |
+
*
|
| 288 |
+
* @param array $keys
|
| 289 |
+
* @param Mage_Payment_Model_Info $payment
|
| 290 |
+
* @param bool $labelValuesOnly
|
| 291 |
+
*/
|
| 292 |
+
protected function _getFullInfo(array $keys, Mage_Payment_Model_Info $payment, $labelValuesOnly)
|
| 293 |
+
{
|
| 294 |
+
$result = array();
|
| 295 |
+
foreach ($keys as $key) {
|
| 296 |
+
if (!isset($this->_paymentMapFull[$key])) {
|
| 297 |
+
$this->_paymentMapFull[$key] = array();
|
| 298 |
+
}
|
| 299 |
+
if (!isset($this->_paymentMapFull[$key]['label'])) {
|
| 300 |
+
if (!$payment->hasAdditionalInformation($key)) {
|
| 301 |
+
$this->_paymentMapFull[$key]['label'] = false;
|
| 302 |
+
$this->_paymentMapFull[$key]['value'] = false;
|
| 303 |
+
} else {
|
| 304 |
+
$value = $payment->getAdditionalInformation($key);
|
| 305 |
+
$this->_paymentMapFull[$key]['label'] = $this->_getLabel($key);
|
| 306 |
+
$this->_paymentMapFull[$key]['value'] = $value;
|
| 307 |
+
//$this->_paymentMapFull[$key]['value'] = $this->_getValue($value, $key);
|
| 308 |
+
}
|
| 309 |
+
}
|
| 310 |
+
if (!empty($this->_paymentMapFull[$key]['value'])) {
|
| 311 |
+
if ($labelValuesOnly) {
|
| 312 |
+
$result[$this->_paymentMapFull[$key]['label']] = $this->_paymentMapFull[$key]['value'];
|
| 313 |
+
} else {
|
| 314 |
+
$result[$key] = $this->_paymentMapFull[$key];
|
| 315 |
+
}
|
| 316 |
+
}
|
| 317 |
+
}
|
| 318 |
+
return $result;
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
/**
|
| 322 |
+
* Render info item labels
|
| 323 |
+
*
|
| 324 |
+
* @param string $key
|
| 325 |
+
*/
|
| 326 |
+
protected function _getLabel($key)
|
| 327 |
+
{
|
| 328 |
+
switch ($key) {
|
| 329 |
+
case 'riskScore':
|
| 330 |
+
return Mage::helper('payment')->__('Risk Score');
|
| 331 |
+
case 'payMethod':
|
| 332 |
+
return Mage::helper('payment')->__('Payment Method');
|
| 333 |
+
case 'paymentRef':
|
| 334 |
+
return Mage::helper('payment')->__('Payment Reference');
|
| 335 |
+
case 'message':
|
| 336 |
+
return Mage::helper('payment')->__('Message');
|
| 337 |
+
}
|
| 338 |
+
return '';
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
+
/**
|
| 342 |
+
* Apply a filter upon value getting
|
| 343 |
+
*
|
| 344 |
+
* @param string $value
|
| 345 |
+
* @param string $key
|
| 346 |
+
* @return string
|
| 347 |
+
*/
|
| 348 |
+
protected function _getValue($value, $key)
|
| 349 |
+
{
|
| 350 |
+
$label = '';
|
| 351 |
+
switch ($key) {
|
| 352 |
+
case 'vpc_avs_code':
|
| 353 |
+
$label = $this->_getAvsLabel($value);
|
| 354 |
+
break;
|
| 355 |
+
case 'vpc_cvv2_match':
|
| 356 |
+
$label = $this->_getCvv2Label($value);
|
| 357 |
+
break;
|
| 358 |
+
default:
|
| 359 |
+
return $value;
|
| 360 |
+
}
|
| 361 |
+
return sprintf('#%s%s', $value, $value == $label ? '' : ': ' . $label);
|
| 362 |
+
}
|
| 363 |
+
|
| 364 |
+
/**
|
| 365 |
+
* Attempt to convert AVS check result code into label
|
| 366 |
+
*
|
| 367 |
+
* @param string $value
|
| 368 |
+
* @return string
|
| 369 |
+
*/
|
| 370 |
+
protected function _getAvsLabel($value)
|
| 371 |
+
{
|
| 372 |
+
switch ($value) {
|
| 373 |
+
// Visa, MasterCard, Discover and American Express
|
| 374 |
+
case 'A':
|
| 375 |
+
return Mage::helper('payment')->__('Matched Address only (no ZIP)');
|
| 376 |
+
case 'B': // international "A"
|
| 377 |
+
return Mage::helper('payment')->__('Matched Address only (no ZIP). International');
|
| 378 |
+
case 'N':
|
| 379 |
+
return Mage::helper('payment')->__('No Details matched');
|
| 380 |
+
case 'C': // international "N"
|
| 381 |
+
return Mage::helper('payment')->__('No Details matched. International');
|
| 382 |
+
case 'X':
|
| 383 |
+
return Mage::helper('payment')->__('Exact Match. Address and nine-digit ZIP code');
|
| 384 |
+
case 'D': // international "X"
|
| 385 |
+
return Mage::helper('payment')->__('Exact Match. Address and Postal Code. International');
|
| 386 |
+
case 'F': // UK-specific "X"
|
| 387 |
+
return Mage::helper('payment')->__('Exact Match. Address and Postal Code. UK-specific');
|
| 388 |
+
case 'E':
|
| 389 |
+
return Mage::helper('payment')->__('N/A. Not allowed for MOTO (Internet/Phone) transactions');
|
| 390 |
+
case 'G':
|
| 391 |
+
return Mage::helper('payment')->__('N/A. Global Unavailable');
|
| 392 |
+
case 'I':
|
| 393 |
+
return Mage::helper('payment')->__('N/A. International Unavailable');
|
| 394 |
+
case 'Z':
|
| 395 |
+
return Mage::helper('payment')->__('Matched five-digit ZIP only (no Address)');
|
| 396 |
+
case 'P': // international "Z"
|
| 397 |
+
return Mage::helper('payment')->__('Matched Postal Code only (no Address)');
|
| 398 |
+
case 'R':
|
| 399 |
+
return Mage::helper('payment')->__('N/A. Retry');
|
| 400 |
+
case 'S':
|
| 401 |
+
return Mage::helper('payment')->__('N/A. Service not Supported');
|
| 402 |
+
case 'U':
|
| 403 |
+
return Mage::helper('payment')->__('N/A. Unavailable');
|
| 404 |
+
case 'W':
|
| 405 |
+
return Mage::helper('payment')->__('Matched whole nine-didgit ZIP (no Address)');
|
| 406 |
+
case 'Y':
|
| 407 |
+
return Mage::helper('payment')->__('Yes. Matched Address and five-didgit ZIP');
|
| 408 |
+
// Maestro and Solo
|
| 409 |
+
case '0':
|
| 410 |
+
return Mage::helper('payment')->__('All the address information matched');
|
| 411 |
+
case '1':
|
| 412 |
+
return Mage::helper('payment')->__('None of the address information matched');
|
| 413 |
+
case '2':
|
| 414 |
+
return Mage::helper('payment')->__('Part of the address information matched');
|
| 415 |
+
case '3':
|
| 416 |
+
return Mage::helper('payment')->__('N/A. The merchant did not provide AVS information');
|
| 417 |
+
case '4':
|
| 418 |
+
return Mage::helper('payment')->__('N/A. Address not checked, or acquirer had no response. Service not available');
|
| 419 |
+
default:
|
| 420 |
+
return $value;
|
| 421 |
+
}
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
+
/**
|
| 425 |
+
* Attempt to convert CVV2 check result code into label
|
| 426 |
+
*
|
| 427 |
+
* @param string $value
|
| 428 |
+
* @return string
|
| 429 |
+
*/
|
| 430 |
+
protected function _getCvv2Label($value)
|
| 431 |
+
{
|
| 432 |
+
switch ($value) {
|
| 433 |
+
// Visa, MasterCard, Discover and American Express
|
| 434 |
+
case 'M':
|
| 435 |
+
return Mage::helper('payment')->__('Matched (CVV2CSC)');
|
| 436 |
+
case 'N':
|
| 437 |
+
return Mage::helper('payment')->__('No match');
|
| 438 |
+
case 'P':
|
| 439 |
+
return Mage::helper('payment')->__('N/A. Not processed');
|
| 440 |
+
case 'S':
|
| 441 |
+
return Mage::helper('payment')->__('N/A. Service not supported');
|
| 442 |
+
case 'U':
|
| 443 |
+
return Mage::helper('payment')->__('N/A. Service not available');
|
| 444 |
+
case 'X':
|
| 445 |
+
return Mage::helper('payment')->__('N/A. No response');
|
| 446 |
+
// Maestro and Solo
|
| 447 |
+
case '0':
|
| 448 |
+
return Mage::helper('payment')->__('Matched (CVV2)');
|
| 449 |
+
case '1':
|
| 450 |
+
return Mage::helper('payment')->__('No match');
|
| 451 |
+
case '2':
|
| 452 |
+
return Mage::helper('payment')->__('N/A. The merchant has not implemented CVV2 code handling');
|
| 453 |
+
case '3':
|
| 454 |
+
return Mage::helper('payment')->__('N/A. Merchant has indicated that CVV2 is not present on card');
|
| 455 |
+
case '4':
|
| 456 |
+
return Mage::helper('payment')->__('N/A. Service not available');
|
| 457 |
+
default:
|
| 458 |
+
return $value;
|
| 459 |
+
}
|
| 460 |
+
}
|
| 461 |
+
|
| 462 |
+
/**
|
| 463 |
+
* Attempt to convert centinel VPAS result into label
|
| 464 |
+
*
|
| 465 |
+
* @param string $value
|
| 466 |
+
* @return string
|
| 467 |
+
*/
|
| 468 |
+
private function _getCentinelVpasLabel($value)
|
| 469 |
+
{
|
| 470 |
+
switch ($value) {
|
| 471 |
+
case '2':
|
| 472 |
+
case 'D':
|
| 473 |
+
return Mage::helper('payment')->__('Authenticated, Good Result');
|
| 474 |
+
case '1':
|
| 475 |
+
return Mage::helper('payment')->__('Authenticated, Bad Result');
|
| 476 |
+
case '3':
|
| 477 |
+
case '6':
|
| 478 |
+
case '8':
|
| 479 |
+
case 'A':
|
| 480 |
+
case 'C':
|
| 481 |
+
return Mage::helper('payment')->__('Attempted Authentication, Good Result');
|
| 482 |
+
case '4':
|
| 483 |
+
case '7':
|
| 484 |
+
case '9':
|
| 485 |
+
return Mage::helper('payment')->__('Attempted Authentication, Bad Result');
|
| 486 |
+
case '':
|
| 487 |
+
case '0':
|
| 488 |
+
case 'B':
|
| 489 |
+
return Mage::helper('payment')->__('No Liability Shift');
|
| 490 |
+
default:
|
| 491 |
+
return $value;
|
| 492 |
+
}
|
| 493 |
+
}
|
| 494 |
+
}
|
app/code/local/ND/Alphabank/Model/System/Config/Source/Transaction.php
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class ND_Alphabank_Model_System_Config_Source_Transaction
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Options getter
|
| 8 |
+
*
|
| 9 |
+
* @return array
|
| 10 |
+
*/
|
| 11 |
+
public function toOptionArray()
|
| 12 |
+
{
|
| 13 |
+
return array(
|
| 14 |
+
array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Payment (Sale)')),
|
| 15 |
+
array('value' => 2, 'label'=>Mage::helper('adminhtml')->__('Authorization')),
|
| 16 |
+
);
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Get options in "key-value" format
|
| 21 |
+
*
|
| 22 |
+
* @return array
|
| 23 |
+
*/
|
| 24 |
+
public function toArray()
|
| 25 |
+
{
|
| 26 |
+
return array(
|
| 27 |
+
1 => Mage::helper('adminhtml')->__('Payment (Sale)'),
|
| 28 |
+
2 => Mage::helper('adminhtml')->__('Authorization'),
|
| 29 |
+
);
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
}
|
app/code/local/ND/Alphabank/controllers/CheckoutController.php
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class ND_Alphabank_CheckoutController extends ND_Alphabank_Controller_Abstract
|
| 4 |
+
{
|
| 5 |
+
protected $_redirectBlockType = 'alphabank/checkout_redirect';
|
| 6 |
+
|
| 7 |
+
public function responseAction()
|
| 8 |
+
{
|
| 9 |
+
$responseParams = $this->getRequest()->getParams();
|
| 10 |
+
if($responseParams['status']==ND_Alphabank_Model_Info::PAYMENTSTATUS_CANCELED)
|
| 11 |
+
{
|
| 12 |
+
$order = Mage::getModel('sales/order');
|
| 13 |
+
$order->loadByIncrementId($responseParams['orderid']);
|
| 14 |
+
$order->addStatusToHistory($order->getStatus(), Mage::helper('core')->__('Transaction is aborted by user.'));
|
| 15 |
+
$order->save();
|
| 16 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('core')->__('Transaction is aborted by user.'));
|
| 17 |
+
$this->_redirect('checkout/cart');
|
| 18 |
+
return;
|
| 19 |
+
}
|
| 20 |
+
elseif($responseParams['status']==ND_Alphabank_Model_Info::PAYMENTSTATUS_REFUSED)
|
| 21 |
+
{
|
| 22 |
+
$userMessageAry = explode("-",$responseParams['message']);
|
| 23 |
+
$userMessage = (count($userMessage)>1)?$userMessageAry[1]:$userMessageAry[0];
|
| 24 |
+
$order = Mage::getModel('sales/order');
|
| 25 |
+
$order->loadByIncrementId($responseParams['orderid']);
|
| 26 |
+
$order->addStatusToHistory($order->getStatus(), $responseParams['message']);
|
| 27 |
+
$order->save();
|
| 28 |
+
Mage::getSingleton('core/session')->addError($userMessage);
|
| 29 |
+
$this->_redirect('checkout/cart');
|
| 30 |
+
return;
|
| 31 |
+
}
|
| 32 |
+
elseif($responseParams['status']==ND_Alphabank_Model_Info::PAYMENTSTATUS_CAPTURED)
|
| 33 |
+
{
|
| 34 |
+
Mage::getModel('alphabank/checkout')->afterSuccessOrder($responseParams);
|
| 35 |
+
//Mage::getSingleton('core/session')->addSuccess($responseParams['message']);
|
| 36 |
+
$this->_redirect('checkout/onepage/success');
|
| 37 |
+
return;
|
| 38 |
+
}
|
| 39 |
+
else
|
| 40 |
+
{
|
| 41 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('core')->__('Trasaction Failed'));
|
| 42 |
+
$this->_redirect('checkout/cart');
|
| 43 |
+
return;
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
}
|
app/code/local/ND/Alphabank/etc/config.xml
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<ND_Alphabank>
|
| 5 |
+
<version>0.1.0</version>
|
| 6 |
+
</ND_Alphabank>
|
| 7 |
+
</modules>
|
| 8 |
+
<global>
|
| 9 |
+
<models>
|
| 10 |
+
<alphabank>
|
| 11 |
+
<class>ND_Alphabank_Model</class>
|
| 12 |
+
</alphabank>
|
| 13 |
+
</models>
|
| 14 |
+
<helpers>
|
| 15 |
+
<alphabank>
|
| 16 |
+
<class>ND_Alphabank_Helper</class>
|
| 17 |
+
</alphabank>
|
| 18 |
+
</helpers>
|
| 19 |
+
<resources>
|
| 20 |
+
<alphabank_setup>
|
| 21 |
+
<setup>
|
| 22 |
+
<module>ND_Alphabank</module>
|
| 23 |
+
</setup>
|
| 24 |
+
<connection>
|
| 25 |
+
<use>core_setup</use>
|
| 26 |
+
</connection>
|
| 27 |
+
</alphabank_setup>
|
| 28 |
+
<alphabank_write>
|
| 29 |
+
<connection>
|
| 30 |
+
<use>core_write</use>
|
| 31 |
+
</connection>
|
| 32 |
+
</alphabank_write>
|
| 33 |
+
<alphabank_read>
|
| 34 |
+
<connection>
|
| 35 |
+
<use>core_read</use>
|
| 36 |
+
</connection>
|
| 37 |
+
</alphabank_read>
|
| 38 |
+
</resources>
|
| 39 |
+
<blocks>
|
| 40 |
+
<alphabank><class>ND_Alphabank_Block</class></alphabank>
|
| 41 |
+
</blocks>
|
| 42 |
+
</global>
|
| 43 |
+
<frontend>
|
| 44 |
+
<secure_url>
|
| 45 |
+
<alphabank_checkout>/alphabank/checkout</alphabank_checkout>
|
| 46 |
+
</secure_url>
|
| 47 |
+
<routers>
|
| 48 |
+
<alphabank>
|
| 49 |
+
<use>standard</use>
|
| 50 |
+
<args>
|
| 51 |
+
<module>ND_Alphabank</module>
|
| 52 |
+
<frontName>alphabank</frontName>
|
| 53 |
+
</args>
|
| 54 |
+
</alphabank>
|
| 55 |
+
</routers>
|
| 56 |
+
<layout>
|
| 57 |
+
<updates>
|
| 58 |
+
<alphabank>
|
| 59 |
+
<file>alphabank.xml</file>
|
| 60 |
+
</alphabank>
|
| 61 |
+
</updates>
|
| 62 |
+
</layout>
|
| 63 |
+
</frontend>
|
| 64 |
+
<default>
|
| 65 |
+
<payment>
|
| 66 |
+
<alphabank_checkout>
|
| 67 |
+
<merchant_id backend_model="adminhtml/system_config_backend_encrypted"/>
|
| 68 |
+
<model>alphabank/checkout</model>
|
| 69 |
+
<title>Alpha Bank e-Commerce</title>
|
| 70 |
+
<order_status>processing</order_status>
|
| 71 |
+
<allowspecific>0</allowspecific>
|
| 72 |
+
</alphabank_checkout>
|
| 73 |
+
</payment>
|
| 74 |
+
</default>
|
| 75 |
+
</config>
|
app/code/local/ND/Alphabank/etc/system.xml
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<sections>
|
| 4 |
+
<payment>
|
| 5 |
+
<groups>
|
| 6 |
+
<alphabank_checkout translate="label" module="payment">
|
| 7 |
+
<label>Alpha Bank e-Commerce</label>
|
| 8 |
+
<frontend_type>text</frontend_type>
|
| 9 |
+
<sort_order>401</sort_order>
|
| 10 |
+
<show_in_default>1</show_in_default>
|
| 11 |
+
<show_in_website>1</show_in_website>
|
| 12 |
+
<show_in_store>0</show_in_store>
|
| 13 |
+
<fields>
|
| 14 |
+
<active translate="label">
|
| 15 |
+
<label>Enabled</label>
|
| 16 |
+
<frontend_type>select</frontend_type>
|
| 17 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 18 |
+
<sort_order>10</sort_order>
|
| 19 |
+
<show_in_default>1</show_in_default>
|
| 20 |
+
<show_in_website>1</show_in_website>
|
| 21 |
+
<show_in_store>0</show_in_store>
|
| 22 |
+
</active>
|
| 23 |
+
<title translate="label">
|
| 24 |
+
<label>Title</label>
|
| 25 |
+
<frontend_type>text</frontend_type>
|
| 26 |
+
<sort_order>20</sort_order>
|
| 27 |
+
<show_in_default>1</show_in_default>
|
| 28 |
+
<show_in_website>1</show_in_website>
|
| 29 |
+
<show_in_store>0</show_in_store>
|
| 30 |
+
</title>
|
| 31 |
+
<merchant_id translate="label">
|
| 32 |
+
<label>Merchant ID</label>
|
| 33 |
+
<frontend_type>text</frontend_type>
|
| 34 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
| 35 |
+
<sort_order>30</sort_order>
|
| 36 |
+
<show_in_default>1</show_in_default>
|
| 37 |
+
<show_in_website>1</show_in_website>
|
| 38 |
+
<show_in_store>0</show_in_store>
|
| 39 |
+
</merchant_id>
|
| 40 |
+
<secret_key translate="label">
|
| 41 |
+
<label>Secret Key</label>
|
| 42 |
+
<frontend_type>text</frontend_type>
|
| 43 |
+
<sort_order>40</sort_order>
|
| 44 |
+
<show_in_default>1</show_in_default>
|
| 45 |
+
<show_in_website>1</show_in_website>
|
| 46 |
+
<show_in_store>0</show_in_store>
|
| 47 |
+
</secret_key>
|
| 48 |
+
<api_url translate="label">
|
| 49 |
+
<label>API Gateway URL (Live)</label>
|
| 50 |
+
<frontend_type>text</frontend_type>
|
| 51 |
+
<sort_order>50</sort_order>
|
| 52 |
+
<show_in_default>1</show_in_default>
|
| 53 |
+
<show_in_website>1</show_in_website>
|
| 54 |
+
<show_in_store>0</show_in_store>
|
| 55 |
+
</api_url>
|
| 56 |
+
<api_test_url translate="label">
|
| 57 |
+
<label>API Gateway URL (Test)</label>
|
| 58 |
+
<frontend_type>text</frontend_type>
|
| 59 |
+
<sort_order>60</sort_order>
|
| 60 |
+
<show_in_default>1</show_in_default>
|
| 61 |
+
<show_in_website>1</show_in_website>
|
| 62 |
+
<show_in_store>0</show_in_store>
|
| 63 |
+
</api_test_url>
|
| 64 |
+
<test_mode translate="label">
|
| 65 |
+
<label>Test Mode</label>
|
| 66 |
+
<frontend_type>select</frontend_type>
|
| 67 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 68 |
+
<sort_order>70</sort_order>
|
| 69 |
+
<show_in_default>1</show_in_default>
|
| 70 |
+
<show_in_website>1</show_in_website>
|
| 71 |
+
<show_in_store>0</show_in_store>
|
| 72 |
+
</test_mode>
|
| 73 |
+
<transaction_type translate="label">
|
| 74 |
+
<label>Type of Transaction</label>
|
| 75 |
+
<frontend_type>select</frontend_type>
|
| 76 |
+
<source_model>alphabank/system_config_source_transaction</source_model>
|
| 77 |
+
<sort_order>80</sort_order>
|
| 78 |
+
<show_in_default>1</show_in_default>
|
| 79 |
+
<show_in_website>1</show_in_website>
|
| 80 |
+
<show_in_store>0</show_in_store>
|
| 81 |
+
</transaction_type>
|
| 82 |
+
<order_status translate="label">
|
| 83 |
+
<label>New order status</label>
|
| 84 |
+
<frontend_type>select</frontend_type>
|
| 85 |
+
<source_model>adminhtml/system_config_source_order_status_processing</source_model>
|
| 86 |
+
<sort_order>90</sort_order>
|
| 87 |
+
<show_in_default>1</show_in_default>
|
| 88 |
+
<show_in_website>1</show_in_website>
|
| 89 |
+
<show_in_store>0</show_in_store>
|
| 90 |
+
</order_status>
|
| 91 |
+
<debug translate="label">
|
| 92 |
+
<label>Debug</label>
|
| 93 |
+
<frontend_type>select</frontend_type>
|
| 94 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 95 |
+
<sort_order>100</sort_order>
|
| 96 |
+
<show_in_default>1</show_in_default>
|
| 97 |
+
<show_in_website>1</show_in_website>
|
| 98 |
+
<show_in_store>0</show_in_store>
|
| 99 |
+
</debug>
|
| 100 |
+
<allowspecific translate="label">
|
| 101 |
+
<label>Payment from applicable countries</label>
|
| 102 |
+
<frontend_type>allowspecific</frontend_type>
|
| 103 |
+
<sort_order>110</sort_order>
|
| 104 |
+
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
|
| 105 |
+
<show_in_default>1</show_in_default>
|
| 106 |
+
<show_in_website>1</show_in_website>
|
| 107 |
+
<show_in_store>1</show_in_store>
|
| 108 |
+
</allowspecific>
|
| 109 |
+
<specificcountry translate="label">
|
| 110 |
+
<label>Payment from Specific countries</label>
|
| 111 |
+
<frontend_type>multiselect</frontend_type>
|
| 112 |
+
<sort_order>120</sort_order>
|
| 113 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
| 114 |
+
<show_in_default>1</show_in_default>
|
| 115 |
+
<show_in_website>1</show_in_website>
|
| 116 |
+
<show_in_store>1</show_in_store>
|
| 117 |
+
</specificcountry>
|
| 118 |
+
</fields>
|
| 119 |
+
</alphabank_checkout>
|
| 120 |
+
</groups>
|
| 121 |
+
</payment>
|
| 122 |
+
</sections>
|
| 123 |
+
</config>
|
app/code/local/ND/Alphabank/sql/migsvpc_setup/mysql4-install-0.1.0.php
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
$installer = $this;
|
| 4 |
+
|
| 5 |
+
$installer->startSetup();
|
| 6 |
+
|
| 7 |
+
$installer->run("
|
| 8 |
+
|
| 9 |
+
-- DROP TABLE IF EXISTS `{$this->getTable('alphabank/api_debug')}`;
|
| 10 |
+
CREATE TABLE `{$this->getTable('alphabank/api_debug')}` (
|
| 11 |
+
`debug_id` int(10) unsigned NOT NULL auto_increment,
|
| 12 |
+
`debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
|
| 13 |
+
`request_body` text,
|
| 14 |
+
`response_body` text,
|
| 15 |
+
PRIMARY KEY (`debug_id`),
|
| 16 |
+
KEY `debug_at` (`debug_at`)
|
| 17 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
| 18 |
+
|
| 19 |
+
");
|
| 20 |
+
|
| 21 |
+
$installer->endSetup();
|
app/design/frontend/base/default/layout/alphabank.xml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
|
| 3 |
+
<layout version="0.1.0">
|
| 4 |
+
<alphabank_checkout_failure>
|
| 5 |
+
<reference name="root">
|
| 6 |
+
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
|
| 7 |
+
</reference>
|
| 8 |
+
<reference name="content">
|
| 9 |
+
<block type="alphabank/checkout_failure" name="alphabank_checkout_failure" template="alphabank/checkout/failure.phtml"></block>
|
| 10 |
+
</reference>
|
| 11 |
+
</alphabank_checkout_failure>
|
| 12 |
+
|
| 13 |
+
<alphabank_checkout_response>
|
| 14 |
+
<!--<reference name="root">
|
| 15 |
+
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
|
| 16 |
+
</reference>-->
|
| 17 |
+
<reference name="content">
|
| 18 |
+
<block type="alphabank/checkout_response" name="alphabank_checkout_response" template="alphabank/checkout/response.phtml"></block>
|
| 19 |
+
</reference>
|
| 20 |
+
</alphabank_checkout_response>
|
| 21 |
+
</layout>
|
app/design/frontend/base/default/template/alphabank/checkout/form.phtml
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<fieldset class="form-list">
|
| 2 |
+
<?php $_code=$this->getMethodCode() ?>
|
| 3 |
+
<ul id="payment_form_<?php echo $_code ?>" style="display:none">
|
| 4 |
+
<li>
|
| 5 |
+
<div class="generic-select-input input-box">
|
| 6 |
+
<label for="<?php echo $_code ?>_lang"><?php echo $this->__('Select Language') ?></label><br />
|
| 7 |
+
<select id="<?php echo $_code ?>_lang" name="payment[lang]">
|
| 8 |
+
<option value="">--<?php echo $this->__('Please Select') ?>--</option>
|
| 9 |
+
<option value="el"><?php echo $this->__('Greek');?></option>
|
| 10 |
+
<option value="en"><?php echo $this->__('English');?></option>
|
| 11 |
+
<option value="fr"><?php echo $this->__('French');?></option>
|
| 12 |
+
</select>
|
| 13 |
+
</div>
|
| 14 |
+
</li>
|
| 15 |
+
<li>
|
| 16 |
+
<?php echo $this->__('You will be redirected to Alpha e-Commerce website when you place an order.') ?>
|
| 17 |
+
</li>
|
| 18 |
+
</ul>
|
| 19 |
+
</fieldset>
|
app/design/frontend/base/default/template/alphabank/checkout/response.phtml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* ND MigsVpc payment gateway
|
| 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 you can be sent a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
|
| 16 |
+
*
|
| 17 |
+
* @category Fontis
|
| 18 |
+
* @package Fontis_EwayAu
|
| 19 |
+
* @copyright Copyright (c) 2010 Fontis (http://www.fontis.com.au)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
?>
|
| 23 |
+
<div class="page-head">
|
| 24 |
+
<h3><?php echo $this->__('Error occured') ?></h3>
|
| 25 |
+
</div>
|
| 26 |
+
<p><?php echo $this->getErrorMessage() ?>.</p>
|
| 27 |
+
<p><?php echo $this->__('Please <a href="%s">continue shopping</a>.', $this->getContinueShoppingUrl()) ?></p>
|
app/design/frontend/base/default/template/alphabank/form.phtml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<fieldset class="form-list">
|
| 2 |
+
<?php $_code=$this->getMethodCode() ?>
|
| 3 |
+
<ul id="payment_form_<?php echo $_code ?>" style="display:none">
|
| 4 |
+
<li>
|
| 5 |
+
<div class="generic-select-input input-box">
|
| 6 |
+
<p class="columnSelectedDeposit"><?php echo $this->__('--Language--');?></p>
|
| 7 |
+
<label for="<?php echo $_code ?>_lang"><?php echo $this->__('Select Language') ?></label><br />
|
| 8 |
+
<select id="<?php echo $_code ?>_lang" name="payment[lang]">
|
| 9 |
+
<option value="">--<?php echo $this->__('Please Select') ?>--</option>
|
| 10 |
+
<option value="el"><?php echo $this->__('Greek');?></option>
|
| 11 |
+
<option value="en"><?php echo $this->__('English');?></option>
|
| 12 |
+
<option value="fr"><?php echo $this->__('French');?></option>
|
| 13 |
+
</select>
|
| 14 |
+
</div>
|
| 15 |
+
</li>
|
| 16 |
+
</ul>
|
| 17 |
+
</fieldset>
|
app/design/frontend/base/default/template/alphabank/info.phtml
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* ND MigsVpc payment gateway
|
| 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 you can be sent a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
|
| 16 |
+
*
|
| 17 |
+
* @category Fontis
|
| 18 |
+
* @package Fontis_EwayAu
|
| 19 |
+
* @copyright Copyright (c) 2010 Fontis (http://www.fontis.com.au)
|
| 20 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 21 |
+
*/
|
| 22 |
+
?>
|
| 23 |
+
<?php if($_info = $this->getInfo()): ?>
|
| 24 |
+
<?php echo $this->__('Name on the Card: %s', $this->htmlEscape($this->getInfo()->getCcOwner())) ?><br />
|
| 25 |
+
<?php echo $this->__('Credit Card Type: %s', $this->htmlEscape($this->getCcTypeName())) ?><br />
|
| 26 |
+
<?php echo $this->__('Credit Card Number: xxxx-%s', $this->htmlEscape($this->getInfo()->getCcLast4())) ?><br />
|
| 27 |
+
<?php echo $this->__('Expiration Date: %s/%s', $this->htmlEscape($this->getCcExpMonth()), $this->htmlEscape($this->getInfo()->getCcExpYear())) ?>
|
| 28 |
+
<?php else: ?>
|
| 29 |
+
|
| 30 |
+
<?php endif; ?>
|
app/etc/modules/ND_Alphabank.xml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<ND_Alphabank>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>local</codePool>
|
| 7 |
+
<depends>
|
| 8 |
+
<Mage_Payment/>
|
| 9 |
+
</depends>
|
| 10 |
+
</ND_Alphabank>
|
| 11 |
+
</modules>
|
| 12 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>ND_Alphabank</name>
|
| 4 |
+
<version>0.1.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Alpha Bank e-Commerce payment gateway integration.</summary>
|
| 10 |
+
<description>The extension provides Alpha Bank e-Commerce payment gateway integration.
|
| 11 |
+

|
| 12 |
+
The service supports payments with debit, credit and prepaid cards:
|
| 13 |
+

|
| 14 |
+
- American Express
|
| 15 |
+
- Visa, Visa Electron
|
| 16 |
+
- MasterCard
|
| 17 |
+
- Maestro
|
| 18 |
+
- Diners</description>
|
| 19 |
+
<notes>First Stable Release Version 0.1.0</notes>
|
| 20 |
+
<authors><author><name>Nikul Doshi</name><user>nikulonline</user><email>nikulonline@gmail.com</email></author></authors>
|
| 21 |
+
<date>2014-08-12</date>
|
| 22 |
+
<time>10:07:41</time>
|
| 23 |
+
<contents><target name="magelocal"><dir name="ND"><dir name="Alphabank"><dir name="Block"><dir name="Checkout"><file name="Failure.php" hash="1fa882cc591743797193370f57b207ae"/><file name="Form.php" hash="41df72f7d3ac80ed063accfcfa93a034"/><file name="Redirect.php" hash="bf60abc16deb6adc4858359200100cdc"/><file name="Response.php" hash="69fc106e7605c66ac7d9d12987170643"/></dir><file name="Form.php" hash="33adbdca8d42d746d6d379d818212a7d"/><file name="Info.php" hash="f172d29235ab84f986090c8c4763c0f7"/><dir name="Payment"><file name="Info.php" hash="cf3715174750b0030fb548e6dd373fd5"/></dir></dir><dir name="Controller"><file name="Abstract.php" hash="6e545787a53a62d68d3179c7f082442b"/></dir><dir name="Helper"><file name="Data.php" hash="173fb1993d443eeb0cb7367d4499124b"/></dir><dir name="Model"><file name="Checkout.php" hash="64892fc0f8e04068b333b42d18373930"/><file name="Info.php" hash="e055fadf3b037c03a7b14358a3009a8b"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Transaction.php" hash="b44e3bfd41581e798dad2f53da4f4ec8"/></dir></dir></dir></dir><dir name="controllers"><file name="CheckoutController.php" hash="988c8f685157384c222c7977f8d2c8aa"/></dir><dir name="etc"><file name="config.xml" hash="aa476a7e2aa8b149a5b375ba85b5753e"/><file name="system.xml" hash="0c8990a727d556bc915c8c959d868481"/></dir><dir name="sql"><dir name="migsvpc_setup"><file name="mysql4-install-0.1.0.php" hash="46a18f4f78b50db8cbcd18d73d315d8b"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="alphabank.xml" hash="1c312fed74b476b1cce3137b6452e4ff"/></dir><dir name="template"><dir name="alphabank"><dir name="checkout"><file name="form.phtml" hash="e3705bae565e3580c7a1ac6cb99c6a7f"/><file name="response.phtml" hash="8a3f5b9be4901568104472399b1b1398"/></dir><file name="form.phtml" hash="ea5eb22101b12a887523f4eb50e84d9f"/><file name="info.phtml" hash="c13fe64ae97929b3b732d25b695527ea"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="ND_Alphabank.xml" hash="a74257cc6246b1f6252bb73136562b1f"/></dir></target></contents>
|
| 24 |
+
<compatible/>
|
| 25 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 26 |
+
</package>
|
