【问题标题】:404 not found error when trying to create a transaction BrainTree尝试创建交易 BrainTree 时出现 404 not found 错误
【发布时间】:2019-08-02 07:54:47
【问题描述】:

大家好,我正在尝试与 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 很好,只是当我发送 nonce 时,我在尝试进行交易时收到 404 not found 错误。

感谢您抽出宝贵时间,如果您需要更多信息,我很乐意提供。

编辑:我还收到商家帐户未列入白名单的错误,我不知道这是否与此有关。

edit2我无法获取client_token或者我使用令牌化密钥弄错了

【问题讨论】:

    标签: android heroku braintree braintree-rails


    【解决方案1】:

    全面披露:我在 Braintree 工作。如果您还有任何问题,请随时联系support。此外,我还没有将其作为评论而不是答案留下的声誉。也就是说,这应该为您指明正确的方向。

    通常,当找不到您尝试操作的记录时,我们会返回 404 - Not Found Error。例如,如果您尝试传递客户并且客户 ID 无效。当您在创建customer create call 之前或将客户存储在 Vault 中之前尝试将客户 ID 传递到客户令牌时,通常会出现这种情况。也就是说,请随时联系我们的support team,我们很乐意深入研究我们的服务器日志并找到问题的根源。

    关于您关于列入白名单的商家帐户的问题,我们不以任何方式要求将商家帐户列入白名单,并且在 Braintree 方面没有任何错误消息表明应将商家帐户列入白名单。也就是说,您应该确保您传递给客户端令牌的商家帐户存在于您的网关中。您可以通过导航到帐户 > 商家帐户信息 > 向下滚动到商家帐户部分来检查您的商家帐户的名称。如果您仍然遇到问题,您是否介意将完整的错误消息日志连同您的merchant ID 发送到我们的support team?我们不建议在公共论坛上共享此类帐户信息,但如果需要,我们非常乐意帮助您进一步排除故障。

    【讨论】:

    • 我正在使用 Android 演示应用程序。所以我必须先创建一个客户?我想也许只是替换 URL 和标记化密钥
    • 使用标记化密钥时,您只能标记化支付信息。您不得指定客户 ID、设置特定商家帐户 ID 或以其他方式提供任何配置。标记化密钥既是静态又是减少特权。你可以找到更多关于client authorization in our developer documentation的信息。
    • 即使我使用令牌化密钥将 nonce 发送到服务器,在使用 ui 中的 drop 并使用测试信用卡值后失败并出现 404。我到底需要做什么才能使用 android 演示应用程序
    • 嘿@JRowan。我认为您最好使用您的商家 ID 提交 support ticket,以便我们查看我们的服务器日志以解决此问题。我们的支持范围非常有限,而无需查看您帐户的具体信息以及您在何处遇到此 404。
    猜你喜欢
    • 2017-10-19
    • 2012-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-27
    • 2021-06-16
    相关资源
    最近更新 更多