Version Notes
Good!
Download this release
Release Info
| Developer | PB |
| Extension | 9bbd841bf705997db5b5633f8e1b794d |
| Version | 1.0.0.0 |
| Comparing to | |
| See all releases | |
Version 1.0.0.0
- Payparts_Payment-1.0.0.0/app/code/local/Payparts/Payment/Block/Message.php +15 -0
- Payparts_Payment-1.0.0.0/app/code/local/Payparts/Payment/Block/Redirect.php +33 -0
- Payparts_Payment-1.0.0.0/app/code/local/Payparts/Payment/Helper/Data.php +35 -0
- Payparts_Payment-1.0.0.0/app/code/local/Payparts/Payment/Model/Redirect.php +308 -0
- Payparts_Payment-1.0.0.0/app/code/local/Payparts/Payment/controllers/PaymentController.php +104 -0
- Payparts_Payment-1.0.0.0/app/code/local/Payparts/Payment/etc/config.xml +68 -0
- Payparts_Payment-1.0.0.0/app/code/local/Payparts/Payment/etc/system.xml +109 -0
- Payparts_Payment-1.0.0.0/app/design/frontend/base/default/template/payparts/message.phtml +86 -0
- Payparts_Payment-1.0.0.0/app/design/frontend/base/default/template/payparts/redirect.phtml +6 -0
- Payparts_Payment-1.0.0.0/app/etc/modules/Payparts_Payparts_Payment.xml +13 -0
- Payparts_Payment-1.0.0.0/app/locale/ru_RU/Payparts_Payment.csv +15 -0
- package.xml +18 -0
Payparts_Payment-1.0.0.0/app/code/local/Payparts/Payment/Block/Message.php
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Payparts notification "form"
|
| 4 |
+
*/
|
| 5 |
+
class Payparts_Payment_Block_Message extends Mage_Payment_Block_Form
|
| 6 |
+
{
|
| 7 |
+
/**
|
| 8 |
+
* Set template with message
|
| 9 |
+
*/
|
| 10 |
+
protected function _construct()
|
| 11 |
+
{
|
| 12 |
+
parent::_construct();
|
| 13 |
+
$this->setTemplate('payparts/message.phtml');
|
| 14 |
+
}
|
| 15 |
+
}
|
Payparts_Payment-1.0.0.0/app/code/local/Payparts/Payment/Block/Redirect.php
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Payparts_Payment_Block_Redirect extends Mage_Core_Block_Template {
|
| 4 |
+
|
| 5 |
+
/**
|
| 6 |
+
* Set template with message
|
| 7 |
+
*/
|
| 8 |
+
protected function _construct() {
|
| 9 |
+
$this->setTemplate('payparts/redirect.phtml');
|
| 10 |
+
parent::_construct();
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* Return redirect form
|
| 15 |
+
*
|
| 16 |
+
* @return Varien_Data_Form
|
| 17 |
+
*/
|
| 18 |
+
public function getForm() {
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
$paymentMethod = Mage::getModel('payparts/redirect');
|
| 22 |
+
|
| 23 |
+
$html = '<form method="POST" action="' . $paymentMethod->getPaypartsPlaceUrl() . '" id="payparts_redirect" name="payparts_redirect">';
|
| 24 |
+
foreach ($paymentMethod->getRedirectFormFields() as $key => $value) {
|
| 25 |
+
$html .= '<input type="hidden" name="' . $key . '" value="' . $value . '">';
|
| 26 |
+
}
|
| 27 |
+
$html .= '<input type="submit" value="' . $this->__("Click here, if not redirected for 30 seconds.") . '">';
|
| 28 |
+
$html .= '</form>';
|
| 29 |
+
|
| 30 |
+
return $html;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
}
|
Payparts_Payment-1.0.0.0/app/code/local/Payparts/Payment/Helper/Data.php
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Payparts_Payment_Helper_Data extends Mage_Core_Helper_Abstract
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
public function refillCart($order)
|
| 7 |
+
{
|
| 8 |
+
$cartRefilled = true;
|
| 9 |
+
|
| 10 |
+
$cart = Mage::getSingleton('checkout/cart');
|
| 11 |
+
$items = $order->getItemsCollection();
|
| 12 |
+
foreach ($items as $item) {
|
| 13 |
+
try {
|
| 14 |
+
$cart->addOrderItem($item);
|
| 15 |
+
} catch (Mage_Core_Exception $e) {
|
| 16 |
+
$cartRefilled = false;
|
| 17 |
+
if (Mage::getSingleton('checkout/session')->getUseNotice(true)) {
|
| 18 |
+
Mage::getSingleton('checkout/session')->addNotice($e->getMessage());
|
| 19 |
+
} else {
|
| 20 |
+
Mage::getSingleton('checkout/session')->addError($e->getMessage());
|
| 21 |
+
}
|
| 22 |
+
$this->_redirect('customer/account/history');
|
| 23 |
+
} catch (Exception $e) {
|
| 24 |
+
$cartRefilled = false;
|
| 25 |
+
Mage::getSingleton('checkout/session')->addException(
|
| 26 |
+
$e,
|
| 27 |
+
Mage::helper('checkout')->__('Cannot add the item to shopping cart.')
|
| 28 |
+
);
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
+
$cart->save();
|
| 32 |
+
|
| 33 |
+
return $cartRefilled;
|
| 34 |
+
}
|
| 35 |
+
}
|
Payparts_Payment-1.0.0.0/app/code/local/Payparts/Payment/Model/Redirect.php
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Payparts_Payment_Model_Redirect extends Mage_Payment_Model_Method_Abstract {
|
| 4 |
+
/**
|
| 5 |
+
* unique internal payment method identifier
|
| 6 |
+
*/
|
| 7 |
+
protected $_code = 'payparts_redirect';
|
| 8 |
+
protected $_formBlockType = 'payparts/message';
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Payment Method features
|
| 12 |
+
*
|
| 13 |
+
* @var bool
|
| 14 |
+
*/
|
| 15 |
+
protected $_canUseForMultishipping = false;
|
| 16 |
+
protected $_canUseInternal = false;
|
| 17 |
+
protected $_isInitializeNeeded = true;
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Instantiate state and set it to state object
|
| 21 |
+
*
|
| 22 |
+
* @param string $paymentAction
|
| 23 |
+
* @param Varien_Object $stateObject
|
| 24 |
+
*/
|
| 25 |
+
public function initialize($paymentAction, $stateObject) {
|
| 26 |
+
$stateObject->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
|
| 27 |
+
$stateObject->setStatus('pending_payment');
|
| 28 |
+
$stateObject->setIsNotified(false);
|
| 29 |
+
$stateObject->save();
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
/**
|
| 33 |
+
* Return Order place redirect url
|
| 34 |
+
*
|
| 35 |
+
* @return string
|
| 36 |
+
*/
|
| 37 |
+
public function getOrderPlaceRedirectUrl() {
|
| 38 |
+
return Mage::getUrl('payparts/payment/redirect', array('_secure' => false));
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* Return Payparts place URL
|
| 43 |
+
*
|
| 44 |
+
* @return string
|
| 45 |
+
*/
|
| 46 |
+
public function getPaypartsPlaceUrl() {
|
| 47 |
+
$resultToken = $this->getPayPartsToken();
|
| 48 |
+
if(!$resultToken['status']){
|
| 49 |
+
Mage::throwException(Mage::helper('payparts')->__('PayParts :', $resultToken['message']));
|
| 50 |
+
}
|
| 51 |
+
// die;
|
| 52 |
+
return '//payparts2.privatbank.ua/ipp/v2/payment?token=' . (string)$resultToken['token'];
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
public function deliveryCalculate($amount, $tax_amount, $total_qty){
|
| 56 |
+
return (float)($amount - round($tax_amount, 2)) / (int)$total_qty;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
public function getSignature($result){
|
| 60 |
+
return base64_encode(
|
| 61 |
+
hex2bin(
|
| 62 |
+
SHA1( $result['store_passwd']
|
| 63 |
+
.$result['store_id']
|
| 64 |
+
.$result['order_id_unique']
|
| 65 |
+
.str_replace('.', '', $result['amount'])
|
| 66 |
+
.$result['currency']
|
| 67 |
+
.$result['partsCount']
|
| 68 |
+
.$result['merchantType']
|
| 69 |
+
.$result['responseUrl']
|
| 70 |
+
.$result['redirectUrl']
|
| 71 |
+
.$result['products_string']
|
| 72 |
+
.$result['store_passwd']
|
| 73 |
+
)
|
| 74 |
+
)
|
| 75 |
+
);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
private function getTax($order){
|
| 79 |
+
return $order->getTaxAmount()+$order->getShippingAmount();
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
private function preparedData(){
|
| 83 |
+
$result = array();
|
| 84 |
+
$session = Mage::getSingleton('checkout/session');
|
| 85 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
|
| 86 |
+
|
| 87 |
+
foreach ($order->getAllVisibleItems() as $itemId => $item)
|
| 88 |
+
{
|
| 89 |
+
$result['orders_sales'][] = array(
|
| 90 |
+
'name' => $item->getName(),
|
| 91 |
+
'price' => (string)number_format($item->getPrice(), 2, '.', ''),
|
| 92 |
+
'count' => (int)$item->getQtyOrdered()
|
| 93 |
+
|
| 94 |
+
);
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
$result['order_id_unique'] = $order->getRealOrderId().'_'.uniqid();
|
| 98 |
+
$result['store_passwd'] = $this->getConfigData('shoppassword');
|
| 99 |
+
$result['store_id'] = $this->getConfigData('shopident');
|
| 100 |
+
$result['amount'] = (string)number_format($order->getGrandTotal(), 2, '.', '');
|
| 101 |
+
$result['merchantType'] = (string)$session->system;
|
| 102 |
+
$result['partsCount'] = (string)$session->parts;
|
| 103 |
+
$result['currency'] = $order->getOrderCurrencyCode();
|
| 104 |
+
$result['responseUrl'] = Mage::getUrl('payparts/payment/return/', array('transaction_id' => $order->getRealOrderId()));
|
| 105 |
+
$result['redirectUrl'] = Mage::getUrl('payparts/payment/fail/');
|
| 106 |
+
$result['products_string'] = "";
|
| 107 |
+
|
| 108 |
+
if($order->getTaxAmount()){
|
| 109 |
+
$result['orders_sales'][] = array(
|
| 110 |
+
'name' => 'Tax',
|
| 111 |
+
'price' => (string)number_format($this->getTax($order), 2, '.', ''),
|
| 112 |
+
'count' => 1
|
| 113 |
+
);
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
for ($i=0; $i<count($result['orders_sales']);$i++)
|
| 117 |
+
{
|
| 118 |
+
$result['products_string'] .= $result['orders_sales'][$i]['name']
|
| 119 |
+
.(string)$result['orders_sales'][$i]['count']
|
| 120 |
+
.str_replace('.', '', $result['orders_sales'][$i]['price']);
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
$requestData = json_encode(
|
| 124 |
+
array(
|
| 125 |
+
"storeId" => $result['store_id'],
|
| 126 |
+
"orderId" => $result['order_id_unique'],
|
| 127 |
+
"amount" => $result['amount'],
|
| 128 |
+
"currency" => $result['currency'],
|
| 129 |
+
"partsCount" => $result['partsCount'],
|
| 130 |
+
"merchantType" => $result['merchantType'],
|
| 131 |
+
"products" => $result['orders_sales'],
|
| 132 |
+
"responseUrl" => $result['responseUrl'],
|
| 133 |
+
"redirectUrl" => $result['redirectUrl'],
|
| 134 |
+
"signature" => $this->getSignature($result)
|
| 135 |
+
)
|
| 136 |
+
);
|
| 137 |
+
|
| 138 |
+
var_dump($requestData);
|
| 139 |
+
return $requestData;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
private function getPayPartsToken(){
|
| 143 |
+
$result = array('status' => false);
|
| 144 |
+
$ch = curl_init();
|
| 145 |
+
curl_setopt($ch, CURLOPT_URL, 'https://payparts2.privatbank.ua/ipp/v2/payment/create');
|
| 146 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
| 147 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->preparedData());
|
| 148 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
| 149 |
+
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
|
| 150 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
|
| 151 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
| 152 |
+
'Accept: application/json',
|
| 153 |
+
'Accept-Encoding: UTF-8',
|
| 154 |
+
'Content-Type: application/json; charset=UTF-8'
|
| 155 |
+
));
|
| 156 |
+
|
| 157 |
+
$response = json_decode(curl_exec($ch));
|
| 158 |
+
curl_close($ch);
|
| 159 |
+
|
| 160 |
+
if ($response->token){
|
| 161 |
+
$result['status'] = true;
|
| 162 |
+
$result['token'] = $response->token;
|
| 163 |
+
} else{
|
| 164 |
+
$result['message'] = ($response->errorMessage) ? $response->errorMessage : $response->message;
|
| 165 |
+
}
|
| 166 |
+
return $result;
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
/**
|
| 170 |
+
* Return redirect form fields
|
| 171 |
+
* @return array
|
| 172 |
+
*/
|
| 173 |
+
public function getRedirectFormFields() {
|
| 174 |
+
$result = array();
|
| 175 |
+
$session = Mage::getSingleton('checkout/session');
|
| 176 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
if (!$order->getId()) {
|
| 180 |
+
return $result;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
$order_id = $order->getRealOrderId();
|
| 184 |
+
|
| 185 |
+
$result['myPayPartsMerchantID'] = $this->getConfigData('login');
|
| 186 |
+
$result['myPayPartsMerchantExpTime'] = $this->getConfigData('validitytime');
|
| 187 |
+
$result['myPayPartsMerchantShopName'] = $this->getConfigData('shopname');
|
| 188 |
+
$result['myPayPartsMerchantSum'] = round($order->getGrandTotal(), 2);
|
| 189 |
+
$result['myPayPartsTotalQtyOrdered'] = (int)$order->getTotalQtyOrdered();
|
| 190 |
+
$result['myPayPartsTaxAmount'] = round($order->getTaxAmount(), 2);
|
| 191 |
+
$result['myPayPartsUnitSum'] = round((int)($result['myPayPartsMerchantSum'] - round($order->getTaxAmount(), 2)) / (int)$order->getTotalQtyOrdered(), 2);
|
| 192 |
+
|
| 193 |
+
$result['myPayPartsMerchantCurrency'] = $order->getOrderCurrencyCode(); //must be UAH
|
| 194 |
+
|
| 195 |
+
if ($result['myPayPartsMerchantCurrency'] != 'UAH') {
|
| 196 |
+
Mage::throwException(Mage::helper('payparts')->__('PayParts ( payparts2.privatbank.ua ) works only with UAH but not with (%s)', $result['myPayPartsMerchantCurrency']));
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
$result['myPayPartsMerchantOrderId'] = $order_id;
|
| 201 |
+
$result['myPayPartsMerchantOrderDesc'] = Mage::app()->getStore()->getGroup()->getName() . ' №' . $order_id;
|
| 202 |
+
$result['myPayPartsMerchantResultUrl'] = Mage::getUrl('payparts/payment/notify');
|
| 203 |
+
$result['myPayPartsMerchantSuccessUrl'] = Mage::getUrl('payparts/payment/return', array('transaction_id' => $order_id));
|
| 204 |
+
$result['myPayPartsMerchantFailUrl'] = Mage::getUrl('payparts/payment/fail', array('transaction_id' => $order_id));
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
ksort($result);
|
| 208 |
+
$req_str = '';
|
| 209 |
+
foreach ($result AS $pkey => $pval)
|
| 210 |
+
$req_str.=($pkey . '=' . $pval);
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
// Add a secret key to the request string if needed.
|
| 214 |
+
if ($this->getConfigData('checkhash')) {
|
| 215 |
+
$req_str .= Mage::helper('core')->decrypt($this->getConfigData('secretkey'));
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
$result['myPayPartsMerchantHash'] = md5($req_str);
|
| 219 |
+
|
| 220 |
+
var_dump($result);
|
| 221 |
+
// die;
|
| 222 |
+
return $result;
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
/**
|
| 226 |
+
* Check incoming request CRC
|
| 227 |
+
*
|
| 228 |
+
* @param array $request
|
| 229 |
+
* @return bool
|
| 230 |
+
*/
|
| 231 |
+
public function validateRequest($request) {
|
| 232 |
+
|
| 233 |
+
$order_id = $request['OrderId'];
|
| 234 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId((int) $order_id);
|
| 235 |
+
|
| 236 |
+
if ($order) {
|
| 237 |
+
|
| 238 |
+
// сбор хеша по пост данным для проверки $_REQUEST["MerchantHash"]
|
| 239 |
+
$dataM = array(
|
| 240 |
+
'MerchantId' => $request["MerchantId"], // номер мерчанта в системе Манекси
|
| 241 |
+
'PaymentId' => $request["PaymentId"], // номер платежа в системе Манекси
|
| 242 |
+
'OrderId' => $request["OrderId"], // номер заказа, который был передан Торговцем
|
| 243 |
+
'Amount' => $request["Amount"], // сумма заказа
|
| 244 |
+
'Currency' => $request["Currency"], // валюта заказа
|
| 245 |
+
'Success' => $request["Success"], // успешность проведения платежа
|
| 246 |
+
'Type' => $request["Type"], // идентификатор способа платежа
|
| 247 |
+
'TypeName' => $request["TypeName"]//описание выбранного способа оплаты
|
| 248 |
+
);
|
| 249 |
+
|
| 250 |
+
if(!empty($request['TransId']))
|
| 251 |
+
{
|
| 252 |
+
$dataM['TransId'] = $request['TransId'];
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
ksort($dataM); //сортировка данных массива по ключу
|
| 256 |
+
$req_str3 = ''; // первоначальное значение строки данных для подписи
|
| 257 |
+
foreach ($dataM AS $pkey => $pval)
|
| 258 |
+
$req_str3.=($pkey . '=' . $pval);
|
| 259 |
+
if ($this->getConfigData('checkhash')) {
|
| 260 |
+
$req_str3 .= Mage::helper('core')->decrypt($this->getConfigData('secretkey'));
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
$ServerHashM = md5($req_str3);
|
| 264 |
+
|
| 265 |
+
// сборка хеша по пост данным для проверки полей от подмены
|
| 266 |
+
$datas = array();
|
| 267 |
+
$datas["MerchantId"] = $request["MerchantId"]; // номер мерчанта в системе Манекси
|
| 268 |
+
$datas["OrderId"] = $request["OrderId"]; // номер заказа, который был передан Торговцем
|
| 269 |
+
$datas["Amount"] = $request["Amount"] * 100; // сумма заказа
|
| 270 |
+
$datas["Currency"] = $request["Currency"]; // валюта заказа
|
| 271 |
+
$datas["Success"] = $request["Success"]; // успешность проведения платежа
|
| 272 |
+
ksort($datas); //сортировка данных массива по ключу
|
| 273 |
+
$req_str1 = ''; // первоначальное значение строки данных для подписи
|
| 274 |
+
foreach ($datas AS $pkey => $pval)
|
| 275 |
+
$req_str1.=($pkey . '=' . $pval);
|
| 276 |
+
if ($this->getConfigData('checkhash')) {
|
| 277 |
+
$req_str1 .= Mage::helper('core')->decrypt($this->getConfigData('secretkey'));
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
$ServerHash2 = md5($req_str1);
|
| 282 |
+
|
| 283 |
+
//соборка провеочного хеша для проверки полей от подмены и упешного статуса (Success = 1)
|
| 284 |
+
$datasC = array();
|
| 285 |
+
$datasC["MerchantId"] = $this->getConfigData('login'); // номер мерчанта в системе Манекси
|
| 286 |
+
$datasC["OrderId"] = $order_id; // номер заказа, который был передан Торговцем
|
| 287 |
+
$datasC["Amount"] = $order->getGrandTotal() * 100; // сумма заказа
|
| 288 |
+
$datasC["Currency"] = $order->getOrderCurrencyCode(); // валюта заказа
|
| 289 |
+
$datasC["Success"] = "1"; // успешность проведения платежа
|
| 290 |
+
ksort($datasC); //сортировка данных массива по ключу
|
| 291 |
+
$req_str2 = ''; // первоначальное значение строки данных для подписи
|
| 292 |
+
foreach ($datasC AS $pkey => $pval)
|
| 293 |
+
$req_str2.=($pkey . '=' . $pval);
|
| 294 |
+
if ($this->getConfigData('checkhash')) {
|
| 295 |
+
$req_str2 .= Mage::helper('core')->decrypt($this->getConfigData('secretkey'));
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
$CheckHash = md5($req_str2);
|
| 299 |
+
if (strpos($CheckHash, $ServerHash2) !== false) {
|
| 300 |
+
if (strpos($request["MerchantHash"], $ServerHashM) !== false) {
|
| 301 |
+
return true;
|
| 302 |
+
}
|
| 303 |
+
}
|
| 304 |
+
}
|
| 305 |
+
return false;
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
}
|
Payparts_Payment-1.0.0.0/app/code/local/Payparts/Payment/controllers/PaymentController.php
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Payparts_Payment_PaymentController extends Mage_Core_Controller_Front_Action
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Redirect to PayParts
|
| 8 |
+
*/
|
| 9 |
+
public function redirectAction()
|
| 10 |
+
{
|
| 11 |
+
|
| 12 |
+
$session = Mage::getSingleton('checkout/session');
|
| 13 |
+
$session->setPaypartsQuoteId($session->getQuoteId());
|
| 14 |
+
|
| 15 |
+
$this->getResponse()->setBody($this->getLayout()->createBlock('payparts/redirect')->toHtml());
|
| 16 |
+
$session->pay_parts_paym_state = false;
|
| 17 |
+
$session->unsQuoteId();
|
| 18 |
+
$session->unsRedirectUrl();
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
/**
|
| 22 |
+
* When a customer cancel payment from PayParts.
|
| 23 |
+
*/
|
| 24 |
+
public function failAction()
|
| 25 |
+
{
|
| 26 |
+
$session = Mage::getSingleton('checkout/session');
|
| 27 |
+
$session->setQuoteId($session->getPaypartsQuoteId());
|
| 28 |
+
if ($session->getLastRealOrderId()) {
|
| 29 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
|
| 30 |
+
if ($order->getId()) {
|
| 31 |
+
$order->cancel()->save();
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
$quote = Mage::getModel('sales/quote')->load($session->getPaypartsQuoteId());
|
| 37 |
+
if ($quote->getId()) {
|
| 38 |
+
$quote->setActive(true);
|
| 39 |
+
$quote->save();
|
| 40 |
+
}
|
| 41 |
+
$session->addError(Mage::helper('payparts')->__('Payment failed. Pleas try again later.'));
|
| 42 |
+
if($session->pay_parts_paym_state){
|
| 43 |
+
$session->addError(Mage::helper('payparts')->__('Payment is held successfully.'));
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
$this->_redirect('checkout/cart');
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
/**
|
| 50 |
+
* Customer return processing
|
| 51 |
+
*/
|
| 52 |
+
public function returnAction()
|
| 53 |
+
{
|
| 54 |
+
try {
|
| 55 |
+
$session = Mage::getSingleton('checkout/session');
|
| 56 |
+
$postData = Mage::helper('core')->jsonDecode(Mage::app()->getRequest()->getRawBody());
|
| 57 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
|
| 58 |
+
if($postData['paymentState'] == 'SUCCESS'){
|
| 59 |
+
$session->pay_parts_paym_state = true;
|
| 60 |
+
Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
|
| 61 |
+
$order->setStatus('payparts_paid');
|
| 62 |
+
$order->setState('payparts_paid');
|
| 63 |
+
$order->save();
|
| 64 |
+
}
|
| 65 |
+
else if($postData['paymentState'] == 'CANCELED'){
|
| 66 |
+
$order->cancel()->save();
|
| 67 |
+
}
|
| 68 |
+
$this->_redirect('checkout/onepage/success');
|
| 69 |
+
return;
|
| 70 |
+
} catch (Mage_Core_Exception $e) {
|
| 71 |
+
$this->_getCheckout()->addError($e->getMessage());
|
| 72 |
+
} catch(Exception $e) {
|
| 73 |
+
Mage::logException($e);
|
| 74 |
+
}
|
| 75 |
+
$this->_redirect('checkout/cart');
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* Background notifications
|
| 80 |
+
*/
|
| 81 |
+
public function notifyAction()
|
| 82 |
+
{
|
| 83 |
+
$session = Mage::getSingleton('checkout/session');
|
| 84 |
+
$request = Mage::app()->getRequest()->getPost();
|
| 85 |
+
$session->pattern = Mage::app()->getRequest()->getRawBody();
|
| 86 |
+
parse_str(Mage::app()->getRequest()->getRawBody(), $parts_params);
|
| 87 |
+
|
| 88 |
+
if($parts_params['parts']){
|
| 89 |
+
$session->parts = $parts_params['parts'];
|
| 90 |
+
$session->system = $parts_params['system'];
|
| 91 |
+
}
|
| 92 |
+
$paymentMethod = Mage::getModel('payparts/redirect');
|
| 93 |
+
if (!$paymentMethod->validateRequest($request)) {
|
| 94 |
+
return;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($request['OrderId']);
|
| 98 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING);
|
| 99 |
+
$order->setStatus('processing');
|
| 100 |
+
$order->setIsNotified(false);
|
| 101 |
+
$order->save();
|
| 102 |
+
echo 'OK ' . $request['OrderId'];
|
| 103 |
+
}
|
| 104 |
+
}
|
Payparts_Payment-1.0.0.0/app/code/local/Payparts/Payment/etc/config.xml
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Payparts_Payment>
|
| 5 |
+
<version>1.0.0.0</version>
|
| 6 |
+
</Payparts_Payment>
|
| 7 |
+
</modules>
|
| 8 |
+
<global>
|
| 9 |
+
<models>
|
| 10 |
+
<payparts>
|
| 11 |
+
<class>Payparts_Payment_Model</class>
|
| 12 |
+
<resourceModel>payparts_resource</resourceModel>
|
| 13 |
+
</payparts>
|
| 14 |
+
</models>
|
| 15 |
+
<blocks>
|
| 16 |
+
<payparts>
|
| 17 |
+
<class>Payparts_Payment_Block</class>
|
| 18 |
+
</payparts>
|
| 19 |
+
</blocks>
|
| 20 |
+
<helpers>
|
| 21 |
+
<payparts>
|
| 22 |
+
<class>Payparts_Payment_Helper</class>
|
| 23 |
+
</payparts>
|
| 24 |
+
</helpers>
|
| 25 |
+
</global>
|
| 26 |
+
<frontend>
|
| 27 |
+
<routers>
|
| 28 |
+
<payparts>
|
| 29 |
+
<use>standard</use>
|
| 30 |
+
<args>
|
| 31 |
+
<module>Payparts_Payment</module>
|
| 32 |
+
<frontName>payparts</frontName>
|
| 33 |
+
</args>
|
| 34 |
+
</payparts>
|
| 35 |
+
</routers>
|
| 36 |
+
<translate>
|
| 37 |
+
<modules>
|
| 38 |
+
<Payparts_Payment>
|
| 39 |
+
<files>
|
| 40 |
+
<default>Payparts_Payment.csv</default>
|
| 41 |
+
</files>
|
| 42 |
+
</Payparts_Payment>
|
| 43 |
+
</modules>
|
| 44 |
+
</translate>
|
| 45 |
+
</frontend>
|
| 46 |
+
<adminhtml>
|
| 47 |
+
<translate>
|
| 48 |
+
<modules>
|
| 49 |
+
<Payparts_Payment>
|
| 50 |
+
<files>
|
| 51 |
+
<default>Payparts_Payment.csv</default>
|
| 52 |
+
</files>
|
| 53 |
+
</Payparts_Payment>
|
| 54 |
+
</modules>
|
| 55 |
+
</translate>
|
| 56 |
+
</adminhtml>
|
| 57 |
+
<default>
|
| 58 |
+
<payment>
|
| 59 |
+
<payparts_redirect>
|
| 60 |
+
<model>payparts/redirect</model>
|
| 61 |
+
<active>1</active>
|
| 62 |
+
<title>PayParts</title>
|
| 63 |
+
<validitytime>140</validitytime>
|
| 64 |
+
<sort_order>0</sort_order>
|
| 65 |
+
</payparts_redirect>
|
| 66 |
+
</payment>
|
| 67 |
+
</default>
|
| 68 |
+
</config>
|
Payparts_Payment-1.0.0.0/app/code/local/Payparts/Payment/etc/system.xml
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<sections>
|
| 4 |
+
<payment>
|
| 5 |
+
<groups>
|
| 6 |
+
<payparts_redirect translate="label">
|
| 7 |
+
<label>PayParts (payparts2.privatbank.ua)</label>
|
| 8 |
+
<frontend_type>text</frontend_type>
|
| 9 |
+
<sort_order>1</sort_order>
|
| 10 |
+
<show_in_default>1</show_in_default>
|
| 11 |
+
<show_in_website>1</show_in_website>
|
| 12 |
+
<show_in_store>1</show_in_store>
|
| 13 |
+
<fields>
|
| 14 |
+
<active translate="label">
|
| 15 |
+
<label>Enabled</label>
|
| 16 |
+
<frontend_type>select</frontend_type>
|
| 17 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 18 |
+
<sort_order>10</sort_order>
|
| 19 |
+
<show_in_default>1</show_in_default>
|
| 20 |
+
<show_in_website>1</show_in_website>
|
| 21 |
+
<show_in_store>0</show_in_store>
|
| 22 |
+
</active>
|
| 23 |
+
<title translate="label">
|
| 24 |
+
<label>Payment title</label>
|
| 25 |
+
<frontend_type>text</frontend_type>
|
| 26 |
+
<sort_order>20</sort_order>
|
| 27 |
+
<show_in_default>1</show_in_default>
|
| 28 |
+
<show_in_website>1</show_in_website>
|
| 29 |
+
<show_in_store>1</show_in_store>
|
| 30 |
+
</title>
|
| 31 |
+
<ppperiod translate="label">
|
| 32 |
+
<label>PP parts</label>
|
| 33 |
+
<frontend_type>text</frontend_type>
|
| 34 |
+
<sort_order>30</sort_order>
|
| 35 |
+
<show_in_default>1</show_in_default>
|
| 36 |
+
<show_in_website>1</show_in_website>
|
| 37 |
+
<show_in_store>1</show_in_store>
|
| 38 |
+
</ppperiod>
|
| 39 |
+
<iiperiod translate="label">
|
| 40 |
+
<label>II parts</label>
|
| 41 |
+
<frontend_type>text</frontend_type>
|
| 42 |
+
<sort_order>40</sort_order>
|
| 43 |
+
<show_in_default>1</show_in_default>
|
| 44 |
+
<show_in_website>1</show_in_website>
|
| 45 |
+
<show_in_store>1</show_in_store>
|
| 46 |
+
</iiperiod>
|
| 47 |
+
<pbperiod translate="label">
|
| 48 |
+
<label>PB parts</label>
|
| 49 |
+
<frontend_type>text</frontend_type>
|
| 50 |
+
<sort_order>50</sort_order>
|
| 51 |
+
<show_in_default>1</show_in_default>
|
| 52 |
+
<show_in_website>1</show_in_website>
|
| 53 |
+
<show_in_store>1</show_in_store>
|
| 54 |
+
</pbperiod>
|
| 55 |
+
<shopident translate="label">
|
| 56 |
+
<label>Ident shop</label>
|
| 57 |
+
<frontend_type>text</frontend_type>
|
| 58 |
+
<sort_order>60</sort_order>
|
| 59 |
+
<show_in_default>1</show_in_default>
|
| 60 |
+
<show_in_website>1</show_in_website>
|
| 61 |
+
<show_in_store>1</show_in_store>
|
| 62 |
+
</shopident>
|
| 63 |
+
<shoppassword translate="label">
|
| 64 |
+
<label>Shop password</label>
|
| 65 |
+
<frontend_type>text</frontend_type>
|
| 66 |
+
<sort_order>70</sort_order>
|
| 67 |
+
<show_in_default>1</show_in_default>
|
| 68 |
+
<show_in_website>1</show_in_website>
|
| 69 |
+
<show_in_store>1</show_in_store>
|
| 70 |
+
</shoppassword>
|
| 71 |
+
<login translate="label">
|
| 72 |
+
<label>Merchant ID</label>
|
| 73 |
+
<frontend_type>text</frontend_type>
|
| 74 |
+
<sort_order>80</sort_order>
|
| 75 |
+
<show_in_default>1</show_in_default>
|
| 76 |
+
<show_in_website>1</show_in_website>
|
| 77 |
+
<show_in_store>0</show_in_store>
|
| 78 |
+
</login>
|
| 79 |
+
<checkhash translate="label">
|
| 80 |
+
<label>Check hash</label>
|
| 81 |
+
<frontend_type>select</frontend_type>
|
| 82 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 83 |
+
<sort_order>90</sort_order>
|
| 84 |
+
<show_in_default>1</show_in_default>
|
| 85 |
+
<show_in_website>1</show_in_website>
|
| 86 |
+
<show_in_store>0</show_in_store>
|
| 87 |
+
</checkhash>
|
| 88 |
+
<validitytime translate="label">
|
| 89 |
+
<label>Validity time</label>
|
| 90 |
+
<frontend_type>text</frontend_type>
|
| 91 |
+
<sort_order>100</sort_order>
|
| 92 |
+
<show_in_default>1</show_in_default>
|
| 93 |
+
<show_in_website>1</show_in_website>
|
| 94 |
+
<show_in_store>0</show_in_store>
|
| 95 |
+
</validitytime>
|
| 96 |
+
<sort_order translate="label">
|
| 97 |
+
<label>Sort Order</label>
|
| 98 |
+
<frontend_type>text</frontend_type>
|
| 99 |
+
<sort_order>110</sort_order>
|
| 100 |
+
<show_in_default>1</show_in_default>
|
| 101 |
+
<show_in_website>1</show_in_website>
|
| 102 |
+
<show_in_store>0</show_in_store>
|
| 103 |
+
</sort_order>
|
| 104 |
+
</fields>
|
| 105 |
+
</payparts_redirect>
|
| 106 |
+
</groups>
|
| 107 |
+
</payment>
|
| 108 |
+
</sections>
|
| 109 |
+
</config>
|
Payparts_Payment-1.0.0.0/app/design/frontend/base/default/template/payparts/message.phtml
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<ul id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none" class="form-list">
|
| 2 |
+
<li>
|
| 3 |
+
<?php echo $this->__('PayParts (<a href="//payparts2.privatbank.ua/ipp/" target="_blank">payparts2.privatbank.ua</a>) payment system.') ?>
|
| 4 |
+
</li>
|
| 5 |
+
<li id="payparts-select-block">
|
| 6 |
+
<p>Программа
|
| 7 |
+
<select id="system-sel" name="partsCount" style="width: 187px">
|
| 8 |
+
<option name="Оплата частями" pp-name="PP" value="<?php echo Mage::getStoreConfig('payment/payparts_redirect/ppperiod')+1 ?>" selected>Оплата частями</option>
|
| 9 |
+
<option name="Мгновенная рассрочка" pp-name="II" value="<?php echo Mage::getStoreConfig('payment/payparts_redirect/iiperiod')+1 ?>">Мгновенная рассрочка</option>
|
| 10 |
+
<option name="Деньги в периоде" pp-name="PB" value="<?php echo Mage::getStoreConfig('payment/payparts_redirect/pbperiod')+1 ?>">Деньги в периоде</option>
|
| 11 |
+
</select>
|
| 12 |
+
Срок,мес.
|
| 13 |
+
<select id="month-sel" name="partsCount" style="width: 40px">
|
| 14 |
+
<option disabled>Срок,мес.</option>
|
| 15 |
+
<option selected value="2">2</option>
|
| 16 |
+
<?for ($i=0;$i < Mage::getStoreConfig('payment/payparts_redirect/ppperiod')+1; $i++){
|
| 17 |
+
if($i > 2){
|
| 18 |
+
echo '<option value='.$i.'>'.$i.'</option>';
|
| 19 |
+
} else
|
| 20 |
+
{
|
| 21 |
+
continue;
|
| 22 |
+
}
|
| 23 |
+
}?>
|
| 24 |
+
</select>
|
| 25 |
+
<button type="button" title="submit" class="button" id="send-period"> Check </button>
|
| 26 |
+
</p>
|
| 27 |
+
<p id="send-parts-error" style="display: none;">Error some</p>
|
| 28 |
+
</li>
|
| 29 |
+
<li id="payparts-success" style="display: none;">
|
| 30 |
+
<p><span id="system-name">Оплата частями</span> на <span id="payparts-period-success"></span> мес.</p>
|
| 31 |
+
</li>
|
| 32 |
+
</ul>
|
| 33 |
+
<script type="text/javascript">
|
| 34 |
+
function send() {
|
| 35 |
+
var paySystem = getPaySelectedAttr();
|
| 36 |
+
|
| 37 |
+
document.getElementById('payparts-period-success').innerHTML = document.getElementById('month-sel').value;
|
| 38 |
+
var url = "<?php echo $this->getUrl('payparts/payment/notify/', array('_secure' => false)); ?>";
|
| 39 |
+
new Ajax.Request( url, {
|
| 40 |
+
method: 'post',
|
| 41 |
+
parameters: 'parts='+document.getElementById('month-sel').value+'&system='+ paySystem['system'],
|
| 42 |
+
onSuccess: successFunc,
|
| 43 |
+
onFailure: failureFunc
|
| 44 |
+
});
|
| 45 |
+
|
| 46 |
+
}
|
| 47 |
+
function successFunc(response){
|
| 48 |
+
console.log(response);
|
| 49 |
+
document.getElementById("payparts-select-block").style.display = "none";
|
| 50 |
+
document.getElementById("payparts-success").style.display = "block";
|
| 51 |
+
document.getElementById("payment-buttons-container").style.display = "block";
|
| 52 |
+
return true;
|
| 53 |
+
}
|
| 54 |
+
function failureFunc(response){
|
| 55 |
+
document.getElementById("send-parts-error").style.display = "block";
|
| 56 |
+
return false;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
function getPaySelectedAttr(){
|
| 60 |
+
var result = {};
|
| 61 |
+
var e = document.getElementById("system-sel");
|
| 62 |
+
result['value'] = e.options[e.selectedIndex].value;
|
| 63 |
+
result['system'] = e.options[e.selectedIndex].getAttribute('pp-name');
|
| 64 |
+
result['name'] = e.options[e.selectedIndex].getAttribute('name');
|
| 65 |
+
return result;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
function periodChange(){
|
| 69 |
+
var selectData = getPaySelectedAttr();
|
| 70 |
+
var result = '<option disabled>Срок,мес.</option><option selected value="2">2</option>';
|
| 71 |
+
console.log(selectData);
|
| 72 |
+
|
| 73 |
+
for ($i=0;$i < selectData['value']; $i++){
|
| 74 |
+
if($i > 2){
|
| 75 |
+
result += '<option value='+$i+'>'+$i+'</option>';
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
document.getElementById('month-sel').innerHTML = result;
|
| 79 |
+
document.getElementById('system-name').innerHTML = selectData['name'];
|
| 80 |
+
|
| 81 |
+
}
|
| 82 |
+
document.getElementById("send-parts-error").style.display = "none";
|
| 83 |
+
document.getElementById("payment-buttons-container").style.display = "none";
|
| 84 |
+
document.getElementById('send-period').onclick = send;
|
| 85 |
+
document.getElementById('system-sel').onchange = periodChange;
|
| 86 |
+
</script>
|
Payparts_Payment-1.0.0.0/app/design/frontend/base/default/template/payparts/redirect.phtml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<html>
|
| 2 |
+
<body>
|
| 3 |
+
<?php echo $this->getForm(); ?>
|
| 4 |
+
<script type="text/javascript">document.getElementById("payparts_redirect").submit();</script>
|
| 5 |
+
</body>
|
| 6 |
+
</html>
|
Payparts_Payment-1.0.0.0/app/etc/modules/Payparts_Payparts_Payment.xml
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Payparts_Payment>
|
| 5 |
+
<active>enable</active>
|
| 6 |
+
<codePool>community</codePool>
|
| 7 |
+
<depends>
|
| 8 |
+
<Mage_Sales />
|
| 9 |
+
<Mage_Payment />
|
| 10 |
+
</depends>
|
| 11 |
+
</Payparts_Payment>
|
| 12 |
+
</modules>
|
| 13 |
+
</config>
|
Payparts_Payment-1.0.0.0/app/locale/ru_RU/Payparts_Payment.csv
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"Extension:","Модуль:"
|
| 2 |
+
"Enabled","Включен"
|
| 3 |
+
"Ident shop","Идентификатор магазина"
|
| 4 |
+
"Shop password","Проль магазина"
|
| 5 |
+
"Check hash","Проверять HASH"
|
| 6 |
+
"Secret key","Секретный ключ"
|
| 7 |
+
"Sort order","Порядок сортировки"
|
| 8 |
+
"Payment failed. Pleas try again later.","Оплата не удалась."
|
| 9 |
+
"Payment is held successfully.","Оплата удалась."
|
| 10 |
+
"PayParts (payparts2.privatbank.ua) works only with UAH but not with (%s)","PayParts (payparts2.privatbank.ua) принимает только UAH, текущая валюта %s"
|
| 11 |
+
"PayParts (payparts2.privatbank.ua) payment system.","Платежная система PayParts (payparts2.privatbank.ua). Вы будете перенаправлены на сайт <a href="//payparts2.privatbank.ua/ipp/">payparts2.privatbank.ua</a> после подтверждения покупки."
|
| 12 |
+
"You will be redirected to the PayParts (payparts2.privatbank.ua) website in a few seconds","Вы будете перенаправлены на сайт PayParts (payparts2.privatbank.ua) через несколько секунд."
|
| 13 |
+
"Cannot add the item to shopping cart.","Невозможно добавить товар в корзину."
|
| 14 |
+
"Payment title","Название метода оплаты"
|
| 15 |
+
"Click here, if not redirected for 30 seconds.","Нажмите здесь, если в течении 30 секунд не произошла переадресация"
|
package.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>9bbd841bf705997db5b5633f8e1b794d</name>
|
| 4 |
+
<version>1.0.0.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license>OSL</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>This is new payment method.</summary>
|
| 10 |
+
<description>This is new payment method.</description>
|
| 11 |
+
<notes>Good!</notes>
|
| 12 |
+
<authors><author><name>PB</name><user>pbuser</user><email>info@privatbank.ua</email></author></authors>
|
| 13 |
+
<date>2015-11-25</date>
|
| 14 |
+
<time>15:31:57</time>
|
| 15 |
+
<contents><target name="magecommunity"><dir><dir name="app"><dir name="code"><dir name="local"><dir name="Payparts"><dir name="Payment"><dir name="etc"><file name="system.xml" hash=""/><file name="config.xml" hash=""/></dir><dir name="Block"><file name="Message.php" hash=""/><file name="Redirect.php" hash=""/></dir><dir name="controllers"><file name="PaymentController.php" hash=""/></dir><dir name="Helper"><file name="Data.php" hash=""/></dir><dir name="Model"><file name="Redirect.php" hash=""/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir><dir name="app"><dir name="etc"><dir name="modules"><file name="Payparts_PaypartsPayment.xml" hash=""/></dir></dir></dir></dir></target><target name="magedesign"><dir><dir name="app"><dir name="design"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="payparts"><file name="message.phtml" hash=""/><file name="redirect.phtml" hash=""/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir><dir name="app"><dir name="locale"><dir name="ru_RU"><file name="Payparts_Payment.csv" hash=""/></dir></dir></dir></dir></target></contents>
|
| 16 |
+
<compatible/>
|
| 17 |
+
<dependencies><required><php><min>5.5.9</min><max>7.0.0</max></php></required></dependencies>
|
| 18 |
+
</package>
|
