Module: MollieNLIDeal

Defined in:
lib/mollienl-ideal/api.rb,
lib/mollienl-ideal/bank.rb,
lib/mollienl-ideal/config.rb,
lib/mollienl-ideal/engine.rb,
lib/mollienl-ideal/payment_result.rb,
lib/mollienl-ideal/payment_request.rb

Defined Under Namespace

Modules: Config Classes: Bank, Engine, PaymentRequest, PaymentResult

Constant Summary collapse

MOLLIE_URL =
"https://secure.mollie.nl/xml/ideal?"

Class Method Summary collapse

Class Method Details

.check_status(transaction_id) ⇒ Object

can be used for the report_url or standalone to check the status of the transaction. The mollie documentation specifies that this method can be called only once for a transaction.



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/mollienl-ideal/api.rb', line 43

def self.check_status(transaction_id)
  p = { 
    :a => "check", 
    :partnerid => Config.partner_id,
    :transaction_id => transaction_id
  }

  doc = get_data(p)
  doc.elements.each("response/order") do |elem|
    return PaymentResult.new(elem)
  end
end

.do_request_payment(amount, description, bank_id) ⇒ Object

Requests a payment for the specified amount (in cents) with description for the bank selected from the get_banks method.

the response holds a transaction_id which is the reference to this transaction, and a url to which must be redirected to in order to make the payment on the website of the selected bank



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/mollienl-ideal/api.rb', line 23

def self.do_request_payment(amount, description, bank_id)
  p = { 
    :a => "fetch", 
    :partnerid => Config.partner_id,
    :description => description,
    :reporturl => Config.report_url,
    :returnurl => Config.return_url,
    :amount => amount,
    :bank_id => bank_id
  }

  doc = get_data(p)
  doc.elements.each("response/order") do |elem|
    return PaymentRequest.new(elem)
  end
end

.get_banksObject

Returns a list of banks of which one must be selected to process the

transaction


6
7
8
9
10
11
12
13
14
15
# File 'lib/mollienl-ideal/api.rb', line 6

def self.get_banks
  banks = []

  doc = get_data({ "a" => "banklist"})
  doc.elements.each("response/bank") do |elem|
    banks << Bank.new(elem)
  end

  banks
end

.get_data(params) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/mollienl-ideal/api.rb', line 56

def self.get_data(params)
  params["testmode"] = Config.test_mode

  uri = URI.parse(MOLLIE_URL + URI.encode_www_form(params))
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true

  response = http.request(Net::HTTP::Get.new(uri.request_uri))

  doc = REXML::Document.new response.body
  doc.elements.each("response/item[@type='error']/message") do |elem|
    raise elem.text
  end

  doc
end