I used paymentRequest.stream to start listen to events for a third party account.

But it gets all events from the beginning if I don't provide a paging token. As it is a third party account, my client side application doesn't listen to the event all the time, so it doesn't have the latest pagingToken. So I will get a lot of events from the past.

Is there a way for me just to start listening to future events for a third party account? Which means I only want to listen on events from the time the client runs, but ignores everything in the past?

1 Answer 1


Not 100% sure about Java SDK, but JavaScript SDK allows to specify "now" as a cursor to be notified of payments happening starting from when this script runs.


Looks like the method mentioned above doesn't work with Java SDK. The alternative approach requires two calls instead of one, but it was battle-tested and guaranteed to work.

Prepare request builder for transactions, set limit to 1 and execute it. Once you get the response, you have a paging_token for the first transaction in a list that can be specified as a cursor in streaming mode. If the first request returns zero rows, it means that there were no transactions on this account and you can safely omit a cursor in a streaming request call.

  • 1
    Thanks and I did use "now" from your advice. I found that without "now", the onEvent was called for all transactions. But with "now", it wasn't called at all.
    – Hai Bi
    Feb 4, 2018 at 2:59
  • Got it to work, according to your method. So I have to close the first EventSource returned by the stream function for the first time. Then I start another stream using the pageToken as cursor and it did work as you said.
    – Hai Bi
    Feb 4, 2018 at 4:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.