Method: TAM::API.charge_by_code

Defined in:
lib/tam/api/charging.rb

.charge_by_code(user, code) ⇒ Hash

Requests for charging or payment to the subscriber account in the operator billing system byt charging code.

Returns:

  • (Hash)

    “message”=>“Request was handled succesfully”}



26
27
28
29
30
31
32
33
34
# File 'lib/tam/api/charging.rb', line 26

def self.charge_by_code(user, code)
  begin
    payload = JSON.generate({'method' => 'CODE', 'charging_code' => code.to_s})
    response = dispatch_to_tam(:post, '/api/1/charge/request', user, payload)
    JSON.parse response
  rescue TAM::ServiceUnavailable
    raise TAM::ServiceUnavailable.new 'The charging service is not available. If you are using the service on a persona, i.e.: through the sandbox, then remember to set the balance of that persona'
  end
end