Version Notes
Reworked API section for newer Magento version
Download this release
Release Info
| Developer | Huseyin Ozturk |
| Extension | NetPay_Netpayonlinepayments |
| Version | 1.0.5 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.4 to 1.0.5
- app/code/local/NetPay/Netpayonlinepayments/Block/Api.php +6 -3
- app/code/local/NetPay/Netpayonlinepayments/Helper/Data.php +61 -4
- app/code/local/NetPay/Netpayonlinepayments/Model/Netpayapi.php +52 -29
- app/code/local/NetPay/Netpayonlinepayments/etc/config.xml +3 -3
- app/code/local/NetPay/Netpayonlinepayments/etc/system.xml +59 -0
- app/design/frontend/{default → base}/default/layout/netpayonlinepayments.xml +16 -13
- app/design/frontend/{default → base}/default/template/netpayonlinepayments/api_form.phtml +0 -0
- app/design/frontend/{default → base}/default/template/netpayonlinepayments/form.phtml +0 -0
- app/design/frontend/{default → base}/default/template/netpayonlinepayments/redirect.phtml +0 -0
- lib/NetPay/Connection.php +37 -3
- package.xml +5 -5
app/code/local/NetPay/Netpayonlinepayments/Block/Api.php
CHANGED
|
@@ -29,11 +29,14 @@ class NetPay_Netpayonlinepayments_Block_Api extends Mage_Payment_Block_Form_Cc
|
|
| 29 |
{
|
| 30 |
parent::_construct();
|
| 31 |
|
| 32 |
-
//$head = $this->getLayout()->getBlock('head');
|
| 33 |
-
//$head->addJs('NetPay/netpay-api.js');
|
| 34 |
-
|
| 35 |
$this->setTemplate('netpayonlinepayments/api_form.phtml');
|
| 36 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
/**
|
| 39 |
* @Purpose : Fucntion to return allowed credit card array for payment block in checkout
|
| 29 |
{
|
| 30 |
parent::_construct();
|
| 31 |
|
|
|
|
|
|
|
|
|
|
| 32 |
$this->setTemplate('netpayonlinepayments/api_form.phtml');
|
| 33 |
}
|
| 34 |
+
|
| 35 |
+
protected function _prepareLayout()
|
| 36 |
+
{
|
| 37 |
+
//$this->getLayout()->getBlock('head')->addJs('NetPay/netpay-api.js');
|
| 38 |
+
return parent::_prepareLayout();
|
| 39 |
+
}
|
| 40 |
|
| 41 |
/**
|
| 42 |
* @Purpose : Fucntion to return allowed credit card array for payment block in checkout
|
app/code/local/NetPay/Netpayonlinepayments/Helper/Data.php
CHANGED
|
@@ -38,10 +38,22 @@ class NetPay_Netpayonlinepayments_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 38 |
switch ($paymentMode)
|
| 39 |
{
|
| 40 |
case NetPay_Netpayonlinepayments_Model_Source_PaymentMode::PAYMENT_LIVE:
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
break;
|
| 43 |
case NetPay_Netpayonlinepayments_Model_Source_PaymentMode::PAYMENT_TEST:
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
break;
|
| 46 |
}
|
| 47 |
return $url;
|
|
@@ -59,10 +71,22 @@ class NetPay_Netpayonlinepayments_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 59 |
switch ($paymentMode)
|
| 60 |
{
|
| 61 |
case NetPay_Netpayonlinepayments_Model_Source_PaymentMode::PAYMENT_LIVE:
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
break;
|
| 64 |
case NetPay_Netpayonlinepayments_Model_Source_PaymentMode::PAYMENT_TEST:
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
break;
|
| 67 |
}
|
| 68 |
return $url;
|
|
@@ -94,6 +118,39 @@ class NetPay_Netpayonlinepayments_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 94 |
public function getApiPassword() {
|
| 95 |
return Mage::getModel('netpayonlinepayments/netpayapi')->getConfigData('password');
|
| 96 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
|
| 98 |
/**
|
| 99 |
* @Purpose : Function to return response url where hosted from method response will be submitted from gateway after transaction
|
| 38 |
switch ($paymentMode)
|
| 39 |
{
|
| 40 |
case NetPay_Netpayonlinepayments_Model_Source_PaymentMode::PAYMENT_LIVE:
|
| 41 |
+
$conf_url = Mage::getStoreConfig('payment/netpayonlinepayments/live_url');
|
| 42 |
+
if($conf_url == '') {
|
| 43 |
+
$url = $this->liveGatewayUrlHostedForm;
|
| 44 |
+
}
|
| 45 |
+
else {
|
| 46 |
+
$url = $conf_url;
|
| 47 |
+
}
|
| 48 |
break;
|
| 49 |
case NetPay_Netpayonlinepayments_Model_Source_PaymentMode::PAYMENT_TEST:
|
| 50 |
+
$conf_url = Mage::getStoreConfig('payment/netpayonlinepayments/test_url');
|
| 51 |
+
if($conf_url == '') {
|
| 52 |
+
$url = $this->testGatewayUrlHostedForm;
|
| 53 |
+
}
|
| 54 |
+
else {
|
| 55 |
+
$url = $conf_url;
|
| 56 |
+
}
|
| 57 |
break;
|
| 58 |
}
|
| 59 |
return $url;
|
| 71 |
switch ($paymentMode)
|
| 72 |
{
|
| 73 |
case NetPay_Netpayonlinepayments_Model_Source_PaymentMode::PAYMENT_LIVE:
|
| 74 |
+
$conf_url = Mage::getStoreConfig('payment/netpayapi/live_url');
|
| 75 |
+
if($conf_url == '') {
|
| 76 |
+
$url = $this->apiIntegrationLiveUrl;
|
| 77 |
+
}
|
| 78 |
+
else {
|
| 79 |
+
$url = $conf_url;
|
| 80 |
+
}
|
| 81 |
break;
|
| 82 |
case NetPay_Netpayonlinepayments_Model_Source_PaymentMode::PAYMENT_TEST:
|
| 83 |
+
$conf_url = Mage::getStoreConfig('payment/netpayapi/test_url');
|
| 84 |
+
if($conf_url == '') {
|
| 85 |
+
$url = $this->apiIntegartionTestUrl;
|
| 86 |
+
}
|
| 87 |
+
else {
|
| 88 |
+
$url = $conf_url;
|
| 89 |
+
}
|
| 90 |
break;
|
| 91 |
}
|
| 92 |
return $url;
|
| 118 |
public function getApiPassword() {
|
| 119 |
return Mage::getModel('netpayonlinepayments/netpayapi')->getConfigData('password');
|
| 120 |
}
|
| 121 |
+
|
| 122 |
+
/**
|
| 123 |
+
* @Purpose : Function to return Api Certificate Path set from configuration section
|
| 124 |
+
* @Outputs : Return Api Cert Path
|
| 125 |
+
* @author : NetPay Development Team
|
| 126 |
+
*/
|
| 127 |
+
public function getApiCert() {
|
| 128 |
+
return Mage::getModel('netpayonlinepayments/netpayapi')->getConfigData('cert_path');
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
/**
|
| 132 |
+
* @Purpose : Function to return Api Key Path set from configuration section
|
| 133 |
+
* @Outputs : Return Api Key Path
|
| 134 |
+
* @author : NetPay Development Team
|
| 135 |
+
*/
|
| 136 |
+
public function getApiKey() {
|
| 137 |
+
return Mage::getModel('netpayonlinepayments/netpayapi')->getConfigData('key_path');
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
/**
|
| 141 |
+
* @Purpose : Function to return Api Certificate Password set from configuration section
|
| 142 |
+
* @Outputs : Return Api Certificate Password
|
| 143 |
+
* @author : NetPay Development Team
|
| 144 |
+
*/
|
| 145 |
+
public function getApiCertPass() {
|
| 146 |
+
$pass = trim(Mage::getModel('netpayonlinepayments/netpayapi')->getConfigData('certificate_pass'));
|
| 147 |
+
if($pass !== '') {
|
| 148 |
+
return $pass;
|
| 149 |
+
}
|
| 150 |
+
else {
|
| 151 |
+
return NULL;
|
| 152 |
+
}
|
| 153 |
+
}
|
| 154 |
|
| 155 |
/**
|
| 156 |
* @Purpose : Function to return response url where hosted from method response will be submitted from gateway after transaction
|
app/code/local/NetPay/Netpayonlinepayments/Model/Netpayapi.php
CHANGED
|
@@ -33,6 +33,12 @@ class NetPay_Netpayonlinepayments_Model_Netpayapi extends Mage_Payment_Model_Met
|
|
| 33 |
protected $_canSaveCc = false; //if made try, the actual credit card number and cvv code are stored in database.
|
| 34 |
protected $_canUseInternal = false;
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
const OPERATION_TYPE = "PURCHASE";
|
| 38 |
const GET_TOKEN_OPERATION = "RETRIEVE_TOKEN";
|
|
@@ -194,7 +200,7 @@ class NetPay_Netpayonlinepayments_Model_Netpayapi extends Mage_Payment_Model_Met
|
|
| 194 |
//Transaction fields
|
| 195 |
$transactionId = $helper->create_unique_transaction_id($orderId);
|
| 196 |
$fields['transaction']['transaction_id'] = $transactionId;
|
| 197 |
-
$fields['transaction']['amount'] =
|
| 198 |
$fields['transaction']['currency'] = $order->getBaseCurrencyCode();
|
| 199 |
//$fields['transaction']['reference'] = '';
|
| 200 |
$fields['transaction']['source'] = self::SOURCE;
|
|
@@ -230,7 +236,7 @@ class NetPay_Netpayonlinepayments_Model_Netpayapi extends Mage_Payment_Model_Met
|
|
| 230 |
$ccMonth = (strlen($ccMonth) == 1)? '0'.$ccMonth:$ccMonth;
|
| 231 |
$ccYear = substr($payment->getCcExpYear(), 2, 2);
|
| 232 |
|
| 233 |
-
$ccFullName = $payment->getCcOwner();
|
| 234 |
$ccFullNameArr = explode(' ', $ccFullName);
|
| 235 |
|
| 236 |
if(!empty($ccFullNameArr))
|
|
@@ -261,12 +267,12 @@ class NetPay_Netpayonlinepayments_Model_Netpayapi extends Mage_Payment_Model_Met
|
|
| 261 |
|
| 262 |
|
| 263 |
//Billing fields
|
| 264 |
-
$fields['billing']['bill_to_company'] = $billingData['company'];
|
| 265 |
-
$fields['billing']['bill_to_address'] = $billingData['street'];
|
| 266 |
-
$fields['billing']['bill_to_town_city'] = $billingData['city'];
|
| 267 |
-
$fields['billing']['bill_to_county'] = $billingData['region'];
|
| 268 |
-
$fields['billing']['bill_to_postcode'] = $billingData['postcode'];
|
| 269 |
-
$fields['billing']['bill_to_country'] = Mage::getModel( 'directory/country' )->load( $billingData['country_id'] )->getData('iso3_code');
|
| 270 |
|
| 271 |
//Removing empty values from array
|
| 272 |
foreach($fields['billing'] as $key=>$value) {
|
|
@@ -282,18 +288,18 @@ class NetPay_Netpayonlinepayments_Model_Netpayapi extends Mage_Payment_Model_Met
|
|
| 282 |
|
| 283 |
$fullName .= ' '.$shippingData['lastname'];
|
| 284 |
|
| 285 |
-
$fields['shipping']['ship_to_title'] = $shippingData['prefix'];
|
| 286 |
-
$fields['shipping']['ship_to_firstname'] = $shippingData['firstname'];
|
| 287 |
-
$fields['shipping']['ship_to_middlename'] = $shippingData['middlename'];
|
| 288 |
-
$fields['shipping']['ship_to_lastname'] = $shippingData['lastname'];
|
| 289 |
-
$fields['shipping']['ship_to_fullname'] = $fullName;
|
| 290 |
-
$fields['shipping']['ship_to_company'] = $shippingData['company'];
|
| 291 |
-
$fields['shipping']['ship_to_address'] = $shippingData['street'];
|
| 292 |
-
$fields['shipping']['ship_to_town_city'] = $shippingData['city'];
|
| 293 |
-
$fields['shipping']['ship_to_county'] = $shippingData['region'];
|
| 294 |
-
$fields['shipping']['ship_to_country'] = Mage::getModel( 'directory/country' )->load( $shippingData['country_id'] )->getData('iso3_code');
|
| 295 |
-
|
| 296 |
-
$fields['shipping']['ship_to_phone']= $shippingData['telephone'];
|
| 297 |
|
| 298 |
} else {
|
| 299 |
$fullName = $billingData['firstname'];
|
|
@@ -302,12 +308,12 @@ class NetPay_Netpayonlinepayments_Model_Netpayapi extends Mage_Payment_Model_Met
|
|
| 302 |
|
| 303 |
$fullName = ' '.$billingData['lastname'];
|
| 304 |
|
| 305 |
-
$fields['shipping']['ship_to_title'] = $billingData['prefix'];
|
| 306 |
-
$fields['shipping']['ship_to_firstname'] = $billingData['firstname'];
|
| 307 |
-
$fields['shipping']['ship_to_middlename'] = $billingData['middlename'];
|
| 308 |
-
$fields['shipping']['ship_to_lastname'] = $billingData['lastname'];
|
| 309 |
-
$fields['shipping']['ship_to_fullname'] = $fullName;
|
| 310 |
-
$fields['shipping']['ship_to_phone'] = $billingData['telephone'];
|
| 311 |
}
|
| 312 |
|
| 313 |
//Removing empty values from array
|
|
@@ -319,8 +325,8 @@ class NetPay_Netpayonlinepayments_Model_Netpayapi extends Mage_Payment_Model_Met
|
|
| 319 |
//Customer fields
|
| 320 |
$fields['customer']['customer_email'] = $order->getCustomerEmail();
|
| 321 |
|
| 322 |
-
if($billingData['telephone'] != '')
|
| 323 |
-
$fields['customer']['customer_phone'] = $billingData['telephone'];
|
| 324 |
|
| 325 |
//Order Items
|
| 326 |
$items = $order->getAllItems();
|
|
@@ -335,7 +341,7 @@ class NetPay_Netpayonlinepayments_Model_Netpayapi extends Mage_Payment_Model_Met
|
|
| 335 |
if($description == '')
|
| 336 |
$description = $name;
|
| 337 |
|
| 338 |
-
$price =
|
| 339 |
$taxable = 1;
|
| 340 |
|
| 341 |
$fields['order']['order_items'][$i]['item_id'] = $sku;
|
|
@@ -792,6 +798,11 @@ class NetPay_Netpayonlinepayments_Model_Netpayapi extends Mage_Payment_Model_Met
|
|
| 792 |
}
|
| 793 |
|
| 794 |
$rest = new NetPay_Connection($gatewayUrl, $header);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 795 |
$response = $rest->put($api_method, $fields);
|
| 796 |
|
| 797 |
if($this->getConfigData('debug')) { //Debug Response
|
|
@@ -800,6 +811,18 @@ class NetPay_Netpayonlinepayments_Model_Netpayapi extends Mage_Payment_Model_Met
|
|
| 800 |
|
| 801 |
return $response;
|
| 802 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 803 |
|
| 804 |
/**
|
| 805 |
* fucntion to Save token temp data stored in database with current session relation
|
| 33 |
protected $_canSaveCc = false; //if made try, the actual credit card number and cvv code are stored in database.
|
| 34 |
protected $_canUseInternal = false;
|
| 35 |
|
| 36 |
+
protected $_ssl_path = array(
|
| 37 |
+
'certificate' => '', // Full certificate file path
|
| 38 |
+
'key' => '', // Full certificate file path
|
| 39 |
+
'certificate_pass' => NULL // Optional of TEST MODE is ACCOUNT CODE
|
| 40 |
+
);
|
| 41 |
+
|
| 42 |
|
| 43 |
const OPERATION_TYPE = "PURCHASE";
|
| 44 |
const GET_TOKEN_OPERATION = "RETRIEVE_TOKEN";
|
| 200 |
//Transaction fields
|
| 201 |
$transactionId = $helper->create_unique_transaction_id($orderId);
|
| 202 |
$fields['transaction']['transaction_id'] = $transactionId;
|
| 203 |
+
$fields['transaction']['amount'] = number_format( $amount, 2, '.', '' );
|
| 204 |
$fields['transaction']['currency'] = $order->getBaseCurrencyCode();
|
| 205 |
//$fields['transaction']['reference'] = '';
|
| 206 |
$fields['transaction']['source'] = self::SOURCE;
|
| 236 |
$ccMonth = (strlen($ccMonth) == 1)? '0'.$ccMonth:$ccMonth;
|
| 237 |
$ccYear = substr($payment->getCcExpYear(), 2, 2);
|
| 238 |
|
| 239 |
+
$ccFullName = trim($payment->getCcOwner());
|
| 240 |
$ccFullNameArr = explode(' ', $ccFullName);
|
| 241 |
|
| 242 |
if(!empty($ccFullNameArr))
|
| 267 |
|
| 268 |
|
| 269 |
//Billing fields
|
| 270 |
+
$fields['billing']['bill_to_company'] = substr(trim($billingData['company']), 0, 100);
|
| 271 |
+
$fields['billing']['bill_to_address'] = substr(trim(preg_replace("#[^A-Za-z0-9\. ',()\-]+#", '', $billingData['street'])), 0, 100);
|
| 272 |
+
$fields['billing']['bill_to_town_city'] = substr(trim(preg_replace("#[^A-Za-z0-9\. ',()\-]+#", '', $billingData['city'])), 0, 50);
|
| 273 |
+
$fields['billing']['bill_to_county'] = substr(trim(preg_replace("#[^A-Za-z0-9\. ',()\-]+#", '', $billingData['region'])), 0, 50);
|
| 274 |
+
$fields['billing']['bill_to_postcode'] = substr(trim(preg_replace("#[^A-Za-z0-9\. ',()\-]+#", '', $billingData['postcode'])), 0, 10);
|
| 275 |
+
$fields['billing']['bill_to_country'] = substr(trim(preg_replace("#[^A-Za-z]{3}#", '', Mage::getModel( 'directory/country' )->load( $billingData['country_id'] )->getData('iso3_code'))), 0, 3);
|
| 276 |
|
| 277 |
//Removing empty values from array
|
| 278 |
foreach($fields['billing'] as $key=>$value) {
|
| 288 |
|
| 289 |
$fullName .= ' '.$shippingData['lastname'];
|
| 290 |
|
| 291 |
+
$fields['shipping']['ship_to_title'] = substr(trim(preg_replace("#[^A-Za-z\. ]+#", '', $shippingData['prefix'])), 0, 20);
|
| 292 |
+
$fields['shipping']['ship_to_firstname'] = substr(trim(preg_replace("#[^A-Za-z'\.\- ]+#", '', $shippingData['firstname'])), 0, 50);
|
| 293 |
+
$fields['shipping']['ship_to_middlename'] = substr(trim(preg_replace("#[^A-Za-z'\.\- ]+#", '', $shippingData['middlename'])), 0, 50);
|
| 294 |
+
$fields['shipping']['ship_to_lastname'] = substr(trim(preg_replace("#[^A-Za-z'\.,\- ]+#", '', $shippingData['lastname'])), 0, 50);
|
| 295 |
+
$fields['shipping']['ship_to_fullname'] = substr(trim(preg_replace("#[^A-Za-z'\.\- ]+#", '', $fullName)), 0, 100);
|
| 296 |
+
$fields['shipping']['ship_to_company'] = substr(trim($shippingData['company']), 0, 100);
|
| 297 |
+
$fields['shipping']['ship_to_address'] = substr(trim(preg_replace("#[^A-Za-z0-9\. ',()\-]+#", '', $shippingData['street'])), 0, 100);
|
| 298 |
+
$fields['shipping']['ship_to_town_city'] = substr(trim(preg_replace("#[^A-Za-z0-9\. ',()\-]+#", '', $shippingData['city'])), 0, 50);
|
| 299 |
+
$fields['shipping']['ship_to_county'] = substr(trim(preg_replace("#[^A-Za-z0-9\. ',()\-]+#", '', $shippingData['region'])), 0, 50);
|
| 300 |
+
$fields['shipping']['ship_to_country'] = substr(trim(preg_replace("#[^A-Za-z]{3}#", '', Mage::getModel( 'directory/country' )->load( $shippingData['country_id'] )->getData('iso3_code'))), 0, 3);
|
| 301 |
+
//$fields['shipping']['ship_to_method'] = $order->getShippingDescription();
|
| 302 |
+
$fields['shipping']['ship_to_phone']= substr(trim(preg_replace("#[^0-9 \+()\- \.]+#", '', $shippingData['telephone'])), 0, 20);
|
| 303 |
|
| 304 |
} else {
|
| 305 |
$fullName = $billingData['firstname'];
|
| 308 |
|
| 309 |
$fullName = ' '.$billingData['lastname'];
|
| 310 |
|
| 311 |
+
$fields['shipping']['ship_to_title'] = substr(trim(preg_replace("#[^A-Za-z\. ]+#", '', $billingData['prefix'])), 0, 20);
|
| 312 |
+
$fields['shipping']['ship_to_firstname'] = substr(trim(preg_replace("#[^A-Za-z'\.\- ]+#", '', $billingData['firstname'])), 0, 50);
|
| 313 |
+
$fields['shipping']['ship_to_middlename'] = substr(trim(preg_replace("#[^A-Za-z'\.\- ]+#", '', $billingData['middlename'])), 0, 50);
|
| 314 |
+
$fields['shipping']['ship_to_lastname'] = substr(trim(preg_replace("#[^A-Za-z'\.,\- ]+#", '', $billingData['lastname'])), 0, 50);
|
| 315 |
+
$fields['shipping']['ship_to_fullname'] = substr(trim(preg_replace("#[^A-Za-z'\.\- ]+#", '', $fullName)), 0, 100);
|
| 316 |
+
$fields['shipping']['ship_to_phone'] = substr(trim(preg_replace("#[^0-9 \+()\- \.]+#", '', $billingData['telephone'])), 0, 20);
|
| 317 |
}
|
| 318 |
|
| 319 |
//Removing empty values from array
|
| 325 |
//Customer fields
|
| 326 |
$fields['customer']['customer_email'] = $order->getCustomerEmail();
|
| 327 |
|
| 328 |
+
if(trim($billingData['telephone']) != '')
|
| 329 |
+
$fields['customer']['customer_phone'] = substr(trim(preg_replace("#[^0-9 \+()\- \.]+#", '', $billingData['telephone'])), 0, 20);
|
| 330 |
|
| 331 |
//Order Items
|
| 332 |
$items = $order->getAllItems();
|
| 341 |
if($description == '')
|
| 342 |
$description = $name;
|
| 343 |
|
| 344 |
+
$price = number_format( $item->getData('price'), 2, '.', '' );
|
| 345 |
$taxable = 1;
|
| 346 |
|
| 347 |
$fields['order']['order_items'][$i]['item_id'] = $sku;
|
| 798 |
}
|
| 799 |
|
| 800 |
$rest = new NetPay_Connection($gatewayUrl, $header);
|
| 801 |
+
|
| 802 |
+
$this->configureSslPaths();
|
| 803 |
+
|
| 804 |
+
$rest->set_ssl_path($this->_ssl_path);
|
| 805 |
+
|
| 806 |
$response = $rest->put($api_method, $fields);
|
| 807 |
|
| 808 |
if($this->getConfigData('debug')) { //Debug Response
|
| 811 |
|
| 812 |
return $response;
|
| 813 |
}
|
| 814 |
+
|
| 815 |
+
/**
|
| 816 |
+
* sets variables in ssl path var from magento config
|
| 817 |
+
*/
|
| 818 |
+
public function configureSslPaths() {
|
| 819 |
+
|
| 820 |
+
$helper = Mage::helper('netpayonlinepayments');
|
| 821 |
+
|
| 822 |
+
$this->_ssl_path['certificate'] = $helper->getApiCert();
|
| 823 |
+
$this->_ssl_path['key'] = $helper->getApiKey();
|
| 824 |
+
$this->_ssl_path['certificate_pass'] = $helper->getApiCertPass();
|
| 825 |
+
}
|
| 826 |
|
| 827 |
/**
|
| 828 |
* fucntion to Save token temp data stored in database with current session relation
|
app/code/local/NetPay/Netpayonlinepayments/etc/config.xml
CHANGED
|
@@ -12,7 +12,7 @@
|
|
| 12 |
*
|
| 13 |
* @category NetPay
|
| 14 |
* @package NetPay_Netpayonlinepayments
|
| 15 |
-
* @copyright Copyright (c)
|
| 16 |
* @license http://opensource.org/licenses/mit-license.php MIT License
|
| 17 |
* @author NetPay Support
|
| 18 |
*/
|
|
@@ -20,7 +20,7 @@
|
|
| 20 |
<config>
|
| 21 |
<modules>
|
| 22 |
<NetPay_Netpayonlinepayments>
|
| 23 |
-
<version>1.0.
|
| 24 |
</NetPay_Netpayonlinepayments>
|
| 25 |
</modules>
|
| 26 |
<global>
|
|
@@ -97,7 +97,7 @@
|
|
| 97 |
<default>
|
| 98 |
<payment>
|
| 99 |
<netpaysettings>
|
| 100 |
-
<version>1.0.
|
| 101 |
</netpaysettings>
|
| 102 |
<netpayonlinepayments>
|
| 103 |
<active>0</active>
|
| 12 |
*
|
| 13 |
* @category NetPay
|
| 14 |
* @package NetPay_Netpayonlinepayments
|
| 15 |
+
* @copyright Copyright (c) 2015
|
| 16 |
* @license http://opensource.org/licenses/mit-license.php MIT License
|
| 17 |
* @author NetPay Support
|
| 18 |
*/
|
| 20 |
<config>
|
| 21 |
<modules>
|
| 22 |
<NetPay_Netpayonlinepayments>
|
| 23 |
+
<version>1.0.5</version>
|
| 24 |
</NetPay_Netpayonlinepayments>
|
| 25 |
</modules>
|
| 26 |
<global>
|
| 97 |
<default>
|
| 98 |
<payment>
|
| 99 |
<netpaysettings>
|
| 100 |
+
<version>1.0.5</version>
|
| 101 |
</netpaysettings>
|
| 102 |
<netpayonlinepayments>
|
| 103 |
<active>0</active>
|
app/code/local/NetPay/Netpayonlinepayments/etc/system.xml
CHANGED
|
@@ -176,6 +176,22 @@
|
|
| 176 |
<show_in_website>1</show_in_website>
|
| 177 |
<show_in_store>0</show_in_store>
|
| 178 |
</mode>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
<debug translate="label">
|
| 180 |
<label>Debug</label>
|
| 181 |
<frontend_type>select</frontend_type>
|
|
@@ -243,6 +259,33 @@
|
|
| 243 |
<show_in_website>1</show_in_website>
|
| 244 |
<show_in_store>0</show_in_store>
|
| 245 |
</password>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
<payment_action translate="label">
|
| 247 |
<label>Payment Action</label>
|
| 248 |
<sort_order>80</sort_order>
|
|
@@ -298,6 +341,22 @@
|
|
| 298 |
<show_in_website>1</show_in_website>
|
| 299 |
<show_in_store>0</show_in_store>
|
| 300 |
</mode>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 301 |
<debug translate="label">
|
| 302 |
<label>Debug</label>
|
| 303 |
<frontend_type>select</frontend_type>
|
| 176 |
<show_in_website>1</show_in_website>
|
| 177 |
<show_in_store>0</show_in_store>
|
| 178 |
</mode>
|
| 179 |
+
<live_url translate="label">
|
| 180 |
+
<label>Live Direct Post End Point URL</label>
|
| 181 |
+
<frontend_type>text</frontend_type>
|
| 182 |
+
<sort_order>104</sort_order>
|
| 183 |
+
<show_in_default>1</show_in_default>
|
| 184 |
+
<show_in_website>1</show_in_website>
|
| 185 |
+
<show_in_store>0</show_in_store>
|
| 186 |
+
</live_url>
|
| 187 |
+
<test_url translate="label">
|
| 188 |
+
<label>Test Direct Post End Point URL</label>
|
| 189 |
+
<frontend_type>text</frontend_type>
|
| 190 |
+
<sort_order>105</sort_order>
|
| 191 |
+
<show_in_default>1</show_in_default>
|
| 192 |
+
<show_in_website>1</show_in_website>
|
| 193 |
+
<show_in_store>0</show_in_store>
|
| 194 |
+
</test_url>
|
| 195 |
<debug translate="label">
|
| 196 |
<label>Debug</label>
|
| 197 |
<frontend_type>select</frontend_type>
|
| 259 |
<show_in_website>1</show_in_website>
|
| 260 |
<show_in_store>0</show_in_store>
|
| 261 |
</password>
|
| 262 |
+
<cert_path translate="label">
|
| 263 |
+
<label>Certificate Path</label>
|
| 264 |
+
<frontend_type>text</frontend_type>
|
| 265 |
+
<sort_order>71</sort_order>
|
| 266 |
+
<show_in_default>1</show_in_default>
|
| 267 |
+
<show_in_website>1</show_in_website>
|
| 268 |
+
<show_in_store>0</show_in_store>
|
| 269 |
+
<comment>Full path to file including file name.</comment>
|
| 270 |
+
</cert_path>
|
| 271 |
+
<key_path translate="label">
|
| 272 |
+
<label>Key Path</label>
|
| 273 |
+
<frontend_type>text</frontend_type>
|
| 274 |
+
<sort_order>72</sort_order>
|
| 275 |
+
<show_in_default>1</show_in_default>
|
| 276 |
+
<show_in_website>1</show_in_website>
|
| 277 |
+
<show_in_store>0</show_in_store>
|
| 278 |
+
<comment>Full path to file including file name.</comment>
|
| 279 |
+
</key_path>
|
| 280 |
+
<certificate_pass translate="label">
|
| 281 |
+
<label>Certificate Password</label>
|
| 282 |
+
<frontend_type>text</frontend_type>
|
| 283 |
+
<sort_order>73</sort_order>
|
| 284 |
+
<show_in_default>1</show_in_default>
|
| 285 |
+
<show_in_website>1</show_in_website>
|
| 286 |
+
<show_in_store>0</show_in_store>
|
| 287 |
+
<comment>Leave empty if certificate has no password.</comment>
|
| 288 |
+
</certificate_pass>
|
| 289 |
<payment_action translate="label">
|
| 290 |
<label>Payment Action</label>
|
| 291 |
<sort_order>80</sort_order>
|
| 341 |
<show_in_website>1</show_in_website>
|
| 342 |
<show_in_store>0</show_in_store>
|
| 343 |
</mode>
|
| 344 |
+
<live_url translate="label">
|
| 345 |
+
<label>Live Web Service End Point URL</label>
|
| 346 |
+
<frontend_type>text</frontend_type>
|
| 347 |
+
<sort_order>104</sort_order>
|
| 348 |
+
<show_in_default>1</show_in_default>
|
| 349 |
+
<show_in_website>1</show_in_website>
|
| 350 |
+
<show_in_store>0</show_in_store>
|
| 351 |
+
</live_url>
|
| 352 |
+
<test_url translate="label">
|
| 353 |
+
<label>Test Web Service End Point URL</label>
|
| 354 |
+
<frontend_type>text</frontend_type>
|
| 355 |
+
<sort_order>105</sort_order>
|
| 356 |
+
<show_in_default>1</show_in_default>
|
| 357 |
+
<show_in_website>1</show_in_website>
|
| 358 |
+
<show_in_store>0</show_in_store>
|
| 359 |
+
</test_url>
|
| 360 |
<debug translate="label">
|
| 361 |
<label>Debug</label>
|
| 362 |
<frontend_type>select</frontend_type>
|
app/design/frontend/{default → base}/default/layout/netpayonlinepayments.xml
RENAMED
|
@@ -1,25 +1,28 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<!--
|
| 3 |
/**
|
| 4 |
-
*
|
| 5 |
-
*
|
| 6 |
-
* NOTICE OF LICENSE
|
| 7 |
-
*
|
| 8 |
-
* This source file is subject to the MIT License
|
| 9 |
-
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
-
* It is also available through the world-wide-web at this URL:
|
| 11 |
-
* http://opensource.org/licenses/mit-license.php
|
| 12 |
-
*
|
| 13 |
-
*
|
| 14 |
-
*
|
| 15 |
-
* @
|
|
|
|
|
|
|
|
|
|
| 16 |
* @license http://opensource.org/licenses/mit-license.php MIT License
|
| 17 |
*/
|
| 18 |
-->
|
| 19 |
<layout>
|
| 20 |
<checkout_onepage_index>
|
| 21 |
<reference name="head">
|
| 22 |
-
<action method="addJs"><
|
| 23 |
</reference>
|
| 24 |
</checkout_onepage_index>
|
| 25 |
</layout>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<!--
|
| 3 |
/**
|
| 4 |
+
* NetPay_Netpayonlinepayments extension
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the MIT License
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/mit-license.php
|
| 12 |
+
*
|
| 13 |
+
* API Payment Method Block
|
| 14 |
+
*
|
| 15 |
+
* @category NetPay
|
| 16 |
+
* @package NetPay_Netpayonlinepayments
|
| 17 |
+
* @author NetPay Development Team
|
| 18 |
+
* @copyright Copyright (c) 2014
|
| 19 |
* @license http://opensource.org/licenses/mit-license.php MIT License
|
| 20 |
*/
|
| 21 |
-->
|
| 22 |
<layout>
|
| 23 |
<checkout_onepage_index>
|
| 24 |
<reference name="head">
|
| 25 |
+
<action method="addJs"><name>NetPay/netpay-api.js</name></action>
|
| 26 |
</reference>
|
| 27 |
</checkout_onepage_index>
|
| 28 |
</layout>
|
app/design/frontend/{default → base}/default/template/netpayonlinepayments/api_form.phtml
RENAMED
|
File without changes
|
app/design/frontend/{default → base}/default/template/netpayonlinepayments/form.phtml
RENAMED
|
File without changes
|
app/design/frontend/{default → base}/default/template/netpayonlinepayments/redirect.phtml
RENAMED
|
File without changes
|
lib/NetPay/Connection.php
CHANGED
|
@@ -48,6 +48,9 @@ class NetPay_Connection {
|
|
| 48 |
//In case of error those will be set
|
| 49 |
private $error_code;
|
| 50 |
private $error_string;
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
/**
|
| 53 |
* Checks if cURL is available and sets basic
|
|
@@ -257,7 +260,7 @@ class NetPay_Connection {
|
|
| 257 |
$this->curl_init_connection();
|
| 258 |
|
| 259 |
$this->curl_no_error_fail();
|
| 260 |
-
$this->curl_set_ssl(
|
| 261 |
$this->curl_apply_headers();
|
| 262 |
$this->curl_apply_options();
|
| 263 |
|
|
@@ -503,10 +506,40 @@ class NetPay_Connection {
|
|
| 503 |
}
|
| 504 |
|
| 505 |
/**
|
| 506 |
-
*
|
| 507 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 508 |
private function curl_set_ssl($verify_peer = TRUE, $verify_host = 2, $path_to_cert = NULL) {
|
| 509 |
-
|
|
|
|
|
|
|
|
|
|
| 510 |
$this->curl_add_option(CURLOPT_SSL_VERIFYPEER, TRUE);
|
| 511 |
$this->curl_add_option(CURLOPT_SSL_VERIFYHOST, $verify_host);
|
| 512 |
$this->curl_add_option(CURLOPT_CAINFO, $path_to_cert);
|
|
@@ -516,6 +549,7 @@ class NetPay_Connection {
|
|
| 516 |
}
|
| 517 |
return $this;
|
| 518 |
}
|
|
|
|
| 519 |
|
| 520 |
/**
|
| 521 |
* Disables cURL fail on error codes over 400
|
| 48 |
//In case of error those will be set
|
| 49 |
private $error_code;
|
| 50 |
private $error_string;
|
| 51 |
+
|
| 52 |
+
//Set ssl before you request
|
| 53 |
+
private $ssl;
|
| 54 |
|
| 55 |
/**
|
| 56 |
* Checks if cURL is available and sets basic
|
| 260 |
$this->curl_init_connection();
|
| 261 |
|
| 262 |
$this->curl_no_error_fail();
|
| 263 |
+
$this->curl_set_ssl();
|
| 264 |
$this->curl_apply_headers();
|
| 265 |
$this->curl_apply_options();
|
| 266 |
|
| 506 |
}
|
| 507 |
|
| 508 |
/**
|
| 509 |
+
* add ssl certificate on request
|
| 510 |
*/
|
| 511 |
+
public function set_ssl_path($ssl) {
|
| 512 |
+
$this->ssl = $ssl;
|
| 513 |
+
return $this;
|
| 514 |
+
}
|
| 515 |
+
|
| 516 |
+
public function curl_set_ssl() {
|
| 517 |
+
if(is_array($this->ssl) && isset($this->ssl['certificate'])){
|
| 518 |
+
$this->curl_add_option(CURLOPT_SSL_VERIFYPEER,FALSE);
|
| 519 |
+
$this->curl_add_option(CURLOPT_SSL_VERIFYHOST, 2);
|
| 520 |
+
$this->curl_add_option(CURLOPT_SSLCERT, $this->ssl['certificate']);
|
| 521 |
+
$this->curl_add_option(CURLOPT_SSLKEY, $this->ssl['key']);
|
| 522 |
+
|
| 523 |
+
// if there is no password
|
| 524 |
+
if (!is_null($this->ssl['certificate_pass']))
|
| 525 |
+
$this->curl_add_option(CURLOPT_SSLCERTPASSWD, $this->ssl['certificate_pass']);
|
| 526 |
+
}
|
| 527 |
+
else{
|
| 528 |
+
$this->curl_add_option(CURLOPT_SSL_VERIFYPEER, FALSE);
|
| 529 |
+
}
|
| 530 |
+
|
| 531 |
+
return $this;
|
| 532 |
+
|
| 533 |
+
}
|
| 534 |
+
|
| 535 |
+
|
| 536 |
+
/*
|
| 537 |
+
|
| 538 |
private function curl_set_ssl($verify_peer = TRUE, $verify_host = 2, $path_to_cert = NULL) {
|
| 539 |
+
|
| 540 |
+
if(is_array($this->ssl))}
|
| 541 |
+
|
| 542 |
+
if ($verify_peer) {
|
| 543 |
$this->curl_add_option(CURLOPT_SSL_VERIFYPEER, TRUE);
|
| 544 |
$this->curl_add_option(CURLOPT_SSL_VERIFYHOST, $verify_host);
|
| 545 |
$this->curl_add_option(CURLOPT_CAINFO, $path_to_cert);
|
| 549 |
}
|
| 550 |
return $this;
|
| 551 |
}
|
| 552 |
+
*/
|
| 553 |
|
| 554 |
/**
|
| 555 |
* Disables cURL fail on error codes over 400
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>NetPay_Netpayonlinepayments</name>
|
| 4 |
-
<version>1.0.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>OSL v3.0</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -22,11 +22,11 @@ Features
|
|
| 22 |
• Supports tokenization, which enables store the payer’s card information on NetPay’s Secure Server
|
| 23 |
• Simple and easy configuration
|
| 24 |
</description>
|
| 25 |
-
<notes>
|
| 26 |
<authors><author><name>Huseyin Ozturk</name><user>netpay</user><email>huseyin.ozturk@netpay.co.uk</email></author></authors>
|
| 27 |
-
<date>2015-
|
| 28 |
-
<time>
|
| 29 |
-
<contents><target name="magelocal"><dir name="NetPay"><dir name="Netpayonlinepayments"><dir name="Block"><file name="Api.php" hash="
|
| 30 |
<compatible/>
|
| 31 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 32 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>NetPay_Netpayonlinepayments</name>
|
| 4 |
+
<version>1.0.5</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>OSL v3.0</license>
|
| 7 |
<channel>community</channel>
|
| 22 |
• Supports tokenization, which enables store the payer’s card information on NetPay’s Secure Server
|
| 23 |
• Simple and easy configuration
|
| 24 |
</description>
|
| 25 |
+
<notes>Reworked API section for newer Magento version</notes>
|
| 26 |
<authors><author><name>Huseyin Ozturk</name><user>netpay</user><email>huseyin.ozturk@netpay.co.uk</email></author></authors>
|
| 27 |
+
<date>2015-09-30</date>
|
| 28 |
+
<time>15:20:10</time>
|
| 29 |
+
<contents><target name="magelocal"><dir name="NetPay"><dir name="Netpayonlinepayments"><dir name="Block"><file name="Api.php" hash="6aaa4f88a658c71d3747048644a10a2c"/><file name="Form.php" hash="ae867dccec77bc8731c0c319c01402a4"/><file name="Redirect.php" hash="d96a5922a4f0aae616d39cec84d78974"/><file name="Secureredirect.php" hash="402a0a4f7dd462e178692863325ef309"/></dir><dir name="Helper"><file name="Data.php" hash="aa659f16c4e1e2848de0a09594dc8b5d"/></dir><dir name="Model"><file name="Card.php" hash="c7cc0d160f316dde037c1b7f2ec14994"/><file name="Configkey.php" hash="e00f6572425364d24ce5c0d1e5fd2d23"/><file name="Direct.php" hash="dc51fbb45ce724e66d5cdeb2eaed2da0"/><dir name="Mysql4"><dir name="Card"><file name="Collection.php" hash="a2b0f9ff13a0bb52376d868b1d8520f0"/></dir><file name="Card.php" hash="c96dfece89ddf6da22aa1e507996e3c0"/><dir name="Response"><file name="Collection.php" hash="ff19db09c7bd5fdbef5241359b5b0cbf"/></dir><file name="Response.php" hash="90753bbe50f4d57ec038361db0ccdbf4"/><dir name="Temp"><file name="Collection.php" hash="03ca3ec1af68e06910190ccc34c30b10"/></dir><file name="Temp.php" hash="955e3a82839546574295d31ca87aa244"/></dir><file name="Netpayapi.php" hash="6987d08f997f0c5e53c411c2e1b9650a"/><file name="Response.php" hash="b6a1675696e1d1fc63992e437ae513c4"/><dir name="Source"><file name="Cctype.php" hash="fd4380fb02a6623cb0180de6dd806f4b"/><file name="OperationType.php" hash="23b55afe09fef51ea812cb97f7715496"/><file name="PaymentAction.php" hash="9c102faff0c1aa82a3eac11bbfdc0088"/><file name="PaymentMethod.php" hash="af97bcd4dd14292f84894e1456ccb24f"/><file name="PaymentMode.php" hash="9fb41527394c8e23ba79bafb36442693"/></dir><file name="Temp.php" hash="8875f13a75ecc75cb34c111c10da2961"/></dir><dir name="controllers"><file name="PaymentController.php" hash="7a15165c3653d0a8d9ef17a453d03578"/></dir><dir name="etc"><file name="config.xml" hash="722bff50171def1c0099fe01ea125f0c"/><file name="system.xml" hash="7f9d07ed0ad5fe7dd0c43ce989004b03"/></dir><dir name="sql"><dir name="netpayonlinepayments_setup"><file name="install-1.0.0.php" hash="bee133624a0c09bf5138383f5381c348"/><file name="mysql4-install-1.0.0.php" hash="13257eaeb1e54a5a3a4fd5ad0dd4f98b"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="NetPay_Netpayonlinepayments.xml" hash="7c99deb0539260de7f8f6e6cd47f8171"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="netpayonlinepayments"><file name="api_form.phtml" hash="ee203403465036ecac848f2797b386ae"/><file name="form.phtml" hash="73335dfaff5bb334793c4da02d43f2e2"/><file name="redirect.phtml" hash="14e8ad032ac0f4d7d569ff1619174997"/></dir></dir><dir name="layout"><file name="netpayonlinepayments.xml" hash="d16a10dba3be3ee58d6e11be52de2bd6"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><file name="netpay_payment.png" hash="8cb0d8dbec0fc02779e053f5d2ad4968"/></dir></dir></dir></dir></target><target name="magelib"><dir name="NetPay"><file name="Connection.php" hash="3940325f7902cc5b31b84a3b8e41bff3"/></dir></target><target name="mage"><dir name="js"><dir name="NetPay"><file name="netpay-api.js" hash="aa36f04cbd78467700fdc712df9f5668"/></dir></dir></target></contents>
|
| 30 |
<compatible/>
|
| 31 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 32 |
</package>
|
