Version Notes
Integration with PayU based on REST API.
Authentication via OAuth.
More info:
https://github.com/PayU/plugin_magento
http://developers.payu.com/en/restapi.html
Download this release
Release Info
Developer | PayU |
Extension | PayU_Account |
Version | 2.2.0 |
Comparing to | |
See all releases |
Code changes from version 2.1.6 to 2.2.0
- app/code/community/PayU/Account/Block/Adminhtml/Sales/Order/View.php +0 -53
- app/code/community/PayU/Account/Block/Advertisement.php +0 -42
- app/code/community/PayU/Account/Block/BeforeSummary.php +0 -53
- app/code/community/PayU/Account/Block/Button.php +0 -17
- app/code/community/PayU/Account/Block/Form.php +32 -17
- app/code/community/PayU/Account/Block/Onestep/Checkout.php +0 -53
- app/code/community/PayU/Account/Block/Redirect.php +0 -58
- app/code/community/PayU/Account/Block/UpdateInfo.php +10 -73
- app/code/community/PayU/Account/Helper/Data.php +17 -69
- app/code/community/PayU/Account/Model/Adminhtml/Sales/Order.php +0 -17
- app/code/community/PayU/Account/Model/Advertisement.php +0 -32
- app/code/community/PayU/Account/Model/Button.php +0 -33
- app/code/community/PayU/Account/Model/Config.php +92 -244
- app/code/community/PayU/Account/Model/Environment.php +0 -36
- app/code/community/PayU/Account/Model/Payment.php +403 -824
- app/code/community/PayU/Account/Model/Session.php +3 -8
- app/code/community/PayU/Account/Model/Thumbnail.php +0 -31
- app/code/community/PayU/Account/Model/ValidityTime.php +0 -42
- app/code/community/PayU/Account/controllers/Adminhtml/Sales/OrderController.php +0 -73
- app/code/community/PayU/Account/controllers/Checkout/CartController.php +0 -19
- app/code/community/PayU/Account/controllers/PaymentController.php +54 -169
- app/code/community/PayU/Account/etc/config.xml +47 -103
- app/code/community/PayU/Account/etc/system.xml +25 -80
- app/design/frontend/base/default/layout/payu_account.xml +0 -106
- app/design/frontend/base/default/template/payu_account/advertisement.phtml +0 -4
- app/design/frontend/base/default/template/payu_account/form.phtml +6 -2
- app/design/frontend/base/default/template/payu_account/info/payu_account.phtml +0 -21
- app/design/frontend/base/default/template/payu_account/onestep/checkout.phtml +0 -5
- app/etc/modules/PayU_Account.xml +2 -2
- app/locale/pl_PL/PayU_Account.csv +18 -56
- lib/PayU/Cache/.htaccess +2 -0
- lib/PayU/Cache/810290d4eed883975e0cd43d80497ac4 +0 -0
- lib/PayU/Cache/index.php +0 -0
- lib/PayU/OpenPayU/AuthType/AuthType.php +12 -0
- lib/PayU/OpenPayU/AuthType/Basic.php +33 -0
- lib/PayU/OpenPayU/AuthType/Oauth.php +39 -0
- lib/PayU/OpenPayU/AuthType/TokenRequest.php +14 -0
- lib/PayU/OpenPayU/Configuration.php +270 -0
- lib/PayU/OpenPayU/Http.php +166 -0
- lib/{payu/sdk_v21 → PayU}/OpenPayU/HttpCurl.php +22 -53
- lib/PayU/OpenPayU/Oauth/Cache/OauthCacheFile.php +40 -0
- lib/PayU/OpenPayU/Oauth/Cache/OauthCacheInterface.php +26 -0
- lib/PayU/OpenPayU/Oauth/Cache/OauthCacheMemcached.php +43 -0
- lib/PayU/OpenPayU/Oauth/Oauth.php +105 -0
- lib/PayU/OpenPayU/Oauth/OauthGrantType.php +6 -0
- lib/PayU/OpenPayU/Oauth/OauthResultClientCredentials.php +121 -0
- lib/PayU/OpenPayU/OpenPayU.php +56 -0
- lib/PayU/OpenPayU/OpenPayUException.php +39 -0
- lib/PayU/OpenPayU/OpenPayuOrderStatus.php +24 -0
- lib/{payu/sdk_v21 → PayU}/OpenPayU/Result.php +8 -10
- lib/PayU/OpenPayU/ResultError.php +59 -0
- lib/{payu/sdk_v21 → PayU}/OpenPayU/Util.php +88 -157
- lib/{payu/sdk_v21 → PayU}/OpenPayU/v2/Order.php +47 -39
- lib/{payu/sdk_v21 → PayU}/OpenPayU/v2/Refund.php +24 -22
- lib/PayU/OpenPayU/v2/Retrieve.php +75 -0
- lib/PayU/openpayu.php +40 -0
- lib/payu/sdk_v21/OpenPayU/Configuration.php +0 -302
- lib/payu/sdk_v21/OpenPayU/Http.php +0 -135
- lib/payu/sdk_v21/OpenPayU/HttpProtocol.php +0 -10
- lib/payu/sdk_v21/OpenPayU/OpenPayU.php +0 -250
- lib/payu/sdk_v21/OpenPayU/OpenPayUBase.php +0 -265
- lib/payu/sdk_v21/OpenPayU/OpenPayUException.php +0 -43
- lib/payu/sdk_v21/OpenPayU/OpenPayUNetwork.php +0 -181
- lib/payu/sdk_v21/OpenPayU/v2/Token.php +0 -66
- lib/payu/sdk_v21/openpayu.php +0 -30
- lib/payu/sdk_v21/openpayu_domain.php +0 -67
- package.xml +15 -10
- readme_images/cache_flushed.png +0 -0
- readme_images/save_config.png +0 -0
- skin/frontend/base/default/css/payu/payu.css +4 -0
app/code/community/PayU/Account/Block/Adminhtml/Sales/Order/View.php
DELETED
@@ -1,53 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* ver. 1.8.1
|
5 |
-
* PayU Adminhtml Sales Order View
|
6 |
-
*
|
7 |
-
* @copyright Copyright (c) 2011-2014 PayU
|
8 |
-
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
9 |
-
* http://www.payu.com
|
10 |
-
* http://www.openpayu.com
|
11 |
-
* http://twitter.com/openpayu
|
12 |
-
*/
|
13 |
-
|
14 |
-
class PayU_Account_Block_Adminhtml_Sales_Order_View extends Mage_Adminhtml_Block_Sales_Order_View {
|
15 |
-
|
16 |
-
// constructor
|
17 |
-
public function __construct() {
|
18 |
-
|
19 |
-
parent::__construct();
|
20 |
-
|
21 |
-
if($this->_isAllowedAction('review_payment') && $this->getOrder()->getPayment()->getMethod() == 'payu_account' && $this->getOrder()->getStatus() == 'pending_payment' && (int)Mage::getStoreConfig('payment/payu_account/selfreturn') == 0){
|
22 |
-
$this->_addButton('payu-complete', array(
|
23 |
-
'label' => Mage::helper('payu_account')->__('Complete PayU payment'),
|
24 |
-
'onclick' => 'setLocation(\'' . $this->getCompletePaymentUrl() . '\')',
|
25 |
-
'class' => ''
|
26 |
-
), 0, 100, 'header', 'header');
|
27 |
-
|
28 |
-
$this->_addButton('payu-cancel', array(
|
29 |
-
'label' => Mage::helper('payu_account')->__('Cancel PayU payment'),
|
30 |
-
'onclick' => 'setLocation(\'' . $this->getCancelPaymentUrl() . '\')',
|
31 |
-
'class' => ''
|
32 |
-
), 0, 200, 'header', 'header');
|
33 |
-
}
|
34 |
-
}
|
35 |
-
|
36 |
-
// rejecting the PayU payment
|
37 |
-
public function getRejectPaymentUrl()
|
38 |
-
{
|
39 |
-
return $this->getUrl('*/sales_order/rejectPayUOrder');
|
40 |
-
}
|
41 |
-
|
42 |
-
// canceling the PayU payment
|
43 |
-
public function getCancelPaymentUrl()
|
44 |
-
{
|
45 |
-
return $this->getUrl('*/sales_order/cancelPayUOrder');
|
46 |
-
}
|
47 |
-
|
48 |
-
// completing the PayU payment
|
49 |
-
public function getCompletePaymentUrl()
|
50 |
-
{
|
51 |
-
return $this->getUrl('*/sales_order/completePayUOrder');
|
52 |
-
}
|
53 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/PayU/Account/Block/Advertisement.php
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* ver. 1.9.0
|
5 |
-
* PayU Advertisement Block
|
6 |
-
* Payment
|
7 |
-
*
|
8 |
-
* @copyright Copyright (c) 2011-2014 PayU
|
9 |
-
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
10 |
-
* http://www.payu.com
|
11 |
-
* http://www.openpayu.com
|
12 |
-
* http://twitter.com/openpayu
|
13 |
-
*/
|
14 |
-
|
15 |
-
class PayU_Account_Block_Advertisement extends Mage_Core_Block_Template
|
16 |
-
{
|
17 |
-
/**
|
18 |
-
* Redirection after clicking the advertisement
|
19 |
-
*
|
20 |
-
* @var string
|
21 |
-
*/
|
22 |
-
protected $_redirectUrl = 'http://www.payu.pl';
|
23 |
-
|
24 |
-
/**
|
25 |
-
* (non-PHPdoc)
|
26 |
-
* @see magento/app/code/core/Mage/Core/Block/Mage_Core_Block_Template::_toHtml()
|
27 |
-
*/
|
28 |
-
protected function _toHtml()
|
29 |
-
{
|
30 |
-
/**
|
31 |
-
* setting the advertisement source url
|
32 |
-
*/
|
33 |
-
$this->setAdvertisementSrc(Mage::getModel('payu_account/config')->getAdvertisementSrc());
|
34 |
-
|
35 |
-
/**
|
36 |
-
* setting the redirect url
|
37 |
-
*/
|
38 |
-
$this->setRedirectUrl($this->_redirectUrl);
|
39 |
-
|
40 |
-
return parent::_toHtml();
|
41 |
-
}
|
42 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/PayU/Account/Block/BeforeSummary.php
DELETED
@@ -1,53 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* ver. 1.9.0
|
5 |
-
* PayU BeforeSummary Redirection Block
|
6 |
-
* Payment
|
7 |
-
*
|
8 |
-
* @copyright Copyright (c) 2011-2014 PayU
|
9 |
-
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
10 |
-
* http://www.payu.com
|
11 |
-
* http://www.openpayu.com
|
12 |
-
* http://twitter.com/openpayu
|
13 |
-
*/
|
14 |
-
|
15 |
-
class PayU_Account_Block_BeforeSummary extends Mage_Core_Block_Abstract
|
16 |
-
{
|
17 |
-
protected $_order = null;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* (non-PHPdoc)
|
21 |
-
* @see magento/app/code/core/Mage/Core/Block/Mage_Core_Block_Abstract::_toHtml()
|
22 |
-
*/
|
23 |
-
protected function _toHtml()
|
24 |
-
{
|
25 |
-
$payment = Mage::getModel('payu_account/payment');
|
26 |
-
|
27 |
-
$form = new Varien_Data_Form();
|
28 |
-
|
29 |
-
$redirectData = $payment->beforeSummary();
|
30 |
-
|
31 |
-
$form->setAction($redirectData['url'])
|
32 |
-
->setId('payu_checkout')
|
33 |
-
->setName('payu_checkout')
|
34 |
-
->setMethod('GET')
|
35 |
-
->setUseContainer(true);
|
36 |
-
|
37 |
-
$form->addField('sessionId', 'hidden', array('name' => 'sessionId', 'value' => $redirectData['sessionId']));
|
38 |
-
$form->addField('oauth_token', 'hidden', array('name' => 'oauth_token', 'value' => $redirectData['oauth_token']));
|
39 |
-
$form->addField('client_id', 'hidden', array('name' => 'client_id', 'value' => $redirectData['client_id']));
|
40 |
-
|
41 |
-
$html = '<html><body>';
|
42 |
-
$html.= $form->toHtml();
|
43 |
-
$html.= '<script type="text/javascript">document.getElementById("payu_checkout").submit();</script>';
|
44 |
-
$html.= '</body></html>';
|
45 |
-
|
46 |
-
return $html;
|
47 |
-
}
|
48 |
-
|
49 |
-
public function setOrder($order) {
|
50 |
-
$this->_order = $order;
|
51 |
-
return $this;
|
52 |
-
}
|
53 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/PayU/Account/Block/Button.php
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* ver. 1.9.0
|
5 |
-
* PayU Button Block
|
6 |
-
*
|
7 |
-
* @copyright Copyright (c) 2011-2014 PayU
|
8 |
-
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
9 |
-
* http://www.payu.com
|
10 |
-
* http://www.openpayu.com
|
11 |
-
* http://twitter.com/openpayu
|
12 |
-
*/
|
13 |
-
|
14 |
-
class PayU_Account_Block_Button extends Mage_Core_Block_Template
|
15 |
-
{
|
16 |
-
|
17 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/PayU/Account/Block/Form.php
CHANGED
@@ -1,18 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
*
|
5 |
-
*
|
6 |
-
*
|
7 |
-
*
|
8 |
-
|
9 |
-
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
10 |
-
* http://www.payu.com
|
11 |
-
* http://www.openpayu.com
|
12 |
-
* http://twitter.com/openpayu
|
13 |
-
*/
|
14 |
-
|
15 |
-
|
16 |
class PayU_Account_Block_Form extends Mage_Payment_Block_Form
|
17 |
{
|
18 |
/**
|
@@ -21,16 +14,30 @@ class PayU_Account_Block_Form extends Mage_Payment_Block_Form
|
|
21 |
*/
|
22 |
protected $_methodCode = 'payu_account';
|
23 |
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
/**
|
26 |
* Set template and redirect message
|
27 |
*/
|
28 |
protected function _construct()
|
29 |
{
|
30 |
$this->setTemplate('payu_account/form.phtml');
|
31 |
-
$this->setMethodTitle('');
|
32 |
-
$this->setMethodLabelAfterHtml('<img src="'.
|
33 |
-
|
34 |
return parent::_construct();
|
35 |
}
|
36 |
|
@@ -42,4 +49,12 @@ class PayU_Account_Block_Form extends Mage_Payment_Block_Form
|
|
42 |
{
|
43 |
return $this->_methodCode;
|
44 |
}
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* PayU Form Block
|
5 |
+
*
|
6 |
+
* @copyright Copyright (c) 2011-2016 PayU
|
7 |
+
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
8 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
class PayU_Account_Block_Form extends Mage_Payment_Block_Form
|
10 |
{
|
11 |
/**
|
14 |
*/
|
15 |
protected $_methodCode = 'payu_account';
|
16 |
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Prepare layout.
|
20 |
+
* Add files to use PayU
|
21 |
+
*
|
22 |
+
* @return PayU_Account_Block_Form
|
23 |
+
*/
|
24 |
+
protected function _prepareLayout()
|
25 |
+
{
|
26 |
+
if ($head = $this->getLayout()->getBlock('head')) {
|
27 |
+
$head->addCss('css/payu/payu.css');
|
28 |
+
}
|
29 |
+
return parent::_prepareLayout();
|
30 |
+
}
|
31 |
+
|
32 |
/**
|
33 |
* Set template and redirect message
|
34 |
*/
|
35 |
protected function _construct()
|
36 |
{
|
37 |
$this->setTemplate('payu_account/form.phtml');
|
38 |
+
$this->setMethodTitle($this->__('Pay with PayU'));
|
39 |
+
$this->setMethodLabelAfterHtml('<img src="' . $this->getPayuLogo() . '" alt="PayU" class="formPayuLogo" />');
|
40 |
+
|
41 |
return parent::_construct();
|
42 |
}
|
43 |
|
49 |
{
|
50 |
return $this->_methodCode;
|
51 |
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @return string
|
55 |
+
*/
|
56 |
+
private function getPayuLogo()
|
57 |
+
{
|
58 |
+
return $this->getSkinUrl('images/payu/payu_logo.png');
|
59 |
+
}
|
60 |
+
}
|
app/code/community/PayU/Account/Block/Onestep/Checkout.php
DELETED
@@ -1,53 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* ver. 1.9.0
|
5 |
-
* PayU One Step Checkout Block
|
6 |
-
*
|
7 |
-
* @copyright Copyright (c) 2011-2014 PayU
|
8 |
-
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
9 |
-
* http://www.payu.com
|
10 |
-
* http://www.openpayu.com
|
11 |
-
* http://twitter.com/openpayu
|
12 |
-
*/
|
13 |
-
|
14 |
-
class PayU_Account_Block_Onestep_Checkout extends Mage_Core_Block_Template
|
15 |
-
{
|
16 |
-
|
17 |
-
/** @var config variable */
|
18 |
-
protected $_config;
|
19 |
-
|
20 |
-
/** @var string Start One Step action */
|
21 |
-
protected $_startAction = 'newOneStep';
|
22 |
-
|
23 |
-
/** @var bool Whether the block should be eventually rendered */
|
24 |
-
protected $_shouldRender = true;
|
25 |
-
|
26 |
-
/** @var string Express checkout model factory name */
|
27 |
-
protected $_checkoutType = 'payu_account/express_checkout';
|
28 |
-
|
29 |
-
/**
|
30 |
-
* (non-PHPdoc)
|
31 |
-
* @see magento/app/code/core/Mage/Core/Block/Mage_Core_Block_Template::_toHtml()
|
32 |
-
*/
|
33 |
-
protected function _toHtml()
|
34 |
-
{
|
35 |
-
|
36 |
-
|
37 |
-
if($this->getRequest()->getParam('submitCustomCheckout'))
|
38 |
-
{
|
39 |
-
$billingAddress = $this->getRequest()->getParam('billing');
|
40 |
-
$billingAddress['use_for_shipping'] = 0;
|
41 |
-
$shippingAddress = $this->getRequest()->getParam('shipping');
|
42 |
-
}
|
43 |
-
|
44 |
-
|
45 |
-
$this->_config = Mage::getModel('payu_account/config');
|
46 |
-
$this->setButtonSrc($this->_config->getButtonSrc());
|
47 |
-
$this->setIsOneStepCheckoutEnabled($this->_config->getIsOneStepCheckoutEnabled());
|
48 |
-
$this->setIsOneStepCheckoutAvailable($this->_config->getIsOneStepCheckoutAvailable());
|
49 |
-
$this->setCheckoutUrl($this->_config->getBaseUrl().$this->_startAction);
|
50 |
-
|
51 |
-
return parent::_toHtml();
|
52 |
-
}
|
53 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/PayU/Account/Block/Redirect.php
DELETED
@@ -1,58 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* ver. 1.9.0
|
5 |
-
* PayU Payment Redirect Block
|
6 |
-
* Payment
|
7 |
-
*
|
8 |
-
* @copyright Copyright (c) 2011-2014 PayU
|
9 |
-
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
10 |
-
* http://www.payu.com
|
11 |
-
* http://www.openpayu.com
|
12 |
-
* http://twitter.com/openpayu
|
13 |
-
*
|
14 |
-
*/
|
15 |
-
|
16 |
-
class PayU_Account_Block_Redirect extends Mage_Core_Block_Abstract {
|
17 |
-
|
18 |
-
protected $_order = null;
|
19 |
-
|
20 |
-
protected $_allShippingMethods = null;
|
21 |
-
|
22 |
-
/**
|
23 |
-
* (non-PHPdoc)
|
24 |
-
*
|
25 |
-
* @see magento1/app/code/core/Mage/Core/Block/Mage_Core_Block_Abstract::_toHtml()
|
26 |
-
*/
|
27 |
-
protected function _toHtml() {
|
28 |
-
/**
|
29 |
-
* Fetching current payment
|
30 |
-
*
|
31 |
-
* @var PayU_Account_Model_Payment
|
32 |
-
*/
|
33 |
-
$payment = Mage::getModel ( 'payu_account/payment' );
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Setting the redirect info
|
37 |
-
*
|
38 |
-
* @var array
|
39 |
-
*/
|
40 |
-
$redirectData = $payment->orderCreateRequest ( $this->_order, $this->_allShippingMethods );
|
41 |
-
|
42 |
-
$html = '<html><body>';
|
43 |
-
$html .= '<script type="text/javascript">window.location.replace("' . urldecode ( $redirectData ['redirectUri'] ) . '");</script>';
|
44 |
-
$html .= '</body></html>';
|
45 |
-
|
46 |
-
return $html;
|
47 |
-
}
|
48 |
-
|
49 |
-
public function setAllShippingMethods($allShippingMethods) {
|
50 |
-
$this->_allShippingMethods = $allShippingMethods;
|
51 |
-
return $this;
|
52 |
-
}
|
53 |
-
|
54 |
-
public function setOrder($order) {
|
55 |
-
$this->_order = $order;
|
56 |
-
return $this;
|
57 |
-
}
|
58 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/PayU/Account/Block/UpdateInfo.php
CHANGED
@@ -1,84 +1,21 @@
|
|
1 |
-
<?php
|
2 |
|
3 |
/**
|
4 |
-
*
|
5 |
-
* PayU Update Info Block
|
6 |
*
|
7 |
-
*
|
8 |
-
*
|
9 |
-
* http://www.payu.com
|
10 |
-
* http://www.openpayu.com
|
11 |
-
* http://twitter.com/openpayu
|
12 |
*/
|
13 |
-
|
14 |
class PayU_Account_Block_UpdateInfo extends Mage_Adminhtml_Block_System_Config_Form_Field
|
15 |
{
|
16 |
-
|
|
|
|
|
|
|
17 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
18 |
{
|
19 |
-
|
20 |
-
|
21 |
-
$latestVersion = Mage::getModel('payu_account/config')->getLatestVersion();
|
22 |
-
|
23 |
-
/** @var array Get latest version info of the plugin */
|
24 |
-
$latestVersionInfo = Mage::getModel('payu_account/config')->getLatestVersionInfo();
|
25 |
-
|
26 |
-
if(!Mage::getModel('payu_account/config')->isLatestVersionInstalled()){
|
27 |
-
|
28 |
-
$html = "<div style='text-align:center;padding:5px;margin:5px 0px 5px 0px;border:1px #e58080 solid;background-color:#f6d3d3;box-shadow:2px 2px 6px #ccc;color:#ae1111;'>".Mage::helper('payu_account')->__('CAUTION: PayU plugin is not up to date.')."</div>";
|
29 |
-
$html .= Mage::helper('payu_account')->__('You are currently using version').":<br><b>";
|
30 |
-
$html .= Mage::getModel('payu_account/config')->getPluginVersion()." ".Mage::helper('payu_account')->__('for')." magento ".Mage::getModel('payu_account/config')->getMinimumMageVersion()."+</b><hr>";
|
31 |
-
|
32 |
-
$html .= Mage::helper('payu_account')->__('The latest version of PayU plugin is');
|
33 |
-
$html .= " <b>".$latestVersion['version']."</b>";
|
34 |
-
|
35 |
-
$html .= "<div style='text-align:center;padding:5px;margin:5px 0px 5px 0px;border:1px #c0dbea solid;background-color:#f4f9fb;box-shadow:2px 2px 6px #ccc;color:#1f516e;'><a href=\"http://".$latestVersionInfo['repository']."\" target=\"_blank\">".$latestVersionInfo['repository']."</a></div>";
|
36 |
-
|
37 |
-
}else{
|
38 |
-
|
39 |
-
$html = "<div style='text-align:center;padding:5px;margin:5px 0px 5px 0px;border:1px #97cf7b solid;background-color:#dbf2d0;box-shadow:2px 2px 6px #ccc;color:#3c8a15;'>".Mage::helper('payu_account')->__('OK: PayU plugin is up to date.')."</div>";
|
40 |
-
$html .= Mage::helper('payu_account')->__('You are currently using version').":<br><b>";
|
41 |
-
$html .= Mage::getModel('payu_account/config')->getPluginVersion()." ".Mage::helper('payu_account')->__('for')." magento ".Mage::getModel('payu_account/config')->getMinimumMageVersion()."+</b><hr>";
|
42 |
-
|
43 |
-
}
|
44 |
-
$html .= Mage::helper('payu_account')->__('Documents attached to this implementation').":<br>";
|
45 |
-
|
46 |
-
if(isset($latestVersion['docs']['guides']))
|
47 |
-
{
|
48 |
-
foreach($latestVersion['docs']['guides'] as $doc){
|
49 |
-
|
50 |
-
$html .= $this->getLayout()->createBlock('adminhtml/widget_button')
|
51 |
-
->setType('button')
|
52 |
-
->setClass('scalable')
|
53 |
-
->setLabel($doc['name'])
|
54 |
-
->setOnClick("window.open('".$doc['url']."')")
|
55 |
-
->toHtml();
|
56 |
-
$html .= "<br>";
|
57 |
-
|
58 |
-
}
|
59 |
-
}
|
60 |
-
|
61 |
-
if(count($latestVersion['docs']['websites']) > 0){
|
62 |
-
$html .= Mage::helper('payu_account')->__('More info on').":<br>";
|
63 |
-
}
|
64 |
-
|
65 |
-
if(isset($latestVersion['docs']['websites']))
|
66 |
-
{
|
67 |
-
foreach($latestVersion['docs']['websites'] as $key => $website){
|
68 |
-
|
69 |
-
|
70 |
-
$html .= $this->getLayout()->createBlock('adminhtml/widget_button')
|
71 |
-
->setType('button')
|
72 |
-
->setClass('scalable')
|
73 |
-
->setLabel($website['name'])
|
74 |
-
->setOnClick("window.open('".$website['url']."')")
|
75 |
-
->toHtml();
|
76 |
-
$html .= "<br>";
|
77 |
-
|
78 |
-
}
|
79 |
-
}
|
80 |
-
|
81 |
-
$html .= $latestVersion['description'];
|
82 |
|
83 |
return $html;
|
84 |
}
|
1 |
+
<?php
|
2 |
|
3 |
/**
|
4 |
+
* PayU Update Info Block
|
|
|
5 |
*
|
6 |
+
* @copyright Copyright (c) 2011-2016 PayU
|
7 |
+
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
|
|
|
|
|
|
8 |
*/
|
|
|
9 |
class PayU_Account_Block_UpdateInfo extends Mage_Adminhtml_Block_System_Config_Form_Field
|
10 |
{
|
11 |
+
/**
|
12 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
13 |
+
* @return string
|
14 |
+
*/
|
15 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
16 |
{
|
17 |
+
$html = Mage::helper('payu_account')->__('You are currently using version') . ":<br><b>";
|
18 |
+
$html .= Mage::getModel('payu_account/config')->getPluginVersion() . " " . Mage::helper('payu_account')->__('for') . " magento " . Mage::getModel('payu_account/config')->getMinimumMageVersion() . "+</b>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
return $html;
|
21 |
}
|
app/code/community/PayU/Account/Helper/Data.php
CHANGED
@@ -1,76 +1,24 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
*
|
5 |
-
*
|
6 |
-
*
|
7 |
-
*
|
8 |
-
|
9 |
-
* http://www.payu.com
|
10 |
-
* http://www.openpayu.com
|
11 |
-
* http://twitter.com/openpayu
|
12 |
-
*/
|
13 |
-
|
14 |
class PayU_Account_Helper_Data extends Mage_Core_Helper_Abstract
|
15 |
{
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
24 |
$round = (int)round($multiplied);
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Change locale of given string and separator
|
30 |
-
* @param string $string
|
31 |
-
* @param string $s
|
32 |
-
*/
|
33 |
-
|
34 |
-
public function localize($string, $s = "/"){
|
35 |
-
|
36 |
-
$lang = explode("_",Mage::app()->getLocale()->getLocaleCode());
|
37 |
-
|
38 |
-
if(!in_array($lang[0],array("pl","en")))
|
39 |
-
$lang[0] = "en";
|
40 |
-
|
41 |
-
$from = array("/pl/","/en/",$s."pl".$s,$s."en".$s,"_en.","_pl.");
|
42 |
-
$to = array("/".$lang[0]."/","/".$lang[0]."/",$s.$lang[0].$s,$s.$lang[0].$s,"_".$lang[0].".","_".$lang[0].".");
|
43 |
-
|
44 |
-
return str_replace($from, $to, $string);
|
45 |
-
|
46 |
-
}
|
47 |
-
|
48 |
-
public function isFirstVersionNewer($build1,$build2){
|
49 |
-
$arr1 = explode(".",$build1);
|
50 |
-
$arr2 = explode(".",$build2);
|
51 |
-
|
52 |
-
$b1 = "";
|
53 |
-
$b2 = "";
|
54 |
-
|
55 |
-
foreach($arr1 as $key => $b){
|
56 |
-
$b1 .= str_pad($arr1[$key], 4,"0",STR_PAD_LEFT);
|
57 |
-
$b2 .= str_pad($arr2[$key], 4,"0",STR_PAD_LEFT);
|
58 |
-
}
|
59 |
-
|
60 |
-
return ((int)$b1 > (int)$b2);
|
61 |
}
|
62 |
-
|
63 |
-
/*
|
64 |
-
public function localize($string, $s = "/"){
|
65 |
-
$lang = explode("_",Mage::app()->getLocale()->getLocaleCode());
|
66 |
-
if(!in_array($lang[0],array("pl","en")))
|
67 |
-
$lang[0] = "en";
|
68 |
-
|
69 |
-
_pl. _pl_ /pl/
|
70 |
-
|
71 |
-
$patt = array('[_./]pl[_./]','[_./]en[_./]');
|
72 |
-
$repl = array('[_./]'.$lang[0].'[_./]','[_./]'.$lang[0].'[_./]');
|
73 |
-
return preg_replace($patt,$repl,$string);
|
74 |
-
}*/
|
75 |
-
|
76 |
-
}
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* PayU Data Helper Model
|
5 |
+
*
|
6 |
+
* @copyright Copyright (c) 2011-2016 PayU
|
7 |
+
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
8 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
9 |
class PayU_Account_Helper_Data extends Mage_Core_Helper_Abstract
|
10 |
{
|
11 |
+
/**
|
12 |
+
* Converts the Magento float values (for instance 9.9900) to PayU accepted Currency format (999)
|
13 |
+
*
|
14 |
+
* @param string
|
15 |
+
* @return int
|
16 |
+
*/
|
17 |
+
public function toAmount($val)
|
18 |
+
{
|
19 |
+
$multiplied = $val * 100;
|
20 |
$round = (int)round($multiplied);
|
21 |
+
|
22 |
+
return $round;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
}
|
24 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/PayU/Account/Model/Adminhtml/Sales/Order.php
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class PayU_Account_Adminhtml_Model_Order extends Mage_Adminhtml_Sales_Model_Order{
|
4 |
-
|
5 |
-
|
6 |
-
public function newFunctions()
|
7 |
-
{
|
8 |
-
//new functions/methods content
|
9 |
-
}
|
10 |
-
|
11 |
-
public function existingFunctions()
|
12 |
-
{
|
13 |
-
//new functions/methods content with the extended functionalities
|
14 |
-
}
|
15 |
-
|
16 |
-
|
17 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/PayU/Account/Model/Advertisement.php
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* ver. 1.9.0
|
5 |
-
* PayU Logo Model
|
6 |
-
*
|
7 |
-
* @copyright Copyright (c) 2011-2014 PayU
|
8 |
-
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
9 |
-
* http://www.payu.com
|
10 |
-
* http://www.openpayu.com
|
11 |
-
* http://twitter.com/openpayu
|
12 |
-
*/
|
13 |
-
|
14 |
-
class PayU_Account_Model_Advertisement
|
15 |
-
{
|
16 |
-
|
17 |
-
public function toOptionArray()
|
18 |
-
{
|
19 |
-
|
20 |
-
$advertisements = Mage::getModel('payu_account/config')->getGoods('media_adverts_skyscraper');
|
21 |
-
|
22 |
-
$options = array();
|
23 |
-
|
24 |
-
foreach ($advertisements as $code => $label) {
|
25 |
-
$options[] = array(
|
26 |
-
'value' => $label,
|
27 |
-
'label' => $label
|
28 |
-
);
|
29 |
-
}
|
30 |
-
return $options;
|
31 |
-
}
|
32 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/PayU/Account/Model/Button.php
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* ver. 1.9.0
|
5 |
-
* PayU Button Model
|
6 |
-
*
|
7 |
-
* @copyright Copyright (c) 2011-2014 PayU
|
8 |
-
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
9 |
-
* http://www.payu.com
|
10 |
-
* http://www.openpayu.com
|
11 |
-
* http://twitter.com/openpayu
|
12 |
-
*/
|
13 |
-
|
14 |
-
class PayU_Account_Model_Button
|
15 |
-
{
|
16 |
-
|
17 |
-
public function toOptionArray()
|
18 |
-
{
|
19 |
-
|
20 |
-
/** @var array get list of available buttons */
|
21 |
-
$buttons = Mage::getModel('payu_account/config')->getGoods('media_buttons');
|
22 |
-
|
23 |
-
$options = array();
|
24 |
-
|
25 |
-
foreach ($buttons as $label) {
|
26 |
-
$options[] = array(
|
27 |
-
'value' => $label,
|
28 |
-
'label' => $label
|
29 |
-
);
|
30 |
-
}
|
31 |
-
return $options;
|
32 |
-
}
|
33 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/PayU/Account/Model/Config.php
CHANGED
@@ -1,279 +1,127 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
*
|
5 |
-
*
|
6 |
-
*
|
7 |
-
*
|
8 |
-
|
9 |
-
* http://www.payu.com
|
10 |
-
* http://www.openpayu.com
|
11 |
-
* http://twitter.com/openpayu
|
12 |
-
*/
|
13 |
-
|
14 |
class PayU_Account_Model_Config
|
15 |
{
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
/** @var array The goods resources are stored here */
|
38 |
-
protected $_goods;
|
39 |
-
|
40 |
-
protected $_storeId;
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Constructor
|
44 |
-
*
|
45 |
-
* @param $params
|
46 |
-
*/
|
47 |
public function __construct($params = array())
|
48 |
{
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
// assign current store id
|
53 |
-
$this->setStoreId(Mage::app()->getStore()->getId());
|
54 |
-
// assign goods data
|
55 |
-
$this->setGoods();
|
56 |
-
// set latest version url
|
57 |
-
$this->setLatestVersionUrl();
|
58 |
-
// set latest version data
|
59 |
-
$this->setLatestVersion();
|
60 |
-
}
|
61 |
-
|
62 |
-
/** set current store Id */
|
63 |
-
public function setStoreId($storeId){
|
64 |
-
$this->_storeId = $storeId;
|
65 |
}
|
66 |
-
|
67 |
/**
|
68 |
-
*
|
69 |
-
* @return
|
70 |
*/
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
//check if we work in production mode
|
76 |
-
case PayU_Account_Model_Environment::PRODUCTION:
|
77 |
-
$this->_env = "secure";
|
78 |
-
break;
|
79 |
-
// default sandbox mode
|
80 |
-
default:
|
81 |
-
$this->_env = "sandbox";
|
82 |
-
break;
|
83 |
-
|
84 |
-
}
|
85 |
-
|
86 |
-
return $this->_env;
|
87 |
-
|
88 |
-
}
|
89 |
-
|
90 |
-
/** @return string get current environment */
|
91 |
-
public function getEnvironment(){
|
92 |
-
return $this->setEnvironment();
|
93 |
}
|
94 |
-
|
95 |
/** @return string get Merchant POS Id */
|
96 |
-
public function getMerchantPosId()
|
97 |
-
|
98 |
-
|
99 |
-
// currently it is the same, so no need to separate parameter configuration
|
100 |
-
return $this->getClientId();
|
101 |
-
|
102 |
-
}
|
103 |
-
|
104 |
-
/** @return string get Pos Auth Key */
|
105 |
-
public function getPosAuthKey(){
|
106 |
-
return $this->getStoreConfig('payment/payu_account/pos_auth_key');
|
107 |
-
}
|
108 |
-
|
109 |
-
/** @return string get (OAuth Client Name) */
|
110 |
-
public function getClientId(){
|
111 |
-
return $this->getStoreConfig('payment/payu_account/oauth_client_name');
|
112 |
-
}
|
113 |
-
|
114 |
-
/** @return string get (OAuth Client Secret) */
|
115 |
-
public function getClientSecret(){
|
116 |
-
return $this->getStoreConfig('payment/payu_account/oauth_client_secret');
|
117 |
-
}
|
118 |
-
|
119 |
-
/** @return string get signature key */
|
120 |
-
public function getSignatureKey(){
|
121 |
-
return $this->getStoreConfig('payment/payu_account/signature_key');
|
122 |
-
}
|
123 |
-
|
124 |
-
/** @return int order validity time in minutes */
|
125 |
-
public function getOrderValidityTime(){
|
126 |
-
|
127 |
-
$validityTime = $this->getStoreConfig('payment/payu_account/validity_time');
|
128 |
-
|
129 |
-
if($validityTime)
|
130 |
-
return $validityTime;
|
131 |
-
|
132 |
-
return "86400";
|
133 |
-
|
134 |
-
}
|
135 |
-
|
136 |
-
/** @return string small logo src */
|
137 |
-
public function getThumbnailSrc(){
|
138 |
-
return $this->getStoreConfig('payment/payu_account/payuthumbnail');
|
139 |
-
}
|
140 |
-
|
141 |
-
/** @return string advertisement banner url */
|
142 |
-
public function getAdvertisementSrc(){
|
143 |
-
return $this->localize($this->getStoreConfig('payment/payu_account/payuadvertisement'));
|
144 |
-
}
|
145 |
-
|
146 |
-
/** @return string one step checkout button url */
|
147 |
-
public function getButtonSrc(){
|
148 |
-
return $this->localize($this->getStoreConfig('payment/payu_account/payubutton'));
|
149 |
-
}
|
150 |
-
|
151 |
-
/** $return string base module url */
|
152 |
-
public function getBaseUrl(){
|
153 |
-
return Mage::getBaseUrl().'payu_account/payment/';
|
154 |
-
}
|
155 |
-
|
156 |
-
/** @return string check if is one step checkout method enabled */
|
157 |
-
public function getIsOneStepCheckoutEnabled(){
|
158 |
-
return $this->getStoreConfig('payment/payu_account/onestepcheckoutenabled');
|
159 |
-
}
|
160 |
-
|
161 |
-
/** @return string check if is one step checkout method available */
|
162 |
-
public function getIsOneStepCheckoutAvailable(){
|
163 |
-
return true;
|
164 |
-
}
|
165 |
-
|
166 |
-
/** @return int what is the default new order status */
|
167 |
-
public function getNewOrderStatus(){
|
168 |
-
return $this->getStoreConfig('payment/payu_account/order_status');
|
169 |
-
}
|
170 |
-
|
171 |
-
public function isLatestVersionInstalled(){
|
172 |
-
return !Mage::helper('payu_account')->isFirstVersionNewer($this->_latestVersion['version'],$this->_pluginVersion);
|
173 |
-
}
|
174 |
-
|
175 |
-
/** @return int what is the default new order status */
|
176 |
-
public function getIsSelfReturnEnabled(){
|
177 |
-
return $this->getStoreConfig('payment/payu_account/selfreturn');
|
178 |
}
|
179 |
|
180 |
/**
|
181 |
-
*
|
182 |
-
* @param string $name
|
183 |
-
* @return array|string $goods
|
184 |
*/
|
185 |
-
public function
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
if($name !== null){
|
190 |
-
|
191 |
-
$name_arr = explode("_",$name);
|
192 |
-
|
193 |
-
foreach($name_arr as $col){
|
194 |
-
if(empty($goodsItem[$col]))
|
195 |
-
return array('error');
|
196 |
-
$goodsItem = $goodsItem[$col];
|
197 |
-
}
|
198 |
-
|
199 |
-
}
|
200 |
-
|
201 |
-
return $this->localize($goodsItem);
|
202 |
-
|
203 |
-
}
|
204 |
-
|
205 |
-
/** @return array get latest plugin version data */
|
206 |
-
public function getLatestVersion(){
|
207 |
-
return $this->_latestVersion;
|
208 |
-
}
|
209 |
-
|
210 |
-
/** @return array get main latest version of plugin info */
|
211 |
-
public function getLatestVersionInfo(){
|
212 |
-
return $this->getGoods($this->_latestVersionPath,"_");
|
213 |
}
|
214 |
-
|
215 |
-
/**
|
216 |
-
|
217 |
-
|
|
|
|
|
|
|
218 |
}
|
219 |
-
|
220 |
-
/**
|
221 |
-
|
222 |
-
|
|
|
|
|
|
|
223 |
}
|
224 |
-
|
225 |
-
/**
|
226 |
-
|
227 |
-
|
|
|
|
|
|
|
228 |
}
|
229 |
-
|
230 |
/**
|
231 |
-
*
|
232 |
-
*
|
233 |
-
* @param $string
|
234 |
-
* @param $s
|
235 |
-
* @return string
|
236 |
*/
|
237 |
-
|
238 |
-
|
|
|
239 |
}
|
240 |
-
|
241 |
-
/**
|
242 |
-
|
243 |
-
|
|
|
|
|
|
|
244 |
}
|
245 |
-
|
246 |
-
/**
|
247 |
-
|
248 |
-
|
|
|
|
|
|
|
249 |
}
|
250 |
-
|
251 |
/**
|
252 |
-
*
|
253 |
-
*
|
254 |
-
* @param $url string
|
255 |
-
* @return array
|
256 |
*/
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
return json_decode($response->getBody(),true);
|
261 |
}
|
262 |
-
|
263 |
/**
|
264 |
* get Store Config variable
|
265 |
* @param $name
|
266 |
* @return string
|
267 |
*/
|
268 |
-
protected function getStoreConfig($name)
|
269 |
-
|
|
|
270 |
}
|
271 |
-
|
272 |
-
public function getDomainName()
|
273 |
-
{
|
274 |
-
return $_SERVER['HTTP_HOST'];
|
275 |
-
}
|
276 |
-
|
277 |
-
|
278 |
}
|
279 |
-
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* PayU Config Model
|
5 |
+
*
|
6 |
+
* @copyright Copyright (c) 2011-2016 PayU
|
7 |
+
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
8 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
9 |
class PayU_Account_Model_Config
|
10 |
{
|
11 |
+
/**
|
12 |
+
* @var string self version
|
13 |
+
*/
|
14 |
+
protected $_pluginVersion = '2.2.0';
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @var string minimum Magento e-commerce version
|
18 |
+
*/
|
19 |
+
protected $_minimumMageVersion = '1.6.0';
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @var int
|
23 |
+
*/
|
24 |
+
protected $_storeId;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Constructor
|
28 |
+
*
|
29 |
+
* @param $params
|
30 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
public function __construct($params = array())
|
32 |
{
|
33 |
+
// assign current store id
|
34 |
+
$this->setStoreId(Mage::app()->getStore()->getId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
}
|
36 |
+
|
37 |
/**
|
38 |
+
* @param int $storeId
|
39 |
+
* @return $this
|
40 |
*/
|
41 |
+
public function setStoreId($storeId)
|
42 |
+
{
|
43 |
+
$this->_storeId = $storeId;
|
44 |
+
return $this;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
46 |
+
|
47 |
/** @return string get Merchant POS Id */
|
48 |
+
public function getMerchantPosId()
|
49 |
+
{
|
50 |
+
return $this->getStoreConfig('payment/payu_account/pos_id');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
+
* @return string get signature key
|
|
|
|
|
55 |
*/
|
56 |
+
public function getSignatureKey()
|
57 |
+
{
|
58 |
+
return $this->getStoreConfig('payment/payu_account/signature_key');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @return string get (OAuth Client Name)
|
63 |
+
*/
|
64 |
+
public function getClientId()
|
65 |
+
{
|
66 |
+
return $this->getStoreConfig('payment/payu_account/oauth_client_id');
|
67 |
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @return string get (OAuth Client Secret)
|
71 |
+
*/
|
72 |
+
public function getClientSecret()
|
73 |
+
{
|
74 |
+
return $this->getStoreConfig('payment/payu_account/oauth_client_secret');
|
75 |
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* @return string one step checkout button url
|
79 |
+
*/
|
80 |
+
public function getButtonSrc()
|
81 |
+
{
|
82 |
+
return 'https://static.payu.com/pl/standard/partners/buttons/payu_account_button_01.png';
|
83 |
}
|
84 |
+
|
85 |
/**
|
86 |
+
* @return string base module url
|
|
|
|
|
|
|
|
|
87 |
*/
|
88 |
+
public function getUrl($action)
|
89 |
+
{
|
90 |
+
return Mage::getUrl("payu_account/payment/$action", array('_secure' => true));
|
91 |
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* @return string check if is one step checkout method enabled
|
95 |
+
*/
|
96 |
+
public function getIsOneStepCheckoutEnabled()
|
97 |
+
{
|
98 |
+
return $this->getStoreConfig('payment/payu_account/onestepcheckoutenabled');
|
99 |
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* @return string get current plugin version
|
103 |
+
*/
|
104 |
+
public function getPluginVersion()
|
105 |
+
{
|
106 |
+
return $this->_pluginVersion;
|
107 |
}
|
108 |
+
|
109 |
/**
|
110 |
+
* @return string get minimum mage version for the plugin to work on
|
|
|
|
|
|
|
111 |
*/
|
112 |
+
public function getMinimumMageVersion()
|
113 |
+
{
|
114 |
+
return $this->_minimumMageVersion;
|
|
|
115 |
}
|
116 |
+
|
117 |
/**
|
118 |
* get Store Config variable
|
119 |
* @param $name
|
120 |
* @return string
|
121 |
*/
|
122 |
+
protected function getStoreConfig($name)
|
123 |
+
{
|
124 |
+
return Mage::getStoreConfig($name, $this->_storeId);
|
125 |
}
|
126 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
}
|
|
app/code/community/PayU/Account/Model/Environment.php
DELETED
@@ -1,36 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* ver. 1.9.0
|
5 |
-
* PayU Environment Model
|
6 |
-
*
|
7 |
-
* @copyright Copyright (c) 2011-2014 PayU
|
8 |
-
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
9 |
-
* http://www.payu.com
|
10 |
-
* http://www.openpayu.com
|
11 |
-
* http://twitter.com/openpayu
|
12 |
-
*/
|
13 |
-
|
14 |
-
|
15 |
-
class PayU_Account_Model_Environment
|
16 |
-
{
|
17 |
-
|
18 |
-
/** @var string Production environment */
|
19 |
-
const PRODUCTION = 'secure';
|
20 |
-
|
21 |
-
/** @var string Testing environment */
|
22 |
-
const SANDBOX = 'sandbox';
|
23 |
-
|
24 |
-
public function toOptionArray() {
|
25 |
-
return array(
|
26 |
-
array(
|
27 |
-
'value' => PayU_Account_Model_Environment::PRODUCTION,
|
28 |
-
'label' => Mage::helper('payu_account')->__('No')
|
29 |
-
),
|
30 |
-
array(
|
31 |
-
'value' => PayU_Account_Model_Environment::SANDBOX,
|
32 |
-
'label' => Mage::helper('payu_account')->__('Yes')
|
33 |
-
)
|
34 |
-
);
|
35 |
-
}
|
36 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/PayU/Account/Model/Payment.php
CHANGED
@@ -1,976 +1,555 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
* ver. 1.9.0
|
5 |
* PayU -Standard Payment Model
|
6 |
*
|
7 |
-
* @copyright Copyright (c) 2011-
|
8 |
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
9 |
-
*
|
10 |
-
* http://www.openpayu.com
|
11 |
-
* http://twitter.com/openpayu
|
12 |
*/
|
13 |
|
14 |
-
require_once
|
15 |
|
16 |
-
class PayU_Account_Model_Payment extends Mage_Payment_Model_Method_Abstract
|
17 |
|
|
|
18 |
{
|
19 |
-
|
20 |
-
|
21 |
-
*
|
22 |
-
* @var PayU_Account_Model_Config
|
23 |
-
*/
|
24 |
-
protected $_config;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* The base module url
|
28 |
-
*
|
29 |
-
* @var string
|
30 |
-
*/
|
31 |
-
protected $_myUrl;
|
32 |
-
|
33 |
/**
|
34 |
* Payment method code
|
35 |
*
|
36 |
* @var string
|
37 |
*/
|
38 |
protected $_code = 'payu_account';
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Payment method title
|
42 |
-
*
|
43 |
-
* @var string
|
44 |
-
*/
|
45 |
-
protected $_title = 'PayU';
|
46 |
-
|
47 |
/**
|
48 |
* Block type
|
49 |
*
|
50 |
* @var string
|
51 |
*/
|
52 |
protected $_formBlockType = 'payu_account/form';
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Is initialization needed
|
56 |
-
*
|
57 |
-
* @var boolean
|
58 |
-
*/
|
59 |
-
protected $_isInitializeNeeded = true;
|
60 |
-
|
61 |
/**
|
62 |
* Transaction id
|
63 |
*/
|
64 |
protected $_transactionId;
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Pay method
|
68 |
-
*/
|
69 |
-
protected $_payuPayMethod;
|
70 |
-
|
71 |
/**
|
72 |
* Currently processed order
|
73 |
*
|
74 |
* @var Mage_Sales_Model_Order
|
75 |
*/
|
76 |
protected $_order;
|
77 |
-
|
78 |
-
protected $_isGateway =
|
79 |
-
protected $_canOrder =
|
80 |
-
protected $_canAuthorize =
|
81 |
protected $_canCapture = true;
|
82 |
-
protected $_canCapturePartial =
|
83 |
protected $_canRefund = true;
|
84 |
protected $_canRefundInvoicePartial = true;
|
85 |
protected $_canVoid = false;
|
86 |
-
protected $_canUseInternal =
|
87 |
protected $_canUseCheckout = true;
|
88 |
protected $_canUseForMultishipping = false;
|
89 |
-
protected $_canSaveCc = false;
|
90 |
protected $_canReviewPayment = true;
|
|
|
|
|
91 |
protected $_payUOrderResult = null;
|
92 |
-
|
93 |
-
const PAYMENT_STATUS_NEW = 'PAYMENT_STATUS_NEW';
|
94 |
-
const PAYMENT_STATUS_CANCEL = 'PAYMENT_STATUS_CANCEL';
|
95 |
-
const PAYMENT_STATUS_REJECT = 'PAYMENT_STATUS_REJECT';
|
96 |
-
const PAYMENT_STATUS_INIT = 'PAYMENT_STATUS_INIT';
|
97 |
-
const PAYMENT_STATUS_SENT = 'PAYMENT_STATUS_SENT';
|
98 |
-
const PAYMENT_STATUS_NOAUTH = 'PAYMENT_STATUS_NOAUTH';
|
99 |
-
const PAYMENT_STATUS_REJECT_DONE = 'PAYMENT_STATUS_REJECT_DONE';
|
100 |
-
const PAYMENT_STATUS_END = 'PAYMENT_STATUS_END';
|
101 |
-
const PAYMENT_STATUS_ERROR = 'PAYMENT_STATUS_ERROR';
|
102 |
-
|
103 |
-
const NEW_PAYMENT_URL = "payu_account/payment/new";
|
104 |
-
|
105 |
-
const ORDER_STATUS_COMPLETE = 'ORDER_STATUS_COMPLETE';
|
106 |
-
const ORDER_STATUS_CANCEL = 'ORDER_STATUS_CANCEL';
|
107 |
-
const ORDER_STATUS_REJECT = 'ORDER_STATUS_REJECT';
|
108 |
-
|
109 |
-
const ORDER_V2_NEW = 'NEW';
|
110 |
-
const ORDER_V2_PENDING = 'PENDING';
|
111 |
-
const ORDER_V2_CANCELED = 'CANCELED';
|
112 |
-
const ORDER_V2_REJECTED = 'REJECTED';
|
113 |
-
const ORDER_V2_COMPLETED = 'COMPLETED';
|
114 |
-
const ORDER_V2_WAITING_FOR_CONFIRMATION = 'WAITING_FOR_CONFIRMATION';
|
115 |
-
|
116 |
-
public function __construct() {
|
117 |
-
parent::__construct ();
|
118 |
-
$this->initializeOpenPayUConfiguration ();
|
119 |
-
}
|
120 |
|
121 |
-
public function
|
122 |
-
|
|
|
|
|
123 |
}
|
124 |
-
|
125 |
/**
|
126 |
-
*
|
127 |
-
* @param Mage_Sales_Model_Order
|
128 |
-
* @param Mage_Shipping_Model_Shipping
|
129 |
-
* @return array
|
130 |
*/
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
$orderCountryCode = $this->_order->getBillingAddress ()->getCountry ();
|
136 |
-
$shippingCostList = array ();
|
137 |
-
|
138 |
-
if (empty ( $allShippingRates ) || Mage::getSingleton ( 'customer/session' )->isLoggedIn()) {
|
139 |
-
|
140 |
-
if($order->getShippingInclTax() > 0) {
|
141 |
-
$shippingCostList ['shippingMethods'] [] = array(
|
142 |
-
'name' => $order->getShippingDescription(),
|
143 |
-
'country' => $orderCountryCode,
|
144 |
-
'price' => $this->toAmount($order->getShippingInclTax()),
|
145 |
-
);
|
146 |
-
}
|
147 |
-
|
148 |
-
$grandTotal = $this->_order->getGrandTotal () - $order->getShippingInclTax();
|
149 |
-
|
150 |
-
|
151 |
-
} else {
|
152 |
-
|
153 |
-
$firstPrice = 0;
|
154 |
-
|
155 |
-
foreach ( $allShippingRates as $key => $rate ) {
|
156 |
-
|
157 |
-
$gross = $this->toAmount ( $rate->getPrice () );
|
158 |
-
|
159 |
-
if($key == 0)
|
160 |
-
$firstPrice = $rate->getPrice ();
|
161 |
-
|
162 |
-
$shippingCostList ['shippingMethods'] [] = array (
|
163 |
-
'name' => $rate->getMethodTitle (),
|
164 |
-
'country' => $orderCountryCode,
|
165 |
-
'price' => $gross
|
166 |
-
);
|
167 |
-
|
168 |
-
}
|
169 |
-
|
170 |
-
$grandTotal = $this->_order->getGrandTotal () - $firstPrice;
|
171 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
}
|
173 |
-
|
174 |
-
$shippingCost = array (
|
175 |
-
'countryCode' => $orderCountryCode,'shipToOtherCountry' => 'true','shippingCostList' => $shippingCostList
|
176 |
-
);
|
177 |
-
|
178 |
-
$orderItems = $this->_order->getAllVisibleItems ();
|
179 |
-
|
180 |
-
$items = array ();
|
181 |
-
$productsTotal = 0;
|
182 |
-
|
183 |
-
$is_discount = false;
|
184 |
-
|
185 |
-
foreach ( $orderItems as $key => $item ) {
|
186 |
-
|
187 |
-
$itemInfo = $item->getData ();
|
188 |
-
|
189 |
-
if($itemInfo ['discount_amount'] > 0){
|
190 |
-
$itemInfo ['price_incl_tax'] = $itemInfo ['price_incl_tax'] - $itemInfo ['discount_amount'];
|
191 |
-
$is_discount = true;
|
192 |
-
}
|
193 |
-
|
194 |
-
else if($itemInfo ['discount_percent'] > 0)
|
195 |
-
$itemInfo ['price_incl_tax'] = $itemInfo ['price_incl_tax'] * (100 - $itemInfo ['discount_percent']) / 100;
|
196 |
-
|
197 |
-
// Check if the item is countable one
|
198 |
-
if ($this->toAmount ( $itemInfo ['price_incl_tax'] ) > 0) {
|
199 |
-
$items ['products'] [] = array (
|
200 |
-
'quantity' => ( int ) $itemInfo ['qty_ordered'],'name' => $itemInfo ['name'],'unitPrice' => $this->toAmount ( $itemInfo ['price_incl_tax'] )
|
201 |
-
);
|
202 |
-
$productsTotal += $itemInfo ['price_incl_tax'] * $itemInfo ['qty_ordered'];
|
203 |
-
}
|
204 |
-
}
|
205 |
-
|
206 |
-
//if($this->_order->getShippingAmount () > 0 && !empty ( $shippingCostList['shippingMethods'][0] ) ){
|
207 |
-
// $items ['products'] ['products'] [] = array (
|
208 |
-
// 'quantity' => 1 ,'name' => Mage::helper ( 'payu_account' )->__('Shipping costs') . " - " . $shippingCostList['shippingMethods'][0]['name'] ,'unitPrice' => $this->toAmount ( $this->_order->getShippingAmount () ));
|
209 |
-
//}
|
210 |
-
|
211 |
-
// assigning the shopping cart
|
212 |
-
$shoppingCart = array (
|
213 |
-
'grandTotal' => $this->toAmount ( $grandTotal ),'CurrencyCode' => $orderCurrencyCode,'ShoppingCartItems' => $items
|
214 |
-
);
|
215 |
-
|
216 |
-
$orderInfo = array (
|
217 |
-
'merchantPosId' => OpenPayU_Configuration::getMerchantPosId (),'orderUrl' => Mage::getBaseUrl () . 'sales/order/view/order_id/' . $this->_order->getId () . '/','description' => 'Order no ' . $this->_order->getRealOrderId (),'validityTime' => $this->_config->getOrderValidityTime ()
|
218 |
-
);
|
219 |
-
|
220 |
-
if($is_discount){
|
221 |
-
$items ['products'] = array();
|
222 |
-
$items ['products'][] = array (
|
223 |
-
'quantity' => 1,'name' => Mage::helper ( 'payu_account' )->__('Order # ') . $this->_order->getId (),'unitPrice' => $this->toAmount ( $grandTotal )
|
224 |
-
);
|
225 |
-
}
|
226 |
-
|
227 |
-
$OCReq = $orderInfo;
|
228 |
-
$OCReq ['products'] = $items ['products'];
|
229 |
-
$OCReq ['customerIp'] = Mage::app ()->getFrontController ()->getRequest ()->getClientIp ();
|
230 |
-
$OCReq ['notifyUrl'] = $this->_myUrl . 'orderNotifyRequest';
|
231 |
-
$OCReq ['cancelUrl'] = $this->_myUrl . 'cancelPayment';
|
232 |
-
$OCReq ['continueUrl'] = $this->_myUrl . 'continuePayment';
|
233 |
-
$OCReq ['currencyCode'] = $orderCurrencyCode;
|
234 |
-
$OCReq ['totalAmount'] = $shoppingCart ['grandTotal'];
|
235 |
-
$OCReq ['extOrderId'] = $this->_order->getId ().'-'.microtime();
|
236 |
-
if(!empty($shippingCostList))
|
237 |
-
$OCReq ['shippingMethods'] = $shippingCostList['shippingMethods'];
|
238 |
-
unset ( $OCReq ['shoppingCart'] );
|
239 |
-
$customer_sheet = array ();
|
240 |
-
|
241 |
-
$billingAddressId = $this->_order->getBillingAddressId ();
|
242 |
-
|
243 |
-
if (! empty ( $billingAddressId )) {
|
244 |
-
|
245 |
-
$billingAddress = $this->_order->getBillingAddress ();
|
246 |
-
|
247 |
-
$customer_mail = $billingAddress->getEmail ();
|
248 |
-
|
249 |
-
if (! empty ( $customer_mail )) {
|
250 |
-
|
251 |
-
$customer_sheet = array (
|
252 |
-
'email' => $billingAddress->getEmail (),'phone' => $billingAddress->getTelephone (),'firstName' => $billingAddress->getFirstname (),'lastName' => $billingAddress->getLastname ()
|
253 |
-
);
|
254 |
-
|
255 |
-
$shippingAddressId = $this->_order->getShippingAddressId ();
|
256 |
-
|
257 |
-
if (! empty ( $shippingAddressId )) {
|
258 |
-
$shippingAddress = $this->_order->getShippingAddress ();
|
259 |
-
}
|
260 |
-
|
261 |
-
if (! $this->_order->getIsVirtual ()) {
|
262 |
-
$customer_sheet ['delivery'] = array (
|
263 |
-
'street' => trim ( implode ( ' ', $shippingAddress->getStreet () ) ),'postalCode' => $shippingAddress->getPostcode (),'city' => $shippingAddress->getCity (),'countryCode' => $shippingAddress->getCountry (),
|
264 |
-
'recipientName' => trim ( $shippingAddress->getFirstname () . ' ' . $shippingAddress->getLastname () ),'recipientPhone' => $shippingAddress->getTelephone (),'recipientEmail' => $shippingAddress->getEmail ()
|
265 |
-
);
|
266 |
-
}
|
267 |
-
|
268 |
-
$OCReq ['buyer'] = $customer_sheet;
|
269 |
-
}
|
270 |
-
}
|
271 |
-
|
272 |
-
$result = OpenPayU_Order::create($OCReq);
|
273 |
-
|
274 |
-
if ($result->getStatus () == 'SUCCESS') {
|
275 |
-
|
276 |
-
// store session identifier in session info
|
277 |
-
Mage::getSingleton ( 'core/session' )->setPayUSessionId ( $result->getResponse ()->orderId );
|
278 |
-
|
279 |
-
// assign current transaction id
|
280 |
-
$this->_transactionId = $result->getResponse ()->orderId;
|
281 |
-
$order->getPayment()->setLastTransId($this->_transactionId);
|
282 |
-
|
283 |
-
|
284 |
-
$locale = Mage::getStoreConfig ( 'general/locale/code', Mage::app ()->getStore ()->getId () );
|
285 |
-
$lang_code = explode ( '_', $locale, 2 );
|
286 |
-
|
287 |
-
$ret = array (
|
288 |
-
'redirectUri' => $result->getResponse ()->redirectUri,'url' => OpenPayu_Configuration::getSummaryUrl (),'sessionId' => $result->getResponse ()->orderId,'lang' => strtolower ( $lang_code [1] )
|
289 |
-
);
|
290 |
-
|
291 |
-
$customer = Mage::getModel ( 'customer/customer' );
|
292 |
-
|
293 |
-
if ($this->_order->getCustomerIsGuest ()) {
|
294 |
-
$email = $billingAddress->getEmail ();
|
295 |
-
$customer->setWebsiteId ( Mage::app ()->getWebsite ()->getId () );
|
296 |
-
$customer->loadByEmail ( $email );
|
297 |
-
|
298 |
-
} else {
|
299 |
-
$customer->load ( $this->_order->getCustomerId () );
|
300 |
-
}
|
301 |
-
|
302 |
-
if (! $customer->getId ()) {
|
303 |
-
$this->_order->setCustomerEmail ( $email );
|
304 |
-
}
|
305 |
-
|
306 |
-
$this->_order->sendNewOrderEmail ();
|
307 |
|
308 |
-
|
309 |
-
|
310 |
-
} else {
|
311 |
-
Mage::throwException ( Mage::helper ( 'payu_account' )->__ ( 'There was a problem with initializing the payment, please contact the store administrator. ' . $result->getError () ) );
|
312 |
-
}
|
313 |
-
|
314 |
-
return $ret;
|
315 |
-
|
316 |
}
|
317 |
|
318 |
-
|
319 |
/**
|
320 |
-
*
|
321 |
*
|
322 |
-
* @
|
323 |
-
* @param float $amount
|
324 |
-
* @return $this
|
325 |
*/
|
326 |
-
public function
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
$result = OpenPayU_Refund::create($this->_order->getPayment ()->getLastTransId(), 'Magento payu refund', $amount);
|
331 |
-
|
332 |
-
Mage::log($result,null, 'orderRefund.log');
|
333 |
-
|
334 |
-
if ($result->getStatus() == 'SUCCESS') {
|
335 |
-
return $this;
|
336 |
-
}
|
337 |
-
|
338 |
-
$serverMsg = OpenPayU_Util::statusDesc($result->getStatus());
|
339 |
-
$errorMsg = $this->_getHelper()->__($serverMsg);
|
340 |
-
Mage::throwException($errorMsg);
|
341 |
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
}
|
343 |
-
|
344 |
/**
|
345 |
-
* One Step Checkout initialization
|
346 |
-
*
|
347 |
* @return Mage_Sales_Model_Order
|
348 |
*/
|
349 |
-
public function
|
350 |
-
|
351 |
-
$checkout = Mage::getSingleton ( 'checkout/type_onepage' );
|
352 |
-
$customerSession = Mage::getSingleton ( 'customer/session' );
|
353 |
-
$checkout->initCheckout ();
|
354 |
-
|
355 |
-
// if guest payment
|
356 |
-
if (! $customerSession->isLoggedIn ()) {
|
357 |
-
|
358 |
-
$billingAddress = array (
|
359 |
-
'address_id' => 5,'firstname' => $this->_tempInfo,'lastname' => $this->_tempInfo,'company' => "",'street' => array (
|
360 |
-
0 => $this->_tempInfo,1 => $this->_tempInfo
|
361 |
-
) ,'region_id' => '',
|
362 |
-
'region' => '','city' => $this->_tempInfo,'postcode' => $this->_tempInfo,'country_id' => Mage::helper ( 'core' )->getDefaultCountry (),'telephone' => "0000000",'save_in_address_book' => 0
|
363 |
-
);
|
364 |
-
|
365 |
-
$checkout->saveBilling ( $billingAddress, false );
|
366 |
-
$checkout->saveShipping ( $billingAddress, false );
|
367 |
-
$checkout->saveCheckoutMethod ( 'guest' );
|
368 |
-
$checkout->getQuote ()->setCustomerId ( null )->setCustomerIsGuest ( true )->setCustomerEmail ( md5 ( rand () . rand () ) . "_TEMP_PayU@" . Mage::getModel ( 'payu_account/config' )->getDomainName () )->setCustomerGroupId ( Mage_Customer_Model_Group::NOT_LOGGED_IN_ID );
|
369 |
-
|
370 |
-
} else {
|
371 |
-
$customer = $customerSession->getCustomer ();
|
372 |
-
|
373 |
-
$billing = $checkout->getQuote ()->getBillingAddress ();
|
374 |
-
$shipping = $checkout->getQuote ()->isVirtual () ? null : $checkout->getQuote ()->getShippingAddress ();
|
375 |
-
|
376 |
-
$customerBilling = $billing->exportCustomerAddress ();
|
377 |
-
|
378 |
-
$billing->setCustomerAddress ( $customerBilling );
|
379 |
-
$customerBilling->setIsDefaultBilling ( true );
|
380 |
-
|
381 |
-
if ($shipping && ! $shipping->getSameAsBilling ()) {
|
382 |
-
$customerShipping = $shipping->exportCustomerAddress ();
|
383 |
-
$shipping->setCustomerAddress ( $customerShipping );
|
384 |
-
$customerShipping->setIsDefaultShipping ( true );
|
385 |
-
} else {
|
386 |
-
$customerBilling->setIsDefaultShipping ( true );
|
387 |
-
}
|
388 |
-
|
389 |
-
$checkout->saveCheckoutMethod ( 'register' );
|
390 |
-
|
391 |
-
$checkout->getQuote ()->setCustomerId ( $customerSession->getCustomerId () )->setCustomerIsGuest ( false );
|
392 |
-
}
|
393 |
-
|
394 |
-
$checkout->getQuote ()->getBillingAddress ()->setShippingMethod ( 'flatrate_flatrate' )->setCollectShippingRates ( true )->save();
|
395 |
-
$checkout->getQuote ()->getShippingAddress()->setShippingMethod ( 'flatrate_flatrate' )->setCollectShippingRates ( true )->save();
|
396 |
-
|
397 |
-
// presetting the default shipment method
|
398 |
-
$checkout->saveShippingMethod ( 'flatrate_flatrate' );
|
399 |
-
$checkout->getQuote ()->collectTotals ()->save ();
|
400 |
-
|
401 |
-
// assigning the payment method type
|
402 |
-
$checkout->savePayment ( array (
|
403 |
-
'method' => $this->_code
|
404 |
-
) );
|
405 |
-
|
406 |
-
$checkout->saveOrder ();
|
407 |
-
|
408 |
-
$this->_order = Mage::getModel ( 'sales/order' )->load ( $checkout->getQuote ()->getId (), 'quote_id' );
|
409 |
-
|
410 |
-
$storeId = Mage::app ()->getStore ()->getId ();
|
411 |
-
$paymentHelper = Mage::helper ( "payment" );
|
412 |
-
$zeroSubTotalPaymentAction = $paymentHelper->getZeroSubTotalPaymentAutomaticInvoice ( $storeId );
|
413 |
-
if ($paymentHelper->isZeroSubTotal ( $storeId ) && $this->_order->getGrandTotal () == 0 && $zeroSubTotalPaymentAction == Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE && $paymentHelper->getZeroSubTotalOrderStatus ( $storeId ) == 'pending') {
|
414 |
-
$invoice = $this->_initInvoice ();
|
415 |
-
$invoice->getOrder ()->setIsInProcess ( true );
|
416 |
-
$transactionSave = Mage::getModel ( 'core/resource_transaction' )->addObject ( $invoice )->addObject ( $invoice->getOrder () );
|
417 |
-
$transactionSave->save ();
|
418 |
-
}
|
419 |
-
|
420 |
return $this->_order;
|
421 |
-
|
422 |
}
|
423 |
-
|
424 |
/**
|
425 |
-
*
|
426 |
-
* @param Mage_Payment_Model_Info $payment
|
427 |
-
* @return bool
|
428 |
*/
|
429 |
-
public function
|
430 |
-
|
431 |
-
|
432 |
-
$sessionId = $payment->getLastTransId ();
|
433 |
-
|
434 |
-
if (empty ( $sessionId )) {
|
435 |
-
return false;
|
436 |
-
}
|
437 |
-
|
438 |
-
if (! $this->orderStatusUpdateRequest ( self::ORDER_V2_COMPLETED, $sessionId )) {
|
439 |
-
return false;
|
440 |
-
}
|
441 |
-
|
442 |
-
return true;
|
443 |
}
|
444 |
-
|
445 |
/**
|
|
|
446 |
*
|
447 |
-
* @
|
448 |
-
* @return bool
|
449 |
*/
|
450 |
-
public function
|
451 |
-
|
452 |
-
|
453 |
-
$sessionId = $payment->getLastTransId ();
|
454 |
-
|
455 |
-
if (empty ( $sessionId )) {
|
456 |
-
return false;
|
457 |
-
}
|
458 |
-
|
459 |
-
if (! $this->orderStatusUpdateRequest ( self::ORDER_V2_REJECTED, $sessionId )) {
|
460 |
-
return false;
|
461 |
-
}
|
462 |
-
|
463 |
-
return true;
|
464 |
}
|
465 |
-
|
466 |
/**
|
|
|
467 |
*
|
468 |
-
* @
|
469 |
-
* $order
|
470 |
-
* @return bool OpenPayU_Result
|
471 |
*/
|
472 |
-
public function
|
473 |
-
|
474 |
-
|
475 |
-
$result = $this->orderStatusUpdateRequest ( self::ORDER_V2_COMPLETED, $this->_order->getPayment ()->getLastTransId () );
|
476 |
-
return $result;
|
477 |
-
|
478 |
}
|
479 |
-
|
480 |
/**
|
|
|
481 |
*
|
482 |
-
* @
|
483 |
-
* @return bool
|
484 |
*/
|
485 |
-
public function
|
486 |
-
|
487 |
-
return $this->
|
488 |
}
|
489 |
-
|
490 |
/**
|
|
|
491 |
*
|
492 |
-
* @
|
493 |
-
* @return bool
|
494 |
*/
|
495 |
-
public function
|
496 |
-
|
497 |
-
|
498 |
-
$result = OpenPayU_Order::cancel($this->_order->getPayment ()->getLastTransId ());
|
499 |
-
if ($result->getStatus() == 'SUCCESS') {
|
500 |
-
//$this->updateOrderStatus ( self::ORDER_V2_CANCELED );
|
501 |
-
return true;
|
502 |
-
}
|
503 |
-
return false;
|
504 |
}
|
505 |
-
|
506 |
/**
|
507 |
-
*
|
|
|
|
|
|
|
508 |
*/
|
509 |
-
public function
|
510 |
-
|
511 |
-
$
|
512 |
-
|
513 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
514 |
}
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
$
|
525 |
-
|
526 |
-
|
527 |
-
$this->
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
$
|
533 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
534 |
}
|
535 |
-
|
536 |
}
|
537 |
-
|
|
|
538 |
/**
|
539 |
-
* @param $
|
540 |
-
* @
|
541 |
-
* @return bool OpenPayU_Result
|
542 |
*/
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
if (empty ( $sessionId )) {
|
550 |
-
Mage::log ( "PayU sessionId empty: " . $this->getId () );
|
551 |
return false;
|
552 |
}
|
553 |
-
|
554 |
-
$status_update = array(
|
555 |
-
"orderId" => stripslashes($sessionId),
|
556 |
-
"orderStatus" => $status
|
557 |
-
);
|
558 |
-
|
559 |
-
$result = OpenPayU_Order::statusUpdate ( $status_update );
|
560 |
-
|
561 |
-
if ($result) {
|
562 |
-
return true;
|
563 |
-
} else {
|
564 |
-
Mage::log ( "PayU error while updating status: " . $result->getError () );
|
565 |
-
}
|
566 |
-
|
567 |
-
return $result;
|
568 |
-
}
|
569 |
-
|
570 |
-
protected function setOrderByOrderId( $extOrderId ) {
|
571 |
-
$this->_order = Mage::getModel ( 'sales/order' )->load ( $extOrderId );
|
572 |
-
}
|
573 |
-
|
574 |
-
public function orderNotifyRequest() {
|
575 |
-
|
576 |
-
$body = file_get_contents ( 'php://input' );
|
577 |
-
$data = trim ( $body );
|
578 |
-
|
579 |
-
$result = OpenPayU_Order::consumeNotification ( $data );
|
580 |
-
$response = $result->getResponse();
|
581 |
-
if ($response->order->orderId) {
|
582 |
-
|
583 |
-
$this->_transactionId = $response->order->orderId;
|
584 |
-
|
585 |
-
$extOrderIdExploded = $pieces = explode("-", $response->order->extOrderId);
|
586 |
-
$orderId = $extOrderIdExploded[0];
|
587 |
-
// Mage::log(print_r($orderId, true),null, 'notification.log');
|
588 |
-
|
589 |
-
$this->setOrderByOrderId ( $orderId );
|
590 |
-
|
591 |
-
if($response->order->status == 'COMPLETED' && $this->_order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING){
|
592 |
-
header("HTTP/1.1 200 OK");
|
593 |
-
exit;
|
594 |
-
}
|
595 |
|
596 |
-
|
597 |
-
|
598 |
-
header("HTTP/1.1 200 OK");
|
599 |
}
|
600 |
-
|
|
|
601 |
}
|
602 |
-
|
603 |
/**
|
604 |
-
*
|
605 |
-
* @
|
|
|
606 |
*/
|
607 |
-
|
608 |
{
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
$this->_order->setCustomerFirstname($customerRecord->firstName);
|
615 |
-
$this->_order->setCustomerLastname($customerRecord->lastName);
|
616 |
-
$this->_order->setCustomerEmail($customerRecord->email);
|
617 |
-
|
618 |
-
if (isset($data->delivery) && !empty( $data->delivery )) {
|
619 |
-
|
620 |
-
$shippingAddress = $data->delivery;
|
621 |
-
|
622 |
-
/* $billing = $this->_order->getBillingAddress();
|
623 |
-
|
624 |
-
$billing->setCity($shippingAddress->city);
|
625 |
-
$billing->setStreet($shippingAddress->street);
|
626 |
-
$billing->setPostcode($shippingAddress->postalCode);
|
627 |
-
$billing->setCountryId($shippingAddress->countryCode);
|
628 |
-
|
629 |
-
$this->_order->setBillingAddress($billing)->save(); */
|
630 |
-
|
631 |
-
$recipient = explode(" ", $shippingAddress->recipientName);
|
632 |
-
|
633 |
-
$shipping = $this->_order->getShippingAddress();
|
634 |
-
|
635 |
-
$shipping->setFirstname($recipient[0]);
|
636 |
-
$shipping->setLastname($recipient[1]);
|
637 |
-
//$shipping->setTelephone($customerRecord['phone']);
|
638 |
-
$shipping->setCity($shippingAddress->city);
|
639 |
-
$shipping->setStreet($shippingAddress->street);
|
640 |
-
$shipping->setPostcode($shippingAddress->postalCode);
|
641 |
-
$shipping->setCountryId($shippingAddress->countryCode);
|
642 |
-
|
643 |
-
$this->_order->setShippingAddress($shipping)->save();
|
644 |
-
|
645 |
-
}
|
646 |
-
|
647 |
-
/* if (isset($data['billing']) && !empty( $data['billing'] )) {
|
648 |
-
$billingAddress = $data['billing'];
|
649 |
-
|
650 |
-
$billing = $this->_order->getBillingAddress();
|
651 |
-
|
652 |
-
$recipient = explode(" ", $billingAddress['recipientName']);
|
653 |
-
|
654 |
-
$billing->setFirstname($recipient[0]);
|
655 |
-
$billing->setLastname($recipient[1]);
|
656 |
-
$billing->setCompany($billingAddress['recipientName']);
|
657 |
-
$billing->setTelephone($customerRecord['phone']);
|
658 |
-
$billing->setCity($billingAddress['city']);
|
659 |
-
$billing->setStreet($billingAddress['street']);
|
660 |
-
$billing->setPostcode($billingAddress['postalCode']);
|
661 |
-
$billing->setCountryId($billingAddress['countryCode']);
|
662 |
-
//$this->_order->setCustomerTaxvat($billingAddress['TIN']);
|
663 |
-
|
664 |
-
$this->_order->setBillingAddress($billing)->save();
|
665 |
-
}
|
666 |
-
else
|
667 |
-
{
|
668 |
-
$billing = $this->_order->getBillingAddress();
|
669 |
-
|
670 |
-
$billing->setFirstname($customerRecord['firstName']);
|
671 |
-
$billing->setLastname($customerRecord['lastName']);
|
672 |
-
$billing->setTelephone($customerRecord['phone']);
|
673 |
-
|
674 |
-
$this->_order->setBillingAddress($billing)->save();
|
675 |
-
} */
|
676 |
-
|
677 |
-
if (!$this->_order->getEmailSent()) {
|
678 |
-
$this->_order->sendNewOrderEmail();
|
679 |
-
$this->_order->setEmailSent(1);
|
680 |
-
}
|
681 |
-
|
682 |
-
$this->_order->save();
|
683 |
-
|
684 |
-
} catch (Error $e) {
|
685 |
-
Mage::logException("Can not update order data: " . $e);
|
686 |
}
|
687 |
-
|
|
|
|
|
|
|
|
|
|
|
688 |
}
|
689 |
-
|
690 |
/**
|
|
|
691 |
*
|
692 |
-
*
|
693 |
-
* @param
|
|
|
694 |
*/
|
695 |
-
|
696 |
{
|
|
|
|
|
|
|
697 |
try {
|
698 |
-
$
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
$
|
707 |
-
$shippingRates = $shipping->collectRatesByAddress($address)->getResult();
|
708 |
-
|
709 |
-
$shippingCostList = array();
|
710 |
-
|
711 |
-
foreach ($shippingRates->getAllRates() as $rate) {
|
712 |
-
$type = $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle();
|
713 |
-
|
714 |
-
if ($type == $typeChosen) {
|
715 |
-
$this->_order->setShippingDescription($typeChosen);
|
716 |
-
$this->_order->setShippingMethod($rate->getCarrier() . "_" . $rate->getMethod());
|
717 |
-
$current = $this->_order->getShippingAmount();
|
718 |
-
$this->_order->setShippingAmount($cost / 100);
|
719 |
-
$this->_order->setGrandTotal($this->_order->getGrandTotal() + $this->_order->getShippingAmount() - $current);
|
720 |
-
$this->_order->save();
|
721 |
-
}
|
722 |
-
}
|
723 |
-
|
724 |
}
|
725 |
-
|
726 |
-
} catch (
|
727 |
-
|
|
|
|
|
728 |
}
|
729 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
730 |
}
|
731 |
|
732 |
-
|
733 |
/**
|
734 |
* Update payment status
|
735 |
*
|
736 |
* @param $paymentStatus
|
737 |
-
* @param $payUOrderStatus
|
738 |
*/
|
739 |
-
|
740 |
-
|
741 |
-
$payment = $this->
|
742 |
-
$currentState = $payment->getAdditionalInformation ( 'payu_payment_status' );
|
743 |
|
744 |
-
|
745 |
-
return;
|
746 |
|
747 |
-
if ($currentState != $paymentStatus) {
|
748 |
try {
|
749 |
switch ($paymentStatus) {
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
case self::ORDER_V2_PENDING:
|
755 |
-
$this->updatePaymentStatusPending ( $payment );
|
756 |
break;
|
757 |
-
|
758 |
-
case
|
759 |
-
$this->
|
760 |
break;
|
761 |
-
|
762 |
-
case
|
763 |
-
|
|
|
764 |
break;
|
765 |
-
|
766 |
-
case
|
767 |
-
$this->
|
768 |
break;
|
769 |
}
|
770 |
-
|
771 |
-
$payment->setAdditionalInformation
|
772 |
-
|
773 |
-
|
|
|
|
|
774 |
}
|
775 |
}
|
776 |
}
|
777 |
-
|
778 |
-
/**
|
779 |
-
* Get PayU session namespace
|
780 |
-
*
|
781 |
-
* @return PayU_Account_Model_Session
|
782 |
-
*/
|
783 |
-
public function getSession() {
|
784 |
-
return Mage::getSingleton ( 'payu_account/session' );
|
785 |
-
}
|
786 |
-
|
787 |
-
/**
|
788 |
-
* Get checkout session namespace
|
789 |
-
*
|
790 |
-
* @return Mage_Checkout_Model_Session
|
791 |
-
*/
|
792 |
-
public function getCheckout() {
|
793 |
-
return Mage::getSingleton ( 'checkout/session' );
|
794 |
-
}
|
795 |
-
|
796 |
-
/**
|
797 |
-
* Returns amount in PayU acceptable format
|
798 |
-
*
|
799 |
-
* @param $val
|
800 |
-
*/
|
801 |
-
protected function toAmount($val) {
|
802 |
-
return Mage::helper ( 'payu_account' )->toAmount ( $val );
|
803 |
-
}
|
804 |
-
|
805 |
-
/**
|
806 |
-
* Redirection url
|
807 |
-
*
|
808 |
-
* @return string
|
809 |
-
*/
|
810 |
-
public function getOrderPlaceRedirectUrl() {
|
811 |
-
return Mage::getUrl ( 'payu_account/payment/new', array (
|
812 |
-
'_secure' => true
|
813 |
-
) );
|
814 |
-
}
|
815 |
-
|
816 |
-
/**
|
817 |
-
* Get current quote
|
818 |
-
*
|
819 |
-
* @return Mage_Sales_Model_Quote
|
820 |
-
*/
|
821 |
-
public function getQuote() {
|
822 |
-
return $this->getCheckout ()->getQuote ();
|
823 |
-
}
|
824 |
-
|
825 |
/**
|
826 |
* Update payment status to new
|
827 |
*
|
828 |
-
* @param $payment
|
829 |
*/
|
830 |
-
|
831 |
-
|
832 |
-
$
|
833 |
-
|
834 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
835 |
}
|
836 |
-
|
837 |
/**
|
838 |
* Change the status to canceled
|
839 |
*
|
840 |
-
* @param
|
841 |
*/
|
842 |
-
|
843 |
-
|
844 |
-
$
|
845 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
846 |
}
|
847 |
-
|
848 |
/**
|
849 |
* Change the status to rejected
|
850 |
*
|
851 |
-
* @param $payment
|
852 |
*/
|
853 |
-
|
854 |
-
|
855 |
-
$
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
public function updatePaymentStatusSent($payment) {
|
865 |
-
if ($this->_order->getState () != Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW) {
|
866 |
-
$payment->setTransactionId ( $this->_transactionId );
|
867 |
-
$payment->setIsTransactionApproved ( false );
|
868 |
-
$payment->setIsTransactionClosed ( false );
|
869 |
-
$payment->addTransaction ( Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER );
|
870 |
-
$payment->setPreparedMessage ( "PayU - " . Mage::helper ( 'payu_account' )->__ ( 'Transaction awaits approval.' ) );
|
871 |
-
$this->_order->setState ( Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, true, "PayU - " . Mage::helper ( 'payu_account' )->__ ( 'Transaction awaits approval.' ), false )->save ();
|
872 |
-
}
|
873 |
}
|
874 |
-
|
875 |
/**
|
876 |
-
* Update payment status to
|
877 |
*
|
878 |
-
* @param
|
879 |
-
* $payment
|
880 |
*/
|
881 |
-
|
882 |
-
|
883 |
-
$
|
884 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
885 |
}
|
886 |
-
|
887 |
/**
|
888 |
-
*
|
889 |
-
*
|
890 |
-
* @
|
891 |
*/
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
$
|
896 |
-
$payment->setIsTransactionClosed ( false );
|
897 |
-
$payment->addTransaction ( Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER );
|
898 |
-
$payment->setPreparedMessage ( "PayU - " . Mage::helper ( 'payu_account' )->__ ( 'The transaction is pending.' ) );
|
899 |
-
$this->_order->setState ( Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, "PayU - " . Mage::helper ( 'payu_account' )->__ ( 'The transaction is pending.' ), false )->save ();
|
900 |
}
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
$
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
$payment->setPreparedMessage ( "PayU - " . $method . " " . Mage::helper ( 'payu_account' )->__ ( 'The transaction completed successfully.' ) );
|
925 |
-
$this->_order->setState ( Mage_Sales_Model_Order::STATE_PROCESSING, true, "PayU - " . $method . " " . Mage::helper ( 'payu_account' )->__ ( 'The transaction completed successfully.' ), false )->sendOrderUpdateEmail ( true, "PayU - " . Mage::helper ( 'payu_account' )->__ ( 'The transaction completed successfully in PayU.' ) )->save ();
|
926 |
-
}else{
|
927 |
-
$payment->setPreparedMessage ( "PayU - " . Mage::helper ( 'payu_account' )->__ ( 'The transaction completed successfully.' ) );
|
928 |
-
$this->_order->setState ( Mage_Sales_Model_Order::STATE_PROCESSING, true, "PayU - " . Mage::helper ( 'payu_account' )->__ ( 'The transaction completed successfully.' ), false )->sendOrderUpdateEmail ( true, "PayU - " . Mage::helper ( 'payu_account' )->__ ( 'The transaction completed successfully in PayU.' ) )->save ();
|
929 |
-
}
|
930 |
}
|
931 |
}
|
932 |
-
|
933 |
-
/**
|
934 |
-
* Update payment status to error
|
935 |
-
*
|
936 |
-
* @param $payment
|
937 |
-
*/
|
938 |
-
public function updatePaymentStatusError($payment) {
|
939 |
-
$payment->setTransactionId ( $this->_transactionId );
|
940 |
-
$payment->setPreparedMessage ( "PayU - " . Mage::helper ( 'payu_account' )->__ ( 'The transaction is incorrect.' ) )->setParentTransactionId ( $this->_transactionId );
|
941 |
-
$this->_order->setState ( Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, true, "PayU - " . Mage::helper ( 'payu_account' )->__ ( 'The transaction is incorrect.' ) )->sendOrderUpdateEmail ( true, "PayU - " . Mage::helper ( 'payu_account' )->__ ( 'The transaction is incorrect.' ) )->save ();
|
942 |
-
}
|
943 |
-
|
944 |
-
/**
|
945 |
-
* calculating the tax rate
|
946 |
-
*/
|
947 |
-
protected function calculateTaxRate() {
|
948 |
-
return ($this->_order->getShippingAmount () > 0) ? $this->_order->getShippingTaxAmount () / $this->_order->getShippingAmount () : 0.0;
|
949 |
-
}
|
950 |
-
|
951 |
/**
|
952 |
-
*
|
953 |
*
|
954 |
-
* @
|
955 |
-
|
956 |
-
protected function getConfig() {
|
957 |
-
return Mage::getModel ( 'payu_account/config' );
|
958 |
-
}
|
959 |
-
|
960 |
-
/**
|
961 |
-
* Initialize PayU configuration
|
962 |
*/
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
$this->_myUrl = $this->_config->getBaseUrl ();
|
967 |
-
|
968 |
-
OpenPayU_Configuration::setApiVersion ( 2.1 );
|
969 |
-
OpenPayU_Configuration::setEnvironment ( 'secure' );
|
970 |
-
OpenPayU_Configuration::setMerchantPosId ( $this->_config->getMerchantPosId () );
|
971 |
-
OpenPayU_Configuration::setSignatureKey ( $this->_config->getSignatureKey () );
|
972 |
-
OpenPayU_Configuration::setSender("Magento ver " . Mage::getVersion() . "/Plugin ver " . $this->_config->getPluginVersion());
|
973 |
-
|
974 |
}
|
975 |
|
976 |
}
|
1 |
<?php
|
2 |
|
3 |
/**
|
|
|
4 |
* PayU -Standard Payment Model
|
5 |
*
|
6 |
+
* @copyright Copyright (c) 2011-2016 PayU
|
7 |
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
8 |
+
* http://www.payu.com
|
|
|
|
|
9 |
*/
|
10 |
|
11 |
+
require_once(Mage::getBaseDir('lib') . '/PayU/openpayu.php');
|
12 |
|
|
|
13 |
|
14 |
+
class PayU_Account_Model_Payment extends Mage_Payment_Model_Method_Abstract
|
15 |
{
|
16 |
+
const DELIMITER = '-';
|
17 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
/**
|
19 |
* Payment method code
|
20 |
*
|
21 |
* @var string
|
22 |
*/
|
23 |
protected $_code = 'payu_account';
|
24 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
/**
|
26 |
* Block type
|
27 |
*
|
28 |
* @var string
|
29 |
*/
|
30 |
protected $_formBlockType = 'payu_account/form';
|
31 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
/**
|
33 |
* Transaction id
|
34 |
*/
|
35 |
protected $_transactionId;
|
36 |
+
|
|
|
|
|
|
|
|
|
|
|
37 |
/**
|
38 |
* Currently processed order
|
39 |
*
|
40 |
* @var Mage_Sales_Model_Order
|
41 |
*/
|
42 |
protected $_order;
|
43 |
+
|
44 |
+
protected $_isGateway = false;
|
45 |
+
protected $_canOrder = false;
|
46 |
+
protected $_canAuthorize = false;
|
47 |
protected $_canCapture = true;
|
48 |
+
protected $_canCapturePartial = false;
|
49 |
protected $_canRefund = true;
|
50 |
protected $_canRefundInvoicePartial = true;
|
51 |
protected $_canVoid = false;
|
52 |
+
protected $_canUseInternal = true;
|
53 |
protected $_canUseCheckout = true;
|
54 |
protected $_canUseForMultishipping = false;
|
|
|
55 |
protected $_canReviewPayment = true;
|
56 |
+
protected $_isInitializeNeeded = true;
|
57 |
+
|
58 |
protected $_payUOrderResult = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
+
public function __construct()
|
61 |
+
{
|
62 |
+
parent::__construct();
|
63 |
+
$this->initializeOpenPayUConfiguration();
|
64 |
}
|
65 |
+
|
66 |
/**
|
67 |
+
* @return PayU_Account_Helper_Data
|
|
|
|
|
|
|
68 |
*/
|
69 |
+
protected function _helper()
|
70 |
+
{
|
71 |
+
return Mage::helper('payu_account');
|
72 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
+
/**
|
75 |
+
* Initialize PayU configuration
|
76 |
+
*/
|
77 |
+
protected function initializeOpenPayUConfiguration()
|
78 |
+
{
|
79 |
+
OpenPayU_Configuration::setEnvironment('secure');
|
80 |
+
OpenPayU_Configuration::setMerchantPosId($this->getConfig()->getMerchantPosId());
|
81 |
+
OpenPayU_Configuration::setSignatureKey($this->getConfig()->getSignatureKey());
|
82 |
+
if ($this->getConfig()->getClientId() && $this->getConfig()->getClientSecret()) {
|
83 |
+
OpenPayU_Configuration::setOauthClientId($this->getConfig()->getClientId());
|
84 |
+
OpenPayU_Configuration::setOauthClientSecret($this->getConfig()->getClientSecret());
|
85 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
+
OpenPayU_Configuration::setSender('Magento ver ' . Mage::getVersion() . '/Plugin ver ' . $this->getConfig()->getPluginVersion());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
}
|
89 |
|
|
|
90 |
/**
|
91 |
+
* Get PayU configuration
|
92 |
*
|
93 |
+
* @return PayU_Account_Model_Config
|
|
|
|
|
94 |
*/
|
95 |
+
public function getConfig()
|
96 |
+
{
|
97 |
+
return Mage::getSingleton('payu_account/config');
|
98 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
+
/**
|
101 |
+
* @param string $extOrderId
|
102 |
+
*/
|
103 |
+
private function _setOrderByOrderId($extOrderId)
|
104 |
+
{
|
105 |
+
$this->_order = Mage::getModel('sales/order')->load($extOrderId);
|
106 |
}
|
107 |
+
|
108 |
/**
|
|
|
|
|
109 |
* @return Mage_Sales_Model_Order
|
110 |
*/
|
111 |
+
public function getOrder()
|
112 |
+
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
return $this->_order;
|
|
|
114 |
}
|
115 |
+
|
116 |
/**
|
117 |
+
* @param Mage_Sales_Model_Order $order
|
|
|
|
|
118 |
*/
|
119 |
+
public function setOrder(Mage_Sales_Model_Order $order)
|
120 |
+
{
|
121 |
+
$this->_order = $order;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
}
|
123 |
+
|
124 |
/**
|
125 |
+
* Get PayU session namespace
|
126 |
*
|
127 |
+
* @return PayU_Account_Model_Session
|
|
|
128 |
*/
|
129 |
+
public function getSession()
|
130 |
+
{
|
131 |
+
return Mage::getSingleton('payu_account/session');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
}
|
133 |
+
|
134 |
/**
|
135 |
+
* Redirection url
|
136 |
*
|
137 |
+
* @return string
|
|
|
|
|
138 |
*/
|
139 |
+
public function getOrderPlaceRedirectUrl()
|
140 |
+
{
|
141 |
+
return Mage::getUrl('payu_account/payment/new', array('_secure' => true));
|
|
|
|
|
|
|
142 |
}
|
143 |
+
|
144 |
/**
|
145 |
+
* Get current quote
|
146 |
*
|
147 |
+
* @return Mage_Sales_Model_Quote
|
|
|
148 |
*/
|
149 |
+
public function getQuote()
|
150 |
+
{
|
151 |
+
return $this->getCheckoutSession()->getQuote();
|
152 |
}
|
153 |
+
|
154 |
/**
|
155 |
+
* Get checkout session namespace
|
156 |
*
|
157 |
+
* @return Mage_Checkout_Model_Session
|
|
|
158 |
*/
|
159 |
+
public function getCheckoutSession()
|
160 |
+
{
|
161 |
+
return Mage::getSingleton('checkout/session');
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
}
|
163 |
+
|
164 |
/**
|
165 |
+
* Create order
|
166 |
+
*
|
167 |
+
* @param Mage_Sales_Model_Order
|
168 |
+
* @return array
|
169 |
*/
|
170 |
+
public function orderCreateRequest(Mage_Sales_Model_Order $order)
|
171 |
+
{
|
172 |
+
$this->setOrder($order);
|
173 |
+
$items = array();
|
174 |
+
$items[] = array(
|
175 |
+
'quantity' => 1,
|
176 |
+
'name' => $this->_helper()->__('Shipping') . ': ' . $order->getShippingDescription(),
|
177 |
+
'unitPrice' => $this->_toAmount($order->getShippingInclTax())
|
178 |
+
);
|
179 |
+
|
180 |
+
$orderItems = $order->getAllVisibleItems();
|
181 |
+
$response = array();
|
182 |
+
|
183 |
+
foreach ($orderItems as $key => $item) {
|
184 |
+
$itemInfo = $item->getData();
|
185 |
+
|
186 |
+
$items[] = array(
|
187 |
+
'quantity' => (int)$itemInfo['qty_ordered'],
|
188 |
+
'name' => $itemInfo['name'],
|
189 |
+
'unitPrice' => $this->_toAmount($itemInfo['price_incl_tax'])
|
190 |
+
);
|
191 |
}
|
192 |
+
|
193 |
+
if ($order->getDiscountAmount()) {
|
194 |
+
$items[] = array(
|
195 |
+
'quantity' => 1,
|
196 |
+
'name' => $this->_helper()->__('Discount'),
|
197 |
+
'unitPrice' => $this->_toAmount($order->getDiscountAmount())
|
198 |
+
);
|
199 |
+
}
|
200 |
+
|
201 |
+
$OCReq = array(
|
202 |
+
'merchantPosId' => OpenPayU_Configuration::getMerchantPosId(),
|
203 |
+
'orderUrl' => Mage::getUrl('sales/order/view', array('order_id' => $order->getId())),
|
204 |
+
'description' => $this->_helper()->__('Order #%s', $order->getRealOrderId()),
|
205 |
+
'products' => $items,
|
206 |
+
'customerIp' => Mage::app()->getFrontController()->getRequest()->getClientIp(),
|
207 |
+
'notifyUrl' => $this->getConfig()->getUrl('orderNotifyRequest'),
|
208 |
+
'continueUrl' => $this->getConfig()->getUrl('continuePayment'),
|
209 |
+
'currencyCode' => $order->getOrderCurrencyCode(),
|
210 |
+
'totalAmount' => $this->_toAmount($order->getGrandTotal()),
|
211 |
+
'extOrderId' => uniqid($order->getId() . self::DELIMITER, true),
|
212 |
+
'settings' => array(
|
213 |
+
'invoiceDisabled' => true
|
214 |
+
)
|
215 |
+
);
|
216 |
+
|
217 |
+
$billingAddressId = $order->getBillingAddressId();
|
218 |
+
|
219 |
+
if (!empty ($billingAddressId)) {
|
220 |
+
$billingAddress = $order->getBillingAddress();
|
221 |
+
$customerEmail = $billingAddress->getEmail();
|
222 |
+
if (!empty ($customerEmail)) {
|
223 |
+
$customerSheet = array(
|
224 |
+
'email' => $billingAddress->getEmail(),
|
225 |
+
'phone' => $billingAddress->getTelephone(),
|
226 |
+
'firstName' => $billingAddress->getFirstname(),
|
227 |
+
'lastName' => $billingAddress->getLastname()
|
228 |
+
);
|
229 |
+
|
230 |
+
if (!$order->getIsVirtual() && !empty($order->getShippingAddressId())) {
|
231 |
+
$shippingAddress = $order->getShippingAddress();
|
232 |
+
|
233 |
+
$customerSheet ['delivery'] = array(
|
234 |
+
'street' => trim(implode(' ', $shippingAddress->getStreet())),
|
235 |
+
'postalCode' => $shippingAddress->getPostcode(),
|
236 |
+
'city' => $shippingAddress->getCity(),
|
237 |
+
'countryCode' => $shippingAddress->getCountry(),
|
238 |
+
'recipientName' => trim(
|
239 |
+
$shippingAddress->getFirstname() . ' ' . $shippingAddress->getLastname()
|
240 |
+
),
|
241 |
+
'recipientPhone' => $shippingAddress->getTelephone(),
|
242 |
+
'recipientEmail' => $shippingAddress->getEmail()
|
243 |
+
);
|
244 |
+
}
|
245 |
+
$OCReq['buyer'] = $customerSheet;
|
246 |
+
}
|
247 |
+
}
|
248 |
+
|
249 |
+
try {
|
250 |
+
$result = OpenPayU_Order::create($OCReq);
|
251 |
+
|
252 |
+
if ($result->getStatus() == OpenPayU_Order::SUCCESS) {
|
253 |
+
$this->_transactionId = $result->getResponse()->orderId;
|
254 |
+
|
255 |
+
Mage::getSingleton('core/session')->setPayUSessionId($this->_transactionId);
|
256 |
+
|
257 |
+
$payment = $order->getPayment();
|
258 |
+
$payment->setAdditionalInformation('payu_payment_status', OpenPayuOrderStatus::STATUS_NEW)
|
259 |
+
->save();
|
260 |
+
|
261 |
+
$this->_updatePaymentStatusNew($payment);
|
262 |
+
|
263 |
+
$locale = Mage::getStoreConfig('general/locale/code', Mage::app()->getStore()->getId());
|
264 |
+
$langCode = explode('_', $locale, 2);
|
265 |
+
$response = array(
|
266 |
+
'redirectUri' => $result->getResponse()->redirectUri . '&lang=' . strtolower($langCode[1]),
|
267 |
+
);
|
268 |
+
|
269 |
+
} else {
|
270 |
+
Mage::throwException($this->_helper()
|
271 |
+
->__('There was a problem with the payment initialization, please contact system administrator.'));
|
272 |
+
}
|
273 |
+
} catch (Exception $e) {
|
274 |
+
Mage::throwException($this->_helper()
|
275 |
+
->__('There was a problem with the payment initialization - "%s", please contact system administrator.', $e->getMessage()));
|
276 |
+
|
277 |
+
Mage::logException($e);
|
278 |
}
|
279 |
+
return $response;
|
280 |
}
|
281 |
+
|
282 |
+
|
283 |
/**
|
284 |
+
* @param Mage_Payment_Model_Info $payment
|
285 |
+
* @return bool
|
|
|
286 |
*/
|
287 |
+
public function acceptPayment(Mage_Payment_Model_Info $payment)
|
288 |
+
{
|
289 |
+
parent::acceptPayment($payment);
|
290 |
+
$sessionId = $payment->getLastTransId();
|
291 |
+
|
292 |
+
if (empty($sessionId)) {
|
|
|
|
|
293 |
return false;
|
294 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
|
296 |
+
if (!$this->_orderStatusUpdateRequest(OpenPayuOrderStatus::STATUS_COMPLETED, $sessionId)) {
|
297 |
+
return false;
|
|
|
298 |
}
|
299 |
+
|
300 |
+
return true;
|
301 |
}
|
302 |
+
|
303 |
/**
|
304 |
+
*
|
305 |
+
* @param Mage_Payment_Model_Info $payment
|
306 |
+
* @return bool
|
307 |
*/
|
308 |
+
public function denyPayment(Mage_Payment_Model_Info $payment)
|
309 |
{
|
310 |
+
parent::denyPayment($payment);
|
311 |
+
$sessionId = $payment->getLastTransId();
|
312 |
+
|
313 |
+
if (empty($sessionId)) {
|
314 |
+
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
}
|
316 |
+
|
317 |
+
if (!$this->_orderStatusUpdateRequest(OpenPayuOrderStatus::STATUS_CANCELED, $sessionId)) {
|
318 |
+
return false;
|
319 |
+
}
|
320 |
+
|
321 |
+
return true;
|
322 |
}
|
323 |
+
|
324 |
/**
|
325 |
+
* Refund payment
|
326 |
*
|
327 |
+
* @param Varien_Object $payment
|
328 |
+
* @param float $amount
|
329 |
+
* @return $this
|
330 |
*/
|
331 |
+
public function refund(Varien_Object $payment, $amount)
|
332 |
{
|
333 |
+
/** @var Mage_Sales_Model_Order $order */
|
334 |
+
$order = $payment->getOrder();
|
335 |
+
|
336 |
try {
|
337 |
+
$result = OpenPayU_Refund::create($order->getPayment()->getLastTransId(), $this->_helper()->__('Refund for order: %s', $order->getIncrementId()), $this->_toAmount($amount));
|
338 |
+
|
339 |
+
$comment = $this->_helper()->__('Payu refund - amount: %s, status: %s', $amount, $result->getStatus());
|
340 |
+
|
341 |
+
$order->addStatusHistoryComment($comment)
|
342 |
+
->save();
|
343 |
+
|
344 |
+
if ($result->getStatus() == OpenPayU_Order::SUCCESS) {
|
345 |
+
return $this;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
346 |
}
|
347 |
+
|
348 |
+
} catch (OpenPayU_Exception $e) {
|
349 |
+
$comment = $this->_helper()->__('Payu refund - amount: %s, status: %s', $amount, $e->getMessage());
|
350 |
+
|
351 |
+
Mage::throwException($comment);
|
352 |
}
|
353 |
+
|
354 |
+
}
|
355 |
+
|
356 |
+
public function orderNotifyRequest()
|
357 |
+
{
|
358 |
+
$body = file_get_contents('php://input');
|
359 |
+
$data = trim($body);
|
360 |
+
|
361 |
+
$result = OpenPayU_Order::consumeNotification($data);
|
362 |
+
$response = $result->getResponse();
|
363 |
+
$orderRetrieved = $response->order;
|
364 |
+
|
365 |
+
if (isset($orderRetrieved) && is_object($orderRetrieved) && $orderRetrieved->orderId) {
|
366 |
+
$this->_transactionId = $orderRetrieved->orderId;
|
367 |
+
$extOrderIdExploded = explode(self::DELIMITER, $orderRetrieved->extOrderId);
|
368 |
+
$orderId = array_shift($extOrderIdExploded);
|
369 |
+
|
370 |
+
$this->_setOrderByOrderId($orderId);
|
371 |
+
$this->_updatePaymentStatus($orderRetrieved->status);
|
372 |
+
|
373 |
+
header("HTTP/1.1 200 OK");
|
374 |
+
}
|
375 |
+
exit;
|
376 |
}
|
377 |
|
|
|
378 |
/**
|
379 |
* Update payment status
|
380 |
*
|
381 |
* @param $paymentStatus
|
|
|
382 |
*/
|
383 |
+
private function _updatePaymentStatus($paymentStatus)
|
384 |
+
{
|
385 |
+
$payment = $this->getOrder()->getPayment();
|
|
|
386 |
|
387 |
+
$currentState = $payment->getAdditionalInformation('payu_payment_status');
|
|
|
388 |
|
389 |
+
if ($currentState != OpenPayuOrderStatus::STATUS_COMPLETED && $currentState != $paymentStatus) {
|
390 |
try {
|
391 |
switch ($paymentStatus) {
|
392 |
+
|
393 |
+
case OpenPayuOrderStatus::STATUS_PENDING:
|
394 |
+
//nothing to do
|
|
|
|
|
|
|
395 |
break;
|
396 |
+
|
397 |
+
case OpenPayuOrderStatus::STATUS_CANCELED:
|
398 |
+
$this->_updatePaymentStatusCanceled($payment);
|
399 |
break;
|
400 |
+
|
401 |
+
case OpenPayuOrderStatus::STATUS_WAITING_FOR_CONFIRMATION:
|
402 |
+
case OpenPayuOrderStatus::STATUS_REJECTED:
|
403 |
+
$this->_updatePaymentStatusRejected($payment);
|
404 |
break;
|
405 |
+
|
406 |
+
case OpenPayuOrderStatus::STATUS_COMPLETED:
|
407 |
+
$this->_updatePaymentStatusCompleted($payment);
|
408 |
break;
|
409 |
}
|
410 |
+
|
411 |
+
$payment->setAdditionalInformation('payu_payment_status', $paymentStatus)
|
412 |
+
->save();
|
413 |
+
|
414 |
+
} catch (Exception $e) {
|
415 |
+
Mage::logException($e);
|
416 |
}
|
417 |
}
|
418 |
}
|
419 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
420 |
/**
|
421 |
* Update payment status to new
|
422 |
*
|
423 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
424 |
*/
|
425 |
+
private function _updatePaymentStatusNew(Mage_Sales_Model_Order_Payment $payment)
|
426 |
+
{
|
427 |
+
$comment = $this->_helper()->__('New transaction started.');
|
428 |
+
|
429 |
+
$payment->setTransactionId($this->_transactionId)
|
430 |
+
->setPreparedMessage($comment)
|
431 |
+
->setCurrencyCode($payment->getOrder()->getBaseCurrencyCode())
|
432 |
+
->setIsTransactionApproved(false)
|
433 |
+
->setIsTransactionClosed(false)
|
434 |
+
->save();
|
435 |
+
|
436 |
+
$payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER, null, false, $comment)
|
437 |
+
->save();
|
438 |
+
|
439 |
+
$payment->getOrder()
|
440 |
+
->save();
|
441 |
+
|
442 |
}
|
443 |
+
|
444 |
/**
|
445 |
* Change the status to canceled
|
446 |
*
|
447 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
448 |
*/
|
449 |
+
private function _updatePaymentStatusCanceled(Mage_Sales_Model_Order_Payment $payment)
|
450 |
+
{
|
451 |
+
$comment = $this->_helper()->__('The transaction has been canceled.');
|
452 |
+
|
453 |
+
$payment->setTransactionId($this->_transactionId)
|
454 |
+
->setPreparedMessage($comment)
|
455 |
+
->setIsTransactionApproved(true)
|
456 |
+
->setIsTransactionClosed(true)
|
457 |
+
->save();
|
458 |
+
|
459 |
+
$payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER, null, false, $comment)
|
460 |
+
->save();
|
461 |
+
|
462 |
+
$payment->getOrder()
|
463 |
+
->cancel()
|
464 |
+
->save();
|
465 |
+
|
466 |
}
|
467 |
+
|
468 |
/**
|
469 |
* Change the status to rejected
|
470 |
*
|
471 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
472 |
*/
|
473 |
+
private function _updatePaymentStatusRejected(Mage_Sales_Model_Order_Payment $payment)
|
474 |
+
{
|
475 |
+
$comment = $this->_helper()->__('The transaction is to be accepted or rejected.');
|
476 |
+
|
477 |
+
$payment->setTransactionId($this->_transactionId)
|
478 |
+
->setPreparedMessage($comment)
|
479 |
+
->save();
|
480 |
+
|
481 |
+
$payment->getOrder()
|
482 |
+
->setState(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, true, $comment)
|
483 |
+
->save();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
484 |
}
|
485 |
+
|
486 |
/**
|
487 |
+
* Update payment status to complete
|
488 |
*
|
489 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
|
|
490 |
*/
|
491 |
+
private function _updatePaymentStatusCompleted(Mage_Sales_Model_Order_Payment $payment)
|
492 |
+
{
|
493 |
+
$comment = $this->_helper()->__('The transaction completed successfully.');
|
494 |
+
|
495 |
+
$payment->setTransactionId($this->_transactionId)
|
496 |
+
->setPreparedMessage($comment)
|
497 |
+
->setCurrencyCode($payment->getOrder()->getBaseCurrencyCode())
|
498 |
+
->setIsTransactionApproved(true)
|
499 |
+
->setIsTransactionClosed(true)
|
500 |
+
->registerCaptureNotification($this->getOrder()->getTotalDue(), true)
|
501 |
+
->save();
|
502 |
+
|
503 |
+
$this->getOrder()
|
504 |
+
->save();
|
505 |
+
|
506 |
}
|
507 |
+
|
508 |
/**
|
509 |
+
* @param $status
|
510 |
+
* @param $sessionId
|
511 |
+
* @return bool OpenPayU_Result
|
512 |
*/
|
513 |
+
private function _orderStatusUpdateRequest($status, $sessionId)
|
514 |
+
{
|
515 |
+
if (empty($sessionId)) {
|
516 |
+
$sessionId = $this->getOrder()->getPayment()->getLastTransId();
|
|
|
|
|
|
|
|
|
517 |
}
|
518 |
+
|
519 |
+
if (empty($sessionId)) {
|
520 |
+
Mage::log("PayU sessionId empty: " . $this->getId());
|
521 |
+
return false;
|
522 |
+
}
|
523 |
+
|
524 |
+
if ($status == OpenPayuOrderStatus::STATUS_CANCELED) {
|
525 |
+
$result = OpenPayU_Order::cancel($sessionId);
|
526 |
+
} elseif ($status == OpenPayuOrderStatus::STATUS_COMPLETED) {
|
527 |
+
$status_update = array(
|
528 |
+
"orderId" => $sessionId,
|
529 |
+
"orderStatus" => OpenPayuOrderStatus::STATUS_COMPLETED
|
530 |
+
);
|
531 |
+
$result = OpenPayU_Order::statusUpdate($status_update);
|
532 |
+
} else {
|
533 |
+
return false;
|
534 |
+
}
|
535 |
+
|
536 |
+
if ($result->getStatus() == OpenPayU_Order::SUCCESS) {
|
537 |
+
return true;
|
538 |
+
} else {
|
539 |
+
Mage::log("PayU error while updating status: " . $result->getError());
|
540 |
+
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
541 |
}
|
542 |
}
|
543 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
544 |
/**
|
545 |
+
* Returns amount in PayU acceptable format
|
546 |
*
|
547 |
+
* @param $val
|
548 |
+
* @return int
|
|
|
|
|
|
|
|
|
|
|
|
|
549 |
*/
|
550 |
+
private function _toAmount($val)
|
551 |
+
{
|
552 |
+
return $this->_helper()->toAmount($val);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
553 |
}
|
554 |
|
555 |
}
|
app/code/community/PayU/Account/Model/Session.php
CHANGED
@@ -1,16 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
*
|
5 |
-
* PayU Session Model
|
6 |
*
|
7 |
-
*
|
8 |
-
*
|
9 |
-
* http://www.payu.com
|
10 |
-
* http://www.openpayu.com
|
11 |
-
* http://twitter.com/openpayu
|
12 |
*/
|
13 |
-
|
14 |
class PayU_Account_Model_Session extends Mage_Core_Model_Session_Abstract
|
15 |
{
|
16 |
public function __construct()
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* PayU Session Model
|
|
|
5 |
*
|
6 |
+
* @copyright Copyright (c) 2011-2016 PayU
|
7 |
+
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
|
|
|
|
|
|
8 |
*/
|
|
|
9 |
class PayU_Account_Model_Session extends Mage_Core_Model_Session_Abstract
|
10 |
{
|
11 |
public function __construct()
|
app/code/community/PayU/Account/Model/Thumbnail.php
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* ver. 1.9.0
|
5 |
-
* PayU Thumbnail Model
|
6 |
-
*
|
7 |
-
* @copyright Copyright (c) 2011-2014 PayU
|
8 |
-
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
9 |
-
* http://www.payu.com
|
10 |
-
* http://www.openpayu.com
|
11 |
-
* http://twitter.com/openpayu
|
12 |
-
*/
|
13 |
-
|
14 |
-
class PayU_Account_Model_Thumbnail
|
15 |
-
{
|
16 |
-
public function toOptionArray()
|
17 |
-
{
|
18 |
-
|
19 |
-
$thumbnails = Mage::getModel('payu_account/config')->getGoods('media_logos');
|
20 |
-
|
21 |
-
$options = array();
|
22 |
-
|
23 |
-
foreach ($thumbnails as $label) {
|
24 |
-
$options[] = array(
|
25 |
-
'value' => $label,
|
26 |
-
'label' => $label
|
27 |
-
);
|
28 |
-
}
|
29 |
-
return $options;
|
30 |
-
}
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/PayU/Account/Model/ValidityTime.php
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* ver. 1.9.0
|
5 |
-
* PayU Validity Time Model
|
6 |
-
*
|
7 |
-
* @copyright Copyright (c) 2011-2014 PayU
|
8 |
-
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
9 |
-
* http://www.payu.com
|
10 |
-
* http://www.openpayu.com
|
11 |
-
* http://twitter.com/openpayu
|
12 |
-
*/
|
13 |
-
|
14 |
-
|
15 |
-
class PayU_Account_Model_ValidityTime
|
16 |
-
{
|
17 |
-
|
18 |
-
public function toOptionArray() {
|
19 |
-
|
20 |
-
$minutes = array(
|
21 |
-
|
22 |
-
'86400' => '1440 min (24h)',
|
23 |
-
'43200' => '720 min (12h)',
|
24 |
-
'21600' => '360 min (6h)',
|
25 |
-
'3600' => '60 min (1h)',
|
26 |
-
'1800' => '30 min',
|
27 |
-
|
28 |
-
);
|
29 |
-
|
30 |
-
$options = array();
|
31 |
-
|
32 |
-
foreach ($minutes as $code => $label) {
|
33 |
-
$options[] = array(
|
34 |
-
'value' => $code,
|
35 |
-
'label' => $label
|
36 |
-
);
|
37 |
-
}
|
38 |
-
|
39 |
-
return $options;
|
40 |
-
|
41 |
-
}
|
42 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/PayU/Account/controllers/Adminhtml/Sales/OrderController.php
DELETED
@@ -1,73 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* ver. 1.9.0
|
5 |
-
* PayU Adminhtml Sales Order Controller
|
6 |
-
*
|
7 |
-
* @copyright Copyright (c) 2011-2014 PayU
|
8 |
-
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
9 |
-
* http://www.payu.com
|
10 |
-
* http://www.openpayu.com
|
11 |
-
* http://twitter.com/openpayu
|
12 |
-
*/
|
13 |
-
|
14 |
-
include_once("Mage/Adminhtml/controllers/Sales/OrderController.php");
|
15 |
-
|
16 |
-
class PayU_Account_Adminhtml_Sales_OrderController extends Mage_Adminhtml_Sales_OrderController{
|
17 |
-
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Cancel
|
21 |
-
*/
|
22 |
-
public function cancelPayUOrderAction(){
|
23 |
-
|
24 |
-
$order = Mage::getModel('sales/order')->load(Mage::app()->getRequest()->getParam('order_id'));
|
25 |
-
$payu = Mage::getModel('payu_account/payment');
|
26 |
-
$session = Mage::getSingleton('adminhtml/session');
|
27 |
-
|
28 |
-
if($payu->cancelOrder($order)){
|
29 |
-
$session->addSuccess( Mage::helper('payu_account')->__('The order is awaiting for cancelation in PayU, please wait while status changes.') );
|
30 |
-
}else{
|
31 |
-
$session->addError( Mage::helper('payu_account')->__('There was a problem while canceling the order in PayU.') );
|
32 |
-
}
|
33 |
-
$this->_redirect('*/sales_order/view', array('order_id' => $order->getId()));
|
34 |
-
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Reject
|
39 |
-
*/
|
40 |
-
public function rejectPayUOrderAction(){
|
41 |
-
|
42 |
-
$order = Mage::getModel('sales/order')->load(Mage::app()->getRequest()->getParam('order_id'));
|
43 |
-
$payu = Mage::getModel('payu_account/payment');
|
44 |
-
$session = Mage::getSingleton('adminhtml/session');
|
45 |
-
|
46 |
-
if($payu->rejectOrder($order)){
|
47 |
-
$session->addSuccess( Mage::helper('payu_account')->__('The order has been rejected in PayU.') );
|
48 |
-
}else{
|
49 |
-
$session->addError( Mage::helper('payu_account')->__('There was a problem while rejecting the order in PayU.') );
|
50 |
-
}
|
51 |
-
$this->_redirect('*/sales_order/view', array('order_id' => $order->getId()));
|
52 |
-
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
*
|
57 |
-
*/
|
58 |
-
public function completePayUOrderAction(){
|
59 |
-
|
60 |
-
$order = Mage::getModel('sales/order')->load(Mage::app()->getRequest()->getParam('order_id'));
|
61 |
-
$payu = Mage::getModel('payu_account/payment');
|
62 |
-
$session = Mage::getSingleton('adminhtml/session');
|
63 |
-
|
64 |
-
if($payu->completeOrder($order)){
|
65 |
-
$session->addSuccess(Mage::helper('payu_account')->__('The order is completing in PayU, please wait while status changes.'));
|
66 |
-
}else{
|
67 |
-
$session->addError(Mage::helper('payu_account')->__('There was a problem while completing the order in PayU.'));
|
68 |
-
}
|
69 |
-
$this->_redirect('*/sales_order/view', array('order_id' => $order->getId()));
|
70 |
-
|
71 |
-
}
|
72 |
-
|
73 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/PayU/Account/controllers/Checkout/CartController.php
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* ver. 1.9.0
|
5 |
-
* PayU Cart Controller
|
6 |
-
*
|
7 |
-
* @copyright Copyright (c) 2011-2014 PayU
|
8 |
-
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
9 |
-
* http://www.payu.com
|
10 |
-
* http://www.openpayu.com
|
11 |
-
* http://twitter.com/openpayu
|
12 |
-
*/
|
13 |
-
|
14 |
-
require_once Mage::getModuleDir('controllers', 'Mage_Checkout').'/CartController.php';
|
15 |
-
|
16 |
-
class PayU_Account_Checkout_CartController extends Mage_Checkout_CartController
|
17 |
-
{
|
18 |
-
|
19 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/PayU/Account/controllers/PaymentController.php
CHANGED
@@ -1,212 +1,97 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
*
|
5 |
-
* PayU Standard Payment Controller
|
6 |
*
|
7 |
-
*
|
8 |
-
*
|
9 |
-
* http://www.payu.com
|
10 |
-
* http://www.openpayu.com
|
11 |
-
* http://twitter.com/openpayu
|
12 |
*/
|
13 |
-
|
14 |
-
|
15 |
-
class PayU_Account_PaymentController extends Mage_Core_Controller_Front_Action {
|
16 |
-
|
17 |
-
protected $_session = null;
|
18 |
-
protected $_order = null;
|
19 |
-
protected $_payment = null;
|
20 |
-
|
21 |
-
protected $_allShippingRates = null;
|
22 |
-
|
23 |
/**
|
24 |
-
*
|
|
|
|
|
25 |
*/
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
$this->_order = Mage::getModel('payu_account/payment')->newOneStep();
|
30 |
-
$this->_redirect('payu_account/payment/new');
|
31 |
-
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
-
*
|
36 |
-
*
|
37 |
-
* @return Mage_Sales_Model_Order_Invoice
|
38 |
*/
|
39 |
-
|
40 |
{
|
41 |
-
|
42 |
-
foreach ($this->_order->getAllItems() as $item) {
|
43 |
-
$items[$item->getId()] = $item->getQtyOrdered();
|
44 |
-
}
|
45 |
-
/* @var $invoice Mage_Sales_Model_Service_Order */
|
46 |
-
$invoice = Mage::getModel('sales/service_order', $this->_order)->prepareInvoice($items);
|
47 |
-
$invoice->setEmailSent(true)->register();
|
48 |
-
|
49 |
-
Mage::register('current_invoice', $invoice);
|
50 |
-
return $invoice;
|
51 |
}
|
52 |
|
|
|
53 |
/**
|
54 |
* Initializes new One Page payment
|
55 |
*/
|
56 |
-
public function newAction()
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
$this->setPayment(true);
|
61 |
-
$this->_allShippingRates = Mage::getSingleton('checkout/type_onepage')->getQuote()->getShippingAddress()->getAllShippingRates();
|
62 |
-
$this->getResponse()->setBody($this->getLayout()->createBlock('payu_account/redirect')->setAllShippingMethods($this->_allShippingRates)->setOrder($this->_order)->toHtml());
|
63 |
-
}
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
-
try {
|
71 |
-
Mage::getModel('payu_account/payment')->orderNotifyRequest();
|
72 |
} catch (Exception $e) {
|
73 |
Mage::logException($e);
|
|
|
|
|
74 |
}
|
|
|
|
|
75 |
}
|
76 |
|
77 |
/**
|
78 |
-
*
|
79 |
-
*
|
80 |
-
* @todo not functioning yet
|
81 |
*/
|
82 |
-
public function
|
83 |
-
|
84 |
-
$this->setOrder();
|
85 |
try {
|
86 |
-
|
87 |
} catch (Exception $e) {
|
88 |
Mage::logException($e);
|
89 |
}
|
90 |
-
|
91 |
}
|
92 |
|
93 |
-
/**
|
94 |
-
* Complete payment action
|
95 |
-
*/
|
96 |
-
public function completePaymentAction(){
|
97 |
-
$this->setSession();
|
98 |
-
$this->setOrder();
|
99 |
-
$this->setPayment();
|
100 |
-
|
101 |
-
if(isset($_GET['error']))
|
102 |
-
{
|
103 |
-
$this->_order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true)->save();
|
104 |
-
}
|
105 |
-
elseif (defined('Mage_Sales_Model_Order::STATE_PENDING_PAYMENT')) {
|
106 |
-
$this->_order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true)->save();
|
107 |
-
}
|
108 |
-
|
109 |
-
Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
|
110 |
-
Mage::getSingleton('checkout/session')->setSuccess( Mage::helper('payu_account')->__('Thank you.') );
|
111 |
-
|
112 |
-
if(isset($_GET['error']))
|
113 |
-
$this->_redirect('checkout/onepage/failure',array('_secure' => true));
|
114 |
-
else
|
115 |
-
$this->_redirect('checkout/onepage/success',array('_secure' => true));
|
116 |
-
|
117 |
-
}
|
118 |
-
|
119 |
/**
|
120 |
* Continue payment action
|
121 |
*/
|
122 |
-
public function continuePaymentAction()
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
$
|
127 |
-
|
128 |
-
if(isset($_GET['error'])){
|
129 |
-
$this->_order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true)->save();
|
130 |
-
}elseif ($this->_order->getState() != Mage_Sales_Model_Order::STATE_PROCESSING && defined('Mage_Sales_Model_Order::STATE_PENDING_PAYMENT')) {
|
131 |
-
$this->_order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true)->save();
|
132 |
}
|
133 |
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
else
|
140 |
-
$this->_redirect('checkout/onepage/success',array('_secure' => true));
|
141 |
-
|
142 |
-
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* Cancel payment action
|
146 |
-
*
|
147 |
-
* @todo not yet implemented
|
148 |
-
*/
|
149 |
-
public function cancelPaymentAction(){
|
150 |
-
Mage::getSingleton('checkout/session')->setMessage( Mage::helper('payu_account')->__('The payment has been cancelled.') );
|
151 |
-
$this->_redirect('checkout/cart', array('_secure'=>true));
|
152 |
}
|
153 |
|
154 |
-
|
155 |
-
|
156 |
/**
|
157 |
* Error payment action
|
158 |
-
*
|
159 |
-
* @todo not yet implemented
|
160 |
-
*/
|
161 |
-
public function errorAction() {
|
162 |
-
$this->_redirect('checkout/onepage/failure', array('_secure'=>true));
|
163 |
-
}
|
164 |
-
|
165 |
-
/** Setting checkout session */
|
166 |
-
private function setSession() {
|
167 |
-
$this->_session = Mage::getSingleton('checkout/session');
|
168 |
-
}
|
169 |
-
|
170 |
-
/** Setting the order */
|
171 |
-
private function setOrder() {
|
172 |
-
$id = $this->_session->getLastRealOrderId();
|
173 |
-
$this->_order = Mage::getModel('sales/order')->loadByIncrementId($id);
|
174 |
-
}
|
175 |
-
|
176 |
-
/** Setting the new order */
|
177 |
-
private function setNewOrder() {
|
178 |
-
$this->_order = Mage::getModel('payu_account/payment')->prepareNewOrderByCart();
|
179 |
-
}
|
180 |
-
|
181 |
-
/**
|
182 |
-
* Setting the payment
|
183 |
-
*
|
184 |
-
* @param boolean
|
185 |
*/
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
/**
|
191 |
-
* Check if the order is new
|
192 |
-
*
|
193 |
-
* @return boolean
|
194 |
-
*/
|
195 |
-
private function isNewOrder() {
|
196 |
-
return (Mage::getSingleton('checkout/session')->getLastRealOrderId() == $this->_order->getRealOrderId());
|
197 |
-
}
|
198 |
-
|
199 |
-
|
200 |
-
/** Forcing the order to be new */
|
201 |
-
private function forceNewOrderStatus() {
|
202 |
-
if ($this->isNewOrder()) {
|
203 |
-
$status = $this->_order->getStatus();
|
204 |
-
$state = $this->_order->getState();
|
205 |
-
if ($state == Mage_Sales_Model_Order::STATE_NEW && $status != Mage::getStoreConfig("payment/payu_account/order_status")) {
|
206 |
-
$this->_order->setState(Mage::getStoreConfig("payment/payu_account/order_status"), true)
|
207 |
-
->save();
|
208 |
-
}
|
209 |
-
}
|
210 |
}
|
211 |
-
|
212 |
-
}
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* PayU Standard Payment Controller
|
|
|
5 |
*
|
6 |
+
* @copyright Copyright (c) 2011-2016 PayU
|
7 |
+
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
|
|
|
|
|
|
8 |
*/
|
9 |
+
class PayU_Account_PaymentController extends Mage_Core_Controller_Front_Action
|
10 |
+
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
/**
|
12 |
+
* Get singleton of Checkout Session Model
|
13 |
+
*
|
14 |
+
* @return Mage_Checkout_Model_Session
|
15 |
*/
|
16 |
+
protected function _getCheckout()
|
17 |
+
{
|
18 |
+
return Mage::getSingleton('checkout/session');
|
|
|
|
|
|
|
19 |
}
|
20 |
|
21 |
/**
|
22 |
+
* @return PayU_Account_Model_Payment
|
|
|
|
|
23 |
*/
|
24 |
+
public function getPayment()
|
25 |
{
|
26 |
+
return Mage::getModel('payu_account/payment');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
28 |
|
29 |
+
|
30 |
/**
|
31 |
* Initializes new One Page payment
|
32 |
*/
|
33 |
+
public function newAction()
|
34 |
+
{
|
35 |
+
try {
|
36 |
+
$session = $this->_getCheckout();
|
|
|
|
|
|
|
|
|
37 |
|
38 |
+
$order = Mage::getModel('sales/order');
|
39 |
+
$order->loadByIncrementId($session->getLastRealOrderId());
|
40 |
+
|
41 |
+
if (!$order->getId()) {
|
42 |
+
Mage::throwException($this->__('No order for processing found'));
|
43 |
+
}
|
44 |
+
|
45 |
+
$redirectData = $this->getPayment()->orderCreateRequest($order);
|
46 |
+
|
47 |
+
$this->_redirectUrl($redirectData['redirectUri']);
|
48 |
+
|
49 |
+
return;
|
50 |
|
|
|
|
|
51 |
} catch (Exception $e) {
|
52 |
Mage::logException($e);
|
53 |
+
Mage::getSingleton('core/session')->addError($e->getMessage());
|
54 |
+
|
55 |
}
|
56 |
+
|
57 |
+
$this->_errorAction();
|
58 |
}
|
59 |
|
60 |
/**
|
61 |
+
* Processes PayU OrderNotifyRequest
|
|
|
|
|
62 |
*/
|
63 |
+
public function orderNotifyRequestAction()
|
64 |
+
{
|
|
|
65 |
try {
|
66 |
+
$this->getPayment()->orderNotifyRequest();
|
67 |
} catch (Exception $e) {
|
68 |
Mage::logException($e);
|
69 |
}
|
|
|
70 |
}
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
/**
|
73 |
* Continue payment action
|
74 |
*/
|
75 |
+
public function continuePaymentAction()
|
76 |
+
{
|
77 |
+
try {
|
78 |
+
$this->_getCheckout()->getQuote()->setIsActive(false)->save();
|
79 |
+
} catch (Exception $e) {
|
80 |
+
Mage::logException($e);
|
|
|
|
|
|
|
|
|
81 |
}
|
82 |
|
83 |
+
if (isset($_GET['error'])) {
|
84 |
+
$this->_redirect('checkout/onepage/failure', array('_secure' => true));
|
85 |
+
} else {
|
86 |
+
$this->_redirect('checkout/onepage/success', array('_secure' => true));
|
87 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
}
|
89 |
|
|
|
|
|
90 |
/**
|
91 |
* Error payment action
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
*/
|
93 |
+
public function _errorAction()
|
94 |
+
{
|
95 |
+
$this->_redirect('checkout/onepage/failure', array('_secure' => true));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
}
|
97 |
+
}
|
|
app/code/community/PayU/Account/etc/config.xml
CHANGED
@@ -1,15 +1,13 @@
|
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<config>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
<version>2.1.3</version>
|
7 |
<depends>
|
8 |
-
<Mage_Payment
|
9 |
</depends>
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
<global>
|
14 |
<models>
|
15 |
<payu_account>
|
@@ -25,100 +23,46 @@
|
|
25 |
<payu_account>
|
26 |
<class>PayU_Account_Block</class>
|
27 |
</payu_account>
|
28 |
-
<adminhtml>
|
29 |
-
<rewrite>
|
30 |
-
<sales_order_view>PayU_Account_Block_Adminhtml_Sales_Order_View</sales_order_view>
|
31 |
-
</rewrite>
|
32 |
-
</adminhtml>
|
33 |
</blocks>
|
34 |
-
<resources>
|
35 |
-
<payu_account_setup>
|
36 |
-
<setup>
|
37 |
-
<module>PayU_Account</module>
|
38 |
-
</setup>
|
39 |
-
<connection>
|
40 |
-
<use>core_setup</use>
|
41 |
-
</connection>
|
42 |
-
</payu_account_setup>
|
43 |
-
<payu_account_write>
|
44 |
-
<connection>
|
45 |
-
<use>core_write</use>
|
46 |
-
</connection>
|
47 |
-
</payu_account_write>
|
48 |
-
<payu_account_read>
|
49 |
-
<connection>
|
50 |
-
<use>core_read</use>
|
51 |
-
</connection>
|
52 |
-
</payu_account_read>
|
53 |
-
</resources>
|
54 |
</global>
|
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 |
-
<updates>
|
97 |
-
<payu_account module="PayU_Account">
|
98 |
-
<file>payu_account.xml</file>
|
99 |
-
</payu_account>
|
100 |
-
</updates>
|
101 |
-
</layout>
|
102 |
-
<translate>
|
103 |
-
<modules>
|
104 |
-
<PayU_Account>
|
105 |
-
<files>
|
106 |
-
<default>PayU_Account.csv</default>
|
107 |
-
</files>
|
108 |
-
</PayU_Account>
|
109 |
-
</modules>
|
110 |
-
</translate>
|
111 |
-
</frontend>
|
112 |
-
|
113 |
-
<default>
|
114 |
-
<payment>
|
115 |
-
<payu_account>
|
116 |
-
<active>1</active>
|
117 |
-
<model>payu_account/payment</model>
|
118 |
-
<order_status>1</order_status>
|
119 |
-
<payment_action>authorize</payment_action>
|
120 |
-
<allowspecific>0</allowspecific>
|
121 |
-
</payu_account>
|
122 |
-
</payment>
|
123 |
-
</default>
|
124 |
-
</config>
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<config>
|
3 |
+
<modules>
|
4 |
+
<PayU_Account>
|
5 |
+
<version>2.2.0</version>
|
|
|
6 |
<depends>
|
7 |
+
<Mage_Payment/>
|
8 |
</depends>
|
9 |
+
</PayU_Account>
|
10 |
+
</modules>
|
|
|
11 |
<global>
|
12 |
<models>
|
13 |
<payu_account>
|
23 |
<payu_account>
|
24 |
<class>PayU_Account_Block</class>
|
25 |
</payu_account>
|
|
|
|
|
|
|
|
|
|
|
26 |
</blocks>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
</global>
|
28 |
+
<adminhtml>
|
29 |
+
<translate>
|
30 |
+
<modules>
|
31 |
+
<PayU_Account>
|
32 |
+
<files>
|
33 |
+
<default>PayU_Account.csv</default>
|
34 |
+
</files>
|
35 |
+
</PayU_Account>
|
36 |
+
</modules>
|
37 |
+
</translate>
|
38 |
+
</adminhtml>
|
39 |
+
<frontend>
|
40 |
+
<routers>
|
41 |
+
<payu_account>
|
42 |
+
<use>standard</use>
|
43 |
+
<args>
|
44 |
+
<module>PayU_Account</module>
|
45 |
+
<frontName>payu_account</frontName>
|
46 |
+
</args>
|
47 |
+
</payu_account>
|
48 |
+
</routers>
|
49 |
+
<translate>
|
50 |
+
<modules>
|
51 |
+
<PayU_Account>
|
52 |
+
<files>
|
53 |
+
<default>PayU_Account.csv</default>
|
54 |
+
</files>
|
55 |
+
</PayU_Account>
|
56 |
+
</modules>
|
57 |
+
</translate>
|
58 |
+
</frontend>
|
59 |
+
<default>
|
60 |
+
<payment>
|
61 |
+
<payu_account>
|
62 |
+
<active>0</active>
|
63 |
+
<title>PayU</title>
|
64 |
+
<model>payu_account/payment</model>
|
65 |
+
</payu_account>
|
66 |
+
</payment>
|
67 |
+
</default>
|
68 |
+
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/PayU/Account/etc/system.xml
CHANGED
@@ -3,14 +3,14 @@
|
|
3 |
<sections>
|
4 |
<payment>
|
5 |
<groups>
|
6 |
-
<payu_account translate="label" module="paygate">
|
7 |
-
<label>PayU
|
8 |
<frontend_type>text</frontend_type>
|
9 |
<sort_order>670</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 |
-
<comment>Important: This plugin works only with
|
14 |
<fields>
|
15 |
<header1 translate="label">
|
16 |
<label>Main parameters</label>
|
@@ -21,115 +21,60 @@
|
|
21 |
<show_in_store>1</show_in_store>
|
22 |
</header1>
|
23 |
<active translate="label">
|
24 |
-
<label>
|
25 |
<frontend_type>select</frontend_type>
|
26 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
27 |
-
<sort_order>
|
28 |
<show_in_default>1</show_in_default>
|
29 |
<show_in_website>1</show_in_website>
|
30 |
<show_in_store>1</show_in_store>
|
31 |
</active>
|
32 |
-
<onestepcheckoutenabled translate="label">
|
33 |
-
<label>OneStepCheckout Enabled</label>
|
34 |
-
<frontend_type>select</frontend_type>
|
35 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
36 |
-
<sort_order>2</sort_order>
|
37 |
-
<show_in_default>1</show_in_default>
|
38 |
-
<show_in_website>1</show_in_website>
|
39 |
-
<show_in_store>1</show_in_store>
|
40 |
-
</onestepcheckoutenabled>
|
41 |
-
<selfreturn translate="label">
|
42 |
-
<label>Self-Return Enabled</label>
|
43 |
-
<frontend_type>select</frontend_type>
|
44 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
45 |
-
<sort_order>3</sort_order>
|
46 |
-
<show_in_default>1</show_in_default>
|
47 |
-
<show_in_website>1</show_in_website>
|
48 |
-
<show_in_store>1</show_in_store>
|
49 |
-
</selfreturn>
|
50 |
-
<order_status translate="label">
|
51 |
-
<label>New Order Status</label>
|
52 |
-
<frontend_type>select</frontend_type>
|
53 |
-
<source_model>adminhtml/system_config_source_order_status</source_model>
|
54 |
-
<sort_order>3</sort_order>
|
55 |
-
<show_in_default>1</show_in_default>
|
56 |
-
<show_in_website>1</show_in_website>
|
57 |
-
<show_in_store>0</show_in_store>
|
58 |
-
</order_status>
|
59 |
-
<validity_time translate="label comment">
|
60 |
-
<label>Order Validity Time</label>
|
61 |
-
<frontend_type>select</frontend_type>
|
62 |
-
<source_model>payu_account/validityTime</source_model>
|
63 |
-
<sort_order>5</sort_order>
|
64 |
-
<show_in_default>1</show_in_default>
|
65 |
-
<show_in_website>1</show_in_website>
|
66 |
-
<show_in_store>1</show_in_store>
|
67 |
-
</validity_time>
|
68 |
-
<!--<environment translate="label">
|
69 |
-
<label>Test Mode Enabled</label>
|
70 |
-
<frontend_type>select</frontend_type>
|
71 |
-
<source_model>payu_account/environment</source_model>
|
72 |
-
<sort_order>6</sort_order>
|
73 |
-
<show_in_default>1</show_in_default>
|
74 |
-
<show_in_website>1</show_in_website>
|
75 |
-
<show_in_store>1</show_in_store>
|
76 |
-
</environment>-->
|
77 |
<header2 translate="label">
|
78 |
-
<label>Parameters
|
79 |
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
80 |
-
<sort_order>
|
81 |
<show_in_default>1</show_in_default>
|
82 |
<show_in_website>1</show_in_website>
|
83 |
<show_in_store>1</show_in_store>
|
84 |
</header2>
|
85 |
-
<
|
86 |
<label>POS ID (pos_id)</label>
|
87 |
-
|
88 |
<frontend_type>text</frontend_type>
|
89 |
-
<sort_order>
|
90 |
<show_in_default>1</show_in_default>
|
91 |
<show_in_website>1</show_in_website>
|
92 |
<show_in_store>1</show_in_store>
|
93 |
-
</
|
94 |
<signature_key translate="label">
|
95 |
<label>Second key (MD5)</label>
|
96 |
<comment>Symmetrical key for encrypting communication</comment>
|
97 |
<frontend_type>text</frontend_type>
|
98 |
-
<sort_order>
|
99 |
<show_in_default>1</show_in_default>
|
100 |
<show_in_website>1</show_in_website>
|
101 |
<show_in_store>1</show_in_store>
|
102 |
</signature_key>
|
103 |
-
<
|
104 |
-
<label>
|
105 |
-
<
|
106 |
-
<sort_order>
|
107 |
-
<show_in_default>1</show_in_default>
|
108 |
-
<show_in_website>1</show_in_website>
|
109 |
-
<show_in_store>1</show_in_store>
|
110 |
-
</header4>
|
111 |
-
<payuthumbnail translate="label">
|
112 |
-
<label>Small logo</label>
|
113 |
-
<frontend_type>select</frontend_type>
|
114 |
-
<source_model>payu_account/thumbnail</source_model>
|
115 |
-
<sort_order>20</sort_order>
|
116 |
<show_in_default>1</show_in_default>
|
117 |
<show_in_website>1</show_in_website>
|
118 |
<show_in_store>1</show_in_store>
|
119 |
-
</
|
120 |
-
<
|
121 |
-
<label>
|
122 |
-
<
|
123 |
-
<
|
124 |
-
<sort_order>21</sort_order>
|
125 |
<show_in_default>1</show_in_default>
|
126 |
<show_in_website>1</show_in_website>
|
127 |
<show_in_store>1</show_in_store>
|
128 |
-
</
|
129 |
<header5 translate="label">
|
130 |
<label>PayU Plugin Information</label>
|
131 |
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
132 |
-
<sort_order>
|
133 |
<show_in_default>1</show_in_default>
|
134 |
<show_in_website>0</show_in_website>
|
135 |
<show_in_store>0</show_in_store>
|
@@ -138,7 +83,7 @@
|
|
138 |
<label></label>
|
139 |
<frontend_type>multiline</frontend_type>
|
140 |
<frontend_model>payu_account/updateInfo</frontend_model>
|
141 |
-
<sort_order>
|
142 |
<show_in_default>1</show_in_default>
|
143 |
<show_in_website>0</show_in_website>
|
144 |
<show_in_store>0</show_in_store>
|
@@ -148,4 +93,4 @@
|
|
148 |
</groups>
|
149 |
</payment>
|
150 |
</sections>
|
151 |
-
</config>
|
3 |
<sections>
|
4 |
<payment>
|
5 |
<groups>
|
6 |
+
<payu_account translate="label comment" module="paygate">
|
7 |
+
<label>PayU</label>
|
8 |
<frontend_type>text</frontend_type>
|
9 |
<sort_order>670</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 |
+
<comment>Important: This plugin works only with REST (Checkout) points of sales (POS).</comment>
|
14 |
<fields>
|
15 |
<header1 translate="label">
|
16 |
<label>Main parameters</label>
|
21 |
<show_in_store>1</show_in_store>
|
22 |
</header1>
|
23 |
<active translate="label">
|
24 |
+
<label>Enable plugin?</label>
|
25 |
<frontend_type>select</frontend_type>
|
26 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
27 |
+
<sort_order>10</sort_order>
|
28 |
<show_in_default>1</show_in_default>
|
29 |
<show_in_website>1</show_in_website>
|
30 |
<show_in_store>1</show_in_store>
|
31 |
</active>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
<header2 translate="label">
|
33 |
+
<label>POS Parameters</label>
|
34 |
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
35 |
+
<sort_order>70</sort_order>
|
36 |
<show_in_default>1</show_in_default>
|
37 |
<show_in_website>1</show_in_website>
|
38 |
<show_in_store>1</show_in_store>
|
39 |
</header2>
|
40 |
+
<pos_id translate="label">
|
41 |
<label>POS ID (pos_id)</label>
|
42 |
+
<comment>Point of Sale identifier</comment>
|
43 |
<frontend_type>text</frontend_type>
|
44 |
+
<sort_order>80</sort_order>
|
45 |
<show_in_default>1</show_in_default>
|
46 |
<show_in_website>1</show_in_website>
|
47 |
<show_in_store>1</show_in_store>
|
48 |
+
</pos_id>
|
49 |
<signature_key translate="label">
|
50 |
<label>Second key (MD5)</label>
|
51 |
<comment>Symmetrical key for encrypting communication</comment>
|
52 |
<frontend_type>text</frontend_type>
|
53 |
+
<sort_order>90</sort_order>
|
54 |
<show_in_default>1</show_in_default>
|
55 |
<show_in_website>1</show_in_website>
|
56 |
<show_in_store>1</show_in_store>
|
57 |
</signature_key>
|
58 |
+
<oauth_client_id translate="label">
|
59 |
+
<label>OAuth protocol - client_id</label>
|
60 |
+
<frontend_type>text</frontend_type>
|
61 |
+
<sort_order>100</sort_order>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
<show_in_default>1</show_in_default>
|
63 |
<show_in_website>1</show_in_website>
|
64 |
<show_in_store>1</show_in_store>
|
65 |
+
</oauth_client_id>
|
66 |
+
<oauth_client_secret translate="label">
|
67 |
+
<label>OAuth protocol - client_secret</label>
|
68 |
+
<frontend_type>text</frontend_type>
|
69 |
+
<sort_order>110</sort_order>
|
|
|
70 |
<show_in_default>1</show_in_default>
|
71 |
<show_in_website>1</show_in_website>
|
72 |
<show_in_store>1</show_in_store>
|
73 |
+
</oauth_client_secret>
|
74 |
<header5 translate="label">
|
75 |
<label>PayU Plugin Information</label>
|
76 |
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
77 |
+
<sort_order>230</sort_order>
|
78 |
<show_in_default>1</show_in_default>
|
79 |
<show_in_website>0</show_in_website>
|
80 |
<show_in_store>0</show_in_store>
|
83 |
<label></label>
|
84 |
<frontend_type>multiline</frontend_type>
|
85 |
<frontend_model>payu_account/updateInfo</frontend_model>
|
86 |
+
<sort_order>240</sort_order>
|
87 |
<show_in_default>1</show_in_default>
|
88 |
<show_in_website>0</show_in_website>
|
89 |
<show_in_store>0</show_in_store>
|
93 |
</groups>
|
94 |
</payment>
|
95 |
</sections>
|
96 |
+
</config>
|
app/design/frontend/base/default/layout/payu_account.xml
DELETED
@@ -1,106 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<layout version="0.1.0">
|
3 |
-
|
4 |
-
<catalog_product_view>
|
5 |
-
<!--<reference name="product.info.addtocart">
|
6 |
-
<block type="payu_account/onestep_checkout" name="payu_account.button" template="payu_account/onestep/checkout.phtml">
|
7 |
-
<action method="setIsInCatalogProduct"><value>1</value></action>
|
8 |
-
</block>
|
9 |
-
</reference>-->
|
10 |
-
<reference name="right">
|
11 |
-
<block type="payu_account/advertisement" name="payu_account.advertisement" template="payu_account/advertisement.phtml">
|
12 |
-
</block>
|
13 |
-
</reference>
|
14 |
-
</catalog_product_view>
|
15 |
-
|
16 |
-
<checkout_cart_index>
|
17 |
-
<reference name="checkout.cart.top_methods">
|
18 |
-
<block type="payu_account/onestep_checkout" name="checkout.cart.methods.payu_express.top" before="-" template="payu_account/onestep/checkout.phtml">
|
19 |
-
<action method="setIsQuoteAllowed"><value>1</value></action>
|
20 |
-
</block>
|
21 |
-
</reference>
|
22 |
-
|
23 |
-
<reference name="checkout.cart.methods">
|
24 |
-
<block type="payu_account/onestep_checkout" name="checkout.cart.methods.payu_express.bottom" before="-" template="payu_account/onestep/checkout.phtml">
|
25 |
-
<action method="setIsQuoteAllowed"><value>1</value></action>
|
26 |
-
</block>
|
27 |
-
</reference>
|
28 |
-
|
29 |
-
<update handle="SHORTCUT_popup" />
|
30 |
-
</checkout_cart_index>
|
31 |
-
|
32 |
-
<catalog_category_default>
|
33 |
-
<update handle="SHORTCUT_popup" />
|
34 |
-
<reference name="right">
|
35 |
-
<block type="payu_account/advertisement" name="payu_account.partner.right.advertisement" template="payu_account/advertisement.phtml"/>
|
36 |
-
</reference>
|
37 |
-
</catalog_category_default>
|
38 |
-
|
39 |
-
<catalog_category_layered>
|
40 |
-
<update handle="SHORTCUT_popup" />
|
41 |
-
<reference name="right">
|
42 |
-
<block type="payu_account/advertisement" name="payu_account.partner.right.advertisement" template="payu_account/advertisement.phtml"/>
|
43 |
-
</reference>
|
44 |
-
</catalog_category_layered>
|
45 |
-
|
46 |
-
<catalog_product_compare_index>
|
47 |
-
<update handle="SHORTCUT_popup" />
|
48 |
-
</catalog_product_compare_index>
|
49 |
-
|
50 |
-
<catalogsearch_result_index>
|
51 |
-
<update handle="SHORTCUT_popup" />
|
52 |
-
</catalogsearch_result_index>
|
53 |
-
|
54 |
-
<catalogsearch_advanced_result>
|
55 |
-
<update handle="SHORTCUT_popup" />
|
56 |
-
</catalogsearch_advanced_result>
|
57 |
-
|
58 |
-
<tag_product_list>
|
59 |
-
<update handle="SHORTCUT_popup" />
|
60 |
-
</tag_product_list>
|
61 |
-
<tag_customer_view>
|
62 |
-
<update handle="SHORTCUT_popup" />
|
63 |
-
</tag_customer_view>
|
64 |
-
|
65 |
-
<wishlist_index_index>
|
66 |
-
<update handle="SHORTCUT_popup" />
|
67 |
-
</wishlist_index_index>
|
68 |
-
<review_product_list>
|
69 |
-
<update handle="SHORTCUT_popup" />
|
70 |
-
</review_product_list>
|
71 |
-
|
72 |
-
<checkout_onepage_success>
|
73 |
-
<update handle="SHORTCUT_popup" />
|
74 |
-
</checkout_onepage_success>
|
75 |
-
<checkout_onepage_failure>
|
76 |
-
<update handle="SHORTCUT_popup" />
|
77 |
-
</checkout_onepage_failure>
|
78 |
-
|
79 |
-
<cms_index_index>
|
80 |
-
<reference name="right">
|
81 |
-
<block type="payu_account/advertisement" name="payu_account.partner.right.advertisement" template="payu_account/advertisement.phtml"/>
|
82 |
-
</reference>
|
83 |
-
</cms_index_index>
|
84 |
-
|
85 |
-
<default>
|
86 |
-
<reference name="topCart.extra_actions">
|
87 |
-
<block type="payu_account/onestep_checkout" name="payu_account.partner.top_cart.shortcut" template="payu_account/onestep/checkout.phtml"/>
|
88 |
-
</reference>
|
89 |
-
<reference name="cart_sidebar.extra_actions">
|
90 |
-
<block type="payu_account/onestep_checkout" name="payu_account.partner.cart_sidebar.shortcut" template="payu_account/onestep/checkout.phtml"/>
|
91 |
-
</reference>
|
92 |
-
</default>
|
93 |
-
|
94 |
-
<SHORTCUT_popup>
|
95 |
-
<reference name="product.tooltip">
|
96 |
-
<block type="page/html_wrapper" name="product.info.addtocart.payu_account.wrapper" translate="label">
|
97 |
-
<block type="payu_account/onestep_checkout" name="product.info.addtocart.payu" template="payu_account/onestep/checkout.phtml">
|
98 |
-
<action method="setIsInCatalogProduct"><value>1</value></action>
|
99 |
-
<action method="setShowOrPosition"><value>after</value></action>
|
100 |
-
</block>
|
101 |
-
</block>
|
102 |
-
</reference>
|
103 |
-
</SHORTCUT_popup>
|
104 |
-
|
105 |
-
|
106 |
-
</layout>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/template/payu_account/advertisement.phtml
DELETED
@@ -1,4 +0,0 @@
|
|
1 |
-
<div class="payu-advertisement" style="text-align:center;">
|
2 |
-
<a href="<?php echo $this->getRedirectUrl();?>" target="_blank">
|
3 |
-
<img src="<?php echo $this->getAdvertisementSrc();?>" alt="PayU We Accept" /></a>
|
4 |
-
</div>
|
|
|
|
|
|
|
|
app/design/frontend/base/default/template/payu_account/form.phtml
CHANGED
@@ -1,3 +1,7 @@
|
|
|
|
|
|
1 |
<ul class="form-list" id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none;">
|
2 |
-
<li class="form-alt"
|
3 |
-
|
|
|
|
1 |
+
<?php /** @var PayU_Account_Block_Form $this */ ?>
|
2 |
+
|
3 |
<ul class="form-list" id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none;">
|
4 |
+
<li class="form-alt">
|
5 |
+
<?php echo $this->__('You will be redirected to PayU after submitting the order.'); ?>
|
6 |
+
</li>
|
7 |
+
</ul>
|
app/design/frontend/base/default/template/payu_account/info/payu_account.phtml
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* ver. 1.9.0
|
4 |
-
*
|
5 |
-
* @copyright Copyright (c) 2011-2014 PayU
|
6 |
-
* @license http://opensource.org/licenses/GPL-3.0 Open Software License (GPL 3.0)
|
7 |
-
* http://www.payu.com
|
8 |
-
* http://www.openpayu.com
|
9 |
-
* http://twitter.com/openpayu
|
10 |
-
*/
|
11 |
-
?>
|
12 |
-
<?php echo $this->getMethod()->getTitle() ?>
|
13 |
-
<?php if($this->getInfo()->getAdditionalData()): ?>
|
14 |
-
<?php if($this->getPayableTo()): ?><br /><?php echo Mage::helper('payment')->__('Make Check payable to: %s', $this->htmlEscape($this->getPayableTo())) ?><?php endif; ?>
|
15 |
-
<?php if($this->getMailingAddress()): ?>
|
16 |
-
<label><?php echo Mage::helper('payment')->__('Send Check to:') ?></label>
|
17 |
-
<div class="checkmo-mailing-address">
|
18 |
-
<?php echo nl2br($this->htmlEscape($this->getMailingAddress())) ?>
|
19 |
-
</div>
|
20 |
-
<?php endif; ?>
|
21 |
-
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/template/payu_account/onestep/checkout.phtml
DELETED
@@ -1,5 +0,0 @@
|
|
1 |
-
<?php if($this->getIsOneStepCheckoutEnabled()): ?>
|
2 |
-
<p class="payu-button" style="margin:5px 0 5px 0;">
|
3 |
-
<a onclick="<?php if(!$this->getIsOneStepCheckoutAvailable()): ?>alert('<?php echo $this->__('This feature is currently not available.'); ?>');return false;<?php endif; ?>" href="<?php echo $this->getCheckoutUrl();?>"><img src="<?php echo $this->getButtonSrc(); ?>" alt="PayU One Step Checkout" /></a>
|
4 |
-
</p>
|
5 |
-
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
app/etc/modules/PayU_Account.xml
CHANGED
@@ -5,8 +5,8 @@
|
|
5 |
<active>true</active>
|
6 |
<codePool>community</codePool>
|
7 |
<depends>
|
8 |
-
<Mage_Payment
|
9 |
</depends>
|
10 |
</PayU_Account>
|
11 |
</modules>
|
12 |
-
</config>
|
5 |
<active>true</active>
|
6 |
<codePool>community</codePool>
|
7 |
<depends>
|
8 |
+
<Mage_Payment/>
|
9 |
</depends>
|
10 |
</PayU_Account>
|
11 |
</modules>
|
12 |
+
</config>
|
app/locale/pl_PL/PayU_Account.csv
CHANGED
@@ -1,66 +1,28 @@
|
|
1 |
-
"PayU
|
2 |
-
"
|
3 |
"Main parameters","Główne parametry"
|
4 |
-
"
|
5 |
-
"Self-Return Enabled","Czy autoodbiór włączony"
|
6 |
-
"New Order Status","Status nowego zamówienia"
|
7 |
-
"Test Mode Enabled","Użyj środowiska testowego"
|
8 |
-
"Parameters of production environment","Parametry środowiska produkcyjnego"
|
9 |
"POS ID (pos_id)","Id punktu płatności (pos_id)"
|
10 |
-
"
|
11 |
-
"
|
12 |
-
"POS Auth Key","Klucz autoryzacji płatności"
|
13 |
"OAuth protocol - client_id","Protokół OAuth - client_id"
|
14 |
"OAuth protocol - client_secret","Protokół OAuth - client_secret"
|
15 |
"Symmetrical key for encrypting communication","Symetryczny klucz do szyfrowania komunikacji"
|
16 |
-
"
|
17 |
-
"OneStepCheckout button","Przycisk OneStepCheckout"
|
18 |
-
"Small logo","Małe logo"
|
19 |
-
"PayU advertisement","Reklama PayU"
|
20 |
-
"Credit Card or E-transfer","Karta kredytowa lub e-przelew"
|
21 |
"You are currently using version","Aktualnie zainstalowana wersja"
|
22 |
"for","dla"
|
23 |
-
"The latest version of PayU account plugin is","Najnowszą wersją pluginu konto PayU jest"
|
24 |
-
"Get the latest version - ","Pobierz najnowszą wersję - "
|
25 |
-
"Documents attached to this implementation","Dokumenty dołączone do tej implementacji"
|
26 |
-
"Thank you.","Dziękujemy."
|
27 |
"Yes","Tak"
|
28 |
"No","Nie"
|
29 |
-
"
|
30 |
-
"
|
|
|
|
|
|
|
|
|
|
|
31 |
"The transaction has been canceled.","Transakcja została anulowana."
|
32 |
-
"
|
33 |
-
"The transaction
|
34 |
-
"
|
35 |
-
"
|
36 |
-
"
|
37 |
-
"The transaction is pending.","Transakcja w toku."
|
38 |
-
"Transaction returned.","Transakcja zwrócona."
|
39 |
-
"The transaction has been returned.","Transakcja została zwrócona."
|
40 |
-
"The transaction completed successfully.","Transakcja zakończona pomyślnie"
|
41 |
-
"The transaction is incorrect.","Transakcja nieprawidłowa."
|
42 |
-
"You will be redirected to PayU after submitting the order.","Po złożeniu zamówienia nastąpi przekierowanie do PayU."
|
43 |
-
"Accept PayU order","Akceptuj zamówienie PayU"
|
44 |
-
"Cancel PayU order","Anuluj zamówienie PayU"
|
45 |
-
"Complete PayU payment","Akceptuj płatność PayU"
|
46 |
-
"Cancel PayU payment","Anuluj płatność PayU"
|
47 |
-
"Order Validity Time","Czas ważności zamówienia"
|
48 |
-
"More info on","Więcej informacji na"
|
49 |
-
"The order is awaiting for cancelation in PayU, please wait while status changes.","Zamówienie jest w trakcie anulowania w PayU, proszę czekać na zmianę statusu w sklepie."
|
50 |
-
"There was a problem while canceling the order in PayU.","Wystąpił błąd podczas próby anulowania zamówienia w PayU."
|
51 |
-
"There was a problem while rejecting the order in PayU.","Wystąpił błąd podczas próby anulowania zamówienia w PayU."
|
52 |
-
"The order is completing in PayU, please wait while status changes.","Zamówienie jest w trakcie zmiany na zakończone w PayU, proszę czekać na zmianę statusu w sklepie."
|
53 |
-
"There was a problem while completing the order in PayU.","Wystąpił błąd podczas próby zakończenia zamówienia w PayU."
|
54 |
-
"CAUTION: PayU plugin is not up to date.","UWAGA: Plugin PayU nie jest aktualny."
|
55 |
-
"OK: PayU account plugin is up to date.","OK: Plugin konto PayU jest aktualny."
|
56 |
-
"The latest version of PayU plugin is","Najnowszą wersją pluginu PayU jest"
|
57 |
-
"PayU plugin information","Informacje o wtyczce PayU"
|
58 |
-
"Important: This plugin works only with Checkout points of sales (POS).","Ważne: Plugin działa tylko z POS-ami typu Checkout."
|
59 |
-
"Point of Sale identifier","Identyfikator punktu płatności"
|
60 |
-
"Signature key (MD5)","Klucz sygnatury (MD5)"
|
61 |
-
"Second key (MD5)","Drugi klucz (MD5)"
|
62 |
-
"Order # ","Zamówienie # "
|
63 |
-
"Shipping costs","Dostawa i koszty manipulacyjne"
|
64 |
-
"The transaction completed successfully in PayU.","Transakcja zakończona pomyślnie w PayU."
|
65 |
-
"Pay by link","Szybki przelew"
|
66 |
-
"Pay with card","Płatność kartą"
|
1 |
+
"PayU","PayU"
|
2 |
+
"Enable plugin?","Czy włączyć wtyczkę?"
|
3 |
"Main parameters","Główne parametry"
|
4 |
+
"POS parameters","Parametry punktu płatności (POS)"
|
|
|
|
|
|
|
|
|
5 |
"POS ID (pos_id)","Id punktu płatności (pos_id)"
|
6 |
+
"Point of Sale identifier","Identyfikator punktu płatności"
|
7 |
+
"Second key (MD5)","Drugi klucz (MD5)"
|
|
|
8 |
"OAuth protocol - client_id","Protokół OAuth - client_id"
|
9 |
"OAuth protocol - client_secret","Protokół OAuth - client_secret"
|
10 |
"Symmetrical key for encrypting communication","Symetryczny klucz do szyfrowania komunikacji"
|
11 |
+
"PayU Plugin Information","Informacja o wtyczce PayU"
|
|
|
|
|
|
|
|
|
12 |
"You are currently using version","Aktualnie zainstalowana wersja"
|
13 |
"for","dla"
|
|
|
|
|
|
|
|
|
14 |
"Yes","Tak"
|
15 |
"No","Nie"
|
16 |
+
"Important: This plugin works only with REST (Checkout) points of sales (POS).","WAŻNE: Plugin działa tylko z POS-ami typu REST (Checkout)."
|
17 |
+
"Pay with PayU","Zapłać przez PayU"
|
18 |
+
"Order #%s","Zamówienie #%s"
|
19 |
+
"Discount","Rabat"
|
20 |
+
"Shipping","Dostawa"
|
21 |
+
"No order for processing found","Brak zamówienia do przetwarzania"
|
22 |
+
"New transaction started.","Nowa Transakcjat została rozpoczęta"
|
23 |
"The transaction has been canceled.","Transakcja została anulowana."
|
24 |
+
"The transaction is to be accepted or rejected.","Transakcja może być zaakceptowana lub odrzucona."
|
25 |
+
"The transaction completed successfully.","Transakcja zakończona pomyślnie."
|
26 |
+
"There was a problem with the payment initialization - "%s", please contact system administrator.","Wystąpił problem podczas inicjalizacji płatności - %s, prosimy o kontakt z obsługą sklepu."
|
27 |
+
"Refund for order: %s","Zwrot do zamówienia %s"
|
28 |
+
"Payu refund - amount: %s, status: %s","Zwrot Payu - kwota: %s, status: %s"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/PayU/Cache/.htaccess
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
order deny,allow
|
2 |
+
deny from all
|
lib/PayU/Cache/810290d4eed883975e0cd43d80497ac4
ADDED
Binary file
|
lib/PayU/Cache/index.php
ADDED
File without changes
|
lib/PayU/OpenPayU/AuthType/AuthType.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
interface AuthType
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* @return array
|
8 |
+
*/
|
9 |
+
public function getHeaders();
|
10 |
+
|
11 |
+
|
12 |
+
}
|
lib/PayU/OpenPayU/AuthType/Basic.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class AuthType_Basic implements AuthType
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* @var string
|
8 |
+
*/
|
9 |
+
private $authBasicToken;
|
10 |
+
|
11 |
+
public function __construct($posId, $signatureKey)
|
12 |
+
{
|
13 |
+
if (empty($posId)) {
|
14 |
+
throw new OpenPayU_Exception_Configuration('PosId is empty');
|
15 |
+
}
|
16 |
+
|
17 |
+
if (empty($signatureKey)) {
|
18 |
+
throw new OpenPayU_Exception_Configuration('SignatureKey is empty');
|
19 |
+
}
|
20 |
+
|
21 |
+
$this->authBasicToken = base64_encode($posId . ':' . $signatureKey);
|
22 |
+
}
|
23 |
+
|
24 |
+
public function getHeaders()
|
25 |
+
{
|
26 |
+
return array(
|
27 |
+
'Content-Type: application/json',
|
28 |
+
'Accept: application/json',
|
29 |
+
'Authorization: Basic ' . $this->authBasicToken
|
30 |
+
);
|
31 |
+
}
|
32 |
+
|
33 |
+
}
|
lib/PayU/OpenPayU/AuthType/Oauth.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class AuthType_Oauth implements AuthType
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* @var OauthResultClientCredentials
|
8 |
+
*/
|
9 |
+
private $oauthResult;
|
10 |
+
|
11 |
+
public function __construct($clientId, $clientSecret)
|
12 |
+
{
|
13 |
+
if (empty($clientId)) {
|
14 |
+
throw new OpenPayU_Exception_Configuration('ClientId is empty');
|
15 |
+
}
|
16 |
+
|
17 |
+
if (empty($clientSecret)) {
|
18 |
+
throw new OpenPayU_Exception_Configuration('ClientSecret is empty');
|
19 |
+
}
|
20 |
+
|
21 |
+
try {
|
22 |
+
$this->oauthResult = OpenPayU_Oauth::getAccessToken();
|
23 |
+
} catch (OpenPayU_Exception $e) {
|
24 |
+
throw new OpenPayU_Exception('Oauth error: [code=' . $e->getCode() . '], [message=' . $e->getMessage() . ']');
|
25 |
+
}
|
26 |
+
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
public function getHeaders()
|
31 |
+
{
|
32 |
+
return array(
|
33 |
+
'Content-Type: application/json',
|
34 |
+
'Accept: */*',
|
35 |
+
'Authorization: Bearer ' . $this->oauthResult->getAccessToken()
|
36 |
+
);
|
37 |
+
}
|
38 |
+
|
39 |
+
}
|
lib/PayU/OpenPayU/AuthType/TokenRequest.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class AuthType_TokenRequest implements AuthType
|
4 |
+
{
|
5 |
+
|
6 |
+
public function getHeaders()
|
7 |
+
{
|
8 |
+
return array(
|
9 |
+
'Content-Type: application/x-www-form-urlencoded',
|
10 |
+
'Accept: */*'
|
11 |
+
);
|
12 |
+
}
|
13 |
+
|
14 |
+
}
|
lib/PayU/OpenPayU/Configuration.php
ADDED
@@ -0,0 +1,270 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* OpenPayU Standard Library
|
5 |
+
*
|
6 |
+
* @copyright Copyright (c) 2011-2016 PayU
|
7 |
+
* @license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
8 |
+
* http://www.payu.com
|
9 |
+
* http://developers.payu.com
|
10 |
+
*/
|
11 |
+
class OpenPayU_Configuration
|
12 |
+
{
|
13 |
+
private static $_availableEnvironment = array('custom', 'secure');
|
14 |
+
private static $_availableHashAlgorithm = array('SHA', 'SHA-256', 'SHA-384', 'SHA-512');
|
15 |
+
|
16 |
+
private static $env = 'secure';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Merchant Pos ID for Auth Basic and Notification Consume
|
20 |
+
*/
|
21 |
+
private static $merchantPosId = '';
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Signature Key for Auth Basic and Notification Consume
|
25 |
+
*/
|
26 |
+
private static $signatureKey = '';
|
27 |
+
|
28 |
+
/**
|
29 |
+
* OAuth protocol - client_id
|
30 |
+
*/
|
31 |
+
private static $oauthClientId = '';
|
32 |
+
|
33 |
+
/**
|
34 |
+
* OAuth protocol - client_secret
|
35 |
+
*/
|
36 |
+
private static $oauthClientSecret = '';
|
37 |
+
|
38 |
+
/**
|
39 |
+
* OAuth protocol - endpoint address
|
40 |
+
*/
|
41 |
+
private static $oauthEndpoint = '';
|
42 |
+
|
43 |
+
/**
|
44 |
+
* OAuth protocol - methods for token cache
|
45 |
+
*/
|
46 |
+
private static $oauthTokenCache = null;
|
47 |
+
|
48 |
+
private static $serviceUrl = '';
|
49 |
+
private static $hashAlgorithm = 'SHA-256';
|
50 |
+
|
51 |
+
private static $sender = 'Generic';
|
52 |
+
|
53 |
+
const API_VERSION = '2.1';
|
54 |
+
const COMPOSER_JSON = "/composer.json";
|
55 |
+
const DEFAULT_SDK_VERSION = 'PHP SDK 2.2.2';
|
56 |
+
const OAUTH_CONTEXT = 'pl/standard/user/oauth/authorize';
|
57 |
+
|
58 |
+
/**
|
59 |
+
* @return string
|
60 |
+
*/
|
61 |
+
public static function getApiVersion()
|
62 |
+
{
|
63 |
+
return self::API_VERSION;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* @param string
|
68 |
+
* @throws OpenPayU_Exception_Configuration
|
69 |
+
*/
|
70 |
+
public static function setHashAlgorithm($value)
|
71 |
+
{
|
72 |
+
if (!in_array($value, self::$_availableHashAlgorithm)) {
|
73 |
+
throw new OpenPayU_Exception_Configuration('Hash algorithm "' . $value . '"" is not available');
|
74 |
+
}
|
75 |
+
|
76 |
+
self::$hashAlgorithm = $value;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* @return string
|
81 |
+
*/
|
82 |
+
public static function getHashAlgorithm()
|
83 |
+
{
|
84 |
+
return self::$hashAlgorithm;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @param string $environment
|
89 |
+
* @param string $domain
|
90 |
+
* @param string $api
|
91 |
+
* @param string $version
|
92 |
+
* @throws OpenPayU_Exception_Configuration
|
93 |
+
*/
|
94 |
+
public static function setEnvironment($environment = 'secure', $domain = 'payu.com', $api = 'api/', $version = 'v2_1/')
|
95 |
+
{
|
96 |
+
$environment = strtolower($environment);
|
97 |
+
$domain = strtolower($domain) . '/';
|
98 |
+
|
99 |
+
if (!in_array($environment, self::$_availableEnvironment)) {
|
100 |
+
throw new OpenPayU_Exception_Configuration($environment . ' - is not valid environment');
|
101 |
+
}
|
102 |
+
|
103 |
+
if ($environment == 'secure') {
|
104 |
+
self::$env = $environment;
|
105 |
+
self::$serviceUrl = 'https://' . $environment . '.' . $domain . $api . $version;
|
106 |
+
self::$oauthEndpoint = 'https://' . $environment . '.' . $domain . self::OAUTH_CONTEXT;
|
107 |
+
} else if ($environment == 'custom') {
|
108 |
+
self::$env = $environment;
|
109 |
+
self::$serviceUrl = $domain . $api . $version;
|
110 |
+
self::$oauthEndpoint = $domain . self::OAUTH_CONTEXT;
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* @return string
|
116 |
+
*/
|
117 |
+
public static function getServiceUrl()
|
118 |
+
{
|
119 |
+
return self::$serviceUrl;
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* @return string
|
124 |
+
*/
|
125 |
+
public static function getOauthEndpoint()
|
126 |
+
{
|
127 |
+
return self::$oauthEndpoint;
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* @return string
|
132 |
+
*/
|
133 |
+
public static function getEnvironment()
|
134 |
+
{
|
135 |
+
return self::$env;
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* @param string
|
140 |
+
*/
|
141 |
+
public static function setMerchantPosId($value)
|
142 |
+
{
|
143 |
+
self::$merchantPosId = trim($value);
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* @return string
|
148 |
+
*/
|
149 |
+
public static function getMerchantPosId()
|
150 |
+
{
|
151 |
+
return self::$merchantPosId;
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* @param string
|
156 |
+
*/
|
157 |
+
public static function setSignatureKey($value)
|
158 |
+
{
|
159 |
+
self::$signatureKey = trim($value);
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* @return string
|
164 |
+
*/
|
165 |
+
public static function getSignatureKey()
|
166 |
+
{
|
167 |
+
return self::$signatureKey;
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* @return string
|
172 |
+
*/
|
173 |
+
public static function getOauthClientId()
|
174 |
+
{
|
175 |
+
return self::$oauthClientId;
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* @return string
|
180 |
+
*/
|
181 |
+
public static function getOauthClientSecret()
|
182 |
+
{
|
183 |
+
return self::$oauthClientSecret;
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* @param mixed $oauthClientId
|
188 |
+
*/
|
189 |
+
public static function setOauthClientId($oauthClientId)
|
190 |
+
{
|
191 |
+
self::$oauthClientId = $oauthClientId;
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* @param mixed $oauthClientSecret
|
196 |
+
*/
|
197 |
+
public static function setOauthClientSecret($oauthClientSecret)
|
198 |
+
{
|
199 |
+
self::$oauthClientSecret = $oauthClientSecret;
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* @return null | OauthCacheInterface
|
204 |
+
*/
|
205 |
+
public static function getOauthTokenCache()
|
206 |
+
{
|
207 |
+
return self::$oauthTokenCache;
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* @param OauthCacheInterface $oauthTokenCache
|
212 |
+
* @throws OpenPayU_Exception_Configuration
|
213 |
+
*/
|
214 |
+
public static function setOauthTokenCache($oauthTokenCache)
|
215 |
+
{
|
216 |
+
if (!$oauthTokenCache instanceof OauthCacheInterface) {
|
217 |
+
throw new OpenPayU_Exception_Configuration('Oauth token cache class is not instance of OauthCacheInterface');
|
218 |
+
}
|
219 |
+
self::$oauthTokenCache = $oauthTokenCache;
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* @param string $sender
|
224 |
+
*/
|
225 |
+
public static function setSender($sender)
|
226 |
+
{
|
227 |
+
self::$sender = $sender;
|
228 |
+
}
|
229 |
+
|
230 |
+
/**
|
231 |
+
* @return string
|
232 |
+
*/
|
233 |
+
public static function getSender()
|
234 |
+
{
|
235 |
+
return self::$sender;
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* @return string
|
240 |
+
*/
|
241 |
+
public static function getFullSenderName()
|
242 |
+
{
|
243 |
+
return sprintf("%s@%s", self::getSender(), self::getSdkVersion());
|
244 |
+
}
|
245 |
+
|
246 |
+
/**
|
247 |
+
* @return string
|
248 |
+
*/
|
249 |
+
public static function getSdkVersion()
|
250 |
+
{
|
251 |
+
$composerFilePath = self::getComposerFilePath();
|
252 |
+
if (file_exists($composerFilePath)) {
|
253 |
+
$fileContent = file_get_contents($composerFilePath);
|
254 |
+
$composerData = json_decode($fileContent);
|
255 |
+
if (isset($composerData->version) && isset($composerData->extra[0]->engine)) {
|
256 |
+
return sprintf("%s %s", $composerData->extra[0]->engine, $composerData->version);
|
257 |
+
}
|
258 |
+
}
|
259 |
+
|
260 |
+
return self::DEFAULT_SDK_VERSION;
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
* @return string
|
265 |
+
*/
|
266 |
+
private static function getComposerFilePath()
|
267 |
+
{
|
268 |
+
return realpath(dirname(__FILE__)) . '/../../' . self::COMPOSER_JSON;
|
269 |
+
}
|
270 |
+
}
|
lib/PayU/OpenPayU/Http.php
ADDED
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* OpenPayU Standard Library
|
4 |
+
*
|
5 |
+
* @copyright Copyright (c) 2011-2016 PayU
|
6 |
+
* @license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
7 |
+
* http://www.payu.com
|
8 |
+
* http://developers.payu.com
|
9 |
+
*/
|
10 |
+
|
11 |
+
class OpenPayU_Http
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @param string $pathUrl
|
16 |
+
* @param string $data
|
17 |
+
* @param AuthType $authType
|
18 |
+
* @return mixed
|
19 |
+
* @throws OpenPayU_Exception_Configuration
|
20 |
+
* @throws OpenPayU_Exception_Network
|
21 |
+
*/
|
22 |
+
public static function doPost($pathUrl, $data, $authType)
|
23 |
+
{
|
24 |
+
$response = OpenPayU_HttpCurl::doPayuRequest('POST', $pathUrl, $authType, $data);
|
25 |
+
|
26 |
+
return $response;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @param string $pathUrl
|
31 |
+
* @param AuthType $authType
|
32 |
+
* @return mixed
|
33 |
+
* @throws OpenPayU_Exception_Configuration
|
34 |
+
* @throws OpenPayU_Exception_Network
|
35 |
+
*/
|
36 |
+
public static function doGet($pathUrl, $authType)
|
37 |
+
{
|
38 |
+
$response = OpenPayU_HttpCurl::doPayuRequest('GET', $pathUrl, $authType);
|
39 |
+
|
40 |
+
return $response;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @param string $pathUrl
|
45 |
+
* @param AuthType $authType
|
46 |
+
* @return mixed
|
47 |
+
* @throws OpenPayU_Exception_Configuration
|
48 |
+
* @throws OpenPayU_Exception_Network
|
49 |
+
*/
|
50 |
+
public static function doDelete($pathUrl, $authType)
|
51 |
+
{
|
52 |
+
$response = OpenPayU_HttpCurl::doPayuRequest('DELETE', $pathUrl, $authType);
|
53 |
+
|
54 |
+
return $response;
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* @param string $pathUrl
|
59 |
+
* @param string $data
|
60 |
+
* @param AuthType $authType
|
61 |
+
* @return mixed
|
62 |
+
* @throws OpenPayU_Exception_Configuration
|
63 |
+
* @throws OpenPayU_Exception_Network
|
64 |
+
*/
|
65 |
+
public static function doPut($pathUrl, $data, $authType)
|
66 |
+
{
|
67 |
+
$response = OpenPayU_HttpCurl::doPayuRequest('PUT', $pathUrl, $authType, $data);
|
68 |
+
|
69 |
+
return $response;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @param $statusCode
|
74 |
+
* @param null $message
|
75 |
+
* @throws OpenPayU_Exception
|
76 |
+
* @throws OpenPayU_Exception_Authorization
|
77 |
+
* @throws OpenPayU_Exception_Network
|
78 |
+
* @throws OpenPayU_Exception_ServerMaintenance
|
79 |
+
* @throws OpenPayU_Exception_ServerError
|
80 |
+
*/
|
81 |
+
public static function throwHttpStatusException($statusCode, $message = null)
|
82 |
+
{
|
83 |
+
|
84 |
+
$response = $message->getResponse();
|
85 |
+
$statusDesc = ($response->status && $response->status->statusDesc) ? $response->status->statusDesc : '';
|
86 |
+
|
87 |
+
switch ($statusCode) {
|
88 |
+
case 400:
|
89 |
+
throw new OpenPayU_Exception($message->getStatus().' - '.$statusDesc, $statusCode);
|
90 |
+
break;
|
91 |
+
|
92 |
+
case 401:
|
93 |
+
case 403:
|
94 |
+
throw new OpenPayU_Exception_Authorization($message->getStatus().' - '.$statusDesc, $statusCode);
|
95 |
+
break;
|
96 |
+
|
97 |
+
case 404:
|
98 |
+
throw new OpenPayU_Exception_Network($message->getStatus().' - '.$statusDesc, $statusCode);
|
99 |
+
break;
|
100 |
+
|
101 |
+
case 408:
|
102 |
+
throw new OpenPayU_Exception_ServerError('Request timeout', $statusCode);
|
103 |
+
break;
|
104 |
+
|
105 |
+
case 500:
|
106 |
+
throw new OpenPayU_Exception_ServerError('PayU system is unavailable or your order is not processed.
|
107 |
+
Error:
|
108 |
+
[' . $statusDesc . ']', $statusCode);
|
109 |
+
break;
|
110 |
+
|
111 |
+
case 503:
|
112 |
+
throw new OpenPayU_Exception_ServerMaintenance('Service unavailable', $statusCode);
|
113 |
+
break;
|
114 |
+
|
115 |
+
default:
|
116 |
+
throw new OpenPayU_Exception_Network('Unexpected HTTP code response', $statusCode);
|
117 |
+
break;
|
118 |
+
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* @param $statusCode
|
124 |
+
* @param ResultError $resultError
|
125 |
+
* @throws OpenPayU_Exception
|
126 |
+
* @throws OpenPayU_Exception_Authorization
|
127 |
+
* @throws OpenPayU_Exception_Network
|
128 |
+
* @throws OpenPayU_Exception_ServerError
|
129 |
+
* @throws OpenPayU_Exception_ServerMaintenance
|
130 |
+
*/
|
131 |
+
public static function throwErrorHttpStatusException($statusCode, $resultError)
|
132 |
+
{
|
133 |
+
switch ($statusCode) {
|
134 |
+
case 400:
|
135 |
+
throw new OpenPayU_Exception($resultError->getError().' - '.$resultError->getErrorDescription(), $statusCode);
|
136 |
+
break;
|
137 |
+
|
138 |
+
case 401:
|
139 |
+
case 403:
|
140 |
+
throw new OpenPayU_Exception_Authorization($resultError->getError().' - '.$resultError->getErrorDescription(), $statusCode);
|
141 |
+
break;
|
142 |
+
|
143 |
+
case 404:
|
144 |
+
throw new OpenPayU_Exception_Network($resultError->getError().' - '.$resultError->getErrorDescription(), $statusCode);
|
145 |
+
break;
|
146 |
+
|
147 |
+
case 408:
|
148 |
+
throw new OpenPayU_Exception_ServerError('Request timeout', $statusCode);
|
149 |
+
break;
|
150 |
+
|
151 |
+
case 500:
|
152 |
+
throw new OpenPayU_Exception_ServerError('PayU system is unavailable. Error: [' . $resultError->getErrorDescription() . ']', $resultError);
|
153 |
+
break;
|
154 |
+
|
155 |
+
case 503:
|
156 |
+
throw new OpenPayU_Exception_ServerMaintenance('Service unavailable', $statusCode);
|
157 |
+
break;
|
158 |
+
|
159 |
+
default:
|
160 |
+
throw new OpenPayU_Exception_Network('Unexpected HTTP code response', $statusCode);
|
161 |
+
break;
|
162 |
+
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
}
|
lib/{payu/sdk_v21 → PayU}/OpenPayU/HttpCurl.php
RENAMED
@@ -1,14 +1,14 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
-
* @copyright Copyright (c)
|
6 |
* @license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
7 |
* http://www.payu.com
|
8 |
* http://developers.payu.com
|
9 |
-
* http://twitter.com/openpayu
|
10 |
*/
|
11 |
-
|
|
|
12 |
{
|
13 |
/**
|
14 |
* @var
|
@@ -19,64 +19,46 @@ class OpenPayU_HttpCurl implements OpenPayU_HttpProtocol
|
|
19 |
* @param $requestType
|
20 |
* @param $pathUrl
|
21 |
* @param $data
|
22 |
-
* @param $
|
23 |
-
* @return
|
24 |
* @throws OpenPayU_Exception_Configuration
|
25 |
* @throws OpenPayU_Exception_Network
|
26 |
-
* @throws OpenPayU_Exception_Authorization
|
27 |
*/
|
28 |
-
public static function
|
29 |
{
|
30 |
-
if (empty($pathUrl))
|
31 |
-
throw new OpenPayU_Exception_Configuration('The
|
32 |
-
|
33 |
-
if (empty($posId)) {
|
34 |
-
throw new OpenPayU_Exception_Configuration('PosId is empty');
|
35 |
}
|
36 |
|
37 |
-
|
38 |
-
throw new OpenPayU_Exception_Configuration('SignatureKey is empty');
|
39 |
-
}
|
40 |
-
|
41 |
-
$userNameAndPassword = $posId.":".$signatureKey;
|
42 |
-
|
43 |
-
$header = array();
|
44 |
-
|
45 |
-
if(OpenPayU_Configuration::getApiVersion() >= 2)
|
46 |
-
{
|
47 |
-
$header[] = 'Content-Type:application/json';
|
48 |
-
$header[] = 'Accept:application/json';
|
49 |
-
}
|
50 |
-
|
51 |
-
$ch = curl_init();
|
52 |
-
curl_setopt($ch, CURLOPT_URL, $pathUrl);
|
53 |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $requestType);
|
54 |
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
|
55 |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
|
56 |
curl_setopt($ch, CURLOPT_HEADER, false);
|
57 |
-
curl_setopt($ch, CURLOPT_HTTPHEADER, $
|
58 |
curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'OpenPayU_HttpCurl::readHeader');
|
59 |
-
|
|
|
|
|
60 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
61 |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
62 |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
63 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
64 |
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
|
65 |
-
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
66 |
-
curl_setopt($ch, CURLOPT_USERPWD, $userNameAndPassword);
|
67 |
|
68 |
$response = curl_exec($ch);
|
69 |
$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
70 |
-
if($response === false)
|
71 |
-
throw new OpenPayU_Exception_Network(curl_error($ch));
|
72 |
|
|
|
|
|
|
|
73 |
curl_close($ch);
|
74 |
|
75 |
return array('code' => $httpStatus, 'response' => trim($response));
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
-
* @param $headers
|
80 |
*
|
81 |
* @return mixed
|
82 |
*/
|
@@ -87,11 +69,13 @@ class OpenPayU_HttpCurl implements OpenPayU_HttpProtocol
|
|
87 |
if(preg_match('/X-OpenPayU-Signature/i', $name) || preg_match('/OpenPayu-Signature/i', $name))
|
88 |
return $value;
|
89 |
}
|
|
|
|
|
90 |
}
|
91 |
|
92 |
/**
|
93 |
-
* @param $ch
|
94 |
-
* @param $header
|
95 |
* @return int
|
96 |
*/
|
97 |
public static function readHeader($ch, $header)
|
@@ -103,19 +87,4 @@ class OpenPayU_HttpCurl implements OpenPayU_HttpProtocol
|
|
103 |
return strlen($header);
|
104 |
}
|
105 |
|
106 |
-
/**
|
107 |
-
* @param $headers
|
108 |
-
*/
|
109 |
-
public static function setHeaders($headers)
|
110 |
-
{
|
111 |
-
self::$headers = $headers;
|
112 |
-
}
|
113 |
-
|
114 |
-
/**
|
115 |
-
* @return mixed
|
116 |
-
*/
|
117 |
-
public static function getHeader()
|
118 |
-
{
|
119 |
-
return self::$headers;
|
120 |
-
}
|
121 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* OpenPayU Standard Library
|
4 |
*
|
5 |
+
* @copyright Copyright (c) 2011-2016 PayU
|
6 |
* @license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
7 |
* http://www.payu.com
|
8 |
* http://developers.payu.com
|
|
|
9 |
*/
|
10 |
+
|
11 |
+
class OpenPayU_HttpCurl
|
12 |
{
|
13 |
/**
|
14 |
* @var
|
19 |
* @param $requestType
|
20 |
* @param $pathUrl
|
21 |
* @param $data
|
22 |
+
* @param AuthType $auth
|
23 |
+
* @return array
|
24 |
* @throws OpenPayU_Exception_Configuration
|
25 |
* @throws OpenPayU_Exception_Network
|
|
|
26 |
*/
|
27 |
+
public static function doPayuRequest($requestType, $pathUrl, $auth, $data = null)
|
28 |
{
|
29 |
+
if (empty($pathUrl)) {
|
30 |
+
throw new OpenPayU_Exception_Configuration('The endpoint is empty');
|
|
|
|
|
|
|
31 |
}
|
32 |
|
33 |
+
$ch = curl_init($pathUrl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $requestType);
|
35 |
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
|
36 |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
|
37 |
curl_setopt($ch, CURLOPT_HEADER, false);
|
38 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, $auth->getHeaders());
|
39 |
curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'OpenPayU_HttpCurl::readHeader');
|
40 |
+
if ($data) {
|
41 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
42 |
+
}
|
43 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
44 |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
45 |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
46 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
47 |
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
|
|
|
|
|
48 |
|
49 |
$response = curl_exec($ch);
|
50 |
$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
|
|
|
51 |
|
52 |
+
if($response === false) {
|
53 |
+
throw new OpenPayU_Exception_Network(curl_error($ch));
|
54 |
+
}
|
55 |
curl_close($ch);
|
56 |
|
57 |
return array('code' => $httpStatus, 'response' => trim($response));
|
58 |
}
|
59 |
|
60 |
/**
|
61 |
+
* @param array $headers
|
62 |
*
|
63 |
* @return mixed
|
64 |
*/
|
69 |
if(preg_match('/X-OpenPayU-Signature/i', $name) || preg_match('/OpenPayu-Signature/i', $name))
|
70 |
return $value;
|
71 |
}
|
72 |
+
|
73 |
+
return null;
|
74 |
}
|
75 |
|
76 |
/**
|
77 |
+
* @param resource $ch
|
78 |
+
* @param string $header
|
79 |
* @return int
|
80 |
*/
|
81 |
public static function readHeader($ch, $header)
|
87 |
return strlen($header);
|
88 |
}
|
89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
}
|
lib/PayU/OpenPayU/Oauth/Cache/OauthCacheFile.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class OauthCacheFile implements OauthCacheInterface
|
4 |
+
{
|
5 |
+
private $directory;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* @param string $directory
|
9 |
+
* @throws OpenPayU_Exception_Configuration
|
10 |
+
*/
|
11 |
+
public function __construct($directory = null)
|
12 |
+
{
|
13 |
+
if ($directory === null) {
|
14 |
+
$directory = dirname(__FILE__).'/../../../Cache';
|
15 |
+
}
|
16 |
+
|
17 |
+
if (!is_dir($directory) || !is_writable($directory)) {
|
18 |
+
throw new OpenPayU_Exception_Configuration('Cache directory [' . $directory . '] not exist or not writable.');
|
19 |
+
}
|
20 |
+
|
21 |
+
$this->directory = $directory . (substr($directory, -1) != '/' ? '/' : '');
|
22 |
+
}
|
23 |
+
|
24 |
+
public function get($key)
|
25 |
+
{
|
26 |
+
$cache = @file_get_contents($this->directory . md5($key));
|
27 |
+
return $cache === false ? null : unserialize($cache);
|
28 |
+
}
|
29 |
+
|
30 |
+
public function set($key, $value)
|
31 |
+
{
|
32 |
+
return @file_put_contents($this->directory . md5($key), serialize($value));
|
33 |
+
}
|
34 |
+
|
35 |
+
public function invalidate($key)
|
36 |
+
{
|
37 |
+
return @unlink($this->directory . md5($key));
|
38 |
+
}
|
39 |
+
|
40 |
+
}
|
lib/PayU/OpenPayU/Oauth/Cache/OauthCacheInterface.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
interface OauthCacheInterface
|
5 |
+
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
* @param string $key
|
9 |
+
* @return null | object
|
10 |
+
*/
|
11 |
+
public function get($key);
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @param string $key
|
15 |
+
* @param object $value
|
16 |
+
* @return bool
|
17 |
+
*/
|
18 |
+
public function set($key, $value);
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @param string $key
|
22 |
+
* @return bool
|
23 |
+
*/
|
24 |
+
public function invalidate($key);
|
25 |
+
|
26 |
+
}
|
lib/PayU/OpenPayU/Oauth/Cache/OauthCacheMemcached.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class OauthCacheMemcached implements OauthCacheInterface
|
4 |
+
{
|
5 |
+
private $memcached;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* @param string $host
|
9 |
+
* @param int $port
|
10 |
+
* @param int $weight
|
11 |
+
* @throws OpenPayU_Exception_Configuration
|
12 |
+
*/
|
13 |
+
public function __construct($host = 'localhost', $port = 11211, $weight = 0)
|
14 |
+
{
|
15 |
+
if (!class_exists('Memcached')) {
|
16 |
+
throw new OpenPayU_Exception_Configuration('PHP Memcached extension not installed.');
|
17 |
+
}
|
18 |
+
|
19 |
+
$this->memcached = new Memcached('PayU');
|
20 |
+
$this->memcached->addServer($host, $port, $weight);
|
21 |
+
$stats = $this->memcached->getStats();
|
22 |
+
if ($stats[$host . ':' . $port]['pid'] == -1) {
|
23 |
+
throw new OpenPayU_Exception_Configuration('Problem with connection to memcached server [host=' . $host . '] [port=' . $port . '] [weight=' . $weight . ']');
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
public function get($key)
|
28 |
+
{
|
29 |
+
$cache = $this->memcached->get($key);
|
30 |
+
return $cache === false ? null : unserialize($cache);
|
31 |
+
}
|
32 |
+
|
33 |
+
public function set($key, $value)
|
34 |
+
{
|
35 |
+
return $this->memcached->set($key, serialize($value));
|
36 |
+
}
|
37 |
+
|
38 |
+
public function invalidate($key)
|
39 |
+
{
|
40 |
+
return $this->memcached->delete($key);
|
41 |
+
}
|
42 |
+
|
43 |
+
}
|
lib/PayU/OpenPayU/Oauth/Oauth.php
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class OpenPayU_Oauth
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* @var OauthCacheInterface
|
7 |
+
*/
|
8 |
+
private static $oauthTokenCache;
|
9 |
+
|
10 |
+
const CACHE_KEY = 'AccessToken';
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @param string $clientId
|
14 |
+
* @param string $clientSecret
|
15 |
+
* @return OauthResultClientCredentials
|
16 |
+
* @throws OpenPayU_Exception_ServerError
|
17 |
+
*/
|
18 |
+
public static function getAccessToken($clientId = null, $clientSecret = null)
|
19 |
+
{
|
20 |
+
$cacheKey = self::CACHE_KEY . OpenPayU_Configuration::getOauthClientId();
|
21 |
+
|
22 |
+
self::getOauthTokenCache();
|
23 |
+
|
24 |
+
$tokenCache = self::$oauthTokenCache->get($cacheKey);
|
25 |
+
|
26 |
+
if ($tokenCache instanceof OauthResultClientCredentials && !$tokenCache->hasExpire()) {
|
27 |
+
return $tokenCache;
|
28 |
+
}
|
29 |
+
|
30 |
+
self::$oauthTokenCache->invalidate($cacheKey);
|
31 |
+
|
32 |
+
$authType = new AuthType_TokenRequest();
|
33 |
+
|
34 |
+
$oauthUrl = OpenPayU_Configuration::getOauthEndpoint();
|
35 |
+
$data = array(
|
36 |
+
'grant_type' => OauthGrantType::CLIENT_CREDENTIAL,
|
37 |
+
'client_id' => $clientId ? $clientId : OpenPayU_Configuration::getOauthClientId(),
|
38 |
+
'client_secret' => $clientSecret ? $clientSecret : OpenPayU_Configuration::getOauthClientSecret()
|
39 |
+
);
|
40 |
+
|
41 |
+
$response = self::parseResponse(OpenPayU_Http::doPost($oauthUrl, http_build_query($data), $authType));
|
42 |
+
|
43 |
+
self::$oauthTokenCache->set($cacheKey, $response);
|
44 |
+
|
45 |
+
return $response;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Parse response from PayU
|
50 |
+
*
|
51 |
+
* @param array $response
|
52 |
+
* @return OauthResultClientCredentials
|
53 |
+
* @throws OpenPayU_Exception
|
54 |
+
* @throws OpenPayU_Exception_Authorization
|
55 |
+
* @throws OpenPayU_Exception_Network
|
56 |
+
* @throws OpenPayU_Exception_ServerError
|
57 |
+
* @throws OpenPayU_Exception_ServerMaintenance
|
58 |
+
*/
|
59 |
+
private static function parseResponse($response)
|
60 |
+
{
|
61 |
+
$httpStatus = $response['code'];
|
62 |
+
|
63 |
+
if ($httpStatus == 500) {
|
64 |
+
$result = new ResultError();
|
65 |
+
$result->setErrorDescription($response['response']);
|
66 |
+
OpenPayU_Http::throwErrorHttpStatusException($httpStatus, $result);
|
67 |
+
}
|
68 |
+
|
69 |
+
$message = OpenPayU_Util::convertJsonToArray($response['response'], true);
|
70 |
+
|
71 |
+
if (json_last_error() == JSON_ERROR_SYNTAX) {
|
72 |
+
throw new OpenPayU_Exception_ServerError('Incorrect json response. Response: [' . $response['response'] . ']');
|
73 |
+
}
|
74 |
+
|
75 |
+
if ($httpStatus == 200) {
|
76 |
+
$result = new OauthResultClientCredentials();
|
77 |
+
$result->setAccessToken($message['access_token'])
|
78 |
+
->setTokenType($message['token_type'])
|
79 |
+
->setExpiresIn($message['expires_in'])
|
80 |
+
->setGrantType($message['grant_type'])
|
81 |
+
->calculateExpireDate(new \DateTime());
|
82 |
+
|
83 |
+
return $result;
|
84 |
+
}
|
85 |
+
|
86 |
+
$result = new ResultError();
|
87 |
+
$result->setError($message['error'])
|
88 |
+
->setErrorDescription($message['error_description']);
|
89 |
+
|
90 |
+
OpenPayU_Http::throwErrorHttpStatusException($httpStatus, $result);
|
91 |
+
|
92 |
+
}
|
93 |
+
|
94 |
+
private static function getOauthTokenCache()
|
95 |
+
{
|
96 |
+
$oauthTokenCache = OpenPayU_Configuration::getOauthTokenCache();
|
97 |
+
|
98 |
+
if (!$oauthTokenCache instanceof OauthCacheInterface) {
|
99 |
+
$oauthTokenCache = new OauthCacheFile();
|
100 |
+
OpenPayU_Configuration::setOauthTokenCache($oauthTokenCache);
|
101 |
+
}
|
102 |
+
|
103 |
+
self::$oauthTokenCache = $oauthTokenCache;
|
104 |
+
}
|
105 |
+
}
|
lib/PayU/OpenPayU/Oauth/OauthGrantType.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
abstract class OauthGrantType
|
4 |
+
{
|
5 |
+
const CLIENT_CREDENTIAL = 'client_credentials';
|
6 |
+
}
|
lib/PayU/OpenPayU/Oauth/OauthResultClientCredentials.php
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class OauthResultClientCredentials
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* @var string
|
8 |
+
*/
|
9 |
+
private $accessToken;
|
10 |
+
/**
|
11 |
+
* @var string
|
12 |
+
*/
|
13 |
+
private $tokenType;
|
14 |
+
/**
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
private $expiresIn;
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
private $grantType;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @var DateTime
|
25 |
+
*/
|
26 |
+
private $expireDate;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @return string
|
30 |
+
*/
|
31 |
+
public function getAccessToken()
|
32 |
+
{
|
33 |
+
return $this->accessToken;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @param string $accessToken
|
38 |
+
* @return OauthResultClientCredentials
|
39 |
+
*/
|
40 |
+
public function setAccessToken($accessToken)
|
41 |
+
{
|
42 |
+
$this->accessToken = $accessToken;
|
43 |
+
return $this;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @return string
|
48 |
+
*/
|
49 |
+
public function getTokenType()
|
50 |
+
{
|
51 |
+
return $this->tokenType;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @param string $tokenType
|
56 |
+
* @return OauthResultClientCredentials
|
57 |
+
*/
|
58 |
+
public function setTokenType($tokenType)
|
59 |
+
{
|
60 |
+
$this->tokenType = $tokenType;
|
61 |
+
return $this;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* @return string
|
66 |
+
*/
|
67 |
+
public function getExpiresIn()
|
68 |
+
{
|
69 |
+
return $this->expiresIn;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @param string $expiresIn
|
74 |
+
* @return OauthResultClientCredentials
|
75 |
+
*/
|
76 |
+
public function setExpiresIn($expiresIn)
|
77 |
+
{
|
78 |
+
$this->expiresIn = $expiresIn;
|
79 |
+
return $this;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @return string
|
84 |
+
*/
|
85 |
+
public function getGrantType()
|
86 |
+
{
|
87 |
+
return $this->grantType;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* @param string $grantType
|
92 |
+
* @return OauthResultClientCredentials
|
93 |
+
*/
|
94 |
+
public function setGrantType($grantType)
|
95 |
+
{
|
96 |
+
$this->grantType = $grantType;
|
97 |
+
return $this;
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* @return DateTime
|
102 |
+
*/
|
103 |
+
public function getExpireDate()
|
104 |
+
{
|
105 |
+
return $this->expireDate;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* @param DateTime $date
|
110 |
+
*/
|
111 |
+
public function calculateExpireDate($date)
|
112 |
+
{
|
113 |
+
$this->expireDate = $date->add(new DateInterval('PT' . ($this->expiresIn - 60) . 'S'));
|
114 |
+
}
|
115 |
+
|
116 |
+
public function hasExpire()
|
117 |
+
{
|
118 |
+
return ($this->expireDate <= new DateTime());
|
119 |
+
}
|
120 |
+
|
121 |
+
}
|
lib/PayU/OpenPayU/OpenPayU.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* OpenPayU Standard Library
|
4 |
+
*
|
5 |
+
* @copyright Copyright (c) 2011-2016 PayU
|
6 |
+
* @license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
7 |
+
* http://www.payu.com
|
8 |
+
* http://developers.payu.com
|
9 |
+
*/
|
10 |
+
|
11 |
+
class OpenPayU
|
12 |
+
{
|
13 |
+
protected static function build($data)
|
14 |
+
{
|
15 |
+
$instance = new OpenPayU_Result();
|
16 |
+
$instance->init($data);
|
17 |
+
|
18 |
+
return $instance;
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @param $data
|
23 |
+
* @param $incomingSignature
|
24 |
+
* @throws OpenPayU_Exception_Authorization
|
25 |
+
*/
|
26 |
+
public static function verifyDocumentSignature($data, $incomingSignature)
|
27 |
+
{
|
28 |
+
$sign = OpenPayU_Util::parseSignature($incomingSignature);
|
29 |
+
|
30 |
+
if (false === OpenPayU_Util::verifySignature(
|
31 |
+
$data,
|
32 |
+
$sign->signature,
|
33 |
+
OpenPayU_Configuration::getSignatureKey(),
|
34 |
+
$sign->algorithm)
|
35 |
+
) {
|
36 |
+
throw new OpenPayU_Exception_Authorization('Invalid signature - ' . $sign->signature);
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @return AuthType
|
42 |
+
* @throws OpenPayU_Exception
|
43 |
+
*/
|
44 |
+
protected static function getAuth()
|
45 |
+
{
|
46 |
+
if (OpenPayU_Configuration::getOauthClientId() && OpenPayU_Configuration::getOauthClientSecret()) {
|
47 |
+
$authType = new AuthType_Oauth(OpenPayU_Configuration::getOauthClientId(), OpenPayU_Configuration::getOauthClientSecret());
|
48 |
+
} else {
|
49 |
+
$authType = new AuthType_Basic(OpenPayU_Configuration::getMerchantPosId(), OpenPayU_Configuration::getSignatureKey());
|
50 |
+
}
|
51 |
+
|
52 |
+
return $authType;
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
}
|
lib/PayU/OpenPayU/OpenPayUException.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* OpenPayU Standard Library
|
4 |
+
*
|
5 |
+
* @copyright Copyright (c) 2011-2016 PayU
|
6 |
+
* @license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
7 |
+
* http://www.payu.com
|
8 |
+
* http://developers.payu.com
|
9 |
+
*/
|
10 |
+
|
11 |
+
class OpenPayU_Exception extends \Exception
|
12 |
+
{
|
13 |
+
|
14 |
+
}
|
15 |
+
|
16 |
+
class OpenPayU_Exception_Configuration extends OpenPayU_Exception
|
17 |
+
{
|
18 |
+
|
19 |
+
}
|
20 |
+
|
21 |
+
class OpenPayU_Exception_Network extends OpenPayU_Exception
|
22 |
+
{
|
23 |
+
|
24 |
+
}
|
25 |
+
|
26 |
+
class OpenPayU_Exception_ServerError extends OpenPayU_Exception
|
27 |
+
{
|
28 |
+
|
29 |
+
}
|
30 |
+
|
31 |
+
class OpenPayU_Exception_ServerMaintenance extends OpenPayU_Exception
|
32 |
+
{
|
33 |
+
|
34 |
+
}
|
35 |
+
|
36 |
+
class OpenPayU_Exception_Authorization extends OpenPayU_Exception
|
37 |
+
{
|
38 |
+
|
39 |
+
}
|
lib/PayU/OpenPayU/OpenPayuOrderStatus.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* OpenPayU Standard Library
|
5 |
+
*
|
6 |
+
* @copyright Copyright (c) 2011-2016 PayU
|
7 |
+
* @license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
8 |
+
* http://www.payu.com
|
9 |
+
* http://developers.payu.com
|
10 |
+
*/
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Class OpenPayuOrderStatus
|
14 |
+
*/
|
15 |
+
abstract class OpenPayuOrderStatus
|
16 |
+
{
|
17 |
+
const STATUS_NEW = 'NEW';
|
18 |
+
const STATUS_PENDING = 'PENDING';
|
19 |
+
const STATUS_CANCELED = 'CANCELED';
|
20 |
+
const STATUS_REJECTED = 'REJECTED';
|
21 |
+
const STATUS_COMPLETED = 'COMPLETED';
|
22 |
+
const STATUS_WAITING_FOR_CONFIRMATION = 'WAITING_FOR_CONFIRMATION';
|
23 |
+
|
24 |
+
}
|
lib/{payu/sdk_v21 → PayU}/OpenPayU/Result.php
RENAMED
@@ -1,14 +1,12 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
http://twitter.com/openpayu
|
11 |
-
*/
|
12 |
|
13 |
class OpenPayU_Result
|
14 |
{
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* OpenPayU Standard Library
|
4 |
+
*
|
5 |
+
* @copyright Copyright (c) 2011-2016 PayU
|
6 |
+
* @license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
7 |
+
* http://www.payu.com
|
8 |
+
* http://developers.payu.com
|
9 |
+
*/
|
|
|
|
|
10 |
|
11 |
class OpenPayU_Result
|
12 |
{
|
lib/PayU/OpenPayU/ResultError.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* OpenPayU Standard Library
|
4 |
+
*
|
5 |
+
* @copyright Copyright (c) 2011-2016 PayU
|
6 |
+
* @license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
7 |
+
* http://www.payu.com
|
8 |
+
* http://developers.payu.com
|
9 |
+
*/
|
10 |
+
|
11 |
+
class ResultError
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
private $error;
|
18 |
+
/**
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
private $errorDescription;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @return string
|
25 |
+
*/
|
26 |
+
public function getError()
|
27 |
+
{
|
28 |
+
return $this->error;
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @param string $error
|
33 |
+
* @return ResultError
|
34 |
+
*/
|
35 |
+
public function setError($error)
|
36 |
+
{
|
37 |
+
$this->error = $error;
|
38 |
+
return $this;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @return string
|
43 |
+
*/
|
44 |
+
public function getErrorDescription()
|
45 |
+
{
|
46 |
+
return $this->errorDescription;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* @param string $errorDescription
|
51 |
+
* @return ResultError
|
52 |
+
*/
|
53 |
+
public function setErrorDescription($errorDescription)
|
54 |
+
{
|
55 |
+
$this->errorDescription = $errorDescription;
|
56 |
+
return $this;
|
57 |
+
}
|
58 |
+
|
59 |
+
}
|
lib/{payu/sdk_v21 → PayU}/OpenPayU/Util.php
RENAMED
@@ -1,23 +1,28 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
-
* OpenPayU
|
4 |
*
|
5 |
-
* @copyright Copyright (c)
|
|
|
|
|
|
|
6 |
*/
|
7 |
-
|
8 |
class OpenPayU_Util
|
9 |
{
|
10 |
/**
|
11 |
* Function generate sign data
|
12 |
-
*
|
13 |
-
* @param
|
14 |
* @param string $algorithm
|
15 |
* @param string $merchantPosId
|
16 |
* @param string $signatureKey
|
17 |
-
*
|
|
|
|
|
18 |
* @throws OpenPayU_Exception_Configuration
|
19 |
*/
|
20 |
-
public static function generateSignData($data, $algorithm = 'SHA', $merchantPosId = '', $signatureKey = '')
|
21 |
{
|
22 |
if (empty($signatureKey))
|
23 |
throw new OpenPayU_Exception_Configuration('Merchant Signature Key should not be null or empty.');
|
@@ -25,43 +30,56 @@ class OpenPayU_Util
|
|
25 |
if (empty($merchantPosId))
|
26 |
throw new OpenPayU_Exception_Configuration('MerchantPosId should not be null or empty.');
|
27 |
|
28 |
-
$
|
|
|
29 |
|
30 |
-
$data
|
|
|
|
|
31 |
|
32 |
-
if ($algorithm
|
33 |
-
$
|
34 |
-
} else if (in_array($algorithm, array('SHA', 'SHA1', 'SHA-1'))) {
|
35 |
-
$signature = sha1($data);
|
36 |
-
$algorithm = 'SHA-1';
|
37 |
-
} else if (in_array($algorithm, array('SHA-256', 'SHA256', 'SHA_256'))) {
|
38 |
-
$signature = hash('sha256', $data);
|
39 |
$algorithm = 'SHA-256';
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
}
|
41 |
|
42 |
-
$
|
|
|
|
|
43 |
|
44 |
return $signData;
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
* Function returns signature data object
|
|
|
49 |
* @param string $data
|
|
|
50 |
* @return null|object
|
51 |
*/
|
52 |
public static function parseSignature($data)
|
53 |
{
|
54 |
-
if (empty($data))
|
55 |
return null;
|
|
|
56 |
|
57 |
$signatureData = array();
|
58 |
|
59 |
$list = explode(';', rtrim($data, ';'));
|
60 |
-
if (empty($list))
|
61 |
return null;
|
|
|
62 |
|
63 |
foreach ($list as $value) {
|
64 |
$explode = explode('=', $value);
|
|
|
|
|
|
|
65 |
$signatureData[$explode[0]] = $explode[1];
|
66 |
}
|
67 |
|
@@ -70,10 +88,12 @@ class OpenPayU_Util
|
|
70 |
|
71 |
/**
|
72 |
* Function returns signature validate
|
73 |
-
*
|
74 |
-
* @param $
|
75 |
-
* @param $
|
76 |
-
* @param $
|
|
|
|
|
77 |
* @return bool
|
78 |
*/
|
79 |
public static function verifySignature($message, $signature, $signatureKey, $algorithm = 'MD5')
|
@@ -99,18 +119,21 @@ class OpenPayU_Util
|
|
99 |
|
100 |
/**
|
101 |
* Function builds OpenPayU Json Document
|
102 |
-
*
|
103 |
* @param string $data
|
104 |
* @param string $rootElement
|
105 |
-
*
|
|
|
106 |
*/
|
107 |
public static function buildJsonFromArray($data, $rootElement = '')
|
108 |
{
|
109 |
-
if (!is_array($data))
|
110 |
return null;
|
|
|
111 |
|
112 |
-
if (!empty($rootElement))
|
113 |
$data = array($rootElement => $data);
|
|
|
114 |
|
115 |
$data = self::setSenderProperty($data);
|
116 |
|
@@ -118,113 +141,21 @@ class OpenPayU_Util
|
|
118 |
}
|
119 |
|
120 |
/**
|
121 |
-
* Function builds OpenPayU Xml Document
|
122 |
-
* @access public
|
123 |
* @param string $data
|
124 |
-
* @param string $rootElement
|
125 |
-
* @param string $version
|
126 |
-
* @param string $encoding
|
127 |
-
* @param string $rootElementXsi
|
128 |
-
* @return string $xml
|
129 |
-
*/
|
130 |
-
public static function buildXmlFromArray($data, $rootElement, $version = '1.0', $encoding = 'UTF-8', $rootElementXsi = null)
|
131 |
-
{
|
132 |
-
if (!is_array($data))
|
133 |
-
return null;
|
134 |
-
|
135 |
-
$xml = new XmlWriter();
|
136 |
-
|
137 |
-
$xml->openMemory();
|
138 |
-
|
139 |
-
$xml->setIndent(true);
|
140 |
-
|
141 |
-
$xml->startDocument($version, $encoding);
|
142 |
-
$xml->startElementNS(null, 'OpenPayU', 'http://www.openpayu.com/20/openpayu.xsd');
|
143 |
-
|
144 |
-
$xml->startElement($rootElement);
|
145 |
-
|
146 |
-
if (!empty($rootElementXsi)) {
|
147 |
-
$xml->startAttributeNs('xsi', 'type', 'http://www.w3.org/2001/XMLSchema-instance');
|
148 |
-
$xml->text($rootElementXsi);
|
149 |
-
$xml->endAttribute();
|
150 |
-
}
|
151 |
-
|
152 |
-
self::convertArrayToXml($xml, $data);
|
153 |
-
$xml->endElement();
|
154 |
-
|
155 |
-
$xml->endElement();
|
156 |
-
$xml->endDocument();
|
157 |
-
|
158 |
-
return trim($xml->outputMemory(true));
|
159 |
-
}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* Function converts array to XML document
|
163 |
-
* @access public
|
164 |
-
* @param XMLWriter $xml
|
165 |
-
* @param array $data
|
166 |
-
*/
|
167 |
-
public static function convertArrayToXml(XMLWriter $xml, $data)
|
168 |
-
{
|
169 |
-
if (!empty($data) && is_array($data)) {
|
170 |
-
foreach ($data as $key => $value) {
|
171 |
-
if (is_array($value)) {
|
172 |
-
if (is_numeric($key)) {
|
173 |
-
self::convertArrayToXml($xml, $value);
|
174 |
-
} else {
|
175 |
-
$xml->startElement($key);
|
176 |
-
self::convertArrayToXml($xml, $value);
|
177 |
-
$xml->endElement();
|
178 |
-
}
|
179 |
-
continue;
|
180 |
-
}
|
181 |
-
$xml->writeElement($key, $value);
|
182 |
-
}
|
183 |
-
}
|
184 |
-
}
|
185 |
-
|
186 |
-
/**
|
187 |
-
* @param $data
|
188 |
-
* @return array
|
189 |
-
*/
|
190 |
-
public static function parseXmlDocument($data)
|
191 |
-
{
|
192 |
-
if (empty($data))
|
193 |
-
return null;
|
194 |
-
|
195 |
-
$assoc = self::convertXmlToArray($data);
|
196 |
-
|
197 |
-
return $assoc;
|
198 |
-
}
|
199 |
-
|
200 |
-
/**
|
201 |
-
* Function converts xml to array
|
202 |
-
* @access public
|
203 |
-
* @param string $xml
|
204 |
-
* @return array $tree
|
205 |
-
*/
|
206 |
-
public static function convertXmlToArray($xml)
|
207 |
-
{
|
208 |
-
$xmlObject = simplexml_load_string($xml);
|
209 |
-
$xmlArray = array( $xmlObject->getName() => (array)$xmlObject );
|
210 |
-
return json_decode(json_encode($xmlArray),1);
|
211 |
-
}
|
212 |
-
|
213 |
-
/**
|
214 |
-
* @param $data
|
215 |
* @param bool $assoc
|
216 |
* @return mixed|null
|
217 |
*/
|
218 |
public static function convertJsonToArray($data, $assoc = false)
|
219 |
{
|
220 |
-
if (empty($data))
|
221 |
return null;
|
|
|
222 |
|
223 |
return json_decode($data, $assoc);
|
224 |
}
|
225 |
|
226 |
/**
|
227 |
-
* @param $array
|
228 |
* @return bool|stdClass
|
229 |
*/
|
230 |
public static function parseArrayToObject($array)
|
@@ -233,21 +164,19 @@ class OpenPayU_Util
|
|
233 |
return $array;
|
234 |
}
|
235 |
|
236 |
-
if (self::isAssocArray($array)){
|
237 |
$object = new stdClass();
|
238 |
-
}
|
239 |
-
else{
|
240 |
$object = array();
|
241 |
}
|
242 |
|
243 |
if (is_array($array) && count($array) > 0) {
|
244 |
foreach ($array as $name => $value) {
|
245 |
$name = trim($name);
|
246 |
-
if (isset($name)){
|
247 |
-
if (is_numeric($name)){
|
248 |
$object[] = self::parseArrayToObject($value);
|
249 |
-
}
|
250 |
-
else{
|
251 |
$object->$name = self::parseArrayToObject($value);
|
252 |
}
|
253 |
}
|
@@ -263,22 +192,24 @@ class OpenPayU_Util
|
|
263 |
*/
|
264 |
public static function getRequestHeaders()
|
265 |
{
|
266 |
-
if(!function_exists('apache_request_headers')) {
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
}
|
272 |
}
|
273 |
-
|
274 |
-
|
|
|
275 |
return apache_request_headers();
|
276 |
}
|
277 |
|
278 |
}
|
|
|
279 |
/**
|
280 |
* @param $array
|
281 |
* @param string $namespace
|
|
|
282 |
* @return string
|
283 |
*/
|
284 |
public static function convertArrayToHtmlForm($array, $namespace = "", &$outputFields)
|
@@ -289,9 +220,6 @@ class OpenPayU_Util
|
|
289 |
|
290 |
foreach ($array as $key => $value) {
|
291 |
|
292 |
-
//Temporary important changes only for order by form method
|
293 |
-
$key = self::changeFormFieldFormat($namespace, $key);
|
294 |
-
|
295 |
if ($namespace && $assoc) {
|
296 |
$key = $namespace . '.' . $key;
|
297 |
} elseif ($namespace && !$assoc) {
|
@@ -334,51 +262,54 @@ class OpenPayU_Util
|
|
334 |
}
|
335 |
|
336 |
/**
|
337 |
-
* @param $data
|
338 |
-
* @return
|
339 |
*/
|
340 |
-
|
341 |
{
|
342 |
-
$data['properties'][0]
|
343 |
-
|
|
|
|
|
344 |
return $data;
|
345 |
}
|
346 |
|
347 |
-
public static function statusDesc($response)
|
|
|
348 |
|
349 |
$msg = '';
|
350 |
|
351 |
-
switch ($response){
|
352 |
case 'SUCCESS':
|
353 |
$msg = 'Request has been processed correctly.';
|
354 |
-
|
355 |
case 'DATA_NOT_FOUND':
|
356 |
$msg = 'Data indicated in the request is not available in the PayU system.';
|
357 |
-
|
358 |
case 'WARNING_CONTINUE_3_DS':
|
359 |
$msg = '3DS authorization required.Redirect the Buyer to PayU to continue the 3DS process by calling OpenPayU.authorize3DS().';
|
360 |
-
|
361 |
case 'WARNING_CONTINUE_CVV':
|
362 |
$msg = 'CVV/CVC authorization required. Call OpenPayU.authorizeCVV() method.';
|
363 |
-
|
364 |
case 'ERROR_SYNTAX':
|
365 |
$msg = 'BIncorrect request syntax. Supported formats are JSON or XML.';
|
366 |
-
|
367 |
case 'ERROR_VALUE_INVALID':
|
368 |
$msg = 'One or more required values are incorrect.';
|
369 |
-
|
370 |
case 'ERROR_VALUE_MISSING':
|
371 |
$msg = 'One or more required values are missing.';
|
372 |
-
|
373 |
case 'BUSINESS_ERROR':
|
374 |
$msg = 'PayU system is unavailable. Try again later.';
|
375 |
-
|
376 |
case 'ERROR_INTERNAL':
|
377 |
$msg = 'PayU system is unavailable. Try again later.';
|
378 |
-
|
379 |
case 'GENERAL_ERROR':
|
380 |
$msg = 'Unexpected error. Try again later.';
|
381 |
-
|
382 |
}
|
383 |
|
384 |
return $msg;
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
+
* OpenPayU Standard Library
|
5 |
*
|
6 |
+
* @copyright Copyright (c) 2011-2016 PayU
|
7 |
+
* @license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
8 |
+
* http://www.payu.com
|
9 |
+
* http://developers.payu.com
|
10 |
*/
|
|
|
11 |
class OpenPayU_Util
|
12 |
{
|
13 |
/**
|
14 |
* Function generate sign data
|
15 |
+
*
|
16 |
+
* @param array $data
|
17 |
* @param string $algorithm
|
18 |
* @param string $merchantPosId
|
19 |
* @param string $signatureKey
|
20 |
+
*
|
21 |
+
* @return string
|
22 |
+
*
|
23 |
* @throws OpenPayU_Exception_Configuration
|
24 |
*/
|
25 |
+
public static function generateSignData(array $data, $algorithm = 'SHA-256', $merchantPosId = '', $signatureKey = '')
|
26 |
{
|
27 |
if (empty($signatureKey))
|
28 |
throw new OpenPayU_Exception_Configuration('Merchant Signature Key should not be null or empty.');
|
30 |
if (empty($merchantPosId))
|
31 |
throw new OpenPayU_Exception_Configuration('MerchantPosId should not be null or empty.');
|
32 |
|
33 |
+
$contentForSign = '';
|
34 |
+
ksort($data);
|
35 |
|
36 |
+
foreach ($data as $key => $value) {
|
37 |
+
$contentForSign .= $key . '=' . urlencode($value) . '&';
|
38 |
+
}
|
39 |
|
40 |
+
if (in_array($algorithm, array('SHA-256', 'SHA'))) {
|
41 |
+
$hashAlgorithm = 'sha256';
|
|
|
|
|
|
|
|
|
|
|
42 |
$algorithm = 'SHA-256';
|
43 |
+
} else if ($algorithm == 'SHA-384') {
|
44 |
+
$hashAlgorithm = 'sha384';
|
45 |
+
$algorithm = 'SHA-384';
|
46 |
+
} else if ($algorithm == 'SHA-512') {
|
47 |
+
$hashAlgorithm = 'sha512';
|
48 |
+
$algorithm = 'SHA-512';
|
49 |
}
|
50 |
|
51 |
+
$signature = hash($hashAlgorithm, $contentForSign . $signatureKey);
|
52 |
+
|
53 |
+
$signData = 'sender=' . $merchantPosId . ';algorithm=' . $algorithm . ';signature=' . $signature;
|
54 |
|
55 |
return $signData;
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
* Function returns signature data object
|
60 |
+
*
|
61 |
* @param string $data
|
62 |
+
*
|
63 |
* @return null|object
|
64 |
*/
|
65 |
public static function parseSignature($data)
|
66 |
{
|
67 |
+
if (empty($data)) {
|
68 |
return null;
|
69 |
+
}
|
70 |
|
71 |
$signatureData = array();
|
72 |
|
73 |
$list = explode(';', rtrim($data, ';'));
|
74 |
+
if (empty($list)) {
|
75 |
return null;
|
76 |
+
}
|
77 |
|
78 |
foreach ($list as $value) {
|
79 |
$explode = explode('=', $value);
|
80 |
+
if (count($explode) != 2) {
|
81 |
+
return null;
|
82 |
+
}
|
83 |
$signatureData[$explode[0]] = $explode[1];
|
84 |
}
|
85 |
|
88 |
|
89 |
/**
|
90 |
* Function returns signature validate
|
91 |
+
*
|
92 |
+
* @param string $message
|
93 |
+
* @param string $signature
|
94 |
+
* @param string $signatureKey
|
95 |
+
* @param string $algorithm
|
96 |
+
*
|
97 |
* @return bool
|
98 |
*/
|
99 |
public static function verifySignature($message, $signature, $signatureKey, $algorithm = 'MD5')
|
119 |
|
120 |
/**
|
121 |
* Function builds OpenPayU Json Document
|
122 |
+
*
|
123 |
* @param string $data
|
124 |
* @param string $rootElement
|
125 |
+
*
|
126 |
+
* @return null|string
|
127 |
*/
|
128 |
public static function buildJsonFromArray($data, $rootElement = '')
|
129 |
{
|
130 |
+
if (!is_array($data)) {
|
131 |
return null;
|
132 |
+
}
|
133 |
|
134 |
+
if (!empty($rootElement)) {
|
135 |
$data = array($rootElement => $data);
|
136 |
+
}
|
137 |
|
138 |
$data = self::setSenderProperty($data);
|
139 |
|
141 |
}
|
142 |
|
143 |
/**
|
|
|
|
|
144 |
* @param string $data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
* @param bool $assoc
|
146 |
* @return mixed|null
|
147 |
*/
|
148 |
public static function convertJsonToArray($data, $assoc = false)
|
149 |
{
|
150 |
+
if (empty($data)) {
|
151 |
return null;
|
152 |
+
}
|
153 |
|
154 |
return json_decode($data, $assoc);
|
155 |
}
|
156 |
|
157 |
/**
|
158 |
+
* @param array $array
|
159 |
* @return bool|stdClass
|
160 |
*/
|
161 |
public static function parseArrayToObject($array)
|
164 |
return $array;
|
165 |
}
|
166 |
|
167 |
+
if (self::isAssocArray($array)) {
|
168 |
$object = new stdClass();
|
169 |
+
} else {
|
|
|
170 |
$object = array();
|
171 |
}
|
172 |
|
173 |
if (is_array($array) && count($array) > 0) {
|
174 |
foreach ($array as $name => $value) {
|
175 |
$name = trim($name);
|
176 |
+
if (isset($name)) {
|
177 |
+
if (is_numeric($name)) {
|
178 |
$object[] = self::parseArrayToObject($value);
|
179 |
+
} else {
|
|
|
180 |
$object->$name = self::parseArrayToObject($value);
|
181 |
}
|
182 |
}
|
192 |
*/
|
193 |
public static function getRequestHeaders()
|
194 |
{
|
195 |
+
if (!function_exists('apache_request_headers')) {
|
196 |
+
$headers = array();
|
197 |
+
foreach ($_SERVER as $key => $value) {
|
198 |
+
if (substr($key, 0, 5) == 'HTTP_') {
|
199 |
+
$headers[str_replace(' ', '-', ucwords(str_replace('_', ' ', strtolower(substr($key, 5)))))] = $value;
|
|
|
200 |
}
|
201 |
+
}
|
202 |
+
return $headers;
|
203 |
+
} else {
|
204 |
return apache_request_headers();
|
205 |
}
|
206 |
|
207 |
}
|
208 |
+
|
209 |
/**
|
210 |
* @param $array
|
211 |
* @param string $namespace
|
212 |
+
* @param array $outputFields
|
213 |
* @return string
|
214 |
*/
|
215 |
public static function convertArrayToHtmlForm($array, $namespace = "", &$outputFields)
|
220 |
|
221 |
foreach ($array as $key => $value) {
|
222 |
|
|
|
|
|
|
|
223 |
if ($namespace && $assoc) {
|
224 |
$key = $namespace . '.' . $key;
|
225 |
} elseif ($namespace && !$assoc) {
|
262 |
}
|
263 |
|
264 |
/**
|
265 |
+
* @param array $data
|
266 |
+
* @return array
|
267 |
*/
|
268 |
+
private static function setSenderProperty($data)
|
269 |
{
|
270 |
+
$data['properties'][0] = array(
|
271 |
+
'name' => 'sender',
|
272 |
+
'value' => OpenPayU_Configuration::getFullSenderName()
|
273 |
+
);
|
274 |
return $data;
|
275 |
}
|
276 |
|
277 |
+
public static function statusDesc($response)
|
278 |
+
{
|
279 |
|
280 |
$msg = '';
|
281 |
|
282 |
+
switch ($response) {
|
283 |
case 'SUCCESS':
|
284 |
$msg = 'Request has been processed correctly.';
|
285 |
+
break;
|
286 |
case 'DATA_NOT_FOUND':
|
287 |
$msg = 'Data indicated in the request is not available in the PayU system.';
|
288 |
+
break;
|
289 |
case 'WARNING_CONTINUE_3_DS':
|
290 |
$msg = '3DS authorization required.Redirect the Buyer to PayU to continue the 3DS process by calling OpenPayU.authorize3DS().';
|
291 |
+
break;
|
292 |
case 'WARNING_CONTINUE_CVV':
|
293 |
$msg = 'CVV/CVC authorization required. Call OpenPayU.authorizeCVV() method.';
|
294 |
+
break;
|
295 |
case 'ERROR_SYNTAX':
|
296 |
$msg = 'BIncorrect request syntax. Supported formats are JSON or XML.';
|
297 |
+
break;
|
298 |
case 'ERROR_VALUE_INVALID':
|
299 |
$msg = 'One or more required values are incorrect.';
|
300 |
+
break;
|
301 |
case 'ERROR_VALUE_MISSING':
|
302 |
$msg = 'One or more required values are missing.';
|
303 |
+
break;
|
304 |
case 'BUSINESS_ERROR':
|
305 |
$msg = 'PayU system is unavailable. Try again later.';
|
306 |
+
break;
|
307 |
case 'ERROR_INTERNAL':
|
308 |
$msg = 'PayU system is unavailable. Try again later.';
|
309 |
+
break;
|
310 |
case 'GENERAL_ERROR':
|
311 |
$msg = 'Unexpected error. Try again later.';
|
312 |
+
break;
|
313 |
}
|
314 |
|
315 |
return $msg;
|
lib/{payu/sdk_v21 → PayU}/OpenPayU/v2/Order.php
RENAMED
@@ -1,15 +1,12 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
* OpenPayU
|
5 |
*
|
6 |
-
* @copyright Copyright (c)
|
7 |
* @license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
8 |
-
*
|
9 |
* http://www.payu.com
|
10 |
* http://developers.payu.com
|
11 |
-
* http://twitter.com/openpayu
|
12 |
-
*
|
13 |
*/
|
14 |
|
15 |
/**
|
@@ -36,21 +33,27 @@ class OpenPayU_Order extends OpenPayU
|
|
36 |
* Creates new Order
|
37 |
* - Sends to PayU OrderCreateRequest
|
38 |
*
|
39 |
-
* @access public
|
40 |
* @param array $order A array containing full Order
|
41 |
* @return object $result Response array with OrderCreateResponse
|
42 |
* @throws OpenPayU_Exception
|
43 |
*/
|
44 |
public static function create($order)
|
45 |
{
|
46 |
-
$pathUrl = OpenPayU_Configuration::getServiceUrl() . self::ORDER_SERVICE;
|
47 |
$data = OpenPayU_Util::buildJsonFromArray($order);
|
48 |
|
49 |
if (empty($data)) {
|
50 |
throw new OpenPayU_Exception('Empty message OrderCreateRequest');
|
51 |
}
|
52 |
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
return $result;
|
56 |
}
|
@@ -59,7 +62,6 @@ class OpenPayU_Order extends OpenPayU
|
|
59 |
* Retrieves information about the order
|
60 |
* - Sends to PayU OrderRetrieveRequest
|
61 |
*
|
62 |
-
* @access public
|
63 |
* @param string $orderId PayU OrderId sent back in OrderCreateResponse
|
64 |
* @return OpenPayU_Result $result Response array with OrderRetrieveResponse
|
65 |
* @throws OpenPayU_Exception
|
@@ -70,9 +72,15 @@ class OpenPayU_Order extends OpenPayU
|
|
70 |
throw new OpenPayU_Exception('Empty value of orderId');
|
71 |
}
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
$pathUrl = OpenPayU_Configuration::getServiceUrl() . self::ORDER_SERVICE . $orderId;
|
74 |
|
75 |
-
$result = self::verifyResponse(OpenPayU_Http::
|
76 |
|
77 |
return $result;
|
78 |
}
|
@@ -81,7 +89,6 @@ class OpenPayU_Order extends OpenPayU
|
|
81 |
* Cancels Order
|
82 |
* - Sends to PayU OrderCancelRequest
|
83 |
*
|
84 |
-
* @access public
|
85 |
* @param string $orderId PayU OrderId sent back in OrderCreateResponse
|
86 |
* @return OpenPayU_Result $result Response array with OrderCancelResponse
|
87 |
* @throws OpenPayU_Exception
|
@@ -92,9 +99,15 @@ class OpenPayU_Order extends OpenPayU
|
|
92 |
throw new OpenPayU_Exception('Empty value of orderId');
|
93 |
}
|
94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
$pathUrl = OpenPayU_Configuration::getServiceUrl() . self::ORDER_SERVICE . $orderId;
|
96 |
|
97 |
-
$result = self::verifyResponse(OpenPayU_Http::
|
98 |
return $result;
|
99 |
}
|
100 |
|
@@ -102,24 +115,27 @@ class OpenPayU_Order extends OpenPayU
|
|
102 |
* Updates Order status
|
103 |
* - Sends to PayU OrderStatusUpdateRequest
|
104 |
*
|
105 |
-
* @
|
106 |
-
* @param string $orderStatus A array containing full OrderStatus
|
107 |
* @return OpenPayU_Result $result Response array with OrderStatusUpdateResponse
|
108 |
* @throws OpenPayU_Exception
|
109 |
*/
|
110 |
public static function statusUpdate($orderStatusUpdate)
|
111 |
{
|
112 |
-
$data = array();
|
113 |
if (empty($orderStatusUpdate)) {
|
114 |
throw new OpenPayU_Exception('Empty order status data');
|
115 |
}
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
$data = OpenPayU_Util::buildJsonFromArray($orderStatusUpdate);
|
118 |
-
$
|
119 |
|
120 |
-
$
|
121 |
|
122 |
-
$result = self::verifyResponse(OpenPayU_Http::put($pathUrl, $data), 'OrderStatusUpdateResponse');
|
123 |
return $result;
|
124 |
}
|
125 |
|
@@ -133,8 +149,6 @@ class OpenPayU_Order extends OpenPayU
|
|
133 |
*/
|
134 |
public static function consumeNotification($data)
|
135 |
{
|
136 |
-
$sslConnection = self::isSecureConnection();
|
137 |
-
|
138 |
if (empty($data)) {
|
139 |
throw new OpenPayU_Exception('Empty value of data');
|
140 |
}
|
@@ -142,11 +156,7 @@ class OpenPayU_Order extends OpenPayU
|
|
142 |
$headers = OpenPayU_Util::getRequestHeaders();
|
143 |
$incomingSignature = OpenPayU_HttpCurl::getSignature($headers);
|
144 |
|
145 |
-
|
146 |
-
self::verifyBasicAuthCredentials();
|
147 |
-
} else {
|
148 |
-
self::verifyDocumentSignature($data, $incomingSignature);
|
149 |
-
}
|
150 |
|
151 |
return OpenPayU_Order::verifyResponse(array('response' => $data, 'code' => 200), 'OrderNotifyRequest');
|
152 |
}
|
@@ -165,48 +175,45 @@ class OpenPayU_Order extends OpenPayU
|
|
165 |
|
166 |
$message = OpenPayU_Util::convertJsonToArray($response['response'], true);
|
167 |
|
168 |
-
|
169 |
-
|
|
|
|
|
|
|
170 |
unset($message[$messageName]['Status']);
|
171 |
$data['response'] = $message[$messageName];
|
172 |
} elseif (isset($message)) {
|
173 |
$data['response'] = $message;
|
174 |
-
$data['status'] = isset($message['status']['statusCode']) ? $message['status']['statusCode'] : null;
|
175 |
unset($message['status']);
|
176 |
}
|
177 |
|
178 |
$result = self::build($data);
|
179 |
|
180 |
-
|
181 |
-
== 400 || $httpStatus == 404)
|
182 |
{
|
183 |
return $result;
|
184 |
} else {
|
185 |
OpenPayU_Http::throwHttpStatusException($httpStatus, $result);
|
186 |
}
|
187 |
-
|
188 |
-
return null;
|
189 |
}
|
190 |
|
191 |
/**
|
192 |
* Generate a form body for hosted order
|
193 |
*
|
194 |
* @access public
|
195 |
-
* @param $order
|
196 |
-
* @param $params
|
197 |
* @return string Response html form
|
198 |
*/
|
199 |
public static function hostedOrderForm($order, $params = array())
|
200 |
{
|
201 |
$orderFormUrl = OpenPayU_Configuration::getServiceUrl() . 'orders';
|
202 |
|
203 |
-
$
|
204 |
-
$htmlFormFields = OpenPayU_Util::convertArrayToHtmlForm($order,
|
205 |
-
ksort($usortedFormFieldValuesAsArray);
|
206 |
-
$sortedFormFieldValuesAsString = implode('', array_values($usortedFormFieldValuesAsArray));
|
207 |
|
208 |
$signature = OpenPayU_Util::generateSignData(
|
209 |
-
$
|
210 |
OpenPayU_Configuration::getHashAlgorithm(),
|
211 |
OpenPayU_Configuration::getMerchantPosId(),
|
212 |
OpenPayU_Configuration::getSignatureKey()
|
@@ -222,4 +229,5 @@ class OpenPayU_Order extends OpenPayU
|
|
222 |
|
223 |
return $htmlOutput;
|
224 |
}
|
|
|
225 |
}
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* OpenPayU Standard Library
|
5 |
*
|
6 |
+
* @copyright Copyright (c) 2011-2016 PayU
|
7 |
* @license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
|
|
8 |
* http://www.payu.com
|
9 |
* http://developers.payu.com
|
|
|
|
|
10 |
*/
|
11 |
|
12 |
/**
|
33 |
* Creates new Order
|
34 |
* - Sends to PayU OrderCreateRequest
|
35 |
*
|
|
|
36 |
* @param array $order A array containing full Order
|
37 |
* @return object $result Response array with OrderCreateResponse
|
38 |
* @throws OpenPayU_Exception
|
39 |
*/
|
40 |
public static function create($order)
|
41 |
{
|
|
|
42 |
$data = OpenPayU_Util::buildJsonFromArray($order);
|
43 |
|
44 |
if (empty($data)) {
|
45 |
throw new OpenPayU_Exception('Empty message OrderCreateRequest');
|
46 |
}
|
47 |
|
48 |
+
try {
|
49 |
+
$authType = self::getAuth();
|
50 |
+
} catch (OpenPayU_Exception $e) {
|
51 |
+
throw new OpenPayU_Exception($e->getMessage(), $e->getCode());
|
52 |
+
}
|
53 |
+
|
54 |
+
$pathUrl = OpenPayU_Configuration::getServiceUrl() . self::ORDER_SERVICE;
|
55 |
+
|
56 |
+
$result = self::verifyResponse(OpenPayU_Http::doPost($pathUrl, $data, $authType), 'OrderCreateResponse');
|
57 |
|
58 |
return $result;
|
59 |
}
|
62 |
* Retrieves information about the order
|
63 |
* - Sends to PayU OrderRetrieveRequest
|
64 |
*
|
|
|
65 |
* @param string $orderId PayU OrderId sent back in OrderCreateResponse
|
66 |
* @return OpenPayU_Result $result Response array with OrderRetrieveResponse
|
67 |
* @throws OpenPayU_Exception
|
72 |
throw new OpenPayU_Exception('Empty value of orderId');
|
73 |
}
|
74 |
|
75 |
+
try {
|
76 |
+
$authType = self::getAuth();
|
77 |
+
} catch (OpenPayU_Exception $e) {
|
78 |
+
throw new OpenPayU_Exception($e->getMessage(), $e->getCode());
|
79 |
+
}
|
80 |
+
|
81 |
$pathUrl = OpenPayU_Configuration::getServiceUrl() . self::ORDER_SERVICE . $orderId;
|
82 |
|
83 |
+
$result = self::verifyResponse(OpenPayU_Http::doGet($pathUrl, $authType), 'OrderRetrieveResponse');
|
84 |
|
85 |
return $result;
|
86 |
}
|
89 |
* Cancels Order
|
90 |
* - Sends to PayU OrderCancelRequest
|
91 |
*
|
|
|
92 |
* @param string $orderId PayU OrderId sent back in OrderCreateResponse
|
93 |
* @return OpenPayU_Result $result Response array with OrderCancelResponse
|
94 |
* @throws OpenPayU_Exception
|
99 |
throw new OpenPayU_Exception('Empty value of orderId');
|
100 |
}
|
101 |
|
102 |
+
try {
|
103 |
+
$authType = self::getAuth();
|
104 |
+
} catch (OpenPayU_Exception $e) {
|
105 |
+
throw new OpenPayU_Exception($e->getMessage(), $e->getCode());
|
106 |
+
}
|
107 |
+
|
108 |
$pathUrl = OpenPayU_Configuration::getServiceUrl() . self::ORDER_SERVICE . $orderId;
|
109 |
|
110 |
+
$result = self::verifyResponse(OpenPayU_Http::doDelete($pathUrl, $authType), 'OrderCancelResponse');
|
111 |
return $result;
|
112 |
}
|
113 |
|
115 |
* Updates Order status
|
116 |
* - Sends to PayU OrderStatusUpdateRequest
|
117 |
*
|
118 |
+
* @param string $orderStatusUpdate A array containing full OrderStatus
|
|
|
119 |
* @return OpenPayU_Result $result Response array with OrderStatusUpdateResponse
|
120 |
* @throws OpenPayU_Exception
|
121 |
*/
|
122 |
public static function statusUpdate($orderStatusUpdate)
|
123 |
{
|
|
|
124 |
if (empty($orderStatusUpdate)) {
|
125 |
throw new OpenPayU_Exception('Empty order status data');
|
126 |
}
|
127 |
|
128 |
+
try {
|
129 |
+
$authType = self::getAuth();
|
130 |
+
} catch (OpenPayU_Exception $e) {
|
131 |
+
throw new OpenPayU_Exception($e->getMessage(), $e->getCode());
|
132 |
+
}
|
133 |
+
|
134 |
$data = OpenPayU_Util::buildJsonFromArray($orderStatusUpdate);
|
135 |
+
$pathUrl = OpenPayU_Configuration::getServiceUrl() . self::ORDER_SERVICE . $orderStatusUpdate['orderId'] . '/status';
|
136 |
|
137 |
+
$result = self::verifyResponse(OpenPayU_Http::doPut($pathUrl, $data, $authType), 'OrderStatusUpdateResponse');
|
138 |
|
|
|
139 |
return $result;
|
140 |
}
|
141 |
|
149 |
*/
|
150 |
public static function consumeNotification($data)
|
151 |
{
|
|
|
|
|
152 |
if (empty($data)) {
|
153 |
throw new OpenPayU_Exception('Empty value of data');
|
154 |
}
|
156 |
$headers = OpenPayU_Util::getRequestHeaders();
|
157 |
$incomingSignature = OpenPayU_HttpCurl::getSignature($headers);
|
158 |
|
159 |
+
self::verifyDocumentSignature($data, $incomingSignature);
|
|
|
|
|
|
|
|
|
160 |
|
161 |
return OpenPayU_Order::verifyResponse(array('response' => $data, 'code' => 200), 'OrderNotifyRequest');
|
162 |
}
|
175 |
|
176 |
$message = OpenPayU_Util::convertJsonToArray($response['response'], true);
|
177 |
|
178 |
+
$data['status'] = isset($message['status']['statusCode']) ? $message['status']['statusCode'] : null;
|
179 |
+
|
180 |
+
if (json_last_error() == JSON_ERROR_SYNTAX) {
|
181 |
+
$data['response'] = $response['response'];
|
182 |
+
} elseif (isset($message[$messageName])) {
|
183 |
unset($message[$messageName]['Status']);
|
184 |
$data['response'] = $message[$messageName];
|
185 |
} elseif (isset($message)) {
|
186 |
$data['response'] = $message;
|
|
|
187 |
unset($message['status']);
|
188 |
}
|
189 |
|
190 |
$result = self::build($data);
|
191 |
|
192 |
+
if ($httpStatus == 200 || $httpStatus == 201 || $httpStatus == 422 || $httpStatus == 301 || $httpStatus == 302)
|
|
|
193 |
{
|
194 |
return $result;
|
195 |
} else {
|
196 |
OpenPayU_Http::throwHttpStatusException($httpStatus, $result);
|
197 |
}
|
|
|
|
|
198 |
}
|
199 |
|
200 |
/**
|
201 |
* Generate a form body for hosted order
|
202 |
*
|
203 |
* @access public
|
204 |
+
* @param array $order an array containing full Order
|
205 |
+
* @param array $params an optional array with form elements' params
|
206 |
* @return string Response html form
|
207 |
*/
|
208 |
public static function hostedOrderForm($order, $params = array())
|
209 |
{
|
210 |
$orderFormUrl = OpenPayU_Configuration::getServiceUrl() . 'orders';
|
211 |
|
212 |
+
$formFieldValuesAsArray = array();
|
213 |
+
$htmlFormFields = OpenPayU_Util::convertArrayToHtmlForm($order, '', $formFieldValuesAsArray);
|
|
|
|
|
214 |
|
215 |
$signature = OpenPayU_Util::generateSignData(
|
216 |
+
$formFieldValuesAsArray,
|
217 |
OpenPayU_Configuration::getHashAlgorithm(),
|
218 |
OpenPayU_Configuration::getMerchantPosId(),
|
219 |
OpenPayU_Configuration::getSignatureKey()
|
229 |
|
230 |
return $htmlOutput;
|
231 |
}
|
232 |
+
|
233 |
}
|
lib/{payu/sdk_v21 → PayU}/OpenPayU/v2/Refund.php
RENAMED
@@ -1,14 +1,12 @@
|
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
-
* OpenPayU
|
4 |
*
|
5 |
-
* @copyright Copyright (c)
|
6 |
* @license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
7 |
-
*
|
8 |
* http://www.payu.com
|
9 |
* http://developers.payu.com
|
10 |
-
* http://twitter.com/openpayu
|
11 |
-
*
|
12 |
*/
|
13 |
|
14 |
class OpenPayU_Refund extends OpenPayU
|
@@ -23,28 +21,33 @@ class OpenPayU_Refund extends OpenPayU
|
|
23 |
*/
|
24 |
public static function create($orderId, $description, $amount = null)
|
25 |
{
|
26 |
-
if (empty($orderId))
|
27 |
throw new OpenPayU_Exception('Invalid orderId value for refund');
|
|
|
28 |
|
29 |
-
if (empty($description))
|
30 |
throw new OpenPayU_Exception('Invalid description of refund');
|
31 |
-
|
32 |
$refund = array(
|
33 |
'orderId' => $orderId,
|
34 |
'refund' => array('description' => $description)
|
35 |
);
|
36 |
|
37 |
-
if (!empty($amount))
|
38 |
$refund['refund']['amount'] = (int)$amount;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
$pathUrl = OpenPayU_Configuration::getServiceUrl().'orders/'. $refund['orderId'] . '/refund';
|
41 |
|
42 |
$data = OpenPayU_Util::buildJsonFromArray($refund);
|
43 |
|
44 |
-
|
45 |
-
throw new OpenPayU_Exception('Empty message RefundCreateResponse');
|
46 |
-
|
47 |
-
$result = self::verifyResponse(OpenPayU_Http::post($pathUrl, $data), 'RefundCreateResponse');
|
48 |
|
49 |
return $result;
|
50 |
}
|
@@ -52,7 +55,7 @@ class OpenPayU_Refund extends OpenPayU
|
|
52 |
/**
|
53 |
* @param string $response
|
54 |
* @param string $messageName
|
55 |
-
* @return
|
56 |
*/
|
57 |
public static function verifyResponse($response, $messageName='')
|
58 |
{
|
@@ -61,25 +64,24 @@ class OpenPayU_Refund extends OpenPayU
|
|
61 |
|
62 |
$message = OpenPayU_Util::convertJsonToArray($response['response'], true);
|
63 |
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
66 |
unset($message[$messageName]['Status']);
|
67 |
$data['response'] = $message[$messageName];
|
68 |
} elseif (isset($message)) {
|
69 |
$data['response'] = $message;
|
70 |
-
$data['status'] = isset($message['status']['statusCode']) ? $message['status']['statusCode'] : null;
|
71 |
unset($message['status']);
|
72 |
}
|
73 |
|
74 |
$result = self::build($data);
|
75 |
|
76 |
-
if ($httpStatus == 200 || $httpStatus == 201 || $httpStatus == 422 || $httpStatus == 302
|
77 |
-
400 || $httpStatus == 404)
|
78 |
return $result;
|
79 |
-
else {
|
80 |
OpenPayU_Http::throwHttpStatusException($httpStatus, $result);
|
81 |
}
|
82 |
-
|
83 |
-
return null;
|
84 |
}
|
85 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
+
* OpenPayU Standard Library
|
5 |
*
|
6 |
+
* @copyright Copyright (c) 2011-2016 PayU
|
7 |
* @license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
|
|
8 |
* http://www.payu.com
|
9 |
* http://developers.payu.com
|
|
|
|
|
10 |
*/
|
11 |
|
12 |
class OpenPayU_Refund extends OpenPayU
|
21 |
*/
|
22 |
public static function create($orderId, $description, $amount = null)
|
23 |
{
|
24 |
+
if (empty($orderId)) {
|
25 |
throw new OpenPayU_Exception('Invalid orderId value for refund');
|
26 |
+
}
|
27 |
|
28 |
+
if (empty($description)) {
|
29 |
throw new OpenPayU_Exception('Invalid description of refund');
|
30 |
+
}
|
31 |
$refund = array(
|
32 |
'orderId' => $orderId,
|
33 |
'refund' => array('description' => $description)
|
34 |
);
|
35 |
|
36 |
+
if (!empty($amount)) {
|
37 |
$refund['refund']['amount'] = (int)$amount;
|
38 |
+
}
|
39 |
+
|
40 |
+
try {
|
41 |
+
$authType = self::getAuth();
|
42 |
+
} catch (OpenPayU_Exception $e) {
|
43 |
+
throw new OpenPayU_Exception($e->getMessage(), $e->getCode());
|
44 |
+
}
|
45 |
|
46 |
$pathUrl = OpenPayU_Configuration::getServiceUrl().'orders/'. $refund['orderId'] . '/refund';
|
47 |
|
48 |
$data = OpenPayU_Util::buildJsonFromArray($refund);
|
49 |
|
50 |
+
$result = self::verifyResponse(OpenPayU_Http::doPost($pathUrl, $data, $authType), 'RefundCreateResponse');
|
|
|
|
|
|
|
51 |
|
52 |
return $result;
|
53 |
}
|
55 |
/**
|
56 |
* @param string $response
|
57 |
* @param string $messageName
|
58 |
+
* @return OpenPayU_Result
|
59 |
*/
|
60 |
public static function verifyResponse($response, $messageName='')
|
61 |
{
|
64 |
|
65 |
$message = OpenPayU_Util::convertJsonToArray($response['response'], true);
|
66 |
|
67 |
+
$data['status'] = isset($message['status']['statusCode']) ? $message['status']['statusCode'] : null;
|
68 |
+
|
69 |
+
if (json_last_error() == JSON_ERROR_SYNTAX) {
|
70 |
+
$data['response'] = $response['response'];
|
71 |
+
} elseif (isset($message[$messageName])) {
|
72 |
unset($message[$messageName]['Status']);
|
73 |
$data['response'] = $message[$messageName];
|
74 |
} elseif (isset($message)) {
|
75 |
$data['response'] = $message;
|
|
|
76 |
unset($message['status']);
|
77 |
}
|
78 |
|
79 |
$result = self::build($data);
|
80 |
|
81 |
+
if ($httpStatus == 200 || $httpStatus == 201 || $httpStatus == 422 || $httpStatus == 302) {
|
|
|
82 |
return $result;
|
83 |
+
} else {
|
84 |
OpenPayU_Http::throwHttpStatusException($httpStatus, $result);
|
85 |
}
|
|
|
|
|
86 |
}
|
87 |
}
|
lib/PayU/OpenPayU/v2/Retrieve.php
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* OpenPayU Standard Library
|
4 |
+
*
|
5 |
+
* @copyright Copyright (c) 2011-2016 PayU
|
6 |
+
* @license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
7 |
+
* http://www.payu.com
|
8 |
+
* http://developers.payu.com
|
9 |
+
*/
|
10 |
+
|
11 |
+
class OpenPayU_Retrieve extends OpenPayU
|
12 |
+
{
|
13 |
+
|
14 |
+
const PAYMETHODS_SERVICE = 'paymethods';
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Get Pay Methods from POS
|
18 |
+
* @param string $lang
|
19 |
+
* @return null|OpenPayU_Result
|
20 |
+
* @throws OpenPayU_Exception
|
21 |
+
* @throws OpenPayU_Exception_Configuration
|
22 |
+
*/
|
23 |
+
public static function payMethods($lang = null)
|
24 |
+
{
|
25 |
+
|
26 |
+
try {
|
27 |
+
$authType = self::getAuth();
|
28 |
+
} catch (OpenPayU_Exception $e) {
|
29 |
+
throw new OpenPayU_Exception($e->getMessage(), $e->getCode());
|
30 |
+
}
|
31 |
+
|
32 |
+
if (!$authType instanceof AuthType_Oauth) {
|
33 |
+
throw new OpenPayU_Exception_Configuration('Retrieve works only with OAuth');
|
34 |
+
}
|
35 |
+
|
36 |
+
$pathUrl = OpenPayU_Configuration::getServiceUrl() . self::PAYMETHODS_SERVICE;
|
37 |
+
if ($lang !== null) {
|
38 |
+
$pathUrl .= '?lang=' . $lang;
|
39 |
+
}
|
40 |
+
|
41 |
+
$response = self::verifyResponse(OpenPayU_Http::doGet($pathUrl, $authType));
|
42 |
+
|
43 |
+
return $response;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @param string $response
|
48 |
+
* @return null|OpenPayU_Result
|
49 |
+
*/
|
50 |
+
public static function verifyResponse($response)
|
51 |
+
{
|
52 |
+
$data = array();
|
53 |
+
$httpStatus = $response['code'];
|
54 |
+
|
55 |
+
$message = OpenPayU_Util::convertJsonToArray($response['response'], true);
|
56 |
+
|
57 |
+
$data['status'] = isset($message['status']['statusCode']) ? $message['status']['statusCode'] : null;
|
58 |
+
|
59 |
+
if (json_last_error() == JSON_ERROR_SYNTAX) {
|
60 |
+
$data['response'] = $response['response'];
|
61 |
+
} elseif (isset($message)) {
|
62 |
+
$data['response'] = $message;
|
63 |
+
unset($message['status']);
|
64 |
+
}
|
65 |
+
|
66 |
+
$result = self::build($data);
|
67 |
+
|
68 |
+
if ($httpStatus == 200 || $httpStatus == 201 || $httpStatus == 422 || $httpStatus == 302 || $httpStatus == 400 || $httpStatus == 404) {
|
69 |
+
return $result;
|
70 |
+
} else {
|
71 |
+
OpenPayU_Http::throwHttpStatusException($httpStatus, $result);
|
72 |
+
}
|
73 |
+
|
74 |
+
}
|
75 |
+
}
|
lib/PayU/openpayu.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* OpenPayU Standard Library
|
5 |
+
* ver. 2.1.3
|
6 |
+
*
|
7 |
+
* @copyright Copyright (c) 2011-2016 PayU
|
8 |
+
* @license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
9 |
+
* http://www.payu.com
|
10 |
+
* http://developers.payu.com
|
11 |
+
*/
|
12 |
+
|
13 |
+
include_once('OpenPayU/Configuration.php');
|
14 |
+
include_once('OpenPayU/OpenPayUException.php');
|
15 |
+
include_once('OpenPayU/Util.php');
|
16 |
+
include_once('OpenPayU/OpenPayU.php');
|
17 |
+
include_once('OpenPayU/OpenPayuOrderStatus.php');
|
18 |
+
|
19 |
+
include_once('OpenPayU/Result.php');
|
20 |
+
|
21 |
+
require_once('OpenPayU/Http.php');
|
22 |
+
require_once('OpenPayU/HttpCurl.php');
|
23 |
+
|
24 |
+
require_once('OpenPayU/Oauth/Oauth.php');
|
25 |
+
require_once('OpenPayU/Oauth/OauthGrantType.php');
|
26 |
+
require_once('OpenPayU/Oauth/OauthResultClientCredentials.php');
|
27 |
+
require_once('OpenPayU/Oauth/Cache/OauthCacheInterface.php');
|
28 |
+
require_once('OpenPayU/Oauth/Cache/OauthCacheFile.php');
|
29 |
+
require_once('OpenPayU/Oauth/Cache/OauthCacheMemcached.php');
|
30 |
+
|
31 |
+
require_once('OpenPayU/ResultError.php');
|
32 |
+
|
33 |
+
require_once('OpenPayU/AuthType/AuthType.php');
|
34 |
+
require_once('OpenPayU/AuthType/Basic.php');
|
35 |
+
require_once('OpenPayU/AuthType/TokenRequest.php');
|
36 |
+
require_once('OpenPayU/AuthType/Oauth.php');
|
37 |
+
|
38 |
+
include_once('OpenPayU/v2/Refund.php');
|
39 |
+
include_once('OpenPayU/v2/Order.php');
|
40 |
+
include_once('OpenPayU/v2/Retrieve.php');
|
lib/payu/sdk_v21/OpenPayU/Configuration.php
DELETED
@@ -1,302 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
OpenPayU Standard Library
|
5 |
-
|
6 |
-
@copyright Copyright (c) 2011-2014 PayU
|
7 |
-
@license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
8 |
-
http://www.payu.com
|
9 |
-
http://developers.payu.com
|
10 |
-
http://twitter.com/openpayu
|
11 |
-
*/
|
12 |
-
|
13 |
-
class OpenPayU_Configuration
|
14 |
-
{
|
15 |
-
private static $_availableEnvironment = array('custom', 'secure');
|
16 |
-
public static $env = 'secure';
|
17 |
-
public static $merchantPosId = '';
|
18 |
-
public static $posAuthKey = '';
|
19 |
-
public static $clientId = '';
|
20 |
-
public static $clientSecret = '';
|
21 |
-
public static $signatureKey = '';
|
22 |
-
|
23 |
-
public static $serviceUrl = '';
|
24 |
-
public static $summaryUrl = '';
|
25 |
-
public static $authUrl = '';
|
26 |
-
public static $serviceDomain = '';
|
27 |
-
|
28 |
-
private static $apiVersion = 2;
|
29 |
-
private static $_availableHashAlgorithm = array('MD5', 'SHA', 'SHA1', 'SHA-1', 'SHA-256', 'SHA256', 'SHA_256');
|
30 |
-
private static $hashAlgorithm = 'SHA-1';
|
31 |
-
|
32 |
-
private static $dataFormat = 'json';
|
33 |
-
|
34 |
-
private static $sender = 'Generic';
|
35 |
-
|
36 |
-
const COMPOSER_JSON = "/composer.json";
|
37 |
-
const DEFAULT_SDK_VERSION = 'PHP SDK 2.1.0';
|
38 |
-
|
39 |
-
|
40 |
-
/**
|
41 |
-
* @access public
|
42 |
-
* @param int $version
|
43 |
-
* @throws OpenPayU_Exception_Configuration
|
44 |
-
*/
|
45 |
-
public static function setApiVersion($version)
|
46 |
-
{
|
47 |
-
if (empty($version))
|
48 |
-
throw new OpenPayU_Exception_Configuration('Invalid API version');
|
49 |
-
|
50 |
-
self::$apiVersion = intval($version);
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* @return int
|
55 |
-
*/
|
56 |
-
public static function getApiVersion()
|
57 |
-
{
|
58 |
-
return self::$apiVersion;
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* @access public
|
63 |
-
* @param string
|
64 |
-
* @throws OpenPayU_Exception_Configuration
|
65 |
-
*/
|
66 |
-
public static function setHashAlgorithm($value)
|
67 |
-
{
|
68 |
-
if (!in_array($value, self::$_availableHashAlgorithm))
|
69 |
-
throw new OpenPayU_Exception_Configuration($value . ' - is not available');
|
70 |
-
|
71 |
-
self::$hashAlgorithm = $value;
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* @access public
|
76 |
-
* @return string
|
77 |
-
*/
|
78 |
-
public static function getHashAlgorithm()
|
79 |
-
{
|
80 |
-
return self::$hashAlgorithm;
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* @access public
|
85 |
-
* @param string $value
|
86 |
-
* @param string $domain
|
87 |
-
* @param string $country
|
88 |
-
* @throws OpenPayU_Exception_Configuration
|
89 |
-
*/
|
90 |
-
public static function setEnvironment($value = 'secure', $domain = 'payu.com', $country = 'pl', $api = 'api/', $version = 'v2_1/')
|
91 |
-
{
|
92 |
-
$value = strtolower($value);
|
93 |
-
$domain = strtolower($domain) . '/';
|
94 |
-
|
95 |
-
if (!in_array($value, self::$_availableEnvironment))
|
96 |
-
throw new OpenPayU_Exception_Configuration($value . ' - is not valid environment');
|
97 |
-
|
98 |
-
|
99 |
-
if ($value == 'secure') {
|
100 |
-
self::$env = $value;
|
101 |
-
|
102 |
-
self::$serviceDomain = $domain;
|
103 |
-
|
104 |
-
self::$serviceUrl = 'https://' . $value . '.' . $domain . $api . $version;
|
105 |
-
self::$summaryUrl = self::$serviceUrl . 'co/summary';
|
106 |
-
self::$authUrl = self::$serviceUrl . 'oauth/user/authorize';
|
107 |
-
} else if ($value == 'custom') {
|
108 |
-
self::$env = $value;
|
109 |
-
|
110 |
-
self::$serviceUrl = $domain . $api . $version;
|
111 |
-
self::$summaryUrl = self::$serviceUrl . 'co/summary';
|
112 |
-
self::$authUrl = self::$serviceUrl . 'oauth/user/authorize';
|
113 |
-
}
|
114 |
-
}
|
115 |
-
|
116 |
-
/**
|
117 |
-
* @access public
|
118 |
-
* @return string
|
119 |
-
*/
|
120 |
-
public static function getServiceUrl()
|
121 |
-
{
|
122 |
-
return self::$serviceUrl;
|
123 |
-
}
|
124 |
-
|
125 |
-
/**
|
126 |
-
* @access public
|
127 |
-
* @return string
|
128 |
-
*/
|
129 |
-
public static function getSummaryUrl()
|
130 |
-
{
|
131 |
-
return self::$summaryUrl;
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
* @access public
|
136 |
-
* @return string
|
137 |
-
*/
|
138 |
-
public static function getAuthUrl()
|
139 |
-
{
|
140 |
-
return self::$authUrl;
|
141 |
-
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
* @access public
|
145 |
-
* @return string
|
146 |
-
*/
|
147 |
-
public static function getEnvironment()
|
148 |
-
{
|
149 |
-
return self::$env;
|
150 |
-
}
|
151 |
-
|
152 |
-
/**
|
153 |
-
* @access public
|
154 |
-
* @param string
|
155 |
-
*/
|
156 |
-
public static function setMerchantPosId($value)
|
157 |
-
{
|
158 |
-
self::$merchantPosId = trim($value);
|
159 |
-
}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* @access public
|
163 |
-
* @return string
|
164 |
-
*/
|
165 |
-
public static function getMerchantPosId()
|
166 |
-
{
|
167 |
-
return self::$merchantPosId;
|
168 |
-
}
|
169 |
-
|
170 |
-
/**
|
171 |
-
* @access public
|
172 |
-
* @param string
|
173 |
-
*/
|
174 |
-
public static function setPosAuthKey($value)
|
175 |
-
{
|
176 |
-
self::$posAuthKey = trim($value);
|
177 |
-
}
|
178 |
-
|
179 |
-
/**
|
180 |
-
* @access public
|
181 |
-
* @return string
|
182 |
-
*/
|
183 |
-
public static function getPosAuthKey()
|
184 |
-
{
|
185 |
-
return self::$posAuthKey;
|
186 |
-
}
|
187 |
-
|
188 |
-
/**
|
189 |
-
* @access public
|
190 |
-
* @param string
|
191 |
-
*/
|
192 |
-
public static function setClientId($value)
|
193 |
-
{
|
194 |
-
self::$clientId = trim($value);
|
195 |
-
}
|
196 |
-
|
197 |
-
/**
|
198 |
-
* @access public
|
199 |
-
* @return string
|
200 |
-
*/
|
201 |
-
public static function getClientId()
|
202 |
-
{
|
203 |
-
return self::$clientId;
|
204 |
-
}
|
205 |
-
|
206 |
-
/**
|
207 |
-
* @access public
|
208 |
-
* @param string
|
209 |
-
*/
|
210 |
-
public static function setClientSecret($value)
|
211 |
-
{
|
212 |
-
self::$clientSecret = trim($value);
|
213 |
-
}
|
214 |
-
|
215 |
-
/**
|
216 |
-
* @access public
|
217 |
-
* @return string
|
218 |
-
*/
|
219 |
-
public static function getClientSecret()
|
220 |
-
{
|
221 |
-
return self::$clientSecret;
|
222 |
-
}
|
223 |
-
|
224 |
-
/**
|
225 |
-
* @access public
|
226 |
-
* @param string
|
227 |
-
*/
|
228 |
-
public static function setSignatureKey($value)
|
229 |
-
{
|
230 |
-
self::$signatureKey = trim($value);
|
231 |
-
}
|
232 |
-
|
233 |
-
/**
|
234 |
-
* @access public
|
235 |
-
* @return string
|
236 |
-
*/
|
237 |
-
public static function getSignatureKey()
|
238 |
-
{
|
239 |
-
return self::$signatureKey;
|
240 |
-
}
|
241 |
-
|
242 |
-
/**
|
243 |
-
* @access public
|
244 |
-
* @return string
|
245 |
-
*/
|
246 |
-
public static function getDataFormat($withDot = false)
|
247 |
-
{
|
248 |
-
if ($withDot) {
|
249 |
-
return "." . self::$dataFormat;
|
250 |
-
}
|
251 |
-
|
252 |
-
return self::$dataFormat;
|
253 |
-
}
|
254 |
-
|
255 |
-
/**
|
256 |
-
* @access public
|
257 |
-
* @param string $sender
|
258 |
-
*/
|
259 |
-
public static function setSender($sender)
|
260 |
-
{
|
261 |
-
self::$sender = $sender;
|
262 |
-
}
|
263 |
-
|
264 |
-
/**
|
265 |
-
* @return string
|
266 |
-
*/
|
267 |
-
public static function getSender()
|
268 |
-
{
|
269 |
-
return self::$sender;
|
270 |
-
}
|
271 |
-
|
272 |
-
/**
|
273 |
-
* @return string
|
274 |
-
*/
|
275 |
-
public static function getFullSenderName()
|
276 |
-
{
|
277 |
-
return sprintf("%s@%s", self::getSender(), self::getSdkVersion());
|
278 |
-
}
|
279 |
-
|
280 |
-
/**
|
281 |
-
* @return string
|
282 |
-
*/
|
283 |
-
public static function getSdkVersion()
|
284 |
-
{
|
285 |
-
$composerFilePath = self::getComposerFilePath();
|
286 |
-
if (file_exists($composerFilePath)) {
|
287 |
-
$fileContent = file_get_contents($composerFilePath);
|
288 |
-
$composerData = json_decode($fileContent);
|
289 |
-
if (isset($composerData->version) && isset($composerData->extra[0]->engine) )
|
290 |
-
return sprintf("%s %s", $composerData->extra[0]->engine, $composerData->version);
|
291 |
-
}
|
292 |
-
return self::DEFAULT_SDK_VERSION;
|
293 |
-
}
|
294 |
-
|
295 |
-
/**
|
296 |
-
* @return string
|
297 |
-
*/
|
298 |
-
private static function getComposerFilePath()
|
299 |
-
{
|
300 |
-
return realpath(dirname(__FILE__)) .'/../../'.self::COMPOSER_JSON;
|
301 |
-
}
|
302 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/payu/sdk_v21/OpenPayU/Http.php
DELETED
@@ -1,135 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* OpenPayU
|
4 |
-
*
|
5 |
-
* @copyright Copyright (c) 2014 PayU
|
6 |
-
*/
|
7 |
-
class OpenPayU_Http
|
8 |
-
{
|
9 |
-
/**
|
10 |
-
* @param $pathUrl
|
11 |
-
* @param $data
|
12 |
-
* @return mixed
|
13 |
-
*/
|
14 |
-
public static function post($pathUrl, $data)
|
15 |
-
{
|
16 |
-
//$signature = OpenPayU_Util::generateSignData($data, OpenPayU_Configuration::getHashAlgorithm(), OpenPayU_Configuration::getMerchantPosId(), OpenPayU_Configuration::getSignatureKey());
|
17 |
-
|
18 |
-
$posId = OpenPayU_Configuration::getMerchantPosId();
|
19 |
-
$sigantureKey = OpenPayU_Configuration::getSignatureKey();
|
20 |
-
|
21 |
-
$response = OpenPayU_HttpCurl::doRequest('POST', $pathUrl, $data, $posId, $sigantureKey);
|
22 |
-
|
23 |
-
return $response;
|
24 |
-
}
|
25 |
-
|
26 |
-
public static function postWithSignature($pathUrl, $data)
|
27 |
-
{
|
28 |
-
//$signature = OpenPayU_Util::generateSignData($data, OpenPayU_Configuration::getHashAlgorithm(), OpenPayU_Configuration::getMerchantPosId(), OpenPayU_Configuration::getSignatureKey());
|
29 |
-
|
30 |
-
$posId = OpenPayU_Configuration::getMerchantPosId();
|
31 |
-
$sigantureKey = OpenPayU_Configuration::getSignatureKey();
|
32 |
-
|
33 |
-
$response = OpenPayU_HttpCurl::doRequest('POST', $pathUrl, $data, $posId, $sigantureKey);
|
34 |
-
|
35 |
-
return $response;
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* @param $pathUrl
|
40 |
-
* @param $data
|
41 |
-
* @return mixed
|
42 |
-
*/
|
43 |
-
public static function get($pathUrl, $data)
|
44 |
-
{
|
45 |
-
$posId = OpenPayU_Configuration::getMerchantPosId();
|
46 |
-
$sigantureKey = OpenPayU_Configuration::getSignatureKey();
|
47 |
-
|
48 |
-
$response = OpenPayU_HttpCurl::doRequest('GET', $pathUrl, $data, $posId, $sigantureKey);
|
49 |
-
|
50 |
-
return $response;
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* @param $pathUrl
|
55 |
-
* @param $data
|
56 |
-
* @return mixed
|
57 |
-
*/
|
58 |
-
public static function put($pathUrl, $data)
|
59 |
-
{
|
60 |
-
$posId = OpenPayU_Configuration::getMerchantPosId();
|
61 |
-
$sigantureKey = OpenPayU_Configuration::getSignatureKey();
|
62 |
-
|
63 |
-
$response = OpenPayU_HttpCurl::doRequest('PUT', $pathUrl, $data, $posId, $sigantureKey);
|
64 |
-
|
65 |
-
return $response;
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* @param $pathUrl
|
70 |
-
* @param $data
|
71 |
-
* @return mixed
|
72 |
-
*/
|
73 |
-
public static function delete($pathUrl, $data)
|
74 |
-
{
|
75 |
-
$posId = OpenPayU_Configuration::getMerchantPosId();
|
76 |
-
$sigantureKey = OpenPayU_Configuration::getSignatureKey();
|
77 |
-
|
78 |
-
$response = OpenPayU_HttpCurl::doRequest('DELETE', $pathUrl, $data, $posId, $sigantureKey);
|
79 |
-
|
80 |
-
return $response;
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
*
|
85 |
-
*
|
86 |
-
* @param $statusCode
|
87 |
-
* @param null $message
|
88 |
-
* @throws OpenPayU_Exception
|
89 |
-
* @throws OpenPayU_Exception_Authorization
|
90 |
-
* @throws OpenPayU_Exception_Network
|
91 |
-
* @throws OpenPayU_Exception_ServerMaintenance
|
92 |
-
* @throws OpenPayU_Exception_ServerError
|
93 |
-
*/
|
94 |
-
public static function throwHttpStatusException($statusCode, $message = null)
|
95 |
-
{
|
96 |
-
switch ($statusCode) {
|
97 |
-
default:
|
98 |
-
throw new OpenPayU_Exception_Network('Unexpected HTTP code response', $statusCode);
|
99 |
-
break;
|
100 |
-
|
101 |
-
case 400:
|
102 |
-
throw new OpenPayU_Exception(trim($message->Status->StatusCode . (isset($message->Status->StatusDesc) ?
|
103 |
-
' - ' . $message->Status->StatusDesc : '')), $statusCode);
|
104 |
-
break;
|
105 |
-
|
106 |
-
case 401:
|
107 |
-
throw new OpenPayU_Exception_Authorization(trim($message->Status->StatusCode .
|
108 |
-
(isset($message->Status->StatusDesc) ? ' - ' . $message->Status->StatusDesc : '')), $statusCode);
|
109 |
-
break;
|
110 |
-
|
111 |
-
case 403:
|
112 |
-
throw new OpenPayU_Exception_Authorization(trim($message->Status->StatusCode), $statusCode);
|
113 |
-
break;
|
114 |
-
|
115 |
-
case 404:
|
116 |
-
throw new OpenPayU_Exception_Network('Data indicated in the request is not available in the PayU system.');
|
117 |
-
break;
|
118 |
-
|
119 |
-
case 408:
|
120 |
-
throw new OpenPayU_Exception_ServerError('Request timeout', $statusCode);
|
121 |
-
break;
|
122 |
-
|
123 |
-
case 500:
|
124 |
-
throw new OpenPayU_Exception_ServerError('PayU system is unavailable or your order is not processed.
|
125 |
-
Error:
|
126 |
-
[' . (isset($message->Status->StatusDesc) ?
|
127 |
-
$message->Status->StatusDesc : '') . ']', $statusCode);
|
128 |
-
break;
|
129 |
-
|
130 |
-
case 503:
|
131 |
-
throw new OpenPayU_Exception_ServerMaintenance('Service unavailable', $statusCode);
|
132 |
-
break;
|
133 |
-
}
|
134 |
-
}
|
135 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/payu/sdk_v21/OpenPayU/HttpProtocol.php
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* OpenPayU
|
4 |
-
*
|
5 |
-
* @copyright Copyright (c) 2014 PayU
|
6 |
-
*/
|
7 |
-
interface OpenPayU_HttpProtocol
|
8 |
-
{
|
9 |
-
public static function doRequest($requestType, $pathUrl, $fieldsList, $posId, $signatureKey);
|
10 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/payu/sdk_v21/OpenPayU/OpenPayU.php
DELETED
@@ -1,250 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
OpenPayU Standard Library
|
5 |
-
|
6 |
-
@copyright Copyright (c) 2011-2014 PayU
|
7 |
-
@license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
8 |
-
http://www.payu.com
|
9 |
-
http://developers.payu.com
|
10 |
-
http://twitter.com/openpayu
|
11 |
-
*/
|
12 |
-
|
13 |
-
class OpenPayU extends OpenPayUBase
|
14 |
-
{
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Function builds OrderCreateRequest Document
|
18 |
-
* @access public
|
19 |
-
* @param string $data
|
20 |
-
* @return string
|
21 |
-
*/
|
22 |
-
public static function buildOrderCreateRequest($data)
|
23 |
-
{
|
24 |
-
$xml = OpenPayU::buildOpenPayURequestDocument($data, 'OrderCreateRequest');
|
25 |
-
return $xml;
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Function builds OrderRetrieveRequest Document
|
30 |
-
* @access public
|
31 |
-
* @param array $data
|
32 |
-
* @return string $xml
|
33 |
-
*/
|
34 |
-
public static function buildOrderRetrieveRequest($data)
|
35 |
-
{
|
36 |
-
$xml = OpenPayU::buildOpenPayURequestDocument($data, 'OrderRetrieveRequest');
|
37 |
-
return $xml;
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Function builds ShippingCostRetrieveResponse Document
|
42 |
-
* @access public
|
43 |
-
* @param array $data
|
44 |
-
* @param string $reqId
|
45 |
-
* @return string $xml
|
46 |
-
*/
|
47 |
-
public static function buildShippingCostRetrieveResponse($data, $reqId)
|
48 |
-
{
|
49 |
-
|
50 |
-
$cost = array(
|
51 |
-
'ResId' => $reqId,
|
52 |
-
'Status' => array('StatusCode' => 'OPENPAYU_SUCCESS'),
|
53 |
-
'AvailableShippingCost' => $data
|
54 |
-
);
|
55 |
-
|
56 |
-
$xml = OpenPayU::buildOpenPayUResponseDocument($cost, 'ShippingCostRetrieveResponse');
|
57 |
-
return $xml;
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Function builds buildOrderNotifyResponse Document
|
62 |
-
* @access public
|
63 |
-
* @param string $reqId
|
64 |
-
* @return string $xml
|
65 |
-
*/
|
66 |
-
public static function buildOrderNotifyResponse($reqId)
|
67 |
-
{
|
68 |
-
|
69 |
-
$data = array(
|
70 |
-
'resId' => $reqId,
|
71 |
-
'status' => array('statusCode' => 'SUCCESS')
|
72 |
-
);
|
73 |
-
|
74 |
-
$response = OpenPayU_Util::buildJsonFromArray($data);
|
75 |
-
return $response;
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Function builds verifyResponse Status
|
80 |
-
* @access public
|
81 |
-
* @param string $data
|
82 |
-
* @param string $message
|
83 |
-
* @return string $xml
|
84 |
-
*/
|
85 |
-
public static function verifyResponse($data, $message)
|
86 |
-
{
|
87 |
-
$document = OpenPayU_Util::parseXmlDocument(stripslashes($data));
|
88 |
-
$status = null;
|
89 |
-
|
90 |
-
if (OpenPayU_Configuration::getApiVersion() < 2)
|
91 |
-
$status = $document['OpenPayU']['OrderDomainResponse'][$message]['Status'];
|
92 |
-
else
|
93 |
-
$status = $document['OpenPayU'][$message]['Status'];
|
94 |
-
|
95 |
-
if (empty($status) && OpenPayU_Configuration::getApiVersion() < 2)
|
96 |
-
$status = $document['OpenPayU']['HeaderResponse']['Status'];
|
97 |
-
|
98 |
-
return $status;
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Function returns OrderCancelResponse Status Document
|
103 |
-
* @access public
|
104 |
-
* @param string $data
|
105 |
-
* @return OpenPayU_Result
|
106 |
-
*/
|
107 |
-
public static function verifyOrderCancelResponseStatus($data)
|
108 |
-
{
|
109 |
-
return OpenPayU::verifyResponse($data, 'OrderCancelResponse');
|
110 |
-
}
|
111 |
-
|
112 |
-
/**
|
113 |
-
* Function returns OrderStatusUpdateResponse Status Document
|
114 |
-
* @access public
|
115 |
-
* @param string $data
|
116 |
-
* @return mixed
|
117 |
-
*/
|
118 |
-
public static function verifyOrderStatusUpdateResponseStatus($data)
|
119 |
-
{
|
120 |
-
return OpenPayU::verifyResponse($data, 'OrderStatusUpdateResponse');
|
121 |
-
}
|
122 |
-
|
123 |
-
/**
|
124 |
-
* Function returns OrderCreateResponse Status
|
125 |
-
* @access public
|
126 |
-
* @param string $data
|
127 |
-
* @return mixed
|
128 |
-
*/
|
129 |
-
public static function verifyOrderCreateResponse($data)
|
130 |
-
{
|
131 |
-
return OpenPayU::verifyResponse($data, 'OrderCreateResponse');
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
* Function returns OrderRetrieveResponse Status
|
136 |
-
* @access public
|
137 |
-
* @param string $data
|
138 |
-
* @return mixed
|
139 |
-
*/
|
140 |
-
public static function verifyOrderRetrieveResponseStatus($data)
|
141 |
-
{
|
142 |
-
return OpenPayU::verifyResponse($data, 'OrderRetrieveResponse');
|
143 |
-
}
|
144 |
-
|
145 |
-
/**
|
146 |
-
* Function returns OrderRetrieveResponse Data
|
147 |
-
* @access public
|
148 |
-
* @param string $data
|
149 |
-
* @return array $document
|
150 |
-
*/
|
151 |
-
public static function getOrderRetrieveResponse($data)
|
152 |
-
{
|
153 |
-
$response = OpenPayU::parseXmlDocument(stripslashes($data));
|
154 |
-
|
155 |
-
$document = $response['OpenPayU']['OrderDomainResponse']['OrderRetrieveResponse'];
|
156 |
-
|
157 |
-
if (OpenPayU_Configuration::getApiVersion() >= 2)
|
158 |
-
$document = $response['OpenPayU']['OrderRetrieveResponse'];
|
159 |
-
|
160 |
-
return $document;
|
161 |
-
}
|
162 |
-
|
163 |
-
/**
|
164 |
-
* Function builds OrderCancelRequest Document
|
165 |
-
* @access public
|
166 |
-
* @param string $data
|
167 |
-
* @return string $xml
|
168 |
-
*/
|
169 |
-
public static function buildOrderCancelRequest($data)
|
170 |
-
{
|
171 |
-
$xml = OpenPayU::buildOpenPayURequestDocument($data, 'OrderCancelRequest');
|
172 |
-
|
173 |
-
return $xml;
|
174 |
-
}
|
175 |
-
|
176 |
-
/**
|
177 |
-
* Function builds OrderStatusUpdateRequest Document
|
178 |
-
* @access public
|
179 |
-
* @param string $data
|
180 |
-
* @return string $xml
|
181 |
-
*/
|
182 |
-
public static function buildOrderStatusUpdateRequest($data)
|
183 |
-
{
|
184 |
-
$xml = OpenPayU::buildOpenPayURequestDocument($data, 'OrderStatusUpdateRequest');
|
185 |
-
|
186 |
-
return $xml;
|
187 |
-
}
|
188 |
-
|
189 |
-
protected static function build($data)
|
190 |
-
{
|
191 |
-
$instance = new OpenPayU_Result();
|
192 |
-
$instance->init($data);
|
193 |
-
|
194 |
-
return $instance;
|
195 |
-
}
|
196 |
-
|
197 |
-
/**
|
198 |
-
* @throws OpenPayU_Exception_Authorization
|
199 |
-
*/
|
200 |
-
public static function verifyBasicAuthCredentials()
|
201 |
-
{
|
202 |
-
if (isset($_SERVER['PHP_AUTH_USER'])) {
|
203 |
-
$user = (string)$_SERVER['PHP_AUTH_USER'];
|
204 |
-
} else {
|
205 |
-
throw new OpenPayU_Exception_Authorization('Empty user name');
|
206 |
-
}
|
207 |
-
|
208 |
-
if (isset($_SERVER['PHP_AUTH_PW'])) {
|
209 |
-
$password = (string)$_SERVER['PHP_AUTH_PW'];
|
210 |
-
} else {
|
211 |
-
throw new OpenPayU_Exception_Authorization('Empty password');
|
212 |
-
}
|
213 |
-
|
214 |
-
if ($user !== OpenPayU_Configuration::getMerchantPosId() ||
|
215 |
-
$password !== OpenPayU_Configuration::getSignatureKey()
|
216 |
-
) {
|
217 |
-
throw new OpenPayU_Exception_Authorization("invalid credentials");
|
218 |
-
}
|
219 |
-
}
|
220 |
-
|
221 |
-
/**
|
222 |
-
* @param $data
|
223 |
-
* @param $incomingSignature
|
224 |
-
* @throws OpenPayU_Exception_Authorization
|
225 |
-
*/
|
226 |
-
public static function verifyDocumentSignature($data, $incomingSignature)
|
227 |
-
{
|
228 |
-
$sign = OpenPayU_Util::parseSignature($incomingSignature);
|
229 |
-
|
230 |
-
if (false === OpenPayU_Util::verifySignature(
|
231 |
-
$data,
|
232 |
-
$sign->signature,
|
233 |
-
OpenPayU_Configuration::getSignatureKey(),
|
234 |
-
$sign->algorithm
|
235 |
-
)
|
236 |
-
) {
|
237 |
-
throw new OpenPayU_Exception_Authorization('Invalid signature - ' . $sign->signature);
|
238 |
-
}
|
239 |
-
}
|
240 |
-
|
241 |
-
/**
|
242 |
-
* @return bool
|
243 |
-
*/
|
244 |
-
public static function isSecureConnection()
|
245 |
-
{
|
246 |
-
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
|
247 |
-
return true;
|
248 |
-
return false;
|
249 |
-
}
|
250 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/payu/sdk_v21/OpenPayU/OpenPayUBase.php
DELETED
@@ -1,265 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
OpenPayU Standard Library
|
5 |
-
|
6 |
-
@copyright Copyright (c) 2011-2014 PayU
|
7 |
-
@license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
8 |
-
http://www.payu.com
|
9 |
-
http://developers.payu.com
|
10 |
-
http://twitter.com/openpayu
|
11 |
-
*/
|
12 |
-
|
13 |
-
class OpenPayUBase extends OpenPayUNetwork
|
14 |
-
{
|
15 |
-
|
16 |
-
/** @var string outputConsole message */
|
17 |
-
protected static $outputConsole = '';
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Show outputConsole message
|
21 |
-
* @access public
|
22 |
-
*/
|
23 |
-
public static function printOutputConsole()
|
24 |
-
{
|
25 |
-
echo OpenPayU::$outputConsole;
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Add $outputConsole message
|
30 |
-
* @access public
|
31 |
-
* @param string $header
|
32 |
-
* @param string $text
|
33 |
-
*/
|
34 |
-
public static function addOutputConsole($header, $text = '')
|
35 |
-
{
|
36 |
-
OpenPayU::$outputConsole .= '<br/><strong>' . $header . ':</strong><br />' . $text . '<br/>';
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Function builds OpenPayU Request Document
|
41 |
-
* @access public
|
42 |
-
* @param string $data
|
43 |
-
* @param string $startElement Name of Document Element
|
44 |
-
* @param string $version Xml Version
|
45 |
-
* @param string $xml_encoding Xml Encoding
|
46 |
-
* @return string
|
47 |
-
*/
|
48 |
-
public static function buildOpenPayURequestDocument($data, $startElement, $version = '1.0', $xml_encoding = 'UTF-8')
|
49 |
-
{
|
50 |
-
return OpenPayUBase::buildOpenPayUDocument($data, $startElement, 1, $version, $xml_encoding);
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Function builds OpenPayU Response Document
|
55 |
-
* @access public
|
56 |
-
* @param string $data
|
57 |
-
* @param string $startElement Name of Document Element
|
58 |
-
* @param string $version Xml Version
|
59 |
-
* @param string $xml_encoding Xml Encoding
|
60 |
-
* @return string
|
61 |
-
*/
|
62 |
-
public static function buildOpenPayUResponseDocument($data, $startElement, $version = '1.0', $xml_encoding = 'UTF-8')
|
63 |
-
{
|
64 |
-
return OpenPayUBase::buildOpenPayUDocument($data, $startElement, 0, $version, $xml_encoding);
|
65 |
-
}
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Function converts array to XML document
|
69 |
-
* @access public
|
70 |
-
* @deprecated
|
71 |
-
* @param XMLWriter $xml
|
72 |
-
* @param array $data
|
73 |
-
*/
|
74 |
-
public static function arr2xml(XMLWriter $xml, $data)
|
75 |
-
{
|
76 |
-
if (!empty($data) && is_array($data)) {
|
77 |
-
foreach ($data as $key => $value) {
|
78 |
-
if (is_array($value)) {
|
79 |
-
if (is_numeric($key)) {
|
80 |
-
self::arr2xml($xml, $value);
|
81 |
-
} else {
|
82 |
-
$xml->startElement($key);
|
83 |
-
self::arr2xml($xml, $value);
|
84 |
-
$xml->endElement();
|
85 |
-
}
|
86 |
-
continue;
|
87 |
-
}
|
88 |
-
$xml->writeElement($key, $value);
|
89 |
-
}
|
90 |
-
}
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Function converts array to Form
|
95 |
-
* @access public
|
96 |
-
* @param array $data
|
97 |
-
* @param string $parent
|
98 |
-
* @param integer $index
|
99 |
-
* @return string $fragment
|
100 |
-
*/
|
101 |
-
public static function arr2form($data, $parent, $index)
|
102 |
-
{
|
103 |
-
$fragment = '';
|
104 |
-
|
105 |
-
if (!empty($data) && is_array($data)) {
|
106 |
-
foreach ($data as $key => $value) {
|
107 |
-
if (is_array($value)) {
|
108 |
-
if (is_numeric($key)) {
|
109 |
-
$fragment .= OpenPayUBase::arr2form($value, $parent, $key);
|
110 |
-
} else {
|
111 |
-
$p = $parent != '' ? $parent . '.' . $key : $key;
|
112 |
-
if (is_numeric($index)) {
|
113 |
-
$p .= '[' . $index . ']';
|
114 |
-
}
|
115 |
-
$fragment .= OpenPayUBase::arr2form($value, $p, $key);
|
116 |
-
}
|
117 |
-
continue;
|
118 |
-
}
|
119 |
-
|
120 |
-
$path = $parent != '' ? $parent . '.' . $key : $key;
|
121 |
-
$fragment .= OpenPayUBase::buildFormFragmentInput($path, $value);
|
122 |
-
}
|
123 |
-
}
|
124 |
-
|
125 |
-
return $fragment;
|
126 |
-
}
|
127 |
-
|
128 |
-
/**
|
129 |
-
* Function converts xml to array
|
130 |
-
* @access public
|
131 |
-
* @deprecated
|
132 |
-
* @param XMLReader $xml
|
133 |
-
* @return array $tree
|
134 |
-
*/
|
135 |
-
public static function read($xml)
|
136 |
-
{
|
137 |
-
$tree = null;
|
138 |
-
if(isset($xml))
|
139 |
-
{
|
140 |
-
while ($xml->read()) {
|
141 |
-
if ($xml->nodeType == XMLReader::END_ELEMENT) {
|
142 |
-
return $tree;
|
143 |
-
} else if ($xml->nodeType == XMLReader::ELEMENT) {
|
144 |
-
if (!$xml->isEmptyElement) {
|
145 |
-
$tree[$xml->name] = OpenPayUBase::read($xml);
|
146 |
-
}
|
147 |
-
} else if ($xml->nodeType == XMLReader::TEXT) {
|
148 |
-
$tree = $xml->value;
|
149 |
-
}
|
150 |
-
}
|
151 |
-
}
|
152 |
-
return $tree;
|
153 |
-
}
|
154 |
-
|
155 |
-
/**
|
156 |
-
* Function builds OpenPayU Xml Document
|
157 |
-
* @access public
|
158 |
-
* @param string $data
|
159 |
-
* @param string $startElement
|
160 |
-
* @param integer $request
|
161 |
-
* @param string $xml_version
|
162 |
-
* @param string $xml_encoding
|
163 |
-
* @return string $xml
|
164 |
-
*/
|
165 |
-
public static function buildOpenPayUDocument($data, $startElement, $request = 1, $xml_version = '1.0', $xml_encoding = 'UTF-8')
|
166 |
-
{
|
167 |
-
if (!is_array($data))
|
168 |
-
return false;
|
169 |
-
|
170 |
-
$xml = new XmlWriter();
|
171 |
-
$xml->openMemory();
|
172 |
-
$xml->startDocument($xml_version, $xml_encoding);
|
173 |
-
|
174 |
-
if(OpenPayU_Configuration::getApiVersion() < 2)
|
175 |
-
{
|
176 |
-
$xml->startElementNS(null, 'OpenPayU', 'http://www.openpayu.com/openpayu.xsd');
|
177 |
-
$header = $request == 1 ? 'HeaderRequest' : 'HeaderResponse';
|
178 |
-
|
179 |
-
$xml->startElement($header);
|
180 |
-
|
181 |
-
$xml->writeElement('Algorithm', OpenPayU_Configuration::getHashAlgorithm());
|
182 |
-
|
183 |
-
$xml->writeElement('SenderName', 'exampleSenderName');
|
184 |
-
$xml->writeElement('Version', $xml_version);
|
185 |
-
|
186 |
-
$xml->endElement();
|
187 |
-
}
|
188 |
-
else
|
189 |
-
$xml->startElementNS(null, 'OpenPayU', 'http://www.openpayu.com/20/openpayu.xsd');
|
190 |
-
|
191 |
-
// domain level - open
|
192 |
-
if(OpenPayU_Configuration::getApiVersion() < 2)
|
193 |
-
$xml->startElement(OpenPayUDomain::getDomain4Message($startElement));
|
194 |
-
|
195 |
-
// message level - open
|
196 |
-
$xml->startElement($startElement);
|
197 |
-
|
198 |
-
OpenPayU_Util::convertArrayToXml($xml, $data);
|
199 |
-
|
200 |
-
// message level - close
|
201 |
-
$xml->endElement();
|
202 |
-
// domain level - close
|
203 |
-
$xml->endElement();
|
204 |
-
|
205 |
-
// document level - close
|
206 |
-
if(OpenPayU_Configuration::getApiVersion() < 2)
|
207 |
-
$xml->endElement();
|
208 |
-
|
209 |
-
return $xml->outputMemory(true);
|
210 |
-
}
|
211 |
-
|
212 |
-
/**
|
213 |
-
* Function builds form input element
|
214 |
-
* @access public
|
215 |
-
* @param string $name
|
216 |
-
* @param string $value
|
217 |
-
* @param string $type
|
218 |
-
* @return string
|
219 |
-
*/
|
220 |
-
public static function buildFormFragmentInput($name, $value, $type = 'hidden')
|
221 |
-
{
|
222 |
-
return "<input type='" . $type . "' name='" . $name . "' value='" . $value . "'>\n";
|
223 |
-
}
|
224 |
-
|
225 |
-
/**
|
226 |
-
* Function builds OpenPayU Form
|
227 |
-
* @access public
|
228 |
-
* @param string $data
|
229 |
-
* @param string $msgName
|
230 |
-
* @param string $version
|
231 |
-
* @return string
|
232 |
-
*/
|
233 |
-
public static function buildOpenPayuForm($data, $msgName, $version = '1.0')
|
234 |
-
{
|
235 |
-
if (!is_array($data))
|
236 |
-
return false;
|
237 |
-
|
238 |
-
$url = OpenPayUNetwork::getOpenPayuEndPoint();
|
239 |
-
|
240 |
-
$form = "<form method='post' action='" . $url . "'>\n";
|
241 |
-
$form .= OpenPayUBase::buildFormFragmentInput('HeaderRequest.Version', $version);
|
242 |
-
$form .= OpenPayUBase::buildFormFragmentInput('HeaderRequest.Name', $msgName);
|
243 |
-
$form .= OpenPayUBase::arr2form($data, '', '');
|
244 |
-
$form .= "</form>";
|
245 |
-
|
246 |
-
return $form;
|
247 |
-
}
|
248 |
-
|
249 |
-
/**
|
250 |
-
* Function converts Xml string to array
|
251 |
-
* @access public
|
252 |
-
* @deprecated
|
253 |
-
* @param string $xmldata
|
254 |
-
* @return array $assoc
|
255 |
-
*/
|
256 |
-
public static function parseOpenPayUDocument($xmldata)
|
257 |
-
{
|
258 |
-
$xml = new XMLReader();
|
259 |
-
$xml->XML($xmldata);
|
260 |
-
|
261 |
-
$assoc = self::read($xml);
|
262 |
-
|
263 |
-
return $assoc;
|
264 |
-
}
|
265 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/payu/sdk_v21/OpenPayU/OpenPayUException.php
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* OpenPayU Exception
|
4 |
-
*
|
5 |
-
* @copyright Copyright (c) 2014 PayU
|
6 |
-
* @license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
7 |
-
*
|
8 |
-
* http://www.payu.com
|
9 |
-
* http://developers.payu.com
|
10 |
-
* http://twitter.com/openpayu
|
11 |
-
*
|
12 |
-
*/
|
13 |
-
|
14 |
-
|
15 |
-
class OpenPayU_Exception extends Exception
|
16 |
-
{
|
17 |
-
|
18 |
-
}
|
19 |
-
|
20 |
-
class OpenPayU_Exception_Configuration extends OpenPayU_Exception
|
21 |
-
{
|
22 |
-
|
23 |
-
}
|
24 |
-
|
25 |
-
class OpenPayU_Exception_Network extends OpenPayU_Exception
|
26 |
-
{
|
27 |
-
|
28 |
-
}
|
29 |
-
|
30 |
-
class OpenPayU_Exception_ServerError extends OpenPayU_Exception
|
31 |
-
{
|
32 |
-
|
33 |
-
}
|
34 |
-
|
35 |
-
class OpenPayU_Exception_ServerMaintenance extends OpenPayU_Exception
|
36 |
-
{
|
37 |
-
|
38 |
-
}
|
39 |
-
|
40 |
-
class OpenPayU_Exception_Authorization extends OpenPayU_Exception
|
41 |
-
{
|
42 |
-
|
43 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/payu/sdk_v21/OpenPayU/OpenPayUNetwork.php
DELETED
@@ -1,181 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
OpenPayU Standard Library
|
5 |
-
|
6 |
-
@copyright Copyright (c) 2011-2014 PayU
|
7 |
-
@license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
8 |
-
http://www.payu.com
|
9 |
-
http://developers.payu.com
|
10 |
-
http://twitter.com/openpayu
|
11 |
-
*/
|
12 |
-
|
13 |
-
class OpenPayUNetwork
|
14 |
-
{
|
15 |
-
/** @var string OpenPayU EndPoint Url */
|
16 |
-
protected static $openPayuEndPointUrl = '';
|
17 |
-
|
18 |
-
/**
|
19 |
-
* The function sets EndPointUrl param of OpenPayU
|
20 |
-
* @access public
|
21 |
-
* @param string $ep
|
22 |
-
*/
|
23 |
-
public static function setOpenPayuEndPoint($ep)
|
24 |
-
{
|
25 |
-
self::$openPayuEndPointUrl = $ep;
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* The function gets EndPointUrl param of OpenPayU
|
30 |
-
* @access public
|
31 |
-
* @return string;
|
32 |
-
*/
|
33 |
-
public static function getOpenPayuEndPoint()
|
34 |
-
{
|
35 |
-
return self::$openPayuEndPointUrl;
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* This function checks the availability of cURL
|
40 |
-
* @access private
|
41 |
-
* @return bool
|
42 |
-
*/
|
43 |
-
private static function isCurlInstalled()
|
44 |
-
{
|
45 |
-
if (in_array('curl', get_loaded_extensions()))
|
46 |
-
return true;
|
47 |
-
|
48 |
-
return false;
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* The function returns the parameter EndPointUrl OpenPayU
|
53 |
-
* @access public
|
54 |
-
* @deprecated
|
55 |
-
* @return string
|
56 |
-
* @throws OpenPayU_Exception_Configuration
|
57 |
-
*/
|
58 |
-
public static function OpenPayU_Exception_Configuration()
|
59 |
-
{
|
60 |
-
if (empty(self::$openPayuEndPointUrl))
|
61 |
-
throw new OpenPayU_Exception_Configuration('OpenPayUNetwork::$openPayuEndPointUrl is empty');
|
62 |
-
|
63 |
-
return self::$openPayuEndPointUrl;
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* This function sends data to the EndPointUrl OpenPayU
|
68 |
-
* @access public
|
69 |
-
* @deprecated
|
70 |
-
* @param string $doc
|
71 |
-
* @return string
|
72 |
-
* @throws OpenPayU_Exception_Configuration
|
73 |
-
*/
|
74 |
-
public static function sendOpenPayuDocument($doc)
|
75 |
-
{
|
76 |
-
|
77 |
-
if (empty(self::$openPayuEndPointUrl))
|
78 |
-
throw new OpenPayU_Exception_Configuration('OpenPayUNetwork::$openPayuEndPointUrl is empty');
|
79 |
-
|
80 |
-
if (!self::isCurlInstalled())
|
81 |
-
throw new OpenPayU_Exception_Configuration('cURL is not available');
|
82 |
-
|
83 |
-
$xml = urlencode($doc);
|
84 |
-
return OpenPayU::sendData(self::$openPayuEndPointUrl, 'DOCUMENT=' . $xml);
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* This function sends auth data to the EndPointUrl OpenPayU
|
89 |
-
* @access public
|
90 |
-
* @param string $doc
|
91 |
-
* @param integer $merchantPosId
|
92 |
-
* @param string $signatureKey
|
93 |
-
* @param string $algorithm
|
94 |
-
* @return string
|
95 |
-
* @throws OpenPayU_Exception_Configuration
|
96 |
-
* @deprecated
|
97 |
-
*/
|
98 |
-
public static function sendOpenPayuDocumentAuth($doc, $merchantPosId, $signatureKey, $algorithm = 'MD5')
|
99 |
-
{
|
100 |
-
if (empty(self::$openPayuEndPointUrl))
|
101 |
-
throw new OpenPayU_Exception_Configuration('OpenPayUNetwork::$openPayuEndPointUrl is empty');
|
102 |
-
|
103 |
-
if (empty($signatureKey))
|
104 |
-
throw new OpenPayU_Exception_Configuration('Merchant Signature Key should not be null or empty.');
|
105 |
-
|
106 |
-
if (empty($merchantPosId))
|
107 |
-
throw new OpenPayU_Exception_Configuration('MerchantPosId should not be null or empty.');
|
108 |
-
|
109 |
-
$tosigndata = $doc . $signatureKey;
|
110 |
-
$xml = urlencode($doc);
|
111 |
-
$signature = '';
|
112 |
-
if ($algorithm == 'MD5') {
|
113 |
-
$signature = md5($tosigndata);
|
114 |
-
} else if ($algorithm == 'SHA') {
|
115 |
-
$signature = sha1($tosigndata);
|
116 |
-
} else if ($algorithm == 'SHA-256' || $algorithm == 'SHA256' || $algorithm == 'SHA_256') {
|
117 |
-
$signature = hash('sha256', $tosigndata);
|
118 |
-
}
|
119 |
-
$authData = 'sender=' . $merchantPosId .
|
120 |
-
';signature=' . $signature .
|
121 |
-
';algorithm=' . $algorithm .
|
122 |
-
';content=DOCUMENT';
|
123 |
-
|
124 |
-
if (!self::isCurlInstalled())
|
125 |
-
throw new OpenPayU_Exception_Configuration('curl is not available');
|
126 |
-
|
127 |
-
return OpenPayU::sendDataAuth(self::$openPayuEndPointUrl, 'DOCUMENT=' . $xml, $authData);
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* This function sends auth data to the EndPointUrl OpenPayU
|
132 |
-
* @access public
|
133 |
-
* @deprecated
|
134 |
-
* @param string $url
|
135 |
-
* @param string $doc
|
136 |
-
* @param string $authData
|
137 |
-
* @return string $response
|
138 |
-
*/
|
139 |
-
public static function sendDataAuth($url, $doc, $authData)
|
140 |
-
{
|
141 |
-
$ch = curl_init($url);
|
142 |
-
curl_setopt($ch, CURLOPT_POST, 1);
|
143 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, $doc);
|
144 |
-
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
|
145 |
-
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
146 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
147 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
148 |
-
curl_setopt($ch, CURLOPT_HEADER, false);
|
149 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
150 |
-
|
151 |
-
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-OpenPayU-Signature:' . $authData));
|
152 |
-
|
153 |
-
$response = curl_exec($ch);
|
154 |
-
|
155 |
-
return $response;
|
156 |
-
}
|
157 |
-
|
158 |
-
/**
|
159 |
-
* This function sends data to the EndPointUrl OpenPayU
|
160 |
-
* @access public
|
161 |
-
* @param string $url
|
162 |
-
* @param string $doc
|
163 |
-
* @return string $response
|
164 |
-
*/
|
165 |
-
public static function sendData($url, $doc)
|
166 |
-
{
|
167 |
-
$ch = curl_init($url);
|
168 |
-
curl_setopt($ch, CURLOPT_POST, 1);
|
169 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, $doc);
|
170 |
-
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
|
171 |
-
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
|
172 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
173 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
174 |
-
curl_setopt($ch, CURLOPT_HEADER, false);
|
175 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
176 |
-
|
177 |
-
$response = curl_exec($ch);
|
178 |
-
|
179 |
-
return $response;
|
180 |
-
}
|
181 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/payu/sdk_v21/OpenPayU/v2/Token.php
DELETED
@@ -1,66 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* OpenPayU Token module
|
4 |
-
*
|
5 |
-
* @copyright Copyright (c) 2014 PayU
|
6 |
-
* @license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
7 |
-
*
|
8 |
-
* http://www.payu.com
|
9 |
-
* http://developers.payu.com
|
10 |
-
* http://twitter.com/openpayu
|
11 |
-
*
|
12 |
-
*/
|
13 |
-
|
14 |
-
class OpenPayU_Token extends OpenPayU
|
15 |
-
{
|
16 |
-
/**
|
17 |
-
* @deprecated
|
18 |
-
* @param array $data
|
19 |
-
* @return OpenPayU_Result
|
20 |
-
*/
|
21 |
-
public static function create($data)
|
22 |
-
{
|
23 |
-
$pathUrl = OpenPayU_Configuration::getServiceUrl() . 'token' . OpenPayU_Configuration::getDataFormat(true);
|
24 |
-
|
25 |
-
$xml = OpenPayU_Util::buildXmlFromArray($data, 'TokenCreateRequest');
|
26 |
-
|
27 |
-
$result = self::verifyResponse(OpenPayU_Http::post($pathUrl, $xml), 'TokenCreateResponse');
|
28 |
-
|
29 |
-
return $result;
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* @param string $response
|
34 |
-
* @param string $messageName
|
35 |
-
* @return null|OpenPayU_Result
|
36 |
-
*/
|
37 |
-
public static function verifyResponse($response, $messageName)
|
38 |
-
{
|
39 |
-
$data = array();
|
40 |
-
$httpStatus = $response['code'];
|
41 |
-
$message = OpenPayU_Util::parseXmlDocument($response['response']);
|
42 |
-
|
43 |
-
if (isset($message['OpenPayU'][$messageName])) {
|
44 |
-
$status = $message['OpenPayU'][$messageName]['Status'];
|
45 |
-
$data['Status'] = $status;
|
46 |
-
unset($message['OpenPayU'][$messageName]['Status']);
|
47 |
-
$data['Response'] = $message['OpenPayU'][$messageName];
|
48 |
-
}
|
49 |
-
elseif(isset($message['OpenPayU']))
|
50 |
-
{
|
51 |
-
$status = $message['OpenPayU']['Status'];
|
52 |
-
$data['Status'] = $status;
|
53 |
-
unset($message['OpenPayU']['Status']);
|
54 |
-
}
|
55 |
-
|
56 |
-
$result = self::build($data);
|
57 |
-
|
58 |
-
if ($httpStatus == 200 || $httpStatus == 201 || $httpStatus == 422 || $httpStatus == 302)
|
59 |
-
return $result;
|
60 |
-
else {
|
61 |
-
OpenPayU_Http::throwHttpStatusException($httpStatus, $result);
|
62 |
-
}
|
63 |
-
|
64 |
-
return null;
|
65 |
-
}
|
66 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/payu/sdk_v21/openpayu.php
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
* ver. 1.9.2
|
5 |
-
* OpenPayU Standard Library
|
6 |
-
|
7 |
-
* @copyright Copyright (c) 2011-2014 PayU
|
8 |
-
* @license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
9 |
-
* http://www.payu.com
|
10 |
-
* http://developers.payu.com
|
11 |
-
* http://twitter.com/openpayu
|
12 |
-
*/
|
13 |
-
|
14 |
-
define('OPENPAYU_LIBRARY', true);
|
15 |
-
include_once('OpenPayU/Util.php');
|
16 |
-
include_once('openpayu_domain.php');
|
17 |
-
include_once('OpenPayU/OpenPayUException.php');
|
18 |
-
include_once('OpenPayU/OpenPayUNetwork.php');
|
19 |
-
include_once('OpenPayU/OpenPayUBase.php');
|
20 |
-
include_once('OpenPayU/OpenPayU.php');
|
21 |
-
|
22 |
-
include_once('OpenPayU/Result.php');
|
23 |
-
include_once('OpenPayU/Configuration.php');
|
24 |
-
|
25 |
-
|
26 |
-
include_once('OpenPayU/v2/Refund.php');
|
27 |
-
include_once('OpenPayU/v2/Order.php');
|
28 |
-
require_once('OpenPayU/Http.php');
|
29 |
-
require_once('OpenPayU/HttpProtocol.php');
|
30 |
-
require_once('OpenPayU/HttpCurl.php');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/payu/sdk_v21/openpayu_domain.php
DELETED
@@ -1,67 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
OpenPayU Standard Library
|
5 |
-
|
6 |
-
@copyright Copyright (c) 2011-2014 PayU
|
7 |
-
@license http://opensource.org/licenses/LGPL-3.0 Open Software License (LGPL 3.0)
|
8 |
-
http://www.payu.com
|
9 |
-
http://developers.payu.com
|
10 |
-
http://twitter.com/openpayu
|
11 |
-
|
12 |
-
*/
|
13 |
-
|
14 |
-
class OpenPayUDomain
|
15 |
-
{
|
16 |
-
|
17 |
-
private static $msg2domain = null;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* @deprecated
|
21 |
-
*/
|
22 |
-
private static function builder()
|
23 |
-
{
|
24 |
-
OpenPayUDomain::$msg2domain = array
|
25 |
-
(
|
26 |
-
'OrderCreateRequest' => 'OrderDomainRequest',
|
27 |
-
'OrderCreateResponse' => 'OrderDomainResponse',
|
28 |
-
'OrderStatusUpdateRequest' => 'OrderDomainRequest',
|
29 |
-
'OrderStatusUpdateResponse' => 'OrderDomainResponse',
|
30 |
-
'OrderCancelRequest' => 'OrderDomainRequest',
|
31 |
-
'OrderCancelResponse' => 'OrderDomainResponse',
|
32 |
-
'OrderNotifyRequest' => 'OrderDomainRequest',
|
33 |
-
'OrderNotifyResponse' => 'OrderDomainResponse',
|
34 |
-
'OrderRetrieveRequest' => 'OrderDomainRequest',
|
35 |
-
'OrderRetrieveResponse' => 'OrderDomainResponse',
|
36 |
-
'ShippingCostRetrieveRequest' => 'OrderDomainRequest',
|
37 |
-
'ShippingCostRetrieveResponse' => 'OrderDomainResponse'
|
38 |
-
);
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Function returns Message domain
|
43 |
-
* @param string $msg
|
44 |
-
* @access public
|
45 |
-
* @return array
|
46 |
-
*/
|
47 |
-
public static function getDomain4Message($msg)
|
48 |
-
{
|
49 |
-
self::$msg2domain = array
|
50 |
-
(
|
51 |
-
'OrderCreateRequest' => 'OrderDomainRequest',
|
52 |
-
'OrderCreateResponse' => 'OrderDomainResponse',
|
53 |
-
'OrderStatusUpdateRequest' => 'OrderDomainRequest',
|
54 |
-
'OrderStatusUpdateResponse' => 'OrderDomainResponse',
|
55 |
-
'OrderCancelRequest' => 'OrderDomainRequest',
|
56 |
-
'OrderCancelResponse' => 'OrderDomainResponse',
|
57 |
-
'OrderNotifyRequest' => 'OrderDomainRequest',
|
58 |
-
'OrderNotifyResponse' => 'OrderDomainResponse',
|
59 |
-
'OrderRetrieveRequest' => 'OrderDomainRequest',
|
60 |
-
'OrderRetrieveResponse' => 'OrderDomainResponse',
|
61 |
-
'ShippingCostRetrieveRequest' => 'OrderDomainRequest',
|
62 |
-
'ShippingCostRetrieveResponse' => 'OrderDomainResponse'
|
63 |
-
);
|
64 |
-
|
65 |
-
return self::$msg2domain[$msg];
|
66 |
-
}
|
67 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package.xml
CHANGED
@@ -1,18 +1,23 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>PayU_Account</name>
|
4 |
-
<version>2.
|
5 |
<stability>stable</stability>
|
6 |
-
<license
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>
|
10 |
-
<description>
|
11 |
-
<notes>
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
16 |
<compatible/>
|
17 |
-
<dependencies><required><php><min>5.
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>PayU_Account</name>
|
4 |
+
<version>2.2.0</version>
|
5 |
<stability>stable</stability>
|
6 |
+
<license>Free</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>The plug-in redirects to payment method summary page where user can choose among the most popular payment methods.</summary>
|
10 |
+
<description>Note: it is required to establish a merchant account with PayU S.A. in order to create POS ID needed to configure the plug-in.</description>
|
11 |
+
<notes>Integration with PayU based on REST API.
|
12 |
+
Authentication via OAuth.
|
13 |
+

|
14 |
+
More info:
|
15 |
+
https://github.com/PayU/plugin_magento
|
16 |
+
http://developers.payu.com/en/restapi.html</notes>
|
17 |
+
<authors><author><name>PayU</name><user>testuser</user><email>sdk@payu.com</email></author></authors>
|
18 |
+
<date>2016-12-12</date>
|
19 |
+
<time>10:41:14</time>
|
20 |
+
<contents><target name="magecommunity"><dir name="PayU"><dir name="Account"><dir name="Block"><file name="Form.php" hash="70db3feb73a9628609742490bc5018db"/><file name="UpdateInfo.php" hash="ad8059411091251e4545e7849ca5cc49"/></dir><dir name="Helper"><file name="Data.php" hash="ef537fab5d0e9b97a7529f6b06b8e5c9"/></dir><dir name="Model"><file name="Config.php" hash="d781caad54f6aa1d29bdbda3d0be05ad"/><file name="Payment.php" hash="9413c7d6b51a13b932296b651e51d625"/><file name="Session.php" hash="3f4eec3f5530dc984911d9b6397955a5"/></dir><dir name="controllers"><file name="PaymentController.php" hash="4c92bccb53c4ba13049a992b697a2b0d"/></dir><dir name="etc"><file name="config.xml" hash="7eb44198d389e261d77c6f03fc465da7"/><file name="system.xml" hash="d5206a7caa0ec2b73605f53340f5218b"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="PayU_Account.xml" hash="19c5f7d97751e1ff01023277653f03ba"/></dir></target><target name="magelocale"><dir><dir name="pl_PL"><file name="PayU_Account.csv" hash="89b688fa47c5d0de715a147b3c9b0b2e"/></dir></dir></target><target name="magelib"><dir name="PayU"><dir name="Cache"><file name="810290d4eed883975e0cd43d80497ac4" hash="80c55f0b73f1e71951b2395eb846b7f8"/><file name="index.php" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name=".htaccess" hash="e45967d66b550e75c8b8dc0b7a465393"/></dir><dir name="OpenPayU"><dir name="AuthType"><file name="AuthType.php" hash="2ec8762fd13fda9d0688a68f9d2bd933"/><file name="Basic.php" hash="896bd3e2a47632a971f65b6deaf2f153"/><file name="Oauth.php" hash="65986c4607710e90670668838533aa6d"/><file name="TokenRequest.php" hash="f4bb0f92451a55489c75de6cffad346d"/></dir><file name="Configuration.php" hash="056bd679a45e6098b17bb16b5c3a157e"/><file name="Http.php" hash="cdd4045bf5ae1a833a8ff10b1d9e5835"/><file name="HttpCurl.php" hash="6d143ecf17179bd0d7b3f1758ac4cacb"/><dir name="Oauth"><dir name="Cache"><file name="OauthCacheFile.php" hash="b57ccb709b5505cb19abd571168a8b8f"/><file name="OauthCacheInterface.php" hash="d68b90815ab5d60f4cbb38ccac9c84e5"/><file name="OauthCacheMemcached.php" hash="3555d44cb94c11f09f1c38289a68cdfb"/></dir><file name="Oauth.php" hash="7e7ec220e34b46e7a4e9fdbd82427574"/><file name="OauthGrantType.php" hash="40ae9161926e907a63d7c3ec7fb58a7b"/><file name="OauthResultClientCredentials.php" hash="450d98ce57200f578a93f24a18071b8d"/></dir><file name="OpenPayU.php" hash="8d0af96bd7308cac3dbab070693a7c0c"/><file name="OpenPayUException.php" hash="f9a320613e170232a0b058e14e3f08b1"/><file name="OpenPayuOrderStatus.php" hash="77cee41c66c42c5b817638b6199e068b"/><file name="Result.php" hash="64dd8c0e1c7ea58da4ff3493a5ea08b7"/><file name="ResultError.php" hash="314179abf5a6f75712d78825353f67d6"/><file name="Util.php" hash="af84a905d23ee5abb712db9dc2e52dfd"/><dir name="v2"><file name="Order.php" hash="4b1b8fb83358b324b80a47a758095e68"/><file name="Refund.php" hash="abfaaf1b0d23b9c2dc92dc3e87c59cb2"/><file name="Retrieve.php" hash="cddd1fb292a23eb79f411a32da1654a2"/></dir></dir><file name="openpayu.php" hash="597ad90c6fa2ae1f0b43f318589ed76f"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="payu_account"><file name="form.phtml" hash="f003e7a1d5908f83e20cb53fdc1f5a6e"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="payu"><file name="payu.css" hash="d6133348fe2e0c4df1ef1031ecf999f7"/></dir></dir></dir></dir></dir></target></contents>
|
21 |
<compatible/>
|
22 |
+
<dependencies><required><php><min>5.3.0</min><max>5.7.0</max></php></required></dependencies>
|
23 |
</package>
|
readme_images/cache_flushed.png
DELETED
Binary file
|
readme_images/save_config.png
DELETED
Binary file
|
skin/frontend/base/default/css/payu/payu.css
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
.formPayuLogo {
|
2 |
+
height: 20px;
|
3 |
+
margin-right: 10px;
|
4 |
+
}
|