ombulabs / mercadopago Goto Github PK
View Code? Open in Web Editor NEWGem to communicate with the MercadoPago API
Gem to communicate with the MercadoPago API
master
gem build
+ gem push
My mistake begins very early, mp_client = MercadoPago::Client.new(client_id, client_secret) i enter my clien_id and my client_secret but it's returned a 500 error.
PS: I'm working on a ruby on rails app.
Hi guys, I was wondering if your gem can be used in sandbox mode when I'm doing a GET request with my purchase ID to the IPN system.
Because when I'm excuting mp.notification(@payment_id), I get {"message"=>"Resource XXXXXXX not found", "error"=>"not_found", "status"=>404, "cause"=>[]} as response, but when I do the request manually pointing to https://api.mercadolibre.com/sandbox/collections/notifications/XXXXXXX' everything works as expected. (notice the /sandbox/)
Thanks!
I haven't been able to log in for the last couple of days.
It seems the problem is that refresh_token is taken as mandatory, but oauth is not returning it (copied the responde below).
Are you aware of the problem? Planning to solve it?
{"access_token":"XXXX","live_mode":true,"user_id":xxxxx,"token_type":"bearer","expires_in":21600,"scope":"offline_access payments read write"}%
Hi, I'm implementing the API using PHP and modal
mode. I want to know if this is the right way to redirect the page to back_url
after making the payment.
JavaScript onreturn:
<script type="text/javascript">
function checkoutReturn(json){
if( json.back_url != null && json.collection_id != null ){
var url = json.back_url + '?id='+json.collection_id
window.top.location = url;
console.log('collection_id: '+json.collection_id);
console.log('preference_id: '+json.preference_id);
}
else{
console.log('Ventana de mercado pago cerrada');
}
}
</script>
HTML:
<a href="https://www.mercadopago.com/checkout/pay?pref_id=<?php echo $d['identificador_de_la_preferencia']; ?>" name="MP-Checkout" class="btn btn_pagar_con_opcion" mp-mode="modal" onreturn="checkoutReturn"> </a>
PHP
$mp = new MP("XXXXX", "XXXXX");
$productos = array();
$redireccionamientos = new stdClass();
$redireccionamientos->success = "https://www.mysite.com/caja/terminar/MercadoPagoSuccess.php";
$redireccionamientos->failure = "https://www.mysite.com/caja/terminar/MercadoPagoFailure.php";
$redireccionamientos->pending = "https://www.mysite.com/caja/terminar/MercadoPagoPending.php";
foreach( $_SESSION['carrito']['productos'] as $producto ){
$producto_datos = Modelos_Productos::obtenerProducto(SISTEMA_TIENDA_PAIS, SISTEMA_ID_TIENDA, $producto['id']);
$fila = new stdClass();
$fila->id = $producto['id'];
$fila->title = $producto['nombre'];
if( !empty( $producto_datos['descripcion'] ) ){
$fila->description = util_eliminar_html(util_preparar_var($producto_datos['descripcion'],'html_limpio'));
}
$fila->quantity = $producto['cantidad'];
$fila->unit_price = 5; //$producto['precio_venta'];
$fila->currency_id = "MXN";
//$fila->picture_url = "http://imgs.cdn.com/?tp=p&id=".$producto['id']."&t=340x260";
array_push($productos, $fila);
}
$player = new stdClass();
$player->name = $_SESSION['cliente']['nombre'];
$player->surname = $_SESSION['cliente']['nombre_completo'];
$player->email = $_SESSION['cliente']['email'];
$exclusiones_tipos_pago = array();
$payment_methods = new stdClass();
//array_push( $exclusiones_tipos_pago, array("id"=>"debit_card") );
//array_push( $exclusiones_tipos_pago, array("id"=>"credit_card") );
array_push( $exclusiones_tipos_pago, array("id"=>"ticket") );
array_push( $exclusiones_tipos_pago, array("id"=>"atm") );
$payment_methods->excluded_payment_types = $exclusiones_tipos_pago;
$datos = array (
"items" => $productos,
"payer"=> $player,
"payment_methods" => $payment_methods
);
$resultado = $mp->create_preference($datos);
What chance do we have to update the JSON gem? Since it presents a security problem.
Name: json
Version: 1.8.6
CVE: CVE-2020-10663
GHSA: GHSA-jphg-qwrw-7w9g
Criticality: High
URL: https://www.ruby-lang.org/en/news/2020/03/19/json-dos-cve-2020-10663/
Title: json Gem for Ruby Unsafe Object Creation Vulnerability (additional fix)
Solution: upgrade to '>= 2.3.0'
We should add versions to the gems in the gemspec
file:
WARNING: open-ended dependency on json (>= 1.4.6) is not recommended
if json is semantically versioned, use:
add_runtime_dependency 'json', '~> 1.4', '>= 1.4.6'
WARNING: open-ended dependency on faraday (>= 0.9.0) is not recommended
if faraday is semantically versioned, use:
add_runtime_dependency 'faraday', '~> 0.9', '>= 0.9.0'
WARNING: open-ended dependency on pry (>= 0, development) is not recommended
if pry is semantically versioned, use:
add_development_dependency 'pry', '~> 0'
WARNING: open-ended dependency on rake (>= 0, development) is not recommended
if rake is semantically versioned, use:
add_development_dependency 'rake', '~> 0'
WARNING: open-ended dependency on byebug (>= 0, development) is not recommended
if byebug is semantically versioned, use:
add_development_dependency 'byebug', '~> 0'
WARNING: open-ended dependency on test-unit (>= 0, development) is not recommended
if test-unit is semantically versioned, use:
add_development_dependency 'test-unit', '~> 0'
WARNING: open-ended dependency on vcr (>= 0, development) is not recommended
if vcr is semantically versioned, use:
add_development_dependency 'vcr', '~> 0'
WARNING: open-ended dependency on webmock (>= 0, development) is not recommended
if webmock is semantically versioned, use:
add_development_dependency 'webmock', '~> 0'
client_id = xxxxxx
client_secret = xxxxxxx
mp_client = MercadoPago::Client.new(client_id, client_secret)
NoMethodError: undefined method `response' for #<Errno::ECONNRESET: Connection reset by peer - SSL_connect>
I've tried with the following versions:
ruby-1.9.3-p448
ruby-2.0.0-p247
Also cloned the repo and all tests fail on those versions.
I've tried on a STAGING server and didn't had that problem.
Hi,
Just ran the test suite and the following cases failed:
test_that_authentication_fails_with_wrong_parameters
test_that_request_fails_with_wrong_token
test_that_refresh_token_works
It seems that the MercadoPago API error handling has changed. For example, on the access token refresh test, the API now responds with a 400, saying that the user "has not grant for application" (which is kind of weird).
Should I update the tests to reflect these new error responses?
Thanks.
I was requesting a collection of payments and didn't realize there were more payments that I could fetch via pagination params (limit and offset).
Similar to what https://github.com/octokit/octokit.rb#pagination provides, we could have an auto_paginate
attribute on either the MercadoPago
module or the MercadoPago::Collection
class which auto paginates the results and returns all of them instead of providing a response with pagination attributes.
We should make sure that the tests use recorded responses from Mercado Pago.
I have no idea how to use the gem :s, where must I have to put this code???
client_id = '1234'
client_secret = 'abcdefghijklmnopqrstuvwxyz'
mp_client = MercadoPago::Client.new(client_id, client_secret)
And how can I send the Post request?
We changed the behavior of the search method in PR #43 to allow to paginate the results, but we realized that this module isn't efficient.
To solve this issue would be great if we turn the module into a Enumerable that can lazily load all the records.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.