Implement bitcoin donations via BTCPay

This commit is contained in:
2024-02-14 11:09:03 +01:00
parent 26d613bdca
commit 079ee8833c
46 changed files with 1142 additions and 114 deletions

View File

@@ -0,0 +1,9 @@
class ChangeDonationAmountsAndCurrency < ActiveRecord::Migration[7.1]
def change
rename_column :donations, :amount_usd, :fiat_amount
add_column :donations, :fiat_currency, :string, default: "USD"
remove_column :donations, :amount_eur, :integer
Donation.update_all(fiat_currency: 'USD')
end
end

View File

@@ -0,0 +1,7 @@
class AddNewDonationFields < ActiveRecord::Migration[7.1]
def change
add_column :donations, :donation_method, :string
add_column :donations, :payment_method, :string, default: nil
add_column :donations, :btcpay_invoice_id, :string, default: nil
end
end

View File

@@ -0,0 +1,8 @@
class AddPaymentStatusToDonations < ActiveRecord::Migration[7.1]
def change
add_column :donations, :payment_status, :string, default: nil
add_index :donations, :payment_status
Donation.completed.update_all payment_status: "settled"
end
end

View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.1].define(version: 2024_02_07_080515) do
ActiveRecord::Schema[7.1].define(version: 2024_02_16_124640) do
create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
@@ -50,12 +50,16 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_07_080515) do
create_table "donations", force: :cascade do |t|
t.integer "user_id"
t.integer "amount_sats"
t.integer "amount_eur"
t.integer "amount_usd"
t.integer "fiat_amount"
t.string "public_name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "paid_at", precision: nil
t.string "fiat_currency", default: "USD"
t.string "donation_method"
t.string "payment_method"
t.string "btcpay_invoice_id"
t.string "payment_status"
t.index ["user_id"], name: "index_donations_on_user_id"
end