Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Payment Confirmation Notifications #1

Open
owenkellogg opened this issue Jan 13, 2023 · 0 comments
Open

Payment Confirmation Notifications #1

owenkellogg opened this issue Jan 13, 2023 · 0 comments

Comments

@owenkellogg
Copy link
Contributor

owenkellogg commented Jan 13, 2023

Clients shall subscribe to new payment confirmation notifications over websockets and receive the payment confirmation information in real time.

To achieve this, expose an invoice subscription object, which is an event emitter wrapping the events for a specific invoice.

Clients may subscribe to an invoice's events by providing its uid.

Here is a proposed interface

import { subscribe } from 'anypay'

const invoice = await subscribe({ uid: '71d3debf-b828-424c-b7b2-1299107b776' })

invoice.on("payment.unconfirmed", payment => { console.log("payment received but not confirmed"})

invoice.on("payment.confirmed", payment => { console.log("payment received the required number of confirmations") })

Often you will want to know when new blocks are added on top of the original block that included your transaction. For instance one exchange process may require 3 confirmations while another requires 100 confirmations, and another just 1. It all depends on the risk level associated with the payment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant