Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. # URL + URI
  2. requestUrl = "https://int-ecommerce.nexi.it/" + "ecomm/api/bo/situazioneOrdine";
  3.  
  4. # Parametri per calcolo MAC
  5. apiKey = "<ALIAS>" # Alias fornito da Nexi
  6. chiaveSegreta = "<CHIAVE SEGRETA PER CALCOLO MAC>" # Chiave segreta fornita da Nexi
  7. codTrans = "4bnrgtj34b" # Codice della transazione di cui si cercano i dettagli
  8. timeStamp = (int(time.time())) * 1000
  9.  
  10. # Calcolo MAC
  11. mac_str = 'apiKey=' + apiKey + \
  12.     'codiceTransazione=' + codTrans + \
  13.     "timeStamp=" + str(timeStamp) + \
  14.      chiaveSegreta
  15. mac =  hashlib.sha1(mac_str.encode('utf8')).hexdigest()
  16.  
  17. # Parametri di invio
  18. requestParams = {
  19.     'apiKey': apiKey,
  20.     'codiceTransazione': codTrans,
  21.     'timeStamp': str(timeStamp),
  22.     'mac': mac
  23. }
  24.  
  25. # Chiamata API
  26. response  = requests.post(requestUrl,json=requestParams,headers={'Content-Type':'application/json'})
  27.  
  28. # Parametri di ritorno
  29. response_data = response.json()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement