forked from mastodon/mastodon
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
655 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
class DonationsController < ApplicationController | ||
layout 'public' | ||
|
||
before_action :authenticate_user! | ||
|
||
def donate | ||
@packages = DonationPackage.visible | ||
end | ||
|
||
def payment_gateways | ||
processed = Ecko::Plugins.sponsor.process(params[:package], current_account) | ||
|
||
binding.pry | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
# == Schema Information | ||
# | ||
# Table name: donations | ||
# | ||
# id :bigint(8) not null, primary key | ||
# account_id :bigint(8) not null | ||
# amount :float not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
|
||
class Donation < ApplicationRecord | ||
belongs_to :account, inverse_of: :donations | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# == Schema Information | ||
# | ||
# Table name: donation_packages | ||
# | ||
# id :bigint(8) not null, primary key | ||
# amount :float | ||
# currency :integer | ||
# title :string | ||
# description :text | ||
# donation_reference :integer default(0) | ||
# visible :boolean default(TRUE) | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
class DonationPackage < ApplicationRecord | ||
scope :visible, -> { where(visible: true) } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.donation | ||
.donation-title Please select one of the following to proceed dontion | ||
.donation-block.grid-4 | ||
- @packages.each do |package| | ||
= link_to(payment_gateways_path(package: package.id)) do | ||
.card.box-widget | ||
%h3= "#{package.amount.to_i}$" | ||
%p{:class => "card-title #{package.title.downcase }" }= package.title | ||
%p.card-description= package.description | ||
.donation-account You have donated 0 amount. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
Ecko::Plugins::Stripe.register( | ||
stripe_api_key: ENV['STRIPE_API_KEY'], | ||
currency: 'USD' | ||
Ecko::Plugins::Stripe.register(stripe_api_key: ENV['STRIPE_API_KEY'], currency: 'USD') | ||
Ecko::Plugins::Sponsor.register( | ||
gateways: [ | ||
{ | ||
name: 'Stripe', | ||
checkout: Ecko::Plugins.stripe.checkout_reference | ||
} | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateDonations < ActiveRecord::Migration[6.1] | ||
def change | ||
create_table :donations do |t| | ||
t.references :account, null: false | ||
t.float :amount, null: false | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class CreateDonationPackages < ActiveRecord::Migration[6.1] | ||
def change | ||
create_table :donation_packages do |t| | ||
t.float :amount | ||
t.integer :currency | ||
t.string :title | ||
t.text :description | ||
t.integer :donation_reference, default: 0 | ||
t.boolean :visible, default: true | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
6 changes: 6 additions & 0 deletions
6
db/migrate/20211219013911_add_sponsor_and_donation_to_accounts.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class AddSponsorAndDonationToAccounts < ActiveRecord::Migration[6.1] | ||
def change | ||
add_column :accounts, :sponsor, :integer, default: 0 | ||
add_column :accounts, :donation_amount, :float, default: 0 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/.bundle/ | ||
/.yardoc | ||
/_yardoc/ | ||
/coverage/ | ||
/doc/ | ||
/pkg/ | ||
/spec/reports/ | ||
/tmp/ | ||
|
||
# rspec failure tracking | ||
.rspec_status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--format documentation | ||
--color | ||
--require spec_helper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
source "https://rubygems.org" | ||
|
||
# Specify your gem's dependencies in ecko-plugins-sponsor.gemspec | ||
gemspec | ||
|
||
gem "rake", "~> 13.0" | ||
|
||
gem "rspec", "~> 3.0" |
Oops, something went wrong.