Class: Vpago::PaywayReturnOptionsBuilder
- Inherits:
-
Object
- Object
- Vpago::PaywayReturnOptionsBuilder
- Defined in:
- app/services/vpago/payway_return_options_builder.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #html_params ⇒ Object
-
#initialize(params:) ⇒ PaywayReturnOptionsBuilder
constructor
A new instance of PaywayReturnOptionsBuilder.
- #json_params ⇒ Object
- #merchant_profile_content_type ⇒ Object
- #options ⇒ Object
- #payment ⇒ Object
- #tran_id ⇒ Object
Constructor Details
#initialize(params:) ⇒ PaywayReturnOptionsBuilder
Returns a new instance of PaywayReturnOptionsBuilder.
6 7 8 |
# File 'app/services/vpago/payway_return_options_builder.rb', line 6 def initialize(params:) @params = params end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
4 5 6 |
# File 'app/services/vpago/payway_return_options_builder.rb', line 4 def params @params end |
Instance Method Details
#html_params ⇒ Object
30 31 32 33 |
# File 'app/services/vpago/payway_return_options_builder.rb', line 30 def html_params payload = JSON.parse(params[:response]) { tran_id: payload['tran_id'] } end |
#json_params ⇒ Object
26 27 28 |
# File 'app/services/vpago/payway_return_options_builder.rb', line 26 def json_params { tran_id: params[:tran_id] } end |
#merchant_profile_content_type ⇒ Object
35 36 37 |
# File 'app/services/vpago/payway_return_options_builder.rb', line 35 def merchant_profile_content_type ENV['PAYWAY_MERCHANT_PROFILE_CONTENT_TYPE'].presence || 'html' end |
#options ⇒ Object
10 11 12 13 14 15 16 |
# File 'app/services/vpago/payway_return_options_builder.rb', line 10 def if merchant_profile_content_type == 'html' html_params elsif merchant_profile_content_type == 'json' json_params end end |
#payment ⇒ Object
18 19 20 |
# File 'app/services/vpago/payway_return_options_builder.rb', line 18 def payment @payment ||= Spree::Payment.find_by(number: tran_id) end |
#tran_id ⇒ Object
22 23 24 |
# File 'app/services/vpago/payway_return_options_builder.rb', line 22 def tran_id @tran_id ||= [:tran_id] end |