From 8db77518fa70371f16d34a6bbed0fbdf8c2c59a5 Mon Sep 17 00:00:00 2001 From: SheAA Date: Mon, 17 Sep 2018 15:00:40 +0300 Subject: [PATCH] Android: Fix return of card scan results successfully --- src/android/CardIOCordovaPlugin.java | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/android/CardIOCordovaPlugin.java b/src/android/CardIOCordovaPlugin.java index 0623f42..02fce3f 100644 --- a/src/android/CardIOCordovaPlugin.java +++ b/src/android/CardIOCordovaPlugin.java @@ -87,22 +87,19 @@ private void canScan(JSONArray args) throws JSONException { } // onActivityResult + @Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { + super.onActivityResult(requestCode, resultCode, intent); if (REQUEST_CARD_SCAN == requestCode) { - if (resultCode == CardIOActivity.RESULT_CARD_INFO) { - CreditCard scanResult = null; - if (intent.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT)) { - scanResult = intent - .getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT); - this.callbackContext.success(this.toJSONObject(scanResult)); - } else { - this.callbackContext - .error("card was scanned but no result"); - } - } else if (resultCode == Activity.RESULT_CANCELED) { + if (resultCode == Activity.RESULT_CANCELED) { this.callbackContext.error("card scan cancelled"); + return; + } + if (intent.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT)) { + CreditCard scanResult = intent.getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT); + this.callbackContext.success(this.toJSONObject(scanResult)); } else { - this.callbackContext.error(resultCode); + this.callbackContext.error("card was scanned but no result"); } } }