Ejemplo n.º 1
0
def dump_resource(output, title, resource):
    """Dump resource to output file

    """
    print >>output, '#' * 10, title
    print >>output
    print >>output, dumps_pretty_json(resource.json_data)
    print >>output
Ejemplo n.º 2
0
def dump_resource(output, title, resource):
    """Dump resource to output file

    """
    print >> output, '#' * 10, title
    print >> output
    print >> output, dumps_pretty_json(resource.json_data)
    print >> output
Ejemplo n.º 3
0
 def callback(self, company, payload):
     self.logger.info(
         'Handling callback company=%s, event_id=%s, event_type=%s',
         company.guid, payload['id'], payload['type'],
     )
     self.logger.debug('Payload: \n%s', dumps_pretty_json(payload))
     # Notice: get the event from Balanced API service to ensure the event
     # in callback payload is real. If we don't do this here, it is
     # possible attacker who knows callback_key of this company can forge
     # a callback and make any invoice settled
     try:
         uri = '/v1/events/{}'.format(payload['id'])
         event = self.event_cls.fetch(uri)
     except balanced.exc.BalancedError, e:
         raise InvalidCallbackPayload(
             'Invalid callback payload '
             'BalancedError: {}'.format(e)
         )
Ejemplo n.º 4
0
 def callback(self, company, payload):
     self.logger.info(
         'Handling callback company=%s, event_id=%s, event_type=%s',
         company.guid,
         payload['id'],
         payload['type'],
     )
     self.logger.debug('Payload: \n%s', dumps_pretty_json(payload))
     # Notice: get the event from Balanced API service to ensure the event
     # in callback payload is real. If we don't do this here, it is
     # possible attacker who knows callback_key of this company can forge
     # a callback and make any invoice settled
     try:
         uri = '/v1/events/{}'.format(payload['id'])
         event = self.event_cls.fetch(uri)
     except balanced.exc.BalancedError, e:
         raise InvalidCallbackPayload('Invalid callback payload '
                                      'BalancedError: {}'.format(e))