payneteasy-payneteasyapi 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +6 -6
- data/doc/00-basic-tutorial.md +150 -154
- data/doc/01-library-internals.md +4 -4
- data/doc/library-internals/00-payment-data.md +62 -60
- data/doc/library-internals/01-payment-processor.md +87 -85
- data/doc/library-internals/02-validator.md +37 -38
- data/doc/library-internals/03-property-accessor.md +58 -46
- data/doc/payment-scenarios/00-sale-transactions.md +33 -33
- data/doc/payment-scenarios/01-preauth-capture-transactions.md +36 -36
- data/doc/payment-scenarios/02-transfer-transactions.md +22 -23
- data/doc/payment-scenarios/03-return-transactions.md +9 -9
- data/doc/payment-scenarios/04-recurrent-transactions.md +36 -37
- data/doc/payment-scenarios/05-payment-form-integration.md +19 -19
- data/doc/payment-scenarios/06-merchant-callbacks.md +8 -8
- data/example/capture.rb +38 -1
- data/example/common/functions.rb +40 -6
- data/lib/paynet_easy/paynet_easy_api/util/validator.rb +1 -1
- data/payneteasy-payneteasyapi.gemspec +6 -4
- metadata +4 -20
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
|
|
15
15
|
Поле запроса |Цепочка свойств платежа для проверки
|
|
16
16
|
--------------------|---------------------------------------
|
|
17
|
-
orderid |payment.
|
|
18
|
-
merchant_order |payment.
|
|
19
|
-
client_orderid |payment.
|
|
17
|
+
orderid |payment.paynet_id
|
|
18
|
+
merchant_order |payment.client_id
|
|
19
|
+
client_orderid |payment.client_id
|
|
20
20
|
amount |payment.amount
|
|
21
21
|
status |
|
|
22
22
|
type |
|
|
23
23
|
control |
|
|
24
24
|
|
|
25
|
-
[Пример выполнения запроса sale](../../example/sale.
|
|
26
|
-
[Пример выполнения запроса preauth](../../example/preauth.
|
|
27
|
-
[Пример выполнения запроса sale-form](../../example/sale-form.
|
|
28
|
-
[Пример выполнения запроса preauth-form](../../example/preauth-form.
|
|
29
|
-
[Пример выполнения запроса transfer-form](../../example/transfer-form.
|
|
25
|
+
* [Пример выполнения запроса sale](../../example/sale.rb#L102)
|
|
26
|
+
* [Пример выполнения запроса preauth](../../example/preauth.rb#L102)
|
|
27
|
+
* [Пример выполнения запроса sale-form](../../example/sale-form.rb#L81)
|
|
28
|
+
* [Пример выполнения запроса preauth-form](../../example/preauth-form.rb#81)
|
|
29
|
+
* [Пример выполнения запроса transfer-form](../../example/transfer-form.rb#81)
|
data/example/capture.rb
CHANGED
|
@@ -9,4 +9,41 @@ payment_transaction = PaymentTransaction.new(
|
|
|
9
9
|
'paynet_id' => 1969596,
|
|
10
10
|
}),
|
|
11
11
|
'query_config' => query_config
|
|
12
|
-
})
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
require 'paynet_easy_api'
|
|
15
|
+
|
|
16
|
+
payment_processor = PaymentProcessor.new
|
|
17
|
+
payment_processor.set_handlers(
|
|
18
|
+
{
|
|
19
|
+
PaymentProcessor::HANDLER_SAVE_CHANGES => ->(payment_transaction, response = nil){
|
|
20
|
+
start_session()
|
|
21
|
+
$_SESSION['payment_transaction'] = serialize($paymentTransaction)
|
|
22
|
+
},
|
|
23
|
+
PaymentProcessor::HANDLER_STATUS_UPDATE => ->(response, payment_transaction){
|
|
24
|
+
header("Location: http://{$_SERVER['HTTP_HOST']}/{$_SERVER['REQUEST_URI']}?stage=updateStatus");
|
|
25
|
+
exit
|
|
26
|
+
},
|
|
27
|
+
PaymentProcessor::HANDLER_SHOW_HTML => ->(response, payment_transaction){
|
|
28
|
+
print response.html
|
|
29
|
+
exit
|
|
30
|
+
},
|
|
31
|
+
PaymentProcessor::HANDLER_REDIRECT => ->(response, payment_transaction){
|
|
32
|
+
header("Location: #{response.redirect_url}")
|
|
33
|
+
exit
|
|
34
|
+
},
|
|
35
|
+
PaymentProcessor::HANDLER_FINISH_PROCESSING => ->(payment_transaction, response = nil){
|
|
36
|
+
print "<pre>";
|
|
37
|
+
print "Payment processing finished.\n";
|
|
38
|
+
print "Payment status: '#{payment_transaction.payment.status}'.\n";
|
|
39
|
+
print "Payment transaction status: '#{payment_transaction.status}'.\n";
|
|
40
|
+
print "</pre>";
|
|
41
|
+
},
|
|
42
|
+
PaymentProcessor::HANDLER_CATCH_EXCEPTION => ->(exception, payment_transaction, response = nil){
|
|
43
|
+
print "<pre>";
|
|
44
|
+
print "Exception catched.\n";
|
|
45
|
+
print "Exception message: '#{exception.message}'.\n";
|
|
46
|
+
print "Exception traceback: \n#{exception.backtrace}\n";
|
|
47
|
+
print "</pre>";
|
|
48
|
+
}
|
|
49
|
+
});
|
data/example/common/functions.rb
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
require 'paynet_easy_api'
|
|
2
|
+
require 'cgi'
|
|
3
|
+
require 'cgi/session'
|
|
4
|
+
require 'erb'
|
|
5
|
+
|
|
6
|
+
start_session = -> () do
|
|
7
|
+
$_CGI = CGI.new('html5')
|
|
8
|
+
$_SESSION = CGI::Session.new $_CGI
|
|
9
|
+
$_REQUEST = $_CGI.params
|
|
10
|
+
end
|
|
2
11
|
|
|
3
12
|
query_config = -> () do
|
|
4
13
|
QueryConfig.new(
|
|
@@ -23,24 +32,49 @@ query_config = -> () do
|
|
|
23
32
|
end
|
|
24
33
|
|
|
25
34
|
load_payment_transaction = ->() do
|
|
35
|
+
Marshal.load($_SESSION['payment_transaction']) if $_SESSION.has_key? 'payment_transaction'
|
|
26
36
|
end
|
|
27
37
|
|
|
28
|
-
save_payment_transaction = ->() do
|
|
38
|
+
save_payment_transaction = ->(payment_transaction, response) do
|
|
39
|
+
$_SESSION['payment_transaction'] = Marshal.dump payment_transaction
|
|
29
40
|
end
|
|
30
41
|
|
|
31
|
-
display_wait_page = ->() do
|
|
42
|
+
display_wait_page = ->(response, payment_transaction) do
|
|
43
|
+
current_location = "http://#{ENV['HTTP_HOST']}/#{ENV['REQUEST_URI']}?stage=updateStatus"
|
|
44
|
+
ERB.new(File.read('./wait_page.erb')).run(binding)
|
|
32
45
|
end
|
|
33
46
|
|
|
34
|
-
display_response_html = ->(response) do
|
|
47
|
+
display_response_html = ->(response, payment_transaction) do
|
|
48
|
+
puts $_CGI.header
|
|
49
|
+
puts response.html
|
|
35
50
|
end
|
|
36
51
|
|
|
37
|
-
redirect_to_response_url = ->() do
|
|
52
|
+
redirect_to_response_url = ->(response, payment_transaction) do
|
|
53
|
+
puts $_CGI.header('status' => 'REDIRECT', 'location' => response.redirect_url)
|
|
54
|
+
exit
|
|
38
55
|
end
|
|
39
56
|
|
|
40
|
-
display_ended_payment = ->() do
|
|
57
|
+
display_ended_payment = ->(payment_transaction, response = nil) do
|
|
58
|
+
puts $_CGI.header
|
|
59
|
+
puts <<HTML
|
|
60
|
+
<pre>
|
|
61
|
+
Payment processing finished.
|
|
62
|
+
Payment status: '#{payment_transaction.payment.status}'
|
|
63
|
+
Payment transaction status: '#{payment_transaction.status}'
|
|
64
|
+
</pre>
|
|
65
|
+
HTML
|
|
41
66
|
end
|
|
42
67
|
|
|
43
|
-
display_exception = ->() do
|
|
68
|
+
display_exception = ->(exception, payment_transaction, response = nil) do
|
|
69
|
+
puts $_CGI.header
|
|
70
|
+
puts <<HTML
|
|
71
|
+
<pre>
|
|
72
|
+
Exception catched.
|
|
73
|
+
Exception message: '#{exception.message}'
|
|
74
|
+
Exception backtrace:
|
|
75
|
+
#{exception.backtrace}
|
|
76
|
+
</pre>
|
|
77
|
+
HTML
|
|
44
78
|
end
|
|
45
79
|
|
|
46
80
|
payment_processor = ->() do
|
|
@@ -88,7 +88,7 @@ module PaynetEasy::PaynetEasyApi::Util
|
|
|
88
88
|
begin
|
|
89
89
|
valid = case rule
|
|
90
90
|
when URL then URI::ABS_URI === value
|
|
91
|
-
when IP then IPAddr.new
|
|
91
|
+
when IP then !!IPAddr.new(value)
|
|
92
92
|
when MONTH then (1..12).include? value.to_i
|
|
93
93
|
else
|
|
94
94
|
regexp = @@rule_regexps.key?(rule) ? @@rule_regexps[rule] : rule
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'payneteasy-payneteasyapi'
|
|
3
|
-
s.version = '0.1.
|
|
3
|
+
s.version = '0.1.1'
|
|
4
4
|
s.summary = 'Ruby library for PaynetEasy payment API.'
|
|
5
5
|
s.author = 'Artem Ponomarenko'
|
|
6
6
|
s.email = 'imenem@inbox.ru'
|
|
7
|
-
s.
|
|
7
|
+
s.homepage = 'https://github.com/payneteasy/ruby-library-payneteasy-api'
|
|
8
|
+
s.require_paths = %w(lib lib/paynet_easy/paynet_easy_api)
|
|
8
9
|
|
|
9
|
-
s.files = Dir['
|
|
10
|
+
s.files = Dir['example/**/*.rb'] + Dir['doc/**/*.md'] + Dir['lib/**/*.rb'] +
|
|
11
|
+
%w(.gemtest Gemfile Gemfile.lock Rakefile payneteasy-payneteasyapi.gemspec)
|
|
10
12
|
s.test_files = Dir['test/**/*.rb']
|
|
11
|
-
s.extra_rdoc_files =
|
|
13
|
+
s.extra_rdoc_files = 'README.md'
|
|
12
14
|
|
|
13
15
|
s.required_ruby_version = '>= 1.9.3'
|
|
14
16
|
s.add_development_dependency 'test-unit'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: payneteasy-payneteasyapi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -48,6 +48,8 @@ email: imenem@inbox.ru
|
|
|
48
48
|
executables: []
|
|
49
49
|
extensions: []
|
|
50
50
|
extra_rdoc_files:
|
|
51
|
+
- README.md
|
|
52
|
+
files:
|
|
51
53
|
- example/capture.rb
|
|
52
54
|
- example/common/functions.rb
|
|
53
55
|
- doc/payment-scenarios/06-merchant-callbacks.md
|
|
@@ -64,8 +66,6 @@ extra_rdoc_files:
|
|
|
64
66
|
- doc/library-internals/03-property-accessor.md
|
|
65
67
|
- doc/library-internals/00-payment-data.md
|
|
66
68
|
- doc/library-internals/01-payment-processor.md
|
|
67
|
-
- README.md
|
|
68
|
-
files:
|
|
69
69
|
- lib/paynet_easy/paynet_easy_api/payment_processor.rb
|
|
70
70
|
- lib/paynet_easy/paynet_easy_api/error/validation_error.rb
|
|
71
71
|
- lib/paynet_easy/paynet_easy_api/error/response_error.rb
|
|
@@ -112,22 +112,6 @@ files:
|
|
|
112
112
|
- Gemfile.lock
|
|
113
113
|
- Rakefile
|
|
114
114
|
- payneteasy-payneteasyapi.gemspec
|
|
115
|
-
- example/capture.rb
|
|
116
|
-
- example/common/functions.rb
|
|
117
|
-
- doc/payment-scenarios/06-merchant-callbacks.md
|
|
118
|
-
- doc/payment-scenarios/02-transfer-transactions.md
|
|
119
|
-
- doc/payment-scenarios/04-recurrent-transactions.md
|
|
120
|
-
- doc/payment-scenarios/03-return-transactions.md
|
|
121
|
-
- doc/payment-scenarios/01-preauth-capture-transactions.md
|
|
122
|
-
- doc/payment-scenarios/00-sale-transactions.md
|
|
123
|
-
- doc/payment-scenarios/05-payment-form-integration.md
|
|
124
|
-
- doc/01-library-internals.md
|
|
125
|
-
- doc/00-basic-tutorial.md
|
|
126
|
-
- doc/02-payment-scenarios.md
|
|
127
|
-
- doc/library-internals/02-validator.md
|
|
128
|
-
- doc/library-internals/03-property-accessor.md
|
|
129
|
-
- doc/library-internals/00-payment-data.md
|
|
130
|
-
- doc/library-internals/01-payment-processor.md
|
|
131
115
|
- README.md
|
|
132
116
|
- test/paynet_easy/paynet_easy_api/payment_processor_test.rb
|
|
133
117
|
- test/paynet_easy/paynet_easy_api/fake.rb
|
|
@@ -152,7 +136,7 @@ files:
|
|
|
152
136
|
- test/paynet_easy/paynet_easy_api/callback/paynet_easy_callback_test.rb
|
|
153
137
|
- test/paynet_easy/paynet_easy_api/callback/callback_test_prototype.rb
|
|
154
138
|
- test/paynet_easy/paynet_easy_api/callback/callback_factory_test.rb
|
|
155
|
-
homepage:
|
|
139
|
+
homepage: https://github.com/payneteasy/ruby-library-payneteasy-api
|
|
156
140
|
licenses: []
|
|
157
141
|
post_install_message:
|
|
158
142
|
rdoc_options: []
|