Migrating from a previous Atos-Worldline integration
How to migrate to Viva from an Atos-Worldline integration.
Overview
Migrating to the Viva POS API from a previous integration of Atos-Worldline POS terminals - if you’re running an Atos-Worldline card terminal, the below reference guides explain how you integrate your cash register or ordering application with one of Viva’s POS terminals.
iOS quick integration guide
Creating and starting the service
Use
startServiceOnPort:terminalConnectedBlock:terminalDisconnectedBlock:startServiceFailedBlock |
to create a connection to the terminal. If everything is setup correctly, it should connect automatically.
Objective C
[[ECTService sharedInstance] startServiceOnPort:9000
terminalConnectedBlock:^(ECTTerminal *terminal) {
NSLog(@"A connection with a terminal has been established");
} terminalDisconnectedBlock:^() {
NSLog(@"A terminal got disconnected");
} startServiceFailedBlock:^(ECTError *error) {
NSLog(@"The service failed to start. Error: %@", error);
}];
Your first request
When a terminal has successfully connected, you can go ahead and send your first request. Let’s take a sale request as an example.
Objective C
[[ECTService sharedInstance] makeSaleWithAmountUnit:1 amountDecimal:23 merchantReference:nil discretionaryData:nil successBlock:^(ECTSaleTransactionResult
*result) {
NSLog(@"You have successfully completed your first sale. Congratulations!");
} withFailedBlock:^(ECTError *error) {
NSLog(@"Something went wrong during the sale: %@", error);
}];
Stopping the service
When you want to stop the service, you can call the stopService method. This will disconnect the terminal and stop the service. If you want to reconnect, you should call again the
startServiceOnPort:terminalConnectedBlock:terminalDisconnectedBlock:startServiceFailedBlock |
method. Keeping the connection alive or not depends of your needs. In any cases, when the service is started, if the connection drops then the service will try to reconnect automatically.
Objective C
[[ECTService sharedInstance] stopService];
C++ quick integration guide
- Creating and starting the service
- Listening for connected terminals
- Your first request
- Error handling
- Stopping the service
Creating and starting the service
First you need to create your service instance. You can do this with the factory method ect::MakeService
. You also need to provide a service listener to listen for a connected terminal:
std::unique_ptr<Service> service = ect::MakeService(*this); |
To start listening for a terminal connection, use the following code:
service->startService(9000); |
Listening for connected terminals
You need the terminal instance to make transactions, so store it locally for convenience.
void YourServiceListener::onTerminalConnect(std::shared_ptr<Terminal> terminal) {
// store the terminal for later usage }
void YourServiceListener::onTerminalDisconnect(std::shared_ptr<Terminal> terminal) {
// do something with the disconnected terminal
Your first request
When a terminal has successfully connected, you can go ahead and send your first request. Let’s take a sale request as an example. If you have the possibility to use C++14, it makes life a little bit easier.
C++14
terminal->send(SaleTransaction(SaleAction::Sale, Amount("1.2"), "Merchant Reference", [](const auto& result) {
// do something with the result
}));
C++11
terminal->send(SaleTransaction(SaleAction::Sale, Amount("1.2"), "Merchant Reference", [](const SaleResult& result) {
// do something with the result
}));
Error handling
Use the error member function of the result to know if an error occurred. An optional error object is returned:
C++14
terminal->send(CancelRetailTransaction([this](const auto& result) {
if (auto error = result.error())
// handle error
else
// handle result
}));
Stopping the service
When you want to stop the service, you can call the stopService
method. This will disconnect the terminal and stop the service. If you want to reconnect, you should again call
the startService
method.
Keeping the connection alive or not depends of your needs. In any cases, when the service is started, if the connection drops then the service will try to reconnect automatically.
service->stopService(); |
Get Support
If you would like to integrate with Viva, or if you have any queries about our products and solutions, please see our Contact & Support page to see how we can help!