-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransactions.py
40 lines (34 loc) · 1 KB
/
transactions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import os
import hashlib
import requests
import pprint
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
# Parameters
acquirer_id = os.getenv('ACQUIRERID')
id_commerce = os.getenv('ID_COMMERCE')
purchase_operation = os.getenv('PURCHASE_OPERATION')
secret_key = os.getenv('SECRET_KEY_2')
# Compute verification
data = '{}{}{}{}'.format(acquirer_id,
id_commerce,
purchase_operation,
secret_key)
m = hashlib.sha512()
m.update(data.encode())
verification = m.hexdigest()
endpoint = 'https://integracion.alignetsac.com/VPOS2/rest/operationAcquirer/consulte'
headers = {
'Content-type': 'application/json'
}
data = {
'idAcquirer': acquirer_id,
'idCommerce': id_commerce,
'operationNumber': purchase_operation,
'purchaseVerification': verification
}
response = requests.post(endpoint, json=data, headers=headers)
json_response = response.json()
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(json_response)