-
-
Notifications
You must be signed in to change notification settings - Fork 371
[feat] Add stripe payments #3184
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #3184 +/- ##
==========================================
+ Coverage 60.51% 61.02% +0.51%
==========================================
Files 105 111 +6
Lines 13817 14296 +479
==========================================
+ Hits 8361 8724 +363
- Misses 5456 5572 +116 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
6056fd4 to
0f73535
Compare
8ee77e6 to
18ed036
Compare
f1f080a to
4e18812
Compare
2882a08 to
d0d1dc5
Compare
| class FiatPaymentSuccessStatus(FiatPaymentStatus): | ||
| paid = True | ||
|
|
||
|
|
||
| class FiatPaymentFailedStatus(FiatPaymentStatus): | ||
| paid = False | ||
|
|
||
|
|
||
| class FiatPaymentPendingStatus(FiatPaymentStatus): | ||
| paid = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enum above would obsolete that
| class FiatPaymentResponse(NamedTuple): | ||
| # when ok is None it means we don't know if this succeeded | ||
| ok: bool | None = None | ||
| checking_id: str | None = None # payment_hash, rcp_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this ever be none?
| from lnbits.tasks import create_task | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this needed here now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# tasks.py
from lnbits.core.services.payments import handle_fiat_payment_confirmation`because now tasks.py imports from services (which is fine) and there is a circular dependecy
| raise ValueError( | ||
| f"The amount exceeds the '{fiat_provider_name}'" | ||
| "faucet wallet balance.", | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
howe about creating a services/fiat_payments.py we already at 1k lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the fiat payment logic is coupled with the regular payment logic (created payments, etc)
| def is_internal(self) -> bool: | ||
| return self.checking_id.startswith("internal_") | ||
| return self.checking_id.startswith("internal_") or self.checking_id.startswith( | ||
| "fiat_" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does is_internal also check if its fiat?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fiat payments are always internal payments, but I wanted to have an explicit prefix for it
2617c5f to
9a0899e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested.
Settings are straightforward and simple. Works good, as expected
Allow stripe payments
This PR allows the admin to configure
stripeas a fiat payment provider.This feature allows all (or a selected subset) of users to RECEIVE payments via stripe.
lnbits_stripe.mp4
User Flow
When the Fiat Provider is configured (
Stripein this case) the end user is allowed to select how it wants to receive the funds (lightning or stripe):If the user selects
Stripethen a Stripe Payment Request is generated instead of a LN bolt11.The buyer/payer can scan the QR code or click on it and it will be redirected to a Stripe checkout page like this one:
After the Stripe payment is completed, Stripe will send a notification to the LNbits instance and the LNbits payment will be marked as successful.
For a user that only has fiat funds, but wants to PAY a bolt11 Lightning Invoice (received from someone) then all it has to do is:
Admin Configs
Admins now have a

Fiat Providerstab where they can configure multiple fiat providers (for now only Stripe is supported):These configs should be self explanatory (they have hints and descriptions).
Todos: