Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

Android: Fix return of card scan results successfully #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions src/android/CardIOCordovaPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
Expand Down