Class: OffsitePayments::Integrations::Pxpay::Helper
- Includes:
- ActiveUtils::PostsData
- Defined in:
- lib/offsite_payments/integrations/pxpay.rb
Instance Attribute Summary collapse
-
#redirect_parameters ⇒ Object
readonly
Returns the value of attribute redirect_parameters.
-
#token_parameters ⇒ Object
readonly
Returns the value of attribute token_parameters.
Attributes inherited from Helper
Instance Method Summary collapse
- #credential_based_url ⇒ Object
- #form_fields ⇒ Object
- #form_method ⇒ Object
-
#initialize(order, account, options = {}) ⇒ Helper
constructor
A new instance of Helper.
Methods inherited from Helper
#add_field, #add_fields, #add_raw_html_field, #billing_address, inherited, mapping, #raw_html_fields, #shipping_address, #test?
Constructor Details
#initialize(order, account, options = {}) ⇒ Helper
Returns a new instance of Helper.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/offsite_payments/integrations/pxpay.rb', line 23 def initialize(order, account, = {}) @token_parameters = { 'PxPayUserId' => account, 'PxPayKey' => [:credential2], 'CurrencyInput' => [:currency], 'MerchantReference' => order, 'EmailAddress' => [:customer_email], 'TxnData1' => [:custom1], 'TxnData2' => [:custom2], 'TxnData3' => [:custom3], 'AmountInput' => "%.2f" % [:amount].to_f.round(2), 'EnableAddBillCard' => '0', 'TxnType' => 'Purchase', 'UrlSuccess' => [:return_url], 'UrlFail' => [:return_url] } @redirect_parameters = {} super raise ArgumentError, "error - must specify return_url" if token_parameters['UrlSuccess'].blank? raise ArgumentError, "error - must specify cancel_return_url" if token_parameters['UrlFail'].blank? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class OffsitePayments::Helper
Instance Attribute Details
#redirect_parameters ⇒ Object (readonly)
Returns the value of attribute redirect_parameters.
21 22 23 |
# File 'lib/offsite_payments/integrations/pxpay.rb', line 21 def redirect_parameters @redirect_parameters end |
#token_parameters ⇒ Object (readonly)
Returns the value of attribute token_parameters.
21 22 23 |
# File 'lib/offsite_payments/integrations/pxpay.rb', line 21 def token_parameters @token_parameters end |
Instance Method Details
#credential_based_url ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/offsite_payments/integrations/pxpay.rb', line 47 def credential_based_url raw_response = ssl_post(Pxpay.token_url, generate_request) result = parse_response(raw_response) raise ActionViewHelperError, "error - failed to get token - message was #{result[:redirect]}" unless result[:valid] == "1" url = URI.parse(result[:redirect]) if url.query @redirect_parameters = CGI.parse(url.query) url.query = nil end url.to_s rescue ActiveUtils::ConnectionError raise ActionViewHelperError, "A connection error occurred while contacting the payment gateway. Please try again." end |
#form_fields ⇒ Object
69 70 71 |
# File 'lib/offsite_payments/integrations/pxpay.rb', line 69 def form_fields redirect_parameters end |
#form_method ⇒ Object
65 66 67 |
# File 'lib/offsite_payments/integrations/pxpay.rb', line 65 def form_method "GET" end |