Class: Buckaroo::Gateway
- Inherits:
-
Object
- Object
- Buckaroo::Gateway
- Defined in:
- lib/buckaroo/gateway.rb
Constant Summary collapse
- LANGUAGE =
'nl'
- CURRENCY =
'EUR'
Class Attribute Summary collapse
-
.environment ⇒ Object
Holds the environment in which the run (default is test).
-
.locale ⇒ Object
Holds the users locale.
-
.secret ⇒ Object
Holds the secret that should be used for the website key.
-
.website_key ⇒ Object
Holds the global iDEAL merchant id.
Class Method Summary collapse
-
.test? ⇒ Boolean
Returns whether we’re in test mode or not.
Instance Method Summary collapse
-
#capture(transaction_id) ⇒ Object
Sends a status request for the specified
transaction_id
and returns an StatusResponse. -
#request_url(operation) ⇒ Object
Returns the endpoint for the request.
-
#setup_purchase(money, options) ⇒ Object
TODO: Add comment here.
Class Attribute Details
.environment ⇒ Object
Holds the environment in which the run (default is test)
18 19 20 |
# File 'lib/buckaroo/gateway.rb', line 18 def environment @environment end |
.locale ⇒ Object
Holds the users locale
28 29 30 |
# File 'lib/buckaroo/gateway.rb', line 28 def locale @locale end |
.secret ⇒ Object
Holds the secret that should be used for the website key.
25 26 27 |
# File 'lib/buckaroo/gateway.rb', line 25 def secret @secret end |
.website_key ⇒ Object
Holds the global iDEAL merchant id. Make sure to use a string with leading zeroes if needed.
22 23 24 |
# File 'lib/buckaroo/gateway.rb', line 22 def website_key @website_key end |
Class Method Details
.test? ⇒ Boolean
Returns whether we’re in test mode or not.
35 36 37 38 39 40 |
# File 'lib/buckaroo/gateway.rb', line 35 def self.test? if self.environment.nil? self.environment = :test end self.environment == :test end |
Instance Method Details
#capture(transaction_id) ⇒ Object
Sends a status request for the specified transaction_id
and returns an StatusResponse.
It is your responsibility as the merchant to check if the payment has been made until you receive a response with a finished status like: ‘Success’, ‘Cancelled’, ‘Expired’, everything else equals ‘Open’.
Example
capture_response = gateway.capture(@purchase.transaction_id)
if capture_response.success?
@purchase.update_attributes!(:paid => true)
flash[:notice] = "Congratulations, you are now the proud owner of a Dutch windmill!"
end
See the Gateway class description for a more elaborate example.
80 81 82 83 84 85 |
# File 'lib/buckaroo/gateway.rb', line 80 def capture(transaction_id) config_complete! a = build_status_request(transaction_id) post_data request_url('transactionstatus'), a, StatusResponse end |
#request_url(operation) ⇒ Object
Returns the endpoint for the request.
Automatically uses test or live URLs based on the configuration.
45 46 47 48 49 50 51 52 53 |
# File 'lib/buckaroo/gateway.rb', line 45 def request_url(operation) if self.class.test? url = URLS[:test_url] else url = URLS[:live_url] end return url if operation.nil? url + '?op=' + operation end |
#setup_purchase(money, options) ⇒ Object
TODO: Add comment here
56 57 58 59 60 61 62 |
# File 'lib/buckaroo/gateway.rb', line 56 def setup_purchase(money, ) config_complete! requires!(, :order_id, :return_url, :description, :method) req = build_transaction_request(money, ) post_data request_url('transactionrequest'), req, TransactionResponse end |