大家好我试图与Braintree进行交易,我正在使用Heroku rails服务器。我无法获得client_token,当我尝试进行交易时,我找不到404。我正在使用GitHub上的存储库中的演示应用程序。这是演示应用程序的相关代码。
import com.braintreepayments.demo.models.ClientToken;
import com.braintreepayments.demo.models.Transaction;
import retrofit.Callback;
import retrofit.http.Field;
import retrofit.http.FormUrlEncoded;
import retrofit.http.GET;
import retrofit.http.POST;
import retrofit.http.Query;
public interface ApiClient {
@GET("/client_token")
void getClientToken(@Query("customer_id") String customerId, @Query("merchant_account_id") String merchantAccountId, Callback<ClientToken> callback);
@FormUrlEncoded
@POST("/nonce/transaction")
void createTransaction(@Field("nonce") String nonce, Callback<Transaction> callback);
@FormUrlEncoded
@POST("/nonce/transaction")
//@POST("/checkout")
void createTransaction(@Field("nonce") String nonce, @Field("merchant_account_id") String merchantAccountId, Callback<Transaction> callback);
@FormUrlEncoded
@POST("/nonce/transaction")
void createTransaction(@Field("nonce") String nonce, @Field("merchant_account_id") String merchantAccountId, @Field("three_d_secure_required") boolean requireThreeDSecure, Callback<Transaction> callback);
}
并在交易活动中
private void sendNonceToServer(PaymentMethodNonce nonce) {
Callback<Transaction> callback = new Callback<Transaction>() {
@Override
public void success(Transaction transaction, Response response) {
if (transaction.getMessage() != null &&
transaction.getMessage().startsWith("created")) {
setStatus(R.string.transaction_complete);
setMessage(transaction.getMessage());
} else {
setStatus(R.string.transaction_failed);
if (TextUtils.isEmpty(transaction.getMessage())) {
setMessage("Server response was empty or malformed");
} else {
setMessage(transaction.getMessage());
}
}
}
@Override
public void failure(RetrofitError error) {
Log.d("error",error.getResponse().getReason());
setStatus(R.string.transaction_failed);
setMessage("Unable to create a transaction. Response Code: " +
error.getResponse().getStatus() + " Response body: " +
error.getResponse().getBody());
}
};
if (Settings.isThreeDSecureEnabled(this) && Settings.isThreeDSecureRequired(this)) {
DemoApplication.getApiClient(this).createTransaction(nonce.getNonce(),
Settings.getThreeDSecureMerchantAccountId(this), true, callback);
} else if (Settings.isThreeDSecureEnabled(this)) {
DemoApplication.getApiClient(this).createTransaction(nonce.getNonce(),
Settings.getThreeDSecureMerchantAccountId(this), callback);
} else if (nonce instanceof CardNonce && ((CardNonce) nonce).getCardType().equals("UnionPay")) {
DemoApplication.getApiClient(this).createTransaction(nonce.getNonce(),
Settings.getUnionPayMerchantAccountId(this), callback);
} else {
DemoApplication.getApiClient(this).createTransaction(nonce.getNonce(), Settings.getMerchantAccountId(this),
callback);
}
}
就像我说我得到client_token就好了所以我知道基本网址很好只是当我发送nonce时我在尝试进行交易时遇到404找不到错误。
感谢您的时间,如果您需要我将乐意提供的更多信息。
编辑:我也得到商家帐户未列入白名单的错误,我不知道这是否与它有关。
edit2我无法得到client_token或者我使用了标记化密钥
完全披露:我在Braintree工作。如果您有任何其他问题,请随时联系support。此外,我还没有声誉将此作为评论而不是答案。也就是说,这应该指向正确的方向。
通常情况下,当您尝试操作的记录无法找到时,我们会返回404 - Not Found Error。例如,如果您尝试传入客户并且客户ID无效。当您在customer create call制作之前或客户存储在Vault中之前尝试将客户ID传递到客户端令牌时,通常会出现这种情况。也就是说,请随时联系我们的support team,我们很乐意深入了解我们的服务器日志并找到问题的根源。
关于您列入白名单的商家帐户的问题,我们不要求以任何方式对商家帐户进行任何白名单,并且没有任何错误消息表明商家帐户应该在Braintree一侧列入白名单。也就是说,您应该确保您传递到客户端令牌的商家帐户存在于您的网关中。您可以导航到帐户>商家帐户信息>向下滚动到商家帐户部分,以查看商家帐户的名称。如果您仍然遇到问题,您是否介意将完整错误消息的日志与merchant ID一起发送到我们的support team?我们不建议在公共论坛上共享此类帐户信息,但如果需要,我们非常乐意帮助您进一步排查问题。