Reputation: 127
I'm really stuck with this problem so it would be greatly appreciated if someone could help me.
After I enter amount to pay, choose the way to pay (some credit card for Test from BraintreeDevelopments ) IT FAILS!
Notice: Undefined index: nonce in C:\xampp\htdocs\braintree\checkout.php on line 5
Notice: Undefined index: amount in C:\xampp\htdocs\braintree\checkout.php on line 6
Braintree\Result\Error[errors=[Braintree\Error\ValidationErrorCollection/errors:[( )]], params=transaction=type=sale, amount=, paymentMethodNonce=, options=submitForSettlement=true, message=Amount is required. Cannot determine payment method., creditCardVerification=, transaction=, subscription=, merchantAccount=, verification=]
And this is my 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
?>
But there are nonce and amount in line 5 and 6 -.- i dont understand why -.-
Upvotes: 1
Views: 1055
Reputation: 11
I had the same problem, and the issue was that in the getHeaders()
function, I was putting the wrong params so I wrote it wrong.
I got:
params.put("Content-Type", "application/x-www-form-**urleooded**");
instead of
params.put("Content-Type", "application/x-www-form-**urlencoded**");
Upvotes: 1