DyScan
  • DyScan Integration Guide
  • iOS Integration Guide
  • Android Integration Guide
  • React Native Integration Guide
  • Cordova Integration Guide
  • Integrity Verification
  • Migrating from card.io
    • Migrating from card.io (iOS)
    • Migrating from card.io (Android)
  • Integrating with Stripe
    • Integrating with Stripe (iOS)
    • Integrating with Stripe (Android)
  • Alternate Ways to Integrate iOS
    • Integrating with Swift Package Manager
    • Integrating with Carthage
    • Integrating as a Framework
  • Alternate Ways To Integrate Android
    • Manually Importing the Library
    • Using DyScanView
  • MIGRATING FROM 1.0.X TO 1.1.X
    • Migrating from 1.0.x to 1.1.x (iOS)
    • Migrating from 1.0.x to 1.1.x (Android)
    • Migrating from 1.0.x to 1.1.x (React Native)
Powered by GitBook
On this page

Was this helpful?

  1. Integrating with Stripe

Integrating with Stripe (Android)

PreviousIntegrating with Stripe (iOS)NextIntegrating with Swift Package Manager

Last updated 5 years ago

Was this helpful?

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

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

@Override
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);
            }
            startActivity(intent);
        }
    }
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_enter_card);

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

   if(b != null) {
       mCardInputWidget.setCardNumber(b.getString("cardNumber"));

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