tinkoff 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a4e41a7cb90dde1c23ea9e3b479421a0d0fc1770
4
- data.tar.gz: e7b4a8cf46bd057ba0ced657bdc0ee96bad5c0c4
2
+ SHA256:
3
+ metadata.gz: 50bc66809e4128c77a72bf33185bdeb9f90c5edeca762d91a8566b266ae8122c
4
+ data.tar.gz: 893e4b19b3b75bb1ba6fef012f82b3ca36ffe90c8f6e6ac00ce76c1c75686f0d
5
5
  SHA512:
6
- metadata.gz: 9815634ecca48290a6490bf03d1b21d73e982a9d0072509ad5004dcc173d5979cdb1a1e52b4755b6363e88763e52870574060c4f44dc5647c368472d9c0d9b12
7
- data.tar.gz: 04267e91dcdb309e04a1a05e1d02f1c04752723a17afad8eb62e49fcb6986d7225dc2de97c07b2ecd06ea32171a1d52b325956a3f31db9de4b6268c5107c1aa4
6
+ metadata.gz: 593b6e3def9f1b881cd77e850a627031b29379f75d7e36340a50a25dda855854ff6cf967246438ed29732c20e6bd398e2ac187d683c38f1a502cc6878ad36683
7
+ data.tar.gz: f7a062af88d0cf1e952af7e63e4b7e8041f03a7e7fbeedae2223b8cf26170806fc42a772b464ba3aea11d0eb57c2ccc9b2450a914a6ff330bee0bf0258d4a8be
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Tinkoff
2
2
 
3
- [![Build Status](http://img.shields.io/travis/dankimio/tinkoff.svg?style=flat)](https://travis-ci.org/dankimio/tinkoff)
4
- [![Gem Version](http://img.shields.io/gem/v/tinkoff.svg?style=flat&color=brightgreen)](https://rubygems.org/gems/tinkoff)
3
+ [![Build Status](https://img.shields.io/travis/dankimio/tinkoff.svg?style=flat)](https://travis-ci.org/dankimio/tinkoff)
4
+ [![Gem Version](https://img.shields.io/gem/v/tinkoff.svg?style=flat&color=brightgreen)](https://rubygems.org/gems/tinkoff)
5
5
  [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://raw.githubusercontent.com/dankimio/tinkoff/master/LICENSE.txt)
6
6
 
7
7
 
@@ -40,7 +40,7 @@ Use the client to work with payments.
40
40
  ```ruby
41
41
  # Parameters: amount (in kopecks), order_id, data, options (hash, optional)
42
42
  # data — a hash of arbitrary data (up to 20 pairs), "Email" key is required
43
- # More info: https://oplata.tinkoff.ru/documentation/?section=Init
43
+ # More info: https://www.tinkoff.ru/kassa/develop/api/payments/init-description/
44
44
  Tinkoff::Client.init(100, 1, { Email: 'foo@bar.com' })
45
45
 
46
46
  # Parameters: payment_id, options (hash, optional)
@@ -56,7 +56,15 @@ Tinkoff::Client.cancel(1)
56
56
  Tinkoff::Client.state(1)
57
57
  ```
58
58
 
59
- You can view all available options in the [official documentation](https://oplata.tinkoff.ru/documentation/?section=aboutMet).
59
+ You can view all available options in the [official documentation](https://www.tinkoff.ru/kassa/develop/api/payments/).
60
+
61
+ A notification will be sent to if you provided the URL. You should use it to update the status of your payment / order.
62
+
63
+ ```ruby
64
+ notification = Tinkoff::Notification.new(params)
65
+ order = Order.find(notification.order_id)
66
+ order.update_attribute(:paid, true)
67
+ ```
60
68
 
61
69
  ## Development
62
70
 
@@ -0,0 +1,28 @@
1
+ module Tinkoff
2
+ class Notification
3
+ attr_reader :terminal_key, :order_id, :success, :status, :payment_id,
4
+ :error_code, :amount, :rebill_id, :card_id, :pan, :token
5
+
6
+ def initialize(params)
7
+ @terminal_key = params['TerminalKey']
8
+ @order_id = params['OrderId']
9
+ @success = params['Success'] == 'true'
10
+ @status = params['Status']
11
+ @payment_id = params['PaymentId'].to_i
12
+ @error_code = params['ErrorCode']
13
+ @amount = params['Amount'].to_i
14
+ @rebill_id = params['RebillId'].to_i
15
+ @card_id = params['CardId'].to_i
16
+ @pan = params['Pan']
17
+ @token = params['Token']
18
+ end
19
+
20
+ def success?
21
+ @success
22
+ end
23
+
24
+ def failure?
25
+ !@success
26
+ end
27
+ end
28
+ end
@@ -1,6 +1,6 @@
1
1
  module Tinkoff
2
2
  class Request
3
- BASE_URL = 'https://securepay.tinkoff.ru/rest/'
3
+ BASE_URL = 'https://securepay.tinkoff.ru/rest/'.freeze
4
4
 
5
5
  def initialize(path, params = {})
6
6
  @url = BASE_URL + path
@@ -41,7 +41,8 @@ module Tinkoff
41
41
 
42
42
  # Ключ=значение дополнительных параметров через “|”, например Email=a@test.ru|Phone=+71234567890
43
43
  def prepare_data
44
- return unless @params[:DATA].present?
44
+ return unless @params[:DATA].to_s.empty?
45
+
45
46
  @params[:DATA] = @params[:DATA].to_query.tr('&', '|')
46
47
  end
47
48
  end
@@ -1,3 +1,3 @@
1
1
  module Tinkoff
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'.freeze
3
3
  end
data/lib/tinkoff.rb CHANGED
@@ -1,9 +1,12 @@
1
1
  require 'httparty'
2
2
  require 'active_support'
3
3
  require 'active_support/core_ext/hash'
4
+
4
5
  require 'tinkoff/request'
5
6
  require 'tinkoff/client'
6
7
  require 'tinkoff/payment'
8
+ require 'tinkoff/notification'
9
+
7
10
  require 'tinkoff/version'
8
11
 
9
12
  module Tinkoff
data/tinkoff.gemspec CHANGED
@@ -1,5 +1,4 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'tinkoff/version'
5
4
 
@@ -19,10 +18,9 @@ Gem::Specification.new do |spec|
19
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
19
  spec.require_paths = ['lib']
21
20
 
22
- spec.add_development_dependency 'bundler', '~> 1.13'
23
- spec.add_development_dependency 'rake', '~> 11.0'
21
+ spec.add_development_dependency 'bundler', '~> 2.1'
24
22
  spec.add_development_dependency 'minitest', '~> 5.0'
23
+ spec.add_development_dependency 'rake', '~> 12.3'
25
24
 
26
25
  spec.add_runtime_dependency 'httparty', '~> 0.14'
27
- spec.add_runtime_dependency 'activesupport', '~> 5.0'
28
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tinkoff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Kim
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-01 00:00:00.000000000 Z
11
+ date: 2022-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.13'
19
+ version: '2.1'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.13'
26
+ version: '2.1'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '11.0'
33
+ version: '5.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '11.0'
40
+ version: '5.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: minitest
42
+ name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '5.0'
47
+ version: '12.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '5.0'
54
+ version: '12.3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: httparty
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.14'
69
- - !ruby/object:Gem::Dependency
70
- name: activesupport
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '5.0'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '5.0'
83
69
  description: Ruby wrapper for Tinkoff Acquiring API.
84
70
  email:
85
71
  - itsdanya@gmail.com
@@ -98,16 +84,16 @@ files:
98
84
  - bin/setup
99
85
  - lib/tinkoff.rb
100
86
  - lib/tinkoff/client.rb
87
+ - lib/tinkoff/notification.rb
101
88
  - lib/tinkoff/payment.rb
102
89
  - lib/tinkoff/request.rb
103
- - lib/tinkoff/response.rb
104
90
  - lib/tinkoff/version.rb
105
91
  - tinkoff.gemspec
106
92
  homepage: https://github.com/dankimio/tinkoff
107
93
  licenses:
108
94
  - MIT
109
95
  metadata: {}
110
- post_install_message:
96
+ post_install_message:
111
97
  rdoc_options: []
112
98
  require_paths:
113
99
  - lib
@@ -122,9 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
108
  - !ruby/object:Gem::Version
123
109
  version: '0'
124
110
  requirements: []
125
- rubyforge_project:
126
- rubygems_version: 2.5.1
127
- signing_key:
111
+ rubygems_version: 3.3.7
112
+ signing_key:
128
113
  specification_version: 4
129
114
  summary: Tinkoff API wrapper.
130
115
  test_files: []
@@ -1,19 +0,0 @@
1
- module Tinkoff
2
- class Response
3
- attr_reader :success, :error_code, :message, :details, :amount,
4
- :merchant_email, :merchant_name, :order_id, :payment_id, :tran_date
5
-
6
- def initialize(params)
7
- @success = params['Success']
8
- @error_code = params['ErrorCode']
9
- @message = params['Message']
10
- @details = params['Details']
11
- @amount = params['Amount']
12
- @merchant_email = params['MerchantEmail']
13
- @merchant_name = params['MerchantName']
14
- @order_id = params['OrderId']
15
- @payment_id = params['PaymentId']
16
- @tran_date = params['TranDate']
17
- end
18
- end
19
- end