wepay-rails 0.1.83 → 0.1.84
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +62 -31
- data/VERSION +1 -1
- data/app/controllers/wepay/authorize_controller.rb +12 -0
- data/config/routes.rb +1 -0
- data/lib/examples/wepay.yml +7 -1
- data/lib/helpers/controller_helpers.rb +13 -13
- data/lib/helpers/model_helpers.rb +9 -6
- data/lib/wepay-rails.rb +52 -33
- data/wepay-rails.gemspec +2 -1
- metadata +13 -12
data/README.rdoc
CHANGED
@@ -1,23 +1,42 @@
|
|
1
|
+
= IMPORTANT - This gem is under heavy development and is in extreme alpha phase. As soon as it's in a release state (very soon), I will update the MAJOR version to 1. If you are interested in helping, please drop me a message.
|
2
|
+
|
1
3
|
= wepay-rails
|
2
4
|
|
3
5
|
Wepay-Rails allows your rails app to accept payments with Wepay (http://www.wepay.com).
|
4
6
|
|
7
|
+
To install it, add this to your Gemfile
|
8
|
+
|
9
|
+
gem 'wepay-rails'
|
10
|
+
|
5
11
|
Since Wepay uses Oauth2 to authenticate, wepay-rails has been built to handle this for you. You will need to
|
6
12
|
add a column to one of your models to hold the authentication token. For example, if you have a user model:
|
7
13
|
|
8
14
|
Your migration:
|
9
15
|
|
10
|
-
add_column :
|
16
|
+
add_column :my_model, :wepay_auth_code, :string
|
17
|
+
|
18
|
+
Now, tell wepay_rails where it should store/retrieve the auth code.
|
19
|
+
|
20
|
+
You will need a wepay.yml file added to your config directory. Please copy one from the lib/examples folder of the
|
21
|
+
wepay-rails gem and modify it to your needs. In a future release, the copy will happen via a generator. For now, please
|
22
|
+
manually copy it over.
|
23
|
+
|
24
|
+
Snippet of wepay.yml showing the auth_code_location directive:
|
25
|
+
|
26
|
+
production:
|
27
|
+
auth_code_location: MyModel.wepay_auth_code
|
11
28
|
|
12
29
|
Your model:
|
13
30
|
|
14
|
-
class
|
15
|
-
wepayable
|
31
|
+
class MyModel < ActiveRecord::Base
|
32
|
+
wepayable
|
16
33
|
end
|
17
34
|
|
18
|
-
|
35
|
+
Now you will have some convenience methods added to your model, such as save_<your column name> (eg. save_wepay_auth_code)
|
19
36
|
|
20
|
-
You need to also create a new model called WepayCheckoutRecord.
|
37
|
+
You need to also create a new model called WepayCheckoutRecord. It will be updated by wepay's IPN system as changes to the checkout change - such as the status.
|
38
|
+
Wepay-rails handles those IPN notifications for you. You can write observers watching the WepayCheckoutRecord model if you need to have
|
39
|
+
something specific occur when the checkout changes. In future versions, I'll include a generator - but for now, here's the migration to use:
|
21
40
|
|
22
41
|
class CreateWepayCheckoutRecords < ActiveRecord::Migration
|
23
42
|
def self.up
|
@@ -61,26 +80,18 @@ You need to also create a new model called WepayCheckoutRecord. In future versio
|
|
61
80
|
|
62
81
|
|
63
82
|
You will have to set up a few new controllers to handle callbacks and redirects from wepay back to your app.
|
64
|
-
|
83
|
+
I created one called finalize_controller and I use it for a landing page when the customer is finished paying
|
84
|
+
their order. The other controller I created is a checkout_controller - this controller glues all of the auth
|
85
|
+
stuff together - it checks if the user has an auth code and access token so it can do the checkout for you. I am
|
86
|
+
going to look into ways to have wepay-rails do most of the heavy lifting - look for this to change in future versions.
|
87
|
+
For now, here's how to handle it...
|
65
88
|
|
66
|
-
I created a directory under my controllers directory called wepay so I can keep my wepay callback controllers in one place.
|
67
89
|
app
|
68
90
|
|_ controllers
|
69
|
-
|_ wepay
|
70
|
-
|_ authorize_controller.rb
|
71
91
|
|_ purchase
|
72
92
|
|_ checkout_controller.rb
|
73
93
|
|_ finalize_controller.rb
|
74
94
|
|
75
|
-
class Wepay::AuthorizeController < Wepay::ApplicationController
|
76
|
-
def index
|
77
|
-
current_profile.save_wepay_auth_code params[:code]
|
78
|
-
initialize_wepay_access_token(params[:code])
|
79
|
-
|
80
|
-
redirect_to purchase_checkout_index_path
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
95
|
The wepay-rails gem comes with an IpnController already built in for
|
85
96
|
handling requests from wepay about a specific checkout. If you wish to override it,
|
86
97
|
you can create an IpnController in your rails app.
|
@@ -91,11 +102,6 @@ you can create an IpnController in your rails app.
|
|
91
102
|
end
|
92
103
|
end
|
93
104
|
|
94
|
-
Routes for these:
|
95
|
-
namespace :wepay do
|
96
|
-
resources :authorize, :only => [:index]
|
97
|
-
end
|
98
|
-
|
99
105
|
wepay.yml will also need these directives. See the section on wepay.yml
|
100
106
|
|
101
107
|
When you include WepayRails::Payments, you get the controller actions you need. For instance, initialize_wepay_access_token(auth_code)
|
@@ -104,10 +110,24 @@ which completes the Oauth2 handshake with Wepay and get's the access token for f
|
|
104
110
|
Finally, your checkout controller (or some controller that will interact with the Wepay API):
|
105
111
|
|
106
112
|
class Purchase::CheckoutController < Purchase::PurchaseController
|
107
|
-
before_filter :authenticate_account!
|
113
|
+
before_filter :authenticate_account! # I am using devise - this line depends on your authentication scheme
|
114
|
+
|
115
|
+
# PLEASE READ
|
116
|
+
# Notes: (By the way, I am looking into putting most of this heavy lifting into the actual wepay-rails gem
|
117
|
+
# it's self - stay tuned for that)
|
118
|
+
# I am saving the wepay_auth_code in my Profile model. Somewhere in my rails app, I have a method called
|
119
|
+
# current_profile which I use to return the Profile object of my user - this is why I can use current_profile.wepay_auth_code
|
120
|
+
# please dress this up to work for your application.
|
121
|
+
|
122
|
+
# Please pay attention to the flow here though (Note, I am going to find a way to move most of this pain to wepay-rails - stay tuned):
|
123
|
+
# Step 1: check and see if we have saved a wepay_auth_code for the customer. If not, redirect them to wepay to get one
|
124
|
+
# Step 2: check to see if we have a wepay access token to use for Oauth Communications. If not, go get one
|
125
|
+
# Step 3: now do a checkout using the method init_checkout_and_send_user_to_wepay. When they are done paying you, they will be redirected
|
126
|
+
# back to your application - you will set the location they will be redirected back to using the redirect_uri directive
|
127
|
+
# either here - or in wepay.yml. Using it here overrides wepay.yml.
|
108
128
|
|
109
129
|
def index
|
110
|
-
if current_profile.wepay_auth_code.present? #
|
130
|
+
if current_profile.wepay_auth_code.present? # Code used to get the Oauth Access Token
|
111
131
|
if wepay_access_token_exists? # Temporary Oauth Access token from wepay
|
112
132
|
|
113
133
|
cart = current_account.cart # EXAMPLE - get my shopping cart
|
@@ -125,16 +145,21 @@ Finally, your checkout controller (or some controller that will interact with th
|
|
125
145
|
initialize_wepay_access_token(current_profile.wepay_auth_code) # No access token - so go get one
|
126
146
|
end
|
127
147
|
else
|
128
|
-
redirect_to_wepay_for_auth # Customer doesn't have an auth code yet from Wepay - so go get one
|
148
|
+
redirect_to_wepay_for_auth(current_profile) # Customer doesn't have an auth code yet from Wepay - so go get one
|
129
149
|
end
|
130
150
|
end
|
131
151
|
end
|
132
152
|
|
133
153
|
The controller I use for finalizing the checkout - AKA - the controller the user is sent back to after his/her trip to
|
134
|
-
wepay.
|
154
|
+
wepay to checkout.
|
135
155
|
class Purchase::FinalizeController < ApplicationController
|
136
156
|
def index
|
137
|
-
Do something - the user has come back from wepay and need an acknowlegement or something.
|
157
|
+
# Do something - the user has come back from wepay and need an acknowlegement or something.
|
158
|
+
# For example - my app does something like:
|
159
|
+
|
160
|
+
cart = Cart.find_by_transaction_id(params[:txID])
|
161
|
+
# my redirect_uri included a txID so that I can look up the
|
162
|
+
# cart when the customer came back.
|
138
163
|
end
|
139
164
|
end
|
140
165
|
|
@@ -152,7 +177,9 @@ Configuration is done through config/wepay.yml:
|
|
152
177
|
production:
|
153
178
|
client_id: <your client_id from wepay>
|
154
179
|
client_secret: <your client_secret from wepay>
|
155
|
-
|
180
|
+
auth_code_location: MyModel.wepay_auth_code
|
181
|
+
redirect_uri: "http://www.example.com/wepay/authorize"
|
182
|
+
after_authorize_redirect_uri: "http://www.example.com/purchase/checkout"
|
156
183
|
scope: ['refund_payments','collect_payments','view_balance','view_user']
|
157
184
|
#wepay_api_uri: "https://api.wepay.com"
|
158
185
|
wepay_api_uri: "https://stage.wepay.com"
|
@@ -170,7 +197,9 @@ Configuration is done through config/wepay.yml:
|
|
170
197
|
development:
|
171
198
|
client_id: <your client_id from wepay>
|
172
199
|
client_secret: <your client_secret from wepay>
|
200
|
+
auth_code_location: MyModel.wepay_auth_code
|
173
201
|
redirect_uri: "http://dev.example.com/wepay/authorize"
|
202
|
+
after_authorize_redirect_uri: "http://dev.example.com/purchase/checkout"
|
174
203
|
scope: ['refund_payments','collect_payments','view_balance','view_user']
|
175
204
|
wepay_api_uri: "https://stage.wepay.com"
|
176
205
|
wepay_api_version: "v2"
|
@@ -187,12 +216,14 @@ Configuration is done through config/wepay.yml:
|
|
187
216
|
test:
|
188
217
|
client_id: <your client_id from wepay>
|
189
218
|
client_secret: <your client_secret from wepay>
|
190
|
-
|
219
|
+
auth_code_location: MyModel.wepay_auth_code
|
220
|
+
redirect_uri: "http://test.example.com/wepay/authorize"
|
221
|
+
after_authorize_redirect_uri: "http://test.example.com/purchase/checkout"
|
191
222
|
scope: ['refund_payments','collect_payments','view_balance','view_user']
|
192
223
|
wepay_api_uri: "https://stage.wepay.com"
|
193
224
|
wepay_api_version: "v2"
|
194
225
|
ipn_callback_uri: "http://test.example.com/wepay/ipn"
|
195
|
-
checkout_redirect_uri: "http://
|
226
|
+
checkout_redirect_uri: "http://test.example.com/purchase/finalize"
|
196
227
|
fee_payer: Payee
|
197
228
|
checkout_type: GOODS
|
198
229
|
charge_tax: false
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.84
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class Wepay::AuthorizeController < Wepay::ApplicationController
|
2
|
+
def index
|
3
|
+
ref_id = params[:refID]
|
4
|
+
wepayable = @wepayable_class.find(:conditions => ["#{@wepayable_column} = ?", ref_id])
|
5
|
+
rescue => e
|
6
|
+
raise AuthorizationError.new("WepayRails was unable to find the record to save the auth code to. : #{e.message}") unless wepayable.present?
|
7
|
+
|
8
|
+
wepayable.update_attribute(@wepayable_column.to_sym, params[:code])
|
9
|
+
|
10
|
+
redirect_to @wepay_config[:after_authorize_redirect_uri]
|
11
|
+
end
|
12
|
+
end
|
data/config/routes.rb
CHANGED
data/lib/examples/wepay.yml
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
production:
|
2
2
|
client_id: <your client_id from wepay>
|
3
3
|
client_secret: <your client_secret from wepay>
|
4
|
-
|
4
|
+
auth_code_location: MyModel.wepay_auth_code
|
5
|
+
redirect_uri: "http://www.example.com/wepay/authorize"
|
6
|
+
after_authorize_redirect_uri: "http://www.example.com/purchase/checkout"
|
5
7
|
scope: ['refund_payments','collect_payments','view_balance','view_user']
|
6
8
|
#wepay_api_uri: "https://api.wepay.com"
|
7
9
|
wepay_api_uri: "https://stage.wepay.com"
|
@@ -19,7 +21,9 @@ production:
|
|
19
21
|
development:
|
20
22
|
client_id: <your client_id from wepay>
|
21
23
|
client_secret: <your client_secret from wepay>
|
24
|
+
auth_code_location: MyModel.wepay_auth_code
|
22
25
|
redirect_uri: "http://dev.noisebytes.com/wepay/authorize"
|
26
|
+
after_authorize_redirect_uri: "http://www.example.com/purchase/checkout"
|
23
27
|
scope: ['refund_payments','collect_payments','view_balance','view_user']
|
24
28
|
wepay_api_uri: "https://stage.wepay.com"
|
25
29
|
wepay_api_version: "v2"
|
@@ -36,7 +40,9 @@ development:
|
|
36
40
|
test:
|
37
41
|
client_id: <your client_id from wepay>
|
38
42
|
client_secret: <your client_secret from wepay>
|
43
|
+
auth_code_location: MyModel.wepay_auth_code
|
39
44
|
redirect_uri: "http://dev.noisebytes.com/wepay/authorize"
|
45
|
+
after_authorize_redirect_uri: "http://www.example.com/purchase/checkout"
|
40
46
|
scope: ['refund_payments','collect_payments','view_balance','view_user']
|
41
47
|
wepay_api_uri: "https://stage.wepay.com"
|
42
48
|
wepay_api_version: "v2"
|
@@ -2,8 +2,8 @@ module WepayRails
|
|
2
2
|
module Helpers
|
3
3
|
module ControllerHelpers
|
4
4
|
|
5
|
-
def redirect_to_wepay_for_auth(scope=wepay_gateway.scope)
|
6
|
-
redirect_to wepay_gateway.auth_code_url(scope)
|
5
|
+
def redirect_to_wepay_for_auth(wepayable_object, scope=wepay_gateway.scope)
|
6
|
+
redirect_to wepay_gateway.auth_code_url(wepayable_object, scope)
|
7
7
|
end
|
8
8
|
|
9
9
|
# @deprecated Use wepay_gateway instead of gateway
|
@@ -55,17 +55,17 @@ module WepayRails
|
|
55
55
|
# so when this method is called. The following list of key values are pulled
|
56
56
|
# in for you from your wepay.yml file:
|
57
57
|
#
|
58
|
-
# Note: @
|
59
|
-
# :callback_uri => @
|
60
|
-
# :redirect_uri => @
|
61
|
-
# :fee_payer => @
|
62
|
-
# :type => @
|
63
|
-
# :charge_tax => @
|
64
|
-
# :app_fee => @
|
65
|
-
# :auto_capture => @
|
66
|
-
# :require_shipping => @
|
67
|
-
# :shipping_fee => @
|
68
|
-
# :charge_tax => @
|
58
|
+
# Note: @wepay_config is your wepay.yml as a Hash
|
59
|
+
# :callback_uri => @wepay_config[:ipn_callback_uri],
|
60
|
+
# :redirect_uri => @wepay_config[:checkout_redirect_uri],
|
61
|
+
# :fee_payer => @wepay_config[:fee_payer],
|
62
|
+
# :type => @wepay_config[:checkout_type],
|
63
|
+
# :charge_tax => @wepay_config[:charge_tax] ? 1 : 0,
|
64
|
+
# :app_fee => @wepay_config[:app_fee],
|
65
|
+
# :auto_capture => @wepay_config[:auto_capture] ? 1 : 0,
|
66
|
+
# :require_shipping => @wepay_config[:require_shipping] ? 1 : 0,
|
67
|
+
# :shipping_fee => @wepay_config[:shipping_fee],
|
68
|
+
# :charge_tax => @wepay_config[:charge_tax],
|
69
69
|
# :account_id => wepay_user['account_id'] # wepay-rails goes and gets this for you, but you can override it if you want to.
|
70
70
|
#
|
71
71
|
#
|
@@ -13,18 +13,21 @@ module WepayRails
|
|
13
13
|
# wepayable :wepay_auth_code
|
14
14
|
# end
|
15
15
|
def wepayable(*args)
|
16
|
-
@params = args.last if args.last.is_a?(Hash)
|
17
|
-
@@wepayable_column ||= args.first.to_s
|
18
16
|
|
19
|
-
|
20
|
-
|
17
|
+
# @wepayable_column is initilized in the Rails::Engine now
|
18
|
+
# and pulled from the wepay.yml file
|
19
|
+
define_method "has_#{@wepayable_column}?" do
|
20
|
+
self.send(@wepayable_column.to_sym).present?
|
21
21
|
end
|
22
22
|
|
23
|
-
define_method "save_#{
|
24
|
-
self.update_attribute(
|
23
|
+
define_method "save_#{@wepayable_column}" do |value|
|
24
|
+
self.update_attribute(@wepayable_column.to_sym, value)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
def wepayable_column
|
29
|
+
@wepayable_column
|
30
|
+
end
|
28
31
|
end
|
29
32
|
end
|
30
33
|
end
|
data/lib/wepay-rails.rb
CHANGED
@@ -4,12 +4,20 @@ require 'helpers/controller_helpers'
|
|
4
4
|
module WepayRails
|
5
5
|
|
6
6
|
class Engine < Rails::Engine
|
7
|
+
# Initializers
|
8
|
+
initializer "WepayRails.initialize_wepay_rails" do |app|
|
9
|
+
yml = Rails.root.join('config', 'wepay.yml').to_s
|
10
|
+
@wepay_config = YAML.load_file(yml)[Rails.env].symbolize_keys
|
11
|
+
klass, @wepayable_column = @wepay_config[:auth_code_location].split('.')
|
12
|
+
@wepayable_class = eval(klass)
|
13
|
+
end
|
7
14
|
end
|
8
15
|
|
9
16
|
module Exceptions
|
10
17
|
class AccessTokenError < StandardError; end
|
11
18
|
class ExpiredTokenError < StandardError; end
|
12
19
|
class InitializeCheckoutError < StandardError; end
|
20
|
+
class AuthorizationError < StandardError; end
|
13
21
|
end
|
14
22
|
|
15
23
|
module Payments
|
@@ -29,15 +37,15 @@ module WepayRails
|
|
29
37
|
def initialize(*args)
|
30
38
|
@wepay_access_token = args.first
|
31
39
|
|
32
|
-
yml = Rails.root.join('config', 'wepay.yml').to_s
|
33
|
-
|
40
|
+
#yml = Rails.root.join('config', 'wepay.yml').to_s
|
41
|
+
#@config = YAML.load_file(yml)[Rails.env].symbolize_keys
|
34
42
|
|
35
|
-
@scope = @
|
43
|
+
@scope = @wepay_config.delete(:scope)
|
36
44
|
|
37
45
|
# Build the base uri
|
38
46
|
# Default if there isn't a setting for version and/or api uri
|
39
|
-
version = @
|
40
|
-
api_uri = @
|
47
|
+
version = @wepay_config[:wepay_api_version].present? ? @wepay_config[:wepay_api_version] : "v2"
|
48
|
+
api_uri = @wepay_config[:wepay_api_uri].present? ? @wepay_config[:wepay_api_uri] : "https://wepayapi.com"
|
41
49
|
|
42
50
|
@base_uri = "#{api_uri}/#{version}"
|
43
51
|
end
|
@@ -45,9 +53,9 @@ module WepayRails
|
|
45
53
|
def access_token(auth_code)
|
46
54
|
@wepay_auth_code = auth_code
|
47
55
|
query = {
|
48
|
-
:client_id => @
|
49
|
-
:client_secret => @
|
50
|
-
:redirect_uri => @
|
56
|
+
:client_id => @wepay_config[:client_id],
|
57
|
+
:client_secret => @wepay_config[:client_secret],
|
58
|
+
:redirect_uri => @wepay_config[:redirect_uri],
|
51
59
|
:code => auth_code
|
52
60
|
}
|
53
61
|
response = self.class.get("#{@base_uri}/oauth2/token", :query => query)
|
@@ -65,11 +73,22 @@ module WepayRails
|
|
65
73
|
@wepay_access_token = json["access_token"]
|
66
74
|
end
|
67
75
|
|
68
|
-
# Get the auth code for the customer
|
76
|
+
# Get the auth code url that will be used to fetch the auth code for the customer
|
69
77
|
# arguments are the redirect_uri and an array of permissions that your application needs
|
70
78
|
# ex. ['manage_accounts','collect_payments','view_balance','view_user']
|
71
|
-
def auth_code_url(permissions)
|
72
|
-
params = @
|
79
|
+
def auth_code_url(wepayable_object, permissions)
|
80
|
+
params = @wepay_config.merge(:scope => permissions.join(','))
|
81
|
+
|
82
|
+
# Initially set a reference ID to the column created for the wepayable
|
83
|
+
# so that when the redirect back from wepay happens, we can reference
|
84
|
+
# the original wepayable, and then save the new auth code into the reference ID's
|
85
|
+
# place
|
86
|
+
ref_id = Digest::SHA1.hexdigest("#{Time.now.to_i+rand(4)}")
|
87
|
+
|
88
|
+
wepayable_object.update_attribute(wepayable_object.wepayable_column.to_sym, ref_id)
|
89
|
+
|
90
|
+
params[:authorize_redirect_uri] += (params[:authorize_redirect_uri] =~ /\?/ ? "&" : "?") + "refID=#{ref_id}"
|
91
|
+
params[:authorize_redirect_uri] = CGI::escape(params[:authorize_redirect_uri])
|
73
92
|
|
74
93
|
query = params.map do |k, v|
|
75
94
|
"#{k.to_s}=#{v}"
|
@@ -79,7 +98,7 @@ module WepayRails
|
|
79
98
|
end
|
80
99
|
|
81
100
|
def token_url
|
82
|
-
query = @
|
101
|
+
query = @wepay_config.map do |k, v|
|
83
102
|
"#{k.to_s}=#{v}"
|
84
103
|
end.join('&')
|
85
104
|
|
@@ -107,17 +126,17 @@ module WepayRails
|
|
107
126
|
# so when this method is called. The following list of key values are pulled
|
108
127
|
# in for you from your wepay.yml file:
|
109
128
|
#
|
110
|
-
# Note: @
|
111
|
-
# :callback_uri => @
|
112
|
-
# :redirect_uri => @
|
113
|
-
# :fee_payer => @
|
114
|
-
# :type => @
|
115
|
-
# :charge_tax => @
|
116
|
-
# :app_fee => @
|
117
|
-
# :auto_capture => @
|
118
|
-
# :require_shipping => @
|
119
|
-
# :shipping_fee => @
|
120
|
-
# :charge_tax => @
|
129
|
+
# Note: @wepay_config is your wepay.yml as a Hash
|
130
|
+
# :callback_uri => @wepay_config[:ipn_callback_uri],
|
131
|
+
# :redirect_uri => @wepay_config[:checkout_redirect_uri],
|
132
|
+
# :fee_payer => @wepay_config[:fee_payer],
|
133
|
+
# :type => @wepay_config[:checkout_type],
|
134
|
+
# :charge_tax => @wepay_config[:charge_tax] ? 1 : 0,
|
135
|
+
# :app_fee => @wepay_config[:app_fee],
|
136
|
+
# :auto_capture => @wepay_config[:auto_capture] ? 1 : 0,
|
137
|
+
# :require_shipping => @wepay_config[:require_shipping] ? 1 : 0,
|
138
|
+
# :shipping_fee => @wepay_config[:shipping_fee],
|
139
|
+
# :charge_tax => @wepay_config[:charge_tax],
|
121
140
|
# :account_id => wepay_user['account_id'] # wepay-rails goes and gets this for you, but you can override it if you want to.
|
122
141
|
#
|
123
142
|
#
|
@@ -139,16 +158,16 @@ module WepayRails
|
|
139
158
|
# :charge_tax No A boolean value (0 or 1). If set to 1 and the account has a relevant tax entry (see /account/set_tax), then tax will be charged.
|
140
159
|
def perform_checkout(parms)
|
141
160
|
defaults = {
|
142
|
-
:callback_uri => @
|
143
|
-
:redirect_uri => @
|
144
|
-
:fee_payer => @
|
145
|
-
:type => @
|
146
|
-
:charge_tax => @
|
147
|
-
:app_fee => @
|
148
|
-
:auto_capture => @
|
149
|
-
:require_shipping => @
|
150
|
-
:shipping_fee => @
|
151
|
-
:account_id => @
|
161
|
+
:callback_uri => @wepay_config[:ipn_callback_uri],
|
162
|
+
:redirect_uri => @wepay_config[:checkout_redirect_uri],
|
163
|
+
:fee_payer => @wepay_config[:fee_payer],
|
164
|
+
:type => @wepay_config[:checkout_type],
|
165
|
+
:charge_tax => @wepay_config[:charge_tax] ? 1 : 0,
|
166
|
+
:app_fee => @wepay_config[:app_fee],
|
167
|
+
:auto_capture => @wepay_config[:auto_capture] ? 1 : 0,
|
168
|
+
:require_shipping => @wepay_config[:require_shipping] ? 1 : 0,
|
169
|
+
:shipping_fee => @wepay_config[:shipping_fee],
|
170
|
+
:account_id => @wepay_config[:account_id]
|
152
171
|
}.merge(parms)
|
153
172
|
|
154
173
|
response = self.class.get("#{@base_uri}/checkout/create", {:headers => wepay_auth_header}.merge!(:query => defaults))
|
data/wepay-rails.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{wepay-rails}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.84"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{Adam Medeiros}]
|
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
"Rakefile",
|
28
28
|
"VERSION",
|
29
29
|
"app/controllers/wepay/application_controller.rb",
|
30
|
+
"app/controllers/wepay/authorize_controller.rb",
|
30
31
|
"app/controllers/wepay/ipn_controller.rb",
|
31
32
|
"config/routes.rb",
|
32
33
|
"lib/examples/wepay.yml",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wepay-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.84
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-09-04 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
|
-
requirement: &
|
16
|
+
requirement: &24170840 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *24170840
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: shoulda
|
27
|
-
requirement: &
|
27
|
+
requirement: &24170240 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *24170240
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &24169500 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.0.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *24169500
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &24168940 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.6.4
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *24168940
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rcov
|
60
|
-
requirement: &
|
60
|
+
requirement: &24168440 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *24168440
|
69
69
|
description: Rails gem that interfaces with the WePay API
|
70
70
|
email: adammede@gmail.com
|
71
71
|
executables: []
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- Rakefile
|
85
85
|
- VERSION
|
86
86
|
- app/controllers/wepay/application_controller.rb
|
87
|
+
- app/controllers/wepay/authorize_controller.rb
|
87
88
|
- app/controllers/wepay/ipn_controller.rb
|
88
89
|
- config/routes.rb
|
89
90
|
- lib/examples/wepay.yml
|
@@ -108,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
109
|
version: '0'
|
109
110
|
segments:
|
110
111
|
- 0
|
111
|
-
hash: -
|
112
|
+
hash: -3382167149595370739
|
112
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
114
|
none: false
|
114
115
|
requirements:
|