pin_up 0.3.1 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/pin_up.rb +7 -5
- data/lib/pin_up/base.rb +7 -1
- data/lib/pin_up/pin_errors.rb +44 -0
- data/pin_up.gemspec +11 -5
- data/spec/errors_spec.rb +69 -0
- data/spec/vcr/Errors/should_raise_a_400_error_when_trying_to_make_a_payment_and_a_valid_card_gets_declined.yml +48 -0
- data/spec/vcr/Errors/should_raise_a_404_error_when_looking_for_a_customer_that_doesn_t_exist.yml +49 -0
- data/spec/vcr/Errors/should_raise_a_422_error_when_trying_to_make_a_payment_with_an_expired_card.yml +50 -0
- data/spec/vcr/Errors/should_raise_a_422_error_when_trying_to_make_a_payment_with_an_invalid_card.yml +50 -0
- data/spec/vcr/Errors/should_raise_a_422_error_when_trying_to_update_missing_a_param.yml +50 -0
- data/spec/vcr/Errors/should_show_a_charge_given_a_token.yml +53 -0
- metadata +10 -4
- data/test/helper.rb +0 -18
- data/test/test_pin-payments.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e2c7a358ab23ba02beee3526c1f4ab6252e53c8
|
4
|
+
data.tar.gz: 6185353697ba7307d732473426f6184b0e213f90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e873560e85260a90d22c0a7d6bb8e036a52b4d899871b6697193521f75f2d19cbaa48c85254b81185315cb3c26de5b89aee762513cf2e1f2261b30805a533f1a
|
7
|
+
data.tar.gz: c10874ab6efe3c998ed07c22b4e953fbf669260c686e5caa34d90a96626f7c7c8f42fcae6319063f8d74c8de68188ab3890114dea7e64d4eb2188c6e582ec378
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -22,6 +22,7 @@ Jeweler::Tasks.new do |gem|
|
|
22
22
|
gem.email = "dnitza@gmail.com"
|
23
23
|
gem.authors = ["Daniel Nitsikopoulos"]
|
24
24
|
# dependencies defined in Gemfile
|
25
|
+
gem.files.exclude(Dir.glob('spec/vcr/*.yml'))
|
25
26
|
gem.add_dependency "httparty"
|
26
27
|
end
|
27
28
|
Jeweler::RubygemsDotOrgTasks.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.1
|
data/lib/pin_up.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'httparty'
|
2
2
|
require 'json'
|
3
3
|
|
4
|
-
require 'pin_up/base
|
5
|
-
require 'pin_up/card
|
6
|
-
require 'pin_up/charge
|
7
|
-
require 'pin_up/customer
|
8
|
-
require 'pin_up/refund
|
4
|
+
require 'pin_up/base'
|
5
|
+
require 'pin_up/card'
|
6
|
+
require 'pin_up/charge'
|
7
|
+
require 'pin_up/customer'
|
8
|
+
require 'pin_up/refund'
|
9
|
+
|
10
|
+
require 'pin_up/pin_errors'
|
data/lib/pin_up/base.rb
CHANGED
@@ -59,7 +59,11 @@ module Pin
|
|
59
59
|
##
|
60
60
|
# Builds a response of a single object
|
61
61
|
def self.build_response(response)
|
62
|
-
response.
|
62
|
+
if response.code >= 400
|
63
|
+
Pin::PinError.handle_error(response.code, response.parsed_response)
|
64
|
+
else
|
65
|
+
response.parsed_response['response']
|
66
|
+
end
|
63
67
|
end
|
64
68
|
|
65
69
|
##
|
@@ -70,6 +74,8 @@ module Pin
|
|
70
74
|
response.parsed_response['response'].each do |model|
|
71
75
|
models << model
|
72
76
|
end
|
77
|
+
elsif response.code >= 400
|
78
|
+
Pin::PinError.handle_error(response.code, response.parsed_response)
|
73
79
|
end
|
74
80
|
models
|
75
81
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Pin
|
2
|
+
class PinError < Exception
|
3
|
+
|
4
|
+
def initialize(message=nil, http_status=nil)
|
5
|
+
@message = message
|
6
|
+
@http_status = http_status
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_s
|
10
|
+
status_string = @http_status.nil? ? "" : "(Status #{@http_status}) "
|
11
|
+
"#{status_string}#{@message}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.handle_error(http_status, response)
|
15
|
+
case http_status
|
16
|
+
when 400
|
17
|
+
raise(Pin::ChargeError, "#{response['error']}: #{response['error_description']}. Charge token: #{response['charge_token']}")
|
18
|
+
when 402
|
19
|
+
raise(Pin::InsufficientPinBalance, "#{response['error_description']}")
|
20
|
+
when 404
|
21
|
+
raise(Pin::ResourceNotFound, "#{response['error_description']}")
|
22
|
+
when 422
|
23
|
+
message = ""
|
24
|
+
response['messages'].each do |m|
|
25
|
+
message += "#{m['code']}: #{m['message']}"
|
26
|
+
end
|
27
|
+
raise(Pin::InvalidResource, message)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class ResourceNotFound < PinError
|
33
|
+
end
|
34
|
+
|
35
|
+
class InvalidResource < PinError
|
36
|
+
end
|
37
|
+
|
38
|
+
class ChargeError < PinError
|
39
|
+
end
|
40
|
+
|
41
|
+
class InsufficientPinBalance <PinError
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/pin_up.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "pin_up"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Daniel Nitsikopoulos"]
|
12
|
-
s.date = "2013-07-
|
12
|
+
s.date = "2013-07-08"
|
13
13
|
s.description = "A Ruby gem wrapper for the pin-payments (pin.net.au) API"
|
14
14
|
s.email = "dnitza@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -29,12 +29,14 @@ Gem::Specification.new do |s|
|
|
29
29
|
"lib/pin_up/card.rb",
|
30
30
|
"lib/pin_up/charge.rb",
|
31
31
|
"lib/pin_up/customer.rb",
|
32
|
+
"lib/pin_up/pin_errors.rb",
|
32
33
|
"lib/pin_up/refund.rb",
|
33
34
|
"pin_up.gemspec",
|
34
35
|
"spec/base_spec.rb",
|
35
36
|
"spec/cards_spec.rb",
|
36
37
|
"spec/charges_spec.rb",
|
37
38
|
"spec/customers_spec.rb",
|
39
|
+
"spec/errors_spec.rb",
|
38
40
|
"spec/refund_spec.rb",
|
39
41
|
"spec/spec_helper.rb",
|
40
42
|
"spec/vcr/Base/should_list_succesfully_connect_to_Pin.yml",
|
@@ -51,12 +53,16 @@ Gem::Specification.new do |s|
|
|
51
53
|
"spec/vcr/Customer/should_raise_an_error_if_an_attribute_is_missing_in_the_card_hash.yml",
|
52
54
|
"spec/vcr/Customer/should_show_a_customer_given_a_token.yml",
|
53
55
|
"spec/vcr/Customer/should_update_a_customer_given_a_token_and_details_to_update.yml",
|
56
|
+
"spec/vcr/Errors/should_raise_a_400_error_when_trying_to_make_a_payment_and_a_valid_card_gets_declined.yml",
|
57
|
+
"spec/vcr/Errors/should_raise_a_404_error_when_looking_for_a_customer_that_doesn_t_exist.yml",
|
58
|
+
"spec/vcr/Errors/should_raise_a_422_error_when_trying_to_make_a_payment_with_an_expired_card.yml",
|
59
|
+
"spec/vcr/Errors/should_raise_a_422_error_when_trying_to_make_a_payment_with_an_invalid_card.yml",
|
60
|
+
"spec/vcr/Errors/should_raise_a_422_error_when_trying_to_update_missing_a_param.yml",
|
61
|
+
"spec/vcr/Errors/should_show_a_charge_given_a_token.yml",
|
54
62
|
"spec/vcr/Refund/should_create_a_refund_for_a_given_amount_and_charge.yml",
|
55
63
|
"spec/vcr/Refund/should_create_a_refund_for_the_entire_amount_of_a_charge_if_no_amount_given.yml",
|
56
64
|
"spec/vcr/Refund/should_list_all_refunds_made_to_a_charge_given_a_token.yml",
|
57
|
-
"spec/vcr/Refund/should_return_nothing_if_looking_for_a_charge_without_a_refund.yml"
|
58
|
-
"test/helper.rb",
|
59
|
-
"test/test_pin-payments.rb"
|
65
|
+
"spec/vcr/Refund/should_return_nothing_if_looking_for_a_charge_without_a_refund.yml"
|
60
66
|
]
|
61
67
|
s.homepage = "http://github.com/dNitza/pin_up"
|
62
68
|
s.licenses = ["MIT"]
|
data/spec/errors_spec.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Errors", :vcr, class: Pin::PinError do
|
4
|
+
before(:each) do
|
5
|
+
Pin::Base.new(ENV["PIN_SECRET"], :test)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should raise a 404 error when looking for a customer that doesn't exist" do
|
9
|
+
expect{Pin::Customer.find('foo')}.to raise_error(Pin::ResourceNotFound, "The requested resource could not be found.")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should raise a 422 error when trying to update missing a param" do
|
13
|
+
options = {email: "dNitza@gmail.com", card: {address_line1: "12345 Fake Street", expiry_month: "05", expiry_year: "2014", cvc: "123", name: "Daniel Nitsikopoulos", address_city: "Melbourne", address_postcode: "1234", address_state: "VIC", address_country: "Australia"}}
|
14
|
+
expect{Pin::Customer.update('cus_sRtAD2Am-goZoLg1K-HVpA', options)}.to raise_error(Pin::InvalidResource, "card_number_invalid: Card number is required")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should raise a 422 error when trying to make a payment with an expired card" do
|
18
|
+
options = {email: "dNitza@gmail.com", description: "A new charge from testing Pin gem", amount: "400", currency: "AUD", ip_address: "127.0.0.1", card: {
|
19
|
+
number: "5520000000000000",
|
20
|
+
expiry_month: "05",
|
21
|
+
expiry_year: "2012",
|
22
|
+
cvc: "123",
|
23
|
+
name: "Roland Robot",
|
24
|
+
address_line1: "42 Sevenoaks St",
|
25
|
+
address_city: "Lathlain",
|
26
|
+
address_postcode: "6454",
|
27
|
+
address_state: "WA",
|
28
|
+
address_country: "Australia",
|
29
|
+
}}
|
30
|
+
expect{Pin::Charges.create(options)}.to raise_error(Pin::InvalidResource, "card_expiry_year_invalid: Card expiry year expired")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should raise a 400 error when trying to make a payment and a valid card gets declined" do
|
34
|
+
options = {email: "dNitza@gmail.com", description: "A new charge from testing Pin gem", amount: "400", currency: "AUD", ip_address: "127.0.0.1", card: {
|
35
|
+
number: "5560000000000001",
|
36
|
+
expiry_month: "05",
|
37
|
+
expiry_year: "2014",
|
38
|
+
cvc: "123",
|
39
|
+
name: "Roland Robot",
|
40
|
+
address_line1: "42 Sevenoaks St",
|
41
|
+
address_city: "Lathlain",
|
42
|
+
address_postcode: "6454",
|
43
|
+
address_state: "WA",
|
44
|
+
address_country: "Australia",
|
45
|
+
}}
|
46
|
+
expect{Pin::Charges.create(options)}.to raise_error(Pin::ChargeError, "card_declined: The card was declined. Charge token: ch_9ElYaQ-OpRjlRWvDTpKY8Q")
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should raise a 422 error when trying to make a payment with an invalid card" do
|
50
|
+
options = {email: "dNitza@gmail.com", description: "A new charge from testing Pin gem", amount: "400", currency: "AUD", ip_address: "127.0.0.1", card: {
|
51
|
+
number: "5520000000000099",
|
52
|
+
expiry_month: "05",
|
53
|
+
expiry_year: "2014",
|
54
|
+
cvc: "123",
|
55
|
+
name: "Roland Robot",
|
56
|
+
address_line1: "42 Sevenoaks St",
|
57
|
+
address_city: "Lathlain",
|
58
|
+
address_postcode: "6454",
|
59
|
+
address_state: "WA",
|
60
|
+
address_country: "Australia",
|
61
|
+
}}
|
62
|
+
expect{Pin::Charges.create(options)}.to raise_error(Pin::InvalidResource, "card_number_invalid: Card number is not a valid credit card number")
|
63
|
+
end
|
64
|
+
|
65
|
+
it "Should raise a ResourceNotFound error when can't find customer" do
|
66
|
+
expect{Pin::Customer.charges("foo")}.to raise_error(Pin::ResourceNotFound, "The requested resource could not be found.")
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://<key>:@test-api.pin.net.au/1/charges
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: email=dNitza%40gmail.com&description=A%20new%20charge%20from%20testing%20Pin%20gem&amount=400¤cy=AUD&ip_address=127.0.0.1&card[number]=5560000000000001&card[expiry_month]=05&card[expiry_year]=2014&card[cvc]=123&card[name]=Roland%20Robot&card[address_line1]=42%20Sevenoaks%20St&card[address_city]=Lathlain&card[address_postcode]=6454&card[address_state]=WA&card[address_country]=Australia
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 400
|
13
|
+
message: Bad Request
|
14
|
+
headers:
|
15
|
+
Cache-Control:
|
16
|
+
- no-cache
|
17
|
+
Content-Type:
|
18
|
+
- application/json; charset=utf-8
|
19
|
+
Date:
|
20
|
+
- Mon, 08 Jul 2013 15:52:35 GMT
|
21
|
+
Server:
|
22
|
+
- Apache/2.2.20 (Ubuntu)
|
23
|
+
Status:
|
24
|
+
- '400'
|
25
|
+
Strict-Transport-Security:
|
26
|
+
- max-age=31536000
|
27
|
+
Vary:
|
28
|
+
- User-Agent
|
29
|
+
X-Powered-By:
|
30
|
+
- Phusion Passenger (mod_rails/mod_rack) 3.0.11
|
31
|
+
X-Rack-Cache:
|
32
|
+
- invalidate, pass
|
33
|
+
X-Request-Id:
|
34
|
+
- cfe75967616a6b701038fe093d797543
|
35
|
+
X-Runtime:
|
36
|
+
- '0.070216'
|
37
|
+
X-Ua-Compatible:
|
38
|
+
- IE=Edge,chrome=1
|
39
|
+
Content-Length:
|
40
|
+
- '112'
|
41
|
+
Connection:
|
42
|
+
- keep-alive
|
43
|
+
body:
|
44
|
+
encoding: UTF-8
|
45
|
+
string: '{"error":"card_declined","error_description":"The card was declined","charge_token":"ch_9ElYaQ-OpRjlRWvDTpKY8Q"}'
|
46
|
+
http_version:
|
47
|
+
recorded_at: Mon, 08 Jul 2013 15:52:39 GMT
|
48
|
+
recorded_with: VCR 2.5.0
|
data/spec/vcr/Errors/should_raise_a_404_error_when_looking_for_a_customer_that_doesn_t_exist.yml
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://<key>:@test-api.pin.net.au/1/customers/foo
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 404
|
13
|
+
message: Not Found
|
14
|
+
headers:
|
15
|
+
Cache-Control:
|
16
|
+
- no-cache, private
|
17
|
+
Content-Type:
|
18
|
+
- application/json; charset=utf-8
|
19
|
+
Date:
|
20
|
+
- Sun, 07 Jul 2013 15:49:31 GMT
|
21
|
+
Server:
|
22
|
+
- Apache/2.2.20 (Ubuntu)
|
23
|
+
Status:
|
24
|
+
- '404'
|
25
|
+
Strict-Transport-Security:
|
26
|
+
- max-age=31536000
|
27
|
+
Vary:
|
28
|
+
- User-Agent
|
29
|
+
X-Powered-By:
|
30
|
+
- Phusion Passenger (mod_rails/mod_rack) 3.0.11
|
31
|
+
X-Rack-Cache:
|
32
|
+
- miss
|
33
|
+
X-Request-Id:
|
34
|
+
- 19a42c2ac49949c998b435422b058797
|
35
|
+
X-Runtime:
|
36
|
+
- '0.012857'
|
37
|
+
X-Ua-Compatible:
|
38
|
+
- IE=Edge,chrome=1
|
39
|
+
Content-Length:
|
40
|
+
- '86'
|
41
|
+
Connection:
|
42
|
+
- keep-alive
|
43
|
+
body:
|
44
|
+
encoding: UTF-8
|
45
|
+
string: '{"error":"not_found","error_description":"The requested resource could
|
46
|
+
not be found."}'
|
47
|
+
http_version:
|
48
|
+
recorded_at: Sun, 07 Jul 2013 15:49:31 GMT
|
49
|
+
recorded_with: VCR 2.5.0
|
data/spec/vcr/Errors/should_raise_a_422_error_when_trying_to_make_a_payment_with_an_expired_card.yml
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://<key>:@test-api.pin.net.au/1/charges
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: email=dNitza%40gmail.com&description=A%20new%20charge%20from%20testing%20Pin%20gem&amount=400¤cy=AUD&ip_address=127.0.0.1&card[number]=5520000000000000&card[expiry_month]=05&card[expiry_year]=2012&card[cvc]=123&card[name]=Roland%20Robot&card[address_line1]=42%20Sevenoaks%20St&card[address_city]=Lathlain&card[address_postcode]=6454&card[address_state]=WA&card[address_country]=Australia
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 422
|
13
|
+
message: Unprocessable Entity
|
14
|
+
headers:
|
15
|
+
Cache-Control:
|
16
|
+
- no-cache
|
17
|
+
Content-Type:
|
18
|
+
- application/json; charset=utf-8
|
19
|
+
Date:
|
20
|
+
- Mon, 08 Jul 2013 15:51:08 GMT
|
21
|
+
Server:
|
22
|
+
- Apache/2.2.20 (Ubuntu)
|
23
|
+
Status:
|
24
|
+
- '422'
|
25
|
+
Strict-Transport-Security:
|
26
|
+
- max-age=31536000
|
27
|
+
Vary:
|
28
|
+
- User-Agent
|
29
|
+
X-Powered-By:
|
30
|
+
- Phusion Passenger (mod_rails/mod_rack) 3.0.11
|
31
|
+
X-Rack-Cache:
|
32
|
+
- invalidate, pass
|
33
|
+
X-Request-Id:
|
34
|
+
- 6af8e4ddd1fa56f812e315639cd89d72
|
35
|
+
X-Runtime:
|
36
|
+
- '0.033541'
|
37
|
+
X-Ua-Compatible:
|
38
|
+
- IE=Edge,chrome=1
|
39
|
+
Content-Length:
|
40
|
+
- '211'
|
41
|
+
Connection:
|
42
|
+
- keep-alive
|
43
|
+
body:
|
44
|
+
encoding: UTF-8
|
45
|
+
string: '{"error":"invalid_resource","error_description":"One or more parameters
|
46
|
+
were missing or invalid.","messages":[{"param":"card.expiry_year","code":"card_expiry_year_invalid","message":"Card
|
47
|
+
expiry year expired"}]}'
|
48
|
+
http_version:
|
49
|
+
recorded_at: Mon, 08 Jul 2013 15:51:12 GMT
|
50
|
+
recorded_with: VCR 2.5.0
|
data/spec/vcr/Errors/should_raise_a_422_error_when_trying_to_make_a_payment_with_an_invalid_card.yml
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://<key>:@test-api.pin.net.au/1/charges
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: email=dNitza%40gmail.com&description=A%20new%20charge%20from%20testing%20Pin%20gem&amount=400¤cy=AUD&ip_address=127.0.0.1&card[number]=5520000000000099&card[expiry_month]=05&card[expiry_year]=2014&card[cvc]=123&card[name]=Roland%20Robot&card[address_line1]=42%20Sevenoaks%20St&card[address_city]=Lathlain&card[address_postcode]=6454&card[address_state]=WA&card[address_country]=Australia
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 422
|
13
|
+
message: Unprocessable Entity
|
14
|
+
headers:
|
15
|
+
Cache-Control:
|
16
|
+
- no-cache
|
17
|
+
Content-Type:
|
18
|
+
- application/json; charset=utf-8
|
19
|
+
Date:
|
20
|
+
- Mon, 08 Jul 2013 15:54:22 GMT
|
21
|
+
Server:
|
22
|
+
- Apache/2.2.20 (Ubuntu)
|
23
|
+
Status:
|
24
|
+
- '422'
|
25
|
+
Strict-Transport-Security:
|
26
|
+
- max-age=31536000
|
27
|
+
Vary:
|
28
|
+
- User-Agent
|
29
|
+
X-Powered-By:
|
30
|
+
- Phusion Passenger (mod_rails/mod_rack) 3.0.11
|
31
|
+
X-Rack-Cache:
|
32
|
+
- invalidate, pass
|
33
|
+
X-Request-Id:
|
34
|
+
- 62a02a23ec2654bee73ea0f2de18d551
|
35
|
+
X-Runtime:
|
36
|
+
- '0.026801'
|
37
|
+
X-Ua-Compatible:
|
38
|
+
- IE=Edge,chrome=1
|
39
|
+
Content-Length:
|
40
|
+
- '222'
|
41
|
+
Connection:
|
42
|
+
- keep-alive
|
43
|
+
body:
|
44
|
+
encoding: UTF-8
|
45
|
+
string: '{"error":"invalid_resource","error_description":"One or more parameters
|
46
|
+
were missing or invalid.","messages":[{"param":"card.number","code":"card_number_invalid","message":"Card
|
47
|
+
number is not a valid credit card number"}]}'
|
48
|
+
http_version:
|
49
|
+
recorded_at: Mon, 08 Jul 2013 15:54:25 GMT
|
50
|
+
recorded_with: VCR 2.5.0
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: put
|
5
|
+
uri: https://<key>:@test-api.pin.net.au/1/customers/cus_sRtAD2Am-goZoLg1K-HVpA
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: email=dNitza%40gmail.com&card[address_line1]=12345%20Fake%20Street&card[expiry_month]=05&card[expiry_year]=2014&card[cvc]=123&card[name]=Daniel%20Nitsikopoulos&card[address_city]=Melbourne&card[address_postcode]=1234&card[address_state]=VIC&card[address_country]=Australia
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 422
|
13
|
+
message: Unprocessable Entity
|
14
|
+
headers:
|
15
|
+
Cache-Control:
|
16
|
+
- no-cache
|
17
|
+
Content-Type:
|
18
|
+
- application/json; charset=utf-8
|
19
|
+
Date:
|
20
|
+
- Mon, 08 Jul 2013 15:06:10 GMT
|
21
|
+
Server:
|
22
|
+
- Apache/2.2.20 (Ubuntu)
|
23
|
+
Status:
|
24
|
+
- '422'
|
25
|
+
Strict-Transport-Security:
|
26
|
+
- max-age=31536000
|
27
|
+
Vary:
|
28
|
+
- User-Agent
|
29
|
+
X-Powered-By:
|
30
|
+
- Phusion Passenger (mod_rails/mod_rack) 3.0.11
|
31
|
+
X-Rack-Cache:
|
32
|
+
- invalidate, pass
|
33
|
+
X-Request-Id:
|
34
|
+
- 8affa411927ff9a518c7d56035d50b7b
|
35
|
+
X-Runtime:
|
36
|
+
- '0.019063'
|
37
|
+
X-Ua-Compatible:
|
38
|
+
- IE=Edge,chrome=1
|
39
|
+
Content-Length:
|
40
|
+
- '200'
|
41
|
+
Connection:
|
42
|
+
- keep-alive
|
43
|
+
body:
|
44
|
+
encoding: UTF-8
|
45
|
+
string: '{"error":"invalid_resource","error_description":"One or more parameters
|
46
|
+
were missing or invalid.","messages":[{"param":"card.number","code":"card_number_invalid","message":"Card
|
47
|
+
number is required"}]}'
|
48
|
+
http_version:
|
49
|
+
recorded_at: Mon, 08 Jul 2013 15:06:15 GMT
|
50
|
+
recorded_with: VCR 2.5.0
|
@@ -0,0 +1,53 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://<key>:@test-api.pin.net.au/1/charges/ch_0kdOMXP7gG0_W_Vh8qAWdA
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Cache-Control:
|
16
|
+
- must-revalidate, private, max-age=0
|
17
|
+
Content-Type:
|
18
|
+
- application/json; charset=utf-8
|
19
|
+
Date:
|
20
|
+
- Mon, 08 Jul 2013 16:02:53 GMT
|
21
|
+
Etag:
|
22
|
+
- '"b6b7972e6ba347216085e1fa3dfea52a"'
|
23
|
+
Server:
|
24
|
+
- Apache/2.2.20 (Ubuntu)
|
25
|
+
Status:
|
26
|
+
- '200'
|
27
|
+
Strict-Transport-Security:
|
28
|
+
- max-age=31536000
|
29
|
+
Vary:
|
30
|
+
- User-Agent
|
31
|
+
X-Powered-By:
|
32
|
+
- Phusion Passenger (mod_rails/mod_rack) 3.0.11
|
33
|
+
X-Rack-Cache:
|
34
|
+
- miss
|
35
|
+
X-Request-Id:
|
36
|
+
- 213c399f66edb44536964c687a2dcf00
|
37
|
+
X-Runtime:
|
38
|
+
- '0.078937'
|
39
|
+
X-Ua-Compatible:
|
40
|
+
- IE=Edge,chrome=1
|
41
|
+
Content-Length:
|
42
|
+
- '682'
|
43
|
+
Connection:
|
44
|
+
- keep-alive
|
45
|
+
body:
|
46
|
+
encoding: UTF-8
|
47
|
+
string: '{"response":{"token":"ch_0kdOMXP7gG0_W_Vh8qAWdA","success":true,"amount":190000,"currency":"AUD","description":"mid
|
48
|
+
Plan - My Focusbook","email":"hello@myfocusbook.com.au","ip_address":"24.84.102.169","created_at":"2013-03-23T01:30:30Z","status_message":"An
|
49
|
+
unexpected error has occurred","error_message":null,"card":{"token":"card_h5nBfXPhwVJH5W0jqwl-pQ","display_number":"XXXX-XXXX-XXXX-0000","scheme":"master","address_line1":"33
|
50
|
+
Lyon Street","address_line2":"","address_city":"Melbourne","address_postcode":"3040","address_state":"Victoria","address_country":"Australia"},"transfer":[],"amount_refunded":0,"total_fees":5730,"merchant_entitlement":184270,"refund_pending":false}}'
|
51
|
+
http_version:
|
52
|
+
recorded_at: Mon, 08 Jul 2013 16:02:56 GMT
|
53
|
+
recorded_with: VCR 2.5.0
|
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: 0.
|
4
|
+
version: 0.4.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: 2013-07-
|
11
|
+
date: 2013-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -170,12 +170,14 @@ files:
|
|
170
170
|
- lib/pin_up/card.rb
|
171
171
|
- lib/pin_up/charge.rb
|
172
172
|
- lib/pin_up/customer.rb
|
173
|
+
- lib/pin_up/pin_errors.rb
|
173
174
|
- lib/pin_up/refund.rb
|
174
175
|
- pin_up.gemspec
|
175
176
|
- spec/base_spec.rb
|
176
177
|
- spec/cards_spec.rb
|
177
178
|
- spec/charges_spec.rb
|
178
179
|
- spec/customers_spec.rb
|
180
|
+
- spec/errors_spec.rb
|
179
181
|
- spec/refund_spec.rb
|
180
182
|
- spec/spec_helper.rb
|
181
183
|
- spec/vcr/Base/should_list_succesfully_connect_to_Pin.yml
|
@@ -192,12 +194,16 @@ files:
|
|
192
194
|
- spec/vcr/Customer/should_raise_an_error_if_an_attribute_is_missing_in_the_card_hash.yml
|
193
195
|
- spec/vcr/Customer/should_show_a_customer_given_a_token.yml
|
194
196
|
- spec/vcr/Customer/should_update_a_customer_given_a_token_and_details_to_update.yml
|
197
|
+
- spec/vcr/Errors/should_raise_a_400_error_when_trying_to_make_a_payment_and_a_valid_card_gets_declined.yml
|
198
|
+
- spec/vcr/Errors/should_raise_a_404_error_when_looking_for_a_customer_that_doesn_t_exist.yml
|
199
|
+
- spec/vcr/Errors/should_raise_a_422_error_when_trying_to_make_a_payment_with_an_expired_card.yml
|
200
|
+
- spec/vcr/Errors/should_raise_a_422_error_when_trying_to_make_a_payment_with_an_invalid_card.yml
|
201
|
+
- spec/vcr/Errors/should_raise_a_422_error_when_trying_to_update_missing_a_param.yml
|
202
|
+
- spec/vcr/Errors/should_show_a_charge_given_a_token.yml
|
195
203
|
- spec/vcr/Refund/should_create_a_refund_for_a_given_amount_and_charge.yml
|
196
204
|
- spec/vcr/Refund/should_create_a_refund_for_the_entire_amount_of_a_charge_if_no_amount_given.yml
|
197
205
|
- spec/vcr/Refund/should_list_all_refunds_made_to_a_charge_given_a_token.yml
|
198
206
|
- spec/vcr/Refund/should_return_nothing_if_looking_for_a_charge_without_a_refund.yml
|
199
|
-
- test/helper.rb
|
200
|
-
- test/test_pin-payments.rb
|
201
207
|
homepage: http://github.com/dNitza/pin_up
|
202
208
|
licenses:
|
203
209
|
- MIT
|
data/test/helper.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler'
|
3
|
-
begin
|
4
|
-
Bundler.setup(:default, :development)
|
5
|
-
rescue Bundler::BundlerError => e
|
6
|
-
$stderr.puts e.message
|
7
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
-
exit e.status_code
|
9
|
-
end
|
10
|
-
require 'test/unit'
|
11
|
-
require 'shoulda'
|
12
|
-
|
13
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
-
require 'pin_up'
|
16
|
-
|
17
|
-
class Test::Unit::TestCase
|
18
|
-
end
|
data/test/test_pin-payments.rb
DELETED