I'm looking for the proper way to pass a payment amount to BrainTree.
Here's a link
<a href="/charge?amount=10">charge me $10</a>
Here's some php that can handle this link
Braintree_Transaction::sale(array(
'amount' => Input::get('amount'),
'paymentMethodToken' => Auth::user()->creditcard->token
));
This is obviously unsafe because the client can change the amount.
So you can have an item in the database and an amount attached to that
<a href="/charge?item=1">Charge for Item 1</a>
... And similar code to handle it
$item = Input::get('item');
$price = Product::find($item)->price;
Braintree_Transaction::sale(array(
'amount' => $price,
'paymentMethodToken' => Auth::user()->creditcard->token
));
The thing about this is that what if the client accidentaly puts ?item=45. I'm guessing this shouldn't be able to be manipulated by the client.
What's the right way to do this?