Callback Function Not running

33 views
Skip to first unread message

yingi keme

unread,
Nov 11, 2017, 6:52:37 AM11/11/17
to Django users
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.


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

    
    

Dylan Reinhold

unread,
Nov 11, 2017, 10:47:47 AM11/11/17
to django...@googlegroups.com
Do you have a url entry above that is also matching it?

--
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...@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.

yingi keme

unread,
Nov 11, 2017, 10:53:46 AM11/11/17
to django...@googlegroups.com
No i dont.

But i am thinking that since it is a GET http request, Then there shouldnt be a parameter in the url pattern. So maybe it should be

url(r'callback/' call_back) instead the previous one i did.

Although i havent tried it out yet.

Yingi Kem
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

James Schneider

unread,
Nov 12, 2017, 3:44:53 PM11/12/17
to django...@googlegroups.com

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.


And in my urls.py i have this pattern

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

Your regex is looking for a trailing slash. Try this URL or fix your regex:


-James
Reply all
Reply to author
Forward
0 new messages