module MollieNLIDeal
Constants
- MOLLIE_URL
Public Class Methods
check_status(transaction_id)
click to toggle source
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.
# 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)
click to toggle source
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
# 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_banks()
click to toggle source
Returns a list of banks of which one must be selected to process the transaction
# 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)
click to toggle source
# 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