wepay-rails 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +13 -13
- data/VERSION +1 -1
- data/app/controllers/wepay/ipn_controller.rb +3 -2
- data/lib/api/account_methods.rb +35 -0
- data/lib/api/checkout_methods.rb +63 -0
- data/lib/generators/wepay_rails/install/templates/create_wepay_checkout_records.rb +39 -38
- data/lib/helpers/controller_helpers.rb +16 -2
- data/lib/helpers/model_helpers.rb +0 -28
- data/lib/wepay-rails.rb +16 -92
- data/wepay-rails.gemspec +3 -2
- metadata +14 -13
- data/lib/examples/wepay.yml +0 -58
data/README.rdoc
CHANGED
@@ -56,11 +56,6 @@ you can create an IpnController in your rails app.
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
wepay.yml will also need these directives. See the wepay.yml.example file in config.
|
60
|
-
|
61
|
-
When you include WepayRails::Payments, you get the controller actions you need. For instance, initialize_wepay_access_token(auth_code)
|
62
|
-
which completes the Oauth2 handshake with Wepay and get's the access token for future comunications with Wepay.
|
63
|
-
|
64
59
|
Finally, your checkout controller (or some controller that will interact with the Wepay API):
|
65
60
|
|
66
61
|
class Purchase::CheckoutController < Purchase::PurchaseController
|
@@ -94,15 +89,20 @@ Finally, your checkout controller (or some controller that will interact with th
|
|
94
89
|
|
95
90
|
The controller I use for finalizing the checkout - AKA - the controller the user is sent back to after his/her trip to
|
96
91
|
wepay to checkout.
|
97
|
-
class Purchase::FinalizeController < ApplicationController
|
98
|
-
def index
|
99
|
-
# Do something - the user has come back from wepay and need an acknowlegement or something.
|
100
|
-
# For example - my app does something like:
|
101
92
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
93
|
+
class Purchase::FinalizeController < Wepay::ApplicationController
|
94
|
+
def index
|
95
|
+
cart = Cart.find_by_transaction_id(params[:txID])
|
96
|
+
wcr = WepayCheckoutRecord.find_by_checkout_id(params[:checkout_id])
|
97
|
+
|
98
|
+
checkout = wepay_gateway.lookup_checkout(wcr.checkout_id)
|
99
|
+
wcr.update_attributes(checkout)
|
100
|
+
|
101
|
+
# Convert cart to an order?? Move to observer of WepayCheckoutRecord??
|
102
|
+
cart.convert_cart_to_order if wcr.state == 'authorized'
|
103
|
+
|
104
|
+
render :text => wcr.inspect
|
105
|
+
end
|
106
106
|
end
|
107
107
|
|
108
108
|
Example Routes for these:
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
@@ -4,12 +4,13 @@ class Wepay::IpnController < Wepay::ApplicationController
|
|
4
4
|
record = WepayCheckoutRecord.find_by_checkout_id(params[:checkout_id])
|
5
5
|
|
6
6
|
if record.present?
|
7
|
-
wepay_gateway.
|
7
|
+
wepay_gateway.wepay_access_token = record.access_token
|
8
8
|
checkout = wepay_gateway.lookup_checkout(record.checkout_id)
|
9
9
|
record.update_attributes(checkout)
|
10
|
-
render :text =>
|
10
|
+
render :text => "ok"
|
11
11
|
else
|
12
12
|
raise StandardError.new("Wepay IPN: No record found for checkout_id #{params[:checkout_id]}")
|
13
13
|
end
|
14
|
+
|
14
15
|
end
|
15
16
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module WepayRails
|
2
|
+
module Api
|
3
|
+
module AccountMethods
|
4
|
+
def create_account(params)
|
5
|
+
response = self.class.post("#{@base_uri}/account/create", {:headers => wepay_auth_header}.merge!(:body => params))
|
6
|
+
JSON.parse(response.body)
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_account(account_id)
|
10
|
+
response = self.class.post("#{@base_uri}/account", {:headers => wepay_auth_header}.merge!(:body => {:account_id => account_id}))
|
11
|
+
JSON.parse(response.body)
|
12
|
+
end
|
13
|
+
|
14
|
+
def find_account(args)
|
15
|
+
response = self.class.post("#{@base_uri}/account/find", {:headers => wepay_auth_header}.merge!(:body => args))
|
16
|
+
JSON.parse(response.body)
|
17
|
+
end
|
18
|
+
|
19
|
+
def modify_account(params)
|
20
|
+
response = self.class.put("#{@base_uri}/account/modify", {:headers => wepay_auth_header}.merge!(:body => args))
|
21
|
+
JSON.parse(response.body)
|
22
|
+
end
|
23
|
+
|
24
|
+
def delete_account(account_id)
|
25
|
+
response = self.class.post("#{@base_uri}/account/delete", {:headers => wepay_auth_header}.merge!(:body => {:account_id => account_id}))
|
26
|
+
JSON.parse(response.body)
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_account_balance(account_id)
|
30
|
+
response = self.class.post("#{@base_uri}/account/balance", {:headers => wepay_auth_header}.merge!(:body => {:account_id => account_id}))
|
31
|
+
JSON.parse(response.body)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module WepayRails
|
2
|
+
module Api
|
3
|
+
module CheckoutMethods
|
4
|
+
# Many of the settings you pass in here are already factored in from
|
5
|
+
# the wepay.yml file and only need to be overridden if you insist on doing
|
6
|
+
# so when this method is called. The following list of key values are pulled
|
7
|
+
# in for you from your wepay.yml file:
|
8
|
+
#
|
9
|
+
# Note: @wepay_config is your wepay.yml as a Hash
|
10
|
+
# :callback_uri => @wepay_config[:ipn_callback_uri],
|
11
|
+
# :redirect_uri => @wepay_config[:checkout_redirect_uri],
|
12
|
+
# :fee_payer => @wepay_config[:fee_payer],
|
13
|
+
# :type => @wepay_config[:checkout_type],
|
14
|
+
# :charge_tax => @wepay_config[:charge_tax] ? 1 : 0,
|
15
|
+
# :app_fee => @wepay_config[:app_fee],
|
16
|
+
# :auto_capture => @wepay_config[:auto_capture] ? 1 : 0,
|
17
|
+
# :require_shipping => @wepay_config[:require_shipping] ? 1 : 0,
|
18
|
+
# :shipping_fee => @wepay_config[:shipping_fee],
|
19
|
+
# :charge_tax => @wepay_config[:charge_tax],
|
20
|
+
# :account_id => wepay_user['account_id'] # wepay-rails goes and gets this for you, but you can override it if you want to.
|
21
|
+
#
|
22
|
+
#
|
23
|
+
# params hash key values possibilities are:
|
24
|
+
# Parameter: Required: Description:
|
25
|
+
# :account_id Yes The unique ID of the account you want to create a checkout for.
|
26
|
+
# :short_description Yes A short description of what is being paid for.
|
27
|
+
# :long_description No A long description of what is being paid for.
|
28
|
+
# :type Yes The the checkout type (one of the following: GOODS, SERVICE, DONATION, or PERSONAL)
|
29
|
+
# :reference_id No The unique reference id of the checkout (set by the application in /checkout/create
|
30
|
+
# :amount Yes The amount that the payer will pay.
|
31
|
+
# :app_fee No The amount that the application will receive in fees.
|
32
|
+
# :fee_payer No Who will pay the fees (WePay's fees and any app fees). Set to "Payer" to charge fees to the person paying (Payer will pay amount + fees, payee will receive amount). Set to "Payee" to charge fees to the person receiving money (Payer will pay amount, Payee will receive amount - fees). Defaults to "Payer".
|
33
|
+
# :redirect_uri No The uri the payer will be redirected to after paying.
|
34
|
+
# :callback_uri No The uri that will receive any Instant Payment Notifications sent. Needs to be a full uri (ex https://www.wepay.com )
|
35
|
+
# :auto_capture No A boolean value (0 or 1). Default is 1. If set to 0 then the payment will not automatically be released to the account and will be held by WePay in payment state 'reserved'. To release funds to the account you must call /checkout/capture
|
36
|
+
# :require_shipping No A boolean value (0 or 1). If set to 1 then the payer will be asked to enter a shipping address when they pay. After payment you can retrieve this shipping address by calling /checkout
|
37
|
+
# :shipping_fee No The amount that you want to charge for shipping.
|
38
|
+
# :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.
|
39
|
+
def perform_checkout(parms)
|
40
|
+
defaults = {
|
41
|
+
:callback_uri => @wepay_config[:ipn_callback_uri],
|
42
|
+
:redirect_uri => @wepay_config[:checkout_redirect_uri],
|
43
|
+
:fee_payer => @wepay_config[:fee_payer],
|
44
|
+
:type => @wepay_config[:checkout_type],
|
45
|
+
:charge_tax => @wepay_config[:charge_tax] ? 1 : 0,
|
46
|
+
:app_fee => @wepay_config[:app_fee],
|
47
|
+
:auto_capture => @wepay_config[:auto_capture] ? 1 : 0,
|
48
|
+
:require_shipping => @wepay_config[:require_shipping] ? 1 : 0,
|
49
|
+
:shipping_fee => @wepay_config[:shipping_fee],
|
50
|
+
:account_id => @wepay_config[:account_id]
|
51
|
+
}.merge(parms)
|
52
|
+
|
53
|
+
response = self.class.post("#{@base_uri}/checkout/create", {:headers => wepay_auth_header}.merge!(:body => defaults))
|
54
|
+
JSON.parse(response.body)
|
55
|
+
end
|
56
|
+
|
57
|
+
def lookup_checkout(checkout_id)
|
58
|
+
response = self.class.post("#{@base_uri}/checkout", {:headers => wepay_auth_header}.merge!(:body => {:checkout_id => checkout_id}))
|
59
|
+
JSON.parse(response.body)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -1,39 +1,40 @@
|
|
1
|
-
class CreateWepayCheckoutRecords < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
|
4
|
-
create_table :wepay_checkout_records do |t|
|
5
|
-
t.integer :checkout_id
|
6
|
-
t.integer :account_id
|
7
|
-
t.string :auth_code
|
8
|
-
t.string :
|
9
|
-
t.string :
|
10
|
-
t.
|
11
|
-
t.
|
12
|
-
t.
|
13
|
-
t.decimal :
|
14
|
-
t.
|
15
|
-
t.
|
16
|
-
t.decimal :
|
17
|
-
t.
|
18
|
-
t.
|
19
|
-
t.text :
|
20
|
-
t.text :
|
21
|
-
t.
|
22
|
-
t.string :
|
23
|
-
t.
|
24
|
-
t.text :
|
25
|
-
t.
|
26
|
-
t.boolean :
|
27
|
-
t.
|
28
|
-
t.
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
1
|
+
class CreateWepayCheckoutRecords < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
|
4
|
+
create_table :wepay_checkout_records do |t|
|
5
|
+
t.integer :checkout_id
|
6
|
+
t.integer :account_id
|
7
|
+
t.string :auth_code
|
8
|
+
t.string :access_token
|
9
|
+
t.string :state
|
10
|
+
t.string :short_description
|
11
|
+
t.text :long_description
|
12
|
+
t.string :currency
|
13
|
+
t.decimal :amount
|
14
|
+
t.decimal :app_fee
|
15
|
+
t.string :fee_payer
|
16
|
+
t.decimal :gross
|
17
|
+
t.decimal :fee
|
18
|
+
t.string :reference_id
|
19
|
+
t.text :redirect_uri
|
20
|
+
t.text :callback_uri
|
21
|
+
t.text :checkout_uri
|
22
|
+
t.string :payer_email
|
23
|
+
t.string :payer_name
|
24
|
+
t.text :cancel_reason
|
25
|
+
t.text :refund_reason
|
26
|
+
t.boolean :auto_capture
|
27
|
+
t.boolean :require_shipping
|
28
|
+
t.text :shipping_address
|
29
|
+
t.decimal :tax
|
30
|
+
|
31
|
+
t.timestamps
|
32
|
+
end
|
33
|
+
|
34
|
+
add_index :wepay_checkout_records, :checkout_id
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.down
|
38
|
+
drop_table :wepay_checkout_records
|
39
|
+
end
|
39
40
|
end
|
@@ -111,8 +111,22 @@ module WepayRails
|
|
111
111
|
def init_checkout_and_send_user_to_wepay(params, wepayable_object=nil)
|
112
112
|
initialize_wepay_access_token(wepayable_object) if wepayable_object.present?
|
113
113
|
response = wepay_gateway.perform_checkout(params)
|
114
|
-
|
115
|
-
|
114
|
+
|
115
|
+
unless response && response.has_key?('checkout_uri')
|
116
|
+
raise WepayRails::Exceptions::InitializeCheckoutError.new("A problem occurred while trying to checkout.
|
117
|
+
Wepay didn't send us back a checkout uri. Response was: #{response.inspect},
|
118
|
+
Params were: #{params}, Token was: #{wepay_access_token}")
|
119
|
+
end
|
120
|
+
|
121
|
+
wcr_params = {
|
122
|
+
:auth_code => wepay_gateway.wepay_auth_code,
|
123
|
+
:access_token => wepay_access_token,
|
124
|
+
:checkout_id => response['checkout_id']
|
125
|
+
}
|
126
|
+
|
127
|
+
params.merge!(wcr_params)
|
128
|
+
|
129
|
+
WepayCheckoutRecord.create(params)
|
116
130
|
redirect_to response['checkout_uri'] and return
|
117
131
|
end
|
118
132
|
end
|
@@ -1,34 +1,6 @@
|
|
1
1
|
module WepayRails
|
2
2
|
module Helpers
|
3
3
|
module ModelHelpers
|
4
|
-
|
5
|
-
# Create a column on one of your models where the wepay authorization code
|
6
|
-
# will be stored to be used for future transactions. Example:
|
7
|
-
|
8
|
-
# add_column :users, :wepay_auth_code, :string
|
9
|
-
|
10
|
-
# Then in your model, let's say the User model, you tell wepay-rails what the column name is:
|
11
|
-
#
|
12
|
-
# class User < ActiveRecord::Base
|
13
|
-
# wepayable :wepay_auth_code
|
14
|
-
# end
|
15
|
-
def wepayable(*args)
|
16
|
-
wepayable_log = File.open('/tmp/wepayable.log','a')
|
17
|
-
|
18
|
-
wepayable_column = WepayRails::Configuration.wepayable_column
|
19
|
-
|
20
|
-
wepayable_log.puts "Wepayable column is #{wepayable_column}"
|
21
|
-
|
22
|
-
# @wepayable_column is initilized in the Rails::Engine now
|
23
|
-
# and pulled from the wepay.yml file
|
24
|
-
define_method "has_#{wepayable_column}?" do
|
25
|
-
self.send(wepayable_column.to_sym).present?
|
26
|
-
end
|
27
|
-
|
28
|
-
define_method "save_#{wepayable_column}" do |value|
|
29
|
-
self.update_attribute(wepayable_column.to_sym, value)
|
30
|
-
end
|
31
|
-
end
|
32
4
|
end
|
33
5
|
end
|
34
6
|
end
|
data/lib/wepay-rails.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'active_record'
|
2
2
|
require 'helpers/model_helpers'
|
3
3
|
require 'helpers/controller_helpers'
|
4
|
+
require 'api/account_methods'
|
5
|
+
require 'api/checkout_methods'
|
4
6
|
module WepayRails
|
5
7
|
class Configuration
|
6
8
|
@@wepayable_class = nil
|
@@ -70,17 +72,26 @@ module WepayRails
|
|
70
72
|
end
|
71
73
|
|
72
74
|
def access_token(wepayable_object)
|
75
|
+
w_column = WepayRails::Configuration.wepayable_column.to_s.to_sym
|
73
76
|
auth_code = if wepayable_object.is_a?(String)
|
74
77
|
wepayable_object
|
75
|
-
|
76
|
-
wepayable_object.send(
|
78
|
+
elsif wepayable_object.respond_to?(w_column)
|
79
|
+
wepayable_object.send(w_column)
|
77
80
|
end
|
81
|
+
|
82
|
+
unless auth_code.present?
|
83
|
+
raise WepayRails::Exceptions::AccessTokenError.new("The argument, #{wepayable_object.inspect}, passed into the
|
84
|
+
access_token method cannot be used to get an access token. It is neither a string,
|
85
|
+
nor an object containing the auth_code column you specified in wepay.yml.")
|
86
|
+
end
|
87
|
+
|
78
88
|
params = {
|
79
89
|
:client_id => @wepay_config[:client_id],
|
80
90
|
:client_secret => @wepay_config[:client_secret],
|
81
91
|
:redirect_uri => @wepay_config[:redirect_uri],
|
82
92
|
:code => auth_code
|
83
93
|
}
|
94
|
+
|
84
95
|
response = self.class.post("#{@base_uri}/oauth2/token", :body => params)
|
85
96
|
json = JSON.parse(response.body)
|
86
97
|
|
@@ -95,6 +106,7 @@ module WepayRails
|
|
95
106
|
|
96
107
|
raise WepayRails::Exceptions::AccessTokenError.new("A problem occurred trying to get the access token: #{json.inspect}") unless json.has_key?("access_token")
|
97
108
|
|
109
|
+
@wepay_auth_code = auth_code
|
98
110
|
@wepay_access_token = json["access_token"]
|
99
111
|
end
|
100
112
|
|
@@ -132,96 +144,8 @@ module WepayRails
|
|
132
144
|
@wepay_user ||= user_api.call(wepay_auth_header)
|
133
145
|
end
|
134
146
|
|
135
|
-
|
136
|
-
|
137
|
-
# so when this method is called. The following list of key values are pulled
|
138
|
-
# in for you from your wepay.yml file:
|
139
|
-
#
|
140
|
-
# Note: @wepay_config is your wepay.yml as a Hash
|
141
|
-
# :callback_uri => @wepay_config[:ipn_callback_uri],
|
142
|
-
# :redirect_uri => @wepay_config[:checkout_redirect_uri],
|
143
|
-
# :fee_payer => @wepay_config[:fee_payer],
|
144
|
-
# :type => @wepay_config[:checkout_type],
|
145
|
-
# :charge_tax => @wepay_config[:charge_tax] ? 1 : 0,
|
146
|
-
# :app_fee => @wepay_config[:app_fee],
|
147
|
-
# :auto_capture => @wepay_config[:auto_capture] ? 1 : 0,
|
148
|
-
# :require_shipping => @wepay_config[:require_shipping] ? 1 : 0,
|
149
|
-
# :shipping_fee => @wepay_config[:shipping_fee],
|
150
|
-
# :charge_tax => @wepay_config[:charge_tax],
|
151
|
-
# :account_id => wepay_user['account_id'] # wepay-rails goes and gets this for you, but you can override it if you want to.
|
152
|
-
#
|
153
|
-
#
|
154
|
-
# params hash key values possibilities are:
|
155
|
-
# Parameter: Required: Description:
|
156
|
-
# :account_id Yes The unique ID of the account you want to create a checkout for.
|
157
|
-
# :short_description Yes A short description of what is being paid for.
|
158
|
-
# :long_description No A long description of what is being paid for.
|
159
|
-
# :type Yes The the checkout type (one of the following: GOODS, SERVICE, DONATION, or PERSONAL)
|
160
|
-
# :reference_id No The unique reference id of the checkout (set by the application in /checkout/create
|
161
|
-
# :amount Yes The amount that the payer will pay.
|
162
|
-
# :app_fee No The amount that the application will receive in fees.
|
163
|
-
# :fee_payer No Who will pay the fees (WePay's fees and any app fees). Set to "Payer" to charge fees to the person paying (Payer will pay amount + fees, payee will receive amount). Set to "Payee" to charge fees to the person receiving money (Payer will pay amount, Payee will receive amount - fees). Defaults to "Payer".
|
164
|
-
# :redirect_uri No The uri the payer will be redirected to after paying.
|
165
|
-
# :callback_uri No The uri that will receive any Instant Payment Notifications sent. Needs to be a full uri (ex https://www.wepay.com )
|
166
|
-
# :auto_capture No A boolean value (0 or 1). Default is 1. If set to 0 then the payment will not automatically be released to the account and will be held by WePay in payment state 'reserved'. To release funds to the account you must call /checkout/capture
|
167
|
-
# :require_shipping No A boolean value (0 or 1). If set to 1 then the payer will be asked to enter a shipping address when they pay. After payment you can retrieve this shipping address by calling /checkout
|
168
|
-
# :shipping_fee No The amount that you want to charge for shipping.
|
169
|
-
# :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.
|
170
|
-
def perform_checkout(parms)
|
171
|
-
defaults = {
|
172
|
-
:callback_uri => @wepay_config[:ipn_callback_uri],
|
173
|
-
:redirect_uri => @wepay_config[:checkout_redirect_uri],
|
174
|
-
:fee_payer => @wepay_config[:fee_payer],
|
175
|
-
:type => @wepay_config[:checkout_type],
|
176
|
-
:charge_tax => @wepay_config[:charge_tax] ? 1 : 0,
|
177
|
-
:app_fee => @wepay_config[:app_fee],
|
178
|
-
:auto_capture => @wepay_config[:auto_capture] ? 1 : 0,
|
179
|
-
:require_shipping => @wepay_config[:require_shipping] ? 1 : 0,
|
180
|
-
:shipping_fee => @wepay_config[:shipping_fee],
|
181
|
-
:account_id => @wepay_config[:account_id]
|
182
|
-
}.merge(parms)
|
183
|
-
|
184
|
-
response = self.class.post("#{@base_uri}/checkout/create", {:headers => wepay_auth_header}.merge!(:body => defaults))
|
185
|
-
JSON.parse(response.body)
|
186
|
-
end
|
187
|
-
|
188
|
-
def lookup_checkout(*args)
|
189
|
-
checkout_id = args.first
|
190
|
-
parms = args.last if args.last.is_a?(Hash)
|
191
|
-
|
192
|
-
response = self.class.post("#{@base_uri}/checkout", {:headers => wepay_auth_header}.merge!(:body => {:checkout_id => checkout_id}))
|
193
|
-
JSON.parse(response.body)
|
194
|
-
end
|
195
|
-
|
196
|
-
def create_account(params)
|
197
|
-
response = self.class.post("#{@base_uri}/account/create", {:headers => wepay_auth_header}.merge!(:body => params))
|
198
|
-
JSON.parse(response.body)
|
199
|
-
end
|
200
|
-
|
201
|
-
def get_account(account_id)
|
202
|
-
response = self.class.post("#{@base_uri}/account", {:headers => wepay_auth_header}.merge!(:body => { account_id: account_id }))
|
203
|
-
JSON.parse(response.body)
|
204
|
-
end
|
205
|
-
|
206
|
-
def find_account(args)
|
207
|
-
response = self.class.post("#{@base_uri}/account/find", {:headers => wepay_auth_header}.merge!(:body => args))
|
208
|
-
JSON.parse(response.body)
|
209
|
-
end
|
210
|
-
|
211
|
-
def modify_account(params)
|
212
|
-
response = self.class.put("#{@base_uri}/account/modify", {:headers => wepay_auth_header}.merge!(:body => args))
|
213
|
-
JSON.parse(response.body)
|
214
|
-
end
|
215
|
-
|
216
|
-
def delete_account(account_id)
|
217
|
-
response = self.class.post("#{@base_uri}/account/delete", {:headers => wepay_auth_header}.merge!(:body => { account_id: account_id }))
|
218
|
-
JSON.parse(response.body)
|
219
|
-
end
|
220
|
-
|
221
|
-
def get_account_balance(account_id)
|
222
|
-
response = self.class.post("#{@base_uri}/account/balance", {:headers => wepay_auth_header}.merge!(:body => { account_id: account_id }))
|
223
|
-
JSON.parse(response.body)
|
224
|
-
end
|
147
|
+
include WepayRails::Api::CheckoutMethods
|
148
|
+
include WepayRails::Api::AccountMethods
|
225
149
|
end
|
226
150
|
|
227
151
|
include WepayRails::Exceptions
|
data/wepay-rails.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "wepay-rails"
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Adam Medeiros"]
|
@@ -30,7 +30,8 @@ Gem::Specification.new do |s|
|
|
30
30
|
"app/controllers/wepay/authorize_controller.rb",
|
31
31
|
"app/controllers/wepay/ipn_controller.rb",
|
32
32
|
"config/routes.rb",
|
33
|
-
"lib/
|
33
|
+
"lib/api/account_methods.rb",
|
34
|
+
"lib/api/checkout_methods.rb",
|
34
35
|
"lib/generators/wepay_rails/install/install_generator.rb",
|
35
36
|
"lib/generators/wepay_rails/install/templates/create_wepay_checkout_records.rb",
|
36
37
|
"lib/generators/wepay_rails/install/templates/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.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-11-25 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
|
-
requirement: &
|
16
|
+
requirement: &13677460 !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: *13677460
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: shoulda
|
27
|
-
requirement: &
|
27
|
+
requirement: &13676180 !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: *13676180
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &13674860 !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: *13674860
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &13652260 !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: *13652260
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rcov
|
60
|
-
requirement: &
|
60
|
+
requirement: &13649680 !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: *13649680
|
69
69
|
description: Rails gem that interfaces with the WePay API
|
70
70
|
email: adammede@gmail.com
|
71
71
|
executables: []
|
@@ -87,7 +87,8 @@ files:
|
|
87
87
|
- app/controllers/wepay/authorize_controller.rb
|
88
88
|
- app/controllers/wepay/ipn_controller.rb
|
89
89
|
- config/routes.rb
|
90
|
-
- lib/
|
90
|
+
- lib/api/account_methods.rb
|
91
|
+
- lib/api/checkout_methods.rb
|
91
92
|
- lib/generators/wepay_rails/install/install_generator.rb
|
92
93
|
- lib/generators/wepay_rails/install/templates/create_wepay_checkout_records.rb
|
93
94
|
- lib/generators/wepay_rails/install/templates/wepay.yml
|
@@ -113,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
114
|
version: '0'
|
114
115
|
segments:
|
115
116
|
- 0
|
116
|
-
hash:
|
117
|
+
hash: 1958917921115598228
|
117
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
119
|
none: false
|
119
120
|
requirements:
|
data/lib/examples/wepay.yml
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
production:
|
2
|
-
client_id: <your client_id from wepay>
|
3
|
-
client_secret: <your client_secret from wepay>
|
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"
|
7
|
-
scope: ['refund_payments','collect_payments','view_balance','view_user']
|
8
|
-
#wepay_api_uri: "https://api.wepay.com"
|
9
|
-
wepay_api_uri: "https://stage.wepay.com"
|
10
|
-
wepay_api_version: "v2"
|
11
|
-
ipn_callback_uri: "http://www.example.com/wepay/ipn"
|
12
|
-
checkout_redirect_uri: "http://www.noisebytes.com/purchase/finalize"
|
13
|
-
fee_payer: Payee
|
14
|
-
checkout_type: GOODS
|
15
|
-
charge_tax: false
|
16
|
-
app_fee: 0
|
17
|
-
auto_capture: true
|
18
|
-
require_shipping: false
|
19
|
-
shipping_fee: 0
|
20
|
-
charge_tax: false
|
21
|
-
development:
|
22
|
-
client_id: <your client_id from wepay>
|
23
|
-
client_secret: <your client_secret from wepay>
|
24
|
-
auth_code_location: MyModel.wepay_auth_code
|
25
|
-
redirect_uri: "http://dev.noisebytes.com/wepay/authorize"
|
26
|
-
after_authorize_redirect_uri: "http://www.example.com/purchase/checkout"
|
27
|
-
scope: ['refund_payments','collect_payments','view_balance','view_user']
|
28
|
-
wepay_api_uri: "https://stage.wepay.com"
|
29
|
-
wepay_api_version: "v2"
|
30
|
-
ipn_callback_uri: "http://dev.noisebytes.com/wepay/ipn"
|
31
|
-
checkout_redirect_uri: "http://dev.noisebytes.com/purchase/finalize"
|
32
|
-
fee_payer: Payee
|
33
|
-
checkout_type: GOODS
|
34
|
-
charge_tax: false
|
35
|
-
app_fee: 0
|
36
|
-
require_shipping: false
|
37
|
-
shipping_fee: 0
|
38
|
-
charge_tax: false
|
39
|
-
auto_capture: true
|
40
|
-
test:
|
41
|
-
client_id: <your client_id from wepay>
|
42
|
-
client_secret: <your client_secret from wepay>
|
43
|
-
auth_code_location: MyModel.wepay_auth_code
|
44
|
-
redirect_uri: "http://dev.noisebytes.com/wepay/authorize"
|
45
|
-
after_authorize_redirect_uri: "http://www.example.com/purchase/checkout"
|
46
|
-
scope: ['refund_payments','collect_payments','view_balance','view_user']
|
47
|
-
wepay_api_uri: "https://stage.wepay.com"
|
48
|
-
wepay_api_version: "v2"
|
49
|
-
ipn_callback_uri: "http://test.noisebytes.com/wepay/ipn"
|
50
|
-
checkout_redirect_uri: "http://dev.noisebytes.com/purchase/finalize"
|
51
|
-
fee_payer: Payee
|
52
|
-
checkout_type: GOODS
|
53
|
-
charge_tax: false
|
54
|
-
app_fee: 0
|
55
|
-
auto_capture: true
|
56
|
-
charge_tax: false
|
57
|
-
require_shipping: false
|
58
|
-
shipping_fee: 0
|