btcpayserver/btcpayserver-doc

Fix Using the BTCPay API for Custom Integration

Opened this issue · 5 comments

Described API is not correct on the "Using the BTCPay API for Custom Integration" page (/CustomIntegration/).

window.btcpay.onModalReceiveMessage(yourCallbackFunction) // available from v1.0.5.6

onModalReceiveMessage will invoke your callback when a new status has been pushed from BTCPay Server to the invoice UI. The data format is {invoiceId: "x", status: "y" }

But the callback receives objects like this:
Snímek obrazovky 2023-12-26 v 18 14 50

Generally I would like to read much more complete docs about this frontend SDK. Ideally have it as a TypeScript package, so I does not need to handle loading by <script> and my code will know what types to expect.

@ndeet can you take a look at this one and if we fixed it?

Hey @iBobik, will look into that, seems that information may be outdated. You can find a better example here https://docs.btcpayserver.org/Development/ecommerce-integration-guide/#modal-invoice-page-advanced-optional

We don't have any dedicated Javascript dev around that's why there is no api library or for the modal, would be great if you or somebody could contribute that. That said, the functionality seems simple enough that it maybe is not needed.

internal docs note:

Checking the mentioned custom integration page it is outdated in several ways:

  • links legacy API + examples (should do link to greenfield cURL examples and api docs) + maybe keep the legacy docs for now but name it like that, also pairing process)
  • I would suggest to split the API info to Greenfield and Legacy so both are documented
  • we should merge the example of eCommerce integration with what we have on integration here as it is more complete and in the eCommerce integration guide only link to the custom integration page, modal part? (ecom guide only has the event listeners explained but not how to include, create invoice and instantiate the modal)

Btw, keep in mind e-commerce use cases with static website or limited backend capabilities, where it is handy to have API without authentication like this (sadly) deprecated one.

See this small integration I wrote for Shoptet.cz, major e-commerce SaaS in Czechia:
https://gitlab.com/janpoboril/shoptet-btcpay/-/blob/master/public/checkout.js?ref_type=heads

ndeet commented

Yes you can do that when payment button is enabled, it is not deprecated, but it has problems. Users can modify sent parameters like price easily and e.g. lower the invoice amount and trick the chekout if you have no other checks in place.