Tonespy
Tonespy

Reputation: 3387

Card.io not scanning credit card

I am trying to implement Card.io in my app, I followed the instructions on Card.io website and when I get into my app and I launch it, it locks in on my card, but after that nothing else happens. Below is my code

AndroidManifest

<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.CAMERA"/>

<--!..........................-->

<activity android:name="io.card.payment.CardIOActivity" android:configChanges="keyboardHidden|orientation" android:hardwareAccelerated="true"/>
<activity android:name="io.card.payment.DataEntryActivity" android:screenOrientation="portrait"/>

ActivityResult

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == MY_SCAN_REQUEST_CODE) {
        String cardNumbs, cardExp, cardCVV;
        String resultStr;

        if (data != null && data.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT)) {
            //TODO
            CreditCard scanResult = data.getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT);

            cardNumbs = scanResult.getRedactedCardNumber();
            acctDebitCardNo.setText(cardNumbs);
            if (scanResult.isExpiryValid()) {
                cardExp = scanResult.expiryMonth + "/" + "20" + scanResult.expiryYear;
                acctDebitCardExp.setText(cardExp);
            } else {
                acctDebitCardExp.setError("Card Has Expired");
            }
            if (scanResult.cvv != null) {
                cardCVV = scanResult.cvv;
                acctDebitCardCvv.setText(cardCVV);
            }
        }
    }
}

Permission To Launch Camera

Intent scanIntent = new Intent(getActivity(), CardIOActivity.class);

        // customize these values to suit our/there needs...LOL :).
        scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY, true);
        scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_CVV, true);
        scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_POSTAL_CODE, false); // default: false
        // hides the manual entry button
        // if set, developers should provide their own manual entry mechanism in the app
        scanIntent.putExtra(CardIOActivity.EXTRA_SUPPRESS_MANUAL_ENTRY, false); // default: false
        // matches the theme of your application
        scanIntent.putExtra(CardIOActivity.EXTRA_KEEP_APPLICATION_THEME, true);

        // MY_SCAN_REQUEST_CODE is arbitrary and is only used within this activity.
        startActivityForResult(scanIntent, MY_SCAN_REQUEST_CODE);

I don't know what I'm doing wrong

Upvotes: 2

Views: 1891

Answers (3)

Taslim Oseni
Taslim Oseni

Reputation: 6263

In my own case, the problem was that the card was not embossed (most Nigerian cards are not). Card.io and PayCards do not cater for embossed cards. If this scenario fits your case, you might need to build the scanner by yourself using Firebase MLKit. The whole process is less complex than it sounds. You can follow this guide to help you.

I hope this helps. Merry coding!

Upvotes: 2

Binod Singh
Binod Singh

Reputation: 712

Is the card number embossed? See card-io/card.io-iOS-SDK#20 for a description of why non-embossed cards are not supported.

Upvotes: 0

Jera Balais
Jera Balais

Reputation: 61

  1. First you have to change the file extension of card.io-5.0.1.aar(its inside aars folder) into a zip file.from this link
  2. Once you changed the file, extract it.
  3. After extracted, copy all the files inside the jni folder and paste it inside your project's libs folder.
  4. and voila!.. it should work now! :)

Upvotes: 1

Related Questions