Locaweb_Gateway - Version 1.0.1

Version Notes

O Gateway de Pagamento da Locaweb é um facilitador, que permite a contratação e a integração de diversos meios de pagamento em qualquer tipo de loja online.

Atualmente, temos dois meios de pagamento disponíveis na extension do Magento:
* Cielo Buy Page Loja (sem autenticação)
* Redecard Web Service

Além destes, estamos buscando colaboradores para desenvolver os seguintes meios de pagamento:
* Boletos (Bradesco, Itaú, Banco do Brasil, Santander, HSBC e Caixa)
* Itaú Shopline
* Redecard Komerci Integrado
* Cielo Buy Page Cielo
* Cielo Buy Page Loja (com autenticação)

Se você estiver interessado em colaborar com o desenvolvimento da extension, o repositório está disponível no Github, na seguinte url: https://github.com/locaweb/gateway_magento.

Download this release

Release Info

Developer Locaweb
Extension Locaweb_Gateway
Version 1.0.1
Comparing to
See all releases


Code changes from version 1.0.0 to 1.0.1

lib/LocawebGateway/.DS_Store DELETED
Binary file
lib/LocawebGateway/LocawebGateway.php DELETED
@@ -1,80 +0,0 @@
1
- <?php
2
-
3
- require 'LocawebGatewayPayment.php';
4
- require 'LocawebGatewayRequest.php';
5
- require 'LocawebGatewayConfig.inc.php';
6
-
7
- class LocawebGateway
8
- {
9
- const SANDBOX_URL = "https://api-sandbox.gatewaylocaweb.com.br/v1/transacao";
10
- const PRODUCTION_URL = "https://api.gatewaylocaweb.com.br/v1/transacao";
11
-
12
- public $request_url_append = '';
13
-
14
- function __construct()
15
- {
16
- $this->request()->token = LocawebGatewayConfig::getToken();
17
- $this->request()->url = $this->UrlForEnv(LocawebGatewayConfig::getEnvironment());
18
- }
19
-
20
- function UrlForEnv($environment)
21
- {
22
- if($environment == "sandbox"){
23
- return self::SANDBOX_URL;
24
- } else {
25
- return self::PRODUCTION_URL;
26
- }
27
- }
28
-
29
- static public function criar($data=array())
30
- {
31
- $gateway = new self;
32
- $gateway->_payment = new LocawebGatewayPayment($data);
33
- return $gateway;
34
- }
35
-
36
- static public function capturar($id=null)
37
- {
38
- $gateway = new self;
39
- $gateway->request_url_append .= '/'.$id.'/capturar';
40
- return $gateway;
41
- }
42
-
43
- static public function cancelar($id=null)
44
- {
45
- $gateway = new self;
46
- $gateway->request_url_append .= '/'.$id.'/estornar';
47
- return $gateway;
48
- }
49
-
50
- static public function consultar($id=null)
51
- {
52
- $gateway = new self;
53
- $gateway->request()->httpMethod = 'get';
54
- $gateway->request_url_append .= '/'.$id;
55
- return $gateway;
56
- }
57
-
58
- public function payment()
59
- {
60
- if(empty($this->_payment)){
61
- $this->_payment = new LocawebGatewayPayment;
62
- }
63
- return $this->_payment;
64
- }
65
-
66
- public function request()
67
- {
68
- if(empty($this->_request)){
69
- $this->_request = new LocawebGatewayRequest;
70
- }
71
- return $this->_request;
72
- }
73
-
74
- public function sendRequest()
75
- {
76
- $this->request()->url .= $this->request_url_append;
77
- $this->request()->payload = $this->payment()->toPayload();
78
- return $this->request()->execute();
79
- }
80
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/LocawebGateway/LocawebGatewayConfig.inc.php DELETED
@@ -1,30 +0,0 @@
1
- <?php
2
-
3
- class LocawebGatewayConfig
4
- {
5
- const DEFAULT_ENV = "production";
6
- const DEFAULT_TOKEN = "3a5bbed0-50d4-012f-8d73-0026bb5a6240";
7
-
8
- static protected $environment = self::DEFAULT_ENV;
9
- static protected $token = self::DEFAULT_TOKEN;
10
-
11
- private function __construct(){}
12
-
13
- static public function getToken(){
14
- return self::$token;
15
- }
16
-
17
- static public function setToken($value){
18
- if(self::$token == self::DEFAULT_TOKEN)
19
- self::$token = $value;
20
- }
21
-
22
- static public function getEnvironment(){
23
- return self::$environment;
24
- }
25
-
26
- static public function setEnvironment($value){
27
- if(self::$environment == self::DEFAULT_ENV)
28
- self::$environment = $value;
29
- }
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/LocawebGateway/LocawebGatewayPayment.php DELETED
@@ -1,81 +0,0 @@
1
- <?php
2
-
3
- class LocawebGatewayPayment
4
- {
5
- # Atributo informando a url de retorno para a loja após a finalização
6
- # do processo de pagamento
7
- # 'url_retorno' => 'http://www.minha-loja.com.br/confirmacao-pedido.php?id=12345'
8
- public $url_retorno = '';
9
-
10
- # Atributo que informa se deverá ocorrer a captura automática.
11
- # Valido apenas para operações via Cielo e Redecard.
12
- # 'capturar' => 'true'
13
- public $capturar = '';
14
-
15
- # Campo contendo os detalhes do pedido a ser enviado:
16
- # 'pedido' => array(
17
- # 'numero' => "123",
18
- # 'total' => "100.00",
19
- # 'moeda' => "real",
20
- # 'descricao' => "My Camaro car!"
21
- # )
22
- public $pedido = '';
23
-
24
- # Atributo contendo as informações sobre o pagamento:
25
- # 'pagamento' => array(
26
- # 'meio_pagamento' => 'redecard' # Nesse campo se determina o convenio utilizado.
27
- # 'bandeira' => "visa",
28
- # 'cartao_numero' => "4012001037141112",
29
- # 'cartao_cvv' => "973",
30
- # 'parcelas' => "1",
31
- # 'tipo_operacao' => "credito_a_vista",
32
- # 'cartao_validade' => "082015"
33
- # )
34
- public $pagamento = '';
35
-
36
- # Atributo contendo as informações sobre o comprador:
37
- # 'comprador' => array(
38
- # 'nome' => "Bruna da Silva",
39
- # 'documento' => "27836038881",
40
- # 'endereco' => "Rua da Casa",
41
- # 'numero' => "23",
42
- # 'cep' => "09710240",
43
- # 'bairro' => "Centro",
44
- # 'cidade' => "São Paulo",
45
- # 'estado' => "SP"
46
- # )
47
- public $comprador = '';
48
-
49
- public function __construct(Array $data=array())
50
- {
51
- extract($data);
52
- if (isset($comprador))
53
- $this->comprador = $comprador;
54
- if (isset($pedido))
55
- $this->pedido = $pedido;
56
- if (isset($pagamento))
57
- $this->pagamento = $pagamento;
58
- if (isset($capturar))
59
- $this->capturar = $capturar;
60
- if (isset($url_retorno))
61
- $this->url_retorno = $url_retorno;
62
- }
63
-
64
- public function toPayload(){
65
- $payload = array();
66
- $this->setArrayItemIfValueIsPresent($payload,'pagamento',$this->pagamento);
67
- $this->setArrayItemIfValueIsPresent($payload,'comprador',$this->comprador);
68
- $this->setArrayItemIfValueIsPresent($payload,'pedido',$this->pedido);
69
- $this->setArrayItemIfValueIsPresent($payload,'capturar',$this->capturar);
70
- $this->setArrayItemIfValueIsPresent($payload,'url_retorno',$this->url_retorno);
71
- return $payload;
72
- }
73
-
74
- private function setArrayItemIfValueIsPresent(&$array, $index, $value){
75
- if(isset($value) && !empty($value)){
76
- $array[ $index ] = $value;
77
- return true;
78
- }
79
- return false;
80
- }
81
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/LocawebGateway/LocawebGatewayProcessor.php DELETED
@@ -1,123 +0,0 @@
1
- <?php
2
-
3
- require 'LocawebGateway.php';
4
-
5
- class LocawebGatewayProcessor
6
- {
7
- public $locawebGateway;
8
- public $dados_internos;
9
- public $formulario;
10
-
11
- public function getFormulario($index){
12
- return $this->getValueOrNull($index,$this->formulario);
13
- }
14
-
15
- public function getDadosInternos($index){
16
- return $this->getValueOrNull($index,$this->dados_internos);
17
- }
18
-
19
- public function getValueOrNull($index,$haystack){
20
- if(isset($haystack[$index]) && array_key_exists($index,$haystack)){
21
- return $haystack[$index];
22
- }
23
- return null;
24
- }
25
-
26
- // Processador que recebe os dados necessários e efetua a requisição ao gateway da locaweb
27
- // Recebe 2 váriaveis dados internos e os dados do formulários , os internos são informações
28
- // que devem vir do seu sistema , como por exemplo o numero de um pedido , enquanto os dados
29
- // do formulário são os enviados pelo usuário no momento da compra, como o nr. do cartão.
30
- function __construct($dados_internos,$formulario, $gateway = 'LocawebGateway')
31
- {
32
- $this->dados_internos = $dados_internos;
33
- $this->formulario = $formulario;
34
-
35
- $this->locawebGateway = new $gateway;
36
-
37
- // Preparar dados a serem enviados.
38
- $this->preparePayload();
39
- }
40
-
41
- public function preparePayload(){
42
-
43
- // Configura a URL que deve ser acessada após o processamento pelo gateway ser efetuado.
44
- // Exemplo: 'url_retorno' => 'http://www.minha-loja.com.br/confirmacao-pedido.php?id=12345'
45
- $this->locawebGateway->payment()->url_retorno = $this->getDadosInternos('url_retorno');
46
-
47
- // Configura se a captura deve ocorrer automaticamente
48
- // Valido apenas para operações via Cielo e Redecard.
49
- // Exemplo: 'capturar' => 'true'
50
- $this->locawebGateway->payment()->capturar= $this->getDadosInternos('capturar_automaticamente');
51
-
52
- // Configura os dados relacionados ao pedido.
53
- // Exemplo: 'pedido' => array(
54
- // 'numero' => "123",
55
- // 'total' => "100.00",
56
- // 'moeda' => "real",
57
- // 'descricao' => "My Camaro car!"
58
- // )
59
- $this->locawebGateway->payment()->pedido = array(
60
- 'numero' => $this->getDadosInternos('numero_pedido'),
61
- 'total' => sprintf('%.2f', (double) $this->getDadosInternos('total')),
62
- 'moeda' => $this->getDadosInternos('moeda'),
63
- 'descricao' => $this->getDadosInternos('descricao')
64
- );
65
-
66
- // Atributo contendo as informações sobre o pagamento:
67
- // Exemplo: 'pagamento' => array(
68
- // 'bandeira' => "visa",
69
- // 'cartao_numero' => "4012001037141112",
70
- // 'cartao_cvv' => "973",
71
- // 'parcelas' => "1",
72
- // 'tipo_operacao' => "credito_a_vista",
73
- // 'cartao_validade' => "082015"
74
- // )
75
- $this->locawebGateway->payment()->pagamento = array(
76
- 'meio_pagamento' => $this->getDadosInternos('meio_pagamento'),
77
- 'bandeira' => $this->getFormulario('bandeira'),
78
- 'cartao_numero' => $this->getFormulario('cartao_numero'),
79
- 'cartao_cvv' => $this->getFormulario('cartao_cvv'),
80
- 'cartao_validade' => preg_replace('/[^\d]/','',$this->getFormulario('cartao_validade')) # E.R. para remover tudo que não for numero.
81
- );
82
-
83
- #Parcelas e tipo de operações são tratados separadamente para confirmar se o usuario escolheu dentro do nivel permitido.
84
- if(is_array($this->getDadosInternos('parcelas_permitidas')))
85
- if(in_array($this->getFormulario('parcelas'),$this->getDadosInternos('parcelas_permitidas')))
86
- $this->locawebGateway->payment()->pagamento['parcelas'] = $this->getFormulario('parcelas');
87
- else
88
- throw new Exception('Numero de Parcelas inválidas');
89
-
90
- if(is_array($this->getDadosInternos('operacoes_permitidas')))
91
- if(in_array($this->getFormulario('tipo_operacao'),$this->getDadosInternos('operacoes_permitidas')))
92
- $this->locawebGateway->payment()->pagamento['tipo_operacao'] = $this->getFormulario('tipo_operacao');
93
- else
94
- throw new Exception('Tipo de operação inválida');
95
-
96
- // Atributo contendo as informações sobre o comprador:
97
- // 'comprador' => array(
98
- // 'nome' => "Bruna da Silva",
99
- // 'documento' => "27836038881",
100
- // 'endereco' => "Rua da Casa",
101
- // 'numero' => "1",
102
- // 'cep' => "09710240",
103
- // 'bairro' => "Centro",
104
- // 'cidade' => "São Paulo",
105
- // 'estado' => "SP"
106
- if(is_array($this->getFormulario('endereco'))){
107
- $endereco = implode($this->getFormulario('endereco'));
108
- } else {
109
- $endereco = $this->getFormulario('endereco');
110
- }
111
-
112
- $this->locawebGateway->payment()->comprador = array(
113
- 'nome' => $this->getFormulario('nome'),
114
- 'documento' => preg_replace('/[^\d]/','',$this->getFormulario('documento')), # E.R. para remover tudo que não for numero.
115
- 'endereco' => $endereco,
116
- 'cep' => preg_replace('/[^\d]/','',$this->getFormulario('cep')), # E.R. para remover tudo que não for numero.
117
- 'bairro' => $this->getFormulario('bairro'),
118
- 'numero' => $this->getFormulario('numero'),
119
- 'cidade' => $this->getFormulario('cidade'),
120
- 'estado' => $this->getFormulario('estado')
121
- );
122
- }
123
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/LocawebGateway/LocawebGatewayRequest.php DELETED
@@ -1,102 +0,0 @@
1
- <?php
2
- require_once('SimpleRestClient.php');
3
-
4
- class LocawebGatewayRequest
5
- {
6
- // Qual o token do cliente a ser utilizado
7
- public $token = '';
8
-
9
- // Dados a serem enviados
10
- public $payload = '';
11
-
12
- // Url do seu webservice da locaweb
13
- public $url = '';
14
-
15
- // RestClient to be used
16
- private $_restClient;
17
-
18
- // Formato do envio
19
- public $httpMethod = 'post';
20
-
21
- // Return the restclient initialized to common requests.
22
- protected function _buildRestClient()
23
- {
24
- return new SimpleRestClient($arquivo_certificado=null,$arquivo_key=null, $senha=null,
25
- $user_agent="LocawebPhpPlugin (SimpleRestClient/Curl)", $options=null);
26
- }
27
-
28
- public function __construct($client = null)
29
- {
30
- if ($client == null)
31
- $client = $this->_buildRestClient();
32
-
33
- $this->setRestClient($client);
34
- }
35
-
36
- public function dataToBeEncoded()
37
- {
38
- return array_filter(array(
39
- 'token' => $this->token,
40
- 'transacao' => $this->payload
41
- ));
42
- }
43
-
44
- // Builds the JSON meant to be sent.
45
- public function buildJSON()
46
- {
47
- return json_encode($this->dataToBeEncoded());
48
- }
49
-
50
- public function buildParams()
51
- {
52
- $request_url = '';
53
- if(count($this->dataToBeEncoded())>0)
54
- {
55
- $request_url .= '?';
56
- $request_url .= http_build_query($this->dataToBeEncoded());
57
- }
58
-
59
- return $request_url;
60
- }
61
-
62
- // Sends the data to the current url.
63
- public function execute()
64
- {
65
- if($this->httpMethod == 'post')
66
- $response = $this->post($this->buildJSON());
67
- else
68
- $response = $this->get($this->buildParams());
69
-
70
- return json_decode($response);
71
- }
72
-
73
- // Executes the get action.
74
- public function get($data)
75
- {
76
- $request_url = $this->url;
77
- $request_url .= $data;
78
- $restclient = $this->_restClient;
79
- $restclient->getWebRequest($request_url);
80
- return $restclient->getWebResponse();
81
- }
82
-
83
- // Executes the post action.
84
- public function post($data)
85
- {
86
- $restclient = $this->_restClient;
87
- $restclient->postWebRequest($this->url , $data);
88
- return $restclient->getWebResponse();
89
- }
90
-
91
- // Allow setting a different restClient.
92
- private function setRestClient($client)
93
- {
94
- $this->_restClient = $client;
95
- }
96
- // Allow getting the restClient.
97
-
98
- public function getRestClient()
99
- {
100
- return $this->_restClient;
101
- }
102
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/LocawebGateway/SimpleRestClient.php DELETED
@@ -1,268 +0,0 @@
1
- <?php
2
- /**
3
- * SimpleRestClient
4
- *
5
- * @copyright 2009
6
- * @author University of Washington
7
- * @version 1.0 9/24/2009
8
- *
9
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
10
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
11
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
12
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13
- *
14
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions
15
- * of the Software.
16
- *
17
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
18
- * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
- * DEALINGS IN THE SOFTWARE.
22
- */
23
- class SimpleRestClient
24
- {
25
- // Provide default CURL options
26
- protected $_default_opts = array(
27
- CURLOPT_RETURNTRANSFER => true, // return result instead of echoing
28
- CURLOPT_SSL_VERIFYPEER => false, // stop cURL from verifying the peer's certificate
29
- CURLOPT_FOLLOWLOCATION => true, // follow redirects, Location: headers
30
- CURLOPT_MAXREDIRS => 10, // but dont redirect more than 10 times
31
- CURLOPT_HTTPHEADER => array("Content-Type: application/json") // Default format to json
32
- );
33
-
34
- protected $_response=null;
35
-
36
- // hash to store any CURLOPT_ option values
37
- protected $_options;
38
-
39
- // container for full CURL getinfo hash
40
- protected $_info=null;
41
-
42
- // variable to hold the CURL handle
43
- private $_c=null;
44
-
45
- /**
46
- * Instantiate a SimpleRestClient object.
47
- *
48
- * @param string $cert_file path to SSL public identity file
49
- * @param string $key_file path to SSL private key file
50
- * @param string $key_file passphrase to access $key_file
51
- * @param string $user_agent client identifier sent to server with HTTP headers
52
- * @param array $options hash of CURLOPT_ options and values
53
- */
54
- public function __construct($cert_file=null,$key_file=null, $password=null, $user_agent="PhpRestClient", $options=null)
55
- {
56
- // make sure we can use curl
57
- if (!function_exists('curl_init')) {
58
- throw new Exception('Trying to use CURL, but module not installed.');
59
- }
60
-
61
- // load default options then add the ones passed as argument
62
- $this->_options = $this->_default_opts;
63
- if (is_array($options)) {
64
- foreach ($options as $curlopt => $value) {
65
- $this->_options[$curlopt] = $value;
66
- }
67
- }
68
-
69
- // Use the mutator methods to take advantage of any processing or error checking
70
- $this->setCertFile($cert_file);
71
- $this->setKeyFile($key_file, $password);
72
- $this->_options[CURLOPT_USERAGENT] = $user_agent;
73
-
74
- // initialize the _info container
75
- $this->_info = array();
76
- }
77
-
78
- /**
79
- * Set a CURL option
80
- *
81
- * @param int $curlopt index of option expressed as CURLOPT_ constant
82
- * @param mixed $value what to set this option to
83
- */
84
- public function setOption($curlopt, $value)
85
- {
86
- $this->_options[$curlopt] = $value;
87
- }
88
-
89
- /**
90
- * Set the local file system location of the SSL public certificate file that
91
- * cURL should pass to the server to identify itself.
92
- *
93
- * @param string $cert_file path to SSL public identity file
94
- */
95
- public function setCertFile($cert_file)
96
- {
97
- if (!is_null($cert_file))
98
- {
99
- if (!file_exists($cert_file)) {
100
- throw new Exception('Cert file: '. $cert_file .' does not exist!');
101
- }
102
- if (!is_readable($cert_file)) {
103
- throw new Exception('Cert file: '. $cert_file .' is not readable!');
104
- }
105
- // Put this in _options hash
106
- $this->_options[CURLOPT_SSLCERT] = $cert_file;
107
- }
108
- }
109
-
110
- /**
111
- * Set the local file system location of the private key file that cURL should
112
- * use to decrypt responses from the server.
113
- *
114
- * @param string $key_file path to SSL private key file
115
- * @param string $password passphrase to access $key_file
116
- */
117
- public function setKeyFile($key_file, $password = null)
118
- {
119
- if (!is_null($key_file))
120
- {
121
- if (!file_exists($key_file)) {
122
- throw new Exception('SSL Key file: '. $key_file .' does not exist!');
123
- }
124
- if (!is_readable($key_file)) {
125
- throw new Exception('SSL Key file: '. $key_file .' is not readable!');
126
- }
127
- // set the private key in _options hash
128
- $this->_options[CURLOPT_SSLKEY] = $key_file;
129
- // optionally store a pass phrase for key
130
- if (!is_null($password)) {
131
- $this->_options[CURLOPT_SSLCERTPASSWD] = $password;
132
- }
133
- }
134
- }
135
-
136
- /**
137
- * Set the client software identifier sent to server with HTTP request headers
138
- *
139
- * @param string $user_agent client identifier
140
- */
141
- public function setUserAgent($user_agent)
142
- {
143
- $this->_options[CURLOPT_USERAGENT] = $user_agent;
144
- }
145
-
146
- /**
147
- * Retrieve the response from the server captured after calling makeWebRequest()
148
- *
149
- * @return string
150
- */
151
- public function getWebResponse()
152
- {
153
- return $this->_response;
154
- }
155
-
156
- /**
157
- * Make an HTTP GET request to the URL provided. Capture the results for future
158
- * use.
159
- *
160
- * @param string $url absolute URL to make an HTTP request to
161
- */
162
- public function getWebRequest($url) // removed $public argument, implied by existence of SSLCERT and SSLKEY in _options
163
- {
164
- $_c = curl_init($url); // $url is the resource we're fetching
165
-
166
- // set the options
167
- foreach ($this->_options as $curlopt => $value) {
168
- curl_setopt($_c, $curlopt, $value);
169
- }
170
-
171
- $_raw_data = curl_exec($_c);
172
- $_raw_data = $this->fix_iis_data($_raw_data);
173
- if (curl_errno($_c) != 0) {
174
- throw new Exception('Aborting. cURL error: ' . curl_error($_c));
175
- }
176
- $this->_response=str_replace("xmlns=","a=",$_raw_data); //Getting rid of xmlns so that clients can use SimpleXML and XPath without problems otherwise SimpleXML does not recognize the document as an XML document
177
-
178
- // Store all cURL metadata about this request
179
- $this->_info = curl_getinfo($_c);
180
- curl_close($_c);
181
- }
182
- /**
183
- * Make an HTTP POST request to the URL provided. Capture the results for future
184
- * use.
185
- * @param array $data can be either a string or an array
186
- */
187
- public function postWebRequest($url, $data)
188
- {
189
- // Serialize the data into a query string
190
- if (is_array($data)) {
191
- $post_data = '';
192
- $need_amp = false;
193
- foreach ($data as $varname => $val) {
194
- if ($need_amp) $post_data .= '&';
195
- $val = urlencode($val);
196
- $post_data .= "{$varname}={$val}";
197
- $need_amp = true;
198
- }
199
- } elseif (is_string($data)) {
200
- $post_data = $data;
201
- } else {
202
- $post_data = '';
203
- }
204
-
205
- //Do the POST and get back the results
206
- $_c = curl_init($url); // $url is the resource we're fetching
207
- // set the options
208
- foreach ($this->_options as $curlopt => $value) {
209
- curl_setopt($_c, $curlopt, $value);
210
- }
211
- curl_setopt($_c,CURLOPT_POST, 1);
212
- curl_setopt($_c,CURLOPT_POSTFIELDS, $post_data);
213
- $_raw_data = curl_exec($_c);
214
- $_raw_data = $this->fix_iis_data($_raw_data);
215
- if (curl_errno($_c) != 0) {
216
- throw new Exception('Aborting. cURL error: ' . curl_error($_c));
217
- }
218
- $this->_response=str_replace("xmlns=","a=",$_raw_data); //Getting rid of xmlns so that clients can use SimpleXML and XPath without problems otherwise SimpleXML does not recognize the document as an XML document
219
- // Store all cURL metadata about this request
220
- $this->_info = curl_getinfo($_c);
221
- curl_close($_c);
222
- }
223
- /**
224
- * Get stats and info about the last run HTTP request. Data available here
225
- * is from Curl's curl_getinfo function. Either returns the full assoc
226
- * array of data or the specified item.
227
- *
228
- * @param string $item index to a specific info item
229
- * @return mixed
230
- */
231
- public function getInfo($item = 0)
232
- {
233
- if ($item === 0) { return $this->_info; }
234
-
235
- if (array_key_exists($item, $this->_info)) {
236
- return $this->_info[$item];
237
- } else {
238
- return null;
239
- }
240
- }
241
-
242
- /**
243
- * Get the HTTP status code returned by the last execution of makeWebRequest()
244
- *
245
- * @return int
246
- */
247
- public function getStatusCode()
248
- {
249
- return $this->getInfo('http_code');
250
- }
251
- /**
252
- * Apply a couple of heuristics to fix data coming from an IIS server
253
- */
254
- private function fix_iis_data($data)
255
- {
256
- // IIS has an annoying habit of prepending binary garbage to the beginning
257
- // of their XML payloads. Nuke it.
258
- $beg = strpos($data, '<?xml');
259
- if ($beg) {
260
- $data = substr($data, $beg, strlen($data) - strlen($beg));
261
- }
262
-
263
- // IIS often inserts invalid character references.
264
- $data = str_replace('&#x0;', '', $data);
265
-
266
- return($data);
267
- }
268
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Locaweb_Gateway</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
@@ -14,23 +14,31 @@ Atualmente, temos dois meios de pagamento dispon&#xED;veis na extension do Magen
14
  * Redecard Web Service&#xD;
15
  &#xD;
16
  Al&#xE9;m destes, estamos buscando colaboradores para desenvolver os seguintes meios de pagamento:&#xD;
17
- * Boletos (Santander, Ita&#xFA;, Caixa, HSBC, Bradesco e Banco do Brasil)&#xD;
18
  * Ita&#xFA; Shopline&#xD;
19
  * Redecard Komerci Integrado&#xD;
20
  * Cielo Buy Page Cielo&#xD;
21
  * Cielo Buy Page Loja (com autentica&#xE7;&#xE3;o)&#xD;
22
  &#xD;
23
  Se voc&#xEA; estiver interessado em colaborar com o desenvolvimento da extension, o reposit&#xF3;rio est&#xE1; dispon&#xED;vel no Github, na seguinte url: https://github.com/locaweb/gateway_magento.</description>
24
- <notes>Corre&#xE7;&#xF5;es em meios de pagamento&#xD;
25
- &#xD;
26
- Atualmente, temos dois meios de pagamento dispon&#xED;veis na extension:&#xD;
27
  &#xD;
 
28
  * Cielo Buy Page Loja (sem autentica&#xE7;&#xE3;o)&#xD;
29
- * Redecard Web Service</notes>
 
 
 
 
 
 
 
 
 
30
  <authors><author><name>Locaweb</name><user>locaweb</user><email>saas-dev@locaweb.com.br</email></author></authors>
31
  <date>2012-10-19</date>
32
- <time>15:53:07</time>
33
- <contents><target name="magecommunity"><dir name="Locaweb"><dir name="Abstract"><dir name="Config"><file name="Cctype.php" hash="bfc9fd031cf7357fb426cf8b8aff15bf"/><file name="Parceltype.php" hash="d0cd2f5dd62c44b8617f5a3389053f6b"/></dir><dir name="Model"><dir name="Payment"><dir name="Method"><file name="Cc.php" hash="7caa7f717867a481e5e2d3096caf6379"/></dir></dir></dir></dir><dir name="CieloBuyLoja"><dir name="Block"><dir name="Form"><file name="Cc.php" hash="3e5849dc322c7078f8885e0ee6c297f2"/></dir></dir><dir name="Config"><file name="Cctype.php" hash="5ae06f93bb4aae2b574c1f4805baafe4"/></dir><dir name="Helper"><file name="Data.php" hash="ee1f59db5830572a72795453ae01a9ce"/></dir><dir name="Model"><file name="Transaction.php" hash="31419aacb716199344bb2f38a5c6e062"/></dir><dir name="etc"><file name="config.xml" hash="340618f85e07339b07407ecdbe9a1c7a"/><file name="system.xml" hash="9dd3909b96959b257eed078080c4258d"/></dir></dir><dir name="RedeCardWS"><dir name="Block"><dir name="Form"><file name="Cc.php" hash="bca9a9e131a6474c83c0db98938ce4fb"/></dir></dir><dir name="Config"><file name="Cctype.php" hash="22417a736b9d221f0cba98e5460c9aee"/></dir><dir name="Helper"><file name="Data.php" hash="71b47a6f927431a976e4ad7b7e6d8a83"/></dir><dir name="Model"><file name="Transaction.php" hash="054b2ea6b3fcc13088e88985115e01e6"/></dir><dir name="etc"><file name="config.xml" hash="a40004df4b7fd042e583ec6267a7db55"/><file name="system.xml" hash="8c1c3c9b468645474947160d007075cb"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Locaweb_CieloBuyLoja.xml" hash="5c81993759047a9829b3b78424bf59a4"/><file name="Locaweb_RedecardWS.xml" hash="225d101fca4c4fa09ea3f3a3d4895cae"/></dir></target><target name="magelocale"><dir name="pt_BR"><file name="Locaweb_Gateway.csv" hash="acefe4130e9aee0a18d1945be634043f"/></dir></target><target name="magelib"><dir name="LocawebGateway"><file name="LocawebGateway.php" hash="e3354e104dedabf5f1a98afce709caec"/><file name="LocawebGatewayConfig.inc.php" hash="86bc0538d9716d98a9101b22991273a1"/><file name="LocawebGatewayPayment.php" hash="d32dcca070b9e47dd7395f4d91a6456d"/><file name="LocawebGatewayProcessor.php" hash="5af81c01ce4829dda6c9fd2e4cb12f0a"/><file name="LocawebGatewayRequest.php" hash="75a8a17a65e539c9d230ef8c3741fb3b"/><file name="SimpleRestClient.php" hash="906af2d14a9cdf9e68dfc1499977b0ba"/><file name=".DS_Store" hash="fe95c3663a0bce608c3a05050f085fce"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="abstract"><dir name="form"><file name="cc.phtml" hash="99927cd67e61e69abe0d421e6c010882"/></dir></dir></dir></dir></dir></dir></target></contents>
34
  <compatible/>
35
- <dependencies><required><php><min>5.3.3</min><max>5.3.3</max></php></required></dependencies>
36
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Locaweb_Gateway</name>
4
+ <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
14
  * Redecard Web Service&#xD;
15
  &#xD;
16
  Al&#xE9;m destes, estamos buscando colaboradores para desenvolver os seguintes meios de pagamento:&#xD;
17
+ * Boletos (Bradesco, Ita&#xFA;, Banco do Brasil, Santander, HSBC e Caixa)&#xD;
18
  * Ita&#xFA; Shopline&#xD;
19
  * Redecard Komerci Integrado&#xD;
20
  * Cielo Buy Page Cielo&#xD;
21
  * Cielo Buy Page Loja (com autentica&#xE7;&#xE3;o)&#xD;
22
  &#xD;
23
  Se voc&#xEA; estiver interessado em colaborar com o desenvolvimento da extension, o reposit&#xF3;rio est&#xE1; dispon&#xED;vel no Github, na seguinte url: https://github.com/locaweb/gateway_magento.</description>
24
+ <notes>O Gateway de Pagamento da Locaweb &#xE9; um facilitador, que permite a contrata&#xE7;&#xE3;o e a integra&#xE7;&#xE3;o de diversos meios de pagamento em qualquer tipo de loja online.&#xD;
 
 
25
  &#xD;
26
+ Atualmente, temos dois meios de pagamento dispon&#xED;veis na extension do Magento:&#xD;
27
  * Cielo Buy Page Loja (sem autentica&#xE7;&#xE3;o)&#xD;
28
+ * Redecard Web Service&#xD;
29
+ &#xD;
30
+ Al&#xE9;m destes, estamos buscando colaboradores para desenvolver os seguintes meios de pagamento:&#xD;
31
+ * Boletos (Bradesco, Ita&#xFA;, Banco do Brasil, Santander, HSBC e Caixa)&#xD;
32
+ * Ita&#xFA; Shopline&#xD;
33
+ * Redecard Komerci Integrado&#xD;
34
+ * Cielo Buy Page Cielo&#xD;
35
+ * Cielo Buy Page Loja (com autentica&#xE7;&#xE3;o)&#xD;
36
+ &#xD;
37
+ Se voc&#xEA; estiver interessado em colaborar com o desenvolvimento da extension, o reposit&#xF3;rio est&#xE1; dispon&#xED;vel no Github, na seguinte url: https://github.com/locaweb/gateway_magento.</notes>
38
  <authors><author><name>Locaweb</name><user>locaweb</user><email>saas-dev@locaweb.com.br</email></author></authors>
39
  <date>2012-10-19</date>
40
+ <time>17:17:02</time>
41
+ <contents><target name="magecommunity"><dir name="Locaweb"><dir name="Abstract"><dir name="Config"><file name="Cctype.php" hash="bfc9fd031cf7357fb426cf8b8aff15bf"/><file name="Parceltype.php" hash="d0cd2f5dd62c44b8617f5a3389053f6b"/></dir><dir name="Model"><dir name="Payment"><dir name="Method"><file name="Cc.php" hash="7caa7f717867a481e5e2d3096caf6379"/></dir></dir></dir></dir><dir name="CieloBuyLoja"><dir name="Block"><dir name="Form"><file name="Cc.php" hash="3e5849dc322c7078f8885e0ee6c297f2"/></dir></dir><dir name="Config"><file name="Cctype.php" hash="5ae06f93bb4aae2b574c1f4805baafe4"/></dir><dir name="Helper"><file name="Data.php" hash="ee1f59db5830572a72795453ae01a9ce"/></dir><dir name="Model"><file name="Transaction.php" hash="31419aacb716199344bb2f38a5c6e062"/></dir><dir name="etc"><file name="config.xml" hash="340618f85e07339b07407ecdbe9a1c7a"/><file name="system.xml" hash="9dd3909b96959b257eed078080c4258d"/></dir></dir><dir name="RedeCardWS"><dir name="Block"><dir name="Form"><file name="Cc.php" hash="bca9a9e131a6474c83c0db98938ce4fb"/></dir></dir><dir name="Config"><file name="Cctype.php" hash="22417a736b9d221f0cba98e5460c9aee"/></dir><dir name="Helper"><file name="Data.php" hash="71b47a6f927431a976e4ad7b7e6d8a83"/></dir><dir name="Model"><file name="Transaction.php" hash="054b2ea6b3fcc13088e88985115e01e6"/></dir><dir name="etc"><file name="config.xml" hash="a40004df4b7fd042e583ec6267a7db55"/><file name="system.xml" hash="8c1c3c9b468645474947160d007075cb"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="abstract"><dir name="form"><file name="cc.phtml" hash="99927cd67e61e69abe0d421e6c010882"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Locaweb_CieloBuyLoja.xml" hash="5c81993759047a9829b3b78424bf59a4"/><file name="Locaweb_RedecardWS.xml" hash="225d101fca4c4fa09ea3f3a3d4895cae"/></dir></target><target name="magelocale"><dir name="pt_BR"><file name="Locaweb_Gateway.csv" hash="acefe4130e9aee0a18d1945be634043f"/></dir></target><target name="magelib"><dir name="."><file name="LocawebGateway" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></target></contents>
42
  <compatible/>
43
+ <dependencies><required><php><min>5.3.0</min><max>5.4.0</max></php></required></dependencies>
44
  </package>