openpay 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.gitignore +1 -0
- data/.idea/.rakeTasks +2 -2
- data/.idea/OpenPay.iml +30 -20
- data/.idea/runConfigurations/Run_spec__bankaccounts_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__cards_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__charges_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__customers_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__exceptions_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__fees_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__payouts_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__plans_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__subscriptions_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/Run_spec__transfers_spec___OpenPay.xml +1 -0
- data/.idea/runConfigurations/all_specs.xml +1 -0
- data/.idea/workspace.xml +484 -268
- data/Gemfile +0 -6
- data/README.md +111 -29
- data/lib/openpay.rb +7 -3
- data/lib/openpay/bankaccounts.rb +10 -11
- data/lib/openpay/cards.rb +12 -14
- data/lib/openpay/charges.rb +38 -14
- data/lib/openpay/customers.rb +73 -67
- data/lib/openpay/errors/openpay_exception_factory.rb +14 -26
- data/lib/openpay/fees.rb +1 -1
- data/lib/openpay/open_pay_resource.rb +77 -77
- data/lib/openpay/open_pay_resource_factory.rb +1 -1
- data/lib/openpay/openpay_api.rb +6 -16
- data/lib/openpay/payouts.rb +13 -17
- data/lib/openpay/plans.rb +1 -7
- data/lib/openpay/subscriptions.rb +21 -29
- data/lib/openpay/transfers.rb +14 -18
- data/lib/openpay/utils/search_params.rb +20 -0
- data/lib/version.rb +1 -2
- data/openpay.gemspec +0 -8
- data/test/Factories.rb +80 -126
- data/test/spec/bankaccounts_spec.rb +55 -61
- data/test/spec/cards_spec.rb +56 -76
- data/test/spec/charges_spec.rb +89 -84
- data/test/spec/customers_spec.rb +37 -47
- data/test/spec/exceptions_spec.rb +4 -21
- data/test/spec/fees_spec.rb +51 -7
- data/test/spec/payouts_spec.rb +102 -65
- data/test/spec/plans_spec.rb +27 -50
- data/test/spec/subscriptions_spec.rb +87 -24
- data/test/spec/transfers_spec.rb +42 -44
- data/test/spec/utils/search_params_spec.rb +36 -0
- data/test/spec_helper.rb +1 -5
- metadata +15 -55
- data/lib/OpenPay/Cards.rb +0 -75
- data/lib/OpenPay/Charges.rb +0 -77
- data/lib/OpenPay/Customers.rb +0 -194
- data/lib/OpenPay/Fees.rb +0 -5
- data/lib/OpenPay/Payouts.rb +0 -59
- data/lib/OpenPay/Plans.rb +0 -23
- data/lib/OpenPay/Subscriptions.rb +0 -58
- data/lib/OpenPay/Transfers.rb +0 -43
- data/lib/OpenPay/bankaccounts.rb +0 -59
- data/lib/OpenPay/errors/openpay_connection_exception.rb +0 -3
- data/lib/OpenPay/errors/openpay_exception.rb +0 -29
- data/lib/OpenPay/errors/openpay_exception_factory.rb +0 -60
- data/lib/OpenPay/errors/openpay_transaction_exception.rb +0 -5
- data/lib/OpenPay/open_pay_resource.rb +0 -242
- data/lib/OpenPay/open_pay_resource_factory.rb +0 -10
- data/lib/OpenPay/openpay_api.rb +0 -58
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
include OpenpayUtils
|
3
|
+
|
4
|
+
describe OpenpayUtils do
|
5
|
+
|
6
|
+
describe SearchParams do
|
7
|
+
|
8
|
+
subject(:search_params) { SearchParams.new }
|
9
|
+
|
10
|
+
describe 'setters and getters' do
|
11
|
+
|
12
|
+
it 'sets and gets a given value' do
|
13
|
+
val = "val"
|
14
|
+
search_params.val = val
|
15
|
+
expect(search_params.val).to eq(val)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'sets and gets a non existing attribute' do
|
19
|
+
expect(search_params.val).to eq(nil)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '.to_s' do
|
24
|
+
it 'generates the filter string based on the attributes' do
|
25
|
+
creation_date = "2013-11-01"
|
26
|
+
search_params.creation_gte = creation_date
|
27
|
+
limit = 2
|
28
|
+
search_params.limit = limit
|
29
|
+
amount = 100
|
30
|
+
search_params.amount_lte = amount
|
31
|
+
expect(search_params.to_s).to eq("?creation[gte]=2013-11-01&limit=2&amount[lte]=100")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
data/test/spec_helper.rb
CHANGED
@@ -2,7 +2,6 @@ $: << '.'
|
|
2
2
|
$: << 'lib'
|
3
3
|
$: << 'lib/openpay'
|
4
4
|
|
5
|
-
|
6
5
|
require 'openpay'
|
7
6
|
require 'factory_girl'
|
8
7
|
require 'test/Factories'
|
@@ -10,12 +9,9 @@ require 'rspec'
|
|
10
9
|
require 'rspec-expectations'
|
11
10
|
require 'json_spec'
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
12
|
RSpec.configure do |config|
|
17
13
|
config.expect_with :rspec do |c|
|
18
14
|
c.syntax = :expect
|
19
15
|
config.include JsonSpec::Helpers
|
20
16
|
end
|
21
|
-
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openpay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ronnie_bermejo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - '>='
|
31
|
+
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - '>='
|
38
|
+
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -56,58 +56,30 @@ dependencies:
|
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - '>='
|
59
|
+
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - '>='
|
66
|
+
- - ! '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: json_spec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - '>='
|
73
|
+
- - ! '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - '>='
|
80
|
+
- - ! '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rspec
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - '>='
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - '>='
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: factory_girl
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - '='
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 4.2.0
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - '='
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 4.2.0
|
111
83
|
description: ruby client for Openpay API services (version 1.0.2)
|
112
84
|
email:
|
113
85
|
- ronnie.bermejo.mx@gmail.com
|
@@ -144,22 +116,6 @@ files:
|
|
144
116
|
- LICENSE.txt
|
145
117
|
- README.md
|
146
118
|
- Rakefile
|
147
|
-
- lib/OpenPay/Cards.rb
|
148
|
-
- lib/OpenPay/Charges.rb
|
149
|
-
- lib/OpenPay/Customers.rb
|
150
|
-
- lib/OpenPay/Fees.rb
|
151
|
-
- lib/OpenPay/Payouts.rb
|
152
|
-
- lib/OpenPay/Plans.rb
|
153
|
-
- lib/OpenPay/Subscriptions.rb
|
154
|
-
- lib/OpenPay/Transfers.rb
|
155
|
-
- lib/OpenPay/bankaccounts.rb
|
156
|
-
- lib/OpenPay/errors/openpay_connection_exception.rb
|
157
|
-
- lib/OpenPay/errors/openpay_exception.rb
|
158
|
-
- lib/OpenPay/errors/openpay_exception_factory.rb
|
159
|
-
- lib/OpenPay/errors/openpay_transaction_exception.rb
|
160
|
-
- lib/OpenPay/open_pay_resource.rb
|
161
|
-
- lib/OpenPay/open_pay_resource_factory.rb
|
162
|
-
- lib/OpenPay/openpay_api.rb
|
163
119
|
- lib/openpay.rb
|
164
120
|
- lib/openpay/bankaccounts.rb
|
165
121
|
- lib/openpay/cards.rb
|
@@ -177,6 +133,7 @@ files:
|
|
177
133
|
- lib/openpay/plans.rb
|
178
134
|
- lib/openpay/subscriptions.rb
|
179
135
|
- lib/openpay/transfers.rb
|
136
|
+
- lib/openpay/utils/search_params.rb
|
180
137
|
- lib/version.rb
|
181
138
|
- openpay.gemspec
|
182
139
|
- test/Factories.rb
|
@@ -191,6 +148,7 @@ files:
|
|
191
148
|
- test/spec/plans_spec.rb
|
192
149
|
- test/spec/subscriptions_spec.rb
|
193
150
|
- test/spec/transfers_spec.rb
|
151
|
+
- test/spec/utils/search_params_spec.rb
|
194
152
|
- test/spec_helper.rb
|
195
153
|
homepage: http://openpay.mx/
|
196
154
|
licenses:
|
@@ -205,17 +163,17 @@ require_paths:
|
|
205
163
|
- .
|
206
164
|
required_ruby_version: !ruby/object:Gem::Requirement
|
207
165
|
requirements:
|
208
|
-
- - '>='
|
166
|
+
- - ! '>='
|
209
167
|
- !ruby/object:Gem::Version
|
210
168
|
version: '0'
|
211
169
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
170
|
requirements:
|
213
|
-
- - '>='
|
171
|
+
- - ! '>='
|
214
172
|
- !ruby/object:Gem::Version
|
215
173
|
version: '0'
|
216
174
|
requirements: []
|
217
175
|
rubyforge_project:
|
218
|
-
rubygems_version: 2.0
|
176
|
+
rubygems_version: 2.2.0
|
219
177
|
signing_key:
|
220
178
|
specification_version: 4
|
221
179
|
summary: ruby api for openpay resources
|
@@ -232,4 +190,6 @@ test_files:
|
|
232
190
|
- test/spec/plans_spec.rb
|
233
191
|
- test/spec/subscriptions_spec.rb
|
234
192
|
- test/spec/transfers_spec.rb
|
193
|
+
- test/spec/utils/search_params_spec.rb
|
235
194
|
- test/spec_helper.rb
|
195
|
+
has_rdoc:
|
data/lib/OpenPay/Cards.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'open_pay_resource'
|
2
|
-
|
3
|
-
class Cards < OpenPayResource
|
4
|
-
|
5
|
-
def list(creation,before,after,offset=0,limit=10)
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
|
10
|
-
def get(card='',customer_id=nil)
|
11
|
-
if customer_id
|
12
|
-
customers=@api_hook.create(:customers)
|
13
|
-
customers.get_card(customer_id,card)
|
14
|
-
else
|
15
|
-
super card
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
def create(card,customer_id=nil)
|
21
|
-
if customer_id
|
22
|
-
customers=@api_hook.create(:customers)
|
23
|
-
customers.create_card(customer_id,card)
|
24
|
-
else
|
25
|
-
super card
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
|
30
|
-
def delete(card_id,customer_id=nil)
|
31
|
-
if customer_id
|
32
|
-
customers=@api_hook.create(:customers)
|
33
|
-
customers.delete_card(customer_id,card_id)
|
34
|
-
else
|
35
|
-
super card_id
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
def delete_all(customer_id=nil)
|
41
|
-
if customer_id
|
42
|
-
customers=@api_hook.create(:customers)
|
43
|
-
customers.delete_all_cards(customer_id)
|
44
|
-
else
|
45
|
-
each do |card|
|
46
|
-
delete(card['id'])
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
def each(customer_id=nil)
|
53
|
-
if customer_id
|
54
|
-
all(customer_id).each do |card|
|
55
|
-
yield card
|
56
|
-
end
|
57
|
-
else
|
58
|
-
all.each do |card|
|
59
|
-
yield card
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
def all(customer_id=nil)
|
66
|
-
if customer_id
|
67
|
-
customers=@api_hook.create(:customers)
|
68
|
-
customers.all_cards(customer_id)
|
69
|
-
else
|
70
|
-
super ''
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
|
75
|
-
end
|
data/lib/OpenPay/Charges.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'open_pay_resource'
|
2
|
-
|
3
|
-
class Charges < OpenPayResource
|
4
|
-
|
5
|
-
def all(customer_id=nil)
|
6
|
-
if customer_id
|
7
|
-
customers=@api_hook.create(:customers)
|
8
|
-
customers.all_charges(customer_id)
|
9
|
-
else
|
10
|
-
super ''
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
def cancel(transaction_id,customer_id=nil)
|
16
|
-
if customer_id
|
17
|
-
customers=@api_hook.create(:customers)
|
18
|
-
customers.cancel_charge(customer_id, transaction_id)
|
19
|
-
else
|
20
|
-
post('', transaction_id+'/cancel')
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
def refund(transaction_id,description,customer_id=nil)
|
26
|
-
if customer_id
|
27
|
-
customers=@api_hook.create(:customers)
|
28
|
-
customers.refund_charge(customer_id,transaction_id,description)
|
29
|
-
else
|
30
|
-
post(description, transaction_id+'/refund')
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
def capture(transaction_id,customer_id=nil)
|
36
|
-
if customer_id
|
37
|
-
customers=@api_hook.create(:customers)
|
38
|
-
customers.capture_charge(customer_id,transaction_id )
|
39
|
-
else
|
40
|
-
post( '',transaction_id+'/capture')
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
|
45
|
-
def each(customer_id=nil)
|
46
|
-
if customer_id
|
47
|
-
all(customer_id).each do |card|
|
48
|
-
yield card
|
49
|
-
end
|
50
|
-
else
|
51
|
-
all.each do |card|
|
52
|
-
yield card
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
def get(charge='', customer_id=nil)
|
60
|
-
if customer_id
|
61
|
-
customers=@api_hook.create(:customers)
|
62
|
-
customers.get_charge(customer_id, charge)
|
63
|
-
else
|
64
|
-
super charge
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def create(charge, customer_id=nil)
|
69
|
-
if customer_id
|
70
|
-
customers=@api_hook.create(:customers)
|
71
|
-
customers.create_charge(customer_id, charge)
|
72
|
-
else
|
73
|
-
super charge
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
data/lib/OpenPay/Customers.rb
DELETED
@@ -1,194 +0,0 @@
|
|
1
|
-
require 'open_pay_resource'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
class Customers < OpenPayResource
|
6
|
-
|
7
|
-
|
8
|
-
#Bankaccount
|
9
|
-
def create_bank_account(customer,bank_account)
|
10
|
-
create(bank_account,"#{customer}/bankaccounts")
|
11
|
-
end
|
12
|
-
|
13
|
-
def get_bank_account(customer,bank_id)
|
14
|
-
get("#{customer}/bankaccounts/#{bank_id}")
|
15
|
-
end
|
16
|
-
|
17
|
-
def all_bank_accounts(customer)
|
18
|
-
get("#{customer}/bankaccounts/")
|
19
|
-
end
|
20
|
-
|
21
|
-
def each_bank_account(customer)
|
22
|
-
get("#{customer}/bankaccounts/").each do |account|
|
23
|
-
yield account
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
def delete_bank_account(customer,bank_id)
|
29
|
-
delete("#{customer}/bankaccounts/#{bank_id}")
|
30
|
-
end
|
31
|
-
|
32
|
-
def delete_all_bank_accounts(customer)
|
33
|
-
if env == :production
|
34
|
-
raise OpenpayException.new('This method is not supported on PRODUCTION',false)
|
35
|
-
end
|
36
|
-
each_bank_account(customer) do |account|
|
37
|
-
delete("#{customer}/bankaccounts/#{account['id']}")
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
#Charges
|
43
|
-
# customers.create_charge(customer_id,charge)
|
44
|
-
def create_charge(customer_id,charge)
|
45
|
-
create(charge,"#{customer_id}/charges")
|
46
|
-
end
|
47
|
-
|
48
|
-
#gets a charge_id for a given customer_id
|
49
|
-
def get_charge(customer_id,charge_id)
|
50
|
-
get("#{customer_id}/charges/#{charge_id}")
|
51
|
-
end
|
52
|
-
|
53
|
-
#return all charges for the given customer_id
|
54
|
-
def all_charges(customer_id)
|
55
|
-
get("#{customer_id}/charges/")
|
56
|
-
end
|
57
|
-
|
58
|
-
def cancel_charge(customer_id,charge_id)
|
59
|
-
post(charge_id,"#{customer_id}/charges/#{charge_id}/cancel")
|
60
|
-
end
|
61
|
-
|
62
|
-
def refund_charge(customer_id,charge_id,description)
|
63
|
-
post(description,"#{customer_id}/charges/#{charge_id}/refund")
|
64
|
-
end
|
65
|
-
|
66
|
-
def capture_charge(customer_id,charge_id)
|
67
|
-
post('',"#{customer_id}/charges/#{charge_id}/capture")
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
#Payouts
|
73
|
-
def create_payout(customer_id,payout)
|
74
|
-
post(payout,"#{customer_id}/payouts")
|
75
|
-
end
|
76
|
-
|
77
|
-
def all_payouts(customer_id)
|
78
|
-
get("#{customer_id}/payouts")
|
79
|
-
end
|
80
|
-
|
81
|
-
def get_payout(customer_id,payout_id)
|
82
|
-
get("#{customer_id}/payouts/#{payout_id}")
|
83
|
-
end
|
84
|
-
|
85
|
-
def each_payout(customer_id)
|
86
|
-
all_payouts(customer_id).each do |pay|
|
87
|
-
yield pay
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
#Transfers
|
95
|
-
def create_transfer(customer_id,transfer)
|
96
|
-
post(transfer,"#{customer_id}/transfers")
|
97
|
-
end
|
98
|
-
|
99
|
-
def all_transfers(customer_id)
|
100
|
-
get("#{customer_id}/transfers/")
|
101
|
-
end
|
102
|
-
|
103
|
-
def get_transfer(customer_id,transfer_id)
|
104
|
-
get("#{customer_id}/transfers/#{transfer_id}")
|
105
|
-
end
|
106
|
-
|
107
|
-
def each_transfer(customer_id)
|
108
|
-
all_transfers(customer_id).each do |trans|
|
109
|
-
yield trans
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
#Subscriptions
|
117
|
-
def create_subscription(subscription, plan_id)
|
118
|
-
post(subscription,"#{plan_id}/subscriptions")
|
119
|
-
end
|
120
|
-
|
121
|
-
|
122
|
-
def delete_subscription(customer_id,subscription_id)
|
123
|
-
delete("#{customer_id}/subscriptions/#{subscription_id}")
|
124
|
-
end
|
125
|
-
|
126
|
-
|
127
|
-
def get_subscription(customer_id,subscription_id)
|
128
|
-
get("#{customer_id}/subscriptions/#{subscription_id}")
|
129
|
-
end
|
130
|
-
|
131
|
-
|
132
|
-
def all_subscriptions(customer_id)
|
133
|
-
get("#{customer_id}/subscriptions/")
|
134
|
-
end
|
135
|
-
|
136
|
-
def each_subscription(customer_id)
|
137
|
-
all_subscriptions(customer_id).each do |cust|
|
138
|
-
yield cust
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
|
143
|
-
def delete_all_subscriptions(customer_id)
|
144
|
-
if env == :production
|
145
|
-
raise OpenPayError ('This method is not supported on PRODUCTION')
|
146
|
-
end
|
147
|
-
all_subscriptions(customer_id).each do |sub|
|
148
|
-
delete_subscription(customer_id,sub['id'])
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
#Card
|
156
|
-
def create_card(customer,card)
|
157
|
-
create(card,"#{customer}/cards")
|
158
|
-
end
|
159
|
-
|
160
|
-
|
161
|
-
def get_card(customer,card_id)
|
162
|
-
get("#{customer}/cards/#{card_id}")
|
163
|
-
end
|
164
|
-
|
165
|
-
|
166
|
-
def delete_card(customer,card_id)
|
167
|
-
delete("#{customer}/cards/#{card_id}")
|
168
|
-
end
|
169
|
-
|
170
|
-
|
171
|
-
def delete_all_cards(customer_id)
|
172
|
-
if env == :production
|
173
|
-
raise OpenPayError ('This method is not supported on PRODUCTION')
|
174
|
-
end
|
175
|
-
each_card(customer_id) do |card|
|
176
|
-
delete_card(customer_id,card['id'])
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
|
181
|
-
def each_card(customer)
|
182
|
-
get("#{customer}/cards").each do |card|
|
183
|
-
yield card
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
|
188
|
-
def all_cards(customer)
|
189
|
-
get("#{customer}/cards")
|
190
|
-
end
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
end
|