0

我正在为 Poynt POS 系统开发一个应用程序,我正在尝试集成自定义支付,如他们在此处找到的示例中所示

在该示例的 PaymentActivity.java 中,有一些代码在收集付款时创建一个意图,向其中添加一些额外的数据,然后发送它:

@Override
public void onFragmentInteraction(Transaction transaction, PoyntError error) {
    // Create intent to deliver some kind of result data
    Intent result = new Intent(Intents.ACTION_COLLECT_PAYMENT_RESULT);
    result.putExtra("transaction", transaction);
    result.putExtra("error", error);
    result.putExtra("test", true);
    if (error == null) {
        setResult(Activity.RESULT_OK, result);
    }else{
        setResult(Activity.RESULT_CANCELED, result);
    }
    finish();
}

回到启动 Poynt Payment Fragment 的活动中,有一个活动结果处理程序。此处理程序接受一个意图作为参数,但似乎此意图与在 PaymentActivity 中创建的意图不同:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == Activity.RESULT_OK) {
        if (data != null) {
            Payment payment = data.getParcelableExtra(Intents.INTENT_EXTRAS_PAYMENT);
            Log.d("ConfigurationTest", "Received onPaymentAction from PaymentFragment w/ Status:" + payment.getStatus());

            if (payment.getTransactions() != null && payment.getTransactions().size() > 0) {
                Transaction transaction = payment.getTransactions().get(0);
                Gson gson = new GsonBuilder().setPrettyPrinting().create();
                Type transactionType = new TypeToken<Transaction>() {
                }.getType();
                //logReceivedMessage(gson.toJson(transaction, transactionType));
            }
        }
    }

    Boolean test = data.getBooleanExtra("test", false);
    Log.d("Sample", test.toString());   // this value will be false
}

data 参数没有test额外的字段。它也没有,也transaction没有error。知道这是为什么吗?

4

0 回答 0