Method: TAM::API.charge_by_amount

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

.charge_by_amount(user, amount) ⇒ Hash

Requests for charging or payment to the subscriber account in the operator billing system by amount.

Returns:

  • (Hash)

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



12
13
14
15
16
17
18
19
20
# File 'lib/tam/api/charging.rb', line 12

def self.charge_by_amount(user, amount)
  begin
    payload = JSON.generate({'method' => 'AMOUNT', 'amount' => amount.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