【问题标题】:Braintree transaction status android, how to check if declined?Braintree交易状态android,如何检查是否被拒绝?
【发布时间】:2015-09-12 23:16:03
【问题描述】:

我试图弄清楚如何使用 Braintree 支付网关在我的 Android 应用中检查交易状态。

我已经阅读了他们的文档,如果资金不足,会有类似 2001 的拒绝代码。但这仅指服务器端,我已将其实现为:

...
$nonce = $_POST["payment_method_nonce"];
$amount = $_POST["amount"];

$result = Braintree_Transaction::sale(array(
  'amount' => $amount,
  'paymentMethodNonce' => $nonce
));


if ($result->success) {
    echo("Success! Transaction ID: " . $result->transaction->id);
} else if ($result->transaction->status) {
    echo("Error: " . $result->message);
    echo("<br/>");
    echo("Code: " . $result->transaction->processorResponseCode);
} 

...

但是当我检查付款随机数时,没有办法取回响应,我已经尝试通过读取标题,但我从回显的内容中一无所获:

安卓实现:

void postNonceToServer(String nonce) {

        //set a boolean to veryfy transaction status, then send files in onResume (error if trying in onActivityResult)
        transactionDone = true;

        AsyncHttpClient client = new AsyncHttpClient();
        RequestParams params = new RequestParams();
        params.put("payment_method_nonce", nonce);
        params.put("amount", total);
        client.post("http://edmondvarga.com/laborator/brt_server/payment-methods.php", params,
                new AsyncHttpResponseHandler() {
                    @Override
                    public void onSuccess(int i, Header[] headers, byte[] bytes) {

                        HashMap<String, String> result = new HashMap<String, String>(headers.length);
                        for (Header header : headers) {
                            result.put(header.getName(), header.getValue());
                            Log.i("header", "name/value: " + header.getName() + " " + header.getValue() + " or " + header.getName().toString() + " " + header.getValue().toString());
                        }


                    }

                    @Override
                    public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
                        Log.i("Nonce", "sending nonce failed!");
                    }

                }
        );
    }

那么在为客户提供服务之前,我如何验证交易状态?

【问题讨论】:

    标签: android http response payment-gateway braintree


    【解决方案1】:

    我是 Braintree 的一名开发人员。通常,nonce 不会包含处理器验证信息,因为在您尝试使用 nonce(通过您的服务器端调用)创建事务之前,这些验证不会运行。

    如果您使用我们的嵌入式集成,您可以选择在enabling verifications in the control panel 创建随机数之前运行这些验证。在这种情况下,只有验证通过,nonce 创建才会成功。

    【讨论】:

      【解决方案2】:

      PaymentMetodNonce 是您从客户端处理事务时的随机整数。您需要一个 Braintree 令牌来进行交易。您需要创建 customer_id。使用 customer_id 和 paymentmethodnonce 您可以生成braintree token。按照这个链接: Correct way to link PayPal Accounts to vault with Braintree DropUI

      【讨论】:

        猜你喜欢
        • 2018-09-21
        • 1970-01-01
        • 2015-07-31
        • 1970-01-01
        • 2014-12-31
        • 2020-07-30
        • 2015-11-04
        • 2020-11-21
        • 2014-09-03
        相关资源
        最近更新 更多