Created
June 30, 2009 18:47
-
-
Save tekin/138327 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
flash[:notice] = 'Your payment was unsuccessful' | |
render :action => 'new', | |
end | |
end | |
# the form that loads into the iframe that redirects the user | |
def three_d_form | |
render :layout => false | |
end | |
# the action that the user is redirected to post authentication where you complete the transaction | |
def three_d_complete | |
@response = @order.complete_three_d_secure(params[:PaRes], params[:MD]) | |
if @response.success? | |
render :action => 'verification_complete', layout => false | |
else | |
render :action => 'verification_failed', :layout => false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment