question

vidivici avatar image
vidivici asked vidivici commented

OnOrderUpdateListener2.onPaymentProcessed method calling appears to be intermittent.

OnOrderUpdateListener2.onPaymentProcessed method calling appears to be intermittent, when payment made by card on Clover mini attached to Clover station as USB Pay display.

Here is relevant bits of my code, any hints as to what could be the problem, appreciated:

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


public void onCreate() {

Intent i = new Intent(this, TransactionHandling.class);

Notification notification = new Notification.Builder(this)
.setContentTitle("Loyalty").setContentText("Background Process Running")
.setSmallIcon(R.mipmap.ic_launcher).build();


startForeground(NOTIFICATION_ID, notification);


}


public int onStartCommand(Intent intent, int flags, int startId) {


orderConnectorA = new OrderV31Connector(getApplicationContext(), CloverAccount.getAccount(getApplicationContext()), null);
orderConnectorA.addOnOrderChangedListener(new OrderChangeListener());
orderConnectorA.connect();

Log.d("Order Handling", "Running");

mContext = getApplicationContext();

return START_STICKY;


}


public void onDestroy() {


orderConnectorA.disconnect();
orderConnectorA = null;




NotificationManager nMgr = (NotificationManager) this.getSystemService(this.NOTIFICATION_SERVICE);
nMgr.cancel(NOTIFICATION_ID);


}


private class OrderChangeListener implements OrderV31Connector.OnOrderUpdateListener2 {

@Overridepublic void onPaymentProcessed(String s, String s1) {

Log.d("OPP", s + " paymentid " + s1);

orderId = s;
paymentId = s1; //.................






Clover Android SDKClover Mini
2 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.

chanel avatar image chanel commented ·

Hi @Vidivici, can you explain what you're trying to accomplish with this code?

0 Likes 0 ·
vidivici avatar image vidivici commented ·
This code is intended to produce a notification whenever the onpaymentprocessed method is called. It is intended to be basic code to demonstrate the problem. Obviously I am not able to post code that is proprietary to our business.,This code is just intended to post a notification when the onpaymentprocessed method is called. Obviously I cannot post my functional code as it is proprietary to our business. This second post was intended to be non proprietary basic code to demonstrate that the method was not being called.
0 Likes 0 ·
vidivici avatar image
vidivici answered vidivici published
I have also tried this and notifications are only getting called intermittently:

public class TransactionHandling extends Service {


int mStartMode;
int NOTIFICATION_ID = 1337;
String orderId;
String refundId;
String paymentId;




public IBinder onBind(Intent intent) {<br>    return null;<br>}<br><br><br>public void onCreate() {<br><br>    Intent i = new Intent(this, TransactionHandling.class);<br><br>    Notification notification = new Notification.Builder(this)<br>            .setContentTitle("Loyalty").setContentText("Background Process Running")<br>            .setSmallIcon(R.mipmap.ic_launcher).build();<br><br><br>    startForeground(NOTIFICATION_ID, notification);<br><br><br>}<br><br><br>public int onStartCommand(Intent intent, int flags, int startId) {<br><br><br>    orderConnectorA = new OrderV31Connector(getApplicationContext(), CloverAccount.getAccount(getApplicationContext()), null);<br>    orderConnectorA.addOnOrderChangedListener(new OrderChangeListener());<br>    orderConnectorA.connect();<br><br>    Log.d("Order Handling", "Running");<br><br>    mContext = getApplicationContext();<br><br>    return START_STICKY;<br><br><br>}<br><br><br>public void onDestroy() {<br><br><br>    orderConnectorA.disconnect();<br>    orderConnectorA = null;<br><br><br><br><br>    NotificationManager nMgr = (NotificationManager) this.getSystemService(this.NOTIFICATION_SERVICE);<br>    nMgr.cancel(NOTIFICATION_ID);<br><br><br>}<br><br><br>public class OrderChangeListener implements OrderV31Connector.OnOrderUpdateListener2 {<br><br>    @Override
public void onPaymentProcessed(String s, String s1) {<br><br>        Log.d("OPP", s + " paymentid " + s1);<br><br>        orderId = s;<br>        paymentId = s1;<br><br><br><br>        NotificationManager notificationManager =<br>                (NotificationManager) getSystemService(NOTIFICATION_SERVICE);<br>        int icon = R.mipmap.ic_launcher;<br>        CharSequence notiText = "Points processing launched";<br>        long meow = System.currentTimeMillis();<br><br>        Notification notification = new Notification(icon, notiText, meow);<br><br>        Context context = getApplicationContext();<br>        CharSequence contentTitle = "Points Processing";<br>        CharSequence contentText = "cardnumber:"+s;<br>        Intent notificationIntent = new Intent(getApplicationContext(), MainActivity.class);<br>        PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0);<br><br>        notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);<br><br>        int SERVER_DATA_RECEIVED = 1;<br>        notificationManager.notify(SERVER_DATA_RECEIVED, notification);

}  //................. other methods ................
}




10 |2000

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

chanel avatar image
chanel Deactivated answered vidivici commented
Hi @Vidivici, if you're having issues with "onPaymentProcessed" being fired, take a look at this question: https://clover.cloud.answerhub.com/questions/3038/onorderupdatelistener2-not-firing-onpaymentprocess.html . There, you can find that removing "orderConnector.disconnect()" was the solution for them. Let me know if this solution works for you as well.
1 comment
10 |2000

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

vidivici avatar image vidivici commented ·

I removed the disconnect from the onDestroy method and that has not changed anything.

0 Likes 0 ·

Welcome to the
Clover Developer Community