Afone_Oneclicpay - Version 1.0.0

Version Notes

Package de la version 1.0.0

Download this release

Release Info

Developer Afone
Extension Afone_Oneclicpay
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/local/Afone/Oneclicpay/Helper/Data.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ class Afone_Oneclicpay_Helper_Data extends Mage_Core_Helper_Abstract{
3
+ }
app/code/local/Afone/Oneclicpay/Model/Source/GatewayConfig.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Afone GatewayConfig Action Dropdown source
5
+ */
6
+ class Afone_Oneclicpay_Model_Source_GatewayConfig
7
+ {
8
+ public function toOptionArray()
9
+ {
10
+ return array(
11
+ array(
12
+ 'value' => "HOMOLOGATION",
13
+ 'label' => Mage::helper('oneclicpay')->__('Homologation')
14
+ ),
15
+ array(
16
+ 'value' => "PRODUCTION",
17
+ 'label' => Mage::helper('oneclicpay')->__('Production')
18
+ ),
19
+ );
20
+ }
21
+ }
app/code/local/Afone/Oneclicpay/Model/Standard.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Main payment model
4
+ *
5
+ * @category Model
6
+ * @package Afone_Oneclicpay
7
+ * @author Afone
8
+ * @license GPL http://opensource.org/licenses/gpl-license.php
9
+ */
10
+ class Afone_Oneclicpay_Model_Standard extends Mage_Payment_Model_Method_Abstract {
11
+ protected $_code = 'oneclicpay';
12
+
13
+ protected $_isInitializeNeeded = true;
14
+ protected $_canUseInternal = true;
15
+ protected $_canUseForMultishipping = false;
16
+
17
+ public function getOrderPlaceRedirectUrl() {
18
+ return Mage::getUrl('oneclicpay/payment/redirect', array('_secure' => true));
19
+ }
20
+ }
21
+ ?>
app/code/local/Afone/Oneclicpay/controllers/PaymentController.php ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Main payment controller
4
+ * Documentation : http://docs.oneclicpay.com/
5
+ *
6
+ * @category Controller
7
+ * @package Afone_Oneclicpay
8
+ * @author Afone
9
+ * @license GPL http://opensource.org/licenses/gpl-license.php
10
+ */
11
+ class Afone_Oneclicpay_PaymentController extends Mage_Core_Controller_Front_Action {
12
+
13
+ /**
14
+ * Redirects the user to the success page
15
+ */
16
+ public function successAction() {
17
+ $this->_redirect('checkout/onepage/success');
18
+ }
19
+
20
+ /**
21
+ * Redirects the user to the error page
22
+ */
23
+ public function errorAction() {
24
+ $this->_redirect('checkout/onepage/failure');
25
+ }
26
+
27
+ /*
28
+ * The redirect action is triggered when someone places an order
29
+ */
30
+ public function redirectAction() {
31
+
32
+ $order = new Mage_Sales_Model_Order();
33
+ $order_id = Mage::getSingleton( 'checkout/session' )->getLastRealOrderId();
34
+ $order->loadByIncrementId( $order_id );
35
+
36
+ $oneclicpay['montant'] = number_format( $order->base_grand_total, 2 , '.', '');
37
+ $oneclicpay['idTPE'] = Mage::getStoreConfig( 'payment/oneclicpay/tpe_no' );
38
+ $oneclicpay['idTransaction'] = $order_id;
39
+ $oneclicpay['devise'] = Mage::getStoreConfig( 'payment/oneclicpay/devise' );
40
+ $oneclicpay['lang'] = Mage::getStoreConfig( 'payment/oneclicpay/langue' );
41
+ $oneclicpay['nom_produit'] = Mage::app()->getStore()->getName();
42
+ $oneclicpay['source'] = $_SERVER['SERVER_NAME'];
43
+ $oneclicpay['urlRetourOK'] = Mage::getUrl( 'oneclicpay/payment/success' , array('_secure' => true) );
44
+ $oneclicpay['urlRetourNOK'] = Mage::getUrl( 'oneclicpay/payment/error' , array('_secure' => true));
45
+ $oneclicpay['urlIPN'] = Mage::getUrl( 'oneclicpay/payment/ipn' , array('_secure' => true) );
46
+ $oneclicpay['key'] = Mage::getStoreConfig( 'payment/oneclicpay/secret_key' );
47
+
48
+ // Encoding
49
+ $oneclicpayWithKey = base64_encode(implode("|", $oneclicpay));
50
+ unset($oneclicpay['key']);
51
+ $oneclicpay['sec'] = hash("sha512",$oneclicpayWithKey);
52
+
53
+ // Generate Form
54
+ $form = "";
55
+ foreach ($oneclicpay as $key => $value) {
56
+ $form .= "<input type='hidden' name='$key' value='$value'/>";
57
+ }
58
+ $oneclicpay_config['form'] = $form;
59
+
60
+ $oneclicpay_config['url-config'] = Mage::getStoreConfig( 'payment/oneclicpay/url_gateway_config' );
61
+ if ($oneclicpay_config['url-config']=="HOMOLOGATION")
62
+ {
63
+ $oneclicpay_config['form-action'] = Mage::getStoreConfig( 'payment/oneclicpay/url_gateway_homologation' );
64
+ }
65
+ else
66
+ {
67
+ $oneclicpay_config['form-action'] = Mage::getStoreConfig( 'payment/oneclicpay/url_gateway_production' );
68
+ }
69
+
70
+ // Save information
71
+ Mage::register( 'oneclicpay', $oneclicpay_config );
72
+
73
+ // Load and render the layout
74
+ $this->loadLayout();
75
+ $block = $this->getLayout()->createBlock('Mage_Core_Block_Template','oneclicpay',array('template' => 'oneclicpay/redirect.phtml'));
76
+ $this->getLayout()->getBlock('content')->append($block);
77
+ $this->renderLayout();
78
+ }
79
+
80
+ /*
81
+ * The ipn action is triggered when your gateway sends back a response after processing the customer's payment
82
+ */
83
+ public function ipnAction() {
84
+ Mage::log("Appel de l'ipn ...", Zend_Log::DEBUG);
85
+ Mage::log($_REQUEST, Zend_Log::DEBUG);
86
+
87
+
88
+ if($this->getRequest()->isPost())
89
+ {
90
+ if (!$this->validSec($_REQUEST, Mage::getStoreConfig( 'payment/oneclicpay/secret_key' )))
91
+ {
92
+ Mage::log("Oneclicpay : Erreur lors de la validation des informations transmises !", Zend_Log::ERR);
93
+ $this->cancelAction();
94
+ header("Status: 400 Bad Request", false, 400);
95
+ exit();
96
+ }
97
+
98
+ $validated="";
99
+ if (isset($_REQUEST['result']))
100
+ $validated = $_REQUEST['result'];
101
+
102
+
103
+ if($validated == "OK") {
104
+ // Payment was successful, so update the order's state, send order email and move to the success page
105
+ $orderId="";
106
+ if (isset($_REQUEST['idTransaction']))
107
+ $orderId = $_REQUEST['idTransaction'];
108
+
109
+ $order = Mage::getModel('sales/order');
110
+ $order->loadByIncrementId($orderId);
111
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Gateway has authorized the payment.');
112
+
113
+ $order->sendNewOrderEmail();
114
+ $order->setEmailSent(true);
115
+
116
+ $order->save();
117
+
118
+ Mage::getSingleton('checkout/session')->unsQuoteId();
119
+ }
120
+ else
121
+ {
122
+ // There is a problem in the response we got
123
+ Mage::log("Oneclicpay : Paiement refusé !", Zend_Log::DEBUG);
124
+ $this->cancelAction();
125
+ exit();
126
+ }
127
+ }
128
+ else
129
+ {
130
+ Mage::log("Oneclicpay : Aucun paramètres POST reçu !", Zend_Log::ERR);
131
+ header("Status: 400 Bad Request", false, 400);
132
+ exit();
133
+ }
134
+ }
135
+
136
+ /*
137
+ * The cancel action is triggered when an order is to be cancelled
138
+ */
139
+ public function cancelAction() {
140
+ if (Mage::getSingleton('checkout/session')->getLastRealOrderId()) {
141
+ $order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
142
+ if($order->getId()) {
143
+ // Flag the order as 'cancelled' and save it
144
+ $order->cancel()->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, 'Gateway has declined the payment.')->save();
145
+ }
146
+ }
147
+ }
148
+
149
+ /*
150
+ * Secret Validation
151
+ */
152
+ private function validSec($values, $secret_key){
153
+ if (isset($values['sec']) && $values['sec'] != "")
154
+ {
155
+ $sec = $values['sec'];
156
+ unset($values['sec']);
157
+ return strtoupper(hash("sha512", base64_encode(implode("|",$values)."|".$secret_key))) == strtoupper($sec);
158
+ }
159
+ else
160
+ {
161
+ return false;
162
+ }
163
+ }
164
+
165
+ }
app/code/local/Afone/Oneclicpay/etc/config.xml ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Afone_Oneclicpay>
5
+ <version>1.0.0</version>
6
+ </Afone_Oneclicpay>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <oneclicpay>
11
+ <class>Afone_Oneclicpay_Model</class>
12
+ </oneclicpay>
13
+ </models>
14
+ <helpers>
15
+ <oneclicpay>
16
+ <class>Afone_Oneclicpay_Helper</class>
17
+ </oneclicpay>
18
+ </helpers>
19
+ </global>
20
+ <default>
21
+ <payment>
22
+ <oneclicpay>
23
+ <model>oneclicpay/standard</model>
24
+ <active>1</active>
25
+ <order_status>pending</order_status>
26
+ <title>Paiement CB - OneClicPay</title>
27
+ <payment_action>sale</payment_action>
28
+ <allowspecific>0</allowspecific>
29
+ <sort_order>1</sort_order>
30
+ <devise>EUR</devise>
31
+ <langue>fr</langue>
32
+ <url_gateway_config>HOMOLOGATION</url_gateway_config>
33
+ <url_gateway_homologation>https://secure.homologation.oneclicpay.com</url_gateway_homologation>
34
+ <url_gateway_production>https://secure.oneclicpay.com</url_gateway_production>
35
+ </oneclicpay>
36
+ </payment>
37
+ </default>
38
+ <frontend>
39
+ <routers>
40
+ <oneclicpay>
41
+ <use>standard</use>
42
+ <args>
43
+ <module>Afone_Oneclicpay</module>
44
+ <frontName>oneclicpay</frontName>
45
+ </args>
46
+ </oneclicpay>
47
+ </routers>
48
+ <translate>
49
+ <modules>
50
+ <Afone_Oneclicpay>
51
+ <files>
52
+ <default>Afone_Oneclicpay.csv</default>
53
+ </files>
54
+ </Afone_Oneclicpay>
55
+ </modules>
56
+ </translate>
57
+ </frontend>
58
+ <adminhtml>
59
+ <translate>
60
+ <modules>
61
+ <Afone_Oneclicpay>
62
+ <files>
63
+ <default>Afone_Oneclicpay.csv</default>
64
+ </files>
65
+ </Afone_Oneclicpay>
66
+ </modules>
67
+ </translate>
68
+ </adminhtml>
69
+ </config>
app/code/local/Afone/Oneclicpay/etc/system.xml ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <payment>
5
+ <groups>
6
+ <oneclicpay translate="label comment" module="oneclicpay">
7
+ <label>Oneclicpay</label>
8
+ <comment><![CDATA[OneClicPay est une solution de paiement sécurisé sur Internet. Véritable TPE Virtuel, OneClicPay permet d’encaisser les paiements réalisés sur Internet 24 heures sur 24 et 7 jours sur 7. <br/>Plus d'information sur <a href="http://docs.oneclicpay.com/">la documentation officielle</a>.]]></comment>
9
+ <frontend_type>text</frontend_type>
10
+ <sort_order>600</sort_order>
11
+ <show_in_default>1</show_in_default>
12
+ <show_in_website>1</show_in_website>
13
+ <show_in_store>1</show_in_store>
14
+ <fields>
15
+ <active translate="label">
16
+ <label>Enabled</label>
17
+ <frontend_type>select</frontend_type>
18
+ <source_model>adminhtml/system_config_source_yesno</source_model>
19
+ <sort_order>10</sort_order>
20
+ <show_in_default>1</show_in_default>
21
+ <show_in_website>1</show_in_website>
22
+ <show_in_store>0</show_in_store>
23
+ </active>
24
+ <title translate="label comment">
25
+ <label>Title</label>
26
+ <comment>
27
+ <![CDATA[Texte affiché au client lors du choix du mode paiement]]>
28
+ </comment>
29
+ <frontend_type>text</frontend_type>
30
+ <sort_order>20</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ </title>
35
+ <order_status translate="label">
36
+ <label>New Order Status</label>
37
+ <frontend_type>select</frontend_type>
38
+ <source_model>adminhtml/system_config_source_order_status</source_model>
39
+ <sort_order>50</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>0</show_in_store>
43
+ </order_status>
44
+ <sort_order translate="label">
45
+ <label>Sort Order</label>
46
+ <frontend_type>text</frontend_type>
47
+ <sort_order>100</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>0</show_in_store>
51
+ </sort_order>
52
+ <tpe_no translate="label comment">
53
+ <label>TPE number</label>
54
+ <comment>
55
+ <![CDATA[Votre numéro de TPE vous sera communiqué par AfonePaiement]]>
56
+ </comment>
57
+ <frontend_type>text</frontend_type>
58
+ <sort_order>80</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>0</show_in_store>
62
+ </tpe_no>
63
+ <secret_key translate="label comment">
64
+ <label>Secret Key</label>
65
+ <comment>
66
+ <![CDATA[Votre clé secrète vous sera communiquée par AfonePaiement (elle doit rester personnelle et ne jamais être communiquée)]]>
67
+ </comment>
68
+ <frontend_type>text</frontend_type>
69
+ <sort_order>81</sort_order>
70
+ <show_in_default>1</show_in_default>
71
+ <show_in_website>1</show_in_website>
72
+ <show_in_store>0</show_in_store>
73
+ </secret_key>
74
+ <devise translate="label">
75
+ <label>Devise</label>
76
+ <frontend_type>text</frontend_type>
77
+ <sort_order>90</sort_order>
78
+ <show_in_default>1</show_in_default>
79
+ <show_in_website>1</show_in_website>
80
+ <show_in_store>0</show_in_store>
81
+ </devise>
82
+ <langue translate="label">
83
+ <label>Language</label>
84
+ <frontend_type>text</frontend_type>
85
+ <sort_order>100</sort_order>
86
+ <show_in_default>1</show_in_default>
87
+ <show_in_website>1</show_in_website>
88
+ <show_in_store>0</show_in_store>
89
+ </langue>
90
+ <url_gateway_config translate="label comment">
91
+ <label>URL Gateway Configuration</label>
92
+ <comment>
93
+ <![CDATA[L'homologation vous permet de tester votre installation. La production est à activer une fois les tests validés.]]>
94
+ </comment>
95
+ <frontend_type>select</frontend_type>
96
+ <source_model>oneclicpay/source_gatewayConfig</source_model>
97
+ <sort_order>83</sort_order>
98
+ <show_in_default>1</show_in_default>
99
+ <show_in_website>1</show_in_website>
100
+ <show_in_store>0</show_in_store>
101
+ </url_gateway_config>
102
+ <url_gateway_homologation translate="label">
103
+ <label>Gateway URL for approval</label>
104
+ <frontend_type>text</frontend_type>
105
+ <sort_order>84</sort_order>
106
+ <show_in_default>1</show_in_default>
107
+ <show_in_website>1</show_in_website>
108
+ <show_in_store>0</show_in_store>
109
+ </url_gateway_homologation>
110
+ <url_gateway_production translate="label">
111
+ <label>Gateway URL for production</label>
112
+ <frontend_type>text</frontend_type>
113
+ <sort_order>85</sort_order>
114
+ <show_in_default>1</show_in_default>
115
+ <show_in_website>1</show_in_website>
116
+ <show_in_store>0</show_in_store>
117
+ </url_gateway_production>
118
+ </fields>
119
+ </oneclicpay>
120
+ </groups>
121
+ </payment>
122
+ </sections>
123
+ </config>
app/design/frontend/base/default/template/oneclicpay/redirect.phtml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Get data
3
+ $oneclicpay = Mage::registry( 'oneclicpay' );
4
+
5
+ if ($oneclicpay['url-config']=="HOMOLOGATION")
6
+ {
7
+ echo "<center><b><span style='color:red'>PAIEMENT DE TEST</span></b></center>";
8
+ }
9
+ ?>
10
+
11
+ <p><?php echo $this->__('Please wait, you will be redirected to the payment form.');?> <a href="javascript:document.oneclicpay.submit();"><?php echo $this->__('Or click here.');?></a></p>
12
+
13
+ <form name="oneclicpay" method="post" action="<?php echo $oneclicpay['form-action']; ?>">
14
+ <?php echo $oneclicpay['form']; ?>
15
+ </form>
16
+
17
+ <script type="text/javascript">
18
+ document.oneclicpay.submit();
19
+ </script>
app/etc/modules/Afone_Oneclicpay.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Afone_Oneclicpay>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Afone_Oneclicpay>
8
+ </modules>
9
+ </config>
app/locale/fr_FR/Afone_Oneclicpay.csv ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ "TPE number","Numéro de TPE"
2
+ "Secret Key","Clé secrète"
3
+ "URL Gateway Configuration","Type de passerelle à utiliser"
4
+ "Gateway URL for approval","URL pour l'homologation"
5
+ "Gateway URL for production","URL pour la production"
6
+ "Please wait, you will be redirected to the payment form.","Veuillez patienter, vous allez être redirigé vers le formulaire de paiement."
7
+ "Or click here.","Si ce n'est pas le cas, cliquez ici."
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Afone_Oneclicpay</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/gpl-license.php">GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>The extension provides Oneclicpay payment integration. </summary>
10
+ <description>The extension provides Oneclicpay payment integration. </description>
11
+ <notes>Package de la version 1.0.0</notes>
12
+ <authors><author><name>Afone</name><user>SMA</user><email>smalinge@afone.com</email></author><author><name>Afone</name><user>oneclicpay-technique</user><email>technique@oneclicpay.com</email></author></authors>
13
+ <date>2013-10-08</date>
14
+ <time>14:01:57</time>
15
+ <contents><target name="magelocal"><dir name="Afone"><dir name="Oneclicpay"><dir name="Helper"><file name="Data.php" hash="caee2487db1c668736557edcaae0fd55"/></dir><dir name="Model"><dir name="Source"><file name="GatewayConfig.php" hash="63598a997d974345fc3662799370f374"/></dir><file name="Standard.php" hash="2988ff0d6378635a3c9288e6ce5d7872"/></dir><dir name="controllers"><file name="PaymentController.php" hash="52e1e685558827e0dc724e28f65d8ca9"/></dir><dir name="etc"><file name="config.xml" hash="0196627d7365a2093c44fe70c7da8639"/><file name="system.xml" hash="8fb17c5fe63118b2d83c1629a2a2ed10"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="oneclicpay"><file name="redirect.phtml" hash="c90a096e245cd2f1d9c70b335925db6c"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Afone_Oneclicpay.xml" hash="d7e6f5fc8da697d0f9ee23b930e6ca93"/></dir></target><target name="magelocale"><dir name="fr_FR"><file name="Afone_Oneclicpay.csv" hash="878c3cf6317e3ba81afd49c5bfa833cd"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>