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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +2 -2
- data/lib/yandex_widget/client.rb +20 -7
- data/lib/yandex_widget/requests.rb +7 -2
- data/lib/yandex_widget/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb5bddfd929a93a3eff8e932ffad75cf88e8879755f431fafb166b392d11d778
|
4
|
+
data.tar.gz: 17df248b50029ea397be5563bd5d7359c33c797fe9a85650b8e6ef894e62de96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c0bbd77992cf5253cde0b3a76537f608b3be23008c11f3969169378c71a4e0382cc59df0215b7e7978e7bc818426d1f5d457172d9fa66555c7251737fd9cb88
|
7
|
+
data.tar.gz: 97b0445371f2a0270c125e94cd9a83213742cdcdc9868a7ee9f321709839ffef0b982ce1970b1a720fb0ede4ac9a0bf3e9dd48932e94cd7df3dff8c2bc719dc4
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
yandex_widget (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.
|
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)
|
data/lib/yandex_widget/client.rb
CHANGED
@@ -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('
|
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(
|
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
|
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.
|
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-
|
11
|
+
date: 2020-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|