pin_up 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -6
- data/Gemfile +2 -3
- data/Gemfile.lock +76 -75
- data/Guardfile +47 -39
- data/README.md +24 -0
- data/VERSION +1 -1
- data/lib/pin_up/balance.rb +15 -0
- data/lib/pin_up/bank_accounts.rb +19 -0
- data/lib/pin_up/base.rb +2 -0
- data/lib/pin_up/client.rb +5 -5
- data/lib/pin_up/customer.rb +39 -0
- data/lib/pin_up/pin_errors.rb +6 -1
- data/lib/pin_up/recipient.rb +50 -0
- data/lib/pin_up/transfer.rb +43 -0
- data/lib/pin_up.rb +5 -0
- data/pin_up.gemspec +19 -16
- data/spec/balance_spec.rb +11 -0
- data/spec/bank_accounts_spec.rb +12 -0
- data/spec/cards_spec.rb +1 -1
- data/spec/charges_spec.rb +16 -16
- data/spec/customers_spec.rb +38 -12
- data/spec/errors_spec.rb +11 -4
- data/spec/recipients_spec.rb +36 -0
- data/spec/refund_spec.rb +5 -5
- data/spec/spec_helper.rb +1 -2
- data/spec/transfers_spec.rb +32 -0
- metadata +39 -46
- data/.DS_Store +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e0ca480c8f39469c1101c64b1454a0eca7ed396
|
4
|
+
data.tar.gz: 8363e988eacbbc751d6b6fe7a76e9962c3e2b74a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68445fd60ad8acbdba20b948dc5d5ed2a8f4dd94f614665c166f33170847385f495de6be0e618c12f89437f49e72ffe429b029e5f81b6c3a82711226b941b97c
|
7
|
+
data.tar.gz: c272c8d0eb4cdce4ab0596b5b25e650613e468bc19d5b19608e0310b0944df6de31b71e0c84e937eb00db635b13ca0416a7bf8d7bdafc4947f138a269eae234b
|
data/.travis.yml
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
---
|
2
|
-
env:
|
3
|
-
global:
|
4
|
-
secure: |-
|
5
|
-
Z7eqtE7oQVsmz2iw45MULCsk9Ff028nsPHJjX04GskTCeqhn2AgeFbNEjB7d
|
6
|
-
1mlrJDZyRggBW2ENK6Kti7p196hB1WfH52SYl9dZSLABWDW9oIKo46HjymNP
|
7
|
-
J9RERcoevctKkRGUCvyx0kvX1uN4iI56OJPXFAsYA+w0zAm/1/c=
|
8
2
|
script: bundle exec rspec spec
|
3
|
+
language: ruby
|
4
|
+
rvm:
|
5
|
+
- 2.1.5
|
data/Gemfile
CHANGED
@@ -5,12 +5,11 @@ gem "httparty", ">= 0.11.0"
|
|
5
5
|
group :development do
|
6
6
|
gem "shoulda", "~> 3.5"
|
7
7
|
gem "rdoc", "~> 3.12"
|
8
|
-
gem "rspec"
|
8
|
+
gem "rspec" #, "~> 2.13"
|
9
9
|
gem "jeweler", "~> 1.8.4"
|
10
10
|
gem "simplecov", "~> 0.7.1"
|
11
11
|
gem "webmock", "~> 1.12.3"
|
12
12
|
gem "vcr", "~> 2.5.0"
|
13
|
-
gem "guard-rspec"
|
13
|
+
gem "guard-rspec" #, "~> 3.0.2"
|
14
14
|
gem "terminal-notifier-guard", "~> 1.5.3"
|
15
|
-
gem "capybara", "~> 2.1.0"
|
16
15
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,35 +1,25 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (4.
|
5
|
-
i18n (~> 0.
|
6
|
-
|
7
|
-
|
8
|
-
thread_safe (~> 0.
|
9
|
-
tzinfo (~>
|
10
|
-
addressable (2.3.
|
11
|
-
atomic (1.1.15)
|
4
|
+
activesupport (4.2.1)
|
5
|
+
i18n (~> 0.7)
|
6
|
+
json (~> 1.7, >= 1.7.7)
|
7
|
+
minitest (~> 5.1)
|
8
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
9
|
+
tzinfo (~> 1.1)
|
10
|
+
addressable (2.3.8)
|
12
11
|
builder (3.2.2)
|
13
|
-
|
14
|
-
|
15
|
-
nokogiri (>= 1.3.3)
|
16
|
-
rack (>= 1.0.0)
|
17
|
-
rack-test (>= 0.5.4)
|
18
|
-
xpath (~> 2.0)
|
19
|
-
celluloid (0.15.2)
|
20
|
-
timers (~> 1.1.0)
|
21
|
-
celluloid-io (0.15.0)
|
22
|
-
celluloid (>= 0.15.0)
|
23
|
-
nio4r (>= 0.5.0)
|
12
|
+
celluloid (0.16.0)
|
13
|
+
timers (~> 4.0.0)
|
24
14
|
coderay (1.1.0)
|
25
15
|
crack (0.4.2)
|
26
16
|
safe_yaml (~> 1.0.0)
|
27
17
|
diff-lcs (1.2.5)
|
28
18
|
faraday (0.8.9)
|
29
19
|
multipart-post (~> 1.2.0)
|
30
|
-
ffi (1.9.
|
31
|
-
formatador (0.2.
|
32
|
-
git (1.2.
|
20
|
+
ffi (1.9.8)
|
21
|
+
formatador (0.2.5)
|
22
|
+
git (1.2.9.1)
|
33
23
|
github_api (0.10.1)
|
34
24
|
addressable
|
35
25
|
faraday (~> 0.8.1)
|
@@ -37,21 +27,27 @@ GEM
|
|
37
27
|
multi_json (~> 1.4)
|
38
28
|
nokogiri (~> 1.5.2)
|
39
29
|
oauth2
|
40
|
-
guard (2.5
|
30
|
+
guard (2.12.5)
|
41
31
|
formatador (>= 0.2.4)
|
42
|
-
listen (~> 2.
|
32
|
+
listen (~> 2.7)
|
43
33
|
lumberjack (~> 1.0)
|
34
|
+
nenv (~> 0.1)
|
35
|
+
notiffany (~> 0.0)
|
44
36
|
pry (>= 0.9.12)
|
37
|
+
shellany (~> 0.0)
|
45
38
|
thor (>= 0.18.1)
|
46
|
-
guard-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
39
|
+
guard-compat (1.2.1)
|
40
|
+
guard-rspec (4.5.2)
|
41
|
+
guard (~> 2.1)
|
42
|
+
guard-compat (~> 1.1)
|
43
|
+
rspec (>= 2.99.0, < 4.0)
|
44
|
+
hashie (3.4.2)
|
45
|
+
highline (1.7.2)
|
46
|
+
hitimes (1.2.2)
|
47
|
+
httparty (0.13.5)
|
52
48
|
json (~> 1.8)
|
53
49
|
multi_xml (>= 0.5.2)
|
54
|
-
i18n (0.
|
50
|
+
i18n (0.7.0)
|
55
51
|
jeweler (1.8.8)
|
56
52
|
builder
|
57
53
|
bundler (~> 1.0)
|
@@ -61,87 +57,92 @@ GEM
|
|
61
57
|
nokogiri (= 1.5.10)
|
62
58
|
rake
|
63
59
|
rdoc
|
64
|
-
json (1.8.
|
65
|
-
jwt (
|
66
|
-
|
67
|
-
|
68
|
-
celluloid (>= 0.15.2)
|
69
|
-
celluloid-io (>= 0.15.0)
|
60
|
+
json (1.8.3)
|
61
|
+
jwt (1.5.0)
|
62
|
+
listen (2.10.0)
|
63
|
+
celluloid (~> 0.16.0)
|
70
64
|
rb-fsevent (>= 0.9.3)
|
71
65
|
rb-inotify (>= 0.9)
|
72
|
-
lumberjack (1.0.
|
66
|
+
lumberjack (1.0.9)
|
73
67
|
method_source (0.8.2)
|
74
|
-
|
75
|
-
|
76
|
-
multi_json (1.9.0)
|
68
|
+
minitest (5.7.0)
|
69
|
+
multi_json (1.11.0)
|
77
70
|
multi_xml (0.5.5)
|
78
71
|
multipart-post (1.2.0)
|
79
|
-
|
72
|
+
nenv (0.2.0)
|
80
73
|
nokogiri (1.5.10)
|
81
|
-
|
74
|
+
notiffany (0.0.6)
|
75
|
+
nenv (~> 0.1)
|
76
|
+
shellany (~> 0.0)
|
77
|
+
oauth2 (1.0.0)
|
82
78
|
faraday (>= 0.8, < 0.10)
|
83
|
-
jwt (~>
|
79
|
+
jwt (~> 1.0)
|
84
80
|
multi_json (~> 1.3)
|
85
81
|
multi_xml (~> 0.5)
|
86
82
|
rack (~> 1.2)
|
87
|
-
pry (0.
|
88
|
-
coderay (~> 1.0)
|
89
|
-
method_source (~> 0.8)
|
83
|
+
pry (0.10.1)
|
84
|
+
coderay (~> 1.1.0)
|
85
|
+
method_source (~> 0.8.1)
|
90
86
|
slop (~> 3.4)
|
91
|
-
rack (1.
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
rb-fsevent (0.9.4)
|
96
|
-
rb-inotify (0.9.3)
|
87
|
+
rack (1.6.1)
|
88
|
+
rake (10.4.2)
|
89
|
+
rb-fsevent (0.9.5)
|
90
|
+
rb-inotify (0.9.5)
|
97
91
|
ffi (>= 0.5.0)
|
98
92
|
rdoc (3.12.2)
|
99
93
|
json (~> 1.4)
|
100
|
-
rspec (2.
|
101
|
-
rspec-core (~> 2.
|
102
|
-
rspec-expectations (~> 2.
|
103
|
-
rspec-mocks (~> 2.
|
104
|
-
rspec-core (2.
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
94
|
+
rspec (3.2.0)
|
95
|
+
rspec-core (~> 3.2.0)
|
96
|
+
rspec-expectations (~> 3.2.0)
|
97
|
+
rspec-mocks (~> 3.2.0)
|
98
|
+
rspec-core (3.2.3)
|
99
|
+
rspec-support (~> 3.2.0)
|
100
|
+
rspec-expectations (3.2.1)
|
101
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
102
|
+
rspec-support (~> 3.2.0)
|
103
|
+
rspec-mocks (3.2.1)
|
104
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
105
|
+
rspec-support (~> 3.2.0)
|
106
|
+
rspec-support (3.2.2)
|
107
|
+
safe_yaml (1.0.4)
|
108
|
+
shellany (0.0.1)
|
109
109
|
shoulda (3.5.0)
|
110
110
|
shoulda-context (~> 1.0, >= 1.0.1)
|
111
111
|
shoulda-matchers (>= 1.4.1, < 3.0)
|
112
|
-
shoulda-context (1.1
|
113
|
-
shoulda-matchers (2.
|
112
|
+
shoulda-context (1.2.1)
|
113
|
+
shoulda-matchers (2.8.0)
|
114
114
|
activesupport (>= 3.0.0)
|
115
115
|
simplecov (0.7.1)
|
116
116
|
multi_json (~> 1.0)
|
117
117
|
simplecov-html (~> 0.7.1)
|
118
118
|
simplecov-html (0.7.1)
|
119
|
-
slop (3.
|
119
|
+
slop (3.6.0)
|
120
120
|
terminal-notifier-guard (1.5.3)
|
121
|
-
thor (0.
|
122
|
-
thread_safe (0.
|
123
|
-
|
124
|
-
|
125
|
-
tzinfo (
|
121
|
+
thor (0.19.1)
|
122
|
+
thread_safe (0.3.5)
|
123
|
+
timers (4.0.1)
|
124
|
+
hitimes
|
125
|
+
tzinfo (1.2.2)
|
126
|
+
thread_safe (~> 0.1)
|
126
127
|
vcr (2.5.0)
|
127
128
|
webmock (1.12.3)
|
128
129
|
addressable (>= 2.2.7)
|
129
130
|
crack (>= 0.3.2)
|
130
|
-
xpath (2.0.0)
|
131
|
-
nokogiri (~> 1.3)
|
132
131
|
|
133
132
|
PLATFORMS
|
134
133
|
ruby
|
135
134
|
|
136
135
|
DEPENDENCIES
|
137
|
-
|
138
|
-
guard-rspec (~> 3.0.2)
|
136
|
+
guard-rspec
|
139
137
|
httparty (>= 0.11.0)
|
140
138
|
jeweler (~> 1.8.4)
|
141
139
|
rdoc (~> 3.12)
|
142
|
-
rspec
|
140
|
+
rspec
|
143
141
|
shoulda (~> 3.5)
|
144
142
|
simplecov (~> 0.7.1)
|
145
143
|
terminal-notifier-guard (~> 1.5.3)
|
146
144
|
vcr (~> 2.5.0)
|
147
145
|
webmock (~> 1.12.3)
|
146
|
+
|
147
|
+
BUNDLED WITH
|
148
|
+
1.10.3
|
data/Guardfile
CHANGED
@@ -1,45 +1,53 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
2
|
+
# rspec may be run, below are examples of the most common uses.
|
3
|
+
# * bundler: 'bundle exec rspec'
|
4
|
+
# * bundler binstubs: 'bin/rspec'
|
5
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
6
|
+
# installed the spring binstubs per the docs)
|
7
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
8
|
+
# * 'just' rspec: 'rspec'
|
9
|
+
|
10
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
11
|
+
require "guard/rspec/dsl"
|
12
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
13
|
+
|
14
|
+
# Feel free to open issues for suggestions and improvements
|
15
|
+
|
16
|
+
# RSpec files
|
17
|
+
rspec = dsl.rspec
|
18
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
19
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
20
|
+
watch(rspec.spec_files)
|
21
|
+
|
22
|
+
# Ruby files
|
23
|
+
ruby = dsl.ruby
|
24
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
25
|
+
|
26
|
+
# Rails files
|
27
|
+
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
28
|
+
dsl.watch_spec_files_for(rails.app_files)
|
29
|
+
dsl.watch_spec_files_for(rails.views)
|
30
|
+
|
31
|
+
watch(rails.controllers) do |m|
|
32
|
+
[
|
33
|
+
rspec.spec.("routing/#{m[1]}_routing"),
|
34
|
+
rspec.spec.("controllers/#{m[1]}_controller"),
|
35
|
+
rspec.spec.("acceptance/#{m[1]}")
|
36
|
+
]
|
37
|
+
end
|
38
|
+
|
39
|
+
# Rails config changes
|
40
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
41
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
42
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
15
43
|
|
16
44
|
# Capybara features specs
|
17
|
-
watch(
|
45
|
+
watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
|
46
|
+
watch(rails.layouts) { |m| rspec.spec.("features/#{m[1]}") }
|
18
47
|
|
19
48
|
# Turnip features and steps
|
20
49
|
watch(%r{^spec/acceptance/(.+)\.feature$})
|
21
|
-
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$})
|
50
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
51
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
52
|
+
end
|
22
53
|
end
|
23
|
-
|
24
|
-
|
25
|
-
guard :rspec do
|
26
|
-
watch(%r{^spec/.+_spec\.rb$})
|
27
|
-
watch(%r{^lib/pin_up/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
28
|
-
watch('spec/spec_helper.rb') { "spec" }
|
29
|
-
|
30
|
-
# Rails example
|
31
|
-
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
32
|
-
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
33
|
-
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
34
|
-
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
35
|
-
watch('config/routes.rb') { "spec/routing" }
|
36
|
-
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
37
|
-
|
38
|
-
# Capybara features specs
|
39
|
-
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
40
|
-
|
41
|
-
# Turnip features and steps
|
42
|
-
watch(%r{^spec/acceptance/(.+)\.feature$})
|
43
|
-
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
44
|
-
end
|
45
|
-
|
data/README.md
CHANGED
@@ -123,6 +123,30 @@ If passing a hash of details, it must be the full list of details of the credit
|
|
123
123
|
card = Pin::Card.create(card_details)
|
124
124
|
Pin::Customer.create('email@example.com',card['token'])
|
125
125
|
|
126
|
+
##### List cards for a customer
|
127
|
+
|
128
|
+
token = 'customer_token'
|
129
|
+
Pin::Customer.cards(token)
|
130
|
+
|
131
|
+
##### Create a card for a customer (this does not replace their primary card)
|
132
|
+
|
133
|
+
customer_token = 'customer_token'
|
134
|
+
card = { number: '5520000000000000', expiry_month: '12', expiry_year: '2018', cvc: '123', name: 'Roland TestRobot', address_line1: '123 Fake Road', address_line2: '', address_city: 'Melbourne', address_postcode: '1223', address_state: 'Vic', address_country: 'AU' }
|
135
|
+
Pin::Customer.create_card(customer_token, card)
|
136
|
+
|
137
|
+
You can also use a card token rather than a card hash
|
138
|
+
|
139
|
+
customer_token = 'customer_token'
|
140
|
+
card_token = 'card_token'
|
141
|
+
Pin::Customer.create_card(customer_token, card_token)
|
142
|
+
|
143
|
+
##### Delete a card given a customer and a token
|
144
|
+
This method will raise an exception if attempting to remove the user's primary card
|
145
|
+
|
146
|
+
customer_token = 'customer_token'
|
147
|
+
card_token = 'card_token'
|
148
|
+
Pin::Customer.delete_card(customer_token, card_token)
|
149
|
+
|
126
150
|
## Refunds
|
127
151
|
|
128
152
|
##### Find A Refund
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.1.0
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Pin
|
2
|
+
##
|
3
|
+
# This class models Pin's Balance API
|
4
|
+
class Balance < Base
|
5
|
+
##
|
6
|
+
# Returns the current balance of your Pin Payments account.
|
7
|
+
# Transfers can only be made using the funds in the available balance.
|
8
|
+
# The pending amount will become available after the 7 day settlement schedule on your charges.
|
9
|
+
#
|
10
|
+
# https://pin.net.au/docs/api/balance
|
11
|
+
def self.get
|
12
|
+
build_response(make_request(:get, { url: 'balance' }))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Pin
|
2
|
+
##
|
3
|
+
# This class models Pin's Bank Accounts API
|
4
|
+
class BankAccounts < Base
|
5
|
+
##
|
6
|
+
# Creates a bank account token and returns its details.
|
7
|
+
#
|
8
|
+
# The bank account API allows you to securely store bank account details in exchange for a bank account token.
|
9
|
+
# This token can then be used to create a recipient using the recipients API.
|
10
|
+
#
|
11
|
+
# A bank account token can only be used once to create a recipient.
|
12
|
+
# The token automatically expires after 1 month if it hasn’t been used.
|
13
|
+
#
|
14
|
+
# https://pin.net.au/docs/api/bank-accounts
|
15
|
+
def self.create(options)
|
16
|
+
build_response(make_request(:post, { url: 'bank_accounts', options: options }))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/pin_up/base.rb
CHANGED
data/lib/pin_up/client.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module Pin
|
2
2
|
class Client
|
3
3
|
def initialize(method, args, base_url, auth)
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
@method = method
|
5
|
+
@args = args
|
6
|
+
@base_url = base_url
|
7
|
+
@auth = auth
|
8
8
|
end
|
9
9
|
|
10
10
|
##
|
@@ -19,4 +19,4 @@ module Pin
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
22
|
-
end
|
22
|
+
end
|
data/lib/pin_up/customer.rb
CHANGED
@@ -65,5 +65,44 @@ module Pin
|
|
65
65
|
make_request(:get, {url: "customers/#{token}/charges?page=#{page}" }), pagination
|
66
66
|
)
|
67
67
|
end
|
68
|
+
|
69
|
+
##
|
70
|
+
# Get a list of cards for a customer
|
71
|
+
# args: token (String), page (Fixnum), pagination (Boolean)
|
72
|
+
# returns: a collection of cards objects
|
73
|
+
#
|
74
|
+
# if pagination is passed, access the response hash with [:response]
|
75
|
+
# and the pagination hash with [:pagination]
|
76
|
+
#
|
77
|
+
# https://pin.net.au/docs/api/customers#get-customers-cards
|
78
|
+
def self.cards(token, page = nil, pagination = false)
|
79
|
+
build_collection_response(
|
80
|
+
make_request(:get, {url: "customers/#{token}/cards?page=#{page}" }), pagination
|
81
|
+
)
|
82
|
+
end
|
83
|
+
|
84
|
+
##
|
85
|
+
# Create a card for customer given a card OR a card_token
|
86
|
+
# args: customer_token (String), card (Hash) or (String) see docs.
|
87
|
+
# returns: a card object
|
88
|
+
# https://pin.net.au/docs/api/customers#post-customers-cards
|
89
|
+
def self.create_card(token, card)
|
90
|
+
options = if card.respond_to?(:to_hash)
|
91
|
+
card
|
92
|
+
else
|
93
|
+
{ card_token: card }
|
94
|
+
end
|
95
|
+
|
96
|
+
build_response(make_request(:post, {url: "customers/#{token}/cards", options: options} ))
|
97
|
+
end
|
98
|
+
|
99
|
+
##
|
100
|
+
# Deletes a card for customer given a card_token
|
101
|
+
# args: customer_token (String), card_token (String)
|
102
|
+
# returns: a card object
|
103
|
+
# https://pin.net.au/docs/api/customers#delete-customers-card
|
104
|
+
def self.delete_card(token, card_token)
|
105
|
+
build_response(make_request(:delete, {url: "customers/#{token}/cards/#{card_token}"} ))
|
106
|
+
end
|
68
107
|
end
|
69
108
|
end
|
data/lib/pin_up/pin_errors.rb
CHANGED
@@ -15,7 +15,12 @@ module Pin
|
|
15
15
|
def self.handle_error(http_status, response)
|
16
16
|
case http_status
|
17
17
|
when 400
|
18
|
-
|
18
|
+
case response['error']
|
19
|
+
when 'cannot_delete_primary_card'
|
20
|
+
fail(Pin::InvalidResource, response['error_description'])
|
21
|
+
else
|
22
|
+
fail(Pin::ChargeError, "#{response['error']}: #{response['error_description']}. Charge token: #{response['charge_token']}")
|
23
|
+
end
|
19
24
|
when 402
|
20
25
|
fail(Pin::InsufficientPinBalance, "#{response['error_description']}")
|
21
26
|
when 404
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Pin
|
2
|
+
##
|
3
|
+
# This class models Pin's Recipient API
|
4
|
+
class Recipient < Base
|
5
|
+
##
|
6
|
+
# Creates a new recipient and returns its details.
|
7
|
+
# https://pin.net.au/docs/api/recipients#post-recipients
|
8
|
+
# args: options (Hash)
|
9
|
+
# returns: recipient (Hash)
|
10
|
+
def self.create(options)
|
11
|
+
build_response(make_request(:post, { url: 'recipients', options: options }))
|
12
|
+
end
|
13
|
+
|
14
|
+
##
|
15
|
+
# Lists all recipients for your account
|
16
|
+
# args: page (Fixnum), pagination (Boolean)
|
17
|
+
# returns: a collection of recipients
|
18
|
+
#
|
19
|
+
# if pagination is passed, access the response hash with [:response]
|
20
|
+
# and the pagination hash with [:pagination]
|
21
|
+
#
|
22
|
+
# https://pin.net.au/docs/api/recipients#get-recipients
|
23
|
+
def self.all(page = nil, pagination = false)
|
24
|
+
build_collection_response(make_request(:get, {url: "recipients?page=#{page}" } ), pagination)
|
25
|
+
end
|
26
|
+
|
27
|
+
##
|
28
|
+
# Find a recipient for your account given a token
|
29
|
+
# args: token (String)
|
30
|
+
# returns: a recipient
|
31
|
+
# https://pin.net.au/docs/api/recipients#get-recipient
|
32
|
+
def self.find(token)
|
33
|
+
build_response(make_request(:get, {url: "recipients/#{token}" } ))
|
34
|
+
end
|
35
|
+
|
36
|
+
##
|
37
|
+
# Update a recipient for your account given a token
|
38
|
+
# and any of: email, name, bank_account (hash)
|
39
|
+
# args: token (String), options (Hash)
|
40
|
+
# returns: a recipient
|
41
|
+
# https://pin.net.au/docs/api/recipients#put-recipient
|
42
|
+
def self.update(token, options = {})
|
43
|
+
build_response(make_request(:put, { url: "recipients/#{token}", options: options }))
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.transfers(token, pagination = false)
|
47
|
+
build_collection_response(make_request(:get, { url: "recipients/#{token}/transfers" } ), pagination)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Pin
|
2
|
+
##
|
3
|
+
# This class models Pin's Transfers API
|
4
|
+
class Transfer < Base
|
5
|
+
##
|
6
|
+
# Creates a new transfer and returns its details.
|
7
|
+
# https://pin.net.au/docs/api/transfers#post-transfers
|
8
|
+
# args: options (Hash)
|
9
|
+
def self.create(options)
|
10
|
+
build_response(make_request(:post, { url: 'transfers', options: options }))
|
11
|
+
end
|
12
|
+
|
13
|
+
##
|
14
|
+
# Returns a paginated list of all transfers.
|
15
|
+
# page: page (Fixnum), pagination (Boolean)
|
16
|
+
#
|
17
|
+
# if pagination is passed, access the response hash with [:response]
|
18
|
+
# and the pagination hash with [:pagination]
|
19
|
+
#
|
20
|
+
# https://pin.net.au/docs/api/transfers#get-transfers
|
21
|
+
def self.all(page = nil, pagination = false)
|
22
|
+
build_collection_response(make_request(:get, {url: "transfers?page=#{page}" } ), pagination)
|
23
|
+
end
|
24
|
+
|
25
|
+
##
|
26
|
+
# Returns the details of a transfer.
|
27
|
+
# args: token (String)
|
28
|
+
# returns: a transfer
|
29
|
+
# https://pin.net.au/docs/api/transfers#get-transfer
|
30
|
+
def self.find(token)
|
31
|
+
build_response(make_request(:get, {url: "transfers/#{token}" } ))
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# Returns the line items associated with transfer.
|
36
|
+
# args: token (String), page (Fixnum), pagination (Boolean)
|
37
|
+
#
|
38
|
+
# https://pin.net.au/docs/api/transfers#get-transfer-line-items
|
39
|
+
def self.line_items(token, page = nil, pagination = false)
|
40
|
+
build_collection_response(make_request(:get, {url: "transfers/#{token}/line_items?page=#{page}" } ), pagination)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/pin_up.rb
CHANGED
@@ -2,11 +2,16 @@ require 'httparty'
|
|
2
2
|
require 'json'
|
3
3
|
|
4
4
|
require 'pin_up/base'
|
5
|
+
|
6
|
+
require 'pin_up/balance'
|
7
|
+
require 'pin_up/bank_accounts'
|
5
8
|
require 'pin_up/card'
|
6
9
|
require 'pin_up/charge'
|
7
10
|
require 'pin_up/client'
|
8
11
|
require 'pin_up/customer'
|
12
|
+
require 'pin_up/recipient'
|
9
13
|
require 'pin_up/refund'
|
10
14
|
require 'pin_up/retrying_client'
|
15
|
+
require 'pin_up/transfer'
|
11
16
|
|
12
17
|
require 'pin_up/pin_errors'
|