cal.com icon indicating copy to clipboard operation
cal.com copied to clipboard

WIP: implementation lightning network app

Open Totenfluch opened this issue 3 years ago • 5 comments

What does this PR do?

Implementation of Bitcoin Lightning as Plugin

Environment: Production

Type of change

  • [x] New feature (non-breaking change which adds functionality)

How should this be tested?

  • [x] Create a Lightning Wallet and obtain a LN Name or LN URL
  • [x] Insert the LN Name / LN URL into the App Config
  • [x] Activate the Plugin for a Booking
  • [x] Book a meeting
  • [x] Check if sats were received after booking

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project
  • I haven't performed a self-review of my own code and corrected any misspellings
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my PR needs changes to the documentation
  • I haven't checked if my changes generate no new warnings
  • I haven't added tests that prove my fix is effective or that my feature works
  • I haven't checked if new and existing unit tests pass locally with my changes

Totenfluch avatar Jan 07 '23 13:01 Totenfluch

@Totenfluch is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Jan 07 '23 13:01 vercel[bot]

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cal ❌ Failed (Inspect) May 22, 2023 3:57pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
ui ⬜️ Ignored (Inspect) Visit Preview May 22, 2023 3:57pm

vercel[bot] avatar Jan 07 '23 20:01 vercel[bot]

Missing things:

  • How to display the QR Code (lightning payment) to the client on the frontend side; which file needs to be created/edited for it
  • How to display the price to the client in the frontend and which currency to use
  • How to fetch the app settings that were created after the installation and in which file should the invoice be created?

After those, I think it's complete

Totenfluch avatar Jan 07 '23 22:01 Totenfluch

Missing things:

How to display the QR Code (lightning payment) to the client on the frontend side; which file needs to be created/edited for it How to display the price to the client in the frontend and which currency to use How to fetch the app settings that were created after the installation and in which file should the invoice be created? After those, I think it's complete

@zomars can help and answer those in your upcoming call 🙏

we may add a PaymentGate abstraction as well, maybe not in this PR but pretty soon to make it easier to add more payment methods (Razorpay, PayPal, ...) in the future

PeerRich avatar Jan 07 '23 23:01 PeerRich

@Totenfluch We just finished implementing a PaymentService class and this should help with the adoption of new payment methods. Still not live on production but should be accesible from main branch. Basically we use a base Class so any new payment provider should follow. https://github.com/calcom/cal.com/blob/main/packages/lib/PaymentService.ts If payment service requires to show custom UI element or redirect you should be able to achieve this now. I'll leave you my link if you require more info -> https://app.cal.com/alan/15min

Or if you require help updating this PR do let me know!

alannnc avatar Feb 08 '23 22:02 alannnc

@alannnc

I have implemented it was far as I could and have added comments in the PaymentService.ts when something was unclear or seemed unfinished to me. I have also booked a timeslot with you, thanks for the opportunity!

Things that are missing:

  • Correctly import the App Config that is created by the user in the server file so we can create payments
  • importing the lightning decoder dependency with turbo
  • Update the Payment, when the user has paid the invoice. The checking code is in there but I don't get the flow. The related rethink payment flows PR is probably the reason for this
  • getPaymentPaidStatus and getPaymentDetails are missing parameters or I'm missing that they are actually stateful but it doesn't seem like it
  • Does the link in paymentInfo display to the frontend?
  • the Infrastruture for the ln-gateway that is currently hosted by us should be migrated to your servers once the PoC is complete
  • (support for LNURL, probably not in this PoC)

Totenfluch avatar Feb 19 '23 15:02 Totenfluch

thank you for the update! anything we can help with? Those open points sound like something our core team doesn't know much about yet

PeerRich avatar Feb 19 '23 15:02 PeerRich

@PeerRich

Things your Team can help me with:

  • Understand the internal storage of the app credentials better. I think I have implemented it correctly but as there is no documentation, I'm unsure
  • How are new imports added to the project? It seems like a library called "turbo" is used in your project which changes the way new imports are added to the project. As I don't want to break anything here, the team should be able to help

Things that I think still need to be worked on from your side to make this PR possible:

  • Update the Payment, when the user has paid the invoice. I implemented the flow for the Lightning invoice how I think it should work but this is unclear to me as it is not implemented in the stripe file. The related rethink payment flows PR is probably the reason for this
  • getPaymentPaidStatus and getPaymentDetails are missing parameters or I'm missing that they are actually stateful but it doesn't seem like it. Basically the function signature needs to be "async getPaymentPaidStatus(paymentId: Payment["id"]) : Promise" but it is "getPaymentPaidStatus(): Promise". Same for getPaymentDetails.
  • It is unclear, how the frontend can be changed and which parameters are responsible for the frontend. I could dig deep into the code here but I don't think it would be very useful for me to do so

Things we should discuss after this PoC works:

  • the Infrastruture for the ln-gateway that is currently hosted by us should be migrated to your servers
  • support for LNURL and other lightning features

Totenfluch avatar Feb 19 '23 16:02 Totenfluch

whats missing for this to leave draft? I wonder if we can merge this in an MVP stage and manually confirm payments

PeerRich avatar May 22 '23 15:05 PeerRich

also the branch seems to be locked, I don't think I can update it

PeerRich avatar May 22 '23 15:05 PeerRich