[c-lightning] CLN commando payment links, now powering the Damus shopify store!
William Casarin
jb55 at jb55.com
Fri Sep 8 05:45:16 AEST 2023
Hey guys n gals,
Awhile back I made this proof of concept using commando+lnsocket for
generating bolt11 invoices dynamically, a kind of bootleg version of
bolt12.
This proof of concept is now powering lightning payments on the Damus
shopify merch store (https://store.damus.io) !
How it works
------------
Code: https://github.com/jb55/cln-payment-links
Demo: http://lnlink.org
Example: http://lnlink.org/?d=ASED88EIzNU2uFJoQfClxYISu55lhKHrSTCA58HMNPgtrXECbW9uYWQuZW5kcG9pbnQuamI1NS5jb206ODMyNAADYAego9kAnmQBTmdZ0uqhrkXuFX-qs8CckOUKN29B0bf8PTEyMCZtZXRob2Q9aW52b2ljZXxtZXRob2Q9d2FpdGludm9pY2UmcG5hbWVsYWJlbF5sbmxpbmstJnJhdGU9OAREZWF0aCBTdGFyAAUAAABkBkFuIG9iamVjdCBvZiB1bmZhdGhvbWFibGUgcG93ZXIuIFBsZWFzZSBlbnRlciB5b3VyIGFkZHJlc3MgZm9yIGRlbGl2ZXJ5LgAHAghodHRwczovL3VwbG9hZC53aWtpbWVkaWEub3JnL3dpa2lwZWRpYS9lbi9mL2Y5L0RlYXRoX3N0YXIxLnBuZwA%3D
lnlink.org is a webserver-less lightning app that talks directly to CLN
nodes via commando over websockets.
All page data is stored in the URL:
* nodeid
* ip
* authentication rune (invoice, waitinvoice)
* product name
* description
* price
* form input fields
When the user clicks buy, it connects to the configured lightning node
and calls the invoice rpc with commando.
A bolt11 invoice is returned with the configured price, and the
description is set to the product name, description, and form input
fields
User pays, and page is updated with notification of payment via waitinvoice.
Shopify integration
-------------------
To make this work with shopify, I modified lnlink.org to support dynamic
fiat prices in the url, so that when shopify sends the Order
confirmation email, the shopify template can be updated to include this
payment link:
Template: <a href="https://tls.lnlink.org/?d=ASED88EIzNU2uFJoQfClxYISu55lhKHrSTCA58HMNPgtrXECcHJveHkubG5saW5rLm9yZy9tb25hZC5lbmRwb2ludC5qYjU1LmNvbQADYAego9kAnmQBTmdZ0uqhrkXuFX-qs8CckOUKN29B0bf8PTEyMCZtZXRob2Q9aW52b2ljZXxtZXRob2Q9d2FpdGludm9pY2UmcG5hbWVsYWJlbF5sbmxpbmstJnJhdGU9OAREYW11cyBNZXJjaCBQYXltZW50AAZUaGFua3MgZm9yIHlvdXIgcHVyY2hhc2UhAA%3D%3D&fiat={{ total_price }}&ordernumber={{ order_name }}">
Picture: https://jb55.com/s/9ee58cf3a0a9e40a.png
Example: https://tls.lnlink.org/?d=ASED88EIzNU2uFJoQfClxYISu55lhKHrSTCA58HMNPgtrXECcHJveHkubG5saW5rLm9yZy9tb25hZC5lbmRwb2ludC5qYjU1LmNvbQADYAego9kAnmQBTmdZ0uqhrkXuFX-qs8CckOUKN29B0bf8PTEyMCZtZXRob2Q9aW52b2ljZXxtZXRob2Q9d2FpdGludm9pY2UmcG5hbWVsYWJlbF5sbmxpbmstJnJhdGU9OAREYW11cyBNZXJjaCBQYXltZW50AAZUaGFua3MgZm9yIHlvdXIgcHVyY2hhc2UhAA%3D%3D&fiat=6999&ordernumber=x1235test
The last bit of automation would be to write a waitanyinvoice script
that looks for these invoices and marks the order as paid with the
shopify api, but for now we're just doing this manually.
Thought this might be interesting to those running CLN nodes. I really
like the "lightning app" idea, it reminds me of "nostr apps", where all
the logic is in the client instead of putting business logic on servers.
Cheers,
Will
More information about the c-lightning
mailing list