Class: ChargeToken
- Inherits:
-
Object
- Object
- ChargeToken
- Defined in:
- lib/redpay/charge_token.rb
Instance Method Summary collapse
-
#initialize(app, key, endpoint) ⇒ ChargeToken
constructor
A new instance of ChargeToken.
- #Process(request) ⇒ Object
Constructor Details
#initialize(app, key, endpoint) ⇒ ChargeToken
Returns a new instance of ChargeToken.
8 9 10 11 12 |
# File 'lib/redpay/charge_token.rb', line 8 def initialize(app, key, endpoint) @app = app @key = key @endpoint = endpoint end |
Instance Method Details
#Process(request) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/redpay/charge_token.rb', line 14 def Process(request) json_request = JSON.parse(request.to_json, object_class: OpenStruct) # TODO Validate request here # Create a session with the server session = Session.new(@app, @key, @endpoint + "ecard") # Contruct charge token packet req = { "token" => json_request.token, "action" => "TA", "amount" => json_request.amount, "currency" => json_request.currency ||= "USD" } return session.Send(req) end |