

@csrf_exempt_m
@require_POST_m
def fps_ipn_handler(self, request):
    uri = request.build_absolute_uri()
    parsed_url = urlparse.urlparse(uri)
    resp = self.fps_connection.verify_signature(UrlEndPoint=('%s://%s%s' % (parsed_url.scheme, parsed_url.netloc, parsed_url.path)), HttpParameters=request.body)
    if (not (resp.VerifySignatureResult.VerificationStatus == 'Success')):
        return HttpResponseForbidden()
    data = dict(map((lambda x: x.split('=')), request.body.split('&')))
    for (key, val) in data.items():
        data[key] = urllib.unquote_plus(val)
    if AmazonFPSResponse.objects.filter(transactionId=data['transactionId']).count():
        resp = AmazonFPSResponse.objects.get(transactionId=data['transactionId'])
    else:
        resp = AmazonFPSResponse()
    for (key, val) in data.items():
        attr_exists = hasattr(resp, key)
        if (attr_exists and (not callable(getattr(resp, key, None)))):
            if (key == 'transactionDate'):
                val = datetime.datetime(*time.localtime(float(val))[:6])
            setattr(resp, key, val)
    resp.save()
    if (resp.statusCode == 'Success'):
        transaction_was_successful.send(sender=self.__class__, type=data['operation'], response=resp)
    elif (not ('Pending' in resp.statusCode)):
        transaction_was_unsuccessful.send(sender=self.__class__, type=data['operation'], response=resp)
    return HttpResponse(resp.statusCode)

dataset/ETHPy150Open agiliq/merchant/billing/integrations/amazon_fps_integration.py AmazonFpsIntegration.fps_ipn_handler/original