wepay-rails 0.1.41 → 0.1.42

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.rdoc +91 -1
  2. data/VERSION +1 -1
  3. data/wepay-rails.gemspec +2 -2
  4. metadata +13 -13
@@ -1,6 +1,96 @@
1
1
  = wepay-rails
2
2
 
3
- Description goes here.
3
+ Wepay-Rails allows your rails app to accept payments with Wepay (http://www.wepay.com).
4
+
5
+ Since Wepay uses Oauth2 to authenticate, wepay-rails has been built to handle this for you. You will need to
6
+ add a column to one of your models to hold the authentication token. For example, if you have a user model:
7
+
8
+ Your migration:
9
+
10
+ add_column :users, :wepay_auth_code, :string
11
+
12
+ Your model:
13
+
14
+ class User < ActiveRecord::Base
15
+ wepayable :wepay_auth_code
16
+ end
17
+
18
+ Adding wepayable to your model also adds some helpful methods to your model, like save_<your column name>
19
+
20
+ You'll need a controller and action for wepay to call back - add the entry to your routes file:
21
+
22
+ class Wepay::AuthorizeController < ApplicationController
23
+ before_filter :authenticate_account!
24
+
25
+ def index
26
+ current_user.save_wepay_auth_code params[:code]
27
+ initialize_wepay_access_token(params[:code])
28
+
29
+ redirect_to purchase_checkout_index_path
30
+ end
31
+
32
+ private
33
+ include WepayRails::Payments
34
+ end
35
+
36
+ When you include WepayRails::Payments, you get the controller actions you need. For instance, initialize_wepay_access_token(auth_code)
37
+ which completes the Oauth2 handshake with Wepay and get's the access token for future comunications with Wepay.
38
+
39
+ Finally, your checkout controller (or some controller that will interact with the Wepay API):
40
+
41
+ class Purchase::CheckoutController < ApplicationController
42
+ before_filter :authenticate_account!
43
+
44
+ def index
45
+ if current_user.has_wepay_auth_code?
46
+ if wepay_access_token_exists?
47
+ # Send payment off to wepay or get the user or something else
48
+ render :json => gateway.wepay_user
49
+ return
50
+ else
51
+ initialize_wepay_access_token(current_user.wepay_auth_code)
52
+ end
53
+ else
54
+ redirect_to_wepay_for_auth
55
+ end
56
+ end
57
+
58
+ private
59
+ include WepayRails::Payments
60
+ end
61
+
62
+ First, we check to see if we have saved the auth code for the user, if so, we next need to see if we have an Oauth2 access token.
63
+ If not, we can initialize the access token. If it is there, go ahead and make an api call - the example above gets the
64
+ wepay_user.
65
+
66
+ Configuration is done through config/wepay.yml:
67
+
68
+ production:
69
+ client_id: <your wepay client id>
70
+ client_secret: <your wepay client secret code>
71
+ redirect_uri: "<your callback url in your rails app>"
72
+ scope: ['refund_payments','collect_payments','view_balance','view_user']
73
+ #wepay_api_uri: "https://api.wepay.com"
74
+ wepay_api_uri: "https://stage.wepay.com"
75
+ wepay_api_version: "v2"
76
+
77
+ development:
78
+ client_id: 12345
79
+ client_secret: 12345asdfg
80
+ redirect_uri: "http://www.example.com/wepay/authorize"
81
+ scope: ['refund_payments','collect_payments','view_balance','view_user']
82
+ wepay_api_uri: "https://stage.wepay.com"
83
+ wepay_api_version: "v2"
84
+
85
+ test:
86
+ client_id: 12345
87
+ client_secret: 12345asdfg
88
+ redirect_uri: "http://www.example.com/wepay/authorize"
89
+ scope: ['refund_payments','collect_payments','view_balance','view_user']
90
+ wepay_api_uri: "https://stage.wepay.com"
91
+ wepay_api_version: "v2"
92
+
93
+
4
94
 
5
95
  == Contributing to wepay-rails
6
96
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.41
1
+ 0.1.42
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{wepay-rails}
8
- s.version = "0.1.41"
8
+ s.version = "0.1.42"
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"]
12
- s.date = %q{2011-07-21}
12
+ s.date = %q{2011-07-22}
13
13
  s.description = %q{Rails gem that interfaces with the WePay API}
14
14
  s.email = %q{adammede@gmail.com}
15
15
  s.extra_rdoc_files = [
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.41
4
+ version: 0.1.42
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-21 00:00:00.000000000 -07:00
12
+ date: 2011-07-22 00:00:00.000000000 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
17
- requirement: &2151865320 !ruby/object:Gem::Requirement
17
+ requirement: &2151866740 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2151865320
25
+ version_requirements: *2151866740
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: shoulda
28
- requirement: &2151863940 !ruby/object:Gem::Requirement
28
+ requirement: &2151865300 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *2151863940
36
+ version_requirements: *2151865300
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bundler
39
- requirement: &2151862460 !ruby/object:Gem::Requirement
39
+ requirement: &2151864020 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 1.0.0
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2151862460
47
+ version_requirements: *2151864020
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: jeweler
50
- requirement: &2151860200 !ruby/object:Gem::Requirement
50
+ requirement: &2151861920 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 1.6.4
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *2151860200
58
+ version_requirements: *2151861920
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: rcov
61
- requirement: &2151857700 !ruby/object:Gem::Requirement
61
+ requirement: &2151859400 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,7 +66,7 @@ dependencies:
66
66
  version: '0'
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *2151857700
69
+ version_requirements: *2151859400
70
70
  description: Rails gem that interfaces with the WePay API
71
71
  email: adammede@gmail.com
72
72
  executables: []
@@ -107,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  segments:
109
109
  - 0
110
- hash: 2040360273608526584
110
+ hash: 1019805336201408693
111
111
  required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  none: false
113
113
  requirements: