刚刚开始这个项目。客户端应用程序是 Braintree 演示应用程序。我将其修改为指向在本地主机上运行的服务器
这就是我正在做的事情。
ios 应用向服务器发出请求以获取 token
服务器使用下面的方法从 Braintree 获取 token 并发回服务器
BraintreeGateway 网关 = new BraintreeGateway( 环境.SANDBOX, 商户账户ID, “…………”, “…………” ); 字符串 token = gateway.clientToken().generate();//Braintree 确实返回了一个 token
ios 演示应用程序使用嵌入式 View 创建随机数
ios 演示应用将随机数发送到服务器
//nonce 发送到服务器 71a89c9d-6ca7-4804-a895-b0e7564425c6
服务器使用以下代码调用 Braintree API
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;
最后一步从 Braintree 获得 403 com.braintreegateway.exceptions.AuthorizationException 异常。错误流中的 xml 未经授权。来自 Braintree 的输入流显示“服务器返回 HTTP 响应代码:403,URL:https://api.sandbox.braintreegateway.com:443/merchants/vb38crtnzn77b9ys/transactions”
感谢您的帮助
最佳答案
原来有两个ID。一个是merchantId,另一个是merchantAccountId。服务器将商户 ID 发送回客户端。稍后进行收费时,请使用merchantAccountId。
关于Braintree ios + java 事务 API 返回 403,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27436958/