mandarin_pay 1.0.0 → 1.1.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/Gemfile +1 -0
- data/README.md +1 -1
- data/app/controllers/mandarin_pay_controller.rb +3 -6
- data/bin/bundler +1 -0
- data/bin/cdiff +1 -0
- data/bin/coderay +17 -0
- data/bin/colortab +1 -0
- data/bin/coveralls +1 -0
- data/bin/decolor +1 -0
- data/bin/erubis +1 -0
- data/bin/htmldiff +1 -0
- data/bin/ldiff +1 -0
- data/bin/nokogiri +1 -0
- data/bin/pry +17 -0
- data/bin/rackup +1 -0
- data/bin/rails +1 -0
- data/bin/rake +1 -0
- data/bin/rspec +1 -0
- data/bin/sprockets +1 -0
- data/bin/term_display +1 -0
- data/bin/term_mandel +1 -0
- data/bin/thor +1 -0
- data/lib/mandarin_pay/signature_generator.rb +4 -6
- data/lib/mandarin_pay/version.rb +1 -1
- data/spec/mandarin_pay/notification_spec.rb +3 -3
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 621f5679074f8bd32baac048b534b33e7ad0945f
|
|
4
|
+
data.tar.gz: 8efb0d1d68f75be18023fa6612acd1d7d48642e0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 06e57bc17a355b0b0e229273e11efafe326a01f13840d9dc2e9da55f0c39965b878904c4772a7c2360a3ad24aaffe484a66532cfc7332c6228403ce74a07e09c
|
|
7
|
+
data.tar.gz: 74ae510f75c4edc31afb896a55a7d046466d0111a55a6d3f4b55ec981dd90470040635b711847c9089d08b28b4007d0141c1f678e0e9c556e45cd7a61bb355e0
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -4,7 +4,7 @@ by [Drakmail][]
|
|
|
4
4
|
|
|
5
5
|
[Drakmail]: http://drakmail.ru
|
|
6
6
|
|
|
7
|
-
Ruby wrapper for [
|
|
7
|
+
Ruby wrapper for [MandarinPay API][]. Make Mandarin Pay to work with your Rails project without pain. MandarinPay took the best from [rubykassa gem][] and [Active Merchant Robokassa integration] but easier to use and setup.
|
|
8
8
|
|
|
9
9
|
[MandarinPay API]: http://mandarin_pay.com/sites/default/files/protokol_integracii_v0.5.5_0.pdf
|
|
10
10
|
[rubykassa gem]: https://github.com/ZeroOneStudio/rubykassa
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
class MandarinPayController < ApplicationController
|
|
2
2
|
before_action :create_notification
|
|
3
|
+
skip_before_action :verify_authenticity_token
|
|
3
4
|
|
|
4
5
|
def paid
|
|
5
|
-
if @notification.
|
|
6
|
+
if @notification.valid_transaction_signature?
|
|
6
7
|
instance_exec @notification, &MandarinPay.result_callback
|
|
7
8
|
else
|
|
8
9
|
instance_exec @notification, &MandarinPay.fail_callback
|
|
@@ -10,11 +11,7 @@ class MandarinPayController < ApplicationController
|
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
def success
|
|
13
|
-
|
|
14
|
-
instance_exec @notification, &MandarinPay.success_callback
|
|
15
|
-
else
|
|
16
|
-
instance_exec @notification, &MandarinPay.fail_callback
|
|
17
|
-
end
|
|
14
|
+
instance_exec @notification, &MandarinPay.success_callback
|
|
18
15
|
end
|
|
19
16
|
|
|
20
17
|
def fail
|
data/bin/bundler
CHANGED
data/bin/cdiff
CHANGED
data/bin/coderay
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
#
|
|
4
|
+
# This file was generated by Bundler.
|
|
5
|
+
#
|
|
6
|
+
# The application 'coderay' is installed as part of a gem, and
|
|
7
|
+
# this file is here to facilitate running it.
|
|
8
|
+
#
|
|
9
|
+
|
|
10
|
+
require "pathname"
|
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
12
|
+
Pathname.new(__FILE__).realpath)
|
|
13
|
+
|
|
14
|
+
require "rubygems"
|
|
15
|
+
require "bundler/setup"
|
|
16
|
+
|
|
17
|
+
load Gem.bin_path("coderay", "coderay")
|
data/bin/colortab
CHANGED
data/bin/coveralls
CHANGED
data/bin/decolor
CHANGED
data/bin/erubis
CHANGED
data/bin/htmldiff
CHANGED
data/bin/ldiff
CHANGED
data/bin/nokogiri
CHANGED
data/bin/pry
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
#
|
|
4
|
+
# This file was generated by Bundler.
|
|
5
|
+
#
|
|
6
|
+
# The application 'pry' is installed as part of a gem, and
|
|
7
|
+
# this file is here to facilitate running it.
|
|
8
|
+
#
|
|
9
|
+
|
|
10
|
+
require "pathname"
|
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
12
|
+
Pathname.new(__FILE__).realpath)
|
|
13
|
+
|
|
14
|
+
require "rubygems"
|
|
15
|
+
require "bundler/setup"
|
|
16
|
+
|
|
17
|
+
load Gem.bin_path("pry", "pry")
|
data/bin/rackup
CHANGED
data/bin/rails
CHANGED
data/bin/rake
CHANGED
data/bin/rspec
CHANGED
data/bin/sprockets
CHANGED
data/bin/term_display
CHANGED
data/bin/term_mandel
CHANGED
data/bin/thor
CHANGED
|
@@ -2,7 +2,7 @@ module MandarinPay
|
|
|
2
2
|
module SignatureGenerator
|
|
3
3
|
def generate_signature_for(kind, extra_params = {})
|
|
4
4
|
unless [:card_binding, :payment, :transaction].include? kind
|
|
5
|
-
raise ArgumentError, "Available kinds are only :payment, :
|
|
5
|
+
raise ArgumentError, "Available kinds are only :payment, :card_binding or :transaction"
|
|
6
6
|
end
|
|
7
7
|
Digest::SHA256.hexdigest(params_string(kind, extra_params))
|
|
8
8
|
end
|
|
@@ -10,11 +10,9 @@ module MandarinPay
|
|
|
10
10
|
def params_string(kind, extra_params)
|
|
11
11
|
case kind
|
|
12
12
|
when :payment
|
|
13
|
-
Hash[conformity_params(extra_params).
|
|
14
|
-
|
|
15
|
-
Hash[
|
|
16
|
-
when :transaction
|
|
17
|
-
Hash[conformity_params(extra_params).sort].values.join("-") + "-" + MandarinPay.sharedsec
|
|
13
|
+
Hash[conformity_params(extra_params).sort_by { |(key, _v)| key }].values.join("-") + "-" + MandarinPay.sharedsec
|
|
14
|
+
else
|
|
15
|
+
Hash[@params.except("sign").sort_by { |(key, _v)| key }].values.join("-") + "-" + MandarinPay.sharedsec
|
|
18
16
|
end
|
|
19
17
|
end
|
|
20
18
|
|
data/lib/mandarin_pay/version.rb
CHANGED
|
@@ -11,7 +11,7 @@ describe MandarinPay::Notification do
|
|
|
11
11
|
data = {
|
|
12
12
|
"orderId" => "12",
|
|
13
13
|
"price" => "1200",
|
|
14
|
-
"sign" => "
|
|
14
|
+
"sign" => "e3daf8ea5021343c455853a27901a2355a5db5d3c29b9c3f0ce9869a040ce593"
|
|
15
15
|
}
|
|
16
16
|
notification = MandarinPay::Notification.new(data)
|
|
17
17
|
expect(notification.valid_card_binding_signature?).to eq true
|
|
@@ -31,7 +31,7 @@ describe MandarinPay::Notification do
|
|
|
31
31
|
data = {
|
|
32
32
|
"orderId" => "12",
|
|
33
33
|
"price" => "1200",
|
|
34
|
-
"sign" => "
|
|
34
|
+
"sign" => "e3daf8ea5021343c455853a27901a2355a5db5d3c29b9c3f0ce9869a040ce593"
|
|
35
35
|
}
|
|
36
36
|
notification = MandarinPay::Notification.new(data)
|
|
37
37
|
expect(notification.valid_transaction_signature?).to eq true
|
|
@@ -46,6 +46,6 @@ describe MandarinPay::Notification do
|
|
|
46
46
|
expect do
|
|
47
47
|
notification = MandarinPay::Notification.new({})
|
|
48
48
|
notification.generate_signature_for(:bullshit)
|
|
49
|
-
end.to raise_error(ArgumentError, "Available kinds are only :payment, :
|
|
49
|
+
end.to raise_error(ArgumentError, "Available kinds are only :payment, :card_binding or :transaction")
|
|
50
50
|
end
|
|
51
51
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mandarin_pay
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alexander Maslov
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-07-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -84,6 +84,7 @@ files:
|
|
|
84
84
|
- app/controllers/mandarin_pay_controller.rb
|
|
85
85
|
- bin/bundler
|
|
86
86
|
- bin/cdiff
|
|
87
|
+
- bin/coderay
|
|
87
88
|
- bin/colortab
|
|
88
89
|
- bin/coveralls
|
|
89
90
|
- bin/decolor
|
|
@@ -91,6 +92,7 @@ files:
|
|
|
91
92
|
- bin/htmldiff
|
|
92
93
|
- bin/ldiff
|
|
93
94
|
- bin/nokogiri
|
|
95
|
+
- bin/pry
|
|
94
96
|
- bin/rackup
|
|
95
97
|
- bin/rails
|
|
96
98
|
- bin/rake
|