activemerchant-clickandbuy 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.rspec +3 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +47 -0
- data/LICENSE.txt +22 -0
- data/README.md +68 -0
- data/Rakefile +1 -0
- data/activemerchant-clickandbuy.gemspec +21 -0
- data/lib/active_merchant/billing/clickand_buy_gateway.rb +42 -0
- data/lib/active_merchant/clickand_buy/request/base.rb +58 -0
- data/lib/active_merchant/clickand_buy/request/pay_request.rb +32 -0
- data/lib/active_merchant/clickand_buy/request/status_request.rb +21 -0
- data/lib/active_merchant/clickand_buy/version.rb +5 -0
- data/lib/activemerchant-clickandbuy.rb +3 -0
- data/spec/active_merchant/billing/clickand_buy_gateway_spec.rb +71 -0
- data/spec/active_merchant/clickand_buy/request/pay_request_spec.rb +85 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/support/clickand_buy.yml.example +3 -0
- data/spec/support/requests/pay_request_response.xml +1 -0
- metadata +101 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
/spec/support/clickand_buy.yml
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
activemerchant-clickandbuy (0.1.0)
|
5
|
+
activemerchant
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
active_utils (1.0.5)
|
11
|
+
activesupport (>= 2.3.11)
|
12
|
+
i18n
|
13
|
+
activemerchant (1.28.0)
|
14
|
+
active_utils (>= 1.0.2)
|
15
|
+
activesupport (>= 2.3.11)
|
16
|
+
builder (>= 2.0.0)
|
17
|
+
i18n
|
18
|
+
json (>= 1.5.1)
|
19
|
+
money
|
20
|
+
nokogiri
|
21
|
+
activesupport (3.2.8)
|
22
|
+
i18n (~> 0.6)
|
23
|
+
multi_json (~> 1.0)
|
24
|
+
builder (3.1.3)
|
25
|
+
diff-lcs (1.1.3)
|
26
|
+
i18n (0.6.1)
|
27
|
+
json (1.7.5)
|
28
|
+
money (5.0.0)
|
29
|
+
i18n (~> 0.4)
|
30
|
+
json
|
31
|
+
multi_json (1.3.6)
|
32
|
+
nokogiri (1.5.5)
|
33
|
+
rspec (2.11.0)
|
34
|
+
rspec-core (~> 2.11.0)
|
35
|
+
rspec-expectations (~> 2.11.0)
|
36
|
+
rspec-mocks (~> 2.11.0)
|
37
|
+
rspec-core (2.11.1)
|
38
|
+
rspec-expectations (2.11.3)
|
39
|
+
diff-lcs (~> 1.1.3)
|
40
|
+
rspec-mocks (2.11.3)
|
41
|
+
|
42
|
+
PLATFORMS
|
43
|
+
ruby
|
44
|
+
|
45
|
+
DEPENDENCIES
|
46
|
+
activemerchant-clickandbuy!
|
47
|
+
rspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Olek Janiszewski
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Active Merchant ClickandBuy gateway
|
2
|
+
|
3
|
+
This gem provides integration of ClickandBuy (http://www.clickandbuy.com) with Active Merchant (http://activemerchant.org).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'activemerchant-clickandbuy'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install activemerchant-clickandbuy
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
To use the gateway, you'll need to provide your merchant ID, project ID and secret key:
|
22
|
+
|
23
|
+
auth = {merchant_id: 'foo', project_id: 'bar', secret_key: 'baz'}
|
24
|
+
gateway = ActiveMerchant::Billing::ClickandBuyGateway.new(auth)
|
25
|
+
|
26
|
+
Now you can initiate a transaction at ClickandBuy:
|
27
|
+
|
28
|
+
amount = Money.new(1000, 'EUR')
|
29
|
+
options = {
|
30
|
+
success_url: 'https://www.your-site.com/callback/success', # where to redirect the user on success
|
31
|
+
failure_url: 'https://www.your-site.com/callback/failure', # where to redirect the user on failure
|
32
|
+
order_id: 123, # your unique order identifier
|
33
|
+
ip: '1.2.3.4', # user's IP address
|
34
|
+
order_description: 'ACME Earthquake Pills', # what the user is buying
|
35
|
+
locale: 'en', # user's locale ('en' or 'de')
|
36
|
+
success_expiration: 1439 # (optional) how many minutes to wait for success
|
37
|
+
}
|
38
|
+
response = gateway.setup_purchase(amount, options)
|
39
|
+
|
40
|
+
The `response` hash will contain amongst other keys two important ones: `transactionID` and `redirectURL`.
|
41
|
+
The `transactionID` identifies the transaction at ClickandBuy, make sure you store it together with your order.
|
42
|
+
The `redirectURL` is where you redirect the user so that they can confirm the purchase.
|
43
|
+
|
44
|
+
After a user lands on `success_url`, you can check whether or not the transaction had been confirmed:
|
45
|
+
|
46
|
+
transaction = gateway.check_status(transaction_id)
|
47
|
+
|
48
|
+
The `transaction` variable is a hash containing the response details, amongst others a `transactionStatus` key.
|
49
|
+
|
50
|
+
## Running specs
|
51
|
+
|
52
|
+
Copy `spec/support/clickand_buy.yml.example` to `spec/support/clickand_buy.yml`. Now run:
|
53
|
+
|
54
|
+
bundle exec rspec
|
55
|
+
|
56
|
+
By default, only "fast" specs will be running (the API will not be hit). In order to be able
|
57
|
+
to execute remote specs, populate the `clickand_buy.yml` file with your staging account's
|
58
|
+
authentication credentials. To run the remote specs, run the following:
|
59
|
+
|
60
|
+
bundle exec rspec --tag remote
|
61
|
+
|
62
|
+
## Contributing
|
63
|
+
|
64
|
+
1. Fork it
|
65
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
66
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
67
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
68
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'active_merchant/clickand_buy/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = 'activemerchant-clickandbuy'
|
7
|
+
gem.version = ActiveMerchant::ClickandBuy::VERSION
|
8
|
+
gem.authors = ['Olek Janiszewski']
|
9
|
+
gem.email = ['olek.janiszewski@gmail.com']
|
10
|
+
gem.description = %q{This gem provides integration of ClickandBuy with Active Merchant}
|
11
|
+
gem.summary = %q{Integration of ClickandBuy with Active Merchant}
|
12
|
+
gem.homepage = "https://github.com/exviva/activemerchant-clickandbuy"
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($/)
|
15
|
+
gem.test_files = gem.files.grep(%r{^spec/})
|
16
|
+
gem.require_paths = ['lib']
|
17
|
+
|
18
|
+
gem.add_runtime_dependency 'activemerchant'
|
19
|
+
|
20
|
+
gem.add_development_dependency 'rspec'
|
21
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'active_merchant/clickand_buy/request/pay_request'
|
2
|
+
require 'active_merchant/clickand_buy/request/status_request'
|
3
|
+
|
4
|
+
module ActiveMerchant
|
5
|
+
module Billing
|
6
|
+
class ClickandBuyGateway < Gateway
|
7
|
+
self.test_url = 'https://api.clickandbuy-s1.com/webservices/soap/pay_1_1_0'
|
8
|
+
self.live_url = 'https://api.clickandbuy.com/webservices/soap/pay_1_1_0'
|
9
|
+
|
10
|
+
self.homepage_url = 'http://www.clickandbuy.com'
|
11
|
+
self.display_name = 'ClickandBuy'
|
12
|
+
|
13
|
+
def initialize(auth)
|
14
|
+
requires!(auth, :project_id, :merchant_id, :secret_key)
|
15
|
+
@auth = auth
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup_purchase(amount, options)
|
19
|
+
requires!(options, :success_url, :failure_url, :order_id, :ip, :order_description, :locale)
|
20
|
+
perform(ClickandBuy::Request::PayRequest.new(@auth, amount, options))
|
21
|
+
end
|
22
|
+
|
23
|
+
def check_status(transaction_id)
|
24
|
+
perform(ClickandBuy::Request::StatusRequest.new(@auth, transaction_id))
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def perform(request)
|
29
|
+
response_string = ssl_post(endpoint_url, request.body, headers)
|
30
|
+
request.handle_response(response_string)
|
31
|
+
end
|
32
|
+
|
33
|
+
def headers
|
34
|
+
{'Content-Type' => 'text/xml; charset=UTF-8'}
|
35
|
+
end
|
36
|
+
|
37
|
+
def endpoint_url
|
38
|
+
test? ? test_url : live_url
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module ActiveMerchant::ClickandBuy::Request
|
2
|
+
class Base
|
3
|
+
def initialize(auth)
|
4
|
+
@auth = auth
|
5
|
+
end
|
6
|
+
|
7
|
+
def body
|
8
|
+
xml = Builder::XmlMarkup.new
|
9
|
+
xml.instruct!
|
10
|
+
|
11
|
+
xml.SOAP :Envelope, 'xmlns:SOAP' => 'http://schemas.xmlsoap.org/soap/envelope/' do
|
12
|
+
xml.SOAP :Body do
|
13
|
+
xml.tag! request_tag, xmlns: 'http://api.clickandbuy.com/webservices/pay_1_1_0/' do
|
14
|
+
xml.authentication do
|
15
|
+
xml.merchantID @auth[:merchant_id]
|
16
|
+
xml.projectID @auth[:project_id]
|
17
|
+
xml.token token
|
18
|
+
end
|
19
|
+
|
20
|
+
xml.details do
|
21
|
+
details(xml)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
xml.target!
|
28
|
+
end
|
29
|
+
|
30
|
+
def handle_response(response_string)
|
31
|
+
response = Hash.from_xml(response_string)
|
32
|
+
extract_response_details(response['Envelope']['Body'][response_tag])
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
def details; raise NotImplementedError end
|
37
|
+
def extract_response_details(response); raise NotImplementedError end
|
38
|
+
|
39
|
+
def token
|
40
|
+
timestamp = Time.now.utc.strftime('%Y%m%d%H%M%S')
|
41
|
+
hash_input = [@auth[:project_id], @auth[:secret_key], timestamp].join('::')
|
42
|
+
hash = Digest::SHA1.hexdigest(hash_input)
|
43
|
+
[timestamp, hash].join('::')
|
44
|
+
end
|
45
|
+
|
46
|
+
def request_name
|
47
|
+
self.class.name.demodulize.camelize(:lower)
|
48
|
+
end
|
49
|
+
|
50
|
+
def request_tag
|
51
|
+
"#{request_name}_Request"
|
52
|
+
end
|
53
|
+
|
54
|
+
def response_tag
|
55
|
+
"#{request_name}_Response"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'active_merchant/clickand_buy/request/base'
|
2
|
+
|
3
|
+
module ActiveMerchant::ClickandBuy::Request
|
4
|
+
class PayRequest < Base
|
5
|
+
def initialize(auth, amount, options)
|
6
|
+
super(auth)
|
7
|
+
@amount = amount
|
8
|
+
@options = options
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
def details(xml)
|
13
|
+
xml.amount do
|
14
|
+
xml.amount sprintf('%.2f', @amount.to_f)
|
15
|
+
xml.currency @amount.currency_as_string
|
16
|
+
end
|
17
|
+
xml.orderDetails do
|
18
|
+
xml.text @options[:order_description]
|
19
|
+
end
|
20
|
+
xml.successURL @options[:success_url]
|
21
|
+
xml.failureURL @options[:failure_url]
|
22
|
+
xml.externalID @options[:order_id]
|
23
|
+
xml.consumerIPAddress @options[:ip]
|
24
|
+
xml.consumerLanguage @options[:locale]
|
25
|
+
xml.successExpiration @options[:success_expiration] if @options.key?(:success_expiration)
|
26
|
+
end
|
27
|
+
|
28
|
+
def extract_response_details(response)
|
29
|
+
response['transaction']
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'active_merchant/clickand_buy/request/base'
|
2
|
+
|
3
|
+
module ActiveMerchant::ClickandBuy::Request
|
4
|
+
class StatusRequest < Base
|
5
|
+
def initialize(auth, transaction_id)
|
6
|
+
super(auth)
|
7
|
+
@transaction_id = transaction_id
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
def details(xml)
|
12
|
+
xml.transactionIDList do
|
13
|
+
xml.transactionID @transaction_id
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def extract_response_details(response)
|
18
|
+
response['transactionList']['transaction']
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveMerchant::Billing::ClickandBuyGateway do
|
4
|
+
let(:auth) { YAML.load_file(File.expand_path('../../../support/clickand_buy.yml', __FILE__)) }
|
5
|
+
let(:gateway) { described_class.new(auth) }
|
6
|
+
let(:amount) { Money.new(1000, 'EUR') }
|
7
|
+
let(:order_id) { Time.now.to_i }
|
8
|
+
let(:setup_purchase_options) { {success_url: 'http://example.com', failure_url: 'http://example.com', order_id: order_id, ip: '1.2.3.4', order_description: '', locale: 'en', success_expiration: 30} }
|
9
|
+
|
10
|
+
def perform_setup_purchase
|
11
|
+
gateway.setup_purchase(amount, setup_purchase_options)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#initialize' do
|
15
|
+
[:project_id, :merchant_id, :secret_key].each do |key|
|
16
|
+
it "requires #{key} in auth" do
|
17
|
+
expect { described_class.new(auth.except(key)) }.to raise_error(ArgumentError)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#setup_purchase' do
|
23
|
+
subject { perform_setup_purchase }
|
24
|
+
|
25
|
+
[:success_url, :failure_url, :order_id, :ip, :order_description, :locale].each do |key|
|
26
|
+
context "without #{key} in options" do
|
27
|
+
subject { gateway.setup_purchase(amount, setup_purchase_options.except(key)) }
|
28
|
+
|
29
|
+
it 'raises an argument error' do
|
30
|
+
expect { subject }.to raise_error(ArgumentError)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns a hash with transaction details', :remote do
|
36
|
+
subject.should be_a(Hash)
|
37
|
+
|
38
|
+
subject['transactionID'].should match(/\d+/)
|
39
|
+
subject['transactionStatus'].should eq('CREATED')
|
40
|
+
subject['transactionType'].should eq('PAY')
|
41
|
+
subject['externalID'].should eq(order_id.to_s)
|
42
|
+
|
43
|
+
URI.parse(subject['redirectURL']).tap do |redirect_url|
|
44
|
+
redirect_url.scheme.should eq('https')
|
45
|
+
redirect_url.host.should eq('checkout.clickandbuy-s1.com')
|
46
|
+
redirect_url.path.should eq('/frontend/secure/checkout')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#check_status', :remote do
|
52
|
+
let(:transaction_id) { '123' }
|
53
|
+
subject { gateway.check_status(transaction_id) }
|
54
|
+
|
55
|
+
it 'returns the transaction ID' do
|
56
|
+
subject['transactionID'].should eq('123')
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'returns an error if transaction not found' do
|
60
|
+
subject['errorDetails']['code'].should eq('3')
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'with a valid transaction ID' do
|
64
|
+
let(:transaction_id) { perform_setup_purchase['transactionID'] }
|
65
|
+
|
66
|
+
it 'returns the transaction status' do
|
67
|
+
subject['transactionStatus'].should eq('CREATED')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveMerchant::ClickandBuy::Request::PayRequest do
|
4
|
+
let(:url) { proc {|variation| "http://example.com/callback/#{variation}" } }
|
5
|
+
let(:success_url) { url[:success] }
|
6
|
+
let(:failure_url) { url[:failure] }
|
7
|
+
let(:order_id) { Time.now.to_i }
|
8
|
+
let(:ip) { '1.2.3.4' }
|
9
|
+
let(:locale) { 'en' }
|
10
|
+
let(:order_description) { 'Foo bar baz' }
|
11
|
+
let(:success_url) { url[:success] }
|
12
|
+
|
13
|
+
let(:auth) { {merchant_id: 123, project_id: 456, secret_key: 'foo'} }
|
14
|
+
let(:amount) { Money.new(1000, 'EUR') }
|
15
|
+
let(:options) { {success_url: success_url, failure_url: failure_url, order_id: order_id, ip: ip, order_description: order_description, locale: locale} }
|
16
|
+
|
17
|
+
let(:request) { described_class.new(auth, amount, options) }
|
18
|
+
|
19
|
+
describe '#body' do
|
20
|
+
let(:body) { request.body }
|
21
|
+
let(:body_hash) { Hash.from_xml(request.body) }
|
22
|
+
let(:request_hash) { body_hash['Envelope']['Body']['payRequest_Request'] }
|
23
|
+
let(:details) { request_hash['details'] }
|
24
|
+
|
25
|
+
it 'uses the auth argument to provide authentication' do
|
26
|
+
authentication = request_hash['authentication']
|
27
|
+
authentication['merchantID'].should eq('123')
|
28
|
+
authentication['projectID'].should eq('456')
|
29
|
+
authentication['token'].should match(/\A\d{14}::\w{40}\z/)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'uses the amount argument to provide amount' do
|
33
|
+
amount_tag = details['amount']
|
34
|
+
amount_tag['amount'].should eq(sprintf('%.2f', amount.to_f))
|
35
|
+
amount_tag['currency'].should eq(amount.currency_as_string)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'uses the order_description option for order details text' do
|
39
|
+
text = details['orderDetails']['text']
|
40
|
+
text.should eq(order_description)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'uses the success_url option for successURL' do
|
44
|
+
details['successURL'].should eq(success_url)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'uses the failure_url option for failureURL' do
|
48
|
+
details['failureURL'].should eq(failure_url)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'uses the order_id option for externalID' do
|
52
|
+
details['externalID'].should eq(order_id.to_s)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'uses the ip option for consumerIPAddress' do
|
56
|
+
details['consumerIPAddress'].should eq(ip)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'uses the locale option for consumerLanguage' do
|
60
|
+
details['consumerLanguage'].should eq(locale)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'does not have successExpiration' do
|
64
|
+
details.should_not have_key('successExpiration')
|
65
|
+
end
|
66
|
+
|
67
|
+
describe 'with success_expiration provided' do
|
68
|
+
before { options[:success_expiration] = 1439 }
|
69
|
+
|
70
|
+
it 'uses the success_expiration option for successExpiration' do
|
71
|
+
details['successExpiration'].should eq('1439')
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#handle_response' do
|
77
|
+
let(:response_string) { File.read(File.expand_path('../../../../support/requests/pay_request_response.xml', __FILE__)) }
|
78
|
+
subject { request.handle_response(response_string) }
|
79
|
+
|
80
|
+
it 'returns the transaction hash' do
|
81
|
+
subject['transactionID'].should eq('1397737001')
|
82
|
+
subject['redirectURL'].should eq('https://checkout.clickandbuy-s1.com/frontend/secure/checkout?tx=1397737001&s=988809699F35D642&h=09FBBC928EDAA067207D4E69B5EA9CAD441D4812')
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
|
6
|
+
require 'activemerchant-clickandbuy'
|
7
|
+
require 'money'
|
8
|
+
require 'active_support/core_ext/hash/except'
|
9
|
+
|
10
|
+
ActiveMerchant::Billing::Base.mode = :test
|
11
|
+
|
12
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
15
|
+
config.run_all_when_everything_filtered = true
|
16
|
+
config.filter_run :focus
|
17
|
+
|
18
|
+
# Run specs in random order to surface order dependencies. If you find an
|
19
|
+
# order dependency and want to debug it, you can fix the order by providing
|
20
|
+
# the seed, which is printed after each run.
|
21
|
+
# --seed 1234
|
22
|
+
config.order = 'random'
|
23
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><ns2:payRequest_Response xmlns:ns2="http://api.clickandbuy.com/webservices/pay_1_1_0/"><ns2:requestTrackingID>3a121134#m1-s1#20120925165757</ns2:requestTrackingID><ns2:transaction><ns2:transactionID>1397737001</ns2:transactionID><ns2:externalID>1348592270</ns2:externalID><ns2:transactionStatus>CREATED</ns2:transactionStatus><ns2:transactionType>PAY</ns2:transactionType><ns2:redirectURL>https://checkout.clickandbuy-s1.com/frontend/secure/checkout?tx=1397737001&s=988809699F35D642&h=09FBBC928EDAA067207D4E69B5EA9CAD441D4812</ns2:redirectURL></ns2:transaction></ns2:payRequest_Response></SOAP-ENV:Body></SOAP-ENV:Envelope>
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: activemerchant-clickandbuy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Olek Janiszewski
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activemerchant
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: This gem provides integration of ClickandBuy with Active Merchant
|
47
|
+
email:
|
48
|
+
- olek.janiszewski@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- .rspec
|
55
|
+
- Gemfile
|
56
|
+
- Gemfile.lock
|
57
|
+
- LICENSE.txt
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- activemerchant-clickandbuy.gemspec
|
61
|
+
- lib/active_merchant/billing/clickand_buy_gateway.rb
|
62
|
+
- lib/active_merchant/clickand_buy/request/base.rb
|
63
|
+
- lib/active_merchant/clickand_buy/request/pay_request.rb
|
64
|
+
- lib/active_merchant/clickand_buy/request/status_request.rb
|
65
|
+
- lib/active_merchant/clickand_buy/version.rb
|
66
|
+
- lib/activemerchant-clickandbuy.rb
|
67
|
+
- spec/active_merchant/billing/clickand_buy_gateway_spec.rb
|
68
|
+
- spec/active_merchant/clickand_buy/request/pay_request_spec.rb
|
69
|
+
- spec/spec_helper.rb
|
70
|
+
- spec/support/clickand_buy.yml.example
|
71
|
+
- spec/support/requests/pay_request_response.xml
|
72
|
+
homepage: https://github.com/exviva/activemerchant-clickandbuy
|
73
|
+
licenses: []
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 1.8.23
|
93
|
+
signing_key:
|
94
|
+
specification_version: 3
|
95
|
+
summary: Integration of ClickandBuy with Active Merchant
|
96
|
+
test_files:
|
97
|
+
- spec/active_merchant/billing/clickand_buy_gateway_spec.rb
|
98
|
+
- spec/active_merchant/clickand_buy/request/pay_request_spec.rb
|
99
|
+
- spec/spec_helper.rb
|
100
|
+
- spec/support/clickand_buy.yml.example
|
101
|
+
- spec/support/requests/pay_request_response.xml
|