smulube-activemerchant 1.5.1.2 → 1.5.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -0
- data/CONTRIBUTORS +4 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +2 -2
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +2 -2
- data/lib/active_merchant/billing/gateways/bogus.rb +12 -8
- data/lib/active_merchant/billing/gateways/garanti.rb +222 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +1 -1
- data/lib/active_merchant/billing/gateways/payflow_nvp_uk.rb +4 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +5 -0
- data/lib/active_merchant/billing/gateways/sage.rb +2 -2
- data/lib/active_merchant/lib/connection.rb +5 -0
- data/lib/active_merchant/version.rb +1 -1
- data/test/fixtures.yml +8 -3
- data/test/remote/gateways/remote_cyber_source_test.rb +5 -3
- data/test/remote/gateways/remote_garanti_test.rb +58 -0
- data/test/unit/connection_test.rb +8 -0
- data/test/unit/credit_card_methods_test.rb +13 -0
- data/test/unit/gateways/garanti_test.rb +82 -0
- data/test/unit/gateways/payflow_nvp_uk_test.rb +4 -0
- data/test/unit/gateways/paypal_express_test.rb +7 -0
- data.tar.gz.sig +0 -0
- metadata +8 -3
- metadata.gz.sig +0 -0
data/CHANGELOG
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
= ActiveMerchant CHANGELOG
|
2
2
|
|
3
|
+
* Fix failing CyberSource remote test [Patrick Joyce]
|
4
|
+
* Support for Garanti Sanal Pos: Turkish bank and billing gateway [Selem Delul]
|
5
|
+
* Add deprecation note for Money objects to Bogus gateway [Soleone]
|
6
|
+
* Updated test URL for Merchant eSolutions and added valid remote test credentials [Soleone]
|
7
|
+
* Add new error class for SSL certificate problems in connection class [Soleone]
|
8
|
+
* Update valid_month and valid_expiry_year to coerce string arguments to integers [cody]
|
9
|
+
* Add support for displaying credit cards with PayPal Express. Use the :allow_guest_checkout => true option when setting up the transaction [Edward Ocampo-Gooding]
|
10
|
+
* Use card_brand method for checking for checks in Sage and Beanstream [cody]
|
3
11
|
* Add JCB and Diners Club to LinkPoint [Soleone]
|
4
12
|
|
5
13
|
== Version 1.5.1 (February 14, 2010)
|
data/CONTRIBUTORS
CHANGED
@@ -22,11 +22,11 @@ module ActiveMerchant #:nodoc:
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def valid_month?(month)
|
25
|
-
(1..12).include?(month)
|
25
|
+
(1..12).include?(month.to_i)
|
26
26
|
end
|
27
27
|
|
28
28
|
def valid_expiry_year?(year)
|
29
|
-
(Time.now.year..Time.now.year + 20).include?(year)
|
29
|
+
(Time.now.year..Time.now.year + 20).include?(year.to_i)
|
30
30
|
end
|
31
31
|
|
32
32
|
def valid_start_year?(year)
|
@@ -78,7 +78,7 @@ module ActiveMerchant #:nodoc:
|
|
78
78
|
|
79
79
|
private
|
80
80
|
def purchase_action(source)
|
81
|
-
source
|
81
|
+
card_brand(source) == "check" ? :check_purchase : :purchase
|
82
82
|
end
|
83
83
|
|
84
84
|
def void_action(original_transaction_type)
|
@@ -221,7 +221,7 @@ module ActiveMerchant #:nodoc:
|
|
221
221
|
end
|
222
222
|
|
223
223
|
def add_source(post, source)
|
224
|
-
source
|
224
|
+
card_brand(source) == "check" ? add_check(post, source) : add_credit_card(post, source)
|
225
225
|
end
|
226
226
|
|
227
227
|
def add_transaction_type(post, action)
|
@@ -19,46 +19,50 @@ module ActiveMerchant #:nodoc:
|
|
19
19
|
self.display_name = 'Bogus'
|
20
20
|
|
21
21
|
def authorize(money, creditcard, options = {})
|
22
|
+
money = amount(money)
|
22
23
|
case creditcard.number
|
23
24
|
when '1'
|
24
|
-
Response.new(true, SUCCESS_MESSAGE, {:authorized_amount => money
|
25
|
+
Response.new(true, SUCCESS_MESSAGE, {:authorized_amount => money}, :test => true, :authorization => AUTHORIZATION )
|
25
26
|
when '2'
|
26
|
-
Response.new(false, FAILURE_MESSAGE, {:authorized_amount => money
|
27
|
+
Response.new(false, FAILURE_MESSAGE, {:authorized_amount => money, :error => FAILURE_MESSAGE }, :test => true)
|
27
28
|
else
|
28
29
|
raise Error, ERROR_MESSAGE
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
32
33
|
def purchase(money, creditcard, options = {})
|
34
|
+
money = amount(money)
|
33
35
|
case creditcard.number
|
34
36
|
when '1'
|
35
|
-
Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money
|
37
|
+
Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true)
|
36
38
|
when '2'
|
37
|
-
Response.new(false, FAILURE_MESSAGE, {:paid_amount => money
|
39
|
+
Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE },:test => true)
|
38
40
|
else
|
39
41
|
raise Error, ERROR_MESSAGE
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
43
45
|
def credit(money, ident, options = {})
|
46
|
+
money = amount(money)
|
44
47
|
case ident
|
45
48
|
when '1'
|
46
49
|
raise Error, CREDIT_ERROR_MESSAGE
|
47
50
|
when '2'
|
48
|
-
Response.new(false, FAILURE_MESSAGE, {:paid_amount => money
|
51
|
+
Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE }, :test => true)
|
49
52
|
else
|
50
|
-
Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money
|
53
|
+
Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true)
|
51
54
|
end
|
52
55
|
end
|
53
56
|
|
54
57
|
def capture(money, ident, options = {})
|
58
|
+
money = amount(money)
|
55
59
|
case ident
|
56
60
|
when '1'
|
57
61
|
raise Error, CAPTURE_ERROR_MESSAGE
|
58
62
|
when '2'
|
59
|
-
Response.new(false, FAILURE_MESSAGE, {:paid_amount => money
|
63
|
+
Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE }, :test => true)
|
60
64
|
else
|
61
|
-
Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money
|
65
|
+
Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true)
|
62
66
|
end
|
63
67
|
end
|
64
68
|
|
@@ -0,0 +1,222 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class GarantiGateway < Gateway
|
4
|
+
URL = 'https://ccpos.garanti.com.tr/servlet/cc5ApiServer'
|
5
|
+
|
6
|
+
# The countries the gateway supports merchants from as 2 digit ISO country codes
|
7
|
+
self.supported_countries = ['US','TR']
|
8
|
+
|
9
|
+
# The card types supported by the payment gateway
|
10
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
11
|
+
|
12
|
+
# The homepage URL of the gateway
|
13
|
+
self.homepage_url = 'https://ccpos.garanti.com.tr/ccRaporlar/garanti/ccReports'
|
14
|
+
|
15
|
+
# The name of the gateway
|
16
|
+
self.display_name = 'Garanti Sanal POS'
|
17
|
+
|
18
|
+
self.default_currency = 'TRL'
|
19
|
+
|
20
|
+
CURRENCY_CODES = {
|
21
|
+
'YTL' => 949,
|
22
|
+
'TRL' => 949,
|
23
|
+
'USD' => 840,
|
24
|
+
'EUR' => 978
|
25
|
+
}
|
26
|
+
|
27
|
+
|
28
|
+
def initialize(options = {})
|
29
|
+
requires!(options, :login, :password, :client_id)
|
30
|
+
@options = options
|
31
|
+
super
|
32
|
+
end
|
33
|
+
|
34
|
+
def purchase(money, credit_card, options = {})
|
35
|
+
commit(money, build_sale_request(money, credit_card, options))
|
36
|
+
end
|
37
|
+
|
38
|
+
def authorize(money, credit_card, options = {})
|
39
|
+
commit(money, build_authorize_request(money, credit_card, options))
|
40
|
+
end
|
41
|
+
|
42
|
+
def capture(money, reference, options = {})
|
43
|
+
commit(money, build_capture_request(money,reference,options))
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def build_xml_request(transaction_type,&block)
|
49
|
+
xml = Builder::XmlMarkup.new
|
50
|
+
xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
|
51
|
+
|
52
|
+
xml.tag! 'CC5Request' do
|
53
|
+
xml.tag! 'Name', @options[:login]
|
54
|
+
xml.tag! 'Password', @options[:password]
|
55
|
+
xml.tag! 'ClientId', @options[:client_id]
|
56
|
+
xml.tag! 'Mode', if test? then 'R' else 'P' end
|
57
|
+
xml.tag! 'Type', transaction_type
|
58
|
+
|
59
|
+
if block_given?
|
60
|
+
yield xml
|
61
|
+
else
|
62
|
+
xml.target!
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def build_sale_request(money, credit_card, options)
|
68
|
+
build_xml_request('Auth') do |xml|
|
69
|
+
add_customer_data(xml,options)
|
70
|
+
add_order_data(xml,options)
|
71
|
+
add_credit_card(xml, credit_card)
|
72
|
+
add_addresses(xml, options)
|
73
|
+
|
74
|
+
xml.tag! 'Total', amount(money)
|
75
|
+
xml.tag! 'Currency', currency_code(options[:currency])
|
76
|
+
|
77
|
+
xml.target!
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def build_authorize_request(money, credit_card, options)
|
82
|
+
build_xml_request('PreAuth') do |xml|
|
83
|
+
add_customer_data(xml,options)
|
84
|
+
add_order_data(xml,options)
|
85
|
+
add_credit_card(xml, credit_card)
|
86
|
+
add_addresses(xml, options)
|
87
|
+
|
88
|
+
xml.tag! 'Total', amount(money)
|
89
|
+
xml.tag! 'Currency', currency_code(options[:currency])
|
90
|
+
|
91
|
+
xml.target!
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def build_capture_request(money, reference, options = {})
|
97
|
+
build_xml_request('PostAuth') do |xml|
|
98
|
+
add_customer_data(xml,options)
|
99
|
+
xml.tag! 'OrderId', reference
|
100
|
+
xml.tag! 'Total', amount(money)
|
101
|
+
xml.tag! 'Currency', currency_code(options[:currency])
|
102
|
+
|
103
|
+
xml.target!
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def build_void_request(reference, options = {})
|
108
|
+
build_xml_request('Void') do |xml|
|
109
|
+
add_customer_data(xml,options)
|
110
|
+
xml.tag! 'OrderId', reference
|
111
|
+
xml.tag! 'Total', amount(money)
|
112
|
+
xml.tag! 'Currency', currency_code(options[:currency])
|
113
|
+
|
114
|
+
xml.target!
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def build_credit_request(money, reference, options = {})
|
119
|
+
build_xml_request('Credit') do |xml|
|
120
|
+
add_customer_data(xml,options)
|
121
|
+
xml.tag! 'OrderId', reference
|
122
|
+
xml.tag! 'Total', amount(money)
|
123
|
+
xml.tag! 'Currency', currency_code(options[:currency])
|
124
|
+
|
125
|
+
xml.target!
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def add_customer_data(xml, options)
|
130
|
+
xml.tag! 'IPAddress', options[:ip_]
|
131
|
+
xml.tag! 'Email', options[:email]
|
132
|
+
end
|
133
|
+
|
134
|
+
def add_order_data(xml,options)
|
135
|
+
xml.tag! 'OrderId', options[:order_id]
|
136
|
+
xml.tag! 'GroupId', nil
|
137
|
+
xml.tag! 'TransId', nil
|
138
|
+
end
|
139
|
+
|
140
|
+
def add_credit_card(xml, credit_card)
|
141
|
+
xml.tag! 'Number', credit_card.number
|
142
|
+
xml.tag! 'Expires', [format_exp(credit_card.month),format_exp(credit_card.year)].join('/')
|
143
|
+
xml.tag! 'Cvv2Val', credit_card.verification_value
|
144
|
+
end
|
145
|
+
|
146
|
+
def format_exp(value)
|
147
|
+
format(value, :two_digits)
|
148
|
+
end
|
149
|
+
|
150
|
+
def add_addresses(xml,options)
|
151
|
+
if billing_address = options[:billing_address] || options[:address]
|
152
|
+
xml.tag! 'BillTo' do
|
153
|
+
xml.tag! 'Name', billing_address[:name]
|
154
|
+
xml.tag! 'Street1', billing_address[:address1]
|
155
|
+
xml.tag! 'Street2', billing_address[:address2]
|
156
|
+
xml.tag! 'City', billing_address[:city]
|
157
|
+
xml.tag! 'StateProv', billing_address[:state]
|
158
|
+
xml.tag! 'PostalCode', billing_address[:zip]
|
159
|
+
xml.tag! 'Country', billing_address[:country]
|
160
|
+
xml.tag! 'Company', billing_address[:company]
|
161
|
+
xml.tag! 'TelVoice', billing_address[:phone]
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
if shipping_address = options[:shipping_address]
|
166
|
+
xml.tag! 'ShipTo' do
|
167
|
+
xml.tag! 'Name', shipping_address[:name]
|
168
|
+
xml.tag! 'Street1', shipping_address[:address1]
|
169
|
+
xml.tag! 'Street2', shipping_address[:address2]
|
170
|
+
xml.tag! 'City', shipping_address[:city]
|
171
|
+
xml.tag! 'StateProv',shipping_address[:state]
|
172
|
+
xml.tag! 'PostalCode',shipping_address[:zip]
|
173
|
+
xml.tag! 'Country', shipping_address[:country]
|
174
|
+
xml.tag! 'Company', shipping_address[:company]
|
175
|
+
xml.tag! 'TelVoice', shipping_address[:phone]
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def currency_code(currency)
|
181
|
+
CURRENCY_CODES[currency] || CURRENCY_CODES[default_currency]
|
182
|
+
end
|
183
|
+
|
184
|
+
def commit(money,request)
|
185
|
+
raw_response = ssl_post(URL,"DATA=" + request)
|
186
|
+
response = parse(raw_response)
|
187
|
+
|
188
|
+
success = success?(response)
|
189
|
+
|
190
|
+
Response.new(success,
|
191
|
+
success ? 'Approved' : 'Declined',
|
192
|
+
response,
|
193
|
+
:test => test?,
|
194
|
+
:authorization => response[:order_id])
|
195
|
+
end
|
196
|
+
|
197
|
+
def parse(body)
|
198
|
+
xml = REXML::Document.new(body)
|
199
|
+
|
200
|
+
response = {}
|
201
|
+
xml.root.elements.to_a.each do |node|
|
202
|
+
parse_element(response, node)
|
203
|
+
end
|
204
|
+
response
|
205
|
+
end
|
206
|
+
|
207
|
+
def parse_element(response, node)
|
208
|
+
if node.has_elements?
|
209
|
+
node.elements.each{|element| parse_element(response, element) }
|
210
|
+
else
|
211
|
+
response[node.name.underscore.to_sym] = node.text
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
def success?(response)
|
216
|
+
response[:response] == "Approved"
|
217
|
+
end
|
218
|
+
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
@@ -2,7 +2,7 @@ module ActiveMerchant #:nodoc:
|
|
2
2
|
module Billing #:nodoc:
|
3
3
|
class MerchantESolutionsGateway < Gateway
|
4
4
|
|
5
|
-
TEST_URL = 'https://
|
5
|
+
TEST_URL = 'https://cert.merchante-solutions.com/mes-api/tridentApi'
|
6
6
|
LIVE_URL = 'https://api.merchante-solutions.com/mes-api/tridentApi'
|
7
7
|
|
8
8
|
# The countries the gateway supports merchants from as 2 digit ISO country codes
|
@@ -114,6 +114,11 @@ module ActiveMerchant #:nodoc:
|
|
114
114
|
xml.tag! 'n2:cpp-header-border-color', options[:header_border_color] unless options[:header_border_color].blank?
|
115
115
|
xml.tag! 'n2:cpp-payflow-color', options[:background_color] unless options[:background_color].blank?
|
116
116
|
|
117
|
+
if options[:allow_guest_checkout]
|
118
|
+
xml.tag! 'n2:SolutionType', 'Sole'
|
119
|
+
xml.tag! 'n2:LandingPage', 'Billing'
|
120
|
+
end
|
121
|
+
|
117
122
|
xml.tag! 'n2:LocaleCode', options[:locale] unless options[:locale].blank?
|
118
123
|
end
|
119
124
|
end
|
@@ -88,7 +88,7 @@ module ActiveMerchant #:nodoc:
|
|
88
88
|
# * <tt>:drivers_license_number</tt> - The customer's drivers license number.
|
89
89
|
# * <tt>:date_of_birth</tt> - The customer's date of birth as a Time or Date object or a string in the format <tt>mm/dd/yyyy</tt>.
|
90
90
|
def purchase(money, source, options = {})
|
91
|
-
if source
|
91
|
+
if card_brand(source) == "check"
|
92
92
|
virtual_check.purchase(money, source, options)
|
93
93
|
else
|
94
94
|
bankcard.purchase(money, source, options)
|
@@ -125,7 +125,7 @@ module ActiveMerchant #:nodoc:
|
|
125
125
|
# * <tt>money</tt> - The amount to be authorized as an integer value in cents.
|
126
126
|
# * <tt>source</tt> - The CreditCard or Check object to be used as the target for the credit.
|
127
127
|
def credit(money, source, options = {})
|
128
|
-
if source
|
128
|
+
if card_brand(source) == "check"
|
129
129
|
virtual_check.credit(money, source, options)
|
130
130
|
else
|
131
131
|
bankcard.credit(money, source, options)
|
@@ -4,6 +4,9 @@ require 'net/https'
|
|
4
4
|
require 'benchmark'
|
5
5
|
|
6
6
|
module ActiveMerchant
|
7
|
+
class ClientCertificateError < ActiveMerchantError # :nodoc
|
8
|
+
end
|
9
|
+
|
7
10
|
class ConnectionError < ActiveMerchantError # :nodoc:
|
8
11
|
end
|
9
12
|
|
@@ -82,6 +85,8 @@ module ActiveMerchant
|
|
82
85
|
raise RetriableConnectionError, "The remote server refused the connection"
|
83
86
|
rescue Timeout::Error, Errno::ETIMEDOUT => e
|
84
87
|
raise ConnectionError, "The connection to the remote server timed out"
|
88
|
+
rescue OpenSSL::X509::CertificateError => e
|
89
|
+
raise ClientCertificateError, "The remote server did not accept the provided SSL certificate"
|
85
90
|
end
|
86
91
|
end
|
87
92
|
end
|
data/test/fixtures.yml
CHANGED
@@ -348,8 +348,13 @@ wirecard:
|
|
348
348
|
login: 56500
|
349
349
|
password: TestXAPTER
|
350
350
|
|
351
|
-
#
|
351
|
+
# Working test credentials, no need to replace
|
352
352
|
merchant_esolutions:
|
353
|
-
login: "
|
354
|
-
password: "
|
353
|
+
login: "94100008043900000004"
|
354
|
+
password: "gvQzgKXOTEoDzpzJzROrQQzoKLaEqxjf"
|
355
|
+
|
356
|
+
garanti:
|
357
|
+
client_id: '100104'
|
358
|
+
login: 'paymentuser'
|
359
|
+
password: 'userpayment'
|
355
360
|
|
@@ -126,9 +126,11 @@ class RemoteCyberSourceTest < Test::Unit::TestCase
|
|
126
126
|
|
127
127
|
def test_invalid_login
|
128
128
|
gateway = CyberSourceGateway.new( :login => '', :password => '' )
|
129
|
-
|
130
|
-
|
131
|
-
|
129
|
+
authentication_exception = assert_raise ActiveMerchant::ResponseError, 'Failed with 500 Internal Server Error' do
|
130
|
+
gateway.purchase(@amount, @credit_card, @options)
|
131
|
+
end
|
132
|
+
assert response = authentication_exception.response
|
133
|
+
assert_match /wsse:InvalidSecurity/, response.body
|
132
134
|
end
|
133
135
|
|
134
136
|
def test_successful_credit
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
# NOTE: tests fail randomly because Garanti returns random(!) responses for their test server
|
4
|
+
class RemoteGarantiTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@gateway = GarantiGateway.new(fixtures(:garanti))
|
8
|
+
|
9
|
+
@amount = 1000 # 1000 cents = 10$
|
10
|
+
@declined_card = credit_card('4000100011112224')
|
11
|
+
@credit_card = credit_card('4000300011112220')
|
12
|
+
|
13
|
+
@options = {
|
14
|
+
:order_id => ActiveMerchant::Utils.generate_unique_id,
|
15
|
+
:billing_address => address,
|
16
|
+
:description => 'Store Purchase'
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_successful_purchase
|
21
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
22
|
+
assert_success response
|
23
|
+
assert_equal 'Approved', response.message
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_unsuccessful_purchase
|
27
|
+
assert response = @gateway.purchase(@amount, @declined_card, @options)
|
28
|
+
assert_failure response
|
29
|
+
assert_equal 'Declined', response.message
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_authorize_and_capture
|
33
|
+
amount = @amount
|
34
|
+
assert auth = @gateway.authorize(amount, @credit_card, @options)
|
35
|
+
assert_success auth
|
36
|
+
assert_equal 'Approved', auth.message
|
37
|
+
assert auth.authorization
|
38
|
+
assert capture = @gateway.capture(amount, auth.authorization)
|
39
|
+
assert_success capture
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_failed_capture
|
43
|
+
assert response = @gateway.capture(@amount, '')
|
44
|
+
assert_failure response
|
45
|
+
assert_equal 'Declined', response.message
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_invalid_login
|
49
|
+
gateway = GarantiGateway.new(
|
50
|
+
:login => '',
|
51
|
+
:password => '',
|
52
|
+
:client_id => '100104'
|
53
|
+
)
|
54
|
+
assert response = gateway.purchase(@amount, @credit_card, @options)
|
55
|
+
assert_failure response
|
56
|
+
assert_equal 'Insufficient permissions to perform requested operation.', response.params["err_msg"]
|
57
|
+
end
|
58
|
+
end
|
@@ -126,4 +126,12 @@ class ConnectionTest < Test::Unit::TestCase
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
|
+
def test_failure_with_ssl_certificate
|
130
|
+
Net::HTTP.any_instance.expects(:post).raises(OpenSSL::X509::CertificateError)
|
131
|
+
|
132
|
+
assert_raises(ActiveMerchant::ClientCertificateError) do
|
133
|
+
@connection.request(:post, '')
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
129
137
|
end
|
@@ -45,6 +45,19 @@ class CreditCardMethodsTest < Test::Unit::TestCase
|
|
45
45
|
assert_false valid_start_year?(1987)
|
46
46
|
end
|
47
47
|
|
48
|
+
def test_valid_start_year_can_handle_strings
|
49
|
+
assert valid_start_year?("2009")
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_valid_month_can_handle_strings
|
53
|
+
assert valid_month?("1")
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_valid_expiry_year_can_handle_strings
|
57
|
+
year = Time.now.year + 1
|
58
|
+
assert valid_expiry_year?(year.to_s)
|
59
|
+
end
|
60
|
+
|
48
61
|
def test_should_be_able_to_identify_valid_issue_numbers
|
49
62
|
assert valid_issue_number?(1)
|
50
63
|
assert valid_issue_number?(10)
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class GarantiTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Base.gateway_mode = :test
|
6
|
+
@gateway = GarantiGateway.new(fixtures(:garanti))
|
7
|
+
|
8
|
+
@credit_card = credit_card
|
9
|
+
@amount = 1000 #1000 cents, 10$
|
10
|
+
|
11
|
+
@options = {
|
12
|
+
:order_id => 'db4af18c5222503d845180350fbda516',
|
13
|
+
:billing_address => address,
|
14
|
+
:description => 'Store Purchase'
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_successful_purchase
|
19
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
20
|
+
|
21
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
22
|
+
|
23
|
+
assert_success response
|
24
|
+
|
25
|
+
# Replace with authorization number from the successful response
|
26
|
+
assert_equal 'db4af18c5222503d845180350fbda516', response.authorization
|
27
|
+
assert response.test?
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_unsuccessful_request
|
31
|
+
@gateway.expects(:ssl_post).returns(failed_purchase_response)
|
32
|
+
|
33
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
34
|
+
assert_failure response
|
35
|
+
assert response.test?
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
# Place raw successful response from gateway here
|
41
|
+
def successful_purchase_response
|
42
|
+
<<-EOF
|
43
|
+
<CC5Response>
|
44
|
+
<OrderId>db4af18c5222503d845180350fbda516</OrderId>
|
45
|
+
<GroupId>db4af18c5222503d845180350fbda516</GroupId>
|
46
|
+
<Response>Approved</Response>
|
47
|
+
<AuthCode>853030</AuthCode>
|
48
|
+
<HostRefNum></HostRefNum>
|
49
|
+
<ProcReturnCode></ProcReturnCode>
|
50
|
+
<TransId>4bd864bb-e506-3000-002d-00144f7c9514</TransId>
|
51
|
+
<ErrMsg></ErrMsg>
|
52
|
+
<Extra>
|
53
|
+
<TRXDATE>20100428 21:27:32</TRXDATE>
|
54
|
+
<NUMCODE>00000099999999</NUMCODE>
|
55
|
+
</Extra>
|
56
|
+
</CC5Response>
|
57
|
+
|
58
|
+
EOF
|
59
|
+
end
|
60
|
+
|
61
|
+
# Place raw failed response from gateway here
|
62
|
+
def failed_purchase_response
|
63
|
+
<<-EOF
|
64
|
+
<?xml version="1.0" encoding="ISO-8859-9"?>
|
65
|
+
<CC5Response>
|
66
|
+
<OrderId>97a1afb1ccc3aeaffa683e86ede62269</OrderId>
|
67
|
+
<GroupId>97a1afb1ccc3aeaffa683e86ede62269</GroupId>
|
68
|
+
<Response>Declined</Response>
|
69
|
+
<AuthCode></AuthCode>
|
70
|
+
<HostRefNum></HostRefNum>
|
71
|
+
<ProcReturnCode></ProcReturnCode>
|
72
|
+
<TransId>4bd864bb-e4fd-3000-002d-00144f7c9514</TransId>
|
73
|
+
<ErrMsg></ErrMsg>
|
74
|
+
<Extra>
|
75
|
+
<TRXDATE>20100428 21:27:30</TRXDATE>
|
76
|
+
<NUMCODE>00100099999999</NUMCODE>
|
77
|
+
</Extra>
|
78
|
+
</CC5Response>
|
79
|
+
|
80
|
+
EOF
|
81
|
+
end
|
82
|
+
end
|
@@ -16,6 +16,10 @@ class PayflowNvpUkTest < Test::Unit::TestCase
|
|
16
16
|
:description => 'Store Purchase'
|
17
17
|
}
|
18
18
|
end
|
19
|
+
|
20
|
+
def test_able_to_view_gateway_url
|
21
|
+
assert_equal("https://pilot-payflowpro.paypal.com", @gateway.gateway_url)
|
22
|
+
end
|
19
23
|
|
20
24
|
def test_successful_purchase
|
21
25
|
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
@@ -166,6 +166,13 @@ class PaypalExpressTest < Test::Unit::TestCase
|
|
166
166
|
|
167
167
|
assert_equal ["10736", "10002"] , response.params['error_codes'].split(',')
|
168
168
|
end
|
169
|
+
|
170
|
+
def test_allow_guest_checkout
|
171
|
+
xml = REXML::Document.new(@gateway.send(:build_setup_request, 'SetExpressCheckout', 10, {:allow_guest_checkout => true}))
|
172
|
+
|
173
|
+
assert_equal 'Sole', REXML::XPath.first(xml, '//n2:SolutionType').text
|
174
|
+
assert_equal 'Billing', REXML::XPath.first(xml, '//n2:LandingPage').text
|
175
|
+
end
|
169
176
|
|
170
177
|
private
|
171
178
|
def successful_details_response
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 1
|
7
7
|
- 5
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.5.1.
|
9
|
+
- 3
|
10
|
+
version: 1.5.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tobias Luetke
|
@@ -39,7 +39,7 @@ cert_chain:
|
|
39
39
|
hPaSTyVU0yCSnw==
|
40
40
|
-----END CERTIFICATE-----
|
41
41
|
|
42
|
-
date: 2010-
|
42
|
+
date: 2010-05-27 00:00:00 +01:00
|
43
43
|
default_executable:
|
44
44
|
dependencies:
|
45
45
|
- !ruby/object:Gem::Dependency
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- lib/active_merchant/billing/gateways/eway.rb
|
128
128
|
- lib/active_merchant/billing/gateways/exact.rb
|
129
129
|
- lib/active_merchant/billing/gateways/first_pay.rb
|
130
|
+
- lib/active_merchant/billing/gateways/garanti.rb
|
130
131
|
- lib/active_merchant/billing/gateways/instapay.rb
|
131
132
|
- lib/active_merchant/billing/gateways/jetpay.rb
|
132
133
|
- lib/active_merchant/billing/gateways/linkpoint.rb
|
@@ -243,6 +244,7 @@ files:
|
|
243
244
|
- test/remote/gateways/remote_eway_test.rb
|
244
245
|
- test/remote/gateways/remote_exact_test.rb
|
245
246
|
- test/remote/gateways/remote_first_pay_test.rb
|
247
|
+
- test/remote/gateways/remote_garanti_test.rb
|
246
248
|
- test/remote/gateways/remote_instapay_test.rb
|
247
249
|
- test/remote/gateways/remote_jetpay_test.rb
|
248
250
|
- test/remote/gateways/remote_linkpoint_test.rb
|
@@ -312,6 +314,7 @@ files:
|
|
312
314
|
- test/unit/gateways/eway_test.rb
|
313
315
|
- test/unit/gateways/exact_test.rb
|
314
316
|
- test/unit/gateways/first_pay_test.rb
|
317
|
+
- test/unit/gateways/garanti_test.rb
|
315
318
|
- test/unit/gateways/gateway_test.rb
|
316
319
|
- test/unit/gateways/instapay_test.rb
|
317
320
|
- test/unit/gateways/jetpay_test.rb
|
@@ -463,6 +466,7 @@ test_files:
|
|
463
466
|
- test/unit/gateways/viaklix_test.rb
|
464
467
|
- test/unit/gateways/quickpay_test.rb
|
465
468
|
- test/unit/gateways/modern_payments_cim_test.rb
|
469
|
+
- test/unit/gateways/garanti_test.rb
|
466
470
|
- test/unit/gateways/merchant_e_solutions_test.rb
|
467
471
|
- test/unit/gateways/moneris_test.rb
|
468
472
|
- test/unit/gateways/pay_secure_test.rb
|
@@ -546,6 +550,7 @@ test_files:
|
|
546
550
|
- test/remote/gateways/remote_payment_express_test.rb
|
547
551
|
- test/remote/gateways/remote_sage_bankcard_test.rb
|
548
552
|
- test/remote/gateways/remote_elavon_test.rb
|
553
|
+
- test/remote/gateways/remote_garanti_test.rb
|
549
554
|
- test/remote/gateways/remote_viaklix_test.rb
|
550
555
|
- test/remote/gateways/remote_beanstream_test.rb
|
551
556
|
- test/remote/gateways/remote_secure_pay_au_test.rb
|
metadata.gz.sig
CHANGED
Binary file
|