Reputation: 2011
Just started the project. The client side app is the Braintree demo app. I modified it to point to my server running on localhost
Here is what I'm doing.
ios app makes an request to server to get a token
server uses method below to get a token from Braintree and sends back to server
BraintreeGateway gateway = new BraintreeGateway( Environment.SANDBOX, merchantAccountId, ".........", "............." ); String token = gateway.clientToken().generate(); // Braintree did return a token
ios demo app creates a nonce with the drop-in view
ios demo app sends the nonce to the server
// nonce sends to server 71a89c9d-6ca7-4804-a895-b0e7564425c6
server calls Braintree API with code below
TransactionRequest request = new TransactionRequest()
.amount(new BigDecimal(19.0f))
.merchantAccountId(merchantAccountId)
.paymentMethodNonce(nonce)
.options()
.submitForSettlement(true)
.done()
.channel("MyShoppingCartProvider");
Result<Transaction> result = gateway.transaction().sale(request);
return result;
The last step got 403 com.braintreegateway.exceptions.AuthorizationException exception from Braintree. The xml from the error stream is Unauthorized. The input stream from Braintree says "Server returned HTTP response code: 403 for URL: https://api.sandbox.braintreegateway.com:443/merchants/vb38crtnzn77b9ys/transactions"
Thanks for the help
Upvotes: 2
Views: 1517
Reputation: 2011
It turns out that there are two IDs. One is merchantId and the other merchantAccountId. The server sends back the merchantId back to client. And later for charging, use merchantAccountId.
Upvotes: 4