killbill-firstdata_e4 0.1.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.
data/db/ddl.sql ADDED
@@ -0,0 +1,137 @@
1
+ CREATE TABLE `firstdata_e4_payment_methods` (
2
+ `id` int(11) NOT NULL AUTO_INCREMENT,
3
+ `kb_payment_method_id` varchar(255) DEFAULT NULL,
4
+ `token` varchar(255) DEFAULT NULL,
5
+ `cc_first_name` varchar(255) DEFAULT NULL,
6
+ `cc_last_name` varchar(255) DEFAULT NULL,
7
+ `cc_type` varchar(255) DEFAULT NULL,
8
+ `cc_exp_month` varchar(255) DEFAULT NULL,
9
+ `cc_exp_year` varchar(255) DEFAULT NULL,
10
+ `cc_number` varchar(255) DEFAULT NULL,
11
+ `cc_last_4` varchar(255) DEFAULT NULL,
12
+ `cc_start_month` varchar(255) DEFAULT NULL,
13
+ `cc_start_year` varchar(255) DEFAULT NULL,
14
+ `cc_issue_number` varchar(255) DEFAULT NULL,
15
+ `cc_verification_value` varchar(255) DEFAULT NULL,
16
+ `cc_track_data` varchar(255) DEFAULT NULL,
17
+ `address1` varchar(255) DEFAULT NULL,
18
+ `address2` varchar(255) DEFAULT NULL,
19
+ `city` varchar(255) DEFAULT NULL,
20
+ `state` varchar(255) DEFAULT NULL,
21
+ `zip` varchar(255) DEFAULT NULL,
22
+ `country` varchar(255) DEFAULT NULL,
23
+ `is_deleted` tinyint(1) NOT NULL DEFAULT '0',
24
+ `created_at` datetime NOT NULL,
25
+ `updated_at` datetime NOT NULL,
26
+ `kb_account_id` varchar(255) DEFAULT NULL,
27
+ `kb_tenant_id` varchar(255) DEFAULT NULL,
28
+ PRIMARY KEY (`id`),
29
+ KEY `index_firstdata_e4_payment_methods_on_kb_account_id` (`kb_account_id`),
30
+ KEY `index_firstdata_e4_payment_methods_on_kb_payment_method_id` (`kb_payment_method_id`)
31
+ ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
32
+
33
+ CREATE TABLE `firstdata_e4_transactions` (
34
+ `id` int(11) NOT NULL AUTO_INCREMENT,
35
+ `firstdata_e4_response_id` int(11) NOT NULL,
36
+ `api_call` varchar(255) NOT NULL,
37
+ `kb_payment_id` varchar(255) NOT NULL,
38
+ `kb_payment_transaction_id` varchar(255) NOT NULL,
39
+ `transaction_type` varchar(255) NOT NULL,
40
+ `payment_processor_account_id` varchar(255) DEFAULT NULL,
41
+ `txn_id` varchar(255) DEFAULT NULL,
42
+ `amount_in_cents` int(11) DEFAULT NULL,
43
+ `currency` varchar(255) DEFAULT NULL,
44
+ `created_at` datetime NOT NULL,
45
+ `updated_at` datetime NOT NULL,
46
+ `kb_account_id` varchar(255) NOT NULL,
47
+ `kb_tenant_id` varchar(255) NOT NULL,
48
+ PRIMARY KEY (`id`),
49
+ KEY `index_firstdata_e4_transactions_on_kb_payment_id` (`kb_payment_id`)
50
+ ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
51
+
52
+ CREATE TABLE `firstdata_e4_responses` (
53
+ `id` int(11) NOT NULL AUTO_INCREMENT,
54
+ `api_call` varchar(255) NOT NULL,
55
+ `kb_payment_id` varchar(255) DEFAULT NULL,
56
+ `kb_payment_transaction_id` varchar(255) DEFAULT NULL,
57
+ `transaction_type` varchar(255) DEFAULT NULL,
58
+ `payment_processor_account_id` varchar(255) DEFAULT NULL,
59
+ `message` varchar(255) DEFAULT NULL,
60
+ `authorization` varchar(255) DEFAULT NULL,
61
+ `fraud_review` tinyint(1) DEFAULT NULL,
62
+ `test` tinyint(1) DEFAULT NULL,
63
+ `params_amount_requested` varchar(255) DEFAULT NULL,
64
+ `params_authorization_num` varchar(255) DEFAULT NULL,
65
+ `params_avs` varchar(255) DEFAULT NULL,
66
+ `params_bank_message` varchar(255) DEFAULT NULL,
67
+ `params_bank_resp_code` varchar(255) DEFAULT NULL,
68
+ `params_bank_resp_code_2` varchar(255) DEFAULT NULL,
69
+ `params_card_cost` varchar(255) DEFAULT NULL,
70
+ `params_card_holders_name` varchar(255) DEFAULT NULL,
71
+ `params_card_type` varchar(255) DEFAULT NULL,
72
+ `params_cavv` varchar(255) DEFAULT NULL,
73
+ `params_cavv_algorithm` varchar(255) DEFAULT NULL,
74
+ `params_cavv_response` varchar(255) DEFAULT NULL,
75
+ `params_client_email` varchar(255) DEFAULT NULL,
76
+ `params_client_ip` varchar(255) DEFAULT NULL,
77
+ `params_ctr` text DEFAULT NULL,
78
+ `params_currency` varchar(255) DEFAULT NULL,
79
+ `params_current_balance` varchar(255) DEFAULT NULL,
80
+ `params_customer_ref` varchar(255) DEFAULT NULL,
81
+ `params_cvd_presence_ind` varchar(255) DEFAULT NULL,
82
+ `params_cvv2` varchar(255) DEFAULT NULL,
83
+ `params_dollar_amount` varchar(255) DEFAULT NULL,
84
+ `params_ean` varchar(255) DEFAULT NULL,
85
+ `params_ecommerce_flag` varchar(255) DEFAULT NULL,
86
+ `params_error_description` varchar(255) DEFAULT NULL,
87
+ `params_exact_id` varchar(255) DEFAULT NULL,
88
+ `params_error_number` varchar(255) DEFAULT NULL,
89
+ `params_exact_message` varchar(255) DEFAULT NULL,
90
+ `params_exact_resp_code` varchar(255) DEFAULT NULL,
91
+ `params_language` varchar(255) DEFAULT NULL,
92
+ `params_merchant_address` varchar(255) DEFAULT NULL,
93
+ `params_merchant_city` varchar(255) DEFAULT NULL,
94
+ `params_merchant_country` varchar(255) DEFAULT NULL,
95
+ `params_merchant_name` varchar(255) DEFAULT NULL,
96
+ `params_merchant_postal` varchar(255) DEFAULT NULL,
97
+ `params_merchant_province` varchar(255) DEFAULT NULL,
98
+ `params_merchant_url` varchar(255) DEFAULT NULL,
99
+ `params_pan` varchar(255) DEFAULT NULL,
100
+ `params_partial_redemption` varchar(255) DEFAULT NULL,
101
+ `params_password` varchar(255) DEFAULT NULL,
102
+ `params_previous_balance` varchar(255) DEFAULT NULL,
103
+ `params_reference_3` varchar(255) DEFAULT NULL,
104
+ `params_reference_no` varchar(255) DEFAULT NULL,
105
+ `params_retrieval_ref_no` varchar(255) DEFAULT NULL,
106
+ `params_secure_auth_required` varchar(255) DEFAULT NULL,
107
+ `params_secure_auth_result` varchar(255) DEFAULT NULL,
108
+ `params_sequence_no` varchar(255) DEFAULT NULL,
109
+ `params_surcharge_amount` varchar(255) DEFAULT NULL,
110
+ `params_tax1_amount` varchar(255) DEFAULT NULL,
111
+ `params_tax1_number` varchar(255) DEFAULT NULL,
112
+ `params_tax2_amount` varchar(255) DEFAULT NULL,
113
+ `params_tax2_number` varchar(255) DEFAULT NULL,
114
+ `params_track1` varchar(255) DEFAULT NULL,
115
+ `params_track2` varchar(255) DEFAULT NULL,
116
+ `params_transaction_approved` varchar(255) DEFAULT NULL,
117
+ `params_transaction_error` varchar(255) DEFAULT NULL,
118
+ `params_transaction_tag` varchar(255) DEFAULT NULL,
119
+ `params_transaction_type` varchar(255) DEFAULT NULL,
120
+ `params_transarmor_token` varchar(255) DEFAULT NULL,
121
+ `params_verification_str1` varchar(255) DEFAULT NULL,
122
+ `params_virtual_card` varchar(255) DEFAULT NULL,
123
+ `params_xid` varchar(255) DEFAULT NULL,
124
+ `params_zip_code` varchar(255) DEFAULT NULL,
125
+ `avs_result_code` varchar(255) DEFAULT NULL,
126
+ `avs_result_message` varchar(255) DEFAULT NULL,
127
+ `avs_result_street_match` varchar(255) DEFAULT NULL,
128
+ `avs_result_postal_match` varchar(255) DEFAULT NULL,
129
+ `cvv_result_code` varchar(255) DEFAULT NULL,
130
+ `cvv_result_message` varchar(255) DEFAULT NULL,
131
+ `success` tinyint(1) DEFAULT NULL,
132
+ `created_at` datetime NOT NULL,
133
+ `updated_at` datetime NOT NULL,
134
+ `kb_account_id` varchar(255) DEFAULT NULL,
135
+ `kb_tenant_id` varchar(255) DEFAULT NULL,
136
+ PRIMARY KEY (`id`)
137
+ ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
data/db/schema.rb ADDED
@@ -0,0 +1,138 @@
1
+ require 'active_record'
2
+
3
+ ActiveRecord::Schema.define(:version => 20140410153635) do
4
+ create_table "firstdata_e4_payment_methods", :force => true do |t|
5
+ t.string "kb_payment_method_id" # NULL before Kill Bill knows about it
6
+ t.string "token" # firstdata_e4 id
7
+ t.string "cc_first_name"
8
+ t.string "cc_last_name"
9
+ t.string "cc_type"
10
+ t.string "cc_exp_month"
11
+ t.string "cc_exp_year"
12
+ t.string "cc_number"
13
+ t.string "cc_last_4"
14
+ t.string "cc_start_month"
15
+ t.string "cc_start_year"
16
+ t.string "cc_issue_number"
17
+ t.string "cc_verification_value"
18
+ t.string "cc_track_data"
19
+ t.string "address1"
20
+ t.string "address2"
21
+ t.string "city"
22
+ t.string "state"
23
+ t.string "zip"
24
+ t.string "country"
25
+ t.boolean "is_deleted", :null => false, :default => false
26
+ t.datetime "created_at", :null => false
27
+ t.datetime "updated_at", :null => false
28
+ t.string "kb_account_id"
29
+ t.string "kb_tenant_id"
30
+ end
31
+
32
+ add_index(:firstdata_e4_payment_methods, :kb_account_id)
33
+ add_index(:firstdata_e4_payment_methods, :kb_payment_method_id)
34
+
35
+ create_table "firstdata_e4_transactions", :force => true do |t|
36
+ t.integer "firstdata_e4_response_id", :null => false
37
+ t.string "api_call", :null => false
38
+ t.string "kb_payment_id", :null => false
39
+ t.string "kb_payment_transaction_id", :null => false
40
+ t.string "transaction_type", :null => false
41
+ t.string "payment_processor_account_id"
42
+ t.string "txn_id" # firstdata_e4 transaction id
43
+ # Both null for void
44
+ t.integer "amount_in_cents"
45
+ t.string "currency"
46
+ t.datetime "created_at", :null => false
47
+ t.datetime "updated_at", :null => false
48
+ t.string "kb_account_id", :null => false
49
+ t.string "kb_tenant_id", :null => false
50
+ end
51
+
52
+ add_index(:firstdata_e4_transactions, :kb_payment_id)
53
+
54
+ create_table "firstdata_e4_responses", :force => true do |t|
55
+ t.string "api_call", :null => false
56
+ t.string "kb_payment_id"
57
+ t.string "kb_payment_transaction_id"
58
+ t.string "transaction_type"
59
+ t.string "payment_processor_account_id"
60
+ t.string "message"
61
+ t.string "authorization"
62
+ t.boolean "fraud_review"
63
+ t.boolean "test"
64
+ t.string "params_amount_requested"
65
+ t.string "params_authorization_num"
66
+ t.string "params_avs"
67
+ t.string "params_bank_message"
68
+ t.string "params_bank_resp_code"
69
+ t.string "params_bank_resp_code_2"
70
+ t.string "params_card_cost"
71
+ t.string "params_card_holders_name"
72
+ t.string "params_card_type"
73
+ t.string "params_cavv"
74
+ t.string "params_cavv_algorithm"
75
+ t.string "params_cavv_response"
76
+ t.string "params_client_email"
77
+ t.string "params_client_ip"
78
+ t.text "params_ctr"
79
+ t.string "params_currency"
80
+ t.string "params_current_balance"
81
+ t.string "params_customer_ref"
82
+ t.string "params_cvd_presence_ind"
83
+ t.string "params_cvv2"
84
+ t.string "params_dollar_amount"
85
+ t.string "params_ean"
86
+ t.string "params_ecommerce_flag"
87
+ t.string "params_error_description"
88
+ t.string "params_exact_id"
89
+ t.string "params_error_number"
90
+ t.string "params_exact_message"
91
+ t.string "params_exact_resp_code"
92
+ t.string "params_language"
93
+ t.string "params_merchant_address"
94
+ t.string "params_merchant_city"
95
+ t.string "params_merchant_country"
96
+ t.string "params_merchant_name"
97
+ t.string "params_merchant_postal"
98
+ t.string "params_merchant_province"
99
+ t.string "params_merchant_url"
100
+ t.string "params_pan"
101
+ t.string "params_partial_redemption"
102
+ t.string "params_password"
103
+ t.string "params_previous_balance"
104
+ t.string "params_reference_3"
105
+ t.string "params_reference_no"
106
+ t.string "params_retrieval_ref_no"
107
+ t.string "params_secure_auth_required"
108
+ t.string "params_secure_auth_result"
109
+ t.string "params_sequence_no"
110
+ t.string "params_surcharge_amount"
111
+ t.string "params_tax1_amount"
112
+ t.string "params_tax1_number"
113
+ t.string "params_tax2_amount"
114
+ t.string "params_tax2_number"
115
+ t.string "params_track1"
116
+ t.string "params_track2"
117
+ t.string "params_transaction_approved"
118
+ t.string "params_transaction_error"
119
+ t.string "params_transaction_tag"
120
+ t.string "params_transaction_type"
121
+ t.string "params_transarmor_token"
122
+ t.string "params_verification_str1"
123
+ t.string "params_virtual_card"
124
+ t.string "params_xid"
125
+ t.string "params_zip_code"
126
+ t.string "avs_result_code"
127
+ t.string "avs_result_message"
128
+ t.string "avs_result_street_match"
129
+ t.string "avs_result_postal_match"
130
+ t.string "cvv_result_code"
131
+ t.string "cvv_result_message"
132
+ t.boolean "success"
133
+ t.datetime "created_at", :null => false
134
+ t.datetime "updated_at", :null => false
135
+ t.string "kb_account_id"
136
+ t.string "kb_tenant_id"
137
+ end
138
+ end
data/firstdata_e4.yml ADDED
@@ -0,0 +1,29 @@
1
+ :firstdata_e4:
2
+ :login: <%= ENV['LOGIN'] %>
3
+ :password: <%= ENV['PASSWORD'] %>
4
+ :test: true
5
+
6
+ :database:
7
+ # SQLite (development)
8
+ :adapter: sqlite3
9
+ :database: test.db
10
+ # For MySQL
11
+ # :adapter: mysql
12
+ # :username: 'killbill'
13
+ # :password: 'killbill'
14
+ # :database: 'killbill' # or set the URL :
15
+ # #:url: jdbc:mysql://127.0.0.1:3306/killbill
16
+ # :driver: org.mariadb.jdbc.Driver # as in KB
17
+ # :pool: 30 # AR's default is max 5 connections
18
+ # In Kill Bill
19
+ # :adapter: mysql
20
+ # :jndi: 'killbill/osgi/jdbc'
21
+ # :pool: false # false-pool (JNDI pool's max)
22
+ # # uncomment if pool does not support JDBC4 :
23
+ # #:connection_alive_sql: 'select 1'
24
+ # # MySQL adapter #configure_connection defaults :
25
+ # # @@SESSION.sql_auto_is_null = 0,
26
+ # # @@SESSION.wait_timeout = 2147483,
27
+ # # @@SESSION.sql_mode = 'STRICT_ALL_TABLES'
28
+ # # ... can be disabled (on AR-JDBC 1.4) using :
29
+ # :configure_connection: false
@@ -0,0 +1,52 @@
1
+ version = File.read(File.expand_path('../VERSION', __FILE__)).strip
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'killbill-firstdata_e4'
5
+ s.version = version
6
+ s.summary = 'Plugin to use First Data e4 as a gateway.'
7
+ s.description = 'Kill Bill payment plugin for First Data e4.'
8
+
9
+ s.required_ruby_version = '>= 1.9.3'
10
+
11
+ s.license = 'Apache License (2.0)'
12
+
13
+ s.author = 'Kill Bill core team'
14
+ s.email = 'killbilling-users@googlegroups.com'
15
+ s.homepage = 'http://killbill.io'
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.bindir = 'bin'
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
21
+ s.require_paths = ['lib']
22
+
23
+ s.rdoc_options << '--exclude' << '.'
24
+
25
+ s.add_dependency 'killbill', '~> 7.0'
26
+
27
+ s.add_dependency 'sinatra', '~> 1.3.4'
28
+ s.add_dependency 'thread_safe', '~> 0.3.4'
29
+ s.add_dependency 'activerecord', '~> 4.1.0'
30
+ if defined?(JRUBY_VERSION)
31
+ s.add_dependency 'activerecord-bogacs', '~> 0.3'
32
+ s.add_dependency 'activerecord-jdbc-adapter', '~> 1.3'
33
+ # Required to avoid errors like java.lang.NoClassDefFoundError: org/bouncycastle/asn1/DERBoolean
34
+ s.add_dependency 'jruby-openssl', '~> 0.9.6'
35
+ end
36
+ s.add_dependency 'actionpack', '~> 4.1.0'
37
+ s.add_dependency 'actionview', '~> 4.1.0'
38
+ s.add_dependency 'activemerchant', '~> 1.48.0'
39
+ s.add_dependency 'offsite_payments', '~> 2.1.0'
40
+ s.add_dependency 'monetize', '~> 1.1.0'
41
+ s.add_dependency 'money', '~> 6.5.1'
42
+
43
+ s.add_development_dependency 'jbundler', '~> 0.9.2'
44
+ s.add_development_dependency 'rake', '>= 10.0.0'
45
+ s.add_development_dependency 'rspec', '~> 2.12.0'
46
+ if defined?(JRUBY_VERSION)
47
+ s.add_development_dependency 'jdbc-sqlite3', '~> 3.7'
48
+ s.add_development_dependency 'jdbc-mariadb', '~> 1.1'
49
+ else
50
+ s.add_development_dependency 'sqlite3', '~> 1.3.7'
51
+ end
52
+ end
@@ -0,0 +1,3 @@
1
+ mainClass=Killbill::FirstdataE4::PaymentPlugin
2
+ require=firstdata_e4
3
+ pluginType=PAYMENT
@@ -0,0 +1,172 @@
1
+ module Killbill #:nodoc:
2
+ module FirstdataE4 #:nodoc:
3
+ class PaymentPlugin < ::Killbill::Plugin::ActiveMerchant::PaymentPlugin
4
+
5
+ def initialize
6
+ gateway_builder = Proc.new do |config|
7
+ # Change this if needed
8
+ ::ActiveMerchant::Billing::FirstdataE4Gateway.new :login => config[:login],
9
+ :password => config[:password]
10
+ end
11
+
12
+ super(gateway_builder,
13
+ :firstdata_e4,
14
+ ::Killbill::FirstdataE4::FirstdataE4PaymentMethod,
15
+ ::Killbill::FirstdataE4::FirstdataE4Transaction,
16
+ ::Killbill::FirstdataE4::FirstdataE4Response)
17
+ end
18
+
19
+ def on_event(event)
20
+ # Require to deal with per tenant configuration invalidation
21
+ super(event)
22
+ #
23
+ # Custom event logic could be added below...
24
+ #
25
+ end
26
+
27
+ def authorize_payment(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, amount, currency, properties, context)
28
+ # Pass extra parameters for the gateway here
29
+ options = {}
30
+
31
+ properties = merge_properties(properties, options)
32
+ super(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, amount, currency, properties, context)
33
+ end
34
+
35
+ def capture_payment(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, amount, currency, properties, context)
36
+ # Pass extra parameters for the gateway here
37
+ options = {}
38
+
39
+ properties = merge_properties(properties, options)
40
+ super(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, amount, currency, properties, context)
41
+ end
42
+
43
+ def purchase_payment(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, amount, currency, properties, context)
44
+ # Pass extra parameters for the gateway here
45
+ options = {}
46
+
47
+ properties = merge_properties(properties, options)
48
+ super(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, amount, currency, properties, context)
49
+ end
50
+
51
+ def void_payment(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, properties, context)
52
+ # Pass extra parameters for the gateway here
53
+ options = {}
54
+
55
+ properties = merge_properties(properties, options)
56
+ super(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, properties, context)
57
+ end
58
+
59
+ def credit_payment(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, amount, currency, properties, context)
60
+ # Pass extra parameters for the gateway here
61
+ options = {}
62
+
63
+ properties = merge_properties(properties, options)
64
+ super(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, amount, currency, properties, context)
65
+ end
66
+
67
+ def refund_payment(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, amount, currency, properties, context)
68
+ # Pass extra parameters for the gateway here
69
+ options = {}
70
+
71
+ properties = merge_properties(properties, options)
72
+ super(kb_account_id, kb_payment_id, kb_payment_transaction_id, kb_payment_method_id, amount, currency, properties, context)
73
+ end
74
+
75
+ def get_payment_info(kb_account_id, kb_payment_id, properties, context)
76
+ # Pass extra parameters for the gateway here
77
+ options = {}
78
+
79
+ properties = merge_properties(properties, options)
80
+ super(kb_account_id, kb_payment_id, properties, context)
81
+ end
82
+
83
+ def search_payments(search_key, offset, limit, properties, context)
84
+ # Pass extra parameters for the gateway here
85
+ options = {}
86
+
87
+ properties = merge_properties(properties, options)
88
+ super(search_key, offset, limit, properties, context)
89
+ end
90
+
91
+ def add_payment_method(kb_account_id, kb_payment_method_id, payment_method_props, set_default, properties, context)
92
+ # Pass extra parameters for the gateway here
93
+ options = {}
94
+
95
+ properties = merge_properties(properties, options)
96
+ super(kb_account_id, kb_payment_method_id, payment_method_props, set_default, properties, context)
97
+ end
98
+
99
+ def delete_payment_method(kb_account_id, kb_payment_method_id, properties, context)
100
+ # Pass extra parameters for the gateway here
101
+ options = {}
102
+
103
+ properties = merge_properties(properties, options)
104
+ super(kb_account_id, kb_payment_method_id, properties, context)
105
+ end
106
+
107
+ def get_payment_method_detail(kb_account_id, kb_payment_method_id, properties, context)
108
+ # Pass extra parameters for the gateway here
109
+ options = {}
110
+
111
+ properties = merge_properties(properties, options)
112
+ super(kb_account_id, kb_payment_method_id, properties, context)
113
+ end
114
+
115
+ def set_default_payment_method(kb_account_id, kb_payment_method_id, properties, context)
116
+ # TODO
117
+ end
118
+
119
+ def get_payment_methods(kb_account_id, refresh_from_gateway, properties, context)
120
+ # Pass extra parameters for the gateway here
121
+ options = {}
122
+
123
+ properties = merge_properties(properties, options)
124
+ super(kb_account_id, refresh_from_gateway, properties, context)
125
+ end
126
+
127
+ def search_payment_methods(search_key, offset, limit, properties, context)
128
+ # Pass extra parameters for the gateway here
129
+ options = {}
130
+
131
+ properties = merge_properties(properties, options)
132
+ super(search_key, offset, limit, properties, context)
133
+ end
134
+
135
+ def reset_payment_methods(kb_account_id, payment_methods, properties, context)
136
+ super
137
+ end
138
+
139
+ def build_form_descriptor(kb_account_id, descriptor_fields, properties, context)
140
+ # Pass extra parameters for the gateway here
141
+ options = {}
142
+ properties = merge_properties(properties, options)
143
+
144
+ # Add your custom static hidden tags here
145
+ options = {
146
+ #:token => config[:firstdata_e4][:token]
147
+ }
148
+ descriptor_fields = merge_properties(descriptor_fields, options)
149
+
150
+ super(kb_account_id, descriptor_fields, properties, context)
151
+ end
152
+
153
+ def process_notification(notification, properties, context)
154
+ # Pass extra parameters for the gateway here
155
+ options = {}
156
+ properties = merge_properties(properties, options)
157
+
158
+ super(notification, properties, context) do |gw_notification, service|
159
+ # Retrieve the payment
160
+ # gw_notification.kb_payment_id =
161
+ #
162
+ # Set the response body
163
+ # gw_notification.entity =
164
+ end
165
+ end
166
+
167
+ def get_active_merchant_module
168
+ ::OffsitePayments.integration(:first_data)
169
+ end
170
+ end
171
+ end
172
+ end
@@ -0,0 +1,80 @@
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::FirstdataE4::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::FirstdataE4::PrivatePaymentPlugin.new(session)
22
+ end
23
+ end
24
+
25
+ # curl -v http://127.0.0.1:9292/plugins/killbill-firstdata_e4/form
26
+ get '/plugins/killbill-firstdata_e4/form', :provides => 'html' do
27
+ order_id = request.GET['order_id']
28
+ account_id = request.GET['account_id']
29
+ options = {
30
+ :amount => request.GET['amount'],
31
+ :currency => request.GET['currency'],
32
+ :test => request.GET['test'],
33
+ :credential2 => request.GET['credential2'],
34
+ :credential3 => request.GET['credential3'],
35
+ :credential4 => request.GET['credential4'],
36
+ :country => request.GET['country'],
37
+ :account_name => request.GET['account_name'],
38
+ :transaction_type => request.GET['transaction_type'],
39
+ :authcode => request.GET['authcode'],
40
+ :notify_url => request.GET['notify_url'],
41
+ :return_url => request.GET['return_url'],
42
+ :redirect_param => request.GET['redirect_param'],
43
+ :forward_url => request.GET['forward_url']
44
+ }
45
+
46
+ @form = plugin(session).payment_form_for(order_id, account_id, :firstdata_e4, options) do |service|
47
+ # Add your custom hidden tags here, e.g.
48
+ #service.token = config[:firstdata_e4][:token]
49
+ submit_tag 'Submit'
50
+ end
51
+
52
+ erb :form
53
+ end
54
+
55
+ # curl -v http://127.0.0.1:9292/plugins/killbill-firstdata_e4/1.0/pms/1
56
+ get '/plugins/killbill-firstdata_e4/1.0/pms/:id', :provides => 'json' do
57
+ if pm = ::Killbill::FirstdataE4::FirstdataE4PaymentMethod.find_by_id(params[:id].to_i)
58
+ pm.to_json
59
+ else
60
+ status 404
61
+ end
62
+ end
63
+
64
+ # curl -v http://127.0.0.1:9292/plugins/killbill-firstdata_e4/1.0/transactions/1
65
+ get '/plugins/killbill-firstdata_e4/1.0/transactions/:id', :provides => 'json' do
66
+ if transaction = ::Killbill::FirstdataE4::FirstdataE4Transaction.find_by_id(params[:id].to_i)
67
+ transaction.to_json
68
+ else
69
+ status 404
70
+ end
71
+ end
72
+
73
+ # curl -v http://127.0.0.1:9292/plugins/killbill-firstdata_e4/1.0/responses/1
74
+ get '/plugins/killbill-firstdata_e4/1.0/responses/:id', :provides => 'json' do
75
+ if transaction = ::Killbill::FirstdataE4::FirstdataE4Response.find_by_id(params[:id].to_i)
76
+ transaction.to_json
77
+ else
78
+ status 404
79
+ end
80
+ end
@@ -0,0 +1,23 @@
1
+ module Killbill #:nodoc:
2
+ module FirstdataE4 #:nodoc:
3
+ class FirstdataE4PaymentMethod < ::Killbill::Plugin::ActiveMerchant::ActiveRecord::PaymentMethod
4
+
5
+ self.table_name = 'firstdata_e4_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::FirstdataE4::FirstdataE4PaymentMethod)
8
+ super(kb_account_id,
9
+ kb_payment_method_id,
10
+ kb_tenant_id,
11
+ cc_or_token,
12
+ response,
13
+ options,
14
+ {
15
+ # Pass custom key/values here
16
+ #:params_id => extract(response, 'id'),
17
+ #:params_card_id => extract(response, 'card', 'id')
18
+ }.merge!(extra_params),
19
+ model)
20
+ end
21
+ end
22
+ end
23
+ end