gpt4 book ai didi

android - Braintree交易状态android,如何检查是否被拒绝?

转载 作者:可可西里 更新时间:2023-11-01 17:36:08 26 4
gpt4 key购买 nike

我尝试弄清楚如何使用 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);
}

...

但是当我检查付款随机数时,没有办法取回响应,我尝试通过阅读 header ,但是我从回显中什么也得不到:

安卓实现:

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

}
);
}

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

最佳答案

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

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

关于android - Braintree交易状态android,如何检查是否被拒绝?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31065756/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com