I'm using the braintree API and I'm able to put dropin form of them on page:
var braintreeToken = @Html.Raw(Json.Encode(Model.brainTreeToken));
braintree.setup(
braintreeToken,
"dropin", {
container: "payment-form"
});
...
Here's the result:
Intheirdocumentationitsaysbraintree.jswilladdahiddeninputnamedpayment_method_noncetoyourform
,thatis,ahiddenfieldisaddedwiththenoncevalue.
Inmycontroller,IgetthisfieldintheFormCollectionbutitalwayscomesasanemptystring.Itdoesnotcomenull,itcomesempty.
[HttpPost]publicvoidCreateTransaction(FormCollectioncollection){stringpayment_method_nonce=collection["payment_method_nonce"];
The above string is always empty. Supposedly, it would fetch a nonce string to be able to do the transaction. How do I resolve this?
EDIT
The form I write in the view is:
<form id="createTransactionForm" method="post">
<div id="payment-form"></div>
<input type="submit" value="Test - Pay">
</form>
The id id="payment-form" will be populated with the braintree dropin.
Using the browser inspector you can see the HTML final result, which results in one form within another. I've wondered if this is correct, if the form I write is necessary, and yes, it is anyway.
The result: