activemerchant 1.9.3 → 1.9.4

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.tar.gz.sig CHANGED
@@ -1 +1,2 @@
1
- ���!��?�}N�O�?64����q��}�3P��~\�@+J��f'J7^[�3����P����%2ǟ�AR΀��'�K��+�idyN~�3�P���V ��"��Mbq3S+�Rˆ.���l��Cy��f/�p�I\5f����χ��>��矶ԩ�L�u�܏8��I��W�M?n3Bw�
1
+ L��
2
+ ��1r��Y���
data/CHANGELOG CHANGED
@@ -1,5 +1,9 @@
1
1
  = ActiveMerchant CHANGELOG
2
2
 
3
+ == Version 1.9.4 (Jan 5, 2011)
4
+
5
+ * Update Garanti gateway to integrate with new API [Selem Delul]
6
+
3
7
  == Version 1.9.3 (December 17, 2010)
4
8
 
5
9
  * Fix BBS Netaxept to change transaction type from C (for MOTO: mail order telephone order) to M (for credit card orders) [Soleone]
@@ -1,7 +1,7 @@
1
1
  module ActiveMerchant #:nodoc:
2
2
  module Billing #:nodoc:
3
3
  class GarantiGateway < Gateway
4
- URL = 'https://ccpos.garanti.com.tr/servlet/cc5ApiServer'
4
+ URL = 'https://sanalposprov.garanti.com.tr/VPServlet'
5
5
 
6
6
  # The countries the gateway supports merchants from as 2 digit ISO country codes
7
7
  self.supported_countries = ['US','TR']
@@ -10,51 +10,76 @@ module ActiveMerchant #:nodoc:
10
10
  self.supported_cardtypes = [:visa, :master, :american_express, :discover]
11
11
 
12
12
  # The homepage URL of the gateway
13
- self.homepage_url = 'https://sanalposweb.garanti.com.tr/gvpsui/login/LoginStart.jsp'
13
+ self.homepage_url = 'https://sanalposweb.garanti.com.tr'
14
14
 
15
15
  # The name of the gateway
16
16
  self.display_name = 'Garanti Sanal POS'
17
17
 
18
18
  self.default_currency = 'TRL'
19
19
 
20
+ self.money_format = :cents
21
+
20
22
  CURRENCY_CODES = {
21
23
  'YTL' => 949,
22
24
  'TRL' => 949,
25
+ 'TL' => 949,
23
26
  'USD' => 840,
24
- 'EUR' => 978
27
+ 'EUR' => 978,
28
+ 'GBP' => 826,
29
+ 'JPY' => 392
25
30
  }
26
31
 
27
32
 
28
33
  def initialize(options = {})
29
- requires!(options, :login, :password, :client_id)
34
+ requires!(options, :login, :password, :terminal_id, :merchant_id)
30
35
  @options = options
31
36
  super
32
37
  end
33
38
 
34
39
  def purchase(money, credit_card, options = {})
40
+ options = options.merge(:gvp_order_type => "sales")
35
41
  commit(money, build_sale_request(money, credit_card, options))
36
42
  end
37
43
 
38
44
  def authorize(money, credit_card, options = {})
45
+ options = options.merge(:gvp_order_type => "preauth")
39
46
  commit(money, build_authorize_request(money, credit_card, options))
40
47
  end
41
48
 
42
- def capture(money, reference, options = {})
43
- commit(money, build_capture_request(money,reference,options))
49
+ def capture(money, ref_id, options = {})
50
+ options = options.merge(:gvp_order_type => "postauth")
51
+ commit(money, build_capture_request(money, ref_id, options))
44
52
  end
45
53
 
46
54
  private
47
55
 
48
- def build_xml_request(transaction_type,&block)
49
- xml = Builder::XmlMarkup.new
50
- xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
56
+ def security_data
57
+ rjusted_terminal_id = @options[:terminal_id].to_s.rjust(9, "0")
58
+ Digest::SHA1.hexdigest(@options[:password].to_s + rjusted_terminal_id).upcase
59
+ end
60
+
61
+ def generate_hash_data(order_id, terminal_id, credit_card_number, amount, security_data)
62
+ data = [order_id, terminal_id, credit_card_number, amount, security_data].join
63
+ Digest::SHA1.hexdigest(data).upcase
64
+ end
65
+
66
+ def build_xml_request(money, credit_card, options, &block)
67
+ card_number = credit_card.respond_to?(:number) ? credit_card.number : ''
68
+ hash_data = generate_hash_data(options[:order_id], @options[:terminal_id], card_number, amount(money), security_data)
69
+
70
+ xml = Builder::XmlMarkup.new(:indent => 2)
71
+ xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8"
51
72
 
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
73
+ xml.tag! 'GVPSRequest' do
74
+ xml.tag! 'Mode', test? ? 'TEST' : 'PROD'
75
+ xml.tag! 'Version', 'V0.01'
76
+ xml.tag! 'Terminal' do
77
+ xml.tag! 'ProvUserID', 'PROVAUT'
78
+ xml.tag! 'HashData', hash_data
79
+ xml.tag! 'UserID', @options[:login]
80
+ xml.tag! 'ID', @options[:terminal_id]
81
+ xml.tag! 'MerchantID', @options[:merchant_id]
82
+ end
58
83
 
59
84
  if block_given?
60
85
  yield xml
@@ -65,130 +90,124 @@ module ActiveMerchant #:nodoc:
65
90
  end
66
91
 
67
92
  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)
93
+ build_xml_request(money, credit_card, options) do |xml|
94
+ add_customer_data(xml, options)
95
+ add_order_data(xml, options) do |xml|
96
+ add_addresses(xml, options)
97
+ end
71
98
  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])
99
+ add_transaction_data(xml, money, options)
76
100
 
77
101
  xml.target!
78
102
  end
79
103
  end
80
104
 
81
105
  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)
106
+ build_xml_request(money, credit_card, options) do |xml|
107
+ add_customer_data(xml, options)
108
+ add_order_data(xml, options) do |xml|
109
+ add_addresses(xml, options)
110
+ end
85
111
  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])
112
+ add_transaction_data(xml, money, options)
90
113
 
91
114
  xml.target!
92
-
93
115
  end
94
116
  end
95
117
 
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])
118
+ def build_capture_request(money, ref_id, options)
119
+ options = options.merge(:order_id => ref_id)
120
+ build_xml_request(money, ref_id, options) do |xml|
121
+ add_customer_data(xml, options)
122
+ add_order_data(xml, options)
123
+ add_transaction_data(xml, money, options)
102
124
 
103
125
  xml.target!
104
126
  end
105
127
  end
106
128
 
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!
129
+ def add_customer_data(xml, options)
130
+ xml.tag! 'Customer' do
131
+ xml.tag! 'IPAddress', options[:ip] || '1.1.1.1'
132
+ xml.tag! 'EmailAddress', options[:email]
115
133
  end
116
134
  end
117
135
 
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])
136
+ def add_order_data(xml, options, &block)
137
+ xml.tag! 'Order' do
138
+ xml.tag! 'OrderID', options[:order_id]
139
+ xml.tag! 'GroupID'
124
140
 
125
- xml.target!
141
+ if block_given?
142
+ yield xml
143
+ end
126
144
  end
127
145
  end
128
146
 
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
147
  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
148
+ xml.tag! 'Card' do
149
+ xml.tag! 'Number', credit_card.number
150
+ xml.tag! 'ExpireDate', [format_exp(credit_card.month), format_exp(credit_card.year)].join
151
+ xml.tag! 'CVV2', credit_card.verification_value
152
+ end
144
153
  end
145
154
 
146
155
  def format_exp(value)
147
156
  format(value, :two_digits)
148
157
  end
149
158
 
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]
159
+ def add_addresses(xml, options)
160
+ xml.tag! 'AddressList' do
161
+ if billing_address = options[:billing_address] || options[:address]
162
+ xml.tag! 'Address' do
163
+ xml.tag! 'Type', 'B'
164
+ add_address(xml, billing_address)
165
+ end
162
166
  end
163
- end
164
167
 
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]
168
+ if options[:shipping_address]
169
+ xml.tag! 'Address' do
170
+ xml.tag! 'Type', 'S'
171
+ add_address(xml, options[:shipping_address])
172
+ end
176
173
  end
177
174
  end
178
175
  end
179
176
 
177
+ def add_address(xml, address)
178
+ xml.tag! 'Name', address[:name]
179
+ address_text = address[:address1]
180
+ address_text << " #{address[:address2]}" if address[:address2]
181
+ xml.tag! 'Text', address_text
182
+ xml.tag! 'City', address[:city]
183
+ xml.tag! 'District', address[:state]
184
+ xml.tag! 'PostalCode', address[:zip]
185
+ xml.tag! 'Country', address[:country]
186
+ xml.tag! 'Company', address[:company]
187
+ xml.tag! 'PhoneNumber', address[:phone].to_s.gsub(/[^0-9]/, '') if address[:phone]
188
+ end
189
+
190
+ def add_transaction_data(xml, money, options)
191
+ xml.tag! 'Transaction' do
192
+ xml.tag! 'Type', options[:gvp_order_type]
193
+ xml.tag! 'Amount', amount(money)
194
+ xml.tag! 'CurrencyCode', currency_code(options[:currency] || currency(money))
195
+ xml.tag! 'CardholderPresentCode', 0
196
+ end
197
+ end
198
+
180
199
  def currency_code(currency)
181
200
  CURRENCY_CODES[currency] || CURRENCY_CODES[default_currency]
182
201
  end
183
202
 
184
203
  def commit(money,request)
185
- raw_response = ssl_post(URL,"DATA=" + request)
204
+ raw_response = ssl_post(URL, "data=" + request)
186
205
  response = parse(raw_response)
187
206
 
188
207
  success = success?(response)
189
208
 
190
209
  Response.new(success,
191
- success ? 'Approved' : 'Declined',
210
+ success ? 'Approved' : "Declined (Reason: #{response[:reason_code]} - #{response[:error_msg]})",
192
211
  response,
193
212
  :test => test?,
194
213
  :authorization => response[:order_id])
@@ -213,7 +232,7 @@ module ActiveMerchant #:nodoc:
213
232
  end
214
233
 
215
234
  def success?(response)
216
- response[:response] == "Approved"
235
+ response[:message] == "Approved"
217
236
  end
218
237
 
219
238
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveMerchant
2
- VERSION = "1.9.3"
2
+ VERSION = "1.9.4"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activemerchant
3
3
  version: !ruby/object:Gem::Version
4
- hash: 53
4
+ hash: 59
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 9
9
- - 3
10
- version: 1.9.3
9
+ - 4
10
+ version: 1.9.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tobias Luetke
@@ -36,7 +36,7 @@ cert_chain:
36
36
  hPaSTyVU0yCSnw==
37
37
  -----END CERTIFICATE-----
38
38
 
39
- date: 2010-12-17 00:00:00 -05:00
39
+ date: 2011-01-05 00:00:00 +01:00
40
40
  default_executable:
41
41
  dependencies:
42
42
  - !ruby/object:Gem::Dependency
metadata.gz.sig CHANGED
Binary file