Skip to content

Webhook to get Kofi payments and donations, save the data on Google Sheets, and submit confirmation emails to clients

License

Notifications You must be signed in to change notification settings

darideveloper/kofi-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



Kofi Api

Kofi Api

Webhook to get Kofi payments and donations, save the data on Google Sheets, and submit confirmation emails to clients

Project type: client


Table of Contents
  1. Build With
  2. Related Projects
  3. Media
  4. Details
  5. Install
  6. Settings
  7. Run
  8. Deploy
  9. Roadmap

Build with

Related projects

Details

For run the project, you should host it, or use a tool link Ngrok, to make public a localhost project.

You need also your Kofi Token, Google Sheet API Key, and Email Credentials.

More details are in the Settings section.

Data from Kofi

Donations

Each time donation, the project gets:

  • date
  • time
  • user name
  • message
  • amount
  • email
  • currency
  • url

Sales

Each time sales, the project gets:

  • date
  • time
  • user name
  • amount
  • email
  • currency
  • shop items
  • shop items links
  • shipping name
  • country
  • shipping
  • url

Commissions

  • date
  • time
  • user name
  • amount
  • email
  • currency
  • country
  • full address
  • url

Install

Third party modules

Install all the python modules from pip:

$ pip install -r requirements.txt

Settings

Enviroment variables

In the file .env, are the main options and settings of the project.

Create a .env file, and place the following content

KOFI_TOKEN=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
GOOGLE_SHEETS=https://docs.google.com/spreadsheets/d/{random-chars}/edit?usp=sharing
[email protected]
EMAIL_PASS=yourpass123*
EMAIL_SUBJECT_STORE=your-store-name
[email protected]

Note: you can see as reference the sample.env file

KOFI_TOKEN

You Kofi token. You can get it ko-fi.com/manage/webhooks, in the advanced section.

kofi token

GOOGLE_SHEETS

The link of the google sheet where data will be saved.

  1. The file can be named as you like, but you should have a sheet named kofi donations, and the following columns in the same order:
  • date
  • time
  • user name
  • message
  • amount
  • email
  • currency
  • url
  1. And a sheet names kofi sales with the columns:
  • date
  • time
  • user name
  • amount
  • email
  • currency
  • shop items
  • shop items links
  • shipping name
  • country
  • shipping
  • url
  1. And a sheet names kofi commissions with the columns:
  • date
  • time
  • user name
  • amount
  • email
  • currency
  • country
  • full address
  • url
  1. After create them, be sure to generate the link with edit permisions. You can do it, following the this tutorial

EMAIL_USER

Your email user, who will send the notifications email to the clients. The project supports gmail, outlook, hotmail, live, yahoo and aol.

EMAIL_PASS

You email password.

Usually, the email services don't allow you to connect directly with your password, instead of that, you should create a secondary password, and use it. Here a tutorial about how to generate an alternative password (application password) in gmaill

EMAIL_SUBJECT_STORE

Store name to generate the thanks email subject, like:

  • Thanks for your support to your-store-name
  • Thanks for purchasing your-store-name

DEBUG_EMAIL_TO

An email where you'll get a notification if something was wrong. It can be the same as EMAIL_USER

Google Sheets credentials

You should create a credentials file from your Google Console, with the same account owner of the Google Sheets file, to allow connect to it.

  1. Generate if following this tutorial.
  2. Download the json file.
  3. Place in the project folder as credentials.json

Setup Kofi Webhook

After deploying the project, update the link provided by your hosting, in ko-fi.com/manage/webhooks

kofi setup webhook

HTML TEMPLATE

You can edit the HTML to submit to the client, after a sale or donation, editing the file templates/thanks.html.

You render the user name, using "user_name" and the event type (Donation, or Shop Order) using "res_type".

Here is the default code and the result email.

Note: if you want to use images, upload then to an image server or github, and place in the HTML only the link

<style>
  @import url('https://fonts.googleapis.com/css2?family=Asap+Condensed:wght@700&display=swap');

  h1 {
    font-family: 'Asap Condensed', sans-serif;
    font-size: 2.5rem;
    text-align: center;
    color:#2c3333;
  }

</style>

<h1>user_name Thanks for your res_type</h1>
<img width="800" src="https://raw.githubusercontent.com/darideveloper/kofi-api-sheets-email/master/imgs/banner.webp">

email sample

Run

Run the flask app with python

python app.py

Deploy

The project has been created to be hosted in Heroku, this is because it is the recommended hosting.

Roadmap

  • WebHook for get donations and payments
  • Save donations data in google sheets
  • Save sales data in google sheets
  • Send email to clients with html template
  • Send email when error happens

About

Webhook to get Kofi payments and donations, save the data on Google Sheets, and submit confirmation emails to clients

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published