Class: Mollie::Ideal
Instance Attribute Summary collapse
-
#partner_id ⇒ Object
readonly
Returns the value of attribute partner_id.
-
#production ⇒ Object
(also: #production?)
readonly
Returns the value of attribute production.
Class Method Summary collapse
-
.banks ⇒ Array<Hash{Symbol => String}>
(also: banklist)
All supported banks.
Instance Method Summary collapse
-
#initialize(partner_id, options = {:production => false}) ⇒ Ideal
constructor
Create a new Ideal object.
-
#request_transaction(options = {}) ⇒ Hash
Request a transaction.
-
#verify_transaction(options = {}) ⇒ Hash
Verify the status of a transaction.
Constructor Details
#initialize(partner_id, options = {:production => false}) ⇒ Ideal
Create a new Ideal object
41 42 43 44 |
# File 'lib/mollie/ideal.rb', line 41 def initialize(partner_id, ={:production => false}) @partner_id = partner_id @production = [:production] end |
Instance Attribute Details
#partner_id ⇒ Object (readonly)
Returns the value of attribute partner_id.
33 34 35 |
# File 'lib/mollie/ideal.rb', line 33 def partner_id @partner_id end |
#production ⇒ Object (readonly) Also known as: production?
Returns the value of attribute production.
33 34 35 |
# File 'lib/mollie/ideal.rb', line 33 def production @production end |
Class Method Details
.banks ⇒ Array<Hash{Symbol => String}> Also known as: banklist
All supported banks.
57 58 59 60 61 62 63 64 65 |
# File 'lib/mollie/ideal.rb', line 57 def self.banks resp = get('', :query => {:a => 'banklist'}) parsed_response = resp.parsed_response return error_response(resp) if resp.error? parsed_response["bank"].map do |b| {:id => b["bank_id"], :name => b["bank_name"]} end end |
Instance Method Details
#request_transaction(options = {}) ⇒ Hash
Request a transaction.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/mollie/ideal.rb', line 101 def request_transaction(={}) = () .merge!(:a => 'fetch', :partnerid => self.partner_id) .merge!(:testmode => 'true') unless self.production? resp = self.class.get('', :query => , :accept => 'text/xml') parsed_response = resp.parsed_response return error_response(resp) if resp.error? order = parsed_response["order"] %w(transaction_id amount currency url).map(&:to_sym).inject({}) do |res, k| v = order[k.to_s] || order[k.to_s.upcase] v = v.to_i if k == :amount res[k] = v res end end |
#verify_transaction(options = {}) ⇒ Hash
Note:
Once a transaction is payed, only the next time you verify the transaction will the value of ‘payed’ be ‘true’. Else it will be ‘false’.
Verify the status of a transaction.
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/mollie/ideal.rb', line 158 def verify_transaction(={}) = () .merge!(:a => 'check', :partnerid => self.partner_id) .merge!(:testmode => 'true') unless self.production? resp = self.class.get('', :query => ) parsed_response = resp.parsed_response return error_response(resp) if resp.error? order = parsed_response["order"] result = %w(transaction_id amount currency payed status message).map(&:to_sym).inject({}) do |res, k| v = order[k.to_s] || order[k.to_s.upcase] v = v.to_i if k == :amount v = (v == 'true') if k == :payed res[k] = v res end if consumer = order["consumer"] consumer = {'consumerName' => 'name', 'consumerAccount' => 'account', 'consumerCity' => 'city'}.inject({}) do |res, (theirs, ours)| res[ours.to_sym] = consumer[theirs] res end result[:consumer] = consumer end result end |