pin_payment 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +6 -3
- data/lib/pin_payment.rb +1 -0
- data/lib/pin_payment/base.rb +4 -0
- data/lib/pin_payment/charge.rb +9 -0
- data/lib/pin_payment/customer.rb +4 -0
- data/lib/pin_payment/refund.rb +13 -2
- data/lib/pin_payment/transfer.rb +3 -3
- data/lib/pin_payment/version.rb +1 -1
- data/pin_payment.gemspec +2 -2
- data/test/fixtures/responses.yml +2 -0
- data/test/test_pin_customer.rb +15 -0
- data/test/test_pin_setup.rb +1 -1
- metadata +14 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dfb1ab658537697e3c6f11264745662ee3e35dd
|
4
|
+
data.tar.gz: 20fc251cc598cda75a17a8c0a5eff56c4d2c9643
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee665c32242d24ebd7d57803f733c434e12af65236de28da4d0b8f05fd58499c63798ecc02ca2701778a2b6c76f38d80e8c0950b47ed094165ad96ac56cfce35
|
7
|
+
data.tar.gz: b6951a24fda40f460075767ae4fddb3970020268cc9c7baa23f2692a738204fb3efcc8bbec49283ba16deffb59458d41c6652c3b395c440d622d04815cce9d3d
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,20 +1,23 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pin_payment (0.5.
|
4
|
+
pin_payment (0.5.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
fakeweb (1.3.0)
|
10
|
+
minitest (5.11.3)
|
10
11
|
rake (10.0.4)
|
11
|
-
yard (0.8.6.1)
|
12
12
|
|
13
13
|
PLATFORMS
|
14
14
|
ruby
|
15
15
|
|
16
16
|
DEPENDENCIES
|
17
17
|
fakeweb
|
18
|
+
minitest
|
18
19
|
pin_payment!
|
19
20
|
rake
|
20
|
-
|
21
|
+
|
22
|
+
BUNDLED WITH
|
23
|
+
1.17.2
|
data/lib/pin_payment.rb
CHANGED
data/lib/pin_payment/base.rb
CHANGED
@@ -23,6 +23,10 @@ module PinPayment
|
|
23
23
|
def self.get uri, options = {}
|
24
24
|
fetch Net::HTTP::Get, uri, options
|
25
25
|
end
|
26
|
+
|
27
|
+
def self.delete uri, options = {}
|
28
|
+
fetch Net::HTTP::Delete, uri, options
|
29
|
+
end
|
26
30
|
|
27
31
|
def self.fetch klass, uri, options
|
28
32
|
client = Net::HTTP.new(uri.host, uri.port)
|
data/lib/pin_payment/charge.rb
CHANGED
@@ -47,6 +47,15 @@ module PinPayment
|
|
47
47
|
Refund.create self
|
48
48
|
end
|
49
49
|
|
50
|
+
# Fetches all refunds of your charge using the pin API.
|
51
|
+
#
|
52
|
+
# @return [Array<PinPayment::Refund>]
|
53
|
+
# TODO: pagination
|
54
|
+
def refunds
|
55
|
+
response = Charge.get(URI.parse(PinPayment.api_url).tap{|uri| uri.path = "/1/charges/#{token}/refunds" })
|
56
|
+
response.map{|x| Refund.new(x.delete('token'), x) }
|
57
|
+
end
|
58
|
+
|
50
59
|
# @return [Boolean]
|
51
60
|
def success?
|
52
61
|
success == true
|
data/lib/pin_payment/customer.rb
CHANGED
@@ -14,6 +14,10 @@ module PinPayment
|
|
14
14
|
response = post(URI.parse(PinPayment.api_url).tap{|uri| uri.path = '/1/customers' }, options)
|
15
15
|
new(response.delete('token'), response)
|
16
16
|
end
|
17
|
+
|
18
|
+
def self.delete_customer(token)
|
19
|
+
delete(URI.parse(PinPayment.api_url).tap{|uri| uri.path = "/1/customers/#{token}" })
|
20
|
+
end
|
17
21
|
|
18
22
|
# Update a customer using the pin API.
|
19
23
|
#
|
data/lib/pin_payment/refund.rb
CHANGED
@@ -7,9 +7,20 @@ module PinPayment
|
|
7
7
|
#
|
8
8
|
# @param [String, PinPayment::Charge] charge_or_token the charge (or token of the charge) to refund
|
9
9
|
# @return [PinPayment::Refund]
|
10
|
-
def self.create
|
10
|
+
def self.create refund_data
|
11
|
+
charge_or_token = refund_data.is_a?(Hash) ? refund_data[:charge] : refund_data
|
11
12
|
token = charge_or_token.is_a?(Charge) ? charge_or_token.token : charge_or_token
|
12
|
-
|
13
|
+
options = refund_data.is_a?(Hash) && refund_data[:amount] ? { amount: refund_data[:amount] } : {}
|
14
|
+
response = post(URI.parse(PinPayment.api_url).tap{|uri| uri.path = "/1/charges/#{token}/refunds" }, options)
|
15
|
+
new(response.delete('token'), response)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Fetches a refund using the Pin API.
|
19
|
+
#
|
20
|
+
# @param [String] token the charge token
|
21
|
+
# @return [PinPayment::Refund]
|
22
|
+
def self.find token
|
23
|
+
response = get(URI.parse(PinPayment.api_url).tap{ |uri| uri.path = "/1/refunds/#{token}" })
|
13
24
|
new(response.delete('token'), response)
|
14
25
|
end
|
15
26
|
|
data/lib/pin_payment/transfer.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module PinPayment
|
2
2
|
class Transfer < Base
|
3
3
|
|
4
|
-
attr_accessor :description, :amount, :currency, :recipient, :token
|
5
|
-
protected :description=, :amount=, :currency=, :recipient=, :token=
|
4
|
+
attr_accessor :description, :amount, :currency, :recipient, :token, :status, :paid_at, :total_debits, :total_credits
|
5
|
+
protected :description=, :amount=, :currency=, :recipient=, :token=, :status=, :paid_at=, :total_debits=, :total_credits=
|
6
6
|
|
7
7
|
# Uses the pin API to create a transfer.
|
8
8
|
#
|
@@ -45,7 +45,7 @@ module PinPayment
|
|
45
45
|
protected
|
46
46
|
|
47
47
|
def self.attributes
|
48
|
-
[:token, :description, :amount, :currency, :recipient]
|
48
|
+
[:token, :description, :amount, :currency, :recipient, :status, :paid_at, :total_debits, :total_credits]
|
49
49
|
end
|
50
50
|
|
51
51
|
class LineItem < Base
|
data/lib/pin_payment/version.rb
CHANGED
data/pin_payment.gemspec
CHANGED
@@ -14,9 +14,9 @@ spec = Gem::Specification.new do |s|
|
|
14
14
|
|
15
15
|
s.add_development_dependency('fakeweb')
|
16
16
|
s.add_development_dependency('rake')
|
17
|
-
s.add_development_dependency('
|
17
|
+
s.add_development_dependency('minitest')
|
18
18
|
|
19
|
-
s.required_ruby_version = '>=
|
19
|
+
s.required_ruby_version = '>= 2.3.0'
|
20
20
|
|
21
21
|
s.files = `git ls-files`.split("\n")
|
22
22
|
s.test_files = `git ls-files -- test/*`.split("\n")
|
data/test/fixtures/responses.yml
CHANGED
@@ -12,6 +12,8 @@ customer:
|
|
12
12
|
created: '{"response":{"token":"cus__03Cn1lSk3offZ0IGkwpCg","email":"foo@example.com","created_at":"2013-06-12T10:08:30Z","card":{"token":"card_qMwnMfpG-olOhfJeyxmrcg","display_number":"XXXX-XXXX-XXXX-0000","scheme":"master","address_line1":"123 Main St","address_line2":"","address_city":"Melbourne","address_postcode":"3000","address_state":"Victoria","address_country":"Australia"}}}'
|
13
13
|
all: '{"response":[{"token":"cus_OEHdj9KE_OiC9eig0h3IEA","email":"user1@example.com","created_at":"2013-06-25T04:14:35Z","card":{"token":"card_7rviJ2IZM__WC9Dnj0RHJA","display_number":"XXXX-XXXX-XXXX-0000","scheme":"visa","address_line1":"123 Main St","address_line2":"","address_city":"Melbourne","address_postcode":"3000","address_state":"Victoria","address_country":"Australia"}},{"token":"cus_cO2VtF4YzK6i1QBcLsdzOA","email":"user2@example.com","created_at":"2013-06-24T05:53:42Z","card":{"token":"card_bVou2J4hzbDIwe-sQ3ZqdQ","display_number":"XXXX-XXXX-XXXX-0000","scheme":"visa","address_line1":"123 Main St","address_line2":"","address_city":"Melbourne","address_postcode":"3000","address_state":"Victoria","address_country":"Australia"}}],"count":2,"pagination":{"current":1,"previous":null,"next":null,"per_page":25,"pages":1,"count":2}}'
|
14
14
|
create_with_card: '{"response":{"token":"cus_XZg1ULpWaROQCOT5PdwLkQ","email":"roland@pin.net.au","created_at":"2013-06-27T00:24:43Z","card":{"token":"card_nytGw7koRg23EEp9NTmz9w","display_number":"XXXX-XXXX-XXXX-0000","scheme":"master","address_line1":"42 Sevenoaks St","address_line2":null,"address_city":"Lathlain","address_postcode":"6454","address_state":"WA","address_country":"Australia"}}}'
|
15
|
+
deleted: '{"response":{}}'
|
16
|
+
delete_not_found: '{"error":"resource_not_found","error_description":"No resource was found at this URL."}'
|
15
17
|
refund:
|
16
18
|
success: '{"response":{"token":"rf_wMYx5YHKaZAwQgj5rtNuTg","success":null,"amount":1000,"currency":"USD","charge":"ch_BjGW-S6WUisI6mOgpDRimg","created_at":"2013-06-25T03:16:33Z","error_message":null,"status_message":"Pending"}}'
|
17
19
|
duplicate: '{"error":"invalid_resource","error_description":"One or more parameters were missing or invalid.","messages":{"charge":["You have tried to refund more than the original charge"]}}'
|
data/test/test_pin_customer.rb
CHANGED
@@ -16,6 +16,21 @@ class TestPinCustomer < MiniTest::Unit::TestCase
|
|
16
16
|
customer = created_customer
|
17
17
|
assert_kind_of PinPayment::Customer, customer
|
18
18
|
end
|
19
|
+
|
20
|
+
def test_delete_success
|
21
|
+
customer = created_customer
|
22
|
+
FakeWeb.register_uri(:delete, "https://test-api.pin.net.au/1/customers/#{customer.token}", body: fixtures['responses']['customer']['deleted'])
|
23
|
+
response = PinPayment::Customer.delete_customer(customer.token)
|
24
|
+
assert_empty response
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_delete_not_found
|
28
|
+
token = 'none-existing-token'
|
29
|
+
FakeWeb.register_uri(:delete, "https://test-api.pin.net.au/1/customers/#{token}", body: fixtures['responses']['customer']['delete_not_found'])
|
30
|
+
assert_raises PinPayment::Error::ResourceNotFound do
|
31
|
+
PinPayment::Customer.delete_customer(token)
|
32
|
+
end
|
33
|
+
end
|
19
34
|
|
20
35
|
def test_direct_update
|
21
36
|
customer = created_customer
|
data/test/test_pin_setup.rb
CHANGED
@@ -21,7 +21,7 @@ class TestPinSetup < MiniTest::Unit::TestCase
|
|
21
21
|
oldurl = PinPayment.api_url
|
22
22
|
assert_equal 'https://test-api.pin.net.au', PinPayment.api_url
|
23
23
|
PinPayment.api_url = 'foo'
|
24
|
-
assert_equal 'foo', PinPayment.api_url
|
24
|
+
assert_equal 'https://foo', PinPayment.api_url
|
25
25
|
PinPayment.api_url = oldurl
|
26
26
|
end
|
27
27
|
end
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pin_payment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danial Pearce
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fakeweb
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
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: :development
|
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
|
42
|
-
name:
|
42
|
+
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: Pin is the easiest way to accept payments online. See https://pin.net.au/
|
@@ -60,7 +60,7 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
-
- .gitignore
|
63
|
+
- ".gitignore"
|
64
64
|
- Gemfile
|
65
65
|
- Gemfile.lock
|
66
66
|
- LICENSE
|
@@ -100,17 +100,17 @@ require_paths:
|
|
100
100
|
- lib
|
101
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- -
|
103
|
+
- - ">="
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
version:
|
105
|
+
version: 2.3.0
|
106
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
112
|
rubyforge_project:
|
113
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.5.1
|
114
114
|
signing_key:
|
115
115
|
specification_version: 4
|
116
116
|
summary: Ruby bindings for the Pin API
|
@@ -126,4 +126,3 @@ test_files:
|
|
126
126
|
- test/test_pin_refund.rb
|
127
127
|
- test/test_pin_setup.rb
|
128
128
|
- test/test_pin_transfer.rb
|
129
|
-
has_rdoc:
|