Integrating with Stripe (Android)

If you haven't already, follow the "Importing DyScan" and "Interfacing DyScan" steps in the General Integration Guide.

Then, in your activity that launches DyScan, edit the onActivityResultfunction to look like the following.

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == MY_SCAN_REQUEST_CODE) {
        if (data != null && data.hasExtra(DyScanActivity.EXTRA_SCAN_RESULT)) {
            CreditCard scanResult = data.getParcelableExtra(DyScanActivity.EXTRA_SCAN_RESULT);
            // EnterCardActivity is an Activity containing Stripe's CardInputWidget
            Intent intent = new Intent(MainActivity.this, EnterCardActivity.class);
            intent.putExtra(“cardNumber”, scanResult.cardNumber);
            if(scanResult.expiryYear > 0) {
                intent.putExtra(“expiryYear”, scanResult.expiryYear);
                intent.putExtra(“expiryMonth”, scanResult.expiryMonth);

Now we just need to look for these extra values in the payment information activity. This can be done by modifying the onCreate()function. For example:

// In the Activity containing a CardInputWidget object called
// mCardInputWidget

protected void onCreate(Bundle savedInstanceState) {

   mCardInputWidget = (CardInputWidget) findViewById(;
   Bundle b = getIntent().getExtras();

   if(b != null) {

       if(b.getInt("expiryYear") > 0 ) {
           mCardInputWidget.setExpiryDate(b.getInt("expiryMonth"), b.getInt("expiryYear"));

Last updated