pay_boutique 0.2.1
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 +7 -0
- data/.gitignore +26 -0
- data/.rubocop.yml +11 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +47 -0
- data/LICENSE.txt +21 -0
- data/README.md +58 -0
- data/Rakefile +1 -0
- data/lib/pay_boutique/config.rb +18 -0
- data/lib/pay_boutique/parametrizable.rb +47 -0
- data/lib/pay_boutique/payment_details.rb +76 -0
- data/lib/pay_boutique/payment_gateway.rb +87 -0
- data/lib/pay_boutique/request.rb +19 -0
- data/lib/pay_boutique/request_parser.rb +23 -0
- data/lib/pay_boutique/response_parser.rb +35 -0
- data/lib/pay_boutique/signature.rb +21 -0
- data/lib/pay_boutique/version.rb +3 -0
- data/lib/pay_boutique.rb +25 -0
- data/pay_boutique.gemspec +32 -0
- metadata +134 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: eeffe06179653010e3ba3bc6cb4f1859fa3c8c2e34ec6caf47903922b186dad3
|
|
4
|
+
data.tar.gz: 83836f4afb51bb837ffbe3f21b32b2ca5350e65064fd673676a5c8488943bef4
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7a7a03f85d3c1f60c37b8e0d1d9bb574c7309def12f778f341fdb4f5d705a483633d78a2a31f498879c1d550c49ab30b091d6bc9c85eb0c6963e19223a376842
|
|
7
|
+
data.tar.gz: b40a5630b2addc1225446635656ab6d8928dd26333160aa55e5dcbceddabea306f362f63ed757b835f59e2339a49c23326a29654b81059c3f10bc2821d24e1a8
|
data/.gitignore
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
*.sassc
|
|
4
|
+
.bundle
|
|
5
|
+
.config
|
|
6
|
+
.yardoc
|
|
7
|
+
.rvmrc
|
|
8
|
+
.rspec
|
|
9
|
+
.sass-cache
|
|
10
|
+
.DS_Store
|
|
11
|
+
Gemfile.lock # gem projects only!
|
|
12
|
+
InstalledFiles
|
|
13
|
+
_yardoc
|
|
14
|
+
doc/
|
|
15
|
+
coverage
|
|
16
|
+
lib/bundler/man
|
|
17
|
+
capybara-*.html
|
|
18
|
+
pkg
|
|
19
|
+
rdoc
|
|
20
|
+
spec/reports
|
|
21
|
+
spec/tmp
|
|
22
|
+
test/tmp
|
|
23
|
+
test/version_tmp
|
|
24
|
+
tmp
|
|
25
|
+
.idea/
|
|
26
|
+
atlassian-ide-plugin.xml
|
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
pay_boutique (0.2.0)
|
|
5
|
+
activesupport (>= 4.2.0)
|
|
6
|
+
httparty (>= 0.7.7)
|
|
7
|
+
nokogiri (>= 1.5.0)
|
|
8
|
+
|
|
9
|
+
GEM
|
|
10
|
+
remote: https://rubygems.org/
|
|
11
|
+
specs:
|
|
12
|
+
activesupport (5.2.0)
|
|
13
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
14
|
+
i18n (>= 0.7, < 2)
|
|
15
|
+
minitest (~> 5.1)
|
|
16
|
+
tzinfo (~> 1.1)
|
|
17
|
+
coderay (1.1.2)
|
|
18
|
+
concurrent-ruby (1.0.5)
|
|
19
|
+
httparty (0.16.2)
|
|
20
|
+
multi_xml (>= 0.5.2)
|
|
21
|
+
i18n (1.0.1)
|
|
22
|
+
concurrent-ruby (~> 1.0)
|
|
23
|
+
method_source (0.9.0)
|
|
24
|
+
mini_portile2 (2.3.0)
|
|
25
|
+
minitest (5.11.3)
|
|
26
|
+
multi_xml (0.6.0)
|
|
27
|
+
nokogiri (1.8.4)
|
|
28
|
+
mini_portile2 (~> 2.3.0)
|
|
29
|
+
pry (0.11.3)
|
|
30
|
+
coderay (~> 1.1.0)
|
|
31
|
+
method_source (~> 0.9.0)
|
|
32
|
+
rake (10.5.0)
|
|
33
|
+
thread_safe (0.3.6)
|
|
34
|
+
tzinfo (1.2.5)
|
|
35
|
+
thread_safe (~> 0.1)
|
|
36
|
+
|
|
37
|
+
PLATFORMS
|
|
38
|
+
ruby
|
|
39
|
+
|
|
40
|
+
DEPENDENCIES
|
|
41
|
+
bundler (~> 1.9)
|
|
42
|
+
pay_boutique!
|
|
43
|
+
pry
|
|
44
|
+
rake (~> 10.0)
|
|
45
|
+
|
|
46
|
+
BUNDLED WITH
|
|
47
|
+
1.16.2
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 Yuri Zubov
|
|
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
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# PayBoutique
|
|
2
|
+
|
|
3
|
+
The PayBoutique meant to offer an alternate object-oriented model of development with the PayBoutique APIs
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'pay_boutique'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle
|
|
16
|
+
|
|
17
|
+
Or install it yourself as:
|
|
18
|
+
|
|
19
|
+
$ gem install pay_boutique
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
Configure your app
|
|
23
|
+
```ruby
|
|
24
|
+
PayBoutique.config do |config|
|
|
25
|
+
config.site_address = PAY_BOUTIQUE[:site_address]
|
|
26
|
+
config.buyer_currency = PAY_BOUTIQUE[:buyer_currency]
|
|
27
|
+
config.merchant_currency = PAY_BOUTIQUE[:merchant_currency]
|
|
28
|
+
config.password = PAY_BOUTIQUE[:password]
|
|
29
|
+
config.live = PAY_BOUTIQUE[:live]
|
|
30
|
+
config.credit_card_postback_url = PAY_BOUTIQUE[:credit_card_postback_url]
|
|
31
|
+
config.merchant_id = PAY_BOUTIQUE[:merchant_id]
|
|
32
|
+
config.success_url = PAY_BOUTIQUE[:success_url]
|
|
33
|
+
config.failure_url = PAY_BOUTIQUE[:failure_url]
|
|
34
|
+
config.qiwi_postback_url = PAY_BOUTIQUE[:qiwi_postback_url]
|
|
35
|
+
config.user_id = PAY_BOUTIQUE[:user_id]
|
|
36
|
+
config.request_url = PAY_BOUTIQUE[:request_url]
|
|
37
|
+
config.postback_url = PAY_BOUTIQUE[:postback_url]
|
|
38
|
+
end
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Development
|
|
42
|
+
|
|
43
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
44
|
+
|
|
45
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
46
|
+
|
|
47
|
+
## Contributing
|
|
48
|
+
|
|
49
|
+
1. Fork it ( https://github.com/[my-github-username]/pay_boutique/fork )
|
|
50
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
51
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
52
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
53
|
+
5. Create a new Pull Request
|
|
54
|
+
# pay_boutique
|
|
55
|
+
|
|
56
|
+
# Docs
|
|
57
|
+
|
|
58
|
+
Here you can see api docs [https://sites.google.com/a/payboutique.com/paybwiki/wiki/xml_v0-5](https://sites.google.com/a/payboutique.com/paybwiki/wiki/xml_v0-5)
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'bundler/gem_tasks'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module PayBoutique
|
|
2
|
+
class Config
|
|
3
|
+
include ActiveSupport::Configurable
|
|
4
|
+
|
|
5
|
+
CONFIGS = %i[
|
|
6
|
+
site_address buyer_currency merchant_currency password live credit_card_postback_url
|
|
7
|
+
merchant_id success_url failure_url qiwi_postback_url user_id request_url postback_url
|
|
8
|
+
].freeze
|
|
9
|
+
|
|
10
|
+
config_accessor(*CONFIGS)
|
|
11
|
+
|
|
12
|
+
def initialize(**options)
|
|
13
|
+
options.each do |key, value|
|
|
14
|
+
config.send("#{key}=", value)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module PayBoutique
|
|
2
|
+
module Parametrizable
|
|
3
|
+
def initialize(params)
|
|
4
|
+
@params = params
|
|
5
|
+
|
|
6
|
+
filter_params
|
|
7
|
+
verify_params
|
|
8
|
+
|
|
9
|
+
__setobj__ @params
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
Config::CONFIGS.each do |attribute|
|
|
13
|
+
define_method attribute do
|
|
14
|
+
instance_variable_get("@#{attribute}") || PayBoutique.configuration.send(attribute)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def postback_url
|
|
19
|
+
@postback_url || PayBoutique.configuration.send("#{@params.payment_method}_postback_url") ||
|
|
20
|
+
PayBoutique.configuration.postback_url
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def time
|
|
26
|
+
@time ||= Time.now.utc.strftime('%Y%m%dT%H%M%S+00')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def verify_params
|
|
30
|
+
missed_params = self.class.required_params - (existing_params & self.class.required_params)
|
|
31
|
+
return unless missed_params.any?
|
|
32
|
+
|
|
33
|
+
missed_params = missed_params.map(&:inspect).join(', ')
|
|
34
|
+
raise ArgumentError, "wrong arguments, missed: #{missed_params}"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def filter_params
|
|
38
|
+
@params.to_h.each_key do |field|
|
|
39
|
+
@params.delete_field field if !self.class.params.include?(field) && @params[field]
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def existing_params
|
|
44
|
+
@existing_params ||= @params.to_h.keys.compact + PayBoutique.configuration.config.compact.keys
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
module PayBoutique
|
|
2
|
+
class PaymentDetails < Request
|
|
3
|
+
attr_accessor :order_id, :reference_id
|
|
4
|
+
|
|
5
|
+
class Params < SimpleDelegator
|
|
6
|
+
include Parametrizable
|
|
7
|
+
BODY_TYPE = 'getStatus'.freeze
|
|
8
|
+
IDS = %i[order_id reference_id].freeze
|
|
9
|
+
VERSION = '0.5'.freeze
|
|
10
|
+
|
|
11
|
+
def to_xml
|
|
12
|
+
@xml = Nokogiri::XML::Builder.new do |root|
|
|
13
|
+
root.Message(version: VERSION) do |xml|
|
|
14
|
+
xml.Header do |header|
|
|
15
|
+
header.Identity do |identity|
|
|
16
|
+
identity.UserID user_id
|
|
17
|
+
identity.Signature Signature.create(time)
|
|
18
|
+
end
|
|
19
|
+
header.Time time
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
xml.Body(type: BODY_TYPE) do |body|
|
|
23
|
+
body.Order do |order|
|
|
24
|
+
order.OrderID order_id if try(:order_id)
|
|
25
|
+
order.ReferenceID reference_id if try(:reference_id)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
@xml
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def verify_params
|
|
36
|
+
@missed_params = self.class.required_params - (existing_params & self.class.required_params)
|
|
37
|
+
return if @missed_params.empty? || missed_only_one_id
|
|
38
|
+
|
|
39
|
+
raise ArgumentError, "wrong arguments, missed: #{@missed_params.map(&:inspect).join(', ')}"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def missed_only_one_id
|
|
43
|
+
@missed_params.size == 1 && IDS.include?(@missed_params.first)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
class << self
|
|
47
|
+
def required_params
|
|
48
|
+
configs = Config::CONFIGS + IDS
|
|
49
|
+
|
|
50
|
+
if PayBoutique.configuration.qiwi_postback_url || PayBoutique.configuration.credit_card_postback_url
|
|
51
|
+
configs.delete(:postback_url)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
configs
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def params
|
|
58
|
+
required_params
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def self.retrieve(**args)
|
|
64
|
+
response = new(args).call
|
|
65
|
+
RequestParser.new(response)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def initialize(**params)
|
|
69
|
+
@params = Params.new(OpenStruct.new(params))
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def call
|
|
73
|
+
self.class.post(request_url, body: request_body)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
module PayBoutique
|
|
2
|
+
class PaymentGateway < Request
|
|
3
|
+
class Params < SimpleDelegator
|
|
4
|
+
include Parametrizable
|
|
5
|
+
|
|
6
|
+
BODY_TYPE = 'GetInvoice'.freeze
|
|
7
|
+
VERSION = '0.5'.freeze
|
|
8
|
+
|
|
9
|
+
def to_xml
|
|
10
|
+
@xml = Nokogiri::XML::Builder.new do |root|
|
|
11
|
+
root.Message(version: VERSION) do |xml|
|
|
12
|
+
xml.Header do |header|
|
|
13
|
+
header.Identity do |identity|
|
|
14
|
+
identity.UserID user_id
|
|
15
|
+
identity.Signature Signature.create(time)
|
|
16
|
+
end
|
|
17
|
+
header.Time time
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
xml.Body(type: BODY_TYPE, live: PayBoutique.configuration.live) do |body|
|
|
21
|
+
body.Order(paymentMethod: payment_method_camelize, buyerCurrency: buyer_currency) do |order|
|
|
22
|
+
order.MerchantID merchant_id
|
|
23
|
+
order.OrderID order_id
|
|
24
|
+
order.AmountMerchantCurrency amount_merchant_currency
|
|
25
|
+
order.MerchantCurrency merchant_currency
|
|
26
|
+
order.ExpirationTime expiration_time if try(:expiration_time)
|
|
27
|
+
order.Label label if try(:label)
|
|
28
|
+
order.SiteAddress site_address
|
|
29
|
+
order.Description description if try(:description)
|
|
30
|
+
order.SuccessURL success_url if try(:success_url)
|
|
31
|
+
order.FailureURL failure_url if try(:failure_url)
|
|
32
|
+
order.PostbackUrl postback_url
|
|
33
|
+
order.Buyer do |buyer|
|
|
34
|
+
buyer.FirstName first_name if try(:first_name)
|
|
35
|
+
buyer.MiddleName middle_name if try(:middle_name)
|
|
36
|
+
buyer.LastName last_name if try(:last_name)
|
|
37
|
+
buyer.Address address if try(:address)
|
|
38
|
+
buyer.City city if try(:city)
|
|
39
|
+
buyer.Country country if try(:country)
|
|
40
|
+
buyer.AccountID account_id if try(:account_id)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
@xml
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
def payment_method_camelize
|
|
52
|
+
payment_method.to_s.camelize
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
class << self
|
|
56
|
+
def required_params
|
|
57
|
+
configs = Config::CONFIGS + %i[payment_method order_id amount_merchant_currency]
|
|
58
|
+
|
|
59
|
+
if PayBoutique.configuration.qiwi_postback_url || PayBoutique.configuration.credit_card_postback_url
|
|
60
|
+
configs.delete(:postback_url)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
configs
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def params
|
|
67
|
+
%i[
|
|
68
|
+
user_id buyer_currency merchant_currency amount_merchant_currency
|
|
69
|
+
merchant_id order_id expiration_time description merchant_reference
|
|
70
|
+
label product_name site_address payment_method first_name middle_name
|
|
71
|
+
last_name address city country account_id success_url failure_url
|
|
72
|
+
credit_card_postback_url qiwi_postback_url
|
|
73
|
+
]
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def initialize(**params)
|
|
79
|
+
@params = Params.new(OpenStruct.new(params))
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def url
|
|
83
|
+
response = self.class.post(request_url, body: request_body)
|
|
84
|
+
RequestParser.new(response).redirect_url
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'httparty'
|
|
2
|
+
|
|
3
|
+
module PayBoutique
|
|
4
|
+
class Request
|
|
5
|
+
include HTTParty
|
|
6
|
+
headers 'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8'
|
|
7
|
+
debug_output $stdout
|
|
8
|
+
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
def request_body
|
|
12
|
+
{ xml: @params.to_xml.doc.root.to_xml }.to_params
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def request_url
|
|
16
|
+
@params.request_url || PayBoutique.configuration.request_url
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module PayBoutique
|
|
2
|
+
class RequestParser
|
|
3
|
+
def initialize(str_xml)
|
|
4
|
+
@xml = Nokogiri::XML(str_xml)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def amount_merchant_currency
|
|
8
|
+
@xml.xpath('//Message//Body//AmountMerchantCurrency').text
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def order_id
|
|
12
|
+
@xml.xpath('//Message//Body//OrderID').text
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def redirect_url
|
|
16
|
+
@xml.xpath('//Message//Body//RedirectURL').text
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def card_mask
|
|
20
|
+
@xml.xpath('//Message//Body//Card//CardMask').text
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module PayBoutique
|
|
2
|
+
class ResponseParser
|
|
3
|
+
attr_reader :order_id, :amount
|
|
4
|
+
|
|
5
|
+
def initialize(str_xml)
|
|
6
|
+
@xml = Nokogiri::XML(str_xml)
|
|
7
|
+
@order_id = @xml.xpath('//Message//Body//OrderID').text
|
|
8
|
+
@amount = @xml.xpath('//Message//Body//AmountMerchantCurrency').text
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def valid?
|
|
12
|
+
checksum = @xml.xpath('//Message//Header//Identity//Checksum').text
|
|
13
|
+
time = @xml.xpath('//Message//Header//Time').text
|
|
14
|
+
reference_id = @xml.xpath('//Message//Body//ReferenceID').text
|
|
15
|
+
|
|
16
|
+
checksum == Signature.create(time, reference_id)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def status
|
|
20
|
+
@xml.xpath('//Message//Body//Status').text
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def reference_id
|
|
24
|
+
@xml.xpath('//Message//Body//ReferenceID').text
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def captured?
|
|
28
|
+
status == 'captured'
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def payment_method
|
|
32
|
+
@xml.xpath('//Message//Body//PaymentMethod').text.snakecase.to_sym
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module PayBoutique
|
|
2
|
+
class Signature
|
|
3
|
+
class << self
|
|
4
|
+
def create(*args)
|
|
5
|
+
Digest::SHA512
|
|
6
|
+
.hexdigest((user_id + Digest::SHA512.hexdigest(password) + args.join).upcase)
|
|
7
|
+
.upcase
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
def user_id
|
|
13
|
+
PayBoutique.configuration.user_id
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def password
|
|
17
|
+
PayBoutique.configuration.password
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
data/lib/pay_boutique.rb
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'yaml'
|
|
2
|
+
require 'active_support'
|
|
3
|
+
|
|
4
|
+
require 'pay_boutique/config'
|
|
5
|
+
require 'pay_boutique/request'
|
|
6
|
+
require 'pay_boutique/parametrizable'
|
|
7
|
+
require 'pay_boutique/payment_details'
|
|
8
|
+
require 'pay_boutique/response_parser'
|
|
9
|
+
require 'pay_boutique/payment_gateway'
|
|
10
|
+
require 'pay_boutique/request_parser'
|
|
11
|
+
require 'pay_boutique/signature'
|
|
12
|
+
require 'pay_boutique/version'
|
|
13
|
+
|
|
14
|
+
module PayBoutique
|
|
15
|
+
def configuration
|
|
16
|
+
@configuration ||= Config.new
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def config
|
|
20
|
+
config = configuration
|
|
21
|
+
yield(config)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
module_function :configuration, :config
|
|
25
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
+
require 'pay_boutique/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'pay_boutique'
|
|
7
|
+
spec.version = PayBoutique::VERSION
|
|
8
|
+
spec.authors = ['Yuri Zubov', 'Alexandr Senyuk']
|
|
9
|
+
spec.email = ['I0Result86@gmail.com']
|
|
10
|
+
spec.homepage = 'https://github.com/SumatoSoft/pay-boutique'
|
|
11
|
+
|
|
12
|
+
spec.summary = 'Payment system PayBoutique'
|
|
13
|
+
spec.description = 'Very simple wrapper for payment system PayBoutique'
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
|
|
16
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
|
17
|
+
# delete this section to allow pushing this gem to any host.
|
|
18
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.' unless spec.respond_to?(:metadata)
|
|
19
|
+
|
|
20
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
|
21
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
22
|
+
spec.bindir = 'exe'
|
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
24
|
+
spec.require_paths = ['lib']
|
|
25
|
+
|
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.9'
|
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
28
|
+
|
|
29
|
+
spec.add_runtime_dependency 'activesupport', '>= 4.2.0'
|
|
30
|
+
spec.add_runtime_dependency 'httparty', '>= 0.7.7'
|
|
31
|
+
spec.add_runtime_dependency 'nokogiri', '>= 1.5.0'
|
|
32
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: pay_boutique
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Yuri Zubov
|
|
8
|
+
- Alexandr Senyuk
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: exe
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2018-07-11 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: bundler
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
requirements:
|
|
18
|
+
- - "~>"
|
|
19
|
+
- !ruby/object:Gem::Version
|
|
20
|
+
version: '1.9'
|
|
21
|
+
type: :development
|
|
22
|
+
prerelease: false
|
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
24
|
+
requirements:
|
|
25
|
+
- - "~>"
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: '1.9'
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: rake
|
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - "~>"
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '10.0'
|
|
35
|
+
type: :development
|
|
36
|
+
prerelease: false
|
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - "~>"
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '10.0'
|
|
42
|
+
- !ruby/object:Gem::Dependency
|
|
43
|
+
name: activesupport
|
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - ">="
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: 4.2.0
|
|
49
|
+
type: :runtime
|
|
50
|
+
prerelease: false
|
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - ">="
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: 4.2.0
|
|
56
|
+
- !ruby/object:Gem::Dependency
|
|
57
|
+
name: httparty
|
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
|
59
|
+
requirements:
|
|
60
|
+
- - ">="
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: 0.7.7
|
|
63
|
+
type: :runtime
|
|
64
|
+
prerelease: false
|
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
66
|
+
requirements:
|
|
67
|
+
- - ">="
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: 0.7.7
|
|
70
|
+
- !ruby/object:Gem::Dependency
|
|
71
|
+
name: nokogiri
|
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
|
73
|
+
requirements:
|
|
74
|
+
- - ">="
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: 1.5.0
|
|
77
|
+
type: :runtime
|
|
78
|
+
prerelease: false
|
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
80
|
+
requirements:
|
|
81
|
+
- - ">="
|
|
82
|
+
- !ruby/object:Gem::Version
|
|
83
|
+
version: 1.5.0
|
|
84
|
+
description: Very simple wrapper for payment system PayBoutique
|
|
85
|
+
email:
|
|
86
|
+
- I0Result86@gmail.com
|
|
87
|
+
executables: []
|
|
88
|
+
extensions: []
|
|
89
|
+
extra_rdoc_files: []
|
|
90
|
+
files:
|
|
91
|
+
- ".gitignore"
|
|
92
|
+
- ".rubocop.yml"
|
|
93
|
+
- Gemfile
|
|
94
|
+
- Gemfile.lock
|
|
95
|
+
- LICENSE.txt
|
|
96
|
+
- README.md
|
|
97
|
+
- Rakefile
|
|
98
|
+
- lib/pay_boutique.rb
|
|
99
|
+
- lib/pay_boutique/config.rb
|
|
100
|
+
- lib/pay_boutique/parametrizable.rb
|
|
101
|
+
- lib/pay_boutique/payment_details.rb
|
|
102
|
+
- lib/pay_boutique/payment_gateway.rb
|
|
103
|
+
- lib/pay_boutique/request.rb
|
|
104
|
+
- lib/pay_boutique/request_parser.rb
|
|
105
|
+
- lib/pay_boutique/response_parser.rb
|
|
106
|
+
- lib/pay_boutique/signature.rb
|
|
107
|
+
- lib/pay_boutique/version.rb
|
|
108
|
+
- pay_boutique.gemspec
|
|
109
|
+
homepage: https://github.com/SumatoSoft/pay-boutique
|
|
110
|
+
licenses:
|
|
111
|
+
- MIT
|
|
112
|
+
metadata:
|
|
113
|
+
allowed_push_host: https://rubygems.org
|
|
114
|
+
post_install_message:
|
|
115
|
+
rdoc_options: []
|
|
116
|
+
require_paths:
|
|
117
|
+
- lib
|
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
119
|
+
requirements:
|
|
120
|
+
- - ">="
|
|
121
|
+
- !ruby/object:Gem::Version
|
|
122
|
+
version: '0'
|
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
|
+
requirements:
|
|
125
|
+
- - ">="
|
|
126
|
+
- !ruby/object:Gem::Version
|
|
127
|
+
version: '0'
|
|
128
|
+
requirements: []
|
|
129
|
+
rubyforge_project:
|
|
130
|
+
rubygems_version: 2.7.3
|
|
131
|
+
signing_key:
|
|
132
|
+
specification_version: 4
|
|
133
|
+
summary: Payment system PayBoutique
|
|
134
|
+
test_files: []
|