Compropago_Payment_Extension - Version 1.1.0

Version Notes

## 10/06/2016 v1.1.0
* Feature: Seleccion de proveedores
* Feature: Normalizacion de vista de seleccion de proveedores
* Feature: Validacion de proveedor obligatorio
* Feature: Captura de telefono de cliente

Download this release

Release Info

Developer Oswaldo Lopez Garcia
Extension Compropago_Payment_Extension
Version 1.1.0
Comparing to
See all releases


Code changes from version 1.0.3.1 to 1.1.0

app/code/community/Compropago/.DS_Store ADDED
Binary file
app/code/community/Compropago/Block/Form.php CHANGED
@@ -1,10 +1,11 @@
1
-
2
  <?php
3
  /**
4
  * Description of Form
5
  *
6
  * @author waldix <waldix86@gmail.com>
7
  */
 
 
8
  class Compropago_Block_Form extends Mage_Payment_Block_Form
9
  {
10
  protected function _construct()
 
1
  <?php
2
  /**
3
  * Description of Form
4
  *
5
  * @author waldix <waldix86@gmail.com>
6
  */
7
+
8
+
9
  class Compropago_Block_Form extends Mage_Payment_Block_Form
10
  {
11
  protected function _construct()
app/code/community/Compropago/Block/OnepageSuccess.php CHANGED
@@ -1,13 +1,16 @@
1
-
2
  <?php
3
- class Compropago_Block_OnepageSuccess extends Mage_Checkout_Block_Onepage_Success
4
- {
5
- // Write your custom methods
6
- // All parent’s methods also will work
7
- protected function _beforeToHtml()
8
- {
9
- $outHtml = parent::_beforeToHtml();
10
- $this->setTemplate('compropago/onepage_success.phtml');
11
- return $outHtml;
12
- }
13
- }
 
 
 
 
 
1
  <?php
2
+
3
+ class Compropago_Block_OnepageSuccess extends Mage_Checkout_Block_Onepage_Success
4
+ {
5
+ /**
6
+ * Regresa el recibo de compra
7
+ *
8
+ * @return mixed
9
+ */
10
+ protected function _beforeToHtml()
11
+ {
12
+ $outHtml = parent::_beforeToHtml();
13
+ $this->setTemplate('compropago/onepage_success.phtml');
14
+ return $outHtml;
15
+ }
16
+ }
app/code/community/Compropago/Model/Api.php CHANGED
@@ -1,34 +1,36 @@
1
-
2
  <?php
3
  /**
4
- * API para el consumo de los servicios
5
- * de PagoFacil
 
6
  * @author ivelazquex <isai.velazquez@gmail.com>
7
  */
 
 
8
  class Compropago_Model_Api
9
  {
10
- // --- ATTRIBUTES ---
11
  /**
12
  * URL del servicio de PagoFacil en ambiente de produccion
13
- * @var string
 
14
  */
15
  protected $_url = 'https://api.compropago.com/v1/charges';
 
16
  /**
17
  * respuesta sin parsear del servicio
 
18
  * @var string
19
  */
20
  protected $_response = NULL;
21
-
22
-
23
- // --- OPERATIONS ---
24
-
25
  public function __construct()
26
  {
27
-
28
  }
29
-
30
  /**
31
- * consume el servicio de pago de PagoFacil
 
32
  * @param string[] vector con la informacion de la peticion
33
  * @return mixed respuesta del consumo del servicio
34
  * @throws Exception
@@ -36,15 +38,13 @@ class Compropago_Model_Api
36
  public function payment($info)
37
  {
38
  $response = null;
39
- // NOTA la url a la cual s edebe conectar en produccion no viene
40
- // la direccion de produccion en el documento
41
-
42
- if (!is_array($info))
43
- {
44
  throw new Exception('parameter is not an array');
45
  }
 
46
  $info['url'] = $this->_url;
47
- // datos para la peticion del servicio
48
  $data = array(
49
  'order_id' => $info['order_id'],
50
  'order_price' => $info['order_price'],
@@ -52,40 +52,36 @@ class Compropago_Model_Api
52
  'image_url' => $info['image_url'],
53
  'customer_name' => $info['customer_name'],
54
  'customer_email' => $info['customer_email'],
 
55
  'payment_type' => $info['payment_type']
56
  );
57
- $username = $info['client_secret'];
58
- $password = $info['client_id'];
59
- // consumo del servicio
60
  $ch = curl_init();
61
  curl_setopt($ch, CURLOPT_URL, $this->_url);
62
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
63
  curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
64
- curl_setopt($ch, CURLOPT_USERPWD, $username . ":");
65
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
66
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
67
  curl_setopt($ch, CURLOPT_POST, true);
68
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
69
- // Blindly accept the certificate
70
  $this->_response = curl_exec($ch);
71
  curl_close($ch);
72
- // tratamiento de la respuesta del servicio
73
  $response = json_decode($this->_response,true);
74
- // respuesta del servicio
75
- if ($response == null)
76
- {
77
  Mage::throwException("El servicio de Compropago no se encuentra disponible.");
78
  }
79
-
80
- if ($response['type'] == "error")
81
- {
82
- $errorMessage = $response['message'] . "\n";
83
  Mage::throwException($errorMessage);
84
  }
85
-
86
  return $response;
87
  }
88
-
89
  /**
90
  * obtiene la respuesta del servicio
91
  * @return string
@@ -93,5 +89,5 @@ class Compropago_Model_Api
93
  public function getResponse()
94
  {
95
  return $this->_response;
96
- }
97
  }
 
1
  <?php
2
  /**
3
+ * API para el consumo de los servicios de ComproPago
4
+ *
5
+ * @author Eduardo Aguilar <eduardo.aguilar@compropago.com>
6
  * @author ivelazquex <isai.velazquez@gmail.com>
7
  */
8
+
9
+
10
  class Compropago_Model_Api
11
  {
 
12
  /**
13
  * URL del servicio de PagoFacil en ambiente de produccion
14
+ *
15
+ * @var string
16
  */
17
  protected $_url = 'https://api.compropago.com/v1/charges';
18
+
19
  /**
20
  * respuesta sin parsear del servicio
21
+ *
22
  * @var string
23
  */
24
  protected $_response = NULL;
25
+
 
 
 
26
  public function __construct()
27
  {
28
+
29
  }
30
+
31
  /**
32
+ * Consume el servicio de pago de ComproPago
33
+ *
34
  * @param string[] vector con la informacion de la peticion
35
  * @return mixed respuesta del consumo del servicio
36
  * @throws Exception
38
  public function payment($info)
39
  {
40
  $response = null;
41
+
42
+ if (!is_array($info)){
 
 
 
43
  throw new Exception('parameter is not an array');
44
  }
45
+
46
  $info['url'] = $this->_url;
47
+
48
  $data = array(
49
  'order_id' => $info['order_id'],
50
  'order_price' => $info['order_price'],
52
  'image_url' => $info['image_url'],
53
  'customer_name' => $info['customer_name'],
54
  'customer_email' => $info['customer_email'],
55
+ 'customer_phone' => $info['customer_phone'],
56
  'payment_type' => $info['payment_type']
57
  );
58
+
 
 
59
  $ch = curl_init();
60
  curl_setopt($ch, CURLOPT_URL, $this->_url);
61
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
62
  curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
63
+ curl_setopt($ch, CURLOPT_USERPWD, $info['client_secret'] . ":");
64
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
65
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
66
  curl_setopt($ch, CURLOPT_POST, true);
67
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
 
68
  $this->_response = curl_exec($ch);
69
  curl_close($ch);
70
+
71
  $response = json_decode($this->_response,true);
72
+
73
+ if ($response == null){
 
74
  Mage::throwException("El servicio de Compropago no se encuentra disponible.");
75
  }
76
+
77
+ if ($response['type'] == "error") {
78
+ $errorMessage = $response['message'] . "\n";
 
79
  Mage::throwException($errorMessage);
80
  }
81
+
82
  return $response;
83
  }
84
+
85
  /**
86
  * obtiene la respuesta del servicio
87
  * @return string
89
  public function getResponse()
90
  {
91
  return $this->_response;
92
+ }
93
  }
app/code/community/Compropago/Model/Providers.php CHANGED
@@ -5,6 +5,11 @@
5
 
6
  class Compropago_Model_Providers
7
  {
 
 
 
 
 
8
  public function toOptionArray()
9
  {
10
  $options = array();
@@ -19,6 +24,11 @@ class Compropago_Model_Providers
19
  return $options;
20
  }
21
 
 
 
 
 
 
22
  private function getProviders()
23
  {
24
  $url = 'https://api.compropago.com/v1/providers/';
@@ -28,27 +38,21 @@ class Compropago_Model_Providers
28
  curl_setopt($ch, CURLOPT_URL, $url);
29
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
30
  curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
31
- curl_setopt($ch, CURLOPT_USERPWD, "" . ":" . "");
32
-
33
- // Blindly accept the certificate
34
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
35
  $response = curl_exec($ch);
36
  curl_close($ch);
37
 
38
- // tratamiento de la respuesta del servicio
39
  $response = json_decode($response,true);
40
 
41
- // respuesta del servicio
42
- if ($response['type'] == "error")
43
- {
44
  $errorMessage = $response['message'] . "\n";
45
  Mage::throwException($errorMessage);
46
  }
47
 
48
  $hash = array();
49
 
50
- foreach($response as $record)
51
- {
52
  $hash[$record['rank']] = $record;
53
  }
54
 
@@ -56,11 +60,10 @@ class Compropago_Model_Providers
56
 
57
  $records = array();
58
 
59
- foreach($hash as $record)
60
- {
61
- $records []= $record;
62
  }
63
 
64
- return $records;
65
  }
66
  }
5
 
6
  class Compropago_Model_Providers
7
  {
8
+ /**
9
+ * Convercion de Proveedores para desplegar SelectBox
10
+ *
11
+ * @return array
12
+ */
13
  public function toOptionArray()
14
  {
15
  $options = array();
24
  return $options;
25
  }
26
 
27
+ /**
28
+ * Obtencion de proveedores ordenados por Rank
29
+ *
30
+ * @return array
31
+ */
32
  private function getProviders()
33
  {
34
  $url = 'https://api.compropago.com/v1/providers/';
38
  curl_setopt($ch, CURLOPT_URL, $url);
39
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
40
  curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
41
+ curl_setopt($ch, CURLOPT_USERPWD, ":");
 
 
42
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
43
  $response = curl_exec($ch);
44
  curl_close($ch);
45
 
 
46
  $response = json_decode($response,true);
47
 
48
+ if ($response['type'] == "error") {
 
 
49
  $errorMessage = $response['message'] . "\n";
50
  Mage::throwException($errorMessage);
51
  }
52
 
53
  $hash = array();
54
 
55
+ foreach($response as $record) {
 
56
  $hash[$record['rank']] = $record;
57
  }
58
 
60
 
61
  $records = array();
62
 
63
+ foreach($hash as $record){
64
+ $records[] = $record;
 
65
  }
66
 
67
+ return $records;
68
  }
69
  }
app/code/community/Compropago/Model/Standard.php CHANGED
@@ -4,6 +4,7 @@
4
  *
5
  * @author ivelazquex <isai.velazquez@gmail.com>
6
  */
 
7
  class Compropago_Model_Standard extends Mage_Payment_Model_Method_Abstract
8
  {
9
  protected $_code = 'compropago';
@@ -13,6 +14,12 @@ class Compropago_Model_Standard extends Mage_Payment_Model_Method_Abstract
13
  protected $_canUseInternal = false;
14
  protected $_isInitializeNeeded = true;
15
 
 
 
 
 
 
 
16
  public function assignData($data)
17
  {
18
  $customer = Mage::getSingleton('customer/session')->getCustomer();
@@ -22,7 +29,7 @@ class Compropago_Model_Standard extends Mage_Payment_Model_Method_Abstract
22
  }
23
 
24
  if ($data->getStoreCode() != ''){
25
- $store_code = $data->getStoreCode();
26
  } else {
27
  $store_code = 'OXXO';
28
  }
@@ -31,26 +38,36 @@ class Compropago_Model_Standard extends Mage_Payment_Model_Method_Abstract
31
  $info = array(
32
  "payment_type" => $store_code,
33
  "customer_name" => htmlentities($customer->getFirstname()),
34
- "customer_email" => htmlentities($customer->getEmail())
 
35
  );
36
  } else {
37
  $sessionCheckout = Mage::getSingleton('checkout/session');
38
  $quote = $sessionCheckout->getQuote();
39
  $billingAddress = $quote->getBillingAddress();
40
- $billing = $billingAddress->getData();
41
  $info = array(
42
  "payment_type" => $store_code,
43
  "customer_name" => htmlentities($billing['firstname']),
44
- "customer_email" => htmlentities($billing['email'])
 
45
  );
46
  }
47
 
48
  $infoInstance = $this->getInfoInstance();
49
- $infoInstance->setAdditionalData(serialize($info));
50
 
51
  return $this;
52
  }
53
 
 
 
 
 
 
 
 
 
54
  public function initialize($paymentAction, $stateObject)
55
  {
56
  parent::initialize($paymentAction, $stateObject);
@@ -61,17 +78,15 @@ class Compropago_Model_Standard extends Mage_Payment_Model_Method_Abstract
61
 
62
  // Set the default state of the new order.
63
  $state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT; // state now = 'pending_payment'
64
- //Mage::log('state->'.$state,null,'compropago.log');
65
- $default_status = 'pending';
66
 
67
  $stateObject->setState($state);
68
  $stateObject->setStatus($default_status);
69
  $stateObject->setIsNotified(false);
70
 
71
- //Retrieve cart/quote information.
72
  $sessionCheckout = Mage::getSingleton('checkout/session');
73
  $quoteId = $sessionCheckout->getQuoteId();
74
- // obtiene el quote para informacion de la orden
75
  $quote = Mage::getModel("sales/quote")->load($quoteId);
76
  $grandTotal = $quote->getData('grand_total');
77
  $subTotal = $quote->getSubtotal();
@@ -81,12 +96,12 @@ class Compropago_Model_Standard extends Mage_Payment_Model_Method_Abstract
81
  $order = $convertQuote->toOrder($quote);
82
  $orderNumber = $order->getIncrementId();
83
  $order1 = Mage::getModel('sales/order')->loadByIncrementId($orderNumber);
84
-
 
85
  foreach ($order1->getAllItems() as $item) {
86
  $name .= $item->getName();
87
  }
88
 
89
- // obtener datos del pago en info y asignar monto total
90
  $infoIntance = $this->getInfoInstance();
91
  $info = unserialize($infoIntance->getAdditionalData());
92
  $info['order_id'] = $orderNumber;
@@ -94,69 +109,68 @@ class Compropago_Model_Standard extends Mage_Payment_Model_Method_Abstract
94
  $info['order_name'] = $name;
95
  $info['client_secret'] = trim($this->getConfigData('private_key'));
96
  $info['client_id'] = trim($this->getConfigData('public_key'));
97
- // enviar pago
98
  try
99
  {
100
  $Api = new Compropago_Model_Api();
101
  $response = $Api->payment($info);
102
- }
103
- catch (Exception $error)
104
- {
105
- Mage::throwException($error->getMessage());
106
- }
107
 
108
- // respuesta del servicio
109
- if ($response == null)
110
- {
111
- Mage::throwException("El servicio de Compropago no se encuentra disponible.");
112
- }
113
 
114
- if ($response['type'] == "error")
115
- {
116
- $errorMessage = $response['message'] . "\n";
117
- Mage::throwException($errorMessage);
118
- }
119
 
120
- if($response['api_version'] == '1.0'){
121
- $id = $response['payment_id'];
122
- } elseif ($response['api_version'] == '1.1' || $response['api_version'] == '1.2') {
123
- $id = $response['id'];
124
- }
 
 
 
125
 
126
- Mage::getSingleton('core/session')->setCompropagoId($id);
 
 
 
 
127
  return $this;
128
  }
 
 
 
 
 
 
 
129
  public function getProviders()
130
  {
131
- if (trim($this->getConfigData('private_key')) == ''
132
- || trim($this->getConfigData('public_key')) == ''
133
- ) {
134
  Mage::throwException("Datos incompletos del servicio, contacte al administrador del sitio");
135
  }
136
- $url = 'https://api.compropago.com/v1/providers/';
137
- $url.= 'true';
138
- $username = trim($this->getConfigData('private_key'));
139
- $password = trim($this->getConfigData('public_key'));
140
 
141
  $ch = curl_init();
142
  curl_setopt($ch, CURLOPT_URL, $url);
143
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
144
  curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
145
- curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
146
- // Blindly accept the certificate
147
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
148
  $this->_response = curl_exec($ch);
149
  curl_close($ch);
150
- // tratamiento de la respuesta del servicio
151
  $response = json_decode($this->_response,true);
152
 
153
- // respuesta del servicio
154
  if ($response['type'] == "error"){
155
  $errorMessage = $response['message'] . "\n";
156
  Mage::throwException($errorMessage);
157
  }
158
 
159
-
160
  $filter = explode(",",$this->getConfigData('provider_available'));
161
 
162
  $hash = array();
@@ -178,6 +192,12 @@ class Compropago_Model_Standard extends Mage_Payment_Model_Method_Abstract
178
 
179
  return $records;
180
  }
 
 
 
 
 
 
181
  public function showLogoProviders()
182
  {
183
  return ( (int)trim($this->getConfigData("provider")) == 1 ? true : false );
4
  *
5
  * @author ivelazquex <isai.velazquez@gmail.com>
6
  */
7
+
8
  class Compropago_Model_Standard extends Mage_Payment_Model_Method_Abstract
9
  {
10
  protected $_code = 'compropago';
14
  protected $_canUseInternal = false;
15
  protected $_isInitializeNeeded = true;
16
 
17
+ /**
18
+ * Asignacion de informacion inicial
19
+ *
20
+ * @param $data
21
+ * @return $this
22
+ */
23
  public function assignData($data)
24
  {
25
  $customer = Mage::getSingleton('customer/session')->getCustomer();
29
  }
30
 
31
  if ($data->getStoreCode() != ''){
32
+ $store_code = $data->getStoreCode();
33
  } else {
34
  $store_code = 'OXXO';
35
  }
38
  $info = array(
39
  "payment_type" => $store_code,
40
  "customer_name" => htmlentities($customer->getFirstname()),
41
+ "customer_email" => htmlentities($customer->getEmail()),
42
+ "customer_phone" => $data->getCustomerPhone()
43
  );
44
  } else {
45
  $sessionCheckout = Mage::getSingleton('checkout/session');
46
  $quote = $sessionCheckout->getQuote();
47
  $billingAddress = $quote->getBillingAddress();
48
+ $billing = $billingAddress->getData();
49
  $info = array(
50
  "payment_type" => $store_code,
51
  "customer_name" => htmlentities($billing['firstname']),
52
+ "customer_email" => htmlentities($billing['email']),
53
+ "customer_phone" => $data->getCustomerPhone()
54
  );
55
  }
56
 
57
  $infoInstance = $this->getInfoInstance();
58
+ $infoInstance->setAdditionalData(serialize($info));
59
 
60
  return $this;
61
  }
62
 
63
+ /**
64
+ * Inicializacion del objeto principal
65
+ *
66
+ * @param $paymentAction
67
+ * @param $stateObject
68
+ * @return $this
69
+ * @throws Mage_Core_Exception
70
+ */
71
  public function initialize($paymentAction, $stateObject)
72
  {
73
  parent::initialize($paymentAction, $stateObject);
78
 
79
  // Set the default state of the new order.
80
  $state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT; // state now = 'pending_payment'
81
+ $default_status = 'pending';
 
82
 
83
  $stateObject->setState($state);
84
  $stateObject->setStatus($default_status);
85
  $stateObject->setIsNotified(false);
86
 
 
87
  $sessionCheckout = Mage::getSingleton('checkout/session');
88
  $quoteId = $sessionCheckout->getQuoteId();
89
+
90
  $quote = Mage::getModel("sales/quote")->load($quoteId);
91
  $grandTotal = $quote->getData('grand_total');
92
  $subTotal = $quote->getSubtotal();
96
  $order = $convertQuote->toOrder($quote);
97
  $orderNumber = $order->getIncrementId();
98
  $order1 = Mage::getModel('sales/order')->loadByIncrementId($orderNumber);
99
+
100
+ $name = "";
101
  foreach ($order1->getAllItems() as $item) {
102
  $name .= $item->getName();
103
  }
104
 
 
105
  $infoIntance = $this->getInfoInstance();
106
  $info = unserialize($infoIntance->getAdditionalData());
107
  $info['order_id'] = $orderNumber;
109
  $info['order_name'] = $name;
110
  $info['client_secret'] = trim($this->getConfigData('private_key'));
111
  $info['client_id'] = trim($this->getConfigData('public_key'));
112
+
113
  try
114
  {
115
  $Api = new Compropago_Model_Api();
116
  $response = $Api->payment($info);
 
 
 
 
 
117
 
118
+ if ($response == null) {
119
+ Mage::throwException("El servicio de Compropago no se encuentra disponible.");
120
+ }
 
 
121
 
122
+ if ($response['type'] == "error") {
123
+ $errorMessage = $response['message'] . "\n";
124
+ Mage::throwException($errorMessage.">>".json_encode($info));
125
+ }
 
126
 
127
+ $id = null;
128
+ if($response['api_version'] == '1.0'){
129
+ $id = $response['payment_id'];
130
+ } elseif ($response['api_version'] == '1.1' || $response['api_version'] == '1.2') {
131
+ $id = $response['id'];
132
+ }else{
133
+ Mage::throwException("Payment Id not defined");
134
+ }
135
 
136
+ Mage::getSingleton('core/session')->setCompropagoId($id);
137
+ }catch (Exception $error){
138
+ Mage::throwException($error->getMessage().">>".json_encode($info));
139
+ }
140
+
141
  return $this;
142
  }
143
+
144
+ /**
145
+ * Obtiene listado filtrado de proveedores
146
+ *
147
+ * @return array
148
+ * @throws Mage_Core_Exception
149
+ */
150
  public function getProviders()
151
  {
152
+ if (trim($this->getConfigData('private_key')) == '' || trim($this->getConfigData('public_key')) == '') {
 
 
153
  Mage::throwException("Datos incompletos del servicio, contacte al administrador del sitio");
154
  }
155
+
156
+ $url = 'https://api.compropago.com/v1/providers/true';
 
 
157
 
158
  $ch = curl_init();
159
  curl_setopt($ch, CURLOPT_URL, $url);
160
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
161
  curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
162
+ curl_setopt($ch, CURLOPT_USERPWD, ":");
 
163
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
164
  $this->_response = curl_exec($ch);
165
  curl_close($ch);
166
+
167
  $response = json_decode($this->_response,true);
168
 
 
169
  if ($response['type'] == "error"){
170
  $errorMessage = $response['message'] . "\n";
171
  Mage::throwException($errorMessage);
172
  }
173
 
 
174
  $filter = explode(",",$this->getConfigData('provider_available'));
175
 
176
  $hash = array();
192
 
193
  return $records;
194
  }
195
+
196
+ /**
197
+ * Determina si se mostraran los logos para la seleccion de proveedores
198
+ *
199
+ * @return bool
200
+ */
201
  public function showLogoProviders()
202
  {
203
  return ( (int)trim($this->getConfigData("provider")) == 1 ? true : false );
app/code/community/Compropago/controllers/WebhookController.php CHANGED
@@ -1,12 +1,12 @@
1
  <?php
2
- /**
3
- * Webhook para notificaciones de pagos.
4
- *
5
- * @author waldix (waldix86@gmail.com)
6
- */
7
  class Compropago_WebhookController extends Mage_Core_Controller_Front_Action{
8
  protected $_model = null;
9
-
10
  public function _construct() {
11
  $this->_model = Mage::getModel('compropago/Standard');
12
  }
@@ -18,13 +18,13 @@ class Compropago_WebhookController extends Mage_Core_Controller_Front_Action{
18
  if(isset($event_json)){
19
  if ($event_json->{'api_version'} === '1.1') {
20
  if ($event_json->{'id'}){
21
- $order = $this->verifyOrder($event_json->{'id'});
22
- $type = $order['type'];
23
 
24
- if (isset($order['id'])){
25
- if ($order['id'] === $event_json->{'id'}) {
26
  $order_id = $order['order_info']['order_id'];
27
- $this->changeStatus($order_id, $type);
28
  } else {
29
  echo 'Order not valid';
30
  }
@@ -34,11 +34,11 @@ class Compropago_WebhookController extends Mage_Core_Controller_Front_Action{
34
  }
35
  } else {
36
  if ($event_json->data->object->{'id'}){
37
- $order = $this->verifyOrder($event_json->data->object->{'id'});
38
  $type = $order['type'];
39
  if (isset($order['data']['object']['id'])){
40
  if ($order['data']['object']['id'] === $event_json->data->object->{'id'}) {
41
- $order_id = $order['data']['object']['payment_details']['product_id'];
42
  $this->changeStatus($order_id, $type);
43
  } else {
44
  echo 'Order not valid';
@@ -46,16 +46,16 @@ class Compropago_WebhookController extends Mage_Core_Controller_Front_Action{
46
  } else {
47
  echo 'Order not valid';
48
  }
49
-
50
  }
51
- }
52
  } else {
53
  echo 'Order not valid';
54
- }
55
  }
56
- public function changeStatus($order_id, $type){
57
- $_order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
58
- switch ($type) {
59
  case 'charge.pending':
60
  $status = $this->_model->getConfigData('order_status_new');
61
  $message = 'The user has not completed the payment process yet.';
@@ -63,7 +63,7 @@ class Compropago_WebhookController extends Mage_Core_Controller_Front_Action{
63
  $_order->setStatus($status);
64
  $history = $_order->addStatusHistoryComment($message);
65
  $history->setIsCustomerNotified(false);
66
- $_order->save();
67
  break;
68
  case 'charge.success':
69
  $status = $this->_model->getConfigData('order_status_approved');
@@ -72,16 +72,16 @@ class Compropago_WebhookController extends Mage_Core_Controller_Front_Action{
72
  $_order->setStatus($status);
73
  $history = $_order->addStatusHistoryComment($message);
74
  $history->setIsCustomerNotified(true);
75
- $_order->save();
76
  break;
77
- case 'charge.declined':
78
  $status = $this->_model->getConfigData('order_status_in_process');
79
  $message = 'The user has not completed the payment process yet.';
80
  $_order->setData('state',$status);
81
  $_order->setStatus($status);
82
  $history = $_order->addStatusHistoryComment($message);
83
  $history->setIsCustomerNotified(false);
84
- $_order->save();
85
  break;
86
  case 'charge.deleted':
87
  $status = $this->_model->getConfigData('order_status_cancelled');
@@ -90,7 +90,7 @@ class Compropago_WebhookController extends Mage_Core_Controller_Front_Action{
90
  $_order->setStatus($status);
91
  $history = $_order->addStatusHistoryComment($message);
92
  $history->setIsCustomerNotified(false);
93
- $_order->save();
94
  break;
95
  case 'charge.expired':
96
  $status = $this->_model->getConfigData('order_status_cancelled');
@@ -99,28 +99,28 @@ class Compropago_WebhookController extends Mage_Core_Controller_Front_Action{
99
  $_order->setStatus($status);
100
  $history = $_order->addStatusHistoryComment($message);
101
  $history->setIsCustomerNotified(false);
102
- $_order->save();
103
- break;
104
  default:
105
  $status = $this->_model->getConfigData('order_status_in_process');
106
- $message = "";
107
- $_order->addStatusToHistory($status, $message,true);
108
  }
109
  $_order->save();
110
  }
111
  public function verifyOrder($id){
112
  $url = 'https://api.compropago.com/v1/charges/';
113
- $url .= $id;
114
  $username = trim($this->_model->getConfigData('private_key'));
115
  $ch = curl_init();
116
  curl_setopt($ch, CURLOPT_URL, $url);
117
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
118
  curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
119
  curl_setopt($ch, CURLOPT_USERPWD, $username . ":");
120
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
121
  $this->_response = curl_exec($ch);
122
  curl_close($ch);
123
  $response = json_decode($this->_response,true);
124
  return $response;
125
- }
126
  }
1
  <?php
2
+ /**
3
+ * Webhook para notificaciones de pagos.
4
+ *
5
+ * @author waldix (waldix86@gmail.com)
6
+ */
7
  class Compropago_WebhookController extends Mage_Core_Controller_Front_Action{
8
  protected $_model = null;
9
+
10
  public function _construct() {
11
  $this->_model = Mage::getModel('compropago/Standard');
12
  }
18
  if(isset($event_json)){
19
  if ($event_json->{'api_version'} === '1.1') {
20
  if ($event_json->{'id'}){
21
+ $order = $this->verifyOrder($event_json->{'id'});
22
+ $type = $order['type'];
23
 
24
+ if (isset($order['id'])){
25
+ if ($order['id'] === $event_json->{'id'}) {
26
  $order_id = $order['order_info']['order_id'];
27
+ $this->changeStatus($order_id, $type);
28
  } else {
29
  echo 'Order not valid';
30
  }
34
  }
35
  } else {
36
  if ($event_json->data->object->{'id'}){
37
+ $order = $this->verifyOrder($event_json->data->object->{'id'});
38
  $type = $order['type'];
39
  if (isset($order['data']['object']['id'])){
40
  if ($order['data']['object']['id'] === $event_json->data->object->{'id'}) {
41
+ $order_id = $order['data']['object']['payment_details']['product_id'];
42
  $this->changeStatus($order_id, $type);
43
  } else {
44
  echo 'Order not valid';
46
  } else {
47
  echo 'Order not valid';
48
  }
49
+
50
  }
51
+ }
52
  } else {
53
  echo 'Order not valid';
54
+ }
55
  }
56
+ public function changeStatus($order_id, $type){
57
+ $_order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
58
+ switch ($type) {
59
  case 'charge.pending':
60
  $status = $this->_model->getConfigData('order_status_new');
61
  $message = 'The user has not completed the payment process yet.';
63
  $_order->setStatus($status);
64
  $history = $_order->addStatusHistoryComment($message);
65
  $history->setIsCustomerNotified(false);
66
+ $_order->save();
67
  break;
68
  case 'charge.success':
69
  $status = $this->_model->getConfigData('order_status_approved');
72
  $_order->setStatus($status);
73
  $history = $_order->addStatusHistoryComment($message);
74
  $history->setIsCustomerNotified(true);
75
+ $_order->save();
76
  break;
77
+ case 'charge.declined':
78
  $status = $this->_model->getConfigData('order_status_in_process');
79
  $message = 'The user has not completed the payment process yet.';
80
  $_order->setData('state',$status);
81
  $_order->setStatus($status);
82
  $history = $_order->addStatusHistoryComment($message);
83
  $history->setIsCustomerNotified(false);
84
+ $_order->save();
85
  break;
86
  case 'charge.deleted':
87
  $status = $this->_model->getConfigData('order_status_cancelled');
90
  $_order->setStatus($status);
91
  $history = $_order->addStatusHistoryComment($message);
92
  $history->setIsCustomerNotified(false);
93
+ $_order->save();
94
  break;
95
  case 'charge.expired':
96
  $status = $this->_model->getConfigData('order_status_cancelled');
99
  $_order->setStatus($status);
100
  $history = $_order->addStatusHistoryComment($message);
101
  $history->setIsCustomerNotified(false);
102
+ $_order->save();
103
+ break;
104
  default:
105
  $status = $this->_model->getConfigData('order_status_in_process');
106
+ $message = "";
107
+ $_order->addStatusToHistory($status, $message,true);
108
  }
109
  $_order->save();
110
  }
111
  public function verifyOrder($id){
112
  $url = 'https://api.compropago.com/v1/charges/';
113
+ $url .= $id;
114
  $username = trim($this->_model->getConfigData('private_key'));
115
  $ch = curl_init();
116
  curl_setopt($ch, CURLOPT_URL, $url);
117
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
118
  curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
119
  curl_setopt($ch, CURLOPT_USERPWD, $username . ":");
120
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
121
  $this->_response = curl_exec($ch);
122
  curl_close($ch);
123
  $response = json_decode($this->_response,true);
124
  return $response;
125
+ }
126
  }
app/design/frontend/base/default/template/compropago/cash.phtml CHANGED
@@ -1,46 +1,86 @@
1
  <?php
2
  /**
3
- *
4
  * Form payment cash
5
  *
 
6
  * @author Oswaldo Lopez (waldix86@gmail.com)
7
  */
8
  ?>
9
 
10
- <?php $_code= $this->getMethodCode();
11
- $_model = $this->getMethod();
12
- $_getProviders = $_model->getProviders();
 
13
  ?>
14
- <img id="image_providers" onload="loadImage(this);" src="<?php echo $this->getSkinUrl('images/compropago/providers.png') ?>" class="image_providers_compropago">
15
- <ul id="payment_form_<?php echo $_code ?>" style="display:none" >
16
- <label class="label-instructions">Selecciona un establecimiento para realizar el pago en efectivo:</label>
17
- <?php if (!$_model->showLogoProviders())
18
- { ?>
19
- <li>
20
- <select id="<?php echo $_code ?>_store"
21
- name="payment[store_code]">
22
- <?php foreach ($_getProviders as $_provider): ?>
23
- <option value="<?php echo $_provider['internal_name'] ?>"><?php echo $_provider['name'] ?></option>
24
- <?php endforeach; ?>
25
- </select>
26
- </li>
27
- <?php } else { ?>
28
- <li>
29
- <div class="row stores-compact" style="padding: 5px 15px; opacity: 1; width:100%; margin-bottom:70px;" id="<?php echo $_code ?>_store">
30
- <?php foreach ($_getProviders as $_provider): ?>
31
- <!--<php if($_provider['internal_name'] == 'OXXO' || $_provider['internal_name'] == 'SEVEN_ELEVEN' || $_provider['internal_name'] == 'EXTRA' || $_provider['internal_name'] == 'CHEDRAUI'): ?>-->
32
- <div class="element-box">
33
- <label for="<?php echo $_code ?>_<?php echo $_provider['internal_name'] ?>" class="provider-description <?php echo $_provider['internal_name'] == 'OXXO' ? 'seleccion_store' : '' ?>" onclick="seleccionar(this,'<?php echo $_provider['internal_name'] ?>');">
34
- <img src="<?php echo $_provider['image_medium'] ?>" class="image_provider">
35
- </label>
36
- </div>
37
- <!--<php endif; ?>-->
38
- <?php endforeach; ?>
39
- <input id="store_code_selected" type="hidden" name="payment[store_code]" value="">
40
- </div>
41
- </li>
42
- <?php } ?>
43
- </ul>
44
- <div>
45
- <?php echo $this->getMethod()->getConfigData('message');?>
46
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
  /**
 
3
  * Form payment cash
4
  *
5
+ * @author Eduardo Aguilar <eduardo.aguilar@compropago.com>
6
  * @author Oswaldo Lopez (waldix86@gmail.com)
7
  */
8
  ?>
9
 
10
+ <?php
11
+ $_code = $this->getMethodCode();
12
+ $_model = $this->getMethod();
13
+ $_getProviders = $_model->getProviders();
14
  ?>
15
+
16
+ <script>
17
+ paymentcheck = document.querySelector("#p_method_compropago");
18
+ provider = document.querySelector("#store_code_selected");
19
+ paymentcheck.checked = true;
20
+
21
+ btn = document.querySelector("button[ onclick^=payment ]");
22
+ btn.setAttribute("onclick"," ");
23
+
24
+ phone = document.querySelector("[title=Telephone]").value;
25
+ document.querySelector("#customer_phone").value = phone;
26
+
27
+ btn.addEventListener("click",function(evt){
28
+ evt.preventDefault();
29
+
30
+ if(paymentcheck.checked){
31
+ if(provider.value == ""){
32
+ alert("Seleccione una tienda para realizar el pago");
33
+ }else{
34
+ payment.save();
35
+ }
36
+ }else{
37
+ payment.save();
38
+ }
39
+ });
40
+ </script>
41
+
42
+
43
+ <div style="overflow: hidden;">
44
+ <ul id="payment_form_<?php echo $_code; ?>" style="display: none">
45
+ <label class="label-instructions">Selecciona un establecimiento para realizar el pago en efectivo:</label>
46
+ <?php if (!$_model->showLogoProviders()) { ?>
47
+
48
+ <li>
49
+ <select id="<?php echo $_code; ?>_store" name="payment[store_code]">
50
+ <?php foreach ($_getProviders as $_provider){ ?>
51
+ <option value="<?php echo $_provider['internal_name']; ?>"><?php echo $_provider['name']; ?></option>
52
+ <?php } ?>
53
+ </select>
54
+ </li>
55
+
56
+ <?php } else { ?>
57
+ <li>
58
+ <div class="row stores-compact" style="padding: 5px 15px; opacity: 1; width:100%; margin-bottom:70px;" id="<?php echo $_code; ?>_store">
59
+ <?php foreach ($_getProviders as $_provider){ ?>
60
+
61
+ <div class="element-box">
62
+ <label
63
+ id="cp-provider"
64
+ data-provider="<?php echo $_provider['internal_name']; ?>"
65
+ for="<?php echo $_code; ?>_<?php echo $_provider['internal_name']; ?>"
66
+ class="provider-description "
67
+ onclick="seleccionar(this);"
68
+ style="margin: 6px !important;">
69
+ <img src="<?php echo $_provider['image_medium']; ?>" class="image_provider" style="margin: 0 !important;">
70
+ </label>
71
+ </div>
72
+
73
+ <?php } ?>
74
+ <input id="store_code_selected" type="hidden" name="payment[store_code]" value="">
75
+ <input type="hidden" id="customer_phone" name="payment[customer_phone]" value="">
76
+ </div>
77
+ </li>
78
+ <?php } ?>
79
+ </ul>
80
+ <div>
81
+ <?php echo $this->getMethod()->getConfigData('message');?>
82
+ </div>
83
+ </div>
84
+
85
+
86
+
app/design/frontend/base/default/template/compropago/onepage_success.phtml CHANGED
@@ -5,65 +5,68 @@
5
  ?>
6
 
7
  <?php echo $this->getMessagesBlock()->getGroupedHtml(); ?>
8
- <?php $compropagoId = Mage::getSingleton('core/session')->getCompropagoId();
9
- ?>
10
 
11
  <div id="receipt" class="receipt">
12
- <div class="page-title">
13
- <h3 style="font-size: 1.0em;">¡Felicitaciones! Su pedido ha sido generado correctamente.</h3>
14
- </div>
15
- <?php if ($this->getOrderId()):?>
16
- <?php if ($compropagoId == '') :?>
17
- <p><?php echo $this->__('Your order # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getViewOrderUrl()), $this->escapeHtml($this->getOrderId()))) ?></p>
18
- <?php else :?>
19
- <div id="compropagodContainer" style="width: 100%;">
20
- <iframe style="width: 100%; height: 865px;>" id="compropagodFrame" src="https://www.compropago.com/comprobante/?confirmation_id=<?php echo $compropagoId; ?>" frameborder="0" scrolling="yes"> </iframe>
21
  </div>
22
- <?php Mage::getSingleton('core/session')->setCompropagoId(''); ?>
23
- <?php endif;?>
24
- <?php if ($this->getCanViewOrder() && $this->getCanPrintOrder()) :?>
25
- <p>
26
- <?php echo $this->__('Click <a href="%s" onclick="this.target=\'_blank\'">here to print</a> a copy of your order confirmation.', $this->getPrintUrl()) ?>
27
- <?php echo $this->getChildHtml() ?>
28
- </p>
29
- <?php endif;?>
30
- <?php endif;?>
 
 
 
 
 
 
 
 
 
 
 
31
 
32
- <?php if ($this->getAgreementRefId()): ?>
33
- <p><?php echo $this->__('Your billing agreement # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getAgreementUrl()), $this->escapeHtml($this->getAgreementRefId())))?></p>
34
- <?php endif;?>
35
 
36
- <?php if ($profiles = $this->getRecurringProfiles()):?>
37
- <p><?php echo $this->__('Your recurring payment profiles:'); ?></p>
38
- <ul class="disc">
39
- <?php foreach($profiles as $profile):?>
40
- <?php $profileIdHtml = ($this->getCanViewProfiles() ? sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getProfileUrl($profile)), $this->escapeHtml($this->getObjectData($profile, 'reference_id'))) : $this->escapeHtml($this->getObjectData($profile, 'reference_id')));?>
41
- <li><?php echo $this->__('Payment profile # %s: "%s".', $profileIdHtml, $this->escapeHtml($this->getObjectData($profile, 'schedule_description')))?></li>
42
- <?php endforeach;?>
43
- </ul>
44
- <?php endif;?>
45
- <div class="buttons-set">
46
- <button type="button" class="button continue-succes" title="<?php echo $this->__('Continue Shopping') ?>" onclick="window.location='<?php echo $this->getUrl() ?>'"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
47
- </div>
48
  </div>
49
  <script type="text/javascript">
50
- function resizeIframe() {
51
- var container=document.getElementById("compropagodContainer");
52
- var iframe=document.getElementById("compropagodFrame");
53
- if(iframe && container){
54
- var ratio=585/811;
55
- var width=container.offsetWidth;
56
- var height=(width/ratio);
57
- if(height>937){ height=937;}
58
- iframe.style.width=width + 'px';
59
- iframe.style.height=height + 'px';
 
60
  }
61
- }
62
-
63
- window.onload = function(event) {
64
- resizeIframe();
65
- };
66
- window.onresize = function(event) {
67
- resizeIframe();
68
- };
69
  </script>
5
  ?>
6
 
7
  <?php echo $this->getMessagesBlock()->getGroupedHtml(); ?>
8
+ <?php $compropagoId = Mage::getSingleton('core/session')->getCompropagoId(); ?>
 
9
 
10
  <div id="receipt" class="receipt">
11
+ <div class="page-title">
12
+ <h3 style="font-size: 1.0em;">¡Felicitaciones! Su pedido ha sido generado correctamente.</h3>
 
 
 
 
 
 
 
13
  </div>
14
+ <?php if ($this->getOrderId()):?>
15
+ <?php if ($compropagoId == '') :?>
16
+ <p>
17
+ <?php echo $this->__('Your order # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getViewOrderUrl()), $this->escapeHtml($this->getOrderId()))) ?>
18
+ <?php echo $this->__('Click <a href="%s" onclick="this.target=\'_blank\'">here to print</a> a copy of your order confirmation.', $this->getPrintUrl()) ?>
19
+ <?php echo $this->getChildHtml() ?>
20
+ </p>
21
+ <?php else :?>
22
+ <div id="compropagodContainer" style="width: 100%;">
23
+ <iframe style="width: 100%; height: 865px;>" id="compropagodFrame" src="https://www.compropago.com/comprobante/?confirmation_id=<?php echo $compropagoId; ?>" frameborder="0" scrolling="yes"> </iframe>
24
+ </div>
25
+ <?php Mage::getSingleton('core/session')->setCompropagoId(''); ?>
26
+ <?php endif;?>
27
+ <?php if ($this->getCanViewOrder() && $this->getCanPrintOrder()) :?>
28
+ <p>
29
+ <?php echo $this->__('Click <a href="%s" onclick="this.target=\'_blank\'">here to print</a> a copy of your order confirmation.', $this->getPrintUrl()) ?>
30
+ <?php echo $this->getChildHtml() ?>
31
+ </p>
32
+ <?php endif;?>
33
+ <?php endif;?>
34
 
35
+ <?php if ($this->getAgreementRefId()): ?>
36
+ <p><?php echo $this->__('Your billing agreement # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getAgreementUrl()), $this->escapeHtml($this->getAgreementRefId())))?></p>
37
+ <?php endif;?>
38
 
39
+ <?php if ($profiles = $this->getRecurringProfiles()):?>
40
+ <p><?php echo $this->__('Your recurring payment profiles:'); ?></p>
41
+ <ul class="disc">
42
+ <?php foreach($profiles as $profile):?>
43
+ <?php $profileIdHtml = ($this->getCanViewProfiles() ? sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getProfileUrl($profile)), $this->escapeHtml($this->getObjectData($profile, 'reference_id'))) : $this->escapeHtml($this->getObjectData($profile, 'reference_id')));?>
44
+ <li><?php echo $this->__('Payment profile # %s: "%s".', $profileIdHtml, $this->escapeHtml($this->getObjectData($profile, 'schedule_description')))?></li>
45
+ <?php endforeach;?>
46
+ </ul>
47
+ <?php endif;?>
48
+ <div class="buttons-set">
49
+ <button type="button" class="button continue-succes" title="<?php echo $this->__('Continue Shopping') ?>" onclick="window.location='<?php echo $this->getUrl() ?>'"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
50
+ </div>
51
  </div>
52
  <script type="text/javascript">
53
+ function resizeIframe() {
54
+ var container=document.getElementById("compropagodContainer");
55
+ var iframe=document.getElementById("compropagodFrame");
56
+ if(iframe && container){
57
+ var ratio=585/811;
58
+ var width=container.offsetWidth;
59
+ var height=(width/ratio);
60
+ if(height>937){ height=937;}
61
+ iframe.style.width=width + 'px';
62
+ iframe.style.height=height + 'px';
63
+ }
64
  }
65
+
66
+ window.onload = function(event) {
67
+ resizeIframe();
68
+ };
69
+ window.onresize = function(event) {
70
+ resizeIframe();
71
+ };
 
72
  </script>
js/compropago/compropago.js CHANGED
@@ -1,39 +1,46 @@
1
- function seleccionar(t,internal_name){
2
- var class_name = t.className,
3
- seleccionados = document.getElementsByClassName("seleccion_store"),
4
- store_code = document.getElementById('store_code_selected');
5
-
6
- for (i = 0; i < seleccionados.length; i++) {
7
- seleccionados[i].className = seleccionados[i].className.replace(/\bseleccion_store\b/,'');
8
- }
9
 
10
- if(class_name.search("seleccion_store") == -1){
11
- t.className += "seleccion_store";
12
- store_code.value = internal_name;
13
- }
14
- };
15
 
16
- function loadImage (t) {
17
- var input = document.getElementById('p_method_compropago');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
- if(input.checked){
20
- t.hide();
21
- } else {
22
- t.show();
23
- }
24
- };
25
 
26
  window.onload = function(){
27
  $$("#co-payment-form input[type=radio]").each(function(input){
28
- input.observe("click", function(){
29
- var input = document.getElementById('p_method_compropago'),
30
- image = document.getElementById('image_providers');
31
-
32
- if(input.checked){
33
- image.hide();
34
- } else {
35
- image.show();
36
- }
37
- })
38
- })
39
- }
1
+ /**
2
+ * @author Eduardo Aguilar <eduardo.aguilar@compropago.com>
3
+ * @author Oswaldo Lopez
4
+ */
 
 
 
 
5
 
6
+ function seleccionar(t){
7
+ provider = t.getAttribute("data-provider");
8
+ seleccionados = document.querySelectorAll("#cp-provider");
9
+ store_code = document.querySelector('#store_code_selected');
 
10
 
11
+ for(var x = 0; x < seleccionados.length; x++){
12
+ seleccionados[x].setAttribute("style",
13
+ "box-shadow: 0px 0px 0px 0px transparent;"+
14
+ "-webkit-box-shadow: 0px 0px 0px 0px transparent;"+
15
+ "-moz-box-shadow: 0px 0px 0px 0px transparent;"+
16
+ "margin: 6px !important;"
17
+ );
18
+ }
19
+
20
+ for (var i = 0; i < seleccionados.length; i++) {
21
+ seleccionados[i].className = seleccionados[i].className.replace(/\bseleccion_store\b/,'');
22
+ }
23
+
24
+ t.setAttribute("style",
25
+ "box-shadow: 0px 0px 2px 4px rgba(0,170,239,1);"+
26
+ "-webkit-box-shadow: 0px 0px 2px 4px rgba(0,170,239,1);"+
27
+ "-moz-box-shadow: 0px 0px 2px 4px rgba(0,170,239,1);"+
28
+ "margin: 6px !important;"
29
+ );
30
+
31
+ if(t.className.search("seleccion_store") == -1){
32
+ t.className += "seleccion_store";
33
+ store_code.value = provider;
34
+ }
35
+ }
36
 
 
 
 
 
 
 
37
 
38
  window.onload = function(){
39
  $$("#co-payment-form input[type=radio]").each(function(input){
40
+ input.observe("click", function(t){
41
+ if(t.getAttribute("id") == "cp-provider"){
42
+ seleccionar(t);
43
+ }
44
+ });
45
+ });
46
+ };
 
 
 
 
 
package.xml CHANGED
@@ -1,18 +1,34 @@
1
  <?xml version="1.0"?>
2
  <package>
3
- <name>ComproPago</name>
4
- <version>1.0.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Extension for cash payments in Compropago.</summary>
10
- <description>It is a tool that allows us to process cash payments in shop.</description>
11
- <notes>Validation Order Id</notes>
12
- <authors><author><name>Oswaldo Lopez Garcia</name><user>waldix</user><email>waldix@compropago.com</email></author></authors>
13
- <date>2016-05-02</date>
14
- <time>19:07:39</time>
15
- <contents><target name="mageetc"><dir name="modules"><file name="Compropago.xml" hash="884374bb8a46b5ac9a62cd8b9f351401"/></dir></target><target name="magecommunity"><dir name="Compropago"><dir name="Block"><file name="Form.php" hash="102aede546471a086a767c8b62fb83a4"/><file name="OnepageSuccess.php" hash="b941b628c1570af5f37cf0214008b1bd"/></dir><dir name="Helper"><file name="Data.php" hash="5d3d5f4f86f2cec56315a1b02cc3d308"/></dir><dir name="Model"><file name="Api.php" hash="938a6d86c0c5217f3ba06c6459fb3599"/><file name="Providers.php" hash="53c2d805af2a5af102537420b4776b32"/><file name="Standard.php" hash="5a171def8a9ee9d2d52f9dd1784b4f2d"/></dir><dir name="controllers"><file name="WebhookController.php" hash="a76da821b51784ce4b4a01dc1893f414"/></dir><dir name="etc"><file name="config.xml" hash="26776d50679f9c07924f5ab0a7beeb76"/><file name="system.xml" hash="63d480092fa87465736d905668e3110a"/></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="compropago"><file name="cash.phtml" hash="bf57cd924b25bfaf95d067e5bb0b4909"/><file name="onepage_success.phtml" hash="a1b54a2c84f1c0210c050de308327487"/></dir></dir><dir name="layout"><file name="compropago.xml" hash="b4c43eb397d0a9ce59b35377ef70e0ed"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="compropago"><file name="compropago.css" hash="08479b7c091dfc3cbec76ca272d62355"/></dir></dir><dir name="images"><dir name="compropago"><file name="providers.png" hash="44d36ab2a211de651e0ba98dd5961bea"/><file name="warning.png" hash="e30bf5b88671a415ca7771b3e5dd9c19"/></dir></dir></dir></dir></dir></target><target name="mage"><dir><dir name="js"><dir name="compropago"><file name="compropago.js" hash="0eff4d21b97e7878269ef84186e1b299"/></dir></dir></dir></target></contents>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
+ <name>Compropago_Payment_Extension</name>
4
+ <version>1.1.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>This extension allows you to receive cash payments in the convenience store Mexico:OXXO, 7Eleven, Elektra....</summary>
10
+ <description>ComproPago is the fastest and largest cash payments platform in Mexico. &#xD;
11
+ &#xD;
12
+ This extension allows you receive cash payments in Oxxo, 7eleven, Extra, Benavides, Coppel and other convenience stores across Mexico. &#xD;
13
+ &#xD;
14
+ Some of the benefits of adding ComproPago as a payment method in your online store are: The fastest confirmation time in the industry: less than 8 hours. &#xD;
15
+ &#xD;
16
+ The largest convenience store network in the whole country. &#xD;
17
+ &#xD;
18
+ The possibility of requesting your funds and receiving them in your bank account within 24 hours. &#xD;
19
+ &#xD;
20
+ Besides you will be able to: Automatically update your order status both in your online store and in ComproPago&#x2019;s account. &#xD;
21
+ &#xD;
22
+ Send email notifications for pending orders and reminder notifications to increase conversion rates.</description>
23
+ <notes>## 10/06/2016 v1.1.0&#xD;
24
+ * Feature: Seleccion de proveedores&#xD;
25
+ * Feature: Normalizacion de vista de seleccion de proveedores&#xD;
26
+ * Feature: Validacion de proveedor obligatorio&#xD;
27
+ * Feature: Captura de telefono de cliente</notes>
28
+ <authors><author><name>Oswaldo Lopez Garcia</name><user>waldix</user><email>waldix@compropago.com</email></author><author><name>Eduardo Aguilar</name><user>eduardoay</user><email>eduardo.aguilar@compropago.com</email></author></authors>
29
+ <date>2016-06-15</date>
30
+ <time>22:54:28</time>
31
+ <contents><target name="mageetc"><dir name="modules"><file name="Compropago.xml" hash="884374bb8a46b5ac9a62cd8b9f351401"/></dir></target><target name="magecommunity"><dir name="Compropago"><dir><dir name="Block"><file name="Form.php" hash="3433488444c881f51228924453689c4a"/><file name="OnepageSuccess.php" hash="7873729a10083644d735ce193e2b1752"/></dir><dir name="Helper"><file name="Data.php" hash="5d3d5f4f86f2cec56315a1b02cc3d308"/></dir><dir name="Model"><file name="Api.php" hash="a054a9fbb89867753f2d37561219e827"/><file name="Providers.php" hash="14a80d69659ee43913745a40c59c25cf"/><file name="Standard.php" hash="20e788a3d496d991cc827e8f668681cf"/></dir><dir name="controllers"><file name="WebhookController.php" hash="775c3bffa75a3765ad65d96652356482"/></dir><dir name="etc"><file name="config.xml" hash="26776d50679f9c07924f5ab0a7beeb76"/><file name="system.xml" hash="63d480092fa87465736d905668e3110a"/></dir></dir><file name=".DS_Store" hash="eb03774a462f5cc9f379a3cc14db34f0"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="compropago"><file name="cash.phtml" hash="5d0b597a3f811b22b22b7cb280f9f883"/><file name="onepage_success.phtml" hash="b85d49f5e82ed292da8e0d7c555d0fc4"/></dir></dir><dir name="layout"><file name="compropago.xml" hash="b4c43eb397d0a9ce59b35377ef70e0ed"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="compropago"><file name="compropago.css" hash="c31f0093851df11b1782c68a81e9fa86"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="compropago"><file name="compropago.js" hash="a54eee5266f30f33c3355d0ac770e8f0"/></dir></dir></target></contents>
32
  <compatible/>
33
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
34
  </package>
skin/frontend/base/default/css/compropago/compropago.css CHANGED
@@ -8,7 +8,7 @@
8
  box-shadow:0px 1px 7px 2px rgba(0,0,0,0.18);
9
  border-radius:5px;
10
  -moz-border-radius:5px;
11
- -webkit-border-radius:5px;
12
  width: 60px;
13
  }
14
  .element-box input{
@@ -62,10 +62,10 @@
62
  width:480px;
63
  }
64
 
65
- .label-instructions{
66
  top: 5px;
67
- position: relative;
68
- }
69
 
70
  .logo-success{
71
  bottom: 12px;
8
  box-shadow:0px 1px 7px 2px rgba(0,0,0,0.18);
9
  border-radius:5px;
10
  -moz-border-radius:5px;
11
+ -webkit-border-radius:5px;
12
  width: 60px;
13
  }
14
  .element-box input{
62
  width:480px;
63
  }
64
 
65
+ .label-instructions{
66
  top: 5px;
67
+ position: relative;
68
+ }
69
 
70
  .logo-success{
71
  bottom: 12px;
skin/frontend/base/default/images/compropago/providers.png DELETED
Binary file
skin/frontend/base/default/images/compropago/warning.png DELETED
Binary file