Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Braintree Sandbox Testing (fake nonces)

I am testing the Braintree sandbox (PHP) and even though I am using a fake-nonce, the transactions still show goes through valid

I have a dropin frontend and a PHP Backend

My backend code for testing looks like below:

$amount = '12.00';
$nonce = 'fake-processor-declined-visa-nonce';
$result = Braintree_Transaction::sale(['amount' => $amount, 
                                       'paymentMethodNonce' => $nonce, 
                                       'options' => ['submitForSettlement' => true]
                                      ]);
$debug = get_object_vars($result);
print_r($debug);

outcome

Array
(
    [success] => 1
    [transaction] => Braintree\Transaction Object
        (
            [_attributes:protected] => Array
                (
                    [id] => 9bnyb32r
                    [status] => submitted_for_settlement
                    [type] => sale
                    [currencyIsoCode] => EUR
                    [amount] => 12.00
                    [merchantAccountId] => somenamehere
                    [subMerchantAccountId] => 
                    [masterMerchantAccountId] => 
                    [orderId] => 
                    [createdAt] => DateTime Object

I assued the fake nouces are there for testing error outcome in the sandbox...or am I missing something

https://developers.braintreepayments.com/reference/general/testing/php#test-amounts

like image 955
fredmarks Avatar asked Dec 19 '22 15:12

fredmarks


2 Answers

Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.

Invalid nonces trigger an unsuccessful card verification response, but do not cause transactions to fail. In order to simulate an unsuccessful transaction, adjust the amount of the transaction instead.

like image 63
Dana K. Avatar answered Dec 21 '22 04:12

Dana K.


Trying to test some similar things in PHP, I found some helpful, well-named test nonces in \Braintree\Test\Nonces in the PHP Braintree library. I was able to use fake-valid-visa-nonce to do the testing I needed to create a new payment method.

like image 23
Dave Lyon Avatar answered Dec 21 '22 05:12

Dave Lyon