Square POS API adding Unique ID, is it possible? - javascript

I am working with Square POS API and have successfully sent a request to the android app via a mobile web app. The app opens, displays the correct price, accepts payment and returns to the callback URL.
I have read over the documentation a few times and may be missing it but is there a way I can add a Unique ID that is sent to the app and returned to the callback page so I can update the correct line item in the database?
possibly something like:
"l.com.squareup.pos.UNIQUE_ID=" + unique_id + ";" +
var posUrl =
"intent:#Intent;" +
"action=com.squareup.pos.action.CHARGE;" +
"package=com.squareup;" +
"S.com.squareup.pos.WEB_CALLBACK_URI=" + callbackUrl + ";" +
"S.com.squareup.pos.CLIENT_ID=" + applicationId + ";" +
"S.com.squareup.pos.API_VERSION=" + sdkVersion + ";" +
"i.com.squareup.pos.TOTAL_AMOUNT=" + transactionTotal + ";" +
"S.com.squareup.pos.CURRENCY_CODE=" + currencyCode + ";" +
"S.com.squareup.pos.TENDER_TYPES=" + tenderTypes + ";" +
"l.com.squareup.pos.AUTO_RETURN_TIMEOUT_MS=" + callbacktime + ";" +
"l.com.squareup.pos.UNIQUE_ID=" + unique_id + ";" +
"end";

Related

Ics file is "sending update" instead of creating a "send"

I have this meeting appointment i'm trying to send from an .ics file.
This is the data
"BEGIN:VCALENDAR\n" +
"CALSCALE:GREGORIAN\n" +
"METHOD:PUBLISH\n" +
"PRODID:-//Send project Invite//EN\n" +
"VERSION:2.0\n" +
"BEGIN:VEVENT\n" +
"UID:gestionprojetsCalendarInvite\n" +
"DTSTART;VALUE=DATE-TIME:" +
convertDate(startDate) +
"\n" +
"DTEND;VALUE=DATE-TIME:" +
convertDate(endDate) +
"\n" +
"SUMMARY:" +
subject +
"\n" +
"DESCRIPTION:" +
description +
"\n" +
"LOCATION:" +
location +
"\n" +
to.filter(o => o != '').map(o => "ATTENDEE;MAILTO:" + o.email).join("\n") +
"\n" +
"BEGIN:VALARM" +
"\n" +
"TRIGGER:-PT15M" +
"\n" +
"ACTION:DISPLAY" +
"\n" +
"DESCRIPTION:Reminder" +
"\n" +
"END:VALARM\n" +
"END:VEVENT\n" +
"END:VCALENDAR";
I want to know why, when I open the .ics file, it's saying "send update" instead of "send".
What I get :
What I want :
I believe it’s because you have static UID for all .ics you generated. "UID:gestionprojetsCalendarInvite\n"
UID aka unique ID, is supposed to uniquely represent a calendar event. When you open an ics file containing duplicated UID, your app (Outlook I guess?) thinks you want to update an existing event, not creating a new one.
Try give it a different UID to see if that solves your problem.
Ref: https://icalendar.org/New-Properties-for-iCalendar-RFC-7986/5-3-uid-property.html

ICalendar add Attendees

I have this
let data =
"BEGIN:VCALENDAR\n" +
"CALSCALE:GREGORIAN\n" +
"METHOD:PUBLISH\n" +
"PRODID:-//Send project Invite//EN\n" +
"VERSION:2.0\n" +
"BEGIN:VEVENT\n" +
"UID:gestionprojectCalendarInvite\n" +
"DTSTART;VALUE=DATE-TIME:" +
convertDate(startDate) +
"\n" +
"DTEND;VALUE=DATE-TIME:" +
convertDate(endDate) +
"\n" +
"SUMMARY:" +
subject +
"\n" +
"DESCRIPTION:" +
description +
"\n" +
"LOCATION:" +
location +
"\n" +
"END:VEVENT\n" +
"END:VCALENDAR";
How can I add attendees to the data that is sent to the calendar event that i'm creating.
Here is the place where I need my info in :
I added
ATTENDEE;PARTSTAT=ACCEPTED;CN=NAME_OF_ATTENDEE:mailto:EMAIL_OF_ATTENDEE
Replace NAME_OF_ATTENDEE and EMAIL_OF_ATTENDEE with what you need.
This will put the correct information in the TO: box

creating a page based on a field

In my form I have a total field which is the sum of several checkboxes. When it reaches 21 total page one must be created. below the code, which worked well in another case and this time it gives me a syntax error. someone there you an idea ??
Thank you in advance
this.getField("TOTAL").value =
this.getField("P6eval_competences.manageriales.0").value +
this.getField("P6eval_competences.manageriales.1").value +
this.getField("P6eval_competences.manageriales.2").value +
this.getField("P6eval_competences.manageriales.3").value +
this.getField("P6eval_competences.manageriales.4").value +
this.getField("P6eval_competences.manageriales.5").value +
this.getField("P6eval_competences.manageriales.6").value +
this.getField("P6eval_competences.manageriales.7").value +
this.getField("P6eval_competences.manageriales.8").value +
this.getField("P6eval_competences.manageriales.9").value +
this.getField("P6eval_competences.manageriales.10").value +
this.getField("P6eval_competences.manageriales.11").value +
this.getField("P6eval_competences.manageriales.12").value +
this.getField("P6eval_competences.manageriales.13").value +
this.getField("P6eval_competences.manageriales.14").value +
this.getField("P6eval_competences.manageriales.15").value +
this.getField("P6eval_competences.manageriales.16").value +
this.getField("P6eval_competences.manageriales.17").value +
this.getField("P6eval_competences.manageriales.18").value +
this.getField("P6eval_competences.manageriales.19").value +
this.getField("P6eval_competences.manageriales.20").value +
this.getField("P6eval_competences.manageriales.21").value +
this.getField("P6eval_competences.manageriales.22").value +
this.getField("P6eval_competences.manageriales.23").value +
this.getField("P6eval_competences.manageriales.24").value +
this.getField("P6eval_competences.manageriales.25").value +
this.getField("P6eval_competences.manageriales.26").value +
this.getField("P6eval_competences.manageriales.27").value +
this.getField("P6eval_competences.manageriales.28").value +
this.getField("P6eval_competences.manageriales.29").value +
this.getField("P6eval_competences.manageriales.30").value +
this.getField("P6eval_competences.manageriales.31").value;
if (getField("TOTAL").value == "21") {
var expTplt = getTemplate("NIVEAU MATURE");
expTplt.spawn(numPages, true, false);
}
I think you should use parseInt() method cause the values which are returned are not Integer rather they are Strings.

Trying to inject datapoints into iOS webView using highcharts

While porting an android app to iOS we hit a barrier:
We have a UIwebView set up to run HighCharts (it works with their provided sample), but we can't figure out how to pass variables to Javascript in order to display real time changes.
The android-equivalent of what we're trying to do is:
webView.loadUrl("javascript:" + "point = " + "[Date.UTC("
+ mYear + "," + mMonth + "," + mDay + "," + hr
+ "," + min + "," + sec + "),"
+ value+ "];");
or another example:
webView.loadUrl("javascript:" + "var curve_name = " + "'Illuminance';" +
"var unit_of_meas = " + "'lx';" +
"var x_axis_title = " + "'Date';" +
"var y_axis_title = " + "'Illuminance (lx)';" +
"var plot_title = " + "'Illuminance data';" +
"var plot_subtitle = " + "'';")
UIWebView has a method called stringByEvaluatingJavaScriptFromString that you can use to run a script. I think that you can also use it to just pass and initialize any variable that you like.

Tab characters converted to spaces in Google Apps Script

I have a Google Apps Script I am writing that combines a number of reports into a consolidated tab-delimited (TSV) format. However, I am noticing that whenever I write to file, the tabs in my strings are being converted into spaces. Is there some other string literal that I should use?
var content =
data.parameters.time[0] + "\t" +
data.parameters.url[0] + "\t" +
data.parameters.code_name[0] + "\t" +
data.parameters.app_name[0] + "\t" +
data.parameters.version[0] + "\t" +
data.parameters.cookies[0] + "\t" +
data.parameters.lang[0] + "\t" +
data.parameters.platform[0] + "\t" +
data.parameters.user_agent[0] + "\t" +
data.parameters.ex[0];
fld.createFile(makeid() + ".tab", content, ContentService.MimeType.CSV);
Nothing is wrong with using the \t string literal - rather you're using the wrong MimeType enum, from the ContentService. DriveApp methods expect MimeType as a string. Try:
fld.createFile(makeid() + ".tab", content, MimeType.CSV);
Here's a snippet that shows the tab characters survive the file write when the MimeType is properly set:
function myFunction() {
var content =
'time' + "\t" +
'url' + "\t" +
'code_name' + "\t" +
'etcetera';
Logger.log("Initial TSV: " + JSON.stringify(content.split("\t")));
var newFile = DriveApp.createFile("Delete-me" + ".tab", content, MimeType.CSV);
// Check our result, by reading back the file
var blob = newFile.getBlob();
var docContent = blob.getDataAsString()
Logger.log("Result TSV: " + JSON.stringify(docContent.split("\t")));
}
Logs:
[15-04-07 14:53:08:767 EDT] Initial TSV: ["time","url","code_name","etcetera"]
[15-04-07 14:53:09:542 EDT] Result TSV: ["time","url","code_name","etcetera"]

Categories

Resources