Class: Mollie::Ideal

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/mollie/ideal.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.testmodeObject

Returns the value of attribute testmode.



9
10
11
# File 'lib/mollie/ideal.rb', line 9

def testmode
  @testmode
end

Class Method Details

.banklistObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/mollie/ideal.rb', line 11

def banklist
  options = {:a => "banklist"}
  options.merge!({:testmode=>true}) if testmode
  payload = send_command(options).payload
  
  if payload.bank.class.name == "Mash"
    #in testmode there is  only 1 bank. This is not wrapped in an Array.
    return [payload.bank]
  elsif payload.bank.class.name == "Array"
    #in production mode the list is an Array.
    payload.bank
  end
end

.check_order(transaction_id) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/mollie/ideal.rb', line 43

def check_order(transaction_id)
  options = {
    :a => "check",
    :partnerid=>Mollie.partner_id,
    :transaction_id => transaction_id
  }
  options.merge!({:testmode=>true}) if testmode
  send_command(options).payload.order
end

.prepare_payment(bank_id, amount, description, return_url, callback_url) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/mollie/ideal.rb', line 25

def prepare_payment(bank_id,amount,description,return_url,callback_url)
  
  #callback_url is being called by mollie in the background. They add an GET parameter :transaction_id
  #return_url is used after the payment is done. The redirection also adds the :transaction_id as an GET parameter
  options = {
    :a => "fetch",
    :bank_id=>bank_id,
    :description=>description,
    :amount=>amount,
    :reporturl=>callback_url,
    :returnurl=>return_url,
    :partnerid=>Mollie.partner_id
  }
  
  options.merge!({:testmode=>true}) if testmode
  send_command(options).payload.order
end

.send_command(options) ⇒ Object



54
55
56
# File 'lib/mollie/ideal.rb', line 54

def send_command(options)
  IdealResponse.new(Mash.new( get("/xml/ideal", :query=> options, :format=>:xml) ))
end