Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug de precisión cuando se usa json_encode #49

Open
gonzalesc opened this issue Jun 13, 2020 · 0 comments
Open

Bug de precisión cuando se usa json_encode #49

gonzalesc opened this issue Jun 13, 2020 · 0 comments

Comments

@gonzalesc
Copy link

gonzalesc commented Jun 13, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant