liqpay 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/test.yml +13 -0
- data/CHANGELOG.md +11 -2
- data/Gemfile +3 -1
- data/LICENSE.txt +21 -0
- data/README.md +32 -33
- data/Rakefile +2 -0
- data/lib/liqpay/liqpay_helper.rb +18 -11
- data/lib/liqpay/railtie.rb +5 -2
- data/lib/liqpay/request.rb +50 -38
- data/lib/liqpay/response.rb +21 -17
- data/lib/liqpay/{base_operation.rb → signed_payload.rb} +11 -7
- data/lib/liqpay/version.rb +3 -1
- data/lib/liqpay.rb +13 -4
- data/liqpay.gemspec +14 -12
- metadata +34 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3c1117a472e90a9a56221f2baacad6ae89efd7a84cbe9cbee9762573631cbe2e
|
4
|
+
data.tar.gz: cba6b10b4fbb29155797b6593dc7c4368917d71403abe4a61780afa68c72f154
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b043dd9e4b1072798fd26d022864ca779f44adcd445bdee87412f76a8b216721928471d8a9703d1ed351ed056283a27170a1a9eda058042e7c694a9397f1778
|
7
|
+
data.tar.gz: f79e479e46f0c9a02276367b530f6255608398659c17d6c3ed0fa264e90aafa5e294e29effa6cdff733d53bd16084f51aa75f388dc9dcb3d02da45ed3dea0884
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,16 @@
|
|
1
|
+
## 2.0.0 (2022-09-25)
|
2
|
+
|
3
|
+
- Migrate to LiqPAY Checkout API v3.
|
4
|
+
- Modernize code.
|
5
|
+
|
6
|
+
## 1.0.1
|
7
|
+
|
8
|
+
- Bugfix: rewritten `liqpay_button` to use `concat` instead of raw strings.
|
9
|
+
|
1
10
|
## 1.0.0
|
2
11
|
|
3
|
-
|
12
|
+
- Updated gem to be compatible with the new LiqPAY API
|
4
13
|
|
5
14
|
## 0.1.2
|
6
15
|
|
7
|
-
|
16
|
+
- Fixed initializer syntax
|
data/Gemfile
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 Leonid Shevtsov
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
# LiqPAY
|
2
2
|
|
3
|
-
|
3
|
+
[![Buy me a coffee](https://www.buymeacoffee.com/assets/img/BMC-btn-logo.svg) Пригостіть кавою, якщо цей гем для вас є корисним.](https://www.buymeacoffee.com/leonidshevtsov)
|
4
4
|
|
5
|
-
|
5
|
+
This Ruby gem implements the [LiqPAY](https://www.liqpay.ua) billing system API, as described in [the LiqPAY documentation](https://www.liqpay.ua/documentation/api/aquiring).
|
6
6
|
|
7
7
|
## Demo
|
8
8
|
|
9
|
-
There is a demo app
|
9
|
+
There is a demo app source at https://github.com/leonid-shevtsov/liqpay_demo. Heroku removed free app hosting, so no more online demo. Also, Liqpay eventually blocks such usage of keys, so it won't survive for long.
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
13
13
|
Include the [liqpay gem](https://rubygems.org/gems/liqpay) in your `Gemfile`:
|
14
14
|
|
15
15
|
```ruby
|
16
|
-
gem 'liqpay', '~>
|
16
|
+
gem 'liqpay', '~>2.0.0'
|
17
17
|
```
|
18
18
|
|
19
|
-
The gem
|
19
|
+
The gem requires at least Ruby 2.7.
|
20
20
|
|
21
21
|
## Configuration
|
22
22
|
|
@@ -24,7 +24,7 @@ You can provide all of the payment options in the request object, but the recomm
|
|
24
24
|
your initializers.
|
25
25
|
|
26
26
|
You should supply the `public_key` and `private_key` options, that are
|
27
|
-
provided by LiqPAY when you sign up and create a shop on the [shops page](https://www.liqpay.
|
27
|
+
provided by LiqPAY when you sign up and create a shop on the [shops page](https://www.liqpay.ua/uk/adminbusiness):
|
28
28
|
|
29
29
|
```ruby
|
30
30
|
# config/initializers/liqpay.rb
|
@@ -35,44 +35,43 @@ Liqpay.default_options = {
|
|
35
35
|
}
|
36
36
|
```
|
37
37
|
|
38
|
-
|
39
38
|
## Processing payments through LiqPay
|
40
39
|
|
41
40
|
### General flow
|
42
41
|
|
43
|
-
1.
|
42
|
+
1. User initiates the payment process; you redirect him to LiqPAY via a POST form, providing necessary parameters such as the payment's amount, order id and description.
|
44
43
|
|
45
|
-
2.
|
44
|
+
2. Users completes payment through LiqPAY.
|
46
45
|
|
47
|
-
3.
|
46
|
+
3. LiqPAY redirects the user to the URL you specified with GET.
|
48
47
|
|
49
|
-
4.
|
48
|
+
4. You wait for a callback that LiqPAY will POST to your designated `server_url`.
|
50
49
|
|
51
|
-
5.
|
50
|
+
5. If the payment was successful: You process the payment on your side.
|
52
51
|
|
53
|
-
6.
|
52
|
+
6. If the payment was cancelled: You cancel the operation.
|
54
53
|
|
55
|
-
The most recent version of the LiqPAY API
|
54
|
+
The most recent version of the LiqPAY API _requires_ you to have a serverside endpoint, which makes it impossible to test it with a local address. Use [ngrok](https://ngrok.com) for local testing.
|
56
55
|
|
57
|
-
### Implementation in Rails
|
56
|
+
### Implementation in Rails
|
58
57
|
|
59
|
-
0.
|
58
|
+
0. Configure Liqpay
|
60
59
|
|
61
|
-
1.
|
60
|
+
1. Create a `Liqpay::Request` object
|
62
61
|
|
63
62
|
The required options are: the amount and currency of the payment, and an
|
64
|
-
"order ID".
|
65
|
-
|
63
|
+
"order ID".
|
64
|
+
|
66
65
|
The "order ID" is just a random string that you will use to
|
67
66
|
identify the payment after it has been completed. If you have an `Order`
|
68
67
|
model (I suggest that you should), pass its ID. If not, it can be a random
|
69
|
-
string stored in the session, or whatever, but
|
68
|
+
string stored in the session, or whatever, but _it must be unique_.
|
70
69
|
|
71
70
|
```ruby
|
72
71
|
@liqpay_request = Liqpay::Request.new(
|
73
|
-
amount: '999.99',
|
74
|
-
currency: 'UAH',
|
75
|
-
order_id: '123',
|
72
|
+
amount: '999.99',
|
73
|
+
currency: 'UAH',
|
74
|
+
order_id: '123',
|
76
75
|
description: 'Some Product',
|
77
76
|
result_url: order_url(@order),
|
78
77
|
server_url: liqpay_payment_url
|
@@ -81,10 +80,10 @@ The most recent version of the LiqPAY API *requires* you to have a serverside en
|
|
81
80
|
|
82
81
|
**Note that this does not do anything permanent.** No saves to the database, no
|
83
82
|
requests to LiqPAY.
|
84
|
-
|
85
|
-
2. Put a payment button somewhere
|
86
83
|
|
87
|
-
|
84
|
+
1. Put a payment button somewhere
|
85
|
+
|
86
|
+
As you need to make a POST request, there is definitely going to be a form somewhere.
|
88
87
|
|
89
88
|
To output a form consisting of a single "Pay with LiqPAY" button, do
|
90
89
|
|
@@ -106,9 +105,9 @@ The most recent version of the LiqPAY API *requires* you to have a serverside en
|
|
106
105
|
<% end %>
|
107
106
|
```
|
108
107
|
|
109
|
-
|
108
|
+
1. Set up a receiving endpoint.
|
110
109
|
|
111
|
-
```ruby
|
110
|
+
```ruby
|
112
111
|
# config/routes.rb
|
113
112
|
post '/liqpay_payment' => 'payments#liqpay_payment'
|
114
113
|
|
@@ -137,10 +136,10 @@ That's about it.
|
|
137
136
|
|
138
137
|
### Security considerations
|
139
138
|
|
140
|
-
|
141
|
-
|
142
|
-
|
139
|
+
- Check that amount from response matches the expected amount;
|
140
|
+
- check that the order id is valid;
|
141
|
+
- check that the order isn't completed yet (to avoid replay attacks);
|
143
142
|
|
144
|
-
|
143
|
+
---
|
145
144
|
|
146
|
-
Ruby implementation (c) 2012-
|
145
|
+
Ruby implementation (c) 2012-2022 Leonid Shevtsov
|
data/Rakefile
CHANGED
data/lib/liqpay/liqpay_helper.rb
CHANGED
@@ -1,28 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Liqpay
|
4
|
+
# Helpers to integrate LiqPay billing
|
2
5
|
module LiqpayHelper
|
3
6
|
# Displays a form to send a payment request to LiqPay
|
4
7
|
#
|
5
|
-
# You can either pass in a block, that SHOULD render a submit button
|
6
|
-
# let the helper create a simple submit button for you.
|
8
|
+
# You can either pass in a block, that SHOULD render a submit button
|
9
|
+
# (or not, if you plan to submit the form otherwise), or let the helper create a simple submit button for you.
|
7
10
|
#
|
8
11
|
# liqpay_request - an instance of Liqpay::Request
|
9
12
|
# options - currently accepts two options
|
10
13
|
# id - the ID of the form being created (`liqpay_form` by default)
|
11
14
|
# title - text on the submit button (`Pay with LiqPay` by default); not used if you pass in a block
|
12
|
-
def liqpay_button(liqpay_request, options={}
|
15
|
+
def liqpay_button(liqpay_request, options = {})
|
13
16
|
id = options.fetch(:id, 'liqpay_form')
|
14
17
|
title = options.fetch(:title, 'Pay with LiqPAY')
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
render_button(liqpay_request: liqpay_request, id: id, title: title)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def render_button(liqpay_request:, id:, title:)
|
24
|
+
content_tag(:form, id: id, action: Liqpay::LIQPAY_ENDPOINT_URL, method: :post) do
|
25
|
+
liqpay_request.form_fields.each do |name, value|
|
26
|
+
concat hidden_field_tag(name, value)
|
27
|
+
end
|
20
28
|
if block_given?
|
21
|
-
|
29
|
+
yield
|
22
30
|
else
|
23
|
-
|
31
|
+
concat submit_tag(title, name: nil)
|
24
32
|
end
|
25
|
-
result
|
26
33
|
end
|
27
34
|
end
|
28
35
|
end
|
data/lib/liqpay/railtie.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'liqpay/liqpay_helper'
|
2
4
|
|
3
5
|
module Liqpay
|
6
|
+
# Rails integration for the LiqPay view helpers
|
4
7
|
class Railtie < Rails::Railtie
|
5
|
-
initializer 'liqpay.view_helpers' do |
|
6
|
-
ActionView::Base.
|
8
|
+
initializer 'liqpay.view_helpers' do |_app|
|
9
|
+
ActionView::Base.include Liqpay::LiqpayHelper
|
7
10
|
end
|
8
11
|
end
|
9
12
|
end
|
data/lib/liqpay/request.rb
CHANGED
@@ -1,76 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'base64'
|
2
|
-
require 'liqpay/
|
4
|
+
require 'liqpay/signed_payload'
|
3
5
|
|
4
6
|
module Liqpay
|
5
|
-
|
7
|
+
# Represends a request to the LiqPay API
|
8
|
+
class Request < SignedPayload
|
9
|
+
REQUIRED_FIELDS = %i[public_key amount currency description order_id action].freeze
|
10
|
+
OPTIONAL_FIELDS = %i[result_url server_url].freeze
|
11
|
+
REQUEST_FIELDS = (REQUIRED_FIELDS + OPTIONAL_FIELDS + %i[version]).freeze
|
12
|
+
|
6
13
|
# REQUIRED Amount of payment (Float), in :currency
|
7
14
|
attr_accessor :amount
|
8
15
|
# REQUIRED Currency of payment - one of `Liqpay::SUPPORTED_CURRENCIES`
|
9
16
|
attr_accessor :currency
|
10
17
|
# REQUIRED Description to be displayed to the user
|
11
18
|
attr_accessor :description
|
12
|
-
#
|
19
|
+
# REQUIRED Arbitrary but unique ID
|
13
20
|
attr_accessor :order_id
|
21
|
+
# REQUIRED = either Liqpay::ACTION_PAY or Liqpay::ACTION_DONATE
|
22
|
+
attr_accessor :action
|
14
23
|
# RECOMMENDED URL that the user will be redirected to after payment
|
15
24
|
attr_accessor :result_url
|
16
25
|
# RECOMMENDED URL that'll receive the order details in the background.
|
17
26
|
attr_accessor :server_url
|
18
|
-
# OPTIONAL type of payment = either `buy` (the default) or `donate`
|
19
|
-
attr_accessor :type
|
20
|
-
# OPTIONAL UI language - `ru` or `en`
|
21
|
-
attr_accessor :language
|
22
27
|
|
23
|
-
def initialize(options={})
|
28
|
+
def initialize(options = {})
|
24
29
|
super(options)
|
25
30
|
|
26
|
-
|
27
|
-
@
|
28
|
-
|
29
|
-
@order_id = options[:order_id]
|
30
|
-
@result_url = options[:result_url]
|
31
|
-
@server_url = options[:server_url]
|
32
|
-
@type = options[:type]
|
33
|
-
@language = options[:language]
|
31
|
+
(REQUIRED_FIELDS + OPTIONAL_FIELDS).each { |field| send("#{field}=", options[field]) }
|
32
|
+
@action ||= Liqpay::ACTION_PAY
|
33
|
+
|
34
34
|
@kamikaze = options[:kamikaze]
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
38
|
-
|
37
|
+
def version
|
38
|
+
Liqpay::LIQPAY_API_VERSION
|
39
|
+
end
|
40
|
+
|
41
|
+
def data
|
42
|
+
json_data = REQUEST_FIELDS
|
43
|
+
.map { |field| [field, send(field)] }
|
44
|
+
.to_h
|
45
|
+
.reject { |_k, v| v.nil? }
|
46
|
+
.transform_values(&:to_s)
|
47
|
+
puts JSON.dump(json_data)
|
48
|
+
@data ||= Base64.strict_encode64(JSON.dump(json_data)).strip
|
39
49
|
end
|
40
50
|
|
41
51
|
def form_fields
|
42
52
|
validate! unless @kamikaze
|
43
|
-
{
|
44
|
-
public_key: public_key,
|
45
|
-
amount: amount,
|
46
|
-
currency: currency,
|
47
|
-
description: description,
|
48
|
-
order_id: order_id,
|
49
|
-
result_url: result_url,
|
50
|
-
server_url: server_url,
|
51
|
-
type: type,
|
52
|
-
signature: signature,
|
53
|
-
language: language
|
54
|
-
}.reject{|k,v| v.nil?}
|
53
|
+
{ data: data, signature: signature }
|
55
54
|
end
|
56
55
|
|
57
|
-
|
56
|
+
private
|
57
|
+
|
58
58
|
def validate!
|
59
|
-
|
60
|
-
|
59
|
+
validate_required_fields!
|
60
|
+
validate_currency!
|
61
|
+
validate_amount!
|
62
|
+
end
|
63
|
+
|
64
|
+
def validate_required_fields!
|
65
|
+
REQUIRED_FIELDS.each do |required_field|
|
66
|
+
raise Liqpay::Exception, "#{required_field} is a required field" unless send(required_field).to_s != ''
|
61
67
|
end
|
68
|
+
end
|
62
69
|
|
63
|
-
|
70
|
+
def validate_currency!
|
71
|
+
return if Liqpay::SUPPORTED_CURRENCIES.include?(currency)
|
72
|
+
|
73
|
+
raise Liqpay::Exception, "currency must be one of #{Liqpay::SUPPORTED_CURRENCIES.join(', ')}"
|
74
|
+
end
|
64
75
|
|
76
|
+
def validate_amount!
|
65
77
|
begin
|
66
|
-
self.amount = Float(
|
78
|
+
self.amount = Float(amount)
|
67
79
|
rescue ArgumentError, TypeError
|
68
|
-
raise Liqpay::Exception
|
80
|
+
raise Liqpay::Exception, 'amount must be a number'
|
69
81
|
end
|
70
82
|
|
71
|
-
raise Liqpay::Exception
|
83
|
+
raise Liqpay::Exception, 'amount must be rounded to 2 decimal digits' unless amount.round(2) == amount
|
72
84
|
|
73
|
-
raise Liqpay::Exception
|
85
|
+
raise Liqpay::Exception, 'amount must be more than 0.01' unless amount > 0.01
|
74
86
|
end
|
75
87
|
end
|
76
88
|
end
|
data/lib/liqpay/response.rb
CHANGED
@@ -1,23 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'base64'
|
2
|
-
require 'liqpay/
|
4
|
+
require 'liqpay/signed_payload'
|
3
5
|
|
4
6
|
module Liqpay
|
5
|
-
|
6
|
-
|
7
|
+
# Represents a response from the LiqPay API.
|
8
|
+
class Response < SignedPayload
|
9
|
+
SUCCESS_STATUSES = %w[success wait_secure sandbox].freeze
|
7
10
|
|
8
|
-
ATTRIBUTES = %w
|
9
|
-
%w
|
11
|
+
ATTRIBUTES = %w[public_key order_id amount currency description type status transaction_id sender_phone].freeze
|
12
|
+
%w[public_key order_id description type].each do |attr|
|
10
13
|
attr_reader attr
|
11
14
|
end
|
12
15
|
|
16
|
+
attr_reader :data
|
17
|
+
|
13
18
|
# Amount of payment. MUST match the requested amount
|
14
19
|
attr_reader :amount
|
15
20
|
# Currency of payment. MUST match the requested currency
|
16
21
|
attr_reader :currency
|
17
22
|
# Status of payment. One of '
|
18
|
-
# failure
|
23
|
+
# failure
|
19
24
|
# success
|
20
|
-
# wait_secure - success, but the card wasn't known to the system
|
25
|
+
# wait_secure - success, but the card wasn't known to the system
|
26
|
+
# sandbox
|
21
27
|
attr_reader :status
|
22
28
|
# LiqPAY's internal transaction ID
|
23
29
|
attr_reader :transaction_id
|
@@ -27,28 +33,26 @@ module Liqpay
|
|
27
33
|
def initialize(params = {}, options = {})
|
28
34
|
super(options)
|
29
35
|
|
36
|
+
@data = params['data']
|
37
|
+
parsed_data = JSON.parse(Base64.strict_decode64(data))
|
38
|
+
|
30
39
|
ATTRIBUTES.each do |attribute|
|
31
|
-
instance_variable_set "@#{attribute}",
|
40
|
+
instance_variable_set "@#{attribute}", parsed_data[attribute]
|
32
41
|
end
|
33
|
-
@request_signature = params[
|
42
|
+
@request_signature = params['signature']
|
34
43
|
|
35
44
|
decode!
|
36
45
|
end
|
37
46
|
|
38
47
|
# Returns true, if the transaction was successful
|
39
48
|
def success?
|
40
|
-
SUCCESS_STATUSES.include?
|
49
|
+
SUCCESS_STATUSES.include? status
|
41
50
|
end
|
42
51
|
|
43
|
-
|
44
|
-
[amount, currency, public_key, order_id, type, description, status, transaction_id, sender_phone]
|
45
|
-
end
|
52
|
+
private
|
46
53
|
|
47
|
-
private
|
48
54
|
def decode!
|
49
|
-
if signature != @request_signature
|
50
|
-
raise Liqpay::InvalidResponse
|
51
|
-
end
|
55
|
+
raise Liqpay::InvalidResponse if signature != @request_signature
|
52
56
|
end
|
53
57
|
end
|
54
58
|
end
|
@@ -1,11 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'digest/sha1'
|
2
4
|
require 'base64'
|
3
5
|
|
4
6
|
module Liqpay
|
5
|
-
|
7
|
+
# Handles signing and verification of LiqPay request/responses
|
8
|
+
class SignedPayload
|
6
9
|
attr_accessor :public_key, :private_key
|
7
10
|
|
8
|
-
def initialize(options={})
|
11
|
+
def initialize(options = {})
|
9
12
|
options.replace(Liqpay.default_options.merge(options))
|
10
13
|
|
11
14
|
@public_key = options[:public_key]
|
@@ -13,16 +16,17 @@ module Liqpay
|
|
13
16
|
end
|
14
17
|
|
15
18
|
def signature
|
16
|
-
@signature ||= sign(
|
19
|
+
@signature ||= sign(data)
|
17
20
|
end
|
18
21
|
|
19
|
-
def
|
22
|
+
def data
|
20
23
|
raise NotImplementedError
|
21
24
|
end
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
+
private
|
27
|
+
|
28
|
+
def sign(data)
|
29
|
+
Base64.strict_encode64(Digest::SHA1.digest(@private_key + data + @private_key)).strip
|
26
30
|
end
|
27
31
|
end
|
28
32
|
end
|
data/lib/liqpay/version.rb
CHANGED
data/lib/liqpay.rb
CHANGED
@@ -1,16 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'liqpay/version'
|
2
4
|
require 'liqpay/request'
|
3
5
|
require 'liqpay/response'
|
4
6
|
|
5
7
|
require 'liqpay/railtie' if defined?(Rails)
|
6
8
|
|
9
|
+
# Liqpay implements the LiqPay payment API.
|
7
10
|
module Liqpay
|
8
|
-
LIQPAY_ENDPOINT_URL = 'https://www.liqpay.
|
9
|
-
|
11
|
+
LIQPAY_ENDPOINT_URL = 'https://www.liqpay.ua/api/3/checkout'
|
12
|
+
LIQPAY_API_VERSION = 3
|
13
|
+
|
14
|
+
# Other actions are not supported
|
15
|
+
ACTION_PAY = 'pay'
|
16
|
+
ACTION_DONATE = 'paydonate'
|
17
|
+
|
18
|
+
SUPPORTED_CURRENCIES = %w[USD EUR UAH BYN KZT].freeze
|
10
19
|
|
11
20
|
@default_options = {}
|
12
21
|
class << self; attr_accessor :default_options; end
|
13
22
|
|
14
|
-
class Exception <
|
15
|
-
class InvalidResponse <
|
23
|
+
class Exception < StandardError; end
|
24
|
+
class InvalidResponse < StandardError; end
|
16
25
|
end
|
data/liqpay.gemspec
CHANGED
@@ -1,20 +1,22 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/liqpay/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
6
|
+
s.name = 'liqpay'
|
7
7
|
s.version = Liqpay::VERSION
|
8
|
-
s.authors = [
|
9
|
-
s.email = [
|
10
|
-
s.homepage =
|
11
|
-
s.summary =
|
12
|
-
s.
|
8
|
+
s.authors = ['Leonid Shevtsov']
|
9
|
+
s.email = ['leonid@shevtsov.me']
|
10
|
+
s.homepage = 'https://github.com/leonid-shevtsov/liqpay'
|
11
|
+
s.summary = 'LiqPAY billing API implementation in Ruby'
|
12
|
+
s.required_ruby_version = '>= 2.7.0'
|
13
|
+
s.licenses = ['MIT']
|
13
14
|
|
14
|
-
s.add_development_dependency 'rake'
|
15
|
+
s.add_development_dependency 'rake', '~>13'
|
16
|
+
s.add_development_dependency 'rubocop', '~>1'
|
15
17
|
|
16
18
|
s.files = `git ls-files`.split("\n")
|
17
19
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
-
s.require_paths = [
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
21
|
+
s.require_paths = ['lib']
|
20
22
|
end
|
metadata
CHANGED
@@ -1,70 +1,86 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liqpay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leonid Shevtsov
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '13'
|
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: '
|
27
|
-
|
26
|
+
version: '13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubocop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1'
|
41
|
+
description:
|
28
42
|
email:
|
29
43
|
- leonid@shevtsov.me
|
30
44
|
executables: []
|
31
45
|
extensions: []
|
32
46
|
extra_rdoc_files: []
|
33
47
|
files:
|
34
|
-
- .
|
48
|
+
- ".github/workflows/test.yml"
|
49
|
+
- ".gitignore"
|
35
50
|
- CHANGELOG.md
|
36
51
|
- Gemfile
|
52
|
+
- LICENSE.txt
|
37
53
|
- README.md
|
38
54
|
- Rakefile
|
39
55
|
- lib/liqpay.rb
|
40
|
-
- lib/liqpay/base_operation.rb
|
41
56
|
- lib/liqpay/liqpay_helper.rb
|
42
57
|
- lib/liqpay/railtie.rb
|
43
58
|
- lib/liqpay/request.rb
|
44
59
|
- lib/liqpay/response.rb
|
60
|
+
- lib/liqpay/signed_payload.rb
|
45
61
|
- lib/liqpay/version.rb
|
46
62
|
- liqpay.gemspec
|
47
63
|
homepage: https://github.com/leonid-shevtsov/liqpay
|
48
|
-
licenses:
|
64
|
+
licenses:
|
65
|
+
- MIT
|
49
66
|
metadata: {}
|
50
|
-
post_install_message:
|
67
|
+
post_install_message:
|
51
68
|
rdoc_options: []
|
52
69
|
require_paths:
|
53
70
|
- lib
|
54
71
|
required_ruby_version: !ruby/object:Gem::Requirement
|
55
72
|
requirements:
|
56
|
-
- -
|
73
|
+
- - ">="
|
57
74
|
- !ruby/object:Gem::Version
|
58
|
-
version:
|
75
|
+
version: 2.7.0
|
59
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
77
|
requirements:
|
61
|
-
- -
|
78
|
+
- - ">="
|
62
79
|
- !ruby/object:Gem::Version
|
63
80
|
version: '0'
|
64
81
|
requirements: []
|
65
|
-
|
66
|
-
|
67
|
-
signing_key:
|
82
|
+
rubygems_version: 3.2.15
|
83
|
+
signing_key:
|
68
84
|
specification_version: 4
|
69
85
|
summary: LiqPAY billing API implementation in Ruby
|
70
86
|
test_files: []
|