question

evillrich avatar image
evillrich asked evillrich commented

Can a Custom Tender modify an order

I've read through the documentation several times, code examples, etc. I thought I read somewhere that a Custom Tender can't modify an order but I can't find a reference to that info again.

I specifically have tried to add a Customer to the Order in a custom tender (to pre-populate an email address) and it didn't update the Order. I used the exact same code in a MODIFY_ORDER intent and that did update the Order with the Customer.

Can someone confirm if a custom tender can update an Order? Also, if there are specific restrictions on what can/can't be updated in the custom tender that would be helpful as well.

Thanks.

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

One additional note. I found in the Custom Tenders doc the following:

"Please note that a custom tender cannot add a discount or items to an order, it must pay for the entire order."

However, that doesn't specifically address what can/cannot be done to an order. For example, can a Customer be added to an Order? Perhaps no changes can be made... That is my question.

Thanks,

0 Likes 0 ·

1 Answer

Mark Mullan avatar image
Mark Mullan answered evillrich commented

Hi,

I was just able to setNote successfully using the Clover OrderConnector while in the merchant-facing custom tender activity. Is there anything in particular you're looking to accomplish?

EDIT: sample code for this, if it would help. The OrderID is passed as an Extra, so setOrderId(getIntent().getStringExtra(Intents.EXTRA_ORDER_ID)); in onCreate/onResume.

public void setNote(View view) {
    new AsyncTask<Void, Void, Order>() {
        @Override
        protected final Order doInBackground(Void... params) {
            try {
                return mOrderConnector.getOrder(orderId);
            } catch(RemoteException | ClientException | ServiceException | BindingException e) {
                e.printStackTrace();
            }
            return null;
        }

        protected final void onPostExecute(Order o) {
           o.setNote("setting the note!");
            new AsyncTask<Order, Void, Void>() {
                @Override
                protected final Void doInBackground(Order... params) {
                    try {
                        mOrderConnector.updateOrder(params[0]);
                    } catch(RemoteException | ClientException | ServiceException | BindingException e) {
                        e.printStackTrace();
                    }
                    return null;
                }
            }.execute(o);
        }
    }.execute();
}
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.

Thanks for the sample code.

I'm trying to add a Customer to the Order in the Merchant facing custom tender. My goal is to pre-populate the email address so that the email address is "on file" for receipt delivery.

I perform the order lookup using OrderConnector, add the EmailAddress to a customer, add the Customer to the Order, and update the order via OrderConnector. I do this all in an AsyncTask's doInBackground() method. Is there a reason why you are splitting the Note update across 2 AsyncTasks?

Thanks

0 Likes 0 ·

Great - I'm breaking this across 2 AsyncTasks because each OrderConnector method is Async, and we want to queue the calls to ensure that they execute sequentially.

0 Likes 0 ·

Welcome to the
Clover Developer Community