wayforpay 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ac203bf9298139ac2be3e1cef08eba76fed5bcb5
4
- data.tar.gz: b979a161c53384bd04be7c0b6fa80e2671962d89
3
+ metadata.gz: 94b59dd85af800a1dde176fec4259762dd145224
4
+ data.tar.gz: ad5097ef6a72210c9eec55e877e45746c41bd1b6
5
5
  SHA512:
6
- metadata.gz: 5ddeae517f34a156ce8f9f7e9df02591270f4da7e889a194aeaf504e3bb872573f08ccb9aaabc16e1095c8ba0bcfefbaf54d0d17698a67e50aaef7eabd846040
7
- data.tar.gz: b47f777278907c63dd370acf4880cbefbab53b325d6d71b01286dfd90f72f174915e80511ef199091be2739c1a0b9db108c6e19576a60558b0041f1fa929ef59
6
+ metadata.gz: d81949cdf1452311536554b2f477a86c4341617dded74a8d6dfd80b79a2b74452035adbd4038ae9cb65fd6e06bcc9359eede43836600d9a1b4affe764eea5dd1
7
+ data.tar.gz: 2be5f567bbc2a757414aedc7cc570b7c7ecd15415a2f6028b67d3e890d07766d446bf651e4cae42ada5c50b4d5faf933d867b22565bd0a63b4fd922c58603186
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Active Bridge, LLC
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,25 +1,142 @@
1
+ [![Gem Version](http://img.shields.io/gem/v/wayforpay.svg)](https://rubygems.org/gems/wayforpay)
2
+
1
3
  ## Installation
2
4
 
3
- Add this line to your application's `Gemfile`:
5
+ Add this line to your application's `Gemfile`:
6
+ ```ruby
7
+ gem 'wayforpay'
8
+ ```
9
+ And then execute:
10
+ ```ruby
11
+ $ bundle install
12
+ ```
13
+ Or install it yourself as:
14
+ ```ruby
15
+ $ gem install wayforpay
16
+ ```
4
17
 
5
- gem 'wayforpay'
18
+ ## Documentation
19
+ [Wayforpay API Docs](https://wiki.wayforpay.com/display/WADE/Wayforpay+Api+documentations+ENG)
6
20
 
7
- And then execute:
21
+ ## Usage
8
22
 
9
- $ bundle install
23
+ ```ruby
24
+ require 'wayforpay'
25
+ ```
26
+ Create new file `config/initializers/wayforpay.rb` and put your own credentials here (**required**):
10
27
 
11
- Or install it yourself as:
28
+ ```ruby
29
+ Wayforpay.configure do |config|
30
+ config.merchant_account = 'test_merch_n1' # Seller identifier. This value is assigned to You from the side of WayForPay
31
+ config.merchant_domain_name = 'example.com'
32
+ config.encrypt_secret_key = 'flk3409refn54t54t*FNJRET'
33
+ end
34
+ ```
35
+ Click [here](https://wiki.wayforpay.com/display/WADE/Test+details) for more information.
12
36
 
13
- $ gem install wayforpay
37
+ ## Payments
38
+ ### Blocking money on the payment card ([Hold](https://wiki.wayforpay.com/pages/viewpage.action?pageId=1736987))
14
39
 
15
- ## Usage
40
+ ```ruby
41
+ Wayforpay::Payments.hold(parameters)
42
+ ```
43
+
44
+ Required parameters:
45
+
46
+ | Parameter | Description |
47
+ | ----------------- | ------------------------------------------------------ |
48
+ | orderReference | Unique number of the order in merchant’s system |
49
+ | orderDate | Date of order placing |
50
+ | amount | Amount of refund |
51
+ | currency | Currency of order: UAH (USD, EUR) |
52
+ | productName[] | Array with the names of ordered products |
53
+ | productPrice[] | Array with the prices per product unit |
54
+ | productCount[] | Array with the quantity of ordered goods by each item |
55
+ | *card* | Card number 16 characters |
56
+ | *expMonth* | Card Expiry Date (mounth) - MM |
57
+ | *expYear* | Card Expiry Date (year) - YY |
58
+ | *cardCvv* | Card Security Code CVV / CVV2 |
59
+ | *cardHolder* | Cardholder Name, as indicated on the card |
60
+ | *recToken* | Card token for recarring withdrawals, without client (without reference to card details) |
61
+
62
+ ***Note: fields (card+expMonth+expYear+cardCvv+cardHolder) or recToken should be required.***
63
+
64
+ An example of request:
65
+
66
+ ```ruby
67
+ {
68
+ "orderReference": "myOrder1",
69
+ "orderDate": 1421412898,
70
+ "amount": 0.13,
71
+ "currency": "UAH",
72
+ "card": "4111111111111111",
73
+ "expMonth": "11",
74
+ "expYear": "2020",
75
+ "cardCvv": "111",
76
+ "cardHolder": "TARAS BULBA",
77
+ "productName": ["Samsung WB1100F","Samsung Galaxy Tab 4 7.0 8GB 3G Black"],
78
+ "productPrice": [21.1,30.99],
79
+ "productCount": [1,2]
80
+ }
81
+ ```
82
+
83
+ ### Refund/Cancellation of payment ([Refund](https://wiki.wayforpay.com/pages/viewpage.action?pageId=1736981))
84
+
85
+ ```ruby
86
+ Wayforpay::Payments.refund(parameters)
87
+ ```
16
88
 
17
- TODO: Write usage instructions
89
+ Required parameters:
90
+
91
+ | Parameter | Description |
92
+ | ----------------- | ----------------------------------------------- |
93
+ | orderReference | Unique number of the order in merchant’s system |
94
+ | amount | Amount of refund |
95
+ | currency | Currency of order: UAH |
96
+ | comment | Merchant Comment, Description reversal reason |
18
97
 
98
+ An example of request:
99
+
100
+ ```ruby
101
+ {
102
+ "orderReference": "DH783023",
103
+ "amount": 100,
104
+ "currency": "UAH",
105
+ "comment": "Not in stock"
106
+ }
107
+ ```
108
+
109
+ ### Withdrawal of blocked amount ([Settle](https://wiki.wayforpay.com/pages/viewpage.action?pageId=1736989))
110
+
111
+ ```ruby
112
+ Wayforpay::Payments.settle(parameters)
113
+ ```
114
+
115
+ Required parameters:
116
+
117
+ | Parameter | Description |
118
+ | ----------------- | ----------------------------------------------- |
119
+ | orderReference | Unique number of the order in merchant’s system |
120
+ | amount | The amount of write-offs confirmation |
121
+ | currency | Write-off currency |
122
+
123
+ An example of request:
124
+
125
+ ```ruby
126
+ {
127
+ "orderReference": "DH783023",
128
+ "amount": 100 ,
129
+ "currency": "UAH"
130
+ }
131
+ ```
19
132
  ## Contributing
20
133
 
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
134
+ 1. Fork it
135
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
136
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
137
+ 4. Push to the branch (`git push origin my-new-feature`)
138
+ 5. Create new Pull Request
139
+
140
+ ## Copyright
141
+
142
+ Copyright (c) 2018 Active Bridge, LLC. See LICENSE for details.
@@ -1,3 +1,3 @@
1
1
  module Wayforpay
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
@@ -1,27 +1,33 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/wayforpay/version', __FILE__)
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'wayforpay/version'
3
5
 
4
6
  Gem::Specification.new do |s|
5
7
  s.name = 'wayforpay'
6
8
  s.version = Wayforpay::VERSION
7
9
  s.authors = ['Serhii Savenko','Yaroslav Tupitskyi']
8
10
  s.email = ['yarik@active-bridge.com']
9
- s.homepage = 'https://github.com/activebridge/wayforpay'
10
11
  s.summary = %q{Wayforpay API}
11
12
  s.description = %q{Wayforpay API}
13
+ s.homepage = 'https://github.com/activebridge/wayforpay'
14
+ s.license = 'MIT'
12
15
  s.platform = Gem::Platform::RUBY
13
16
 
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
+ s.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ s.bindir = 'exe'
21
+ s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ s.require_paths = ['lib']
17
23
 
18
24
  s.required_ruby_version = '>= 2.0.0'
19
25
 
20
- s.add_dependency 'builder', '>= 2.1.2'
26
+ s.add_dependency 'builder', '>= 1.14'
21
27
 
22
28
  {
23
- 'rake' => '~> 0.8.7',
24
- 'rspec' => '~> 2.12',
29
+ 'rake' => '~> 10.0',
30
+ 'rspec' => '~> 3.0',
25
31
  'webmock' => '~> 1.6.2'
26
32
  }.each { |l, v| s. add_development_dependency l, v }
27
33
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wayforpay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serhii Savenko
8
8
  - Yaroslav Tupitskyi
9
9
  autorequire:
10
- bindir: bin
10
+ bindir: exe
11
11
  cert_chain: []
12
- date: 2018-01-03 00:00:00.000000000 Z
12
+ date: 2018-01-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: builder
@@ -17,42 +17,42 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 2.1.2
20
+ version: '1.14'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 2.1.2
27
+ version: '1.14'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: 0.8.7
34
+ version: '10.0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: 0.8.7
41
+ version: '10.0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rspec
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '2.12'
48
+ version: '3.0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '2.12'
55
+ version: '3.0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: webmock
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -77,6 +77,7 @@ files:
77
77
  - ".gitignore"
78
78
  - ".rspec"
79
79
  - Gemfile
80
+ - LICENSE.txt
80
81
  - README.md
81
82
  - lib/wayforpay.rb
82
83
  - lib/wayforpay/constants.rb
@@ -85,15 +86,10 @@ files:
85
86
  - lib/wayforpay/request.rb
86
87
  - lib/wayforpay/util/configuration.rb
87
88
  - 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
89
  - wayforpay.gemspec
95
90
  homepage: https://github.com/activebridge/wayforpay
96
- licenses: []
91
+ licenses:
92
+ - MIT
97
93
  metadata: {}
98
94
  post_install_message:
99
95
  rdoc_options: []
@@ -115,10 +111,4 @@ rubygems_version: 2.6.11
115
111
  signing_key:
116
112
  specification_version: 4
117
113
  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
114
+ test_files: []
@@ -1,15 +0,0 @@
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
@@ -1,152 +0,0 @@
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
@@ -1,67 +0,0 @@
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
@@ -1,78 +0,0 @@
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
@@ -1,16 +0,0 @@
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
@@ -1,25 +0,0 @@
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