culqi-php
culqi-php copied to clipboard
Bug de precisión cuando se usa json_encode
Hola. Los invito a leer este bug : https://bugs.php.net/bug.php?id=72567
Y aunque la solución es corregir el parámetro serialize_precision en el php.ini , podemos cambiar el campo "amount" a string.
Modificando lib/Culqi/Client.php
` namespace Culqi; use Culqi\Error as Errors;
/**
-
Class Client
-
@package Culqi */ class Client { public function request($method, $url, $api_key, $data = NULL, $secure_url = false) { try { $url_params = is_array($data) ? '?' . http_build_query($data) : ''; $headers= array("Authorization" => "Bearer ".$api_key, "Content-Type" => "application/json", "Accept" => "application/json"); $options = array( 'timeout' => 120 );
// TODO: We change to string to avoid the precision bug on PHP 7.1 // URL : https://bugs.php.net/bug.php?id=72567 if( is_array( $data ) && isset( $data['amount'] ) ) $data['amount'] = strval( $data['amount'] );
........ } `
PD: si alguien lanza el pullrequest sería de gran ayuda.