Skip to content

Instantly share code, notes, and snippets.

<% 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();
<% 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(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 %>
<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>
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
response = gateway.three_d_complete(pa_res, md)
if response.success?
puts "Authentication complete and purchase successfully made"
else
puts "Purchase not authorised or authentication failed, try again"
end
response = gateway.purchase(100, credit_card)
if response.success?
puts "Purchase successfully made"
elsif response.three_d_secure?
puts "Purchase requires additional 3D Authentication"
else
puts "Purchase not authorised, try again"
end
response = gateway.purchase(100, credit_card)
if response.success?
puts "Purchase successfully made"
else
puts "Purchase not authorised, try again"
end
gateway = ActiveMerchant::Billing::ProtxGateway.new({
:login => 'test',
:password => 'password',
:enable_3d_secure => true
})
git fetch origin other_branch:other_branch
* [new branch] other_branch -> other_branch
git branch
* master
other_branch
git checkout other_branch
# Or, in one swift command:
git checkout -t origin/other_branch