question

bradboggs avatar image
bradboggs asked ·

Launching my app in the middle of payment flow

I am trying to launch my app mid-payment-flow using a Broadcast receiver which is listening for ACTION_ORDER_CREATED. Is this possible? This statement in the docs make it seem like it is( https://docs.clover.com/clover-platform/docs/inte...):
" Clover emits broadcasts when important events occur, such as when a new order or payment is created. Your application can register a broadcast receiver in order to listen and respond to these events.
Example
Setting a listener for the ACTION_ORDER_CREATED intent will trigger your app whenever an order is created. Your app will receive the ID for the new order."

As of now, it doesn't launch, and I am not able to see any evidence that the broadcast receiver is receiving anything. Below is my Receiver code and my AndroidManifest.xml. Any advice is appreciated!

TransactionReceiver.java
public class TransactionReceiver extends BroadcastReceiver {
                
@Override public void onReceive(Context context, Intent intent) {
String action = intent.getAction(); if (action.equals(Intents.ACTION_ORDER_CREATED)) {
Log.d(Constants.TRANSACTION_RECEIVER_TAG,"---ACTION ORDER CREATED---");
String orderId = intent.getStringExtra(EXTRA_CLOVER_ORDER_ID);
Intent mainIntent = new Intent(context, MainActivity.class);
mainIntent.putExtra("ORDER_ID", orderId);
context.startActivity(mainIntent);
}
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.bboggs.zipsclover"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> </intent-filter>
</activity>
<receiver
android:name=".TransactionReceiver"
android:enabled="true"
android:exported="true" >
<intent-filter>
<action android:name="com.clover.intent.action.ORDER_CREATED" />
</intent-filter>
</receiver>
</application>
</manifest>


IntentsBroadcasts
2 comments
10 |2000 characters needed characters left characters exceeded

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

What device are you testing with? What SDK version are you targeting?

0 Likes 0 · ·
bradboggs avatar image bradboggs Jeffrey Blattman ♦♦ ·

I'm using an emulator: Clover Station 2018, targetSDK 26

0 Likes 0 · ·

1 Answer

Jeffrey Blattman avatar image
Jeffrey Blattman answered ·
As part of the Android 8.0 (API level 26) Background Execution Limits, apps that target the API level 26 or higher can no longer register broadcast receivers for implicit broadcasts in their manifest.

See: https://developer.android.com/guide/components/broadcast-exceptions

This includes most of the intents defined in the Clover Android SDK.

Regardless, what you are trying to do is probably not going to work well. Clover starts a host a different activities at different times during the payment flow. There's no guarantee your activity won't be clobbered by the Clover app starting a different activity.

There are several well-defined integration points in the order / payment flow, including custom tenders and order modifications.

1 comment Share
10 |2000 characters needed characters left characters exceeded

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

@Jeffrey Blattman Thanks for your response! That's really helpful info. I went the order modification route, and the integration worked perfectly. Thanks again!
0 Likes 0 · ·

Welcome to the
Clover Developer Community