大家好,我正在尝试与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,因此我知道基本URL很好,只是当我发送随机数时,我在尝试进行交易时收到404 not found错误。
如果您需要更多信息,我们将很乐意为您提供帮助。
编辑:我还收到以下错误:商家帐户未列入白名单,我也不知道是否与此有关。
edit2 我无法使用符号化密钥弄错了client_token
答案 0 :(得分:6)
全部披露:我在Braintree工作。如果您还有其他疑问,请随时与support联系。另外,我还没有声誉,可以将其作为评论而不是答案。就是说,这应该为您指明正确的方向。
通常,当找不到您要操作的记录时,我们返回一个404 - Not Found Error。例如,如果您尝试传递客户而客户ID无效。当您尝试在制作customer create call之前或将客户存储在Vault中之前,尝试将客户ID传递到客户令牌中时,通常会出现这种情况。也就是说,请随时与我们的support team联系,我们很乐意深入研究服务器日志并找到问题的根源。
关于您的列入白名单的商家帐户的问题,我们不需要以任何方式将商家帐户列入白名单,并且在Braintree方面没有任何错误消息表明应将商家帐户列入白名单。也就是说,您应确保要传递给客户令牌的商户帐户存在于网关中。您可以通过导航至帐户>商家帐户信息>向下滚动到“商家帐户”部分来检查商家帐户的名称。如果仍然遇到问题,您介意将完整的错误消息日志与merchant ID一起发送到我们的support team吗?我们不建议在公共论坛上共享这种类型的帐户信息,但是如果需要,我们非常乐意帮助进一步解决问题。