Class: ActiveMerchant::Billing::IdealGateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/active_merchant_ideal/ideal.rb

Overview

Response classes

  • IdealResponse

  • IdealTransactionResponse

  • IdealStatusResponse

  • IdealDirectoryResponse

See the IdealResponse base class for more information on errors.

Constant Summary collapse

AUTHENTICATION_TYPE =
'SHA1_RSA'
LANGUAGE =
'nl'
CURRENCY =
'EUR'
API_VERSION =
'1.1.0'
XML_NAMESPACE =
'http://www.idealdesk.com/Message'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ IdealGateway

Initializes a new IdealGateway instance.

You can optionally specify :sub_id. Defaults to 0.



93
94
95
96
# File 'lib/active_merchant_ideal/ideal.rb', line 93

def initialize(options = {})
  @sub_id = options[:sub_id] || 0
  super
end

Instance Attribute Details

#sub_idObject (readonly)

Returns the merchant ‘subID’ being used for this IdealGateway instance. Defaults to 0.



88
89
90
# File 'lib/active_merchant_ideal/ideal.rb', line 88

def sub_id
  @sub_id
end

Class Method Details

.ideal_certificateObject

Returns the global merchant ideal_certificate.



74
75
76
# File 'lib/active_merchant_ideal/ideal.rb', line 74

def self.ideal_certificate
  @ideal_certificate
end

.ideal_certificate=(certificate_data) ⇒ Object

Instantiates and assings a OpenSSL::X509::Certificate instance with the provided iDEAL certificate data.



69
70
71
# File 'lib/active_merchant_ideal/ideal.rb', line 69

def self.ideal_certificate=(certificate_data)
  @ideal_certificate = OpenSSL::X509::Certificate.new(certificate_data)
end

.ideal_certificate_file=(certificate_file) ⇒ Object

Loads the global merchant ideal_certificate from disk.



63
64
65
# File 'lib/active_merchant_ideal/ideal.rb', line 63

def self.ideal_certificate_file=(certificate_file)
  self.ideal_certificate = File.read(certificate_file)
end

.private_certificateObject

Returns the global merchant private_certificate.



58
59
60
# File 'lib/active_merchant_ideal/ideal.rb', line 58

def self.private_certificate
  @private_certificate
end

.private_certificate=(certificate_data) ⇒ Object

Instantiates and assings a OpenSSL::X509::Certificate instance with the provided private certificate data.



53
54
55
# File 'lib/active_merchant_ideal/ideal.rb', line 53

def self.private_certificate=(certificate_data)
  @private_certificate = OpenSSL::X509::Certificate.new(certificate_data)
end

.private_certificate_file=(certificate_file) ⇒ Object

Loads the global merchant private_certificate from disk.



47
48
49
# File 'lib/active_merchant_ideal/ideal.rb', line 47

def self.private_certificate_file=(certificate_file)
  self.private_certificate = File.read(certificate_file)
end

.private_keyObject

Returns the global merchant private_certificate.



42
43
44
# File 'lib/active_merchant_ideal/ideal.rb', line 42

def self.private_key
  @private_key
end

.private_key=(pkey_data) ⇒ Object

Instantiates and assings a OpenSSL::PKey::RSA instance with the provided private key data.



37
38
39
# File 'lib/active_merchant_ideal/ideal.rb', line 37

def self.private_key=(pkey_data)
  @private_key = OpenSSL::PKey::RSA.new(pkey_data, passphrase)
end

.private_key_file=(pkey_file) ⇒ Object

Loads the global merchant private_key from disk.



31
32
33
# File 'lib/active_merchant_ideal/ideal.rb', line 31

def self.private_key_file=(pkey_file)
  self.private_key = File.read(pkey_file)
end

Instance Method Details

#acquirer_urlObject

Returns the url of the acquirer matching the current environment.

When #test? returns true the IdealGateway.test_url is used, otherwise the IdealGateway.live_url is used.



102
103
104
# File 'lib/active_merchant_ideal/ideal.rb', line 102

def acquirer_url
  test? ? self.class.test_url : self.class.live_url
end

#capture(transaction_id) ⇒ Object

Sends a acquirer status request for the specified transaction_id and returns an IdealStatusResponse.

It is your responsibility as the merchant to check if the payment has been made until you receive a response with a finished status like: ‘Success’, ‘Cancelled’, ‘Expired’, everything else equals ‘Open’.

Example

capture_response = gateway.capture(@purchase.transaction_id)
if capture_response.success?
  @purchase.update_attributes!(:paid => true)
  flash[:notice] = "Congratulations, you are now the proud owner of a Dutch windmill!"
end

See the IdealGateway class description for a more elaborate example.



179
180
181
# File 'lib/active_merchant_ideal/ideal.rb', line 179

def capture(transaction_id)
  post_data build_status_request_body(:transaction_id => transaction_id), IdealStatusResponse
end

#issuersObject

Sends a directory request to the acquirer and returns an IdealDirectoryResponse. Use IdealDirectoryResponse#list to receive the actuall array of available issuers.

gateway.issuers.list # => [{ :id => '1006', :name => 'ABN AMRO Bank' }, …]


111
112
113
# File 'lib/active_merchant_ideal/ideal.rb', line 111

def issuers
  post_data build_directory_request_body, IdealDirectoryResponse
end

#setup_purchase(money, options) ⇒ Object

Starts a purchase by sending an acquirer transaction request for the specified money amount in EURO cents.

On success returns an IdealTransactionResponse with the #transaction_id which is needed for the capture step. (See capture for an example.)

The iDEAL specification states that it is not allowed to use another window or frame when redirecting the consumer to the issuer. So the entire merchant’s page has to be replaced by the selected issuer’s page.

Options

Note that all options that have a character limit are also checked for diacritical characters. If it does contain diacritical characters, or exceeds the character limit, an ArgumentError is raised.

Required

  • :issuer_id - The :id of an issuer available at the acquirer to which the transaction should be made.

  • :order_id - The order number. Limited to 12 characters.

  • :description - A description of the transaction. Limited to 32 characters.

  • :return_url - A URL on the merchant’s system to which the consumer is redirected after payment. The acquirer will add the following GET variables:

    • trxid - The :order_id.

    • ec - The :entrance_code if it was specified.

Optional

  • :entrance_code - This code is an abitrary token which can be used to identify the transaction besides the :order_id. Limited to 40 characters.

  • :expiration_period - The period of validity of the payment request measured from the receipt by the issuer. The consumer must approve the payment within this period, otherwise the IdealStatusResponse#status will be set to ‘Expired’. E.g., consider an :expiration_period of ‘P3DT6H10M’:

    • P: relative time designation.

    • 3 days.

    • T: separator.

    • 6 hours.

    • 10 minutes.

Example

transaction_response = gateway.setup_purchase(4321, valid_options)
if transaction_response.success?
  @purchase.update_attributes!(:transaction_id => transaction_response.transaction_id)
  redirect_to transaction_response.service_url
end

See the IdealGateway class description for a more elaborate example.



159
160
161
# File 'lib/active_merchant_ideal/ideal.rb', line 159

def setup_purchase(money, options)
  post_data build_transaction_request_body(money, options), IdealTransactionResponse
end