Browse files

Fix bug on signup and add active_merchant gem

  • Loading branch information...
1 parent 7b23595 commit fcfec2b2440ac88f794c1eda68923aa875bf7797 @yencn02 committed Oct 19, 2011
View
2 Gemfile
@@ -8,6 +8,8 @@ gem 'rails', '3.1.0'
gem 'mysql2'
gem 'omniauth'
gem "fbgraph"
+gem "money"
+gem "activemerchant"
# Gems used only for assets and not required
# in production environments by default.
View
11 Gemfile.lock
@@ -15,6 +15,11 @@ GEM
rack-mount (~> 0.8.2)
rack-test (~> 0.6.1)
sprockets (~> 2.0.0)
+ activemerchant (1.17.0)
+ activesupport (>= 2.3.11)
+ braintree (>= 2.0.0)
+ builder (>= 2.0.0)
+ json (>= 1.5.1)
activemodel (3.1.0)
activesupport (= 3.1.0)
bcrypt-ruby (~> 3.0.0)
@@ -34,6 +39,8 @@ GEM
ansi (1.3.0)
arel (2.2.1)
bcrypt-ruby (3.0.1)
+ braintree (2.11.0)
+ builder (>= 2.0.0)
builder (3.0.0)
coffee-rails (3.1.1)
coffee-script (>= 2.2.0)
@@ -76,6 +83,8 @@ GEM
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
+ money (3.7.1)
+ i18n (~> 0.4)
multi_json (1.0.3)
multi_xml (0.2.2)
multipart-post (1.1.3)
@@ -187,9 +196,11 @@ PLATFORMS
ruby
DEPENDENCIES
+ activemerchant
coffee-rails (~> 3.1.0)
fbgraph
jquery-rails
+ money
mysql2
omniauth
rails (= 3.1.0)
View
3 app/assets/javascripts/payments.js.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
View
3 app/assets/stylesheets/payments.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the payments controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
View
5 app/controllers/payments_controller.rb
@@ -0,0 +1,5 @@
+class PaymentsController < ApplicationController
+ def new
+ end
+
+end
View
1 app/controllers/users_controller.rb
@@ -30,6 +30,7 @@ def create
def activate
logout_keeping_session!
user = User.find_by_activation_code(params[:activation_code]) unless params[:activation_code].blank?
+ puts user.inspect, "==================================="
case
when (!params[:activation_code].blank?) && user && !user.active?
user.activate!
View
2 app/helpers/payments_helper.rb
@@ -0,0 +1,2 @@
+module PaymentsHelper
+end
View
2 app/models/user.rb
@@ -24,7 +24,7 @@ class User < ActiveRecord::Base
:if => lambda { |c| c.provider.blank? }
validates :password, :presence => true, :if => lambda { |c| c.provider.blank? }
- validates :password_comfirmation, :presence => true, :if => lambda { |c| c.provider.blank? }
+ validates :password_confirmation, :presence => true, :if => lambda { |c| c.provider.blank? }
# HACK HACK HACK -- how to do attr_accessible from here?
# prevents a user from submitting a crafted form that bypasses activation
View
22 app/views/payments/new.html.erb
@@ -0,0 +1,22 @@
+<h1>Payments</h1>
+
+<% payment_service_for @order.id, PAYPAL_ACCOUNT,
+ :amount => @order.price, :currency => 'EUR',
+ :service => :paypal do |service|
+
+ service.customer :first_name => current_user.name,
+ :last_name => current_user.surname,
+ :email => current_user.email
+
+ service.item_name @order.items_summary
+
+ # PayPal will POST a callback here when the payment is done
+ service.notify_url notifications_url(@order)
+ # PayPal will take your user here with a POST after he pays
+ service.return_url paypal_return_notifications_url(@order)
+ # PayPal will redirect your user here if he cancels the payment
+ service.cancel_return_url paypal_cancel_notifications_url(@order) %>
+
+ <%= submit_tag 'Pay this order' %>
+<% end %>
+
View
6 config/initializers/active_merchant.rb
@@ -0,0 +1,6 @@
+if Rails.env.production?
+ PAYPAL_ACCOUNT = 'yencn02@live.com'
+else
+ PAYPAL_ACCOUNT = 'yencn02@gmail.com'
+ ActiveMerchant::Billing::Base.mode = :test
+end
View
2 config/routes.rb
@@ -1,5 +1,7 @@
Yenh::Application.routes.draw do
+ get "payments/new"
+
# The priority is based upon order of creation:
# first created -> highest priority.

0 comments on commit fcfec2b

Please sign in to comment.