module Polirb::Transactions
Public Instance Methods
get_transaction(transaction_token)
click to toggle source
# File lib/polirb/client/transactions.rb, line 27 def get_transaction(transaction_token) get_transaction_response(request(:get, Polirb::Static::GET_TRANSACTION, { "token" => transaction_token } )) end
initiate_transaction(amount, merchant_reference, merchant_data)
click to toggle source
# File lib/polirb/client/transactions.rb, line 6 def initiate_transaction(amount, merchant_reference, merchant_data) defaults = { "CurrencyCode" => "AUD", "MerchantHomepageURL" => self.merchant_homepage_url, "SuccessURL" => self.success_url, "FailureURL" => self.failure_url, "CancellationURL" => self.cancellation_url, "NotificationURL" => self.notification_url, "Timeout" => self.timeout, } supplied = { "Amount" => amount, "MerchantReference" => merchant_reference, "MerchantData" => merchant_data, } defaults.merge!(supplied) initiate_transaction_response(request(:post, Polirb::Static::INITIATE_TRANSACTION, defaults)) end
Private Instance Methods
get_transaction_response(response)
click to toggle source
# File lib/polirb/client/transactions.rb, line 49 def get_transaction_response(response) if response { :success => true, :currency_code => response["CurrencyCode"], :payment_amount => response["PaymentAmount"], :amount_paid => response["AmountPaid"], :end_date_time => response["EndDateTime"], :transaction_status_code => response["TransactionStatusCode"], :error_code => response["ErrorCode"], :merchant_reference => response["MerchantReference"], :merchant_data => response["MerchantData"], } else { :success => false, } end end
initiate_transaction_response(response)
click to toggle source
# File lib/polirb/client/transactions.rb, line 33 def initiate_transaction_response(response) if response["Success"] == true { :success => true, :transaction_ref_no => response["TransactionRefNo"], :navigate_url => response["NavigateURL"], } else { :success => false, :error_code => "", :error_message => "", } end end