Class: ActiveMerchant::Billing::Integrations::MollieIdeal::Helper
- Defined in:
- lib/active_merchant/billing/integrations/mollie_ideal/helper.rb
Instance Attribute Summary collapse
-
#redirect_paramaters ⇒ Object
readonly
Returns the value of attribute redirect_paramaters.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#transaction_id ⇒ Object
readonly
Returns the value of attribute transaction_id.
Attributes inherited from Helper
Instance Method Summary collapse
- #credential_based_url ⇒ Object
- #form_method ⇒ Object
-
#initialize(order, account, options = {}) ⇒ Helper
constructor
A new instance of Helper.
- #request_redirect ⇒ Object
- #set_form_fields_for_redirect(uri) ⇒ Object
Methods inherited from Helper
#add_field, #add_fields, #add_raw_html_field, #billing_address, #form_fields, inherited, mapping, #raw_html_fields, #shipping_address, #test?
Constructor Details
#initialize(order, account, options = {}) ⇒ Helper
Returns a new instance of Helper.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/active_merchant/billing/integrations/mollie_ideal/helper.rb', line 9 def initialize(order, account, = {}) @token = account @redirect_paramaters = { :amount => [:amount], :description => [:account_name], :issuer => [:redirect_param], :redirectUrl => [:return_url], :method => 'ideal', :metadata => { :order => order } } @redirect_paramaters[:webhookUrl] = [:notify_url] if [:notify_url] super raise ArgumentError, "The redirect_param option needs to be set to the bank_id the customer selected." if [:redirect_param].blank? raise ArgumentError, "The return_url option needs to be set." if [:return_url].blank? raise ArgumentError, "The account_name option needs to be set." if [:account_name].blank? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ActiveMerchant::Billing::Integrations::Helper
Instance Attribute Details
#redirect_paramaters ⇒ Object (readonly)
Returns the value of attribute redirect_paramaters.
7 8 9 |
# File 'lib/active_merchant/billing/integrations/mollie_ideal/helper.rb', line 7 def redirect_paramaters @redirect_paramaters end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
7 8 9 |
# File 'lib/active_merchant/billing/integrations/mollie_ideal/helper.rb', line 7 def token @token end |
#transaction_id ⇒ Object (readonly)
Returns the value of attribute transaction_id.
7 8 9 |
# File 'lib/active_merchant/billing/integrations/mollie_ideal/helper.rb', line 7 def transaction_id @transaction_id end |
Instance Method Details
#credential_based_url ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/active_merchant/billing/integrations/mollie_ideal/helper.rb', line 29 def credential_based_url response = request_redirect @transaction_id = response['id'] uri = URI.parse(response['links']['paymentUrl']) set_form_fields_for_redirect(uri) uri.query = '' uri.to_s.sub(/\?\z/, '') end |
#form_method ⇒ Object
39 40 41 |
# File 'lib/active_merchant/billing/integrations/mollie_ideal/helper.rb', line 39 def form_method "GET" end |
#request_redirect ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/active_merchant/billing/integrations/mollie_ideal/helper.rb', line 53 def request_redirect MollieIdeal.create_payment(token, redirect_paramaters) rescue ResponseError => e if e.response.code == '422' error = JSON.parse(e.response.body)['error']['message'] raise RedirectError, error else raise end end |
#set_form_fields_for_redirect(uri) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/active_merchant/billing/integrations/mollie_ideal/helper.rb', line 43 def set_form_fields_for_redirect(uri) CGI.parse(uri.query).each do |key, value| if value.is_a?(Array) && value.length == 1 add_field(key, value.first) else add_field(key, value) end end end |