pin-payments 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pin-payments.rb +5 -4
- metadata +27 -10
- checksums.yaml +0 -15
- data/lib/base.rb +0 -26
- data/lib/card.rb +0 -34
- data/lib/charge.rb +0 -18
- data/lib/customer.rb +0 -44
data/lib/pin-payments.rb
CHANGED
metadata
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pin-payments
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Alex Ghiculescu
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-
|
12
|
+
date: 2013-07-26 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: httparty
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
@@ -20,6 +22,7 @@ dependencies:
|
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
@@ -27,6 +30,7 @@ dependencies:
|
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: bundler
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ~>
|
32
36
|
- !ruby/object:Gem::Version
|
@@ -34,44 +38,57 @@ dependencies:
|
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - ~>
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: '1.3'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: webmock
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
41
62
|
description: A wrapper for the Pin Payments (https://pin.net.au/) API
|
42
63
|
email: alexghiculescu@gmail.com
|
43
64
|
executables: []
|
44
65
|
extensions: []
|
45
66
|
extra_rdoc_files: []
|
46
67
|
files:
|
47
|
-
- lib/base.rb
|
48
|
-
- lib/card.rb
|
49
|
-
- lib/charge.rb
|
50
|
-
- lib/customer.rb
|
51
68
|
- lib/pin-payments.rb
|
52
69
|
homepage: https://github.com/ghiculescu/pin-payments
|
53
70
|
licenses:
|
54
71
|
- MIT
|
55
|
-
metadata: {}
|
56
72
|
post_install_message:
|
57
73
|
rdoc_options: []
|
58
74
|
require_paths:
|
59
75
|
- lib
|
60
76
|
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
61
78
|
requirements:
|
62
79
|
- - ! '>='
|
63
80
|
- !ruby/object:Gem::Version
|
64
81
|
version: '0'
|
65
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
66
84
|
requirements:
|
67
85
|
- - ! '>='
|
68
86
|
- !ruby/object:Gem::Version
|
69
87
|
version: '0'
|
70
88
|
requirements: []
|
71
89
|
rubyforge_project:
|
72
|
-
rubygems_version:
|
90
|
+
rubygems_version: 1.8.25
|
73
91
|
signing_key:
|
74
|
-
specification_version:
|
92
|
+
specification_version: 3
|
75
93
|
summary: Pin Payments API wrapper
|
76
94
|
test_files: []
|
77
|
-
has_rdoc:
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
OTVmN2FlMGRkMWU5ODkwMjRhMWI1MTllY2RhOThlMDIxYmQ3YzI5Ng==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
Yzc5MjJmMmM5OGYzODczYzYxM2Q1OTVlMTdlNWJhZmM0OWU4MmJkNw==
|
7
|
-
!binary "U0hBNTEy":
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
YjgyNWQzODJiZDJhMDM2MGM2M2I3OTMyOTBmOTU1ZDI2MzIwM2VhOTIzYTgz
|
10
|
-
YTI3MTFiNmIzMDUzN2U0OWIyYTIyMGUxZjRmYzc0MDBjMTBkNDkxYjM2NWJi
|
11
|
-
OTNlNTMyYjMzY2MwMDA1MWYxYjFhYmRjNTMxMjRkMzdjNDE4YmY=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MDY2ZmRiMmY4ODU1ZGY2MjcxMjY3ODI3YTg2NDA3ZmFhNmFlZjhlNjEwZTBj
|
14
|
-
NzczNWU4NGVlOThiNDM3ODhjM2MxNGE4NmQyNGFkMTc3MzYwNmIyODhmYTNh
|
15
|
-
Y2M0MmYzOGU4YzM3NmQzOGFmMzgxZDlhOWNiMmUwOTBiZWU3Njc=
|
data/lib/base.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
module Pin
|
2
|
-
class Base
|
3
|
-
include HTTParty
|
4
|
-
base_uri "https://test-api.pin.net.au/1"
|
5
|
-
|
6
|
-
def self.setup!(key, mode = :live)
|
7
|
-
@@auth = {username: key, password: ''}
|
8
|
-
uri = if mode == :test
|
9
|
-
"https://test-api.pin.net.au/1"
|
10
|
-
elsif mode == :live
|
11
|
-
"https://api.pin.net.au/1"
|
12
|
-
else
|
13
|
-
raise "Incorrect API mode! Must be :live or :test (leave blank for :live)."
|
14
|
-
end
|
15
|
-
base_uri uri
|
16
|
-
end
|
17
|
-
|
18
|
-
protected
|
19
|
-
def self.authenticated_post(url, body)
|
20
|
-
post(url, body: body, basic_auth: @@auth)
|
21
|
-
end
|
22
|
-
def self.authenticated_get(url, query = {})
|
23
|
-
get(url, query: query, basic_auth: @@auth)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/lib/card.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
module Pin
|
2
|
-
class Card < Base
|
3
|
-
attr_accessor :number, :expiry_month, :expiry_year, :cvc, :name, :address_line1,
|
4
|
-
:address_line2, :address_city, :address_postcode, :address_state,
|
5
|
-
:address_country,
|
6
|
-
:token, :display_number, :scheme
|
7
|
-
|
8
|
-
def initialize(attributes = {})
|
9
|
-
attributes.each {|name, value| send("#{name}=", value)}
|
10
|
-
end
|
11
|
-
|
12
|
-
def to_hash
|
13
|
-
hash = {}
|
14
|
-
instance_variables.each {|var| hash[var.to_s.delete("@")] = instance_variable_get(var) }
|
15
|
-
hash
|
16
|
-
end
|
17
|
-
|
18
|
-
# options should be a hash with the following keys:
|
19
|
-
# :number, :expiry_month, :expiry_year, :cvc, :name, :address_line1,
|
20
|
-
# :address_city, :address_postcode, :address_state, :address_country
|
21
|
-
#
|
22
|
-
# it can also have the following optional keys:
|
23
|
-
# :address_line2
|
24
|
-
def self.create(options = {})
|
25
|
-
response = authenticated_post '/cards', options
|
26
|
-
if response.code == 201 # card created
|
27
|
-
new(response.parsed_response['response'])
|
28
|
-
else
|
29
|
-
# handle the error
|
30
|
-
false
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
data/lib/charge.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
module Pin
|
2
|
-
class Charge < Base
|
3
|
-
attr_accessor :email, :description, :amount, :currency, :ip_address
|
4
|
-
|
5
|
-
# options should be a hash with the following params
|
6
|
-
# email, description, amount, currency, ip_address are mandatory
|
7
|
-
# identifier must be a hash, can take the forms
|
8
|
-
# {card: <Pin::Card>}
|
9
|
-
# {card_token: String<"...">}
|
10
|
-
# {customer_token: String<"...">}
|
11
|
-
# {customer: <Pin::Customer>}
|
12
|
-
# eg. {email: 'alex@payaus.com', description: '1 month of PayAus', amount: 19900, currency: 'AUD', ip_address: '203.192.1.172', customer_token: 'asdf'}
|
13
|
-
def self.create(options = {})
|
14
|
-
options[:customer_token] = options.delete(:customer).token if options[:customer].present?
|
15
|
-
authenticated_post '/charges', options
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/lib/customer.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
module Pin
|
2
|
-
class Customer < Base
|
3
|
-
attr_accessor :email, :created_at, :token, :card
|
4
|
-
|
5
|
-
def initialize(attributes = {})
|
6
|
-
attributes.each do |name, value|
|
7
|
-
if name == 'card' # TODO: this should be generalised (has_one relationship i suppose)
|
8
|
-
self.card = Card.new value
|
9
|
-
else
|
10
|
-
send("#{name}=", value)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
# email should be a string
|
16
|
-
# card_or_token can be a Pin::Card object
|
17
|
-
# or a card_token (as a string)
|
18
|
-
def self.create(email, card_or_token)
|
19
|
-
body = if card_or_token.respond_to?(:to_hash) # card
|
20
|
-
{card: card_or_token.to_hash}
|
21
|
-
else # token
|
22
|
-
{card_token: card_or_token}
|
23
|
-
end.merge(email: email)
|
24
|
-
|
25
|
-
authenticated_post '/customers', body
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.all # TODO: pagination
|
29
|
-
response = authenticated_get '/customers'
|
30
|
-
customers = []
|
31
|
-
if response.code == 200
|
32
|
-
response.parsed_response['response'].each do |customer|
|
33
|
-
customers << new(customer)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
customers
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.find(token)
|
40
|
-
response = authenticated_get "/customers/#{token}"
|
41
|
-
new(response.parsed_response['response'])
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|