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
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
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) )
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))