killbill-litle 1.10.0 → 2.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 +4 -4
- data/.gitignore +4 -5
- data/.travis.yml +22 -3
- data/Gemfile +1 -1
- data/Gemfile.head +5 -0
- data/Gemfile.lock +129 -0
- data/Jarfile +9 -6
- data/Jarfile.lock +58 -0
- data/LICENSE +201 -0
- data/NEWS +3 -0
- data/README.md +58 -98
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/config.ru +1 -1
- data/db/ddl.sql +32 -21
- data/db/schema.rb +44 -32
- data/killbill-litle.gemspec +20 -16
- data/lib/litle.rb +82 -12
- data/lib/litle/api.rb +144 -204
- data/lib/litle/application.rb +96 -0
- data/lib/litle/models/payment_method.rb +21 -0
- data/lib/litle/models/response.rb +44 -0
- data/lib/litle/models/transaction.rb +11 -0
- data/lib/litle/private_api.rb +42 -13
- data/lib/litle/views/paypage.erb +8 -5
- data/litle.yml +33 -11
- data/pom.xml +3 -2
- data/release.sh +41 -21
- data/spec/litle/base_plugin_spec.rb +35 -62
- data/spec/litle/remote/certification_spec.rb +713 -0
- data/spec/litle/remote/integration_spec.rb +97 -168
- data/spec/spec_helper.rb +3 -16
- metadata +102 -55
- data/lib/litle/config/application.rb +0 -66
- data/lib/litle/config/configuration.rb +0 -51
- data/lib/litle/config/properties.rb +0 -23
- data/lib/litle/litle/gateway.rb +0 -32
- data/lib/litle/models/litle_payment_method.rb +0 -167
- data/lib/litle/models/litle_response.rb +0 -199
- data/lib/litle/models/litle_transaction.rb +0 -44
- data/spec/litle/currency_conversion_spec.rb +0 -21
- data/spec/litle/litle_payment_method_spec.rb +0 -95
- data/spec/litle/litle_response_spec.rb +0 -91
- data/spec/litle/utils_spec.rb +0 -22
@@ -0,0 +1,96 @@
|
|
1
|
+
# -- encoding : utf-8 --
|
2
|
+
|
3
|
+
set :views, File.expand_path(File.dirname(__FILE__) + '/views')
|
4
|
+
|
5
|
+
include Killbill::Plugin::ActiveMerchant::Sinatra
|
6
|
+
|
7
|
+
configure do
|
8
|
+
# Usage: rackup -Ilib -E test
|
9
|
+
if development? or test?
|
10
|
+
# Make sure the plugin is initialized
|
11
|
+
plugin = ::Killbill::Litle::PaymentPlugin.new
|
12
|
+
plugin.logger = Logger.new(STDOUT)
|
13
|
+
plugin.logger.level = Logger::INFO
|
14
|
+
plugin.conf_dir = File.dirname(File.dirname(__FILE__)) + '/..'
|
15
|
+
plugin.start_plugin
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
helpers do
|
20
|
+
def plugin(session = {})
|
21
|
+
::Killbill::Litle::PrivatePaymentPlugin.new(session)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# curl -v http://127.0.0.1:9292/plugins/killbill-litle/form
|
26
|
+
get '/plugins/killbill-litle/form', :provides => 'html' do
|
27
|
+
kb_account_id = request.GET['kb_account_id']
|
28
|
+
required_parameter! :kb_account_id, kb_account_id
|
29
|
+
|
30
|
+
kb_tenant_id = request.GET['kb_tenant_id']
|
31
|
+
kb_tenant = request.env['killbill_tenant']
|
32
|
+
kb_tenant_id ||= kb_tenant.id.to_s unless kb_tenant.nil?
|
33
|
+
|
34
|
+
currency = request.GET['currency'] || plugin.get_currency(kb_account_id)
|
35
|
+
|
36
|
+
tenant_config = config(kb_tenant_id)
|
37
|
+
litle_config = tenant_config[:litle].is_a?(Array) ? (tenant_config[:litle].find { |c| c[:account_id] == currency }) : tenant_config[:litle]
|
38
|
+
|
39
|
+
paypage_id = litle_config[:paypage_id]
|
40
|
+
required_parameter! :paypage_id, paypage_id, "is not configured for currency #{currency.to_sym}"
|
41
|
+
|
42
|
+
secure_page_url = litle_config[:secure_page_url]
|
43
|
+
required_parameter! :secure_page_url, secure_page_url, 'is not configured'
|
44
|
+
|
45
|
+
locals = {
|
46
|
+
:currency => currency,
|
47
|
+
:secure_page_url => secure_page_url,
|
48
|
+
:paypage_id => paypage_id,
|
49
|
+
:kb_account_id => kb_account_id,
|
50
|
+
:kb_tenant_id => kb_tenant_id,
|
51
|
+
:merchant_txn_id => request.GET['merchant_txn_id'] || '1',
|
52
|
+
:order_id => request.GET['order_id'] || '1',
|
53
|
+
:report_group => request.GET['report_group'] || 'Default Report Group',
|
54
|
+
:success_page => params[:successPage] || '/plugins/killbill-litle',
|
55
|
+
:failure_page => params[:failurePage]
|
56
|
+
}
|
57
|
+
erb :paypage, :locals => locals
|
58
|
+
end
|
59
|
+
|
60
|
+
# This is mainly for testing. Your application should redirect from the PayPage checkout above
|
61
|
+
# to a custom endpoint where you call the Kill Bill add payment method JAX-RS API.
|
62
|
+
# If you really want to use this endpoint, you'll have to call the Kill Bill refresh payment methods API
|
63
|
+
# to get a Kill Bill payment method id assigned.
|
64
|
+
post '/plugins/killbill-litle' do
|
65
|
+
pm = plugin.add_payment_method(params)
|
66
|
+
|
67
|
+
status 201
|
68
|
+
redirect '/plugins/killbill-litle/1.0/pms/' + pm.id.to_s
|
69
|
+
end
|
70
|
+
|
71
|
+
# curl -v http://127.0.0.1:9292/plugins/killbill-litle/1.0/pms/1
|
72
|
+
get '/plugins/killbill-litle/1.0/pms/:id', :provides => 'json' do
|
73
|
+
if pm = ::Killbill::Litle::LitlePaymentMethod.find_by_id(params[:id].to_i)
|
74
|
+
pm.to_json
|
75
|
+
else
|
76
|
+
status 404
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# curl -v http://127.0.0.1:9292/plugins/killbill-litle/1.0/transactions/1
|
81
|
+
get '/plugins/killbill-litle/1.0/transactions/:id', :provides => 'json' do
|
82
|
+
if transaction = ::Killbill::Litle::LitleTransaction.find_by_id(params[:id].to_i)
|
83
|
+
transaction.to_json
|
84
|
+
else
|
85
|
+
status 404
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# curl -v http://127.0.0.1:9292/plugins/killbill-litle/1.0/responses/1
|
90
|
+
get '/plugins/killbill-litle/1.0/responses/:id', :provides => 'json' do
|
91
|
+
if transaction = ::Killbill::Litle::LitleResponse.find_by_id(params[:id].to_i)
|
92
|
+
transaction.to_json
|
93
|
+
else
|
94
|
+
status 404
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Killbill #:nodoc:
|
2
|
+
module Litle #:nodoc:
|
3
|
+
class LitlePaymentMethod < ::Killbill::Plugin::ActiveMerchant::ActiveRecord::PaymentMethod
|
4
|
+
|
5
|
+
self.table_name = 'litle_payment_methods'
|
6
|
+
|
7
|
+
def self.from_response(kb_account_id, kb_payment_method_id, kb_tenant_id, cc_or_token, response, options, extra_params = {}, model = ::Killbill::Litle::LitlePaymentMethod)
|
8
|
+
super(kb_account_id,
|
9
|
+
kb_payment_method_id,
|
10
|
+
kb_tenant_id,
|
11
|
+
cc_or_token,
|
12
|
+
response,
|
13
|
+
options,
|
14
|
+
{
|
15
|
+
:token => extract(response, 'litleToken')
|
16
|
+
}.merge!(extra_params),
|
17
|
+
model)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Killbill #:nodoc:
|
2
|
+
module Litle #:nodoc:
|
3
|
+
class LitleResponse < ::Killbill::Plugin::ActiveMerchant::ActiveRecord::Response
|
4
|
+
|
5
|
+
self.table_name = 'litle_responses'
|
6
|
+
|
7
|
+
has_one :litle_transaction
|
8
|
+
|
9
|
+
def self.from_response(api_call, kb_account_id, kb_payment_id, kb_payment_transaction_id, transaction_type, payment_processor_account_id, kb_tenant_id, response, extra_params = {}, model = ::Killbill::Litle::LitleResponse)
|
10
|
+
super(api_call,
|
11
|
+
kb_account_id,
|
12
|
+
kb_payment_id,
|
13
|
+
kb_payment_transaction_id,
|
14
|
+
transaction_type,
|
15
|
+
payment_processor_account_id,
|
16
|
+
kb_tenant_id,
|
17
|
+
response,
|
18
|
+
{
|
19
|
+
:params_litle_txn_id => extract(response, 'litleTxnId'),
|
20
|
+
:params_order_id => extract(response, 'orderId') || extract(response, 'id'),
|
21
|
+
:params_litle_token => extract(response, 'litleToken'),
|
22
|
+
:params_auth_code => extract(response, 'authCode'),
|
23
|
+
:params_response => extract(response, 'response'),
|
24
|
+
:params_response_time => extract(response, 'responseTime'),
|
25
|
+
:params_message => extract(response, 'message')
|
26
|
+
}.merge!(extra_params),
|
27
|
+
model)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.search_where_clause(t, search_key)
|
31
|
+
where_clause = t[:params_litle_txn_id].eq(search_key)
|
32
|
+
|
33
|
+
# Only search successful payments and refunds
|
34
|
+
where_clause = where_clause.and(t[:success].eq(true))
|
35
|
+
|
36
|
+
super.or(where_clause)
|
37
|
+
end
|
38
|
+
|
39
|
+
def first_reference_id
|
40
|
+
params_litle_txn_id
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/litle/private_api.rb
CHANGED
@@ -1,19 +1,48 @@
|
|
1
|
-
module Killbill
|
2
|
-
|
3
|
-
|
1
|
+
module Killbill #:nodoc:
|
2
|
+
module Litle #:nodoc:
|
3
|
+
class PrivatePaymentPlugin < ::Killbill::Plugin::ActiveMerchant::PrivatePaymentPlugin
|
4
|
+
def initialize(session = {})
|
5
|
+
super(:litle,
|
6
|
+
::Killbill::Litle::LitlePaymentMethod,
|
7
|
+
::Killbill::Litle::LitleTransaction,
|
8
|
+
::Killbill::Litle::LitleResponse,
|
9
|
+
session)
|
10
|
+
end
|
4
11
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
12
|
+
def add_payment_method(params)
|
13
|
+
payment_processor_account_id = params[:payment_processor_account_id] || :default
|
14
|
+
|
15
|
+
exp_month, exp_year = (params[:exp_date] || '').split('/')
|
16
|
+
|
17
|
+
# TODO Save response row (to keep the response_litle_txn_id)
|
11
18
|
|
12
|
-
|
19
|
+
# Create the payment method (not associated with a Kill Bill payment method yet)
|
20
|
+
Killbill::Litle::LitlePaymentMethod.create!(:kb_account_id => params[:kb_account_id],
|
21
|
+
:kb_payment_method_id => nil,
|
22
|
+
:kb_tenant_id => params[:kb_tenant_id],
|
23
|
+
:token => params[:response_paypage_registration_id],
|
24
|
+
:cc_first_name => params[:first_name],
|
25
|
+
:cc_last_name => params[:last_name],
|
26
|
+
:cc_type => nil,
|
27
|
+
:cc_exp_month => exp_month,
|
28
|
+
:cc_exp_year => exp_year,
|
29
|
+
:cc_last_4 => params[:cc_num],
|
30
|
+
:address1 => nil,
|
31
|
+
:address2 => nil,
|
32
|
+
:city => nil,
|
33
|
+
:state => nil,
|
34
|
+
:zip => nil,
|
35
|
+
:country => nil,
|
36
|
+
:created_at => Time.now.utc,
|
37
|
+
:updated_at => Time.now.utc)
|
38
|
+
end
|
13
39
|
|
14
|
-
|
15
|
-
|
16
|
-
|
40
|
+
def get_currency(kb_account_id)
|
41
|
+
account = kb_apis.get_account_by_id(kb_account_id)
|
42
|
+
account.currency
|
43
|
+
rescue => e
|
44
|
+
'USD'
|
45
|
+
end
|
17
46
|
end
|
18
47
|
end
|
19
48
|
end
|
data/lib/litle/views/paypage.erb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
<!-- Inspired from the Litle official example: https://
|
1
|
+
<!-- Inspired from the Litle official example: https://www.testlitle.com/checkout/dontSeeCard.html -->
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>Pay Page Checkout</title>
|
5
|
-
<script src="
|
5
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
|
6
|
+
<script src="<%= secure_page_url %>/LitlePayPage/litle-api2.js" type="text/javascript"></script>
|
6
7
|
<script>
|
7
8
|
$(document).ready(
|
8
9
|
function() {
|
@@ -68,6 +69,7 @@
|
|
68
69
|
else if (response.response == '889') {
|
69
70
|
handleError("We are experiencing technical difficulties. Please try your query again later.");
|
70
71
|
}
|
72
|
+
console.log(response.message);
|
71
73
|
return false;
|
72
74
|
}
|
73
75
|
|
@@ -90,7 +92,7 @@
|
|
90
92
|
"url": "<%= secure_page_url %>"
|
91
93
|
};
|
92
94
|
|
93
|
-
sendToLitle(litleRequest, formFields, submitAfterLitle, onErrorAfterLitle, timeoutOnLitle, 5000);
|
95
|
+
new LitlePayPage().sendToLitle(litleRequest, formFields, submitAfterLitle, onErrorAfterLitle, timeoutOnLitle, 5000);
|
94
96
|
return false;
|
95
97
|
}
|
96
98
|
);
|
@@ -101,6 +103,7 @@
|
|
101
103
|
<body>
|
102
104
|
<form method="post" id="form_checkout" name="form_checkout" action="<%= success_page %>">
|
103
105
|
<input type="hidden" id="kb_account_id" name="kb_account_id" value="<%= kb_account_id %>"/>
|
106
|
+
<input type="hidden" id="kb_tenant_id" name="kb_tenant_id" value="<%= kb_tenant_id %>"/>
|
104
107
|
|
105
108
|
<input type="hidden" id="request_paypage_id" name="request_paypage_id" value="<%= paypage_id %>"/>
|
106
109
|
<input type="hidden" id="request_merchant_txn_id" name="request_merchant_txn_id" value="<%= merchant_txn_id %>"/>
|
@@ -135,8 +138,8 @@
|
|
135
138
|
</body>
|
136
139
|
<script>
|
137
140
|
function callLitle() {
|
138
|
-
if (typeof sendToLitle != 'function') {
|
139
|
-
|
141
|
+
if (typeof new LitlePayPage().sendToLitle != 'function') {
|
142
|
+
alert("We are experiencing technical difficulties. Please try your query again later (API unavailable).");
|
140
143
|
}
|
141
144
|
}
|
142
145
|
</script>
|
data/litle.yml
CHANGED
@@ -1,16 +1,38 @@
|
|
1
1
|
:litle:
|
2
|
-
:
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
- :account_id: "USD"
|
3
|
+
:merchant_id: "your-merchant-id-USD"
|
4
|
+
:username: "your-username"
|
5
|
+
:password: "your-password"
|
6
|
+
:secure_page_url: "https://request-prelive.np-securepaypage-litle.com"
|
7
|
+
:paypage_id: "litle-paypage-id-USD"
|
8
|
+
- :account_id: "EUR"
|
9
|
+
:merchant_id: "your-merchant-id-EUR"
|
10
|
+
:username: "your-username"
|
11
|
+
:password: "your-password"
|
12
|
+
:secure_page_url: "https://request-prelive.np-securepaypage-litle.com"
|
13
|
+
:paypage_id: "litle-paypage-id-EUR"
|
9
14
|
|
10
15
|
:database:
|
16
|
+
# SQLite (development)
|
11
17
|
:adapter: sqlite3
|
12
18
|
:database: test.db
|
13
|
-
|
14
|
-
:
|
15
|
-
:
|
16
|
-
|
19
|
+
# For MySQL
|
20
|
+
# :adapter: mysql
|
21
|
+
# :username: 'killbill'
|
22
|
+
# :password: 'killbill'
|
23
|
+
# :database: 'killbill' # or set the URL :
|
24
|
+
# #:url: jdbc:mysql://127.0.0.1:3306/killbill
|
25
|
+
# :driver: org.mariadb.jdbc.Driver # as in KB
|
26
|
+
# :pool: 30 # AR's default is max 5 connections
|
27
|
+
# In Kill Bill
|
28
|
+
# :adapter: mysql
|
29
|
+
# :jndi: 'killbill/osgi/jdbc'
|
30
|
+
# :pool: false # false-pool (JNDI pool's max)
|
31
|
+
# # uncomment if pool does not support JDBC4 :
|
32
|
+
# #:connection_alive_sql: 'select 1'
|
33
|
+
# # MySQL adapter #configure_connection defaults :
|
34
|
+
# # @@SESSION.sql_auto_is_null = 0,
|
35
|
+
# # @@SESSION.wait_timeout = 2147483,
|
36
|
+
# # @@SESSION.sql_mode = 'STRICT_ALL_TABLES'
|
37
|
+
# # ... can be disabled (on AR-JDBC 1.4) using :
|
38
|
+
# :configure_connection: false
|
data/pom.xml
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<!--
|
3
3
|
~ Copyright 2010-2013 Ning, Inc.
|
4
|
+
~ Copyright 2014-2015 The Billing Project, LLC
|
4
5
|
~
|
5
|
-
~
|
6
|
+
~ The Billing Project licenses this file to you under the Apache License, version 2.0
|
6
7
|
~ (the "License"); you may not use this file except in compliance with the
|
7
8
|
~ License. You may obtain a copy of the License at:
|
8
9
|
~
|
@@ -25,7 +26,7 @@
|
|
25
26
|
<groupId>org.kill-bill.billing.plugin.ruby</groupId>
|
26
27
|
<artifactId>litle-plugin</artifactId>
|
27
28
|
<packaging>pom</packaging>
|
28
|
-
<version>
|
29
|
+
<version>2.0.0</version>
|
29
30
|
<name>litle-plugin</name>
|
30
31
|
<url>http://github.com/killbill/killbill-litle-plugin</url>
|
31
32
|
<description>Plugin for accessing Litle as a payment gateway</description>
|
data/release.sh
CHANGED
@@ -1,41 +1,61 @@
|
|
1
1
|
set -e
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
BUNDLE=${BUNDLE-"bundle exec"}
|
4
|
+
MVN=${MVN-"mvn"}
|
5
|
+
|
6
|
+
if [ 'GNU' != "$(tar --help | grep GNU | head -1 | awk '{print $1}')" ]; then
|
7
|
+
echo 'Unable to release: make sure to use GNU tar'
|
5
8
|
exit 1
|
6
9
|
fi
|
7
10
|
|
8
11
|
if $(ruby -e'require "java"'); then
|
9
12
|
# Good
|
10
|
-
echo
|
13
|
+
echo 'Detected JRuby'
|
11
14
|
else
|
12
|
-
echo
|
15
|
+
echo 'Unable to release: make sure to use JRuby'
|
13
16
|
exit 1
|
14
17
|
fi
|
15
18
|
|
16
19
|
VERSION=`grep -E '<version>([0-9]+\.[0-9]+\.[0-9]+)</version>' pom.xml | sed 's/[\t \n]*<version>\(.*\)<\/version>[\t \n]*/\1/'`
|
17
|
-
if [ "$VERSION" != "$(cat $PWD/VERSION)" ]; then
|
18
|
-
echo
|
20
|
+
if [[ -z "$NO_RELEASE" && "$VERSION" != "$(cat $PWD/VERSION)" ]]; then
|
21
|
+
echo 'Unable to release: make sure the versions in pom.xml and VERSION match'
|
19
22
|
exit 1
|
20
23
|
fi
|
21
24
|
|
22
|
-
echo
|
23
|
-
rake killbill:clean
|
25
|
+
echo 'Cleaning up'
|
26
|
+
$BUNDLE rake killbill:clean
|
27
|
+
|
28
|
+
echo 'Building gem'
|
29
|
+
$BUNDLE rake build
|
24
30
|
|
25
|
-
|
26
|
-
|
31
|
+
if [[ -z "$NO_RELEASE" ]]; then
|
32
|
+
echo 'Pushing the gem to Rubygems'
|
33
|
+
$BUNDLE rake release
|
34
|
+
fi
|
27
35
|
|
28
|
-
echo
|
29
|
-
rake killbill:package
|
36
|
+
echo 'Building artifact'
|
37
|
+
$BUNDLE rake killbill:package
|
30
38
|
|
31
39
|
ARTIFACT="$PWD/pkg/killbill-litle-$VERSION.tar.gz"
|
32
40
|
echo "Pushing $ARTIFACT to Maven Central"
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
41
|
+
|
42
|
+
if [[ -z "$NO_RELEASE" ]]; then
|
43
|
+
GOAL=gpg:sign-and-deploy-file
|
44
|
+
REPOSITORY_ID=ossrh-releases
|
45
|
+
URL=https://oss.sonatype.org/service/local/staging/deploy/maven2/
|
46
|
+
else
|
47
|
+
GOAL=deploy:deploy-file
|
48
|
+
REPOSITORY_ID=sonatype-nexus-snapshots
|
49
|
+
URL=https://oss.sonatype.org/content/repositories/snapshots/
|
50
|
+
VERSION="$VERSION-SNAPSHOT"
|
51
|
+
fi
|
52
|
+
|
53
|
+
$MVN $GOAL \
|
54
|
+
-DgroupId=org.kill-bill.billing.plugin.ruby \
|
55
|
+
-DartifactId=litle-plugin \
|
56
|
+
-Dversion=$VERSION \
|
57
|
+
-Dpackaging=tar.gz \
|
58
|
+
-DrepositoryId=$REPOSITORY_ID \
|
59
|
+
-Durl=$URL \
|
60
|
+
-Dfile=$ARTIFACT \
|
61
|
+
-DpomFile=pom.xml
|
@@ -1,14 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Killbill::Litle::PaymentPlugin do
|
4
|
+
|
5
|
+
include ::Killbill::Plugin::ActiveMerchant::RSpec
|
6
|
+
|
4
7
|
before(:each) do
|
5
8
|
Dir.mktmpdir do |dir|
|
6
|
-
file = File.new(File.join(dir, 'litle.yml'),
|
9
|
+
file = File.new(File.join(dir, 'litle.yml'), 'w+')
|
7
10
|
file.write(<<-eos)
|
8
11
|
:litle:
|
9
|
-
:
|
10
|
-
:USD: 'merchant_id'
|
11
|
-
:password: 'password'
|
12
|
+
:test: true
|
12
13
|
# As defined by spec_helper.rb
|
13
14
|
:database:
|
14
15
|
:adapter: 'sqlite3'
|
@@ -16,10 +17,7 @@ describe Killbill::Litle::PaymentPlugin do
|
|
16
17
|
eos
|
17
18
|
file.close
|
18
19
|
|
19
|
-
@plugin = Killbill::Litle::PaymentPlugin.
|
20
|
-
@plugin.logger = Logger.new(STDOUT)
|
21
|
-
@plugin.logger.level = Logger::INFO
|
22
|
-
@plugin.conf_dir = File.dirname(file)
|
20
|
+
@plugin = build_plugin(::Killbill::Litle::PaymentPlugin, 'litle', File.dirname(file))
|
23
21
|
|
24
22
|
# Start the plugin here - since the config file will be deleted
|
25
23
|
@plugin.start_plugin
|
@@ -30,58 +28,33 @@ describe Killbill::Litle::PaymentPlugin do
|
|
30
28
|
@plugin.stop_plugin
|
31
29
|
end
|
32
30
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
verify_pms kb_account_id, 5
|
63
|
-
|
64
|
-
@plugin.stop_plugin
|
65
|
-
end
|
66
|
-
|
67
|
-
private
|
68
|
-
|
69
|
-
def verify_pms(kb_account_id, size)
|
70
|
-
pms = @plugin.get_payment_methods(kb_account_id)
|
71
|
-
pms.size.should == size
|
72
|
-
pms.each do |pm|
|
73
|
-
pm.account_id.should == kb_account_id
|
74
|
-
pm.is_default.should == false
|
75
|
-
pm.external_payment_method_id.should == 'litle-' + pm.payment_method_id.split('-')[1]
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def create_pm_info_plugin(kb_account_id, kb_payment_method_id, is_default, external_payment_method_id)
|
80
|
-
pm_info_plugin = Killbill::Plugin::Model::PaymentMethodInfoPlugin.new
|
81
|
-
pm_info_plugin.account_id = kb_account_id
|
82
|
-
pm_info_plugin.payment_method_id = kb_payment_method_id
|
83
|
-
pm_info_plugin.is_default = is_default
|
84
|
-
pm_info_plugin.external_payment_method_id = external_payment_method_id
|
85
|
-
pm_info_plugin
|
86
|
-
end
|
31
|
+
# No offsite payments integration
|
32
|
+
|
33
|
+
#xit 'should generate forms correctly' do
|
34
|
+
# kb_account_id = SecureRandom.uuid
|
35
|
+
# kb_tenant_id = SecureRandom.uuid
|
36
|
+
# context = @plugin.kb_apis.create_context(kb_tenant_id)
|
37
|
+
# fields = @plugin.hash_to_properties({
|
38
|
+
# :order_id => '1234',
|
39
|
+
# :amount => 10
|
40
|
+
# })
|
41
|
+
# form = @plugin.build_form_descriptor kb_account_id, fields, [], context
|
42
|
+
#
|
43
|
+
# form.kb_account_id.should == kb_account_id
|
44
|
+
# form.form_method.should == 'POST'
|
45
|
+
# form.form_url.should == 'https://litle.com'
|
46
|
+
#
|
47
|
+
# form_fields = @plugin.properties_to_hash(form.form_fields)
|
48
|
+
#end
|
49
|
+
|
50
|
+
#xit 'should receive notifications correctly' do
|
51
|
+
# description = 'description'
|
52
|
+
#
|
53
|
+
# kb_tenant_id = SecureRandom.uuid
|
54
|
+
# context = @plugin.kb_apis.create_context(kb_tenant_id)
|
55
|
+
# properties = @plugin.hash_to_properties({ :description => description })
|
56
|
+
#
|
57
|
+
# notification = ""
|
58
|
+
# gw_notification = @plugin.process_notification notification, properties, context
|
59
|
+
#end
|
87
60
|
end
|