import requests from urllib.parse import urlencode # This Python script uses the requests library, which is a common library for making HTTP requests in Python. # You might need to install it using pip install requests if you haven't done so already. # ProductID nID = "400300x400050x400010" # Example value. This would order 3 different products in a single order. Replace with actual logic to obtain this value from your data. # or if ordering just a single productID nID="400300" # Quantity nQuantity = "1x3x2" # Example value. This would order 1 of the first product, 3 of the second, and 2 of the third. nQuantity="1" would order one of each product in your nID # Database variables and fixed values sAPI_KEY = "YourTrepStarGeneratedAPI_KEY" #Get this from your TrepStar dashboard accounts area (generate the key there). sCustEmail = "customer.name@somewhere.com" sCustName = "John Doe" sCo = "Customer Company Name" sCustAddress = "123 street, suite#2" #All parts of the street address here including any apt# etc. sCustCity = "Apple Valley" sCustState = "MN" sCustZip = "55124" sCustCountry = "US" #2 letter country codes. sSpecialText = "Put customer specific instructions here." sInvoice = "123ABC" #Please generate one, perhaps your product SKU with the current hour minute and second attached like MYPROD_121423 nPrice = "12.95" bUsePriceOnCustomsForm = "0" sTypeShipping = "rtrackstandard" sMode = "test" #Change to prod to create actual production orders that will be fulfilled. All test orders will show up in recent orders and then you may delete those after testing. # Form the URL strURL = "https://www.trepstar.com/custdata.asp" params = { "productID": nID, "ordermethod": "url", "quantity": nQuantity, "API_KEY": sAPI_KEY, "source": "cdfulfill", "mode": sMode, "email": sCustEmail, "name": sCustName, "nprice": nPrice, "bUsePriceOnCustomsForm": bUsePriceOnCustomsForm, "co": sCo, "addr": sCustAddress, "city": sCustCity, "st": sCustState, "zip": sCustZip, "typeMailMethod": sTypeShipping, "country": sCustCountry, "specialtext": sSpecialText, "invoice": sInvoice } # Encode the parameters and append them to the URL encoded_params = urlencode(params) full_url = f"{strURL}?{encoded_params}" try: # Make the web request with SSL verification enabled by default response = requests.get(full_url) # Check if the response status code indicates success if response.status_code == 200: print("

The Network call worked. Do something with the response text.

") if "[SUCCESS]" in response.text: print("Success: The following was returned from the server:
") else: print("Failure: The following was returned from the server:
") print("
") print(response.text) else: print(f"Request failed with status code: {response.status_code}") except requests.RequestException as e: print(f"An error occurred: {e}")