Get ticket object in payment processor

You wont be able to load a ticket as terminalticket if its already open and a payment has been initiated on a different terminal.

Ooo, I didn’t think of that.

Shoot…

However, if a unique ticket identifier is obtained then sql could be used to add a calculation. It’s getting an unique ticket identifier is where I’m stuck.

So, what data is passed to a payment processor?

You do not need the ticket ID from payment processor it is already understood that it is working with that ticket. You can access values from that ticket inside the script already. Use the Execute Script payment processor. Maybe toy around with whats available there.

I get that a ticket can’t be opened via the API when it’s open in the payment screen.

With the ticket ID or ticket UID, a SQL stored procedure could be called to create an account transaction linked to the ticket account transaction document and add a calculation, bypassing loading a terminal ticket.

Is the ticket ID/UID/object unavailable to the payment processor? I’ve tried ticketId, ticketID, TicketId, TicketID, etc. to no avail.

You do not need the ticket ID as functions to get data are already available for that ticket.

1 Like

What you are trying to do may not be possible through processors. Instead of doing this maybe we should find the reason for the remainder and look at solving that?

Man, Jesse, if I could figure it out, I’d be happier than a pig in shit.

I’ve gone though this thread multiple times and still am so confused:

I’ve played with the exchange rate that will work on small amounts (under 1000) but not for large amount (over 10000) and vice versa. I seem to have remainder of 0.08 Honduran Lempiras (0.0032 USD).

I already have a stored procedure that will insert into AccountTransactions, AccountTransactionValues, and Calculations. Like Q was talking about in that thread, we really don’t deal with 1 lempiras. So, anything under 5 should be rounded-off.

In order to execute the stored procedure to add a calculation I first need an identifier for the ticket.

like in Emre’s post about payment integrations, I’d like to be able to get the ticket object as shown here:

function getListOfTicketOrders(ticket) {
	// Sample for reading ticket and order data. 
	// If needed you can use it to read product names, prices, etc.

	var orders = ticket.Orders.ToArr(); 							// ToArray() converts a .net Array to JS Array so we can loop through orders.
	var result = '';                     							
	var total = 0;
	for (i = 0; i < orders.length; i++) {
		result = result + orders[i].Quantity 						// Reading order quantity
			+ ' x ' + orders[i].MenuItemName 						// Reading menu item name
			+ ' - ' + ticket.GetExactTotalFor(orders[i]) + '\r';	// Reading order total with discounts & services applied
	}
	result = result + 'Total: ' + ticket.TotalAmount + '\r';		// Ticket Total
	result = result + 'Remaining: ' + ticket.RemainingAmount;		// Remaining Total
	return result;
}

But I can’t seem to get anything from the ticket object (like ticket.RemainingAmount) when using a payment processor.

1 Like

Would it be possible to prompt for a value? For example to ask a question like " Would you like to add tip?" and enter a value. But not using the change , just asking any time when making a payment.

Thanks

That’s what brought me to thinking about working with a payment processor.

But I may have a different solution for you. I’ll post in your thread if I get it working.

1 Like

Yes you can prompt ask questions and enter a value and it can trigger a calculation. This can be done via Payment Processor

Would you mind showing me the way? Thanks

As to my original question, is the ticket object available from within a payment processor script? If so, what is the method to retrieve said object? Thanks much

You do not need the ticket object because you can access the ticket properties directly with a script and you do not need to load the ticket.

is this true elsewhere or just on payment processor script?

No it’s not true elsewhere.

thats a shame, would be great is script had this ticket object available for current open ticket.

If your accessing a currently open ticket then yes you can access it without loading it but it all depends on when you are accessing it and what process is injecting the script.

Interesting, never seen that before. Is it like a global var? Above shows it as an input variable? So what needs to go in the call?

So he is confusing two different tutorials from two different use cases. The tutorial he referenced that showed the Ticket Object was the Credit Card Payment integration module tutorial. THe one he is wanting to actually use is a script invoked from a Payment Processor attached to a payment type. Those are two different scenarios. IF you use the Payment Processor and you use Execute Script then it is exposing the ticket already. The key is its not a Automation/Scripts script its specifically from Execute Script payment processor type.

Understood, shame, that would make scripts even more useful as wouldnt have to feed in so many variables all the time.