Version Notes
First Stable Release Version 0.1.1
Download this release
Release Info
| Developer | Nikul Doshi |
| Extension | ND_Vivapayments |
| Version | 0.1.1 |
| Comparing to | |
| See all releases | |
Version 0.1.1
- app/code/local/ND/Vivapayments/Block/Checkout/Failure.php +24 -0
- app/code/local/ND/Vivapayments/Block/Checkout/Form.php +32 -0
- app/code/local/ND/Vivapayments/Block/Checkout/Redirect.php +34 -0
- app/code/local/ND/Vivapayments/Block/Checkout/Response.php +29 -0
- app/code/local/ND/Vivapayments/Block/Form.php +32 -0
- app/code/local/ND/Vivapayments/Block/Info.php +17 -0
- app/code/local/ND/Vivapayments/Block/Payment/Info.php +33 -0
- app/code/local/ND/Vivapayments/Controller/Abstract.php +95 -0
- app/code/local/ND/Vivapayments/Helper/Data.php +40 -0
- app/code/local/ND/Vivapayments/Model/Checkout.php +312 -0
- app/code/local/ND/Vivapayments/Model/Info.php +476 -0
- app/code/local/ND/Vivapayments/Model/System/Config/Source/Transaction.php +32 -0
- app/code/local/ND/Vivapayments/controllers/CheckoutController.php +50 -0
- app/code/local/ND/Vivapayments/etc/config.xml +76 -0
- app/code/local/ND/Vivapayments/etc/system.xml +107 -0
- app/design/frontend/base/default/layout/vivapayments.xml +21 -0
- app/design/frontend/base/default/template/vivapayments/checkout/form.phtml +18 -0
- app/design/frontend/base/default/template/vivapayments/checkout/response.phtml +27 -0
- app/design/frontend/base/default/template/vivapayments/form.phtml +19 -0
- app/design/frontend/base/default/template/vivapayments/info.phtml +30 -0
- app/etc/modules/ND_Vivapayments.xml +12 -0
- package.xml +26 -0
app/code/local/ND/Vivapayments/Block/Checkout/Failure.php
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class ND_Vivapayments_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')->getVivaErrorMessage();
|
| 13 |
+
Mage::getSingleton('checkout/session')->unsVivaErrorMessage();
|
| 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/Vivapayments/Block/Checkout/Form.php
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class ND_Vivapayments_Block_Checkout_Form extends Mage_Payment_Block_Form
|
| 4 |
+
{
|
| 5 |
+
protected function _construct()
|
| 6 |
+
{
|
| 7 |
+
parent::_construct();
|
| 8 |
+
$this->setTemplate('vivapayments/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('vivapaymentscctypes');
|
| 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/Vivapayments/Block/Checkout/Redirect.php
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class ND_Vivapayments_Block_Checkout_Redirect extends Mage_Core_Block_Abstract
|
| 4 |
+
{
|
| 5 |
+
protected function _toHtml()
|
| 6 |
+
{
|
| 7 |
+
$checkout = $this->getOrder()->getPayment()->getMethodInstance();
|
| 8 |
+
$formFields = $checkout->getFormFields();
|
| 9 |
+
if(!empty($formFields['error'])) {
|
| 10 |
+
Mage::getSingleton('core/session')->addError($formFields['error']);
|
| 11 |
+
$url = Mage::getUrl('checkout/cart');
|
| 12 |
+
Mage::app()->getResponse()->setRedirect($url);
|
| 13 |
+
return;
|
| 14 |
+
}
|
| 15 |
+
$form = new Varien_Data_Form();
|
| 16 |
+
$form->setId('vivapayments_checkout_checkout')
|
| 17 |
+
->setName('vivapayments_checkout_checkout')
|
| 18 |
+
->setMethod('POST')
|
| 19 |
+
->setUseContainer(true);
|
| 20 |
+
|
| 21 |
+
foreach ($checkout->getFormFields() as $field=>$value) {
|
| 22 |
+
$form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value));
|
| 23 |
+
}
|
| 24 |
+
$form->setAction($checkout->getGatewayRedirectUrl());
|
| 25 |
+
$html = '<html><body>';
|
| 26 |
+
$html.= $this->__('You will be redirected to Viva Payments website in a few seconds ...');
|
| 27 |
+
$html.= $form->toHtml();
|
| 28 |
+
$html.= '<script type="text/javascript">document.getElementById("vivapayments_checkout_checkout").submit();</script>';
|
| 29 |
+
$html.= '</body></html>';
|
| 30 |
+
$html = str_replace('<div><input name="form_key" type="hidden" value="'.Mage::getSingleton('core/session')->getFormKey().'" /></div>','',$html);
|
| 31 |
+
|
| 32 |
+
return $html;
|
| 33 |
+
}
|
| 34 |
+
}
|
app/code/local/ND/Vivapayments/Block/Checkout/Response.php
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class ND_Vivapayments_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('vivapayments/checkout/response.phtml');
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
public function getErrorMessage ()
|
| 16 |
+
{
|
| 17 |
+
$msg = Mage::getSingleton('checkout/session')->getVivaErrorMessage();
|
| 18 |
+
Mage::getSingleton('checkout/session')->unsVivaErrorMessage();
|
| 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/Vivapayments/Block/Form.php
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class ND_Vivapayments_Block_Form extends Mage_Payment_Block_Form_Cc
|
| 4 |
+
{
|
| 5 |
+
protected function _construct()
|
| 6 |
+
{
|
| 7 |
+
parent::_construct();
|
| 8 |
+
$this->setTemplate('vivapayments/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('vivapaymentscctypes');
|
| 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/Vivapayments/Block/Info.php
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class ND_Vivapayments_Block_Info extends Mage_Payment_Block_Info_Cc
|
| 4 |
+
{
|
| 5 |
+
protected function _construct()
|
| 6 |
+
{
|
| 7 |
+
parent::_construct();
|
| 8 |
+
$this->setTemplate('vivapayments/info.phtml');
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
public function toPdf()
|
| 12 |
+
{
|
| 13 |
+
$this->setTemplate('vivapayments/pdf/info.phtml');
|
| 14 |
+
return $this->toHtml();
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
}
|
app/code/local/ND/Vivapayments/Block/Payment/Info.php
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class ND_Vivapayments_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 Viva Payments-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('vivapayments/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/Vivapayments/Controller/Abstract.php
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
abstract class ND_Vivapayments_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->setVivaQuoteId($session->getQuoteId());
|
| 35 |
+
$session->setVivaRealOrderId($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 Viva Payments.'));
|
| 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 |
+
* Viva returns POST variables to this action
|
| 54 |
+
*/
|
| 55 |
+
public function successAction()
|
| 56 |
+
{
|
| 57 |
+
$status = $this->_checkReturnedPost();
|
| 58 |
+
|
| 59 |
+
$session = $this->getCheckout();
|
| 60 |
+
|
| 61 |
+
$session->unsVivaRealOrderId();
|
| 62 |
+
$session->setQuoteId($session->getVivaQuoteId(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()->getVivaErrorMessage()) {
|
| 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/Vivapayments/Helper/Data.php
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class ND_Vivapayments_Helper_Data extends Mage_Core_Helper_Abstract
|
| 3 |
+
{
|
| 4 |
+
public function getTransactionDetails($tid=0)
|
| 5 |
+
{
|
| 6 |
+
if(!$tid) return false;
|
| 7 |
+
$checkoutModel = Mage::getModel('vivapayments/checkout');
|
| 8 |
+
$MerchantId = $checkoutModel->getMerchantId();
|
| 9 |
+
$APIKey = $checkoutModel->getSecretKey();
|
| 10 |
+
$ch = curl_init($checkoutModel->getTransactionUrl().$tid);
|
| 11 |
+
curl_setopt($ch, CURLOPT_POST, false);
|
| 12 |
+
curl_setopt($ch, CURLOPT_HEADER, false);
|
| 13 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
| 14 |
+
curl_setopt($ch, CURLOPT_USERPWD, $MerchantId.':'.$APIKey);
|
| 15 |
+
if($checkoutModel->isTestMode()) {
|
| 16 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
| 17 |
+
}
|
| 18 |
+
else {
|
| 19 |
+
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST,'TLSv1');
|
| 20 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
| 21 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
| 22 |
+
}
|
| 23 |
+
$response = curl_exec($ch);
|
| 24 |
+
curl_close($ch);
|
| 25 |
+
if(is_object(json_decode($response))){
|
| 26 |
+
return json_decode($response);
|
| 27 |
+
}else{
|
| 28 |
+
return false;
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
public function validateOrder($oid=0)
|
| 33 |
+
{
|
| 34 |
+
if(!$oid) return false;
|
| 35 |
+
$order = Mage::getModel('sales/order');
|
| 36 |
+
$order->loadByIncrementId($oid);
|
| 37 |
+
if(empty($order)) return false;
|
| 38 |
+
return ($order->getStatus()==ND_Vivapayments_Model_Info::PAYMENTSTATUS_PENDING) ? true : false;
|
| 39 |
+
}
|
| 40 |
+
}
|
app/code/local/ND/Vivapayments/Model/Checkout.php
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class ND_Vivapayments_Model_Checkout extends Mage_Payment_Model_Method_Abstract
|
| 4 |
+
{
|
| 5 |
+
protected $_code = 'vivapayments_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 = 'vivapayments/checkout_form';
|
| 18 |
+
protected $_paymentMethod = 'checkout';
|
| 19 |
+
protected $_infoBlockType = 'vivapayments/payment_info';
|
| 20 |
+
|
| 21 |
+
protected $_order;
|
| 22 |
+
|
| 23 |
+
protected $_paymentUrl = null;
|
| 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 getSourceCode()
|
| 48 |
+
{
|
| 49 |
+
$source_code = Mage::getStoreConfig('payment/' . $this->getCode() . '/source_code');
|
| 50 |
+
return $source_code;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
public function getAmount()
|
| 54 |
+
{
|
| 55 |
+
$_amount = (double)$this->getOrder()->getBaseGrandTotal();
|
| 56 |
+
return $_amount*100;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
public function validate()
|
| 60 |
+
{
|
| 61 |
+
$paymentInfo = $this->getInfoInstance();
|
| 62 |
+
if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
|
| 63 |
+
$currency_code = $paymentInfo->getOrder()->getBaseCurrencyCode();
|
| 64 |
+
} else {
|
| 65 |
+
$currency_code = $paymentInfo->getQuote()->getBaseCurrencyCode();
|
| 66 |
+
}
|
| 67 |
+
if($paymentInfo->getLang()!='') {
|
| 68 |
+
$paymentInfo->setAdditionalInformation('lang',$paymentInfo->getLang());
|
| 69 |
+
//Mage::throwException($paymentInfo->getLang());
|
| 70 |
+
}
|
| 71 |
+
return true;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
public function getOrderPlaceRedirectUrl()
|
| 75 |
+
{
|
| 76 |
+
return $url = Mage::getUrl('vivapayments/' . $this->_paymentMethod . '/redirect');
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
public function isTestMode()
|
| 80 |
+
{
|
| 81 |
+
return Mage::getStoreConfig('payment/' . $this->getCode() . '/test_mode');
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
public function getGatewayRedirectUrl()
|
| 85 |
+
{
|
| 86 |
+
if(!is_null($this->_paymentUrl)) {
|
| 87 |
+
$url = $this->_paymentUrl;
|
| 88 |
+
}
|
| 89 |
+
else {
|
| 90 |
+
$url = $this->getCheckoutUrl();
|
| 91 |
+
}
|
| 92 |
+
return $url;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
public function getCreateOrderUrl()
|
| 96 |
+
{
|
| 97 |
+
if($this->isTestMode()) {
|
| 98 |
+
$url = 'http://demo.vivapayments.com/api/orders/';
|
| 99 |
+
}
|
| 100 |
+
else {
|
| 101 |
+
$url = 'https://www.vivapayments.com/api/orders/';
|
| 102 |
+
}
|
| 103 |
+
return $url;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
public function getCheckoutUrl()
|
| 107 |
+
{
|
| 108 |
+
if($this->isTestMode()) {
|
| 109 |
+
$url = 'http://demo.vivapayments.com/web/newtransaction.aspx';
|
| 110 |
+
}
|
| 111 |
+
else {
|
| 112 |
+
$url = 'https://www.vivapayments.com/web/newtransaction.aspx';
|
| 113 |
+
}
|
| 114 |
+
return $url;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
public function getTransactionUrl()
|
| 118 |
+
{
|
| 119 |
+
if($this->isTestMode()) {
|
| 120 |
+
$url = 'http://demo.vivapayments.com/api/transactions/';
|
| 121 |
+
}
|
| 122 |
+
else {
|
| 123 |
+
$url = 'https://www.vivapayments.com/api/transactions/';
|
| 124 |
+
}
|
| 125 |
+
return $url;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
public function getFormFields()
|
| 129 |
+
{
|
| 130 |
+
$postargs = "";
|
| 131 |
+
$postargsAry = array();
|
| 132 |
+
$fieldsArr = array();
|
| 133 |
+
$paymentInfo = $this->getInfoInstance();
|
| 134 |
+
$shippingAddress = $this->getOrder()->getShippingAddress();
|
| 135 |
+
$billingAddress = $this->getOrder()->getBillingAddress();
|
| 136 |
+
$additional_information = $paymentInfo->getAdditionalInformation();
|
| 137 |
+
$MerchantId = $this->getMerchantId();
|
| 138 |
+
$APIKey = $this->getSecretKey();
|
| 139 |
+
$order_number = $paymentInfo->getOrder()->getRealOrderId();
|
| 140 |
+
$order_amount = $this->getAmount();
|
| 141 |
+
$fieldsArr = array(
|
| 142 |
+
'Amount'=>urlencode($order_amount),
|
| 143 |
+
'AllowRecurring'=>false,
|
| 144 |
+
'RequestLang'=>(!empty($additional_information['lang']))?$additional_information['lang']:'',
|
| 145 |
+
'Email'=>$billingAddress->getEmail(),
|
| 146 |
+
'Phone'=>$billingAddress->getTelephone(),
|
| 147 |
+
'FullName'=>$billingAddress->getFirstname().' '.$billingAddress->getLastname(),
|
| 148 |
+
'IsPreAuth'=>false,
|
| 149 |
+
'MerchantTrns'=>$order_number,
|
| 150 |
+
'CustomerTrns'=>'Payment for your order #'.$order_number.'',
|
| 151 |
+
'SourceCode'=>$this->getSourceCode(),
|
| 152 |
+
'PaymentTimeOut'=>600,
|
| 153 |
+
'AllowRecurring'=>false,
|
| 154 |
+
'Tags'=>'Payment from website',
|
| 155 |
+
'AllowTaxCard'=>false,
|
| 156 |
+
//'ServiceId'=>4,
|
| 157 |
+
'ActionUser'=>'NGD',
|
| 158 |
+
'DisableIVR'=>true,
|
| 159 |
+
'DisableCash'=>true,
|
| 160 |
+
'DisableCard'=>false,
|
| 161 |
+
'DisablePayAtHome'=>false
|
| 162 |
+
);
|
| 163 |
+
|
| 164 |
+
foreach($fieldsArr as $key => $val) {
|
| 165 |
+
$postargsAry[] = $key.'='.$val;
|
| 166 |
+
}
|
| 167 |
+
$postargs = implode("&",$postargsAry);
|
| 168 |
+
// Init request
|
| 169 |
+
$ch = curl_init($this->getCreateOrderUrl());
|
| 170 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
| 171 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $postargs);
|
| 172 |
+
curl_setopt($ch, CURLOPT_HEADER, false);
|
| 173 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
| 174 |
+
curl_setopt($ch, CURLOPT_USERPWD, $MerchantId.':'.$APIKey);
|
| 175 |
+
if($this->isTestMode()) {
|
| 176 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
| 177 |
+
}
|
| 178 |
+
else {
|
| 179 |
+
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST,'TLSv1');
|
| 180 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
| 181 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
| 182 |
+
}
|
| 183 |
+
$response = curl_exec($ch);
|
| 184 |
+
curl_close($ch);
|
| 185 |
+
try {
|
| 186 |
+
if(is_object(json_decode($response))){
|
| 187 |
+
$resultObj=json_decode($response);
|
| 188 |
+
}else{
|
| 189 |
+
$result['error'] = Mage::helper('core')->__('Invalid response.');
|
| 190 |
+
return $result;
|
| 191 |
+
}
|
| 192 |
+
} catch( Exception $e ) {
|
| 193 |
+
$result['error'] = $e->getMessage();
|
| 194 |
+
return $result;
|
| 195 |
+
}
|
| 196 |
+
if ($resultObj->ErrorCode==0){ //success when ErrorCode = 0
|
| 197 |
+
$orderId = $resultObj->OrderCode;
|
| 198 |
+
$this->_paymentUrl = $this->getCheckoutUrl().'?ref='.$orderId;
|
| 199 |
+
}
|
| 200 |
+
else{
|
| 201 |
+
$result['error'] = Mage::helper('core')->__($resultObj->ErrorText);
|
| 202 |
+
return $result;
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
$debugData = array(
|
| 206 |
+
'request' => $fieldsArr
|
| 207 |
+
);
|
| 208 |
+
$this->_debug($debugData);
|
| 209 |
+
|
| 210 |
+
return $fieldsArr;
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
/**
|
| 214 |
+
* Get debug flag
|
| 215 |
+
*
|
| 216 |
+
* @return string
|
| 217 |
+
*/
|
| 218 |
+
public function getDebug()
|
| 219 |
+
{
|
| 220 |
+
return Mage::getStoreConfig('payment/' . $this->getCode() . '/debug');
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
public function capture(Varien_Object $payment, $amount)
|
| 224 |
+
{
|
| 225 |
+
$payment->setStatus(self::STATUS_APPROVED)
|
| 226 |
+
->setLastTransId($this->getTransactionId());
|
| 227 |
+
|
| 228 |
+
return $this;
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
public function cancel(Varien_Object $payment)
|
| 232 |
+
{
|
| 233 |
+
$payment->setStatus(self::STATUS_DECLINED)
|
| 234 |
+
->setLastTransId($this->getTransactionId());
|
| 235 |
+
|
| 236 |
+
return $this;
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
public function getRedirectBlockType()
|
| 240 |
+
{
|
| 241 |
+
return $this->_redirectBlockType;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
public function assignData($data)
|
| 245 |
+
{
|
| 246 |
+
//Mage::throwException(implode(',',$data));
|
| 247 |
+
$result = parent::assignData($data);
|
| 248 |
+
return $result;
|
| 249 |
+
}
|
| 250 |
+
/**
|
| 251 |
+
* Return payment method type string
|
| 252 |
+
*
|
| 253 |
+
* @return string
|
| 254 |
+
*/
|
| 255 |
+
public function getPaymentMethodType()
|
| 256 |
+
{
|
| 257 |
+
return $this->_paymentMethod;
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
public function afterSuccessOrder($response)
|
| 261 |
+
{
|
| 262 |
+
$debugData = array(
|
| 263 |
+
'response' => $response
|
| 264 |
+
);
|
| 265 |
+
$this->_debug($debugData);
|
| 266 |
+
$infoModel = Mage::getModel('vivapayments/info');
|
| 267 |
+
$order = Mage::getModel('sales/order');
|
| 268 |
+
$order->loadByIncrementId($response->MerchantTrns);
|
| 269 |
+
$paymentInst = $order->getPayment()->getMethodInstance();
|
| 270 |
+
$paymentInst->setStatus(self::STATUS_APPROVED)
|
| 271 |
+
->setLastTransId($response->TransactionId)
|
| 272 |
+
->setTransactionId($response->TransactionId)
|
| 273 |
+
->setAdditionalInformation(ND_Vivapayments_Model_Info::TRANSACTION_TYPE_ID,$response->TransactionType->TransactionTypeId)
|
| 274 |
+
->setAdditionalInformation(ND_Vivapayments_Model_Info::STATUS_ID,$response->StatusId)
|
| 275 |
+
->setAdditionalInformation(ND_Vivapayments_Model_Info::SOURCE_CODE,$response->SourceCode)
|
| 276 |
+
->setAdditionalInformation(ND_Vivapayments_Model_Info::ORDER_CODE,$response->Order->OrderCode)
|
| 277 |
+
->setAdditionalInformation(ND_Vivapayments_Model_Info::TRANSACTION_TYPE_MESSAGE,$infoModel->_getTransactionTypeIdLabel($response->TransactionType->TransactionTypeId))
|
| 278 |
+
->setAdditionalInformation(ND_Vivapayments_Model_Info::CREDIT_CARD_NUMBER,$infoModel->_getTransactionTypeIdLabel($response->CreditCard->Number))
|
| 279 |
+
->setAdditionalInformation(ND_Vivapayments_Model_Info::ISSUING_BANK,$infoModel->_getTransactionTypeIdLabel($response->CreditCard->IssuingBank))
|
| 280 |
+
->setAdditionalInformation(ND_Vivapayments_Model_Info::CREDIT_CARD_HOLDER,$infoModel->_getTransactionTypeIdLabel($response->CreditCard->CardHolderName))
|
| 281 |
+
->setAdditionalInformation(ND_Vivapayments_Model_Info::CREDIT_CARD_TYPE,$infoModel->_getTransactionTypeIdLabel($response->CreditCard->CardType->Name));
|
| 282 |
+
|
| 283 |
+
$order->sendNewOrderEmail();
|
| 284 |
+
if ($order->canInvoice()) {
|
| 285 |
+
$invoice = $order->prepareInvoice();
|
| 286 |
+
|
| 287 |
+
$invoice->register()->capture();
|
| 288 |
+
Mage::getModel('core/resource_transaction')
|
| 289 |
+
->addObject($invoice)
|
| 290 |
+
->addObject($invoice->getOrder())
|
| 291 |
+
->save();
|
| 292 |
+
}
|
| 293 |
+
$transaction = Mage::getModel('sales/order_payment_transaction');
|
| 294 |
+
$transaction->setTxnId($response->TransactionId);
|
| 295 |
+
$order->getPayment()->setAdditionalInformation(ND_Vivapayments_Model_Info::TRANSACTION_TYPE_ID,$response->TransactionType->TransactionTypeId)
|
| 296 |
+
->setAdditionalInformation(ND_Vivapayments_Model_Info::STATUS_ID,$response->StatusId)
|
| 297 |
+
->setAdditionalInformation(ND_Vivapayments_Model_Info::SOURCE_CODE,$response->SourceCode)
|
| 298 |
+
->setAdditionalInformation(ND_Vivapayments_Model_Info::ORDER_CODE,$response->Order->OrderCode)
|
| 299 |
+
->setAdditionalInformation(ND_Vivapayments_Model_Info::TRANSACTION_TYPE_MESSAGE,$infoModel->_getTransactionTypeIdLabel($response->TransactionType->TransactionTypeId))
|
| 300 |
+
->setAdditionalInformation(ND_Vivapayments_Model_Info::CREDIT_CARD_NUMBER,$infoModel->_getTransactionTypeIdLabel($response->CreditCard->Number))
|
| 301 |
+
->setAdditionalInformation(ND_Vivapayments_Model_Info::ISSUING_BANK,$infoModel->_getTransactionTypeIdLabel($response->CreditCard->IssuingBank))
|
| 302 |
+
->setAdditionalInformation(ND_Vivapayments_Model_Info::CREDIT_CARD_HOLDER,$infoModel->_getTransactionTypeIdLabel($response->CreditCard->CardHolderName))
|
| 303 |
+
->setAdditionalInformation(ND_Vivapayments_Model_Info::CREDIT_CARD_TYPE,$infoModel->_getTransactionTypeIdLabel($response->CreditCard->CardType->Name));
|
| 304 |
+
$transaction->setOrderPaymentObject($order->getPayment())
|
| 305 |
+
->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
|
| 306 |
+
$transaction->save();
|
| 307 |
+
$order_status = Mage::helper('core')->__('Payment is successful.');
|
| 308 |
+
|
| 309 |
+
$order->addStatusToHistory(Mage_Sales_Model_Order::STATE_PROCESSING, $order_status);
|
| 310 |
+
$order->save();
|
| 311 |
+
}
|
| 312 |
+
}
|
app/code/local/ND/Vivapayments/Model/Info.php
ADDED
|
@@ -0,0 +1,476 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class ND_Vivapayments_Model_Info
|
| 3 |
+
{
|
| 4 |
+
/**
|
| 5 |
+
* Cross-models public exchange keys
|
| 6 |
+
*
|
| 7 |
+
* @var string
|
| 8 |
+
*/
|
| 9 |
+
const MERCHANT_ID = 'MerchantId';
|
| 10 |
+
const STATUS_ID = 'StatusId';
|
| 11 |
+
const SOURCE_CODE = 'SourceCode';
|
| 12 |
+
const TRANSACTION_ID = 'TransactionId';
|
| 13 |
+
const MERCH_TXN_REF = 'MerchantTrns';
|
| 14 |
+
const ORDER_CODE = 'OrderCode';
|
| 15 |
+
const TRANSACTION_TYPE_ID = 'TransactionTypeId';
|
| 16 |
+
const TRANSACTION_TYPE_MESSAGE = 'TransactionTypeMessage';
|
| 17 |
+
const CREDIT_CARD_NUMBER = 'CcNumber';
|
| 18 |
+
const ISSUING_BANK = 'IssuingBank';
|
| 19 |
+
const CREDIT_CARD_HOLDER = 'CardHolderName';
|
| 20 |
+
const CREDIT_CARD_TYPE = 'CardType';
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* All payment information map
|
| 24 |
+
*
|
| 25 |
+
* @var array
|
| 26 |
+
*/
|
| 27 |
+
protected $_paymentMap = array(
|
| 28 |
+
self::MERCHANT_ID => 'MerchantId',
|
| 29 |
+
self::STATUS_ID => 'StatusId',
|
| 30 |
+
self::SOURCE_CODE => 'SourceCode',
|
| 31 |
+
self::TRANSACTION_ID => 'TransactionId',
|
| 32 |
+
self::MERCH_TXN_REF => 'MerchantTrns',
|
| 33 |
+
self::ORDER_CODE => 'OrderCode',
|
| 34 |
+
self::TRANSACTION_TYPE_ID => 'TransactionTypeId',
|
| 35 |
+
self::TRANSACTION_TYPE_MESSAGE => 'TransactionTypeMessage',
|
| 36 |
+
self::CREDIT_CARD_NUMBER => 'CcNumber',
|
| 37 |
+
self::ISSUING_BANK => 'IssuingBank',
|
| 38 |
+
self::CREDIT_CARD_HOLDER => 'CardHolderName',
|
| 39 |
+
self::CREDIT_CARD_TYPE => 'CardType'
|
| 40 |
+
);
|
| 41 |
+
|
| 42 |
+
/**
|
| 43 |
+
* Viva payment status possible values
|
| 44 |
+
*
|
| 45 |
+
* @var string
|
| 46 |
+
*/
|
| 47 |
+
const PAYMENTSTATUS_NONE = 'none';
|
| 48 |
+
const PAYMENTSTATUS_PENDING = 'pending';
|
| 49 |
+
const PAYMENTSTATUS_ACCEPTED = 'accepted';
|
| 50 |
+
const PAYMENTSTATUS_REJECTED = 'rejected';
|
| 51 |
+
const PAYMENTSTATUS_REVIEWED = 'reviewed';
|
| 52 |
+
const PAYMENTSTATUS_NOTCHECKED = 'not_checked';
|
| 53 |
+
const PAYMENTSTATUS_SYSREJECT = 'system_rejected';
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* Map of payment information available to customer
|
| 57 |
+
*
|
| 58 |
+
* @var array
|
| 59 |
+
*/
|
| 60 |
+
protected $_paymentPublicMap = array(
|
| 61 |
+
//'',
|
| 62 |
+
);
|
| 63 |
+
|
| 64 |
+
/**
|
| 65 |
+
* Rendered payment map cache
|
| 66 |
+
*
|
| 67 |
+
* @var array
|
| 68 |
+
*/
|
| 69 |
+
protected $_paymentMapFull = array();
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
* All available payment info getter
|
| 73 |
+
*
|
| 74 |
+
* @param Mage_Payment_Model_Info $payment
|
| 75 |
+
* @param bool $labelValuesOnly
|
| 76 |
+
* @return array
|
| 77 |
+
*/
|
| 78 |
+
public function getPaymentInfo(Mage_Payment_Model_Info $payment, $labelValuesOnly = false)
|
| 79 |
+
{
|
| 80 |
+
// collect Viva-specific info
|
| 81 |
+
$result = $this->_getFullInfo(array_values($this->_paymentMap), $payment, $labelValuesOnly);
|
| 82 |
+
|
| 83 |
+
// add last_trans_id
|
| 84 |
+
$label = Mage::helper('payment')->__('Last Transaction ID');
|
| 85 |
+
$value = $payment->getLastTransId();
|
| 86 |
+
if ($labelValuesOnly) {
|
| 87 |
+
$result[$label] = $value;
|
| 88 |
+
} else {
|
| 89 |
+
$result['last_trans_id'] = array('label' => $label, 'value' => $value);
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
return $result;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
/**
|
| 96 |
+
* Public payment info getter
|
| 97 |
+
*
|
| 98 |
+
* @param Mage_Payment_Model_Info $payment
|
| 99 |
+
* @param bool $labelValuesOnly
|
| 100 |
+
* @return array
|
| 101 |
+
*/
|
| 102 |
+
public function getPublicPaymentInfo(Mage_Payment_Model_Info $payment, $labelValuesOnly = false)
|
| 103 |
+
{
|
| 104 |
+
return $this->_getFullInfo($this->_paymentPublicMap, $payment, $labelValuesOnly);
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
/**
|
| 108 |
+
* Grab data from source and map it into payment
|
| 109 |
+
*
|
| 110 |
+
* @param array|Varien_Object|callback $from
|
| 111 |
+
* @param Mage_Payment_Model_Info $payment
|
| 112 |
+
*/
|
| 113 |
+
public function importToPayment($from, Mage_Payment_Model_Info $payment)
|
| 114 |
+
{
|
| 115 |
+
$fullMap = array_merge($this->_paymentMap, $this->_systemMap);
|
| 116 |
+
if (is_object($from)) {
|
| 117 |
+
$from = array($from, 'getDataUsingMethod');
|
| 118 |
+
}
|
| 119 |
+
Varien_Object_Mapper::accumulateByMap($from, array($payment, 'setAdditionalInformation'), $fullMap);
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
/**
|
| 123 |
+
* Grab data from payment and map it into target
|
| 124 |
+
*
|
| 125 |
+
* @param Mage_Payment_Model_Info $payment
|
| 126 |
+
* @param array|Varien_Object|callback $to
|
| 127 |
+
* @param array $map
|
| 128 |
+
* @return array|Varien_Object
|
| 129 |
+
*/
|
| 130 |
+
public function &exportFromPayment(Mage_Payment_Model_Info $payment, $to, array $map = null)
|
| 131 |
+
{
|
| 132 |
+
$fullMap = array_merge($this->_paymentMap, $this->_systemMap);
|
| 133 |
+
Varien_Object_Mapper::accumulateByMap(array($payment, 'getAdditionalInformation'), $to,
|
| 134 |
+
$map ? $map : array_flip($fullMap)
|
| 135 |
+
);
|
| 136 |
+
return $to;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
/**
|
| 140 |
+
* Check whether the payment is in review state
|
| 141 |
+
*
|
| 142 |
+
* @param Mage_Payment_Model_Info $payment
|
| 143 |
+
* @return bool
|
| 144 |
+
*/
|
| 145 |
+
public static function isPaymentReviewRequired(Mage_Payment_Model_Info $payment)
|
| 146 |
+
{
|
| 147 |
+
$paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
|
| 148 |
+
if (self::PAYMENTSTATUS_PENDING === $paymentStatus) {
|
| 149 |
+
$pendingReason = $payment->getAdditionalInformation(self::PENDING_REASON_GLOBAL);
|
| 150 |
+
return !in_array($pendingReason, array('authorization', 'order'));
|
| 151 |
+
}
|
| 152 |
+
return false;
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
/**
|
| 156 |
+
* Check whether fraud order review detected and can be reviewed
|
| 157 |
+
*
|
| 158 |
+
* @param Mage_Payment_Model_Info $payment
|
| 159 |
+
* @return bool
|
| 160 |
+
*/
|
| 161 |
+
public static function isFraudReviewAllowed(Mage_Payment_Model_Info $payment)
|
| 162 |
+
{
|
| 163 |
+
return self::isPaymentReviewRequired($payment)
|
| 164 |
+
&& 1 == $payment->getAdditionalInformation(self::IS_FRAUD_GLOBAL);
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
/**
|
| 168 |
+
* Check whether the payment is completed
|
| 169 |
+
*
|
| 170 |
+
* @param Mage_Payment_Model_Info $payment
|
| 171 |
+
* @return bool
|
| 172 |
+
*/
|
| 173 |
+
public static function isPaymentCompleted(Mage_Payment_Model_Info $payment)
|
| 174 |
+
{
|
| 175 |
+
$paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
|
| 176 |
+
return self::PAYMENTSTATUS_COMPLETED === $paymentStatus;
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
/**
|
| 180 |
+
* Check whether the payment was processed successfully
|
| 181 |
+
*
|
| 182 |
+
* @param Mage_Payment_Model_Info $payment
|
| 183 |
+
* @return bool
|
| 184 |
+
*/
|
| 185 |
+
public static function isPaymentSuccessful(Mage_Payment_Model_Info $payment)
|
| 186 |
+
{
|
| 187 |
+
$paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
|
| 188 |
+
if (in_array($paymentStatus, array(
|
| 189 |
+
self::PAYMENTSTATUS_COMPLETED, self::PAYMENTSTATUS_INPROGRESS, self::PAYMENTSTATUS_REFUNDED,
|
| 190 |
+
self::PAYMENTSTATUS_REFUNDEDPART, self::PAYMENTSTATUS_UNREVERSED, self::PAYMENTSTATUS_PROCESSED,
|
| 191 |
+
))) {
|
| 192 |
+
return true;
|
| 193 |
+
}
|
| 194 |
+
$pendingReason = $payment->getAdditionalInformation(self::PENDING_REASON_GLOBAL);
|
| 195 |
+
return self::PAYMENTSTATUS_PENDING === $paymentStatus
|
| 196 |
+
&& in_array($pendingReason, array('authorization', 'order'));
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
/**
|
| 200 |
+
* Check whether the payment was processed unsuccessfully or failed
|
| 201 |
+
*
|
| 202 |
+
* @param Mage_Payment_Model_Info $payment
|
| 203 |
+
* @return bool
|
| 204 |
+
*/
|
| 205 |
+
public static function isPaymentFailed(Mage_Payment_Model_Info $payment)
|
| 206 |
+
{
|
| 207 |
+
$paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
|
| 208 |
+
return in_array($paymentStatus, array(
|
| 209 |
+
self::PAYMENTSTATUS_REJECTED
|
| 210 |
+
));
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
/**
|
| 214 |
+
* Explain pending payment reason code
|
| 215 |
+
*
|
| 216 |
+
* @param string $code
|
| 217 |
+
* @return string
|
| 218 |
+
*/
|
| 219 |
+
public static function explainPendingReason($code)
|
| 220 |
+
{
|
| 221 |
+
switch ($code) {
|
| 222 |
+
case 'address':
|
| 223 |
+
return Mage::helper('payment')->__('Customer did not include a confirmed address.');
|
| 224 |
+
case 'authorization':
|
| 225 |
+
case 'order':
|
| 226 |
+
return Mage::helper('payment')->__('The payment is authorized but not settled.');
|
| 227 |
+
case 'echeck':
|
| 228 |
+
return Mage::helper('payment')->__('The payment eCheck is not yet cleared.');
|
| 229 |
+
case 'intl':
|
| 230 |
+
return Mage::helper('payment')->__('Merchant holds a non-U.S. account and does not have a withdrawal mechanism.');
|
| 231 |
+
case 'multi-currency': // break is intentionally omitted
|
| 232 |
+
case 'multi_currency': // break is intentionally omitted
|
| 233 |
+
case 'multicurrency':
|
| 234 |
+
return Mage::helper('payment')->__('The payment curency does not match any of the merchant\'s balances currency.');
|
| 235 |
+
case 'paymentreview':
|
| 236 |
+
return Mage::helper('payment')->__('The payment is pending while it is being reviewed by Viva for risk.');
|
| 237 |
+
case 'unilateral':
|
| 238 |
+
return Mage::helper('payment')->__('The payment is pending because it was made to an email address that is not yet registered or confirmed.');
|
| 239 |
+
case 'verify':
|
| 240 |
+
return Mage::helper('payment')->__('The merchant account is not yet verified.');
|
| 241 |
+
case 'upgrade':
|
| 242 |
+
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.');
|
| 243 |
+
case 'none': // break is intentionally omitted
|
| 244 |
+
case 'other': // break is intentionally omitted
|
| 245 |
+
default:
|
| 246 |
+
return Mage::helper('payment')->__('Unknown reason. Please contact Viva customer service.');
|
| 247 |
+
}
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
/**
|
| 251 |
+
* Explain the refund or chargeback reason code
|
| 252 |
+
*
|
| 253 |
+
* @param $code
|
| 254 |
+
* @return string
|
| 255 |
+
*/
|
| 256 |
+
public static function explainReasonCode($code)
|
| 257 |
+
{
|
| 258 |
+
switch ($code) {
|
| 259 |
+
case 'chargeback':
|
| 260 |
+
return Mage::helper('payment')->__('Chargeback by customer.');
|
| 261 |
+
case 'guarantee':
|
| 262 |
+
return Mage::helper('payment')->__('Customer triggered a money-back guarantee.');
|
| 263 |
+
case 'buyer-complaint':
|
| 264 |
+
return Mage::helper('payment')->__('Customer complaint.');
|
| 265 |
+
case 'refund':
|
| 266 |
+
return Mage::helper('payment')->__('Refund issued by merchant.');
|
| 267 |
+
case 'adjustment_reversal':
|
| 268 |
+
return Mage::helper('payment')->__('Reversal of an adjustment.');
|
| 269 |
+
case 'chargeback_reimbursement':
|
| 270 |
+
return Mage::helper('payment')->__('Reimbursement for a chargeback.');
|
| 271 |
+
case 'chargeback_settlement':
|
| 272 |
+
return Mage::helper('payment')->__('Settlement of a chargeback.');
|
| 273 |
+
case 'none': // break is intentionally omitted
|
| 274 |
+
case 'other':
|
| 275 |
+
default:
|
| 276 |
+
return Mage::helper('payment')->__('Unknown reason. Please contact Viva customer service.');
|
| 277 |
+
}
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
/**
|
| 281 |
+
* Whether a reversal/refund can be disputed with Viva
|
| 282 |
+
*
|
| 283 |
+
* @param string $code
|
| 284 |
+
* @return bool;
|
| 285 |
+
*/
|
| 286 |
+
public static function isReversalDisputable($code)
|
| 287 |
+
{
|
| 288 |
+
switch ($code) {
|
| 289 |
+
case 'none':
|
| 290 |
+
case 'other':
|
| 291 |
+
case 'chargeback':
|
| 292 |
+
case 'buyer-complaint':
|
| 293 |
+
case 'adjustment_reversal':
|
| 294 |
+
return true;
|
| 295 |
+
case 'guarantee':
|
| 296 |
+
case 'refund':
|
| 297 |
+
case 'chargeback_reimbursement':
|
| 298 |
+
case 'chargeback_settlement':
|
| 299 |
+
default:
|
| 300 |
+
return false;
|
| 301 |
+
}
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
/**
|
| 305 |
+
* Render info item
|
| 306 |
+
*
|
| 307 |
+
* @param array $keys
|
| 308 |
+
* @param Mage_Payment_Model_Info $payment
|
| 309 |
+
* @param bool $labelValuesOnly
|
| 310 |
+
*/
|
| 311 |
+
protected function _getFullInfo(array $keys, Mage_Payment_Model_Info $payment, $labelValuesOnly)
|
| 312 |
+
{
|
| 313 |
+
$result = array();
|
| 314 |
+
foreach ($keys as $key) {
|
| 315 |
+
if (!isset($this->_paymentMapFull[$key])) {
|
| 316 |
+
$this->_paymentMapFull[$key] = array();
|
| 317 |
+
}
|
| 318 |
+
if (!isset($this->_paymentMapFull[$key]['label'])) {
|
| 319 |
+
if (!$payment->hasAdditionalInformation($key)) {
|
| 320 |
+
$this->_paymentMapFull[$key]['label'] = false;
|
| 321 |
+
$this->_paymentMapFull[$key]['value'] = false;
|
| 322 |
+
} else {
|
| 323 |
+
$value = $payment->getAdditionalInformation($key);
|
| 324 |
+
$this->_paymentMapFull[$key]['label'] = $this->_getLabel($key);
|
| 325 |
+
$this->_paymentMapFull[$key]['value'] = $value;
|
| 326 |
+
//$this->_paymentMapFull[$key]['value'] = $this->_getValue($value, $key);
|
| 327 |
+
}
|
| 328 |
+
}
|
| 329 |
+
if (!empty($this->_paymentMapFull[$key]['value'])) {
|
| 330 |
+
if ($labelValuesOnly) {
|
| 331 |
+
$result[$this->_paymentMapFull[$key]['label']] = $this->_paymentMapFull[$key]['value'];
|
| 332 |
+
} else {
|
| 333 |
+
$result[$key] = $this->_paymentMapFull[$key];
|
| 334 |
+
}
|
| 335 |
+
}
|
| 336 |
+
}
|
| 337 |
+
return $result;
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
/**
|
| 341 |
+
* Render info item labels
|
| 342 |
+
*
|
| 343 |
+
* @param string $key
|
| 344 |
+
*/
|
| 345 |
+
public function _getLabel($key)
|
| 346 |
+
{
|
| 347 |
+
switch ($key) {
|
| 348 |
+
case 'MerchantId':
|
| 349 |
+
return Mage::helper('payment')->__('Merchant Id');
|
| 350 |
+
case 'StatusId':
|
| 351 |
+
return Mage::helper('payment')->__('Status Id');
|
| 352 |
+
case 'SourceCode':
|
| 353 |
+
return Mage::helper('payment')->__('Source Code');
|
| 354 |
+
case 'TransactionId':
|
| 355 |
+
return Mage::helper('payment')->__('Transaction Id');
|
| 356 |
+
case 'MerchantTrns':
|
| 357 |
+
return Mage::helper('payment')->__('Merchant Transaction Reference');
|
| 358 |
+
case 'OrderCode':
|
| 359 |
+
return Mage::helper('payment')->__('Order Code');
|
| 360 |
+
case 'TransactionTypeId':
|
| 361 |
+
return Mage::helper('payment')->__('Transaction Type Id');
|
| 362 |
+
case 'TransactionTypeMessage':
|
| 363 |
+
return Mage::helper('payment')->__('Transaction Type Message');
|
| 364 |
+
case 'CcNumber':
|
| 365 |
+
return Mage::helper('payment')->__('Credit Card Number');
|
| 366 |
+
case 'IssuingBank':
|
| 367 |
+
return Mage::helper('payment')->__('Issuing Bank');
|
| 368 |
+
case 'CardHolderName':
|
| 369 |
+
return Mage::helper('payment')->__('Card Holder Name');
|
| 370 |
+
case 'CardType':
|
| 371 |
+
return Mage::helper('payment')->__('Card Type');
|
| 372 |
+
}
|
| 373 |
+
return '';
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
/**
|
| 377 |
+
* Apply a filter upon value getting
|
| 378 |
+
*
|
| 379 |
+
* @param string $value
|
| 380 |
+
* @param string $key
|
| 381 |
+
* @return string
|
| 382 |
+
*/
|
| 383 |
+
public function _getValue($value, $key)
|
| 384 |
+
{
|
| 385 |
+
$label = '';
|
| 386 |
+
switch ($key) {
|
| 387 |
+
case 'vpc_avs_code':
|
| 388 |
+
$label = $this->_getAvsLabel($value);
|
| 389 |
+
break;
|
| 390 |
+
case 'vpc_cvv2_match':
|
| 391 |
+
$label = $this->_getCvv2Label($value);
|
| 392 |
+
break;
|
| 393 |
+
default:
|
| 394 |
+
return $value;
|
| 395 |
+
}
|
| 396 |
+
return sprintf('#%s%s', $value, $value == $label ? '' : ': ' . $label);
|
| 397 |
+
}
|
| 398 |
+
|
| 399 |
+
/**
|
| 400 |
+
* Attempt to convert StatusId check result code into label
|
| 401 |
+
*
|
| 402 |
+
* @param string $value
|
| 403 |
+
* @return string
|
| 404 |
+
*/
|
| 405 |
+
public function _getStatusIdLabel($value)
|
| 406 |
+
{
|
| 407 |
+
switch ($value) {
|
| 408 |
+
case 'E':
|
| 409 |
+
return Mage::helper('payment')->__('The transaction was not completed because of an error');
|
| 410 |
+
case 'A': // international "A"
|
| 411 |
+
return Mage::helper('payment')->__('The transaction is in progress');
|
| 412 |
+
case 'M':
|
| 413 |
+
return Mage::helper('payment')->__('The cardholder has disputed the transaction with the issuing Bank');
|
| 414 |
+
case 'MA': // international "N"
|
| 415 |
+
return Mage::helper('payment')->__('Dispute Awaiting Response');
|
| 416 |
+
case 'MI':
|
| 417 |
+
return Mage::helper('payment')->__('Dispute in Progress');
|
| 418 |
+
case 'ML': // international "X"
|
| 419 |
+
return Mage::helper('payment')->__('A disputed transaction has been refunded (Dispute Lost)');
|
| 420 |
+
case 'MW': // UK-specific "X"
|
| 421 |
+
return Mage::helper('payment')->__('Dispute Won');
|
| 422 |
+
case 'MS':
|
| 423 |
+
return Mage::helper('payment')->__('Suspected Dispute');
|
| 424 |
+
case 'X':
|
| 425 |
+
return Mage::helper('payment')->__('The transaction was cancelled by the merchant');
|
| 426 |
+
case 'R':
|
| 427 |
+
return Mage::helper('payment')->__('The transaction has been fully or partially refunded');
|
| 428 |
+
case 'F':
|
| 429 |
+
return Mage::helper('payment')->__('The transaction has been completed successfully');
|
| 430 |
+
default:
|
| 431 |
+
return $value;
|
| 432 |
+
}
|
| 433 |
+
}
|
| 434 |
+
|
| 435 |
+
/**
|
| 436 |
+
* Attempt to convert TransactionTypeId check result code into label
|
| 437 |
+
*
|
| 438 |
+
* @param string $value
|
| 439 |
+
* @return string
|
| 440 |
+
*/
|
| 441 |
+
public function _getTransactionTypeIdLabel($value)
|
| 442 |
+
{
|
| 443 |
+
switch ($value) {
|
| 444 |
+
case '0':
|
| 445 |
+
return Mage::helper('payment')->__('Capture - A Capture event of a preAuthorized transaction');
|
| 446 |
+
case '1':
|
| 447 |
+
return Mage::helper('payment')->__('PreAuth - Authorization hold');
|
| 448 |
+
case '3':
|
| 449 |
+
return Mage::helper('payment')->__('UpdateTaxCard - Tax Card receipt transaction');
|
| 450 |
+
case '4':
|
| 451 |
+
return Mage::helper('payment')->__('RefundCard - Refund transaction');
|
| 452 |
+
case '5':
|
| 453 |
+
return Mage::helper('payment')->__('ChargeCard - Card payment transaction');
|
| 454 |
+
case '6':
|
| 455 |
+
return Mage::helper('payment')->__('Installments - A card payment that will be done with installments');
|
| 456 |
+
case '7':
|
| 457 |
+
return Mage::helper('payment')->__('Void - A cancelled transaction');
|
| 458 |
+
case '13':
|
| 459 |
+
return Mage::helper('payment')->__('Claim Refund - Refund transaction for a claimed transaction');
|
| 460 |
+
case '15':
|
| 461 |
+
return Mage::helper('payment')->__('Dias - Payment made through the DIAS system');
|
| 462 |
+
case '16':
|
| 463 |
+
return Mage::helper('payment')->__('PaymentFromReseller - Cash Payments, through the Viva Payments Authorised Resellers Network');
|
| 464 |
+
case '18':
|
| 465 |
+
return Mage::helper('payment')->__('RefundInstallments - A Refunded installment');
|
| 466 |
+
case '19':
|
| 467 |
+
return Mage::helper('payment')->__('Clearance - Clearance of a transactions batch');
|
| 468 |
+
case '22':
|
| 469 |
+
return Mage::helper('payment')->__('ReverseTaxCard - Refund previous tax card transaction');
|
| 470 |
+
case '24':
|
| 471 |
+
return Mage::helper('payment')->__('BankTranfer - Bank Transfer command from the merchant\'s wallet to their IBAN');
|
| 472 |
+
default:
|
| 473 |
+
return $value;
|
| 474 |
+
}
|
| 475 |
+
}
|
| 476 |
+
}
|
app/code/local/ND/Vivapayments/Model/System/Config/Source/Transaction.php
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class ND_Vivapayments_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/Vivapayments/controllers/CheckoutController.php
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class ND_Vivapayments_CheckoutController extends ND_Vivapayments_Controller_Abstract
|
| 4 |
+
{
|
| 5 |
+
protected $_redirectBlockType = 'vivapayments/checkout_redirect';
|
| 6 |
+
|
| 7 |
+
public function responseAction()
|
| 8 |
+
{
|
| 9 |
+
$responseParams = $this->getRequest()->getParams();
|
| 10 |
+
if(!empty($responseParams['t'])) {
|
| 11 |
+
$infoModel = Mage::getModel('vivapayments/info');
|
| 12 |
+
$checkoutModel = Mage::getModel('vivapayments/checkout');
|
| 13 |
+
$response = Mage::helper('vivapayments')->getTransactionDetails($responseParams['t']);
|
| 14 |
+
if($response->ErrorCode==0) {
|
| 15 |
+
$transaction = $response->Transactions[0];
|
| 16 |
+
if(Mage::helper('vivapayments')->validateOrder($transaction->MerchantTrns) && $transaction->StatusId=='F') {
|
| 17 |
+
$checkoutModel->afterSuccessOrder($transaction);
|
| 18 |
+
$this->_redirect('checkout/onepage/success');
|
| 19 |
+
return;
|
| 20 |
+
}
|
| 21 |
+
else {
|
| 22 |
+
Mage::getSingleton('core/session')->addError($this->__('Invalid transaction!'));
|
| 23 |
+
$this->_redirect('checkout/cart');
|
| 24 |
+
return;
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
else {
|
| 28 |
+
if(!empty($response->Transactions[0])) {
|
| 29 |
+
$transaction = $response->Transactions[0];
|
| 30 |
+
$order = Mage::getModel('sales/order');
|
| 31 |
+
$order->loadByIncrementId($transaction->MerchantTrns);
|
| 32 |
+
$order->addStatusToHistory($order->getStatus(), $response->ErrorText);
|
| 33 |
+
$order->save();
|
| 34 |
+
$error = $response->ErrorText;
|
| 35 |
+
}
|
| 36 |
+
else {
|
| 37 |
+
$error = $this->__('There is an error occured during transaction. Please try again!');
|
| 38 |
+
}
|
| 39 |
+
Mage::getSingleton('core/session')->addError($error);
|
| 40 |
+
$this->_redirect('checkout/cart');
|
| 41 |
+
return;
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
else {
|
| 45 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('core')->__('Trasaction is failed!'));
|
| 46 |
+
$this->_redirect('checkout/cart');
|
| 47 |
+
return;
|
| 48 |
+
}
|
| 49 |
+
}
|
| 50 |
+
}
|
app/code/local/ND/Vivapayments/etc/config.xml
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<ND_Vivapayments>
|
| 5 |
+
<version>0.1.1</version>
|
| 6 |
+
</ND_Vivapayments>
|
| 7 |
+
</modules>
|
| 8 |
+
<global>
|
| 9 |
+
<models>
|
| 10 |
+
<vivapayments>
|
| 11 |
+
<class>ND_Vivapayments_Model</class>
|
| 12 |
+
</vivapayments>
|
| 13 |
+
</models>
|
| 14 |
+
<helpers>
|
| 15 |
+
<vivapayments>
|
| 16 |
+
<class>ND_Vivapayments_Helper</class>
|
| 17 |
+
</vivapayments>
|
| 18 |
+
</helpers>
|
| 19 |
+
<resources>
|
| 20 |
+
<vivapayments_setup>
|
| 21 |
+
<setup>
|
| 22 |
+
<module>ND_Vivapayments</module>
|
| 23 |
+
</setup>
|
| 24 |
+
<connection>
|
| 25 |
+
<use>core_setup</use>
|
| 26 |
+
</connection>
|
| 27 |
+
</vivapayments_setup>
|
| 28 |
+
<vivapayments_write>
|
| 29 |
+
<connection>
|
| 30 |
+
<use>core_write</use>
|
| 31 |
+
</connection>
|
| 32 |
+
</vivapayments_write>
|
| 33 |
+
<vivapayments_read>
|
| 34 |
+
<connection>
|
| 35 |
+
<use>core_read</use>
|
| 36 |
+
</connection>
|
| 37 |
+
</vivapayments_read>
|
| 38 |
+
</resources>
|
| 39 |
+
<blocks>
|
| 40 |
+
<vivapayments><class>ND_Vivapayments_Block</class></vivapayments>
|
| 41 |
+
</blocks>
|
| 42 |
+
</global>
|
| 43 |
+
<frontend>
|
| 44 |
+
<secure_url>
|
| 45 |
+
<vivapayments_checkout>/vivapayments/checkout</vivapayments_checkout>
|
| 46 |
+
</secure_url>
|
| 47 |
+
<routers>
|
| 48 |
+
<vivapayments>
|
| 49 |
+
<use>standard</use>
|
| 50 |
+
<args>
|
| 51 |
+
<module>ND_Vivapayments</module>
|
| 52 |
+
<frontName>vivapayments</frontName>
|
| 53 |
+
</args>
|
| 54 |
+
</vivapayments>
|
| 55 |
+
</routers>
|
| 56 |
+
<layout>
|
| 57 |
+
<updates>
|
| 58 |
+
<vivapayments>
|
| 59 |
+
<file>vivapayments.xml</file>
|
| 60 |
+
</vivapayments>
|
| 61 |
+
</updates>
|
| 62 |
+
</layout>
|
| 63 |
+
</frontend>
|
| 64 |
+
<default>
|
| 65 |
+
<payment>
|
| 66 |
+
<vivapayments_checkout>
|
| 67 |
+
<merchant_id backend_model="adminhtml/system_config_backend_encrypted"/>
|
| 68 |
+
<model>vivapayments/checkout</model>
|
| 69 |
+
<title>Viva Payments</title>
|
| 70 |
+
<order_status>pending</order_status>
|
| 71 |
+
<source_code>Default</source_code>
|
| 72 |
+
<allowspecific>0</allowspecific>
|
| 73 |
+
</vivapayments_checkout>
|
| 74 |
+
</payment>
|
| 75 |
+
</default>
|
| 76 |
+
</config>
|
app/code/local/ND/Vivapayments/etc/system.xml
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<sections>
|
| 4 |
+
<payment>
|
| 5 |
+
<groups>
|
| 6 |
+
<vivapayments_checkout translate="label" module="payment">
|
| 7 |
+
<label>Viva Payments</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 |
+
<source_code translate="label">
|
| 49 |
+
<label>Website/App Source Code</label>
|
| 50 |
+
<frontend_type>text</frontend_type>
|
| 51 |
+
<comment>For Test source code <a target="_blank" href="http://demo.vivapayments.com/selfcare/en-us/sources/paymentsources">Click here</a>. For Live source code <a target="_blank" href="http://www.vivapayments.com/selfcare/en-us/sources/paymentsources">Click here</a>.</comment>
|
| 52 |
+
<sort_order>50</sort_order>
|
| 53 |
+
<show_in_default>1</show_in_default>
|
| 54 |
+
<show_in_website>1</show_in_website>
|
| 55 |
+
<show_in_store>0</show_in_store>
|
| 56 |
+
</source_code>
|
| 57 |
+
<test_mode translate="label">
|
| 58 |
+
<label>Test Mode</label>
|
| 59 |
+
<frontend_type>select</frontend_type>
|
| 60 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 61 |
+
<sort_order>70</sort_order>
|
| 62 |
+
<show_in_default>1</show_in_default>
|
| 63 |
+
<show_in_website>1</show_in_website>
|
| 64 |
+
<show_in_store>0</show_in_store>
|
| 65 |
+
</test_mode>
|
| 66 |
+
<order_status translate="label">
|
| 67 |
+
<label>New order status</label>
|
| 68 |
+
<frontend_type>select</frontend_type>
|
| 69 |
+
<source_model>adminhtml/system_config_source_order_status_newprocessing</source_model>
|
| 70 |
+
<sort_order>90</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 |
+
</order_status>
|
| 75 |
+
<debug translate="label">
|
| 76 |
+
<label>Debug</label>
|
| 77 |
+
<frontend_type>select</frontend_type>
|
| 78 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 79 |
+
<sort_order>100</sort_order>
|
| 80 |
+
<show_in_default>1</show_in_default>
|
| 81 |
+
<show_in_website>1</show_in_website>
|
| 82 |
+
<show_in_store>0</show_in_store>
|
| 83 |
+
</debug>
|
| 84 |
+
<allowspecific translate="label">
|
| 85 |
+
<label>Payment from applicable countries</label>
|
| 86 |
+
<frontend_type>allowspecific</frontend_type>
|
| 87 |
+
<sort_order>110</sort_order>
|
| 88 |
+
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
|
| 89 |
+
<show_in_default>1</show_in_default>
|
| 90 |
+
<show_in_website>1</show_in_website>
|
| 91 |
+
<show_in_store>1</show_in_store>
|
| 92 |
+
</allowspecific>
|
| 93 |
+
<specificcountry translate="label">
|
| 94 |
+
<label>Payment from Specific countries</label>
|
| 95 |
+
<frontend_type>multiselect</frontend_type>
|
| 96 |
+
<sort_order>120</sort_order>
|
| 97 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
| 98 |
+
<show_in_default>1</show_in_default>
|
| 99 |
+
<show_in_website>1</show_in_website>
|
| 100 |
+
<show_in_store>1</show_in_store>
|
| 101 |
+
</specificcountry>
|
| 102 |
+
</fields>
|
| 103 |
+
</vivapayments_checkout>
|
| 104 |
+
</groups>
|
| 105 |
+
</payment>
|
| 106 |
+
</sections>
|
| 107 |
+
</config>
|
app/design/frontend/base/default/layout/vivapayments.xml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
|
| 3 |
+
<layout version="0.1.0">
|
| 4 |
+
<vivapayments_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="vivapayments/checkout_failure" name="vivapayments_checkout_failure" template="vivapayments/checkout/failure.phtml"></block>
|
| 10 |
+
</reference>
|
| 11 |
+
</vivapayments_checkout_failure>
|
| 12 |
+
|
| 13 |
+
<vivapayments_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="vivapayments/checkout_response" name="vivapayments_checkout_response" template="vivapayments/checkout/response.phtml"></block>
|
| 19 |
+
</reference>
|
| 20 |
+
</vivapayments_checkout_response>
|
| 21 |
+
</layout>
|
app/design/frontend/base/default/template/vivapayments/checkout/form.phtml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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-GR"><?php echo $this->__('Greek');?></option>
|
| 10 |
+
<option value="en-US"><?php echo $this->__('English');?></option>
|
| 11 |
+
</select>
|
| 12 |
+
</div>
|
| 13 |
+
</li>
|
| 14 |
+
<li>
|
| 15 |
+
<?php echo $this->__('You will be redirected to Viva Payments website when you place an order.') ?>
|
| 16 |
+
</li>
|
| 17 |
+
</ul>
|
| 18 |
+
</fieldset>
|
app/design/frontend/base/default/template/vivapayments/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/vivapayments/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 |
+
<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-GR"><?php echo $this->__('Greek');?></option>
|
| 11 |
+
<option value="en-US"><?php echo $this->__('English');?></option>
|
| 12 |
+
</select>
|
| 13 |
+
</div>
|
| 14 |
+
</li>
|
| 15 |
+
<li>
|
| 16 |
+
<?php echo $this->__('You will be redirected to Viva Payments website when you place an order.') ?>
|
| 17 |
+
</li>
|
| 18 |
+
</ul>
|
| 19 |
+
</fieldset>
|
app/design/frontend/base/default/template/vivapayments/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_Vivapayments.xml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<ND_Vivapayments>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>local</codePool>
|
| 7 |
+
<depends>
|
| 8 |
+
<Mage_Payment/>
|
| 9 |
+
</depends>
|
| 10 |
+
</ND_Vivapayments>
|
| 11 |
+
</modules>
|
| 12 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>ND_Vivapayments</name>
|
| 4 |
+
<version>0.1.1</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>A payment gateway integration of Viva Payments.</summary>
|
| 10 |
+
<description>This extension integrates payment method of Viva Payment (Greece).
|
| 11 |
+

|
| 12 |
+
It uses redirect method for customer to make payment through www.vivapayments.com. It accepts all major credit cards.
|
| 13 |
+

|
| 14 |
+
- American Express
|
| 15 |
+
- Visa, Visa Electron
|
| 16 |
+
- MasterCard
|
| 17 |
+
- Maestro
|
| 18 |
+
- Diners</description>
|
| 19 |
+
<notes>First Stable Release Version 0.1.1</notes>
|
| 20 |
+
<authors><author><name>Nikul Doshi</name><user>nikulonline</user><email>nikulonline@gmail.com</email></author></authors>
|
| 21 |
+
<date>2014-10-28</date>
|
| 22 |
+
<time>14:23:55</time>
|
| 23 |
+
<contents><target name="magelocal"><dir name="ND"><dir name="Vivapayments"><dir name="Block"><dir name="Checkout"><file name="Failure.php" hash="b94ea5e569879ac7abf65a80612e3320"/><file name="Form.php" hash="e95040814c487d51ae5a0fbf985f7d9b"/><file name="Redirect.php" hash="5980080a2956f8be961a1064acd05d24"/><file name="Response.php" hash="dc5aeb36aa923efe4c235a3b885e5995"/></dir><file name="Form.php" hash="cfbd3859184f424858e7b08183d555b0"/><file name="Info.php" hash="280b8ee1a193b010154493587c417af0"/><dir name="Payment"><file name="Info.php" hash="53746cf30d6dc0c1b9acdb10b9684994"/></dir></dir><dir name="Controller"><file name="Abstract.php" hash="55233b4a19b41e5fd551af3957da7d1f"/></dir><dir name="Helper"><file name="Data.php" hash="90c8524ba0571360b9add0bb6454f731"/></dir><dir name="Model"><file name="Checkout.php" hash="0fa2d65868503d6e4980815001abccb8"/><file name="Info.php" hash="90b2f91cb71e773596eb5226564138f8"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Transaction.php" hash="1c8f3c15744e67b527a846f70d407d46"/></dir></dir></dir></dir><dir name="controllers"><file name="CheckoutController.php" hash="05e4a3e45b6eeb5a3bc55965be12b8c7"/></dir><dir name="etc"><file name="config.xml" hash="eacaa3a52c695be8de7c984c9501999f"/><file name="system.xml" hash="f47d2b49a215e906d65c089b55d91e3e"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="vivapayments.xml" hash="0e80a8dd9a78be7094e2d403c3108c98"/></dir><dir name="template"><dir name="vivapayments"><dir name="checkout"><file name="form.phtml" hash="0f1edde7b3758c0f8c55675fcccebf80"/><file name="response.phtml" hash="8a3f5b9be4901568104472399b1b1398"/></dir><file name="form.phtml" hash="57b33e4bff7698884c893e9b7fc420f9"/><file name="info.phtml" hash="c13fe64ae97929b3b732d25b695527ea"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="ND_Vivapayments.xml" hash="634f25d66576733dc3d2209bfa8e5be6"/></dir></target></contents>
|
| 24 |
+
<compatible/>
|
| 25 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 26 |
+
</package>
|
