Code Monkey home page Code Monkey logo

paycord's Introduction

Welcome to Paycord

Paid roles for discord using Stripe, Python, Flask & Docker.

Preview

Screenshot 1 Screenshot 2 Screenshot 3

Setup

Production

  • On stripe dashboard, go Developers ➡️ Webhooks ➡️ Add endpoint ➡️ endpoint URL ➡️ "myUrlHere/event" ➡️ "checkout.session.completed" & "customer.subscription.deleted" events required.
  • On stripe dashboard, go Settings ➡️ Customer portal ➡️ Ensure "Update subscriptions" is all disabled ➡️ then update your "Business information"
  • On discord developer portal, go OAuth2 ➡️ General ➡️ Redirects ➡️ "myUrlHere/discord/authorize".
  • Invite discord bot to guild.
  • Download docker-compose.yml
  • sudo docker-compose build; sudo docker-compose up -d
  • Proxy exposed port.
  • Ensure Discord roles for products is below Discord bot.

Development

  • Git clone this repo.
  • pip3 install -r requirements.txt
  • export environment variables in CLI.
export DISCORD_CLIENT_ID="..."
export DISCORD_CLIENT_SECRET="..."
export DISCORD_BOT_TOKEN="..."
export DISCORD_GUILD_ID="..."
export ROOT_DISCORD_IDS="...,..."
export STRIPE_WEBHOOK_SECRET="..."
export STRIPE_API_KEY="..."
  • Run mongodb server.
  • python app.py to run.

Environment variables

  • DISCORD_CLIENT_ID - required
    • Client ID of OAuth2 from Discord developer portal
  • DISCORD_CLIENT_SECRET - required
    • Client Secret of OAuth2 from Discord developer portal
  • DISCORD_BOT_TOKEN - required
    • Bot token from Discord developer portal
  • DISCORD_GUILD_ID - required
    • Enable developer mode & provide the ID for the guild.
  • ROOT_DISCORD_IDS - required
    • Comma separated list of Discord user IDs who can add & remove products.
  • STRIPE_WEBHOOK_SECRET - required
  • STRIPE_API_KEY - required
  • MESSAGE_ON_COMPLETE - optional, by default "Thank you {username} for subscribing to {name} for {currency_symbol}{price}"
    • Leave as blank ("") to disable.
    • Supported parameters
      • id
        • User's discord snowflake ID.
      • username
        • User's discord username.
      • avatar
        • User's avatar hash.
      • discriminator
        • User's discriminator.
      • public_flags
        • User's pubic flags.
      • product_id
        • ID of product brought
      • name
        • Name of product brought.
      • price
        • Price of product brought.
      • description
        • Description of product brought.
      • role_id
        • Role ID of product brought.
      • currency
        • Currency of product.
      • currency_symbol
        • Symbol of currency.
  • MONTHLY_GOAL - optional, by default 0.0 (Disabled)
  • MONTHLY_GOAL_PARAGRAPH - optional, by default "The goal below indicates how much our services cost a month to run.\nYou can help support our service by purchasing one of the packages below."
  • CURRENCY - optional, by default "USD" (Supported currencies)
  • DISCORD_API_URL - optional, by default "https://discord.com/api"
  • LOGO_URL - optional, by default "https://i.imgur.com/d5SBQ6v.png"
  • PAGE_NAME - optional, by default "Paycord"
  • SUBSCRIPTION_RECURRENCE - optional, by default "month" (Supported recurrences)
  • SUBSCRIPTION_INTERVAL - optional, by default 1
  • DISCORD_WEBHOOK - optional, by default disabled
    • Provide a discord webhook to push alerts for new & cancelled subscriptions.
  • MONGO_IP - optional, by default "localhost"
  • MONGO_PORT - optional, by default 27017
  • MONGO_DB - optional, by default "paycord"

TODOs

  • Allow one package to have multiple roles.
  • Form validation for root users (Didn't think this was super important, but would be nice to implement with wtforms.)
  • Allow upgrading of packages.

Thanks to

paycord's People

Contributors

lubricantjam avatar wardpearce avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

tomerheber

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.