question

dipen avatar image
dipen asked alexander-vlasov commented

How to get notified when an order is completed?

I am looking for a broadcast (Android) to get notified when an order is completed. Means the completed payments has been made. Right now I am able to get the notification for each payment made on an order but I couldn't find any thing to identify if the order is completely paid. Is there any straightforward way or broadcast by which I can get this notification?

OrdersBroadcasts
10 |2000

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

q-factor avatar image
q-factor answered alexander-vlasov commented

One way is to check the "state" of the order and see if it is PAID. Not sure if there is a broadcast for the same.

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.

Thanks for the answer but I already checked with state and it is giving as "locked" even though the payment is done.

0 Likes 0 ·

let me check. I thought it would have the value PAID.

0 Likes 0 ·

Same here. Only null, open, locked states are available through Android SDK.

0 Likes 0 ·

A locked order means that a payment, credit, and/or refund object(s) has been added to the order.

If you're implementing an Android app, you can also utilize: OnOrderUpdateListener2

0 Likes 0 ·

We can check if order's total equals to sum of payments' amount and state is locked. This is usually means that order was paid. But at this moment cashier is on Receipt screen where he could void the transaction. And that's is problem. It would be much better if SDK provides separate notification or new state 'paid' when cashier presses 'Done' button.

0 Likes 0 ·
alexander-vlasov avatar image
alexander-vlasov answered

Same here. Only null, open, locked states are available through Android SDK.

10 |2000

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

Mike M avatar image
Mike M answered

In that case, you can listen to the broadcast action Intents.ACTION_V1_PAY_BUILD_HIDE, which will fire off after the user has hidden the PayActivity. Because this also fires off when the user backs out of the PayActivity, you can either correlate it with Intents.ACTION_PAYMENT_PROCESSED to determine if it were fired after a payment, or check if the order total equals the sum of the payment amounts.

10 |2000

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

Mike M avatar image
Mike M answered

A few things you can check out.

Using Intents.ACTION_PAYMENT_PROCESSED to detect if a payment was processed.

Using Intents.ACTION_V1_PAY_BUILD_HIDE to detect if an employee his "Done" or simply leaves/backs the PayActivity.

Using OrderCalc getTotal(...) to calculate an order's lineItem total.

You should be able to use those 3 as flags to determine the "completion" state of an Order.

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