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

Fix Using the BTCPay API for Custom Integration #1356

Open
iBobik opened this issue Dec 26, 2023 · 5 comments
Open

Fix Using the BTCPay API for Custom Integration #1356

iBobik opened this issue Dec 26, 2023 · 5 comments

Comments

@iBobik
Copy link
Contributor

iBobik commented Dec 26, 2023

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.

@pavlenex
Copy link
Contributor

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

@ndeet
Copy link
Contributor

ndeet commented May 21, 2024

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.

@ndeet
Copy link
Contributor

ndeet commented May 21, 2024

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)

@iBobik
Copy link
Contributor Author

iBobik commented May 21, 2024

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
Copy link
Contributor

ndeet commented May 21, 2024

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.

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

4 participants
@iBobik @ndeet @pavlenex and others