404 not found error when trying to create a transaction BrainTree

1k Views Asked by At

hello everyone I am trying to make a transaction with Braintree and I am using the Heroku rails server. I cannot get the client_token and when I try to make the transaction I get 404 not found. I am using the demo app from the repository on GitHub. this is the relevant code from the demo app.

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);
}

and in the transaction activity

 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);
        }
    }

like I said I get the client_token just fine so I know the base url is fine its just that when I sent the nonce I get a 404 not found error while trying to make a transaction.

thank you for your time if you need any more information I will be happy to provide.

edit: I also get the error that merchant account is not whitelisted and I have no idea if that has something to do with it.

edit2 I couldn't get the client_token either I was mistaken by using the tokenization key

1

There are 1 best solutions below

4
On

Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support. Additionally, I do not have the reputation yet to leave this as a comment instead of an answer. That said, this should point you in the right direction.

Typically, we return a 404 - Not Found Error when the record that you're trying to operate on can't be found. For example, if you try to pass in a customer and the customer ID isn't valid. This often manifests when you are attempting to pass a customer ID into the client token before the customer create call has been made or before the customer has been stored in the Vault. That said, please feel free to reach out to our support team and we would be happy to dig into our server logs and get to the root of the issue.

Regarding your issue about the whitelisted merchant accounts, we do not require any whitelisting of merchant accounts, in any way, and do not have any error messages that indicate that a merchant account should be whitelisted, on the Braintree side. That said, you should ensure that the merchant account you are passing into the client token exists in your gateway. You can check the name of your merchant accounts by navigating to Account > Merchant Account Info > Scroll down to the Merchant Account section. If you are still running into issues would you mind sending a log of the full error message along with your merchant ID to our support team? We do not recommend sharing this type of account information over public forums, but would be more than happy to help troubleshoot further, if needed.