Skip to content

Instantly share code, notes, and snippets.

<h2>Card Verification and Authorisation</h2>
<p>A message explaining what is happening and what is required of the user.</p>
<iframe src="<%= three_d_form_order_payment_path(@order, :acs_url => @payment.acs_url, :md => @payment.md, :pa_req => @payment.pa_req) %>" name="3diframe" width="350" height="500" frameborder="0">
<p>Your Browser does not support iframes. To verify your card and complete this transaction, please use a browser that does.</p>
</iframe>
<% form_tag(params[:acs_url], :id => '3dform') do %>
<%= hidden_field_tag :PaReq, params[:pa_req] %>
<%= hidden_field_tag :MD, params[:md] %>
<%= hidden_field_tag :TermUrl, three_d_complete_order_payment_url(@order) %>
<noscript>
<p>Click the button below to continue with verification.</p>
<%= submit_tag 'Continue with Card Verfication' %>
</noscript>
<% end %>
<% form_tag complete_order_path(@order), :id => 'reload_frame', :target => '_top', :method => 'get' do %>
<noscript>
<p>Verification complete, click the button below to continue.</p>
<%= submit_tag 'Continue to order confirmation %>
</noscript>
<% end %>
<% javascript_tag do %>
window.onload=function(){
document.getElementById('reload_frame').submit();
}
<% form_tag new_order_payment_path(@order), :id => 'reload_frame', :target => '_top', :method => 'get' do %>
<%= hidden_field_tag :verification_failed, true %>
<noscript>
<p>Verification failed, click the button below to try again.</p>
<%= submit_tag 'Try again' %>
</noscript>
<% end %>
<% javascript_tag do %>
window.onload=function(){
document.getElementById('reload_frame').submit();
def create
@credit_card = ActiveMerchant::Billing::CreditCard.new(params[:credit_card])
@billing_address = Address.new(params[:address])
@payment = @order.payments.create(:credit_card => @credit_card, :address => @billing_address)
if @payment.success?
redirect_to complete_order_url(@order)
elsif @payment.requires_authentication?
# A view with an iframe from which the user is redirected to the authentication page
render :action => 'three_d_iframe'
else
AF:
code: AF
name: Afghanistan
AL:
code: AL
name: Albania
DZ:
code: DZ
name: Algeria
AS:
# install the facebook_api gem first
require 'rubygems'
require 'facebook_api'
FacebookApi.configure do |config|
config.api_key = 'API_KEY_HERE'
config.secret_key = 'SECRET_KEY_HERE'
end
event_info = {:name => 'Event name', :start_time => Time.now.to_i}.to_json
@tekin
tekin / weekends.rb
Created June 6, 2011 08:30 — forked from alterisian/weekends.rb
Weekends left til the end of summer
# Author: Ian Moss aka oceanician : http://twitter.com/oceanician
# First Published: https://gist.github.com/1009253
# modulus is your friend! this works because of the way ruby
# modulus behaves when the dvidend is negative.
def friday_after(date)
date +(5 -date.cwday) % 7
end
# Returns all the Fridays between today and the date specified.
class User < ActiveRecord::Base
has_many :events, :extend => AssociationDefaultAttributes do
def default_attributes
{ :venue => proxy_owner.default_venue }
end
end
end
module AssociationDefaultAttributes
def create(attrs, &block)
module AssociationDefaultAttributes
def create(attrs, &block)
super(default_attributes.merge(attrs), &block)
end
def build(attrs={}, &block)
super(default_attributes.merge(attrs), &block)
end
end