Class: Buckaroo::Ideal::Request
- Inherits:
-
Object
- Object
- Buckaroo::Ideal::Request
- Includes:
- Util
- Defined in:
- lib/buckaroo-ideal/request.rb
Overview
A class to help with the generation of payment forms for the Buckaroo Payment Gateway.
A form has a number of required parameters that are retreived from the Buckaroo::Idea::Order
:
-
currency
– required; but set by default to ‘EUR’ -
invoice_number
– required; not set by default -
amount
– required; this is the whole amount, it is automatically converted to cents -
bank
– optional -
description
– optional
It is possible to set the following options for this form:
-
language
– required, defaults to ‘NL’ -
return_method
– required, defaults toBuckaroo::Ideal::Config.return_method
-
style
– required, defaults toBuckaroo::Ideal::Config.style
-
autoclose_popup
– required, defaults toBuckaroo::Ideal::Config.autoclose_popup
-
reference
– optional -
success_url
– optional according to documentation -
reject_url
– optional -
error_url
– optional
The test_mode
, gateway_url
and merchant_key
are read from Buckaroo::Ideal::Config
.
To access the information required to create a form, instantiate a new Buckaroo::Ideal::Request
with an Buckaroo::Ideal::Order
instance:
order = Buckaroo::Ideal::Order.new(amount: 100, invoice_number: 'EETNU-123')
request = Buckaroo::Ideal::Request.new(order)
You can then use the information to create a form. An example in Rails:
<%= form_tag request.gateway_url do %>
<% request.parameters.each do |name, value| %>
<%= hidden_field_tag name, value %>
<% end %>
<%= submit_tag 'Proceed to payment' %>
<% end %>
Constant Summary
Constants included from Util
Instance Attribute Summary collapse
-
#autoclose_popup ⇒ Boolean
Defaults to the configured
Buckaroo::Ideal::Config.autoclose_popup
, but can be overwritten in theOrder
instance. -
#error_url ⇒ String
Defaults to the configured
Buckaroo::Ideal::Config.error_url
, but can be overwritten in theOrder
instance. -
#language ⇒ String
The language in wich Buckaroo’s user interface is presented.
-
#order ⇒ Buckaroo::Ideal::Order
readonly
The order for which the payment request is being made.
-
#reject_url ⇒ String
Defaults to the configured
Buckaroo::Ideal::Config.reject_url
, but can be overwritten in theOrder
instance. -
#return_method ⇒ String
Defaults to the configured
Buckaroo::Ideal::Config.return_method
, but can be overwritten in theOrder
instance. -
#style ⇒ String
Defaults to the configured
Buckaroo::Ideal::Config.style
, but can be overwritten in theOrder
instance. -
#success_url ⇒ String
Defaults to the configured
Buckaroo::Ideal::Config.success_url
, but can be overwritten in theOrder
instance.
Class Method Summary collapse
Instance Method Summary collapse
-
#gateway_url ⇒ String
The configured gateway_url in
Buckaroo::Ideal::Config
. -
#initialize(order, settings = {}) ⇒ Buckaroo::Ideal::Request
constructor
Initialize a new
Buckaroo::Ideal::Request
instance for the given order. -
#merchant_key ⇒ String
The configured merchant_key in
Buckaroo::Ideal::Config
. - #parameters ⇒ Object
-
#test_mode ⇒ Boolean
The configured test_mode in
Buckaroo::Ideal::Config
.
Methods included from Util
#compact, #from_cents, #from_numeric_boolean, #to_cents, #to_normalized_string, #to_numeric_boolean
Constructor Details
#initialize(order, settings = {}) ⇒ Buckaroo::Ideal::Request
Initialize a new Buckaroo::Ideal::Request
instance for the given order.
121 122 123 124 125 126 127 |
# File 'lib/buckaroo-ideal/request.rb', line 121 def initialize(order, settings = {}) @order = order settings = self.class.defaults.merge(settings) settings.each do |key, value| set key, value end end |
Instance Attribute Details
#autoclose_popup ⇒ Boolean
Defaults to the configured Buckaroo::Ideal::Config.autoclose_popup
, but can be overwritten in the Order
instance.
113 114 115 |
# File 'lib/buckaroo-ideal/request.rb', line 113 def autoclose_popup @autoclose_popup end |
#error_url ⇒ String
Defaults to the configured Buckaroo::Ideal::Config.error_url
, but can be overwritten in the Order
instance.
94 95 96 |
# File 'lib/buckaroo-ideal/request.rb', line 94 def error_url @error_url end |
#language ⇒ String
Returns The language in wich Buckaroo’s user interface is presented.
73 74 75 |
# File 'lib/buckaroo-ideal/request.rb', line 73 def language @language end |
#order ⇒ Buckaroo::Ideal::Order (readonly)
Returns The order for which the payment request is being made.
69 70 71 |
# File 'lib/buckaroo-ideal/request.rb', line 69 def order @order end |
#reject_url ⇒ String
Defaults to the configured Buckaroo::Ideal::Config.reject_url
, but can be overwritten in the Order
instance.
87 88 89 |
# File 'lib/buckaroo-ideal/request.rb', line 87 def reject_url @reject_url end |
#return_method ⇒ String
Defaults to the configured Buckaroo::Ideal::Config.return_method
, but can be overwritten in the Order
instance.
101 102 103 |
# File 'lib/buckaroo-ideal/request.rb', line 101 def return_method @return_method end |
#style ⇒ String
Defaults to the configured Buckaroo::Ideal::Config.style
, but can be overwritten in the Order
instance.
107 108 109 |
# File 'lib/buckaroo-ideal/request.rb', line 107 def style @style end |
#success_url ⇒ String
Defaults to the configured Buckaroo::Ideal::Config.success_url
, but can be overwritten in the Order
instance.
80 81 82 |
# File 'lib/buckaroo-ideal/request.rb', line 80 def success_url @success_url end |
Class Method Details
.defaults ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/buckaroo-ideal/request.rb', line 46 def self.defaults { :language => 'NL', :success_url => Config.success_url, :reject_url => Config.reject_url, :error_url => Config.error_url, :return_method => Config.return_method, :style => Config.style, :autoclose_popup => Config.autoclose_popup } end |
Instance Method Details
#gateway_url ⇒ String
Returns The configured gateway_url in Buckaroo::Ideal::Config
.
59 |
# File 'lib/buckaroo-ideal/request.rb', line 59 delegate :gateway_url, :to => Config |
#merchant_key ⇒ String
Returns The configured merchant_key in Buckaroo::Ideal::Config
.
65 |
# File 'lib/buckaroo-ideal/request.rb', line 65 delegate :merchant_key, :to => Config |
#parameters ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/buckaroo-ideal/request.rb', line 129 def parameters { 'BPE_Currency' => order.currency, 'BPE_Invoice' => order.invoice_number, 'BPE_Amount' => to_cents(order.amount), 'BPE_Merchant' => merchant_key, 'BPE_Language' => language, 'BPE_Mode' => to_numeric_boolean(test_mode), 'BPE_Return_Method' => return_method, 'BPE_Style' => style, 'BPE_Autoclose_Popup' => to_numeric_boolean(autoclose_popup), 'BPE_Signature2' => signature }.merge compact({ 'BPE_Issuer' => order.bank, 'BPE_Description' => order.description, 'BPE_Reference' => order.reference, 'BPE_Return_Success' => success_url, 'BPE_Return_Reject' => reject_url, 'BPE_Return_Error' => error_url }) end |
#test_mode ⇒ Boolean
Returns The configured test_mode in Buckaroo::Ideal::Config
.
62 |
# File 'lib/buckaroo-ideal/request.rb', line 62 delegate :test_mode, :to => Config |