spook_and_pay 0.2.2.alpha → 0.2.3.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spook_and_pay/credit_card.rb +12 -6
- data/lib/spook_and_pay/providers/braintree.rb +1 -2
- data/lib/spook_and_pay/providers/spreedly.rb +17 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36337e6bc05a6c51b5f0b89042c43e9953061eda
|
4
|
+
data.tar.gz: 1f1debb4bcb3efd35d7ef032297ada9e2fd017eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2d55cb04f26b634d0d915fcbdd4a240f238488baa614975eb249aa0a953d6a18c63af4bc71e646e43b96d2c40ea1ff8ab11a87807176da34ecadb148e101888
|
7
|
+
data.tar.gz: 10a674a7f2371a7e5dd0bc8758dd904a1640ed33b86d11c36bfdda68495cd3cd1baabd79dae89faddd561077c3eb9bc315b021f59d17d32c09a299dacb1228ce
|
@@ -7,7 +7,7 @@ module SpookAndPay
|
|
7
7
|
extend SpookAndPay::ErroringReader
|
8
8
|
|
9
9
|
# The basic attributes of the credit card.
|
10
|
-
attr_reader :provider, :id
|
10
|
+
attr_reader :provider, :id, :raw
|
11
11
|
|
12
12
|
# The fields required for a credit card
|
13
13
|
FIELDS = [:number, :expiration_month, :expiration_year, :cvv, :card_type, :name, :valid, :expired].freeze
|
@@ -32,9 +32,11 @@ module SpookAndPay
|
|
32
32
|
# @option vals String :name
|
33
33
|
# @option vals [true, false] :expired
|
34
34
|
# @option vals [true, false] :valid
|
35
|
-
|
35
|
+
# @param Class raw
|
36
|
+
def initialize(provider, id, vals, raw = nil)
|
36
37
|
@provider = provider
|
37
|
-
@id
|
38
|
+
@id = id
|
39
|
+
@raw = raw
|
38
40
|
FIELDS.each {|f| instance_variable_set(:"@#{f}", vals[f]) if vals.has_key?(f)}
|
39
41
|
end
|
40
42
|
|
@@ -47,9 +49,13 @@ module SpookAndPay
|
|
47
49
|
if @number.nil? or @number.empty?
|
48
50
|
nil
|
49
51
|
else
|
50
|
-
|
51
|
-
|
52
|
-
|
52
|
+
if @number.length < 12
|
53
|
+
case card_type
|
54
|
+
when 'american_express' then "XXXX-XXXXXX-#{@number}"
|
55
|
+
else "XXXX-XXXX-XXXX-#{@number}"
|
56
|
+
end
|
57
|
+
else
|
58
|
+
@number
|
53
59
|
end
|
54
60
|
end
|
55
61
|
end
|
@@ -63,9 +63,8 @@ module SpookAndPay
|
|
63
63
|
# Confirms the submission of payment details to the provider.
|
64
64
|
#
|
65
65
|
# @param String query_string
|
66
|
-
#
|
67
66
|
# @return SpookAndPay::Result
|
68
|
-
def confirm_payment_submission(query_string)
|
67
|
+
def confirm_payment_submission(query_string, opts = {})
|
69
68
|
result = adapter.confirm(query_string)
|
70
69
|
|
71
70
|
case result
|
@@ -48,24 +48,22 @@ module SpookAndPay
|
|
48
48
|
# Confirms the submission of payment details to Spreedly Core.
|
49
49
|
#
|
50
50
|
# @param String query_string
|
51
|
+
# @param Hash opts
|
52
|
+
# @option opts [String, Numeric] :amount
|
53
|
+
# @option opts [:purchase, :authorize, :store] :execute
|
51
54
|
# @return SpookAndPay::Result
|
52
|
-
def confirm_payment_submission(query_string)
|
55
|
+
def confirm_payment_submission(query_string, opts)
|
53
56
|
token = Rack::Utils.parse_nested_query(query_string)["token"]
|
54
|
-
|
55
|
-
|
56
|
-
if
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
57
|
+
card = credit_card(token)
|
58
|
+
|
59
|
+
if card.valid?
|
60
|
+
case opts[:execute]
|
61
|
+
when :authorize then card.authorize!(opts[:amount])
|
62
|
+
when :purchase then card.purchase!(opts[:amount])
|
63
|
+
when :store then SpookAndPay::Result.new(true, nil, :credit_card => card)
|
64
|
+
end
|
62
65
|
else
|
63
|
-
SpookAndPay::Result.new(
|
64
|
-
false,
|
65
|
-
credit_card,
|
66
|
-
:credit_card => coerce_credit_card(credit_card),
|
67
|
-
:errors => extract_card_errors(credit_card)
|
68
|
-
)
|
66
|
+
SpookAndPay::Result.new(false, nil, :credit_card => card, :errors => extract_card_errors(card.raw))
|
69
67
|
end
|
70
68
|
end
|
71
69
|
|
@@ -128,7 +126,7 @@ module SpookAndPay
|
|
128
126
|
}
|
129
127
|
|
130
128
|
if result.respond_to?(:payment_method)
|
131
|
-
opts[:
|
129
|
+
opts[:credit_card] = coerce_credit_card(result.payment_method)
|
132
130
|
end
|
133
131
|
|
134
132
|
SpookAndPay::Result.new(result.succeeded, result, opts)
|
@@ -203,10 +201,11 @@ module SpookAndPay
|
|
203
201
|
:number => card.number,
|
204
202
|
:name => card.full_name,
|
205
203
|
:expiration_month => card.month,
|
206
|
-
:expiration_year => card.year
|
204
|
+
:expiration_year => card.year,
|
205
|
+
:valid => card.valid?
|
207
206
|
}
|
208
207
|
|
209
|
-
SpookAndPay::CreditCard.new(self, card.token, fields)
|
208
|
+
SpookAndPay::CreditCard.new(self, card.token, fields, card)
|
210
209
|
end
|
211
210
|
|
212
211
|
# Takes a transaction generated by the Spreedly lib and coerces it into a
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spook_and_pay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3.alpha
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Sutton
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: braintree
|