Version Notes
Première version du module
Download this release
Release Info
Developer | Watt is it |
Extension | Wattisit_Paygreen |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- app/code/community/Wattisit/Paygreen/Block/Form.php +23 -0
- app/code/community/Wattisit/Paygreen/Block/Info.php +45 -0
- app/code/community/Wattisit/Paygreen/Block/Monblock.php +8 -0
- app/code/community/Wattisit/Paygreen/Block/Payment.php +49 -0
- app/code/community/Wattisit/Paygreen/Helper/Data.php +102 -0
- app/code/community/Wattisit/Paygreen/Model/Buttons.php +9 -0
- app/code/community/Wattisit/Paygreen/Model/Datasource/Status.php +41 -0
- app/code/community/Wattisit/Paygreen/Model/Mysql4/Buttons.php +8 -0
- app/code/community/Wattisit/Paygreen/Model/Mysql4/Buttons/Collection.php +9 -0
- app/code/community/Wattisit/Paygreen/Model/PaymentMethod.php +48 -0
- app/code/community/Wattisit/Paygreen/Model/Resource/Setup.php +3 -0
- app/code/community/Wattisit/Paygreen/controllers/Adminhtml/ButtonsController.php +75 -0
- app/code/community/Wattisit/Paygreen/controllers/Adminhtml/IndexController.php +9 -0
- app/code/community/Wattisit/Paygreen/controllers/IndexController.php +128 -0
- app/code/community/Wattisit/Paygreen/controllers/StaticController.php +41 -0
- app/code/community/Wattisit/Paygreen/etc/config.xml +124 -0
- app/code/community/Wattisit/Paygreen/etc/system.xml +98 -0
- app/code/community/Wattisit/Paygreen/lib/PaygreenClient.php +165 -0
- app/code/community/Wattisit/Paygreen/lib/PaygrenModuleUtils.php +28 -0
- app/code/community/Wattisit/Paygreen/public/icons/paiement.png +0 -0
- app/code/community/Wattisit/Paygreen/public/icons/paygreen_paiement.png +0 -0
- app/code/community/Wattisit/Paygreen/sql/paygreen_setup/mysql4-install-0.1.0.php +30 -0
- app/design/adminhtml/base/default/layout/paygreen.xml +9 -0
- app/design/adminhtml/base/default/template/paygreen/afficher.phtml +5 -0
- app/design/adminhtml/base/default/template/paygreen/buttons.phtml +132 -0
- app/design/frontend/base/default/layout/paygreen.xml +12 -0
- app/design/frontend/base/default/template/paygreen/afficher.phtml +5 -0
- app/design/frontend/base/default/template/paygreen/caller.phtml +16 -0
- app/design/frontend/base/default/template/paygreen/informations.phtml +7 -0
- app/design/frontend/base/default/template/paygreen/paiement.phtml +44 -0
- app/design/frontend/base/default/template/paygreen/returned.phtml +15 -0
- app/etc/modules/Wattisit_Paygreen.xml +12 -0
- package.xml +28 -0
app/code/community/Wattisit/Paygreen/Block/Form.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Wattisit_Paygreen_Block_Form extends Mage_Payment_Block_Form {
|
4 |
+
protected function _construct() {
|
5 |
+
$this->setTemplate('paygreen/paiement.phtml');
|
6 |
+
parent::_construct();
|
7 |
+
}
|
8 |
+
|
9 |
+
public function getButtons() {
|
10 |
+
return Mage::getModel('paygreen/buttons')->getCollection()
|
11 |
+
->setOrder('position','asc');
|
12 |
+
}
|
13 |
+
|
14 |
+
public function getIcons($img) {
|
15 |
+
$url = $this->getUrl('paygreen/static/get',
|
16 |
+
array(
|
17 |
+
't' => 'icons',
|
18 |
+
'f' => $img
|
19 |
+
)
|
20 |
+
);
|
21 |
+
return substr($url, 0, -1);
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Wattisit/Paygreen/Block/Info.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Wattisit_Paygreen_Block_Info extends Mage_Payment_Block_Info {
|
4 |
+
protected function _construct() {
|
5 |
+
parent::_construct();
|
6 |
+
$this->setTemplate('paygreen/informations.phtml');
|
7 |
+
}
|
8 |
+
|
9 |
+
public function getButtonType() {
|
10 |
+
$info = $this->getAdditional();
|
11 |
+
return $info['button'];
|
12 |
+
}
|
13 |
+
|
14 |
+
|
15 |
+
public function getButton() {
|
16 |
+
return Mage::getModel('paygreen/buttons')->load($this->getButtonType());
|
17 |
+
}
|
18 |
+
|
19 |
+
|
20 |
+
protected function getAdditional() {
|
21 |
+
$info = $this->getData('info');
|
22 |
+
if (!($info instanceof Mage_Payment_Model_Info)) {
|
23 |
+
Mage::throwException($this->__('Cannot retrieve the payment info model object.'));
|
24 |
+
}
|
25 |
+
return $info->getAdditionalInformation();
|
26 |
+
}
|
27 |
+
public function getIcons($img) {
|
28 |
+
$url = $this->getUrl('paygreen/static/get',
|
29 |
+
array(
|
30 |
+
't' => 'icons',
|
31 |
+
'f' => $img
|
32 |
+
)
|
33 |
+
);
|
34 |
+
return substr($url, 0, -1);
|
35 |
+
}
|
36 |
+
|
37 |
+
/*public function getInfo()
|
38 |
+
{
|
39 |
+
$info = $this->getData('info');
|
40 |
+
if (!($info instanceof Mage_Payment_Model_Info)) {
|
41 |
+
Mage::throwException($this->__('Cannot retrieve the payment info model object.'));
|
42 |
+
}
|
43 |
+
return $info;
|
44 |
+
}*/
|
45 |
+
}
|
app/code/community/Wattisit/Paygreen/Block/Monblock.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Wattisit_Paygreen_Block_Monblock extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
public function methodblock()
|
5 |
+
{
|
6 |
+
return 'informations de mon block !!' ;
|
7 |
+
}
|
8 |
+
}
|
app/code/community/Wattisit/Paygreen/Block/Payment.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Wattisit_Paygreen_Block_Payment extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
public function methodblock()
|
5 |
+
{
|
6 |
+
return '>>'.$this->getMerchantId() ;
|
7 |
+
}
|
8 |
+
|
9 |
+
protected function getMerchantId() {
|
10 |
+
return trim(Mage::getStoreConfig('payment/paygreen/merchant_id'));
|
11 |
+
}
|
12 |
+
protected function getAccessKey() {
|
13 |
+
return trim(Mage::getStoreConfig('payment/paygreen/access_key'));
|
14 |
+
}
|
15 |
+
|
16 |
+
protected function title() {
|
17 |
+
return trim(Mage::getStoreConfig('payment/paygreen/title'));
|
18 |
+
}
|
19 |
+
protected function acceptedMessage() {
|
20 |
+
return trim(Mage::getStoreConfig('payment/paygreen/paiement_accepted'));
|
21 |
+
}
|
22 |
+
protected function refusedMessage() {
|
23 |
+
return trim(Mage::getStoreConfig('payment/paygreen/paiement_refused'));
|
24 |
+
}
|
25 |
+
protected function cancelledMessage() {
|
26 |
+
return trim(Mage::getStoreConfig('payment/paygreen/paiement_cancelled'));
|
27 |
+
}
|
28 |
+
|
29 |
+
public function isConfigure() {
|
30 |
+
$merchant_id = $this->getMerchantId();
|
31 |
+
$access_key = $this->getAccessKey();
|
32 |
+
return isset($merchant_id) && isset($access_key);
|
33 |
+
}
|
34 |
+
|
35 |
+
public function getAll() {
|
36 |
+
return Mage::getModel('paygreen/buttons')->getCollection()
|
37 |
+
->setOrder('position','asc');
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getIcons($img) {
|
41 |
+
$url = $this->getUrl('paygreen/static/get',
|
42 |
+
array(
|
43 |
+
't' => 'icons',
|
44 |
+
'f' => $img
|
45 |
+
)
|
46 |
+
);
|
47 |
+
return substr($url, 0, -1);
|
48 |
+
}
|
49 |
+
}
|
app/code/community/Wattisit/Paygreen/Helper/Data.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Wattisit_Paygreen_Helper_Data extends Mage_Core_Helper_Data
|
4 |
+
{
|
5 |
+
const DIR_ICONS = 'icons';
|
6 |
+
|
7 |
+
/*public $merchant_id = '';
|
8 |
+
public $access_key = '';
|
9 |
+
public $paiement_accepted = '';
|
10 |
+
public $paiement_refused = '';*/
|
11 |
+
|
12 |
+
public function __get($name) {
|
13 |
+
return Mage::getStoreConfig('payment/paygreen/'.$name);
|
14 |
+
}
|
15 |
+
|
16 |
+
public function getExtPubDir($type)
|
17 |
+
{
|
18 |
+
return __DIR__.DS.'..'.DS.'public'.DS.$type;
|
19 |
+
}
|
20 |
+
|
21 |
+
public function getAllowedFiles($dir)
|
22 |
+
{
|
23 |
+
$results = array();
|
24 |
+
$handler = opendir($this->getExtPubDir($dir));
|
25 |
+
|
26 |
+
/* Might be improved later via cache, not to list entire folder on each request. */
|
27 |
+
while ($file = readdir($handler)) {
|
28 |
+
if ($file != "." && $file != "..") {
|
29 |
+
$results[] = $file;
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
closedir($handler);
|
34 |
+
|
35 |
+
return $results;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function initPaygren() {
|
39 |
+
$paygreenSdkPath = __DIR__.DS.'..'.DS.'lib'.DS;
|
40 |
+
require_once($paygreenSdkPath.'PaygreenClient.php');
|
41 |
+
require_once($paygreenSdkPath.'PaygrenModuleUtils.php');
|
42 |
+
$paygreen = new PaygrenModuleUtils($this->merchant_id);
|
43 |
+
$paygreen->setToken($this->access_key);
|
44 |
+
return $paygreen;
|
45 |
+
}
|
46 |
+
|
47 |
+
public function setOrderStatus($paygreen, $order)
|
48 |
+
{
|
49 |
+
switch($paygreen->result['status']) {
|
50 |
+
case PaygreenClient::STATUS_REFUSED:
|
51 |
+
$status = $this->failed_order_status;
|
52 |
+
break;
|
53 |
+
case PaygreenClient::STATUS_SUCCESSED:
|
54 |
+
$status = $this->authorized_order_status;
|
55 |
+
break;
|
56 |
+
case PaygreenClient::STATUS_CANCELLING:
|
57 |
+
$status = $this->canceled_order_status;
|
58 |
+
break;
|
59 |
+
default:
|
60 |
+
return false;
|
61 |
+
}
|
62 |
+
|
63 |
+
$state = Mage::getModel('sales/order_status')->getCollection()
|
64 |
+
->joinStates()
|
65 |
+
->addFieldToFilter('state_table.status', $status)
|
66 |
+
->getFirstItem()
|
67 |
+
->getState();
|
68 |
+
|
69 |
+
if (empty($state)) {
|
70 |
+
$state = Mage_Sales_Model_Order::STATE_PROCESSING;
|
71 |
+
}
|
72 |
+
$order->setState($state, $status);
|
73 |
+
}
|
74 |
+
|
75 |
+
public function addTransaction($paygreen, $order)
|
76 |
+
{
|
77 |
+
$transactionId = $paygreen->pid;
|
78 |
+
if (version_compare(Mage::getVersion(), '1.4', 'ge')) {
|
79 |
+
/* @var $payment Mage_Payment_Model_Method_Abstract */
|
80 |
+
$payment = $order->getPayment();
|
81 |
+
if (!$payment->getTransaction($transactionId)) { // if transaction isn't saved yet
|
82 |
+
$transaction = Mage::getModel('sales/order_payment_transaction');
|
83 |
+
$transaction->setTxnId($transactionId);
|
84 |
+
$transaction->setOrderPaymentObject($order->getPayment());
|
85 |
+
$transaction->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_PAYMENT);
|
86 |
+
/*if ($paymentAction == '100') {
|
87 |
+
|
88 |
+
} else if ($paymentAction == '101') {
|
89 |
+
$transaction->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_PAYMENT);
|
90 |
+
}*/
|
91 |
+
$transaction->save();
|
92 |
+
$order->sendNewOrderEmail();
|
93 |
+
}
|
94 |
+
} else {
|
95 |
+
$order->getPayment()->setLastTransId($transactionId);
|
96 |
+
$order->sendNewOrderEmail();
|
97 |
+
}
|
98 |
+
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
// end class
|
app/code/community/Wattisit/Paygreen/Model/Buttons.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Wattisit_Paygreen_Model_Buttons extends Mage_Core_Model_Abstract
|
3 |
+
{
|
4 |
+
public function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->_init('paygreen/buttons');
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Wattisit/Paygreen/Model/Datasource/Status.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Wattisit_Paygreen_Model_Datasource_Status extends Mage_Adminhtml_Model_System_Config_Source_Order_Status
|
3 |
+
{
|
4 |
+
protected $_options;
|
5 |
+
|
6 |
+
public function toOptionArray()
|
7 |
+
{
|
8 |
+
if ($this->_options === null) {
|
9 |
+
$options = array();
|
10 |
+
if (class_exists('Mage_Sales_Model_Mysql4_Order_Status_Collection')) {
|
11 |
+
$collection = Mage::getResourceModel('sales/order_status_collection')
|
12 |
+
->orderByLabel();
|
13 |
+
$statusValue = '';
|
14 |
+
foreach ($collection as $status) {
|
15 |
+
$statusValue = $status->getStatus();
|
16 |
+
if( $statusValue === 'complete' || $statusValue === 'closed' ) {
|
17 |
+
continue;
|
18 |
+
}
|
19 |
+
$options[] = array(
|
20 |
+
'value' => $statusValue,
|
21 |
+
'label' => $status->getStoreLabel()
|
22 |
+
);
|
23 |
+
}
|
24 |
+
} else {
|
25 |
+
$statuses = Mage::getSingleton('sales/order_config')->getStatuses();
|
26 |
+
foreach ($statuses as $code=>$label) {
|
27 |
+
if( $code === 'complete' || $code === 'closed' ) {
|
28 |
+
continue;
|
29 |
+
}
|
30 |
+
$options[] = array(
|
31 |
+
'value' => $code,
|
32 |
+
'label' => $label
|
33 |
+
);
|
34 |
+
}
|
35 |
+
}
|
36 |
+
$this->_options = $options;
|
37 |
+
}
|
38 |
+
|
39 |
+
return $this->_options;
|
40 |
+
}
|
41 |
+
}
|
app/code/community/Wattisit/Paygreen/Model/Mysql4/Buttons.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Wattisit_Paygreen_Model_Mysql4_Buttons extends Mage_Core_Model_Mysql4_Abstract
|
3 |
+
{
|
4 |
+
public function _construct()
|
5 |
+
{
|
6 |
+
$this->_init('paygreen/buttons', 'id');
|
7 |
+
}
|
8 |
+
}
|
app/code/community/Wattisit/Paygreen/Model/Mysql4/Buttons/Collection.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Wattisit_Paygreen_Model_Mysql4_Buttons_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
3 |
+
{
|
4 |
+
public function _construct()
|
5 |
+
{
|
6 |
+
parent::_construct();
|
7 |
+
$this->_init('paygreen/buttons');
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Wattisit/Paygreen/Model/PaymentMethod.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Wattisit_Paygreen_Model_PaymentMethod extends Mage_Payment_Model_Method_Abstract {
|
3 |
+
protected $_code = 'paygreen';
|
4 |
+
|
5 |
+
protected $_canUseForMultishipping = false;
|
6 |
+
|
7 |
+
protected $_formBlockType = 'paygreen/form';
|
8 |
+
protected $_infoBlockType = 'paygreen/info';
|
9 |
+
|
10 |
+
|
11 |
+
public function isAvailable($quote = null) {
|
12 |
+
return true;
|
13 |
+
}
|
14 |
+
|
15 |
+
public function assignData($data)
|
16 |
+
{
|
17 |
+
|
18 |
+
if (!($data instanceof Varien_Object)) {
|
19 |
+
$data = new Varien_Object($data);
|
20 |
+
}
|
21 |
+
$info = $this->getInfoInstance();
|
22 |
+
$info->setAdditionalInformation(array('button' => $data->paygreen_btn))
|
23 |
+
;
|
24 |
+
|
25 |
+
return $this;
|
26 |
+
}
|
27 |
+
|
28 |
+
public function validate()
|
29 |
+
{
|
30 |
+
parent::validate();
|
31 |
+
|
32 |
+
// Validate the credit card number
|
33 |
+
$info = $this->getInfoInstance();
|
34 |
+
//die($info->getButton());
|
35 |
+
//$errorMsg = Mage::helper('payment')->__('Credit card type is not allowed for this payment method.');
|
36 |
+
//Mage::throwException($errorMsg);
|
37 |
+
return $this;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getOrderPlaceRedirectUrl()
|
41 |
+
{
|
42 |
+
$info = $this->getInfoInstance()->getAdditionalInformation();
|
43 |
+
return Mage::getUrl('paygreen/index/paiement', array(
|
44 |
+
'b'=>$info['button']
|
45 |
+
));
|
46 |
+
}
|
47 |
+
|
48 |
+
}
|
app/code/community/Wattisit/Paygreen/Model/Resource/Setup.php
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Wattisit_Paygreen_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup {
|
3 |
+
}
|
app/code/community/Wattisit/Paygreen/controllers/Adminhtml/ButtonsController.php
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Wattisit_Paygreen_Adminhtml_ButtonsController extends Mage_Adminhtml_Controller_Action
|
3 |
+
{
|
4 |
+
public function indexAction()
|
5 |
+
{
|
6 |
+
$merchant_id = trim(Mage::getStoreConfig('payment/paygreen/merchant_id'));
|
7 |
+
$access_key = trim(Mage::getStoreConfig('payment/paygreen/access_key'));
|
8 |
+
if(empty($merchant_id) || empty($access_key))
|
9 |
+
Mage::getSingleton('adminhtml/session')->addError('Vous devez configurer le module Paygreen : System > Configuration > Payment Methods > Paygreen');
|
10 |
+
$this->loadLayout();
|
11 |
+
$this->renderLayout();
|
12 |
+
}
|
13 |
+
|
14 |
+
public function saveAction() {
|
15 |
+
if($this->getRequest()->getPost()) {
|
16 |
+
if($this->getRequest()->getPost('submitPaygreenModuleButton', '0') == '1')
|
17 |
+
$this->_saveItem($this->getRequest());
|
18 |
+
else if($this->getRequest()->getPost('submitPaygreenModuleButtonDelete', '0') == '1')
|
19 |
+
$this->_deleteItem($this->getRequest());
|
20 |
+
}
|
21 |
+
return $this->_redirect('adminpaygreen/adminhtml_buttons/index');
|
22 |
+
}
|
23 |
+
|
24 |
+
private function _saveItem($req) {
|
25 |
+
if($req->getPost('id') > 0)
|
26 |
+
$button = Mage::getModel('paygreen/buttons')->load($req->getPost('id'));
|
27 |
+
else
|
28 |
+
$button = Mage::getModel('paygreen/buttons');
|
29 |
+
|
30 |
+
if(array_key_exists('image', $_FILES) && is_array($_FILES['image'])) {
|
31 |
+
if($_FILES['image']['error'] == 0) {
|
32 |
+
$uploader = new Varien_File_Uploader('image');
|
33 |
+
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
|
34 |
+
$uploader->setAllowRenameFiles(false);
|
35 |
+
$uploader->setFilesDispersion(false);
|
36 |
+
|
37 |
+
$path = Mage::getModuleDir('', 'Wattisit_Paygreen').DS.'public'.DS.'icons'.DS;
|
38 |
+
|
39 |
+
$uploader->save($path, $_FILES['image']['name']);
|
40 |
+
|
41 |
+
$button->setData('image', $_FILES['image']['name']);
|
42 |
+
|
43 |
+
} else {
|
44 |
+
Mage::getSingleton('adminhtml/session')->addError('Impossible de changer l\'image.');
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
$button->setData('label', $req->getPost('label'));
|
49 |
+
$button->setData('height', $req->getPost('height'));
|
50 |
+
if($req->getPost('position') > 0)
|
51 |
+
$button->setData('position', $req->getPost('position'));
|
52 |
+
else
|
53 |
+
$button->setData('position', Mage::getModel('paygreen/buttons')->getCollection()->getSize()+1);
|
54 |
+
try {
|
55 |
+
$button->save();
|
56 |
+
Mage::getSingleton('adminhtml/session')->addSuccess('Le bouton "'.$button->getData('label').'" à bien été sauvé.');
|
57 |
+
|
58 |
+
} catch (Exception $e){
|
59 |
+
Mage::getSingleton('adminhtml/session')->addError('Impossible de sauver ce boutton : '.$ex->getMessage());
|
60 |
+
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
private function _deleteItem($req) {
|
65 |
+
$model = Mage::getModel('paygreen/buttons');
|
66 |
+
try {
|
67 |
+
$model->setId($req->getPost('id'))->delete();
|
68 |
+
Mage::getSingleton('adminhtml/session')->addSuccess('Le bouton "'.$req->getPost('label').'" à correctement été supprimé.');
|
69 |
+
|
70 |
+
} catch (Exception $e){
|
71 |
+
Mage::getSingleton('adminhtml/session')->addError('Impossible de supprimer ce boutton : '.$ex->getMessage());
|
72 |
+
|
73 |
+
}
|
74 |
+
}
|
75 |
+
}
|
app/code/community/Wattisit/Paygreen/controllers/Adminhtml/IndexController.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Wattisit_Paygreen_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
|
3 |
+
{
|
4 |
+
public function indexAction()
|
5 |
+
{
|
6 |
+
$this->loadLayout();
|
7 |
+
$this->renderLayout();
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Wattisit/Paygreen/controllers/IndexController.php
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Wattisit_Paygreen_IndexController extends Mage_Core_Controller_Front_Action
|
4 |
+
{
|
5 |
+
public function indexAction()
|
6 |
+
{
|
7 |
+
$this->loadLayout();
|
8 |
+
$this->renderLayout();
|
9 |
+
}
|
10 |
+
|
11 |
+
public function paiementAction() {
|
12 |
+
$this->loadLayout();
|
13 |
+
|
14 |
+
$btn_id = $this->getRequest()->getParam('b');
|
15 |
+
|
16 |
+
$_session = Mage::getSingleton('checkout/session');
|
17 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($_session->getLastRealOrderId());
|
18 |
+
|
19 |
+
$btn = Mage::getModel('paygreen/buttons')->load($btn_id);
|
20 |
+
|
21 |
+
$paygreen = Mage::helper('paygreen')->initPaygren();
|
22 |
+
|
23 |
+
if($order->getBaseGrandTotal() == 0){ // If order amount is null, exit payment process
|
24 |
+
//Mage::helper('payline')->setOrderStatus($this->order, Mage::getStoreConfig('payment/payline_common/authorized_order_status'));
|
25 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, true, 'Payment Success.');
|
26 |
+
|
27 |
+
return true;
|
28 |
+
}
|
29 |
+
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
30 |
+
$buyerLastName = substr($customer->getLastname(), 0, 50);
|
31 |
+
if ($buyerLastName == null || $buyerLastName == '') {
|
32 |
+
$buyerLastName = substr($billingAddress->getLastname(), 0, 50);
|
33 |
+
}
|
34 |
+
$buyerFirstName = substr($customer->getFirstname(), 0, 50);
|
35 |
+
if ($buyerFirstName == null || $buyerFirstName == '') {
|
36 |
+
$buyerFirstName = substr($billingAddress->getFirstname(), 0, 50);
|
37 |
+
}
|
38 |
+
$email = $customer->getEmail();
|
39 |
+
if ($email == null || $email == '') {
|
40 |
+
$email = $order->getCustomerEmail();
|
41 |
+
}
|
42 |
+
|
43 |
+
$country = 'FR';
|
44 |
+
$billingAddress = $order->getBillingAddress();
|
45 |
+
if($billingAddress != null){
|
46 |
+
$country = $billingAddress->getCountry();
|
47 |
+
}
|
48 |
+
|
49 |
+
$paygreen->customer(
|
50 |
+
$order->getCustomerId(),
|
51 |
+
$buyerLastName,
|
52 |
+
$buyerFirstName,
|
53 |
+
$email,
|
54 |
+
$country
|
55 |
+
);
|
56 |
+
|
57 |
+
$paygreen->generateForNbPaiement(
|
58 |
+
substr($order->getRealOrderId(), 0, 50),
|
59 |
+
$btn->nbPayment,
|
60 |
+
$order->getBaseGrandTotal(),
|
61 |
+
$order->getBaseCurrencyCode()
|
62 |
+
);
|
63 |
+
$paygreen->return_cancel_url = Mage::getUrl('paygreen/index/return');
|
64 |
+
$paygreen->return_url = Mage::getUrl('paygreen/index/return');
|
65 |
+
$paygreen->return_callback_url = Mage::getUrl('paygreen/index/validation');
|
66 |
+
|
67 |
+
$block = $this->getLayout()->createBlock('paygreen/payment')
|
68 |
+
->setData('btn', $btn)
|
69 |
+
->setData('paygreen', $paygreen)
|
70 |
+
->setTemplate('paygreen/caller.phtml');
|
71 |
+
$this->getLayout()->getBlock('content')->append($block);
|
72 |
+
$this->renderLayout();
|
73 |
+
}
|
74 |
+
|
75 |
+
public function returnAction() {
|
76 |
+
$this->loadLayout();
|
77 |
+
if($this->getRequest()->getPost()) {
|
78 |
+
$data = $this->getRequest()->getPost('data');
|
79 |
+
|
80 |
+
} else {
|
81 |
+
$data = $this->getRequest()->getParams()['data'];
|
82 |
+
}
|
83 |
+
|
84 |
+
if($data == null)
|
85 |
+
mageCoreErrorHandler(E_ERROR, "Donnée vide, veuillez nous contacter", __FILE__, __LINE__);
|
86 |
+
|
87 |
+
$paygreen = Mage::helper('paygreen')->initPaygren();
|
88 |
+
$paygreen->parseData($data);
|
89 |
+
|
90 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($paygreen->transaction_id);
|
91 |
+
|
92 |
+
$block = $this->getLayout()->createBlock('paygreen/payment')
|
93 |
+
->setData('paygreen', $paygreen)
|
94 |
+
->setData('order', $order)
|
95 |
+
->setTemplate('paygreen/returned.phtml');
|
96 |
+
$this->getLayout()->getBlock('content')->append($block);
|
97 |
+
$this->renderLayout();
|
98 |
+
}
|
99 |
+
|
100 |
+
|
101 |
+
|
102 |
+
|
103 |
+
|
104 |
+
public function validationAction() {
|
105 |
+
if($this->getRequest()->getPost()) {
|
106 |
+
$data = $this->getRequest()->getPost('data');
|
107 |
+
|
108 |
+
} else {
|
109 |
+
$data = $this->getRequest()->getParams()['data'];
|
110 |
+
}
|
111 |
+
|
112 |
+
if($data == null)
|
113 |
+
mageCoreErrorHandler(E_ERROR, "Donnée vide, veuillez nous contacter", __FILE__, __LINE__);
|
114 |
+
|
115 |
+
$paygreen = Mage::helper('paygreen')->initPaygren();
|
116 |
+
$paygreen->parseData($data);
|
117 |
+
|
118 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($paygreen->transaction_id);
|
119 |
+
|
120 |
+
Mage::helper('paygreen')->setOrderStatus($paygreen, $order);
|
121 |
+
Mage::helper('paygreen')->addTransaction($paygreen, $order);
|
122 |
+
|
123 |
+
$order->save();
|
124 |
+
|
125 |
+
echo '<pre>';
|
126 |
+
print_r($paygreen);
|
127 |
+
}
|
128 |
+
}
|
app/code/community/Wattisit/Paygreen/controllers/StaticController.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Wattisit_Paygreen_StaticController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
|
5 |
+
public function getAction()
|
6 |
+
{
|
7 |
+
$type = $this->getRequest()->getParam('t');
|
8 |
+
|
9 |
+
switch ($type) {
|
10 |
+
case 'icons':
|
11 |
+
return $this->_icons();
|
12 |
+
break;
|
13 |
+
default:
|
14 |
+
$this->getResponse()->setHeader('HTTP/1.1','404 Not Found');
|
15 |
+
$this->getResponse()->setHeader('Status','404 File not found');
|
16 |
+
break;
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
20 |
+
|
21 |
+
private function _icons()
|
22 |
+
{
|
23 |
+
$file = $this->getRequest()->getParam('f', 'paygreen_paiement.png');
|
24 |
+
$type = $this->getRequest()->getParam('t');
|
25 |
+
|
26 |
+
$helper = Mage::helper('paygreen');
|
27 |
+
|
28 |
+
if (in_array($file, $helper->getAllowedFiles($type))) {
|
29 |
+
$icon = new Varien_Image($helper->getExtPubDir($helper::DIR_ICONS).DS.$file);
|
30 |
+
$icon->keepTransparency(true);
|
31 |
+
header("Content-type: ".$icon->getMimeType());
|
32 |
+
$this->getResponse()->setHeader('Content-Type', $icon->getMimeType());
|
33 |
+
$this->getResponse()->setBody(readfile($helper->getExtPubDir($helper::DIR_ICONS).DS.$file));
|
34 |
+
} else {
|
35 |
+
die('404 '.$file.' '.$type);
|
36 |
+
$this->getResponse()->setHeader('HTTP/1.1','404 Not Found');
|
37 |
+
$this->getResponse()->setHeader('Status','404 File not found');
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
}
|
app/code/community/Wattisit/Paygreen/etc/config.xml
ADDED
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Wattisit_Paygreen>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<depends>
|
8 |
+
<Mage_Payment />
|
9 |
+
</depends>
|
10 |
+
</Wattisit_Paygreen>
|
11 |
+
</modules>
|
12 |
+
<frontend>
|
13 |
+
<routers>
|
14 |
+
<paygreen>
|
15 |
+
<use>standard</use>
|
16 |
+
<args>
|
17 |
+
<module>Wattisit_Paygreen</module>
|
18 |
+
<frontName>paygreen</frontName>
|
19 |
+
</args>
|
20 |
+
</paygreen>
|
21 |
+
</routers>
|
22 |
+
<layout>
|
23 |
+
<updates>
|
24 |
+
<paygreen>
|
25 |
+
<file>paygreen.xml</file>
|
26 |
+
</paygreen>
|
27 |
+
</updates>
|
28 |
+
</layout>
|
29 |
+
</frontend>
|
30 |
+
<admin>
|
31 |
+
<routers>
|
32 |
+
<paygreen>
|
33 |
+
<use>admin</use>
|
34 |
+
<args>
|
35 |
+
<module>Wattisit_Paygreen</module>
|
36 |
+
<frontName>adminpaygreen</frontName>
|
37 |
+
</args>
|
38 |
+
</paygreen>
|
39 |
+
</routers>
|
40 |
+
</admin>
|
41 |
+
<adminhtml>
|
42 |
+
<layout>
|
43 |
+
<updates>
|
44 |
+
<paygreen>
|
45 |
+
<file>paygreen.xml</file>
|
46 |
+
</paygreen>
|
47 |
+
</updates>
|
48 |
+
</layout>
|
49 |
+
<menu>
|
50 |
+
<paygreen translate="title" module="adminhtml">
|
51 |
+
<title>Paygreen</title>
|
52 |
+
<sort_order>300</sort_order>
|
53 |
+
<children>
|
54 |
+
<set_time>
|
55 |
+
<title>Gestion des boutons</title>
|
56 |
+
<action>adminpaygreen/adminhtml_buttons</action>
|
57 |
+
</set_time>
|
58 |
+
</children>
|
59 |
+
</paygreen>
|
60 |
+
</menu>
|
61 |
+
</adminhtml>
|
62 |
+
<global>
|
63 |
+
<blocks>
|
64 |
+
<paygreen>
|
65 |
+
<class>Wattisit_Paygreen_Block</class>
|
66 |
+
</paygreen>
|
67 |
+
</blocks>
|
68 |
+
<models>
|
69 |
+
<paygreen>
|
70 |
+
<class>Wattisit_Paygreen_Model</class>
|
71 |
+
<resourceModel>paygreen_mysql4</resourceModel>
|
72 |
+
</paygreen>
|
73 |
+
<paygreen_mysql4>
|
74 |
+
<class>Wattisit_Paygreen_Model_Mysql4</class>
|
75 |
+
<entities>
|
76 |
+
<buttons>
|
77 |
+
<table>paygreen_buttons</table>
|
78 |
+
</buttons>
|
79 |
+
</entities>
|
80 |
+
</paygreen_mysql4>
|
81 |
+
</models>
|
82 |
+
<!-- permet au module de lire et ecrire -->
|
83 |
+
<resources>
|
84 |
+
<paygreen_setup>
|
85 |
+
<setup>
|
86 |
+
<module>Wattisit_Paygreen</module>
|
87 |
+
<class>Wattisit_Paygreen_Model_Resource_Setup</class>
|
88 |
+
</setup>
|
89 |
+
</paygreen_setup>
|
90 |
+
<!-- connection pour ecrire -->
|
91 |
+
<paygreen_write>
|
92 |
+
<connection>
|
93 |
+
<use>core_write</use>
|
94 |
+
</connection>
|
95 |
+
</paygreen_write>
|
96 |
+
<!-- connection pour lire-->
|
97 |
+
<paygreen_read>
|
98 |
+
<connection>
|
99 |
+
<use>core_read</use>
|
100 |
+
</connection>
|
101 |
+
</paygreen_read>
|
102 |
+
</resources>
|
103 |
+
<helpers>
|
104 |
+
<paygreen>
|
105 |
+
<class>Wattisit_Paygreen_Helper</class>
|
106 |
+
</paygreen>
|
107 |
+
</helpers>
|
108 |
+
</global>
|
109 |
+
<default>
|
110 |
+
<payment>
|
111 |
+
<paygreen>
|
112 |
+
<title>Paygreen</title>
|
113 |
+
<model>paygreen/paymentMethod</model>
|
114 |
+
<active>1</active>
|
115 |
+
<paiement_accepted>Votre paiement avec Paygreen a été accepté</paiement_accepted>
|
116 |
+
<paiement_refused>Votre paiement avec Paygreen n'a pas abouti</paiement_refused>
|
117 |
+
<paiement_cancelled>Votre paiement avec Paygreen a été annulé</paiement_cancelled>
|
118 |
+
<failed_order_status>holded</failed_order_status>
|
119 |
+
<canceled_order_status>canceled</canceled_order_status>
|
120 |
+
<authorized_order_status>processing</authorized_order_status>
|
121 |
+
</paygreen>
|
122 |
+
</payment>
|
123 |
+
</default>
|
124 |
+
</config>
|
app/code/community/Wattisit/Paygreen/etc/system.xml
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<payment>
|
5 |
+
<groups>
|
6 |
+
<paygreen module="paygreen">
|
7 |
+
<label>Paygreen</label>
|
8 |
+
<sort_order>10</sort_order>
|
9 |
+
<show_in_default>1</show_in_default>
|
10 |
+
<show_in_website>1</show_in_website>
|
11 |
+
<show_in_store>1</show_in_store>
|
12 |
+
<comment><![CDATA[Pour récupérer votre clée privée et identifiant unique, veuillez vous <a href="https://paygreen.fr/subscribe" target="_blank">inscrire sur Paygreen</a>]]></comment>
|
13 |
+
<fields>
|
14 |
+
<title translate="label">
|
15 |
+
<label>Title</label>
|
16 |
+
<frontend_type>text</frontend_type>
|
17 |
+
<sort_order>1</sort_order>
|
18 |
+
<show_in_default>1</show_in_default>
|
19 |
+
<show_in_website>1</show_in_website>
|
20 |
+
<show_in_store>1</show_in_store>
|
21 |
+
</title>
|
22 |
+
<merchant_id module="paygreen">
|
23 |
+
<label>Clé privée</label>
|
24 |
+
<frontend_type>text</frontend_type>
|
25 |
+
<sort_order>2</sort_order>
|
26 |
+
<show_in_default>1</show_in_default>
|
27 |
+
<show_in_website>1</show_in_website>
|
28 |
+
<show_in_store>1</show_in_store>
|
29 |
+
</merchant_id>
|
30 |
+
<access_key>
|
31 |
+
<label>Identifiant unique</label>
|
32 |
+
<frontend_type>text</frontend_type>
|
33 |
+
<sort_order>3</sort_order>
|
34 |
+
<show_in_default>1</show_in_default>
|
35 |
+
<show_in_website>1</show_in_website>
|
36 |
+
<show_in_store>1</show_in_store>
|
37 |
+
</access_key>
|
38 |
+
<paiement_accepted>
|
39 |
+
<label>Phrase lors d\'un paiement réussi</label>
|
40 |
+
<frontend_type>text</frontend_type>
|
41 |
+
<sort_order>4</sort_order>
|
42 |
+
<show_in_default>1</show_in_default>
|
43 |
+
<show_in_website>1</show_in_website>
|
44 |
+
<show_in_store>1</show_in_store>
|
45 |
+
</paiement_accepted>
|
46 |
+
<paiement_refused>
|
47 |
+
<label>Phrase lors d\'un paiement refusé</label>
|
48 |
+
<frontend_type>text</frontend_type>
|
49 |
+
<sort_order>5</sort_order>
|
50 |
+
<show_in_default>1</show_in_default>
|
51 |
+
<show_in_website>1</show_in_website>
|
52 |
+
<show_in_store>1</show_in_store>
|
53 |
+
</paiement_refused>
|
54 |
+
<paiement_cancelled>
|
55 |
+
<label>Phrase lors d\'un paiement refusé</label>
|
56 |
+
<frontend_type>text</frontend_type>
|
57 |
+
<sort_order>5</sort_order>
|
58 |
+
<show_in_default>1</show_in_default>
|
59 |
+
<show_in_website>1</show_in_website>
|
60 |
+
<show_in_store>1</show_in_store>
|
61 |
+
</paiement_cancelled>
|
62 |
+
<authorized_order_status>
|
63 |
+
<label>Statut d'acceptation</label>
|
64 |
+
<comment>Statut de la commande après acceptation</comment>
|
65 |
+
<frontend_type>select</frontend_type>
|
66 |
+
<source_model>paygreen/datasource_status</source_model>
|
67 |
+
<sort_order>130</sort_order>
|
68 |
+
<show_in_default>1</show_in_default>
|
69 |
+
<show_in_website>1</show_in_website>
|
70 |
+
<show_in_store>1</show_in_store>
|
71 |
+
</authorized_order_status>
|
72 |
+
<failed_order_status>
|
73 |
+
<label>Statut d'échec</label>
|
74 |
+
<comment>Statut de la commande après un refus</comment>
|
75 |
+
<frontend_type>select</frontend_type>
|
76 |
+
<source_model>paygreen/datasource_status</source_model>
|
77 |
+
<sort_order>140</sort_order>
|
78 |
+
<show_in_default>1</show_in_default>
|
79 |
+
<show_in_website>1</show_in_website>
|
80 |
+
<show_in_store>1</show_in_store>
|
81 |
+
</failed_order_status>
|
82 |
+
<canceled_order_status>
|
83 |
+
<label>Statut d'annulation</label>
|
84 |
+
<comment>Statut de la commande après une annulation</comment>
|
85 |
+
<frontend_type>select</frontend_type>
|
86 |
+
<source_model>paygreen/datasource_status</source_model>
|
87 |
+
<sort_order>150</sort_order>
|
88 |
+
<show_in_default>1</show_in_default>
|
89 |
+
<show_in_website>1</show_in_website>
|
90 |
+
<show_in_store>1</show_in_store>
|
91 |
+
</canceled_order_status>
|
92 |
+
|
93 |
+
</fields>
|
94 |
+
</paygreen>
|
95 |
+
</groups>
|
96 |
+
</payment>
|
97 |
+
</sections>
|
98 |
+
</config>
|
app/code/community/Wattisit/Paygreen/lib/PaygreenClient.php
ADDED
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class PaygreenClient
|
4 |
+
{
|
5 |
+
const VERSION = '0.4B';
|
6 |
+
const CURRENCY_EUR = 'EUR';
|
7 |
+
|
8 |
+
|
9 |
+
const STATUS_WAITING = "WAITING";
|
10 |
+
const STATUS_PENDING = "PENDING";
|
11 |
+
const STATUS_CANCELLING = "CANCELLED";
|
12 |
+
const STATUS_REFUNDED = "REFUNDED";
|
13 |
+
const STATUS_RESETED = "RESETED";
|
14 |
+
const STATUS_FAILED = "FAILED";
|
15 |
+
const STATUS_SUCCESSED = "SUCCESSED";
|
16 |
+
const STATUS_REFUSED = "REFUSED";
|
17 |
+
|
18 |
+
const MODE_CASH = "CASH";
|
19 |
+
const MODE_RECURRING = "RECURRING";
|
20 |
+
|
21 |
+
const RECURRING_DAILY = 10;
|
22 |
+
const RECURRING_WEEKLY = 20;
|
23 |
+
const RECURRING_SEMI_MONTHLY = 30;
|
24 |
+
const RECURRING_MONTHLY = 40;
|
25 |
+
const RECURRING_BIMONTHLY = 50;
|
26 |
+
const RECURRING_QUARTERLY = 60;
|
27 |
+
const RECURRING_SEMI_ANNUAL = 70;
|
28 |
+
const RECURRING_ANNUAL = 80;
|
29 |
+
const RECURRING_BIANNUAL = 90;
|
30 |
+
|
31 |
+
public static $RECURRING_LABEL = array(
|
32 |
+
self::RECURRING_DAILY => 'jour',
|
33 |
+
self::RECURRING_WEEKLY => 'semaine',
|
34 |
+
self::RECURRING_SEMI_MONTHLY => 'quinzaine',
|
35 |
+
self::RECURRING_MONTHLY => 'mois',
|
36 |
+
self::RECURRING_BIMONTHLY => '2 mois',
|
37 |
+
self::RECURRING_QUARTERLY => '4 mois',
|
38 |
+
self::RECURRING_SEMI_ANNUAL => 'semestre',
|
39 |
+
self::RECURRING_ANNUAL => 'an',
|
40 |
+
self::RECURRING_BIANNUAL => '2 ans'
|
41 |
+
);
|
42 |
+
|
43 |
+
private static $host = "http://local.paygreen.fr/paiement/new/";
|
44 |
+
|
45 |
+
private $token;
|
46 |
+
private $key;
|
47 |
+
protected $data = array();
|
48 |
+
|
49 |
+
public function __construct($encryptKey, $rootUrl = null)
|
50 |
+
{
|
51 |
+
$this->key = $encryptKey;
|
52 |
+
|
53 |
+
if($rootUrl != null)
|
54 |
+
self::$host = $rootUrl.'/paiement/new/';
|
55 |
+
}
|
56 |
+
|
57 |
+
public function privateKey($encryptKey)
|
58 |
+
{
|
59 |
+
$this->key = $encryptKey;
|
60 |
+
}
|
61 |
+
|
62 |
+
public function setToken($shopToken)
|
63 |
+
{
|
64 |
+
$this->token = base64_encode(time().":".$shopToken);
|
65 |
+
}
|
66 |
+
|
67 |
+
public function parseToken($token)
|
68 |
+
{
|
69 |
+
$this->token = $token;
|
70 |
+
return explode(':',base64_decode($token));
|
71 |
+
}
|
72 |
+
|
73 |
+
public function __set($name, $value)
|
74 |
+
{
|
75 |
+
$this->data[$name] = $value;
|
76 |
+
}
|
77 |
+
|
78 |
+
public function __get($name)
|
79 |
+
{
|
80 |
+
return $this->data[$name];
|
81 |
+
}
|
82 |
+
|
83 |
+
public function toArray()
|
84 |
+
{
|
85 |
+
return $this->data;
|
86 |
+
}
|
87 |
+
|
88 |
+
public function mergeData($data)
|
89 |
+
{
|
90 |
+
$this->data = array_merge($this->data, $data);
|
91 |
+
}
|
92 |
+
|
93 |
+
|
94 |
+
|
95 |
+
public function parseData($post)
|
96 |
+
{
|
97 |
+
$text = trim(mcrypt_decrypt(MCRYPT_BLOWFISH, $this->key, base64_decode($post), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)));
|
98 |
+
$this->data = json_decode(utf8_decode($text), true);
|
99 |
+
}
|
100 |
+
|
101 |
+
public function generateData()
|
102 |
+
{
|
103 |
+
$text = utf8_encode(json_encode($this->data));
|
104 |
+
return trim(base64_encode(mcrypt_encrypt(MCRYPT_BLOWFISH, $this->key, $text, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
|
105 |
+
}
|
106 |
+
|
107 |
+
public function getActionForm()
|
108 |
+
{
|
109 |
+
return self::$host.$this->token;
|
110 |
+
}
|
111 |
+
|
112 |
+
public function renderForm()
|
113 |
+
{
|
114 |
+
?>
|
115 |
+
<form method="post" action="<?php echo $this->getActionForm(); ?>">
|
116 |
+
<input type="hidden" name="data" value="<?php echo $this->generateData(); ?>?>" />
|
117 |
+
<input type="submit" value="Payer" />
|
118 |
+
</form>
|
119 |
+
<?php
|
120 |
+
}
|
121 |
+
|
122 |
+
public function customer($id, $last_name, $first_name, $email, $country = "FR")
|
123 |
+
{
|
124 |
+
$this->customer_id = $id;
|
125 |
+
$this->customer_last_name = $last_name;
|
126 |
+
$this->customer_first_name = $first_name;
|
127 |
+
$this->customer_email = $email;
|
128 |
+
$this->customer_country = $country;
|
129 |
+
return $this;
|
130 |
+
}
|
131 |
+
|
132 |
+
public function immediatePaiement($transactionId, $amount, $currency = self::CURRENCY_EUR)
|
133 |
+
{
|
134 |
+
return $this->transaction($transactionId, $amount, $currency);
|
135 |
+
}
|
136 |
+
|
137 |
+
public function transaction($transactionId, $amount, $currency = self::CURRENCY_EUR)
|
138 |
+
{
|
139 |
+
$this->transaction_id = $transactionId;
|
140 |
+
$this->mode = self::MODE_CASH;
|
141 |
+
$this->amount = $amount;
|
142 |
+
$this->currency = $currency;
|
143 |
+
return $this;
|
144 |
+
}
|
145 |
+
|
146 |
+
public function subscribtionPaiement($reccuringMode = null, $dueCount = null, $transactionDay = null, $startAt = null)
|
147 |
+
{
|
148 |
+
$this->mode = self::MODE_RECURRING;
|
149 |
+
if($reccuringMode != null) {
|
150 |
+
$this->reccuringMode = $reccuringMode;
|
151 |
+
$this->reccuringDueCount = $dueCount;
|
152 |
+
$this->reccuringTransactionDay = $transactionDay;
|
153 |
+
$this->reccuringStartAt = $startAt;
|
154 |
+
}
|
155 |
+
|
156 |
+
return $this;
|
157 |
+
}
|
158 |
+
|
159 |
+
public function subscriptionFirstAmount($firstAmount, $firstAmountDate = null) {
|
160 |
+
$this->reccuringFirstAmount = $firstAmount;
|
161 |
+
$this->reccuringFirstAmountDate = $firstAmountDate;
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
?>
|
app/code/community/Wattisit/Paygreen/lib/PaygrenModuleUtils.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class PaygrenModuleUtils extends PaygreenClient {
|
3 |
+
|
4 |
+
public function generateForNbPaiement($transactionId, $nbPaiement, $amount, $currency) {
|
5 |
+
if($nbPaiement>1) {
|
6 |
+
$occurenceAmount = floor($amount / $nbPaiement);
|
7 |
+
$firstAmount = $amount - ($occurenceAmount * ($nbPaiement-1));
|
8 |
+
|
9 |
+
$paiement->subscribtionPaiement(
|
10 |
+
$paiement::RECURRING_MONTHLY,
|
11 |
+
$nbPaiement,
|
12 |
+
date('d')
|
13 |
+
);
|
14 |
+
if($occurenceAmount != $firstAmount)
|
15 |
+
$paiement->subscriptionFirstAmount(
|
16 |
+
round($firstAmount * 100)
|
17 |
+
);
|
18 |
+
} else {
|
19 |
+
$occurenceAmount = $amount;
|
20 |
+
}
|
21 |
+
$this->transaction(
|
22 |
+
$transactionId,
|
23 |
+
round($occurenceAmount * 100),
|
24 |
+
$currency
|
25 |
+
);
|
26 |
+
}
|
27 |
+
|
28 |
+
}
|
app/code/community/Wattisit/Paygreen/public/icons/paiement.png
ADDED
Binary file
|
app/code/community/Wattisit/Paygreen/public/icons/paygreen_paiement.png
ADDED
Binary file
|
app/code/community/Wattisit/Paygreen/sql/paygreen_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$installer=$this;
|
3 |
+
$installer->startSetup();
|
4 |
+
echo 'Running This Upgrade: '.get_class($this)."\n <br /> \n";
|
5 |
+
$installer->run("
|
6 |
+
DROP TABLE IF EXISTS `{$this->getTable('paygreen/buttons')}`;
|
7 |
+
CREATE TABLE IF NOT EXISTS `{$this->getTable('paygreen/buttons')}` (
|
8 |
+
`id` INT NOT NULL AUTO_INCREMENT,
|
9 |
+
`label` VARCHAR(100) NULL,
|
10 |
+
`image` VARCHAR(45) NULL,
|
11 |
+
`height` INT NULL,
|
12 |
+
`position` INT NULL,
|
13 |
+
`displayType` VARCHAR(45) NULL DEFAULT 'default',
|
14 |
+
`nbPayment` INT NOT NULL DEFAULT 1,
|
15 |
+
`minAmount` DECIMAL(10,2) NULL,
|
16 |
+
`maxAmount` DECIMAL(10,2) NULL,
|
17 |
+
PRIMARY KEY (`id`))ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
18 |
+
");
|
19 |
+
$connection=$installer->getConnection();
|
20 |
+
if (!$connection->fetchOne("SELECT id FROM ".$installer->getTable('paygreen/buttons'))) {
|
21 |
+
$connection->insert($installer->getTable('paygreen/buttons'), array(
|
22 |
+
'label' => 'Payer par carte bancaire',
|
23 |
+
'position' => '1',
|
24 |
+
'height' => '60',
|
25 |
+
'displayType' => 'bloc',
|
26 |
+
'nbPayment' => '1',
|
27 |
+
));
|
28 |
+
|
29 |
+
}
|
30 |
+
$installer->endSetup();
|
app/design/adminhtml/base/default/layout/paygreen.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" ?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<paygreen_adminhtml_buttons_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="paygreen/payment" name="admin_buttons"
|
6 |
+
template="paygreen/buttons.phtml" />
|
7 |
+
</reference>
|
8 |
+
</paygreen_adminhtml_buttons_index>
|
9 |
+
</layout>
|
app/design/adminhtml/base/default/template/paygreen/afficher.phtml
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
-----------------------------------------<br />
|
2 |
+
<?php
|
3 |
+
echo $this->methodblock();
|
4 |
+
?>
|
5 |
+
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
|
app/design/adminhtml/base/default/template/paygreen/buttons.phtml
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="content-header">
|
2 |
+
<table cellspacing="0">
|
3 |
+
<tr>
|
4 |
+
<td style="width:50%;"><h3 class="icon-head head-payment-method">Configuration des boutons de paiement</h3></td>
|
5 |
+
<td class="a-right">
|
6 |
+
|
7 |
+
</td>
|
8 |
+
</tr>
|
9 |
+
</table>
|
10 |
+
</div>
|
11 |
+
<style type="text/css">
|
12 |
+
.help-block span {
|
13 |
+
display: block;
|
14 |
+
padding-left: 5px;
|
15 |
+
line-height: 28px;
|
16 |
+
font-weight: bold;
|
17 |
+
font-size: 16px;
|
18 |
+
text-decoration: none;
|
19 |
+
cursor: pointer;
|
20 |
+
color:#eb5e00;
|
21 |
+
}
|
22 |
+
.buttons {
|
23 |
+
padding-top:10px;
|
24 |
+
text-align: center;
|
25 |
+
padding-bottom: 10px;
|
26 |
+
}
|
27 |
+
.button-bloc {
|
28 |
+
display: inline-block;
|
29 |
+
border-left:4px solid #dfdfdf;
|
30 |
+
padding:0 5px;
|
31 |
+
}
|
32 |
+
</style>
|
33 |
+
<?php
|
34 |
+
$buttons = $this->getAll()->load();
|
35 |
+
|
36 |
+
$emptyItem = new Wattisit_Paygreen_Model_Buttons();
|
37 |
+
$emptyItem->id = 0;
|
38 |
+
|
39 |
+
$buttons->addItem($emptyItem);
|
40 |
+
|
41 |
+
foreach($buttons as $btn):
|
42 |
+
?>
|
43 |
+
<div id="formNewButton" class="button-bloc">
|
44 |
+
<form class="form-horizontal" action="<?php echo Mage::getUrl('adminpaygreen/adminhtml_buttons/save') ?>" method="post" enctype="multipart/form-data">
|
45 |
+
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
|
46 |
+
<input type="hidden" name="id" value="<?php echo $btn->id ?>">
|
47 |
+
|
48 |
+
<h4><?php if($btn->id > 0): ?>
|
49 |
+
<?php echo $btn->label; ?>
|
50 |
+
<?php else: ?>
|
51 |
+
Nouveau button
|
52 |
+
<?php endif ?></h4>
|
53 |
+
|
54 |
+
<fieldset>
|
55 |
+
<table cellspacing="0" class="form-list">
|
56 |
+
<tbody>
|
57 |
+
|
58 |
+
<tr>
|
59 |
+
<td class="label">
|
60 |
+
<label for="label">Libellé</label>
|
61 |
+
</td>
|
62 |
+
<td class="value">
|
63 |
+
<input id="label" name="label" type="text" placeholder="Libellé du bouton" class="input-text" required="required" value="<?php echo $btn->label ?>">
|
64 |
+
</td>
|
65 |
+
<td class="help-block"><span title="Texte affiché à droite de l'icône">?</span></td>
|
66 |
+
</tr>
|
67 |
+
|
68 |
+
<tr>
|
69 |
+
<td class="label">
|
70 |
+
<label for="image">Icône</label>
|
71 |
+
</td>
|
72 |
+
<td class="value">
|
73 |
+
<input id="image" name="image" class="input-file" type="file">
|
74 |
+
</td>
|
75 |
+
</tr>
|
76 |
+
|
77 |
+
<tr>
|
78 |
+
<td class="label">
|
79 |
+
<label for="image"> Image utilisée</label>
|
80 |
+
</td>
|
81 |
+
<td class="value">
|
82 |
+
<?php if($btn->image): ?>
|
83 |
+
<img src="<?php echo $this->getIcons($btn->image);?>" style="max-height:40px;" />
|
84 |
+
<?php else: ?>
|
85 |
+
<img src="<?php echo $this->getIcons('paygreen_paiement.png');?>" style="max-height:40px;" />
|
86 |
+
<?php endif; ?>
|
87 |
+
</td>
|
88 |
+
</tr>
|
89 |
+
|
90 |
+
<tr>
|
91 |
+
<td class="label">
|
92 |
+
<label for="height">Hauteur de l'image</label>
|
93 |
+
</td>
|
94 |
+
<td class="value">
|
95 |
+
<input id="height" name="height" type="number" placeholder="" class="input-text" value="<?php echo $btn->height ?>">
|
96 |
+
</td>
|
97 |
+
<td class="help-block"><span title="Si vide, la taille de l'image sera celle réélle">?</span></td>
|
98 |
+
</tr>
|
99 |
+
|
100 |
+
<tr>
|
101 |
+
<td class="label">
|
102 |
+
<label for="position">N° position</label>
|
103 |
+
</td>
|
104 |
+
<td class="value">
|
105 |
+
<input id="position" name="position" type="number" placeholder="" class="input-text" value="<?php echo $btn->position ?>">
|
106 |
+
</td>
|
107 |
+
<td class="help-block"><span title="Si vide, sera calculé automatiquement">?</span></td>
|
108 |
+
</tr>
|
109 |
+
|
110 |
+
<tr >
|
111 |
+
<td colspan="3" class="buttons">
|
112 |
+
<?php if($btn->id > 0): ?>
|
113 |
+
<button id="resetBtn" name="submitPaygreenModuleButtonDelete" value="1" class="delete">
|
114 |
+
<span><span><span>Supprimer</span></span></span>
|
115 |
+
</button>
|
116 |
+
<?php else: ?>
|
117 |
+
<button id="resetBtn" name="resetBtn" type="reset" class="cancel">
|
118 |
+
<span><span><span>Annuler</span></span></span>
|
119 |
+
</button>
|
120 |
+
<?php endif ?>
|
121 |
+
<button id="validBtn" name="submitPaygreenModuleButton" value="1" class="save">
|
122 |
+
<span><span><span>Valider</span></span></span>
|
123 |
+
</button>
|
124 |
+
</td>
|
125 |
+
</tr>
|
126 |
+
|
127 |
+
</tbody>
|
128 |
+
</table>
|
129 |
+
</fieldset>
|
130 |
+
</form>
|
131 |
+
</div>
|
132 |
+
<?php endforeach; ?>
|
app/design/frontend/base/default/layout/paygreen.xml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<layout version="0.1.0">
|
2 |
+
<default>
|
3 |
+
<reference name="content">
|
4 |
+
</reference>
|
5 |
+
</default>
|
6 |
+
<paygreen_index_index>
|
7 |
+
<reference name="content">
|
8 |
+
<block type="paygreen/payment" name="afficher_monbloc"
|
9 |
+
template="paygreen/afficher.phtml" />
|
10 |
+
</reference>
|
11 |
+
</paygreen_index_index>
|
12 |
+
</layout>
|
app/design/frontend/base/default/template/paygreen/afficher.phtml
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
-----------------------------------------
|
2 |
+
<?php
|
3 |
+
echo $this->methodblock();
|
4 |
+
?>
|
5 |
+
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
app/design/frontend/base/default/template/paygreen/caller.phtml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div style="text-align:center">
|
2 |
+
<form method="POST" id="paygreenForm" action="<?php echo $this->paygreen->getActionForm() ?>">
|
3 |
+
<h3>Redirection en cours vers votre moyen de paiement</h3>
|
4 |
+
<button type="submit" >
|
5 |
+
<input type="hidden" name="platform" value="magento" />
|
6 |
+
<input type="hidden" name="data" value="<?php echo $this->paygreen->generateData() ?>" />
|
7 |
+
<img height="<?php echo $this->btn->height ?>" src="<?php echo $this->getIcons($this->btn->image) ?>" style="display: inline-block" />
|
8 |
+
</button><br />
|
9 |
+
si vous n'êtes pas rediriger, cliquez sur l'image ci-dessus
|
10 |
+
</form>
|
11 |
+
</div>
|
12 |
+
<script type="text/javascript">
|
13 |
+
window.onload=function(){
|
14 |
+
document.forms['paygreenForm'].submit()
|
15 |
+
}
|
16 |
+
</script>
|
app/design/frontend/base/default/template/paygreen/informations.phtml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$btn = $this->getButton();
|
3 |
+
?>
|
4 |
+
<div style="text-align:center">
|
5 |
+
<img height="<?php echo $btn->height ?>" src="<?php echo $this->getIcons($btn->image) ?>" style="display: inline-block" />
|
6 |
+
<h3><?php echo $btn->label; ?></h3>
|
7 |
+
</div>
|
app/design/frontend/base/default/template/paygreen/paiement.phtml
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$buttons = $this->getButtons();
|
3 |
+
?><fieldset class="form-list paygreen-list">
|
4 |
+
<?php $_code=$this->getMethodCode() ?>
|
5 |
+
<ul id="payment_form_<?php echo $_code ?>" style="display:none">
|
6 |
+
<?php foreach($buttons as $i => $btn) : ?>
|
7 |
+
<li>
|
8 |
+
<label data-value="<?php echo $i ?>">
|
9 |
+
<input type="radio" value="<?php echo $btn->id ?>" name="payment[paygreen_btn]"<?php echo ($i == 1 ? ' checked="checked"' : '') ?> />
|
10 |
+
<img height="<?php echo $btn->height ?>" src="<?php echo $this->getIcons($btn->image) ?>" />
|
11 |
+
<h3><?php echo $btn->label; ?></h3>
|
12 |
+
</label>
|
13 |
+
</li>
|
14 |
+
<?php endforeach; ?>
|
15 |
+
</ul>
|
16 |
+
</fieldset>
|
17 |
+
<style type="text/css">
|
18 |
+
.paygreen-list li input {
|
19 |
+
float:left;
|
20 |
+
}
|
21 |
+
.paygreen-list li label {
|
22 |
+
display: block;
|
23 |
+
}
|
24 |
+
.paygreen-list li label input {
|
25 |
+
display:none;
|
26 |
+
}
|
27 |
+
.paygreen-list input[type="radio"]:checked+img+h3 {
|
28 |
+
font-weight: bold;
|
29 |
+
}
|
30 |
+
.paygreen-list li label.active {
|
31 |
+
text-decoration: none;
|
32 |
+
font-weight: bold;
|
33 |
+
}
|
34 |
+
.paygreen-list li label img {
|
35 |
+
float:left;
|
36 |
+
}
|
37 |
+
.paygreen-list li label h3 {
|
38 |
+
line-height: <?php echo $btn->height ?>px;
|
39 |
+
font-weight: none;
|
40 |
+
}
|
41 |
+
</style>
|
42 |
+
<script type="text/javascript">
|
43 |
+
|
44 |
+
</script>
|
app/design/frontend/base/default/template/paygreen/returned.phtml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<h2><?php echo $this->title(); ?></h2>
|
2 |
+
<p><?php
|
3 |
+
switch($this->paygreen->result['status']) {
|
4 |
+
case PaygreenClient::STATUS_REFUSED:
|
5 |
+
echo $this->refusedMessage();
|
6 |
+
break;
|
7 |
+
case PaygreenClient::STATUS_SUCCESSED:
|
8 |
+
echo $this->acceptedMessage();
|
9 |
+
break;
|
10 |
+
case PaygreenClient::STATUS_CANCELLING:
|
11 |
+
echo $this->cancelledMessage();
|
12 |
+
break;
|
13 |
+
}
|
14 |
+
?></p>
|
15 |
+
<a href="<?php echo Mage::getUrl('sales/order/view', array('order_id' => $this->order->entity_id)); ?>">Voir votre commande</a>
|
app/etc/modules/Wattisit_Paygreen.xml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Wattisit_Paygreen>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<depends>
|
8 |
+
<Mage_Payment />
|
9 |
+
</depends>
|
10 |
+
</Wattisit_Paygreen>
|
11 |
+
</modules>
|
12 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Wattisit_Paygreen</name>
|
4 |
+
<version>0.1.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>GNU General Public License (GPL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>PayGreen vous permet d'accepter le paiement en carte bancaire sur votre boutique en ligne magento 
|
10 |
+
</summary>
|
11 |
+
<description>Ce module de paiement vous permet de personnaliser votre page de paiement:
|
12 |
+
Votre page de paiement est à vos couleurs
|
13 |
+
Organisez ponctuellement des opérations de collecte de dons (ARRONDI) pour les associations de votre choix
|
14 |
+
Activer/Désactiver le système 3D secure
|
15 |
+
Proposez un Abonnement à vos clients
|
16 |
+
Faites payer vos clients par Mail
|
17 |
+

|
18 |
+
Notre tarification est fonction de votre volume de vente mensuel :
|
19 |
+

|
20 |
+
PayGreen est une des solutions les plus économiques sur le marché. Notre tarification s&apos;adapte à votre chiffre d&apos;affaire et est personnalisée au delà d&apos;un certain volume de vente mensuel.</description>
|
21 |
+
<notes>Première version du module</notes>
|
22 |
+
<authors><author><name>Watt is it</name><user>WattIsIt</user><email>support@paygreen.fr</email></author></authors>
|
23 |
+
<date>2016-01-22</date>
|
24 |
+
<time>16:38:22</time>
|
25 |
+
<contents><target name="magecommunity"><dir name="Wattisit"><dir name="Paygreen"><dir name="Block"><file name="Form.php" hash="c486be7ad97297691e6b83d271aadcf7"/><file name="Info.php" hash="516fcaf040998026baa3644de0edf94d"/><file name="Monblock.php" hash="e0f1f98e9d71e8cb743917bfac5bd700"/><file name="Payment.php" hash="09efc37b621dd3e94e02d2db1baeef87"/></dir><dir name="Helper"><file name="Data.php" hash="550bfcf93e4ed09ab1be9cbaee44212e"/></dir><dir name="Model"><file name="Buttons.php" hash="8fbbf473861c83c3677f34f16c31e0b9"/><dir name="Datasource"><file name="Status.php" hash="3bea16c5e273efdf62ae94cb024f4aab"/></dir><dir name="Mysql4"><dir name="Buttons"><file name="Collection.php" hash="274ab664f0a7bd7f9a974ed8f5c73506"/></dir><file name="Buttons.php" hash="56e462ef52928299dd22966f25158dc7"/></dir><file name="PaymentMethod.php" hash="10de424a39f4d20f02304badd080e4da"/><dir name="Resource"><file name="Setup.php" hash="2494181127c400e52393c06f380ecdd7"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ButtonsController.php" hash="41cb09f007ea5e6df1354e29189c8363"/><file name="IndexController.php" hash="a448ad93eadb4fcbaeed98d4df202c97"/></dir><file name="IndexController.php" hash="439e3259f8956dea927ae2b00642f1e4"/><file name="StaticController.php" hash="d56a70df2495e9b9764ef550b21b09b5"/></dir><dir name="etc"><file name="config.xml" hash="ff4b4268e0231b138b5134a2c34b55ca"/><file name="system.xml" hash="b2c9d7b05655c883fb00a75407ae8e31"/></dir><dir name="lib"><file name="PaygreenClient.php" hash="093207ee5be746d7ce1bead614e09dea"/><file name="PaygrenModuleUtils.php" hash="cf7f835b9467e40f4873ca34dd4595ac"/></dir><dir name="public"><dir name="icons"><file name="paiement.png" hash="c413cdb06f10d973a1a008d58df59825"/><file name="paygreen_paiement.png" hash="c413cdb06f10d973a1a008d58df59825"/></dir></dir><dir name="sql"><dir name="paygreen_setup"><file name="mysql4-install-0.1.0.php" hash="910ce8551b0b3dc9fa0171f82359859e"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Wattisit_Paygreen.xml" hash="b9300cc18cf27d2c4e73acc3dd393c9e"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="layout"><file name="paygreen.xml" hash="19079d4438a040b6b95a48cb651c50c3"/></dir><dir name="template"><dir name="paygreen"><file name="afficher.phtml" hash="76974630bce82ee2fc437957bc2d4bdc"/><file name="buttons.phtml" hash="b2c6264e4d99505080d7ef47247d58c0"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="paygreen.xml" hash="c935447e735eba2cf657543eaebffffb"/></dir><dir name="template"><dir name="paygreen"><file name="afficher.phtml" hash="9755e2421d8cfc5358d82f65bcb66352"/><file name="caller.phtml" hash="b6dfe497f7699290f6919398a240b7e6"/><file name="informations.phtml" hash="0048eedb8d2b01a432794e9b995744ad"/><file name="paiement.phtml" hash="fdd864256fc1147edbb902a78da8466a"/><file name="returned.phtml" hash="49d8bc37a8f79b38b464515a188c0ce5"/></dir></dir></dir></dir></dir></target></contents>
|
26 |
+
<compatible/>
|
27 |
+
<dependencies><required><php><min>5.0.0</min><max>5.5.0</max></php></required></dependencies>
|
28 |
+
</package>
|