Version Notes
Support for multi currencies.
Download this release
Release Info
| Developer | Magento Core Team |
| Extension | Phoenix_Worldpay |
| Version | 1.1 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0 to 1.1
- app/code/community/Phoenix/Worldpay/Model/Abstract.php +0 -164
- app/code/community/Phoenix/Worldpay/Model/Cc.php +145 -10
- app/code/community/Phoenix/Worldpay/Model/Shared.php +0 -169
- app/code/community/Phoenix/Worldpay/controllers/ProcessingController.php +11 -2
- app/code/community/Phoenix/Worldpay/etc/config.xml +2 -1
- app/code/community/Phoenix/Worldpay/etc/system.xml +11 -1
- package.xml +5 -6
app/code/community/Phoenix/Worldpay/Model/Abstract.php
DELETED
|
@@ -1,164 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* Magento
|
| 4 |
-
*
|
| 5 |
-
* NOTICE OF LICENSE
|
| 6 |
-
*
|
| 7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
-
* It is also available through the world-wide-web at this URL:
|
| 10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
-
* If you did not receive a copy of the license and are unable to
|
| 12 |
-
* obtain it through the world-wide-web, please send an email
|
| 13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
-
*
|
| 15 |
-
* @category Phoenix
|
| 16 |
-
* @package Phoenix_Worldpay
|
| 17 |
-
* @copyright Copyright (c) 2009 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
|
| 18 |
-
*/
|
| 19 |
-
|
| 20 |
-
abstract class Phoenix_Worldpay_Model_Abstract extends Mage_Payment_Model_Method_Abstract
|
| 21 |
-
|
| 22 |
-
{
|
| 23 |
-
|
| 24 |
-
/**
|
| 25 |
-
* unique internal payment method identifier
|
| 26 |
-
*
|
| 27 |
-
* @var string [a-z0-9_]
|
| 28 |
-
**/
|
| 29 |
-
protected $_code = 'worldpay_abstract';
|
| 30 |
-
|
| 31 |
-
protected $_isGateway = false;
|
| 32 |
-
protected $_canAuthorize = true;
|
| 33 |
-
protected $_canCapture = true;
|
| 34 |
-
protected $_canCapturePartial = false;
|
| 35 |
-
protected $_canRefund = false;
|
| 36 |
-
protected $_canVoid = false;
|
| 37 |
-
protected $_canUseInternal = false;
|
| 38 |
-
protected $_canUseCheckout = true;
|
| 39 |
-
protected $_canUseForMultishipping = true;
|
| 40 |
-
|
| 41 |
-
protected $_paymentMethod = 'abstract';
|
| 42 |
-
protected $_defaultLocale = 'en';
|
| 43 |
-
|
| 44 |
-
protected $_testUrl = 'https://select-test.worldpay.com/';
|
| 45 |
-
protected $_liveUrl = 'https://select.worldpay.com/';
|
| 46 |
-
|
| 47 |
-
protected $_order;
|
| 48 |
-
|
| 49 |
-
/**
|
| 50 |
-
* Get order model
|
| 51 |
-
*
|
| 52 |
-
* @return Mage_Sales_Model_Order
|
| 53 |
-
*/
|
| 54 |
-
public function getOrder()
|
| 55 |
-
{
|
| 56 |
-
if (!$this->_order) {
|
| 57 |
-
$paymentInfo = $this->getInfoInstance();
|
| 58 |
-
$this->_order = Mage::getModel('sales/order')
|
| 59 |
-
->loadByIncrementId($paymentInfo->getOrder()->getRealOrderId());
|
| 60 |
-
}
|
| 61 |
-
return $this->_order;
|
| 62 |
-
}
|
| 63 |
-
|
| 64 |
-
public function getOrderPlaceRedirectUrl()
|
| 65 |
-
{
|
| 66 |
-
return Mage::getUrl('worldpay/processing/redirect');
|
| 67 |
-
}
|
| 68 |
-
|
| 69 |
-
public function capture(Varien_Object $payment, $amount)
|
| 70 |
-
{
|
| 71 |
-
$payment->setStatus(self::STATUS_APPROVED)
|
| 72 |
-
->setLastTransId($this->getTransactionId());
|
| 73 |
-
|
| 74 |
-
return $this;
|
| 75 |
-
}
|
| 76 |
-
|
| 77 |
-
public function cancel(Varien_Object $payment)
|
| 78 |
-
{
|
| 79 |
-
$payment->setStatus(self::STATUS_DECLINED)
|
| 80 |
-
->setLastTransId($this->getTransactionId());
|
| 81 |
-
|
| 82 |
-
return $this;
|
| 83 |
-
}
|
| 84 |
-
|
| 85 |
-
/**
|
| 86 |
-
* Return payment method type string
|
| 87 |
-
*
|
| 88 |
-
* @return string
|
| 89 |
-
*/
|
| 90 |
-
public function getPaymentMethodType()
|
| 91 |
-
{
|
| 92 |
-
return $this->_paymentMethod;
|
| 93 |
-
}
|
| 94 |
-
|
| 95 |
-
public function getUrl()
|
| 96 |
-
{
|
| 97 |
-
if ($this->getConfigData('transaction_mode') == 'live')
|
| 98 |
-
return $this->_liveUrl;
|
| 99 |
-
return $this->_testUrl;
|
| 100 |
-
}
|
| 101 |
-
|
| 102 |
-
/**
|
| 103 |
-
* prepare params array to send it to gateway page via POST
|
| 104 |
-
*
|
| 105 |
-
* @return array
|
| 106 |
-
*/
|
| 107 |
-
public function getFormFields()
|
| 108 |
-
{
|
| 109 |
-
$amount = number_format($this->getOrder()->getBaseGrandTotal(),2,'.','');
|
| 110 |
-
$billing = $this->getOrder()->getBillingAddress();
|
| 111 |
-
$currency = $this->getOrder()->getBaseCurrencyCode();
|
| 112 |
-
$street = $billing->getStreet();
|
| 113 |
-
$hashStr = '';
|
| 114 |
-
|
| 115 |
-
$locale = explode('_', Mage::app()->getLocale()->getLocaleCode());
|
| 116 |
-
if (is_array($locale) && !empty($locale))
|
| 117 |
-
$locale = $locale[0];
|
| 118 |
-
else
|
| 119 |
-
$locale = $this->getDefaultLocale();
|
| 120 |
-
|
| 121 |
-
$params = array(
|
| 122 |
-
'instId' => $this->getConfigData('inst_id'),
|
| 123 |
-
'cartId' => $this->getOrder()->getRealOrderId() . '-' . $this->getOrder()->getQuoteId(),
|
| 124 |
-
'authMode' => ($this->getConfigData('request_type') == self::ACTION_AUTHORIZE) ? 'E' : 'A',
|
| 125 |
-
'testMode' => ($this->getConfigData('transaction_mode') == 'test') ? '100' : '0',
|
| 126 |
-
'amount' => $amount,
|
| 127 |
-
'currency' => $currency,
|
| 128 |
-
'desc' => Mage::helper('worldpay')->__('Your purchase at') . ' ' . Mage::app()->getStore()->getName(),
|
| 129 |
-
'name' => Mage::helper('core')->removeAccents($billing->getFirstname().' '.$billing->getLastname()),
|
| 130 |
-
'address' => Mage::helper('core')->removeAccents($street[0]).' '.Mage::helper('core')->removeAccents($billing->getCity()),
|
| 131 |
-
'postcode' => $billing->getPostcode() ,
|
| 132 |
-
'country' => $billing->getCountry(),
|
| 133 |
-
'tel' => $billing->getTelephone(),
|
| 134 |
-
'email' => $this->getOrder()->getCustomerEmail(),
|
| 135 |
-
'lang' => $locale,
|
| 136 |
-
'MC_orderid' => $this->getOrder()->getRealOrderId(),
|
| 137 |
-
'MC_callback' => Mage::getUrl('worldpay/processing/response', array('_secure'=>true))
|
| 138 |
-
);
|
| 139 |
-
|
| 140 |
-
// set additional flags
|
| 141 |
-
if ($this->getConfigData('fix_contact') == 1)
|
| 142 |
-
$params['fixContact'] = 1;
|
| 143 |
-
if ($this->getConfigData('hide_contact') == 1)
|
| 144 |
-
$params['hideContact'] = 1;
|
| 145 |
-
|
| 146 |
-
// add md5 hash
|
| 147 |
-
if ($this->getConfigData('security_key') != '') {
|
| 148 |
-
$params['signatureFields'] = 'amount:currency:instId:cartId:authMode:email:MC_orderid:MC_callback';
|
| 149 |
-
$params['signature'] = md5(
|
| 150 |
-
$this->getConfigData('security_key') . ':' .
|
| 151 |
-
$params['amount'] . ':' .
|
| 152 |
-
$params['currency'] . ':' .
|
| 153 |
-
$params['instId'] . ':' .
|
| 154 |
-
$params['cartId'] . ':' .
|
| 155 |
-
$params['authMode'] . ':' .
|
| 156 |
-
$params['email'] . ':' .
|
| 157 |
-
$params['MC_orderid'] . ':' .
|
| 158 |
-
$params['MC_callback']
|
| 159 |
-
);
|
| 160 |
-
}
|
| 161 |
-
|
| 162 |
-
return $params;
|
| 163 |
-
}
|
| 164 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
*/
|
| 19 |
|
| 20 |
-
class Phoenix_Worldpay_Model_Cc extends
|
| 21 |
{
|
| 22 |
-
/**
|
| 23 |
-
* unique internal payment method identifier
|
| 24 |
-
*
|
| 25 |
-
* @var string [a-z0-9_]
|
| 26 |
-
**/
|
| 27 |
-
protected $_code = 'worldpay_cc';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
protected $_formBlockType = 'worldpay/form';
|
| 29 |
protected $_infoBlockType = 'worldpay/info';
|
| 30 |
-
protected $_paymentMethod = 'cc';
|
| 31 |
|
| 32 |
-
protected $
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
}
|
| 17 |
* @copyright Copyright (c) 2009 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
|
| 18 |
*/
|
| 19 |
|
| 20 |
+
class Phoenix_Worldpay_Model_Cc extends Mage_Payment_Model_Method_Abstract
|
| 21 |
{
|
| 22 |
+
/**
|
| 23 |
+
* unique internal payment method identifier
|
| 24 |
+
*
|
| 25 |
+
* @var string [a-z0-9_]
|
| 26 |
+
**/
|
| 27 |
+
protected $_code = 'worldpay_cc';
|
| 28 |
+
|
| 29 |
+
protected $_isGateway = false;
|
| 30 |
+
protected $_canAuthorize = true;
|
| 31 |
+
protected $_canCapture = true;
|
| 32 |
+
protected $_canCapturePartial = false;
|
| 33 |
+
protected $_canRefund = false;
|
| 34 |
+
protected $_canVoid = false;
|
| 35 |
+
protected $_canUseInternal = false;
|
| 36 |
+
protected $_canUseCheckout = true;
|
| 37 |
+
protected $_canUseForMultishipping = true;
|
| 38 |
+
|
| 39 |
+
protected $_paymentMethod = 'cc';
|
| 40 |
+
protected $_defaultLocale = 'en';
|
| 41 |
+
|
| 42 |
+
protected $_testUrl = 'https://select-test.wp3.rbsworldpay.com/wcc/purchase';
|
| 43 |
+
protected $_liveUrl = 'https://select.wp3.rbsworldpay.com/wcc/purchase';
|
| 44 |
+
|
| 45 |
protected $_formBlockType = 'worldpay/form';
|
| 46 |
protected $_infoBlockType = 'worldpay/info';
|
|
|
|
| 47 |
|
| 48 |
+
protected $_order;
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* Get order model
|
| 52 |
+
*
|
| 53 |
+
* @return Mage_Sales_Model_Order
|
| 54 |
+
*/
|
| 55 |
+
public function getOrder()
|
| 56 |
+
{
|
| 57 |
+
if (!$this->_order) {
|
| 58 |
+
$paymentInfo = $this->getInfoInstance();
|
| 59 |
+
$this->_order = Mage::getModel('sales/order')
|
| 60 |
+
->loadByIncrementId($paymentInfo->getOrder()->getRealOrderId());
|
| 61 |
+
}
|
| 62 |
+
return $this->_order;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
public function getOrderPlaceRedirectUrl()
|
| 66 |
+
{
|
| 67 |
+
return Mage::getUrl('worldpay/processing/redirect');
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
public function capture(Varien_Object $payment, $amount)
|
| 71 |
+
{
|
| 72 |
+
$payment->setStatus(self::STATUS_APPROVED)
|
| 73 |
+
->setLastTransId($this->getTransactionId());
|
| 74 |
+
|
| 75 |
+
return $this;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
public function cancel(Varien_Object $payment)
|
| 79 |
+
{
|
| 80 |
+
$payment->setStatus(self::STATUS_DECLINED)
|
| 81 |
+
->setLastTransId($this->getTransactionId());
|
| 82 |
+
|
| 83 |
+
return $this;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
/**
|
| 87 |
+
* Return payment method type string
|
| 88 |
+
*
|
| 89 |
+
* @return string
|
| 90 |
+
*/
|
| 91 |
+
public function getPaymentMethodType()
|
| 92 |
+
{
|
| 93 |
+
return $this->_paymentMethod;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
public function getUrl()
|
| 97 |
+
{
|
| 98 |
+
if ($this->getConfigData('transaction_mode') == 'live')
|
| 99 |
+
return $this->_liveUrl;
|
| 100 |
+
return $this->_testUrl;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
/**
|
| 104 |
+
* prepare params array to send it to gateway page via POST
|
| 105 |
+
*
|
| 106 |
+
* @return array
|
| 107 |
+
*/
|
| 108 |
+
public function getFormFields()
|
| 109 |
+
{
|
| 110 |
+
// get transaction amount and currency
|
| 111 |
+
if ($this->getConfigData('use_store_currency')) {
|
| 112 |
+
$price = number_format($this->getOrder()->getGrandTotal(),2,'.','');
|
| 113 |
+
$currency = $this->getOrder()->getOrderCurrencyCode();
|
| 114 |
+
} else {
|
| 115 |
+
$price = number_format($this->getOrder()->getBaseGrandTotal(),2,'.','');
|
| 116 |
+
$currency = $this->getOrder()->getBaseCurrencyCode();
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
$billing = $this->getOrder()->getBillingAddress();
|
| 120 |
+
$street = $billing->getStreet();
|
| 121 |
+
|
| 122 |
+
$locale = explode('_', Mage::app()->getLocale()->getLocaleCode());
|
| 123 |
+
if (is_array($locale) && !empty($locale))
|
| 124 |
+
$locale = $locale[0];
|
| 125 |
+
else
|
| 126 |
+
$locale = $this->getDefaultLocale();
|
| 127 |
+
|
| 128 |
+
$params = array(
|
| 129 |
+
'instId' => $this->getConfigData('inst_id'),
|
| 130 |
+
'cartId' => $this->getOrder()->getRealOrderId() . '-' . $this->getOrder()->getQuoteId(),
|
| 131 |
+
'authMode' => ($this->getConfigData('request_type') == self::ACTION_AUTHORIZE) ? 'E' : 'A',
|
| 132 |
+
'testMode' => ($this->getConfigData('transaction_mode') == 'test') ? '100' : '0',
|
| 133 |
+
'amount' => $price,
|
| 134 |
+
'currency' => $currency,
|
| 135 |
+
'desc' => Mage::helper('worldpay')->__('Your purchase at') . ' ' . Mage::app()->getStore()->getName(),
|
| 136 |
+
'name' => Mage::helper('core')->removeAccents($billing->getFirstname().' '.$billing->getLastname()),
|
| 137 |
+
'address' => Mage::helper('core')->removeAccents($street[0]).' '.Mage::helper('core')->removeAccents($billing->getCity()),
|
| 138 |
+
'postcode' => $billing->getPostcode() ,
|
| 139 |
+
'country' => $billing->getCountry(),
|
| 140 |
+
'tel' => $billing->getTelephone(),
|
| 141 |
+
'email' => $this->getOrder()->getCustomerEmail(),
|
| 142 |
+
'lang' => $locale,
|
| 143 |
+
'MC_orderid' => $this->getOrder()->getRealOrderId(),
|
| 144 |
+
'MC_callback' => Mage::getUrl('worldpay/processing/response', array('_secure'=>true))
|
| 145 |
+
);
|
| 146 |
+
|
| 147 |
+
// set additional flags
|
| 148 |
+
if ($this->getConfigData('fix_contact') == 1)
|
| 149 |
+
$params['fixContact'] = 1;
|
| 150 |
+
if ($this->getConfigData('hide_contact') == 1)
|
| 151 |
+
$params['hideContact'] = 1;
|
| 152 |
+
|
| 153 |
+
// add md5 hash
|
| 154 |
+
if ($this->getConfigData('security_key') != '') {
|
| 155 |
+
$params['signatureFields'] = 'amount:currency:instId:cartId:authMode:email';
|
| 156 |
+
$params['signature'] = md5(
|
| 157 |
+
$this->getConfigData('security_key') . ':' .
|
| 158 |
+
$params['amount'] . ':' .
|
| 159 |
+
$params['currency'] . ':' .
|
| 160 |
+
$params['instId'] . ':' .
|
| 161 |
+
$params['cartId'] . ':' .
|
| 162 |
+
$params['authMode'] . ':' .
|
| 163 |
+
$params['email']
|
| 164 |
+
);
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
return $params;
|
| 168 |
+
}
|
| 169 |
}
|
app/code/community/Phoenix/Worldpay/Model/Shared.php
DELETED
|
@@ -1,169 +0,0 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* Magento
|
| 4 |
-
*
|
| 5 |
-
* NOTICE OF LICENSE
|
| 6 |
-
*
|
| 7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
-
* It is also available through the world-wide-web at this URL:
|
| 10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
-
* If you did not receive a copy of the license and are unable to
|
| 12 |
-
* obtain it through the world-wide-web, please send an email
|
| 13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
-
*
|
| 15 |
-
* @category Phoenix
|
| 16 |
-
* @package Phoenix_Worldpay
|
| 17 |
-
* @copyright Copyright (c) 2008 Phoenix Medien GmbH & Co. KG (http://www.phoenix-medien.de)
|
| 18 |
-
*/
|
| 19 |
-
|
| 20 |
-
class Phoenix_Worldpay_Model_Shared extends Mage_Payment_Model_Method_Abstract
|
| 21 |
-
|
| 22 |
-
{
|
| 23 |
-
|
| 24 |
-
/**
|
| 25 |
-
* unique internal payment method identifier
|
| 26 |
-
*
|
| 27 |
-
* @var string [a-z0-9_]
|
| 28 |
-
**/
|
| 29 |
-
protected $_code = 'worldpay_shared';
|
| 30 |
-
|
| 31 |
-
protected $_isGateway = false;
|
| 32 |
-
protected $_canAuthorize = true;
|
| 33 |
-
protected $_canCapture = true;
|
| 34 |
-
protected $_canCapturePartial = false;
|
| 35 |
-
protected $_canRefund = false;
|
| 36 |
-
protected $_canVoid = false;
|
| 37 |
-
protected $_canUseInternal = false;
|
| 38 |
-
protected $_canUseCheckout = true;
|
| 39 |
-
protected $_canUseForMultishipping = true;
|
| 40 |
-
|
| 41 |
-
protected $_paymentMethod = 'shared';
|
| 42 |
-
protected $_defaultLocale = 'en';
|
| 43 |
-
|
| 44 |
-
protected $_testUrl = 'https://select-test.worldpay.com/';
|
| 45 |
-
protected $_liveUrl = 'https://select.worldpay.com/';
|
| 46 |
-
|
| 47 |
-
protected $_order;
|
| 48 |
-
|
| 49 |
-
/**
|
| 50 |
-
* Get order model
|
| 51 |
-
*
|
| 52 |
-
* @return Mage_Sales_Model_Order
|
| 53 |
-
*/
|
| 54 |
-
public function getOrder()
|
| 55 |
-
{
|
| 56 |
-
if (!$this->_order) {
|
| 57 |
-
$paymentInfo = $this->getInfoInstance();
|
| 58 |
-
$this->_order = Mage::getModel('sales/order')
|
| 59 |
-
->loadByIncrementId($paymentInfo->getOrder()->getRealOrderId());
|
| 60 |
-
}
|
| 61 |
-
return $this->_order;
|
| 62 |
-
}
|
| 63 |
-
|
| 64 |
-
public function getOrderPlaceRedirectUrl()
|
| 65 |
-
{
|
| 66 |
-
return Mage::getUrl('worldpay/processing/redirect');
|
| 67 |
-
}
|
| 68 |
-
|
| 69 |
-
public function capture(Varien_Object $payment, $amount)
|
| 70 |
-
{
|
| 71 |
-
$payment->setStatus(self::STATUS_APPROVED)
|
| 72 |
-
->setLastTransId($this->getTransactionId());
|
| 73 |
-
|
| 74 |
-
return $this;
|
| 75 |
-
}
|
| 76 |
-
|
| 77 |
-
public function cancel(Varien_Object $payment)
|
| 78 |
-
{
|
| 79 |
-
$payment->setStatus(self::STATUS_DECLINED)
|
| 80 |
-
->setLastTransId($this->getTransactionId());
|
| 81 |
-
|
| 82 |
-
return $this;
|
| 83 |
-
}
|
| 84 |
-
|
| 85 |
-
/**
|
| 86 |
-
* Return redirect block type
|
| 87 |
-
*
|
| 88 |
-
* @return string
|
| 89 |
-
*/
|
| 90 |
-
public function getRedirectBlockType()
|
| 91 |
-
{
|
| 92 |
-
return $this->_redirectBlockType;
|
| 93 |
-
}
|
| 94 |
-
|
| 95 |
-
/**
|
| 96 |
-
* Return payment method type string
|
| 97 |
-
*
|
| 98 |
-
* @return string
|
| 99 |
-
*/
|
| 100 |
-
public function getPaymentMethodType()
|
| 101 |
-
{
|
| 102 |
-
return $this->_paymentMethod;
|
| 103 |
-
}
|
| 104 |
-
|
| 105 |
-
public function getUrl()
|
| 106 |
-
{
|
| 107 |
-
if ($this->getConfigData('transaction_mode') == 'live')
|
| 108 |
-
return $this->_liveUrl;
|
| 109 |
-
return $this->_testUrl;
|
| 110 |
-
}
|
| 111 |
-
|
| 112 |
-
/**
|
| 113 |
-
* prepare params array to send it to gateway page via POST
|
| 114 |
-
*
|
| 115 |
-
* @return array
|
| 116 |
-
*/
|
| 117 |
-
public function getFormFields()
|
| 118 |
-
{
|
| 119 |
-
$amount = number_format($this->getOrder()->getBaseGrandTotal(),2,'.','');
|
| 120 |
-
$billing = $this->getOrder()->getBillingAddress();
|
| 121 |
-
$currency = $this->getOrder()->getBaseCurrencyCode();
|
| 122 |
-
$street = $billing->getStreet();
|
| 123 |
-
$hashStr = '';
|
| 124 |
-
|
| 125 |
-
$locale = explode('_', Mage::app()->getLocale()->getLocaleCode());
|
| 126 |
-
if (is_array($locale) && !empty($locale))
|
| 127 |
-
$locale = $locale[0];
|
| 128 |
-
else
|
| 129 |
-
$locale = $this->getDefaultLocale();
|
| 130 |
-
|
| 131 |
-
$params = array(
|
| 132 |
-
'instId' => $this->getConfigData('inst_id'),
|
| 133 |
-
'cartId' => $this->getOrder()->getRealOrderId() . '-' . $this->getOrder()->getQuoteId(),
|
| 134 |
-
'authMode' => ($this->getConfigData('request_type') == self::ACTION_AUTHORIZE) ? 'E' : 'A',
|
| 135 |
-
'testMode' => ($this->getConfigData('transaction_mode') == 'test') ? '100' : '0',
|
| 136 |
-
'amount' => $amount,
|
| 137 |
-
'currency' => $currency,
|
| 138 |
-
'desc' => Mage::helper('worldpay')->__('Your purchase at') . ' ' . Mage::app()->getStore()->getName(),
|
| 139 |
-
'name' => Mage::helper('core')->removeAccents($billing->getFirstname().' '.$billing->getLastname()),
|
| 140 |
-
'address' => Mage::helper('core')->removeAccents($street[0]).' '.Mage::helper('core')->removeAccents($billing->getCity()),
|
| 141 |
-
'postcode' => $billing->getPostcode() ,
|
| 142 |
-
'country' => $billing->getCountry(),
|
| 143 |
-
'tel' => $billing->getTelephone(),
|
| 144 |
-
'email' => $this->getOrder()->getCustomerEmail(),
|
| 145 |
-
'lang' => $locale,
|
| 146 |
-
'MC_orderid' => $this->getOrder()->getRealOrderId(),
|
| 147 |
-
);
|
| 148 |
-
|
| 149 |
-
// set additional flags
|
| 150 |
-
if ($this->getConfigData('fix_contact') == 1)
|
| 151 |
-
$params['fixContact'] = 1;
|
| 152 |
-
if ($this->getConfigData('hide_contact') == 1)
|
| 153 |
-
$params['hideContact'] = 1;
|
| 154 |
-
|
| 155 |
-
// add md5 hash
|
| 156 |
-
if ($this->getConfigData('security_key') != '') {
|
| 157 |
-
$params['signatureFields'] = 'amount:currency:cartId:email';
|
| 158 |
-
$params['signature'] = md5(
|
| 159 |
-
$this->getConfigData('security_key') . ':' .
|
| 160 |
-
$params['amount'] . ':' .
|
| 161 |
-
$params['currency'] . ':' .
|
| 162 |
-
$params['cartId'] . ':' .
|
| 163 |
-
$params['email']
|
| 164 |
-
);
|
| 165 |
-
}
|
| 166 |
-
|
| 167 |
-
return $params;
|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
|
|
|
|
|
|
app/code/community/Phoenix/Worldpay/controllers/ProcessingController.php
CHANGED
|
@@ -162,12 +162,21 @@ class Phoenix_Worldpay_ProcessingController extends Mage_Core_Controller_Front_A
|
|
| 162 |
if (!empty($request['transStatus']) && $request['transStatus'] != 'Y')
|
| 163 |
throw new Exception('Transaction was not successfull.');
|
| 164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
// check transaction amount
|
| 166 |
-
if (
|
| 167 |
throw new Exception('Transaction currency doesn\'t match.');
|
| 168 |
|
| 169 |
// check transaction currency
|
| 170 |
-
if ($
|
| 171 |
throw new Exception('Transaction currency doesn\'t match.');
|
| 172 |
|
| 173 |
return $request;
|
| 162 |
if (!empty($request['transStatus']) && $request['transStatus'] != 'Y')
|
| 163 |
throw new Exception('Transaction was not successfull.');
|
| 164 |
|
| 165 |
+
// check transaction amount and currency
|
| 166 |
+
if ($this->_order->getPayment()->getMethodInstance()->getConfigData('use_store_currency')) {
|
| 167 |
+
$price = number_format($this->_order->getGrandTotal(),2,'.','');
|
| 168 |
+
$currency = $this->_order->getOrderCurrencyCode();
|
| 169 |
+
} else {
|
| 170 |
+
$price = number_format($this->_order->getBaseGrandTotal(),2,'.','');
|
| 171 |
+
$currency = $this->_order->getBaseCurrencyCode();
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
// check transaction amount
|
| 175 |
+
if ($price != $request['authAmount'])
|
| 176 |
throw new Exception('Transaction currency doesn\'t match.');
|
| 177 |
|
| 178 |
// check transaction currency
|
| 179 |
+
if ($currency != $request['authCurrency'])
|
| 180 |
throw new Exception('Transaction currency doesn\'t match.');
|
| 181 |
|
| 182 |
return $request;
|
app/code/community/Phoenix/Worldpay/etc/config.xml
CHANGED
|
@@ -21,7 +21,7 @@
|
|
| 21 |
<config>
|
| 22 |
<modules>
|
| 23 |
<Phoenix_Worldpay>
|
| 24 |
-
<version>1.
|
| 25 |
</Phoenix_Worldpay>
|
| 26 |
</modules>
|
| 27 |
<global>
|
|
@@ -125,6 +125,7 @@
|
|
| 125 |
<order_status>1</order_status>
|
| 126 |
<title>Credit Card (Worldpay)</title>
|
| 127 |
<allowspecific>0</allowspecific>
|
|
|
|
| 128 |
<request_type>authorize</request_type>
|
| 129 |
<transaction_mode>test</transaction_mode>
|
| 130 |
<fix_contact>1</fix_contact>
|
| 21 |
<config>
|
| 22 |
<modules>
|
| 23 |
<Phoenix_Worldpay>
|
| 24 |
+
<version>1.1.0</version>
|
| 25 |
</Phoenix_Worldpay>
|
| 26 |
</modules>
|
| 27 |
<global>
|
| 125 |
<order_status>1</order_status>
|
| 126 |
<title>Credit Card (Worldpay)</title>
|
| 127 |
<allowspecific>0</allowspecific>
|
| 128 |
+
<use_store_currency>0</use_store_currency>
|
| 129 |
<request_type>authorize</request_type>
|
| 130 |
<transaction_mode>test</transaction_mode>
|
| 131 |
<fix_contact>1</fix_contact>
|
app/code/community/Phoenix/Worldpay/etc/system.xml
CHANGED
|
@@ -81,7 +81,17 @@
|
|
| 81 |
<show_in_default>1</show_in_default>
|
| 82 |
<show_in_website>1</show_in_website>
|
| 83 |
<show_in_store>1</show_in_store>
|
| 84 |
-
</specificcountry>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
<inst_id>
|
| 86 |
<label>Installation ID</label>
|
| 87 |
<frontend_type>text</frontend_type>
|
| 81 |
<show_in_default>1</show_in_default>
|
| 82 |
<show_in_website>1</show_in_website>
|
| 83 |
<show_in_store>1</show_in_store>
|
| 84 |
+
</specificcountry>
|
| 85 |
+
<use_store_currency translate="label">
|
| 86 |
+
<label>Pay in store currency</label>
|
| 87 |
+
<comment>Choose "Yes" to use store view currency instead of base currency.</comment>
|
| 88 |
+
<frontend_type>select</frontend_type>
|
| 89 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 90 |
+
<sort_order>7</sort_order>
|
| 91 |
+
<show_in_default>1</show_in_default>
|
| 92 |
+
<show_in_website>1</show_in_website>
|
| 93 |
+
<show_in_store>1</show_in_store>
|
| 94 |
+
</use_store_currency>
|
| 95 |
<inst_id>
|
| 96 |
<label>Installation ID</label>
|
| 97 |
<frontend_type>text</frontend_type>
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Phoenix_Worldpay</name>
|
| 4 |
-
<version>1.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -19,12 +19,11 @@ Notice: This extension is still beta. We recommend to test all transactions in y
|
|
| 19 |
The extension is developed and maintained by the German Magento Silver Partner Phoenix Medien (http://www.phoenix-medien.de).
|
| 20 |
|
| 21 |
The development was sponsored by liaison dangereuse (http://www.liaison-dangereuse.de).</description>
|
| 22 |
-
<notes>
|
| 23 |
-
Includes AVS information and dynamic payment response.</notes>
|
| 24 |
<authors><author><name>Phoenix Medien</name><user>auto-converted</user><email>info@phoenix-medien.de</email></author></authors>
|
| 25 |
-
<date>2009-
|
| 26 |
-
<time>
|
| 27 |
-
<contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="worldpay"><dir name="pdf"><file name="info.phtml" hash="3a92c60f5c05a3e51df366cee651edd6"/></dir><file name="info.phtml" hash="bbf2f9a11fd73ceb7aff46b763d95adc"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="worldpay.xml" hash="a229b174eff5a9320862ec72743961f4"/></dir><dir name="template"><dir name="worldpay"><file name="failure.phtml" hash="383014063d48c501abb9a3f78a5758eb"/><file name="form.phtml" hash="e9a5067faeea45f941e2df6a7eb02920"/><file name="info.phtml" hash="c1f61ee39bc04f0783c192236d2db39f"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="de_DE"><file name="Phoenix_Worldpay.csv" hash="b0224148b4cc03ea52016b985d19b0ae"/></dir><dir name="en_US"><file name="Phoenix_Worldpay.csv" hash="30b93daeda3bdfdaadbf15ecbd18c0b5"/></dir></target><target name="mageetc"><dir name="modules"><file name="Phoenix_Worldpay.xml" hash="52b9dc5cd0d94ab43d8691438f090617"/></dir></target><target name="magecommunity"><dir name="Phoenix"><dir name="Worldpay"><dir name="Block"><file name="Failure.php" hash="e96caa77dcdeb5b4e46145e1f032db90"/><file name="Form.php" hash="d279b2d502e875e155101007eef7ebc5"/><file name="Info.php" hash="24bc51b1b86cd3a020982b09e8695c22"/><file name="Processing.php" hash="0f495f4f01f213d999291164d8d6a0c6"/><file name="Success.php" hash="cec01e1f56b8321bb4cafbfc0e330678"/></dir><dir name="controllers"><file name="ProcessingController.php" hash="
|
| 28 |
<compatible/>
|
| 29 |
<dependencies/>
|
| 30 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Phoenix_Worldpay</name>
|
| 4 |
+
<version>1.1</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
| 7 |
<channel>community</channel>
|
| 19 |
The extension is developed and maintained by the German Magento Silver Partner Phoenix Medien (http://www.phoenix-medien.de).
|
| 20 |
|
| 21 |
The development was sponsored by liaison dangereuse (http://www.liaison-dangereuse.de).</description>
|
| 22 |
+
<notes>Support for multi currencies.</notes>
|
|
|
|
| 23 |
<authors><author><name>Phoenix Medien</name><user>auto-converted</user><email>info@phoenix-medien.de</email></author></authors>
|
| 24 |
+
<date>2009-06-03</date>
|
| 25 |
+
<time>17:41:00</time>
|
| 26 |
+
<contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="worldpay"><dir name="pdf"><file name="info.phtml" hash="3a92c60f5c05a3e51df366cee651edd6"/></dir><file name="info.phtml" hash="bbf2f9a11fd73ceb7aff46b763d95adc"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="worldpay.xml" hash="a229b174eff5a9320862ec72743961f4"/></dir><dir name="template"><dir name="worldpay"><file name="failure.phtml" hash="383014063d48c501abb9a3f78a5758eb"/><file name="form.phtml" hash="e9a5067faeea45f941e2df6a7eb02920"/><file name="info.phtml" hash="c1f61ee39bc04f0783c192236d2db39f"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="de_DE"><file name="Phoenix_Worldpay.csv" hash="b0224148b4cc03ea52016b985d19b0ae"/></dir><dir name="en_US"><file name="Phoenix_Worldpay.csv" hash="30b93daeda3bdfdaadbf15ecbd18c0b5"/></dir></target><target name="mageetc"><dir name="modules"><file name="Phoenix_Worldpay.xml" hash="52b9dc5cd0d94ab43d8691438f090617"/></dir></target><target name="magecommunity"><dir name="Phoenix"><dir name="Worldpay"><dir name="Block"><file name="Failure.php" hash="e96caa77dcdeb5b4e46145e1f032db90"/><file name="Form.php" hash="d279b2d502e875e155101007eef7ebc5"/><file name="Info.php" hash="24bc51b1b86cd3a020982b09e8695c22"/><file name="Processing.php" hash="0f495f4f01f213d999291164d8d6a0c6"/><file name="Success.php" hash="cec01e1f56b8321bb4cafbfc0e330678"/></dir><dir name="controllers"><file name="ProcessingController.php" hash="51718aa6b752d5104a0e14095ec4e7f5"/></dir><dir name="etc"><file name="config.xml" hash="7a86bfaec4546842de2a53366b8fbdf0"/><file name="system.xml" hash="78b743467bb9ac02c0afa7ee077c106f"/></dir><dir name="Helper"><file name="Data.php" hash="354473f472247a9dae11a1fac0cef407"/></dir><dir name="Model"><dir name="Config"><dir name="Backend"><file name="Instid.php" hash="20c846f756ccc1edc0673e6c9ab464bf"/></dir></dir><dir name="Source"><file name="RequestType.php" hash="795d51b4c3f04bb00cf6cca5a3180cd7"/><file name="TransactionMode.php" hash="da4cadb5df1213edc34f22b67235d374"/></dir><file name="Cc.php" hash="e124fb5f3e5724ee9051bd7c73ad7c2c"/><file name="Config.php" hash="9098369b245a824396354e1b64cd47ab"/></dir></dir></dir></target></contents>
|
| 27 |
<compatible/>
|
| 28 |
<dependencies/>
|
| 29 |
</package>
|
