upgrades: add authorize.net integration.

Add integration for accepting payments with Authorize.net.

https://developer.authorize.net/hello_world.html
This commit is contained in:
evazion
2022-05-15 00:39:31 -05:00
parent 4b65e96abc
commit 1eb15da7c5
11 changed files with 340 additions and 17 deletions

View File

@@ -4,7 +4,7 @@ class UserUpgradesController < ApplicationController
respond_to :js, :html, :json, :xml
def create
@user_upgrade = authorize UserUpgrade.create(recipient: recipient, purchaser: CurrentUser.user, status: "pending", upgrade_type: params[:upgrade_type])
@user_upgrade = authorize UserUpgrade.create(recipient: recipient, purchaser: CurrentUser.user, status: "pending", upgrade_type: params[:upgrade_type], payment_processor: params[:payment_processor])
@country = params[:country] || CurrentUser.country || "US"
@allow_promotion_codes = params[:promo].to_s.truthy?
@checkout = @user_upgrade.create_checkout!(country: @country, allow_promotion_codes: @allow_promotion_codes)

View File

@@ -1,7 +1,8 @@
# frozen_string_literal: true
class WebhooksController < ApplicationController
skip_forgery_protection only: :receive
skip_forgery_protection only: [:receive, :authorize_net]
rescue_with Stripe::SignatureVerificationError, status: 400
rescue_with DiscordSlashCommand::WebhookVerificationError, status: 401
@@ -17,4 +18,9 @@ class WebhooksController < ApplicationController
head 400
end
end
def authorize_net
PaymentTransaction::AuthorizeNet.receive_webhook(request)
head 200
end
end