TPVPC: JavaScript Integration
Web-based Point-of-Sale applications integrate with Get Central through the Local Service, which acts as a secure bridge between the browser environment and the native TPVPC. This guide describes the supported integration model and the event-driven interaction required for browser-based implementations.
This guide applies to TpvpcImplantado.
Requirements
Before you begin, ensure you have:
- Get Central Local Service installed and running on the client machine
- The
tpvpc-impl.jslibrary available to your web application - Network access to the Local Service endpoint
The Local Service exposes HTTP and HTTPS endpoints on predefined local ports, depending on the installation and configuration.
When using HTTPS, the Local Service may rely on a locally generated certificate. The browser must trust this certificate for requests to succeed.
JavaScript Integration Process
JavaScript integration is asynchronous and event-driven. All communication with the TPVPC is performed through a global integration object exposed by the Local Service.
Step 1: Subscribe to Device and Transaction Events
Because browser calls are non-blocking, applications must subscribe to events to track the transaction lifecycle and respond to device interaction requests.
Event names and payloads are defined by the Local Service and may vary by version. Applications should be prepared to handle multiple event notifications during a single transaction.
function handleEvent(eventData) {
console.log("Device event:", eventData);
}
// Example event subscriptions
tpvpcImpl.subscribeEvent("pinpadImplantadoEvent_1", handleEvent);
tpvpcImpl.subscribeEvent("pinpadImplantadoEvent_3", handleEvent);Event identifiers are integration-specific and should not be hardcoded without consulting the Local Service documentation for the installed version.
Step 2: Execute TPVPC Functions
Operations are executed by invoking TPVPC functions through the Local Service. Requests are forwarded asynchronously, and results are returned via a callback.
No financial logic should be inferred from intermediate events. The transaction outcome must be determined only after the final response is received.
tpvpcImpl.execFnDll(
"fnDllOperPinPad",
["1.00", "TEST0001", "PAGO"],
function (response) {
if (response && response.Response === 0) {
console.log("Transaction completed");
console.log(response.Result);
}
}
);The XML response returned in response.Result must be parsed to determine the financial outcome of the operation.
Step 3: Validate the Transaction Result
The transaction is authorized only if the XML response contains:
<estado>F</estado>
<resultado>Autorizada</resultado>Any other result indicates that the transaction was denied, regardless of the technical execution status.
Next Steps
After completing the JavaScript integration, you can proceed with further implementation:
- To process standard payments, refer to the Process a Single-Step Payment guide.
- For details on generating and printing receipts from the browser, see the Generate and Print Receipts documentation.
- To implement subscription models or token-on-file logic, consult the Handle Recurring Payments guide.
- For a complete reference of technical exit codes and troubleshooting logs, refer to the Result Codes and Errors and Logs and Troubleshooting documentation.