Class: Stall::Payments::ManualPaymentGateway::Response
Instance Attribute Summary
#request
Instance Method Summary
collapse
#calculate_checksum_for
#initialize, #process
Instance Method Details
#cart ⇒ Object
76
77
78
|
# File 'lib/stall/payments/manual_payment_gateway.rb', line 76
def cart
@cart ||= ProductList.find_by_token(request.params[:cart][:token])
end
|
#cart_params ⇒ Object
80
81
82
|
# File 'lib/stall/payments/manual_payment_gateway.rb', line 80
def cart_params
@cart_params ||= request.params[:cart]
end
|
#rendering_options ⇒ Object
#success? ⇒ Boolean
55
56
57
|
# File 'lib/stall/payments/manual_payment_gateway.rb', line 55
def success?
true
end
|
#valid? ⇒ Boolean
To allow manual payment method we verify that the provided checksum corresponds to the one we can calculate with the provided params in the form.
This avoids forging a request with ‘manual_payment` in the URL for a cart which was not set to use this method, thus allowing people to validate orders without paying them.
67
68
69
70
71
72
73
74
|
# File 'lib/stall/payments/manual_payment_gateway.rb', line 67
def valid?
calculated_checksum = calculate_checksum_for(
cart_params[:token], cart_params[:reference], cart_params[:timestamp]
)
provided_checksum = cart_params[:checksum]
calculated_checksum == provided_checksum
end
|