activewepay 1.0.1 → 1.0.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.
- checksums.yaml +8 -8
- data/README.md +33 -2
- data/activewepay.gemspec +1 -1
- data/lib/activewepay.rb +29 -27
- data/lib/activewepay/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Yzk2OThkM2Y4YmQzOTM4YTJjYzM0NmRiY2QzMGM0YzhhYjczNmRmYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZmI0OTY1MzEyZjNmOGEzYWQwZWI0N2U2MGE1NTgzYjQ0MmZkNjZlZA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NGQ5NjIxZjA3NzUyMTRmNTQxYjVmODAxMWZlMWU2OTdmNDJkZjYwMTJhZDc4
|
10
|
+
NjFlMDkyYzJlNTNkYmYwNmNkZTc2ZGYxYmU5N2QxNTBhZTAwNmE4ZjdhMjYx
|
11
|
+
YjcyNThjYWMwZWNhMGVkODMzMmI1OTczNmEyODk1ZTk5ZmQ1MmQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2NiMTYyOWIxYTM3NjI1Yzc1NjdkZWFiNWMwOWMxZGRlNjU1MmRhN2E5ZWZm
|
14
|
+
YmQyZjA4NDVhOTVjMmMyNzQ2Nzk3ZjEwMTJmMzJhNGM3MzI3NTMxNGZiNjQw
|
15
|
+
MTkwMzg0ZGMyYzQzMjQ4ODQ3ODA1OTEwNjNhZjNiZjBjZjZkYzg=
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Activewepay
|
2
2
|
|
3
|
-
|
3
|
+
Access the WePay like ActiveModel/ActiveRecord objects.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,7 +18,38 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
Access a WePay object by calling something like `ActiveWepay::Checkout.create` or `ActiveWepay::Checkout.find(<checkout id>)`
|
22
|
+
|
23
|
+
### Setup:
|
24
|
+
|
25
|
+
Once instantiated, an object can have useful methods called on it, depending on the object type. Example:
|
26
|
+
|
27
|
+
checkout = ActiveWepay::Checkout.create({
|
28
|
+
oauth_token: <oauth token>,
|
29
|
+
account_id: <account id>,
|
30
|
+
amount: <amount>,
|
31
|
+
redirect_uri: <redirect uri>,
|
32
|
+
callback_uri: <callback uri>
|
33
|
+
})
|
34
|
+
checkout.refund
|
35
|
+
|
36
|
+
|
37
|
+
preapproval = ActiveWepay::Preapproval.create
|
38
|
+
preapproval.cancel
|
39
|
+
|
40
|
+
You can also access the returned properties on the object:
|
41
|
+
|
42
|
+
checkout.amount
|
43
|
+
checkout.id
|
44
|
+
|
45
|
+
preapproval.preapproval_uri
|
46
|
+
|
47
|
+
If there's an error in the call, you can call them like you would any ActiveModel object:
|
48
|
+
|
49
|
+
checkout.errors.any?
|
50
|
+
checkout.errors.full_messages
|
51
|
+
|
52
|
+
The gem automatically switches between stage and production domains based on the Rails environment.
|
22
53
|
|
23
54
|
## Contributing
|
24
55
|
|
data/activewepay.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["asherlc@asherlc.com"]
|
11
11
|
spec.description = %q{ActiveModel style WePay interface.}
|
12
12
|
spec.summary = %q{{ActiveModel style WePay interface.}}
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/Asherlc/activewepay"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
data/lib/activewepay.rb
CHANGED
@@ -21,6 +21,7 @@ module ActiveWepay
|
|
21
21
|
|
22
22
|
def initialize
|
23
23
|
@errors = ActiveModel::Errors.new(self)
|
24
|
+
@options ||= {}
|
24
25
|
end
|
25
26
|
|
26
27
|
# make a call to the WePay API
|
@@ -71,8 +72,10 @@ module ActiveWepay
|
|
71
72
|
class Account < Base
|
72
73
|
def self.create(oauth_token, name)
|
73
74
|
@account = self.new
|
75
|
+
@account.options[:oauth_token] = oauth_token
|
76
|
+
|
74
77
|
theme = { name: 'Black and White', primary_color: 'FFFFFF', secondary_color: '000000', background_color: 'FFFFFF', button_color: 'FFFFFF' }
|
75
|
-
@account.call('/account/create', oauth_token, {
|
78
|
+
@account.call('/account/create', @account.options[:oauth_token], {
|
76
79
|
:name => name,
|
77
80
|
:description => 'Automatically generated by Vocalem',
|
78
81
|
:theme_object => theme
|
@@ -81,44 +84,43 @@ module ActiveWepay
|
|
81
84
|
end
|
82
85
|
|
83
86
|
class Checkout < Base
|
84
|
-
def self.create(
|
87
|
+
def self.create(options = {})
|
85
88
|
@checkout = self.new
|
86
|
-
@checkout.oauth_token = oauth_token
|
87
89
|
@checkout.options = options
|
88
|
-
@checkout.call('/checkout/create', oauth_token, {
|
89
|
-
account_id: options[:
|
90
|
-
amount: options[:amount],
|
90
|
+
@checkout.call('/checkout/create', @checkout.options[:oauth_token], {
|
91
|
+
account_id: @checkout.options[:account_id],
|
92
|
+
amount: @checkout.options[:amount],
|
91
93
|
short_description: 'Payment',
|
92
94
|
type: 'DONATION',
|
93
95
|
mode: 'iframe',
|
94
|
-
app_fee: options[:amount] * 0.021,
|
95
|
-
redirect_uri: options[:redirect_uri],
|
96
|
-
callback_uri: options[:callback_uri]
|
96
|
+
app_fee: @checkout.options[:amount] * 0.021,
|
97
|
+
redirect_uri: @checkout.options[:redirect_uri],
|
98
|
+
callback_uri: @checkout.options[:callback_uri]
|
97
99
|
})
|
98
100
|
end
|
99
101
|
|
100
102
|
def self.find(id, oauth_token)
|
101
103
|
@checkout = self.new
|
102
104
|
@checkout.id = id
|
103
|
-
@checkout.oauth_token = oauth_token
|
105
|
+
@checkout.options[:oauth_token] = oauth_token
|
104
106
|
@checkout.information
|
105
107
|
end
|
106
108
|
|
107
109
|
def information
|
108
|
-
call('/checkout/', @oauth_token, {
|
110
|
+
call('/checkout/', @options[:oauth_token], {
|
109
111
|
checkout_id: @id
|
110
112
|
})
|
111
113
|
end
|
112
114
|
|
113
115
|
def cancel
|
114
|
-
self.call('/checkout/cancel/', @oauth_token, {
|
116
|
+
self.call('/checkout/cancel/', @options[:oauth_token], {
|
115
117
|
checkout_id: @id,
|
116
118
|
cancel_reason: 'Refund'
|
117
119
|
})
|
118
120
|
end
|
119
121
|
|
120
122
|
def refund
|
121
|
-
call('/checkout/refund', @oauth_token, {
|
123
|
+
call('/checkout/refund', @options[:oauth_token], {
|
122
124
|
checkout_id: @id,
|
123
125
|
refund_reason: 'Refunded'
|
124
126
|
})
|
@@ -128,33 +130,34 @@ module ActiveWepay
|
|
128
130
|
class Preapproval < Base
|
129
131
|
attr_accessor :options, :id
|
130
132
|
|
131
|
-
def self.create(options)
|
133
|
+
def self.create(options = {})
|
132
134
|
@recurring = self.new
|
133
135
|
@recurring.options = options
|
134
|
-
@recurring.call('/preapproval/create',
|
136
|
+
@recurring.call('/preapproval/create', @recurring.options[:oauth_token], {
|
135
137
|
short_description: 'Vocalem plan change',
|
136
|
-
account_id:
|
137
|
-
amount: options[:amount],
|
138
|
+
account_id: @recurring.options[:account_id],
|
139
|
+
amount: @recurring.options[:amount],
|
138
140
|
period: 'monthly',
|
139
|
-
redirect_uri: options[:redirect_uri],
|
140
|
-
callback_uri: options[:callback_uri],
|
141
|
+
redirect_uri: @recurring.options[:redirect_uri],
|
142
|
+
callback_uri: @recurring.options[:callback_uri],
|
141
143
|
auto_recur: true,
|
142
144
|
mode: 'iframe'
|
143
145
|
})
|
144
146
|
end
|
145
147
|
|
146
|
-
def self.find(id)
|
148
|
+
def self.find(id, oauth_token)
|
147
149
|
@recurring = self.new
|
150
|
+
@recurring.options[:oauth_token] = oauth_token
|
148
151
|
@recurring.id = id
|
149
152
|
|
150
|
-
@recurring.call('/preapproval/',
|
153
|
+
@recurring.call('/preapproval/', @recurring.options[:oauth_token], {
|
151
154
|
preapproval_id: id
|
152
155
|
})
|
153
156
|
end
|
154
157
|
|
155
158
|
def cancel
|
156
159
|
|
157
|
-
call('/preapproval/cancel',
|
160
|
+
call('/preapproval/cancel', @options[:oauth_token], {
|
158
161
|
preapproval_id: @id
|
159
162
|
})
|
160
163
|
end
|
@@ -163,14 +166,13 @@ module ActiveWepay
|
|
163
166
|
class Withdrawal < Base
|
164
167
|
attr_accessor :options, :id, :oauth_token
|
165
168
|
|
166
|
-
def self.create(
|
169
|
+
def self.create(options = {})
|
167
170
|
@withdrawal = self.new
|
168
171
|
@withdrawal.options = options
|
169
|
-
@withdrawal.oauth_token = oauth_token
|
170
172
|
|
171
|
-
@withdrawal.call('/withdrawal/create', oauth_token, {
|
172
|
-
account_id: options[:
|
173
|
-
redirect_uri: options[:redirect_uri],
|
173
|
+
@withdrawal.call('/withdrawal/create', @withdrawal.options[:oauth_token], {
|
174
|
+
account_id: @withdrawal.options[:account_id],
|
175
|
+
redirect_uri: @withdrawal.options[:redirect_uri],
|
174
176
|
mode: 'iframe'
|
175
177
|
})
|
176
178
|
end
|
data/lib/activewepay/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activewepay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Asher Cohen
|
@@ -67,7 +67,7 @@ files:
|
|
67
67
|
- activewepay.gemspec
|
68
68
|
- lib/activewepay.rb
|
69
69
|
- lib/activewepay/version.rb
|
70
|
-
homepage:
|
70
|
+
homepage: https://github.com/Asherlc/activewepay
|
71
71
|
licenses:
|
72
72
|
- MIT
|
73
73
|
metadata: {}
|