
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Complete MVC solution to accept charges from users on your Ruby on Rails site
Add to Gemfile:
gem 'supercharged'
run
rails g supercharged:migrations
rails db:migrate
rails g supercharged:views
In your application.js manifest:
//= require supercharged
And then in some assets file:
$ ->
new SuperchargedForm("[role='gateway-charge-form']")
Create config/initializers/supercharged.rb
ActiveMerchant::Billing::Base.integration_mode = Rails.env.production? ? :production : :test
ActiveMerchant::Billing::Base.mode = Rails.env.production? ? :production : :test
Add
supercharged
to your routes.rb somewhere in draw block.
Create view in app/views/supercharged/charges/new.html.haml
= charge_form_for(:paypal, account: 'yourpaypalaccountid', html: {}) do |service|
- service.description 'Write here description that will be shown in paymennt form'
= charge_form_amount_field(service)
= submit_tag 'Pay now'
Create controller in app/controllers/charges_controller.rb and inherit from Supercharged::ChargesController. Then add what you need or change existing methods with 'super'.
class ChargesController < Supercharged::ChargesController
before_filter :authenticate_user! # this is Devise's authenticate method
end
If you create your own controllers then you need to customize routing method:
supercharged controllers: {charges: :charges, gateway_notifications: :gateway_notifications}
Create model in app/models/charge.rb and inherit from Supercharged::Charge::Base
class Charge < ActiveRecord::Base
include Supercharged::Charge::Base
# your custom code here
def approve(real_amount)
transaction do
# update user balance with your own update_balance method or other things you want to do after charged approved
user.update_balance(real_amount)
super
end
end
def min_amount
# specify min value for amount field here
# default is 1
42
end
end
To display validation, supercharged form class has onValidationError
callback:
$ ->
new SuperchargedForm("[role='gateway-charge-form']", {
onValidationError: (errors)->
console.log "supercharged validation errors: ", errors
})
The example app is at https://github.com/divineforest/supercharged-example-app
Supercharged is released under the MIT License
FAQs
Unknown package
We found that supercharged demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.