activepayment 0.2.5 → 1.0.0
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 +7 -0
- data/.ruby-version +1 -0
- data/.travis.yml +1 -1
- data/README.md +126 -0
- data/activepayment.gemspec +1 -0
- data/doc/WD_card_processing_4_0_0.pdf +0 -0
- data/doc/WD_country¤cy_codes_1-1-0_en.pdf +0 -0
- data/doc/WD_https_gateway_2-3-0_en.pdf +0 -0
- data/lib/activepayment.rb +2 -2
- data/lib/activepayment/gateway_base.rb +7 -2
- data/lib/activepayment/paypal/gateway.rb +57 -0
- data/lib/activepayment/version.rb +1 -1
- data/lib/activepayment/wirecard/gateway.rb +4 -11
- data/spec/functional/wirecard/config.yml +12 -0
- data/spec/functional/wirecard/wirecard_spec.rb +32 -39
- data/spec/spec_helper.rb +9 -8
- data/spec/unit/paypal/gateway_spec.rb +69 -0
- data/spec/unit/wirecard/gateway_spec.rb +15 -10
- metadata +63 -55
- data/.rspec +0 -1
- data/.rvmrc +0 -1
- data/README.rdoc +0 -44
- data/lib/activepayment/payone/gateway.rb +0 -76
- data/lib/activepayment/payone/response.rb +0 -41
- data/spec/fixtures/payone/gateway/authorization_request.txt +0 -1
- data/spec/fixtures/payone/gateway/successful_authorization_response.txt +0 -3
- data/spec/functional/payone/config.yml +0 -3
- data/spec/functional/payone/payone_spec.rb +0 -67
- data/spec/unit/payone/gateway_spec.rb +0 -136
- data/spec/unit/payone/response_spec.rb +0 -21
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 673fe904e2566fb07f426850eace602276b3bafa
|
|
4
|
+
data.tar.gz: 4f93bd3897ea8e260c25039e4116605bcbed0747
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 2a63c28d1ba5e9d86197cc29c640f9ea5ada12bca2176bbd362c963b403da17731b413f9c1398384965fd90147f98eedccfae88ab36f112efadd84f99d2c5b6d
|
|
7
|
+
data.tar.gz: c6cb5887707d001166ed0e2f221c62a3ffbf3af764780547adeeab4007b8c3ca0aaaf19875ff736a64515997acf6f16625577b8a8f53e8f71694143a44f520c6
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.1.1
|
data/.travis.yml
CHANGED
data/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
ActivePayment
|
|
2
|
+
=============
|
|
3
|
+
|
|
4
|
+
[][travis]
|
|
5
|
+
[][gem]
|
|
6
|
+
[][codeclimate]
|
|
7
|
+
[][gemnasium]
|
|
8
|
+
|
|
9
|
+
[travis]: https://travis-ci.org/aklaiber/activepayment
|
|
10
|
+
[gem]: https://rubygems.org/gems/activepayment
|
|
11
|
+
[codeclimate]: https://codeclimate.com/github/aklaiber/activepayment
|
|
12
|
+
[gemnasium]: https://gemnasium.com/aklaiber/activepayment
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
ActivePayment is an abstraction layer for different Payment-Interfaces (XML, JSON)
|
|
16
|
+
|
|
17
|
+
##### Usage Paypal Gateway
|
|
18
|
+
|
|
19
|
+
``` ruby
|
|
20
|
+
ActivePayment::Paypal::Gateway.business = 'seller_111111_biz@example.com'
|
|
21
|
+
ActivePayment::Paypal::Gateway.cmd = '_xclick'
|
|
22
|
+
ActivePayment::Paypal::Gateway.default_currency = 'EUR'
|
|
23
|
+
ActivePayment::Wirecard::Gateway.mode = 'live'
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
``` ruby
|
|
27
|
+
gateway = ActivePayment::Paypal::Gateway.new('TRANSACTION ID', 100)
|
|
28
|
+
|
|
29
|
+
gateway.return_url = 'http://example.com/payment_completed_url'
|
|
30
|
+
gateway.notify_url = 'http://example.com/payment_notify_url'
|
|
31
|
+
gateway.cancel_url = 'http://example.com/payment_cancel_url'
|
|
32
|
+
gateway.invoice = 'INVOICE NUMBER'
|
|
33
|
+
gateway.item_name = 'ITEM NAME'
|
|
34
|
+
|
|
35
|
+
gateway.redirect_url.to_s
|
|
36
|
+
|
|
37
|
+
# => https://www.paypal.com/cgi-bin/webscr?amount=1.0&business=seller_111111_biz%40example.com&cancel_return=http%3A%2F%2Fexample.com%2Fpayment_cancel_url&cmd=_xclick¤cy_code=EUR&invoice=INVOICE+NUMBER&item_name=ITEM+NAME¬ify_url=http%3A%2F%2Fexample.com%2Fpayment_notify_url&return=http%3A%2F%2Fexample.com%2Fpayment_completed_url
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
##### Usage Wirecard Gateway
|
|
41
|
+
|
|
42
|
+
``` ruby
|
|
43
|
+
ActivePayment::Wirecard::Gateway.login = 56501
|
|
44
|
+
ActivePayment::Wirecard::Gateway.password = 'TestXAPTER'
|
|
45
|
+
ActivePayment::Wirecard::Gateway.signature = '56501'
|
|
46
|
+
ActivePayment::Wirecard::Gateway.mode = 'demo'
|
|
47
|
+
ActivePayment::Wirecard::Gateway.default_currency = 'EUR'
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
``` ruby
|
|
51
|
+
gateway = ActivePayment::Wirecard::Gateway.new('TRANSACTION ID', 100)
|
|
52
|
+
|
|
53
|
+
gateway.jop_id = 'test dummy data'
|
|
54
|
+
gateway.transaction_params = {
|
|
55
|
+
commerce_type: 'eCommerce',
|
|
56
|
+
country_code: 'DE',
|
|
57
|
+
contact_data: { ip_address: '192.168.1.1' },
|
|
58
|
+
corptrustcenter_data: {
|
|
59
|
+
address: {
|
|
60
|
+
first_name: 'first_name',
|
|
61
|
+
last_name: 'last_name',
|
|
62
|
+
address_1: 'address_1',
|
|
63
|
+
address_2: 'address_2',
|
|
64
|
+
city: 'city',
|
|
65
|
+
zip_code: 'zip_code',
|
|
66
|
+
state: 'state',
|
|
67
|
+
country: 'country',
|
|
68
|
+
phone: 'phone',
|
|
69
|
+
email: 'email'
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
``` ruby
|
|
76
|
+
gateway.authorization(
|
|
77
|
+
credit_card_number: '4200000000000000',
|
|
78
|
+
cvc2: '001',
|
|
79
|
+
expiration_year: '2020',
|
|
80
|
+
expiration_month: '01',
|
|
81
|
+
card_holder_name: 'TEST CARDHOLDER'
|
|
82
|
+
)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
``` ruby
|
|
86
|
+
gateway.capture_authorization('TEST GUWID')
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
``` ruby
|
|
90
|
+
gateway.purchase(
|
|
91
|
+
credit_card_number: '4200000000000000',
|
|
92
|
+
cvc2: '001',
|
|
93
|
+
expiration_year: '2020',
|
|
94
|
+
expiration_month: '01',
|
|
95
|
+
card_holder_name: 'TEST CARDHOLDER'
|
|
96
|
+
)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
``` ruby
|
|
100
|
+
gateway.enrollment_check(
|
|
101
|
+
credit_card_number: '4200000000000000',
|
|
102
|
+
cvc2: '001',
|
|
103
|
+
expiration_year: '2020',
|
|
104
|
+
expiration_month: '01',
|
|
105
|
+
card_holder_name: 'TEST CARDHOLDER'
|
|
106
|
+
)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Installation
|
|
110
|
+
-----------------
|
|
111
|
+
|
|
112
|
+
gem install activepayment
|
|
113
|
+
|
|
114
|
+
or add the following line to Gemfile:
|
|
115
|
+
|
|
116
|
+
gem 'activepayment'
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
Supported Gateways
|
|
120
|
+
-----------------
|
|
121
|
+
|
|
122
|
+
* {Payone}[http://www.payone.de] - DE
|
|
123
|
+
* {Wirecard}[http://www.wirecard.com] - DE
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
data/activepayment.gemspec
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/activepayment.rb
CHANGED
|
@@ -9,15 +9,15 @@ require "active_support/core_ext"
|
|
|
9
9
|
require "builder"
|
|
10
10
|
require "nokogiri"
|
|
11
11
|
require "uuid"
|
|
12
|
+
require "money"
|
|
12
13
|
|
|
13
14
|
require "activepayment/railtie" if defined?(Rails)
|
|
14
15
|
require "activepayment/version"
|
|
15
16
|
require "activepayment/gateway_base"
|
|
16
17
|
|
|
17
|
-
require "activepayment/payone/gateway"
|
|
18
18
|
require "activepayment/wirecard/gateway"
|
|
19
|
+
require "activepayment/paypal/gateway"
|
|
19
20
|
|
|
20
|
-
require "activepayment/payone/response"
|
|
21
21
|
require "activepayment/wirecard/response"
|
|
22
22
|
|
|
23
23
|
module ActivePayment
|
|
@@ -2,9 +2,14 @@ module ActivePayment
|
|
|
2
2
|
module Gateway
|
|
3
3
|
class Base
|
|
4
4
|
|
|
5
|
-
class_attribute :gateway_name, :test_url, :live_url, :default_currency
|
|
5
|
+
class_attribute :gateway_name, :test_url, :live_url, :default_currency, :mode
|
|
6
6
|
|
|
7
|
-
attr_accessor :transaction_params
|
|
7
|
+
attr_accessor :transaction_params, :amount, :transaction_id
|
|
8
|
+
|
|
9
|
+
def initialize(transaction_id, amount)
|
|
10
|
+
@transaction_id = transaction_id
|
|
11
|
+
@amount = amount.kind_of?(Money) ? amount : Money.new(amount, default_currency.upcase)
|
|
12
|
+
end
|
|
8
13
|
|
|
9
14
|
def self.build(name)
|
|
10
15
|
"ActivePayment::#{name.to_s.classify}::Gateway".constantize
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
module ActivePayment
|
|
2
|
+
module Paypal
|
|
3
|
+
class Gateway < ActivePayment::Gateway::Base
|
|
4
|
+
|
|
5
|
+
class_attribute :business, :cmd
|
|
6
|
+
|
|
7
|
+
attr_accessor :amount, :transaction_id, :jop_id, :return_url, :notify_url, :cancel_url, :invoice, :item_name
|
|
8
|
+
|
|
9
|
+
self.gateway_name = 'paypal'
|
|
10
|
+
self.test_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr?'
|
|
11
|
+
self.live_url = 'https://www.paypal.com/cgi-bin/webscr?'
|
|
12
|
+
|
|
13
|
+
public
|
|
14
|
+
|
|
15
|
+
def redirect_url
|
|
16
|
+
URI.parse(self.url.to_s + transaction_params.to_query)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def purchase_valid?(request)
|
|
20
|
+
response = post_validation_request(request)
|
|
21
|
+
|
|
22
|
+
if response.eql?('VERIFIED')
|
|
23
|
+
return true
|
|
24
|
+
else
|
|
25
|
+
return false
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def post_validation_request(origin_response)
|
|
32
|
+
uri = URI.parse("#{self.url.to_s}cmd=_notify-validate")
|
|
33
|
+
|
|
34
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
35
|
+
http.open_timeout = 60
|
|
36
|
+
http.read_timeout = 60
|
|
37
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
38
|
+
http.use_ssl = true
|
|
39
|
+
http.post(uri.request_uri, origin_response, 'Content-Length' => "#{origin_response.size}", 'User-Agent' => 'My custom user agent').body
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def transaction_params
|
|
43
|
+
{
|
|
44
|
+
business: business,
|
|
45
|
+
cmd: cmd,
|
|
46
|
+
amount: amount.to_f,
|
|
47
|
+
currency_code: default_currency,
|
|
48
|
+
return: return_url,
|
|
49
|
+
notify_url: notify_url,
|
|
50
|
+
cancel_return: cancel_url,
|
|
51
|
+
invoice: invoice,
|
|
52
|
+
item_name: item_name
|
|
53
|
+
}
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -10,13 +10,6 @@ module ActivePayment
|
|
|
10
10
|
self.test_url = 'https://c3-test.wirecard.com/secure/ssl-gateway'
|
|
11
11
|
self.live_url = 'https://c3.wirecard.com/secure/ssl-gateway'
|
|
12
12
|
|
|
13
|
-
def initialize(transaction_id, amount)
|
|
14
|
-
@transaction_id = transaction_id
|
|
15
|
-
@amount = amount
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
public
|
|
19
|
-
|
|
20
13
|
def authorization(credit_card)
|
|
21
14
|
post_request(self.authorization_request(credit_card))
|
|
22
15
|
end
|
|
@@ -25,7 +18,7 @@ module ActivePayment
|
|
|
25
18
|
build_request(:authorization) do |xml|
|
|
26
19
|
xml.tag! 'TransactionID', self.transaction_id
|
|
27
20
|
xml.tag! 'Currency', Gateway.default_currency
|
|
28
|
-
xml.tag! 'Amount', self.amount
|
|
21
|
+
xml.tag! 'Amount', self.amount.cents
|
|
29
22
|
|
|
30
23
|
add_optional_node(xml, :commerce_type)
|
|
31
24
|
add_optional_node(xml, :country_code)
|
|
@@ -43,7 +36,7 @@ module ActivePayment
|
|
|
43
36
|
build_request(:capture_authorization) do |xml|
|
|
44
37
|
xml.tag! 'TransactionID', self.transaction_id
|
|
45
38
|
xml.tag! 'GuWID', guwid
|
|
46
|
-
xml.tag! 'Amount', self.amount
|
|
39
|
+
xml.tag! 'Amount', self.amount.cents
|
|
47
40
|
|
|
48
41
|
add_optional_node(xml, :country_code)
|
|
49
42
|
end
|
|
@@ -57,7 +50,7 @@ module ActivePayment
|
|
|
57
50
|
build_request(:purchase) do |xml|
|
|
58
51
|
xml.tag! 'TransactionID', self.transaction_id
|
|
59
52
|
xml.tag! 'Currency', Gateway.default_currency
|
|
60
|
-
xml.tag! 'Amount', self.amount
|
|
53
|
+
xml.tag! 'Amount', self.amount.cents
|
|
61
54
|
xml.tag! 'GuWID', guwid unless guwid.blank?
|
|
62
55
|
xml.tag! 'THREE-D_SECURE' do
|
|
63
56
|
xml.tag! 'PARes', pares
|
|
@@ -79,7 +72,7 @@ module ActivePayment
|
|
|
79
72
|
build_request(:enrollment_check) do |xml|
|
|
80
73
|
xml.tag! 'TransactionID', self.transaction_id
|
|
81
74
|
xml.tag! 'Currency', Gateway.default_currency
|
|
82
|
-
xml.tag! 'Amount', self.amount
|
|
75
|
+
xml.tag! 'Amount', self.amount.cents
|
|
83
76
|
|
|
84
77
|
add_optional_node(xml, :country_code)
|
|
85
78
|
add_optional_node(xml, :credit_card_data, credit_card)
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
without_3d_secure:
|
|
2
|
+
wirecard:
|
|
3
|
+
login: 56501
|
|
4
|
+
password: TestXAPTER
|
|
5
|
+
signature: 56501
|
|
6
|
+
mode: demo
|
|
7
|
+
default_currency: EUR
|
|
2
8
|
|
|
3
9
|
with_3d_secure:
|
|
10
|
+
wirecard:
|
|
11
|
+
login: 000000315DE09F66
|
|
12
|
+
password: TestXAPTER
|
|
13
|
+
signature: 000000315DE0A429
|
|
14
|
+
mode:
|
|
15
|
+
default_currency: EUR
|
|
4
16
|
|
|
@@ -3,22 +3,22 @@ require "spec_helper"
|
|
|
3
3
|
describe ActivePayment::Wirecard::Gateway do
|
|
4
4
|
|
|
5
5
|
let(:amount) { 100 }
|
|
6
|
-
let(:gateway)
|
|
6
|
+
let(:gateway) do
|
|
7
|
+
gateway = ActivePayment::Wirecard::Gateway.new(123, amount)
|
|
8
|
+
gateway.jop_id = 'test dummy data'
|
|
9
|
+
gateway.transaction_params = { commerce_type: 'eCommerce', country_code: 'DE' }
|
|
10
|
+
gateway
|
|
11
|
+
end
|
|
7
12
|
|
|
8
13
|
describe "post request" do
|
|
9
14
|
|
|
10
15
|
before(:all) do
|
|
11
16
|
ActivePayment::Wirecard::Gateway.config = load_config('wirecard', 'without_3d_secure')
|
|
12
|
-
|
|
13
|
-
gateway.jop_id = 'test dummy data'
|
|
14
|
-
gateway.transaction_params = {
|
|
15
|
-
:commerce_type => 'eCommerce',
|
|
16
|
-
:country_code => 'DE'
|
|
17
|
-
}
|
|
18
17
|
end
|
|
19
18
|
|
|
20
19
|
it "should post authorization request" do
|
|
21
|
-
response = gateway.authorization(
|
|
20
|
+
response = gateway.authorization(credit_card_number: '4200000000000000', cvc2: '001', expiration_year: '2020', expiration_month: '01', card_holder_name: 'TEST CARDHOLDER')
|
|
21
|
+
# response = gateway.authorization(credit_card_hash)
|
|
22
22
|
|
|
23
23
|
response.successful?.should be_true
|
|
24
24
|
response.info.should include('THIS IS A DEMO')
|
|
@@ -49,26 +49,29 @@ describe ActivePayment::Wirecard::Gateway do
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
describe "with address" do
|
|
52
|
-
|
|
52
|
+
let(:gateway) do
|
|
53
|
+
gateway = ActivePayment::Wirecard::Gateway.new(123, amount)
|
|
54
|
+
gateway.jop_id = 'test dummy data'
|
|
53
55
|
gateway.transaction_params = {
|
|
54
|
-
:
|
|
55
|
-
:
|
|
56
|
-
:
|
|
57
|
-
:
|
|
58
|
-
:
|
|
59
|
-
:
|
|
60
|
-
:
|
|
61
|
-
:
|
|
62
|
-
:
|
|
63
|
-
:
|
|
64
|
-
:
|
|
65
|
-
:
|
|
66
|
-
:
|
|
67
|
-
:
|
|
68
|
-
:
|
|
56
|
+
commerce_type: 'eCommerce',
|
|
57
|
+
country_code: 'DE',
|
|
58
|
+
contact_data: {ip_address: '192.168.1.1'},
|
|
59
|
+
corptrustcenter_data: {
|
|
60
|
+
address: {
|
|
61
|
+
first_name: Forgery::Name.first_name,
|
|
62
|
+
last_name: Forgery::Name.last_name,
|
|
63
|
+
address_1: '550 South Winchester blvd.',
|
|
64
|
+
address_2: 'P.O. Box 850',
|
|
65
|
+
city: 'San Jose',
|
|
66
|
+
zip_code: '95128',
|
|
67
|
+
state: 'CA',
|
|
68
|
+
country: 'US',
|
|
69
|
+
phone: '+1(202)555-1234',
|
|
70
|
+
email: 'John.Doe@email.com'
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
73
|
}
|
|
74
|
+
gateway
|
|
72
75
|
end
|
|
73
76
|
|
|
74
77
|
it "should post authorization request with address" do
|
|
@@ -84,27 +87,17 @@ describe ActivePayment::Wirecard::Gateway do
|
|
|
84
87
|
end
|
|
85
88
|
|
|
86
89
|
describe "3D secure" do
|
|
87
|
-
|
|
88
90
|
before(:all) do
|
|
89
91
|
ActivePayment::Wirecard::Gateway.config = load_config('wirecard', 'with_3d_secure')
|
|
90
|
-
|
|
91
|
-
gateway.jop_id = 'test dummy data'
|
|
92
|
-
gateway.transaction_params = {
|
|
93
|
-
:commerce_type => 'eCommerce',
|
|
94
|
-
:country_code => 'DE'
|
|
95
|
-
}
|
|
96
92
|
end
|
|
97
93
|
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
context "enrollment_check" do
|
|
95
|
+
it "should failed" do
|
|
96
|
+
response = gateway.enrollment_check(credit_card_hash('4012000300001003', :cvc2 => '003'))
|
|
100
97
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
response['GuWID'].should_not be_blank
|
|
104
|
-
response['PAReq'].should_not be_blank
|
|
105
|
-
response['AcsUrl'].should_not be_blank
|
|
98
|
+
response.successful?.should be_false
|
|
99
|
+
end
|
|
106
100
|
end
|
|
107
|
-
|
|
108
101
|
end
|
|
109
102
|
|
|
110
103
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
|
3
3
|
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
require
|
|
4
|
+
require 'activepayment'
|
|
5
|
+
require 'rspec'
|
|
6
|
+
require 'forgery'
|
|
7
|
+
require 'yaml'
|
|
7
8
|
|
|
8
9
|
FIXTURES_PATH = "#{File.dirname(__FILE__)}/fixtures"
|
|
9
10
|
|
|
@@ -13,11 +14,11 @@ end
|
|
|
13
14
|
|
|
14
15
|
def credit_card_hash(number = '4200000000000000', options = {})
|
|
15
16
|
{
|
|
16
|
-
:
|
|
17
|
-
:
|
|
18
|
-
:
|
|
19
|
-
:
|
|
20
|
-
:
|
|
17
|
+
credit_card_number: number,
|
|
18
|
+
cvc2: '001',
|
|
19
|
+
expiration_year: Time.now.year + 1,
|
|
20
|
+
expiration_month: '01',
|
|
21
|
+
card_holder_name: Forgery::Name.full_name
|
|
21
22
|
}.update(options)
|
|
22
23
|
end
|
|
23
24
|
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe ActivePayment::Paypal::Gateway do
|
|
4
|
+
before(:all) do
|
|
5
|
+
ActivePayment::Paypal::Gateway.business = 'seller_1321436147_biz@bonayou.com'
|
|
6
|
+
ActivePayment::Paypal::Gateway.cmd = '_xclick'
|
|
7
|
+
ActivePayment::Paypal::Gateway.default_currency = 'EUR'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
let(:amount) { 1000 }
|
|
11
|
+
let(:gateway) { ActivePayment::Paypal::Gateway.new(123, amount)}
|
|
12
|
+
|
|
13
|
+
describe '#url' do
|
|
14
|
+
let(:url) { gateway.redirect_url.to_s }
|
|
15
|
+
|
|
16
|
+
it { expect(url).to include(ActivePayment::Paypal::Gateway.test_url)}
|
|
17
|
+
it { expect(url).to include(CGI.escape(ActivePayment::Paypal::Gateway.business)) }
|
|
18
|
+
it { expect(url).to include(CGI.escape(ActivePayment::Paypal::Gateway.cmd)) }
|
|
19
|
+
it { expect(url).to include(CGI.escape(ActivePayment::Paypal::Gateway.default_currency)) }
|
|
20
|
+
|
|
21
|
+
it 'sets amount' do
|
|
22
|
+
expect(url).to include(gateway.amount.to_f.to_s)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'sets return url' do
|
|
26
|
+
gateway.return_url = 'http://example.com/payment_completed_url'
|
|
27
|
+
|
|
28
|
+
expect(url).to include(CGI.escape(gateway.return_url))
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'sets notify url' do
|
|
32
|
+
gateway.notify_url = 'http://example.com/payment_notify_url'
|
|
33
|
+
|
|
34
|
+
expect(url).to include(CGI.escape(gateway.notify_url))
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'sets cancel url' do
|
|
38
|
+
gateway.cancel_url = 'http://example.com/payment_cancel_url'
|
|
39
|
+
|
|
40
|
+
expect(url).to include(CGI.escape(gateway.cancel_url))
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'sets invoice' do
|
|
44
|
+
gateway.invoice = 'INVOICE NUMBER'
|
|
45
|
+
|
|
46
|
+
expect(url).to include(CGI.escape(gateway.invoice))
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'sets cancel url' do
|
|
50
|
+
gateway.item_name = 'ITEM NAME'
|
|
51
|
+
|
|
52
|
+
expect(url).to include(CGI.escape(gateway.item_name))
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
describe '#purchase_valid?' do
|
|
57
|
+
it 'returns VERIFIED' do
|
|
58
|
+
expect(gateway).to receive(:post_validation_request).once.and_return('VERIFIED')
|
|
59
|
+
|
|
60
|
+
expect(gateway.purchase_valid?('TEST REQUEST')).to be_true
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it 'returns INVALID' do
|
|
64
|
+
expect(gateway).to receive(:post_validation_request).once.and_return('INVALID')
|
|
65
|
+
|
|
66
|
+
expect(gateway.purchase_valid?('TEST REQUEST')).to be_false
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -3,21 +3,23 @@ require 'spec_helper'
|
|
|
3
3
|
describe ActivePayment::Wirecard::Gateway do
|
|
4
4
|
|
|
5
5
|
let(:amount) { 100 }
|
|
6
|
-
let(:gateway) { ActivePayment::Wirecard::Gateway.new(123, amount) }
|
|
7
6
|
let(:guwid) { 'C822580121385121429927' }
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
ActivePayment::Wirecard::Gateway.login = 56501
|
|
11
|
-
ActivePayment::Wirecard::Gateway.password = "TestXAPTER"
|
|
12
|
-
ActivePayment::Wirecard::Gateway.signature = "56501"
|
|
13
|
-
ActivePayment::Wirecard::Gateway.mode = "demo"
|
|
14
|
-
ActivePayment::Wirecard::Gateway.default_currency = 'EUR'
|
|
15
|
-
|
|
7
|
+
let(:gateway) do
|
|
8
|
+
gateway = ActivePayment::Wirecard::Gateway.new(123, amount)
|
|
16
9
|
gateway.jop_id = 'test dummy data'
|
|
17
10
|
gateway.transaction_params = {
|
|
18
11
|
:commerce_type => 'eCommerce',
|
|
19
12
|
:country_code => 'DE'
|
|
20
13
|
}
|
|
14
|
+
gateway
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
before(:all) do
|
|
18
|
+
ActivePayment::Wirecard::Gateway.login = 56501
|
|
19
|
+
ActivePayment::Wirecard::Gateway.password = 'TestXAPTER'
|
|
20
|
+
ActivePayment::Wirecard::Gateway.signature = '56501'
|
|
21
|
+
ActivePayment::Wirecard::Gateway.mode = 'demo'
|
|
22
|
+
ActivePayment::Wirecard::Gateway.default_currency = 'EUR'
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
it "should build authorization request" do
|
|
@@ -51,7 +53,9 @@ describe ActivePayment::Wirecard::Gateway do
|
|
|
51
53
|
end
|
|
52
54
|
|
|
53
55
|
describe "with address" do
|
|
54
|
-
|
|
56
|
+
let(:gateway) do
|
|
57
|
+
gateway = ActivePayment::Wirecard::Gateway.new(123, amount)
|
|
58
|
+
gateway.jop_id = 'test dummy data'
|
|
55
59
|
gateway.transaction_params = {
|
|
56
60
|
:commerce_type => 'eCommerce',
|
|
57
61
|
:country_code => 'DE',
|
|
@@ -71,6 +75,7 @@ describe ActivePayment::Wirecard::Gateway do
|
|
|
71
75
|
}
|
|
72
76
|
}
|
|
73
77
|
}
|
|
78
|
+
gateway
|
|
74
79
|
end
|
|
75
80
|
|
|
76
81
|
it "should build authorization request" do
|
metadata
CHANGED
|
@@ -1,142 +1,139 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activepayment
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 1.0.0
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- Alexander Klaiber
|
|
9
8
|
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 2014-05-21 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: activesupport
|
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
|
17
|
-
none: false
|
|
18
16
|
requirements:
|
|
19
|
-
- -
|
|
17
|
+
- - ">="
|
|
20
18
|
- !ruby/object:Gem::Version
|
|
21
19
|
version: '0'
|
|
22
20
|
type: :runtime
|
|
23
21
|
prerelease: false
|
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
-
none: false
|
|
26
23
|
requirements:
|
|
27
|
-
- -
|
|
24
|
+
- - ">="
|
|
28
25
|
- !ruby/object:Gem::Version
|
|
29
26
|
version: '0'
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
|
31
28
|
name: i18n
|
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
|
33
|
-
none: false
|
|
34
30
|
requirements:
|
|
35
|
-
- -
|
|
31
|
+
- - ">="
|
|
36
32
|
- !ruby/object:Gem::Version
|
|
37
33
|
version: '0'
|
|
38
34
|
type: :runtime
|
|
39
35
|
prerelease: false
|
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
-
none: false
|
|
42
37
|
requirements:
|
|
43
|
-
- -
|
|
38
|
+
- - ">="
|
|
44
39
|
- !ruby/object:Gem::Version
|
|
45
40
|
version: '0'
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
|
47
42
|
name: nokogiri
|
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
|
49
|
-
none: false
|
|
50
44
|
requirements:
|
|
51
|
-
- -
|
|
45
|
+
- - ">="
|
|
52
46
|
- !ruby/object:Gem::Version
|
|
53
47
|
version: '0'
|
|
54
48
|
type: :runtime
|
|
55
49
|
prerelease: false
|
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
-
none: false
|
|
58
51
|
requirements:
|
|
59
|
-
- -
|
|
52
|
+
- - ">="
|
|
60
53
|
- !ruby/object:Gem::Version
|
|
61
54
|
version: '0'
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
|
63
56
|
name: builder
|
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
|
65
|
-
none: false
|
|
66
58
|
requirements:
|
|
67
|
-
- -
|
|
59
|
+
- - ">="
|
|
68
60
|
- !ruby/object:Gem::Version
|
|
69
61
|
version: '0'
|
|
70
62
|
type: :runtime
|
|
71
63
|
prerelease: false
|
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
73
|
-
none: false
|
|
74
65
|
requirements:
|
|
75
|
-
- -
|
|
66
|
+
- - ">="
|
|
76
67
|
- !ruby/object:Gem::Version
|
|
77
68
|
version: '0'
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
|
79
70
|
name: uuid
|
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
|
81
|
-
none: false
|
|
82
72
|
requirements:
|
|
83
|
-
- -
|
|
73
|
+
- - ">="
|
|
84
74
|
- !ruby/object:Gem::Version
|
|
85
75
|
version: '0'
|
|
86
76
|
type: :runtime
|
|
87
77
|
prerelease: false
|
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
89
|
-
none: false
|
|
90
79
|
requirements:
|
|
91
|
-
- -
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: money
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
92
95
|
- !ruby/object:Gem::Version
|
|
93
96
|
version: '0'
|
|
94
97
|
- !ruby/object:Gem::Dependency
|
|
95
98
|
name: rspec
|
|
96
99
|
requirement: !ruby/object:Gem::Requirement
|
|
97
|
-
none: false
|
|
98
100
|
requirements:
|
|
99
|
-
- -
|
|
101
|
+
- - ">="
|
|
100
102
|
- !ruby/object:Gem::Version
|
|
101
103
|
version: '0'
|
|
102
104
|
type: :development
|
|
103
105
|
prerelease: false
|
|
104
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
105
|
-
none: false
|
|
106
107
|
requirements:
|
|
107
|
-
- -
|
|
108
|
+
- - ">="
|
|
108
109
|
- !ruby/object:Gem::Version
|
|
109
110
|
version: '0'
|
|
110
111
|
- !ruby/object:Gem::Dependency
|
|
111
112
|
name: rake
|
|
112
113
|
requirement: !ruby/object:Gem::Requirement
|
|
113
|
-
none: false
|
|
114
114
|
requirements:
|
|
115
|
-
- -
|
|
115
|
+
- - ">="
|
|
116
116
|
- !ruby/object:Gem::Version
|
|
117
117
|
version: '0'
|
|
118
118
|
type: :development
|
|
119
119
|
prerelease: false
|
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
-
none: false
|
|
122
121
|
requirements:
|
|
123
|
-
- -
|
|
122
|
+
- - ">="
|
|
124
123
|
- !ruby/object:Gem::Version
|
|
125
124
|
version: '0'
|
|
126
125
|
- !ruby/object:Gem::Dependency
|
|
127
126
|
name: forgery
|
|
128
127
|
requirement: !ruby/object:Gem::Requirement
|
|
129
|
-
none: false
|
|
130
128
|
requirements:
|
|
131
|
-
- -
|
|
129
|
+
- - ">="
|
|
132
130
|
- !ruby/object:Gem::Version
|
|
133
131
|
version: '0'
|
|
134
132
|
type: :development
|
|
135
133
|
prerelease: false
|
|
136
134
|
version_requirements: !ruby/object:Gem::Requirement
|
|
137
|
-
none: false
|
|
138
135
|
requirements:
|
|
139
|
-
- -
|
|
136
|
+
- - ">="
|
|
140
137
|
- !ruby/object:Gem::Version
|
|
141
138
|
version: '0'
|
|
142
139
|
description: ActivePayment is an abstraction layer for different Payment-Interfaces
|
|
@@ -147,25 +144,24 @@ executables: []
|
|
|
147
144
|
extensions: []
|
|
148
145
|
extra_rdoc_files: []
|
|
149
146
|
files:
|
|
150
|
-
- .gitignore
|
|
151
|
-
- .
|
|
152
|
-
- .
|
|
153
|
-
- .travis.yml
|
|
147
|
+
- ".gitignore"
|
|
148
|
+
- ".ruby-version"
|
|
149
|
+
- ".travis.yml"
|
|
154
150
|
- Gemfile
|
|
155
|
-
- README.
|
|
151
|
+
- README.md
|
|
156
152
|
- Rakefile
|
|
157
153
|
- activepayment.gemspec
|
|
154
|
+
- doc/WD_card_processing_4_0_0.pdf
|
|
155
|
+
- doc/WD_country¤cy_codes_1-1-0_en.pdf
|
|
156
|
+
- doc/WD_https_gateway_2-3-0_en.pdf
|
|
158
157
|
- lib/activepayment.rb
|
|
159
158
|
- lib/activepayment/gateway_base.rb
|
|
160
|
-
- lib/activepayment/
|
|
161
|
-
- lib/activepayment/payone/response.rb
|
|
159
|
+
- lib/activepayment/paypal/gateway.rb
|
|
162
160
|
- lib/activepayment/railtie.rb
|
|
163
161
|
- lib/activepayment/version.rb
|
|
164
162
|
- lib/activepayment/wirecard/gateway.rb
|
|
165
163
|
- lib/activepayment/wirecard/response.rb
|
|
166
164
|
- spec/fixtures/activepayment_config.yml
|
|
167
|
-
- spec/fixtures/payone/gateway/authorization_request.txt
|
|
168
|
-
- spec/fixtures/payone/gateway/successful_authorization_response.txt
|
|
169
165
|
- spec/fixtures/wirecard/gateway/authorization_request.xml
|
|
170
166
|
- spec/fixtures/wirecard/gateway/authorization_request_with_address.xml
|
|
171
167
|
- spec/fixtures/wirecard/gateway/capture_authorization_request.xml
|
|
@@ -174,38 +170,50 @@ files:
|
|
|
174
170
|
- spec/fixtures/wirecard/gateway/purchase_request_with_3d.xml
|
|
175
171
|
- spec/fixtures/wirecard/gateway/successful_authorization_response.xml
|
|
176
172
|
- spec/fixtures/wirecard/gateway/successful_capture_response.xml
|
|
177
|
-
- spec/functional/payone/config.yml
|
|
178
|
-
- spec/functional/payone/payone_spec.rb
|
|
179
173
|
- spec/functional/wirecard/config.yml
|
|
180
174
|
- spec/functional/wirecard/wirecard_spec.rb
|
|
181
175
|
- spec/spec_helper.rb
|
|
182
176
|
- spec/unit/gateway_base_spec.rb
|
|
183
|
-
- spec/unit/
|
|
184
|
-
- spec/unit/payone/response_spec.rb
|
|
177
|
+
- spec/unit/paypal/gateway_spec.rb
|
|
185
178
|
- spec/unit/wirecard/gateway_spec.rb
|
|
186
179
|
- spec/unit/wirecard/response_spec.rb
|
|
187
180
|
homepage: ''
|
|
188
181
|
licenses: []
|
|
182
|
+
metadata: {}
|
|
189
183
|
post_install_message:
|
|
190
184
|
rdoc_options: []
|
|
191
185
|
require_paths:
|
|
192
186
|
- lib
|
|
193
187
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
194
|
-
none: false
|
|
195
188
|
requirements:
|
|
196
|
-
- -
|
|
189
|
+
- - ">="
|
|
197
190
|
- !ruby/object:Gem::Version
|
|
198
191
|
version: '0'
|
|
199
192
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
|
-
none: false
|
|
201
193
|
requirements:
|
|
202
|
-
- -
|
|
194
|
+
- - ">="
|
|
203
195
|
- !ruby/object:Gem::Version
|
|
204
196
|
version: '0'
|
|
205
197
|
requirements: []
|
|
206
198
|
rubyforge_project: activepayment
|
|
207
|
-
rubygems_version:
|
|
199
|
+
rubygems_version: 2.2.2
|
|
208
200
|
signing_key:
|
|
209
|
-
specification_version:
|
|
201
|
+
specification_version: 4
|
|
210
202
|
summary: CreditCard transactions framework
|
|
211
|
-
test_files:
|
|
203
|
+
test_files:
|
|
204
|
+
- spec/fixtures/activepayment_config.yml
|
|
205
|
+
- spec/fixtures/wirecard/gateway/authorization_request.xml
|
|
206
|
+
- spec/fixtures/wirecard/gateway/authorization_request_with_address.xml
|
|
207
|
+
- spec/fixtures/wirecard/gateway/capture_authorization_request.xml
|
|
208
|
+
- spec/fixtures/wirecard/gateway/enrollment_check_request.xml
|
|
209
|
+
- spec/fixtures/wirecard/gateway/purchase_request.xml
|
|
210
|
+
- spec/fixtures/wirecard/gateway/purchase_request_with_3d.xml
|
|
211
|
+
- spec/fixtures/wirecard/gateway/successful_authorization_response.xml
|
|
212
|
+
- spec/fixtures/wirecard/gateway/successful_capture_response.xml
|
|
213
|
+
- spec/functional/wirecard/config.yml
|
|
214
|
+
- spec/functional/wirecard/wirecard_spec.rb
|
|
215
|
+
- spec/spec_helper.rb
|
|
216
|
+
- spec/unit/gateway_base_spec.rb
|
|
217
|
+
- spec/unit/paypal/gateway_spec.rb
|
|
218
|
+
- spec/unit/wirecard/gateway_spec.rb
|
|
219
|
+
- spec/unit/wirecard/response_spec.rb
|
data/.rspec
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
--colour
|
data/.rvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
rvm --create use 1.9.2-p290
|
data/README.rdoc
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
= ActivePayment
|
|
2
|
-
|
|
3
|
-
ActivePayment is an abstraction layer for different Payment-Interfaces (XML, JSON)
|
|
4
|
-
|
|
5
|
-
== Compatibility
|
|
6
|
-
|
|
7
|
-
activepayment is tested against Ruby 1.9.2 .
|
|
8
|
-
|
|
9
|
-
{<img src="http://travis-ci.org/aklaiber/activepayment.png" />}[http://travis-ci.org/aklaiber/activepayment]
|
|
10
|
-
|
|
11
|
-
== Install
|
|
12
|
-
|
|
13
|
-
gem install activepayment
|
|
14
|
-
|
|
15
|
-
or add the following line to Gemfile:
|
|
16
|
-
|
|
17
|
-
gem 'activepayment'
|
|
18
|
-
|
|
19
|
-
and run bundle install from your shell.
|
|
20
|
-
|
|
21
|
-
== Examples
|
|
22
|
-
|
|
23
|
-
=== Config
|
|
24
|
-
|
|
25
|
-
ActivePayment::Payone::Gateway.config = {:mid => 123456, :portalid => 1234, :key => 'test', :mode => 'test'}
|
|
26
|
-
|
|
27
|
-
=== Post request
|
|
28
|
-
|
|
29
|
-
gateway = ActivePayment::Payone::Gateway.new
|
|
30
|
-
|
|
31
|
-
gateway.authorization
|
|
32
|
-
gateway.createaccess
|
|
33
|
-
gateway.updateuser(:userid => 123)
|
|
34
|
-
gateway.updateaccess(:accessid => 123, :action => 'update')
|
|
35
|
-
gateway.threedscheck(:cardpan => "4111111111111111", :exiturl => "http://www.example.com")
|
|
36
|
-
gateway.updatereminder(:txid => 123, :reminderlevel => 2)
|
|
37
|
-
|
|
38
|
-
== Supported Gateways
|
|
39
|
-
|
|
40
|
-
* {Payone}[http://www.payone.de] - DE
|
|
41
|
-
* {Wirecard}[http://www.wirecard.com] - DE
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
module ActivePayment
|
|
2
|
-
module Payone
|
|
3
|
-
class Gateway < ActivePayment::Gateway::Base
|
|
4
|
-
|
|
5
|
-
class_attribute :mid, :portalid, :key, :mode
|
|
6
|
-
|
|
7
|
-
self.gateway_name = "payone"
|
|
8
|
-
self.test_url = 'https://api.pay1.de/post-gateway/'
|
|
9
|
-
self.live_url = 'https://api.pay1.de/post-gateway/'
|
|
10
|
-
self.default_currency = 'EUR'
|
|
11
|
-
|
|
12
|
-
private
|
|
13
|
-
|
|
14
|
-
def self.define_request(name, options = {})
|
|
15
|
-
define_method(name) do |local_params = {}|
|
|
16
|
-
post_request(self.send("#{name}_request", local_params))
|
|
17
|
-
end
|
|
18
|
-
define_method("#{name}_request") do |local_params = {}|
|
|
19
|
-
request_method = options[:request_method].blank? ? name : options[:request_method]
|
|
20
|
-
build_request(request_method, options) do |params|
|
|
21
|
-
params.merge!(local_params)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
public
|
|
27
|
-
|
|
28
|
-
define_request :authorization, :obligation_params => [:aid, :amount, :currency, :reference], :default => {:currency => self.default_currency}
|
|
29
|
-
define_request :createaccess, :obligation_params => [:aid, :reference]
|
|
30
|
-
define_request :updateuser, :obligation_params => [:userid]
|
|
31
|
-
define_request :updateaccess, :obligation_params => [:accessid, :action]
|
|
32
|
-
define_request :updatereminder, :obligation_params => [:txid]
|
|
33
|
-
define_request :threedscheck, :request_method => '3dscheck', :obligation_params => [:aid], :default => {:currency => self.default_currency}
|
|
34
|
-
|
|
35
|
-
private
|
|
36
|
-
|
|
37
|
-
def add_optional_param(params, name, value = nil)
|
|
38
|
-
if value.blank? && self.transaction_params.include?(name) && !self.transaction_params[name].blank?
|
|
39
|
-
value = self.transaction_params[name]
|
|
40
|
-
end
|
|
41
|
-
unless value.blank?
|
|
42
|
-
params[name] = value
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def build_request(method, options = {}, &block)
|
|
47
|
-
params = {:mid => self.mid, :portalid => self.portalid, :key => Digest::MD5.new.hexdigest(self.key), :mode => self.mode, :request => method}
|
|
48
|
-
params.merge!(options[:default]) if options[:default]
|
|
49
|
-
params.merge!(self.transaction_params) if self.transaction_params
|
|
50
|
-
yield params
|
|
51
|
-
check_params(params, options[:obligation_params]) if options[:obligation_params]
|
|
52
|
-
params.to_query
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def check_params(params, obligation_params)
|
|
56
|
-
obligation_params.each do |obligation_param|
|
|
57
|
-
if !params.include?(obligation_param)
|
|
58
|
-
raise Exception, "Payone API Parameters not complete: #{obligation_param} not exists"
|
|
59
|
-
elsif params[obligation_param].blank?
|
|
60
|
-
raise Exception, "Payone API Parameters not complete: #{obligation_param} is nil or empty"
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def post_request(content)
|
|
66
|
-
http_connection do |http|
|
|
67
|
-
response = http.post(self.url.path, content, {'Content-Type'=> 'application/x-www-form-urlencoded'})
|
|
68
|
-
unless response.blank?
|
|
69
|
-
return ActivePayment::Payone::Response.new(response.body)
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
module ActivePayment
|
|
2
|
-
module Payone
|
|
3
|
-
class Response
|
|
4
|
-
|
|
5
|
-
def initialize(content)
|
|
6
|
-
@content = content
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def to_s
|
|
10
|
-
@content.to_s
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def [](key)
|
|
14
|
-
@content.split("\n").each do |param|
|
|
15
|
-
param_key, param_value = param.scan(/([^=]+)=(.+)/).first
|
|
16
|
-
if param_key.eql?(key.to_s)
|
|
17
|
-
return param_value
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def successful?
|
|
23
|
-
self.status.eql?('APPROVED') || self.status.eql?('REDIRECT') || self.status.eql?('OK')
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def failed?
|
|
27
|
-
self.status.eql?('ERROR')
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def method_missing(method, *args)
|
|
31
|
-
value = self[method]
|
|
32
|
-
unless value.blank?
|
|
33
|
-
value
|
|
34
|
-
else
|
|
35
|
-
super
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
aid=18270&amount=100&cardcvc2=233&cardexpiredate=1202&cardholder=John+Doe&cardpan=4901170005495083&cardtype=V&clearingtype=cc¤cy=EUR&key=0&mid=18268&mode=test&portalid=2226&reference=00000000000000000001&request=authorization
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe ActivePayment::Payone::Gateway do
|
|
4
|
-
|
|
5
|
-
let(:amount) { 100 }
|
|
6
|
-
let(:gateway) { ActivePayment::Payone::Gateway.new(amount) }
|
|
7
|
-
|
|
8
|
-
before(:each) do
|
|
9
|
-
gateway.transaction_params = {
|
|
10
|
-
:aid => 18270,
|
|
11
|
-
:clearingtype => 'cc',
|
|
12
|
-
:cardholder => "John Doe",
|
|
13
|
-
:cardexpiredate => "#{(Date.today + 1.year).strftime("%y")}02",
|
|
14
|
-
:cardtype => "V",
|
|
15
|
-
:cardpan => "4111111111111111",
|
|
16
|
-
:cardcvc2 => 233,
|
|
17
|
-
:lastname => 'Doe',
|
|
18
|
-
:firstname => 'John',
|
|
19
|
-
:country => 'DE',
|
|
20
|
-
:productid => 4893,
|
|
21
|
-
:amount => amount,
|
|
22
|
-
:reference => 'test'
|
|
23
|
-
}
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
describe "Portal Zugang" do
|
|
27
|
-
|
|
28
|
-
let(:payone_response) { gateway.createaccess(:reference => Time.now.to_i + rand(10000)) }
|
|
29
|
-
let(:payone_user_id) { payone_response.userid }
|
|
30
|
-
let(:payone_access_id) { payone_response.accessid }
|
|
31
|
-
|
|
32
|
-
before(:all) do
|
|
33
|
-
ActivePayment::Payone::Gateway.config = load_config('payone', 'zugang')
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it "should post createaccess request" do
|
|
37
|
-
response = gateway.createaccess(:reference => Time.now.to_i + rand(10000))
|
|
38
|
-
|
|
39
|
-
response.successful?.should be_true
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it "should post updateuser request" do
|
|
43
|
-
response = gateway.updateuser(:userid => payone_user_id, :street => "teststr.1")
|
|
44
|
-
|
|
45
|
-
response.successful?.should be_true
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it "should post updateaccess request" do
|
|
49
|
-
response = gateway.updateaccess(:accessid => payone_access_id, :action => 'update')
|
|
50
|
-
|
|
51
|
-
response.successful?.should be_true
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
describe "Portal Shop" do
|
|
56
|
-
before(:all) do
|
|
57
|
-
ActivePayment::Payone::Gateway.config = load_config('payone', 'shop')
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
it "should post authorization request" do
|
|
61
|
-
response = gateway.authorization(:reference => Time.now.to_i + rand(10000))
|
|
62
|
-
|
|
63
|
-
response.successful?.should be_true
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
end
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe ActivePayment::Payone::Gateway do
|
|
4
|
-
|
|
5
|
-
let(:amount) { 100 }
|
|
6
|
-
let(:gateway) { ActivePayment::Payone::Gateway.new(amount) }
|
|
7
|
-
|
|
8
|
-
before(:all) do
|
|
9
|
-
ActivePayment::Payone::Gateway.mid = 18268
|
|
10
|
-
ActivePayment::Payone::Gateway.portalid = 2226
|
|
11
|
-
ActivePayment::Payone::Gateway.key = 'test'
|
|
12
|
-
ActivePayment::Payone::Gateway.mode = "test"
|
|
13
|
-
|
|
14
|
-
gateway.transaction_params = {
|
|
15
|
-
:aid => 18270,
|
|
16
|
-
:productid => 123,
|
|
17
|
-
:clearingtype => 'cc',
|
|
18
|
-
:cardholder => "John Doe",
|
|
19
|
-
:cardexpiredate => "1202",
|
|
20
|
-
:cardtype => "V",
|
|
21
|
-
:cardpan => "4901170005495083",
|
|
22
|
-
:cardcvc2 => 233,
|
|
23
|
-
:reference => "00000000000000000001",
|
|
24
|
-
:amount => amount
|
|
25
|
-
}
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it "should build authorization request" do
|
|
29
|
-
request = gateway.authorization_request
|
|
30
|
-
|
|
31
|
-
request.should_not be_blank
|
|
32
|
-
request.should include('request=authorization')
|
|
33
|
-
request.should include('aid=18270')
|
|
34
|
-
request.should include('clearingtype=cc')
|
|
35
|
-
request.should include('reference=00000000000000000001')
|
|
36
|
-
request.should include('amount=100')
|
|
37
|
-
request.should include('currency=EUR')
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it "should build createaccess request" do
|
|
41
|
-
request = gateway.createaccess_request
|
|
42
|
-
|
|
43
|
-
request.should_not be_blank
|
|
44
|
-
request.should include('request=createaccess')
|
|
45
|
-
request.should include('aid=18270')
|
|
46
|
-
request.should include('clearingtype=cc')
|
|
47
|
-
request.should include('reference=00000000000000000001')
|
|
48
|
-
request.should include('productid=123')
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it "should build updateuser request" do
|
|
52
|
-
request = gateway.updateuser_request(:userid => 123)
|
|
53
|
-
|
|
54
|
-
request.should_not be_blank
|
|
55
|
-
request.should include('request=updateuser')
|
|
56
|
-
request.should include('userid=123')
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it "should build updateaccess request" do
|
|
60
|
-
request = gateway.updateaccess_request(:accessid => 123, :action => 'update')
|
|
61
|
-
|
|
62
|
-
request.should_not be_blank
|
|
63
|
-
request.should include('request=updateaccess')
|
|
64
|
-
request.should include('accessid=123')
|
|
65
|
-
request.should include('action=update')
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
it "should build 3dscheck request" do
|
|
69
|
-
request = gateway.threedscheck_request(:cardpan => "4111111111111111", :exiturl => "http://www.example.com")
|
|
70
|
-
|
|
71
|
-
request.should_not be_blank
|
|
72
|
-
request.should include('request=3dscheck')
|
|
73
|
-
request.should include('amount=100')
|
|
74
|
-
request.should include('currency=EUR')
|
|
75
|
-
request.should include('clearingtype=cc')
|
|
76
|
-
request.should include('exiturl=http%3A%2F%2Fwww.example.com')
|
|
77
|
-
request.should include('cardpan=4111111111111111')
|
|
78
|
-
request.should include('cardtype=V')
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
it "should build updatereminder request" do
|
|
82
|
-
request = gateway.updatereminder_request(:txid => 123, :reminderlevel => 2)
|
|
83
|
-
|
|
84
|
-
request.should_not be_blank
|
|
85
|
-
request.should include('txid=123')
|
|
86
|
-
request.should include('reminderlevel=2')
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it "should get exception if forget mandatory parameter" do
|
|
90
|
-
gateway.transaction_params.delete(:reference)
|
|
91
|
-
lambda { gateway.createaccess_request }.should raise_exception(ActivePayment::Exception, "Payone API Parameters not complete: reference not exists")
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
describe "config" do
|
|
95
|
-
it 'should set by methods' do
|
|
96
|
-
ActivePayment::Payone::Gateway.mid = 1
|
|
97
|
-
ActivePayment::Payone::Gateway.portalid = 2
|
|
98
|
-
ActivePayment::Payone::Gateway.key = "test_key"
|
|
99
|
-
|
|
100
|
-
ActivePayment::Payone::Gateway.mid.should eql(1)
|
|
101
|
-
ActivePayment::Payone::Gateway.portalid.should eql(2)
|
|
102
|
-
ActivePayment::Payone::Gateway.key.should eql("test_key")
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
it 'should set by hash' do
|
|
106
|
-
ActivePayment::Payone::Gateway.config = {:mid => 1, :portalid => 2, :key => "test_key"}
|
|
107
|
-
|
|
108
|
-
ActivePayment::Payone::Gateway.mid.should eql(1)
|
|
109
|
-
ActivePayment::Payone::Gateway.portalid.should eql(2)
|
|
110
|
-
ActivePayment::Payone::Gateway.key.should eql("test_key")
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
it 'should set by block' do
|
|
114
|
-
ActivePayment::Payone::Gateway.config do |c|
|
|
115
|
-
c.mid = 1
|
|
116
|
-
c.portalid = 2
|
|
117
|
-
c.key = "test_key"
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
ActivePayment::Payone::Gateway.mid.should eql(1)
|
|
121
|
-
ActivePayment::Payone::Gateway.portalid.should eql(2)
|
|
122
|
-
ActivePayment::Payone::Gateway.key.should eql("test_key")
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
it 'should set by yml' do
|
|
126
|
-
File.open("#{FIXTURES_PATH}/activepayment_config.yml") do |config_file|
|
|
127
|
-
ActivePayment::Payone::Gateway.config = YAML.load(config_file.read)['development']
|
|
128
|
-
|
|
129
|
-
ActivePayment::Payone::Gateway.mid.should eql(1)
|
|
130
|
-
ActivePayment::Payone::Gateway.portalid.should eql(2)
|
|
131
|
-
ActivePayment::Payone::Gateway.key.should eql("test_key")
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe ActivePayment::Payone::Response do
|
|
4
|
-
|
|
5
|
-
it "should get params by []" do
|
|
6
|
-
File.open("#{FIXTURES_PATH}/payone/gateway/successful_authorization_response.txt") do |file|
|
|
7
|
-
response = ActivePayment::Payone::Response.new(file.read)
|
|
8
|
-
response[:status].should eql('APPROVED')
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it "should get params by method" do
|
|
13
|
-
File.open("#{FIXTURES_PATH}/payone/gateway/successful_authorization_response.txt") do |file|
|
|
14
|
-
response = ActivePayment::Payone::Response.new(file.read)
|
|
15
|
-
response.status.should eql('APPROVED')
|
|
16
|
-
response.successful?.should be_true
|
|
17
|
-
response.failed?.should be_false
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
end
|