paytureman 0.7.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -3
- data/lib/payments/payment_new.rb +14 -3
- data/lib/payture/api.rb +1 -2
- data/lib/paytureman.rb +1 -0
- data/paytureman.gemspec +1 -1
- data/spec/requests/payment_process_spec.rb +16 -3
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93ed4accb43af89b5912d643d401bb0a57b3d820
|
4
|
+
data.tar.gz: 8f0dcd732997f6da697499957406e6f766fa291f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6309dc5b976f1d8a9d9da35e3e313ccb442ac12c41c1a7ed16c9d04d8b07137cdd09a5cb196b9243dbee213891ce95d4a18d148e3d8c164c592ca12558163398
|
7
|
+
data.tar.gz: 55fbc502ba9dd8d8536348b693279db95b3be5c83eea8bc7e2c7df320a46821ec5aacb9a682162cc0b23381eac75dce47f2becc1960c788062022a236d833e44
|
data/README.md
CHANGED
@@ -45,9 +45,7 @@ payment = Paytureman::PaymentNew.new(order_id, amount, customer_ip)
|
|
45
45
|
payment = Paytureman::PaymentNew.new(order_id, amount, customer_ip, :production)
|
46
46
|
|
47
47
|
# prepare it
|
48
|
-
description = Paytureman::PaymentDescription.new
|
49
|
-
description.product = 'Paytureman demo payment'
|
50
|
-
description.total = amount
|
48
|
+
description = Paytureman::PaymentDescription.new(product: 'Paytureman demo payment', total: amount, url: '...success url...')
|
51
49
|
|
52
50
|
payment = payment.prepare(description)
|
53
51
|
# ... assert(payment.kind_of?(Paytureman::PaymentPrepared))
|
data/lib/payments/payment_new.rb
CHANGED
@@ -1,11 +1,22 @@
|
|
1
1
|
module Paytureman
|
2
2
|
|
3
|
-
|
3
|
+
VALID_OPTIONS = [
|
4
|
+
:template_tag,
|
5
|
+
:language,
|
6
|
+
:url,
|
7
|
+
:total,
|
8
|
+
:product
|
9
|
+
]
|
10
|
+
|
11
|
+
class PaymentDescription
|
12
|
+
def initialize(description = {})
|
13
|
+
@description = description.dup
|
14
|
+
@description.assert_valid_keys(*VALID_OPTIONS)
|
15
|
+
end
|
4
16
|
|
5
17
|
def to_h
|
6
|
-
|
18
|
+
@description.select { |_, v| v.present? }
|
7
19
|
end
|
8
|
-
|
9
20
|
end
|
10
21
|
|
11
22
|
class PaymentNew < Payment
|
data/lib/payture/api.rb
CHANGED
@@ -12,9 +12,8 @@ module Paytureman
|
|
12
12
|
|
13
13
|
data = { SessionType: :Block, OrderId: order_id, Amount: amount, IP: ip }
|
14
14
|
data.merge!(description)
|
15
|
-
|
16
15
|
init_params = {
|
17
|
-
'Data' => URI.escape(data.map { |
|
16
|
+
'Data' => URI.escape(data.map { |k, v| "#{k.to_s.camelize}=#{v}" }.join(';'))
|
18
17
|
}
|
19
18
|
|
20
19
|
response = make_request(:init, init_params)
|
data/lib/paytureman.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'active_support/core_ext/class/attribute_accessors'
|
2
2
|
require 'active_support/core_ext/string/inflections'
|
3
3
|
require 'active_support/core_ext/object/blank'
|
4
|
+
require 'active_support/core_ext/hash/keys'
|
4
5
|
require 'rexml/document'
|
5
6
|
require 'rest_client'
|
6
7
|
require 'singleton'
|
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 = "1.0.0"
|
8
8
|
spec.authors = ["Ivan Kasatenko", "Nickolay Sverchkov", "Alexander Fomin"]
|
9
9
|
spec.email = ["contact@uniqsystems.ru"]
|
10
10
|
spec.summary = %q{Payture API implementation}
|
@@ -74,14 +74,27 @@ describe "Payment" do
|
|
74
74
|
expect(RestClient).to receive(:post).with(
|
75
75
|
init_payment_url,
|
76
76
|
{
|
77
|
-
"Data" => "SessionType=Block;OrderId=#{order_id};Amount=#{(amount*100).to_i};IP=#{ip};Product=#{URI.escape(product)};Total=#{total}",
|
77
|
+
"Data" => "SessionType=Block;OrderId=#{order_id};Amount=#{(amount*100).to_i};IP=#{ip};Product=#{URI.escape(product)};Total=#{total};Url=http://localhost:3000/?foo=bar",
|
78
78
|
"Key" => "MerchantRutravel"
|
79
79
|
}
|
80
80
|
).and_return(empty_response)
|
81
81
|
|
82
82
|
payment = PaymentNew.new(order_id, amount, ip)
|
83
83
|
|
84
|
-
payment.prepare(PaymentDescription.new(product, total))
|
84
|
+
payment.prepare(PaymentDescription.new(product: product, total: total, url: 'http://localhost:3000/?foo=bar'))
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should raise error if unkonwn option used" do
|
88
|
+
expect { PaymentDescription.new(unknown: 'foobar') }.to raise_error
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should not use modified options" do
|
92
|
+
options = { url: 'url' }
|
93
|
+
description = PaymentDescription.new(options)
|
94
|
+
|
95
|
+
options[:unknown] = 'foobar'
|
96
|
+
|
97
|
+
expect(description.to_h).to eq(url: 'url')
|
85
98
|
end
|
86
99
|
|
87
100
|
it "should not use description in request if they not defined" do
|
@@ -95,7 +108,7 @@ describe "Payment" do
|
|
95
108
|
|
96
109
|
payment = PaymentNew.new(order_id, amount, ip)
|
97
110
|
|
98
|
-
payment.prepare(PaymentDescription.new(nil, nil, nil, nil))
|
111
|
+
payment.prepare(PaymentDescription.new(product: nil, total: nil, language: nil, url: nil))
|
99
112
|
end
|
100
113
|
|
101
114
|
let(:real_configuration) {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paytureman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Kasatenko
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2015-05-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest_client
|
@@ -161,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
161
|
version: '0'
|
162
162
|
requirements: []
|
163
163
|
rubyforge_project:
|
164
|
-
rubygems_version: 2.2.
|
164
|
+
rubygems_version: 2.2.2
|
165
165
|
signing_key:
|
166
166
|
specification_version: 4
|
167
167
|
summary: Payture API implementation
|
@@ -170,3 +170,4 @@ test_files:
|
|
170
170
|
- spec/requests/payture/api_spec.rb
|
171
171
|
- spec/requests/service/configuration_spec.rb
|
172
172
|
- spec/spec_helper.rb
|
173
|
+
has_rdoc:
|