简体   繁体   中英

CheckOut payment with Braintree failed

When I click checkout for payment, my order not send to the server (SQL). Here is my log:

Braintree\\Result\\Error[errors=[Braintree\\Error\\ValidationErrorCollection/errors:[( )]], params=transaction=type=sale, amount=4.4024E7, paymentMethodNonce=tokencc_bc_hxvh83_fkxpvx_9bg2mr_ny5prr_7n5, options=submitForSettlement=true, message=Amount is an invalid format., creditCardVerification=, transaction=, subscription=, merchantAccount=, verification=]

///file config php braintree here

//braintree_init
    braintree_init.php:
<?php
    session_start();
    require_once ("lib/autoload.php");

    if (file_exists(__DIR__ . "/../.env"))
    {

        $dotenv = new Dotenv\Dotenv(__DIR__ . "/../");
        $dotenv->load();
    }
    //add key value form braintree
    Braintree_Configuration::environment('sandbox');
    Braintree_Configuration::merchantId('33z8qvth85f5z6bs');
    Braintree_Configuration::publicKey('wh99mdq8ymvvkkms');
    Braintree_Configuration::privateKey('d65a6142e8e5123521143737e6a78601');
    ?>

//check out
    checkout.php:
    <?php
    require_once ("braintree_init.php");
    require_once ('lib/Braintree.php');

    $nonce = $_POST['nonce'];
    $amount = $_POST['amount'];

    $result = Braintree_Transaction::sale([
        'amount' => $amount,
        'paymentMethodNonce' => $nonce,
        'options' => [
            'submitForSettlement' => True
        ]
    ]);
    echo $result;
    ?>

//// file main check token 

    file main.php
    <?php
    require_once ("braintree_init.php");
    require_once ('lib/Braintree.php');

result send to order failed

Full disclosure, I work at Braintree. If you have any further questions, contact Support

The error message has message=Amount is an invalid format. included. You need to format the amount correctly. You're currently passing 4.4024E7 . You can find the guidelines for formatting values for parameters in Braintree's developer docs .

As an example, the transaction should be successful if you passed 4.40 as the amount value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM