question

marc-omorain avatar image
marc-omorain asked sdesai published

What's the recommended API for printing orders?

What API should I use for printing a full itemized receipt?

When I use BillPrintJob, using an order ID, I can print correctly:

BillPrintJob.Builder().orderId(orderId).build().print(context, account, printer)

When I use the static StaticReceiptPrintJob the print service NPEs:

StaticReceiptPrintJob.Builder().order(order).build().print(context, account, printer);

Here is the NPE in the logs:

05-13 13:00:33.878 11597-11609/? D/PrinterController: Printer connect
05-13 13:00:33.881 11597-11609/? D/PrinterController: Automatic Status Back response received
05-13 13:00:33.881 11597-11609/? D/PrinterController: Status response received
05-13 13:00:33.881 11597-11609/? D/PrinterController: Returning printer status: OK
05-13 13:00:33.882 11597-11609/? D/UsbDeviceConnectionJNI: close
05-13 13:00:33.882 11597-11609/? D/PrinterController: Printer disconnect
05-13 13:00:33.969 1263-21748/? W/SeikoMini: onHandleIntent(PrinterIntentService.java:373): print failed, printer: Printer{uuid=8NHTTP59K01JM, type=SEIKO_MINI_USB, name=Mini, mac=null, ip=null, category=RECEIPT}
    java.lang.NullPointerException
    at com.clover.engine.services.ReceiptPrinterPlugins.ReceiptGenerator.createReceiptView(ReceiptGenerator.java:2035)
    at com.clover.engine.services.ReceiptPrinterPlugins.ReceiptGenerator.createReceiptView(ReceiptGenerator.java:1599)
    at com.clover.engine.services.ReceiptPrinterPlugins.seiko.SeikoMini.printReceipt(SeikoMini.java:75)
    at com.clover.engine.services.PrinterIntentService.onHandleIntent(PrinterIntentService.java:302)
    at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:136)
    at android.os.HandlerThread.run(HandlerThread.java:61)
05-13 13:00:33.986 1263-21748/? I/SeikoMini: scheduleRepeat(PrinterIntentService.java:495): scheduling repeat, delaying 6250ms

I want to print a receipt with as much information on it as possible - payment, line items, modifications, customer name, phone number, address.

Thanks for any help.

Marc

10 |2000

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

Jeffrey Blattman avatar image
Jeffrey Blattman answered marc-omorain commented

Do not use any of the non-Static* print job classes they are deprecated. If you are trying to print an order use StaticOrderPrintJob. If you still have trouble let us know.

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

marc-omorain avatar image marc-omorain commented ·

Hi Jeff,

As I said, when I use the StaticReceiptPrintJob class the Clover printing system his an NPE and doesn't print. I'll try the StaticOrderPrintJob now.

Am I doing something wrong with my invocation of StaticReceiptPrintJob?

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

A receipt print job is for printing payment receipts. You aren't supplying a payment or payment ID, hence the crash. You need to use StaticOrderPrintJob.

0 Likes 0 ·
marc-omorain avatar image marc-omorain commented ·

Hi Jeff,

The order print job is not the same as the ReceiptPrintJob or BillPrintJob :(

Here is a photo of the two:

https://cloud.githubusercontent.com/a...

I want to print the data from the static print job (which has prices, cashier, merchant name, etc.). The Order print job has strange looking size and spacing and layout and doesn't include price of items. It's not professional enough looking to show to a customer IMO.

Is there a way that I could send some sort of zero payment information to an order to avoid the NPE?

Thanks!

0 Likes 0 ·
marc-omorain avatar image marc-omorain commented ·

It also appears that extra receipt print data added though a ContentProvider doesn't appear on the StaticOrder print job as far as I can tell. I might be wrong though.

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

The order print job is for printing kitchen orders. It's not intended for customers, right. I think you want StaticBillPrintJob. Did you try that? I don't know what you mean by "extra receipt print data added though a ContentProvider". What content provider? What interface are you using? What is "extra receipt print data"?

0 Likes 0 ·
Show more comments
sdesai avatar image
sdesai answered sdesai published
Does anyone have a workaround for this bug? It's pretty easy to repo consistently and there are at least 3 other tickets with the same problem. ( https://community.clover.com/questions/2242/nullpo... https://community.clover.com/questions/2238/whats-... https://community.clover.com/questions/9257/printi...

Steps:
1. Create order with https://www.clover.com/api_docs/#!/orders/CreateOr...
2. In app print order with StaticReceiptPrintJob or StaticBillPrintJob based on if the order is paid or not.

If you print the order from Orders screen everything is fine. If you clear the print queue and call the print job again everything is fine too, so when trying to repo you always need a new order created from the API to test with.
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