Version Notes
Version number: 1.3.2
Download this release
Release Info
Developer | Valerii Demidov |
Extension | CDev_XPaymentsConnector |
Version | 1.3.2 |
Comparing to | |
See all releases |
Code changes from version 1.3.1 to 1.3.2
- app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Sales/Order/View/Tab/Xporderstate.php +3 -1
- app/code/community/Cdev/XPaymentsConnector/Block/Checkout/Onepage/Orderdetail.php +93 -0
- app/code/community/Cdev/XPaymentsConnector/Block/Recurring/Profile/View.php +9 -0
- app/code/community/Cdev/XPaymentsConnector/Helper/Data.php +659 -265
- app/code/community/Cdev/XPaymentsConnector/Model/Observer.php +217 -160
- app/code/community/Cdev/XPaymentsConnector/Model/Payment/Cc.php +239 -129
- app/code/community/Cdev/XPaymentsConnector/Model/Payment/Savedcards.php +58 -35
- app/code/community/Cdev/XPaymentsConnector/Model/Quote.php +31 -7
- app/code/community/Cdev/XPaymentsConnector/Model/Quote/Address/Total/Nominal.php +10 -1
- app/code/community/Cdev/XPaymentsConnector/Model/Quote/Address/Total/Nominal/Recurring/Initialfee/Tax.php +66 -0
- app/code/community/Cdev/XPaymentsConnector/Model/Sales/Recurring/Profile.php +62 -7
- app/code/community/Cdev/XPaymentsConnector/controllers/CustomerController.php +1 -1
- app/code/community/Cdev/XPaymentsConnector/controllers/ProcessingController.php +270 -207
- app/code/community/Cdev/XPaymentsConnector/etc/config.xml +6 -2
- app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.9-1.1.0.php +29 -0
- app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.1.0-1.1.1.php +29 -0
- app/design/adminhtml/default/default/template/xpaymentsconnector/order/view/tab/xporderstate.phtml +189 -183
- app/design/frontend/default/default/layout/xpaymentsconnector.xml +2 -0
- app/design/frontend/default/default/template/xpaymentsconnector/checkout/onepage/order-detail.phtml +59 -0
- app/design/frontend/default/default/template/xpaymentsconnector/checkout/onepage/xpayment-iframe.phtml +6 -5
- app/design/frontend/default/default/template/xpaymentsconnector/form/cc.phtml +3 -3
- app/design/frontend/rwd/default/layout/xpaymentsconnector.xml +2 -0
- app/design/frontend/rwd/default/template/xpaymentsconnector/checkout/onepage/order-detail.phtml +59 -0
- app/design/frontend/rwd/default/template/xpaymentsconnector/checkout/onepage/xpayment-iframe.phtml +6 -5
- app/design/frontend/rwd/default/template/xpaymentsconnector/form/cc.phtml +3 -3
- app/locale/en_US/Cdev_XPaymentsConnector.csv +11 -4
- js/xpayment/checkout-submit.js +3 -1
- js/xpayment/settings.css +8 -0
- package.xml +5 -5
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Sales/Order/View/Tab/Xporderstate.php
CHANGED
@@ -112,7 +112,6 @@ class Cdev_XPaymentsConnector_Block_Adminhtml_Sales_Order_View_Tab_Xporderstate
|
|
112 |
if($this->transactionStatus){
|
113 |
$this->transactionInfo[$currentOrder->getIncrementId()]["payment"]["xpc_txnid"] = $this->txnid;
|
114 |
}
|
115 |
-
|
116 |
}
|
117 |
|
118 |
while(!is_null($parentOrder = $currentOrder->getRelationParentId())){
|
@@ -149,6 +148,9 @@ class Cdev_XPaymentsConnector_Block_Adminhtml_Sales_Order_View_Tab_Xporderstate
|
|
149 |
case ($xpOrderStateData["refundedAmountAvailGateway"] > 0 && $xpOrderStateData["capturedAmountAvailGateway"] < 0.01):
|
150 |
$actionAmount = $xpOrderStateData["refundedAmountAvailGateway"];
|
151 |
break;
|
|
|
|
|
|
|
152 |
}
|
153 |
return $actionAmount;
|
154 |
}
|
112 |
if($this->transactionStatus){
|
113 |
$this->transactionInfo[$currentOrder->getIncrementId()]["payment"]["xpc_txnid"] = $this->txnid;
|
114 |
}
|
|
|
115 |
}
|
116 |
|
117 |
while(!is_null($parentOrder = $currentOrder->getRelationParentId())){
|
148 |
case ($xpOrderStateData["refundedAmountAvailGateway"] > 0 && $xpOrderStateData["capturedAmountAvailGateway"] < 0.01):
|
149 |
$actionAmount = $xpOrderStateData["refundedAmountAvailGateway"];
|
150 |
break;
|
151 |
+
case ($actionAmount < 0.01 && $xpOrderStateData["chargedAmount"] > 0):
|
152 |
+
$actionAmount = $xpOrderStateData["chargedAmount"];
|
153 |
+
break;
|
154 |
}
|
155 |
return $actionAmount;
|
156 |
}
|
app/code/community/Cdev/XPaymentsConnector/Block/Checkout/Onepage/Orderdetail.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* Block for additional information about 'recurring items'
|
24 |
+
*/
|
25 |
+
|
26 |
+
class Cdev_XPaymentsConnector_Block_Checkout_Onepage_Orderdetail extends Mage_Core_Block_Template
|
27 |
+
{
|
28 |
+
|
29 |
+
public function getRecurringQuoteItems(){
|
30 |
+
$checkoutSession = Mage::getSingleton('checkout/session');
|
31 |
+
$quoteItems = $checkoutSession->getQuote()->getAllItems();
|
32 |
+
$result = array();
|
33 |
+
|
34 |
+
foreach ($quoteItems as $quoteItem) {
|
35 |
+
if ($quoteItem) {
|
36 |
+
$product = $quoteItem->getProduct();
|
37 |
+
$issetRecurringOreder = (bool)$product->getIsRecurring();
|
38 |
+
if ($issetRecurringOreder) {
|
39 |
+
$result[] = $quoteItem;
|
40 |
+
}
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
return $result;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* @param Mage_Sales_Model_Quote_Item $recQuoteItem
|
49 |
+
* @return mixed
|
50 |
+
*/
|
51 |
+
public function getRecurringItemMessage(Mage_Sales_Model_Quote_Item $recQuoteItem){
|
52 |
+
|
53 |
+
$xpHelper = Mage::helper('xpaymentsconnector');
|
54 |
+
$recurringItemMessage = '';
|
55 |
+
$initialFeeMessage = '';
|
56 |
+
$rowTotal = $recQuoteItem->getNominalRowTotal();
|
57 |
+
|
58 |
+
$currency_symbol = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
|
59 |
+
|
60 |
+
$product = $recQuoteItem->getProduct();
|
61 |
+
$productAdditionalInfo = unserialize($product->getCustomOption('info_buyRequest')->getValue());
|
62 |
+
$deferredDateStamp = strtotime($productAdditionalInfo['recurring_profile_start_datetime']);
|
63 |
+
if($deferredDateStamp){
|
64 |
+
$initialFeeMessage = $this->__(" (initial fee only, 1st recurring fee will be charged on %s)",date('d-M-Y',$deferredDateStamp));
|
65 |
+
$rowTotal = $recQuoteItem->getXpRecurringInitialFee() + $recQuoteItem->getInitialfeeTaxAmount();
|
66 |
+
}
|
67 |
+
|
68 |
+
$recurringItemMessage = $xpHelper
|
69 |
+
->__("%s%s for recurring product '%s' in your cart.",
|
70 |
+
$rowTotal, $currency_symbol,$recQuoteItem->getName());
|
71 |
+
|
72 |
+
$mainMessage = $recurringItemMessage.$initialFeeMessage;
|
73 |
+
|
74 |
+
return $mainMessage;
|
75 |
+
|
76 |
+
}
|
77 |
+
|
78 |
+
public function getSimpleQuoteItemMessage(){
|
79 |
+
$checkoutSession = Mage::getSingleton('checkout/session');
|
80 |
+
$quot = $checkoutSession->getQuote();
|
81 |
+
$simpleQuoteItemMessage = '';
|
82 |
+
if($quot->getGrandTotal()){
|
83 |
+
$currency_symbol = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
|
84 |
+
$xpHelper = Mage::helper('xpaymentsconnector');
|
85 |
+
$simpleQuoteItemMessage = $this->__("%s%s for all non-recurring products in your cart.",$quot->getGrandTotal(), $currency_symbol);
|
86 |
+
}
|
87 |
+
|
88 |
+
return $simpleQuoteItemMessage;
|
89 |
+
|
90 |
+
}
|
91 |
+
|
92 |
+
|
93 |
+
}
|
app/code/community/Cdev/XPaymentsConnector/Block/Recurring/Profile/View.php
CHANGED
@@ -40,6 +40,15 @@ class Cdev_XPaymentsConnector_Block_Recurring_Profile_View extends Mage_Sales_Bl
|
|
40 |
'is_amount' => true,
|
41 |
));
|
42 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
}
|
44 |
|
45 |
}
|
40 |
'is_amount' => true,
|
41 |
));
|
42 |
}
|
43 |
+
$initialFeeTaxAmount = $orderItemInfo["initialfee_tax_amount"];
|
44 |
+
if($initialFeeTaxAmount){
|
45 |
+
$initialFeeTaxNominalModel = Mage::getModel("xpaymentsconnector/quote_address_total_nominal_recurring_initialfee_tax");
|
46 |
+
$this->_addInfo(array(
|
47 |
+
'label' => $initialFeeTaxNominalModel->getLabel(),
|
48 |
+
'value' => Mage::helper('core')->formatCurrency($initialFeeTaxAmount, false),
|
49 |
+
'is_amount' => true,
|
50 |
+
));
|
51 |
+
}
|
52 |
}
|
53 |
|
54 |
}
|
app/code/community/Cdev/XPaymentsConnector/Helper/Data.php
CHANGED
@@ -21,7 +21,7 @@
|
|
21 |
|
22 |
/**
|
23 |
* Common helper
|
24 |
-
*
|
25 |
* @package Cdev_XPaymentsConnector
|
26 |
* @see ____class_see____
|
27 |
* @since 1.0.0
|
@@ -33,11 +33,17 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
33 |
const WEEK_TIME_STAMP = 604800;
|
34 |
const SEMI_MONTH_TIME_STAMP = 1209600;
|
35 |
|
36 |
-
const STATE_XPAYMENT_PENDING_PAYMENT =
|
37 |
-
const XPAYMENTS_LOG_FILE =
|
38 |
-
|
39 |
-
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
/**
|
43 |
* This function return 'IncrementId' for feature order.
|
@@ -48,15 +54,15 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
48 |
* return
|
49 |
* @return bool or int
|
50 |
*/
|
51 |
-
public function getOrderKey()
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
55 |
}
|
56 |
return false;
|
57 |
}
|
58 |
|
59 |
-
|
60 |
/**
|
61 |
* This function create 'IncrementId' for feature order.
|
62 |
* Xpayment Prepare Order Mas(xpayment_prepare_order):
|
@@ -68,29 +74,54 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
68 |
*/
|
69 |
public function prepareOrderKey()
|
70 |
{
|
71 |
-
$xpaymentPrepareOrder = Mage::getSingleton(
|
72 |
if(!isset($xpaymentPrepareOrder["prepare_order_id"])){
|
73 |
-
$
|
74 |
-
|
75 |
-
$useStartDateParam = $this->checkStartDateData();
|
76 |
-
if ($useStartDateParam["success"]) {
|
77 |
-
$xpaymentPrepareOrder["prepare_order_id"] = "subscription";
|
78 |
-
Mage::getSingleton("checkout/session")->setData("xpayment_prepare_order",$xpaymentPrepareOrder);
|
79 |
-
return;
|
80 |
-
}
|
81 |
-
}
|
82 |
-
$storeId = Mage::app()->getStore()->getStoreId();
|
83 |
-
$prepareOrderId = Mage::getSingleton('eav/config')
|
84 |
-
->getEntityType('order')
|
85 |
-
->fetchNewIncrementId($storeId);
|
86 |
|
87 |
-
|
88 |
-
Mage::getSingleton("checkout/session")->setData("xpayment_prepare_order", $xpaymentPrepareOrder);
|
89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
|
92 |
}
|
93 |
|
|
|
94 |
/**
|
95 |
* This function set 'place_display' flag for feature x-payment form.
|
96 |
* Xpayment Prepare Order Mas(xpayment_prepare_order):
|
@@ -104,10 +135,10 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
104 |
public function setIframePlaceDisplaySettings()
|
105 |
{
|
106 |
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
107 |
-
if($useIframe){
|
108 |
-
$xpaymentPrepareOrder = Mage::getSingleton(
|
109 |
-
$xpaymentPrepareOrder[
|
110 |
-
Mage::getSingleton(
|
111 |
}
|
112 |
}
|
113 |
|
@@ -115,9 +146,10 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
115 |
* check 'xpayment' config settigs
|
116 |
* @return bool
|
117 |
*/
|
118 |
-
public function isIframePaymentPlaceDisplay()
|
119 |
-
|
120 |
-
|
|
|
121 |
return true;
|
122 |
}
|
123 |
return false;
|
@@ -132,10 +164,11 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
132 |
* return
|
133 |
* @return bool or int
|
134 |
*/
|
135 |
-
public function getXpaymentResponse()
|
136 |
-
|
137 |
-
|
138 |
-
|
|
|
139 |
}
|
140 |
return false;
|
141 |
}
|
@@ -151,36 +184,78 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
151 |
*/
|
152 |
public function getIframeToken()
|
153 |
{
|
154 |
-
$xpaymentPrepareOrder = Mage::getSingleton(
|
155 |
-
if ($xpaymentPrepareOrder && isset($xpaymentPrepareOrder[
|
156 |
-
return $xpaymentPrepareOrder[
|
157 |
} else {
|
158 |
$api = Mage::getModel('xpaymentsconnector/payment_cc');
|
159 |
$result = $api->sendIframeHandshakeRequest();
|
160 |
-
$xpaymentPrepareOrder[
|
161 |
-
Mage::getSingleton(
|
162 |
-
return $xpaymentPrepareOrder[
|
163 |
}
|
164 |
|
165 |
}
|
166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
/**
|
168 |
* Unset prepare order params
|
169 |
* @param array $unsetParams
|
170 |
*/
|
171 |
-
public function unsetXpaymentPrepareOrder($unsetParams = array())
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
|
|
176 |
unset($xpaymentPrepareOrder[$param]);
|
177 |
}
|
178 |
}
|
179 |
-
Mage::getSingleton(
|
180 |
return;
|
181 |
}
|
182 |
|
183 |
-
Mage::getSingleton(
|
184 |
}
|
185 |
|
186 |
/**
|
@@ -190,26 +265,26 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
190 |
*/
|
191 |
public function savePaymentResponse($responseData)
|
192 |
{
|
193 |
-
$xpaymentPrepareOrder = Mage::getSingleton(
|
194 |
-
$xpaymentPrepareOrder[
|
195 |
-
Mage::getSingleton(
|
196 |
}
|
197 |
|
198 |
/**
|
199 |
* Save all allowed payments for current checkout session in store.
|
200 |
* - allowed_payments
|
201 |
-
*
|
202 |
*/
|
203 |
public function setAllowedPaymentsMethods($methodsInstances)
|
204 |
{
|
205 |
-
$xpaymentPrepareOrder = Mage::getSingleton(
|
206 |
-
$xpaymentPrepareOrder[
|
207 |
$methods = array();
|
208 |
-
foreach($methodsInstances as $methodInstance){
|
209 |
-
$methods[][
|
210 |
}
|
211 |
-
$xpaymentPrepareOrder[
|
212 |
-
Mage::getSingleton(
|
213 |
}
|
214 |
|
215 |
/**
|
@@ -218,9 +293,9 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
218 |
*/
|
219 |
public function getAllowedPaymentsMethods()
|
220 |
{
|
221 |
-
$xpaymentPrepareOrder = Mage::getSingleton(
|
222 |
-
if ($xpaymentPrepareOrder && isset($xpaymentPrepareOrder[
|
223 |
-
return $xpaymentPrepareOrder[
|
224 |
}
|
225 |
return false;
|
226 |
}
|
@@ -229,10 +304,11 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
229 |
public function getReviewButtonTemplate($name, $block)
|
230 |
{
|
231 |
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
232 |
-
$useIframe =
|
|
|
233 |
if ($quote) {
|
234 |
$payment = $quote->getPayment();
|
235 |
-
if ($payment && $payment->getMethod() ==
|
236 |
return $name;
|
237 |
}
|
238 |
}
|
@@ -244,115 +320,190 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
244 |
return '';
|
245 |
}
|
246 |
|
247 |
-
public function isNeedToSaveUserCard()
|
248 |
-
|
|
|
249 |
return $result;
|
250 |
}
|
251 |
|
|
|
|
|
|
|
|
|
252 |
public function isRegisteredUser()
|
253 |
{
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
return true;
|
259 |
-
} else {
|
260 |
-
return false;
|
261 |
-
}
|
262 |
-
}
|
263 |
-
|
264 |
-
public function isXpaymentsMethod($currentPaymentCode){
|
265 |
-
$xpaymentPaymentCode = Mage::getModel("xpaymentsconnector/payment_cc")->getCode();
|
266 |
-
$saveCardsPaymentCode = Mage::getModel("xpaymentsconnector/payment_savedcards")->getCode();
|
267 |
-
$prepaidpayments = Mage::getModel("xpaymentsconnector/payment_prepaidpayments")->getCode();
|
268 |
-
$usePaymetCodes = array($xpaymentPaymentCode,$saveCardsPaymentCode,$prepaidpayments);
|
269 |
-
if (in_array($currentPaymentCode, $usePaymetCodes)){
|
270 |
return true;
|
271 |
-
}else{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
return false;
|
273 |
}
|
274 |
}
|
275 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
276 |
/**
|
277 |
* @param Mage_Payment_Model_Recurring_Profile $recurringProfile
|
278 |
* @param bool $isFirstRecurringOrder
|
279 |
* @return int
|
280 |
*/
|
281 |
-
public function createOrder(Mage_Payment_Model_Recurring_Profile $recurringProfile
|
|
|
|
|
282 |
|
283 |
-
|
|
|
|
|
|
|
284 |
|
285 |
-
|
286 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
}
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
$
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
$productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_REGULAR);
|
301 |
-
$productItemInfo->setTaxAmount($taxAmount);
|
302 |
-
$productItemInfo->setShippingAmount($shippingAmount);
|
303 |
-
$productItemInfo->setPrice($orderSubtotal);
|
304 |
-
|
305 |
-
Mage::dispatchEvent('before_recurring_profile_order_create', array('profile' => $recurringProfile,'product_item_info'=>$productItemInfo));
|
306 |
-
$order = $recurringProfile->createOrder($productItemInfo);
|
307 |
-
if($isFirstRecurringOrder){
|
308 |
-
if($orderKey = $this->getOrderKey()){
|
309 |
-
$order->setIncrementId($orderKey);
|
310 |
-
}
|
311 |
}
|
312 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
313 |
|
314 |
-
|
315 |
-
$recurringProfile->addOrderRelation($order->getId());
|
316 |
|
317 |
-
|
|
|
|
|
|
|
318 |
}
|
319 |
|
320 |
/**
|
321 |
* @param Mage_Payment_Model_Recurring_Profile $recurringProfile
|
322 |
* @return int
|
323 |
*/
|
324 |
-
public function getCurrentBillingPeriodTimeStamp(Mage_Payment_Model_Recurring_Profile $recurringProfile)
|
325 |
-
|
326 |
-
$
|
|
|
327 |
//$masPeriodUnits = $recurringProfile->getAllPeriodUnits();
|
328 |
$billingTimeStamp = 0;
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
|
357 |
$billingPeriodTimeStamp = round($billingTimeStamp / $periodFrequency);
|
358 |
|
@@ -364,10 +515,11 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
364 |
* @param Mage_Payment_Model_Recurring_Profile $recurringProfile
|
365 |
* @return array
|
366 |
*/
|
367 |
-
public function getProfileOrderCardData(Mage_Payment_Model_Recurring_Profile $recurringProfile)
|
|
|
368 |
$txnId = $recurringProfile->getReferenceId();
|
369 |
-
$cardData = Mage::getModel(
|
370 |
-
|
371 |
}
|
372 |
|
373 |
/**
|
@@ -375,17 +527,18 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
375 |
* @param bool $result
|
376 |
* @param timestamp $newTransactionDate
|
377 |
*/
|
378 |
-
public
|
379 |
-
|
|
|
380 |
$currentCycleFailureCount = $recurringProfile->getXpCycleFailureCount();
|
381 |
//add failed attempt
|
382 |
$currentCycleFailureCount++;
|
383 |
$recurringProfile->setXpCycleFailureCount($currentCycleFailureCount);
|
384 |
$maxPaymentFailure = $recurringProfile->getSuspensionThreshold();
|
385 |
-
if($currentCycleFailureCount > $maxPaymentFailure){
|
386 |
$recurringProfile->cancel();
|
387 |
}
|
388 |
-
}else{
|
389 |
$recurringProfile->setXpCycleFailureCount(0);
|
390 |
|
391 |
// update date of success transaction
|
@@ -402,12 +555,41 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
402 |
|
403 |
}
|
404 |
|
405 |
-
public function
|
|
|
406 |
$checkoutSession = Mage::getSingleton('checkout/session');
|
407 |
-
$
|
408 |
-
|
409 |
-
|
410 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
411 |
}
|
412 |
|
413 |
return false;
|
@@ -420,10 +602,11 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
420 |
*/
|
421 |
public function payDeferredSubscription(Mage_Payment_Model_Recurring_Profile $recurringProfile)
|
422 |
{
|
423 |
-
|
424 |
-
$
|
425 |
-
$infoBuyRequest = unserialize($orderItemInfo[
|
426 |
-
$startDateTime = $infoBuyRequest[
|
|
|
427 |
|
428 |
if (!empty($startDateTime)) {
|
429 |
$dateTimeStamp = strtotime($startDateTime);
|
@@ -433,159 +616,210 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
433 |
if ($zendDate->getTimestamp() > $currentZendDate->getTimestamp()) {
|
434 |
//set start date time
|
435 |
$recurringProfile->setStartDatetime($zendDate->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
|
|
|
436 |
|
437 |
-
|
438 |
-
|
439 |
-
$grandTotal = $initialFeeAmount;
|
440 |
-
} else {
|
441 |
-
$grandTotal = floatval(Mage::getStoreConfig("xpaymentsconnector/settings/xpay_minimum_payment_recurring_amount"));
|
442 |
}
|
443 |
|
444 |
|
445 |
-
$paymentMethodCode = $recurringProfile->getData(
|
446 |
|
447 |
$cardData = NULL;
|
448 |
switch ($paymentMethodCode) {
|
449 |
-
case(Mage::getModel(
|
450 |
-
|
451 |
-
$paymentCardNumber = $recurringProfile->getQuote()->getPayment()->getData("xp_payment_card");
|
452 |
-
|
453 |
-
$cardData = Mage::getModel("xpaymentsconnector/usercards")->load($paymentCardNumber);
|
454 |
-
$cardData = $cardData->getData();
|
455 |
|
456 |
-
$
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
$recurringProfile->activate();
|
462 |
-
} else {
|
463 |
-
Mage::getSingleton("checkout/session")->addError($response["error_message"]);
|
464 |
-
$recurringProfile->cancel();
|
465 |
}
|
466 |
-
|
|
|
467 |
|
|
|
468 |
break;
|
469 |
-
case(
|
470 |
-
if ($useIframe) {
|
471 |
$cardData = $this->getXpaymentResponse();
|
472 |
-
$
|
473 |
-
|
474 |
-
list($status, $response) = Mage::getModel("xpaymentsconnector/payment_cc")->requestPaymentInfo($cardData["txnId"]);
|
475 |
-
|
476 |
-
if (
|
477 |
-
$status
|
478 |
-
&& in_array($response['status'], array(Cdev_XPaymentsConnector_Model_Payment_Cc::AUTH_STATUS, Cdev_XPaymentsConnector_Model_Payment_Cc::CHARGED_STATUS))
|
479 |
-
) {
|
480 |
-
Mage::getSingleton("checkout/session")->setData("user_card_save",true);
|
481 |
-
Mage::getModel("xpaymentsconnector/payment_cc")->saveUserCard($cardData, Cdev_XPaymentsConnector_Model_Usercards::RECURRING_CARD);
|
482 |
-
$recurringProfile->activate();
|
483 |
} else {
|
484 |
-
$
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
491 |
|
492 |
-
//check transaction state
|
493 |
-
list($status, $response) = Mage::getModel("xpaymentsconnector/payment_cc")->requestPaymentInfo($cardData["txnId"]);
|
494 |
-
if (
|
495 |
-
$status
|
496 |
-
&& in_array($response['status'], array(Cdev_XPaymentsConnector_Model_Payment_Cc::AUTH_STATUS, Cdev_XPaymentsConnector_Model_Payment_Cc::CHARGED_STATUS))
|
497 |
-
) {
|
498 |
-
// save user card
|
499 |
-
Mage::getSingleton("checkout/session")->setData("user_card_save",true);
|
500 |
-
Mage::getModel("xpaymentsconnector/payment_cc")->saveUserCard($cardData,$usageType = Cdev_XPaymentsConnector_Model_Usercards::RECURRING_CARD);
|
501 |
-
|
502 |
-
$recurringProfile->setReferenceId($cardData["txnId"]);
|
503 |
-
$recurringProfile->activate();
|
504 |
-
$recurringProfile->save();
|
505 |
-
return true;
|
506 |
-
}else{
|
507 |
-
$recurringProfile->cancel();
|
508 |
}
|
509 |
-
|
510 |
-
|
|
|
511 |
}
|
512 |
|
513 |
}
|
514 |
}
|
|
|
|
|
515 |
return false;
|
516 |
}
|
517 |
|
518 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
519 |
$result = array();
|
520 |
-
$
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
$
|
526 |
-
|
527 |
-
|
528 |
-
$
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
$result[
|
534 |
-
return $result;
|
535 |
} else {
|
536 |
-
$result[
|
537 |
-
return $result;
|
538 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
539 |
} else {
|
540 |
-
$result[
|
541 |
-
return $result;
|
542 |
}
|
|
|
|
|
543 |
}
|
544 |
-
$result["success"] = false;
|
545 |
return $result;
|
546 |
}
|
547 |
|
548 |
-
public function getRecurringProfileState()
|
|
|
549 |
$maxPaymentFailureMessage = $this->__('This profile has run out of maximal limit of unsuccessful payment attempts.');
|
550 |
|
551 |
if (Mage::app()->getStore()->isAdmin()) {
|
552 |
Mage::getSingleton('adminhtml/session')->addNotice($maxPaymentFailureMessage);
|
553 |
-
}else{
|
554 |
Mage::getSingleton('core/session')->addNotice($maxPaymentFailureMessage);
|
555 |
}
|
556 |
}
|
557 |
|
558 |
-
public function addRecurringTransactionError($response = array())
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
|
|
573 |
}
|
574 |
|
575 |
-
public function setRecurringProductDiscount()
|
|
|
576 |
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
577 |
$items = $quote->getAllVisibleItems();
|
578 |
-
foreach($items as $item){
|
579 |
$discount = $item->getDiscountAmount();
|
580 |
$profile = $item->getProduct()->getRecurringProfile();
|
581 |
-
$profile[
|
582 |
$item->getProduct()->setRecurringProfile($profile)->save();
|
583 |
}
|
584 |
}
|
585 |
|
586 |
-
public function getIframeUrl()
|
587 |
-
|
588 |
-
|
|
|
|
|
589 |
|
590 |
$this->prepareOrderKey();
|
591 |
$token = $this->getIframeToken();
|
@@ -594,4 +828,164 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
|
|
594 |
return $iframeUrl;
|
595 |
}
|
596 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
597 |
}
|
21 |
|
22 |
/**
|
23 |
* Common helper
|
24 |
+
*
|
25 |
* @package Cdev_XPaymentsConnector
|
26 |
* @see ____class_see____
|
27 |
* @since 1.0.0
|
33 |
const WEEK_TIME_STAMP = 604800;
|
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';
|
40 |
|
41 |
+
/**
|
42 |
+
* save/update qty for createOrder function.
|
43 |
+
* @var int
|
44 |
+
*/
|
45 |
+
protected $itemsQty = null;
|
46 |
+
public $payDeferredProfileId = null;
|
47 |
|
48 |
/**
|
49 |
* This function return 'IncrementId' for feature order.
|
54 |
* return
|
55 |
* @return bool or int
|
56 |
*/
|
57 |
+
public function getOrderKey()
|
58 |
+
{
|
59 |
+
$xpaymentPrepareOrderData = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
|
60 |
+
if ($xpaymentPrepareOrderData && isset($xpaymentPrepareOrderData['prepare_order_id'])) {
|
61 |
+
return $xpaymentPrepareOrderData['prepare_order_id'];
|
62 |
}
|
63 |
return false;
|
64 |
}
|
65 |
|
|
|
66 |
/**
|
67 |
* This function create 'IncrementId' for feature order.
|
68 |
* Xpayment Prepare Order Mas(xpayment_prepare_order):
|
74 |
*/
|
75 |
public function prepareOrderKey()
|
76 |
{
|
77 |
+
$xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
|
78 |
if(!isset($xpaymentPrepareOrder["prepare_order_id"])){
|
79 |
+
$this->prepareSimpleOrderKey();
|
80 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
+
}
|
|
|
83 |
|
84 |
+
public function updateRecurringMasKeys(Mage_Payment_Model_Recurring_Profile $recurringProfile)
|
85 |
+
{
|
86 |
+
$orderItemInfo = $recurringProfile->getData('order_item_info');
|
87 |
+
$xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
|
88 |
+
$xpaymentPrepareOrder['recurring_mas'][$orderItemInfo['product_id']] = $this->getOrderKey();
|
89 |
+
Mage::getSingleton('checkout/session')->setData('xpayment_prepare_order', $xpaymentPrepareOrder);
|
90 |
+
}
|
91 |
+
|
92 |
+
public function getPrepareRecurringMasKey(Mage_Payment_Model_Recurring_Profile $recurringProfile)
|
93 |
+
{
|
94 |
+
$xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
|
95 |
+
if ($xpaymentPrepareOrder && isset($xpaymentPrepareOrder['recurring_mas'])) {
|
96 |
+
$orderItemInfo = $recurringProfile->getData('order_item_info');
|
97 |
+
$prodId = $orderItemInfo['product_id'];
|
98 |
+
if (isset($xpaymentPrepareOrder['recurring_mas'][$prodId])) {
|
99 |
+
return $xpaymentPrepareOrder['recurring_mas'][$prodId];
|
100 |
+
}
|
101 |
}
|
102 |
+
return false;
|
103 |
+
}
|
104 |
+
|
105 |
+
|
106 |
+
/**
|
107 |
+
* @return mixed
|
108 |
+
*/
|
109 |
+
public function prepareSimpleOrderKey()
|
110 |
+
{
|
111 |
+
$storeId = Mage::app()->getStore()->getStoreId();
|
112 |
+
$prepareOrderId = Mage::getSingleton('eav/config')
|
113 |
+
->getEntityType('order')
|
114 |
+
->fetchNewIncrementId($storeId);
|
115 |
+
|
116 |
+
$xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
|
117 |
+
$xpaymentPrepareOrder['prepare_order_id'] = $prepareOrderId;
|
118 |
+
|
119 |
+
Mage::getSingleton('checkout/session')->setData('xpayment_prepare_order', $xpaymentPrepareOrder);
|
120 |
+
return $prepareOrderId;
|
121 |
|
122 |
}
|
123 |
|
124 |
+
|
125 |
/**
|
126 |
* This function set 'place_display' flag for feature x-payment form.
|
127 |
* Xpayment Prepare Order Mas(xpayment_prepare_order):
|
135 |
public function setIframePlaceDisplaySettings()
|
136 |
{
|
137 |
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
138 |
+
if ($useIframe) {
|
139 |
+
$xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
|
140 |
+
$xpaymentPrepareOrder['place_display'] = Mage::getStoreConfig('payment/xpayments/placedisplay');
|
141 |
+
Mage::getSingleton('checkout/session')->setData('xpayment_prepare_order', $xpaymentPrepareOrder);
|
142 |
}
|
143 |
}
|
144 |
|
146 |
* check 'xpayment' config settigs
|
147 |
* @return bool
|
148 |
*/
|
149 |
+
public function isIframePaymentPlaceDisplay()
|
150 |
+
{
|
151 |
+
$xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
|
152 |
+
if (isset($xpaymentPrepareOrder['place_display']) && ($xpaymentPrepareOrder['place_display'] == 'payment')) {
|
153 |
return true;
|
154 |
}
|
155 |
return false;
|
164 |
* return
|
165 |
* @return bool or int
|
166 |
*/
|
167 |
+
public function getXpaymentResponse()
|
168 |
+
{
|
169 |
+
$xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
|
170 |
+
if ($xpaymentPrepareOrder && isset($xpaymentPrepareOrder['xpayment_response'])) {
|
171 |
+
return $xpaymentPrepareOrder['xpayment_response'];
|
172 |
}
|
173 |
return false;
|
174 |
}
|
184 |
*/
|
185 |
public function getIframeToken()
|
186 |
{
|
187 |
+
$xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
|
188 |
+
if ($xpaymentPrepareOrder && isset($xpaymentPrepareOrder['token']) && !empty($xpaymentPrepareOrder['token'])) {
|
189 |
+
return $xpaymentPrepareOrder['token'];
|
190 |
} else {
|
191 |
$api = Mage::getModel('xpaymentsconnector/payment_cc');
|
192 |
$result = $api->sendIframeHandshakeRequest();
|
193 |
+
$xpaymentPrepareOrder['token'] = $result['response']['token'];
|
194 |
+
Mage::getSingleton('checkout/session')->setData('xpayment_prepare_order', $xpaymentPrepareOrder);
|
195 |
+
return $xpaymentPrepareOrder['token'];
|
196 |
}
|
197 |
|
198 |
}
|
199 |
|
200 |
+
/**
|
201 |
+
* This function sets a type for prepared order
|
202 |
+
* Xpayment Prepare Order Mas(xpayment_prepare_order):
|
203 |
+
* - prepare_order_id (int)
|
204 |
+
* - xpayment_response
|
205 |
+
* - type (string)
|
206 |
+
* - is_recurring
|
207 |
+
*/
|
208 |
+
public function setPrepareOrderType()
|
209 |
+
{
|
210 |
+
$xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
|
211 |
+
$result = $this->checkIssetRecurringOrder();
|
212 |
+
if ($result['isset']) {
|
213 |
+
$xpaymentPrepareOrder['type'] = self::RECURRING_ORDER_TYPE;
|
214 |
+
} else {
|
215 |
+
$xpaymentPrepareOrder['type'] = self::SIMPLE_ORDER_TYPE;
|
216 |
+
}
|
217 |
+
|
218 |
+
Mage::getSingleton('checkout/session')->setData('xpayment_prepare_order', $xpaymentPrepareOrder);
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* This function checks a type for prepared order
|
223 |
+
* Xpayment Prepare Order Mas(xpayment_prepare_order):
|
224 |
+
* - prepare_order_id (int)
|
225 |
+
* - xpayment_response
|
226 |
+
* - type (string)
|
227 |
+
* - is_recurring
|
228 |
+
* @return bool
|
229 |
+
*/
|
230 |
+
public function checkIsRecurringPrepareOrderType()
|
231 |
+
{
|
232 |
+
$xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
|
233 |
+
if ($xpaymentPrepareOrder && isset($xpaymentPrepareOrder['type']) && !empty($xpaymentPrepareOrder['type'])) {
|
234 |
+
($xpaymentPrepareOrder['type'] == self::RECURRING_ORDER_TYPE) ? true : false;
|
235 |
+
return ($xpaymentPrepareOrder['type'] == self::RECURRING_ORDER_TYPE) ? true : false;
|
236 |
+
} else {
|
237 |
+
return false;
|
238 |
+
}
|
239 |
+
}
|
240 |
+
|
241 |
/**
|
242 |
* Unset prepare order params
|
243 |
* @param array $unsetParams
|
244 |
*/
|
245 |
+
public function unsetXpaymentPrepareOrder($unsetParams = array())
|
246 |
+
{
|
247 |
+
if (!empty($unsetParams)) {
|
248 |
+
$xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
|
249 |
+
foreach ($unsetParams as $param) {
|
250 |
+
if (is_array($xpaymentPrepareOrder) && isset($xpaymentPrepareOrder[$param])) {
|
251 |
unset($xpaymentPrepareOrder[$param]);
|
252 |
}
|
253 |
}
|
254 |
+
Mage::getSingleton('checkout/session')->setData('xpayment_prepare_order', $xpaymentPrepareOrder);
|
255 |
return;
|
256 |
}
|
257 |
|
258 |
+
Mage::getSingleton('checkout/session')->unsetData('xpayment_prepare_order');
|
259 |
}
|
260 |
|
261 |
/**
|
265 |
*/
|
266 |
public function savePaymentResponse($responseData)
|
267 |
{
|
268 |
+
$xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
|
269 |
+
$xpaymentPrepareOrder['xpayment_response'] = $responseData;
|
270 |
+
Mage::getSingleton('checkout/session')->setData('xpayment_prepare_order', $xpaymentPrepareOrder);
|
271 |
}
|
272 |
|
273 |
/**
|
274 |
* Save all allowed payments for current checkout session in store.
|
275 |
* - allowed_payments
|
276 |
+
* @param array $methods
|
277 |
*/
|
278 |
public function setAllowedPaymentsMethods($methodsInstances)
|
279 |
{
|
280 |
+
$xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
|
281 |
+
$xpaymentPrepareOrder['allowed_payments'] = $methodsInstances;
|
282 |
$methods = array();
|
283 |
+
foreach ($methodsInstances as $methodInstance) {
|
284 |
+
$methods[]['method_code'] = $methodInstance->getCode();
|
285 |
}
|
286 |
+
$xpaymentPrepareOrder['allowed_payments'] = $methods;
|
287 |
+
Mage::getSingleton('checkout/session')->setData('xpayment_prepare_order', $xpaymentPrepareOrder);
|
288 |
}
|
289 |
|
290 |
/**
|
293 |
*/
|
294 |
public function getAllowedPaymentsMethods()
|
295 |
{
|
296 |
+
$xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
|
297 |
+
if ($xpaymentPrepareOrder && isset($xpaymentPrepareOrder['allowed_payments']) && !empty($xpaymentPrepareOrder['allowed_payments'])) {
|
298 |
+
return $xpaymentPrepareOrder['allowed_payments'];
|
299 |
}
|
300 |
return false;
|
301 |
}
|
304 |
public function getReviewButtonTemplate($name, $block)
|
305 |
{
|
306 |
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
307 |
+
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
308 |
+
$xpCcMethodCode = Mage::getModel('xpaymentsconnector/payment_cc')->getCode();
|
309 |
if ($quote) {
|
310 |
$payment = $quote->getPayment();
|
311 |
+
if ($payment && $payment->getMethod() == $xpCcMethodCode && $useIframe) {
|
312 |
return $name;
|
313 |
}
|
314 |
}
|
320 |
return '';
|
321 |
}
|
322 |
|
323 |
+
public function isNeedToSaveUserCard()
|
324 |
+
{
|
325 |
+
$result = (bool)Mage::getSingleton('checkout/session')->getData('user_card_save');
|
326 |
return $result;
|
327 |
}
|
328 |
|
329 |
+
public function userCardSaved(){
|
330 |
+
Mage::getSingleton('checkout/session')->setData('user_card_save',false);
|
331 |
+
}
|
332 |
+
|
333 |
public function isRegisteredUser()
|
334 |
{
|
335 |
+
$currentCustomerState = Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod();
|
336 |
+
$registerMethod = Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER;
|
337 |
+
$customerMethod = Mage_Checkout_Model_Type_Onepage::METHOD_CUSTOMER;
|
338 |
+
if (($currentCustomerState == $registerMethod) || ($currentCustomerState == $customerMethod)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
return true;
|
340 |
+
} else {
|
341 |
+
return false;
|
342 |
+
}
|
343 |
+
}
|
344 |
+
|
345 |
+
public function isXpaymentsMethod($currentPaymentCode)
|
346 |
+
{
|
347 |
+
$xpaymentPaymentCode = Mage::getModel('xpaymentsconnector/payment_cc')->getCode();
|
348 |
+
$saveCardsPaymentCode = Mage::getModel('xpaymentsconnector/payment_savedcards')->getCode();
|
349 |
+
$prepaidpayments = Mage::getModel('xpaymentsconnector/payment_prepaidpayments')->getCode();
|
350 |
+
$usePaymetCodes = array($xpaymentPaymentCode, $saveCardsPaymentCode, $prepaidpayments);
|
351 |
+
if (in_array($currentPaymentCode, $usePaymetCodes)) {
|
352 |
+
return true;
|
353 |
+
} else {
|
354 |
return false;
|
355 |
}
|
356 |
}
|
357 |
|
358 |
+
/**
|
359 |
+
* This function prepare order keys for recurring orders
|
360 |
+
* @return int
|
361 |
+
*/
|
362 |
+
public function prepareOrderKeyByRecurringProfile(Mage_Payment_Model_Recurring_Profile $recurringProfile)
|
363 |
+
{
|
364 |
+
$quote = $recurringProfile->getQuote();
|
365 |
+
$this->itemsQty = $quote->getItemsCount();
|
366 |
+
$orderItemInfo = $recurringProfile->getData('order_item_info');
|
367 |
+
$quote->getItemById($orderItemInfo['item_id'])->isDeleted(true);
|
368 |
+
|
369 |
+
if ($this->itemsQty > 1) {
|
370 |
+
// update order key
|
371 |
+
$unsetParams = array('prepare_order_id');
|
372 |
+
$this->unsetXpaymentPrepareOrder($unsetParams);
|
373 |
+
$this->prepareOrderKey();
|
374 |
+
}
|
375 |
+
}
|
376 |
+
|
377 |
/**
|
378 |
* @param Mage_Payment_Model_Recurring_Profile $recurringProfile
|
379 |
* @param bool $isFirstRecurringOrder
|
380 |
* @return int
|
381 |
*/
|
382 |
+
public function createOrder(Mage_Payment_Model_Recurring_Profile $recurringProfile, $isFirstRecurringOrder = false,$orderAmountData = array())
|
383 |
+
{
|
384 |
+
$orderItemInfo = $recurringProfile->getData('order_item_info');
|
385 |
|
386 |
+
if (!is_array($orderItemInfo)) {
|
387 |
+
$orderItemInfo = unserialize($orderItemInfo);
|
388 |
+
}
|
389 |
+
$initialFeeAmount = $recurringProfile->getInitAmount();
|
390 |
|
391 |
+
$productSubtotal = ($isFirstRecurringOrder) ? $orderItemInfo['row_total'] + $initialFeeAmount : $orderItemInfo['row_total'];
|
392 |
+
$price = $productSubtotal / $orderItemInfo['qty'];
|
393 |
+
if(isset($orderAmountData['product_subtotal']) && $initialFeeAmount > 0 ){
|
394 |
+
$productSubtotal = $orderAmountData['product_subtotal'];
|
395 |
+
$price = $orderAmountData['product_subtotal'] / $orderItemInfo['qty'];
|
396 |
+
}
|
397 |
+
|
398 |
+
//check is set related orders
|
399 |
+
|
400 |
+
$useDiscount = ($recurringProfile->getXpCountSuccessTransaction() > 0) ? false : true;
|
401 |
+
$discountAmount = ($useDiscount) ? $orderItemInfo['discount_amount'] : 0;
|
402 |
+
if(isset($orderAmountData['discount_amount'])){
|
403 |
+
$discountAmount = $orderAmountData['discount_amount'];
|
404 |
+
}
|
405 |
+
|
406 |
+
$taxAmount = $recurringProfile->getData('tax_amount');
|
407 |
+
if(isset($orderAmountData['tax_amount'])){
|
408 |
+
$taxAmount = $orderAmountData['tax_amount'];
|
409 |
+
}
|
410 |
+
|
411 |
+
if($isFirstRecurringOrder && !isset($orderAmountData['tax_amount'])){
|
412 |
+
$taxAmount += $orderItemInfo['initialfee_tax_amount'];
|
413 |
+
}
|
414 |
+
|
415 |
+
$shippingAmount = $recurringProfile->getData('shipping_amount');
|
416 |
+
if(isset($orderAmountData['shipping_amount'])){
|
417 |
+
$shippingAmount = $orderAmountData['shipping_amount'];
|
418 |
+
}
|
419 |
+
|
420 |
+
$productItemInfo = new Varien_Object;
|
421 |
+
$productItemInfo->setDiscountAmount($discountAmount);
|
422 |
+
$productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_REGULAR);
|
423 |
+
$productItemInfo->setTaxAmount($taxAmount);
|
424 |
+
$productItemInfo->setShippingAmount($shippingAmount);
|
425 |
+
$productItemInfo->setPrice($price);
|
426 |
+
$productItemInfo->setQty($orderItemInfo['qty']);
|
427 |
+
$productItemInfo->setRowTotal($productSubtotal);
|
428 |
+
$productItemInfo->setBaseRowTotal($productSubtotal);
|
429 |
+
$productItemInfo->getOriginalPrice($price);
|
430 |
+
|
431 |
+
if($initialFeeAmount > 0){
|
432 |
+
if(isset($orderAmountData['grand_total'])){
|
433 |
+
$productItemInfo->setRowTotalInclTax($orderAmountData['grand_total']);
|
434 |
+
$productItemInfo->setBaseRowTotalInclTax($orderAmountData['grand_total']);
|
435 |
}
|
436 |
+
}
|
437 |
+
|
438 |
+
Mage::dispatchEvent('before_recurring_profile_order_create', array('profile' => $recurringProfile, 'product_item_info' => $productItemInfo));
|
439 |
+
$order = $recurringProfile->createOrder($productItemInfo);
|
440 |
+
$order->setCustomerId($recurringProfile->getCustomerId());
|
441 |
+
|
442 |
+
if ($isFirstRecurringOrder) {
|
443 |
+
$orderKey = 0;
|
444 |
+
if ($this->getPrepareRecurringMasKey($recurringProfile)) {
|
445 |
+
$orderKey = $this->getPrepareRecurringMasKey($recurringProfile);
|
446 |
+
} elseIf ($this->getOrderKey()) {
|
447 |
+
$orderKey = $this->getOrderKey();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
448 |
}
|
449 |
+
if ($orderKey) {
|
450 |
+
$order->setIncrementId($orderKey);
|
451 |
+
//unset order Key
|
452 |
+
$unsetParams = array('prepare_order_id');
|
453 |
+
$this->unsetXpaymentPrepareOrder($unsetParams);
|
454 |
+
}
|
455 |
+
}
|
456 |
+
if(isset($orderAmountData['shipping_amount'])){
|
457 |
+
$order->setShippingAmount($orderAmountData['shipping_amount']);
|
458 |
+
$order->setBaseShippingAmount($orderAmountData['shipping_amount']);
|
459 |
+
}
|
460 |
+
|
461 |
|
462 |
+
Mage::dispatchEvent('before_recurring_profile_order_save', array('order' => $order));
|
|
|
463 |
|
464 |
+
$order->save();
|
465 |
+
$recurringProfile->addOrderRelation($order->getId());
|
466 |
+
|
467 |
+
return $order->getId();
|
468 |
}
|
469 |
|
470 |
/**
|
471 |
* @param Mage_Payment_Model_Recurring_Profile $recurringProfile
|
472 |
* @return int
|
473 |
*/
|
474 |
+
public function getCurrentBillingPeriodTimeStamp(Mage_Payment_Model_Recurring_Profile $recurringProfile)
|
475 |
+
{
|
476 |
+
$periodUnit = $recurringProfile->getData('period_unit'); //day
|
477 |
+
$periodFrequency = $recurringProfile->getData('period_frequency');
|
478 |
//$masPeriodUnits = $recurringProfile->getAllPeriodUnits();
|
479 |
$billingTimeStamp = 0;
|
480 |
+
switch ($periodUnit) {
|
481 |
+
case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_DAY:
|
482 |
+
$billingTimeStamp = self::DAY_TIME_STAMP;
|
483 |
+
break;
|
484 |
+
case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_WEEK;
|
485 |
+
$billingTimeStamp = self::WEEK_TIME_STAMP;
|
486 |
+
break;
|
487 |
+
case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_SEMI_MONTH;
|
488 |
+
$billingTimeStamp = self::SEMI_MONTH_TIME_STAMP;
|
489 |
+
break;
|
490 |
+
case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_MONTH;
|
491 |
+
$startDateTime = strtotime($recurringProfile->getStartDatetime());
|
492 |
+
$lastSuccessTransactionDate = strtotime($recurringProfile->getXpSuccessTransactionDate());
|
493 |
+
$lastActionDate = ($startDateTime > $lastSuccessTransactionDate) ? $startDateTime : $lastSuccessTransactionDate;
|
494 |
+
$nextMonth = mktime(date('H', $lastActionDate), date('i', $lastActionDate), date('s', $lastActionDate), date('m', $lastActionDate) + 1, date('d', $lastActionDate), date('Y', $lastActionDate));
|
495 |
+
$billingTimeStamp = $nextMonth - $lastActionDate;
|
496 |
+
|
497 |
+
break;
|
498 |
+
case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_YEAR;
|
499 |
+
$startDateTime = strtotime($recurringProfile->getStartDatetime());
|
500 |
+
$lastSuccessTransactionDate = strtotime($recurringProfile->getXpSuccessTransactionDate());
|
501 |
+
$lastActionDate = ($startDateTime > $lastSuccessTransactionDate) ? $startDateTime : $lastSuccessTransactionDate;
|
502 |
+
$nextYear = mktime(date('H', $lastActionDate), date('i', $lastActionDate), date('s', $lastActionDate), date('m', $lastActionDate), date('d', $lastActionDate), date('Y', $lastActionDate) + 1);
|
503 |
+
$billingTimeStamp = $nextYear - $lastActionDate;
|
504 |
+
|
505 |
+
break;
|
506 |
+
}
|
507 |
|
508 |
$billingPeriodTimeStamp = round($billingTimeStamp / $periodFrequency);
|
509 |
|
515 |
* @param Mage_Payment_Model_Recurring_Profile $recurringProfile
|
516 |
* @return array
|
517 |
*/
|
518 |
+
public function getProfileOrderCardData(Mage_Payment_Model_Recurring_Profile $recurringProfile)
|
519 |
+
{
|
520 |
$txnId = $recurringProfile->getReferenceId();
|
521 |
+
$cardData = Mage::getModel('xpaymentsconnector/usercards')->load($txnId, 'txnid');
|
522 |
+
return $cardData;
|
523 |
}
|
524 |
|
525 |
/**
|
527 |
* @param bool $result
|
528 |
* @param timestamp $newTransactionDate
|
529 |
*/
|
530 |
+
public function updateCurrentBillingPeriodTimeStamp(Mage_Payment_Model_Recurring_Profile $recurringProfile, bool $result, $newTransactionDate = null)
|
531 |
+
{
|
532 |
+
if (!$result) {
|
533 |
$currentCycleFailureCount = $recurringProfile->getXpCycleFailureCount();
|
534 |
//add failed attempt
|
535 |
$currentCycleFailureCount++;
|
536 |
$recurringProfile->setXpCycleFailureCount($currentCycleFailureCount);
|
537 |
$maxPaymentFailure = $recurringProfile->getSuspensionThreshold();
|
538 |
+
if ($currentCycleFailureCount > $maxPaymentFailure) {
|
539 |
$recurringProfile->cancel();
|
540 |
}
|
541 |
+
} else {
|
542 |
$recurringProfile->setXpCycleFailureCount(0);
|
543 |
|
544 |
// update date of success transaction
|
555 |
|
556 |
}
|
557 |
|
558 |
+
public function checkIssetRecurringOrder()
|
559 |
+
{
|
560 |
$checkoutSession = Mage::getSingleton('checkout/session');
|
561 |
+
$quoteItems = $checkoutSession->getQuote()->getAllItems();
|
562 |
+
$result = array();
|
563 |
+
|
564 |
+
foreach ($quoteItems as $quoteItem) {
|
565 |
+
if ($quoteItem) {
|
566 |
+
$product = $quoteItem->getProduct();
|
567 |
+
$issetRecurringOreder = (bool)$product->getIsRecurring();
|
568 |
+
if ($issetRecurringOreder) {
|
569 |
+
$result['isset'] = $issetRecurringOreder;
|
570 |
+
$result['quote_item'] = $quoteItem;
|
571 |
+
return $result;
|
572 |
+
}
|
573 |
+
}
|
574 |
+
}
|
575 |
+
$result['isset'] = false;
|
576 |
+
|
577 |
+
return $result;
|
578 |
+
}
|
579 |
+
|
580 |
+
public function checkIssetSimpleOrder()
|
581 |
+
{
|
582 |
+
$checkoutSession = Mage::getSingleton('checkout/session');
|
583 |
+
$quoteItems = $checkoutSession->getQuote()->getAllItems();
|
584 |
+
|
585 |
+
foreach ($quoteItems as $quoteItem) {
|
586 |
+
if ($quoteItem) {
|
587 |
+
$product = $quoteItem->getProduct();
|
588 |
+
$issetRecurringOreder = (bool)$product->getIsRecurring();
|
589 |
+
if (!$issetRecurringOreder) {
|
590 |
+
return true;
|
591 |
+
}
|
592 |
+
}
|
593 |
}
|
594 |
|
595 |
return false;
|
602 |
*/
|
603 |
public function payDeferredSubscription(Mage_Payment_Model_Recurring_Profile $recurringProfile)
|
604 |
{
|
605 |
+
|
606 |
+
$orderItemInfo = $recurringProfile->getData('order_item_info');
|
607 |
+
$infoBuyRequest = unserialize($orderItemInfo['info_buyRequest']);
|
608 |
+
$startDateTime = $infoBuyRequest['recurring_profile_start_datetime'];
|
609 |
+
$xpaymentCCModel = Mage::getModel('xpaymentsconnector/payment_cc');
|
610 |
|
611 |
if (!empty($startDateTime)) {
|
612 |
$dateTimeStamp = strtotime($startDateTime);
|
616 |
if ($zendDate->getTimestamp() > $currentZendDate->getTimestamp()) {
|
617 |
//set start date time
|
618 |
$recurringProfile->setStartDatetime($zendDate->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
|
619 |
+
$orderAmountData = $this->preparePayDeferredOrderAmountData($recurringProfile);
|
620 |
|
621 |
+
if (!isset($orderItemInfo['recurring_initial_fee'])) {
|
622 |
+
$orderAmountData['grand_total'] = floatval(Mage::getStoreConfig('xpaymentsconnector/settings/xpay_minimum_payment_recurring_amount'));
|
|
|
|
|
|
|
623 |
}
|
624 |
|
625 |
|
626 |
+
$paymentMethodCode = $recurringProfile->getData('method_code');
|
627 |
|
628 |
$cardData = NULL;
|
629 |
switch ($paymentMethodCode) {
|
630 |
+
case(Mage::getModel('xpaymentsconnector/payment_savedcards')->getCode()):
|
|
|
|
|
|
|
|
|
|
|
631 |
|
632 |
+
if(!is_null($recurringProfile->getInitAmount())){
|
633 |
+
$paymentCardNumber = $recurringProfile->getQuote()->getPayment()->getData('xp_payment_card');
|
634 |
+
$card = Mage::getModel('xpaymentsconnector/usercards')->load($paymentCardNumber);
|
635 |
+
$cardData = $card->getData();
|
636 |
+
$this->resendPayDeferredRecurringTransaction($recurringProfile, $orderAmountData, $cardData);
|
|
|
|
|
|
|
|
|
637 |
}
|
638 |
+
$this->payDeferredProfileId = $recurringProfile->getProfileId();
|
639 |
+
$recurringProfile->activate();
|
640 |
|
641 |
+
return true;
|
642 |
break;
|
643 |
+
case($xpaymentCCModel->getCode()):
|
|
|
644 |
$cardData = $this->getXpaymentResponse();
|
645 |
+
if (!is_null($this->payDeferredProfileId)) {
|
646 |
+
$this->resendPayDeferredRecurringTransaction($recurringProfile, $orderAmountData, $cardData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
647 |
} else {
|
648 |
+
$recurringProfile->setReferenceId($cardData['txnId']);
|
649 |
+
//check transaction state
|
650 |
+
list($status, $response) = $xpaymentCCModel->requestPaymentInfo($cardData['txnId']);
|
651 |
+
if (
|
652 |
+
$status
|
653 |
+
&& in_array($response['status'], array(Cdev_XPaymentsConnector_Model_Payment_Cc::AUTH_STATUS, Cdev_XPaymentsConnector_Model_Payment_Cc::CHARGED_STATUS))
|
654 |
+
) {
|
655 |
+
if(!is_null($recurringProfile->getInitAmount())){
|
656 |
+
//create order
|
657 |
+
$orderId = $this->createOrder($recurringProfile, $isFirstRecurringOrder = true, $orderAmountData);
|
658 |
+
//update order
|
659 |
+
$xpaymentCCModel->updateOrderByXpaymentResponse($orderId, $cardData['txnId']);
|
660 |
+
}
|
661 |
+
|
662 |
+
Mage::getSingleton('checkout/session')->setData('user_card_save', true);
|
663 |
+
$xpaymentCCModel->saveUserCard($cardData, Cdev_XPaymentsConnector_Model_Usercards::RECURRING_CARD);
|
664 |
+
$recurringProfile->activate();
|
665 |
+
} else {
|
666 |
+
$this->addRecurringTransactionError($response);
|
667 |
+
$recurringProfile->cancel();
|
668 |
+
}
|
669 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
670 |
}
|
671 |
+
|
672 |
+
$this->payDeferredProfileId = $recurringProfile->getProfileId();
|
673 |
+
return true;
|
674 |
}
|
675 |
|
676 |
}
|
677 |
}
|
678 |
+
|
679 |
+
$this->payDeferredProfileId = $recurringProfile->getProfileId();
|
680 |
return false;
|
681 |
}
|
682 |
|
683 |
+
/**
|
684 |
+
* @param Mage_Payment_Model_Recurring_Profile $recurringProfile
|
685 |
+
* @param $orderAmountData
|
686 |
+
* @param $cardData
|
687 |
+
*/
|
688 |
+
public function resendPayDeferredRecurringTransaction(Mage_Payment_Model_Recurring_Profile $recurringProfile, $orderAmountData, $cardData)
|
689 |
+
{
|
690 |
+
$xpaymentCCModel = Mage::getModel('xpaymentsconnector/payment_cc');
|
691 |
+
$recurringProfile->setReferenceId($cardData['txnId']);
|
692 |
+
$orderId = NULL;
|
693 |
+
//create order
|
694 |
+
if (!is_null($recurringProfile->getInitAmount())) {
|
695 |
+
$orderId = $this->createOrder($recurringProfile, $isFirstRecurringOrder = true, $orderAmountData);
|
696 |
+
}
|
697 |
+
$response = $xpaymentCCModel->sendAgainTransactionRequest(
|
698 |
+
$orderId,
|
699 |
+
NULL,
|
700 |
+
$orderAmountData['grand_total'],
|
701 |
+
$cardData);
|
702 |
+
|
703 |
+
//update order
|
704 |
+
if(!is_null($orderId)){
|
705 |
+
$xpaymentCCModel->updateOrderByXpaymentResponse($orderId, $response['response']['transaction_id']);
|
706 |
+
}
|
707 |
+
|
708 |
+
if ($response['success']) {
|
709 |
+
$recurringProfile->activate();
|
710 |
+
} else {
|
711 |
+
Mage::getSingleton('checkout/session')->addError($response['error_message']);
|
712 |
+
$recurringProfile->cancel();
|
713 |
+
}
|
714 |
+
}
|
715 |
+
|
716 |
+
public function checkStartDateData()
|
717 |
+
{
|
718 |
$result = array();
|
719 |
+
$result['total_min_amount'] = 0;
|
720 |
+
$quoteItems = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
|
721 |
+
foreach ($quoteItems as $quoteItem) {
|
722 |
+
if ($quoteItem) {
|
723 |
+
$currentProduct = $quoteItem->getProduct();
|
724 |
+
$isRecurringProduct = (bool)$currentProduct->getIsRecurring();
|
725 |
+
if ($isRecurringProduct) {
|
726 |
+
$checkQuoteItemResult = $this->checkStartDateDataByProduct($currentProduct,$quoteItem);
|
727 |
+
if ($checkQuoteItemResult[$currentProduct->getId()]['success']) {
|
728 |
+
$minimumPaymentAmount = $checkQuoteItemResult[$currentProduct->getId()]['minimal_payment_amount'];
|
729 |
+
$result['total_min_amount'] += $minimumPaymentAmount;
|
730 |
+
}
|
731 |
+
|
732 |
+
$result['items'] = $checkQuoteItemResult;
|
|
|
733 |
} else {
|
734 |
+
$result['items'][$currentProduct->getId()] = false;
|
|
|
735 |
}
|
736 |
+
}
|
737 |
+
}
|
738 |
+
|
739 |
+
return $result;
|
740 |
+
}
|
741 |
+
|
742 |
+
/**
|
743 |
+
* @param $product
|
744 |
+
* @param null $quoteItem
|
745 |
+
* @return mixed
|
746 |
+
*/
|
747 |
+
public function checkStartDateDataByProduct($product,$quoteItem = false)
|
748 |
+
{
|
749 |
+
$productAdditionalInfo = unserialize($product->getCustomOption('info_buyRequest')->getValue());
|
750 |
+
$dateTimeStamp = strtotime($productAdditionalInfo['recurring_profile_start_datetime']);
|
751 |
+
|
752 |
+
if ($dateTimeStamp) {
|
753 |
+
$userSetTime = new Zend_Date($productAdditionalInfo['recurring_profile_start_datetime']);
|
754 |
+
$currentZendDate = new Zend_Date(time());
|
755 |
+
if ($userSetTime->getTimestamp() > $currentZendDate->getTimestamp()) {
|
756 |
+
$result[$product->getId()]['success'] = true;
|
757 |
+
$recurringProfileData = $product->getData('recurring_profile');
|
758 |
+
if($quoteItem){
|
759 |
+
$initAmount = $quoteItem->getXpRecurringInitialFee();
|
760 |
+
}else{
|
761 |
+
$initAmount = $recurringProfileData['init_amount'];
|
762 |
+
}
|
763 |
+
|
764 |
+
$defaultMinimumPayment = floatval(Mage::getStoreConfig('xpaymentsconnector/settings/xpay_minimum_payment_recurring_amount'));
|
765 |
+
$minimumPaymentAmount = ($initAmount) ? $initAmount : $defaultMinimumPayment;
|
766 |
+
$result[$product->getId()]['minimal_payment_amount'] = $minimumPaymentAmount;
|
767 |
+
|
768 |
} else {
|
769 |
+
$result[$product->getId()]['success'] = false;
|
|
|
770 |
}
|
771 |
+
} else {
|
772 |
+
$result[$product->getId()]['success'] = false;
|
773 |
}
|
|
|
774 |
return $result;
|
775 |
}
|
776 |
|
777 |
+
public function getRecurringProfileState()
|
778 |
+
{
|
779 |
$maxPaymentFailureMessage = $this->__('This profile has run out of maximal limit of unsuccessful payment attempts.');
|
780 |
|
781 |
if (Mage::app()->getStore()->isAdmin()) {
|
782 |
Mage::getSingleton('adminhtml/session')->addNotice($maxPaymentFailureMessage);
|
783 |
+
} else {
|
784 |
Mage::getSingleton('core/session')->addNotice($maxPaymentFailureMessage);
|
785 |
}
|
786 |
}
|
787 |
|
788 |
+
public function addRecurringTransactionError($response = array())
|
789 |
+
{
|
790 |
+
$this->unsetXpaymentPrepareOrder();
|
791 |
+
if (!empty($response)) {
|
792 |
+
if (!empty($response['error_message'])) {
|
793 |
+
$errorMessage = $this->__("%s. The subscription has been canceled.", $response['error_message']);
|
794 |
+
Mage::getSingleton('checkout/session')->addError($errorMessage);
|
795 |
+
} else {
|
796 |
+
$transactionStatusLabel = Mage::getModel('xpaymentsconnector/payment_cc')->getTransactionStatusLabels();
|
797 |
+
$errorMessage = $this->__("Transaction status is '%s'. The subscription has been canceled.", $transactionStatusLabel[$response['status']]);
|
798 |
+
Mage::getSingleton('checkout/session')->addError($errorMessage);
|
799 |
+
}
|
800 |
+
} else {
|
801 |
+
$errorMessage = $this->__('The subscription has been canceled.');
|
802 |
+
Mage::getSingleton('checkout/session')->addError($errorMessage);
|
803 |
+
}
|
804 |
}
|
805 |
|
806 |
+
public function setRecurringProductDiscount()
|
807 |
+
{
|
808 |
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
809 |
$items = $quote->getAllVisibleItems();
|
810 |
+
foreach ($items as $item) {
|
811 |
$discount = $item->getDiscountAmount();
|
812 |
$profile = $item->getProduct()->getRecurringProfile();
|
813 |
+
$profile['discount_amount'] = $discount;
|
814 |
$item->getProduct()->setRecurringProfile($profile)->save();
|
815 |
}
|
816 |
}
|
817 |
|
818 |
+
public function getIframeUrl()
|
819 |
+
{
|
820 |
+
|
821 |
+
$xpaymentFormData = Mage::helper('payment')->getMethodInstance('xpayments')->getFormFields();
|
822 |
+
$xpaymentFormUrl = Mage::helper('payment')->getMethodInstance('xpayments')->getUrl();
|
823 |
|
824 |
$this->prepareOrderKey();
|
825 |
$token = $this->getIframeToken();
|
828 |
return $iframeUrl;
|
829 |
}
|
830 |
|
831 |
+
/**
|
832 |
+
* This function fixed magento bug. Magento can't create user
|
833 |
+
* during checkout with recurring products.
|
834 |
+
* @return mixed
|
835 |
+
* @throws Exception
|
836 |
+
*/
|
837 |
+
public function registeredUser()
|
838 |
+
{
|
839 |
+
$transaction = Mage::getModel('core/resource_transaction');
|
840 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
841 |
+
if ($quote->getCustomerId()) {
|
842 |
+
$customer = $quote->getCustomer();
|
843 |
+
$transaction->addObject($customer);
|
844 |
+
}
|
845 |
+
|
846 |
+
try {
|
847 |
+
$transaction->save();
|
848 |
+
$customer->save();
|
849 |
+
return $customer;
|
850 |
+
} catch (Exception $e) {
|
851 |
+
|
852 |
+
if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
|
853 |
+
// reset customer ID's on exception, because customer not saved
|
854 |
+
$quote->getCustomer()->setId(null);
|
855 |
+
}
|
856 |
+
|
857 |
+
throw $e;
|
858 |
+
}
|
859 |
+
return false;
|
860 |
+
}
|
861 |
+
|
862 |
+
/**
|
863 |
+
* Save custom calculating initial fee amount
|
864 |
+
* @param Mage_Catalog_Model_Product $product
|
865 |
+
*/
|
866 |
+
public function updateRecurringQuoteItem(Mage_Catalog_Model_Product $product)
|
867 |
+
{
|
868 |
+
$quote = Mage::getModel('checkout/cart')->getQuote();
|
869 |
+
if ($product->getIsRecurring()) {
|
870 |
+
$quoteItem = $quote->getItemByProduct($product);
|
871 |
+
$recurringProfile = $product->getRecurringProfile();
|
872 |
+
$initAmount = $recurringProfile['init_amount'];
|
873 |
+
if(!is_null($initAmount)){
|
874 |
+
$qty = $quoteItem->getQty();
|
875 |
+
$totalInitAmount = $qty * $initAmount;
|
876 |
+
|
877 |
+
if (isset($recurringProfile['init_amount']) &&
|
878 |
+
!empty($recurringProfile['init_amount']) &&
|
879 |
+
$recurringProfile['init_amount'] > 0
|
880 |
+
) {
|
881 |
+
|
882 |
+
$quoteItem->setXpRecurringInitialFee($totalInitAmount);
|
883 |
+
$initialFeeTax = $this->calculateTaxForProductCustomPrice($product,$totalInitAmount);
|
884 |
+
if($initialFeeTax){
|
885 |
+
$quoteItem->setInitialfeeTaxAmount($initialFeeTax);
|
886 |
+
}
|
887 |
+
|
888 |
+
$quoteItem->save();
|
889 |
+
}
|
890 |
+
}
|
891 |
+
}
|
892 |
+
|
893 |
+
}
|
894 |
+
|
895 |
+
public function updateAllRecurringQuoteItem()
|
896 |
+
{
|
897 |
+
$quote = Mage::getModel('checkout/cart')->getQuote();
|
898 |
+
$quoteItems = $quote->getAllVisibleItems();
|
899 |
+
foreach ($quoteItems as $quoteItem) {
|
900 |
+
$product = $quoteItem->getProduct();
|
901 |
+
$this->updateRecurringQuoteItem($product);
|
902 |
+
}
|
903 |
+
|
904 |
+
}
|
905 |
+
|
906 |
+
/**
|
907 |
+
* Add default settings for submitRecurringProfile function
|
908 |
+
* @param Mage_Payment_Model_Recurring_Profile $profile
|
909 |
+
*/
|
910 |
+
public function addXpDefaultRecurringSettings(Mage_Payment_Model_Recurring_Profile $profile){
|
911 |
+
$quote = $profile->getQuote();
|
912 |
+
$customerId = $quote->getCustomer()->getId();
|
913 |
+
if (is_null($customerId)) {
|
914 |
+
$customer = $this->registeredUser();
|
915 |
+
if($customer){
|
916 |
+
$customerId = $customer->getId();
|
917 |
+
}
|
918 |
+
}
|
919 |
+
$profile->setCustomerId($customerId);
|
920 |
+
$orderItemInfo = $profile->getOrderItemInfo();
|
921 |
+
if($orderItemInfo['xp_recurring_initial_fee']){
|
922 |
+
$profile->setInitAmount($orderItemInfo['xp_recurring_initial_fee']);
|
923 |
+
}
|
924 |
+
|
925 |
+
$quoteItemInfo = $profile->getQuoteItemInfo();
|
926 |
+
if(!is_null($quoteItemInfo)){
|
927 |
+
$currentProduct = $quoteItemInfo->getProduct();
|
928 |
+
$this->updateRecurringQuoteItem($currentProduct);
|
929 |
+
}
|
930 |
+
|
931 |
+
}
|
932 |
+
|
933 |
+
/**
|
934 |
+
* Calculate tax for product custom price.
|
935 |
+
* @param $product
|
936 |
+
* @param $price
|
937 |
+
* @return mixed
|
938 |
+
*/
|
939 |
+
public function calculateTaxForProductCustomPrice($product, $price)
|
940 |
+
{
|
941 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
942 |
+
$store = Mage::app()->getStore($quote->getStoreId());
|
943 |
+
$request = Mage::getSingleton('tax/calculation')->getRateRequest(null, null, null, $store);
|
944 |
+
$taxClassId = $product->getData('tax_class_id');
|
945 |
+
$percent = Mage::getSingleton('tax/calculation')->getRate($request->setProductClassId($taxClassId));
|
946 |
+
$tax = $price * ($percent / 100);
|
947 |
+
|
948 |
+
return $tax;
|
949 |
+
}
|
950 |
+
|
951 |
+
/**
|
952 |
+
* orderAmountData
|
953 |
+
* - discount_amount
|
954 |
+
* - tax_amount
|
955 |
+
* - shipping_amount
|
956 |
+
* - product_subtotal
|
957 |
+
* @param Mage_Payment_Model_Recurring_Profile $recurringProfile
|
958 |
+
* @return array
|
959 |
+
*/
|
960 |
+
public function preparePayDeferredOrderAmountData(Mage_Payment_Model_Recurring_Profile $recurringProfile)
|
961 |
+
{
|
962 |
+
$quoteItemInfo = $recurringProfile->getQuoteItemInfo();
|
963 |
+
|
964 |
+
if(!is_null($quoteItemInfo)){
|
965 |
+
$currentProduct = $quoteItemInfo->getProduct();
|
966 |
+
}else{
|
967 |
+
$orderItemInfo = $recurringProfile->getOrderItemInfo();
|
968 |
+
if(is_string($orderItemInfo)){
|
969 |
+
$orderItemInfo = unserialize($orderItemInfo);
|
970 |
+
}
|
971 |
+
$currentProduct = Mage::getModel('catalog/product')->load($orderItemInfo['product_id']);
|
972 |
+
}
|
973 |
+
|
974 |
+
$orderAmountData = array();
|
975 |
+
if(!is_null($recurringProfile->getInitAmount())){
|
976 |
+
$orderAmountData['discount_amount'] = 0;
|
977 |
+
if(isset($orderItemInfo['initialfee_tax_amount']) && !empty($orderItemInfo['initialfee_tax_amount']) ){
|
978 |
+
$orderAmountData['tax_amount'] = $orderItemInfo['initialfee_tax_amount'];
|
979 |
+
}else{
|
980 |
+
$orderAmountData['tax_amount'] =
|
981 |
+
$this->calculateTaxForProductCustomPrice($currentProduct,$recurringProfile->getInitAmount());
|
982 |
+
}
|
983 |
+
$orderAmountData['shipping_amount'] = 0;
|
984 |
+
$orderAmountData['product_subtotal'] = $recurringProfile->getInitAmount();
|
985 |
+
$orderAmountData['grand_total'] = $orderAmountData['tax_amount'] + $orderAmountData['product_subtotal'];
|
986 |
+
}
|
987 |
+
|
988 |
+
return $orderAmountData;
|
989 |
+
}
|
990 |
+
|
991 |
}
|
app/code/community/Cdev/XPaymentsConnector/Model/Observer.php
CHANGED
@@ -25,28 +25,22 @@
|
|
25 |
|
26 |
class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model_Observer
|
27 |
{
|
|
|
28 |
|
29 |
public function preDispatchCheckout($observer)
|
30 |
{
|
31 |
|
32 |
-
Mage::getSingleton(
|
33 |
|
34 |
//unset x-payment form place settings
|
35 |
-
$unsetParams = array(
|
36 |
-
Mage::helper(
|
|
|
37 |
|
38 |
//set recurring product discount
|
39 |
-
$
|
40 |
-
if ($
|
41 |
-
|
42 |
-
$useStartDateParam = Mage::helper("xpaymentsconnector")->checkStartDateData();
|
43 |
-
if ($useStartDateParam["success"]) {
|
44 |
-
$currency_symbol = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
|
45 |
-
$noticeMessage = Mage::helper("xpaymentsconnector")
|
46 |
-
->__("To create a subscription that uses an X-Payments method, your card will be charged a minimal payment - %s%s",
|
47 |
-
$useStartDateParam["minimal_payment_amount"], $currency_symbol);
|
48 |
-
Mage::getSingleton("core/session")->addNotice($noticeMessage);
|
49 |
-
}
|
50 |
}
|
51 |
|
52 |
}
|
@@ -56,19 +50,19 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
|
|
56 |
$event = $observer->getEvent();
|
57 |
$method = $event->getMethodInstance();
|
58 |
$result = $event->getResult();
|
59 |
-
$saveCardsPaymentCode = Mage::getModel(
|
60 |
-
$prepaidpayments = Mage::getModel(
|
61 |
|
62 |
if (($method->getCode() == $saveCardsPaymentCode) || ($method->getCode() == $prepaidpayments)) {
|
63 |
$quote = $event->getQuote();
|
64 |
if ($quote) {
|
65 |
-
$customerId = $quote->getData(
|
66 |
$isBalanceCard = Cdev_XPaymentsConnector_Model_Usercards::SIMPLE_CARD;
|
67 |
if ($method->getCode() == $prepaidpayments) {
|
68 |
$isBalanceCard = Cdev_XPaymentsConnector_Model_Usercards::BALANCE_CARD;
|
69 |
}
|
70 |
if ($customerId) {
|
71 |
-
$cardsCount = Mage::getModel(
|
72 |
->getCollection()
|
73 |
->addFieldToFilter('user_id', $customerId)
|
74 |
->addFieldToFilter('usage_type', $isBalanceCard)
|
@@ -91,48 +85,61 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
|
|
91 |
|
92 |
public function updateOrder($observer)
|
93 |
{
|
|
|
94 |
$event = $observer->getEvent();
|
95 |
$order = $event->getOrder();
|
96 |
-
|
|
|
97 |
$paymentMethod = $order->getPayment()->getMethodInstance()->getCode();
|
98 |
-
$
|
99 |
-
$
|
|
|
|
|
|
|
100 |
|
101 |
if ($paymentMethod == $xpaymentPaymentCode) {
|
102 |
$order->setCanSendNewEmailFlag(false);
|
103 |
-
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
104 |
|
105 |
-
$request =
|
106 |
|
107 |
|
108 |
if ($useIframe) {
|
109 |
/*update order table*/
|
110 |
$order->setData('xpc_txnid', $request['txnId']);
|
111 |
-
$order->setData(
|
112 |
$order->save();
|
113 |
|
114 |
-
$result =
|
115 |
-
if ($result[
|
116 |
/* save credit card to user profile */
|
117 |
-
$response =
|
118 |
-
|
119 |
/* end (save payment card) */
|
120 |
} else {
|
121 |
-
|
122 |
}
|
|
|
123 |
}
|
124 |
|
125 |
} elseif ($paymentMethod == $saveCardsPaymentCode) {
|
|
|
126 |
$order->setCanSendNewEmailFlag(false);
|
127 |
-
$
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
}
|
133 |
} else {
|
134 |
-
|
135 |
}
|
|
|
136 |
}
|
137 |
|
138 |
|
@@ -144,7 +151,7 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
|
|
144 |
*/
|
145 |
public function orderSuccessAction($observer)
|
146 |
{
|
147 |
-
Mage::helper(
|
148 |
}
|
149 |
|
150 |
|
@@ -154,35 +161,35 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
|
|
154 |
public function postdispatchAdminhtmlSalesOrderCreateSave($observer)
|
155 |
{
|
156 |
$quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
|
157 |
-
$incrementId = $quote->getData(
|
158 |
$order = Mage::getModel('sales/order')->load($incrementId, 'increment_id');
|
159 |
$paymentMethod = $order->getPayment()->getMethodInstance()->getCode();
|
160 |
$admSession = Mage::getSingleton('adminhtml/session');
|
161 |
-
$saveCardsPaymentCode = Mage::getModel(
|
162 |
-
$prepaidpayments = Mage::getModel(
|
163 |
|
164 |
if ($paymentMethod == $saveCardsPaymentCode) {
|
165 |
$orderId = $order->getId();
|
166 |
-
$grandTotal = $quote->getData(
|
167 |
$this->adminhtmlSendSaveCardsPaymentTransaction($orderId,$grandTotal);
|
168 |
} elseif ($paymentMethod == $prepaidpayments) {
|
169 |
-
$xpPrepaidPaymentsCard = $admSession->getData(
|
170 |
-
$currentUserCard = Mage::getModel(
|
171 |
-
$txnid = $currentUserCard->getData(
|
172 |
$lastTransId = $txnid;
|
173 |
|
174 |
-
$order->setData(
|
175 |
$order->getPayment()->setTransactionId($txnid);
|
176 |
$api = Mage::getModel('xpaymentsconnector/payment_cc');
|
177 |
list($status, $response) = $api->requestPaymentInfo($txnid,false,true);
|
178 |
|
179 |
if($status){
|
180 |
-
$currentTransaction = end($response[
|
181 |
-
$lastTransId = $currentTransaction[
|
182 |
}
|
183 |
|
184 |
$order->getPayment()->setLastTransId($lastTransId);
|
185 |
-
$order->setData(
|
186 |
$order->setState(
|
187 |
Mage_Sales_Model_Order::STATE_PROCESSING,
|
188 |
(bool)Mage_Sales_Model_Order::STATE_PROCESSING,
|
@@ -190,8 +197,8 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
|
|
190 |
);
|
191 |
$order->save();
|
192 |
}
|
193 |
-
$admSession->unsetData(
|
194 |
-
$admSession->unsetData(
|
195 |
|
196 |
}
|
197 |
|
@@ -234,13 +241,13 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
|
|
234 |
protected function adminhtmlSendSaveCardsPaymentTransaction($orderId,$grandTotal,$checkOrderAmount = true)
|
235 |
{
|
236 |
$admSession = Mage::getSingleton('adminhtml/session');
|
237 |
-
$xpCreditCards = $admSession->getData(
|
238 |
|
239 |
-
$response = Mage::getModel(
|
240 |
-
if ($response[
|
241 |
-
Mage::getModel(
|
242 |
} else {
|
243 |
-
Mage::getSingleton(
|
244 |
}
|
245 |
|
246 |
}
|
@@ -249,17 +256,17 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
|
|
249 |
{
|
250 |
$quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
|
251 |
$paymentMethod = $quote->getPayment()->getMethodInstance()->getCode();
|
252 |
-
$prepaidpayments = Mage::getModel(
|
253 |
if ($paymentMethod == $prepaidpayments) {
|
254 |
$admSession = Mage::getSingleton('adminhtml/session');
|
255 |
-
$xpPrepaidPaymentsCard = $admSession->getData(
|
256 |
-
$currentUserCard = Mage::getModel(
|
257 |
-
$grandTotal = $quote->getData(
|
258 |
$cardAmount = $currentUserCard->getAmount();
|
259 |
if ($cardAmount < $grandTotal) {
|
260 |
-
$errorMessage = Mage::helper(
|
261 |
->__("You can't make an order using card (**%s) worth over %s",
|
262 |
-
$currentUserCard->getData(
|
263 |
Mage::helper('core')->currency($cardAmount));
|
264 |
$admSession->addError($errorMessage);
|
265 |
/*redirect to last page*/
|
@@ -280,20 +287,20 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
|
|
280 |
|
281 |
public function adminhtmlSavePaymentCard()
|
282 |
{
|
283 |
-
$payment = Mage::app()->getRequest()->getPost(
|
284 |
-
$saveCardsPaymentCode = Mage::getModel(
|
285 |
-
$prepaidpayments = Mage::getModel(
|
286 |
|
287 |
if ($payment) {
|
288 |
-
if ($payment[
|
289 |
-
if ($payment[
|
290 |
$admSession = Mage::getSingleton('adminhtml/session');
|
291 |
-
$admSession->setData(
|
292 |
}
|
293 |
-
} elseif ($payment[
|
294 |
-
if ($payment[
|
295 |
$admSession = Mage::getSingleton('adminhtml/session');
|
296 |
-
$admSession->setData(
|
297 |
}
|
298 |
}
|
299 |
}
|
@@ -302,8 +309,8 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
|
|
302 |
public function unsetXpaymentSelectedCard()
|
303 |
{
|
304 |
$admSession = Mage::getSingleton('adminhtml/session');
|
305 |
-
$admSession->unsetData(
|
306 |
-
$admSession->unsetData(
|
307 |
}
|
308 |
|
309 |
public function orderInvoiceSaveBefore($observer)
|
@@ -311,8 +318,8 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
|
|
311 |
$invoice = $observer->getEvent()->getInvoice();
|
312 |
$order = $invoice->getOrder();
|
313 |
$paymentCode = $order->getPayment()->getMethodInstance()->getCode();
|
314 |
-
if (Mage::helper(
|
315 |
-
$txnid = $order->getData(
|
316 |
$invoice->setTransactionId($txnid);
|
317 |
}
|
318 |
}
|
@@ -322,78 +329,117 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
|
|
322 |
$invoice = $observer->getInvoice();
|
323 |
$order = $invoice->getOrder();
|
324 |
$paymentCode = $order->getPayment()->getMethodInstance()->getCode();
|
325 |
-
if (Mage::helper(
|
326 |
$data = array(
|
327 |
-
'txnId' => $order->getData(
|
328 |
'amount' => number_format($invoice->getGrandTotal(), 2, '.', ''),
|
329 |
);
|
330 |
-
Mage::getModel(
|
331 |
}
|
332 |
}
|
333 |
|
334 |
public function createOrdersByCustomerSubscriptions($observer)
|
335 |
{
|
336 |
-
$xpaymentsHelper = Mage::helper(
|
337 |
$recurringProfileList = Mage::getModel('sales/recurring_profile')
|
338 |
->getCollection()
|
339 |
-
->addFieldToFilter(
|
|
|
|
|
340 |
if ($recurringProfileList->getSize() > 0) {
|
341 |
foreach ($recurringProfileList as $profile) {
|
342 |
-
$
|
343 |
-
$
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
$newTransactionDate = $lastActionDate + $profilePeriodValue;
|
348 |
-
|
349 |
-
$currentDateObj = new Zend_Date(time());
|
350 |
-
$currentDateStamp = $currentDateObj->getTimestamp();
|
351 |
-
|
352 |
-
//var_dump("current = ".date("Y-m-d H:m:s",$currentDateStamp),"start = ".date("Y-m-d H:m:s",$startDateTime),"last = ".date("Y-m-d H:m:s",$lastActionDate),"new = ".date("Y-m-d H:m:s",$newTransactionDate),"profile_id = ".$profile->getProfileId());die;
|
353 |
-
|
354 |
-
$timePassed = $currentDateStamp - $lastActionDate;
|
355 |
-
|
356 |
-
if ($timePassed >= $profilePeriodValue) {
|
357 |
-
// check by count of success transaction
|
358 |
-
$currentSuccessCycles = $profile->getXpCountSuccessTransaction();
|
359 |
-
$periodMaxCycles = $profile->getPeriodMaxCycles();
|
360 |
-
|
361 |
-
if ($periodMaxCycles >= $currentSuccessCycles) {
|
362 |
-
$orderItemInfo = $profile->getData("order_item_info");
|
363 |
-
if (!is_array($orderItemInfo)) {
|
364 |
-
$orderItemInfo = unserialize($orderItemInfo);
|
365 |
-
}
|
366 |
-
$grandTotal = $orderItemInfo["nominal_row_total"];
|
367 |
-
$initialFeeAmount = $orderItemInfo["recurring_initial_fee"];
|
368 |
-
|
369 |
-
// add discount for grand total amount
|
370 |
-
$useDiscount = current($profile->getChildOrderIds()) > 0;
|
371 |
-
$discountAmount = ($useDiscount) ? $orderItemInfo["discount_amount"] : 0;
|
372 |
-
|
373 |
-
$orderId = $xpaymentsHelper->createOrder($profile);
|
374 |
-
$cardData = $xpaymentsHelper->getProfileOrderCardData($profile);
|
375 |
-
|
376 |
-
$response = Mage::getModel("xpaymentsconnector/payment_cc")->sendAgainTransactionRequest($orderId, NULL, $grandTotal - $initialFeeAmount + $discountAmount, $cardData);
|
377 |
|
378 |
-
|
379 |
-
|
380 |
-
$xpaymentsHelper->
|
381 |
-
|
382 |
-
|
|
|
|
|
|
|
|
|
383 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
384 |
|
385 |
-
|
386 |
-
$xpaymentsHelper->updateCurrentBillingPeriodTimeStamp($profile, $response["success"], $newTransactionDate);
|
387 |
-
Mage::log($response["error_message"], null, $xpaymentsHelper::XPAYMENTS_LOG_FILE, true);
|
388 |
}
|
389 |
-
|
390 |
-
} else {
|
391 |
-
// Subscription is completed
|
392 |
-
$profile->cancel();
|
393 |
-
|
394 |
}
|
395 |
}
|
396 |
-
|
397 |
}
|
398 |
|
399 |
}
|
@@ -407,15 +453,15 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
|
|
407 |
*/
|
408 |
public function addRedirectForXpaymentMethod($observer)
|
409 |
{
|
410 |
-
$profiles = $observer->getData(
|
411 |
if (!empty($profiles)) {
|
412 |
$profile = current($profiles);
|
413 |
-
$currentPaymentMethodCode = $profile->getData(
|
414 |
-
$xpaymentPaymentCode = Mage::getModel(
|
415 |
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
416 |
if (($currentPaymentMethodCode == $xpaymentPaymentCode) && !$useIframe) {
|
417 |
$redirectUrl = Mage::getUrl('xpaymentsconnector/processing/redirect', array('_secure' => true));
|
418 |
-
Mage::getSingleton(
|
419 |
}
|
420 |
|
421 |
}
|
@@ -425,25 +471,34 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
|
|
425 |
/**
|
426 |
* Set discount for recurring product(for ajax cart item quantity update)
|
427 |
* Remove X-Payments token
|
|
|
428 |
* @param $observer
|
429 |
*/
|
430 |
public function updateCartItem($observer)
|
431 |
{
|
432 |
-
$unsetParams = array(
|
433 |
-
Mage::helper(
|
|
|
434 |
|
435 |
//set recurring product discount
|
436 |
-
Mage::helper(
|
|
|
437 |
}
|
438 |
|
439 |
/**
|
440 |
-
* Remove X-Payments token
|
|
|
441 |
* @param $observer
|
442 |
*/
|
443 |
public function checkoutCartAdd($observer)
|
444 |
{
|
445 |
-
$
|
446 |
-
|
|
|
|
|
|
|
|
|
|
|
447 |
}
|
448 |
|
449 |
/**
|
@@ -452,8 +507,8 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
|
|
452 |
*/
|
453 |
public function postdispatchCartDelete($observer)
|
454 |
{
|
455 |
-
$unsetParams = array(
|
456 |
-
Mage::helper(
|
457 |
}
|
458 |
|
459 |
|
@@ -463,7 +518,7 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
|
|
463 |
*/
|
464 |
public function predispatchSaveShippingMethod()
|
465 |
{
|
466 |
-
Mage::helper(
|
467 |
}
|
468 |
|
469 |
/**
|
@@ -472,10 +527,11 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
|
|
472 |
*/
|
473 |
public function postdispatchSaveShippingMethod($observer)
|
474 |
{
|
475 |
-
$
|
|
|
476 |
if (!$isPaymentPlaceDisplayFlag) {
|
477 |
-
$unsetParams = array(
|
478 |
-
|
479 |
}
|
480 |
}
|
481 |
|
@@ -483,19 +539,20 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
|
|
483 |
{
|
484 |
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
485 |
$paymentMethodCode = $quote->getPayment()->getMethodInstance()->getCode();
|
486 |
-
$xpaymentPaymentCode = Mage::getModel(
|
|
|
487 |
|
488 |
-
$isXpayments =
|
489 |
if ($isXpayments) {
|
490 |
-
|
491 |
}
|
492 |
if ($paymentMethodCode == $xpaymentPaymentCode) {
|
493 |
-
$saveCard = Mage::app()->getRequest()->getPost(
|
494 |
if ($saveCard) {
|
495 |
-
Mage::getSingleton(
|
496 |
}
|
497 |
} else {
|
498 |
-
Mage::getSingleton(
|
499 |
}
|
500 |
}
|
501 |
|
@@ -505,15 +562,15 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
|
|
505 |
*/
|
506 |
public function preDispatchCartIndex($observer)
|
507 |
{
|
508 |
-
$unsetXpPrepareOrder = Mage::app()->getRequest()->getParam(
|
|
|
509 |
if (isset($unsetXpPrepareOrder)) {
|
510 |
-
$unsetParams = array(
|
511 |
-
|
512 |
}
|
513 |
|
514 |
-
|
515 |
//set recurring product discount
|
516 |
-
|
517 |
|
518 |
}
|
519 |
|
@@ -528,14 +585,14 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
|
|
528 |
|
529 |
if(!empty($xpTransactionData)
|
530 |
&& isset($xpTransactionData['xpaction'])
|
531 |
-
&& isset($xpTransactionData[
|
532 |
-
&& isset($xpTransactionData[
|
533 |
){
|
534 |
|
535 |
-
$xpaymentModel = Mage::getModel(
|
536 |
$data = array(
|
537 |
-
'txnId' => $xpTransactionData[
|
538 |
-
'amount' => number_format($xpTransactionData[
|
539 |
);
|
540 |
$result = array();
|
541 |
switch ($xpTransactionData['xpaction']) {
|
@@ -551,7 +608,7 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
|
|
551 |
}
|
552 |
|
553 |
if(empty($result['error_message'])){
|
554 |
-
$message = Mage::helper(
|
555 |
$xpTransactionData['xpaction'],
|
556 |
$xpTransactionData['orderid']);
|
557 |
Mage::getSingleton('adminhtml/session')->addSuccess($message);
|
25 |
|
26 |
class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model_Observer
|
27 |
{
|
28 |
+
protected $_current_customer_id = null;
|
29 |
|
30 |
public function preDispatchCheckout($observer)
|
31 |
{
|
32 |
|
33 |
+
Mage::getSingleton('checkout/session')->unsetData('user_card_save');
|
34 |
|
35 |
//unset x-payment form place settings
|
36 |
+
$unsetParams = array('place_display');
|
37 |
+
$xpHelper = Mage::helper('xpaymentsconnector');
|
38 |
+
$xpHelper->unsetXpaymentPrepareOrder($unsetParams);
|
39 |
|
40 |
//set recurring product discount
|
41 |
+
$issetRecurrnigProduct = $xpHelper->checkIssetRecurringOrder();
|
42 |
+
if ($issetRecurrnigProduct['isset']) {
|
43 |
+
$xpHelper->setRecurringProductDiscount();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
}
|
45 |
|
46 |
}
|
50 |
$event = $observer->getEvent();
|
51 |
$method = $event->getMethodInstance();
|
52 |
$result = $event->getResult();
|
53 |
+
$saveCardsPaymentCode = Mage::getModel('xpaymentsconnector/payment_savedcards')->getCode();
|
54 |
+
$prepaidpayments = Mage::getModel('xpaymentsconnector/payment_prepaidpayments')->getCode();
|
55 |
|
56 |
if (($method->getCode() == $saveCardsPaymentCode) || ($method->getCode() == $prepaidpayments)) {
|
57 |
$quote = $event->getQuote();
|
58 |
if ($quote) {
|
59 |
+
$customerId = $quote->getData('customer_id');
|
60 |
$isBalanceCard = Cdev_XPaymentsConnector_Model_Usercards::SIMPLE_CARD;
|
61 |
if ($method->getCode() == $prepaidpayments) {
|
62 |
$isBalanceCard = Cdev_XPaymentsConnector_Model_Usercards::BALANCE_CARD;
|
63 |
}
|
64 |
if ($customerId) {
|
65 |
+
$cardsCount = Mage::getModel('xpaymentsconnector/usercards')
|
66 |
->getCollection()
|
67 |
->addFieldToFilter('user_id', $customerId)
|
68 |
->addFieldToFilter('usage_type', $isBalanceCard)
|
85 |
|
86 |
public function updateOrder($observer)
|
87 |
{
|
88 |
+
$xpHelper = Mage::helper('xpaymentsconnector');
|
89 |
$event = $observer->getEvent();
|
90 |
$order = $event->getOrder();
|
91 |
+
|
92 |
+
$checkoutSession = Mage::getSingleton('checkout/session');
|
93 |
$paymentMethod = $order->getPayment()->getMethodInstance()->getCode();
|
94 |
+
$paymentCcModel = Mage::getModel('xpaymentsconnector/payment_cc');
|
95 |
+
$xpaymentPaymentCode = $paymentCcModel->getCode();
|
96 |
+
$saveCardsPaymentCode = Mage::getModel('xpaymentsconnector/payment_savedcards')->getCode();
|
97 |
+
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
98 |
+
$quote = $observer->getQuote();
|
99 |
|
100 |
if ($paymentMethod == $xpaymentPaymentCode) {
|
101 |
$order->setCanSendNewEmailFlag(false);
|
|
|
102 |
|
103 |
+
$request = $xpHelper->getXpaymentResponse();
|
104 |
|
105 |
|
106 |
if ($useIframe) {
|
107 |
/*update order table*/
|
108 |
$order->setData('xpc_txnid', $request['txnId']);
|
109 |
+
$order->setData('xp_card_data', serialize($request));
|
110 |
$order->save();
|
111 |
|
112 |
+
$result = $paymentCcModel->updateOrderByXpaymentResponse($order->getId(), $request['txnId']);
|
113 |
+
if ($result['success']) {
|
114 |
/* save credit card to user profile */
|
115 |
+
$response = $xpHelper->getXpaymentResponse();
|
116 |
+
$paymentCcModel->saveUserCard($response);
|
117 |
/* end (save payment card) */
|
118 |
} else {
|
119 |
+
$checkoutSession->addError($result['error_message']);
|
120 |
}
|
121 |
+
|
122 |
}
|
123 |
|
124 |
} elseif ($paymentMethod == $saveCardsPaymentCode) {
|
125 |
+
|
126 |
$order->setCanSendNewEmailFlag(false);
|
127 |
+
$paymentCardNumber = NULL;
|
128 |
+
$grandTotal = NULL;
|
129 |
+
$cardData = NULL;
|
130 |
+
$paymentCardNumber = $quote->getPayment()->getData('xp_payment_card');
|
131 |
+
$cardData = Mage::getModel('xpaymentsconnector/usercards')->load($paymentCardNumber);
|
132 |
+
|
133 |
+
$response = $paymentCcModel->sendAgainTransactionRequest($order->getId(),$paymentCardNumber,$grandTotal,$cardData);
|
134 |
+
if ($response['success']) {
|
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 |
}
|
144 |
|
145 |
|
151 |
*/
|
152 |
public function orderSuccessAction($observer)
|
153 |
{
|
154 |
+
Mage::helper('xpaymentsconnector')->unsetXpaymentPrepareOrder();
|
155 |
}
|
156 |
|
157 |
|
161 |
public function postdispatchAdminhtmlSalesOrderCreateSave($observer)
|
162 |
{
|
163 |
$quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
|
164 |
+
$incrementId = $quote->getData('reserved_order_id');
|
165 |
$order = Mage::getModel('sales/order')->load($incrementId, 'increment_id');
|
166 |
$paymentMethod = $order->getPayment()->getMethodInstance()->getCode();
|
167 |
$admSession = Mage::getSingleton('adminhtml/session');
|
168 |
+
$saveCardsPaymentCode = Mage::getModel('xpaymentsconnector/payment_savedcards')->getCode();
|
169 |
+
$prepaidpayments = Mage::getModel('xpaymentsconnector/payment_prepaidpayments')->getCode();
|
170 |
|
171 |
if ($paymentMethod == $saveCardsPaymentCode) {
|
172 |
$orderId = $order->getId();
|
173 |
+
$grandTotal = $quote->getData('grand_total');
|
174 |
$this->adminhtmlSendSaveCardsPaymentTransaction($orderId,$grandTotal);
|
175 |
} elseif ($paymentMethod == $prepaidpayments) {
|
176 |
+
$xpPrepaidPaymentsCard = $admSession->getData('xp_prepaid_payments');
|
177 |
+
$currentUserCard = Mage::getModel('xpaymentsconnector/usercards')->load($xpPrepaidPaymentsCard);
|
178 |
+
$txnid = $currentUserCard->getData('txnId');
|
179 |
$lastTransId = $txnid;
|
180 |
|
181 |
+
$order->setData('xpc_txnid',$txnid);
|
182 |
$order->getPayment()->setTransactionId($txnid);
|
183 |
$api = Mage::getModel('xpaymentsconnector/payment_cc');
|
184 |
list($status, $response) = $api->requestPaymentInfo($txnid,false,true);
|
185 |
|
186 |
if($status){
|
187 |
+
$currentTransaction = end($response['transactions']);
|
188 |
+
$lastTransId = $currentTransaction['txnid'];
|
189 |
}
|
190 |
|
191 |
$order->getPayment()->setLastTransId($lastTransId);
|
192 |
+
$order->setData('xp_card_data',serialize($currentUserCard->getData()));
|
193 |
$order->setState(
|
194 |
Mage_Sales_Model_Order::STATE_PROCESSING,
|
195 |
(bool)Mage_Sales_Model_Order::STATE_PROCESSING,
|
197 |
);
|
198 |
$order->save();
|
199 |
}
|
200 |
+
$admSession->unsetData('xp_payment_card');
|
201 |
+
$admSession->unsetData('xp_prepaid_payments');
|
202 |
|
203 |
}
|
204 |
|
241 |
protected function adminhtmlSendSaveCardsPaymentTransaction($orderId,$grandTotal,$checkOrderAmount = true)
|
242 |
{
|
243 |
$admSession = Mage::getSingleton('adminhtml/session');
|
244 |
+
$xpCreditCards = $admSession->getData('xp_payment_card');
|
245 |
|
246 |
+
$response = Mage::getModel('xpaymentsconnector/payment_cc')->sendAgainTransactionRequest($orderId, $xpCreditCards, $grandTotal);
|
247 |
+
if ($response['success']) {
|
248 |
+
Mage::getModel('xpaymentsconnector/payment_cc')->updateOrderByXpaymentResponse($orderId, $response['response']['transaction_id'],$checkOrderAmount);
|
249 |
} else {
|
250 |
+
Mage::getSingleton('adminhtml/session')->addError($response['error_message']);
|
251 |
}
|
252 |
|
253 |
}
|
256 |
{
|
257 |
$quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
|
258 |
$paymentMethod = $quote->getPayment()->getMethodInstance()->getCode();
|
259 |
+
$prepaidpayments = Mage::getModel('xpaymentsconnector/payment_prepaidpayments')->getCode();
|
260 |
if ($paymentMethod == $prepaidpayments) {
|
261 |
$admSession = Mage::getSingleton('adminhtml/session');
|
262 |
+
$xpPrepaidPaymentsCard = $admSession->getData('xp_prepaid_payments');
|
263 |
+
$currentUserCard = Mage::getModel('xpaymentsconnector/usercards')->load($xpPrepaidPaymentsCard);
|
264 |
+
$grandTotal = $quote->getData('grand_total');
|
265 |
$cardAmount = $currentUserCard->getAmount();
|
266 |
if ($cardAmount < $grandTotal) {
|
267 |
+
$errorMessage = Mage::helper('xpaymentsconnector')
|
268 |
->__("You can't make an order using card (**%s) worth over %s",
|
269 |
+
$currentUserCard->getData('last_4_cc_num'),
|
270 |
Mage::helper('core')->currency($cardAmount));
|
271 |
$admSession->addError($errorMessage);
|
272 |
/*redirect to last page*/
|
287 |
|
288 |
public function adminhtmlSavePaymentCard()
|
289 |
{
|
290 |
+
$payment = Mage::app()->getRequest()->getPost('payment');
|
291 |
+
$saveCardsPaymentCode = Mage::getModel('xpaymentsconnector/payment_savedcards')->getCode();
|
292 |
+
$prepaidpayments = Mage::getModel('xpaymentsconnector/payment_prepaidpayments')->getCode();
|
293 |
|
294 |
if ($payment) {
|
295 |
+
if ($payment['method'] == $saveCardsPaymentCode) {
|
296 |
+
if ($payment['xp_payment_card']) {
|
297 |
$admSession = Mage::getSingleton('adminhtml/session');
|
298 |
+
$admSession->setData('xp_payment_card', $payment['xp_payment_card']);
|
299 |
}
|
300 |
+
} elseif ($payment['method'] == $prepaidpayments) {
|
301 |
+
if ($payment['xp_prepaid_payments']) {
|
302 |
$admSession = Mage::getSingleton('adminhtml/session');
|
303 |
+
$admSession->setData('xp_prepaid_payments', $payment['xp_prepaid_payments']);
|
304 |
}
|
305 |
}
|
306 |
}
|
309 |
public function unsetXpaymentSelectedCard()
|
310 |
{
|
311 |
$admSession = Mage::getSingleton('adminhtml/session');
|
312 |
+
$admSession->unsetData('xp_payment_card');
|
313 |
+
$admSession->unsetData('xp_prepaid_payments');
|
314 |
}
|
315 |
|
316 |
public function orderInvoiceSaveBefore($observer)
|
318 |
$invoice = $observer->getEvent()->getInvoice();
|
319 |
$order = $invoice->getOrder();
|
320 |
$paymentCode = $order->getPayment()->getMethodInstance()->getCode();
|
321 |
+
if (Mage::helper('xpaymentsconnector')->isXpaymentsMethod($paymentCode)) {
|
322 |
+
$txnid = $order->getData('xpc_txnid');
|
323 |
$invoice->setTransactionId($txnid);
|
324 |
}
|
325 |
}
|
329 |
$invoice = $observer->getInvoice();
|
330 |
$order = $invoice->getOrder();
|
331 |
$paymentCode = $order->getPayment()->getMethodInstance()->getCode();
|
332 |
+
if (Mage::helper('xpaymentsconnector')->isXpaymentsMethod($paymentCode)) {
|
333 |
$data = array(
|
334 |
+
'txnId' => $order->getData('xpc_txnid'),
|
335 |
'amount' => number_format($invoice->getGrandTotal(), 2, '.', ''),
|
336 |
);
|
337 |
+
Mage::getModel('xpaymentsconnector/payment_cc')->authorizedTransactionRequest('void', $data);
|
338 |
}
|
339 |
}
|
340 |
|
341 |
public function createOrdersByCustomerSubscriptions($observer)
|
342 |
{
|
343 |
+
$xpaymentsHelper = Mage::helper('xpaymentsconnector');
|
344 |
$recurringProfileList = Mage::getModel('sales/recurring_profile')
|
345 |
->getCollection()
|
346 |
+
->addFieldToFilter('state', array('neq' => Mage_Sales_Model_Recurring_Profile::STATE_CANCELED));
|
347 |
+
|
348 |
+
$userTransactionHasBeenSend = false;
|
349 |
if ($recurringProfileList->getSize() > 0) {
|
350 |
foreach ($recurringProfileList as $profile) {
|
351 |
+
$customerId = $profile->getCustomerId();
|
352 |
+
if($this->_current_customer_id != $customerId){
|
353 |
+
$this->_current_customer_id = $customerId;
|
354 |
+
$userTransactionHasBeenSend = false;
|
355 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
356 |
|
357 |
+
if(!$userTransactionHasBeenSend){
|
358 |
+
if ($profile->getState() == Mage_Sales_Model_Recurring_Profile::STATE_UNKNOWN) {
|
359 |
+
$cardData = $xpaymentsHelper->getProfileOrderCardData($profile);
|
360 |
+
$orderAmountData = $xpaymentsHelper->preparePayDeferredOrderAmountData($profile);
|
361 |
+
if(!empty($orderAmountData)){
|
362 |
+
$xpaymentsHelper->resendPayDeferredRecurringTransaction($profile, $orderAmountData, $cardData);
|
363 |
+
$userTransactionHasBeenSend = true;
|
364 |
+
}else{
|
365 |
+
$profile->activate();
|
366 |
}
|
367 |
+
continue;
|
368 |
+
} elseif ($profile->getState() == Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE) {
|
369 |
+
$startDateTime = strtotime($profile->getStartDatetime());
|
370 |
+
$lastSuccessTransactionDate = strtotime($profile->getXpSuccessTransactionDate());
|
371 |
+
$lastActionDate = ($startDateTime > $lastSuccessTransactionDate) ? $startDateTime : $lastSuccessTransactionDate;
|
372 |
+
|
373 |
+
$profilePeriodValue = $xpaymentsHelper->getCurrentBillingPeriodTimeStamp($profile);
|
374 |
+
$newTransactionDate = $lastActionDate + $profilePeriodValue;
|
375 |
+
|
376 |
+
$currentDateObj = new Zend_Date(time());
|
377 |
+
$currentDateStamp = $currentDateObj->getTimestamp();
|
378 |
+
/*
|
379 |
+
var_dump('period_stamp ='.$profilePeriodValue / 3600 ."(h)",
|
380 |
+
"current = ".date("Y-m-d H:m:s",$currentDateStamp),
|
381 |
+
"start = ".date("Y-m-d H:m:s",$startDateTime),
|
382 |
+
"last = ".date("Y-m-d H:m:s",$lastActionDate),
|
383 |
+
"new = ".date("Y-m-d H:m:s",$newTransactionDate),
|
384 |
+
"profile_id = ".$profile->getProfileId());die;
|
385 |
+
*/
|
386 |
+
|
387 |
+
$timePassed = $currentDateStamp - $lastActionDate;
|
388 |
+
|
389 |
+
if ($timePassed >= $profilePeriodValue) {
|
390 |
+
// check by count of success transaction
|
391 |
+
$currentSuccessCycles = $profile->getXpCountSuccessTransaction();
|
392 |
+
$periodMaxCycles = $profile->getPeriodMaxCycles();
|
393 |
+
|
394 |
+
if (($periodMaxCycles > $currentSuccessCycles) || is_null($periodMaxCycles)) {
|
395 |
+
$orderItemInfo = $profile->getData('order_item_info');
|
396 |
+
if (!is_array($orderItemInfo)) {
|
397 |
+
$orderItemInfo = unserialize($orderItemInfo);
|
398 |
+
}
|
399 |
+
|
400 |
+
$initialFeeAmount = $orderItemInfo['recurring_initial_fee'];
|
401 |
+
|
402 |
+
|
403 |
+
|
404 |
+
$isFirstRecurringOrder = false;
|
405 |
+
|
406 |
+
//calculate grand total
|
407 |
+
$billingAmount = $profile->getBillingAmount();
|
408 |
+
$shippingAmount = $profile->getShippingAmount();
|
409 |
+
$taxAmount = $profile->getTaxAmount();
|
410 |
+
|
411 |
+
$initialFeeTax = ($profile->getInitiaFeePaid()) ? 0 : 123;
|
412 |
+
// add discount for transaction amount
|
413 |
+
$useDiscount = ($profile->getXpCountSuccessTransaction() > 0) ? false : true;
|
414 |
+
$discountAmount = ($useDiscount) ? $orderItemInfo['discount_amount'] : 0;
|
415 |
+
|
416 |
+
$transactionAmount = $billingAmount + $shippingAmount + $taxAmount - $discountAmount ;
|
417 |
+
|
418 |
+
$orderId = $xpaymentsHelper->createOrder($profile,$isFirstRecurringOrder);
|
419 |
+
$cardData = $xpaymentsHelper->getProfileOrderCardData($profile);
|
420 |
+
|
421 |
+
$response = Mage::getModel('xpaymentsconnector/payment_cc')->sendAgainTransactionRequest($orderId, NULL, $transactionAmount , $cardData);
|
422 |
+
$userTransactionHasBeenSend = true;
|
423 |
+
if ($response['success']) {
|
424 |
+
$result = Mage::getModel('xpaymentsconnector/payment_cc')->updateOrderByXpaymentResponse($orderId, $response['response']['transaction_id']);
|
425 |
+
$xpaymentsHelper->updateCurrentBillingPeriodTimeStamp($profile, $result['success'], $newTransactionDate);
|
426 |
+
if (!$result['success']) {
|
427 |
+
Mage::log($result['error_message'], null, $xpaymentsHelper::XPAYMENTS_LOG_FILE, true);
|
428 |
+
}
|
429 |
+
|
430 |
+
} else {
|
431 |
+
$xpaymentsHelper->updateCurrentBillingPeriodTimeStamp($profile, $response['success'], $newTransactionDate);
|
432 |
+
Mage::log($response['error_message'], null, $xpaymentsHelper::XPAYMENTS_LOG_FILE, true);
|
433 |
+
}
|
434 |
+
|
435 |
+
} else {
|
436 |
+
// Subscription is completed
|
437 |
+
$profile->cancel();
|
438 |
|
439 |
+
}
|
|
|
|
|
440 |
}
|
|
|
|
|
|
|
|
|
|
|
441 |
}
|
442 |
}
|
|
|
443 |
}
|
444 |
|
445 |
}
|
453 |
*/
|
454 |
public function addRedirectForXpaymentMethod($observer)
|
455 |
{
|
456 |
+
$profiles = $observer->getData('recurring_profiles');
|
457 |
if (!empty($profiles)) {
|
458 |
$profile = current($profiles);
|
459 |
+
$currentPaymentMethodCode = $profile->getData('method_code');
|
460 |
+
$xpaymentPaymentCode = Mage::getModel('xpaymentsconnector/payment_cc')->getCode();
|
461 |
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
462 |
if (($currentPaymentMethodCode == $xpaymentPaymentCode) && !$useIframe) {
|
463 |
$redirectUrl = Mage::getUrl('xpaymentsconnector/processing/redirect', array('_secure' => true));
|
464 |
+
Mage::getSingleton('checkout/session')->setRedirectUrl($redirectUrl);
|
465 |
}
|
466 |
|
467 |
}
|
471 |
/**
|
472 |
* Set discount for recurring product(for ajax cart item quantity update)
|
473 |
* Remove X-Payments token
|
474 |
+
* Update initial Fee for recurring product;
|
475 |
* @param $observer
|
476 |
*/
|
477 |
public function updateCartItem($observer)
|
478 |
{
|
479 |
+
$unsetParams = array('token');
|
480 |
+
$xpHelper = Mage::helper('xpaymentsconnector');
|
481 |
+
$xpHelper->unsetXpaymentPrepareOrder($unsetParams);
|
482 |
|
483 |
//set recurring product discount
|
484 |
+
Mage::helper('xpaymentsconnector')->setRecurringProductDiscount();
|
485 |
+
$xpHelper->updateAllRecurringQuoteItem();
|
486 |
}
|
487 |
|
488 |
/**
|
489 |
+
* Remove X-Payments token;
|
490 |
+
* Update initial Fee for recurring product;
|
491 |
* @param $observer
|
492 |
*/
|
493 |
public function checkoutCartAdd($observer)
|
494 |
{
|
495 |
+
$xpHelper = Mage::helper('xpaymentsconnector');
|
496 |
+
$unsetParams = array('token');
|
497 |
+
$xpHelper->unsetXpaymentPrepareOrder($unsetParams);
|
498 |
+
|
499 |
+
$product = $observer->getProduct();
|
500 |
+
$xpHelper->updateRecurringQuoteItem($product);
|
501 |
+
|
502 |
}
|
503 |
|
504 |
/**
|
507 |
*/
|
508 |
public function postdispatchCartDelete($observer)
|
509 |
{
|
510 |
+
$unsetParams = array('token', 'prepare_order_id');
|
511 |
+
Mage::helper('xpaymentsconnector')->unsetXpaymentPrepareOrder($unsetParams);
|
512 |
}
|
513 |
|
514 |
|
518 |
*/
|
519 |
public function predispatchSaveShippingMethod()
|
520 |
{
|
521 |
+
Mage::helper('xpaymentsconnector')->setIframePlaceDisplaySettings();
|
522 |
}
|
523 |
|
524 |
/**
|
527 |
*/
|
528 |
public function postdispatchSaveShippingMethod($observer)
|
529 |
{
|
530 |
+
$xpHelper = Mage::helper('xpaymentsconnector');
|
531 |
+
$isPaymentPlaceDisplayFlag = $xpHelper->isIframePaymentPlaceDisplay();
|
532 |
if (!$isPaymentPlaceDisplayFlag) {
|
533 |
+
$unsetParams = array('token');
|
534 |
+
$xpHelper->unsetXpaymentPrepareOrder($unsetParams);
|
535 |
}
|
536 |
}
|
537 |
|
539 |
{
|
540 |
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
541 |
$paymentMethodCode = $quote->getPayment()->getMethodInstance()->getCode();
|
542 |
+
$xpaymentPaymentCode = Mage::getModel('xpaymentsconnector/payment_cc')->getCode();
|
543 |
+
$xpHelper = Mage::helper('xpaymentsconnector');
|
544 |
|
545 |
+
$isXpayments = $xpHelper->isXpaymentsMethod($paymentMethodCode);
|
546 |
if ($isXpayments) {
|
547 |
+
$xpHelper->prepareOrderKey();
|
548 |
}
|
549 |
if ($paymentMethodCode == $xpaymentPaymentCode) {
|
550 |
+
$saveCard = Mage::app()->getRequest()->getPost('savecard');
|
551 |
if ($saveCard) {
|
552 |
+
Mage::getSingleton('checkout/session')->setData('user_card_save', $saveCard);
|
553 |
}
|
554 |
} else {
|
555 |
+
Mage::getSingleton('checkout/session')->unsetData('user_card_save');
|
556 |
}
|
557 |
}
|
558 |
|
562 |
*/
|
563 |
public function preDispatchCartIndex($observer)
|
564 |
{
|
565 |
+
$unsetXpPrepareOrder = Mage::app()->getRequest()->getParam('unset_xp_prepare_order');
|
566 |
+
$xpHelper = Mage::helper('xpaymentsconnector');
|
567 |
if (isset($unsetXpPrepareOrder)) {
|
568 |
+
$unsetParams = array('token');
|
569 |
+
$xpHelper->unsetXpaymentPrepareOrder($unsetParams);
|
570 |
}
|
571 |
|
|
|
572 |
//set recurring product discount
|
573 |
+
$xpHelper->setRecurringProductDiscount();
|
574 |
|
575 |
}
|
576 |
|
585 |
|
586 |
if(!empty($xpTransactionData)
|
587 |
&& isset($xpTransactionData['xpaction'])
|
588 |
+
&& isset($xpTransactionData['xpc_txnid'])
|
589 |
+
&& isset($xpTransactionData['transaction_amount'])
|
590 |
){
|
591 |
|
592 |
+
$xpaymentModel = Mage::getModel('xpaymentsconnector/payment_cc');
|
593 |
$data = array(
|
594 |
+
'txnId' => $xpTransactionData['xpc_txnid'],
|
595 |
+
'amount' => number_format($xpTransactionData['transaction_amount'], 2, '.', ''),
|
596 |
);
|
597 |
$result = array();
|
598 |
switch ($xpTransactionData['xpaction']) {
|
608 |
}
|
609 |
|
610 |
if(empty($result['error_message'])){
|
611 |
+
$message = Mage::helper('xpaymentsconnector')->__("Transaction '%s' to order (%s) was successful!",
|
612 |
$xpTransactionData['xpaction'],
|
613 |
$xpTransactionData['orderid']);
|
614 |
Mage::getSingleton('adminhtml/session')->addSuccess($message);
|
app/code/community/Cdev/XPaymentsConnector/Model/Payment/Cc.php
CHANGED
@@ -90,7 +90,7 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
90 |
// Root-level tag for all XML messages
|
91 |
const TAG_ROOT = 'data';
|
92 |
|
93 |
-
// Value of the
|
94 |
const TYPE_CELL = 'cell';
|
95 |
|
96 |
// Payment statuses
|
@@ -177,6 +177,10 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
177 |
*/
|
178 |
protected $_order = null;
|
179 |
|
|
|
|
|
|
|
|
|
180 |
/**
|
181 |
* Get order
|
182 |
*
|
@@ -251,12 +255,12 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
251 |
public function canCapture()
|
252 |
{
|
253 |
$order = $this->getOrder();
|
254 |
-
list($status, $response) = $this->requestPaymentInfo($order->getData(
|
255 |
if($status){
|
256 |
-
if($response[
|
257 |
return false;
|
258 |
}
|
259 |
-
elseif($response[
|
260 |
return true;
|
261 |
}
|
262 |
}else{
|
@@ -501,7 +505,7 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
501 |
'confId' => intval($this->getPaymentConfiguration()->getData('confid')),
|
502 |
'refId' => $refId,
|
503 |
'cart' => $cart,
|
504 |
-
'returnUrl' => Mage::getUrl('xpaymentsconnector/processing/
|
505 |
'callbackUrl' => Mage::getUrl('xpaymentsconnector/processing/callback', array('order_id' => $refId,'_secure' => true)),
|
506 |
'template' => 'default',
|
507 |
'saveCard' => 'Y',
|
@@ -522,7 +526,11 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
522 |
Mage::getSingleton('checkout/session')->setData('xpayments_token', $response['token']);
|
523 |
}
|
524 |
|
525 |
-
|
|
|
|
|
|
|
|
|
526 |
}
|
527 |
|
528 |
/**
|
@@ -544,17 +552,17 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
544 |
$data = array(
|
545 |
'txnId' => $txn_id,
|
546 |
);
|
547 |
-
$infoClass =
|
548 |
}else{
|
549 |
$data = array(
|
550 |
'txnId' => $txn_id,
|
551 |
'refresh' => $refresh ? 1 : 0
|
552 |
);
|
553 |
-
$infoClass =
|
554 |
}
|
555 |
|
556 |
list($status, $response) = $this->request('payment', $infoClass, $data);
|
557 |
-
$checkResponse = (!$withAdditionalInfo)?$response:$response[
|
558 |
|
559 |
if ($status) {
|
560 |
if (!is_array($response) || !isset($checkResponse['status'])) {
|
@@ -884,11 +892,11 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
884 |
*/
|
885 |
protected function isForceAuth()
|
886 |
{
|
887 |
-
|
888 |
-
$isRecurrnigProduct =
|
889 |
-
if ($isRecurrnigProduct) {
|
890 |
-
$useStartDateParam =
|
891 |
-
if ($useStartDateParam[
|
892 |
$useInitialFeeAuthorize = Mage::getStoreConfig('payment/xpayments/use_initialfee_authorize');
|
893 |
return (bool)$useInitialFeeAuthorize;
|
894 |
}
|
@@ -1341,9 +1349,9 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1341 |
{
|
1342 |
$xPaymentDataResponse = array();
|
1343 |
$checkoutData = Mage::getSingleton('checkout/session');
|
1344 |
-
$refId = Mage::helper(
|
1345 |
|
1346 |
-
$xPaymentDataResponse[
|
1347 |
$result = array();
|
1348 |
$cart = array();
|
1349 |
|
@@ -1371,8 +1379,8 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1371 |
list($status, $response) = $this->request('payment', 'init', $sendData);
|
1372 |
|
1373 |
|
1374 |
-
$xPaymentDataResponse[
|
1375 |
-
$xPaymentDataResponse[
|
1376 |
|
1377 |
|
1378 |
//****************stop*****************//
|
@@ -1380,12 +1388,12 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1380 |
|
1381 |
if (!$status || (!isset($response['token']) || !is_string($response['token']))) {
|
1382 |
$result['success'] = false;
|
1383 |
-
$result['error_message'] = Mage::helper('core')->__(
|
1384 |
return $result;
|
1385 |
}
|
1386 |
|
1387 |
|
1388 |
-
$checkoutData->setData(
|
1389 |
|
1390 |
if ($status) {
|
1391 |
Mage::getSingleton('checkout/session')->setData('xpayments_token', $response['token']);
|
@@ -1398,56 +1406,61 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1398 |
|
1399 |
|
1400 |
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
|
|
1401 |
if(is_null($paymentCardNumber)){
|
1402 |
-
$paymentCardNumber = $quote->getPayment()->getData(
|
1403 |
}
|
1404 |
if(is_null($grandTotal)){
|
1405 |
$grandTotal = $quote->getGrandTotal();
|
1406 |
}
|
1407 |
|
1408 |
if(is_null($cardData)){
|
1409 |
-
$cardData = Mage::getModel(
|
1410 |
if($cardData){
|
1411 |
$cardData = $cardData->getData();
|
1412 |
}
|
1413 |
}
|
1414 |
|
1415 |
$data = array(
|
1416 |
-
'txnId' => $cardData[
|
1417 |
'amount' => number_format($grandTotal, 2, '.','')
|
1418 |
);
|
1419 |
$order = NULL;
|
|
|
1420 |
if(!is_null($order_id)){
|
1421 |
$order = Mage::getModel('sales/order')->load($order_id);
|
1422 |
$orderIcrementId = $order->getIncrementId();
|
1423 |
$data['description'] = 'Order #' . $orderIcrementId;
|
1424 |
}else{
|
1425 |
-
$xpOrderKey =
|
|
|
|
|
|
|
1426 |
$data['description'] = 'Order(i-frame) #' . $xpOrderKey;
|
1427 |
}
|
1428 |
|
1429 |
|
1430 |
list($status, $response) = $this->request('payment', 'recharge', $data);
|
1431 |
|
1432 |
-
$xPaymentDataResponse[
|
1433 |
-
$xPaymentDataResponse[
|
1434 |
|
1435 |
if($order){
|
1436 |
-
$order->setData(
|
1437 |
$order->save();
|
1438 |
|
1439 |
if ($status && (!isset($response['transaction_id']) || !is_string($response['transaction_id']))) {
|
1440 |
-
|
1441 |
$order->cancel();
|
1442 |
-
$errorMessage =
|
1443 |
$order->addStatusToHistory(
|
1444 |
$order::STATE_CANCELED,
|
1445 |
$errorMessage
|
1446 |
);
|
1447 |
|
1448 |
$order->save();
|
1449 |
-
$result[
|
1450 |
-
$result[
|
1451 |
|
1452 |
return $result;
|
1453 |
}
|
@@ -1455,7 +1468,7 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1455 |
}
|
1456 |
|
1457 |
|
1458 |
-
$xPaymentDataResponse[
|
1459 |
|
1460 |
return $xPaymentDataResponse;
|
1461 |
|
@@ -1474,19 +1487,21 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1474 |
*/
|
1475 |
protected function iframePrepareCart($checkoutData,$customer,$isCardAuthorizePayment = false)
|
1476 |
{
|
1477 |
-
$
|
1478 |
-
$
|
|
|
1479 |
|
1480 |
$billingAddress = $checkoutData->getQuote()->getBillingAddress();
|
1481 |
$shippingAddress = $checkoutData->getQuote()->getShippingAddress();
|
1482 |
$quote = $checkoutData->getQuote();
|
1483 |
$result = array();
|
1484 |
/*initial fee check*/
|
1485 |
-
$
|
|
|
1486 |
$forceTransactionType = ($this->isForceAuth()) ? 'A' : 'S';
|
1487 |
$minimalPayment = false;
|
1488 |
-
$cardAuthorizeAmount = 0;
|
1489 |
|
|
|
1490 |
$totals = $quote->getTotals(); //Total object
|
1491 |
|
1492 |
$totalCost = 0;
|
@@ -1494,25 +1509,37 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1494 |
$tax = 0;
|
1495 |
$shipping = 0;
|
1496 |
$description = 'Order(i-frame) #' . $refId;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1497 |
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
$
|
|
|
1502 |
|
1503 |
-
$
|
1504 |
-
$
|
|
|
1505 |
|
1506 |
-
} else {
|
1507 |
-
$tax = $quoteItem->getData("tax_amount");
|
1508 |
-
$shipping = $quoteItem->getData("shipping_amount");
|
1509 |
-
$totalCost = $quoteItem->getData("nominal_row_total");
|
1510 |
-
$discount = abs($quoteItem->getData("discount_amount"));
|
1511 |
}
|
1512 |
|
1513 |
} elseif ($isCardAuthorizePayment) {
|
1514 |
|
1515 |
-
$totalCost = floatval(Mage::getStoreConfig(
|
1516 |
|
1517 |
} else {
|
1518 |
|
@@ -1582,10 +1609,10 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1582 |
$addressIndex = $prefix . 'Address';
|
1583 |
foreach ($addressFields as $field => $fn) {
|
1584 |
$result[$addressIndex][$field] = $data->getData($fn);
|
1585 |
-
if(($field ==
|
1586 |
$result[$addressIndex][$field] = $customer->getData($field);
|
1587 |
}
|
1588 |
-
if(($prefix ==
|
1589 |
$shippingIsEmpty = false;
|
1590 |
}
|
1591 |
|
@@ -1605,28 +1632,50 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1605 |
}
|
1606 |
|
1607 |
if($shippingIsEmpty){
|
1608 |
-
$result[
|
1609 |
}
|
1610 |
|
1611 |
$cartItems = $quote->getAllVisibleItems();
|
1612 |
|
1613 |
// Set products
|
1614 |
-
|
1615 |
-
$
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1625 |
}
|
1626 |
|
1627 |
if($isCardAuthorizePayment){
|
1628 |
$result['items'][] = array(
|
1629 |
-
'sku' =>
|
1630 |
'name' => 'Card Authorize',
|
1631 |
'price' => number_format($totalCost, 2, '.',''),
|
1632 |
'quantity' => intval(1),
|
@@ -1653,32 +1702,29 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1653 |
|
1654 |
if (
|
1655 |
$status
|
1656 |
-
&& in_array($response[
|
1657 |
) {
|
1658 |
// TODO - save message - $response['message']
|
1659 |
-
|
1660 |
// TODO - process faud status
|
1661 |
-
/*
|
1662 |
-
if ($response['isFraudStatus']) {
|
1663 |
-
}
|
1664 |
-
*/
|
1665 |
-
/**/
|
1666 |
-
if ($response["payment"]['amount'] != number_format($order->getGrandTotal(), 2, '.','') && $checkOrderAmount) {
|
1667 |
|
|
|
|
|
|
|
1668 |
// Total wrong
|
1669 |
Mage::log(
|
1670 |
'Order total amount doesn\'t match: Order total = ' . number_format($order->getGrandTotal(), 2, '.','')
|
1671 |
-
. ', X-Payments amount = ' . $response[
|
1672 |
Zend_Log::ERR
|
1673 |
);
|
1674 |
Mage::throwException('Transaction amount doesn\'t match.');
|
1675 |
|
1676 |
-
} elseif ($response[
|
1677 |
-
|
|
|
1678 |
// Currency wrong
|
1679 |
Mage::log(
|
1680 |
'Order currency doesn\'t match: Order currency = ' . $this->getCurrency()
|
1681 |
-
. ', X-Payments currency = ' . $response[
|
1682 |
Zend_Log::ERR
|
1683 |
);
|
1684 |
Mage::throwException('Transaction currency doesn\'t match.');
|
@@ -1687,17 +1733,14 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1687 |
|
1688 |
$order->getPayment()->setTransactionId($txnid);
|
1689 |
|
1690 |
-
$currentTransaction = end($response[
|
1691 |
-
$order->getPayment()->setLastTransId($currentTransaction[
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
|
1696 |
-
if (isset($response[
|
1697 |
-
$order->getPayment()->setCcAvsStatus($response[
|
1698 |
}
|
1699 |
|
1700 |
-
if ($response[
|
1701 |
$order->setState(
|
1702 |
Mage_Sales_Model_Order::STATE_PROCESSING,
|
1703 |
(bool)$order->getPayment()->getMethodInstance()->getConfigData('order_status'),
|
@@ -1715,10 +1758,10 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1715 |
$order->save();
|
1716 |
$order->sendNewOrderEmail();
|
1717 |
}
|
1718 |
-
$result[
|
1719 |
return $result;
|
1720 |
}else{
|
1721 |
-
Mage::helper(
|
1722 |
$order->cancel();
|
1723 |
$order->addStatusToHistory(
|
1724 |
$order::STATE_CANCELED,
|
@@ -1726,12 +1769,12 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1726 |
);
|
1727 |
$order->save();
|
1728 |
|
1729 |
-
$result[
|
1730 |
-
if(!empty($response[
|
1731 |
-
$result[
|
1732 |
}else{
|
1733 |
$transactionStatusLabel = $this->getTransactionStatusLabels();
|
1734 |
-
$result[
|
1735 |
}
|
1736 |
|
1737 |
return $result;
|
@@ -1747,20 +1790,23 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1747 |
*/
|
1748 |
public function saveUserCard($cardData,$usageType = Cdev_XPaymentsConnector_Model_Usercards::SIMPLE_CARD){
|
1749 |
|
1750 |
-
|
1751 |
-
|
|
|
|
|
1752 |
try
|
1753 |
{
|
1754 |
-
if (
|
1755 |
-
$usercards = Mage::getModel(
|
1756 |
$usercards->setData(array(
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
);
|
1763 |
-
|
|
|
1764 |
}
|
1765 |
}
|
1766 |
catch(Exception $e)
|
@@ -1772,7 +1818,7 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1772 |
}
|
1773 |
|
1774 |
public function authorizedTransactionRequest($action,$data){
|
1775 |
-
$data[
|
1776 |
list($status, $response) = $this->request('payment', $action, $data);
|
1777 |
|
1778 |
//****************stop*****************//
|
@@ -1800,7 +1846,7 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1800 |
|
1801 |
$order = $this->getOrder();
|
1802 |
$data = array(
|
1803 |
-
'txnId' => $order->getData(
|
1804 |
'amount' => number_format($amount, 2, '.', ''),
|
1805 |
);
|
1806 |
|
@@ -1829,7 +1875,7 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1829 |
$order = $this->getOrder();
|
1830 |
/*processing during capture invoice*/
|
1831 |
$data = array(
|
1832 |
-
'txnId' => $order->getData(
|
1833 |
'amount' => number_format($amount, 2, '.', ''),
|
1834 |
);
|
1835 |
|
@@ -1857,21 +1903,67 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1857 |
*/
|
1858 |
public function submitRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile, Mage_Payment_Model_Info $paymentInfo)
|
1859 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1860 |
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
1861 |
-
if($useIframe){
|
1862 |
-
$payDeferredSubscription = Mage::helper("xpaymentsconnector")->payDeferredSubscription($profile);
|
1863 |
-
if(!$payDeferredSubscription){
|
1864 |
-
$this->createFirstRecurringOrder($profile);
|
1865 |
-
}
|
1866 |
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1871 |
|
1872 |
-
|
1873 |
-
|
|
|
|
|
|
|
|
|
1874 |
}
|
|
|
|
|
|
|
|
|
1875 |
}
|
1876 |
|
1877 |
}
|
@@ -1919,10 +2011,10 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1919 |
*/
|
1920 |
public function getTransactionStatusLabels(){
|
1921 |
$statuses = array(
|
1922 |
-
self::NEW_STATUS =>
|
1923 |
-
self::AUTH_STATUS =>
|
1924 |
-
self::DECLINED_STATUS =>
|
1925 |
-
self::CHARGED_STATUS =>
|
1926 |
);
|
1927 |
return $statuses;
|
1928 |
}
|
@@ -1931,20 +2023,32 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1931 |
*
|
1932 |
* @param Mage_Payment_Model_Recurring_Profile $profile
|
1933 |
*/
|
1934 |
-
public function createFirstRecurringOrder(Mage_Payment_Model_Recurring_Profile $profile)
|
1935 |
-
|
1936 |
-
$
|
|
|
|
|
1937 |
|
1938 |
/*update order by card data*/
|
1939 |
-
$order =
|
1940 |
-
$order->setData(
|
1941 |
$order->save();
|
|
|
1942 |
|
1943 |
-
$profile->setReferenceId($cardData[
|
1944 |
-
|
|
|
|
|
|
|
|
|
1945 |
|
1946 |
-
|
1947 |
-
|
|
|
|
|
|
|
|
|
|
|
1948 |
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
|
1949 |
} else {
|
1950 |
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
|
@@ -1952,12 +2056,18 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
|
|
1952 |
$newTransactionDate = new Zend_Date(time());
|
1953 |
$profile->setXpSuccessTransactionDate($newTransactionDate->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
|
1954 |
$profile->setXpCountSuccessTransaction(1);
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
|
|
|
|
1958 |
|
1959 |
}
|
|
|
|
|
|
|
1960 |
return $profile;
|
|
|
1961 |
}
|
1962 |
|
1963 |
}
|
90 |
// Root-level tag for all XML messages
|
91 |
const TAG_ROOT = 'data';
|
92 |
|
93 |
+
// Value of the 'type' attribute for list items in XML
|
94 |
const TYPE_CELL = 'cell';
|
95 |
|
96 |
// Payment statuses
|
177 |
*/
|
178 |
protected $_order = null;
|
179 |
|
180 |
+
public $_currentProfileId = null;
|
181 |
+
public $firstTransactionSuccess = true;
|
182 |
+
|
183 |
+
|
184 |
/**
|
185 |
* Get order
|
186 |
*
|
255 |
public function canCapture()
|
256 |
{
|
257 |
$order = $this->getOrder();
|
258 |
+
list($status, $response) = $this->requestPaymentInfo($order->getData('xpc_txnid'));
|
259 |
if($status){
|
260 |
+
if($response['status'] == self::CHARGED_STATUS){
|
261 |
return false;
|
262 |
}
|
263 |
+
elseif($response['status'] == self::AUTH_ACTION){
|
264 |
return true;
|
265 |
}
|
266 |
}else{
|
505 |
'confId' => intval($this->getPaymentConfiguration()->getData('confid')),
|
506 |
'refId' => $refId,
|
507 |
'cart' => $cart,
|
508 |
+
'returnUrl' => Mage::getUrl('xpaymentsconnector/processing/iframereturn', array('order_id' => $refId,'_secure' => true)),
|
509 |
'callbackUrl' => Mage::getUrl('xpaymentsconnector/processing/callback', array('order_id' => $refId,'_secure' => true)),
|
510 |
'template' => 'default',
|
511 |
'saveCard' => 'Y',
|
526 |
Mage::getSingleton('checkout/session')->setData('xpayments_token', $response['token']);
|
527 |
}
|
528 |
|
529 |
+
$xPaymentDataResponse = array();
|
530 |
+
$xPaymentDataResponse['status'] = $status;
|
531 |
+
$xPaymentDataResponse['response'] = $response;
|
532 |
+
|
533 |
+
return $xPaymentDataResponse;
|
534 |
}
|
535 |
|
536 |
/**
|
552 |
$data = array(
|
553 |
'txnId' => $txn_id,
|
554 |
);
|
555 |
+
$infoClass = 'get_additional_info';
|
556 |
}else{
|
557 |
$data = array(
|
558 |
'txnId' => $txn_id,
|
559 |
'refresh' => $refresh ? 1 : 0
|
560 |
);
|
561 |
+
$infoClass = 'get_info';
|
562 |
}
|
563 |
|
564 |
list($status, $response) = $this->request('payment', $infoClass, $data);
|
565 |
+
$checkResponse = (!$withAdditionalInfo)?$response:$response['payment'];
|
566 |
|
567 |
if ($status) {
|
568 |
if (!is_array($response) || !isset($checkResponse['status'])) {
|
892 |
*/
|
893 |
protected function isForceAuth()
|
894 |
{
|
895 |
+
$xpHelper = Mage::helper('xpaymentsconnector');
|
896 |
+
$isRecurrnigProduct = $xpHelper->checkIssetRecurringOrder();
|
897 |
+
if ($isRecurrnigProduct['isset']) {
|
898 |
+
$useStartDateParam = $xpHelper->checkStartDateData();
|
899 |
+
if ($useStartDateParam['total_min_amount']) {
|
900 |
$useInitialFeeAuthorize = Mage::getStoreConfig('payment/xpayments/use_initialfee_authorize');
|
901 |
return (bool)$useInitialFeeAuthorize;
|
902 |
}
|
1349 |
{
|
1350 |
$xPaymentDataResponse = array();
|
1351 |
$checkoutData = Mage::getSingleton('checkout/session');
|
1352 |
+
$refId = Mage::helper('xpaymentsconnector')->getOrderKey();
|
1353 |
|
1354 |
+
$xPaymentDataResponse['order_refid'] = $refId;
|
1355 |
$result = array();
|
1356 |
$cart = array();
|
1357 |
|
1379 |
list($status, $response) = $this->request('payment', 'init', $sendData);
|
1380 |
|
1381 |
|
1382 |
+
$xPaymentDataResponse['status'] = $status;
|
1383 |
+
$xPaymentDataResponse['response'] = $response;
|
1384 |
|
1385 |
|
1386 |
//****************stop*****************//
|
1388 |
|
1389 |
if (!$status || (!isset($response['token']) || !is_string($response['token']))) {
|
1390 |
$result['success'] = false;
|
1391 |
+
$result['error_message'] = Mage::helper('core')->__('Transaction token can not be found or has wrong type');
|
1392 |
return $result;
|
1393 |
}
|
1394 |
|
1395 |
|
1396 |
+
$checkoutData->setData('xpayment',$xPaymentDataResponse);
|
1397 |
|
1398 |
if ($status) {
|
1399 |
Mage::getSingleton('checkout/session')->setData('xpayments_token', $response['token']);
|
1406 |
|
1407 |
|
1408 |
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
1409 |
+
$xpHelper = Mage::helper('xpaymentsconnector');
|
1410 |
if(is_null($paymentCardNumber)){
|
1411 |
+
$paymentCardNumber = $quote->getPayment()->getData('xp_payment_card');
|
1412 |
}
|
1413 |
if(is_null($grandTotal)){
|
1414 |
$grandTotal = $quote->getGrandTotal();
|
1415 |
}
|
1416 |
|
1417 |
if(is_null($cardData)){
|
1418 |
+
$cardData = Mage::getModel('xpaymentsconnector/usercards')->load($paymentCardNumber);
|
1419 |
if($cardData){
|
1420 |
$cardData = $cardData->getData();
|
1421 |
}
|
1422 |
}
|
1423 |
|
1424 |
$data = array(
|
1425 |
+
'txnId' => $cardData['txnId'],
|
1426 |
'amount' => number_format($grandTotal, 2, '.','')
|
1427 |
);
|
1428 |
$order = NULL;
|
1429 |
+
|
1430 |
if(!is_null($order_id)){
|
1431 |
$order = Mage::getModel('sales/order')->load($order_id);
|
1432 |
$orderIcrementId = $order->getIncrementId();
|
1433 |
$data['description'] = 'Order #' . $orderIcrementId;
|
1434 |
}else{
|
1435 |
+
$xpOrderKey = $xpHelper->getOrderKey();
|
1436 |
+
if(!$xpOrderKey){
|
1437 |
+
$xpOrderKey = $xpHelper->prepareSimpleOrderKey();
|
1438 |
+
}
|
1439 |
$data['description'] = 'Order(i-frame) #' . $xpOrderKey;
|
1440 |
}
|
1441 |
|
1442 |
|
1443 |
list($status, $response) = $this->request('payment', 'recharge', $data);
|
1444 |
|
1445 |
+
$xPaymentDataResponse['status'] = $status;
|
1446 |
+
$xPaymentDataResponse['response'] = $response;
|
1447 |
|
1448 |
if($order){
|
1449 |
+
$order->setData('xp_card_data',serialize($cardData));
|
1450 |
$order->save();
|
1451 |
|
1452 |
if ($status && (!isset($response['transaction_id']) || !is_string($response['transaction_id']))) {
|
1453 |
+
$xpHelper->unsetXpaymentPrepareOrder();
|
1454 |
$order->cancel();
|
1455 |
+
$errorMessage = $xpHelper->__('Transaction token can not found or has wrong type. The order has been canceled.');
|
1456 |
$order->addStatusToHistory(
|
1457 |
$order::STATE_CANCELED,
|
1458 |
$errorMessage
|
1459 |
);
|
1460 |
|
1461 |
$order->save();
|
1462 |
+
$result['success'] = false;
|
1463 |
+
$result['error_message'] = $errorMessage;
|
1464 |
|
1465 |
return $result;
|
1466 |
}
|
1468 |
}
|
1469 |
|
1470 |
|
1471 |
+
$xPaymentDataResponse['success'] = true;
|
1472 |
|
1473 |
return $xPaymentDataResponse;
|
1474 |
|
1487 |
*/
|
1488 |
protected function iframePrepareCart($checkoutData,$customer,$isCardAuthorizePayment = false)
|
1489 |
{
|
1490 |
+
$xpHelper = Mage::helper('xpaymentsconnector');
|
1491 |
+
$refId = $xpHelper->getOrderKey();
|
1492 |
+
$customerEmail = '';
|
1493 |
|
1494 |
$billingAddress = $checkoutData->getQuote()->getBillingAddress();
|
1495 |
$shippingAddress = $checkoutData->getQuote()->getShippingAddress();
|
1496 |
$quote = $checkoutData->getQuote();
|
1497 |
$result = array();
|
1498 |
/*initial fee check*/
|
1499 |
+
$issetRecurringProduct = $xpHelper->checkIssetRecurringOrder();
|
1500 |
+
|
1501 |
$forceTransactionType = ($this->isForceAuth()) ? 'A' : 'S';
|
1502 |
$minimalPayment = false;
|
|
|
1503 |
|
1504 |
+
$quote->collectTotals();
|
1505 |
$totals = $quote->getTotals(); //Total object
|
1506 |
|
1507 |
$totalCost = 0;
|
1509 |
$tax = 0;
|
1510 |
$shipping = 0;
|
1511 |
$description = 'Order(i-frame) #' . $refId;
|
1512 |
+
$currentProduct = false;
|
1513 |
+
$recurringProfile = false;
|
1514 |
+
$issetSimpleProducts = $xpHelper->checkIssetSimpleOrder();
|
1515 |
+
|
1516 |
+
if ($issetRecurringProduct['isset'] && !$issetSimpleProducts) {
|
1517 |
+
$currentProduct = $issetRecurringProduct['quote_item']->getProduct();
|
1518 |
+
$quoteItem = $quote->getItemByProduct($currentProduct);
|
1519 |
+
$useStartDateParams = $xpHelper->checkStartDateDataByProduct($currentProduct,$quoteItem);
|
1520 |
+
$recurringProfile = $currentProduct->getRecurringProfile();
|
1521 |
+
if ($useStartDateParams[$currentProduct->getId()]['success']) {
|
1522 |
+
$minimalPayment = $useStartDateParams[$currentProduct->getId()]['minimal_payment_amount'];
|
1523 |
+
$tax = 0;
|
1524 |
+
if(!empty($recurringProfile['init_amount'])){
|
1525 |
+
$tax = $issetRecurringProduct['quote_item']->getData('initialfee_tax_amount');
|
1526 |
+
}
|
1527 |
|
1528 |
+
$totalCost = $minimalPayment + $tax;
|
1529 |
+
} else {
|
1530 |
+
$initialFeeAmount = $issetRecurringProduct['quote_item']->getData('initialfee_tax_amount');
|
1531 |
+
$mainTax = $issetRecurringProduct['quote_item']->getData('tax_amount');
|
1532 |
+
$tax = $mainTax + $initialFeeAmount;
|
1533 |
|
1534 |
+
$shipping = $issetRecurringProduct['quote_item']->getData('shipping_amount');
|
1535 |
+
$totalCost = $issetRecurringProduct['quote_item']->getData('nominal_row_total');
|
1536 |
+
$discount = abs($issetRecurringProduct['quote_item']->getData('discount_amount'));
|
1537 |
|
|
|
|
|
|
|
|
|
|
|
1538 |
}
|
1539 |
|
1540 |
} elseif ($isCardAuthorizePayment) {
|
1541 |
|
1542 |
+
$totalCost = floatval(Mage::getStoreConfig('xpaymentsconnector/settings/xpay_minimum_payment_recurring_amount'));
|
1543 |
|
1544 |
} else {
|
1545 |
|
1609 |
$addressIndex = $prefix . 'Address';
|
1610 |
foreach ($addressFields as $field => $fn) {
|
1611 |
$result[$addressIndex][$field] = $data->getData($fn);
|
1612 |
+
if(($field == 'firstname' || $field == 'lastname') && $isCardAuthorizePayment){
|
1613 |
$result[$addressIndex][$field] = $customer->getData($field);
|
1614 |
}
|
1615 |
+
if(($prefix == 'shipping') && $result[$addressIndex][$field]){
|
1616 |
$shippingIsEmpty = false;
|
1617 |
}
|
1618 |
|
1632 |
}
|
1633 |
|
1634 |
if($shippingIsEmpty){
|
1635 |
+
$result['shippingAddress'] = $result['billingAddress'];
|
1636 |
}
|
1637 |
|
1638 |
$cartItems = $quote->getAllVisibleItems();
|
1639 |
|
1640 |
// Set products
|
1641 |
+
if ($issetRecurringProduct['isset'] && !$issetSimpleProducts) {
|
1642 |
+
if($currentProduct){
|
1643 |
+
$quantity = $issetRecurringProduct['quote_item']->getQty();
|
1644 |
+
$recurringPrice = $currentProduct->getPrice();
|
1645 |
+
if(!empty($recurringProfile['init_amount'])){
|
1646 |
+
$xpRecurringInitialFee = $issetRecurringProduct['quote_item']->getXpRecurringInitialFee();
|
1647 |
+
$recurringPrice += $xpRecurringInitialFee/$quantity;
|
1648 |
+
}
|
1649 |
+
|
1650 |
+
$price = ($minimalPayment) ? $minimalPayment/$quantity : $recurringPrice;
|
1651 |
+
$result['items'][] = array(
|
1652 |
+
'sku' => $currentProduct->getData('sku'),
|
1653 |
+
'name' => $currentProduct->getData('name'),
|
1654 |
+
'price' => number_format($price, 2, '.',''),
|
1655 |
+
'quantity' => intval($quantity),
|
1656 |
+
);
|
1657 |
+
}
|
1658 |
+
}else{
|
1659 |
+
foreach ($cartItems as $item) {
|
1660 |
+
if(!$item->getIsNominal()){
|
1661 |
+
$productId = $item->getProductId();
|
1662 |
+
$product = Mage::getModel('catalog/product')->load($productId);
|
1663 |
+
$price = $product->getPrice();
|
1664 |
+
$quantity = $item->getQty();
|
1665 |
+
|
1666 |
+
$result['items'][] = array(
|
1667 |
+
'sku' => $product->getData('sku'),
|
1668 |
+
'name' => $product->getData('name'),
|
1669 |
+
'price' => number_format($price, 2, '.',''),
|
1670 |
+
'quantity' => intval($quantity),
|
1671 |
+
);
|
1672 |
+
}
|
1673 |
+
}
|
1674 |
}
|
1675 |
|
1676 |
if($isCardAuthorizePayment){
|
1677 |
$result['items'][] = array(
|
1678 |
+
'sku' => '000000',
|
1679 |
'name' => 'Card Authorize',
|
1680 |
'price' => number_format($totalCost, 2, '.',''),
|
1681 |
'quantity' => intval(1),
|
1702 |
|
1703 |
if (
|
1704 |
$status
|
1705 |
+
&& in_array($response['payment']['status'], array(self::AUTH_STATUS, self::CHARGED_STATUS))
|
1706 |
) {
|
1707 |
// TODO - save message - $response['message']
|
|
|
1708 |
// TODO - process faud status
|
|
|
|
|
|
|
|
|
|
|
|
|
1709 |
|
1710 |
+
if ($response['payment']['amount'] != number_format($order->getGrandTotal(), 2, '.','') && $checkOrderAmount) {
|
1711 |
+
$order->cancel();
|
1712 |
+
$order->save();
|
1713 |
// Total wrong
|
1714 |
Mage::log(
|
1715 |
'Order total amount doesn\'t match: Order total = ' . number_format($order->getGrandTotal(), 2, '.','')
|
1716 |
+
. ', X-Payments amount = ' . $response['payment']['amount'],
|
1717 |
Zend_Log::ERR
|
1718 |
);
|
1719 |
Mage::throwException('Transaction amount doesn\'t match.');
|
1720 |
|
1721 |
+
} elseif ($response['payment']['currency'] != $this->getCurrency()) {
|
1722 |
+
$order->cancel();
|
1723 |
+
$order->save();
|
1724 |
// Currency wrong
|
1725 |
Mage::log(
|
1726 |
'Order currency doesn\'t match: Order currency = ' . $this->getCurrency()
|
1727 |
+
. ', X-Payments currency = ' . $response['payment']['currency'],
|
1728 |
Zend_Log::ERR
|
1729 |
);
|
1730 |
Mage::throwException('Transaction currency doesn\'t match.');
|
1733 |
|
1734 |
$order->getPayment()->setTransactionId($txnid);
|
1735 |
|
1736 |
+
$currentTransaction = end($response['transactions']);
|
1737 |
+
$order->getPayment()->setLastTransId($currentTransaction['txnid']);
|
|
|
|
|
|
|
1738 |
|
1739 |
+
if (isset($response['payment']['advinfo']) && isset($response['payment']['advinfo']['AVS'])) {
|
1740 |
+
$order->getPayment()->setCcAvsStatus($response['payment']['advinfo']['AVS']);
|
1741 |
}
|
1742 |
|
1743 |
+
if ($response['payment']['status'] == self::AUTH_ACTION) {
|
1744 |
$order->setState(
|
1745 |
Mage_Sales_Model_Order::STATE_PROCESSING,
|
1746 |
(bool)$order->getPayment()->getMethodInstance()->getConfigData('order_status'),
|
1758 |
$order->save();
|
1759 |
$order->sendNewOrderEmail();
|
1760 |
}
|
1761 |
+
$result['success'] = true;
|
1762 |
return $result;
|
1763 |
}else{
|
1764 |
+
Mage::helper('xpaymentsconnector')->unsetXpaymentPrepareOrder();
|
1765 |
$order->cancel();
|
1766 |
$order->addStatusToHistory(
|
1767 |
$order::STATE_CANCELED,
|
1769 |
);
|
1770 |
$order->save();
|
1771 |
|
1772 |
+
$result['success'] = false;
|
1773 |
+
if(!empty($response['payment']['error_message'])){
|
1774 |
+
$result['error_message'] = Mage::helper('xpaymentsconnector')->__('%s. The order has been canceled.',$response['payment']['error_message']);
|
1775 |
}else{
|
1776 |
$transactionStatusLabel = $this->getTransactionStatusLabels();
|
1777 |
+
$result['error_message'] = Mage::helper('xpaymentsconnector')->__('Transaction status is "%s". The order has been canceled.',$transactionStatusLabel[$response['payment']['status']]);
|
1778 |
}
|
1779 |
|
1780 |
return $result;
|
1790 |
*/
|
1791 |
public function saveUserCard($cardData,$usageType = Cdev_XPaymentsConnector_Model_Usercards::SIMPLE_CARD){
|
1792 |
|
1793 |
+
$customerSession = Mage::getSingleton('customer/session');
|
1794 |
+
$xpHelper = Mage::helper('xpaymentsconnector');
|
1795 |
+
if($customerSession->isLoggedIn()){
|
1796 |
+
$customer = $customerSession->getCustomer();
|
1797 |
try
|
1798 |
{
|
1799 |
+
if ($xpHelper->isNeedToSaveUserCard()) {
|
1800 |
+
$usercards = Mage::getModel('xpaymentsconnector/usercards');
|
1801 |
$usercards->setData(array(
|
1802 |
+
'user_id' => $customer->getId(),
|
1803 |
+
'txnId' => $cardData['txnId'],
|
1804 |
+
'last_4_cc_num' => $cardData['last_4_cc_num'],
|
1805 |
+
'card_type' => $cardData['card_type'],
|
1806 |
+
'usage_type' => $usageType)
|
1807 |
);
|
1808 |
+
$xpHelper->userCardSaved();
|
1809 |
+
return $usercards->save();
|
1810 |
}
|
1811 |
}
|
1812 |
catch(Exception $e)
|
1818 |
}
|
1819 |
|
1820 |
public function authorizedTransactionRequest($action,$data){
|
1821 |
+
$data['target'] = 'payment';
|
1822 |
list($status, $response) = $this->request('payment', $action, $data);
|
1823 |
|
1824 |
//****************stop*****************//
|
1846 |
|
1847 |
$order = $this->getOrder();
|
1848 |
$data = array(
|
1849 |
+
'txnId' => $order->getData('xpc_txnid'),
|
1850 |
'amount' => number_format($amount, 2, '.', ''),
|
1851 |
);
|
1852 |
|
1875 |
$order = $this->getOrder();
|
1876 |
/*processing during capture invoice*/
|
1877 |
$data = array(
|
1878 |
+
'txnId' => $order->getData('xpc_txnid'),
|
1879 |
'amount' => number_format($amount, 2, '.', ''),
|
1880 |
);
|
1881 |
|
1903 |
*/
|
1904 |
public function submitRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile, Mage_Payment_Model_Info $paymentInfo)
|
1905 |
{
|
1906 |
+
$xpHelper = Mage::helper('xpaymentsconnector');
|
1907 |
+
$quote = $profile->getQuote();
|
1908 |
+
// registered new user and update profile
|
1909 |
+
$xpHelper->addXpDefaultRecurringSettings($profile);
|
1910 |
+
// end registered user
|
1911 |
+
$xpHelper->setPrepareOrderType();
|
1912 |
+
|
1913 |
+
//add txnid for all subscriptions
|
1914 |
+
$cardData = $xpHelper->getXpaymentResponse();
|
1915 |
+
|
1916 |
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
|
|
|
|
|
|
|
|
|
|
1917 |
|
1918 |
+
if (!$xpHelper->checkIssetSimpleOrder()) {
|
1919 |
+
if ($useIframe) {
|
1920 |
+
if (is_null($this->_currentProfileId)) {
|
1921 |
+
$payDeferredSubscription = $xpHelper->payDeferredSubscription($profile);
|
1922 |
+
if ($payDeferredSubscription) {
|
1923 |
+
$this->_currentProfileId = $profile->getProfileId();
|
1924 |
+
} else {
|
1925 |
+
$this->createFirstRecurringOrder($profile);
|
1926 |
+
}
|
1927 |
+
if($profile->getState() == Mage_Sales_Model_Recurring_Profile::STATE_CANCELED){
|
1928 |
+
$this->firstTransactionSuccess = false;
|
1929 |
+
};
|
1930 |
+
}else{
|
1931 |
+
if (!$this->firstTransactionSuccess) {
|
1932 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
|
1933 |
+
}
|
1934 |
+
}
|
1935 |
+
$xpHelper->prepareOrderKeyByRecurringProfile($profile);
|
1936 |
+
} else {
|
1937 |
+
if (is_null($this->_currentProfileId)) {
|
1938 |
+
$updateSendData = array();
|
1939 |
+
$updateSendData['template'] = 'default';
|
1940 |
+
$xpaymentResponse = $this->sendIframeHandshakeRequest($updateSendData);
|
1941 |
+
|
1942 |
+
if (isset($xpaymentResponse['success']) && !$xpaymentResponse['success']) {
|
1943 |
+
$this->firstTransactionSuccess = false;
|
1944 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
|
1945 |
+
}
|
1946 |
+
$xpHelper->updateRecurringMasKeys($profile);
|
1947 |
+
$this->_currentProfileId = $profile->getProfileId();
|
1948 |
+
} else {
|
1949 |
+
if (!$this->firstTransactionSuccess) {
|
1950 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
|
1951 |
+
}
|
1952 |
+
}
|
1953 |
+
}
|
1954 |
+
}
|
1955 |
|
1956 |
+
if($useIframe){
|
1957 |
+
$profile->setReferenceId($cardData['txnId']);
|
1958 |
+
if (is_null($this->_currentProfileId) && $xpHelper->checkIssetSimpleOrder()) {
|
1959 |
+
//save user card
|
1960 |
+
Mage::getSingleton('checkout/session')->setData('user_card_save', true);
|
1961 |
+
$this->saveUserCard($cardData, $usageType = Cdev_XPaymentsConnector_Model_Usercards::RECURRING_CARD);
|
1962 |
}
|
1963 |
+
$this->_currentProfileId = $profile->getProfileId();
|
1964 |
+
}else {
|
1965 |
+
$orderItemInfo = $profile->getData('order_item_info');
|
1966 |
+
$quote->getItemById($orderItemInfo['item_id'])->isDeleted(true);
|
1967 |
}
|
1968 |
|
1969 |
}
|
2011 |
*/
|
2012 |
public function getTransactionStatusLabels(){
|
2013 |
$statuses = array(
|
2014 |
+
self::NEW_STATUS => 'New',
|
2015 |
+
self::AUTH_STATUS => 'Authorized',
|
2016 |
+
self::DECLINED_STATUS => 'Declined',
|
2017 |
+
self::CHARGED_STATUS => 'Charged',
|
2018 |
);
|
2019 |
return $statuses;
|
2020 |
}
|
2023 |
*
|
2024 |
* @param Mage_Payment_Model_Recurring_Profile $profile
|
2025 |
*/
|
2026 |
+
public function createFirstRecurringOrder(Mage_Payment_Model_Recurring_Profile $profile)
|
2027 |
+
{
|
2028 |
+
$xpHelper = Mage::helper('xpaymentsconnector');
|
2029 |
+
$cardData = $xpHelper->getXpaymentResponse();
|
2030 |
+
$orderId = $xpHelper->createOrder($profile, $isFirstRecurringOrder = true);
|
2031 |
|
2032 |
/*update order by card data*/
|
2033 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
2034 |
+
$order->setData('xp_card_data', serialize($cardData));
|
2035 |
$order->save();
|
2036 |
+
$orderItemInfo = $profile->getData('order_item_info');
|
2037 |
|
2038 |
+
$profile->setReferenceId($cardData['txnId']);
|
2039 |
+
if (is_null($this->_currentProfileId)) {
|
2040 |
+
$result = $this->updateOrderByXpaymentResponse($orderId, $cardData['txnId']);
|
2041 |
+
} else {
|
2042 |
+
$grandTotal = $orderItemInfo['nominal_row_total'];
|
2043 |
+
$response = $this->sendAgainTransactionRequest($orderId, NULL, $grandTotal, $cardData);
|
2044 |
|
2045 |
+
if ($response['success']) {
|
2046 |
+
$result = $this->updateOrderByXpaymentResponse($orderId, $response['response']['transaction_id']);
|
2047 |
+
}
|
2048 |
+
}
|
2049 |
+
|
2050 |
+
if (!$result['success']) {
|
2051 |
+
Mage::getSingleton('checkout/session')->addError($result['error_message']);
|
2052 |
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
|
2053 |
} else {
|
2054 |
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
|
2056 |
$newTransactionDate = new Zend_Date(time());
|
2057 |
$profile->setXpSuccessTransactionDate($newTransactionDate->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
|
2058 |
$profile->setXpCountSuccessTransaction(1);
|
2059 |
+
if (is_null($this->_currentProfileId)) {
|
2060 |
+
//save user card
|
2061 |
+
Mage::getSingleton('checkout/session')->setData('user_card_save', true);
|
2062 |
+
$this->saveUserCard($cardData, $usageType = Cdev_XPaymentsConnector_Model_Usercards::RECURRING_CARD);
|
2063 |
+
}
|
2064 |
|
2065 |
}
|
2066 |
+
|
2067 |
+
$this->_currentProfileId = $profile->getProfileId();
|
2068 |
+
|
2069 |
return $profile;
|
2070 |
+
|
2071 |
}
|
2072 |
|
2073 |
}
|
app/code/community/Cdev/XPaymentsConnector/Model/Payment/Savedcards.php
CHANGED
@@ -20,14 +20,14 @@
|
|
20 |
*/
|
21 |
|
22 |
/**
|
23 |
-
*
|
24 |
* Class Cdev_XPaymentsConnector_Model_Payment_Savedcards
|
25 |
*/
|
26 |
|
27 |
class Cdev_XPaymentsConnector_Model_Payment_Savedcards extends Mage_Payment_Model_Method_Abstract
|
28 |
implements Mage_Payment_Model_Recurring_Profile_MethodInterface
|
29 |
{
|
30 |
-
protected $_code =
|
31 |
protected $_formBlockType = 'xpaymentsconnector/form_savedcards';
|
32 |
protected $_infoBlockType = 'xpaymentsconnector/info_savedcards';
|
33 |
|
@@ -45,6 +45,8 @@ class Cdev_XPaymentsConnector_Model_Payment_Savedcards extends Mage_Payment_Mode
|
|
45 |
protected $_canRefundInvoicePartial = true;
|
46 |
|
47 |
protected $_order = null;
|
|
|
|
|
48 |
|
49 |
|
50 |
/**
|
@@ -81,11 +83,11 @@ class Cdev_XPaymentsConnector_Model_Payment_Savedcards extends Mage_Payment_Mode
|
|
81 |
|
82 |
$order = $this->getOrder();
|
83 |
$data = array(
|
84 |
-
'txnId' => $order->getData(
|
85 |
'amount' => number_format($amount, 2, '.', ''),
|
86 |
);
|
87 |
|
88 |
-
Mage::getModel(
|
89 |
|
90 |
|
91 |
return $this;
|
@@ -103,11 +105,11 @@ class Cdev_XPaymentsConnector_Model_Payment_Savedcards extends Mage_Payment_Mode
|
|
103 |
$order = $this->getOrder();
|
104 |
/*processing during capture invoice*/
|
105 |
$data = array(
|
106 |
-
'txnId' => $order->getData(
|
107 |
'amount' => number_format($amount, 2, '.', ''),
|
108 |
);
|
109 |
|
110 |
-
Mage::getModel(
|
111 |
|
112 |
return $this;
|
113 |
}
|
@@ -131,41 +133,62 @@ class Cdev_XPaymentsConnector_Model_Payment_Savedcards extends Mage_Payment_Mode
|
|
131 |
*/
|
132 |
public function submitRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile, Mage_Payment_Model_Info $paymentInfo){
|
133 |
|
134 |
-
$
|
135 |
-
$
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
if
|
149 |
-
$
|
150 |
-
if
|
151 |
-
|
152 |
-
$
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
}
|
|
|
161 |
|
162 |
-
|
163 |
-
|
|
|
|
|
|
|
|
|
|
|
164 |
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
|
165 |
}
|
166 |
-
}
|
167 |
}
|
168 |
|
|
|
169 |
|
170 |
}
|
171 |
|
20 |
*/
|
21 |
|
22 |
/**
|
23 |
+
* 'Use saved credit cards (X-Payments)'
|
24 |
* Class Cdev_XPaymentsConnector_Model_Payment_Savedcards
|
25 |
*/
|
26 |
|
27 |
class Cdev_XPaymentsConnector_Model_Payment_Savedcards extends Mage_Payment_Model_Method_Abstract
|
28 |
implements Mage_Payment_Model_Recurring_Profile_MethodInterface
|
29 |
{
|
30 |
+
protected $_code = 'savedcards';
|
31 |
protected $_formBlockType = 'xpaymentsconnector/form_savedcards';
|
32 |
protected $_infoBlockType = 'xpaymentsconnector/info_savedcards';
|
33 |
|
45 |
protected $_canRefundInvoicePartial = true;
|
46 |
|
47 |
protected $_order = null;
|
48 |
+
public $firstTransactionSuccess = true;
|
49 |
+
|
50 |
|
51 |
|
52 |
/**
|
83 |
|
84 |
$order = $this->getOrder();
|
85 |
$data = array(
|
86 |
+
'txnId' => $order->getData('xpc_txnid'),
|
87 |
'amount' => number_format($amount, 2, '.', ''),
|
88 |
);
|
89 |
|
90 |
+
Mage::getModel('xpaymentsconnector/payment_cc')->authorizedTransactionRequest('capture', $data);
|
91 |
|
92 |
|
93 |
return $this;
|
105 |
$order = $this->getOrder();
|
106 |
/*processing during capture invoice*/
|
107 |
$data = array(
|
108 |
+
'txnId' => $order->getData('xpc_txnid'),
|
109 |
'amount' => number_format($amount, 2, '.', ''),
|
110 |
);
|
111 |
|
112 |
+
Mage::getModel('xpaymentsconnector/payment_cc')->authorizedTransactionRequest('refund', $data);
|
113 |
|
114 |
return $this;
|
115 |
}
|
133 |
*/
|
134 |
public function submitRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile, Mage_Payment_Model_Info $paymentInfo){
|
135 |
|
136 |
+
$xpHelper = Mage::helper('xpaymentsconnector');
|
137 |
+
$xpHelper->setPrepareOrderType();
|
138 |
+
$quote = $profile->getQuote();
|
139 |
+
$orderItemInfo = $profile->getData('order_item_info');
|
140 |
+
// registered new user and update profile
|
141 |
+
$xpHelper->addXpDefaultRecurringSettings($profile);
|
142 |
+
// end registered user
|
143 |
+
$paymentCardNumber = $quote->getPayment()->getData('xp_payment_card');
|
144 |
+
$cardData = Mage::getModel('xpaymentsconnector/usercards')->load($paymentCardNumber);
|
145 |
+
$txnid = $cardData->getData('txnId');
|
146 |
+
|
147 |
+
if (!$xpHelper->checkIssetSimpleOrder()) {
|
148 |
+
if(is_null($xpHelper->payDeferredProfileId)){
|
149 |
+
$payDeferredSubscription = $xpHelper->payDeferredSubscription($profile);
|
150 |
+
if(!$payDeferredSubscription){
|
151 |
+
$grandTotal = $orderItemInfo['nominal_row_total'];
|
152 |
+
if($txnid){
|
153 |
+
$orderId = $xpHelper->createOrder($profile,$isFirstRecurringOrder = true);
|
154 |
+
$response = Mage::getModel('xpaymentsconnector/payment_cc')->
|
155 |
+
sendAgainTransactionRequest($orderId, NULL, $grandTotal);
|
156 |
+
|
157 |
+
if ($response['success']) {
|
158 |
+
$result = Mage::getModel('xpaymentsconnector/payment_cc')->
|
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->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
|
167 |
+
$profile->setXpCountSuccessTransaction(1);
|
168 |
+
|
169 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
|
170 |
+
}
|
171 |
+
|
172 |
+
} else {
|
173 |
+
Mage::getSingleton('checkout/session')->addError($response['error_message']);
|
174 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
|
175 |
+
}
|
176 |
}
|
177 |
+
}
|
178 |
|
179 |
+
$xpHelper->prepareOrderKeyByRecurringProfile($profile);
|
180 |
+
}
|
181 |
+
|
182 |
+
if($profile->getState() == Mage_Sales_Model_Recurring_Profile::STATE_CANCELED){
|
183 |
+
$this->firstTransactionSuccess = false;
|
184 |
+
}else{
|
185 |
+
if (!$this->firstTransactionSuccess) {
|
186 |
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
|
187 |
}
|
188 |
+
};
|
189 |
}
|
190 |
|
191 |
+
$profile->setReferenceId($txnid);
|
192 |
|
193 |
}
|
194 |
|
app/code/community/Cdev/XPaymentsConnector/Model/Quote.php
CHANGED
@@ -24,14 +24,38 @@ class Cdev_XPaymentsConnector_Model_Quote extends Mage_Sales_Model_Quote
|
|
24 |
|
25 |
public function getReservedOrderId()
|
26 |
{
|
27 |
-
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
return parent::getReservedOrderId();
|
34 |
-
}
|
35 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
}
|
37 |
|
24 |
|
25 |
public function getReservedOrderId()
|
26 |
{
|
27 |
+
$reservedOrderId = Mage::helper("xpaymentsconnector")->getOrderKey();
|
28 |
|
29 |
+
if ($reservedOrderId) {
|
30 |
+
return $reservedOrderId;
|
31 |
+
} else {
|
32 |
+
return parent::getReservedOrderId();
|
|
|
|
|
33 |
}
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Adding new item to quote
|
38 |
+
*
|
39 |
+
* @param Mage_Sales_Model_Quote_Item $item
|
40 |
+
* @return Mage_Sales_Model_Quote
|
41 |
+
*/
|
42 |
+
public function addItem(Mage_Sales_Model_Quote_Item $item)
|
43 |
+
{
|
44 |
+
/**
|
45 |
+
* Temporary workaround for purchase process: it is too dangerous to purchase more than one nominal item
|
46 |
+
* or a mixture of nominal and non-nominal items, although technically possible.
|
47 |
+
*
|
48 |
+
* The problem is that currently it is implemented as sequential submission of nominal items and order, by one click.
|
49 |
+
* It makes logically impossible to make the process of the purchase failsafe.
|
50 |
+
* Proper solution is to submit items one by one with customer confirmation each time.
|
51 |
+
*/
|
52 |
+
|
53 |
+
$item->setQuote($this);
|
54 |
+
if (!$item->getId()) {
|
55 |
+
$this->getItemsCollection()->addItem($item);
|
56 |
+
Mage::dispatchEvent('sales_quote_add_item', array('quote_item' => $item));
|
57 |
+
}
|
58 |
+
return $this;
|
59 |
+
}
|
60 |
}
|
61 |
|
app/code/community/Cdev/XPaymentsConnector/Model/Quote/Address/Total/Nominal.php
CHANGED
@@ -55,7 +55,12 @@ class Cdev_XPaymentsConnector_Model_Quote_Address_Total_Nominal extends Mage_Sal
|
|
55 |
$totals[] = $itemRowTotal;
|
56 |
if ($model->getCode() == "recurring_discount") {
|
57 |
$rowTotal -= $itemRowTotal;
|
58 |
-
$baseRowTotal -= $
|
|
|
|
|
|
|
|
|
|
|
59 |
} else {
|
60 |
$rowTotal += $itemRowTotal;
|
61 |
$baseRowTotal += $model->getItemBaseRowTotal($item);
|
@@ -67,6 +72,10 @@ class Cdev_XPaymentsConnector_Model_Quote_Address_Total_Nominal extends Mage_Sal
|
|
67 |
if ((float)$itemRowTotal > 0 && $label = $model->getLabel()) {
|
68 |
if ($model->getCode() == "recurring_discount") {
|
69 |
$itemRowTotal = -$itemRowTotal;
|
|
|
|
|
|
|
|
|
70 |
}
|
71 |
$totalDetails[] = new Varien_Object(array(
|
72 |
'label' => $label,
|
55 |
$totals[] = $itemRowTotal;
|
56 |
if ($model->getCode() == "recurring_discount") {
|
57 |
$rowTotal -= $itemRowTotal;
|
58 |
+
$baseRowTotal -= $itemRowTotal;
|
59 |
+
}elseif (($model->getCode() == "recurring_initial_fee" ) &&
|
60 |
+
!is_null($item->getXpRecurringInitialFee())
|
61 |
+
) {
|
62 |
+
$rowTotal += $item->getXpRecurringInitialFee();
|
63 |
+
$baseRowTotal += $item->getXpRecurringInitialFee();
|
64 |
} else {
|
65 |
$rowTotal += $itemRowTotal;
|
66 |
$baseRowTotal += $model->getItemBaseRowTotal($item);
|
72 |
if ((float)$itemRowTotal > 0 && $label = $model->getLabel()) {
|
73 |
if ($model->getCode() == "recurring_discount") {
|
74 |
$itemRowTotal = -$itemRowTotal;
|
75 |
+
}elseif ($model->getCode() == "recurring_initial_fee") {
|
76 |
+
if(!is_null($item->getXpRecurringInitialFee())){
|
77 |
+
$itemRowTotal = $item->getXpRecurringInitialFee();
|
78 |
+
}
|
79 |
}
|
80 |
$totalDetails[] = new Varien_Object(array(
|
81 |
'label' => $label,
|
app/code/community/Cdev/XPaymentsConnector/Model/Quote/Address/Total/Nominal/Recurring/Initialfee/Tax.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 |
+
/**
|
23 |
+
* Total model for recurring profile tax for initial fee
|
24 |
+
*/
|
25 |
+
class Cdev_XPaymentsConnector_Model_Quote_Address_Total_Nominal_Recurring_Initialfee_Tax
|
26 |
+
extends Mage_Sales_Model_Quote_Address_Total_Nominal_RecurringAbstract
|
27 |
+
{
|
28 |
+
/**
|
29 |
+
* Custom row total/profile keys
|
30 |
+
*
|
31 |
+
* @var string
|
32 |
+
*/
|
33 |
+
protected $_itemRowTotalKey = 'recurring_initialfee_tax';
|
34 |
+
protected $_profileDataKey = 'initialfee_tax_amount';
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Get initial fee label
|
38 |
+
*
|
39 |
+
* @return string
|
40 |
+
*/
|
41 |
+
public function getLabel()
|
42 |
+
{
|
43 |
+
return Mage::helper('sales')->__('Initial Fee Tax');
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Getter for row default total
|
49 |
+
*
|
50 |
+
* @param Mage_Sales_Model_Quote_Item_Abstract $item
|
51 |
+
* @return float
|
52 |
+
*/
|
53 |
+
public function getItemRowTotal(Mage_Sales_Model_Quote_Item_Abstract $item)
|
54 |
+
{
|
55 |
+
$xpHelper = Mage::helper('xpaymentsconnector');
|
56 |
+
$xpRecurringInitialFee = $item->getXpRecurringInitialFee();
|
57 |
+
if (!is_null($xpRecurringInitialFee) && !empty($xpRecurringInitialFee)) {
|
58 |
+
$currentProduct = $item->getProduct();
|
59 |
+
$taxInitialFee = $xpHelper->calculateTaxForProductCustomPrice($currentProduct,$xpRecurringInitialFee);
|
60 |
+
$item->setInitialfeeTaxAmount($taxInitialFee);
|
61 |
+
$item->save();
|
62 |
+
|
63 |
+
return $taxInitialFee;
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
app/code/community/Cdev/XPaymentsConnector/Model/Sales/Recurring/Profile.php
CHANGED
@@ -56,16 +56,35 @@ class Cdev_XPaymentsConnector_Model_Sales_Recurring_Profile extends Mage_Sales_M
|
|
56 |
$isVirtual = 1;
|
57 |
$weight = 0;
|
58 |
$discountAmount = 0;
|
|
|
|
|
59 |
foreach ($itemInfoObjects as $itemInfo) {
|
60 |
$item = $this->_getItem($itemInfo);
|
61 |
-
$
|
62 |
-
$
|
|
|
|
|
|
|
|
|
63 |
$taxAmount += $item->getTaxAmount();
|
64 |
-
|
|
|
|
|
|
|
65 |
$weight += $item->getWeight();
|
66 |
if (!$item->getIsVirtual()) {
|
67 |
$isVirtual = 0;
|
68 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
$items[] = $item;
|
70 |
}
|
71 |
|
@@ -119,7 +138,7 @@ class Cdev_XPaymentsConnector_Model_Sales_Recurring_Profile extends Mage_Sales_M
|
|
119 |
$order->setData($key, $shippingInfo[$key]);
|
120 |
}
|
121 |
}
|
122 |
-
|
123 |
$order->setStoreId($this->getStoreId())
|
124 |
->setState(Mage_Sales_Model_Order::STATE_NEW)
|
125 |
->setBaseToOrderRate($orderInfo['base_to_quote_rate'])
|
@@ -137,7 +156,7 @@ class Cdev_XPaymentsConnector_Model_Sales_Recurring_Profile extends Mage_Sales_M
|
|
137 |
->setGrandTotal($grandTotal)
|
138 |
->setIsVirtual($isVirtual)
|
139 |
->setWeight($weight)
|
140 |
-
->setTotalQtyOrdered($
|
141 |
->setBillingAddress($billingAddress)
|
142 |
->setShippingAddress($shippingAddress)
|
143 |
->setPayment($payment);
|
@@ -177,6 +196,28 @@ class Cdev_XPaymentsConnector_Model_Sales_Recurring_Profile extends Mage_Sales_M
|
|
177 |
protected function _getRegularItem($itemInfo)
|
178 |
{
|
179 |
$price = $itemInfo->getPrice() ? $itemInfo->getPrice() : $this->getBillingAmount();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
$shippingAmount = $itemInfo->getShippingAmount() ? $itemInfo->getShippingAmount() : $this->getShippingAmount();
|
181 |
$taxAmount = $itemInfo->getTaxAmount() ? $itemInfo->getTaxAmount() : $this->getTaxAmount();
|
182 |
$orderItemInfo = $this->getOrderItemInfo();
|
@@ -190,14 +231,28 @@ class Cdev_XPaymentsConnector_Model_Sales_Recurring_Profile extends Mage_Sales_M
|
|
190 |
->setBaseOriginalPrice($orderItemInfo['price'])
|
191 |
->setPrice($price)
|
192 |
->setBasePrice($price)
|
193 |
-
->setRowTotal($
|
194 |
-
->setBaseRowTotal($
|
|
|
|
|
|
|
195 |
->setTaxAmount($taxAmount)
|
196 |
->setShippingAmount($shippingAmount)
|
197 |
->setId(null);
|
|
|
198 |
return $item;
|
199 |
}
|
200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
|
202 |
|
203 |
|
56 |
$isVirtual = 1;
|
57 |
$weight = 0;
|
58 |
$discountAmount = 0;
|
59 |
+
$qty = 0;
|
60 |
+
|
61 |
foreach ($itemInfoObjects as $itemInfo) {
|
62 |
$item = $this->_getItem($itemInfo);
|
63 |
+
$price = $item->getPrice();
|
64 |
+
if(!is_null($itemInfo->getRowTotal())){
|
65 |
+
$price = $itemInfo->getRowTotal();
|
66 |
+
}
|
67 |
+
$billingAmount += $price;
|
68 |
+
$shippingAmount += $itemInfo->getShippingAmount();
|
69 |
$taxAmount += $item->getTaxAmount();
|
70 |
+
|
71 |
+
if($itemInfo->getQty()){
|
72 |
+
$qty = $itemInfo->getQty();
|
73 |
+
}
|
74 |
$weight += $item->getWeight();
|
75 |
if (!$item->getIsVirtual()) {
|
76 |
$isVirtual = 0;
|
77 |
}
|
78 |
+
|
79 |
+
if(!is_null($itemInfo->getDiscountAmount())){
|
80 |
+
$discountAmount -= $itemInfo->getDiscountAmount();
|
81 |
+
$item->setOriginalDiscountAmount($itemInfo->getDiscountAmount());
|
82 |
+
$item->setBaseOriginalDiscountAmount($itemInfo->getDiscountAmount());
|
83 |
+
$item->setRecurringDiscount($itemInfo->getDiscountAmount());
|
84 |
+
$item->setDiscountAmount($itemInfo->getDiscountAmount());
|
85 |
+
$item->setBaseDiscountAmount($itemInfo->getDiscountAmount());
|
86 |
+
}
|
87 |
+
|
88 |
$items[] = $item;
|
89 |
}
|
90 |
|
138 |
$order->setData($key, $shippingInfo[$key]);
|
139 |
}
|
140 |
}
|
141 |
+
$qty = ($qty)?$qty:$orderInfo['items_qty'];
|
142 |
$order->setStoreId($this->getStoreId())
|
143 |
->setState(Mage_Sales_Model_Order::STATE_NEW)
|
144 |
->setBaseToOrderRate($orderInfo['base_to_quote_rate'])
|
156 |
->setGrandTotal($grandTotal)
|
157 |
->setIsVirtual($isVirtual)
|
158 |
->setWeight($weight)
|
159 |
+
->setTotalQtyOrdered($qty)
|
160 |
->setBillingAddress($billingAddress)
|
161 |
->setShippingAddress($shippingAddress)
|
162 |
->setPayment($payment);
|
196 |
protected function _getRegularItem($itemInfo)
|
197 |
{
|
198 |
$price = $itemInfo->getPrice() ? $itemInfo->getPrice() : $this->getBillingAmount();
|
199 |
+
$rowTotal = $price;
|
200 |
+
$baseRowTotal = $price;
|
201 |
+
$rowTotalInclTax = $price;
|
202 |
+
$baseRowTotalInclTax = $price;
|
203 |
+
$originalPrice = $price;
|
204 |
+
|
205 |
+
if(!is_null($itemInfo->getRowTotal())){
|
206 |
+
$rowTotal = $itemInfo->getRowTotal();
|
207 |
+
}
|
208 |
+
if(!is_null($itemInfo->getBaseRowTotal())){
|
209 |
+
$baseRowTotal = $itemInfo->getBaseRowTotal();
|
210 |
+
}
|
211 |
+
if(!is_null($itemInfo->getRowTotalInclTax())){
|
212 |
+
$rowTotalInclTax = $itemInfo->getRowTotalInclTax();
|
213 |
+
}
|
214 |
+
if(!is_null($itemInfo->getBaseRowTotalInclTax())){
|
215 |
+
$baseRowTotalInclTax = $itemInfo->getBaseRowTotalInclTax();
|
216 |
+
}
|
217 |
+
if(!is_null($itemInfo->getOriginalPrice())){
|
218 |
+
$originalPrice = $itemInfo->getOriginalPrice();
|
219 |
+
}
|
220 |
+
|
221 |
$shippingAmount = $itemInfo->getShippingAmount() ? $itemInfo->getShippingAmount() : $this->getShippingAmount();
|
222 |
$taxAmount = $itemInfo->getTaxAmount() ? $itemInfo->getTaxAmount() : $this->getTaxAmount();
|
223 |
$orderItemInfo = $this->getOrderItemInfo();
|
231 |
->setBaseOriginalPrice($orderItemInfo['price'])
|
232 |
->setPrice($price)
|
233 |
->setBasePrice($price)
|
234 |
+
->setRowTotal($rowTotal)
|
235 |
+
->setBaseRowTotal($baseRowTotal)
|
236 |
+
->setRowTotalInclTax($rowTotalInclTax)
|
237 |
+
->setBaseRowTotalInclTax($baseRowTotalInclTax)
|
238 |
+
->setOriginalPrice($originalPrice)
|
239 |
->setTaxAmount($taxAmount)
|
240 |
->setShippingAmount($shippingAmount)
|
241 |
->setId(null);
|
242 |
+
|
243 |
return $item;
|
244 |
}
|
245 |
|
246 |
+
/**
|
247 |
+
* Check whether the workflow allows to activate the profile
|
248 |
+
*
|
249 |
+
* @return bool
|
250 |
+
*/
|
251 |
+
public function canActivate()
|
252 |
+
{
|
253 |
+
return false;
|
254 |
+
}
|
255 |
+
|
256 |
|
257 |
|
258 |
|
app/code/community/Cdev/XPaymentsConnector/controllers/CustomerController.php
CHANGED
@@ -59,7 +59,7 @@ class Cdev_XPaymentsConnector_CustomerController extends Mage_Core_Controller_Fr
|
|
59 |
$txnId = $item->getData("txnId");
|
60 |
$recurringProfile = Mage::getModel('sales/recurring_profile')->load($txnId,"reference_id");
|
61 |
if($recurringProfile->getState() == Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE){
|
62 |
-
$errorMessage = Mage::helper("xpaymentsconnector")->__("You can't delete %s card. Because this is recurring card and this recurring is still active.",$item->getXpCardId());
|
63 |
Mage::getSingleton("customer/session")->addError($errorMessage);
|
64 |
continue;
|
65 |
}
|
59 |
$txnId = $item->getData("txnId");
|
60 |
$recurringProfile = Mage::getModel('sales/recurring_profile')->load($txnId,"reference_id");
|
61 |
if($recurringProfile->getState() == Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE){
|
62 |
+
$errorMessage = Mage::helper("xpaymentsconnector")->__("You can't delete %s card. Because this is recurring card and this recurring(s) is still active.",$item->getXpCardId());
|
63 |
Mage::getSingleton("customer/session")->addError($errorMessage);
|
64 |
continue;
|
65 |
}
|
app/code/community/Cdev/XPaymentsConnector/controllers/ProcessingController.php
CHANGED
@@ -41,180 +41,11 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
41 |
return Mage::getSingleton('checkout/session');
|
42 |
}
|
43 |
|
44 |
-
/**
|
45 |
-
* Start payment (handshake + redirect to X-Payments)
|
46 |
-
*
|
47 |
-
* @return void
|
48 |
-
* @access public
|
49 |
-
* @see ____func_see____
|
50 |
-
* @since 1.0.0
|
51 |
-
*/
|
52 |
-
public function redirectAction()
|
53 |
-
{
|
54 |
-
try {
|
55 |
-
$session = $this->_getCheckout();
|
56 |
-
|
57 |
-
// Get order id
|
58 |
-
$order = Mage::getModel('sales/order');
|
59 |
-
$orderId = $session->getLastRealOrderId();
|
60 |
-
$api = Mage::getModel('xpaymentsconnector/payment_cc');
|
61 |
-
|
62 |
-
if($orderId){
|
63 |
-
|
64 |
-
$order->loadByIncrementId($session->getLastRealOrderId());
|
65 |
-
|
66 |
-
$result = $api->sendHandshakeRequest($order);
|
67 |
-
|
68 |
-
if (!$result) {
|
69 |
-
$this->_getCheckout()->addError('Failed to complete the payment transaction. Please use another payment method or contact the store administrator.');
|
70 |
-
|
71 |
-
} else {
|
72 |
-
|
73 |
-
// Update order
|
74 |
-
if ($order->getState() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
|
75 |
-
$order->setState(
|
76 |
-
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
|
77 |
-
(bool)Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
|
78 |
-
Mage::helper('xpaymentsconnector')->__('Customer has been redirected to X-Payments.')
|
79 |
-
)->save();
|
80 |
-
}
|
81 |
-
|
82 |
-
$this->loadLayout();
|
83 |
-
|
84 |
-
$this->renderLayout();
|
85 |
-
|
86 |
-
return;
|
87 |
-
}
|
88 |
-
|
89 |
-
|
90 |
-
}
|
91 |
-
$profileIds = Mage::getSingleton('checkout/session')->getLastRecurringProfileIds();
|
92 |
-
if(!empty($profileIds)){
|
93 |
-
$this->loadLayout();
|
94 |
-
$this->renderLayout();
|
95 |
-
return;
|
96 |
-
}
|
97 |
-
|
98 |
-
if (!$orderId || $profileIds) {
|
99 |
-
Mage::throwException('No order or profile for processing found');
|
100 |
-
}
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
} catch (Mage_Core_Exception $e) {
|
105 |
-
$this->_getCheckout()->addError($e->getMessage());
|
106 |
-
|
107 |
-
} catch(Exception $e) {
|
108 |
-
Mage::logException($e);
|
109 |
-
}
|
110 |
-
|
111 |
-
$this->_redirect('checkout/cart');
|
112 |
-
}
|
113 |
-
|
114 |
public function getOnepage()
|
115 |
{
|
116 |
return Mage::getSingleton('checkout/type_onepage');
|
117 |
}
|
118 |
|
119 |
-
/**
|
120 |
-
* Return customer from X-Payments
|
121 |
-
*
|
122 |
-
* @return void
|
123 |
-
* @access public
|
124 |
-
* @see ____func_see____
|
125 |
-
* @since 1.0.0
|
126 |
-
*/
|
127 |
-
|
128 |
-
public function returnAction()
|
129 |
-
{
|
130 |
-
if ($this->processCancel()) {
|
131 |
-
return;
|
132 |
-
}
|
133 |
-
|
134 |
-
// Check request type
|
135 |
-
if (!$this->getRequest()->isPost()) {
|
136 |
-
Mage::throwException('Wrong request type.');
|
137 |
-
}
|
138 |
-
|
139 |
-
// Check request data
|
140 |
-
$request = $this->getRequest()->getPost();
|
141 |
-
if (empty($request)) {
|
142 |
-
Mage::throwException('Request doesn\'t contain POST elements.');
|
143 |
-
}
|
144 |
-
|
145 |
-
// Check order id
|
146 |
-
if (empty($request['refId'])) {
|
147 |
-
Mage::throwException('Missing or invalid order ID');
|
148 |
-
}
|
149 |
-
|
150 |
-
// Check order
|
151 |
-
$order = Mage::getModel('sales/order')->loadByIncrementId(intval($request['refId']));
|
152 |
-
|
153 |
-
if (!$order->getId()) {
|
154 |
-
Mage::throwException('Order not found');
|
155 |
-
}
|
156 |
-
|
157 |
-
$refId = $request['refId'];
|
158 |
-
|
159 |
-
/*make a temporary entry for cardholder data*/
|
160 |
-
Mage::helper("xpaymentsconnector")->savePaymentResponse($request);
|
161 |
-
|
162 |
-
if($order->getId()){
|
163 |
-
/*update order table*/
|
164 |
-
$customOrderId = Mage::helper("xpaymentsconnector")->getOrderKey();
|
165 |
-
$order->setData('xpc_txnid', $request['txnId']);
|
166 |
-
$order->setData("xp_card_data", serialize($request));
|
167 |
-
$order->save();
|
168 |
-
/*end (update order table)*/
|
169 |
-
|
170 |
-
$result = Mage::getModel("xpaymentsconnector/payment_cc")->updateOrderByXpaymentResponse($order->getId(),$request['txnId'],$refId);
|
171 |
-
|
172 |
-
if ($result["success"]) {
|
173 |
-
/* save credit card to user profile */
|
174 |
-
Mage::getModel("xpaymentsconnector/payment_cc")->saveUserCard($request);
|
175 |
-
/* end (save payment card) */
|
176 |
-
$this->getResponse()->setBody(
|
177 |
-
$this->getLayout()
|
178 |
-
->createBlock('xpaymentsconnector/success')
|
179 |
-
->setOrder($order)
|
180 |
-
->toHtml()
|
181 |
-
);
|
182 |
-
return;
|
183 |
-
|
184 |
-
} else {
|
185 |
-
|
186 |
-
if ($order->canCancel()) {
|
187 |
-
|
188 |
-
$this->restoreCart($order);
|
189 |
-
|
190 |
-
$order->cancel();
|
191 |
-
$order->addStatusToHistory(
|
192 |
-
Mage_Sales_Model_Order::STATE_CANCELED,
|
193 |
-
Mage::helper('xpaymentsconnector')->__('The payment has been canceled')
|
194 |
-
);
|
195 |
-
$order->save();
|
196 |
-
}
|
197 |
-
|
198 |
-
$this->getResponse()->setBody(
|
199 |
-
$this->getLayout()
|
200 |
-
->createBlock('xpaymentsconnector/cancel')
|
201 |
-
->setOrder($order)
|
202 |
-
->toHtml()
|
203 |
-
);
|
204 |
-
return;
|
205 |
-
|
206 |
-
}
|
207 |
-
|
208 |
-
$this->restoreCart($order);
|
209 |
-
|
210 |
-
$this->getResponse()->setBody(
|
211 |
-
$this->getLayout()
|
212 |
-
->createBlock('xpaymentsconnector/failure')
|
213 |
-
->setOrder($order)
|
214 |
-
->toHtml()
|
215 |
-
);
|
216 |
-
}
|
217 |
-
}
|
218 |
|
219 |
/**
|
220 |
* Callback request
|
@@ -302,34 +133,34 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
302 |
$order->save();
|
303 |
}
|
304 |
|
305 |
-
} elseif (isset($request[
|
306 |
|
307 |
-
$userCardModel = Mage::getModel(
|
308 |
$userCardCollection = $userCardModel
|
309 |
->getCollection()
|
310 |
->addFieldToSelect('user_id')
|
311 |
->addFieldToSelect('last_4_cc_num')
|
312 |
->addFieldToSelect('card_type')
|
313 |
-
->addFilter(
|
314 |
if ($userCardCollection->getSize()) {
|
315 |
$newPrepaidCard = $userCardCollection->getFirstItem()->getData();
|
316 |
-
$newPrepaidCard[
|
317 |
-
$newPrepaidCard[
|
318 |
-
$newPrepaidCard[
|
319 |
$userCardModel->setData($newPrepaidCard);
|
320 |
$userCardModel->save();
|
321 |
} else {
|
322 |
-
$order = Mage::getModel('sales/order')->loadByAttribute('xpc_txnid', $request[
|
323 |
if ($order->getId()) {
|
324 |
$newPrepaidCard = array();
|
325 |
-
$newPrepaidCard[
|
326 |
-
$newPrepaidCard[
|
327 |
-
$newPrepaidCard[
|
328 |
-
$newPrepaidCard[
|
329 |
|
330 |
-
$parentXpaymentResponseData = unserialize($order->getData(
|
331 |
-
$newPrepaidCard[
|
332 |
-
$newPrepaidCard[
|
333 |
|
334 |
$userCardModel->setData($newPrepaidCard);
|
335 |
$userCardModel->save();
|
@@ -369,7 +200,7 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
369 |
*/
|
370 |
public function cancelAction()
|
371 |
{
|
372 |
-
Mage::helper(
|
373 |
$profileIds = Mage::getSingleton('checkout/session')->getLastRecurringProfileIds();
|
374 |
if(empty($profileIds)){
|
375 |
$this->_getCheckout()->addError(Mage::helper('xpaymentsconnector')->__('The order has been canceled.'));
|
@@ -406,7 +237,7 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
406 |
/*update recurring*/
|
407 |
if (!empty($profileIds)) {
|
408 |
foreach ($profileIds as $profileId) {
|
409 |
-
Mage::helper(
|
410 |
$profile = Mage::getModel('sales/recurring_profile')->load($profileId);
|
411 |
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
|
412 |
$profile->save();
|
@@ -483,6 +314,177 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
483 |
}
|
484 |
|
485 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
486 |
/**
|
487 |
* Iframe return customer from X-Payments
|
488 |
*
|
@@ -505,8 +507,10 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
505 |
// Check request data
|
506 |
$request = $this->getRequest()->getPost();
|
507 |
|
|
|
|
|
508 |
if (empty($request)) {
|
509 |
-
Mage::throwException(
|
510 |
}
|
511 |
|
512 |
// Check order id
|
@@ -515,25 +519,84 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
515 |
}
|
516 |
|
517 |
if(!empty($request)){
|
518 |
-
|
519 |
}
|
520 |
-
|
|
|
|
|
521 |
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
529 |
}
|
|
|
530 |
}
|
531 |
-
$this->_redirect('checkout/onepage/success');
|
532 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
533 |
return;
|
534 |
}
|
535 |
|
536 |
|
|
|
537 |
$this->getResponse()->setBody(
|
538 |
$this->getLayout()
|
539 |
->createBlock('xpaymentsconnector/beforesuccess')
|
@@ -547,26 +610,26 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
547 |
public function saveusercardAction(){
|
548 |
$request = $this->getRequest()->getPost();
|
549 |
if(!empty($request)){
|
550 |
-
if($request[
|
551 |
-
Mage::getSingleton(
|
552 |
}
|
553 |
}
|
554 |
}
|
555 |
|
556 |
public function istokenactualAction(){
|
557 |
-
$currentToken = $this->getRequest()->getParam(
|
558 |
$result = array();
|
559 |
if($currentToken){
|
560 |
-
$savedToken = Mage::helper(
|
561 |
-
$result[
|
562 |
}else{
|
563 |
-
$result[
|
564 |
}
|
565 |
|
566 |
-
if(!$result[
|
567 |
-
$result[
|
568 |
-
Mage::helper(
|
569 |
-
$result[
|
570 |
}
|
571 |
|
572 |
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
@@ -575,7 +638,7 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
|
|
575 |
|
576 |
public function getcheckoutiframeurlAction(){
|
577 |
$xpUrlPath = array();
|
578 |
-
$xpUrlPath[
|
579 |
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($xpUrlPath));
|
580 |
}
|
581 |
}
|
41 |
return Mage::getSingleton('checkout/session');
|
42 |
}
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
public function getOnepage()
|
45 |
{
|
46 |
return Mage::getSingleton('checkout/type_onepage');
|
47 |
}
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
/**
|
51 |
* Callback request
|
133 |
$order->save();
|
134 |
}
|
135 |
|
136 |
+
} elseif (isset($request['updateData']['parentId'])) {
|
137 |
|
138 |
+
$userCardModel = Mage::getModel('xpaymentsconnector/usercards');
|
139 |
$userCardCollection = $userCardModel
|
140 |
->getCollection()
|
141 |
->addFieldToSelect('user_id')
|
142 |
->addFieldToSelect('last_4_cc_num')
|
143 |
->addFieldToSelect('card_type')
|
144 |
+
->addFilter('txnId', $request['updateData']['parentId']);
|
145 |
if ($userCardCollection->getSize()) {
|
146 |
$newPrepaidCard = $userCardCollection->getFirstItem()->getData();
|
147 |
+
$newPrepaidCard['txnId'] = $request['txnId'];
|
148 |
+
$newPrepaidCard['usage_type'] = Cdev_XPaymentsConnector_Model_Usercards::BALANCE_CARD;
|
149 |
+
$newPrepaidCard['amount'] = $request['updateData']['amount'];
|
150 |
$userCardModel->setData($newPrepaidCard);
|
151 |
$userCardModel->save();
|
152 |
} else {
|
153 |
+
$order = Mage::getModel('sales/order')->loadByAttribute('xpc_txnid', $request['updateData']['parentId']);
|
154 |
if ($order->getId()) {
|
155 |
$newPrepaidCard = array();
|
156 |
+
$newPrepaidCard['user_id'] = $order->getData('customer_id');
|
157 |
+
$newPrepaidCard['txnId'] = $request['txnId'];
|
158 |
+
$newPrepaidCard['usage_type'] = Cdev_XPaymentsConnector_Model_Usercards::BALANCE_CARD;
|
159 |
+
$newPrepaidCard['amount'] = $request['updateData']['amount'];
|
160 |
|
161 |
+
$parentXpaymentResponseData = unserialize($order->getData('xp_card_data'));
|
162 |
+
$newPrepaidCard['last_4_cc_num'] = $parentXpaymentResponseData['last_4_cc_num'];
|
163 |
+
$newPrepaidCard['card_type'] = $parentXpaymentResponseData['card_type'];
|
164 |
|
165 |
$userCardModel->setData($newPrepaidCard);
|
166 |
$userCardModel->save();
|
200 |
*/
|
201 |
public function cancelAction()
|
202 |
{
|
203 |
+
Mage::helper('xpaymentsconnector')->unsetXpaymentPrepareOrder();
|
204 |
$profileIds = Mage::getSingleton('checkout/session')->getLastRecurringProfileIds();
|
205 |
if(empty($profileIds)){
|
206 |
$this->_getCheckout()->addError(Mage::helper('xpaymentsconnector')->__('The order has been canceled.'));
|
237 |
/*update recurring*/
|
238 |
if (!empty($profileIds)) {
|
239 |
foreach ($profileIds as $profileId) {
|
240 |
+
Mage::helper('xpaymentsconnector')->addRecurringTransactionError();
|
241 |
$profile = Mage::getModel('sales/recurring_profile')->load($profileId);
|
242 |
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
|
243 |
$profile->save();
|
314 |
}
|
315 |
|
316 |
|
317 |
+
/**
|
318 |
+
* Start payment (handshake + redirect to X-Payments)
|
319 |
+
*
|
320 |
+
* @return void
|
321 |
+
* @access public
|
322 |
+
* @see ____func_see____
|
323 |
+
* @since 1.0.0
|
324 |
+
*/
|
325 |
+
public function redirectAction()
|
326 |
+
{
|
327 |
+
try {
|
328 |
+
$session = $this->_getCheckout();
|
329 |
+
|
330 |
+
// Get order id
|
331 |
+
$order = Mage::getModel('sales/order');
|
332 |
+
$orderId = $session->getLastRealOrderId();
|
333 |
+
$api = Mage::getModel('xpaymentsconnector/payment_cc');
|
334 |
+
|
335 |
+
if($orderId){
|
336 |
+
|
337 |
+
$order->loadByIncrementId($orderId);
|
338 |
+
|
339 |
+
$result = $api->sendHandshakeRequest($order);
|
340 |
+
|
341 |
+
if (!$result) {
|
342 |
+
$this->_getCheckout()->addError('Failed to complete the payment transaction. Please use another payment method or contact the store administrator.');
|
343 |
+
|
344 |
+
} else {
|
345 |
+
|
346 |
+
// Update order
|
347 |
+
if ($order->getState() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
|
348 |
+
$order->setState(
|
349 |
+
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
|
350 |
+
(bool)Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
|
351 |
+
Mage::helper('xpaymentsconnector')->__('Customer has been redirected to X-Payments.')
|
352 |
+
)->save();
|
353 |
+
}
|
354 |
+
|
355 |
+
$this->loadLayout();
|
356 |
+
|
357 |
+
$this->renderLayout();
|
358 |
+
|
359 |
+
return;
|
360 |
+
}
|
361 |
+
|
362 |
+
|
363 |
+
}
|
364 |
+
$profileIds = Mage::getSingleton('checkout/session')->getLastRecurringProfileIds();
|
365 |
+
if(!empty($profileIds)){
|
366 |
+
$this->loadLayout();
|
367 |
+
$this->renderLayout();
|
368 |
+
return;
|
369 |
+
}
|
370 |
+
|
371 |
+
if (!$orderId || $profileIds) {
|
372 |
+
Mage::throwException('No order or profile for processing found');
|
373 |
+
}
|
374 |
+
|
375 |
+
|
376 |
+
|
377 |
+
} catch (Mage_Core_Exception $e) {
|
378 |
+
$this->_getCheckout()->addError($e->getMessage());
|
379 |
+
|
380 |
+
} catch(Exception $e) {
|
381 |
+
Mage::logException($e);
|
382 |
+
}
|
383 |
+
|
384 |
+
$this->_redirect('checkout/cart');
|
385 |
+
}
|
386 |
+
|
387 |
+
/**
|
388 |
+
* Return customer from X-Payments
|
389 |
+
*
|
390 |
+
* @return void
|
391 |
+
* @access public
|
392 |
+
* @see ____func_see____
|
393 |
+
* @since 1.0.0
|
394 |
+
*/
|
395 |
+
|
396 |
+
public function returnAction()
|
397 |
+
{
|
398 |
+
if ($this->processCancel()) {
|
399 |
+
return;
|
400 |
+
}
|
401 |
+
|
402 |
+
// Check request type
|
403 |
+
if (!$this->getRequest()->isPost()) {
|
404 |
+
Mage::throwException('Wrong request type.');
|
405 |
+
}
|
406 |
+
|
407 |
+
// Check request data
|
408 |
+
$request = $this->getRequest()->getPost();
|
409 |
+
if (empty($request)) {
|
410 |
+
Mage::throwException('Request doesn\'t contain POST elements.');
|
411 |
+
}
|
412 |
+
|
413 |
+
// Check order id
|
414 |
+
if (empty($request['refId'])) {
|
415 |
+
Mage::throwException('Missing or invalid order ID');
|
416 |
+
}
|
417 |
+
|
418 |
+
// Check order
|
419 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId(intval($request['refId']));
|
420 |
+
|
421 |
+
if (!$order->getId()) {
|
422 |
+
Mage::throwException('Order not found');
|
423 |
+
}
|
424 |
+
|
425 |
+
$refId = $request['refId'];
|
426 |
+
|
427 |
+
/*make a temporary entry for cardholder data*/
|
428 |
+
Mage::helper('xpaymentsconnector')->savePaymentResponse($request);
|
429 |
+
|
430 |
+
if($order->getId()){
|
431 |
+
/*update order table*/
|
432 |
+
$customOrderId = Mage::helper('xpaymentsconnector')->getOrderKey();
|
433 |
+
$order->setData('xpc_txnid', $request['txnId']);
|
434 |
+
$order->setData('xp_card_data', serialize($request));
|
435 |
+
$order->save();
|
436 |
+
/*end (update order table)*/
|
437 |
+
|
438 |
+
$result = Mage::getModel('xpaymentsconnector/payment_cc')->updateOrderByXpaymentResponse($order->getId(),$request['txnId'],$refId);
|
439 |
+
|
440 |
+
if ($result['success']) {
|
441 |
+
/* save credit card to user profile */
|
442 |
+
Mage::getModel('xpaymentsconnector/payment_cc')->saveUserCard($request);
|
443 |
+
/* end (save payment card) */
|
444 |
+
$this->getResponse()->setBody(
|
445 |
+
$this->getLayout()
|
446 |
+
->createBlock('xpaymentsconnector/success')
|
447 |
+
->setOrder($order)
|
448 |
+
->toHtml()
|
449 |
+
);
|
450 |
+
return;
|
451 |
+
|
452 |
+
} else {
|
453 |
+
|
454 |
+
if ($order->canCancel()) {
|
455 |
+
|
456 |
+
$this->restoreCart($order);
|
457 |
+
|
458 |
+
$order->cancel();
|
459 |
+
$order->addStatusToHistory(
|
460 |
+
Mage_Sales_Model_Order::STATE_CANCELED,
|
461 |
+
Mage::helper('xpaymentsconnector')->__('The payment has been canceled')
|
462 |
+
);
|
463 |
+
$order->save();
|
464 |
+
}
|
465 |
+
|
466 |
+
$this->getResponse()->setBody(
|
467 |
+
$this->getLayout()
|
468 |
+
->createBlock('xpaymentsconnector/cancel')
|
469 |
+
->setOrder($order)
|
470 |
+
->toHtml()
|
471 |
+
);
|
472 |
+
return;
|
473 |
+
|
474 |
+
}
|
475 |
+
|
476 |
+
$this->restoreCart($order);
|
477 |
+
|
478 |
+
$this->getResponse()->setBody(
|
479 |
+
$this->getLayout()
|
480 |
+
->createBlock('xpaymentsconnector/failure')
|
481 |
+
->setOrder($order)
|
482 |
+
->toHtml()
|
483 |
+
);
|
484 |
+
}
|
485 |
+
}
|
486 |
+
|
487 |
+
|
488 |
/**
|
489 |
* Iframe return customer from X-Payments
|
490 |
*
|
507 |
// Check request data
|
508 |
$request = $this->getRequest()->getPost();
|
509 |
|
510 |
+
$xpHelper = Mage::helper('xpaymentsconnector');
|
511 |
+
|
512 |
if (empty($request)) {
|
513 |
+
Mage::throwException("Request doesn\'t contain POST elements.");
|
514 |
}
|
515 |
|
516 |
// Check order id
|
519 |
}
|
520 |
|
521 |
if(!empty($request)){
|
522 |
+
$xpHelper->savePaymentResponse($request);
|
523 |
}
|
524 |
+
|
525 |
+
$cardData = $xpHelper->getXpaymentResponse();
|
526 |
+
|
527 |
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
528 |
+
$checkoutSession = Mage::getSingleton('checkout/session');
|
529 |
+
$orderIncrementId = $checkoutSession->getLastRealOrderId();
|
530 |
+
if(!$useIframe){
|
531 |
+
$profileIds = $checkoutSession->getLastRecurringProfileIds();
|
532 |
+
$paymentCcModel = Mage::getModel('xpaymentsconnector/payment_cc');
|
533 |
+
|
534 |
+
if ($orderIncrementId) {
|
535 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
|
536 |
+
$orderId = $order->getId();
|
537 |
+
$order->setData('xp_card_data', serialize($request));
|
538 |
+
$order->save();
|
539 |
+
$refId = $request['refId'];
|
540 |
+
|
541 |
+
$result = $paymentCcModel->updateOrderByXpaymentResponse($orderId,$cardData['txnId'],$refId);
|
542 |
+
if (!$result['success']) {
|
543 |
+
$checkoutSession->addError($result['error_message']);
|
544 |
+
}else{
|
545 |
+
if (is_null($profileIds)) {
|
546 |
+
$paymentCcModel->saveUserCard($cardData);
|
547 |
+
}
|
548 |
}
|
549 |
+
|
550 |
}
|
|
|
551 |
|
552 |
+
if($profileIds){
|
553 |
+
foreach($profileIds as $profileId){
|
554 |
+
$profile = Mage::getModel('sales/recurring_profile')->load($profileId);
|
555 |
+
|
556 |
+
if (isset($cardData['txnId'])) {
|
557 |
+
$profile->setReferenceId($cardData['txnId']);
|
558 |
+
if (is_null($paymentCcModel->_currentProfileId)) {
|
559 |
+
//save user card
|
560 |
+
$checkoutSession->setData('user_card_save', true);
|
561 |
+
$paymentCcModel->saveUserCard($cardData, $usageType = Cdev_XPaymentsConnector_Model_Usercards::RECURRING_CARD);
|
562 |
+
}
|
563 |
+
} else {
|
564 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
|
565 |
+
}
|
566 |
+
|
567 |
+
if (is_null($paymentCcModel->_currentProfileId) && !$orderIncrementId) {
|
568 |
+
if (!$xpHelper->getPrepareRecurringMasKey($profile)) {
|
569 |
+
$unsetParams = array('prepare_order_id');
|
570 |
+
$xpHelper->unsetXpaymentPrepareOrder($unsetParams);
|
571 |
+
$xpHelper->prepareOrderKey();
|
572 |
+
$xpHelper->updateRecurringMasKeys($profile);
|
573 |
+
}
|
574 |
+
$payDeferredSubscription = $xpHelper->payDeferredSubscription($profile);
|
575 |
+
|
576 |
+
if (!$payDeferredSubscription) {
|
577 |
+
$updateProfile = $paymentCcModel->createFirstRecurringOrder($profile);
|
578 |
+
$updateProfile->save();
|
579 |
+
}
|
580 |
+
}
|
581 |
+
|
582 |
+
if($profile->getState() == Mage_Sales_Model_Recurring_Profile::STATE_CANCELED){
|
583 |
+
$paymentCcModel->firstTransactionSuccess = false;
|
584 |
+
}else{
|
585 |
+
if (!$paymentCcModel->firstTransactionSuccess) {
|
586 |
+
$profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
|
587 |
+
}
|
588 |
+
};
|
589 |
+
$profile->save();
|
590 |
+
$paymentCcModel->_currentProfileId = $profile->getProfileId();
|
591 |
+
}
|
592 |
+
}
|
593 |
+
|
594 |
+
$this->_redirect('checkout/onepage/success');
|
595 |
return;
|
596 |
}
|
597 |
|
598 |
|
599 |
+
|
600 |
$this->getResponse()->setBody(
|
601 |
$this->getLayout()
|
602 |
->createBlock('xpaymentsconnector/beforesuccess')
|
610 |
public function saveusercardAction(){
|
611 |
$request = $this->getRequest()->getPost();
|
612 |
if(!empty($request)){
|
613 |
+
if($request['user_card_save']){
|
614 |
+
Mage::getSingleton('checkout/session')->setData('user_card_save',$request['user_card_save']);
|
615 |
}
|
616 |
}
|
617 |
}
|
618 |
|
619 |
public function istokenactualAction(){
|
620 |
+
$currentToken = $this->getRequest()->getParam('token');
|
621 |
$result = array();
|
622 |
if($currentToken){
|
623 |
+
$savedToken = Mage::helper('xpaymentsconnector')->getIframeToken();
|
624 |
+
$result['is_actual'] = ($currentToken == $savedToken) ? true: false;
|
625 |
}else{
|
626 |
+
$result['is_actual'] = false;
|
627 |
}
|
628 |
|
629 |
+
if(!$result['is_actual']){
|
630 |
+
$result['error_message'] =
|
631 |
+
Mage::helper('xpaymentsconnector')->__('Your order state has been changed during checkout. You will be redirected to the cart contents page.');
|
632 |
+
$result['redirect'] = Mage::getUrl('checkout/cart',array('unset_xp_prepare_order'=>1));
|
633 |
}
|
634 |
|
635 |
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
638 |
|
639 |
public function getcheckoutiframeurlAction(){
|
640 |
$xpUrlPath = array();
|
641 |
+
$xpUrlPath['iframe_url'] = Mage::helper('xpaymentsconnector')->getIframeUrl();
|
642 |
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($xpUrlPath));
|
643 |
}
|
644 |
}
|
app/code/community/Cdev/XPaymentsConnector/etc/config.xml
CHANGED
@@ -23,7 +23,7 @@
|
|
23 |
<config>
|
24 |
<modules>
|
25 |
<Cdev_XPaymentsConnector>
|
26 |
-
<version>1.
|
27 |
</Cdev_XPaymentsConnector>
|
28 |
</modules>
|
29 |
<global>
|
@@ -306,6 +306,10 @@
|
|
306 |
<class>xpaymentsconnector/quote_address_total_nominal_recurring_discount</class>
|
307 |
<sort_order>10</sort_order>
|
308 |
</recurring_discount>
|
|
|
|
|
|
|
|
|
309 |
</nominal_totals>
|
310 |
</quote>
|
311 |
|
@@ -447,7 +451,7 @@
|
|
447 |
<jobs>
|
448 |
<create_order_by_subscription>
|
449 |
<schedule>
|
450 |
-
<cron_expr
|
451 |
</schedule>
|
452 |
<run>
|
453 |
<model>xpaymentsconnector/observer::createOrdersByCustomerSubscriptions</model>
|
23 |
<config>
|
24 |
<modules>
|
25 |
<Cdev_XPaymentsConnector>
|
26 |
+
<version>1.1.1</version>
|
27 |
</Cdev_XPaymentsConnector>
|
28 |
</modules>
|
29 |
<global>
|
306 |
<class>xpaymentsconnector/quote_address_total_nominal_recurring_discount</class>
|
307 |
<sort_order>10</sort_order>
|
308 |
</recurring_discount>
|
309 |
+
<recurring_initialfee_tax>
|
310 |
+
<class>xpaymentsconnector/quote_address_total_nominal_recurring_initialfee_tax</class>
|
311 |
+
<sort_order>11</sort_order>
|
312 |
+
</recurring_initialfee_tax>
|
313 |
</nominal_totals>
|
314 |
</quote>
|
315 |
|
451 |
<jobs>
|
452 |
<create_order_by_subscription>
|
453 |
<schedule>
|
454 |
+
<cron_expr>0 */1 * * *</cron_expr>
|
455 |
</schedule>
|
456 |
<run>
|
457 |
<model>xpaymentsconnector/observer::createOrdersByCustomerSubscriptions</model>
|
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.9-1.1.0.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* Add additional column for storage custom calculating initial fee amount
|
24 |
+
*/
|
25 |
+
|
26 |
+
$installer = $this;
|
27 |
+
$installer->startSetup();
|
28 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/quote_item'), 'xp_recurring_initial_fee', 'decimal(12,4)');
|
29 |
+
$installer->endSetup();
|
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.1.0-1.1.1.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* Add additional column for storage custom calculating initial fee amount
|
24 |
+
*/
|
25 |
+
|
26 |
+
$installer = $this;
|
27 |
+
$installer->startSetup();
|
28 |
+
$installer->getConnection()->addColumn($installer->getTable('sales/quote_item'), 'initialfee_tax_amount', 'decimal(12,4)');
|
29 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/template/xpaymentsconnector/order/view/tab/xporderstate.phtml
CHANGED
@@ -31,11 +31,11 @@
|
|
31 |
<?php if($xpaymentsOrderInfo["success"]): ?>
|
32 |
<?php $xpaymentOrdersInfoList = $xpaymentsOrderInfo["info"];?>
|
33 |
<?php foreach($xpaymentOrdersInfoList as $orderIncrementId => $xpaymentOrderInfoData): ?>
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
<span class="transaction-accordion">
|
40 |
<span class="transaction-down" >
|
41 |
<img src="<?php echo Mage::getBaseUrl('js') . "xpayment/images/arrow-down.png" ?>">
|
@@ -44,221 +44,227 @@
|
|
44 |
<img src="<?php echo Mage::getBaseUrl('js') . "xpayment/images/arrow-up.png" ?>">
|
45 |
</span>
|
46 |
</span>
|
47 |
-
|
48 |
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
<span class="price">
|
100 |
<strong>
|
101 |
<?php echo $transaction["action"];?>
|
102 |
</strong>
|
103 |
</span></td>
|
104 |
-
|
105 |
<span class="price">
|
106 |
<?php echo $transaction["payment_status"];?>
|
107 |
</span>
|
108 |
-
|
109 |
-
|
110 |
<span class="price">
|
111 |
<?php echo $transaction["status"];?>
|
112 |
</span>
|
113 |
-
|
114 |
-
|
115 |
<span class="price">
|
116 |
<strong>
|
117 |
<?php echo $transaction["total"];?>
|
118 |
</strong>
|
119 |
</span>
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
</div>
|
127 |
</div>
|
|
|
128 |
<br/>
|
129 |
-
|
130 |
<?php if (!empty($xpaymentOrdersState)): ?>
|
131 |
<p>
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
<span id="order_title">
|
171 |
<?php echo $this->__($orderStateData["message"]); ?>
|
172 |
</span></h5>
|
173 |
-
|
174 |
-
|
175 |
<?php echo Mage::helper('core')->currency($orderStateData["amount"], true, false); ?>
|
176 |
</span>
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
<span class="price">
|
182 |
-
<?php
|
|
|
|
|
183 |
</span></td>
|
184 |
-
|
185 |
<span class="price">
|
186 |
-
<?php
|
|
|
|
|
187 |
</span>
|
188 |
-
|
189 |
-
|
190 |
<span class="price">
|
191 |
-
<?php
|
|
|
|
|
192 |
</span>
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
</div>
|
260 |
</div>
|
261 |
</div>
|
|
|
262 |
</p>
|
263 |
<?php endif?>
|
264 |
|
31 |
<?php if($xpaymentsOrderInfo["success"]): ?>
|
32 |
<?php $xpaymentOrdersInfoList = $xpaymentsOrderInfo["info"];?>
|
33 |
<?php foreach($xpaymentOrdersInfoList as $orderIncrementId => $xpaymentOrderInfoData): ?>
|
34 |
+
<?php $xpaymentOrdersState[$orderIncrementId] = $xpaymentOrderInfoData["payment"];?>
|
35 |
+
<?php $xpaymentOrdertransactionsList = $xpaymentOrderInfoData["transactions"]; ?>
|
36 |
+
<div class="entry-edit">
|
37 |
+
<div class="entry-edit-head xp-transaction-head-block">
|
38 |
+
<h4><?php echo $this->__("Transaction list for order %s",$orderIncrementId);?></h4>
|
39 |
<span class="transaction-accordion">
|
40 |
<span class="transaction-down" >
|
41 |
<img src="<?php echo Mage::getBaseUrl('js') . "xpayment/images/arrow-down.png" ?>">
|
44 |
<img src="<?php echo Mage::getBaseUrl('js') . "xpayment/images/arrow-up.png" ?>">
|
45 |
</span>
|
46 |
</span>
|
47 |
+
</div>
|
48 |
|
49 |
+
<div class="grid np" style="display: none">
|
50 |
+
<div class="hor-scroll">
|
51 |
+
<table cellspacing="0" id="xpayment-transaction-list" class="data order-tables">
|
52 |
+
<colgroup>
|
53 |
+
<col />
|
54 |
+
<col />
|
55 |
+
<col width="1">
|
56 |
+
<col width="1">
|
57 |
+
<col width="1">
|
58 |
+
<col width="1">
|
59 |
+
<col width="1">
|
60 |
+
</colgroup><thead>
|
61 |
+
<tr class="headings">
|
62 |
+
<th><span class="nobr"><?php echo $this->__('Additional info'); ?></span></th>
|
63 |
+
<th><span class="nobr"><?php echo $this->__('Date, time'); ?></span></th>
|
64 |
+
<th><span class="nobr"><?php echo $this->__('Type'); ?></span></th>
|
65 |
+
<th><span class="nobr"><?php echo $this->__('Result payment status'); ?></span></th>
|
66 |
+
<th class="last"><span class="nobr"><?php echo $this->__('Transaction result'); ?></span></th>
|
67 |
+
<th class="last"><span class="nobr"><?php echo $this->__('Total'); ?></span></th>
|
68 |
+
</tr>
|
69 |
+
</thead>
|
70 |
+
<tbody>
|
71 |
+
<?php $rowClass = "odd";?>
|
72 |
+
<?php foreach($xpaymentOrdertransactionsList as $key => $transaction):?>
|
73 |
+
<?php $rowClass = ($key%2==0)?"even":"odd"; ?>
|
74 |
+
<tr class="border pointer <?php echo $rowClass?>">
|
75 |
+
<td>
|
76 |
+
<div class="item-container" >
|
77 |
+
<table cellspacing="0" class="form-list">
|
78 |
+
<tbody>
|
79 |
+
<?php foreach($transaction["fields"] as $field): ?>
|
80 |
+
<tr>
|
81 |
+
<td class="label"><label><?php echo $field["name"]?></label></td>
|
82 |
+
<td class="value"><strong><?php echo $field["value"]?></strong></td>
|
83 |
+
</tr>
|
84 |
+
<?php endforeach; ?>
|
85 |
+
</tbody>
|
86 |
+
</table>
|
87 |
+
</div>
|
88 |
+
</td>
|
89 |
+
<td>
|
90 |
+
<div class="item-container">
|
91 |
+
<div class="item-text">
|
92 |
+
<strong>
|
93 |
+
<?php echo date("M d,Y H:i:s",$transaction["date"]);?>
|
94 |
+
</strong>
|
95 |
+
</div>
|
96 |
+
</div>
|
97 |
+
</td>
|
98 |
+
<td class="a-center">
|
99 |
<span class="price">
|
100 |
<strong>
|
101 |
<?php echo $transaction["action"];?>
|
102 |
</strong>
|
103 |
</span></td>
|
104 |
+
<td class="a-center">
|
105 |
<span class="price">
|
106 |
<?php echo $transaction["payment_status"];?>
|
107 |
</span>
|
108 |
+
</td>
|
109 |
+
<td class="a-center">
|
110 |
<span class="price">
|
111 |
<?php echo $transaction["status"];?>
|
112 |
</span>
|
113 |
+
</td>
|
114 |
+
<td class="a-center">
|
115 |
<span class="price">
|
116 |
<strong>
|
117 |
<?php echo $transaction["total"];?>
|
118 |
</strong>
|
119 |
</span>
|
120 |
+
</td>
|
121 |
+
</tr>
|
122 |
+
<?php endforeach;?>
|
123 |
+
</tbody>
|
124 |
+
</table>
|
125 |
+
</div>
|
|
|
126 |
</div>
|
127 |
+
</div>
|
128 |
<br/>
|
129 |
+
<?php endforeach;?>
|
130 |
<?php if (!empty($xpaymentOrdersState)): ?>
|
131 |
<p>
|
132 |
+
<div class="entry-edit">
|
133 |
+
<div class="entry-edit-head">
|
134 |
+
<h4><?php echo $this->__('Order(s) state'); ?></h4>
|
135 |
+
</div>
|
136 |
|
137 |
+
<div class="grid">
|
138 |
+
<div class="hor-scroll">
|
139 |
+
<table cellspacing="0" class="data order-tables">
|
140 |
+
<colgroup>
|
141 |
+
<col>
|
142 |
+
<col width="1">
|
143 |
+
<col width="1">
|
144 |
+
<col width="1">
|
145 |
+
<col width="1">
|
146 |
+
</colgroup>
|
147 |
+
<thead>
|
148 |
+
<tr class="headings">
|
149 |
+
<th><span class="nobr"><?php echo $this->__('Order ID'); ?></span></th>
|
150 |
+
<th><span class="nobr"><?php echo $this->__('Amount'); ?></span></th>
|
151 |
+
<th><span class="nobr"><?php echo $this->__('Authorized'); ?></span></th>
|
152 |
+
<th><span class="nobr"><?php echo $this->__('Captured'); ?></span></th>
|
153 |
+
<th class="last"><span class="nobr"><?php echo $this->__('Refunds'); ?></span></th>
|
154 |
+
<th class="last"><span class="nobr"><?php echo $this->__('Actions'); ?></span></th>
|
155 |
+
</tr>
|
156 |
+
</thead>
|
157 |
+
<tbody class="even">
|
158 |
+
<?php foreach ($xpaymentOrdersState as $orderIncrementId => $orderStateData): ?>
|
159 |
+
<tr class="border">
|
160 |
+
<td>
|
161 |
+
<div class="item-text">
|
162 |
+
<?php echo $orderIncrementId;?>
|
163 |
+
</div>
|
164 |
+
</td>
|
165 |
+
<td>
|
166 |
+
<div class="item-container" id="order_item_446">
|
167 |
+
<div class="item-text">
|
168 |
+
<?php if (!empty($orderStateData["message"])): ?>
|
169 |
+
<h5 class="title">
|
170 |
<span id="order_title">
|
171 |
<?php echo $this->__($orderStateData["message"]); ?>
|
172 |
</span></h5>
|
173 |
+
<?php endif; ?>
|
174 |
+
<span class="price">
|
175 |
<?php echo Mage::helper('core')->currency($orderStateData["amount"], true, false); ?>
|
176 |
</span>
|
177 |
+
</div>
|
178 |
+
</div>
|
179 |
+
</td>
|
180 |
+
<td class="a-center">
|
181 |
<span class="price">
|
182 |
+
<?php if($orderStateData["authorized"] > 0): ?>
|
183 |
+
<?php echo Mage::helper('core')->currency($orderStateData["authorized"], true, false); ?>
|
184 |
+
<?php endif;?>
|
185 |
</span></td>
|
186 |
+
<td class="a-center">
|
187 |
<span class="price">
|
188 |
+
<?php if($orderStateData["capturedAmount"] > 0): ?>
|
189 |
+
<?php echo Mage::helper('core')->currency($orderStateData["capturedAmount"], true, false); ?>
|
190 |
+
<?php endif;?>
|
191 |
</span>
|
192 |
+
</td>
|
193 |
+
<td class="a-center">
|
194 |
<span class="price">
|
195 |
+
<?php if($orderStateData["refundedAmount"] > 0): ?>
|
196 |
+
<?php echo Mage::helper('core')->currency($orderStateData["refundedAmount"], true, false); ?>
|
197 |
+
<?php endif;?>
|
198 |
</span>
|
199 |
+
</td>
|
200 |
+
<td>
|
201 |
+
<div class="item-text">
|
202 |
+
<?php
|
203 |
+
$actionAmount = $this->getCurrentActionAmount($orderStateData);
|
204 |
+
$cssFormId = "xp_fast_transactions_".$orderIncrementId;
|
205 |
+
$amountValidatorName = "validate-transaction-amount_".$orderIncrementId;
|
206 |
+
$requiredValidatorName = "required-entry_".$orderIncrementId;
|
207 |
+
$currentUrl = Mage::helper('core/url')->getCurrentUrl();
|
208 |
+
$formKey = Mage::getSingleton('core/session')->getFormKey();
|
209 |
+
?>
|
210 |
|
211 |
+
<form method="post" id="<?php echo $cssFormId?>" class="xp_fast_transactions" action="<?php echo $currentUrl;?>" >
|
212 |
+
<input type="hidden" name="form_key" value="<?php echo $formKey; ?>" />
|
213 |
+
<input type="text"
|
214 |
+
class="<?php echo $amountValidatorName." ".$requiredValidatorName;?> input-text transaction-amount"
|
215 |
+
name="transaction_amount"
|
216 |
+
value="<?php echo $actionAmount?>">
|
217 |
|
218 |
+
<input type="hidden" name="orderid" value="<?php echo $orderIncrementId;?>">
|
219 |
+
<input type="hidden" name="xpc_txnid" value="<?php echo $orderStateData['xpc_txnid'];?>">
|
220 |
+
<input type="hidden" name="xpaction" class="xpaction" value="">
|
221 |
+
<?php if($orderStateData["capturedAmountAvailGateway"] > 0): ?>
|
222 |
+
<input type="button"
|
223 |
+
class="form-button xp-transaction-submit"
|
224 |
+
name="capture"
|
225 |
+
onclick="submitXpTransaction(
|
226 |
+
'capture',
|
227 |
+
'<?php echo $cssFormId?>',
|
228 |
+
'<?php echo $amountValidatorName?>',
|
229 |
+
'<?php echo $requiredValidatorName?>')"
|
230 |
+
value="Capture">
|
231 |
+
</br>
|
232 |
+
<?php endif;?>
|
233 |
+
<?php if($orderStateData["voidedAmountAvailGateway"] > 0): ?>
|
234 |
+
<input type="button"
|
235 |
+
class="form-button xp-transaction-submit"
|
236 |
+
name="void"
|
237 |
+
onclick="submitXpTransaction(
|
238 |
+
'void',
|
239 |
+
'<?php echo $cssFormId?>',
|
240 |
+
'<?php echo $amountValidatorName?>',
|
241 |
+
'<?php echo $requiredValidatorName?>',
|
242 |
+
'<?php echo $orderStateData["voidedAmountAvailGateway"]?>')"
|
243 |
+
class="form-button "
|
244 |
+
value="Void (<?php echo Mage::helper('core')->currency($orderStateData["voidedAmountAvailGateway"], true, false);?>)">
|
245 |
+
<?php endif;?>
|
246 |
+
<?php if($orderStateData["refundedAmountAvailGateway"] > 0): ?>
|
247 |
+
<input
|
248 |
+
type="button"
|
249 |
+
name="refund"
|
250 |
+
class="form-button"
|
251 |
+
onclick="submitXpTransaction(
|
252 |
+
'refund',
|
253 |
+
'<?php echo $cssFormId?>',
|
254 |
+
'<?php echo $amountValidatorName?>',
|
255 |
+
'<?php echo $requiredValidatorName?>')"
|
256 |
+
value="Refund">
|
257 |
+
<?php endif;?>
|
258 |
+
</form>
|
259 |
+
</div>
|
260 |
+
</td>
|
261 |
+
</tr>
|
262 |
+
<?php endforeach?>
|
263 |
+
</tbody>
|
264 |
+
</table>
|
|
|
265 |
</div>
|
266 |
</div>
|
267 |
+
</div>
|
268 |
</p>
|
269 |
<?php endif?>
|
270 |
|
app/design/frontend/default/default/layout/xpaymentsconnector.xml
CHANGED
@@ -52,6 +52,8 @@
|
|
52 |
<reference name="checkout.onepage.review.info.items.after">
|
53 |
<block type="xpaymentsconnector/checkout_onepage_settings" name="xpayment_settings" output="toHtml"
|
54 |
template="xpaymentsconnector/checkout/onepage/xpayment-iframe.phtml"/>
|
|
|
|
|
55 |
</reference>
|
56 |
<reference name="checkout.onepage.review.button">
|
57 |
<action method="setTemplate">
|
52 |
<reference name="checkout.onepage.review.info.items.after">
|
53 |
<block type="xpaymentsconnector/checkout_onepage_settings" name="xpayment_settings" output="toHtml"
|
54 |
template="xpaymentsconnector/checkout/onepage/xpayment-iframe.phtml"/>
|
55 |
+
<block type="xpaymentsconnector/checkout_onepage_orderdetail" name="xpayment_recurring_detail" output="toHtml"
|
56 |
+
template="xpaymentsconnector/checkout/onepage/order-detail.phtml"/>
|
57 |
</reference>
|
58 |
<reference name="checkout.onepage.review.button">
|
59 |
<action method="setTemplate">
|
app/design/frontend/default/default/template/xpaymentsconnector/checkout/onepage/order-detail.phtml
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
<?php
|
23 |
+
/**
|
24 |
+
* Block for additional information about 'recurring items'
|
25 |
+
*
|
26 |
+
* @see Cdev_XPaymentsConnector_Block_Checkout_Onepage_Orderdetail
|
27 |
+
*/
|
28 |
+
?>
|
29 |
+
|
30 |
+
<?php
|
31 |
+
$recurringQuoteItems = $this->getRecurringQuoteItems();
|
32 |
+
?>
|
33 |
+
|
34 |
+
<?php if(!empty($recurringQuoteItems)):?>
|
35 |
+
<div id="recurring-detail-block">
|
36 |
+
<strong><?php echo $this->__('ATTENTION:');?></strong>
|
37 |
+
</br>
|
38 |
+
<?php echo $this->__('Since this orders contains recurring products we we charge your credit card several times:');?>
|
39 |
+
</br>
|
40 |
+
<ul>
|
41 |
+
<?php $simpleQuoteItemMessage = $this->getSimpleQuoteItemMessage(); ?>
|
42 |
+
<?php if ($simpleQuoteItemMessage): ?>
|
43 |
+
<li>
|
44 |
+
<?php echo $simpleQuoteItemMessage; ?>
|
45 |
+
</li>
|
46 |
+
<?php endif; ?>
|
47 |
+
<?php foreach ($recurringQuoteItems as $recQuoteItem): ?>
|
48 |
+
<?php $recQuoteItemMessage = $this->getRecurringItemMessage($recQuoteItem); ?>
|
49 |
+
<?php if ($recQuoteItemMessage): ?>
|
50 |
+
<li>
|
51 |
+
<?php echo $recQuoteItemMessage; ?>
|
52 |
+
</li>
|
53 |
+
<?php endif; ?>
|
54 |
+
<?php endforeach; ?>
|
55 |
+
</ul>
|
56 |
+
</div>
|
57 |
+
<?php endif;?>
|
58 |
+
|
59 |
+
|
app/design/frontend/default/default/template/xpaymentsconnector/checkout/onepage/xpayment-iframe.phtml
CHANGED
@@ -28,23 +28,24 @@
|
|
28 |
?>
|
29 |
|
30 |
<?php
|
|
|
31 |
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
32 |
-
$isRecuringProduct =
|
33 |
$IsSaveCardsPaymentActive = (bool)Mage::getStoreConfig('payment/savedcards/active');
|
34 |
$displayOnPaymentStep = (bool)(Mage::getStoreConfig('payment/xpayments/placedisplay') == "review");
|
35 |
?>
|
36 |
|
37 |
<?php if($this->isXpaymentMethod() && $useIframe && $displayOnPaymentStep):?>
|
38 |
<?php
|
39 |
-
$iFrameUrl =
|
40 |
-
$isNeedToSaveUserCard =
|
41 |
-
$customerRegistered =
|
42 |
?>
|
43 |
<div id="xpayment-iframe-block">
|
44 |
<iframe id="xp-iframe" class="xp-iframe" data-src="<?php echo $iFrameUrl;?>" src="<?php echo $iFrameUrl;?>" name="xp-iframe">
|
45 |
</iframe>
|
46 |
<?php if($customerRegistered):?>
|
47 |
-
<?php if(!$isRecuringProduct): ?>
|
48 |
<?php if ($IsSaveCardsPaymentActive): ?>
|
49 |
<span id="iframe-save-card-switcher" >
|
50 |
<input type="checkbox" <?php echo ($isNeedToSaveUserCard)?"checked":"";?> title="<?php echo $this->__("Use this credit card"); ?>" class="checkbox x-payment-card " id="iframe_savecard" name="iframe_savecard" value="1" />
|
28 |
?>
|
29 |
|
30 |
<?php
|
31 |
+
$xpHelper = Mage::helper("xpaymentsconnector");
|
32 |
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
33 |
+
$isRecuringProduct = $xpHelper->checkIssetRecurringOrder();
|
34 |
$IsSaveCardsPaymentActive = (bool)Mage::getStoreConfig('payment/savedcards/active');
|
35 |
$displayOnPaymentStep = (bool)(Mage::getStoreConfig('payment/xpayments/placedisplay') == "review");
|
36 |
?>
|
37 |
|
38 |
<?php if($this->isXpaymentMethod() && $useIframe && $displayOnPaymentStep):?>
|
39 |
<?php
|
40 |
+
$iFrameUrl = $xpHelper->getIframeUrl();
|
41 |
+
$isNeedToSaveUserCard = $xpHelper->isNeedToSaveUserCard();
|
42 |
+
$customerRegistered = $xpHelper->isRegisteredUser();
|
43 |
?>
|
44 |
<div id="xpayment-iframe-block">
|
45 |
<iframe id="xp-iframe" class="xp-iframe" data-src="<?php echo $iFrameUrl;?>" src="<?php echo $iFrameUrl;?>" name="xp-iframe">
|
46 |
</iframe>
|
47 |
<?php if($customerRegistered):?>
|
48 |
+
<?php if(!$isRecuringProduct["isset"]): ?>
|
49 |
<?php if ($IsSaveCardsPaymentActive): ?>
|
50 |
<span id="iframe-save-card-switcher" >
|
51 |
<input type="checkbox" <?php echo ($isNeedToSaveUserCard)?"checked":"";?> title="<?php echo $this->__("Use this credit card"); ?>" class="checkbox x-payment-card " id="iframe_savecard" name="iframe_savecard" value="1" />
|
app/design/frontend/default/default/template/xpaymentsconnector/form/cc.phtml
CHANGED
@@ -27,7 +27,7 @@
|
|
27 |
<?php
|
28 |
$_code=$this->getMethodCode();
|
29 |
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
30 |
-
$isRecuringProduct = Mage::helper("xpaymentsconnector")->
|
31 |
$IsSaveCardsPaymentActive = (bool)Mage::getStoreConfig('payment/savedcards/active');
|
32 |
|
33 |
// iframe display settings on the current page
|
@@ -38,7 +38,7 @@
|
|
38 |
?>
|
39 |
|
40 |
<?php if (!$useIframe): ?>
|
41 |
-
<?php if (!$isRecuringProduct): ?>
|
42 |
<?php if ($IsSaveCardsPaymentActive): ?>
|
43 |
<ul id="payment_form_<?php echo $_code ?>" style="display:none;">
|
44 |
<li>
|
@@ -71,7 +71,7 @@
|
|
71 |
</iframe>
|
72 |
<div id="paymentstep-ajax-loader"></div>
|
73 |
<?php if($customerRegistered):?>
|
74 |
-
<?php if(!$isRecuringProduct): ?>
|
75 |
<?php if ($IsSaveCardsPaymentActive): ?>
|
76 |
<span id="iframe-save-card-switcher" >
|
77 |
<input type="checkbox" <?php echo ($isNeedToSaveUserCard)?"checked":"";?> title="<?php echo $this->__("Use this credit card"); ?>" class="checkbox x-payment-card " id="iframe_savecard" name="iframe_savecard" value="1" />
|
27 |
<?php
|
28 |
$_code=$this->getMethodCode();
|
29 |
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
30 |
+
$isRecuringProduct = Mage::helper("xpaymentsconnector")->checkIssetRecurringOrder();
|
31 |
$IsSaveCardsPaymentActive = (bool)Mage::getStoreConfig('payment/savedcards/active');
|
32 |
|
33 |
// iframe display settings on the current page
|
38 |
?>
|
39 |
|
40 |
<?php if (!$useIframe): ?>
|
41 |
+
<?php if (!$isRecuringProduct["isset"]): ?>
|
42 |
<?php if ($IsSaveCardsPaymentActive): ?>
|
43 |
<ul id="payment_form_<?php echo $_code ?>" style="display:none;">
|
44 |
<li>
|
71 |
</iframe>
|
72 |
<div id="paymentstep-ajax-loader"></div>
|
73 |
<?php if($customerRegistered):?>
|
74 |
+
<?php if(!$isRecuringProduct["isset"]): ?>
|
75 |
<?php if ($IsSaveCardsPaymentActive): ?>
|
76 |
<span id="iframe-save-card-switcher" >
|
77 |
<input type="checkbox" <?php echo ($isNeedToSaveUserCard)?"checked":"";?> title="<?php echo $this->__("Use this credit card"); ?>" class="checkbox x-payment-card " id="iframe_savecard" name="iframe_savecard" value="1" />
|
app/design/frontend/rwd/default/layout/xpaymentsconnector.xml
CHANGED
@@ -52,6 +52,8 @@
|
|
52 |
<reference name="checkout.onepage.review.info.items.after">
|
53 |
<block type="xpaymentsconnector/checkout_onepage_settings" name="xpayment_settings" output="toHtml"
|
54 |
template="xpaymentsconnector/checkout/onepage/xpayment-iframe.phtml"/>
|
|
|
|
|
55 |
</reference>
|
56 |
<reference name="checkout.onepage.review.button">
|
57 |
<action method="setTemplate">
|
52 |
<reference name="checkout.onepage.review.info.items.after">
|
53 |
<block type="xpaymentsconnector/checkout_onepage_settings" name="xpayment_settings" output="toHtml"
|
54 |
template="xpaymentsconnector/checkout/onepage/xpayment-iframe.phtml"/>
|
55 |
+
<block type="xpaymentsconnector/checkout_onepage_orderdetail" name="xpayment_recurring_detail" output="toHtml"
|
56 |
+
template="xpaymentsconnector/checkout/onepage/order-detail.phtml"/>
|
57 |
</reference>
|
58 |
<reference name="checkout.onepage.review.button">
|
59 |
<action method="setTemplate">
|
app/design/frontend/rwd/default/template/xpaymentsconnector/checkout/onepage/order-detail.phtml
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
<?php
|
23 |
+
/**
|
24 |
+
* Block for additional information about 'recurring items'
|
25 |
+
*
|
26 |
+
* @see Cdev_XPaymentsConnector_Block_Checkout_Onepage_Orderdetail
|
27 |
+
*/
|
28 |
+
?>
|
29 |
+
|
30 |
+
<?php
|
31 |
+
$recurringQuoteItems = $this->getRecurringQuoteItems();
|
32 |
+
?>
|
33 |
+
|
34 |
+
<?php if(!empty($recurringQuoteItems)):?>
|
35 |
+
<div id="recurring-detail-block">
|
36 |
+
<strong><?php echo $this->__('ATTENTION:');?></strong>
|
37 |
+
</br>
|
38 |
+
<?php echo $this->__('Since this orders contains recurring products we we charge your credit card several times:');?>
|
39 |
+
</br>
|
40 |
+
<ul>
|
41 |
+
<?php $simpleQuoteItemMessage = $this->getSimpleQuoteItemMessage(); ?>
|
42 |
+
<?php if ($simpleQuoteItemMessage): ?>
|
43 |
+
<li>
|
44 |
+
<?php echo $simpleQuoteItemMessage; ?>
|
45 |
+
</li>
|
46 |
+
<?php endif; ?>
|
47 |
+
<?php foreach ($recurringQuoteItems as $recQuoteItem): ?>
|
48 |
+
<?php $recQuoteItemMessage = $this->getRecurringItemMessage($recQuoteItem); ?>
|
49 |
+
<?php if ($recQuoteItemMessage): ?>
|
50 |
+
<li>
|
51 |
+
<?php echo $recQuoteItemMessage; ?>
|
52 |
+
</li>
|
53 |
+
<?php endif; ?>
|
54 |
+
<?php endforeach; ?>
|
55 |
+
</ul>
|
56 |
+
</div>
|
57 |
+
<?php endif;?>
|
58 |
+
|
59 |
+
|
app/design/frontend/rwd/default/template/xpaymentsconnector/checkout/onepage/xpayment-iframe.phtml
CHANGED
@@ -28,23 +28,24 @@
|
|
28 |
?>
|
29 |
|
30 |
<?php
|
|
|
31 |
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
32 |
-
$isRecuringProduct =
|
33 |
$IsSaveCardsPaymentActive = (bool)Mage::getStoreConfig('payment/savedcards/active');
|
34 |
$displayOnPaymentStep = (bool)(Mage::getStoreConfig('payment/xpayments/placedisplay') == "review");
|
35 |
?>
|
36 |
|
37 |
<?php if($this->isXpaymentMethod() && $useIframe && $displayOnPaymentStep):?>
|
38 |
<?php
|
39 |
-
$iFrameUrl =
|
40 |
-
$isNeedToSaveUserCard =
|
41 |
-
$customerRegistered =
|
42 |
?>
|
43 |
<div id="xpayment-iframe-block">
|
44 |
<iframe id="xp-iframe" class="xp-iframe" data-src="<?php echo $iFrameUrl;?>" src="<?php echo $iFrameUrl;?>" name="xp-iframe">
|
45 |
</iframe>
|
46 |
<?php if($customerRegistered):?>
|
47 |
-
<?php if(!$isRecuringProduct): ?>
|
48 |
<?php if ($IsSaveCardsPaymentActive): ?>
|
49 |
<span id="iframe-save-card-switcher" >
|
50 |
<input type="checkbox" <?php echo ($isNeedToSaveUserCard)?"checked":"";?> title="<?php echo $this->__("Use this credit card"); ?>" class="checkbox x-payment-card " id="iframe_savecard" name="iframe_savecard" value="1" />
|
28 |
?>
|
29 |
|
30 |
<?php
|
31 |
+
$xpHelper = Mage::helper("xpaymentsconnector");
|
32 |
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
33 |
+
$isRecuringProduct = $xpHelper->checkIssetRecurringOrder();
|
34 |
$IsSaveCardsPaymentActive = (bool)Mage::getStoreConfig('payment/savedcards/active');
|
35 |
$displayOnPaymentStep = (bool)(Mage::getStoreConfig('payment/xpayments/placedisplay') == "review");
|
36 |
?>
|
37 |
|
38 |
<?php if($this->isXpaymentMethod() && $useIframe && $displayOnPaymentStep):?>
|
39 |
<?php
|
40 |
+
$iFrameUrl = $xpHelper->getIframeUrl();
|
41 |
+
$isNeedToSaveUserCard = $xpHelper->isNeedToSaveUserCard();
|
42 |
+
$customerRegistered = $xpHelper->isRegisteredUser();
|
43 |
?>
|
44 |
<div id="xpayment-iframe-block">
|
45 |
<iframe id="xp-iframe" class="xp-iframe" data-src="<?php echo $iFrameUrl;?>" src="<?php echo $iFrameUrl;?>" name="xp-iframe">
|
46 |
</iframe>
|
47 |
<?php if($customerRegistered):?>
|
48 |
+
<?php if(!$isRecuringProduct["isset"]): ?>
|
49 |
<?php if ($IsSaveCardsPaymentActive): ?>
|
50 |
<span id="iframe-save-card-switcher" >
|
51 |
<input type="checkbox" <?php echo ($isNeedToSaveUserCard)?"checked":"";?> title="<?php echo $this->__("Use this credit card"); ?>" class="checkbox x-payment-card " id="iframe_savecard" name="iframe_savecard" value="1" />
|
app/design/frontend/rwd/default/template/xpaymentsconnector/form/cc.phtml
CHANGED
@@ -27,7 +27,7 @@
|
|
27 |
<?php
|
28 |
$_code=$this->getMethodCode();
|
29 |
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
30 |
-
$isRecuringProduct = Mage::helper("xpaymentsconnector")->
|
31 |
$IsSaveCardsPaymentActive = (bool)Mage::getStoreConfig('payment/savedcards/active');
|
32 |
|
33 |
// iframe display settings on the current page
|
@@ -38,7 +38,7 @@
|
|
38 |
?>
|
39 |
|
40 |
<?php if (!$useIframe): ?>
|
41 |
-
<?php if (!$isRecuringProduct): ?>
|
42 |
<?php if ($IsSaveCardsPaymentActive): ?>
|
43 |
<ul id="payment_form_<?php echo $_code ?>" style="display:none;">
|
44 |
<li>
|
@@ -71,7 +71,7 @@
|
|
71 |
</iframe>
|
72 |
<div id="paymentstep-ajax-loader"></div>
|
73 |
<?php if($customerRegistered):?>
|
74 |
-
<?php if(!$isRecuringProduct): ?>
|
75 |
<?php if ($IsSaveCardsPaymentActive): ?>
|
76 |
<span id="iframe-save-card-switcher" >
|
77 |
<input type="checkbox" <?php echo ($isNeedToSaveUserCard)?"checked":"";?> title="<?php echo $this->__("Use this credit card"); ?>" class="checkbox x-payment-card " id="iframe_savecard" name="iframe_savecard" value="1" />
|
27 |
<?php
|
28 |
$_code=$this->getMethodCode();
|
29 |
$useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
|
30 |
+
$isRecuringProduct = Mage::helper("xpaymentsconnector")->checkIssetRecurringOrder();
|
31 |
$IsSaveCardsPaymentActive = (bool)Mage::getStoreConfig('payment/savedcards/active');
|
32 |
|
33 |
// iframe display settings on the current page
|
38 |
?>
|
39 |
|
40 |
<?php if (!$useIframe): ?>
|
41 |
+
<?php if (!$isRecuringProduct["isset"]): ?>
|
42 |
<?php if ($IsSaveCardsPaymentActive): ?>
|
43 |
<ul id="payment_form_<?php echo $_code ?>" style="display:none;">
|
44 |
<li>
|
71 |
</iframe>
|
72 |
<div id="paymentstep-ajax-loader"></div>
|
73 |
<?php if($customerRegistered):?>
|
74 |
+
<?php if(!$isRecuringProduct["isset"]): ?>
|
75 |
<?php if ($IsSaveCardsPaymentActive): ?>
|
76 |
<span id="iframe-save-card-switcher" >
|
77 |
<input type="checkbox" <?php echo ($isNeedToSaveUserCard)?"checked":"";?> title="<?php echo $this->__("Use this credit card"); ?>" class="checkbox x-payment-card " id="iframe_savecard" name="iframe_savecard" value="1" />
|
app/locale/en_US/Cdev_XPaymentsConnector.csv
CHANGED
@@ -23,14 +23,15 @@
|
|
23 |
"For current order we used your payment card (**%s)","For current order we used your payment card (**%s)"
|
24 |
"For current order we charged funds from your payment card (**%s)","For current order we charged funds from your payment card (**%s)"
|
25 |
"Balance:","Balance:"
|
26 |
-
"Transaction list","Transaction list"
|
27 |
"Additional info","Additional info"
|
28 |
"Date, time","Date, time"
|
29 |
"Type","Type"
|
30 |
"Result payment status","Result payment status"
|
31 |
"Transaction result","Transaction result"
|
32 |
"Total","Total"
|
33 |
-
"Order state","Order state"
|
|
|
34 |
"Amount","Amount"
|
35 |
"Authorized","Authorized"
|
36 |
"Captured","Captured"
|
@@ -76,7 +77,7 @@
|
|
76 |
"%s. The subscription has been canceled","%s. The subscription has been canceled"
|
77 |
"Transaction status is '%s'. The subscription has been canceled.","Transaction status is '%s'. The subscription has been canceled."
|
78 |
"The subscription has been canceled.","The subscription has been canceled."
|
79 |
-
"To create a subscription that uses an X-Payments method, your card will be charged a minimal payment - %s%s","To create a subscription that uses an X-Payments method, your card will be charged a minimal payment - %s%s"
|
80 |
"You can't make an order using card (**%s) worth over %s","You can't make an order using card (**%s) worth over %s"
|
81 |
"Transaction token can not be found or has wrong type","Transaction token can not be found or has wrong type"
|
82 |
"Transaction token can not be found or has wrong type. The order has been canceled.","Transaction token can not be found or has wrong type. The order has been canceled."
|
@@ -111,7 +112,13 @@
|
|
111 |
"You created card number '%s'. Transaction status is '%s'.","You created card number '%s'. Transaction status is '%s'."
|
112 |
"Your order state has been changed during checkout. You will be redirected to the cart contents page.","Your order state has been changed during checkout. You will be redirected to the cart contents page."
|
113 |
"Show credit card form at","Show credit card form at"
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
|
117 |
|
23 |
"For current order we used your payment card (**%s)","For current order we used your payment card (**%s)"
|
24 |
"For current order we charged funds from your payment card (**%s)","For current order we charged funds from your payment card (**%s)"
|
25 |
"Balance:","Balance:"
|
26 |
+
"Transaction list for order %s","Transaction list for order %s"
|
27 |
"Additional info","Additional info"
|
28 |
"Date, time","Date, time"
|
29 |
"Type","Type"
|
30 |
"Result payment status","Result payment status"
|
31 |
"Transaction result","Transaction result"
|
32 |
"Total","Total"
|
33 |
+
"Order(s) state","Order(s) state"
|
34 |
+
"Actions","Actions"
|
35 |
"Amount","Amount"
|
36 |
"Authorized","Authorized"
|
37 |
"Captured","Captured"
|
77 |
"%s. The subscription has been canceled","%s. The subscription has been canceled"
|
78 |
"Transaction status is '%s'. The subscription has been canceled.","Transaction status is '%s'. The subscription has been canceled."
|
79 |
"The subscription has been canceled.","The subscription has been canceled."
|
80 |
+
"To create a subscription(s) that uses an X-Payments method, your card will be charged a minimal payment - %s%s","To create a subscription(s) that uses an X-Payments method, your card will be charged a minimal payment - %s%s"
|
81 |
"You can't make an order using card (**%s) worth over %s","You can't make an order using card (**%s) worth over %s"
|
82 |
"Transaction token can not be found or has wrong type","Transaction token can not be found or has wrong type"
|
83 |
"Transaction token can not be found or has wrong type. The order has been canceled.","Transaction token can not be found or has wrong type. The order has been canceled."
|
112 |
"You created card number '%s'. Transaction status is '%s'.","You created card number '%s'. Transaction status is '%s'."
|
113 |
"Your order state has been changed during checkout. You will be redirected to the cart contents page.","Your order state has been changed during checkout. You will be redirected to the cart contents page."
|
114 |
"Show credit card form at","Show credit card form at"
|
115 |
+
"Transaction '%s' to order (%s) was successful!","Transaction '%s' to order (%s) was successful!"
|
116 |
+
"You can't delete %s card. Because this is recurring card and this recurring(s) is still active.","You can't delete %s card. Because this is recurring card and this recurring(s) is still active."
|
117 |
+
"Since this orders contains recurring products we we charge your credit card several times:","Since this orders contains recurring products we we charge your credit card several times:"
|
118 |
+
"ATTENTION:","ATTENTION:"
|
119 |
+
" (initial fee only, 1st recurring fee will be charged on %s)"," (initial fee only, 1st recurring fee will be charged on %s)"
|
120 |
+
"%s%s for recurring product '%s' in your cart.","%s%s for recurring product '%s' in your cart."
|
121 |
+
"%s%s for all non-recurring products in your cart.","%s%s for all non-recurring products in your cart."
|
122 |
|
123 |
|
124 |
|
js/xpayment/checkout-submit.js
CHANGED
@@ -67,7 +67,9 @@ function submitXpaymentIframe(iframeCheckUrl) {
|
|
67 |
|
68 |
function receiveMessage(event)
|
69 |
{
|
70 |
-
jQuery("#opc-payment
|
|
|
|
|
71 |
jQuery("#review-buttons-container .btn-checkout").show();
|
72 |
jQuery("#review-please-wait").hide();
|
73 |
}
|
67 |
|
68 |
function receiveMessage(event)
|
69 |
{
|
70 |
+
if(jQuery("#opc-payment #xp-iframe").length){
|
71 |
+
jQuery("#opc-payment .step-title").click();
|
72 |
+
}
|
73 |
jQuery("#review-buttons-container .btn-checkout").show();
|
74 |
jQuery("#review-please-wait").hide();
|
75 |
}
|
js/xpayment/settings.css
CHANGED
@@ -454,3 +454,11 @@ iframe .buttonRow {
|
|
454 |
}
|
455 |
|
456 |
/*end(xp transaction form)*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
454 |
}
|
455 |
|
456 |
/*end(xp transaction form)*/
|
457 |
+
|
458 |
+
#recurring-detail-block ul {
|
459 |
+
list-style-type:disc;
|
460 |
+
}
|
461 |
+
|
462 |
+
#recurring-detail-block li {
|
463 |
+
margin-left: 15px;
|
464 |
+
}
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>CDev_XPaymentsConnector</name>
|
4 |
-
<version>1.3.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
|
7 |
<channel>community</channel>
|
@@ -10,11 +10,11 @@
|
|
10 |
<description>X-Payments connector
|
11 |
This extension integrates Magento with X-Payments - a PA-DSS certified payment module.
|
12 |
</description>
|
13 |
-
<notes>Version number: 1.3.
|
14 |
<authors><author><name>Valerii Demidov</name><user>Valerii</user><email>vdemidov@corp.web4pro.com.ua</email></author></authors>
|
15 |
-
<date>
|
16 |
-
<time>
|
17 |
-
<contents><target name="magecommunity"><dir name="Cdev"><dir name="XPaymentsConnector"><dir name="Block"><dir name="Adminhtml"><dir name="Customer"><dir name="Edit"><dir name="Renderer"><file name="Cardtype.php" hash="62499b375fa9c7ba091ff7763d54a95d"/><file name="Txnid.php" hash="13d4ed0d24df35cc9956dc155b3ce8b5"/></dir><dir name="Tab"><file name="Usercards.php" hash="248e454bc1c43d41013fd5d077b39961"/></dir></dir></dir><dir name="Sales"><dir name="Order"><dir name="View"><dir name="Tab"><file name="Xporderstate.php" hash="92505c87913d8a49d246c12669d5e0b5"/></dir></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><file name="Subselect.php" hash="c989f9ce4b9af2885c6d28e874825eab"/></dir></dir></dir><dir name="Usercards"><file name="Grid.php" hash="ba4e515d5e9342b11d63dc796aa96e8a"/></dir></dir><file name="Beforesuccess.php" hash="60a7d25651a98f71ca67ed70380e1659"/><file name="Cancel.php" hash="3283657e21047278d81ac4478ac81de6"/><dir name="Checkout"><dir name="Onepage"><file name="Settings.php" hash="cb6c6eac7712be2889b03a9762db25b6"/></dir></dir><file name="Control.php" hash="e0ef77a236030598882937acb2a9c4e0"/><dir name="Customer"><dir name="Account"><file name="Navigation.php" hash="aad9aa09d20706f042f1deac00d04473"/></dir><file name="Cardadd.php" hash="d46b80f3ee05cc46faf3d74b589baafa"/><file name="Success.php" hash="54f243e60b735cdd5cd879be65838fee"/><file name="Usercards.php" hash="ce4b7f73fb735a55d914ba0dad38d68a"/></dir><file name="Failure.php" hash="537aec3d3ee63ff1ac2d2300c2ca259e"/><dir name="Form"><file name="Cc.php" hash="e66f4a72b6ef02cdec8c45522a171568"/><file name="Container.php" hash="f5b3fd1fbf43eee8a6036a2a3a0bd5f7"/><file name="Prepaidpayments.php" hash="66959c7b8e7714f80f44da9afde93936"/><file name="Savedcards.php" hash="552579e7918fc666dc6de8983fc185b3"/></dir><dir name="Info"><file name="Cc.php" hash="80ec2f2dd7691519d481977ab7bdcec4"/><file name="Prepaidpayments.php" hash="5046201a95c114c6020696b7d2855b7f"/><file name="Savedcards.php" hash="5e8b71515b6d516621aea6abfda332fe"/></dir><dir name="Recurring"><dir name="Profile"><file name="View.php" hash="ee800cc7d48e437d3e993e5bd6d42a96"/></dir></dir><file name="Redirect.php" hash="e4745b70dbe2d33b327a70eb195c9345"/><file name="Success.php" hash="d2f023bc2206cbb33997b791a57b1b4e"/></dir><dir name="Helper"><file name="Data.php" hash="f8788883d2a01fbfbc036d445637b7df"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Source"><file name="Placedisplay.php" hash="a42a68646dc2e1aa77502ec1be0dbaf7"/></dir></dir></dir></dir><dir name="Mysql4"><dir name="Paymentconfiguration"><file name="Collection.php" hash="98760f276af5182d42801865cb116db4"/></dir><file name="Paymentconfiguration.php" hash="ca045f953ec018c583279340c137ff71"/><dir name="Usercards"><file name="Collection.php" hash="6df6d26bef085e86c6db625487006086"/></dir><file name="Usercards.php" hash="ffb98ad5a0c252bbbf14adb086cf0d3c"/></dir><file name="Observer.php" hash="13c09412e4b03d64b600668f74dfa1bb"/><dir name="Payment"><file name="Cc.php" hash="20152eb2e1102aa57d651ac327343036"/><file name="Prepaidpayments.php" hash="9bbab2a26748c59609d6c81d8fc37c41"/><dir name="Recurring"><file name="Profile.php" hash="7c0e5c707531e5d258b8c493243c00a1"/></dir><file name="Savedcards.php" hash="e97d591bcdf4b66231aa62cb72b32770"/></dir><file name="Paymentconfiguration.php" hash="c0a6c5b610e42037f9904247e657a0e6"/><dir name="Quote"><dir name="Address"><dir name="Total"><dir name="Nominal"><dir name="Recurring"><file name="Discount.php" hash="9c2ee0abac22865bb349dc11cebd66b2"/></dir></dir><file name="Nominal.php" hash="a835e5ed1692a8712571db963c22bd60"/></dir></dir></dir><file name="Quote.php" hash="01a8a985a91d805a1af4950406bd89bf"/><dir name="Sales"><dir name="Recurring"><file name="Profile.php" hash="5f5486cb753946720ad932b6eb5d6831"/></dir></dir><dir name="Source"><file name="Paymentconfiguration.php" hash="eb9b8e1187a4a4f4614582d5f7932c37"/></dir><file name="Usercards.php" hash="049b38f03920a17d5dbd0ba5e3a834cc"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="CustomerController.php" hash="8f2bc887259b9d5ae6f3a731e7a2eb6a"/></dir><file name="ControlController.php" hash="92e1380179483d97cd27be1d147833ba"/><file name="CustomerController.php" hash="38cb8af6cf9cf609fd31da5ec79ef263"/><file name="ProcessingController.php" hash="027c7e13ef50375a030aca4dba27381f"/></dir><dir name="etc"><file name="config.xml" hash="04277e4db8262ae9d325218019acbfa8"/><file name="system.xml" hash="40015b50b9b503d49bed0e850cd78e03"/></dir><dir name="sql"><dir name="xpaymentsconnector_setup"><file name="mysql4-install-1.0.0.php" hash="5b6ed901a54700d986dd81029104ed72"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="5e2da32a0f87b747a5e9f3d9095e962a"/><file name="mysql4-upgrade-1.0.1-1.0.2.php" hash="566cd8aa894ff488f60bd718ad8b2772"/><file name="mysql4-upgrade-1.0.2-1.0.3.php" hash="0f44cf02457c2b6a887b399e94b89e57"/><file name="mysql4-upgrade-1.0.3-1.0.4.php" hash="f353d20a6d6ac827be5cd581cc988660"/><file name="mysql4-upgrade-1.0.4-1.0.5.php" hash="9b71385496b9b42e5a79b0cbbc557dff"/><file name="mysql4-upgrade-1.0.5-1.0.6.php" hash="fa79555b4802a96579f314a670ab8ed3"/><file name="mysql4-upgrade-1.0.6-1.0.7.php" hash="b9708303f3160fc0c9347f4600e27aba"/><file name="mysql4-upgrade-1.0.7-1.0.8.php" hash="2d07945a0438bf29f1386e47b2b5498b"/><file name="mysql4-upgrade-1.0.8-1.0.9.php" hash="83a4aace7f0e389c5caaaf97675f6c24"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="xpaymentsconnector.xml" hash="4a769cd81f4c37da59b400510c49593d"/></dir><dir name="template"><dir name="xpaymentsconnector"><file name="control.phtml" hash="66bb941b66f57585b2035f29afcea22d"/><dir name="form"><file name="prepaidpayments.phtml" hash="bfe70a3c62187bcd9915fb621eda58b9"/><file name="savedcards.phtml" hash="27ef4734f19ded0eb98214276a58e550"/></dir><dir name="info"><file name="cc.phtml" hash="67282ccf6f932de083bc477cc4238d22"/><file name="prepaidpayments.phtml" hash="f4bd2aa628257cb1f3450a1632a0b771"/><file name="savedcards.phtml" hash="2f79fa323b250786fb4acbee4a2a8809"/></dir><file name="info.phtml" hash="ab312e6f206c51ff3134b9a3ce5b5440"/><dir name="order"><dir name="view"><dir name="tab"><file name="xporderstate.phtml" hash="88d3a2f3b008553b46f3e2e0488a7a5a"/></dir></dir></dir><dir name="pdf"><file name="info.phtml" hash="9603c212b8efd1247ce36239d7365a73"/></dir><dir name="usercards"><dir name="tab"><file name="js.phtml" hash="ae8189ee0b9f0bd09d61692403527331"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="xpaymentsconnector.xml" hash="3c61c475430307e89459a92b44b140e6"/></dir><dir name="template"><dir name="xpaymentsconnector"><file name="blank.phtml" hash="a22778db8681a9aaee22eb2d8f8c6533"/><file name="cancel.phtml" hash="3ba9764fcbf85a3504664b342450ec2b"/><dir name="checkout"><dir name="onepage"><file name="beforesuccess.phtml" hash="8e05eff3705ac40d758c21523640f969"/><dir name="review"><file name="button.phtml" hash="ed96034bc129f74af1020384499840a9"/></dir><file name="xpayment-iframe.phtml" hash="193d75fa0cc4c11f7ffc94becbfb4afa"/></dir></dir><dir name="customer"><file name="cardaddsuccess.phtml" hash="6771721173b99c0cf70391c22d878276"/><dir name="usercards"><file name="cardadd.phtml" hash="8b347d0f43deb95710709ab7010bf1d7"/><file name="list.phtml" hash="5bf980a24c788af17cd80a8bf511807f"/></dir></dir><file name="failure.phtml" hash="3d0691440fda2d1f3a314cd151d6ea90"/><dir name="form"><file name="cc.phtml" hash="6977a84c16bc2ba0bff8347dc7715069"/><file name="savedcards.phtml" hash="acbfcc5771443fcee06d715c3c049546"/></dir><dir name="info"><file name="cc.phtml" hash="9f96547c119d966eb26c67fb557cf1b8"/><file name="prepaidpayments.phtml" hash="f4bd2aa628257cb1f3450a1632a0b771"/><file name="savedcards.phtml" hash="b44b31ecdf8c653ea8299c9664061b27"/></dir><file name="redirect.phtml" hash="4c9c74e94c9a3015dee181a0ef978550"/></dir></dir></dir></dir><dir name="rwd"><dir name="default"><dir name="layout"><file name="xpaymentsconnector.xml" hash="3c61c475430307e89459a92b44b140e6"/></dir><dir name="template"><dir name="xpaymentsconnector"><file name="blank.phtml" hash="a22778db8681a9aaee22eb2d8f8c6533"/><file name="cancel.phtml" hash="3ba9764fcbf85a3504664b342450ec2b"/><dir name="checkout"><dir name="onepage"><file name="beforesuccess.phtml" hash="8e05eff3705ac40d758c21523640f969"/><dir name="review"><file name="button.phtml" hash="ed96034bc129f74af1020384499840a9"/></dir><file name="xpayment-iframe.phtml" hash="193d75fa0cc4c11f7ffc94becbfb4afa"/></dir></dir><dir name="customer"><file name="cardaddsuccess.phtml" hash="6771721173b99c0cf70391c22d878276"/><dir name="usercards"><file name="cardadd.phtml" hash="8b347d0f43deb95710709ab7010bf1d7"/><file name="list.phtml" hash="5bf980a24c788af17cd80a8bf511807f"/></dir></dir><file name="failure.phtml" hash="3d0691440fda2d1f3a314cd151d6ea90"/><dir name="form"><file name="cc.phtml" hash="6977a84c16bc2ba0bff8347dc7715069"/><file name="savedcards.phtml" hash="acbfcc5771443fcee06d715c3c049546"/></dir><dir name="info"><file name="cc.phtml" hash="9f96547c119d966eb26c67fb557cf1b8"/><file name="prepaidpayments.phtml" hash="f4bd2aa628257cb1f3450a1632a0b771"/><file name="savedcards.phtml" hash="b44b31ecdf8c653ea8299c9664061b27"/></dir><file name="redirect.phtml" hash="4c9c74e94c9a3015dee181a0ef978550"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cdev_XPaymentsConnector.xml" hash="3b87bc5a9c17519d38e7de93b5ad13b9"/></dir></target><target name="mage"><dir name="js"><dir name="xpayment"><file name="backend-xpayment.js" hash="adb23ae4c5a320318d9e3cf26558fffd"/><file name="checkout-submit.js" hash="f6203cdcc53d44b281eae5349d55d412"/><dir name="images"><file name="arrow-down.png" hash="a0beb6cd0ca4dd686ee5bf772432176e"/><file name="arrow-up.png" hash="df40115c816a7e08016c04120ac22e53"/><file name="card_types.png" hash="d35ba97c55e2cc1273a0dd1d7862d84c"/><file name="loader.gif" hash="e67d85a8d2d4021514815d0ff4d65173"/></dir><file name="settings.css" hash="2fd21e43fa991f0304d0de4dc377643c"/></dir></dir></target><target name="magelocale"><dir><dir name="en_US"><file name="Cdev_XPaymentsConnector.csv" hash="d3b55522dd6832c05138d65195a82f87"/></dir></dir></target></contents>
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
20 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>CDev_XPaymentsConnector</name>
|
4 |
+
<version>1.3.2</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
|
7 |
<channel>community</channel>
|
10 |
<description>X-Payments connector
|
11 |
This extension integrates Magento with X-Payments - a PA-DSS certified payment module.
|
12 |
</description>
|
13 |
+
<notes>Version number: 1.3.2</notes>
|
14 |
<authors><author><name>Valerii Demidov</name><user>Valerii</user><email>vdemidov@corp.web4pro.com.ua</email></author></authors>
|
15 |
+
<date>2015-02-05</date>
|
16 |
+
<time>16:29:40</time>
|
17 |
+
<contents><target name="magecommunity"><dir name="Cdev"><dir name="XPaymentsConnector"><dir name="Block"><dir name="Adminhtml"><dir name="Customer"><dir name="Edit"><dir name="Renderer"><file name="Cardtype.php" hash="62499b375fa9c7ba091ff7763d54a95d"/><file name="Txnid.php" hash="13d4ed0d24df35cc9956dc155b3ce8b5"/></dir><dir name="Tab"><file name="Usercards.php" hash="248e454bc1c43d41013fd5d077b39961"/></dir></dir></dir><dir name="Sales"><dir name="Order"><dir name="View"><dir name="Tab"><file name="Xporderstate.php" hash="907a1e3917994e5cf5d70b8cb7ebbc18"/></dir></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><file name="Subselect.php" hash="c989f9ce4b9af2885c6d28e874825eab"/></dir></dir></dir><dir name="Usercards"><file name="Grid.php" hash="ba4e515d5e9342b11d63dc796aa96e8a"/></dir></dir><file name="Beforesuccess.php" hash="60a7d25651a98f71ca67ed70380e1659"/><file name="Cancel.php" hash="3283657e21047278d81ac4478ac81de6"/><dir name="Checkout"><dir name="Onepage"><file name="Orderdetail.php" hash="4073d0b05c272cf3ad4c29da2a5f763f"/><file name="Settings.php" hash="cb6c6eac7712be2889b03a9762db25b6"/></dir></dir><file name="Control.php" hash="e0ef77a236030598882937acb2a9c4e0"/><dir name="Customer"><dir name="Account"><file name="Navigation.php" hash="aad9aa09d20706f042f1deac00d04473"/></dir><file name="Cardadd.php" hash="d46b80f3ee05cc46faf3d74b589baafa"/><file name="Success.php" hash="54f243e60b735cdd5cd879be65838fee"/><file name="Usercards.php" hash="ce4b7f73fb735a55d914ba0dad38d68a"/></dir><file name="Failure.php" hash="537aec3d3ee63ff1ac2d2300c2ca259e"/><dir name="Form"><file name="Cc.php" hash="e66f4a72b6ef02cdec8c45522a171568"/><file name="Container.php" hash="f5b3fd1fbf43eee8a6036a2a3a0bd5f7"/><file name="Prepaidpayments.php" hash="66959c7b8e7714f80f44da9afde93936"/><file name="Savedcards.php" hash="552579e7918fc666dc6de8983fc185b3"/></dir><dir name="Info"><file name="Cc.php" hash="80ec2f2dd7691519d481977ab7bdcec4"/><file name="Prepaidpayments.php" hash="5046201a95c114c6020696b7d2855b7f"/><file name="Savedcards.php" hash="5e8b71515b6d516621aea6abfda332fe"/></dir><dir name="Recurring"><dir name="Profile"><file name="View.php" hash="d795b6e5ef5df912faa5537f38c5eb4b"/></dir></dir><file name="Redirect.php" hash="e4745b70dbe2d33b327a70eb195c9345"/><file name="Success.php" hash="d2f023bc2206cbb33997b791a57b1b4e"/></dir><dir name="Helper"><file name="Data.php" hash="de79f088a435cc4f218e6863bf8c24bf"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Source"><file name="Placedisplay.php" hash="a42a68646dc2e1aa77502ec1be0dbaf7"/></dir></dir></dir></dir><dir name="Mysql4"><dir name="Paymentconfiguration"><file name="Collection.php" hash="98760f276af5182d42801865cb116db4"/></dir><file name="Paymentconfiguration.php" hash="ca045f953ec018c583279340c137ff71"/><dir name="Usercards"><file name="Collection.php" hash="6df6d26bef085e86c6db625487006086"/></dir><file name="Usercards.php" hash="ffb98ad5a0c252bbbf14adb086cf0d3c"/></dir><file name="Observer.php" hash="e52b47f0595ebca44a7682f0f713b07f"/><dir name="Payment"><file name="Cc.php" hash="e720e622005780b4b6cdc20edc08a64a"/><file name="Prepaidpayments.php" hash="9bbab2a26748c59609d6c81d8fc37c41"/><dir name="Recurring"><file name="Profile.php" hash="7c0e5c707531e5d258b8c493243c00a1"/></dir><file name="Savedcards.php" hash="3411a8224120800477a857a6a3dbe63b"/></dir><file name="Paymentconfiguration.php" hash="c0a6c5b610e42037f9904247e657a0e6"/><dir name="Quote"><dir name="Address"><dir name="Total"><dir name="Nominal"><dir name="Recurring"><file name="Discount.php" hash="9c2ee0abac22865bb349dc11cebd66b2"/><dir name="Initialfee"><file name="Tax.php" hash="892804e777f2e1bba1e57cd03d96e5b2"/></dir></dir></dir><file name="Nominal.php" hash="1f57e688dbd2fa26fd1c3c18a830bc04"/></dir></dir></dir><file name="Quote.php" hash="9ddf19dfd97cbbe6423e80207f81a42f"/><dir name="Sales"><dir name="Recurring"><file name="Profile.php" hash="2d2333a03534938f1823a9031cfbbf10"/></dir></dir><dir name="Source"><file name="Paymentconfiguration.php" hash="eb9b8e1187a4a4f4614582d5f7932c37"/></dir><file name="Usercards.php" hash="049b38f03920a17d5dbd0ba5e3a834cc"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="CustomerController.php" hash="8f2bc887259b9d5ae6f3a731e7a2eb6a"/></dir><file name="ControlController.php" hash="92e1380179483d97cd27be1d147833ba"/><file name="CustomerController.php" hash="075e976ce6a5b9fbe7844a4a157fc41c"/><file name="ProcessingController.php" hash="230df2cf7ff6ddb13b60bde95148c6c9"/></dir><dir name="etc"><file name="config.xml" hash="f695161c0abc02c5b4c400e23eaa3fc0"/><file name="system.xml" hash="40015b50b9b503d49bed0e850cd78e03"/></dir><dir name="sql"><dir name="xpaymentsconnector_setup"><file name="mysql4-install-1.0.0.php" hash="5b6ed901a54700d986dd81029104ed72"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="5e2da32a0f87b747a5e9f3d9095e962a"/><file name="mysql4-upgrade-1.0.1-1.0.2.php" hash="566cd8aa894ff488f60bd718ad8b2772"/><file name="mysql4-upgrade-1.0.2-1.0.3.php" hash="0f44cf02457c2b6a887b399e94b89e57"/><file name="mysql4-upgrade-1.0.3-1.0.4.php" hash="f353d20a6d6ac827be5cd581cc988660"/><file name="mysql4-upgrade-1.0.4-1.0.5.php" hash="9b71385496b9b42e5a79b0cbbc557dff"/><file name="mysql4-upgrade-1.0.5-1.0.6.php" hash="fa79555b4802a96579f314a670ab8ed3"/><file name="mysql4-upgrade-1.0.6-1.0.7.php" hash="b9708303f3160fc0c9347f4600e27aba"/><file name="mysql4-upgrade-1.0.7-1.0.8.php" hash="2d07945a0438bf29f1386e47b2b5498b"/><file name="mysql4-upgrade-1.0.8-1.0.9.php" hash="83a4aace7f0e389c5caaaf97675f6c24"/><file name="mysql4-upgrade-1.0.9-1.1.0.php" hash="57f95a027f6f0b4871f883e370dd1f51"/><file name="mysql4-upgrade-1.1.0-1.1.1.php" hash="61c4abd29823a909e14a9653ddd41825"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="xpaymentsconnector.xml" hash="4a769cd81f4c37da59b400510c49593d"/></dir><dir name="template"><dir name="xpaymentsconnector"><file name="control.phtml" hash="66bb941b66f57585b2035f29afcea22d"/><dir name="form"><file name="prepaidpayments.phtml" hash="bfe70a3c62187bcd9915fb621eda58b9"/><file name="savedcards.phtml" hash="27ef4734f19ded0eb98214276a58e550"/></dir><dir name="info"><file name="cc.phtml" hash="67282ccf6f932de083bc477cc4238d22"/><file name="prepaidpayments.phtml" hash="f4bd2aa628257cb1f3450a1632a0b771"/><file name="savedcards.phtml" hash="2f79fa323b250786fb4acbee4a2a8809"/></dir><file name="info.phtml" hash="ab312e6f206c51ff3134b9a3ce5b5440"/><dir name="order"><dir name="view"><dir name="tab"><file name="xporderstate.phtml" hash="9147e963aa81731307b8c854ca8f4f64"/></dir></dir></dir><dir name="pdf"><file name="info.phtml" hash="9603c212b8efd1247ce36239d7365a73"/></dir><dir name="usercards"><dir name="tab"><file name="js.phtml" hash="ae8189ee0b9f0bd09d61692403527331"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="xpaymentsconnector.xml" hash="97340916013f0bb3dfc72deeac4891d3"/></dir><dir name="template"><dir name="xpaymentsconnector"><file name="blank.phtml" hash="a22778db8681a9aaee22eb2d8f8c6533"/><file name="cancel.phtml" hash="3ba9764fcbf85a3504664b342450ec2b"/><dir name="checkout"><dir name="onepage"><file name="beforesuccess.phtml" hash="8e05eff3705ac40d758c21523640f969"/><file name="order-detail.phtml" hash="466423a77fc9a97e1f4db15b9f1650f8"/><dir name="review"><file name="button.phtml" hash="ed96034bc129f74af1020384499840a9"/></dir><file name="xpayment-iframe.phtml" hash="a3916b5115beff8b9a8f3338c85cdf24"/></dir></dir><dir name="customer"><file name="cardaddsuccess.phtml" hash="6771721173b99c0cf70391c22d878276"/><dir name="usercards"><file name="cardadd.phtml" hash="8b347d0f43deb95710709ab7010bf1d7"/><file name="list.phtml" hash="5bf980a24c788af17cd80a8bf511807f"/></dir></dir><file name="failure.phtml" hash="3d0691440fda2d1f3a314cd151d6ea90"/><dir name="form"><file name="cc.phtml" hash="9d6f013e0b935168865364aa99f23df4"/><file name="savedcards.phtml" hash="acbfcc5771443fcee06d715c3c049546"/></dir><dir name="info"><file name="cc.phtml" hash="9f96547c119d966eb26c67fb557cf1b8"/><file name="prepaidpayments.phtml" hash="f4bd2aa628257cb1f3450a1632a0b771"/><file name="savedcards.phtml" hash="b44b31ecdf8c653ea8299c9664061b27"/></dir><file name="redirect.phtml" hash="4c9c74e94c9a3015dee181a0ef978550"/></dir></dir></dir></dir><dir name="rwd"><dir name="default"><dir name="layout"><file name="xpaymentsconnector.xml" hash="97340916013f0bb3dfc72deeac4891d3"/></dir><dir name="template"><dir name="xpaymentsconnector"><file name="blank.phtml" hash="a22778db8681a9aaee22eb2d8f8c6533"/><file name="cancel.phtml" hash="3ba9764fcbf85a3504664b342450ec2b"/><dir name="checkout"><dir name="onepage"><file name="beforesuccess.phtml" hash="8e05eff3705ac40d758c21523640f969"/><file name="order-detail.phtml" hash="466423a77fc9a97e1f4db15b9f1650f8"/><dir name="review"><file name="button.phtml" hash="ed96034bc129f74af1020384499840a9"/></dir><file name="xpayment-iframe.phtml" hash="a3916b5115beff8b9a8f3338c85cdf24"/></dir></dir><dir name="customer"><file name="cardaddsuccess.phtml" hash="6771721173b99c0cf70391c22d878276"/><dir name="usercards"><file name="cardadd.phtml" hash="8b347d0f43deb95710709ab7010bf1d7"/><file name="list.phtml" hash="5bf980a24c788af17cd80a8bf511807f"/></dir></dir><file name="failure.phtml" hash="3d0691440fda2d1f3a314cd151d6ea90"/><dir name="form"><file name="cc.phtml" hash="9d6f013e0b935168865364aa99f23df4"/><file name="savedcards.phtml" hash="acbfcc5771443fcee06d715c3c049546"/></dir><dir name="info"><file name="cc.phtml" hash="9f96547c119d966eb26c67fb557cf1b8"/><file name="prepaidpayments.phtml" hash="f4bd2aa628257cb1f3450a1632a0b771"/><file name="savedcards.phtml" hash="b44b31ecdf8c653ea8299c9664061b27"/></dir><file name="redirect.phtml" hash="4c9c74e94c9a3015dee181a0ef978550"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cdev_XPaymentsConnector.xml" hash="3b87bc5a9c17519d38e7de93b5ad13b9"/></dir></target><target name="mage"><dir name="js"><dir name="xpayment"><file name="backend-xpayment.js" hash="adb23ae4c5a320318d9e3cf26558fffd"/><file name="checkout-submit.js" hash="e5a6861f279564f63c73cbb110f06938"/><dir name="images"><file name="arrow-down.png" hash="a0beb6cd0ca4dd686ee5bf772432176e"/><file name="arrow-up.png" hash="df40115c816a7e08016c04120ac22e53"/><file name="card_types.png" hash="d35ba97c55e2cc1273a0dd1d7862d84c"/><file name="loader.gif" hash="e67d85a8d2d4021514815d0ff4d65173"/></dir><file name="settings.css" hash="529b0402ad92803278f6b7f81399e47d"/></dir></dir></target><target name="magelocale"><dir><dir name="en_US"><file name="Cdev_XPaymentsConnector.csv" hash="2f7c72d8648f87d11ce9a969e38a8676"/></dir></dir></target></contents>
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
20 |
</package>
|