question

sanjay avatar image
sanjay asked ·

"StaticPaymentPrintJob- Print" Notifies with printing error.

Hi


We are using the following code in our android application to print payment receipts via clover devices for the other payment methods like as cash etc (except for Card) by using the following code:


Tender tender = new Tender();

tender.setLabel("PAYMENT_METHOD");

tender.setLabelKey("PAYMENT_METHOD");

Payment mPayment = new Payment();

mPayment.setId("TRANSACTION_ID");

mPayment.setAmount(1000);

mPayment.setTender(tender);

StaticPaymentPrintJob.Builder builder = new StaticPaymentPrintJob.Builder();

builder.flag(PrintJob.FLAG_CUSTOMER);

PrintJob printJob = builder.payment(mPayment).build();

printJob.print(mApplicationContext, getCloverAccount(mApplicationContext));


The code was working fine earlier and receipt was printed as expected but now it is throwing following error and printing is failed every time.


06-30 07:02:22.738 23923-26736/? W/Bayleaf: onHandleIntent(PrinterIntentService.java:401)[IntentService[PrinterIntentService]]: print failed, printer: Printer{uuid=HDK03SRCMEMG0, type=BAYLEAF_USB, name=Flex, mac=null, ip=null, category=RECEIPT}

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.clover.sdk.v3.base.Reference.getId()' on a null object reference

at com.clover.engine.services.ReceiptPrinterPlugins.PaymentTransaction.getOrderId(PaymentTransaction.java:61)

at com.clover.engine.services.ReceiptPrinterPlugins.ReceiptData.getOrder(ReceiptData.java:580)

at com.clover.engine.services.ReceiptPrinterPlugins.DefaultReceiptData.getOrder(DefaultReceiptData.java:3)

at com.clover.engine.services.ReceiptPrinterPlugins.DefaultReceiptViewElements.addTaxesAndFeesBreakdownContainer(DefaultReceiptViewElements.java:462)

at com.clover.engine.services.ReceiptPrinterPlugins.DefaultReceiptViewElements.generateAmountServiceAndTipView(DefaultReceiptViewElements.java:364)

at com.clover.engine.services.ReceiptPrinterPlugins.DefaultReceiptViewElements.generateView(DefaultReceiptViewElements.java:88)

at com.clover.engine.services.ReceiptPrinterPlugins.ReceiptGenerator.createPaymentView(ReceiptGenerator.java:198)

at com.clover.engine.services.ReceiptPrinterPlugins.ReceiptGenerator.createPaymentView(ReceiptGenerator.java:172)

at com.clover.engine.services.ReceiptPrinterPlugins.bayleaf.Bayleaf.printReceipt(Bayleaf.java:252)

at com.clover.engine.services.PrinterIntentService.onHandleIntent(PrinterIntentService.java:318)

at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)

at android.os.Handler.dispatchMessage(Handler.java:102)



What could be the reason for this null pointer exception, We have also tried to update to the latest version of clover android SDK (248.4) but the error is still not fixed. Please suggest to us immediately. It is very urgent.


Thanks

OrdersPaymentsClover MiniPrintClover Flex
10 |2000 characters needed characters left characters exceeded

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

David Marginian avatar image
David Marginian answered ·

In Clover the order is king and a payment gets associated with an order, not the other way around. As I said I don't see how this ever worked and what you're doing is not possible because the order connector will not allow you to set a payment on an order. I can double check with Jeff but I'm pretty sure this is correct.

You have two options:

1) Use ACTION_CLOVER_PAY which will allow for a cash tender. This will also launch a Clover UI.

2) Use this endpoint - https://docs.clover.com/reference/orders-1#ordercreatepaymentfororder-2


12 comments Share
10 |2000 characters needed characters left characters exceeded

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

OK, So if this is not possible then can you please suggest to us that how can we generate the receipt for the cash payment?

0 Likes 0 · ·

Have you considered using the Android SDK for cash payments - https://community.clover.com/questions/22152/action-clover-pay-vs-action-secure-pay.html?

0 Likes 0 · ·
sanjay avatar image sanjay David Marginian ♦♦ ·

The suggestion will be very appreciated if it is for the manual cash like the cash button will be in our application and we will customize the receipt.

0 Likes 0 · ·
Show more comments
David Marginian avatar image
David Marginian answered ·

We don't support third-party gateways, and it is a violation of our terms. Only Clover apps can create payments. We do have an endpoint that allows the creation of a payment record for custom tenders (https://docs.clover.com/reference/orders-1#ordercreatepaymentfororder-2). This API would have to be called via your app as this functionality is not available in the Clover Android SDK. I don't see how this code ever worked. The exception is pretty clear. The payment does not have an order associated with it and thus the exception.

Share
10 |2000 characters needed characters left characters exceeded

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