opay 1.2.0 → 1.2.1
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 +4 -4
- data/README.md +23 -2
- data/app/controllers/opay/paypal_controller.rb +9 -4
- data/config/routes.rb +2 -2
- data/lib/generators/opay/templates/opay_config.rb +3 -0
- data/lib/opay/configuration.rb +5 -2
- data/lib/opay/helpers/form_helper.rb +19 -2
- data/lib/opay/helpers/paypal_helper.rb +3 -1
- data/lib/opay/providers/paypal.rb +4 -10
- data/lib/opay/version.rb +1 -1
- data/spec/dummy/config/initializers/opay_config.rb +3 -0
- data/spec/dummy/config/initializers/secret_token.rb +1 -1
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +1465 -0
- data/spec/dummy/log/test.log +6206 -0
- data/spec/fixtures/xml/paypal/payment_created.xml.erb +26 -0
- data/spec/lib/opay/helpers/form_helper_spec.rb +20 -0
- data/spec/lib/opay/helpers/paypal_helper_spec.rb +22 -0
- data/spec/lib/opay/helpers/payu_helper_spec.rb +3 -3
- data/spec/lib/opay/providers/paypal_spec.rb +47 -0
- metadata +10 -4
- data/spec/dummy/tmp/pids/server.pid +0 -1
@@ -0,0 +1,26 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><env:Header><RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" xmlns:n1="urn:ebay:apis:eBLBaseComponents" env:mustUnderstand="0"><n1:Credentials><n1:Username>ollownia-facilitator_api1.gmail.com</n1:Username><n1:Password>1395743145</n1:Password><n1:Subject/><n1:Signature>AGUkzh-MeQY9FWOCQ5.UwnNAI5EgABkxUU7ynmHt9IbLYXd5FwKiwy6K</n1:Signature></n1:Credentials></RequesterCredentials></env:Header><env:Body><SetExpressCheckoutReq xmlns="urn:ebay:api:PayPalAPI">
|
2
|
+
<SetExpressCheckoutRequest xmlns:n2="urn:ebay:apis:eBLBaseComponents">
|
3
|
+
<n2:Version>72</n2:Version>
|
4
|
+
<n2:SetExpressCheckoutRequestDetails>
|
5
|
+
<n2:ReturnURL>http://localhost:3000/opay/paypal/create</n2:ReturnURL>
|
6
|
+
<n2:CancelURL>http://localhost:3000/?cancel</n2:CancelURL>
|
7
|
+
<n2:NoShipping>0</n2:NoShipping>
|
8
|
+
<n2:AddressOverride>0</n2:AddressOverride>
|
9
|
+
<n2:PaymentDetails>
|
10
|
+
<n2:OrderTotal currencyID="USD">10.00</n2:OrderTotal>
|
11
|
+
<n2:InvoiceID>KwjsCiLXpXKXRBM5zCWP</n2:InvoiceID>
|
12
|
+
<n2:ButtonSource>ActiveMerchant</n2:ButtonSource>
|
13
|
+
<n2:PaymentDetailsItem>
|
14
|
+
<n2:Name>Description</n2:Name>
|
15
|
+
<n2:Number/>
|
16
|
+
<n2:Quantity>1</n2:Quantity>
|
17
|
+
<n2:Amount currencyID="USD">10.00</n2:Amount>
|
18
|
+
<n2:Description/>
|
19
|
+
<n2:ItemURL/>
|
20
|
+
</n2:PaymentDetailsItem>
|
21
|
+
<n2:PaymentAction>Sale</n2:PaymentAction>
|
22
|
+
</n2:PaymentDetails>
|
23
|
+
</n2:SetExpressCheckoutRequestDetails>
|
24
|
+
</SetExpressCheckoutRequest>
|
25
|
+
</SetExpressCheckoutReq>
|
26
|
+
</env:Body></env:Envelope>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Opay
|
4
|
+
describe Helpers::FormHelper, type: :helper do
|
5
|
+
|
6
|
+
context 'form tag' do
|
7
|
+
before do
|
8
|
+
@order = Order.create! name: 'first order', amount: 1000 # 10 zł
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'retunts error in provider not set' do
|
12
|
+
expect{ helper.opay_form_for(@order) }.to raise_error(ArgumentError)
|
13
|
+
expect{ helper.opay_form_for(@order, provider: :not_existing) }.to raise_error(ArgumentError)
|
14
|
+
|
15
|
+
expect { helper.opay_form_for(@order, provider: :payu) {} }.to_not raise_error
|
16
|
+
expect { helper.opay_form_for(@order, provider: :paypal) {} }.to_not raise_error
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Opay
|
4
|
+
describe Helpers::PaypalHelper, type: :helper do
|
5
|
+
|
6
|
+
context 'form tag' do
|
7
|
+
before do
|
8
|
+
@order = Order.create! name: 'first order', amount: 2000 # 20 zł
|
9
|
+
Opay.config.process_payments_localy = false
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'creates form tag' do
|
13
|
+
html = helper.opay_form_for(@order, provider: :paypal) do |f|
|
14
|
+
f.payment_info first_name: 'Jan', last_name: 'Kowalski', email: 'kowalski@gmail.com', desc: 'Test payment', client_ip: '127.0.0.1'
|
15
|
+
end
|
16
|
+
|
17
|
+
html.should have_css('form[action="/opay/paypal/new"]')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -10,7 +10,7 @@ module Opay
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'creates form tag' do
|
13
|
-
html = helper.opay_form_for(@order) do |f|
|
13
|
+
html = helper.opay_form_for(@order, provider: :payu) do |f|
|
14
14
|
f.payment_info first_name: 'Jan', last_name: 'Kowalski', email: 'kowalski@gmail.com', desc: 'Test payment', client_ip: '127.0.0.1'
|
15
15
|
end
|
16
16
|
|
@@ -38,7 +38,7 @@ module Opay
|
|
38
38
|
Opay.config.test_mode = true
|
39
39
|
Opay.config.test_mode.should be true
|
40
40
|
|
41
|
-
html = helper.
|
41
|
+
html = helper.opay_form_for(@order, provider: :payu) do |f|
|
42
42
|
f.payment_info first_name: 'Jan', last_name: 'Kowalski', email: 'kowalski@gmail.com', desc: 'Test payment', client_ip: '127.0.0.1'
|
43
43
|
end
|
44
44
|
|
@@ -48,7 +48,7 @@ module Opay
|
|
48
48
|
it 'works localy' do
|
49
49
|
Opay.config.process_payments_localy = true
|
50
50
|
|
51
|
-
html = helper.
|
51
|
+
html = helper.opay_form_for(@order, provider: :payu) do |f|
|
52
52
|
f.payment_info first_name: 'Jan', last_name: 'Kowalski', email: 'kowalski@gmail.com', desc: 'Test payment', client_ip: '127.0.0.1'
|
53
53
|
end
|
54
54
|
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'Activemerchant'
|
3
|
+
|
4
|
+
module Opay
|
5
|
+
describe Providers::Paypal do
|
6
|
+
context 'md5 signs' do
|
7
|
+
|
8
|
+
before do
|
9
|
+
@login = Opay.config.paypal_login
|
10
|
+
@password = Opay.config.paypal_password
|
11
|
+
@signature = Opay.config.paypal_signature
|
12
|
+
Opay.config.process_payments_localy = false
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'can work in test mode' do
|
16
|
+
Opay.config.test_mode = true
|
17
|
+
|
18
|
+
@order = Order.create! name: 'first order', amount: 1000 # 10 zł
|
19
|
+
@order.prepare_payment
|
20
|
+
|
21
|
+
Opay.config.paypal_login = 'ollownia-facilitator_api1.gmail.com'
|
22
|
+
Opay.config.paypal_password = '1395743145'
|
23
|
+
Opay.config.paypal_signature = 'AGUkzh-MeQY9FWOCQ5.UwnNAI5EgABkxUU7ynmHt9IbLYXd5FwKiwy6K'
|
24
|
+
|
25
|
+
stub_request(:post, 'https://api-3t.sandbox.paypal.com/2.0/')
|
26
|
+
.to_return(status: 200, body: response_from_template('paypal/payment_created.xml', {}))
|
27
|
+
|
28
|
+
Providers::Paypal.create_payment(@order.payment.session_id, 'Description', '127.0.0.1', '/confirm', '/cancel')
|
29
|
+
::ActiveMerchant::Billing::Base.mode.should be :test
|
30
|
+
end
|
31
|
+
|
32
|
+
# it 'creates payment' do
|
33
|
+
# pos_id = '123456'
|
34
|
+
# session_id = '0cde9e950d99630410661b2dedbbd822'
|
35
|
+
# ts = '1234567890'
|
36
|
+
# sig = Digest::MD5.hexdigest(pos_id + session_id + ts + @key1)
|
37
|
+
|
38
|
+
# # valid sig
|
39
|
+
# subject.class_eval { create_sig(pos_id, session_id, ts) }.should eq sig
|
40
|
+
|
41
|
+
# # invalid sig
|
42
|
+
# subject.class_eval { create_sig('23456', session_id, ts) }.should_not eq sig
|
43
|
+
# end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mariusz Ołownia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -333,12 +333,15 @@ files:
|
|
333
333
|
- spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655
|
334
334
|
- spec/dummy/tmp/cache/assets/development/sprockets/f9252c283a2d0d999785e397d349845d
|
335
335
|
- spec/dummy/tmp/cache/assets/development/sprockets/fd4858ad2420a56b427ccd9d5ec86d31
|
336
|
-
- spec/dummy/tmp/pids/server.pid
|
337
336
|
- spec/factories/opay_payments.rb
|
338
337
|
- spec/fixtures/xml/error.xml.erb
|
338
|
+
- spec/fixtures/xml/paypal/payment_created.xml.erb
|
339
339
|
- spec/fixtures/xml/success.xml.erb
|
340
|
+
- spec/lib/opay/helpers/form_helper_spec.rb
|
341
|
+
- spec/lib/opay/helpers/paypal_helper_spec.rb
|
340
342
|
- spec/lib/opay/helpers/payu_helper_spec.rb
|
341
343
|
- spec/lib/opay/payable_spec.rb
|
344
|
+
- spec/lib/opay/providers/paypal_spec.rb
|
342
345
|
- spec/lib/opay/providers/payu_spec.rb
|
343
346
|
- spec/models/opay/payment_spec.rb
|
344
347
|
- spec/spec_helper.rb
|
@@ -440,12 +443,15 @@ test_files:
|
|
440
443
|
- spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655
|
441
444
|
- spec/dummy/tmp/cache/assets/development/sprockets/f9252c283a2d0d999785e397d349845d
|
442
445
|
- spec/dummy/tmp/cache/assets/development/sprockets/fd4858ad2420a56b427ccd9d5ec86d31
|
443
|
-
- spec/dummy/tmp/pids/server.pid
|
444
446
|
- spec/factories/opay_payments.rb
|
445
447
|
- spec/fixtures/xml/error.xml.erb
|
448
|
+
- spec/fixtures/xml/paypal/payment_created.xml.erb
|
446
449
|
- spec/fixtures/xml/success.xml.erb
|
450
|
+
- spec/lib/opay/helpers/form_helper_spec.rb
|
451
|
+
- spec/lib/opay/helpers/paypal_helper_spec.rb
|
447
452
|
- spec/lib/opay/helpers/payu_helper_spec.rb
|
448
453
|
- spec/lib/opay/payable_spec.rb
|
454
|
+
- spec/lib/opay/providers/paypal_spec.rb
|
449
455
|
- spec/lib/opay/providers/payu_spec.rb
|
450
456
|
- spec/models/opay/payment_spec.rb
|
451
457
|
- spec/spec_helper.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
39835
|