Saturday, November 11, 2017

Callback Function Not running

I have a callback function(webhook) implemented below

def call_back(request, param):
    # Testnet
    method='GET'
    x_signature = request.headers.get('X-Signature')
    print(siri)
        
    request_uri_encoded = str(request).splitlines()[0].split()[1]
    request_uri = urllib.parse.unquote(request_uri_encoded)
        
    constant_digest = hashlib.sha512('').digest() # [207, 131, 225, 53, 126,.........., 249, 39, 218, 62]
        
    requestt = method+request_uri+constant_digest
    raw_signature = hmac.new(secret, requestt, hashlib.sha512)
    b64_signature = base64.b64encode(raw_signature.digest())
        
    print('request_uri_encoded: ', request_uri_encoded)
    print('request_uri: ', request_uri) 
    print('x_signature: ', x_signature) 
    print('b64_signature: ', b64_signature) 
        
    if (x_signature == b64_signature):  # IT PRINTS ERROR
        print('SUCCESS')
    else:
        print('ERROR') 


But this callback function dont get to run. The API is to issue a  GET http request to the url specified as my callback url.

The url specified is 'https://Jshhhtoo.localtunnel.me/callback/blue-cap'

And in my urls.py i have this pattern

url(r'^callback/(?P<param>[-\w]+)/$', call_back, name='callback'),

But i dont seem to get why the callback function refuses to run even though from my command line i see that the webservice
keeps issuing a GET callback request. Here is what the GET request shows in my command

[11/Nov/2017 03:23:17] "GET /callback/blue-cap?order_id=204199&amount=4570384&amount_in_btc=
0.04570384&amount_paid_in_btc=0.04570384&status=2&address=muAYN5HZBN4VfvmVhZhTnm7yBN33JQ3JGD&tid=9a5327bb9efa3b2be285c8a47222d6c89a95fd2d3e10c7c4707974c0c52e7e57&
transaction_ids=[%229a5327bb9efa3b2be285c8a47222d6c89a95fd2d3e10c7c4707974c0c52e7e57%22]&keychain_id=2&last_keychain_id=1&after_payment_redirect_to=
https%3A%2F%2Fbitcoinkem.localtunnel.me%2Fsucessful&auto_redirect=true HTTP/1.1" 301 0


Any help please !!!!

    
    

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7ad40d95-3e21-432d-939a-8e4f947aba92%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment