payzen 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/payzen.rb +29 -0
- data/lib/payzen/config.rb +49 -0
- data/lib/payzen/payment_response.rb +96 -0
- data/lib/payzen/version.rb +3 -0
- data/spec/payment_response_spec.rb +100 -0
- data/spec/payzen_spec.rb +45 -0
- data/spec/spec_helper.rb +44 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 68a983c08a51b2596788c38b8d9515c6e7c43ca7
|
4
|
+
data.tar.gz: a5792ae9e903a625eeadd64b97db28503e484d4d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 865e0a69218ba765a5eb14b9a73012c606adf1100f063237ba97835765fec830ac5ef0c5b2f23b5578e042a40ee33d60c5298673942bb6a4a088583eef337ae8
|
7
|
+
data.tar.gz: 953121e243bfc375021823cca5c715fc1df7f5d3541f0549a24e4e87a6c6a014c90279db281c1fe2925bef6c3609978c4c7a77b0dddb6eb680a5562e4507d530
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Wizypay
|
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,41 @@
|
|
1
|
+
# Payzen
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/payzen`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'payzen'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install payzen
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
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`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/payzen.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "payzen"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/payzen.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'payzen/version'
|
2
|
+
require 'digest/sha1'
|
3
|
+
require 'json'
|
4
|
+
require 'active_support/all'
|
5
|
+
|
6
|
+
module Payzen
|
7
|
+
autoload :Config, 'payzen/config'
|
8
|
+
autoload :PaymentResponse, 'payzen/payment_response'
|
9
|
+
|
10
|
+
cattr_accessor(:config)
|
11
|
+
|
12
|
+
def self.setup
|
13
|
+
self.config ||= Config.new
|
14
|
+
yield config
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.transaction(params)
|
18
|
+
params = config.vads_params.merge(params)
|
19
|
+
signature = signature(params)
|
20
|
+
params[:signature] = signature
|
21
|
+
params
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.signature(params)
|
25
|
+
string_to_hash = (params.select { |k, v| v && k.to_s.start_with?('vads_') }.
|
26
|
+
sort_by(&:first).map(&:second) << config.certificate).join('+')
|
27
|
+
Digest::SHA1.hexdigest(string_to_hash)
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Payzen
|
2
|
+
class Config
|
3
|
+
DEFAULTS = {
|
4
|
+
target_url: 'https://secure.payzen.eu/vads-payment/',
|
5
|
+
vads_action_mode: 'INTERACTIVE',
|
6
|
+
vads_ctx_mode: 'TEST',
|
7
|
+
vads_contrib: 'Wizypay',
|
8
|
+
vads_page_action: 'PAYMENT',
|
9
|
+
vads_return_mode: 'POST',
|
10
|
+
vads_version: 'V2',
|
11
|
+
vads_payment_config: 'SINGLE',
|
12
|
+
vads_currency: '978',
|
13
|
+
vads_language: 'fr',
|
14
|
+
# INTERACTIVE: card information entered in Systempay payment page
|
15
|
+
# SILENT: card info captured in merchant's site (contract option)
|
16
|
+
# or 'PRODUCTION'
|
17
|
+
# or 'GET', but request in GET could be too large
|
18
|
+
# 978 EUR; 840 USD'
|
19
|
+
}.freeze
|
20
|
+
|
21
|
+
attr_accessor :certificate,
|
22
|
+
:target_url,
|
23
|
+
:vads_action_mode,
|
24
|
+
:vads_contrib,
|
25
|
+
:vads_ctx_mode,
|
26
|
+
:vads_currency,
|
27
|
+
:vads_language,
|
28
|
+
:vads_page_action,
|
29
|
+
:vads_payment_config,
|
30
|
+
:vads_return_mode,
|
31
|
+
:vads_shop_name,
|
32
|
+
:vads_shop_url,
|
33
|
+
:vads_site_id,
|
34
|
+
:vads_validation_mode,
|
35
|
+
:vads_version
|
36
|
+
|
37
|
+
def initialize
|
38
|
+
DEFAULTS.each do |k, v|
|
39
|
+
send("#{k}=", v)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def vads_params
|
44
|
+
Hash[instance_variables.
|
45
|
+
select { |v| v.to_s.starts_with? '@vads_' }.
|
46
|
+
map { |v| [v[1..-1].to_sym, instance_variable_get(v)] }]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
module Payzen
|
2
|
+
class PaymentResponse
|
3
|
+
|
4
|
+
def self.fractional_payment(params, ext_trans_id, gc_brand, gc_debits, amount, cc_debit, status='CAPTURED')
|
5
|
+
result = { vads_amount: amount,
|
6
|
+
vads_effective_amount: amount,
|
7
|
+
vads_card_brand: 'MULTI',
|
8
|
+
vads_payment_seq: {trans_id: params[:vads_trans_id], transactions: []} }
|
9
|
+
gc_debits.each_with_index do |debit, i|
|
10
|
+
transaction = {
|
11
|
+
amount: to_cents(debit['amount']),
|
12
|
+
operation_type: 'DEBIT',
|
13
|
+
capture_delay: '0',
|
14
|
+
card_brand: gc_brand,
|
15
|
+
card_number: debit['code'],
|
16
|
+
payment_certificate: '',
|
17
|
+
presentation_date: params[:vads_trans_date],
|
18
|
+
ext_trans_id: ext_trans_id,
|
19
|
+
sequence_number: i+1,
|
20
|
+
trans_id: params[:vads_trans_id],
|
21
|
+
trans_status: status}
|
22
|
+
result[:vads_payment_seq][:transactions].push(transaction)
|
23
|
+
end
|
24
|
+
if cc_debit
|
25
|
+
cc_debit[:sequence_number] = result[:vads_payment_seq][:transactions].size+1
|
26
|
+
result[:vads_payment_seq][:transactions].push(cc_debit)
|
27
|
+
end
|
28
|
+
result[:vads_payment_seq] = result[:vads_payment_seq].to_json
|
29
|
+
response = params.merge(result)
|
30
|
+
response.reject!{|k, v| k == :vads_card_number || k == :vads_expiry_month || k == :vads_expiry_year || k == :vads_bank_code ||
|
31
|
+
k == :vads_bank_product || k == :vads_card_country}
|
32
|
+
response[:signature] = Payzen.signature(response)
|
33
|
+
response
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.response_without_psp(params, ext_trans_id, gc_brand, gc_debits, status='CAPTURED')
|
37
|
+
if gc_debits.empty?
|
38
|
+
return params
|
39
|
+
end
|
40
|
+
if (gc_debits.size > 1)
|
41
|
+
result = fractional_payment(params, ext_trans_id, gc_brand, gc_debits, params[:vads_amount], nil, status)
|
42
|
+
else
|
43
|
+
result = { vads_amount: params[:vads_amount],
|
44
|
+
vads_effective_amount: params[:vads_amount],
|
45
|
+
vads_presentation_date: params[:vads_trans_date],
|
46
|
+
vads_effective_creation_date: params[:vads_trans_date],
|
47
|
+
vads_warranty_result: 'NO',
|
48
|
+
vads_validation_mode: '0',
|
49
|
+
vads_card_brand: gc_brand,
|
50
|
+
vads_card_number: gc_debits[0]['code'],
|
51
|
+
vads_trans_status: status,
|
52
|
+
vads_capture_delay: '0',
|
53
|
+
vads_auth_mode: 'FULL',
|
54
|
+
vads_auth_number: '',
|
55
|
+
vads_auth_result: '00',
|
56
|
+
vads_threeds_enrolled: '',
|
57
|
+
vads_threeds_status: '',
|
58
|
+
vads_sequence_number: '1',
|
59
|
+
vads_ext_trans_id: ext_trans_id,
|
60
|
+
vads_operation_type: 'DEBIT',
|
61
|
+
vads_payment_certificate: '',
|
62
|
+
vads_card_country: 'FR',
|
63
|
+
vads_result: '00',
|
64
|
+
vads_language: 'fr'}
|
65
|
+
result = params.merge(result)
|
66
|
+
result[:signature] = Payzen.signature(result)
|
67
|
+
end
|
68
|
+
result
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.response_with_psp(params, ext_trans_id, gc_brand, gc_debits, coupon_amount)
|
72
|
+
if gc_debits.nil? || gc_debits.empty?
|
73
|
+
return params
|
74
|
+
end
|
75
|
+
payment_seq = { amount: params[:vads_amount],
|
76
|
+
operation_type: params[:vads_operation_type],
|
77
|
+
auth_number: params[:vads_auth_number],
|
78
|
+
capture_delay: params[:vads_capture_delay],
|
79
|
+
card_brand: params[:vads_card_brand],
|
80
|
+
card_number: params[:vads_card_number],
|
81
|
+
expiry_month: params[:vads_expiry_month],
|
82
|
+
expiry_year: params[:vads_expiry_year],
|
83
|
+
payment_certificate: params[:vads_payment_certificate],
|
84
|
+
presentation_date: params[:vads_trans_date],
|
85
|
+
trans_id: params[:vads_trans_id],
|
86
|
+
trans_status: params[:vads_trans_status] }
|
87
|
+
fractional_payment(params, ext_trans_id, gc_brand, gc_debits, (params[:vads_amount].to_i + to_cents(coupon_amount)).to_s, payment_seq)
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def self.to_cents(str)
|
93
|
+
(str.to_f * 100).to_i
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Payzen::PaymentResponse do
|
4
|
+
let(:params) do
|
5
|
+
params = {vads_action_mode: 'INTERACTIVE',
|
6
|
+
vads_ctx_mode: 'TEST',
|
7
|
+
vads_contrib: 'Wizypay',
|
8
|
+
vads_page_action: 'PAYMENT',
|
9
|
+
vads_return_mode: 'POST',
|
10
|
+
vads_version: 'V2',
|
11
|
+
vads_currency: '978',
|
12
|
+
vads_language: 'fr',
|
13
|
+
vads_site_id: '84197771',
|
14
|
+
vads_payment_config: 'SINGLE',
|
15
|
+
vads_trans_date: '20150722135629',
|
16
|
+
vads_trans_id: '741418',
|
17
|
+
vads_amount: '5000',
|
18
|
+
vads_order_id: '741418',
|
19
|
+
vads_cust_id: '3000',
|
20
|
+
signature: '8d56ef75763dec4bad4257a6e726cc1015129157'}
|
21
|
+
Payzen.setup do |config|
|
22
|
+
end
|
23
|
+
params
|
24
|
+
end
|
25
|
+
|
26
|
+
let (:result_base) do
|
27
|
+
result_base = {vads_action_mode: 'INTERACTIVE', vads_ctx_mode:'TEST',
|
28
|
+
vads_contrib:'Wizypay', vads_page_action:'PAYMENT',
|
29
|
+
vads_return_mode:'POST', vads_version:'V2',
|
30
|
+
vads_currency:'978', vads_language:'fr',
|
31
|
+
vads_site_id:'84197771', vads_payment_config:'SINGLE',
|
32
|
+
vads_trans_date:'20150722135629', vads_trans_id:'741418',
|
33
|
+
vads_amount:'5000', vads_order_id:'741418',
|
34
|
+
vads_cust_id:'3000', vads_effective_amount:'5000'}
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#response_without_psp' do
|
38
|
+
it 'retuns params if debit is empty' do
|
39
|
+
result = Payzen::PaymentResponse.response_without_psp(params, '111111', 'Wizypay', [])
|
40
|
+
expect(result).to eql params
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'retuns a simple response if only one card has been used' do
|
44
|
+
result = {signature:'7cbd634540357f418822840e3c15213d71398145',
|
45
|
+
vads_presentation_date:'20150722135629',
|
46
|
+
vads_effective_creation_date:'20150722135629', vads_warranty_result:'NO',
|
47
|
+
vads_validation_mode:'0', vads_card_brand:'Wizypay',
|
48
|
+
vads_card_number:'ABCD', vads_trans_status:'CAPTURED',
|
49
|
+
vads_capture_delay:'0', vads_auth_mode:'FULL',
|
50
|
+
vads_auth_number:'', vads_auth_result:'00',
|
51
|
+
vads_threeds_enrolled:'', vads_threeds_status:'',
|
52
|
+
vads_sequence_number:'1', vads_ext_trans_id:'1',
|
53
|
+
vads_operation_type:'DEBIT', vads_payment_certificate:'',
|
54
|
+
vads_card_country:'FR', vads_result:'00'}
|
55
|
+
result = result_base.merge(result)
|
56
|
+
expect(Payzen::PaymentResponse.response_without_psp(params, '1', 'Wizypay', [{'code'=> 'ABCD'}])).to eql result
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'returns a fractional_payment if multiple debits' do
|
60
|
+
result = {signature: "5c0621391fd667deb7f388d3c450a1ee3b560654",vads_card_brand: "MULTI",
|
61
|
+
vads_payment_seq: "{\"trans_id\":\"741418\",\"transactions\":[{\"amount\":300000,\"operation_type\":\"DEBIT\",\"capture_delay\":\"0\",\"card_brand\":\"Wizypay\",\"card_number\":\"ABCD\",\"payment_certificate\":\"\",\"presentation_date\":\"20150722135629\",\"ext_trans_id\":\"1\",\"sequence_number\":1,\"trans_id\":\"741418\",\"trans_status\":\"CAPTURED\"},{\"amount\":200000,\"operation_type\":\"DEBIT\",\"capture_delay\":\"0\",\"card_brand\":\"Wizypay\",\"card_number\":\"EFGH\",\"payment_certificate\":\"\",\"presentation_date\":\"20150722135629\",\"ext_trans_id\":\"1\",\"sequence_number\":2,\"trans_id\":\"741418\",\"trans_status\":\"CAPTURED\"}]}"}
|
62
|
+
result = result_base.merge(result)
|
63
|
+
response = Payzen::PaymentResponse.response_without_psp(params, '1', 'Wizypay', [{'code'=> 'ABCD', 'amount'=> '3000'}, {'code'=>'EFGH', 'amount'=>'2000'}])
|
64
|
+
expect(response).to eql result
|
65
|
+
end
|
66
|
+
|
67
|
+
it "returns CANCELED" do
|
68
|
+
expect(Payzen::PaymentResponse.response_without_psp(params, '1', 'Wizypay', [{'code'=> 'ABCD'}], 'CANCELED')[:vads_trans_status]).to eql 'CANCELED'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "#response_with_psp" do
|
73
|
+
it "returns params if debits is nil" do
|
74
|
+
expect(Payzen::PaymentResponse.response_with_psp(params, '90000', 'Wizypay', nil, '4000')).to eql params
|
75
|
+
end
|
76
|
+
|
77
|
+
it "returns a fractional response" do
|
78
|
+
result = {signature: "47fd7bb9ecdfc8cbbba23c1e639e95a8748963d3",
|
79
|
+
vads_effective_amount: '10000', vads_amount: '10000',
|
80
|
+
vads_operation_type: "DEBIT", vads_auth_number: "00",
|
81
|
+
vads_capture_delay: "0", vads_card_brand: "MULTI",
|
82
|
+
vads_payment_certificate: "1a2154678f456d44c1d54vs6488s",
|
83
|
+
vads_trans_status: "AUTHORISED",
|
84
|
+
vads_payment_seq: "{\"trans_id\":\"741418\",\"transactions\":[{\"amount\":2500,\"operation_type\":\"DEBIT\",\"capture_delay\":\"0\",\"card_brand\":\"Wizypay\",\"card_number\":\"ABCD\",\"payment_certificate\":\"\",\"presentation_date\":\"20150722135629\",\"ext_trans_id\":\"90000\",\"sequence_number\":1,\"trans_id\":\"741418\",\"trans_status\":\"CAPTURED\"},{\"amount\":2500,\"operation_type\":\"DEBIT\",\"capture_delay\":\"0\",\"card_brand\":\"Wizypay\",\"card_number\":\"EFGH\",\"payment_certificate\":\"\",\"presentation_date\":\"20150722135629\",\"ext_trans_id\":\"90000\",\"sequence_number\":2,\"trans_id\":\"741418\",\"trans_status\":\"CAPTURED\"},{\"amount\":\"5000\",\"operation_type\":\"DEBIT\",\"auth_number\":\"00\",\"capture_delay\":\"0\",\"card_brand\":\"CB\",\"card_number\":\"123456789\",\"expiry_month\":\"\",\"expiry_year\":\"\",\"payment_certificate\":\"1a2154678f456d44c1d54vs6488s\",\"presentation_date\":\"20150722135629\",\"trans_id\":\"741418\",\"trans_status\":\"AUTHORISED\",\"sequence_number\":3}]}"}
|
85
|
+
payment = {vads_operation_type: 'DEBIT',
|
86
|
+
vads_auth_number: '00',
|
87
|
+
vads_capture_delay: '0',
|
88
|
+
vads_card_brand: 'CB',
|
89
|
+
vads_card_number: '123456789',
|
90
|
+
vads_expiry_month: '',
|
91
|
+
vads_expiry_year: '',
|
92
|
+
vads_payment_certificate: '1a2154678f456d44c1d54vs6488s',
|
93
|
+
vads_trans_status: 'AUTHORISED'}
|
94
|
+
payment = params.merge(payment)
|
95
|
+
result = result_base.merge(result)
|
96
|
+
response = Payzen::PaymentResponse.response_with_psp(payment, '90000', 'Wizypay', [{'code'=> 'ABCD', 'amount'=> '25'}, {'code'=>'EFGH', 'amount'=>'25'}], '50')
|
97
|
+
expect(response).to eql result
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
data/spec/payzen_spec.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Payzen do
|
4
|
+
let(:params) do
|
5
|
+
@params = {vads_action_mode: 'INTERACTIVE',
|
6
|
+
vads_ctx_mode: 'TEST',
|
7
|
+
vads_contrib: 'Wizypay',
|
8
|
+
vads_page_action: 'PAYMENT',
|
9
|
+
vads_return_mode: 'POST',
|
10
|
+
vads_version: 'V2',
|
11
|
+
vads_currency: '978',
|
12
|
+
vads_language: 'fr',
|
13
|
+
vads_site_id: '84197771',
|
14
|
+
vads_payment_config: 'SINGLE',
|
15
|
+
vads_trans_date: '20150722135629',
|
16
|
+
vads_trans_id: '741418',
|
17
|
+
vads_amount: '5000',
|
18
|
+
vads_order_id: '741418',
|
19
|
+
vads_cust_id: '3000',
|
20
|
+
signature: '8d56ef75763dec4bad4257a6e726cc1015129157'}
|
21
|
+
Payzen.setup do |config|
|
22
|
+
end
|
23
|
+
@params
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#transaction' do
|
27
|
+
before :each do
|
28
|
+
param = {vads_site_id: '84197771',
|
29
|
+
vads_trans_date: '20150722135629',
|
30
|
+
vads_trans_id: '741418',
|
31
|
+
vads_amount: '5000',
|
32
|
+
vads_order_id: '741418',
|
33
|
+
vads_cust_id: '3000'}
|
34
|
+
@payment = Payzen.transaction(param)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'returns the right signature' do
|
38
|
+
expect(Payzen.signature(params)).to eql '8d56ef75763dec4bad4257a6e726cc1015129157'
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'retuns new @params' do
|
42
|
+
expect(@payment).to eql params
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'payzen'
|
2
|
+
require 'payzen/payment_response'
|
3
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
4
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
5
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
6
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
7
|
+
# files.
|
8
|
+
#
|
9
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
10
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
11
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
12
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
13
|
+
# a separate helper file that requires the additional dependencies and performs
|
14
|
+
# the additional setup, and require it from the spec files that actually need
|
15
|
+
# it.
|
16
|
+
#
|
17
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
18
|
+
# users commonly want.
|
19
|
+
#
|
20
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
21
|
+
RSpec.configure do |config|
|
22
|
+
# rspec-expectations config goes here. You can use an alternate
|
23
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
24
|
+
# assertions if you prefer.
|
25
|
+
config.expect_with :rspec do |expectations|
|
26
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
27
|
+
# and `failure_message` of custom matchers include text for helper methods
|
28
|
+
# defined using `chain`, e.g.:
|
29
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
30
|
+
# # => "be bigger than 2 and smaller than 4"
|
31
|
+
# ...rather than:
|
32
|
+
# # => "be bigger than 2"
|
33
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
34
|
+
end
|
35
|
+
|
36
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
37
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
38
|
+
config.mock_with :rspec do |mocks|
|
39
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
40
|
+
# a real object. This is generally recommended, and will default to
|
41
|
+
# `true` in RSpec 4.
|
42
|
+
mocks.verify_partial_doubles = true
|
43
|
+
end
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: payzen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Benjamin BALANGER
|
8
|
+
- Chaker NAKHLI
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-07-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: activesupport
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: bundler
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.10'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.10'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '10.0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '10.0'
|
70
|
+
description:
|
71
|
+
email:
|
72
|
+
- benjamin@wizypay.com
|
73
|
+
- chaker@wizypay.com
|
74
|
+
executables: []
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- bin/console
|
82
|
+
- bin/setup
|
83
|
+
- lib/payzen.rb
|
84
|
+
- lib/payzen/config.rb
|
85
|
+
- lib/payzen/payment_response.rb
|
86
|
+
- lib/payzen/version.rb
|
87
|
+
- spec/payment_response_spec.rb
|
88
|
+
- spec/payzen_spec.rb
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
homepage: http://www.wizypay.com
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 2.0.0
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.4.8
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Payzen payment form generator
|
114
|
+
test_files:
|
115
|
+
- spec/payment_response_spec.rb
|
116
|
+
- spec/payzen_spec.rb
|
117
|
+
- spec/spec_helper.rb
|