Add configurable LNbits invoice memos and pubkey metadata
Read INVOICE_MEMO_YEARLY and INVOICE_MEMO_LIFETIME from the environment and pass the user pubkey in LNbits payment extra for invoice creation.
This commit is contained in:
@@ -20,6 +20,8 @@ type Pricing struct {
|
||||
YearlySats int64
|
||||
LifetimeSats int64
|
||||
ExpiryMins int
|
||||
MemoYearly string
|
||||
MemoLifetime string
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
@@ -131,17 +133,15 @@ func (s *Service) Create(ctx context.Context, req CreateRequest) (*PendingInvoic
|
||||
}
|
||||
|
||||
amount := s.pricing.YearlySats * int64(req.Years)
|
||||
memo := s.pricing.MemoYearly
|
||||
if req.SubscriptionType == user.SubLifetime {
|
||||
amount = s.pricing.LifetimeSats
|
||||
}
|
||||
|
||||
memo := fmt.Sprintf("%s@%s", username, s.domain)
|
||||
if isRenewal {
|
||||
memo = "renewal: " + memo
|
||||
memo = s.pricing.MemoLifetime
|
||||
}
|
||||
|
||||
expirySecs := s.pricing.ExpiryMins * 60
|
||||
hash, request, err := s.lnbits.Create(ctx, amount, memo, expirySecs)
|
||||
extra := map[string]string{"pubkey": req.Pubkey}
|
||||
hash, request, err := s.lnbits.Create(ctx, amount, memo, expirySecs, extra)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user