Getnet DocsGetnet Docs

TPVPC: C# Integration

Integrating Get Central in a .NET environment is performed through Platform Invocation Services (P/Invoke), allowing managed C# code to call the native Get Central library. This guide explains how to configure your project, declare the native functions, and execute a basic payment operation.

This guide applies to TpvpcImplantado.

This integration model applies to TpvpcImplantado.

Requirements

Before you begin, ensure you have:

  • dllTpvpcLatente.dll available at runtime
  • All required native dependencies present in the same directory
  • Visual Studio or another .NET-compatible IDE
  • Project Target Platform set to x86 (the library is 32-bit)

Failure to compile or run in x86 mode will result in a BadImageFormatException.

C-Sharp Integration Process

The integration process consists of mapping the native library functions and invoking them from managed code. No XML is sent as a request; parameters are passed positionally, and the XML is returned as a response.

Step 1: Declare Native Functions

Native functions are declared using the DllImport attribute. The library exposes a fixed set of entry points that must be mapped exactly.

Library Initialization

The following functions are used to initialize the library:

ParameterTypeDescription
cComerciostringMerchant identifier assigned by the acquirer.
cTerminalstringTerminal identifier associated with the PIN pad.
cClaveFirmastringSignature key assigned to the merchant and terminal.
cConfPuertostringCommunication port. Leave empty to use local configuration.
cVersionstringProtocol version. Leave empty to use the default version.
[DllImport("dllTpvpcLatente.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
public static extern int fnDllIniTpvpcLatente(
    string cComercio,
    string cTerminal,
    string cClaveFirma,
    string cConfPuerto,
    string cVersion
);

Payment Execution

The following functions are used to execute a payment operation:

ParameterTypeDescription
cImportestringTransaction amount in format XXXXXXXXX.XX.
cFacturastringMerchant reference for the transaction.
cTipoOperstringOperation type. For standard payments use PAGO.
cXMLRespStringBuilderBuffer that receives the XML response.
iTamMaxRespintMaximum size of the response buffer.
[DllImport("dllTpvpcLatente.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
public static extern int fnDllOperPinPad(
    string cImporte,
    string cFactura,
    string cTipoOper,
    StringBuilder cXMLResp,
    int iTamMaxResp
);

Library Finalization

The following functions are used to finalize the library:

ParameterTypeDescription
——This function takes no parameters.
[DllImport("dllTpvpcLatente.dll", CallingConvention = CallingConvention.StdCall)]
public static extern int fnDllParaTpvpcLatente();

Step 2: Initialize the Library

Before executing any transaction, the library must be initialized once per application lifecycle.

int result = fnDllIniTpvpcLatente(
    "99999999",
    "00000001",
    "CLAVE123456",
    "",
    ""
);

if (result != 0)
{
    // Initialization failed. Do not proceed.
}

A return value of 0 indicates successful initialization.

Step 3: Execute a Payment Operation

Once initialized, a standard card-present payment can be executed using cTipoOper = "PAGO".

StringBuilder xmlResponse = new StringBuilder(8192);

int result = fnDllOperPinPad(
    "1.00",
    "TEST0001",
    "PAGO",
    xmlResponse,
    xmlResponse.Capacity
);

When the function returns, the XML response buffer is populated with the transaction result.

Step 4: Process the Response

The integer return value indicates only the technical execution status. The financial outcome must be determined by parsing the XML response.

A transaction is authorized only if the response contains:

<estado>F</estado>
<resultado>Autorizada</resultado>

Any other combination must be treated as a denied transaction.

Step 5: Finalize the Library

When the application no longer needs to perform operations, the library should be finalized to release system resources.

fnDllParaTpvpcLatente();

Next Steps

After completing the C# integration, you can proceed with further implementation: