Listening for ACTION_ORDER_COMPLETED

Hi

I’m using the ‘Terminal’ app to make some payments and I can successfully capture the ACTION_TRANSACTION_COMPLETED event and get the transaction data however I would also like to access the order object. Currently, I didn’t find any way to access it by having a transaction ID so I tried listening for ACTION_ORDER_COMPLETED event but it seems that this doesn’t fire at all.

I’m looking for some guidance on how to access the order object after making a payment in the terminal app

Hi, I implemented this. I will try to help. All this code is in the poynt examples, you can google it, but i provide this for you, in order to you can search it.

  1. First you need to capture the transaction as you said.

if (Intents.ACTION_NEW_ORDER_CREATED.equals(action)) {
Log.e(“Log”, “Received broadcast: NEW_ORDER_CREATED”);
orderid = String.valueOf(intent.getExtras().get(Intents.INTENT_EXTRAS_ORDER_ID));
getOrder(orderid);
}

  1. You need to bind mOrderService, then the implementation of getOrder:

private IPoyntOrderService mOrderService;
public void getOrder(String orderId) {
if (mOrderService != null) {
try {
mOrderService.getOrder(orderId, UUID.randomUUID().toString(), mOrderServiceListener);
Log.e(“LogApp”, "orderID: " + orderId);
} catch (RemoteException e) {
e.printStackTrace();
}
}
}

  1. Then you can access to the order object in the order service listener:

private IPoyntOrderServiceListener mOrderServiceListener = new IPoyntOrderServiceListener.Stub() {
public void orderResponse(Order order, String requestId, PoyntError poyntError) throws RemoteException {

if(order != null) {
List list = order.getItems();
if(list != null) {
if(list.size() > 0) {
for(OrderItem item : list) {
Log.e(“Log”, item.getName() + “(” + item.getQuantity() + " x " + item.getUnitPrice() + “)”);
}
}
}

So, this you can access the order and order items. Hope this helps!! :grinning:

1 Like