-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Push initial magento code for Magento 1.X version
- Loading branch information
paykun-code
committed
Nov 23, 2018
1 parent
9a04883
commit fe3e21e
Showing
20 changed files
with
1,574 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
.idea/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,36 @@ | ||
# Magento-1.X | ||
Magento Version 1.X | ||
|
||
# <h3>How To Generate Access token and API Secret :</h3> | ||
You can find your Merchant Id in Paykun Dashboard. | ||
|
||
You can generate Or Regenerate Access token and API Secret from login into your paykun admin panel, Then Go To : Settings -> Security -> API Keys. There you will find the generate button if you have not generated api key before. | ||
|
||
If you have generated api key before then you will see the date of the api key generate, since you will not be able to retrieve the old api key (For security reasons) we have provided the re-generate option, so you can re-generate api key in case you have lost the old one. | ||
|
||
Note : Once you re-generate api key your old api key will stop working immediately. So be cautious while using this option. | ||
|
||
# <h3>Prerequisite</h3> | ||
Merchant Id (Please read 'How To Generate Access token and API Secret :') | ||
Access Token (Please read 'How To Generate Access token and API Secret :') | ||
Encryption Key (Please read 'How To Generate Access token and API Secret :') | ||
Wordpress 4.x compatible Woo-Commerce version must be installed and other payment method working properly. | ||
|
||
# <h3>Installation</h3> | ||
Note: Please backup your running source code and database first. | ||
1. Download the zip and extract it to the some temporary location. | ||
2. Copy 'app' directory and paste it in your root directory. | ||
3. Once Copy is done then clear the cache. | ||
4. Now login to the Magento admin and go to the Admin > System > Configuration > Sales > Payment Methods > Paykun Checkout | ||
5. Save the below configuration. | ||
|
||
* Enable - Yes | ||
* Payment Action - Default | ||
* Merchant Id - Staging/Production Merchant Id provided by Paykun | ||
* Access Token - Staging/Production Access Token provided by Paykun | ||
* Encryption Key - Staging/Production Encryption Key provided by Paykun | ||
* Debug - For trouble shooting, also enable magento log from the Configuration > Advanced > Log Settings > Set Enabled to Yes | ||
|
||
10. Now you will be able to see paykun payment method in the checkout page. | ||
|
||
#<h3> In case of any query, please contact to support@paykun.com.</h3> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
class Paykun_Pcheckout_Helper_Data extends Mage_Core_Helper_Abstract | ||
{ | ||
public function indexAction() | ||
{ | ||
echo ""; | ||
} | ||
|
||
public function getPendigStatusAsPerVersion(){ | ||
if (version_compare(Mage::getVersion(), '1.4.0', '<')) { | ||
return Mage_Sales_Model_Order::STATE_HOLDED; | ||
} | ||
return Mage_Sales_Model_Order::STATE_PENDING_PAYMENT; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
=> Installation steps | ||
=> Paykun payment for Magento 1.9.X | ||
=> Extract zip on the following path app > code > community | ||
|
||
=> Now go to the admin > payment methods > select Paykun Pcheckout | ||
=> Enter all the required details provided by paykun. | ||
=> Required fields, Merchant Id, Access Token, Encryption Key | ||
=> Please read below section "How To Generate Access token and API Secret :" | ||
|
||
|
||
================================ | ||
How To Generate Access token and API Secret : | ||
================================ | ||
|
||
You can generate Or Regenerate Access token and API Secret from login into your paykun admin panel, Then Go To : Settings -> Security -> API Keys. There you will find the generate button if you have not generated api key before. | ||
|
||
If you have generated api key before then you will see the date of the api key generate, since you will not be able to retrieve the old api key (For security reasons) we have provided the re-generate option, so you can re-generate api key in case you have lost the old one. | ||
|
||
Note : Once you re-generate api key your old api key will stop working immediately. So be cautious while using this option. |
61 changes: 61 additions & 0 deletions
61
app/code/community/Paykun/Pcheckout/Model/PaymentMethod.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
// This module is more than a normal payment gateway | ||
// It needs dashboard and all | ||
|
||
|
||
class Paykun_Pcheckout_Model_PaymentMethod extends Mage_Payment_Model_Method_Abstract{ | ||
/** | ||
* Availability options | ||
*/ | ||
|
||
private $LOG_FILE_NAME = 'paykun.log'; | ||
|
||
protected $_code = 'pcheckout'; | ||
|
||
protected $_isGateway = true; | ||
protected $_canAuthorize = true; | ||
protected $_canCapture = true; | ||
protected $_canCapturePartial = true; | ||
protected $_canRefund = false; | ||
protected $_canVoid = false; | ||
protected $_canUseInternal = true; | ||
protected $_canUseCheckout = true; | ||
protected $_canUseForMultishipping = true; | ||
protected $_canSaveCc = false; | ||
protected $_isInitializeNeeded = false; | ||
|
||
/** | ||
* @return Mage_Checkout_Model_Session | ||
*/ | ||
protected function _getCheckout() | ||
{ | ||
return Mage::getSingleton('checkout/session'); | ||
} | ||
|
||
// Construct the redirect URL | ||
public function getOrderPlaceRedirectUrl() | ||
{ | ||
$redirect_url = Mage::getUrl('pcheckout/payment/redirect'); | ||
Mage::Log("Step 2 Process: Getting the redirect URL: $redirect_url", Zend_Log::DEBUG, $this->LOG_FILE_NAME); | ||
return $redirect_url; | ||
} | ||
|
||
public function authorize(Varien_Object $payment, $amount){ | ||
Mage::Log('Step 0 Process: Authorize', Zend_Log::DEBUG, $this->LOG_FILE_NAME); | ||
return $this; | ||
} | ||
/** | ||
* this method is called if we are authorising AND | ||
* capturing a transaction | ||
*/ | ||
public function capture(Varien_Object $payment, $amount) | ||
{ | ||
Mage::Log('Step 1 Process: Create and capture the process', Zend_Log::DEBUG, $this->LOG_FILE_NAME); | ||
return $this; | ||
} | ||
|
||
} | ||
|
||
// Suggestions from | ||
// http://stackoverflow.com/questions/6058430/magento-redirect-checkout-payment-to-a-3rd-party-gateway | ||
// |
46 changes: 46 additions & 0 deletions
46
app/code/community/Paykun/Pcheckout/controllers/CryptoController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
class Paykun_Pcheckout_CryptoController { | ||
|
||
public static function encrypt ($text, $key) { | ||
// $iv = random_bytes(16); | ||
$iv = openssl_random_pseudo_bytes(16); | ||
$value = openssl_encrypt(serialize($text), 'AES-256-CBC', $key, 0, $iv); | ||
$bIv = base64_encode($iv); | ||
$mac = hash_hmac('sha256', $bIv.$value, $key); | ||
$c_arr = ['iv'=>$bIv,'value'=>$value,'mac'=>$mac]; | ||
$json = json_encode($c_arr); | ||
$crypted = base64_encode($json); | ||
return $crypted; | ||
} | ||
|
||
public static function decrypt ($sStr, $sKey) { | ||
$payload = json_decode(base64_decode($sStr), true); | ||
|
||
if (!is_array($payload) && isset($payload['iv'], $payload['value'], $payload['mac'])) { | ||
throw new DecryptException('The payload is invalid.'); | ||
} | ||
|
||
// $bytes = random_bytes(16); | ||
$bytes = openssl_random_pseudo_bytes(16); | ||
$calculated = hash_hmac('sha256', hash_hmac('sha256', $payload['iv'].$payload['value'], $sKey), $bytes, true); | ||
if (!hash_equals(hash_hmac('sha256', $payload['mac'], $bytes, true), $calculated)) { | ||
echo 'mac not matched'; | ||
} | ||
|
||
$iv = base64_decode($payload['iv']); | ||
|
||
$decrypted = \openssl_decrypt( | ||
$payload['value'], 'AES-256-CBC', $sKey, 0, $iv | ||
); | ||
|
||
if ($decrypted === false) { | ||
echo 'can\'t decrypt'; | ||
} | ||
|
||
echo unserialize($decrypted); | ||
} | ||
|
||
} | ||
|
||
?> |
Oops, something went wrong.