0

I want to get nonce from server. i wrote backend in PHP that will giving token. after receiving token PaymentMethodNonce returning null.

I want to get nonce from server.

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == REQUEST_CODE) {
            if (resultCode == RESULT_OK) {
                DropInResult result = data.getParcelableExtra(DropInResult.EXTRA_DROP_IN_RESULT);
                PaymentMethodNonce nonce = result.getPaymentMethodNonce();
                String stringNonce = nonce.getNonce();
                Log.d("mylog", "Result: " + stringNonce);
                // Send payment price with the nonce
                // use the result to update your UI and send the payment method nonce to your server
                    paramHash = new HashMap<>();
                    paramHash.put("couponPrice", couponPrice);
                    paramHash.put("nonce", stringNonce);
                sendPaymentDetails();

            } else if (resultCode == Activity.RESULT_CANCELED) {
                // the user canceled
                Log.d("mylog", "user canceled");
            } else {
                // handle errors here, an exception may be available in
                Exception error = (Exception) data.getSerializableExtra(DropInActivity.EXTRA_ERROR);
                Log.d("mylog", "Error : " + error.toString());
            }
        }
    }

DropInResultobject is result. That is returning null but that should be some valid information

  • Confirm you started the intent with **startActivityForResult** and not **startActivity** and also check this [post](https://stackoverflow.com/questions/10407159/how-to-manage-startactivityforresult-on-android) – Giddy Naya Jul 29 '19 at 10:12
  • its already startActivityForResult not startActivity – Saqib Javaid Jul 29 '19 at 10:31

1 Answers1

0

Here's the answer:

val result = intent.getParcelableExtra<DropInResult>(DropInResult.EXTRA_DROP_IN_RESULT)

return null
Unheilig
  • 16,196
  • 193
  • 68
  • 98
Mohamed ElNady
  • 304
  • 1
  • 2
  • 8