Version Notes
Version number: 1.5.5
Download this release
Release Info
Developer | Valerii Demidov |
Extension | CDev_XPaymentsConnector |
Version | 1.5.5 |
Comparing to | |
See all releases |
Code changes from version 1.4.11 to 1.5.5
- app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Customer/Edit/Renderer/Cardnumber.php +41 -0
- app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Sales/Order/View.php +66 -0
- app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Sales/Order/View/Tab/Xporderstate.php +9 -5
- app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Usercards/Grid.php +3 -3
- app/code/community/Cdev/XPaymentsConnector/Block/Checkout/Onepage/Success.php +90 -0
- app/code/community/Cdev/XPaymentsConnector/Block/Customer/Cardadd.php +7 -2
- app/code/community/Cdev/XPaymentsConnector/Block/Info/Cc.php +10 -0
- app/code/community/Cdev/XPaymentsConnector/Block/Info/Savedcards.php +15 -3
- app/code/community/Cdev/XPaymentsConnector/Helper/Data.php +81 -17
- app/code/community/Cdev/XPaymentsConnector/Model/Observer.php +10 -6
- app/code/community/Cdev/XPaymentsConnector/Model/Payment/Cc.php +111 -28
- app/code/community/Cdev/XPaymentsConnector/Model/Payment/Savedcards.php +5 -1
- app/code/community/Cdev/XPaymentsConnector/controllers/Adminhtml/Sales/Order/FraudController.php +91 -0
- app/code/community/Cdev/XPaymentsConnector/controllers/CustomerController.php +19 -11
- app/code/community/Cdev/XPaymentsConnector/controllers/ProcessingController.php +85 -159
- app/code/community/Cdev/XPaymentsConnector/etc/config.xml +15 -1
- app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.1.1-1.1.2.php +101 -0
- app/design/adminhtml/default/default/template/xpaymentsconnector/form/savedcards.phtml +17 -6
- app/design/adminhtml/default/default/template/xpaymentsconnector/info/cc.phtml +13 -7
- app/design/adminhtml/default/default/template/xpaymentsconnector/info/savedcards.phtml +8 -10
- app/design/adminhtml/default/default/template/xpaymentsconnector/order/view/tab/xporderstate.phtml +5 -5
- app/design/frontend/default/default/layout/xpaymentsconnector.xml +6 -0
- app/design/frontend/default/default/template/xpaymentsconnector/checkout/success.phtml +79 -0
- app/design/frontend/default/default/template/xpaymentsconnector/customer/usercards/list.phtml +23 -8
- app/design/frontend/default/default/template/xpaymentsconnector/form/savedcards.phtml +15 -3
- app/design/frontend/default/default/template/xpaymentsconnector/info/cc.phtml +13 -13
- app/design/frontend/default/default/template/xpaymentsconnector/info/savedcards.phtml +6 -4
- app/design/frontend/rwd/default/layout/xpaymentsconnector.xml +6 -0
- app/design/frontend/rwd/default/template/xpaymentsconnector/checkout/success.phtml +79 -0
- app/design/frontend/rwd/default/template/xpaymentsconnector/customer/usercards/list.phtml +23 -8
- app/design/frontend/rwd/default/template/xpaymentsconnector/form/savedcards.phtml +15 -3
- app/design/frontend/rwd/default/template/xpaymentsconnector/info/cc.phtml +13 -8
- app/design/frontend/rwd/default/template/xpaymentsconnector/info/savedcards.phtml +6 -4
- app/locale/en_US/Cdev_XPaymentsConnector.csv +15 -2
- js/xpayment/images/btn_bg_fraud.png +0 -0
- js/xpayment/settings.css +9 -2
- package.xml +5 -5
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Customer/Edit/Renderer/Cardnumber.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* @author Valerii Demidov
|
16 |
+
* @category Cdev
|
17 |
+
* @package Cdev_XPaymentsConnector
|
18 |
+
* @copyright (c) Qualiteam Software Ltd. <info@qtmsoft.com>. All rights reserved.
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Grid column rendering for'Card Type'
|
24 |
+
*/
|
25 |
+
|
26 |
+
class Cdev_XPaymentsConnector_Block_Adminhtml_Customer_Edit_Renderer_Cardnumber extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
|
27 |
+
{
|
28 |
+
|
29 |
+
public function render(Varien_Object $row){
|
30 |
+
|
31 |
+
$row = $row->getData();
|
32 |
+
$cardNumber = $this->__('%s******%s',
|
33 |
+
$row['first6'],
|
34 |
+
$row['last_4_cc_num']
|
35 |
+
);
|
36 |
+
if (!is_null($row['expire_month']) && !is_null($row['expire_year'])) {
|
37 |
+
$cardNumber .= $this->__(' ( %s/%s )', $row['expire_month'], $row['expire_year']);
|
38 |
+
}
|
39 |
+
return "<span>$cardNumber</span>";
|
40 |
+
}
|
41 |
+
}
|
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Sales/Order/View.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* @author Valerii Demidov
|
16 |
+
* @category Cdev
|
17 |
+
* @package Cdev_XPaymentsConnector
|
18 |
+
* @copyright (c) Qualiteam Software Ltd. <info@qtmsoft.com>. All rights reserved.
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
class Cdev_XPaymentsConnector_Block_Adminhtml_Sales_Order_View extends Mage_Adminhtml_Block_Sales_Order_View
|
23 |
+
{
|
24 |
+
|
25 |
+
public function __construct()
|
26 |
+
{
|
27 |
+
|
28 |
+
parent::__construct();
|
29 |
+
|
30 |
+
$order = $this->getOrder();
|
31 |
+
$txnid = $order->getData('xpc_txnid');
|
32 |
+
list($transactionStatus, $transactionInfo)
|
33 |
+
= Mage::getModel('xpaymentsconnector/payment_cc')->requestPaymentInfo($txnid, false, true);
|
34 |
+
|
35 |
+
if ($transactionStatus) {
|
36 |
+
if(isset($transactionInfo['payment']['isFraudStatus']) && $transactionInfo['payment']['isFraudStatus']){
|
37 |
+
$admSession = Mage::getSingleton('adminhtml/session');
|
38 |
+
$messageText = "This transaction has been identified as possibly fraudulent, press 'Accept'".
|
39 |
+
" to confirm the acceptance of the transaction or 'Decline' to cancel it.";
|
40 |
+
$message = $this->__($messageText);
|
41 |
+
$admSession->addNotice($message);
|
42 |
+
|
43 |
+
$activeMessage = Mage::helper('xpaymentsconnector')->__('Are you sure you want to accept this order transaction?');
|
44 |
+
$this->_addButton('active', array(
|
45 |
+
'label' => Mage::helper('xpaymentsconnector')->__('Accept'),
|
46 |
+
'onclick' => "confirmSetLocation('{$activeMessage}', '{$this->getRequestFraudUrl('accept')}')",
|
47 |
+
'class' => 'fraud-button'
|
48 |
+
), -1);
|
49 |
+
|
50 |
+
$cancelMessage = Mage::helper('xpaymentsconnector')->__('Are you sure you want to decline this order transaction?');
|
51 |
+
$this->_addButton('decline', array(
|
52 |
+
'label' => Mage::helper('xpaymentsconnector')->__('Decline'),
|
53 |
+
'onclick' => "confirmSetLocation('{$cancelMessage}', '{$this->getRequestFraudUrl('decline')}')",
|
54 |
+
'class' => 'fraud-button'
|
55 |
+
), -1);
|
56 |
+
}
|
57 |
+
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
public function getRequestFraudUrl($action)
|
63 |
+
{
|
64 |
+
return $this->getUrl('*/sales_order_fraud/'.$action);
|
65 |
+
}
|
66 |
+
}
|
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Sales/Order/View/Tab/Xporderstate.php
CHANGED
@@ -105,10 +105,14 @@ class Cdev_XPaymentsConnector_Block_Adminhtml_Sales_Order_View_Tab_Xporderstate
|
|
105 |
$currentOrder = $this->getOrder();
|
106 |
$currentPaymentCode = $currentOrder->getPayment()->getMethodInstance()->getCode();
|
107 |
$isXpaymentsMethod = Mage::helper('xpaymentsconnector')->isXpaymentsMethod($currentPaymentCode);
|
|
|
|
|
108 |
if($isXpaymentsMethod){
|
|
|
|
|
109 |
if($this->txnid){
|
110 |
list($this->transactionStatus, $this->transactionInfo[$currentOrder->getIncrementId()])
|
111 |
-
=
|
112 |
if($this->transactionStatus){
|
113 |
$this->transactionInfo[$currentOrder->getIncrementId()]['payment']['xpc_txnid'] = $this->txnid;
|
114 |
}
|
@@ -120,7 +124,7 @@ class Cdev_XPaymentsConnector_Block_Adminhtml_Sales_Order_View_Tab_Xporderstate
|
|
120 |
$txnid = $currentOrder->getData('xpc_txnid');
|
121 |
if($txnid){
|
122 |
list($transactionStatus, $transactionInfo)
|
123 |
-
=
|
124 |
if ($transactionStatus) {
|
125 |
$this->transactionInfo[$currentOrder->getIncrementId()] = $transactionInfo;
|
126 |
$this->transactionInfo[$currentOrder->getIncrementId()]['payment']['xpc_txnid'] = $txnid;
|
@@ -142,11 +146,11 @@ class Cdev_XPaymentsConnector_Block_Adminhtml_Sales_Order_View_Tab_Xporderstate
|
|
142 |
public function getCurrentActionAmount($xpOrderStateData){
|
143 |
$actionAmount = 0.00;
|
144 |
switch (true) {
|
145 |
-
case ($xpOrderStateData['
|
146 |
$actionAmount = $xpOrderStateData['capturedAmountAvailGateway'];
|
147 |
break;
|
148 |
-
case ($xpOrderStateData['
|
149 |
-
$actionAmount = $xpOrderStateData['
|
150 |
break;
|
151 |
case ($actionAmount < 0.01 && $xpOrderStateData['chargedAmount'] > 0):
|
152 |
$actionAmount = $xpOrderStateData['chargedAmount'];
|
105 |
$currentOrder = $this->getOrder();
|
106 |
$currentPaymentCode = $currentOrder->getPayment()->getMethodInstance()->getCode();
|
107 |
$isXpaymentsMethod = Mage::helper('xpaymentsconnector')->isXpaymentsMethod($currentPaymentCode);
|
108 |
+
|
109 |
+
|
110 |
if($isXpaymentsMethod){
|
111 |
+
$xpPaymentCcModel = Mage::getModel('xpaymentsconnector/payment_cc');
|
112 |
+
|
113 |
if($this->txnid){
|
114 |
list($this->transactionStatus, $this->transactionInfo[$currentOrder->getIncrementId()])
|
115 |
+
= $xpPaymentCcModel->requestPaymentInfo($this->txnid,false,true);
|
116 |
if($this->transactionStatus){
|
117 |
$this->transactionInfo[$currentOrder->getIncrementId()]['payment']['xpc_txnid'] = $this->txnid;
|
118 |
}
|
124 |
$txnid = $currentOrder->getData('xpc_txnid');
|
125 |
if($txnid){
|
126 |
list($transactionStatus, $transactionInfo)
|
127 |
+
= $xpPaymentCcModel->requestPaymentInfo($txnid, false, true);
|
128 |
if ($transactionStatus) {
|
129 |
$this->transactionInfo[$currentOrder->getIncrementId()] = $transactionInfo;
|
130 |
$this->transactionInfo[$currentOrder->getIncrementId()]['payment']['xpc_txnid'] = $txnid;
|
146 |
public function getCurrentActionAmount($xpOrderStateData){
|
147 |
$actionAmount = 0.00;
|
148 |
switch (true) {
|
149 |
+
case ($xpOrderStateData['capturedAmountAvail'] > 0 && $xpOrderStateData['refundedAmountAvail'] < 0.01):
|
150 |
$actionAmount = $xpOrderStateData['capturedAmountAvailGateway'];
|
151 |
break;
|
152 |
+
case ($xpOrderStateData['refundedAmountAvail'] > 0 && $xpOrderStateData['capturedAmountAvail'] < 0.01):
|
153 |
+
$actionAmount = $xpOrderStateData['refundedAmountAvail'];
|
154 |
break;
|
155 |
case ($actionAmount < 0.01 && $xpOrderStateData['chargedAmount'] > 0):
|
156 |
$actionAmount = $xpOrderStateData['chargedAmount'];
|
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Usercards/Grid.php
CHANGED
@@ -93,11 +93,11 @@ class Cdev_XPaymentsConnector_Block_Adminhtml_Usercards_Grid extends Mage_Adminh
|
|
93 |
'escape' => true
|
94 |
));
|
95 |
|
96 |
-
$this->addColumn('
|
97 |
-
'header' => Mage::helper('xpaymentsconnector')->__('Card number
|
98 |
-
'index' => 'last_4_cc_num',
|
99 |
'type' => 'text',
|
100 |
'width' => '1',
|
|
|
101 |
'escape' => true,
|
102 |
|
103 |
));
|
93 |
'escape' => true
|
94 |
));
|
95 |
|
96 |
+
$this->addColumn('card_number', array(
|
97 |
+
'header' => Mage::helper('xpaymentsconnector')->__('Card number'),
|
|
|
98 |
'type' => 'text',
|
99 |
'width' => '1',
|
100 |
+
'renderer' => 'xpaymentsconnector/adminhtml_customer_edit_renderer_cardnumber',
|
101 |
'escape' => true,
|
102 |
|
103 |
));
|
app/code/community/Cdev/XPaymentsConnector/Block/Checkout/Onepage/Success.php
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* @author Valerii Demidov
|
16 |
+
* @category Cdev
|
17 |
+
* @package Cdev_XPaymentsConnector
|
18 |
+
* @copyright (c) Qualiteam Software Ltd. <info@qtmsoft.com>. All rights reserved.
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Rewrite for success block for failed order transaction.
|
24 |
+
*/
|
25 |
+
|
26 |
+
class Cdev_XPaymentsConnector_Block_Checkout_Onepage_Success extends Mage_Checkout_Block_Onepage_Success
|
27 |
+
{
|
28 |
+
|
29 |
+
protected function _prepareLastOrder()
|
30 |
+
{
|
31 |
+
$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
|
32 |
+
if ($orderId) {
|
33 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
34 |
+
if ($order->getId()) {
|
35 |
+
$isVisible = !in_array($order->getState(),
|
36 |
+
Mage::getSingleton('sales/order_config')->getInvisibleOnFrontStates());
|
37 |
+
$this->addData(array(
|
38 |
+
'is_order_visible' => $isVisible,
|
39 |
+
'view_order_id' => $this->getUrl('sales/order/view/', array('order_id' => $orderId)),
|
40 |
+
'print_url' => $this->getUrl('sales/order/print', array('order_id'=> $orderId)),
|
41 |
+
'can_print_order' => $isVisible,
|
42 |
+
'can_view_order' => Mage::getSingleton('customer/session')->isLoggedIn() && $isVisible,
|
43 |
+
'order_id' => $order->getIncrementId(),
|
44 |
+
'order_status'=> $order->getStatus(),
|
45 |
+
'order_entity_id' => $orderId
|
46 |
+
));
|
47 |
+
}
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* This function check (Is the order was successful?)
|
53 |
+
* @return bool
|
54 |
+
*/
|
55 |
+
public function checkOrderSuccess()
|
56 |
+
{
|
57 |
+
if (Mage_Sales_Model_Order::STATE_CANCELED == $this->_getData('order_status')) {
|
58 |
+
return false;
|
59 |
+
}
|
60 |
+
return true;
|
61 |
+
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* @return string
|
66 |
+
*/
|
67 |
+
public function getButtonUrl()
|
68 |
+
{
|
69 |
+
if ($this->getOrderId()) {
|
70 |
+
if (!$this->checkOrderSuccess()) {
|
71 |
+
return $this->getUrl('sales/order/reorder',
|
72 |
+
array('order_id' => $this->getData('order_entity_id'), '_secure' => true));
|
73 |
+
}
|
74 |
+
}
|
75 |
+
return $this->getUrl();
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* @return string
|
80 |
+
*/
|
81 |
+
public function getButtonLabel()
|
82 |
+
{
|
83 |
+
if ($this->checkOrderSuccess()) {
|
84 |
+
return $this->__('Continue Shopping');
|
85 |
+
} else {
|
86 |
+
return $this->__('Return to checkout');
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
}
|
app/code/community/Cdev/XPaymentsConnector/Block/Customer/Cardadd.php
CHANGED
@@ -48,8 +48,13 @@ class Cdev_XPaymentsConnector_Block_Customer_Cardadd extends Mage_Core_Block_Tem
|
|
48 |
$refId = 'authorization';
|
49 |
$updateSendData = array();
|
50 |
|
51 |
-
$
|
52 |
-
$
|
|
|
|
|
|
|
|
|
|
|
53 |
$updateSendData['refId'] = $refId;
|
54 |
$updateSendData['template'] = 'magento_iframe';
|
55 |
|
48 |
$refId = 'authorization';
|
49 |
$updateSendData = array();
|
50 |
|
51 |
+
$customerSession = Mage::getSingleton('customer/session');
|
52 |
+
$customerId = $customerSession->getId();
|
53 |
+
|
54 |
+
$updateSendData['returnUrl'] = Mage::getUrl('xpaymentsconnector/customer/cardadd',
|
55 |
+
array('order_refid' => $refId,'customer_id' => $customerId,'_secure' => true));
|
56 |
+
$updateSendData['callbackUrl'] = Mage::getUrl('xpaymentsconnector/processing/callback',
|
57 |
+
array('order_refid' => $refId,'customer_id' => $customerId,'_secure' => true));
|
58 |
$updateSendData['refId'] = $refId;
|
59 |
$updateSendData['template'] = 'magento_iframe';
|
60 |
|
app/code/community/Cdev/XPaymentsConnector/Block/Info/Cc.php
CHANGED
@@ -83,4 +83,14 @@ class Cdev_XPaymentsConnector_Block_Info_Cc extends Mage_Payment_Block_Info
|
|
83 |
return preg_replace('/\/+$/Ss', '', $this->getMethod()->getConfig('xpay_url'))
|
84 |
. '/admin.php?target=payment&txnid=' . $this->getInfo()->getLastTransId();
|
85 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
}
|
83 |
return preg_replace('/\/+$/Ss', '', $this->getMethod()->getConfig('xpay_url'))
|
84 |
. '/admin.php?target=payment&txnid=' . $this->getInfo()->getLastTransId();
|
85 |
}
|
86 |
+
|
87 |
+
public function getCardData()
|
88 |
+
{
|
89 |
+
$order = $this->getInfo()->getMethodInstance()->getOrder();
|
90 |
+
$xpCardData = unserialize($order->getXpCardData());
|
91 |
+
$xpCardDataStr = Mage::helper('xpaymentsconnector')->prepareCardDataString($xpCardData);
|
92 |
+
|
93 |
+
return $xpCardDataStr;
|
94 |
+
}
|
95 |
+
|
96 |
}
|
app/code/community/Cdev/XPaymentsConnector/Block/Info/Savedcards.php
CHANGED
@@ -31,6 +31,9 @@ class Cdev_XPaymentsConnector_Block_Info_Savedcards extends Mage_Payment_Block_I
|
|
31 |
$this->setTemplate('xpaymentsconnector/info/savedcards.phtml');
|
32 |
}
|
33 |
|
|
|
|
|
|
|
34 |
public function getAdminXpPaymentCard()
|
35 |
{
|
36 |
$admSession = Mage::getSingleton('adminhtml/session');
|
@@ -39,6 +42,10 @@ class Cdev_XPaymentsConnector_Block_Info_Savedcards extends Mage_Payment_Block_I
|
|
39 |
return $adminhtmlPaymentCardNumber;
|
40 |
}
|
41 |
|
|
|
|
|
|
|
|
|
42 |
public function getCardData($adminhtmlPaymentCardNumber = NULL)
|
43 |
{
|
44 |
$cardData = array();
|
@@ -50,15 +57,20 @@ class Cdev_XPaymentsConnector_Block_Info_Savedcards extends Mage_Payment_Block_I
|
|
50 |
} else {
|
51 |
$cardData = $xpUserCardsModel->load($adminhtmlPaymentCardNumber)->getData();
|
52 |
}
|
|
|
53 |
|
54 |
-
return $
|
55 |
}
|
56 |
|
|
|
|
|
|
|
|
|
57 |
public function getOrderCardData($orderId)
|
58 |
{
|
59 |
$orderCardData = unserialize(Mage::getModel('sales/order')->load($orderId)->getData('xp_card_data'));
|
|
|
60 |
|
61 |
-
return$
|
62 |
}
|
63 |
-
|
64 |
}
|
31 |
$this->setTemplate('xpaymentsconnector/info/savedcards.phtml');
|
32 |
}
|
33 |
|
34 |
+
/**
|
35 |
+
* @return mixed
|
36 |
+
*/
|
37 |
public function getAdminXpPaymentCard()
|
38 |
{
|
39 |
$admSession = Mage::getSingleton('adminhtml/session');
|
42 |
return $adminhtmlPaymentCardNumber;
|
43 |
}
|
44 |
|
45 |
+
/**
|
46 |
+
* @param null $adminhtmlPaymentCardNumber
|
47 |
+
* @return array|mixe
|
48 |
+
*/
|
49 |
public function getCardData($adminhtmlPaymentCardNumber = NULL)
|
50 |
{
|
51 |
$cardData = array();
|
57 |
} else {
|
58 |
$cardData = $xpUserCardsModel->load($adminhtmlPaymentCardNumber)->getData();
|
59 |
}
|
60 |
+
$xpCardDataStr = Mage::helper('xpaymentsconnector')->prepareCardDataString($cardData);
|
61 |
|
62 |
+
return $xpCardDataStr;
|
63 |
}
|
64 |
|
65 |
+
/**
|
66 |
+
* @param $orderId
|
67 |
+
* @return string
|
68 |
+
*/
|
69 |
public function getOrderCardData($orderId)
|
70 |
{
|
71 |
$orderCardData = unserialize(Mage::getModel('sales/order')->load($orderId)->getData('xp_card_data'));
|
72 |
+
$xpCardDataStr = Mage::helper('xpaymentsconnector')->prepareCardDataString($orderCardData);
|
73 |
|
74 |
+
return $xpCardDataStr;
|
75 |
}
|
|
|
76 |
}
|
app/code/community/Cdev/XPaymentsConnector/Helper/Data.php
CHANGED
@@ -34,6 +34,7 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
34 |
const SEMI_MONTH_TIME_STAMP = 1209600;
|
35 |
|
36 |
const STATE_XPAYMENT_PENDING_PAYMENT = 'xp_pending_payment';
|
|
|
37 |
const XPAYMENTS_LOG_FILE = 'xpayments.log';
|
38 |
const RECURRING_ORDER_TYPE = 'recurring';
|
39 |
const SIMPLE_ORDER_TYPE = 'simple';
|
@@ -156,23 +157,44 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
156 |
}
|
157 |
|
158 |
/**
|
159 |
-
* This function return saved X-Payments response
|
160 |
-
*
|
161 |
-
* - prepare_order_id (int)
|
162 |
-
* - xpayment_response
|
163 |
-
* - token
|
164 |
-
* return
|
165 |
-
* @return bool or int
|
166 |
*/
|
167 |
-
public function
|
168 |
{
|
169 |
-
|
170 |
-
|
171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
}
|
173 |
return false;
|
174 |
}
|
175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
/**
|
177 |
* This function return 'token' for X-Payments i-frame Url.
|
178 |
* Xpayment Prepare Order Mas(xpayment_prepare_order):
|
@@ -651,7 +673,8 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
651 |
return true;
|
652 |
break;
|
653 |
case($xpaymentCCModel->getCode()):
|
654 |
-
$
|
|
|
655 |
if (!is_null($this->payDeferredProfileId)) {
|
656 |
$this->resendPayDeferredRecurringTransaction($recurringProfile, $orderAmountData, $cardData);
|
657 |
} else {
|
@@ -808,13 +831,15 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
808 |
Mage::getSingleton('checkout/session')->addError($errorMessage);
|
809 |
} else {
|
810 |
$transactionStatusLabel = Mage::getModel('xpaymentsconnector/payment_cc')->getTransactionStatusLabels();
|
811 |
-
$errorMessage = $this->__("Transaction status is '%s'. The subscription has been canceled.",
|
|
|
812 |
Mage::getSingleton('checkout/session')->addError($errorMessage);
|
813 |
}
|
814 |
} else {
|
815 |
$errorMessage = $this->__('The subscription has been canceled.');
|
816 |
Mage::getSingleton('checkout/session')->addError($errorMessage);
|
817 |
}
|
|
|
818 |
}
|
819 |
|
820 |
public function setRecurringProductDiscount()
|
@@ -822,10 +847,12 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
822 |
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
823 |
$items = $quote->getAllVisibleItems();
|
824 |
foreach ($items as $item) {
|
825 |
-
$
|
826 |
-
|
827 |
-
|
828 |
-
|
|
|
|
|
829 |
}
|
830 |
}
|
831 |
|
@@ -1000,4 +1027,41 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
1000 |
return $orderAmountData;
|
1001 |
}
|
1002 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1003 |
}
|
34 |
const SEMI_MONTH_TIME_STAMP = 1209600;
|
35 |
|
36 |
const STATE_XPAYMENT_PENDING_PAYMENT = 'xp_pending_payment';
|
37 |
+
|
38 |
const XPAYMENTS_LOG_FILE = 'xpayments.log';
|
39 |
const RECURRING_ORDER_TYPE = 'recurring';
|
40 |
const SIMPLE_ORDER_TYPE = 'simple';
|
157 |
}
|
158 |
|
159 |
/**
|
160 |
+
* This function return saved card data from X-Payments response.
|
161 |
+
* @return bool or array
|
|
|
|
|
|
|
|
|
|
|
162 |
*/
|
163 |
+
public function getXpCardData($quoteId = null)
|
164 |
{
|
165 |
+
if (is_null($quoteId)) {
|
166 |
+
$currentCart = Mage::getModel('checkout/cart')->getQuote();
|
167 |
+
$quoteId = $currentCart->getEntityId();
|
168 |
+
}
|
169 |
+
$cartModel = Mage::getModel('sales/quote')->load($quoteId);
|
170 |
+
$cardData = $cartModel->getXpCardData();
|
171 |
+
if (!empty($cardData)) {
|
172 |
+
$cardData = unserialize($cardData);
|
173 |
+
return $cardData;
|
174 |
}
|
175 |
return false;
|
176 |
}
|
177 |
|
178 |
+
/**
|
179 |
+
* This function save user card data to Quote
|
180 |
+
* @param null $quoteId
|
181 |
+
* @param array $cardData
|
182 |
+
* @return array|bool|mixed
|
183 |
+
*/
|
184 |
+
|
185 |
+
public function saveXpCardData($quoteId = null,$cardData = array())
|
186 |
+
{
|
187 |
+
if (is_null($quoteId)) {
|
188 |
+
$currentCart = Mage::getModel('checkout/cart')->getQuote();
|
189 |
+
$quoteId = $currentCart->getEntityId();
|
190 |
+
}
|
191 |
+
$cartModel = Mage::getModel('sales/quote')->load($quoteId);
|
192 |
+
$cardData = serialize($cardData);
|
193 |
+
$cartModel->setXpCardData($cardData);
|
194 |
+
|
195 |
+
$cartModel->save();
|
196 |
+
}
|
197 |
+
|
198 |
/**
|
199 |
* This function return 'token' for X-Payments i-frame Url.
|
200 |
* Xpayment Prepare Order Mas(xpayment_prepare_order):
|
673 |
return true;
|
674 |
break;
|
675 |
case($xpaymentCCModel->getCode()):
|
676 |
+
$quoteId = Mage::app()->getRequest()->getParam('quote_id');
|
677 |
+
$cardData = $this->getXpCardData($quoteId);
|
678 |
if (!is_null($this->payDeferredProfileId)) {
|
679 |
$this->resendPayDeferredRecurringTransaction($recurringProfile, $orderAmountData, $cardData);
|
680 |
} else {
|
831 |
Mage::getSingleton('checkout/session')->addError($errorMessage);
|
832 |
} else {
|
833 |
$transactionStatusLabel = Mage::getModel('xpaymentsconnector/payment_cc')->getTransactionStatusLabels();
|
834 |
+
$errorMessage = $this->__("Transaction status is '%s'. The subscription has been canceled.",
|
835 |
+
$transactionStatusLabel[$response['status']]);
|
836 |
Mage::getSingleton('checkout/session')->addError($errorMessage);
|
837 |
}
|
838 |
} else {
|
839 |
$errorMessage = $this->__('The subscription has been canceled.');
|
840 |
Mage::getSingleton('checkout/session')->addError($errorMessage);
|
841 |
}
|
842 |
+
Mage::getSingleton('checkout/session')->addNotice($this->getFailureCheckoutNoticeHelper());
|
843 |
}
|
844 |
|
845 |
public function setRecurringProductDiscount()
|
847 |
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
848 |
$items = $quote->getAllVisibleItems();
|
849 |
foreach ($items as $item) {
|
850 |
+
if($item->getIsNominal()){
|
851 |
+
$discount = $item->getDiscountAmount();
|
852 |
+
$profile = $item->getProduct()->getRecurringProfile();
|
853 |
+
$profile['discount_amount'] = $discount;
|
854 |
+
$item->getProduct()->setRecurringProfile($profile)->save();
|
855 |
+
}
|
856 |
}
|
857 |
}
|
858 |
|
1027 |
return $orderAmountData;
|
1028 |
}
|
1029 |
|
1030 |
+
/**
|
1031 |
+
* @return string
|
1032 |
+
*/
|
1033 |
+
public function getFailureCheckoutNoticeHelper()
|
1034 |
+
{
|
1035 |
+
$noticeMessage = "Did you enter your billing info correctly? Here are a few things to double check:<br />".
|
1036 |
+
"1. Ensure your billing address matches the address on your credit or debit card statement;<br />".
|
1037 |
+
"2. Check your card verification code (CVV) for accuracy;<br />".
|
1038 |
+
"3. Confirm you've entered the correct expiration date.";
|
1039 |
+
|
1040 |
+
$noticeHelper = $this->__($noticeMessage);
|
1041 |
+
|
1042 |
+
return $noticeHelper;
|
1043 |
+
}
|
1044 |
+
|
1045 |
+
/**
|
1046 |
+
* @param array $xpCardData
|
1047 |
+
* @return string
|
1048 |
+
*/
|
1049 |
+
public function prepareCardDataString($xpCardData)
|
1050 |
+
{
|
1051 |
+
$xpCardDataStr = '';
|
1052 |
+
if (!empty($xpCardData)) {
|
1053 |
+
$last4 = (isset($xpCardData['last4'])) ? $xpCardData['last4'] : $xpCardData['last_4_cc_num'];
|
1054 |
+
|
1055 |
+
$xpCardDataStr = $this->__('%s******%s',
|
1056 |
+
$xpCardData['first6'],
|
1057 |
+
$last4
|
1058 |
+
);
|
1059 |
+
if (!empty($xpCardData['expire_month']) && !empty($xpCardData['expire_year'])) {
|
1060 |
+
$xpCardDataStr .= $this->__(' ( %s/%s )', $xpCardData['expire_month'], $xpCardData['expire_year']);
|
1061 |
+
}
|
1062 |
+
}
|
1063 |
+
|
1064 |
+
return $xpCardDataStr;
|
1065 |
+
}
|
1066 |
+
|
1067 |
}
|
app/code/community/Cdev/XPaymentsConnector/Model/Observer.php
CHANGED
@@ -97,26 +97,28 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
|
|
97 |
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
98 |
$quote = $observer->getQuote();
|
99 |
|
|
|
|
|
100 |
if ($paymentMethod == $xpaymentPaymentCode) {
|
101 |
$order->setCanSendNewEmailFlag(false);
|
102 |
|
103 |
-
$
|
104 |
|
105 |
|
106 |
if ($useIframe) {
|
107 |
/*update order table*/
|
108 |
-
$order->setData('xpc_txnid', $
|
109 |
-
$order->setData('xp_card_data', serialize($request));
|
110 |
$order->save();
|
111 |
|
112 |
-
$result = $paymentCcModel->updateOrderByXpaymentResponse($order->getId(), $
|
113 |
if ($result['success']) {
|
114 |
/* save credit card to user profile */
|
115 |
-
$
|
116 |
-
$paymentCcModel->saveUserCard($
|
117 |
/* end (save payment card) */
|
118 |
} else {
|
119 |
$checkoutSession->addError($result['error_message']);
|
|
|
120 |
}
|
121 |
|
122 |
}
|
@@ -135,9 +137,11 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
|
|
135 |
$result = $paymentCcModel->updateOrderByXpaymentResponse($order->getId(), $response['response']['transaction_id']);
|
136 |
if (!$result['success']) {
|
137 |
$checkoutSession->addError($result['error_message']);
|
|
|
138 |
}
|
139 |
} else {
|
140 |
$checkoutSession->addError($response['error_message']);
|
|
|
141 |
}
|
142 |
|
143 |
}
|
97 |
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
98 |
$quote = $observer->getQuote();
|
99 |
|
100 |
+
$noticeHelper = $xpHelper->getFailureCheckoutNoticeHelper();
|
101 |
+
|
102 |
if ($paymentMethod == $xpaymentPaymentCode) {
|
103 |
$order->setCanSendNewEmailFlag(false);
|
104 |
|
105 |
+
$cardData = $xpHelper->getXpCardData();
|
106 |
|
107 |
|
108 |
if ($useIframe) {
|
109 |
/*update order table*/
|
110 |
+
$order->setData('xpc_txnid', $cardData['txnId']);
|
|
|
111 |
$order->save();
|
112 |
|
113 |
+
$result = $paymentCcModel->updateOrderByXpaymentResponse($order->getId(), $cardData['txnId']);
|
114 |
if ($result['success']) {
|
115 |
/* save credit card to user profile */
|
116 |
+
$xpCardData = unserialize($quote->getXpCardData());
|
117 |
+
$paymentCcModel->saveUserCard($xpCardData);
|
118 |
/* end (save payment card) */
|
119 |
} else {
|
120 |
$checkoutSession->addError($result['error_message']);
|
121 |
+
$checkoutSession->addNotice($noticeHelper);
|
122 |
}
|
123 |
|
124 |
}
|
137 |
$result = $paymentCcModel->updateOrderByXpaymentResponse($order->getId(), $response['response']['transaction_id']);
|
138 |
if (!$result['success']) {
|
139 |
$checkoutSession->addError($result['error_message']);
|
140 |
+
$checkoutSession->addNotice($noticeHelper);
|
141 |
}
|
142 |
} else {
|
143 |
$checkoutSession->addError($response['error_message']);
|
144 |
+
$checkoutSession->addNotice($noticeHelper);
|
145 |
}
|
146 |
|
147 |
}
|
app/code/community/Cdev/XPaymentsConnector/Model/Payment/Cc.php
CHANGED
@@ -121,8 +121,7 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
121 |
const TRAN_TYPE_GET_INFO = 'getInfo';
|
122 |
const TRAN_TYPE_ACCEPT = 'accept';
|
123 |
const TRAN_TYPE_DECLINE = 'decline';
|
124 |
-
const XP_API = '1.
|
125 |
-
const XP_API_NEW = '1.2'; // change to 1.3 in a feature
|
126 |
|
127 |
/**
|
128 |
* unique internal payment method identifier
|
@@ -499,6 +498,12 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
499 |
|
500 |
// Prepare cart
|
501 |
$cart = $this->prepareCart($order, $refId);
|
|
|
|
|
|
|
|
|
|
|
|
|
502 |
$xpHelper = Mage::helper('xpaymentsconnector');
|
503 |
|
504 |
// Data to send to X-Payments
|
@@ -506,10 +511,12 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
506 |
'confId' => intval($this->getPaymentConfiguration()->getData('confid')),
|
507 |
'refId' => $refId,
|
508 |
'cart' => $cart,
|
509 |
-
'returnUrl' => Mage::getUrl('xpaymentsconnector/processing/
|
510 |
-
|
|
|
|
|
511 |
'saveCard' => 'Y',
|
512 |
-
'api_version' => self::
|
513 |
);
|
514 |
|
515 |
list($status, $response) = $this->request('payment', 'init', $data);
|
@@ -953,8 +960,6 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
953 |
unset($users, $user);
|
954 |
}
|
955 |
|
956 |
-
$forceTransactionType = ($this->isForceAuth()) ? 'A' : 'S';
|
957 |
-
|
958 |
$result = array(
|
959 |
'billingAddress' => array(
|
960 |
'email' => $order->getCustomerEmail(),
|
@@ -970,10 +975,13 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
970 |
'totalCost' => 0.00,
|
971 |
'description' => 'Order #' . $refId,
|
972 |
'merchantEmail' => $memail,
|
973 |
-
'forceTransactionType' => $forceTransactionType,
|
974 |
'login' => $order->getCustomerEmail(),
|
975 |
);
|
976 |
|
|
|
|
|
|
|
|
|
977 |
$namePrefixes = array(
|
978 |
'billing' => 'getBillingAddress',
|
979 |
'shipping' => 'getShippingAddress',
|
@@ -1042,6 +1050,7 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1042 |
return $result;
|
1043 |
}
|
1044 |
|
|
|
1045 |
/**
|
1046 |
* Get currency code
|
1047 |
*
|
@@ -1068,7 +1077,7 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1068 |
* @see ____func_see____
|
1069 |
* @since 1.0.0
|
1070 |
*/
|
1071 |
-
|
1072 |
{
|
1073 |
$xml = '';
|
1074 |
|
@@ -1198,7 +1207,7 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1198 |
* @see ____func_see____
|
1199 |
* @since 1.0.0
|
1200 |
*/
|
1201 |
-
|
1202 |
{
|
1203 |
// Preprocess
|
1204 |
srand(time());
|
@@ -1373,6 +1382,8 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1373 |
$xPaymentDataResponse['success'] = true;
|
1374 |
|
1375 |
$checkoutData = Mage::getSingleton('checkout/session');
|
|
|
|
|
1376 |
$xpHelper = Mage::helper('xpaymentsconnector');
|
1377 |
$refId = $xpHelper->getOrderKey();
|
1378 |
|
@@ -1387,16 +1398,28 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1387 |
$cart = $this->iframePrepareCart($checkoutData, false, $isCardAuthorizePayment);
|
1388 |
}
|
1389 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1390 |
// Data to send to X-Payments
|
1391 |
$sendData = array(
|
1392 |
'confId' => intval($this->getPaymentConfiguration()->getData('confid')),
|
1393 |
'refId' => $refId,
|
1394 |
'cart' => $cart,
|
1395 |
-
'returnUrl' => Mage::getUrl('xpaymentsconnector/processing/
|
1396 |
-
|
|
|
|
|
1397 |
);
|
1398 |
|
1399 |
-
|
1400 |
foreach($updateSendData as $sendDataKey => $sendDataValue){
|
1401 |
$sendData[$sendDataKey] = $updateSendData[$sendDataKey];
|
1402 |
}
|
@@ -1544,7 +1567,6 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1544 |
/*initial fee check*/
|
1545 |
$issetRecurringProduct = $xpHelper->checkIssetRecurringOrder();
|
1546 |
|
1547 |
-
$forceTransactionType = ($this->isForceAuth()) ? 'A' : 'S';
|
1548 |
$minimalPayment = false;
|
1549 |
|
1550 |
$quote->collectTotals();
|
@@ -1625,7 +1647,11 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1625 |
$result['discount'] = number_format($discount, 2, '.', '');
|
1626 |
|
1627 |
$result['merchantEmail'] = $customerEmail;
|
1628 |
-
|
|
|
|
|
|
|
|
|
1629 |
$result['login'] = $customerEmail;
|
1630 |
|
1631 |
|
@@ -1805,6 +1831,11 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1805 |
);
|
1806 |
$order->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
|
1807 |
}
|
|
|
|
|
|
|
|
|
|
|
1808 |
$order->save();
|
1809 |
if(method_exists($order,'sendNewOrderEmail')){
|
1810 |
$order->sendNewOrderEmail();
|
@@ -1827,7 +1858,10 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1827 |
$result['success'] = false;
|
1828 |
if(!empty($response['payment']['error_message'])){
|
1829 |
$result['error_message'] = $xpaymentsHelper->__('%s. The order has been canceled.',$response['payment']['error_message']);
|
1830 |
-
}
|
|
|
|
|
|
|
1831 |
$transactionStatusLabel = $this->getTransactionStatusLabels();
|
1832 |
$result['error_message'] = $xpaymentsHelper->__('Transaction status is "%s". The order has been canceled.',$transactionStatusLabel[$response['payment']['status']]);
|
1833 |
}
|
@@ -1853,14 +1887,21 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1853 |
{
|
1854 |
if ($xpHelper->isNeedToSaveUserCard()) {
|
1855 |
$usercards = Mage::getModel('xpaymentsconnector/usercards');
|
|
|
1856 |
$usercards->setData(array(
|
1857 |
-
'user_id' =>
|
1858 |
'txnId' => $cardData['txnId'],
|
1859 |
-
'last_4_cc_num' => $cardData['
|
1860 |
-
'
|
1861 |
-
'
|
|
|
|
|
|
|
|
|
1862 |
);
|
|
|
1863 |
$xpHelper->userCardSaved();
|
|
|
1864 |
return $usercards->save();
|
1865 |
}
|
1866 |
}
|
@@ -1876,10 +1917,6 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1876 |
$data['target'] = 'payment';
|
1877 |
list($status, $response) = $this->request('payment', $action, $data);
|
1878 |
|
1879 |
-
//****************stop*****************//
|
1880 |
-
/*if ( $status && (!empty($response['error_message']))) {
|
1881 |
-
Mage::throwException(Mage::helper('sales')->__($response['error_message']));
|
1882 |
-
}*/
|
1883 |
return $response;
|
1884 |
|
1885 |
}
|
@@ -1896,7 +1933,8 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1896 |
public function capture(Varien_Object $payment, $amount)
|
1897 |
{
|
1898 |
if (!$this->canCapture()) {
|
1899 |
-
Mage::
|
|
|
1900 |
}
|
1901 |
|
1902 |
$order = $this->getOrder();
|
@@ -1923,7 +1961,8 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1923 |
{
|
1924 |
|
1925 |
if (!$this->canRefund()) {
|
1926 |
-
Mage::
|
|
|
1927 |
}
|
1928 |
|
1929 |
/*processing during create invoice*/
|
@@ -1966,7 +2005,7 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1966 |
$xpHelper->setPrepareOrderType();
|
1967 |
|
1968 |
//add txnid for all subscriptions
|
1969 |
-
$cardData = $xpHelper->
|
1970 |
|
1971 |
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
1972 |
|
@@ -2079,7 +2118,7 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
2079 |
public function createFirstRecurringOrder(Mage_Payment_Model_Recurring_Profile $profile)
|
2080 |
{
|
2081 |
$xpHelper = Mage::helper('xpaymentsconnector');
|
2082 |
-
$cardData = $xpHelper->
|
2083 |
$orderId = $xpHelper->createOrder($profile, $isFirstRecurringOrder = true);
|
2084 |
|
2085 |
/*update order by card data*/
|
@@ -2102,6 +2141,7 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
2102 |
|
2103 |
if (!$result['success']) {
|
2104 |
Mage::getSingleton('checkout/session')->addError($result['error_message']);
|
|
|
2105 |
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
|
2106 |
} else {
|
2107 |
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
|
@@ -2123,5 +2163,48 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
2123 |
|
2124 |
}
|
2125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2126 |
}
|
2127 |
|
121 |
const TRAN_TYPE_GET_INFO = 'getInfo';
|
122 |
const TRAN_TYPE_ACCEPT = 'accept';
|
123 |
const TRAN_TYPE_DECLINE = 'decline';
|
124 |
+
const XP_API = '1.5';
|
|
|
125 |
|
126 |
/**
|
127 |
* unique internal payment method identifier
|
498 |
|
499 |
// Prepare cart
|
500 |
$cart = $this->prepareCart($order, $refId);
|
501 |
+
|
502 |
+
// save card data for x-payment 'callback approve' response
|
503 |
+
$quoteId = $order->getQuoteId();
|
504 |
+
$cartModel = Mage::getModel('sales/quote')->load($quoteId);
|
505 |
+
$cartModel->setData('xp_callback_approve',serialize($cart))->save();
|
506 |
+
|
507 |
$xpHelper = Mage::helper('xpaymentsconnector');
|
508 |
|
509 |
// Data to send to X-Payments
|
511 |
'confId' => intval($this->getPaymentConfiguration()->getData('confid')),
|
512 |
'refId' => $refId,
|
513 |
'cart' => $cart,
|
514 |
+
'returnUrl' => Mage::getUrl('xpaymentsconnector/processing/return',
|
515 |
+
array('order_refid' => $refId,'quote_id' => $quoteId,'_secure' => true)),
|
516 |
+
'callbackUrl' => Mage::getUrl('xpaymentsconnector/processing/callback',
|
517 |
+
array('order_refid' => $refId,'quote_id' => $quoteId,'_secure' => true)),
|
518 |
'saveCard' => 'Y',
|
519 |
+
'api_version' => self::XP_API
|
520 |
);
|
521 |
|
522 |
list($status, $response) = $this->request('payment', 'init', $data);
|
960 |
unset($users, $user);
|
961 |
}
|
962 |
|
|
|
|
|
963 |
$result = array(
|
964 |
'billingAddress' => array(
|
965 |
'email' => $order->getCustomerEmail(),
|
975 |
'totalCost' => 0.00,
|
976 |
'description' => 'Order #' . $refId,
|
977 |
'merchantEmail' => $memail,
|
|
|
978 |
'login' => $order->getCustomerEmail(),
|
979 |
);
|
980 |
|
981 |
+
if ($this->isForceAuth()) {
|
982 |
+
$result['forceTransactionType'] = 'A';
|
983 |
+
}
|
984 |
+
|
985 |
$namePrefixes = array(
|
986 |
'billing' => 'getBillingAddress',
|
987 |
'shipping' => 'getShippingAddress',
|
1050 |
return $result;
|
1051 |
}
|
1052 |
|
1053 |
+
|
1054 |
/**
|
1055 |
* Get currency code
|
1056 |
*
|
1077 |
* @see ____func_see____
|
1078 |
* @since 1.0.0
|
1079 |
*/
|
1080 |
+
public function convertHash2XML(array $data, $level = 0)
|
1081 |
{
|
1082 |
$xml = '';
|
1083 |
|
1207 |
* @see ____func_see____
|
1208 |
* @since 1.0.0
|
1209 |
*/
|
1210 |
+
public function encrypt($data)
|
1211 |
{
|
1212 |
// Preprocess
|
1213 |
srand(time());
|
1382 |
$xPaymentDataResponse['success'] = true;
|
1383 |
|
1384 |
$checkoutData = Mage::getSingleton('checkout/session');
|
1385 |
+
|
1386 |
+
|
1387 |
$xpHelper = Mage::helper('xpaymentsconnector');
|
1388 |
$refId = $xpHelper->getOrderKey();
|
1389 |
|
1398 |
$cart = $this->iframePrepareCart($checkoutData, false, $isCardAuthorizePayment);
|
1399 |
}
|
1400 |
|
1401 |
+
$currentCart = Mage::getModel('checkout/cart')->getQuote();
|
1402 |
+
$quoteId = $currentCart->getEntityId();
|
1403 |
+
if ($isCardAuthorizePayment) {
|
1404 |
+
$customerSession = Mage::getSingleton('customer/session')->getCustomer();
|
1405 |
+
$customerSession->setData("xp_buffer",serialize($cart))->save();
|
1406 |
+
} else {
|
1407 |
+
// save card data for x-payment 'callback approve' response
|
1408 |
+
$cartModel = Mage::getModel('sales/quote')->load($quoteId);
|
1409 |
+
$cartModel->setData('xp_callback_approve',serialize($cart))->save();
|
1410 |
+
}
|
1411 |
+
|
1412 |
// Data to send to X-Payments
|
1413 |
$sendData = array(
|
1414 |
'confId' => intval($this->getPaymentConfiguration()->getData('confid')),
|
1415 |
'refId' => $refId,
|
1416 |
'cart' => $cart,
|
1417 |
+
'returnUrl' => Mage::getUrl('xpaymentsconnector/processing/return',
|
1418 |
+
array('order_refid' => $refId,'quote_id' => $quoteId,'_secure' => true)),
|
1419 |
+
'callbackUrl' => Mage::getUrl('xpaymentsconnector/processing/callback',
|
1420 |
+
array('order_refid' => $refId,'quote_id' => $quoteId,'_secure' => true)),
|
1421 |
);
|
1422 |
|
|
|
1423 |
foreach($updateSendData as $sendDataKey => $sendDataValue){
|
1424 |
$sendData[$sendDataKey] = $updateSendData[$sendDataKey];
|
1425 |
}
|
1567 |
/*initial fee check*/
|
1568 |
$issetRecurringProduct = $xpHelper->checkIssetRecurringOrder();
|
1569 |
|
|
|
1570 |
$minimalPayment = false;
|
1571 |
|
1572 |
$quote->collectTotals();
|
1647 |
$result['discount'] = number_format($discount, 2, '.', '');
|
1648 |
|
1649 |
$result['merchantEmail'] = $customerEmail;
|
1650 |
+
|
1651 |
+
if ($this->isForceAuth()) {
|
1652 |
+
$result['forceTransactionType'] = 'A';
|
1653 |
+
}
|
1654 |
+
|
1655 |
$result['login'] = $customerEmail;
|
1656 |
|
1657 |
|
1831 |
);
|
1832 |
$order->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
|
1833 |
}
|
1834 |
+
|
1835 |
+
if(isset($response['payment']['isFraudStatus']) && $response['payment']['isFraudStatus']){
|
1836 |
+
$order->setStatus('fraud');
|
1837 |
+
}
|
1838 |
+
|
1839 |
$order->save();
|
1840 |
if(method_exists($order,'sendNewOrderEmail')){
|
1841 |
$order->sendNewOrderEmail();
|
1858 |
$result['success'] = false;
|
1859 |
if(!empty($response['payment']['error_message'])){
|
1860 |
$result['error_message'] = $xpaymentsHelper->__('%s. The order has been canceled.',$response['payment']['error_message']);
|
1861 |
+
} elseif (!empty($response['error_message'])) {
|
1862 |
+
$result['error_message'] = $xpaymentsHelper->__('%s. The order has been canceled.',$response['error_message']);
|
1863 |
+
}
|
1864 |
+
else{
|
1865 |
$transactionStatusLabel = $this->getTransactionStatusLabels();
|
1866 |
$result['error_message'] = $xpaymentsHelper->__('Transaction status is "%s". The order has been canceled.',$transactionStatusLabel[$response['payment']['status']]);
|
1867 |
}
|
1887 |
{
|
1888 |
if ($xpHelper->isNeedToSaveUserCard()) {
|
1889 |
$usercards = Mage::getModel('xpaymentsconnector/usercards');
|
1890 |
+
|
1891 |
$usercards->setData(array(
|
1892 |
+
'user_id' => $customer->getId(),
|
1893 |
'txnId' => $cardData['txnId'],
|
1894 |
+
'last_4_cc_num' => $cardData['last4'],
|
1895 |
+
'first6' => $cardData['first6'],
|
1896 |
+
'card_type' => $cardData['type'],
|
1897 |
+
'expire_month' => $cardData['expire_month'],
|
1898 |
+
'expire_year' => $cardData['expire_year'],
|
1899 |
+
'usage_type' => $usageType,)
|
1900 |
+
|
1901 |
);
|
1902 |
+
|
1903 |
$xpHelper->userCardSaved();
|
1904 |
+
|
1905 |
return $usercards->save();
|
1906 |
}
|
1907 |
}
|
1917 |
$data['target'] = 'payment';
|
1918 |
list($status, $response) = $this->request('payment', $action, $data);
|
1919 |
|
|
|
|
|
|
|
|
|
1920 |
return $response;
|
1921 |
|
1922 |
}
|
1933 |
public function capture(Varien_Object $payment, $amount)
|
1934 |
{
|
1935 |
if (!$this->canCapture()) {
|
1936 |
+
$xpaymentsHelper = Mage::helper('xpaymentsconnector');
|
1937 |
+
Mage::throwException($xpaymentsHelper->__('Capture action is not available.'));
|
1938 |
}
|
1939 |
|
1940 |
$order = $this->getOrder();
|
1961 |
{
|
1962 |
|
1963 |
if (!$this->canRefund()) {
|
1964 |
+
$xpaymentsHelper = Mage::helper('xpaymentsconnector');
|
1965 |
+
Mage::throwException($xpaymentsHelper->__('Refund action is not available.'));
|
1966 |
}
|
1967 |
|
1968 |
/*processing during create invoice*/
|
2005 |
$xpHelper->setPrepareOrderType();
|
2006 |
|
2007 |
//add txnid for all subscriptions
|
2008 |
+
$cardData = $xpHelper->getXpCardData();
|
2009 |
|
2010 |
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
2011 |
|
2118 |
public function createFirstRecurringOrder(Mage_Payment_Model_Recurring_Profile $profile)
|
2119 |
{
|
2120 |
$xpHelper = Mage::helper('xpaymentsconnector');
|
2121 |
+
$cardData = $xpHelper->getXpCardData();
|
2122 |
$orderId = $xpHelper->createOrder($profile, $isFirstRecurringOrder = true);
|
2123 |
|
2124 |
/*update order by card data*/
|
2141 |
|
2142 |
if (!$result['success']) {
|
2143 |
Mage::getSingleton('checkout/session')->addError($result['error_message']);
|
2144 |
+
Mage::getSingleton('checkout/session')->addNotice($xpHelper->getFailureCheckoutNoticeHelper());
|
2145 |
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
|
2146 |
} else {
|
2147 |
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
|
2163 |
|
2164 |
}
|
2165 |
|
2166 |
+
/**
|
2167 |
+
* Processing for fraud transaction
|
2168 |
+
* @param $action (decline,accept)
|
2169 |
+
*/
|
2170 |
+
public function sendFraudRequest($xpcTxnid,$action)
|
2171 |
+
{
|
2172 |
+
$status = false;
|
2173 |
+
try {
|
2174 |
+
$admSession = Mage::getSingleton('adminhtml/session');
|
2175 |
+
$xpaymentsHelper = Mage::helper('xpaymentsconnector');
|
2176 |
+
|
2177 |
+
$data = array(
|
2178 |
+
'txnId' => $xpcTxnid
|
2179 |
+
);
|
2180 |
+
|
2181 |
+
list($status, $response) = $this->request('payment', $action, $data);
|
2182 |
+
|
2183 |
+
if ($status) {
|
2184 |
+
$message = $xpaymentsHelper->__('\'%s fraud transaction\' was successful!',ucfirst($action));
|
2185 |
+
if (isset($response['message']) && !empty($response['message'])) {
|
2186 |
+
$message .= $xpaymentsHelper->__(' ( X-Payment server response: %s )',$response['message']);
|
2187 |
+
}
|
2188 |
+
$admSession->addNotice($message);
|
2189 |
+
|
2190 |
+
} else {
|
2191 |
+
$message = $xpaymentsHelper->__('\'%s fraud transaction\' was failed!',ucfirst($action));
|
2192 |
+
if (isset($response['message']) && !empty($response['message'])) {
|
2193 |
+
$message .= $xpaymentsHelper->__(' ( X-Payment server response: %s )',$response['message']);
|
2194 |
+
}
|
2195 |
+
$admSession->addError($message);
|
2196 |
+
}
|
2197 |
+
|
2198 |
+
}
|
2199 |
+
catch (Mage_Core_Exception $e) {
|
2200 |
+
$admSession->addError($e->getMessage());
|
2201 |
+
}
|
2202 |
+
catch (Exception $e) {
|
2203 |
+
$admSession->addError($xpaymentsHelper->__('Transaction to the X-Payment server was broken!'));
|
2204 |
+
}
|
2205 |
+
|
2206 |
+
return $status;
|
2207 |
+
|
2208 |
+
}
|
2209 |
}
|
2210 |
|
app/code/community/Cdev/XPaymentsConnector/Model/Payment/Savedcards.php
CHANGED
@@ -159,11 +159,14 @@ class Cdev_XPaymentsConnector_Model_Payment_Savedcards extends Mage_Payment_Mode
|
|
159 |
updateOrderByXpaymentResponse($orderId, $response['response']['transaction_id']);
|
160 |
if (!$result['success']) {
|
161 |
Mage::getSingleton('checkout/session')->addError($result['error_message']);
|
|
|
|
|
162 |
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
|
163 |
} else {
|
164 |
// additional subscription profile setting for success transaction
|
165 |
$newTransactionDate = new Zend_Date(time());
|
166 |
-
$profile->setXpSuccessTransactionDate($newTransactionDate
|
|
|
167 |
$profile->setXpCountSuccessTransaction(1);
|
168 |
|
169 |
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
|
@@ -171,6 +174,7 @@ class Cdev_XPaymentsConnector_Model_Payment_Savedcards extends Mage_Payment_Mode
|
|
171 |
|
172 |
} else {
|
173 |
Mage::getSingleton('checkout/session')->addError($response['error_message']);
|
|
|
174 |
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
|
175 |
}
|
176 |
}
|
159 |
updateOrderByXpaymentResponse($orderId, $response['response']['transaction_id']);
|
160 |
if (!$result['success']) {
|
161 |
Mage::getSingleton('checkout/session')->addError($result['error_message']);
|
162 |
+
Mage::getSingleton('checkout/session')
|
163 |
+
->addNotice($xpHelper->getFailureCheckoutNoticeHelper());
|
164 |
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
|
165 |
} else {
|
166 |
// additional subscription profile setting for success transaction
|
167 |
$newTransactionDate = new Zend_Date(time());
|
168 |
+
$profile->setXpSuccessTransactionDate($newTransactionDate
|
169 |
+
->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
|
170 |
$profile->setXpCountSuccessTransaction(1);
|
171 |
|
172 |
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
|
174 |
|
175 |
} else {
|
176 |
Mage::getSingleton('checkout/session')->addError($response['error_message']);
|
177 |
+
Mage::getSingleton('checkout/session')->addNotice($xpHelper->getFailureCheckoutNoticeHelper());
|
178 |
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
|
179 |
}
|
180 |
}
|
app/code/community/Cdev/XPaymentsConnector/controllers/Adminhtml/Sales/Order/FraudController.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* @author Valerii Demidov
|
16 |
+
* @category Cdev
|
17 |
+
* @package Cdev_XPaymentsConnector
|
18 |
+
* @copyright (c) Qualiteam Software Ltd. <info@qtmsoft.com>. All rights reserved.
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
|
22 |
+
/**
|
23 |
+
*
|
24 |
+
* Class Mage_Adminhtml_Sales_OrderController
|
25 |
+
*/
|
26 |
+
class Cdev_XPaymentsConnector_Adminhtml_Sales_Order_FraudController extends Mage_Adminhtml_Controller_Action
|
27 |
+
{
|
28 |
+
|
29 |
+
public function acceptAction()
|
30 |
+
{
|
31 |
+
|
32 |
+
if ($order = $this->_initOrder()) {
|
33 |
+
|
34 |
+
$xpcTxnid = $order->getXpcTxnid();
|
35 |
+
if(!empty($xpcTxnid)){
|
36 |
+
$xpaymentCCModel = Mage::getModel('xpaymentsconnector/payment_cc');
|
37 |
+
$result = $xpaymentCCModel->sendFraudRequest($xpcTxnid,'accept');
|
38 |
+
|
39 |
+
if ($result) {
|
40 |
+
$order->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
|
41 |
+
$order->save();
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
$this->_redirect('*/sales_order/view', array('order_id' => $order->getId()));
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
public function declineAction()
|
51 |
+
{
|
52 |
+
|
53 |
+
if ($order = $this->_initOrder()) {
|
54 |
+
$xpcTxnid = $order->getXpcTxnid();
|
55 |
+
if(!empty($xpcTxnid)){
|
56 |
+
$xpaymentCCModel = Mage::getModel('xpaymentsconnector/payment_cc');
|
57 |
+
$result = $xpaymentCCModel->sendFraudRequest($xpcTxnid,'decline');
|
58 |
+
|
59 |
+
if ($result) {
|
60 |
+
$order->cancel();
|
61 |
+
$order->save();
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
$this->_redirect('*/sales_order/view', array('order_id' => $order->getId()));
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Initialize order model instance
|
72 |
+
*
|
73 |
+
* @return Mage_Sales_Model_Order || false
|
74 |
+
*/
|
75 |
+
protected function _initOrder()
|
76 |
+
{
|
77 |
+
$id = $this->getRequest()->getParam('order_id');
|
78 |
+
$order = Mage::getModel('sales/order')->load($id);
|
79 |
+
|
80 |
+
if (!$order->getId()) {
|
81 |
+
$this->_getSession()->addError($this->__('This order no longer exists.'));
|
82 |
+
$this->_redirect('*/*/');
|
83 |
+
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
|
84 |
+
return false;
|
85 |
+
}
|
86 |
+
Mage::register('sales_order', $order);
|
87 |
+
Mage::register('current_order', $order);
|
88 |
+
return $order;
|
89 |
+
}
|
90 |
+
|
91 |
+
}
|
app/code/community/Cdev/XPaymentsConnector/controllers/CustomerController.php
CHANGED
@@ -105,9 +105,10 @@ class Cdev_XPaymentsConnector_CustomerController extends Mage_Core_Controller_Fr
|
|
105 |
Mage::throwException('Missing or invalid transaction ID');
|
106 |
}
|
107 |
|
108 |
-
|
|
|
109 |
$transactionStatusLabel = $CCPaymentModel->getTransactionStatusLabels();
|
110 |
-
$resultMessage =
|
111 |
|
112 |
list($status, $response) = $CCPaymentModel->requestPaymentInfo($request['txnId']);
|
113 |
|
@@ -115,22 +116,29 @@ class Cdev_XPaymentsConnector_CustomerController extends Mage_Core_Controller_Fr
|
|
115 |
!$status
|
116 |
|| !in_array($response['status'], array($CCPaymentModel::AUTH_STATUS, $CCPaymentModel::CHARGED_STATUS))
|
117 |
) {
|
118 |
-
|
119 |
-
|
120 |
-
|
|
|
|
|
|
|
|
|
|
|
121 |
}else{
|
|
|
|
|
|
|
122 |
// save user card
|
123 |
-
Mage::getSingleton(
|
124 |
-
$newCardData = $CCPaymentModel->saveUserCard($
|
125 |
-
|
126 |
-
$resultMessage = $this->__("Payment card has been added successfully!");
|
127 |
|
128 |
-
Mage::getSingleton(
|
129 |
}
|
130 |
|
131 |
$this->getResponse()->setBody(
|
132 |
$this->getLayout()
|
133 |
-
->createBlock('xpaymentsconnector/customer_success')->setData(
|
134 |
->toHtml()
|
135 |
);
|
136 |
return;
|
105 |
Mage::throwException('Missing or invalid transaction ID');
|
106 |
}
|
107 |
|
108 |
+
|
109 |
+
$CCPaymentModel = Mage::getModel('xpaymentsconnector/payment_cc');
|
110 |
$transactionStatusLabel = $CCPaymentModel->getTransactionStatusLabels();
|
111 |
+
$resultMessage = '';
|
112 |
|
113 |
list($status, $response) = $CCPaymentModel->requestPaymentInfo($request['txnId']);
|
114 |
|
116 |
!$status
|
117 |
|| !in_array($response['status'], array($CCPaymentModel::AUTH_STATUS, $CCPaymentModel::CHARGED_STATUS))
|
118 |
) {
|
119 |
+
if (isset($transactionStatusLabel[$response['status']])) {
|
120 |
+
$errorMessage = $this->__("Transaction status is '%s'. Card authorization has been cancelled.",$transactionStatusLabel[$response['status']]);
|
121 |
+
} else {
|
122 |
+
$errorMessage = $this->__('%s. Card authorization has been cancelled.',$response['error_message']);
|
123 |
+
}
|
124 |
+
|
125 |
+
Mage::getSingleton('customer/session')->addError($errorMessage);
|
126 |
+
$resultMessage = 'Card authorization has been cancelled.';
|
127 |
}else{
|
128 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
129 |
+
$cardData = unserialize($customer->getData('xp_buffer'));
|
130 |
+
|
131 |
// save user card
|
132 |
+
Mage::getSingleton('checkout/session')->setData('user_card_save',true);
|
133 |
+
$newCardData = $CCPaymentModel->saveUserCard($cardData);
|
134 |
+
$resultMessage = $this->__('Payment card has been added successfully!');
|
|
|
135 |
|
136 |
+
Mage::getSingleton('customer/session')->addSuccess( $this->__("You created card number '%s'. Transaction status is '%s'.",$newCardData->getData('xp_card_id'),$transactionStatusLabel[$response['status']]));
|
137 |
}
|
138 |
|
139 |
$this->getResponse()->setBody(
|
140 |
$this->getLayout()
|
141 |
+
->createBlock('xpaymentsconnector/customer_success')->setData('result_message',$resultMessage)
|
142 |
->toHtml()
|
143 |
);
|
144 |
return;
|
app/code/community/Cdev/XPaymentsConnector/controllers/ProcessingController.php
CHANGED
@@ -21,7 +21,7 @@
|
|
21 |
|
22 |
/**
|
23 |
* Process payment controller
|
24 |
-
*
|
25 |
* @package Cdev_XPaymentsConnector
|
26 |
* @see ____class_see____
|
27 |
* @since 1.0.0
|
@@ -30,7 +30,7 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
30 |
{
|
31 |
/**
|
32 |
* Get checkout session
|
33 |
-
*
|
34 |
* @return object
|
35 |
* @access protected
|
36 |
* @see ____func_see____
|
@@ -49,7 +49,7 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
49 |
|
50 |
/**
|
51 |
* Callback request
|
52 |
-
*
|
53 |
* @return void
|
54 |
* @access public
|
55 |
* @see ____func_see____
|
@@ -57,8 +57,8 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
57 |
*/
|
58 |
public function callbackAction()
|
59 |
{
|
60 |
-
// Check request type
|
61 |
|
|
|
62 |
if (!$this->getRequest()->isPost()) {
|
63 |
Mage::throwException('Wrong request type.');
|
64 |
}
|
@@ -68,8 +68,10 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
68 |
'/^.+$/Ss',
|
69 |
explode(',', Mage::getStoreConfig('xpaymentsconnector/settings/xpay_allowed_ip_addresses'))
|
70 |
);
|
|
|
71 |
$api = Mage::getModel('xpaymentsconnector/payment_cc');
|
72 |
|
|
|
73 |
if ($ips) {
|
74 |
$helper = Mage::helper('core/http');
|
75 |
if (method_exists($helper, 'getRemoteAddr')) {
|
@@ -109,6 +111,57 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
109 |
$xpaymentsHelper::XPAYMENTS_LOG_FILE,
|
110 |
true);
|
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
|
113 |
// Check order
|
114 |
$order = Mage::getModel('sales/order')->loadByAttribute('xpc_txnid', $request['txnId']);
|
@@ -140,54 +193,12 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
140 |
|
141 |
}
|
142 |
|
143 |
-
//TODO: need process 'charge response' from 'x-payment server'
|
144 |
-
/*
|
145 |
-
elseif (isset($request['updateData']['parentId'])) {
|
146 |
-
|
147 |
-
$userCardModel = Mage::getModel('xpaymentsconnector/usercards');
|
148 |
-
$userCardCollection = $userCardModel
|
149 |
-
->getCollection()
|
150 |
-
->addFieldToSelect('user_id')
|
151 |
-
->addFieldToSelect('last_4_cc_num')
|
152 |
-
->addFieldToSelect('card_type')
|
153 |
-
->addFilter('txnId', $request['updateData']['parentId']);
|
154 |
-
if ($userCardCollection->getSize()) {
|
155 |
-
$newPrepaidCard = $userCardCollection->getFirstItem()->getData();
|
156 |
-
$newPrepaidCard['txnId'] = $request['txnId'];
|
157 |
-
$newPrepaidCard['usage_type'] = Cdev_XPaymentsConnector_Model_Usercards::BALANCE_CARD;
|
158 |
-
$newPrepaidCard['amount'] = $request['updateData']['amount'];
|
159 |
-
$userCardModel->setData($newPrepaidCard);
|
160 |
-
$userCardModel->save();
|
161 |
-
} else {
|
162 |
-
$order = Mage::getModel('sales/order')->loadByAttribute('xpc_txnid', $request['updateData']['parentId']);
|
163 |
-
if ($order->getId()) {
|
164 |
-
$newPrepaidCard = array();
|
165 |
-
$newPrepaidCard['user_id'] = $order->getData('customer_id');
|
166 |
-
$newPrepaidCard['txnId'] = $request['txnId'];
|
167 |
-
$newPrepaidCard['usage_type'] = Cdev_XPaymentsConnector_Model_Usercards::BALANCE_CARD;
|
168 |
-
$newPrepaidCard['amount'] = $request['updateData']['amount'];
|
169 |
-
|
170 |
-
$parentXpaymentResponseData = unserialize($order->getData('xp_card_data'));
|
171 |
-
$newPrepaidCard['last_4_cc_num'] = $parentXpaymentResponseData['last_4_cc_num'];
|
172 |
-
$newPrepaidCard['card_type'] = $parentXpaymentResponseData['card_type'];
|
173 |
-
|
174 |
-
$userCardModel->setData($newPrepaidCard);
|
175 |
-
$userCardModel->save();
|
176 |
-
} else {
|
177 |
-
|
178 |
-
$errorMessage = "Unable to create 'prepaid cart' because there is no corresponding order with the number of tokens -".$request['txnId'];
|
179 |
-
$api->getAPIError($errorMessage);
|
180 |
-
|
181 |
-
}
|
182 |
-
}
|
183 |
-
}
|
184 |
-
*/
|
185 |
exit(0);
|
186 |
}
|
187 |
|
188 |
/**
|
189 |
-
* Payment is success
|
190 |
-
*
|
191 |
* @return void
|
192 |
* @access public
|
193 |
* @see ____func_see____
|
@@ -201,7 +212,7 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
201 |
|
202 |
/**
|
203 |
* Payment is cancelled
|
204 |
-
*
|
205 |
* @return void
|
206 |
* @access public
|
207 |
* @see ____func_see____
|
@@ -219,7 +230,7 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
219 |
|
220 |
/**
|
221 |
* Process cancel by customer (from X-Payments interface)
|
222 |
-
*
|
223 |
* @return void
|
224 |
* @access protected
|
225 |
* @see ____func_see____
|
@@ -235,7 +246,7 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
235 |
Mage::throwException('Missing or invalid order ID');
|
236 |
}
|
237 |
|
238 |
-
|
239 |
$order = Mage::getModel('sales/order')->loadByIncrementId(intval($query['refId']));
|
240 |
$profileIds = Mage::getSingleton('checkout/session')->getLastRecurringProfileIds();
|
241 |
|
@@ -289,14 +300,14 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
289 |
}
|
290 |
|
291 |
/**
|
292 |
-
* Restore cart content on payment failure
|
293 |
-
*
|
294 |
* @return void
|
295 |
* @access puplic
|
296 |
* @see ____func_see____
|
297 |
* @since 1.0.6
|
298 |
*/
|
299 |
-
public function restoreCart($order)
|
300 |
{
|
301 |
|
302 |
$session = Mage::getSingleton('checkout/session');
|
@@ -348,7 +359,9 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
348 |
$result = $api->sendHandshakeRequest($order);
|
349 |
|
350 |
if (!$result) {
|
351 |
-
$
|
|
|
|
|
352 |
|
353 |
} else {
|
354 |
|
@@ -367,9 +380,8 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
367 |
|
368 |
return;
|
369 |
}
|
370 |
-
|
371 |
-
|
372 |
}
|
|
|
373 |
$profileIds = Mage::getSingleton('checkout/session')->getLastRecurringProfileIds();
|
374 |
if(!empty($profileIds)){
|
375 |
$this->loadLayout();
|
@@ -393,6 +405,7 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
393 |
$this->_redirect('checkout/cart');
|
394 |
}
|
395 |
|
|
|
396 |
/**
|
397 |
* Return customer from X-Payments
|
398 |
*
|
@@ -401,7 +414,6 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
401 |
* @see ____func_see____
|
402 |
* @since 1.0.0
|
403 |
*/
|
404 |
-
|
405 |
public function returnAction()
|
406 |
{
|
407 |
if ($this->processCancel()) {
|
@@ -419,103 +431,6 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
419 |
Mage::throwException('Request doesn\'t contain POST elements.');
|
420 |
}
|
421 |
|
422 |
-
// Check order id
|
423 |
-
if (empty($request['refId'])) {
|
424 |
-
Mage::throwException('Missing or invalid order ID');
|
425 |
-
}
|
426 |
-
|
427 |
-
// Check order
|
428 |
-
$order = Mage::getModel('sales/order')->loadByIncrementId(intval($request['refId']));
|
429 |
-
|
430 |
-
if (!$order->getId()) {
|
431 |
-
Mage::throwException('Order not found');
|
432 |
-
}
|
433 |
-
|
434 |
-
$refId = $request['refId'];
|
435 |
-
|
436 |
-
/*make a temporary entry for cardholder data*/
|
437 |
-
Mage::helper('xpaymentsconnector')->savePaymentResponse($request);
|
438 |
-
|
439 |
-
if($order->getId()){
|
440 |
-
/*update order table*/
|
441 |
-
$customOrderId = Mage::helper('xpaymentsconnector')->getOrderKey();
|
442 |
-
$order->setData('xpc_txnid', $request['txnId']);
|
443 |
-
$order->setData('xp_card_data', serialize($request));
|
444 |
-
$order->save();
|
445 |
-
/*end (update order table)*/
|
446 |
-
|
447 |
-
$result = Mage::getModel('xpaymentsconnector/payment_cc')->updateOrderByXpaymentResponse($order->getId(),$request['txnId'],$refId);
|
448 |
-
|
449 |
-
if ($result['success']) {
|
450 |
-
/* save credit card to user profile */
|
451 |
-
Mage::getModel('xpaymentsconnector/payment_cc')->saveUserCard($request);
|
452 |
-
/* end (save payment card) */
|
453 |
-
$this->getResponse()->setBody(
|
454 |
-
$this->getLayout()
|
455 |
-
->createBlock('xpaymentsconnector/success')
|
456 |
-
->setOrder($order)
|
457 |
-
->toHtml()
|
458 |
-
);
|
459 |
-
return;
|
460 |
-
|
461 |
-
} else {
|
462 |
-
|
463 |
-
if ($order->canCancel()) {
|
464 |
-
|
465 |
-
$this->restoreCart($order);
|
466 |
-
|
467 |
-
$order->cancel();
|
468 |
-
$order->addStatusToHistory(
|
469 |
-
Mage_Sales_Model_Order::STATE_CANCELED,
|
470 |
-
Mage::helper('xpaymentsconnector')->__('The payment has been canceled')
|
471 |
-
);
|
472 |
-
$order->save();
|
473 |
-
}
|
474 |
-
|
475 |
-
$this->getResponse()->setBody(
|
476 |
-
$this->getLayout()
|
477 |
-
->createBlock('xpaymentsconnector/cancel')
|
478 |
-
->setOrder($order)
|
479 |
-
->toHtml()
|
480 |
-
);
|
481 |
-
return;
|
482 |
-
|
483 |
-
}
|
484 |
-
|
485 |
-
$this->restoreCart($order);
|
486 |
-
|
487 |
-
$this->getResponse()->setBody(
|
488 |
-
$this->getLayout()
|
489 |
-
->createBlock('xpaymentsconnector/failure')
|
490 |
-
->setOrder($order)
|
491 |
-
->toHtml()
|
492 |
-
);
|
493 |
-
}
|
494 |
-
}
|
495 |
-
|
496 |
-
|
497 |
-
/**
|
498 |
-
* Iframe return customer from X-Payments
|
499 |
-
*
|
500 |
-
* @return void
|
501 |
-
* @access public
|
502 |
-
* @see ____func_see____
|
503 |
-
* @since 1.0.0
|
504 |
-
*/
|
505 |
-
public function iframereturnAction()
|
506 |
-
{
|
507 |
-
if ($this->processCancel()) {
|
508 |
-
return;
|
509 |
-
}
|
510 |
-
|
511 |
-
// Check request type
|
512 |
-
if (!$this->getRequest()->isPost()) {
|
513 |
-
Mage::throwException('Wrong request type.');
|
514 |
-
}
|
515 |
-
|
516 |
-
// Check request data
|
517 |
-
$request = $this->getRequest()->getPost();
|
518 |
-
|
519 |
$xpHelper = Mage::helper('xpaymentsconnector');
|
520 |
|
521 |
if (empty($request)) {
|
@@ -531,25 +446,32 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
531 |
$xpHelper->savePaymentResponse($request);
|
532 |
}
|
533 |
|
534 |
-
$cardData = $xpHelper->getXpaymentResponse();
|
535 |
-
|
536 |
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
537 |
$checkoutSession = Mage::getSingleton('checkout/session');
|
538 |
$orderIncrementId = $checkoutSession->getLastRealOrderId();
|
539 |
if(!$useIframe){
|
|
|
|
|
|
|
540 |
$profileIds = $checkoutSession->getLastRecurringProfileIds();
|
541 |
$paymentCcModel = Mage::getModel('xpaymentsconnector/payment_cc');
|
542 |
|
543 |
if ($orderIncrementId) {
|
544 |
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
|
|
|
|
|
|
|
545 |
$orderId = $order->getId();
|
546 |
-
$order->setData('xp_card_data', serialize($request));
|
547 |
-
$order->save();
|
548 |
$refId = $request['refId'];
|
549 |
|
|
|
|
|
|
|
|
|
550 |
$result = $paymentCcModel->updateOrderByXpaymentResponse($orderId,$cardData['txnId'],$refId);
|
551 |
if (!$result['success']) {
|
552 |
$checkoutSession->addError($result['error_message']);
|
|
|
553 |
}else{
|
554 |
if (is_null($profileIds)) {
|
555 |
$paymentCcModel->saveUserCard($cardData);
|
@@ -559,6 +481,10 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
559 |
}
|
560 |
|
561 |
if($profileIds){
|
|
|
|
|
|
|
|
|
562 |
foreach($profileIds as $profileId){
|
563 |
$profile = Mage::getModel('sales/recurring_profile')->load($profileId);
|
564 |
|
21 |
|
22 |
/**
|
23 |
* Process payment controller
|
24 |
+
*
|
25 |
* @package Cdev_XPaymentsConnector
|
26 |
* @see ____class_see____
|
27 |
* @since 1.0.0
|
30 |
{
|
31 |
/**
|
32 |
* Get checkout session
|
33 |
+
*
|
34 |
* @return object
|
35 |
* @access protected
|
36 |
* @see ____func_see____
|
49 |
|
50 |
/**
|
51 |
* Callback request
|
52 |
+
*
|
53 |
* @return void
|
54 |
* @access public
|
55 |
* @see ____func_see____
|
57 |
*/
|
58 |
public function callbackAction()
|
59 |
{
|
|
|
60 |
|
61 |
+
// Check request type
|
62 |
if (!$this->getRequest()->isPost()) {
|
63 |
Mage::throwException('Wrong request type.');
|
64 |
}
|
68 |
'/^.+$/Ss',
|
69 |
explode(',', Mage::getStoreConfig('xpaymentsconnector/settings/xpay_allowed_ip_addresses'))
|
70 |
);
|
71 |
+
|
72 |
$api = Mage::getModel('xpaymentsconnector/payment_cc');
|
73 |
|
74 |
+
|
75 |
if ($ips) {
|
76 |
$helper = Mage::helper('core/http');
|
77 |
if (method_exists($helper, 'getRemoteAddr')) {
|
111 |
$xpaymentsHelper::XPAYMENTS_LOG_FILE,
|
112 |
true);
|
113 |
|
114 |
+
$quoteId = Mage::app()->getRequest()->getParam('quote_id');
|
115 |
+
$customerId = Mage::app()->getRequest()->getParam('customer_id');
|
116 |
+
|
117 |
+
if (isset($request['action'])) {
|
118 |
+
switch ($request['action']) {
|
119 |
+
case 'check_cart':
|
120 |
+
|
121 |
+
if ($quoteId) {
|
122 |
+
$cartModel = Mage::getModel('sales/quote')->load($quoteId);
|
123 |
+
$xpCallbackApprove = $cartModel->getData('xp_callback_approve');
|
124 |
+
} elseif ($customerId) {
|
125 |
+
$customer = Mage::getModel('customer/customer')->load($customerId);
|
126 |
+
$xpCallbackApprove = $customer->getData('xp_buffer');
|
127 |
+
}
|
128 |
+
|
129 |
+
$cartData = array();
|
130 |
+
if (!empty($xpCallbackApprove)) {
|
131 |
+
$cartData = unserialize($xpCallbackApprove);
|
132 |
+
}
|
133 |
+
|
134 |
+
$cartData['ref_id'] = $request['txnId'];
|
135 |
+
Mage::log(sprintf('X-Payment approve response: %s', serialize($cartData)),
|
136 |
+
null,
|
137 |
+
$xpaymentsHelper::XPAYMENTS_LOG_FILE,
|
138 |
+
true);
|
139 |
+
|
140 |
+
$xmlCallbackApprove = $api->convertHash2XML($cartData);
|
141 |
+
// Encrypt
|
142 |
+
$xmlEncrypt = $api->encrypt($xmlCallbackApprove);
|
143 |
+
echo $xmlEncrypt;
|
144 |
+
|
145 |
+
break;
|
146 |
+
|
147 |
+
case 'callback':
|
148 |
+
if (isset($request['updateData']) && isset($request['updateData']['maskedCardData'])) {
|
149 |
+
$cardData = $request['updateData']['maskedCardData'];
|
150 |
+
$cardData['txnId'] = $request['txnId'];
|
151 |
+
|
152 |
+
if ($quoteId) {
|
153 |
+
$xpaymentsHelper->saveXpCardData($quoteId,$cardData);
|
154 |
+
} elseif ($customerId) {
|
155 |
+
$customer = Mage::getModel('customer/customer')->load($customerId);
|
156 |
+
$customer->setData('xp_buffer', serialize($cardData));
|
157 |
+
$customer->save();
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
break;
|
162 |
+
}
|
163 |
+
|
164 |
+
}
|
165 |
|
166 |
// Check order
|
167 |
$order = Mage::getModel('sales/order')->loadByAttribute('xpc_txnid', $request['txnId']);
|
193 |
|
194 |
}
|
195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
exit(0);
|
197 |
}
|
198 |
|
199 |
/**
|
200 |
+
* Payment is success
|
201 |
+
*
|
202 |
* @return void
|
203 |
* @access public
|
204 |
* @see ____func_see____
|
212 |
|
213 |
/**
|
214 |
* Payment is cancelled
|
215 |
+
*
|
216 |
* @return void
|
217 |
* @access public
|
218 |
* @see ____func_see____
|
230 |
|
231 |
/**
|
232 |
* Process cancel by customer (from X-Payments interface)
|
233 |
+
*
|
234 |
* @return void
|
235 |
* @access protected
|
236 |
* @see ____func_see____
|
246 |
Mage::throwException('Missing or invalid order ID');
|
247 |
}
|
248 |
|
249 |
+
// Check order
|
250 |
$order = Mage::getModel('sales/order')->loadByIncrementId(intval($query['refId']));
|
251 |
$profileIds = Mage::getSingleton('checkout/session')->getLastRecurringProfileIds();
|
252 |
|
300 |
}
|
301 |
|
302 |
/**
|
303 |
+
* Restore cart content on payment failure
|
304 |
+
*
|
305 |
* @return void
|
306 |
* @access puplic
|
307 |
* @see ____func_see____
|
308 |
* @since 1.0.6
|
309 |
*/
|
310 |
+
public function restoreCart($order)
|
311 |
{
|
312 |
|
313 |
$session = Mage::getSingleton('checkout/session');
|
359 |
$result = $api->sendHandshakeRequest($order);
|
360 |
|
361 |
if (!$result) {
|
362 |
+
$failedCompleteMessage = 'Failed to complete the payment transaction.'
|
363 |
+
.' Please use another payment method or contact the store administrator.';
|
364 |
+
$this->_getCheckout()->addError($failedCompleteMessage);
|
365 |
|
366 |
} else {
|
367 |
|
380 |
|
381 |
return;
|
382 |
}
|
|
|
|
|
383 |
}
|
384 |
+
|
385 |
$profileIds = Mage::getSingleton('checkout/session')->getLastRecurringProfileIds();
|
386 |
if(!empty($profileIds)){
|
387 |
$this->loadLayout();
|
405 |
$this->_redirect('checkout/cart');
|
406 |
}
|
407 |
|
408 |
+
|
409 |
/**
|
410 |
* Return customer from X-Payments
|
411 |
*
|
414 |
* @see ____func_see____
|
415 |
* @since 1.0.0
|
416 |
*/
|
|
|
417 |
public function returnAction()
|
418 |
{
|
419 |
if ($this->processCancel()) {
|
431 |
Mage::throwException('Request doesn\'t contain POST elements.');
|
432 |
}
|
433 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
434 |
$xpHelper = Mage::helper('xpaymentsconnector');
|
435 |
|
436 |
if (empty($request)) {
|
446 |
$xpHelper->savePaymentResponse($request);
|
447 |
}
|
448 |
|
|
|
|
|
449 |
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
450 |
$checkoutSession = Mage::getSingleton('checkout/session');
|
451 |
$orderIncrementId = $checkoutSession->getLastRealOrderId();
|
452 |
if(!$useIframe){
|
453 |
+
$quoteId = Mage::app()->getRequest()->getParam('quote_id');
|
454 |
+
$cardData = array();
|
455 |
+
|
456 |
$profileIds = $checkoutSession->getLastRecurringProfileIds();
|
457 |
$paymentCcModel = Mage::getModel('xpaymentsconnector/payment_cc');
|
458 |
|
459 |
if ($orderIncrementId) {
|
460 |
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
|
461 |
+
$quoteId = $order->getQuoteId();
|
462 |
+
$cardData = $xpHelper->getXpCardData($quoteId);
|
463 |
+
|
464 |
$orderId = $order->getId();
|
|
|
|
|
465 |
$refId = $request['refId'];
|
466 |
|
467 |
+
// save card data to order from quote
|
468 |
+
$order->setData('xp_card_data', serialize($cardData));
|
469 |
+
$order->save();
|
470 |
+
|
471 |
$result = $paymentCcModel->updateOrderByXpaymentResponse($orderId,$cardData['txnId'],$refId);
|
472 |
if (!$result['success']) {
|
473 |
$checkoutSession->addError($result['error_message']);
|
474 |
+
$checkoutSession->addNotice($xpHelper->getFailureCheckoutNoticeHelper());
|
475 |
}else{
|
476 |
if (is_null($profileIds)) {
|
477 |
$paymentCcModel->saveUserCard($cardData);
|
481 |
}
|
482 |
|
483 |
if($profileIds){
|
484 |
+
if (empty($cardData)) {
|
485 |
+
$cardData = $xpHelper->getXpCardData($quoteId);
|
486 |
+
}
|
487 |
+
|
488 |
foreach($profileIds as $profileId){
|
489 |
$profile = Mage::getModel('sales/recurring_profile')->load($profileId);
|
490 |
|
app/code/community/Cdev/XPaymentsConnector/etc/config.xml
CHANGED
@@ -23,7 +23,7 @@
|
|
23 |
<config>
|
24 |
<modules>
|
25 |
<Cdev_XPaymentsConnector>
|
26 |
-
<version>1.1.
|
27 |
</Cdev_XPaymentsConnector>
|
28 |
</modules>
|
29 |
<global>
|
@@ -81,6 +81,13 @@
|
|
81 |
</connection>
|
82 |
</xpaymentsconnector_read>
|
83 |
</resources>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
<blocks>
|
85 |
<customer>
|
86 |
<rewrite>
|
@@ -93,8 +100,14 @@
|
|
93 |
<checkout>
|
94 |
<rewrite>
|
95 |
<onepage_payment_methods>Cdev_XPaymentsConnector_Block_Form_Container</onepage_payment_methods>
|
|
|
96 |
</rewrite>
|
97 |
</checkout>
|
|
|
|
|
|
|
|
|
|
|
98 |
</blocks>
|
99 |
<events>
|
100 |
<sales_order_payment_cancel_invoice>
|
@@ -433,6 +446,7 @@
|
|
433 |
<settings>
|
434 |
<activationstatus>0</activationstatus>
|
435 |
<xpay_minimum_payment_recurring_amount>0.5</xpay_minimum_payment_recurring_amount>
|
|
|
436 |
</settings>
|
437 |
</xpaymentsconnector>
|
438 |
</default>
|
23 |
<config>
|
24 |
<modules>
|
25 |
<Cdev_XPaymentsConnector>
|
26 |
+
<version>1.1.2</version>
|
27 |
</Cdev_XPaymentsConnector>
|
28 |
</modules>
|
29 |
<global>
|
81 |
</connection>
|
82 |
</xpaymentsconnector_read>
|
83 |
</resources>
|
84 |
+
<fieldsets>
|
85 |
+
<sales_convert_quote>
|
86 |
+
<xp_card_data>
|
87 |
+
<to_order>*</to_order>
|
88 |
+
</xp_card_data>
|
89 |
+
</sales_convert_quote>
|
90 |
+
</fieldsets>
|
91 |
<blocks>
|
92 |
<customer>
|
93 |
<rewrite>
|
100 |
<checkout>
|
101 |
<rewrite>
|
102 |
<onepage_payment_methods>Cdev_XPaymentsConnector_Block_Form_Container</onepage_payment_methods>
|
103 |
+
<onepage_success>Cdev_XPaymentsConnector_Block_Checkout_Onepage_Success</onepage_success>
|
104 |
</rewrite>
|
105 |
</checkout>
|
106 |
+
<adminhtml>
|
107 |
+
<rewrite>
|
108 |
+
<sales_order_view>Cdev_XPaymentsConnector_Block_Adminhtml_Sales_Order_View</sales_order_view>
|
109 |
+
</rewrite>
|
110 |
+
</adminhtml>
|
111 |
</blocks>
|
112 |
<events>
|
113 |
<sales_order_payment_cancel_invoice>
|
446 |
<settings>
|
447 |
<activationstatus>0</activationstatus>
|
448 |
<xpay_minimum_payment_recurring_amount>0.5</xpay_minimum_payment_recurring_amount>
|
449 |
+
<xpay_currency>USD</xpay_currency>
|
450 |
</settings>
|
451 |
</xpaymentsconnector>
|
452 |
</default>
|
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.1.1-1.1.2.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|