question

Yossi avatar image
Yossi asked Raymond Lee Deactivated answered

in-app vs intent based integration

hi all,

Before I roll up my sleeves I wanted to make sure I'm using the right design pattern -

Is it possible to integrate the Clover card swiper / EMV and/or the barcode scanner within my app? similar to how Stripe SDK works (the user "stays" within the app).

Or the only solution is via intents and broadcasts in which I send the user to the register / scanner app and get the user back with some payload?

Thanks.


Broadcasts
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Raymond Lee avatar image
Raymond Lee Deactivated answered
Hi @yossisun,

Unfortunately, due to our card swiper / EMV being on a separate dedicated secure processor for security, we cannot open direct access to the swiper / EMV to third party apps for "card present" payments. So yes, the only solution for "card present" payments is via an intent to our Secure Pay App, and get the user back with a result payload.

Here is an example:
private class SecurePayAsyncTask extends AsyncTask<Void, Void, Void> {
    @Override
    protected Void doInBackground(Void... voids) {
        try {
            // Create Intent to Start Secure Pay App.
            Intent intent = new Intent(Intents.ACTION_SECURE_PAY);
            intent.putExtra(Intents.EXTRA_AMOUNT, new Long(300));
            intent.putExtra(Intents.EXTRA_ORDER_ID, "9CT0S1FC4242T");

            // Start 'CLOVER Secure Pay' App.
            startActivityForResult(intent, SECURE_PAY_REQUEST_CODE);
        }

        catch ( Exception e) {
            e.printStackTrace();
        }

        return null;
    }
}

You can customize the user experience in the Secure Pay App through extras passed with your intent.

Here is the documentation on what you can pass in: https://clover.github.io/clover-android-sdk/com/clover/sdk/v1/Intents.html#ACTION_SECURE_PAY.

You can also pass in TransactionSettings, for further customization:
private class SecurePayAsyncTask extends AsyncTask<Void, Void, Void> {
    @Override
    protected Void doInBackground(Void... voids) {
        try {
            TransactionSettings transactionSettings = new TransactionSettings();
            transactionSettings.setCardEntryMethods(Intents.CARD_ENTRY_METHOD_ICC_CONTACT | Intents.CARD_ENTRY_METHOD_MANUAL | Intents.CARD_ENTRY_METHOD_MAG_STRIPE);
            transactionSettings.setDisableRestartTransactionOnFailure(true);
            transactionSettings.setDisableDuplicateCheck(true);

            // Create Intent to Start Secure Pay App.
            Intent intent = new Intent(Intents.ACTION_SECURE_PAY);
            intent.putExtra(Intents.EXTRA_AMOUNT, new Long(300));
            intent.putExtra(Intents.EXTRA_ORDER_ID, "9CT0S1FC4242T");
            intent.putExtra(Intents.EXTRA_TRANSACTION_SETTINGS, transactionSettings);
            // Start 'CLOVER Secure Pay' App.
            startActivityForResult(intent, SECURE_PAY_REQUEST_CODE);
        }

        catch ( Exception e) {
            e.printStackTrace();
        }

        return null;
    }

Documentation on TransactionSettings here: https://clover.github.io/clover-android-sdk/com/clover/sdk/v3/payments/TransactionSettings.html.

You can retrieve the Payment object created from the Secure Pay app, by calling startActivityForResult() to start the Secure Pay app, and then retrieve the Payment object from the result payload in your onActivityResult(). Here is an example: https://github.com/clover/android-examples/blob/master/paywithsecurepaymentexample/PayWithSecurePaymentExample/src/main/java/com/clover/example/paywithsecurepaymentexample/MainActivity.java#L1160.

If you want to make "card not present" payments similar to Stripe SDK, you can use our Developer Pay API to make credit card payments from within your app. This documentation goes into how to implement Developer Pay API, and there is an example app as well:
https://docs.clover.com/build/developer-pay-api/

For barcode scanner, we do allow you to scan barcodes from within your app, without needing to leave it.

Here is an example you can reference:
https://github.com/clover/clover-android-sdk/blob/...

And here is the extras you can pass to it:
https://clover.github.io/clover-android-sdk/com/cl...

Hope that helps,

Raymond
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community