ya_kassa 0.1.5 → 0.1.6
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/README.md +88 -5
- data/lib/ya_kassa/v3/client/get.rb +5 -1
- data/lib/ya_kassa/v3/receipt_request.rb +1 -2
- data/lib/ya_kassa/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e0e97f8e125bc23105025a162a54854727fe7f9ccc4492443841bfc3248fed4e
|
|
4
|
+
data.tar.gz: 175eaf01abd5e1262fe7c5abb73bff64992f91c35213354e91d3aaeac19150f0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a8353d23560f4bf3239822ede9ae860d729730d76a580179b60cd8d9a10f7f87b6f7fafa76b9bc98b3db8a5d87571406d8f2648404c0162ae7b48ef9bbe4a4be
|
|
7
|
+
data.tar.gz: 90177a8a0ddebc037d54939f31a0483a741ee6ac621f604d60ee7758b5b1f3fb201de4950d6dd15032c7cce3757c82ab2d2992d084ac8809d97892b0329d3c51
|
data/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# YaKassa
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
|
3
|
+
Обёртка для работы с API V3 сервиса ЯндексКасса(YandexKassa)
|
|
6
4
|
|
|
7
5
|
## Installation
|
|
8
6
|
|
|
@@ -20,9 +18,94 @@ Or install it yourself as:
|
|
|
20
18
|
|
|
21
19
|
$ gem install ya_kassa
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
Create initializer file like this
|
|
22
|
+
```ruby
|
|
23
|
+
# /config/initializers/ya_kassa.rb
|
|
24
|
+
|
|
25
|
+
YaKassa::V3::Settings.shop_id = Rails.application.credentials[:ya_kassa][:shop_id]
|
|
26
|
+
YaKassa::V3::Settings.secret_key = Rails.application.credentials[:ya_kassa][:secret_key]
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Example of Usage
|
|
31
|
+
#### Payment
|
|
32
|
+
default_values:
|
|
33
|
+
- amount_currency - `"RUB"`
|
|
34
|
+
- confirmation_type - `"redirect"`
|
|
35
|
+
- capture - `true`
|
|
36
|
+
```ruby
|
|
37
|
+
idempotence_key = '123456'
|
|
38
|
+
|
|
39
|
+
payment_params = {
|
|
40
|
+
amount_value: 10.0,
|
|
41
|
+
payment_id: '123',
|
|
42
|
+
return_url: 'http://example.com'
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
YaKassa::V3::PaymentRequest.new(idempotence_key, payment_params).create
|
|
46
|
+
# => {"id"=>"2534fac6-000f-5000-a000-105ab7c0ab90", "status"=>"pending", "paid"=>false, "amount"=>{"value"=>"10.00", "currency"=>"RUB"}, "confirmation"=>{"type"=>"redirect", "confirmation_url"=>"https://money.yandex.ru/api-pages/v2/payment-confirm/epl?orderId=2534fac6-000f-50....."}, "created_at"=>"2019-10-13T08:57:42.987Z", "metadata"=>{}, "recipient"=>{"account_id"=>"123123", "gateway_id"=>"123123"}, "refundable"=>false, "test"=>true}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
#### Payment status
|
|
50
|
+
```ruby
|
|
51
|
+
YaKassa::V3::PaymentStatusRequest.new('2534fac6-000f-5000-a000-105ab7c0ab90').create
|
|
52
|
+
# => {"id"=>"2534fac6-000f-5000-a000-105ab7c0ab90", "status"=>"pending", "paid"=>false, "amount"=>{"value"=>"10.00", "currency"=>"RUB"}, "confirmation"=>{"type"=>"redirect", "confirmation_url"=>"https://money.yandex.ru/api-pages/v2/payment-confirm/epl?orderId=2534fac6-000f..."}, "created_at"=>"2019-10-13T08:57:42.987Z", "metadata"=>{}, "recipient"=>{"account_id"=>"123123", "gateway_id"=>"123123"}, "refundable"=>false, "test"=>true}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### Payment capture
|
|
56
|
+
Works just for payments with `capture: false`
|
|
57
|
+
```ruby
|
|
58
|
+
idempotence_key = '123456'
|
|
59
|
+
|
|
60
|
+
capture_params = {
|
|
61
|
+
amount_value: 10.0,
|
|
62
|
+
payment_id: '2534fac6-000f-5000-a000-105ab7c0ab90'
|
|
63
|
+
}
|
|
64
|
+
YaKassa::V3::PaymentCaptureRequest.new(idempotence_key, capture_params).create
|
|
65
|
+
# => {"id"=>"253503ee-000f-5000-a000-1c5fb44eaf40", "status"=>"succeeded", "paid"=>true, "amount"=>{"value"=>"10.00", "currency"=>"RUB"}, "authorization_details"=>{"rrn"=>"123123272641", "auth_code"=>"21231"}, "captured_at"=>"2019-10-13T09:38:14.133Z", "created_at"=>"2019-10-13T09:37:58.019Z", "metadata"=>{}, "payment_method"=>{"type"=>"bank_card", "id"=>"253503ee-000f-5000-a000-1c5fb44eaf40", "saved"=>false, "card"=>{"first6"=>"555555", "last4"=>"4444", "expiry_month"=>"01", "expiry_year"=>"2022", "card_type"=>"MasterCard"}, "title"=>"Bank card *4444"}, "recipient"=>{"account_id"=>"45358", "gateway_id"=>"16234542"}, "refundable"=>true, "refunded_amount"=>{"value"=>"0.00", "currency"=>"RUB"}, "test"=>true}
|
|
66
|
+
```
|
|
24
67
|
|
|
25
|
-
|
|
68
|
+
#### Refund
|
|
69
|
+
```ruby
|
|
70
|
+
idempotence_key = '123456'
|
|
71
|
+
|
|
72
|
+
refund_params = {
|
|
73
|
+
amount_value: 10.0,
|
|
74
|
+
payment_id: '2534fac6-000f-5000-a000-105ab7c0ab90'
|
|
75
|
+
}
|
|
76
|
+
YaKassa::V3::RefundRequest.new(idempotence_key, payment_params).create
|
|
77
|
+
# => {"id"=>"253505ba-0015-5000-a000-1f19dc0", "status"=>"succeeded", "amount"=>{"value"=>"10.0", "currency"=>"RUB"}, "created_at"=>"2019-10-13T09:44:26.548Z", "payment_id"=>"253503ee-000f-5000-a000-1c5fb4"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### Receipt
|
|
81
|
+
```ruby
|
|
82
|
+
idempotence_key = '123456'
|
|
83
|
+
|
|
84
|
+
receipt_params = {
|
|
85
|
+
full_name: 'Ivan Ivanov',
|
|
86
|
+
email: 'example@exaple.com',
|
|
87
|
+
phone: '+7 777777',
|
|
88
|
+
payment_id: "253503ee-000f-5000-a000-1c5fb44eaf40",
|
|
89
|
+
items: [
|
|
90
|
+
{ description: 'product1', quantity: 1, amount_value: 10.0 }
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
YaKassa::V3::ReceiptRequest.new(idempotence_key, receipt_params).create
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Validation
|
|
98
|
+
```ruby
|
|
99
|
+
idempotence_key = '123456'
|
|
100
|
+
|
|
101
|
+
payment_params = {
|
|
102
|
+
payment_id: '123',
|
|
103
|
+
return_url: 'http://example.com'
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
YaKassa::V3::PaymentRequest.new(idempotence_key, payment_params).create
|
|
107
|
+
# => {:amount_value=>["Should be Float"]}
|
|
108
|
+
```
|
|
26
109
|
|
|
27
110
|
## Development
|
|
28
111
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module YaKassa
|
|
2
2
|
module V3
|
|
3
3
|
class ReceiptRequest < BaseRequest
|
|
4
|
-
|
|
4
|
+
attributable :customer
|
|
5
5
|
attributable :payment_id
|
|
6
6
|
attributable :type, default: "payment"
|
|
7
7
|
attributable :send, default: "true"
|
|
@@ -22,7 +22,6 @@ module YaKassa
|
|
|
22
22
|
validatable :full_name, :is_a, class: "String"
|
|
23
23
|
validatable :email, :is_a, class: "String"
|
|
24
24
|
validatable :phone, :present
|
|
25
|
-
validatable :inn, :present
|
|
26
25
|
|
|
27
26
|
def body
|
|
28
27
|
{
|
data/lib/ya_kassa/version.rb
CHANGED