qiwi-pay 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module QiwiPay::Wpf
4
+ # Авторизационный запрос (холдирование средств) в случае
5
+ # двухшагового сценария оплаты
6
+ class AuthOperation < PaymentOperation
7
+ # Код операции auth
8
+ def self.opcode
9
+ 3
10
+ end
11
+
12
+ # Описание операции
13
+ def self.description
14
+ 'Авторизационный запрос (холдирование средств) в случае '\
15
+ 'двухшагового сценария оплаты'
16
+ end
17
+
18
+ private
19
+
20
+ def self.in_params
21
+ %i[
22
+ merchant_site currency amount order_id
23
+ email country city region address phone
24
+ cf1 cf2 cf3 cf4 cf5
25
+ product_name merchant_uid modifiers card_token order_expire
26
+ callback_url success_url decline_url
27
+ cheque
28
+ ].freeze
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cgi'
4
+
5
+ module QiwiPay::Wpf
6
+ # WPF payment operation
7
+ #
8
+ # Generates URL or form parameters which should be used to perform
9
+ # operation
10
+ class PaymentOperation < QiwiPay::PaymentOperation
11
+ # @return [String] payment form redirection URL
12
+ # @example
13
+ # https://pay.qiwi.com/paypage/initial?opcode=1&merchant_site=111111
14
+ # &currency=643&amount=1000.00&order_id=1234&email=client@example.com
15
+ # &country=RUS&city=Moscow&product_name=%D0%9E%D0%BF%D0%BB%D0%B0%D1
16
+ # %82%D0%B0+%D1%82%D1%83%D1%80%D0%B0&merchant_uid=432101
17
+ # &callback_url=https%3A%2F%example.com%2Fpayment%2Fcallback
18
+ # &sign=...c4dbf...
19
+ def url
20
+ qry = request_params.map do |k, v|
21
+ "#{k}=#{CGI.escape(v)}" unless v.nil? || v.empty?
22
+ end.compact.join('&')
23
+ URI::HTTPS.build(
24
+ host: QiwiPay::Wpf::ENDPOINT_HOST,
25
+ path: QiwiPay::Wpf::ENDPOINT_PATH,
26
+ query: qry
27
+ ).to_s
28
+ end
29
+
30
+ # @return [Hash] params for payment form
31
+ # @example
32
+ # {
33
+ # :method=>:get,
34
+ # :url=>"https://pay.qiwi.com/paypage/initial",
35
+ # :opcode=>"1",
36
+ # :merchant_site=>"111111",
37
+ # :currency=>"643",
38
+ # :amount=>"1000.00",
39
+ # :order_id=>"1234",
40
+ # :email=>"me@example.com",
41
+ # :country=>"RUS",
42
+ # :city=>"Moscow",
43
+ # :product_name=>"Оплата тура",
44
+ # :merchant_uid=>"432101",
45
+ # :callback_url=>"https://example.com/payment/callback",
46
+ # :sign=>"...c4dbf..."
47
+ # }
48
+ def params
49
+ {
50
+ method: :get,
51
+ url: URI::HTTPS.build(
52
+ host: QiwiPay::Wpf::ENDPOINT_HOST,
53
+ path: QiwiPay::Wpf::ENDPOINT_PATH
54
+ ).to_s
55
+ }.merge(request_params)
56
+ end
57
+
58
+ def params_valid?
59
+ !opcode.nil? &&
60
+ !merchant_site.nil? &&
61
+ !currency.nil?
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module QiwiPay::Wpf
4
+ # Одношаговый сценарий оплаты
5
+ class SaleOperation < PaymentOperation
6
+ # Код операции sale
7
+ def self.opcode
8
+ 1
9
+ end
10
+
11
+ # Описание операции
12
+ def self.description
13
+ 'Одношаговый сценарий оплаты'
14
+ end
15
+
16
+ private
17
+
18
+ def self.in_params
19
+ %i[
20
+ merchant_site currency amount order_id
21
+ email country city region address phone
22
+ cf1 cf2 cf3 cf4 cf5
23
+ product_name merchant_uid modifiers card_token order_expire
24
+ callback_url success_url decline_url
25
+ cheque
26
+ ].freeze
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,40 @@
1
+
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'qiwi-pay/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'qiwi-pay'
8
+ spec.version = QiwiPay::VERSION
9
+ spec.authors = ['Michael Klimenko']
10
+ spec.email = ['mklimenko@onlinetours.ru']
11
+
12
+ spec.summary = 'QiwiPay WPF/API binding for Ruby'
13
+ spec.description = 'Provides support for payment operations using QiwiPay WPF and API services'
14
+ spec.homepage = 'https://github.com/OnlinetoursGit/qiwi-pay'
15
+ spec.license = 'MIT'
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
23
+ 'public gem pushes.'
24
+ end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = 'exe'
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ['lib']
32
+
33
+ spec.add_dependency 'rest-client', ['>= 1.8.0', '< 2.1']
34
+
35
+ spec.add_development_dependency 'bundler', '~> 1.16'
36
+ spec.add_development_dependency 'luhn', '~> 1.0'
37
+ spec.add_development_dependency 'rake', '~> 10.0'
38
+ spec.add_development_dependency 'rspec', '~> 3.0'
39
+ spec.add_development_dependency 'webmock', '~> 2'
40
+ end
metadata ADDED
@@ -0,0 +1,165 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: qiwi-pay
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Klimenko
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-05-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.8.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2.1'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 1.8.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.1'
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.16'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.16'
47
+ - !ruby/object:Gem::Dependency
48
+ name: luhn
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '10.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '10.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: webmock
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '2'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '2'
103
+ description: Provides support for payment operations using QiwiPay WPF and API services
104
+ email:
105
+ - mklimenko@onlinetours.ru
106
+ executables: []
107
+ extensions: []
108
+ extra_rdoc_files: []
109
+ files:
110
+ - ".gitignore"
111
+ - ".rspec"
112
+ - ".rubocop.yml"
113
+ - ".ruby-version"
114
+ - ".travis.yml"
115
+ - Gemfile
116
+ - Gemfile.lock
117
+ - LICENSE
118
+ - README.md
119
+ - Rakefile
120
+ - bin/console
121
+ - bin/setup
122
+ - lib/qiwi-pay.rb
123
+ - lib/qiwi-pay/api/capture_operation.rb
124
+ - lib/qiwi-pay/api/payment_operation.rb
125
+ - lib/qiwi-pay/api/refund_operation.rb
126
+ - lib/qiwi-pay/api/response.rb
127
+ - lib/qiwi-pay/api/reversal_operation.rb
128
+ - lib/qiwi-pay/api/status_operation.rb
129
+ - lib/qiwi-pay/cheque.rb
130
+ - lib/qiwi-pay/confirmation.rb
131
+ - lib/qiwi-pay/credentials.rb
132
+ - lib/qiwi-pay/messages_for_codes.rb
133
+ - lib/qiwi-pay/payment_operation.rb
134
+ - lib/qiwi-pay/signature.rb
135
+ - lib/qiwi-pay/version.rb
136
+ - lib/qiwi-pay/wpf/auth_operation.rb
137
+ - lib/qiwi-pay/wpf/payment_operation.rb
138
+ - lib/qiwi-pay/wpf/sale_operation.rb
139
+ - qiwi-pay.gemspec
140
+ homepage: https://github.com/OnlinetoursGit/qiwi-pay
141
+ licenses:
142
+ - MIT
143
+ metadata:
144
+ allowed_push_host: https://rubygems.org
145
+ post_install_message:
146
+ rdoc_options: []
147
+ require_paths:
148
+ - lib
149
+ required_ruby_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ required_rubygems_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ requirements: []
160
+ rubyforge_project:
161
+ rubygems_version: 2.7.6
162
+ signing_key:
163
+ specification_version: 4
164
+ summary: QiwiPay WPF/API binding for Ruby
165
+ test_files: []