Had to change Sandata's script to grab the groups first and then grab people - going with people first was taking way too long. Updated some notes, worked on Luminate's fiveserv integration.

This commit is contained in:
Norm Rasmussen
2024-05-09 17:07:47 -04:00
parent 4785ff6283
commit fa3ab13579
7 changed files with 215 additions and 17 deletions

View File

@ -3,4 +3,5 @@
{% styles custom %}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tiny-slider/2.9.4/tiny-slider.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/tiny-slider/2.9.2/min/tiny-slider.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tiny-slider/2.9.2/min/tiny-slider.js"></script>

View File

@ -4,7 +4,55 @@
<div class="np-homepage-featured-text">
<div class="np-homepage-headline">
{{ homepage.featured_courses_headline }}
</div>
</div>
<button type="button" value="Submit" onclick="myclick()" class="button" style="border:none; background:transparent;">
Purchase access to a course!
<div id='mylink'></div>
</button>
<div id="dvsnappay_hppform">
</div>
<input src="https://stage.snappayglobal.com/Interop/HostedPaymentPage" id="snappayhppform_response" type="hidden" name="snappayhppform_response" />
<script type="text/javascript">
function myclick() {
var mylink = document.getElementById('mylink');
mylink.onclick = function () {
var t = document.createElement("script");
t.setAttribute("id", "snappay_hppform");
t.setAttribute("src", "https://stage.snappayglobal.com/Areas/Interop/Scripts/HPPForm.js");
t.setAttribute("data-target", "#snappayhppform_response");
t.setAttribute("data-callback", "submit_external_ecommerce");
t.setAttribute("data-accountid", "1003003518");
t.setAttribute("data-merchantid", "496695144562");
t.setAttribute("data-customerid", "100");
t.setAttribute("data-transactionamount", "100");
t.setAttribute("data-currencycode", "USD");
t.setAttribute("data-firstname", "No one");
t.setAttribute("data-lastname", "Noooo One");
t.setAttribute("data-email", "Noone@none.com");
t.setAttribute("data-redirectionurl", "https://www.walmartluminate.com");
t.setAttribute("data-snappayurl", "https://stage.snappayglobal.com/Interop/HostedPaymentPage");
document.getElementsByTagName("head")[0].appendChild(t);
return false;
}
document.getElementById('mylink').click();
}
</script>
<script type="text/javascript">
function submit_external_ecommerce() {
var result = $("#snappayhppform_response").val();
sessionStorage.setItem("snappayhppresponse", result);
sessionStorage.setItem("caller", "js");
}
</script>
<div class="featured-carousel-controls np-hidden-mobile">
<div class="prev-arrow carousel-control"><i class="far fa-chevron-left"></i></div>
<div class="next-arrow carousel-control"><i class="far fa-chevron-right"></i></div>
@ -27,8 +75,8 @@
{% if is_featured %}
{% assign featured_courses_count = featured_courses_count | plus: 1 %}
<div class="featured-course-slide" data-position="{{course.properties.course_position}}">
<div class="featured-course-slide" data-position="{{course.properties.course_position}}">
{% include "cards_article" with course %}
</div>
{% endif %}
@ -87,7 +135,7 @@ window.addEventListener("load", (event) => {
indexesArray.forEach(e =>
document.querySelector(".featured-courses-slider").appendChild(e));
initFeaturedCoursesCarousel()
@ -119,7 +167,7 @@ function initFeaturedCoursesCarousel() {
});
}
</script>
@ -219,4 +267,4 @@ function initFeaturedCoursesCarousel() {
margin-top:12px;
}
}
</style>
</style>

View File

@ -0,0 +1,85 @@
<div id="dvsnappay_hppform">
<a src=""> Test </a>
</div>
<input id="snappayhppform_response" type="hidden" name="snappayhppform_response" />
<script id="snappay_hppform"
src='https://stage.snappayglobal.com/Areas/Interop/Scripts/HPPForm.js'
data-target="#snappayhppform_response"
data-callback="submit_external_ecommerce"
data-accountid='1003003518'
data-customerid='100'
data-currencycode='USD'
data-transactionamount='123.45'
data-merchantid='496695144562'
data-paymentmode='CC' // CC for credit card
data-cvvrequired='Y'
data-enableemailreceipt='Y'
data-redirectionurl='https://northpass.com'
data-snappayurl='https://stage.snappayglobal.com/Interop/HostedPaymentPage'
data-firstname='John'
data-lastname='Smith'
data-addressline1='850 Maple Ave'
data-city='Aurora'
data-state='IL'
data-zip='60504'
data-country='US'
data-email='john.smith@abcd.com'
data-phonenumber='6301234567'
data-signature='ccq3/65vra5FuhV++oFZxBdIvKn9W8PCsd@OIdDHIE='>
</script>
<!-- From Srinavas -->
<script type="text/javascript">
function myclick() {
var isCVV = "N";
var isEmail = "N";
var abcd = document.getElementsByClassName('cvvreq');
if (abcd[0].checked) {
isCVV = "Y";
}
var pqrs = document.getElementsByClassName('emailrecep');
if (pqrs[0].checked) {
isEmail = "Y";
}
var pm = document.getElementsByName('paymentmode');
var selectedPM = "CC";
for (i = 0; i < pm.length; i++) {
if (pm[i].checked)
selectedPM = pm[i].value;
}
var mylink = document.getElementById('mylink');
mylink.onclick = function () {
var t = document.createElement("script");
t.setAttribute("id", "snappay_hppform");
t.setAttribute("src", "https://stage.snappayglobal.com/Areas/Interop/Scripts/HPPForm.js");
t.setAttribute("data-target", "#snappayhppform_response");
t.setAttribute("data-callback", "submit_external_ecommerce");
t.setAttribute("data-accountid", document.getElementById("accountid").value);
t.setAttribute("data-customerid", document.getElementById("customerid").value);
t.setAttribute("data-merchantid", document.getElementById("merchantid").value);
t.setAttribute("data-transactionamount", document.getElementById("transactionamount").value);
t.setAttribute("data-currencycode", document.getElementById("currencycode").value);
t.setAttribute("data-paymentmode", selectedPM);
t.setAttribute("data-cvvrequired", isCVV);
t.setAttribute("data-emailreceipt", isEmail);
t.setAttribute("data-udf0", document.getElementById("udf0").value);
t.setAttribute("data-udf1", document.getElementById("udf1").value);
t.setAttribute("data-udf2", document.getElementById("udf2").value);
t.setAttribute("data-udf3", document.getElementById("udf3").value);
t.setAttribute("data-udf4", document.getElementById("udf4").value);
t.setAttribute("data-udf5", document.getElementById("udf5").value);
t.setAttribute("data-udf6", document.getElementById("udf6").value);
t.setAttribute("data-udf7", document.getElementById("udf7").value);
t.setAttribute("data-udf8", document.getElementById("udf8").value);
t.setAttribute("data-udf9", document.getElementById("udf9").value);
t.setAttribute("data-redirectionurl", "https://www.google.com");
t.setAttribute("data-snappayurl", "https://stage.snappayglobal.com/Interop/HostedPaymentPage");
document.getElementsByTagName("head")[0].appendChild(t);
return false;
}
document.getElementById('mylink').click();
}
</script>

View File

@ -11,6 +11,51 @@ APIKEY = Apikeys.SANDATA
HEADERS = {"accept": "application/json", "X-Api-Key": APIKEY}
PERSON_GROUPS = []
PPL_DELETIONS = []
GROUPS_LIST = []
def get_groups():
count = 1
while True:
url = f"{BASEURL}/groups?limit=100&page={count}"
resp = requests.get(url, headers=HEADERS)
json = resp.json()
nextlink = json["links"]
count += 1
for data in json["data"]:
group_name = data["attributes"]["name"]
members = data["attributes"]["memberships_count"]
id = data["id"]
if "ST - OH" in group_name or "ST - CA" in group_name:
pass
else:
if members > 0:
grouple = (id, group_name, members)
print(grouple)
GROUPS_LIST.append(grouple)
if "next" not in nextlink:
break
get_ppl_from_groups(GROUPS_LIST)
def get_ppl_from_groups(GROUPS_LIST):
for single_group in GROUPS_LIST:
print(single_group)
group_count = 1
while True:
group_url = f"{BASEURL}/groups/{single_group[0]}/memberships?limit=100&page={group_count}"
group_resp = requests.get(group_url, headers=HEADERS)
groupson = group_resp.json()
group_count += 1
nextlink = groupson["links"]
for data in groupson["data"]:
id = data["relationships"]["person"]["data"]["id"]
print(id)
if "next" not in nextlink:
break
def get_people():
@ -35,15 +80,30 @@ def get_people():
uuid = group["id"]
group_url = f"https://api.northpass.com/v2/groups/{uuid}"
response = requests.get(group_url, headers=HEADERS)
group_resp = response.json()
try:
group_resp = response.json()
group_name = group_resp["data"]["attributes"]["name"]
# print(email, group_name)
if "- OH" not in group_name or "- CA" not in group_name:
PPL_DELETIONS.append(id)
print(email, group_name)
group_name = group_resp["data"]["attributes"]["name"]
# print(email, group_name)
if "ST - OH" in group_name or "ST - CA" in group_name:
pass
else:
PPL_DELETIONS.append(id)
print(email, group_name)
PERSON_GROUPS.append((id, email, group_name))
PERSON_GROUPS.append((id, email, group_name))
except JSONDecodeError as e:
print(f"There was a JSON Error --> {e}")
dataerror = df.from_records(PERSON_GROUPS)
dataerror.to_csv('~/Downloads/Sandata-err-all-ppl')
print(dataerror)
print(len(PERSON_GROUPS))
datadelerr = df.from_records(PPL_DELETIONS)
datadelerr.to_csv('~/Downloads/Sandata-err-ppl-to-delete')
pass
finally:
pass
else:
PERSON_GROUPS.append((id, email, "No Group"))
@ -52,9 +112,13 @@ def get_people():
break
dataframe = df.from_records(PERSON_GROUPS)
dataframe.to_csv('~/Downloads/Sandata-all-ppl')
print(dataframe)
print(len(PERSON_GROUPS))
datadel = df.from_records(PPL_DELETIONS)
datadel.to_csv('~/Downloads/Sandata-ppl-to-delete')
# def parse_groups(id, grouplist):
# for uuid in grouplist:
@ -66,4 +130,4 @@ payload = { "payload": ["asd", "asd", "asd"] }
"""
if __name__ == "__main__":
get_people()
get_groups()

View File

@ -8,7 +8,7 @@ const apiKey = "6hUfJdAartHTHhHc0WIRZYPWe"
// Luminate Production ^
const uid = "/\?uid\=7beg87y4-fh24-4929-3rt5-24kdn87s5241";
const groupIds = [
'fbadcf2b-db4a-4342-b1a7-15fc357e6443',
'bcab9f82-4bac-4903-a054-aabae5f0a347'
]
const getAllGroups = async (num) => {

View File

@ -289,4 +289,4 @@ message](https://northpasshq.slack.com/archives/C04RER4PH09/p1709147957374999?th
## 05-06-2024
- [ ] Swift - Update Header Template with Transcript and send to Kayla.
- [X] Swift - Update Header Template with Transcript and send to Kayla.