This is a working xbasic function to add a customer to a square account. Obviously, you'll need a developer account authorization token for your own account but it works great. Took me awhile to figure out but now that I have I can see how easy it is, lol.
This just adds a firstname and a lastname but I think it's simple enough to see what you need to do to make this function better and more complete. Basically I made a list control with a couple fields in the detail view, added a button to run the xbasic...and add a customer to my sandbox account.
you can see more options here: https://developer.squareup.com/explo...er?env=sandbox
This just adds a firstname and a lastname but I think it's simple enough to see what you need to do to make this function better and more complete. Basically I made a list control with a couple fields in the detail view, added a button to run the xbasic...and add a customer to my sandbox account.
Code:
function squareaddcus as c (e as p) dim squareaddcus as c debug(1) dim cf_1 as extension::CurlFile dim flag_1 as l dim slist1[0] as c = [ "Square-Version: 2022-08-23" , "Authorization: Bearer EAAAEJjaDdMBsdfgsdEz4A6Okt6h7EKnErpmaQ0Fbmslc4hdpTleC8kmJkjzEfjYgZIw" , "Content-Type: application/json" ] dim ce as extension::Curl dim f as p f.given_name = e._currentRowDataNew.Firstname f.family_name = e._currentRowDataNew.Lastname ce = extension::Curl.Init() ce.setOpt("BUFFERSIZE",102400) ce.setOpt("URL","https://connect.squareupsandbox.com/v2/customers%22) dim js as c js = json_generate(f) posted_fields = js ce.setOpt("POSTFIELDS",posted_fields) ce.setOpt("POSTFIELDSIZE_LARGE", len(posted_fields) ) ce.setOpt("HTTPHEADER",slist1) ce.setOpt("USERAGENT","curl/7.81.0") ce.setOpt("MAXREDIRS",50) ce.setOpt("CAINFO",a5.Get_Exe_Path()+"\caroot\ca-cert.pem") ce.setOpt("CAPATH",a5.Get_Exe_Path()+"\caroot") ce.setOpt("PROXY_CAPATH", a5.get_exe_path() + "\caroot") ce.setOpt("CUSTOMREQUEST","POST") ce.setOpt("FTP_SKIP_PASV_IP",1) ce.setOpt("TCP_KEEPALIVE",1) ce.SetOpt("FILE",cf_1) flag_1 = ce.Exec() if flag_1 then dim headers as c dim contents as c headers = cf_1.GetHeaders() contents = cf_1.GetContent() 'BE SURE TO COMMENT OUT THIS CODE IN A WEB APPLICATION AS showVar() CANNOT BE USED IN WEB APPLICATIONS dim msg as c msg = "Headers: " + crlf() + headers + crlf() + "Content: " + contents 'showvar( msg) else dim errors as c errors = ce.error() 'BE SURE TO COMMENT OUT THIS CODE IN A WEB APPLICATION AS showVar() CANNOT BE USED IN WEB APPLICATIONS 'showvar("error: " + errors) end if ce.close() end function
you can see more options here: https://developer.squareup.com/explo...er?env=sandbox
Comment