Files
danbooru/app/controllers/webhooks_controller.rb
evazion 173e43b192 user upgrades: add upgrade code system.
Add a system for upgrading accounts using upgrade codes. Users purchase
an upgrade code off-site then redeem it on-site to upgrade their account
to Gold. Upgrade codes are randomly pre-generated and are one time use
only. Codes have enough randomness that guessing a code is infeasible.
2022-06-01 18:31:46 -05:00

30 lines
744 B
Ruby

# frozen_string_literal: true
class WebhooksController < ApplicationController
skip_forgery_protection only: [:receive, :authorize_net]
rescue_with Stripe::SignatureVerificationError, status: 400
rescue_with DiscordSlashCommand::WebhookVerificationError, status: 401
def receive
case params[:source]
when "stripe"
PaymentTransaction::Stripe.receive_webhook(request)
head 200
when "shopify"
PaymentTransaction::Shopify.receive_webhook(request)
head 200
when "discord"
json = DiscordSlashCommand.receive_webhook(request)
render json: json
else
head 400
end
end
def authorize_net
PaymentTransaction::AuthorizeNet.receive_webhook(request)
head 200
end
end