Skip to content
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

Metabootik PoC : on product sale, send commission to a defined Lightning address #97

Open
Tirodem opened this issue May 30, 2023 · 9 comments
Labels
Component/Lightning coyote-review need coyote review / estimation before going further enhancement New feature or request Feat/Administration Feat/cross-beBOP

Comments

@Tirodem
Copy link
Contributor

Tirodem commented May 30, 2023

Following #96
Restricted to #168 whitelisted npubs

Prerequisite

  • create a "Referral" toggle on /admin/product creation/edition form
    • with a "amount" (%, 0-100) input (mandatory if toggle is true)
    • with a "Lightning address" input
    • with a "Whitelisted Bootik" select dropdown (either "Lightning address" OR "Whitelisted Bootik" is mandatory, and we cannot fill both, otherwise raise error)
    • give the option to add another amount + lightning address/whitelisted bootik entry
    • raise alert on save when sum of defined amounts is >= 100

Use cases

Setting referral on a product

  • When I create a product on my Bootik A, I can define a commission for 0 to n Lightning address (if I want to give a commission to an organism or a person -writer, artist, etc-) or 0 to n Whitelisted Bootiks (for commercial partnership)

Process referral on product sale

  • When the product is sold, after the order :
    • send order.items.product.price.amount x order.items.quantity x amount / 100 through lightning to the target adress
    • create a post-order transaction to track the payment in database and link it to the origin order ID
    • if the target of the referral is a whitelisted Bootik, send a referral payment notification through nostr message to its npub :
      • with the order infos
      • with the referral amount
      • with the paid price
      • with the lightning transaction ID
      • with the product URL

Process referral payment on target's side

  • When Bootik B receive a referral payment notification through NostR
    • if Discovery toggle is off : answer "Cool but I asked for nothing, thanks"
    • if Discovery toggle is on :
      • check the lightning transaction ID and confirm it
      • if KO, log error, stop process
      • if OK, create an order with
        • order.notifications.paymentStatuts.npub = sender Bootik A npub
        • order.payment.method = "Lightning"
        • order.payment.status = "paid"
        • order.payment.paidAt = time of nostR referral payment notification
        • order.items = genetic tip product, like Create a generic tip product with free price #174
          • order.items.type = "referral"
          • order.items.name = "Referral"
          • order.items.name = Bootik A npub + product URL from referral payment notification
@Tirodem
Copy link
Contributor Author

Tirodem commented May 30, 2023

Big question here, I think, is : is it possible to automatically send lightning payment from a request with a rightly setted back-office, or should we include manual validation from the owner of the referred Bootik ?
In that case, I shall make it async and change my conditions a bit.

@Tirodem Tirodem added enhancement New feature or request coyote-review need coyote review / estimation before going further not-mvp labels May 30, 2023
@Tirodem
Copy link
Contributor Author

Tirodem commented May 30, 2023

Note : for this feature, always consider amounts in SATS, not dependig of the Bootik main currency
Note2 : this might force us to stock the 2 amounts when ordering (main currency amount, and SATS real amount if SATS/BTC is 2nd currency)

@Tirodem
Copy link
Contributor Author

Tirodem commented May 31, 2023

Following talk with Lionel, it seems that we can use lnurl for direct payment from the seller to the referral bootik : https://docs.bitnob.com/docs/pay-lnurl-qr
That would make the process easier.

Use case with lnurl :

  • when I create product 123456 on Bootik, I can check "referral" toggle (default : false)
  • when "referral" toggle is "true" for a product, on /admin/product/{id} interface, I can fill 3 inputs :
    • referral ratio (%, 0-100) (mandatory)
    • target lnurl (mandatory)
    • target npub (optional)
  • when user buy product 123546 in qty X on Bootik and order si validated, Bootik :
    • triggers a payment of product 123456 price * qty * referral ratio to target lnurl
    • if filled, sends a message to target npub with : "Hey, I'm Bootik {meta-title} ({url}). Following the sale of {qty} {produit 123456 name}, you deserved your commission of {referral ratio}, so here's {transaction_id} for your {transaction_amount}. Cheers !"

@coyotte508
Copy link
Collaborator

yes we should be able to send sats directly to bootik with it's lightning paymetn address

@Tirodem
Copy link
Contributor Author

Tirodem commented Jun 14, 2023

@coyotte508 I rewrote the US considering that

@Tirodem Tirodem changed the title Metabootik PoC : make referral payment with Lightning between Bootiks Metabootik PoC : on product sale, send commission to a defined Lightning address Jun 14, 2023
@Tirodem
Copy link
Contributor Author

Tirodem commented Jun 14, 2023

Note : instead of using a lightning payment with a lightning address related to a bootik npub, we can think about associating the lightning address of the bootik with its nostr account and use the "Zaps" feature from Nostr.
https://thebitcoinmanual.com/articles/nostr-zaps
But it seems to be highly UI related, I think it's better to separate the lightning payment from the nostr notification.
@ludomire WDYT ?

@ludomire
Copy link

Why not both?

@Tirodem
Copy link
Contributor Author

Tirodem commented Jun 14, 2023

We indeeed can associate automatically Bootik's lightning address with its NostR account to allow users to give us Zaps and be whitelisted in Zaps pool.
Still we'll do with Lightning payment first as I'm not sure it's pertinent to use Zaps from NostR to do lightning payment instead of a direct Lightning payment.
I edit #167 for that.

@coyotte508
Copy link
Collaborator

#214 should be done first

After that, 1 day I guess

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component/Lightning coyote-review need coyote review / estimation before going further enhancement New feature or request Feat/Administration Feat/cross-beBOP
Projects
None yet
Development

No branches or pull requests

3 participants