question

mhernaez avatar image
mhernaez asked ismdcf commented

Is there a way to disable the Sale app from launching when inserting a card?

Is it possible to prevent the Sale app from automatically launching when inserting a card? We are trying to prevent a customer from inserting their card prior to our app calling the sale intent.

Any help would be greatly appreciated.
Thanks.
Clover FlexSale
5 comments
10 |2000

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

zgreathouse avatar image zgreathouse commented ·

Could you explain your use case for disabling the Sale app from launching?

0 Likes 0 ·
mhernaez avatar image mhernaez zgreathouse commented ·

Our app is a full point-of-sale system. At time of payment, the Clover Flex is handed to the customer. The customer then interacts with our app prior to calling the sale intent. What we are noticing is that if the customer inserts the card before our app calls the sale intent, it starts the sale app before we want it to. We are trying to prevent the Sale app from launching before the intent is called so that we can capture the result of the sale intent. If the customer inserts the card prematurely, the result of the transaction is not passed back to our app.

0 Likes 0 ·
zgreathouse avatar image zgreathouse mhernaez commented ·

I see, unfortunately there is not a native way to suppress the sale app from launching upon card insertion. What is it that is keeping the attendant from making sure the customer inserts their card at the time of payment and not prematurely?

Also, you mentioned that your app launches the sale intent. Are you utilizing payment connector for processing payments?

0 Likes 0 ·
Show more comments

1 Answer

Greg avatar image
Greg answered ismdcf commented
Hi @mhernaez@silverwarepos.com,

Here is one workaround, after conversing internally with the team. Please note that this is not a public interface so there are no guarantees that it will not change in the future.

1) Add the following permissions to your android manifest.
<uses-permission android:name="com.clover.permission.RECEIVE_CARD_INSERTED"/>
<uses-permission android:name="com.clover.permission.RECEIVE_CARD_SWIPED"/>
2) Create the following service for your app:
public class IntentSuppressionService extends Service {
  private static final String ACTION_BROADCAST_CARD_INSERTED = "com.clover.intent.action.broadcast.CARD_INSERTED";
  private static final String ACTION_BROADCAST_CARD_SWIPED = "com.clover.intent.action.broadcast.CARD_SWIPED";
  private static final int PRIORITY_INTERCEPT = 200;

  private BroadcastReceiver suppressCardInsertedIntentReceiver = null;

  public static void start(Context context) {
    context.startService(new Intent(context, IntentSuppressionService.class));
  }

  public static void stop(Context context) {
    context.stopService(new Intent(context, IntentSuppressionService.class));
  }

  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
    ALog.d(this, "Intent suppression background service is starting");
    return START_STICKY;
  }

  @Override
  public void onCreate() {

    IntentFilter filter = new IntentFilter();
    filter.addAction(ACTION_BROADCAST_CARD_INSERTED);
    filter.addAction(ACTION_BROADCAST_CARD_SWIPED);
    filter.setPriority(PRIORITY_INTERCEPT);

    if (suppressCardInsertedIntentReceiver == null) {
      suppressCardInsertedIntentReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
          String action = intent != null ? intent.getAction() : null;
          if (ACTION_BROADCAST_CARD_INSERTED.equals(action) || ACTION_BROADCAST_CARD_SWIPED.equals(action)) {
            ALog.i(this, "Intent suppression background service is suppressing intent: " + action);
            if (isOrderedBroadcast()) {
              abortBroadcast();
            }
          }
        }
      };

      registerReceiver(suppressCardInsertedIntentReceiver, filter);

      ALog.d(this, "Intent suppression background service broadcast receiver created");
    }
  }

  @Override
  public void onDestroy() {
    if (suppressCardInsertedIntentReceiver != null) {
      unregisterReceiver(suppressCardInsertedIntentReceiver);
      suppressCardInsertedIntentReceiver = null;

      ALog.d(this, "Intent suppression background service broadcast receiver destroyed");
    }
    super.onDestroy();
  }

  @Override
  public IBinder onBind(Intent intent) {
    return null;
  }
}

The intent that is being produced is ordered, so you can set your broadcast receiver to intercept the intent and short circuit it.

Payment Connector should be available for development in Canada, and that will be the supported payment endpoint moving forward. Please continue to post your questions on Community or email semi-integrations@clover.com

Best,
Greg
3 comments
10 |2000

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

mhernaez avatar image mhernaez commented ·

Hi Greg,

That solved the issue! Thanks so much for the support @zgreathouse & @Greg!

Michael

0 Likes 0 ·
Dan avatar image Dan commented ·

Thank's Greg this is very useful (and important) for our use case as well

0 Likes 0 ·
ismdcf avatar image ismdcf commented ·

Hi Greg.

This seems to be inconsistent after the android 10 update. More information I have posted as a separate question. Please could you check and let us know a solution.


https://community.clover.com/questions/36118/sale-prompt-not-suppression-not-working-after-andr.html

Regards

0 Likes 0 ·

Welcome to the
Clover Developer Community