Git Product home page Git Product logo

satspaysession's Introduction

Satspay Session

This micro app delivers a custom Invoice amount from the SatsPayExtension fron LNbits via an FastAPI endpoint.

Why do this? Because we want to be able to specify a lightning invoice in sats with the USD amount (or any other fiat equivalent amount) with a link instead of creating it manually from within the LNBits web interface.

This is a personal service, so in order to use it with your LNBits account you'll need to put in your credentials and then 1 Click deploy to vercel ( See below ) or self host it yourself.

Flow Diagram:

Create LINK ---> convert fiat amt to sats, add optional message ---->

----> forward to SatsPayServer on LNBits --> Display Timed QR Code

LINK Pattern:

https://satspaylink.vercel.app/fiat/{currency}/amt/{value}

You can also just specify the sats amount if you want:

https://satspaylink.vercel.app/amt/100000

this will autogenerate an invoice for 100,000 Sats

Example:

Screenshot 2023-06-19 at 2 26 50 PM

This is a live example, where the repo is deployed at satspaylink.vercel.app and the user specifies currency type and amount at the url:

https://satspaylink.vercel.app/fiat/usd/amt/100

The above link, given the parameters of 100 USD, will calculate the equivalent amount of sats and then redirect the user to a lightning invoice created by the satspayserver extension.

Clicking on the above link will redirect to the lnbits satspay extension with the lightning invoice conversion automatically.

Screenshot 2023-06-08 at 10 29 07 AM

Environment variables

For More information about how SatsPay Server works in LNBits, please visit the extension page and the LNbits.com website

set your LNBits environment variables in vercel

LNBITS_WALLET='your data here'
ONCHAIN_WALLET='your data here'
LNBITS_URL='https://legend.lnbits.com'
INVOICE_API_KEY='your data here'
WEBHOOK='https://yoururlhere.com'
  headers =  {
          "Content-Type": "application/json",
          "X-Api-Key": INVOICE_API_KEY,
        }

Json passed in body

{
  "onchainwallet": "string",
  "lnbitswallet": "string",
  "description": "string",
  "webhook": "string",
  "completelink": "string",
  "completelinktext": "string",
  "custom_css": "string",
  "time": 1,
  "amount": 1,
  "extra": "{\"mempool_endpoint\": \"https://mempool.space\", \"network\": \"Mainnet\"}"
}

FastAPI + Vercel

This example shows how to use FastAPI on Vercel with Serverless Functions using the Python Runtime.

1-Click Deploy to Vercel

Deploy with Vercel

To install

python3 -m venv venv 
source venv/bin/activate
pip install -r requirements.txt

To run this app locally

uvicorn src.app:app --reload

Your application is now available at http://localhost:8000.

satspaysession's People

Contributors

bitkarrot avatar dependabot[bot] avatar

Watchers

 avatar

satspaysession's Issues

webhook issue

Adding onchain and lnbits wallet, with webhook, for some reason when loading the satspay page, the presence of the webhook url means that the invoice is already paid, when it hasn't been paid! yet. Very odd why this is the case.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.