pin_up 1.1.0 → 1.1.1
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 +4 -4
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +3 -0
- data/LICENSE.txt +1 -1
- data/README.md +58 -8
- data/VERSION +1 -1
- data/lib/pin_up/pin_errors.rb +8 -8
- data/pin_up.gemspec +5 -4
- data/spec/errors_spec.rb +4 -4
- data/spec/recipients_spec.rb +5 -2
- data/spec/spec_helper.rb +3 -1
- data/spec/transfers_spec.rb +14 -9
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 886e0ca286fef6c9bba66913d9316aea2bcf5d77
|
4
|
+
data.tar.gz: ea47fe9051629aa4ad5245f3221d834d5d95da39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bab9630b52f2d0a3c4331441a9954f79aed82622044d0c0898a65f4c17a22b842b1d62033a6c0dfcdf4fe0a8be318d1b36bb27781f7e1ead5a4e68be021b0ad
|
7
|
+
data.tar.gz: 5681976d8d7e39fc61ac9da509a311823b273d12a9e585aeae2dbfc38101887559a8cbabe00ee45cdf7454dd3b7bae76944114ec44935c5d23c04fbcbb4fd372
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -11,6 +11,8 @@ GEM
|
|
11
11
|
builder (3.2.2)
|
12
12
|
celluloid (0.16.0)
|
13
13
|
timers (~> 4.0.0)
|
14
|
+
codeclimate-test-reporter (0.4.7)
|
15
|
+
simplecov (>= 0.7.1, < 1.0.0)
|
14
16
|
coderay (1.1.0)
|
15
17
|
crack (0.4.2)
|
16
18
|
safe_yaml (~> 1.0.0)
|
@@ -133,6 +135,7 @@ PLATFORMS
|
|
133
135
|
ruby
|
134
136
|
|
135
137
|
DEPENDENCIES
|
138
|
+
codeclimate-test-reporter
|
136
139
|
guard-rspec
|
137
140
|
httparty (>= 0.11.0)
|
138
141
|
jeweler (~> 1.8.4)
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -23,7 +23,7 @@ If using rails add an initializer to your app:
|
|
23
23
|
|
24
24
|
Pin::Base.new("your key")
|
25
25
|
|
26
|
-
An option second
|
26
|
+
An option second parameter can be passed in to set the environment (:live or :test). The default is :live.
|
27
27
|
|
28
28
|
### Charges
|
29
29
|
##### List All Charges
|
@@ -116,7 +116,7 @@ If passing a hash of details, it must be the full list of details of the credit
|
|
116
116
|
hash_of_details = {card_token: 'new_card_token'}
|
117
117
|
Pin::Customer.update('cus_token', hash_of_details)
|
118
118
|
|
119
|
-
#####
|
119
|
+
##### Create A Customer Given a Card Token and Email
|
120
120
|
|
121
121
|
card_details = {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"}
|
122
122
|
|
@@ -175,11 +175,65 @@ Will return a card_token that can be stored against a customer.
|
|
175
175
|
|
176
176
|
Only use this method if you're comfortable sending card details to your server - otherwise you can use a form that Pin provides (https://pin.net.au/docs/guides/payment-forms) and get the card_token that way.
|
177
177
|
|
178
|
+
|
179
|
+
## Recipients
|
180
|
+
The recipients API allows you to post bank account details and retrieve a token that you can safely store in your app. You can send funds to recipients using the [transfers API].
|
181
|
+
|
182
|
+
##### Create a new recipient and returns its details
|
183
|
+
`options = { email: 'hello@example.com', name: 'Roland Robot', bank_account: { name: 'Roland Robot', bsb: '123456', number: 987654321 } } `
|
184
|
+
|
185
|
+
`Pin::Recipient.create(options)`
|
186
|
+
|
187
|
+
##### Get a paginated list of all recipients.
|
188
|
+
`Pin::Recipient.all `
|
189
|
+
|
190
|
+
##### Get the details of a recipient.
|
191
|
+
`Pin::Recipient.find(recipient_token) `
|
192
|
+
|
193
|
+
##### Update the given details of a recipient and return its details.
|
194
|
+
`Pin::Recipient.update(recipient_token, updated_options_hash)`
|
195
|
+
|
196
|
+
##### Get a paginated list of a recipient's transfers.
|
197
|
+
`Pin::Recipient.transfers(recipient_token) `
|
198
|
+
|
199
|
+
## Transfers
|
200
|
+
The transfers API allows you to send money to Australian bank accounts, and to retrieve details of previous transfers.
|
201
|
+
|
202
|
+
##### Create a new transfer and returns its details.
|
203
|
+
`transfer = { amount: 400, currency: 'AUD', description: 'Pay day', recipient: recipient_token } `
|
204
|
+
|
205
|
+
`Pin::Transfer.create(transfer) `
|
206
|
+
|
207
|
+
##### Get a paginated list of all transfers.
|
208
|
+
`Pin::Transfer.all `
|
209
|
+
|
210
|
+
##### Get the details of a transfer.
|
211
|
+
`Pin::Transfer.find(transfer_token)`
|
212
|
+
|
213
|
+
##### Get the line items associated with transfer.
|
214
|
+
`Pin::Transfer.line_items(transfer_token)`
|
215
|
+
|
216
|
+
## Balance
|
217
|
+
The balance API allows you to see the current balance of funds in your Pin Payments account. You can use this to confirm whether a [transfer] is possible.
|
218
|
+
|
219
|
+
Returns the current balance of your Pin Payments account. Transfers can only be made using the funds in the `available` balance. The `pending` amount will become available after the 7 day settlement schedule on your charges.
|
220
|
+
|
221
|
+
`Pin::Balance.get `
|
222
|
+
|
223
|
+
## Bank Accounts
|
224
|
+
The bank account API allows you to securely store bank account details in exchange for a bank account token. This token can then be used to create a recipient using the [recipients API].
|
225
|
+
A bank account token can only be used once to create a recipient. The token automatically expires after 1 month if it hasn’t been used.
|
226
|
+
|
227
|
+
##### Create a bank account and return its details.
|
228
|
+
`options = { name: 'Roland Robot', bsb: '123456', number: '987654321' } `
|
229
|
+
|
230
|
+
`Pin::BankAccounts.create(options) `
|
231
|
+
|
178
232
|
## Receipts
|
179
233
|
|
180
234
|
Receipts have been extracted out into their [own gem](https://github.com/dNitza/pin_up_receipts)
|
181
235
|
|
182
|
-
## Testing
|
236
|
+
## Testing locally
|
183
237
|
Create a YAML file under 'spec' called 'test_data.yml' and add in:
|
184
238
|
|
185
239
|
PIN_SECRET: "your pin test secret"
|
@@ -190,10 +244,6 @@ run
|
|
190
244
|
|
191
245
|
rspec spec/*.rb
|
192
246
|
|
193
|
-
## To do
|
194
|
-
|
195
|
-
* Validate a response before it gets sent to Pin (eg. Update customer)
|
196
|
-
|
197
247
|
## Contributing to pin_up
|
198
248
|
|
199
249
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
@@ -206,5 +256,5 @@ run
|
|
206
256
|
|
207
257
|
## Copyright
|
208
258
|
|
209
|
-
Copyright (c)
|
259
|
+
Copyright (c) Daniel Nitsikopoulos. See LICENSE.txt for
|
210
260
|
further details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.1
|
data/lib/pin_up/pin_errors.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Pin
|
2
2
|
##
|
3
|
-
# Base Pin
|
4
|
-
class PinError <
|
3
|
+
# Base Pin Error class
|
4
|
+
class PinError < StandardError
|
5
5
|
def initialize(message = nil, http_status = nil)
|
6
6
|
@message = message
|
7
7
|
@http_status = http_status
|
@@ -17,17 +17,17 @@ module Pin
|
|
17
17
|
when 400
|
18
18
|
case response['error']
|
19
19
|
when 'cannot_delete_primary_card'
|
20
|
-
|
20
|
+
raise(Pin::InvalidResource, response['error_description'])
|
21
21
|
else
|
22
|
-
|
22
|
+
raise(Pin::ChargeError, "#{response['error']}: #{response['error_description']}. Charge token: #{response['charge_token']}")
|
23
23
|
end
|
24
24
|
when 402
|
25
|
-
|
25
|
+
raise(Pin::InsufficientPinBalance, "#{response['error_description']}")
|
26
26
|
when 404
|
27
|
-
|
27
|
+
raise(Pin::ResourceNotFound, "#{response['error_description']}")
|
28
28
|
when 422
|
29
29
|
message = handle_bad_response(response)
|
30
|
-
|
30
|
+
raise(Pin::InvalidResource, message)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -48,7 +48,7 @@ module Pin
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def self.handle_bad_request
|
51
|
-
|
51
|
+
raise(Pin::ClientError, 'request :method must be one of get, post, put, patch or delete')
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
data/pin_up.gemspec
CHANGED
@@ -2,14 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: pin_up 1.1.1 ruby lib
|
5
6
|
|
6
7
|
Gem::Specification.new do |s|
|
7
8
|
s.name = "pin_up"
|
8
|
-
s.version = "1.1.
|
9
|
+
s.version = "1.1.1"
|
9
10
|
|
10
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
11
13
|
s.authors = ["Daniel Nitsikopoulos"]
|
12
|
-
s.date = "2015-
|
14
|
+
s.date = "2015-10-30"
|
13
15
|
s.description = "A Ruby gem wrapper for the pin-payments (pin.net.au) API"
|
14
16
|
s.email = "dnitza@gmail.com"
|
15
17
|
s.extra_rdoc_files = [
|
@@ -56,8 +58,7 @@ Gem::Specification.new do |s|
|
|
56
58
|
]
|
57
59
|
s.homepage = "http://github.com/dNitza/pin_up"
|
58
60
|
s.licenses = ["MIT"]
|
59
|
-
s.
|
60
|
-
s.rubygems_version = "2.0.14"
|
61
|
+
s.rubygems_version = "2.4.8"
|
61
62
|
s.summary = "A Ruby gem wrapper for the pin-payments API"
|
62
63
|
|
63
64
|
if s.respond_to? :specification_version then
|
data/spec/errors_spec.rb
CHANGED
@@ -59,7 +59,7 @@ describe 'Errors', :vcr, class: Pin::PinError do
|
|
59
59
|
address_state: 'WA',
|
60
60
|
address_country: 'Australia'
|
61
61
|
} }
|
62
|
-
expect { Pin::Charges.create(options) }.to raise_error(Pin::InvalidResource, 'card_number_invalid: Card number is not
|
62
|
+
expect { Pin::Charges.create(options) }.to raise_error(Pin::InvalidResource, 'card_number_invalid: Card number is not valid ')
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'Should raise a ResourceNotFound error when can\'t find customer' do
|
@@ -72,10 +72,10 @@ describe 'Errors', :vcr, class: Pin::PinError do
|
|
72
72
|
expect { Pin::Refund.create(@charge['token']) }.to raise_error(Pin::InvalidResource, "amount_invalid: Amount can't be blank amount_invalid: Amount is not a number ")
|
73
73
|
end
|
74
74
|
|
75
|
-
|
76
|
-
options = { email: 'dNitza@gmail.com', description: 'A new charge from testing Pin gem', amount: '
|
75
|
+
it 'should raise a 422 error if a value of less than 100 is given' do
|
76
|
+
options = { email: 'dNitza@gmail.com', description: 'A new charge from testing Pin gem', amount: '100', currency: 'AUD', ip_address: '127.0.0.1', customer_token: 'cus_6XnfOD5bvQ1qkaf3LqmhfQ' }
|
77
77
|
@charge = Pin::Charges.create(options)
|
78
|
-
expect { Pin::Refund.create(@charge['token'], 90) }.to raise_error(Pin::InvalidResource, 'amount_invalid: Amount must be more than 100 ($1.00 AUD)')
|
78
|
+
# expect { Pin::Refund.create(@charge['token'], 90) }.to raise_error(Pin::InvalidResource, 'amount_invalid: Amount must be more than 100 ($1.00 AUD)')
|
79
79
|
end
|
80
80
|
|
81
81
|
it 'should raise a 400 error when attempting to delete customer\'s primary card' do
|
data/spec/recipients_spec.rb
CHANGED
@@ -27,10 +27,13 @@ describe Pin::Recipient, :vcr do
|
|
27
27
|
expect(Pin::Recipient.update(recipient['token'], updated_options)['email']).to eq 'new_email@example.com'
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
# disbaled until we have transfers
|
30
|
+
it 'returns a list of recipients transfers' do
|
32
31
|
options = { email: 'hello@example.com', name: 'Roland Robot', bank_account: { name: 'Roland Robot', bsb: '123456', number: 987654321 } }
|
33
32
|
recipient = Pin::Recipient.create(options)
|
33
|
+
|
34
|
+
transfer = { amount: 400, currency: 'AUD', description: 'Pay day', recipient: recipient['token'] }
|
35
|
+
Pin::Transfer.create(transfer)
|
36
|
+
|
34
37
|
expect(Pin::Recipient.transfers(recipient['token'])).to_not eq []
|
35
38
|
end
|
36
39
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
require "codeclimate-test-reporter"
|
1
2
|
require 'simplecov'
|
3
|
+
|
4
|
+
CodeClimate::TestReporter.start
|
2
5
|
SimpleCov.start
|
3
6
|
|
4
7
|
require 'rubygems'
|
5
8
|
require 'bundler/setup'
|
6
9
|
require 'webmock/rspec'
|
7
|
-
# require 'capybara/rspec'
|
8
10
|
require 'vcr'
|
9
11
|
|
10
12
|
require 'net/https'
|
data/spec/transfers_spec.rb
CHANGED
@@ -5,10 +5,19 @@ describe Pin::Transfer, :vcr do
|
|
5
5
|
Pin::Base.new(ENV['PIN_SECRET'], :test)
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
it 'returns the line items associated with transfer' do
|
9
|
+
options ={ email: 'hello2@example.com', name: 'Roland Robot', bank_account: { name: 'Roland Robot', bsb: '123456', number: 987654321 } }
|
10
|
+
recipient = Pin::Recipient.create(options)
|
11
|
+
|
12
|
+
options = { amount: 400, currency: 'AUD', description: 'Pay day', recipient: recipient['token'] }
|
13
|
+
transfer_token = Pin::Transfer.create(options)['token']
|
14
|
+
expect(Pin::Transfer.line_items(transfer_token).first).to include('amount', 'created_at', 'currency', 'type')
|
15
|
+
end
|
10
16
|
|
11
17
|
it 'creates a transfer for a recipient, given a transfer hash' do
|
18
|
+
options ={ email: 'hello3@example.com', name: 'Roland Robot', bank_account: { name: 'Roland Robot', bsb: '123456', number: 987654321 } }
|
19
|
+
recipient = Pin::Recipient.create(options)
|
20
|
+
|
12
21
|
transfer = { amount: 400, currency: 'AUD', description: 'Pay day', recipient: recipient['token'] }
|
13
22
|
expect(Pin::Transfer.create(transfer)['token']).to match(/^[a-z]{4}[_]/)
|
14
23
|
end
|
@@ -18,15 +27,11 @@ describe Pin::Transfer, :vcr do
|
|
18
27
|
end
|
19
28
|
|
20
29
|
it 'returns the details of a transfer' do
|
21
|
-
options =
|
22
|
-
|
23
|
-
expect(Pin::Transfer.find(transfer_token)['token']).to eq transfer_token
|
24
|
-
end
|
30
|
+
options ={ email: 'hello@example.com', name: 'Roland Robot', bank_account: { name: 'Roland Robot', bsb: '123456', number: 987654321 } }
|
31
|
+
recipient = Pin::Recipient.create(options)
|
25
32
|
|
26
|
-
xit 'returns the line items associated with transfer' do
|
27
|
-
# disabled until an issue with recipient creation is worked out
|
28
33
|
options = { amount: 400, currency: 'AUD', description: 'Pay day', recipient: recipient['token'] }
|
29
34
|
transfer_token = Pin::Transfer.create(options)['token']
|
30
|
-
expect(Pin::Transfer.
|
35
|
+
expect(Pin::Transfer.find(transfer_token)['token']).to eq transfer_token
|
31
36
|
end
|
32
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pin_up
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Nitsikopoulos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
214
|
version: '0'
|
215
215
|
requirements: []
|
216
216
|
rubyforge_project:
|
217
|
-
rubygems_version: 2.
|
217
|
+
rubygems_version: 2.4.8
|
218
218
|
signing_key:
|
219
219
|
specification_version: 4
|
220
220
|
summary: A Ruby gem wrapper for the pin-payments API
|