wayforpay 0.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 +7 -0
- data/.gitignore +2 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/README.md +25 -0
- data/lib/wayforpay.rb +26 -0
- data/lib/wayforpay/constants.rb +42 -0
- data/lib/wayforpay/encrypt_field.rb +23 -0
- data/lib/wayforpay/payments.rb +23 -0
- data/lib/wayforpay/request.rb +11 -0
- data/lib/wayforpay/util/configuration.rb +19 -0
- data/lib/wayforpay/version.rb +3 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/wayforpay/encrypt_field_spec.rb +152 -0
- data/spec/wayforpay/payments_spec.rb +67 -0
- data/spec/wayforpay/request_spec.rb +78 -0
- data/spec/wayforpay/util/configuration_spec.rb +16 -0
- data/spec/wayforpay_spec.rb +25 -0
- data/wayforpay.gemspec +27 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ac203bf9298139ac2be3e1cef08eba76fed5bcb5
|
4
|
+
data.tar.gz: b979a161c53384bd04be7c0b6fa80e2671962d89
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5ddeae517f34a156ce8f9f7e9df02591270f4da7e889a194aeaf504e3bb872573f08ccb9aaabc16e1095c8ba0bcfefbaf54d0d17698a67e50aaef7eabd846040
|
7
|
+
data.tar.gz: b47f777278907c63dd370acf4880cbefbab53b325d6d71b01286dfd90f72f174915e80511ef199091be2739c1a0b9db108c6e19576a60558b0041f1fa929ef59
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
## Installation
|
2
|
+
|
3
|
+
Add this line to your application's `Gemfile`:
|
4
|
+
|
5
|
+
gem 'wayforpay'
|
6
|
+
|
7
|
+
And then execute:
|
8
|
+
|
9
|
+
$ bundle install
|
10
|
+
|
11
|
+
Or install it yourself as:
|
12
|
+
|
13
|
+
$ gem install wayforpay
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
TODO: Write usage instructions
|
18
|
+
|
19
|
+
## Contributing
|
20
|
+
|
21
|
+
1. Fork it
|
22
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
23
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
24
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
25
|
+
5. Create new Pull Request
|
data/lib/wayforpay.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative 'wayforpay/constants'
|
2
|
+
require_relative 'wayforpay/encrypt_field'
|
3
|
+
require_relative 'wayforpay/payments'
|
4
|
+
require_relative 'wayforpay/request'
|
5
|
+
require_relative 'wayforpay/util/configuration'
|
6
|
+
|
7
|
+
module Wayforpay
|
8
|
+
extend SingleForwardable
|
9
|
+
|
10
|
+
def_delegators :configuration, :merchant_account,
|
11
|
+
:merchant_domain_name, :encrypt_secret_key
|
12
|
+
|
13
|
+
# Pre-configure with merchant_account, merchant_domain_name
|
14
|
+
# and encrypt_secret_key.
|
15
|
+
def self.configure(&block)
|
16
|
+
yield configuration
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
##
|
22
|
+
# Returns an existing or instantiates a new configuration object.
|
23
|
+
def self.configuration
|
24
|
+
@configuration ||= Util::Configuration.new
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Wayforpay
|
2
|
+
module Constants
|
3
|
+
URL = URI.parse('https://api.wayforpay.com/api').freeze
|
4
|
+
|
5
|
+
HOLD_ENCRYPT_FIELDS = %i[merchantAccount merchantDomainName orderReference orderDate amount currency productName productCount productPrice].freeze
|
6
|
+
REFUND_ENCRYPT_FIELDS = %i[merchantAccount orderReference amount currency].freeze
|
7
|
+
SETTLE_ENCRYPT_FIELDS = %i[merchantAccount orderReference amount currency].freeze
|
8
|
+
|
9
|
+
HOLD_ATTRS = {
|
10
|
+
transactionType: 'CHARGE',
|
11
|
+
authorizationType: 'SimpleSignature',
|
12
|
+
merchantTransactionType: 'AUTH',
|
13
|
+
merchantTransactionSecureType: 'NON3DS',
|
14
|
+
apiVersion: 1
|
15
|
+
}.freeze
|
16
|
+
|
17
|
+
REFUND_ATTRS = {
|
18
|
+
transactionType: 'REFUND',
|
19
|
+
apiVersion: 1
|
20
|
+
}.freeze
|
21
|
+
|
22
|
+
SETTLE_ATTRS = {
|
23
|
+
transactionType: 'SETTLE',
|
24
|
+
apiVersion: 1
|
25
|
+
}.freeze
|
26
|
+
|
27
|
+
def self.hold_params
|
28
|
+
HOLD_ATTRS.merge(
|
29
|
+
merchantAccount: Wayforpay.merchant_account,
|
30
|
+
merchantDomainName: Wayforpay.merchant_domain_name,
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.refund_params
|
35
|
+
REFUND_ATTRS.merge(merchantAccount: Wayforpay.merchant_account)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.settle_params
|
39
|
+
SETTLE_ATTRS.merge(merchantAccount: Wayforpay.merchant_account)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
|
3
|
+
module Wayforpay
|
4
|
+
class EncryptField
|
5
|
+
attr_reader :keys, :attrs
|
6
|
+
|
7
|
+
def initialize(keys, attrs)
|
8
|
+
@keys, @attrs = keys, attrs
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.call(keys, attrs = {})
|
12
|
+
new(keys, attrs).call
|
13
|
+
end
|
14
|
+
|
15
|
+
def call
|
16
|
+
OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('md5'), Wayforpay.encrypt_secret_key, signature_string)
|
17
|
+
end
|
18
|
+
|
19
|
+
def signature_string
|
20
|
+
attrs.values_at(*keys).compact.join(';')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Wayforpay
|
2
|
+
module Payments
|
3
|
+
# required attrs: orderReference, amount, currency, orderDate,
|
4
|
+
# productName[], productPrice[], productCount[],
|
5
|
+
# (card + expMonth + expYear + cardCvv + cardHolder) or recToken
|
6
|
+
def self.hold(attrs = {})
|
7
|
+
request_params = Constants.hold_params.merge(attrs)
|
8
|
+
Wayforpay::Request.(Constants::HOLD_ENCRYPT_FIELDS, request_params)
|
9
|
+
end
|
10
|
+
|
11
|
+
# required attrs: orderReference, amount, currency, comment
|
12
|
+
def self.refund(attrs = {})
|
13
|
+
request_params = Constants.refund_params.merge(attrs)
|
14
|
+
Wayforpay::Request.(Constants::REFUND_ENCRYPT_FIELDS, request_params)
|
15
|
+
end
|
16
|
+
|
17
|
+
# required attrs: orderReference, amount, currency
|
18
|
+
def self.settle(attrs = {})
|
19
|
+
request_params = Constants.settle_params.merge(attrs)
|
20
|
+
Wayforpay::Request.(Constants::SETTLE_ENCRYPT_FIELDS, request_params)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'net/http'
|
3
|
+
|
4
|
+
module Wayforpay
|
5
|
+
class Request
|
6
|
+
def self.call(encrypted_fields, request_attrs)
|
7
|
+
request_attrs[:merchantSignature] = EncryptField.(encrypted_fields, request_attrs)
|
8
|
+
Net::HTTP.post(Constants::URL, request_attrs.to_json)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Wayforpay
|
2
|
+
module Util
|
3
|
+
class Configuration
|
4
|
+
attr_accessor :merchant_account, :merchant_domain_name, :encrypt_secret_key
|
5
|
+
|
6
|
+
def merchant_account=(value)
|
7
|
+
@merchant_account = value
|
8
|
+
end
|
9
|
+
|
10
|
+
def merchant_domain_name=(value)
|
11
|
+
@merchant_domain_name = value
|
12
|
+
end
|
13
|
+
|
14
|
+
def encrypt_secret_key=(value)
|
15
|
+
@encrypt_secret_key = value
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.setup
|
3
|
+
|
4
|
+
require 'wayforpay'
|
5
|
+
require 'webmock/rspec'
|
6
|
+
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.before(:suite) do
|
9
|
+
WebMock.disable_net_connect!
|
10
|
+
end
|
11
|
+
|
12
|
+
config.after(:suite) do
|
13
|
+
WebMock.allow_net_connect!
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
describe Wayforpay::EncryptField do
|
2
|
+
before do
|
3
|
+
Wayforpay.configure do |config|
|
4
|
+
config.merchant_account = 'merchantAccount'
|
5
|
+
config.merchant_domain_name = 'merchantDomainName'
|
6
|
+
config.encrypt_secret_key = 'secretKey'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '.initialize' do
|
11
|
+
let(:keys) { [:amount] }
|
12
|
+
let(:attrs) { { amount: 123, currency: 'UAH' } }
|
13
|
+
|
14
|
+
subject { described_class.new(keys, attrs) }
|
15
|
+
|
16
|
+
it { expect(subject.keys).to eq keys }
|
17
|
+
it { expect(subject.attrs).to eq attrs }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '.call' do
|
21
|
+
let(:keys) { [:amount] }
|
22
|
+
let(:attrs) { { amount: 1 } }
|
23
|
+
let(:encrypt_field) { described_class.new(keys, attrs) }
|
24
|
+
|
25
|
+
it "receives 'new' method for Wayforpay::EncryptField" do
|
26
|
+
expect(described_class).to receive(:new).with(keys, attrs)
|
27
|
+
.and_return(encrypt_field).once
|
28
|
+
described_class.call(keys, attrs)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "receives 'call' method for any instance of Wayforpay::EncryptField" do
|
32
|
+
expect_any_instance_of(described_class).to receive(:call).once
|
33
|
+
described_class.call(keys, attrs)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#call' do
|
38
|
+
subject { described_class.new(keys, attrs).call }
|
39
|
+
|
40
|
+
context 'in case params are HOLD_ENCRYPT_FIELDS and HOLD_ATTRS' do
|
41
|
+
let(:keys) { Wayforpay::Constants::HOLD_ENCRYPT_FIELDS }
|
42
|
+
let(:attrs) do
|
43
|
+
Wayforpay::Constants.hold_params.merge({
|
44
|
+
orderReference: 'new_order',
|
45
|
+
amount: 1,
|
46
|
+
currency: 'UAH',
|
47
|
+
orderDate: 1514214411,
|
48
|
+
productName: ['TRIP'],
|
49
|
+
productPrice: [123],
|
50
|
+
productCount: [1],
|
51
|
+
recToken: 'recToken'
|
52
|
+
})
|
53
|
+
end
|
54
|
+
|
55
|
+
it { is_expected.to eq '69306842abfb5424508a96674aa7bbaf' }
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'in case params are REFUND_ENCRYPT_FIELDS and REFUND_ATTRS' do
|
59
|
+
let(:keys) { Wayforpay::Constants::REFUND_ENCRYPT_FIELDS }
|
60
|
+
let(:attrs) do
|
61
|
+
Wayforpay::Constants.refund_params.merge({
|
62
|
+
orderReference: 'new_order',
|
63
|
+
amount: 2,
|
64
|
+
currency: 'UAH',
|
65
|
+
comment: 'Cancellation of a trip'
|
66
|
+
})
|
67
|
+
end
|
68
|
+
|
69
|
+
it { is_expected.to eq '41b79af1557e7e84531e2e015f412ce1' }
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'in case params are SETTLE_ENCRYPT_FIELDS and SETTLE_ATTRS' do
|
73
|
+
let(:keys) { Wayforpay::Constants::SETTLE_ENCRYPT_FIELDS }
|
74
|
+
let(:attrs) do
|
75
|
+
Wayforpay::Constants.settle_params.merge({
|
76
|
+
orderReference: 'new_order',
|
77
|
+
amount: 3,
|
78
|
+
currency: 'UAH'
|
79
|
+
})
|
80
|
+
end
|
81
|
+
|
82
|
+
it { is_expected.to eq 'ba9a61da321d53b6a94dadeabf24eccf' }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '#signature_string' do
|
87
|
+
subject { described_class.new(keys, attrs).signature_string }
|
88
|
+
|
89
|
+
context 'in case params are HOLD_ENCRYPT_FIELDS and HOLD_ATTRS' do
|
90
|
+
let(:keys) { Wayforpay::Constants::HOLD_ENCRYPT_FIELDS }
|
91
|
+
let(:attrs) do
|
92
|
+
Wayforpay::Constants.hold_params.merge({
|
93
|
+
orderReference: 'new_order',
|
94
|
+
amount: 1,
|
95
|
+
currency: 'UAH',
|
96
|
+
orderDate: 1514214411,
|
97
|
+
productName: ['TRIP'],
|
98
|
+
productPrice: [123, 987],
|
99
|
+
productCount: [2],
|
100
|
+
recToken: 'recToken'
|
101
|
+
})
|
102
|
+
end
|
103
|
+
|
104
|
+
it { is_expected.to eq 'merchantAccount;merchantDomainName;new_order;1514214411;1;UAH;TRIP;2;123;987' }
|
105
|
+
|
106
|
+
context 'in case any required fields are missing' do
|
107
|
+
before { attrs.delete(:orderDate) }
|
108
|
+
|
109
|
+
it { is_expected.to eq 'merchantAccount;merchantDomainName;new_order;1;UAH;TRIP;2;123;987' }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'in case params are REFUND_ENCRYPT_FIELDS and REFUND_ATTRS' do
|
114
|
+
let(:keys) { Wayforpay::Constants::REFUND_ENCRYPT_FIELDS }
|
115
|
+
let(:attrs) do
|
116
|
+
Wayforpay::Constants.refund_params.merge({
|
117
|
+
orderReference: 'new_order',
|
118
|
+
amount: 2,
|
119
|
+
currency: 'UAH',
|
120
|
+
comment: 'Cancellation of a trip'
|
121
|
+
})
|
122
|
+
end
|
123
|
+
|
124
|
+
it { is_expected.to eq 'merchantAccount;new_order;2;UAH' }
|
125
|
+
|
126
|
+
context 'in case any required fields are missing' do
|
127
|
+
before { attrs.delete(:amount) }
|
128
|
+
|
129
|
+
it { is_expected.to eq 'merchantAccount;new_order;UAH' }
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context 'in case params are SETTLE_ENCRYPT_FIELDS and SETTLE_ATTRS' do
|
134
|
+
let(:keys) { Wayforpay::Constants::SETTLE_ENCRYPT_FIELDS }
|
135
|
+
let(:attrs) do
|
136
|
+
Wayforpay::Constants.settle_params.merge({
|
137
|
+
orderReference: 'new_order',
|
138
|
+
amount: 3,
|
139
|
+
currency: 'UAH'
|
140
|
+
})
|
141
|
+
end
|
142
|
+
|
143
|
+
it { is_expected.to eq 'merchantAccount;new_order;3;UAH' }
|
144
|
+
|
145
|
+
context 'in case any required fields are missing' do
|
146
|
+
before { attrs.delete(:orderReference) }
|
147
|
+
|
148
|
+
it { is_expected.to eq 'merchantAccount;3;UAH' }
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
describe Wayforpay::Payments do
|
2
|
+
context '.hold' do
|
3
|
+
let(:attrs) do
|
4
|
+
{
|
5
|
+
orderReference: 'new_order',
|
6
|
+
amount: 123,
|
7
|
+
currency: 'UAH',
|
8
|
+
orderDate: 1514214411,
|
9
|
+
productName: ['TRIP'],
|
10
|
+
productPrice: [123],
|
11
|
+
productCount: [1],
|
12
|
+
recToken: 'recToken'
|
13
|
+
}
|
14
|
+
end
|
15
|
+
let(:request_params) do
|
16
|
+
Wayforpay::Constants.hold_params.merge(attrs)
|
17
|
+
end
|
18
|
+
let(:encrypt_fields) { Wayforpay::Constants::HOLD_ENCRYPT_FIELDS }
|
19
|
+
|
20
|
+
it "receives 'call' method for Wayforpay::Request" do
|
21
|
+
expect(Wayforpay::Request).to receive(:call)
|
22
|
+
.with(encrypt_fields, request_params).once
|
23
|
+
described_class.hold(attrs)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context '.refund' do
|
28
|
+
let(:attrs) do
|
29
|
+
{
|
30
|
+
orderReference: 'new_order',
|
31
|
+
amount: 123,
|
32
|
+
currency: 'UAH',
|
33
|
+
comment: 'Cancellation of a trip'
|
34
|
+
}
|
35
|
+
end
|
36
|
+
let(:request_params) do
|
37
|
+
Wayforpay::Constants.refund_params.merge(attrs)
|
38
|
+
end
|
39
|
+
let(:encrypt_fields) { Wayforpay::Constants::REFUND_ENCRYPT_FIELDS }
|
40
|
+
|
41
|
+
it "receives 'call' method for Wayforpay::Request" do
|
42
|
+
expect(Wayforpay::Request).to receive(:call)
|
43
|
+
.with(encrypt_fields, request_params).once
|
44
|
+
described_class.refund(attrs)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context '.settle' do
|
49
|
+
let(:attrs) do
|
50
|
+
{
|
51
|
+
orderReference: 'new_order',
|
52
|
+
amount: 123,
|
53
|
+
currency: 'UAH',
|
54
|
+
}
|
55
|
+
end
|
56
|
+
let(:request_params) do
|
57
|
+
Wayforpay::Constants.settle_params.merge(attrs)
|
58
|
+
end
|
59
|
+
let(:encrypt_fields) { Wayforpay::Constants::SETTLE_ENCRYPT_FIELDS }
|
60
|
+
|
61
|
+
it "receives 'call' method for Wayforpay::Request" do
|
62
|
+
expect(Wayforpay::Request).to receive(:call)
|
63
|
+
.with(encrypt_fields, request_params).once
|
64
|
+
described_class.settle(attrs)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
describe Wayforpay::Request do
|
2
|
+
before do
|
3
|
+
Wayforpay.configure do |config|
|
4
|
+
config.merchant_account = 'merchantAccount'
|
5
|
+
config.merchant_domain_name = 'merchantDomainName'
|
6
|
+
config.encrypt_secret_key = 'secretKey'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:url) { Wayforpay::Constants::URL }
|
11
|
+
|
12
|
+
context '.call' do
|
13
|
+
let(:merchant_signature) { Wayforpay::EncryptField.(encrypt_fields, request_attrs) }
|
14
|
+
let(:encrypted_attrs) { request_attrs.merge(merchantSignature: merchant_signature) }
|
15
|
+
|
16
|
+
subject { described_class.call(encrypt_fields, request_attrs) }
|
17
|
+
|
18
|
+
context "hold params" do
|
19
|
+
let(:attrs) do
|
20
|
+
{
|
21
|
+
orderReference: 'new_order',
|
22
|
+
amount: 123,
|
23
|
+
currency: 'UAH',
|
24
|
+
orderDate: 1514214411,
|
25
|
+
productName: ['TRIP'],
|
26
|
+
productPrice: [123],
|
27
|
+
productCount: [1],
|
28
|
+
recToken: 'recToken'
|
29
|
+
}
|
30
|
+
end
|
31
|
+
let(:encrypt_fields) { Wayforpay::Constants::HOLD_ENCRYPT_FIELDS }
|
32
|
+
let(:request_attrs) { Wayforpay::Constants.hold_params.merge(attrs) }
|
33
|
+
|
34
|
+
it "receives 'post' method for Net::HTTP" do
|
35
|
+
expect(Net::HTTP).to receive(:post)
|
36
|
+
.with(url, encrypted_attrs.to_json).once
|
37
|
+
subject
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "refund params" do
|
42
|
+
let(:attrs) do
|
43
|
+
{
|
44
|
+
orderReference: 'new_order',
|
45
|
+
amount: 123,
|
46
|
+
currency: 'UAH',
|
47
|
+
comment: 'Cancellation of a trip'
|
48
|
+
}
|
49
|
+
end
|
50
|
+
let(:encrypt_fields) { Wayforpay::Constants::REFUND_ENCRYPT_FIELDS }
|
51
|
+
let(:request_attrs) { Wayforpay::Constants.refund_params.merge(attrs) }
|
52
|
+
|
53
|
+
it "receives 'post' method for Net::HTTP" do
|
54
|
+
expect(Net::HTTP).to receive(:post)
|
55
|
+
.with(url, encrypted_attrs.to_json).once
|
56
|
+
subject
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "settle params" do
|
61
|
+
let(:attrs) do
|
62
|
+
{
|
63
|
+
orderReference: 'new_order',
|
64
|
+
amount: 123,
|
65
|
+
currency: 'UAH',
|
66
|
+
}
|
67
|
+
end
|
68
|
+
let(:encrypt_fields) { Wayforpay::Constants::SETTLE_ENCRYPT_FIELDS }
|
69
|
+
let(:request_attrs) { Wayforpay::Constants.settle_params.merge(attrs) }
|
70
|
+
|
71
|
+
it "receives 'post' method for Net::HTTP" do
|
72
|
+
expect(Net::HTTP).to receive(:post)
|
73
|
+
.with(url, encrypted_attrs.to_json).once
|
74
|
+
subject
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
describe Wayforpay::Util::Configuration do
|
2
|
+
let(:config) { described_class.new }
|
3
|
+
let(:merchant_account) { 'merchantAccount' }
|
4
|
+
let(:merchant_domain_name) { 'merchantDomainName' }
|
5
|
+
let(:encrypt_secret_key) { 'secretKey' }
|
6
|
+
|
7
|
+
before do
|
8
|
+
config.merchant_account = merchant_account
|
9
|
+
config.merchant_domain_name = merchant_domain_name
|
10
|
+
config.encrypt_secret_key = encrypt_secret_key
|
11
|
+
end
|
12
|
+
|
13
|
+
it { expect(config.merchant_account).to eq(merchant_account) }
|
14
|
+
it { expect(config.merchant_domain_name).to eq(merchant_domain_name) }
|
15
|
+
it { expect(config.encrypt_secret_key).to eq(encrypt_secret_key) }
|
16
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
describe Wayforpay do
|
2
|
+
subject { described_class }
|
3
|
+
|
4
|
+
describe '.configure' do
|
5
|
+
let(:merchant_account) { 'merchantAccount' }
|
6
|
+
let(:merchant_domain_name) { 'merchantDomainName' }
|
7
|
+
let(:encrypt_secret_key) { 'secretKey' }
|
8
|
+
|
9
|
+
before do
|
10
|
+
subject.configure do |config|
|
11
|
+
config.merchant_account = merchant_account
|
12
|
+
config.merchant_domain_name = merchant_domain_name
|
13
|
+
config.encrypt_secret_key = encrypt_secret_key
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
after do
|
18
|
+
subject.instance_variable_set('@configuration', nil)
|
19
|
+
end
|
20
|
+
|
21
|
+
it { expect(subject.merchant_account).to eq(merchant_account) }
|
22
|
+
it { expect(subject.merchant_domain_name).to eq(merchant_domain_name) }
|
23
|
+
it { expect(subject.encrypt_secret_key).to eq(encrypt_secret_key) }
|
24
|
+
end
|
25
|
+
end
|
data/wayforpay.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/wayforpay/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'wayforpay'
|
6
|
+
s.version = Wayforpay::VERSION
|
7
|
+
s.authors = ['Serhii Savenko','Yaroslav Tupitskyi']
|
8
|
+
s.email = ['yarik@active-bridge.com']
|
9
|
+
s.homepage = 'https://github.com/activebridge/wayforpay'
|
10
|
+
s.summary = %q{Wayforpay API}
|
11
|
+
s.description = %q{Wayforpay API}
|
12
|
+
s.platform = Gem::Platform::RUBY
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
16
|
+
s.require_path = 'lib'
|
17
|
+
|
18
|
+
s.required_ruby_version = '>= 2.0.0'
|
19
|
+
|
20
|
+
s.add_dependency 'builder', '>= 2.1.2'
|
21
|
+
|
22
|
+
{
|
23
|
+
'rake' => '~> 0.8.7',
|
24
|
+
'rspec' => '~> 2.12',
|
25
|
+
'webmock' => '~> 1.6.2'
|
26
|
+
}.each { |l, v| s. add_development_dependency l, v }
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wayforpay
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Serhii Savenko
|
8
|
+
- Yaroslav Tupitskyi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2018-01-03 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: builder
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 2.1.2
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 2.1.2
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.8.7
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 0.8.7
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '2.12'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '2.12'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: webmock
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.6.2
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.6.2
|
70
|
+
description: Wayforpay API
|
71
|
+
email:
|
72
|
+
- yarik@active-bridge.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- Gemfile
|
80
|
+
- README.md
|
81
|
+
- lib/wayforpay.rb
|
82
|
+
- lib/wayforpay/constants.rb
|
83
|
+
- lib/wayforpay/encrypt_field.rb
|
84
|
+
- lib/wayforpay/payments.rb
|
85
|
+
- lib/wayforpay/request.rb
|
86
|
+
- lib/wayforpay/util/configuration.rb
|
87
|
+
- lib/wayforpay/version.rb
|
88
|
+
- spec/spec_helper.rb
|
89
|
+
- spec/wayforpay/encrypt_field_spec.rb
|
90
|
+
- spec/wayforpay/payments_spec.rb
|
91
|
+
- spec/wayforpay/request_spec.rb
|
92
|
+
- spec/wayforpay/util/configuration_spec.rb
|
93
|
+
- spec/wayforpay_spec.rb
|
94
|
+
- wayforpay.gemspec
|
95
|
+
homepage: https://github.com/activebridge/wayforpay
|
96
|
+
licenses: []
|
97
|
+
metadata: {}
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 2.0.0
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.6.11
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: Wayforpay API
|
118
|
+
test_files:
|
119
|
+
- spec/spec_helper.rb
|
120
|
+
- spec/wayforpay/encrypt_field_spec.rb
|
121
|
+
- spec/wayforpay/payments_spec.rb
|
122
|
+
- spec/wayforpay/request_spec.rb
|
123
|
+
- spec/wayforpay/util/configuration_spec.rb
|
124
|
+
- spec/wayforpay_spec.rb
|