Bryanne Vega avatar image
Bryanne Vega asked Bryanne Vega commented




While printing a static payment print job, I can't get the payment or tenders to show.

Below the "Total" of the receipt I get "NULL SALE"

I'm getting the order from Rest API, converting it to an Order object then passing it to the Print Job.

I've expanded lineItems, customers, payments, credits, refunds, serviceCharge, discounts but no luck.

How can I resolve this?

Thanks for your support.


String orderURI = authResult.baseUrl + uri + "/orders/" + new JSONObject(root2.get("order").toString()).get("id") + "?&expand=lineItems%2Ccustomers%2Cpayments%2Ccredits%2Crefunds%2CservicesCharge%2Cdiscounts%2Ccards%2Cmodifiers%2CcardTransactions%2Ctenders%2CorderTypes&access_token=" + authResult.authToken;

String orderResult = httpClient.get(orderURI);

JSONTokener jsonTokener3 = new JSONTokener(orderResult);

Order order = (JSONObject)jsonTokener3.nextValue();

//PrintJob pj = new BillPrintJob.Builder().orderId(useOrder.getId()).build(); //PrintJob pj = new PaymentPrintJob.Builder().paymentId(payID).build(); //StaticPaymentPrintJob pj = new StaticPaymentPrintJob.Builder().paymentId(payID).build(); PrintJob pj = new StaticPaymentPrintJob.Builder().order(order).build(); //pj.print(ServiceHead.this, account);

10 |2000

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

I can't tell if you are trying to print a bill or a payment receipt. The example code for StaticPaymentPrintJob doesn't include a payment. You need to either set a payment or a payment ID. The non Static* classes are deprecated. Don't use those.

0 Likes 0 ·

Ops. Sorry about that, had an old clipboard.

StaticPaymentPrintJob pj = (StaticPaymentPrintJob) new StaticPaymentPrintJob.Builder().order(useOrder).build(); pj.print(ServiceHead.this, account);

0 Likes 0 ·

I've included a receipt on the initial post

0 Likes 0 ·

You need to call .payment() or .paymentId() on the builder.

0 Likes 0 ·

Happens the same, that's why you see the commented code:

StaticPaymentPrintJob pj = new StaticPaymentPrintJob.Builder().paymentId(payID).build();

Excuse me, I get print failed when I use payment ID.

0 Likes 0 ·
Show more comments

1 Answer

Jeffrey Blattman avatar image
Jeffrey Blattman answered Bryanne Vega commented

Post your code. StaticPaymentPrintJob is for printing payment receipts. You must include a payment, or an order + a payment ID where the payment matching the payment ID exists in the order.

EDIT: The tender object in your payment is incomplete. It doesn't have a label or label key. Here's an example of a complete tender.

  "id": "d2871da5-d2c9",
  "enabled": true,
  "visible": true,
  "labelKey": "com.clover.tender.credit_card",
  "label": "Credit Card",
  "opensCashDrawer": false,
  "href": "https:\/\/\/v3\/merchants\/GARENZRPEFZ6E\/tenders\/d2871da5-d2c9",
  "editable": false
10 |2000

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

Verify the updated post. Like mentioned, it works, but below Totals in the order it says "NULL SALE"

0 Likes 0 ·

Include the payment object in the pastebin please.

0 Likes 0 ·

Well how can I expand this on the request with the Rest API?

Edit: I've tried expanding tenders with no luck of the information being shown on the Rest Api Response.

0 Likes 0 ·

I used this (for example): /v3/merchants/GARENZRPEFZ6E/orders/RCV6S4D9MSC2G and got the payments and the expanded tender. Alternatively you could use OrderConnector.getOrder() to get the locally cached copy of the order.

0 Likes 0 ·

I've got the order object, extracted the payments and compared the ID from the array to the ID in com.clover.intents.extra.PAYMENT_ID, if the payment I'm looking for is there, proceed and the data is now printing accordingly. Thank you for the quick support and excellent answer.

Thanks, -Bryanne

0 Likes 0 ·
Show more comments

Welcome to the
Clover Developer Community