We are currently implementing the Terminal API in a Unity (C#) application for the integration part with Square Terminal.
The implementation was done with reference to the “Create terminal checkout” page of the Terminal API documentation.
Execution on the Unity editor is successful, and the Square Terminal screen transitions to a blue screen prompting for payment.
However, when I built the application and checked the operation of the application on an Android device,
The following error occurred and the Square Terminal screen did not transition ”IndexOutOfRangeException: Index was outside the bounds of the array.”
There is no mention of checkout from Android devices in the API Logs on the Developer Dashboard.
Please let me know if there is a solution to this issue, or if there are any settings that need to be made to run on the actual device.
Thank you in advance.
The development environment and implementation code are as follows
Development environment
Development language: C#
Square API version: 26.0.0
Android device version: 7.0, 11.0
Unity2021.3.15f1
Reference page: Create terminal checkout
Implementation code:
var amountMoney = new Money.Builder()
.Amount(10L)
.Currency(“JPY”)
.Build();
var paymentOptions = new PaymentOptions.Builder()
.Autocomplete(null)
.DelayDuration(null)
.AcceptPartialAuthorization(null)
.DelayAction(null)
.Build();
var deviceOptions = new DeviceCheckoutOptions.Builder(deviceId: ”Serial number on the back of the terminal”)
.SkipReceiptScreen(true)
.Build();
var checkout = new TerminalCheckout.Builder(amountMoney: amountMoney, deviceOptions: deviceOptions)
.PaymentOptions(paymentOptions)
.StatementDescriptionIdentifier(null)
.TipMoney(null)
.Build();
var body = new CreateTerminalCheckoutRequest.Builder(idempotencyKey: ”Unique string”, checkout: checkout)
.Build();
try
{
var result = await client.TerminalApi.CreateTerminalCheckoutAsync(body: body);
}
catch (ApiException e)
{
Console.WriteLine(“Failed to make the request”);
Console.WriteLine($“Response Code: {e.ResponseCode}”);
Console.WriteLine($“Exception: {e.Message}”);
Console.WriteLine($“Errors: {e.Errors}”);
Console.WriteLine($“Data: {e.Data}”);
}