question

Danielle Cox avatar image
Danielle Cox asked Danielle Cox commented

Receipt Connector Race Condition?

I am using receipt connector and have created a provider that, if our tender is part of the order, prints the payment's note on the receipt.

If I finish the tender and hit print customer receipt immediately, getNote returns true. If I wait a second or two, or reprint the receipt, the note is there. I have utilized the rest api to look and the note is there, but I think I have seen instances where it is not.

Any suggestions? It knows about the rest of the payment because that prints.

Thanks!

Danielle

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

Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ commented ·

I assume you mean receipt registration connector. By the time the user is allowed to press print, the payment and order must be fully complete. What I mean is if the order wasn't in a proper paid state w/ your tender, the receipt screen wouldn't allow the receipt to be printed. Did you verify if your provider is being called? There is a 2 second timeout past which the system will give up on your provider.

0 Likes 0 ·
Danielle Cox avatar image Danielle Cox commented ·

Yes I do mean that. I am calling text += payment.getNote(); from inside the query call. I am 100% sure it is being called because the preamble for text is being printed on the receipt. If I press print customer receipt immediately getNote returns null. If I wait a second, it returns the correct value. (This is regardless of printing a second receipt or just waiting.)

0 Likes 0 ·
Danielle Cox avatar image Danielle Cox commented ·

Additionally, if I set a breakpoint (thereby virtually guaranteeing a timeout I can see via the debugger that it returned null.

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

What is setting the note, and when?

0 Likes 0 ·
Danielle Cox avatar image Danielle Cox commented ·

I am setting the note when the payment is processed via the clover.intent.action.MERCHANT_TENDER and is set before the response to the that action is sent.

0 Likes 0 ·
Show more comments

1 Answer

Jeffrey Blattman avatar image
Jeffrey Blattman answered Danielle Cox commented

Yes this is a bug. When your tender returns control to the Payments app, the payment is created and added to the order locally, but the addition of the note to the payment is only sent to the server. The client's local state is not updated. The note doesn't come back to the client until it receives a push message telling it to re-sync the payment's state from the server.

I don't have a work around as we don't expose any way to add the note to the payment locally. I think the only thing you can do would to be save your own order / payment -> note mapping, then use this when the request comes in to your provider.

I'll file an internal bug to track this.

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.

Danielle Cox avatar image Danielle Cox commented ·

While you are filing bugs on this, I would like to point out another and also request a feature, if possible, to have the payment id added.

The other bug I have discovered is that if you from orders select an order, click receipts, and then print, it calls the provider function but does not include the order id. An example is:

URI: content://com.realmobiletech.rmtclover.receipt/text?merchantid=AVK6V7V6H43AT&accountname=Mozart%20Cafe%20%7C%20imafigureskater%40gmail.com%C2%A0(DEV)&account_type=com.clover.account&flags=69

1 Like 1 ·
Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ commented ·

As I mentioned, since Receipt Registration is not the approved mechanism for augmenting receipt data, we don't be enhancing it as a feature.

0 Likes 0 ·

Welcome to the
Clover Developer Community