question

James Tickett avatar image
James Tickett asked Jeffrey Blattman commented

How should I go about closing open/abandoned orders?

Our basic process flow:

Our app creates an order, adds items, then pushes in Payment app with the order#, then once Payment complete it returns and handles the rest (ticket printing etc).

Currently, if a customer is indecisive and the employee backs out to add an item, then returns to payment, this counts as a new order. As a result, we have a lot of open/abandoned orders.

I can imagine going down one of two routes... either our app recognises when an order is abandoned (Currently struggling with this as there seems to be no special Intent), or we have something run at the end of day to clear up all open orders.

Any ideas?

Orders
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

Jeffrey Blattman avatar image
Jeffrey Blattman answered Jeffrey Blattman commented

The problem is exactly what you recognized. How do you know when an order is "abandoned"? Our apps have take the approach that it's up to the merchant to manage this. The merchant can delete orders manually, but we don't do anything to try and clean up unused / unpaid orders.

Currently, if a customer is indecisive and the employee backs out to add an item, then returns to payment, this counts as a new order. As a result, we have a lot of open/abandoned orders.

Why does it count as a new order? We do optimize in places like this. For example, in the sale app, if the merchant backs out of the payment, we re-use the order.

8 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.

James Tickett avatar image James Tickett commented ·

When our app creates the order, it captures the OrderID and pushes this into Payments/Sale app. We have a receiver registered to listen for the ACTIONPAYMENTPROCESSED broadcast and this handles the rest of the process for us. The string storing the OrderID persists, so that we can reuse it for reading/updating the order after the sale.

So I've managed to back out of the sale and it maintain the OrderID (so that we can hopefully reuse it for updating the order) but the issue I have now is that since this is not going through the Receiver, I'm using on onResume()...

0 Likes 0 ·
James Tickett avatar image James Tickett commented ·

... and the issue is that it reaches this code with the OrderID in both scenarios (completed and abandoned)... but it just occurred to me to then use the OrderID to check it's state... think I've got an idea now!

Thanks for your help Jeff!

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

To initiate a payment, you should be starting sale or payments for result. You should look at the result to understand if the payment was successful.

0 Likes 0 ·
James Tickett avatar image James Tickett commented ·

I think I follow what you mean. Currently using:

Intent intent = new Intent(Intents.ACTION_CLOVER_PAY);
        intent.putExtra(Intents.EXTRA_CLOVER_ORDER_ID, orderId);
        intent.putExtra(Intents.EXTRA_OBEY_AUTO_LOGOUT, true);
        startActivity(intent);

Are you saying we ought to be using this rather than startActivity:

setResult(RESULT_OK, intent);
0 Likes 0 ·
Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ commented ·

Almost. You should be using startActivityForResult() then in onActivityResult(), checking the result code is OK. The payments app itself does setResult() to indicate the success or failure back to the starter.

0 Likes 0 ·
Show more comments

Welcome to the
Clover Developer Community