Skip to content

Send transaction

Case

You already have a transaction file prepared in JSON format based on the Transaction data model. If not, refer to the transaction building guide.

If needed, Signal also supports transaction conversion between all supported formats, including DUMP, INI, and JSON. The conversion workflow is described in the corresponding examples of this section.

JSON transaction example
{
    "message_type": "0200",
    "max_amount": "100",
    "generate_fields": [
        "4",
        "7",
        "11",
        "12",
        "37"
    ],
    "data_fields": {
        "2": "4000000000000000",
        "3": "000000",
        "4": "000000004679",
        "7": "0727142832",
        "11": "981533",
        "12": "230727142832",
        "14": "3504",
        "18": "8999",
        "22": "810",
        "37": "159384172368",
        "41": "70000826",
        "42": "000000010000866",
        "43": "PSP*merch.com               >Limassol>CY",
        "47": {
            "227": {
                "01": "Limassol",
                "03": "CYP",
                "04": "3101"
            },
            "072": "20240303_184906_8769658371",
            "033": "5",
            "027": "30303030433032445531325350334c48474b564c",
            "028": "00000308254236854496634394423610b892eb6a",
            "030": "2",
            "226": "unlimit.com"
        },
        "48": {
            "51": "SOME ONE",
            "96": "415481%8164",
            "54": "HOW ARE YOU",
            "42": "01",
            "92": "000"
        },
        "49": "978"
    }
}

Solution

In this scenario, the goal is simple — load the prepared transaction, generate dynamic fields if required, and send it to the remote host.

Use the following code:

# Your file with JSON transaction data
INCOMING_TRANSACTION_FILE_NAME = "transaction_request_example.json"  

# To process this case we need
#  • TermFilesPath constants set to get the config file info
#  • Config data model to load the configuration data from the file
#  • Transaction data model load the transaction data from the file
#  • Terminal as a transaction processing system
# 
# Let's import all of this components

from common.lib.enums.TermFilesPath import TermFilesPath  # System files path to read the configuration
from common.lib.data_models.Config import Config  # Configuration data container
from common.lib.data_models.transaction import Transaction  # Transaction data container
from common.lib.core.Terminal import Terminal  # General transactions processing interface

# Start the processing

# Load the data from transaction file to transaction data model
transaction: Transaction = Transaction(INCOMING_TRANSACTION_FILE_NAME)  

# Load the data from configuration file to config data model
config: Config = Config(TermFilesPath.CONFIG)  

# Create Terminal object
terminal: Terminal = Terminal(config)   

# Terminal reads the data using data models only, not from the files directly
# Now we have the transaction data, accessible using the data model and started Terminal as the processing tool
# Let's send transaction to the host

terminal.send(transaction)

# Done