yandex_widget 0.1.1 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 645f45501fc3c6ddacebc9271ab2efe882bb02c402413813c141262ab1a262d6
4
- data.tar.gz: fda7c32c2662b2f534f91c908c638f99b8be19c66795d54e28c060bad9a9d3a2
3
+ metadata.gz: eb5bddfd929a93a3eff8e932ffad75cf88e8879755f431fafb166b392d11d778
4
+ data.tar.gz: 17df248b50029ea397be5563bd5d7359c33c797fe9a85650b8e6ef894e62de96
5
5
  SHA512:
6
- metadata.gz: 5a7da0082a31cf108e720e9951538a92ff6228324eb6f2d27e90e5a1de55d5016aa25b5c6cd5a64b0d50da059cabf4afa687b7244db14126c0f77a785809ccf2
7
- data.tar.gz: 1dcdccd5277e73970373dbdaedd3614b2e2b182420921d43419bf15de647cc32969290a823ebe6b8f40caa9544b7df694b0ccab92f74dff006d8e48ffe238014
6
+ metadata.gz: 3c0bbd77992cf5253cde0b3a76537f608b3be23008c11f3969169378c71a4e0382cc59df0215b7e7978e7bc818426d1f5d457172d9fa66555c7251737fd9cb88
7
+ data.tar.gz: 97b0445371f2a0270c125e94cd9a83213742cdcdc9868a7ee9f321709839ffef0b982ce1970b1a720fb0ede4ac9a0bf3e9dd48932e94cd7df3dff8c2bc719dc4
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ *.gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yandex_widget (0.1.0)
4
+ yandex_widget (0.2.0)
5
5
  httparty (~> 0.14)
6
6
 
7
7
  GEM
@@ -13,7 +13,7 @@ GEM
13
13
  multi_xml (>= 0.5.2)
14
14
  mime-types (3.3.1)
15
15
  mime-types-data (~> 3.2015)
16
- mime-types-data (3.2020.0425)
16
+ mime-types-data (3.2020.0512)
17
17
  multi_xml (0.6.0)
18
18
  rake (10.5.0)
19
19
  rspec (3.9.0)
@@ -3,24 +3,37 @@ module YandexWidget
3
3
 
4
4
  def self.init(amount, idempotence_key, params = {})
5
5
  params = default_init_params(amount).merge!(params)
6
- YandexWidget::Requests.new('payments', idempotence_key, params: params).init_client
6
+ YandexWidget::Requests.new('', idempotence_key, params: params).init_client
7
7
  end
8
8
 
9
9
  def self.payment_info(payment_id)
10
- YandexWidget::Requests.new("payments/#{payment_id}").request_info
10
+ YandexWidget::Requests.new(payment_id).request_info
11
+ end
12
+
13
+ def self.capture(payment_id, idempotence_key, amount)
14
+ YandexWidget::Requests.new("#{payment_id}/capture", idempotence_key, params: amount_params(amount)).set_status
15
+ end
16
+
17
+ def self.cancel(payment_id, idempotence_key)
18
+ YandexWidget::Requests.new("#{payment_id}/cancel", idempotence_key).set_status
11
19
  end
12
20
 
13
21
  def self.default_init_params(amount)
14
- {
15
- amount: {
16
- value: amount,
17
- currency: 'RUB'
18
- },
22
+ amount_params(amount).merge(
19
23
  confirmation: {
20
24
  type: 'embedded'
21
25
  },
22
26
  capture: true,
23
27
  description: ''
28
+ )
29
+ end
30
+
31
+ def self.amount_params(amount)
32
+ {
33
+ amount: {
34
+ value: amount,
35
+ currency: 'RUB'
36
+ }
24
37
  }
25
38
  end
26
39
  end
@@ -1,11 +1,11 @@
1
1
  module YandexWidget
2
2
  class Requests
3
- BASE_URL = 'https://payment.yandex.net/api/v3/'
3
+ BASE_URL = 'https://payment.yandex.net/api/v3/payments/'
4
4
 
5
5
  def initialize(path, idempotence_key = nil, params: {})
6
6
  @url = BASE_URL + path
7
- @params = params
8
7
  @idempotence_key = idempotence_key
8
+ @params = params
9
9
  end
10
10
 
11
11
  def init_client
@@ -17,6 +17,11 @@ module YandexWidget
17
17
  HTTParty.get(@url, basic_auth: auth, format: :json).parsed_response
18
18
  end
19
19
 
20
+ def set_status
21
+ HTTParty.post(@url, body: @params.to_json, headers: default_headers,
22
+ basic_auth: auth, format: :json)
23
+ end
24
+
20
25
  private
21
26
 
22
27
  def default_headers
@@ -1,3 +1,3 @@
1
1
  module YandexWidget
2
- VERSION = "0.1.1".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yandex_widget
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
  - Mikhail Matyukhin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-12 00:00:00.000000000 Z
11
+ date: 2020-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler