doumi7854 2019-05-01 09:54
浏览 128
已采纳

使用Braintree的CheckOut付款失败

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
  • 写回答

1条回答 默认 最新

  • dphdh395195 2019-05-01 17:40
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?