Giter Club home page Giter Club logo

Comments (1)

dorians avatar dorians commented on August 11, 2024

Payment integration - proposal

Creaiting new payment:

POST /users/me/subscriptions

input:
{
  "tierId": 1
}
output:
{
  "subscriptionId": 1,
  "payUrl": "bitcoin:tb1qufxkm89aybhp600aycm54s5ycdj2pqz9hzxj4l?amount=0.40162157",
  "url": "https://api-demo.forgingblock.io/invoice?id=7hqLE4VN5eS5DyhZLzCVby"
}

Users can have only one subscription activated at the time. If a user doesn't have any, the default tier is used as a fallback.

Canceling subscription:

DELETE /users/me/subscriptions/1

Subscriptions list:

GET /users/me/subscriptions

optional filter: GET /users/me/subscriptions?active=true
output:
[
  {
    "id": 1,
    "tier": "shared",
    "subtier": "free",
    "price": 12.23,
    "dateended": "2019-11-11T12:59:49+00:00",
    "active": true
  }
]

DB changes:

--- a/doc/nautilus.sql
+++ b/doc/nautilus.sql
@@ -26,6 +26,7 @@ create TABLE tiers_configuration(
     dailyhits integer NOT NULL,
     maxresultsetsize integer NOT NULL,
     startdate timestamp NOT NULL,
+    price money NOT NULL,
     FOREIGN KEY (tier, subtier) REFERENCES tiers (tier, subtier)
 );
 create TABLE users(
@@ -56,6 +57,18 @@ create TABLE api_keys(
       REFERENCES users (userid) MATCH SIMPLE
       ON update NO ACTION ON delete NO ACTION
 );
+create TABLE subscriptions(
+    userid integer NOT NULL,
+    tierid serial NOT NULL,
+    price money NOT NULL,
+    dateended timestamp with time zone,
+    CONSTRAINT userid_fk FOREIGN KEY (userid)
+      REFERENCES users (userid) MATCH SIMPLE
+      ON update NO ACTION ON delete NO ACTION
+    CONSTRAINT tierid_fk FOREIGN KEY (tierid)
+      REFERENCES tiers (tierid) MATCH SIMPLE
+      ON update NO ACTION ON delete NO ACTION
+);
 create TABLE usage_left(
     key text NOT NULL,
     daily integer NOT NULL,

Enpoinds from forging block used

POST /create-invoice with IPN
POST /check-invoice-status

Further expansions

  • recurring payments

from nautilus-cloud.

Related Issues (20)

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.