barzahlen 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,99 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Barzahlen::Api::Online::ResponseParser do
6
- it 'should return correct hash when passing transaction-create-xml' do
7
- xml = '<response>
8
- <transaction-id>227840174</transaction-id>
9
- <payment-slip-link>https://cdn.barzahlen.de/slip/227840174/c91dc292bdb8f0ba1a83c738119ef13e652a43b8a8f261cf93d3bfbf233d7da2/Zahlschein_Barzahlen_227840174.pdf</payment-slip-link>
10
- <expiration-notice>Der Zahlschein ist 2 Wochen gültig.</expiration-notice>
11
- <infotext-1>Text mit einem &lt;a href="http://www.barzahlen.de" target="_blank"&gt;Link&lt;/a&gt;</infotext-1>
12
- <infotext-2>Text mit einem &lt;a href="http://www.barzahlen.de" target="_blank"&gt;Link&lt;/a&gt;</infotext-2>
13
- <result>0</result>
14
- <hash>c5422fbcbaba04d65598cd847f2f91b1a18c6b0dc5eab927302affe235e6c37976307e23eef645b43b13c7d3cfbbbca9349247449a49b8aebcdd9b0a2554a893</hash>
15
- </response>'
16
-
17
- result = Barzahlen::Api::Online::ResponseParser.parse xml
18
-
19
- result.should == {
20
- :transaction_id => '227840174',
21
- :payment_slip_link => 'https://cdn.barzahlen.de/slip/227840174/c91dc292bdb8f0ba1a83c738119ef13e652a43b8a8f261cf93d3bfbf233d7da2/Zahlschein_Barzahlen_227840174.pdf',
22
- :expiration_notice => 'Der Zahlschein ist 2 Wochen gültig.',
23
- :infotext_1 => 'Text mit einem <a href="http://www.barzahlen.de" target="_blank">Link</a>',
24
- :infotext_2 => 'Text mit einem <a href="http://www.barzahlen.de" target="_blank">Link</a>',
25
- :result => '0',
26
- :hash => 'c5422fbcbaba04d65598cd847f2f91b1a18c6b0dc5eab927302affe235e6c37976307e23eef645b43b13c7d3cfbbbca9349247449a49b8aebcdd9b0a2554a893'
27
- }
28
- end
29
-
30
- it 'should return correct hash when passing transaction-update-xml' do
31
- xml = '<?xml version="1.0" encoding="UTF-8"?>
32
- <response>
33
- <transaction-id>227840174</transaction-id>
34
- <result>0</result>
35
- <hash>0714be1522e16fe67f397767c98cf37e37fd9c2a5391f49f8b01cb66642150751c77a0cce1ef7268e7bdeee792ed63eab53ef9b860f721c9d9d47ffc871ee3f9</hash>
36
- </response>'
37
-
38
- result = Barzahlen::Api::Online::ResponseParser.parse xml
39
-
40
- result.should == {
41
- :transaction_id => '227840174',
42
- :result => '0',
43
- :hash => '0714be1522e16fe67f397767c98cf37e37fd9c2a5391f49f8b01cb66642150751c77a0cce1ef7268e7bdeee792ed63eab53ef9b860f721c9d9d47ffc871ee3f9'
44
- }
45
- end
46
-
47
- it 'should return correct hash when passing transaction-resend-email-xml' do
48
- xml = '<?xml version="1.0" encoding="UTF-8"?>
49
- <response>
50
- <transaction-id>227840174</transaction-id>
51
- <result>0</result>
52
- <hash>0714be1522e16fe67f397767c98cf37e37fd9c2a5391f49f8b01cb66642150751c77a0cce1ef7268e7bdeee792ed63eab53ef9b860f721c9d9d47ffc871ee3f9</hash>
53
- </response>'
54
-
55
- result = Barzahlen::Api::Online::ResponseParser.parse xml
56
-
57
- result.should == {
58
- :transaction_id => '227840174',
59
- :result => '0',
60
- :hash => '0714be1522e16fe67f397767c98cf37e37fd9c2a5391f49f8b01cb66642150751c77a0cce1ef7268e7bdeee792ed63eab53ef9b860f721c9d9d47ffc871ee3f9'
61
- }
62
- end
63
-
64
- it 'should return correct hash when passing transaction-cancel-xml' do
65
- xml = '<?xml version="1.0" encoding="UTF-8"?>
66
- <response>
67
- <transaction-id>227840174</transaction-id>
68
- <result>0</result>
69
- <hash>0714be1522e16fe67f397767c98cf37e37fd9c2a5391f49f8b01cb66642150751c77a0cce1ef7268e7bdeee792ed63eab53ef9b860f721c9d9d47ffc871ee3f9</hash>
70
- </response>'
71
-
72
- result = Barzahlen::Api::Online::ResponseParser.parse xml
73
-
74
- result.should == {
75
- :transaction_id => '227840174',
76
- :result => '0',
77
- :hash => '0714be1522e16fe67f397767c98cf37e37fd9c2a5391f49f8b01cb66642150751c77a0cce1ef7268e7bdeee792ed63eab53ef9b860f721c9d9d47ffc871ee3f9'
78
- }
79
- end
80
-
81
- it 'should return correct hash when passing transaction-refund-xml' do
82
- xml = '<?xml version="1.0" encoding="UTF-8"?>
83
- <response>
84
- <origin-transaction-id>22780174</origin-transaction-id>
85
- <refund-transaction-id>22791842</refund-transaction-id>
86
- <result>0</result>
87
- <hash>0714be1522e16fe67f397767c98cf37e37fd9c2a5391f49f8b01cb66642150751c77a0cce1ef7268e7bdeee792ed63eab53ef9b860f721c9d9d47ffc871ee3f9</hash>
88
- </response>'
89
-
90
- result = Barzahlen::Api::Online::ResponseParser.parse xml
91
-
92
- result.should == {
93
- :origin_transaction_id => '22780174',
94
- :refund_transaction_id => '22791842',
95
- :result => '0',
96
- :hash => '0714be1522e16fe67f397767c98cf37e37fd9c2a5391f49f8b01cb66642150751c77a0cce1ef7268e7bdeee792ed63eab53ef9b860f721c9d9d47ffc871ee3f9'
97
- }
98
- end
99
- end
@@ -1,108 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'spec_helper'
4
- require 'net/http'
5
-
6
- describe Barzahlen::Api::Online::Transaction do
7
- context 'create' do
8
- it 'should send correct request to api' do
9
- api = create_api
10
- api.should_receive(:request)
11
- .with('v1/transactions/create', :payment_key,
12
- [:shop_id, :customer_email, :amount, :currency, :language, :order_id, :customer_street_nr,
13
- :customer_zipcode, :customer_city, :customer_country, :custom_var_0, :custom_var_1, :custom_var_2,
14
- :payment_key],
15
- :customer_email => 'barzahlen@example.com',
16
- :amount => '13.37',
17
- :currency => 'EUR',
18
- :order_id => '123',
19
- :customer_street_nr => 'Wallstr. 14a',
20
- :customer_zipcode => '10179',
21
- :customer_city => 'Berlin',
22
- :customer_country => 'DE',
23
- :customer_custom_var_0 => 'customer_custom_var_0',
24
- :customer_custom_var_1 => 'customer_custom_var_1',
25
- :customer_custom_var_2 => 'customer_custom_var_2',)
26
-
27
- transaction = Barzahlen::Api::Online::Transaction.new api
28
- transaction.create(:customer_email => 'barzahlen@example.com',
29
- :amount => '13.37',
30
- :currency => 'EUR',
31
- :order_id => '123',
32
- :customer_street_nr => 'Wallstr. 14a',
33
- :customer_zipcode => '10179',
34
- :customer_city => 'Berlin',
35
- :customer_country => 'DE',
36
- :customer_custom_var_0 => 'customer_custom_var_0',
37
- :customer_custom_var_1 => 'customer_custom_var_1',
38
- :customer_custom_var_2 => 'customer_custom_var_2',)
39
- end
40
- end
41
-
42
- context 'update_order_id' do
43
- it 'should send correct request to api' do
44
- api = create_api
45
- api.should_receive(:request)
46
- .with('v1/transactions/update', :payment_key,
47
- [:shop_id, :transaction_id, :order_id, :payment_key],
48
- :transaction_id => '123',
49
- :order_id => '456')
50
-
51
- transaction = Barzahlen::Api::Online::Transaction.new api
52
- transaction.update_order_id '123', '456'
53
- end
54
- end
55
-
56
- context 'resend_email' do
57
- it 'should send correct request to api' do
58
- api = create_api
59
- api.should_receive(:request)
60
- .with('v1/transactions/resend_email', :payment_key,
61
- [:shop_id, :transaction_id, :language, :payment_key],
62
- :transaction_id => '123',
63
- :language => 'de')
64
-
65
- transaction = Barzahlen::Api::Online::Transaction.new api
66
- transaction.resend_email '123', 'de'
67
- end
68
- end
69
-
70
- context 'cancel' do
71
- it 'should send correct request to api' do
72
- api = create_api
73
- api.should_receive(:request)
74
- .with('v1/transactions/cancel', :payment_key,
75
- [:shop_id, :transaction_id, :language, :payment_key],
76
- :transaction_id => '123',
77
- :language => 'de')
78
-
79
- transaction = Barzahlen::Api::Online::Transaction.new(api)
80
- transaction.cancel '123', 'de'
81
- end
82
- end
83
-
84
- context 'refund' do
85
- it 'should send correct request to api' do
86
- api = create_api
87
- api.should_receive(:request)
88
- .with('v1/transactions/refund', :payment_key,
89
- [:shop_id, :transaction_id, :amount, :currency, :language, :payment_key],
90
- :transaction_id => '123',
91
- :amount => '12.23',
92
- :currency => 'EUR',
93
- :language => 'de')
94
-
95
- transaction = Barzahlen::Api::Online::Transaction.new api
96
- transaction.refund '123', '12.23', 'EUR', 'de'
97
- end
98
- end
99
-
100
- private
101
- def create_api
102
- Barzahlen::Api::Online::Api.new(double('Net::HTTP'),
103
- :shop_id => 12345,
104
- :payment_key => 'asdfasdf',
105
- :notification_key => 'foobarfoobar',
106
- :language => 'de',)
107
- end
108
- end
@@ -1,34 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Barzahlen::Api::Online do
6
- before(:each) do
7
- Barzahlen::Api::Online.config = nil
8
- Barzahlen::Api::Online.api = nil
9
- end
10
-
11
- context 'new_transaction_api' do
12
- it 'should raise an error, if no config and api is specified' do
13
- expect { Barzahlen::Api::Online.new_transaction_api }.to raise_error
14
- end
15
-
16
- it 'should return Transcation object' do
17
- Barzahlen::Api::Online.config = {}
18
- transaction_api = Barzahlen::Api::Online.new_transaction_api
19
- expect(transaction_api).to be_a Barzahlen::Api::Online::Transaction
20
- end
21
- end
22
-
23
- context 'new_notification_handler' do
24
- it 'should raise an error, if no config and api is specified' do
25
- expect { Barzahlen::Api::Online.new_notification_handler }.to raise_error
26
- end
27
-
28
- it 'should return NotificationHandler object' do
29
- Barzahlen::Api::Online.config = {}
30
- notification_handler = Barzahlen::Api::Online.new_notification_handler
31
- expect(notification_handler).to be_a Barzahlen::Api::Online::NotificationHandler
32
- end
33
- end
34
- end
@@ -1,8 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'barzahlen/api/online'
4
- require 'barzahlen/api/online/api'
5
- require 'barzahlen/api/online/transaction'
6
- require 'barzahlen/api/online/hash_builder'
7
- require 'barzahlen/api/online/response_parser'
8
- require 'barzahlen/api/online/notification_handler'