Class: OffsitePayments::Integrations::MollieIdeal::Helper
- Defined in:
- lib/offsite_payments/integrations/mollie_ideal.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.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 94 def initialize(order, account, = {}) @token = account @redirect_paramaters = { :amount => [:amount], :description => [:description], :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 description option needs to be set." if [:description].blank? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class OffsitePayments::Helper
Instance Attribute Details
#redirect_paramaters ⇒ Object (readonly)
Returns the value of attribute redirect_paramaters.
92 93 94 |
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 92 def redirect_paramaters @redirect_paramaters end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
92 93 94 |
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 92 def token @token end |
#transaction_id ⇒ Object (readonly)
Returns the value of attribute transaction_id.
92 93 94 |
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 92 def transaction_id @transaction_id end |
Instance Method Details
#credential_based_url ⇒ Object
114 115 116 117 118 119 120 121 122 |
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 114 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
124 125 126 |
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 124 def form_method "GET" end |
#request_redirect ⇒ Object
138 139 140 141 142 143 144 145 146 147 |
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 138 def request_redirect MollieIdeal.create_payment(token, redirect_paramaters) rescue ActiveMerchant::ResponseError => e if %w(401 403 422).include?(e.response.code) error = JSON.parse(e.response.body)['error']['message'] raise ActionViewHelperError, error else raise end end |
#set_form_fields_for_redirect(uri) ⇒ Object
128 129 130 131 132 133 134 135 136 |
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 128 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 |