Class Index [+]

Quicksearch

ActiveMerchant::Billing::IdealBaseGateway

Implementation contains some simplifications

Constants

AUTHENTICATION_TYPE

These constants will never change for most users

LANGUAGE
SUB_ID
API_VERSION

Attributes

url[R]

Public Class Methods

new(options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/ideal/ideal_base.rb, line 22
22:       def initialize(options = {})
23:         requires!(options, :login, :password, :pem)
24:         @options = options
25: 
26:         @options[:pem_password] = options[:password]
27:         @url = test? ? test_url : live_url
28:         super
29:       end

Public Instance Methods

capture(transaction, options = {}) click to toggle source

Check status of transaction and confirm payment transaction_id must be a valid transaction_id from a prior setup.

    # File lib/active_merchant/billing/gateways/ideal/ideal_base.rb, line 40
40:       def capture(transaction, options = {})
41:         options[:transaction_id] = transaction
42:         commit(build_status_request(options))
43:       end
issuers() click to toggle source

Get list of issuers from response.issuer_list

    # File lib/active_merchant/billing/gateways/ideal/ideal_base.rb, line 46
46:       def issuers
47:         commit(build_directory_request)
48:       end
setup_purchase(money, options = {}) click to toggle source

Setup transaction. Get redirect_url from response.service_url

    # File lib/active_merchant/billing/gateways/ideal/ideal_base.rb, line 32
32:       def setup_purchase(money, options = {})
33:         requires!(options, :issuer_id, :return_url, :order_id, :currency, :description, :entrance_code)
34: 
35:         commit(build_transaction_request(money, options))
36:       end
test?() click to toggle source
    # File lib/active_merchant/billing/gateways/ideal/ideal_base.rb, line 50
50:       def test?
51:         @options[:test] || Base.gateway_mode == :test
52:       end

Private Instance Methods

build_directory_request() click to toggle source

www.idealdesk.com/Message“ version=“1.1.0“>

 <createDateTimeStamp>2001-12-17T09:30:47.0Z</createDateTimeStamp>
 <Merchant>
  <merchantID>000000001</merchantID>
  <subID>0</subID>
  <authentication>1</authentication>
  <token>hashkey</token>
  <tokenCode>WajqV1a3nDen0be2r196g9FGFF=</tokenCode>
 </Merchant>

     # File lib/active_merchant/billing/gateways/ideal/ideal_base.rb, line 178
178:       def build_directory_request
179:         datetimestamp = create_time_stamp
180:         message = datetimestamp + @options[:login] + SUB_ID
181:         tokenCode = sign_message(@options[:pem], @options[:password], message)
182: 
183:         xml = Builder::XmlMarkup.new(:indent => 2)
184:         xml.instruct!
185:         xml.tag! 'DirectoryReq', 'xmlns' => 'http://www.idealdesk.com/Message', 'version' => API_VERSION do
186:           xml.tag! 'createDateTimeStamp', datetimestamp
187:           xml.tag! 'Merchant' do
188:             xml.tag! 'merchantID', @options[:login]
189:             xml.tag! 'subID', SUB_ID
190:             xml.tag! 'authentication', AUTHENTICATION_TYPE
191:             xml.tag! 'token', token
192:             xml.tag! 'tokenCode', tokenCode
193:           end
194:         end
195:         xml.target!
196:       end
build_status_request(options) click to toggle source

www.idealdesk.com/Message“ version=“1.1.0“>

 <createDateTimeStamp>2001-12-17T09:30:47.0Z</createDateTimeStamp>
 <Merchant>
  <merchantID>000123456</merchantID>
  <subID>0</subID>
  <authentication>keyed hash</authentication>
  <token>1</token>
  <tokenCode>3823ad872eff23</tokenCode>
 </Merchant>
 <Transaction>
  <transactionID>0001023456789112</transactionID>
 </Transaction>

     # File lib/active_merchant/billing/gateways/ideal/ideal_base.rb, line 144
144:       def build_status_request(options)
145:         datetimestamp = create_time_stamp
146:         message = datetimestamp + @options[:login] + SUB_ID + options[:transaction_id]
147:         tokenCode = sign_message(@options[:pem], @options[:password], message)
148: 
149:         xml = Builder::XmlMarkup.new(:indent => 2)
150:         xml.instruct!
151:         xml.tag! 'AcquirerStatusReq', 'xmlns' => 'http://www.idealdesk.com/Message', 'version' => API_VERSION do
152:           xml.tag! 'createDateTimeStamp', datetimestamp
153:           xml.tag! 'Merchant' do
154:             xml.tag! 'merchantID', @options[:login]
155:             xml.tag! 'subID', SUB_ID
156:             xml.tag! 'authentication' , AUTHENTICATION_TYPE
157:             xml.tag! 'token', token
158:             xml.tag! 'tokenCode', tokenCode
159:           end
160:           xml.tag! 'Transaction' do
161:             xml.tag! 'transactionID', options[:transaction_id]
162:           end
163:         end
164:         xml.target!
165:       end
build_transaction_request(money, options) click to toggle source

www.idealdesk.com/Message“ version=“1.1.0“>

 <createDateTimeStamp>2001-12-17T09:30:47.0Z</createDateTimeStamp>
 <Issuer>
  <issuerID>1003</issuerID>
 </Issuer>
  <Merchant>
    <merchantID>000123456</merchantID>
    <subID>0</subID>
    <authentication>passkey</authentication>
    <token>1</token>
    <tokenCode>3823ad872eff23</tokenCode>
    <merchantReturnURL>https://www.mijnwinkel.nl/betaalafhandeling
     </merchantReturnURL>
  </Merchant>
  <Transaction>
    <purchaseID>iDEAL-aankoop 21</purchaseID>
    <amount>5999</amount>
    <currency>EUR</currency>
    <expirationPeriod>PT3M30S</expirationPeriod>
    <language>nl</language>
    <description>Documentensuite</description>
    <entranceCode>D67tyx6rw9IhY71</entranceCode>
  </Transaction>

     # File lib/active_merchant/billing/gateways/ideal/ideal_base.rb, line 87
 87:       def build_transaction_request(money, options)
 88:         date_time_stamp = create_time_stamp
 89:         message  = date_time_stamp +
 90:                    options[:issuer_id] +
 91:                    @options[:login] +
 92:                    SUB_ID +
 93:                    options[:return_url] +
 94:                    options[:order_id] +
 95:                    money.to_s +
 96:                    (options[:currency] || currency(money)) +
 97:                    LANGUAGE +
 98:                    options[:description] +
 99:                    options[:entrance_code]
100:         token_code = sign_message(@options[:pem], @options[:password], message)
101: 
102:         xml = Builder::XmlMarkup.new(:indent => 2)
103:         xml.instruct!
104:         xml.tag! 'AcquirerTrxReq', 'xmlns' => 'http://www.idealdesk.com/Message', 'version' => API_VERSION do
105:           xml.tag! 'createDateTimeStamp', date_time_stamp
106:           xml.tag! 'Issuer' do
107:             xml.tag! 'issuerID', options[:issuer_id]
108:           end
109:           xml.tag! 'Merchant' do
110:             xml.tag! 'merchantID', @options[:login]
111:             xml.tag! 'subID', SUB_ID
112:             xml.tag! 'authentication', AUTHENTICATION_TYPE
113:             xml.tag! 'token', token
114:             xml.tag! 'tokenCode', token_code
115:             xml.tag! 'merchantReturnURL', options[:return_url]
116:           end
117:           xml.tag! 'Transaction' do
118:             xml.tag! 'purchaseID', options[:order_id]
119:             xml.tag! 'amount', money
120:             xml.tag! 'currency', options[:currency]
121:             xml.tag! 'expirationPeriod', options[:expiration_period] || default_expiration_period
122:             xml.tag! 'language', LANGUAGE
123:             xml.tag! 'description', options[:description]
124:             xml.tag! 'entranceCode', options[:entrance_code]
125:           end
126:           xml.target!
127:         end
128:       end
commit(request) click to toggle source
     # File lib/active_merchant/billing/gateways/ideal/ideal_base.rb, line 198
198:       def commit(request)
199:         raw_response = ssl_post(url, request)
200:         response = Hash.from_xml(raw_response.to_s)
201:         response_type = response.keys[0]
202: 
203:         case response_type
204:           when 'AcquirerTrxRes', 'DirectoryRes'
205:             success = true
206:           when 'ErrorRes'
207:             success = false
208:           when 'AcquirerStatusRes'
209:             raise SecurityError, "Message verification failed.", caller unless status_response_verified?(response)
210:             success = (response['AcquirerStatusRes']['Transaction']['status'] == 'Success')
211:           else
212:             raise ArgumentError, "Unknown response type.", caller
213:         end
214: 
215:         return IdealResponse.new(success, response.keys[0], response, :test => test?)
216:       end
create_fingerprint(cert_file) click to toggle source
     # File lib/active_merchant/billing/gateways/ideal/ideal_base.rb, line 218
218:       def create_fingerprint(cert_file)
219:         cert_data   = OpenSSL::X509::Certificate.new(cert_file).to_s
220:         cert_data   = cert_data.sub(/-----BEGIN CERTIFICATE-----/, '')
221:         cert_data   = cert_data.sub(/-----END CERTIFICATE-----/, '')
222:         fingerprint = ActiveSupport::Base64.decode64(cert_data)
223:         fingerprint = Digest::SHA1.hexdigest(fingerprint)
224:         return fingerprint.upcase
225:       end
create_time_stamp() click to toggle source
     # File lib/active_merchant/billing/gateways/ideal/ideal_base.rb, line 245
245:       def create_time_stamp
246:         Time.now.gmtime.strftime('%Y-%m-%dT%H:%M:%S.000Z')
247:       end
sign_message(private_key_data, password, data) click to toggle source
     # File lib/active_merchant/billing/gateways/ideal/ideal_base.rb, line 227
227:       def sign_message(private_key_data, password, data)
228:         private_key  = OpenSSL::PKey::RSA.new(private_key_data, password)
229:         signature = private_key.sign(OpenSSL::Digest::SHA1.new, data.gsub('\s', ''))
230:         return ActiveSupport::Base64.encode64(signature).gsub(/\n/, '')
231:       end
status_response_verified?(response) click to toggle source
     # File lib/active_merchant/billing/gateways/ideal/ideal_base.rb, line 238
238:       def status_response_verified?(response)
239:         transaction = response['AcquirerStatusRes']['Transaction']
240:         message = response['AcquirerStatusRes']['createDateTimeStamp'] + transaction['transactionID' ] + transaction['status']
241:         message << transaction['consumerAccountNumber'].to_s
242:         verify_message(server_pem, message, response['AcquirerStatusRes']['Signature']['signatureValue'])
243:       end
token() click to toggle source
    # File lib/active_merchant/billing/gateways/ideal/ideal_base.rb, line 55
55:       def token
56:         if @token.nil?
57:           @token = create_fingerprint(@options[:pem])
58:         end
59:         @token
60:       end
verify_message(cert_file, data, signature) click to toggle source
     # File lib/active_merchant/billing/gateways/ideal/ideal_base.rb, line 233
233:       def verify_message(cert_file, data, signature)
234:         public_key = OpenSSL::X509::Certificate.new(cert_file).public_key
235:         return public_key.verify(OpenSSL::Digest::SHA1.new, ActiveSupport::Base64.decode64(signature), data)
236:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.