paytureman 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/payments/payment.rb +21 -1
- data/lib/payments/payment_unknown.rb +6 -0
- data/lib/payture/api.rb +9 -0
- data/lib/paytureman.rb +1 -0
- data/paytureman.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d8145dfb3dbac036340d6431033e2d9dcf36fd8
|
4
|
+
data.tar.gz: 1d2802a1d7e49b216bc800f67176c1a808cb51e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48456b447a38f61e83ebaf7151320c8333325f607e300583bf4783c3916c9ed643daaf3b8c2968941a7dfa748aac1579c255fd68605d5230f8f8df6d5ba3f627
|
7
|
+
data.tar.gz: 718a093a0bcc3a2e9dec27d5580d9e8b2a47c557bc11a3b97f305f2bf9a7e3143747358c0ecb55153754b35fd4a7623e2b4e3d62c96f02db25afa5975b1fd637
|
data/lib/payments/payment.rb
CHANGED
@@ -2,6 +2,8 @@ module Paytureman
|
|
2
2
|
|
3
3
|
class Payment
|
4
4
|
|
5
|
+
attr_reader :order_id
|
6
|
+
|
5
7
|
def initialize(order_id, amount, ip)
|
6
8
|
@order_id, @amount, @ip = order_id, amount, ip
|
7
9
|
end
|
@@ -14,11 +16,29 @@ module Paytureman
|
|
14
16
|
new(memento.order_id, memento.amount, memento.ip)
|
15
17
|
end
|
16
18
|
|
19
|
+
def self.new_from_payment(donor)
|
20
|
+
memento = OpenStruct.new
|
21
|
+
donor.save_to_memento(memento)
|
22
|
+
new_from_memento(memento)
|
23
|
+
end
|
24
|
+
|
25
|
+
def current
|
26
|
+
current_payment_type = {
|
27
|
+
:new => PaymentNew,
|
28
|
+
:prepared => PaymentPrepared,
|
29
|
+
:authorized => PaymentBlocked,
|
30
|
+
:voided => PaymentCancelled,
|
31
|
+
:charged => PaymentCharged
|
32
|
+
}[payture.status(order_id)] || PaymentUnknown
|
33
|
+
current_payment_type.new_from_payment(self)
|
34
|
+
end
|
35
|
+
|
17
36
|
attr_accessor :payture
|
18
37
|
|
19
38
|
protected
|
20
39
|
|
21
|
-
attr_accessor :
|
40
|
+
attr_accessor :amount, :ip
|
41
|
+
attr_writer :order_id
|
22
42
|
|
23
43
|
def payture
|
24
44
|
@payture ||= Api.instance
|
data/lib/payture/api.rb
CHANGED
@@ -23,6 +23,12 @@ module Paytureman
|
|
23
23
|
response[:success]
|
24
24
|
end
|
25
25
|
|
26
|
+
def status(order_id)
|
27
|
+
response = make_request(:pay_status, order_id: order_id)
|
28
|
+
return :prepared if !response[:success] && response[:err_code] == :none
|
29
|
+
response[:success] && response[:state]
|
30
|
+
end
|
31
|
+
|
26
32
|
protected
|
27
33
|
|
28
34
|
def rest_client
|
@@ -48,6 +54,9 @@ module Paytureman
|
|
48
54
|
if result[:amount]
|
49
55
|
result[:amount] = result[:amount].to_i
|
50
56
|
end
|
57
|
+
if result[:err_code]
|
58
|
+
result[:err_code] = result[:err_code].downcase.to_sym
|
59
|
+
end
|
51
60
|
return result
|
52
61
|
end
|
53
62
|
|
data/lib/paytureman.rb
CHANGED
@@ -13,5 +13,6 @@ require_relative 'payments/payment_prepared'
|
|
13
13
|
require_relative 'payments/payment_blocked'
|
14
14
|
require_relative 'payments/payment_charged'
|
15
15
|
require_relative 'payments/payment_cancelled'
|
16
|
+
require_relative 'payments/payment_unknown'
|
16
17
|
|
17
18
|
require_relative 'service/payment_persistence'
|
data/paytureman.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "paytureman"
|
7
|
-
spec.version = "0.
|
7
|
+
spec.version = "0.2.0"
|
8
8
|
spec.authors = ["Ivan Kasatenko"]
|
9
9
|
spec.email = ["ivan@uniqsystems.ru"]
|
10
10
|
spec.summary = %q{Payture API implementation}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paytureman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Kasatenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest_client
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- lib/payments/payment_charged.rb
|
128
128
|
- lib/payments/payment_new.rb
|
129
129
|
- lib/payments/payment_prepared.rb
|
130
|
+
- lib/payments/payment_unknown.rb
|
130
131
|
- lib/payments/payment_with_session.rb
|
131
132
|
- lib/payture/api.rb
|
132
133
|
- lib/paytureman.rb
|