forked from 0l4bone/payment-processor
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconnection.py
More file actions
77 lines (63 loc) · 1.92 KB
/
connection.py
File metadata and controls
77 lines (63 loc) · 1.92 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#REQUIRED IMPORTS
import os
import boto3
import sqlite3
import requests
import sys
import hashlib
#Other imports
from requests.api import head
from square.client import Client
from square.configuration import Configuration
from faker import Faker
from huepy import *
from time import sleep
from django.db import connection
from sqlite3 import Error
# This code is open and you can edit All you need
password = "osbkkjqemNQl1q"
hostname = "127.0.0.1"
client = Client(
access_token="hVBlQMN1XtphPosbkkjqemNQl1qbWsEP3xTHwTuT",
)
customerApi = client.customers
result = customerApi.list()
commands = []
def exec():
if result.success():
fake = Faker()
print(result.body)
#Store file each customer
password = hashlib.md5(str.encode(fake.password())).hexdigest()
commands[0] = "echo {}".format(result.body['customerName'])
commands[1] = ">> {}".format("customers.d4a")
commands[2] = " && "
commands[3] = "chmod 777 {}".format("customers.d4a")
command = commands[0]+commands[1]+commands[2]+commands[3]
exec(command)
return password
elif result.error():
print(result.errors)
def transformData():
#TODO
return True
def getCustomers(data):
internalToken = "EP3xTHwTuTjqemNQlosbkkjqemNQl1q1qbWshVBlQMN1XtphPosEP3x"
access={
"token": internalToken,
"user": "superadmin",
"role": "administrator"
}
headers = {
"Content-Type": "application/json"
}
customers = requests.post('https://' + hostname + '/api/scans', json=access, headers=headers,verify=False)
for customer in customers:
transformData(customer['name'], customer['card'])
def createNewCustomer(customer):
curs = connection.cursor()
name = customer['name']
card = customer['card']
id = customer['id']
curs.execute("insert into customers ('name','card','id') values ('%s','%s',%s)" %(name, card, id))
exec()