wirecard_sepa 0.0.2 → 0.0.3

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: 04e43db72ba035b59d9e26101b5c84664fdd745f
4
- data.tar.gz: 2e174adf77802fce273870d8f72a57b7a1cf9cf7
3
+ metadata.gz: aaa93141c612cc1f432a50fe6cab5c7f031bb9f6
4
+ data.tar.gz: 4016372fc3adbf2c6811a98d3f989e66d02b572c
5
5
  SHA512:
6
- metadata.gz: 449083675e209e5aa7956326e0a448a7fb41e444c9ce6b86f18ffaf6dd29cdc0e67862940e6f92e2ef00b7039270004f9a0e71db0d824a525146ade84d7cd8d9
7
- data.tar.gz: 2edcc3b230df93a2cf7e740e70a72a17c180beab3897c7fdda76536d94e4cce13004e819968d1bc1b8ea7f7980a5b3c915d349587f537c080b22ba2492949bfc
6
+ metadata.gz: 9eefb21db2e5e4ba84f62823217b76cef25bf913f063eeea0b06e6a259840704ce250ab16a8ee835706be967cc9b05b78aafa2b00bc92df78cedff45d8ca512c
7
+ data.tar.gz: 58c5db146fea9374f7222c6022744440deac8f56c5f594e7f1ce1984d71e25ad7d016f42f25c320299c0a7117240e90f6dd5e7e77622f4a800b94fd1657d69e4
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [0.0.3] - 2015-06-15
2
+ ### Changed
3
+ - Added Changelog
4
+ - Added Specs for init/processing recurring payments
5
+
data/README.md CHANGED
@@ -5,10 +5,10 @@
5
5
  A WORK IN PROGRESS PROJECT
6
6
 
7
7
  ## TODOS
8
- 1. Error Handling
9
- 1. Maybe cache template files (are they loaded from disk each request?)
10
- 1. Docs for usage in README.md
11
- 1. Check Recurring Request/Response
8
+ - [ ] Error Handling
9
+ - [ ] Maybe cache template files (are they loaded from disk each request?)
10
+ - [ ] Docs for usage in README.md
11
+ - [ ] Check Recurring Request/Response
12
12
 
13
13
  ## Contributing
14
14
  1. Fork it ( https://github.com/betterplace/wirecard_sepa/fork )
@@ -30,31 +30,41 @@ module WirecardSepa
30
30
  end
31
31
 
32
32
  def transaction_id
33
- xml_doc.at_css('transaction-id').text
33
+ value_at 'transaction-id'
34
34
  end
35
35
 
36
36
  def transaction_state
37
- xml_doc.at_css('transaction-state').text
37
+ value_at 'transaction-state'
38
38
  end
39
39
 
40
40
  def status_code
41
- xml_doc.at_css('status')[:code]
41
+ value_at 'status', attribute: :code
42
42
  end
43
43
 
44
44
  def status_description
45
- xml_doc.at_css('status')[:description]
45
+ value_at 'status', attribute: :description
46
46
  end
47
47
 
48
48
  def due_date
49
- xml_doc.at_css('due-date').text
49
+ value_at 'due-date'
50
50
  end
51
51
 
52
52
  def provider_transaction_reference_id
53
- xml_doc.at_css('provider-transaction-reference-id').text
53
+ value_at 'provider-transaction-reference-id'
54
54
  end
55
55
 
56
56
  private
57
57
 
58
+ # Returns the text of a node with the given position. If
59
+ # an additional attribute is given, this attribute is returned
60
+ # instead.
61
+ # This method provides mainly nil-safeness.
62
+ def value_at(position, attribute: nil)
63
+ node = xml_doc.at_css(position)
64
+ node or return
65
+ attribute ? node[attribute] : node.text
66
+ end
67
+
58
68
  def xml_doc
59
69
  @xml_doc ||= Nokogiri::XML xml
60
70
  end
@@ -1,3 +1,3 @@
1
1
  module WirecardSepa
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -6,6 +6,7 @@ describe WirecardSepa::DirectDebit::Response do
6
6
 
7
7
  let(:success_response) { described_class.new success_xml }
8
8
  let(:failure_response) { described_class.new failure_xml }
9
+ let(:empty_response) { described_class.new '<xml/>' }
9
10
 
10
11
  describe '.for_request(request)' do
11
12
  let(:request) { double('Fake Typhoeus request', body: '</xml>') }
@@ -31,15 +32,41 @@ describe WirecardSepa::DirectDebit::Response do
31
32
  it('params[:due_date]') { expect(params[:due_date]).to eq '2013-10-03' }
32
33
  it('params[:reference_id]') { expect(params[:reference_id]).to eq '33F7A4D125' }
33
34
  end
35
+
36
+ context 'for a failed response' do
37
+ let(:params) { failure_response.params }
38
+
39
+ it('params[:transaction_id]') { expect(params[:transaction_id]).to eq '4185215e-250f-11e3-8d4b-005056a97162' }
40
+ it('params[:transaction_state]') { expect(params[:transaction_state]).to eq 'failed' }
41
+ it('params[:status_code]') { expect(params[:status_code]).to eq '400.1007' }
42
+ it('params[:status_description]') { expect(params[:status_description]).to eq 'The account holder information has not been provided. Please check your input and try again. ' }
43
+ it('params[:due_date]') { expect(params[:due_date]).to be_nil }
44
+ it('params[:reference_id]') { expect(params[:reference_id]).to be_nil }
45
+ end
46
+
47
+ context 'for a failed, empty response' do
48
+ let(:params) { empty_response.params }
49
+
50
+ it('params[:transaction_id]') { expect(params[:transaction_id]).to be_nil }
51
+ it('params[:transaction_state]') { expect(params[:transaction_state]).to be_nil }
52
+ it('params[:status_code]') { expect(params[:status_code]).to be_nil }
53
+ it('params[:status_description]') { expect(params[:status_description]).to be_nil }
54
+ it('params[:due_date]') { expect(params[:due_date]).to be_nil }
55
+ it('params[:reference_id]') { expect(params[:reference_id]).to be_nil }
56
+ end
34
57
  end
35
58
 
36
59
  describe '#success?' do
37
60
  it 'returns true for a succesful response' do
38
- expect(success_response.success?).to eq true
61
+ expect(success_response).to be_success
39
62
  end
40
63
 
41
64
  it 'returns false for a failure response' do
42
- expect(failure_response.success?).to eq false
65
+ expect(failure_response).not_to be_success
66
+ end
67
+
68
+ it 'returns false for a malformed, empty response' do
69
+ expect(empty_response).not_to be_success
43
70
  end
44
71
  end
45
72
  end
@@ -1,65 +1,61 @@
1
1
  require 'spec_helper'
2
2
 
3
+ # TODOs
4
+ # [] Record response from wirecard w/ VCR
3
5
  describe WirecardSepa::Gateway do
4
6
  let(:gateway) { described_class.new(sandbox_gateway_config) }
7
+ let(:debit_params) do
8
+ {
9
+ requested_amount: '12.12',
10
+ account_holder_first_name: 'John',
11
+ account_holder_last_name: 'Doe',
12
+ bank_account_iban: 'DE42512308000000060004',
13
+ bank_account_bic: 'WIREDEMMXXX',
14
+ mandate_id: '1235678',
15
+ mandate_signed_date: '2013-09-24',
16
+ }
17
+ end
18
+ let(:recurring_init_params) do
19
+ {
20
+ requested_amount: '15.00',
21
+ account_holder_first_name: 'Bob',
22
+ account_holder_last_name: 'Hawk',
23
+ bank_account_iban: 'DE42512308000000060004',
24
+ bank_account_bic: 'WIREDEMMXXX',
25
+ mandate_id: '2356789',
26
+ mandate_signed_date: '2013-08-11',
27
+ }
28
+ end
5
29
 
6
30
  describe '#debit(params)' do
7
- let(:params) do
8
- {
9
- requested_amount: '12.12',
10
- account_holder_first_name: 'John',
11
- account_holder_last_name: 'Doe',
12
- bank_account_iban: 'DE42512308000000060004',
13
- bank_account_bic: 'WIREDEMMXXX',
14
- mandate_id: '1235678',
15
- mandate_signed_date: '2013-09-24',
16
- }
17
- end
18
-
19
31
  it 'posts the correct XML' do
20
32
  # TODO: Record response from wirecard
21
- response = gateway.debit(params)
22
- # FIXME: For some reason wirecard always returns the following error:
23
- # "The Request Identifier has not been provided. Please check your input and try again."
24
- # Status-Code: 400.1010
25
- # expect(response).to be_success
26
- expect(response.request.headers['Content-Type']).to eq 'application/xml;charset=UTF-8'
33
+ response = gateway.debit(debit_params)
34
+ expect(response).to be_success
35
+ expect(response.params).to_not be_empty
36
+ expect(response.transaction_id).to_not be_empty
27
37
  end
28
38
  end
29
39
 
30
40
  describe '#recurring_init(params)' do
31
- let(:params) do
32
- {
33
- requested_amount: '15.00',
34
- account_holder_first_name: 'Bob',
35
- account_holder_last_name: 'Hawk',
36
- bank_account_iban: 'DE11512308000000060002',
37
- bank_account_bic: 'WIREDEMMXXX',
38
- mandate_id: '2356789',
39
- mandate_signed_date: '2013-08-11',
40
- }
41
- end
42
-
43
41
  it 'posts the correct XML' do
44
- response = gateway.recurring_init(params)
45
- # FIXME: For some reason wirecard always returns the following error:
46
- # "The Request Identifier has not been provided. Please check your input and try again."
47
- # Status-Code: 400.1010
48
- # expect(response).to be_success
42
+ # TODO: Record response from wirecard
43
+ response = gateway.recurring_init(recurring_init_params)
44
+ expect(response).to be_success
45
+ expect(response.params).to_not be_empty
46
+ expect(response.transaction_id).to_not be_empty
49
47
  end
50
48
  end
51
49
 
52
50
  describe '#recurring_process(params)' do
53
- let(:params) do
54
- { parent_transaction_id: 'e6604f91-663c-11e3-a07b-18037336c0b3' }
55
- end
51
+ let(:init_response) { gateway.recurring_init(recurring_init_params) }
52
+ let(:parent_transaction_id) { init_response.transaction_id }
56
53
 
57
54
  it 'posts the correct XML' do
58
- response = gateway.recurring_process(params)
59
- # FIXME: For some reason wirecard always returns the following error:
60
- # "The Request Identifier has not been provided. Please check your input and try again."
61
- # Status-Code: 400.1010
62
- # expect(response).to be_success
55
+ response = gateway.recurring_process({ parent_transaction_id: parent_transaction_id })
56
+ expect(response).to be_success
57
+ expect(response.params).to_not be_empty
58
+ expect(response.transaction_id).to_not be_empty
63
59
  end
64
60
  end
65
61
  end
data/spec/spec_helper.rb CHANGED
@@ -18,7 +18,7 @@ def sandbox_gateway_config
18
18
  http_auth_username: '70000-APITEST-AP',
19
19
  http_auth_password: 'qD2wzQ_hrc!8',
20
20
  merchant_account_id: '4c901196-eff7-411e-82a3-5ef6b6860d64',
21
- creditor_id: 'abcdef',
21
+ creditor_id: 'DE00000000000000000000',
22
22
  })
23
23
  end
24
24
 
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^spec/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "typhoeus"
22
- spec.add_dependency "nokogiri"
21
+ spec.add_dependency "typhoeus", "~> 0.7"
22
+ spec.add_dependency "nokogiri", "~> 1.6"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.7"
25
25
  spec.add_development_dependency "rake", "~> 10.4"
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wirecard_sepa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - betterplace developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-11 00:00:00.000000000 Z
11
+ date: 2015-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '0.7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '0.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '1.6'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '1.6'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -118,6 +118,7 @@ files:
118
118
  - ".gitignore"
119
119
  - ".rspec"
120
120
  - ".travis.yml"
121
+ - CHANGELOG.md
121
122
  - Gemfile
122
123
  - LICENSE
123
124
  - README.md