Skip to main content

Company Resources

Shared resources across all IPP products. test

test

public void Test1()throws IOException, NoSuchAlgorithmException, CertificateException, KeyStoreException, KeyManagementException {
//Load the certificate (path to certificate)
InputStream is = new FileInputStream("\\ECR-REST.crt");
CertificateFactory cf = CertificateFactory.getInstance("X.509");
X509Certificate caCert = (X509Certificate)cf.generateCertificate(is);
//Setup a TrustmanagerFactory for the loaded certificate
TrustManagerFactory tmf = TrustManagerFactory
.getInstance(TrustManagerFactory.getDefaultAlgorithm());
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(null);
ks.setCertificateEntry("caCert", caCert);
tmf.init(ks);
//Create SSLContext to apply TLS encryption
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, tmf.getTrustManagers(), null);
//Open Https Connection and assign a URL to our REST API.
// set Integration-Key
URL url = new URL("https://192.168.1.105/api/v1/Payments");
HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
urlConnection.setSSLSocketFactory(sslContext.getSocketFactory());
urlConnection.setHostnameVerifier((hostname, session) -> true);
urlConnection.setRequestProperty("Integration-Key","Your integration key");
// Set GET or POST depeding on method you use
urlConnection.setRequestMethod("POST");
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
// You can of course create you own library to manage JSON in other ways
// But we chose to go with "org.json.JSONObject"
String jsonInputString = "";
try {
JSONObject amounts = new JSONObject();
amounts.put("currencySymbol", "SEK");
amounts.put("base", 100);
JSONObject json = new JSONObject();
json.put("amounts", amounts);
json.put("sendReceipt", true);
jsonInputString = json.toString();
}
catch (Exception e) {
System.out.println(e.getMessage());
}
// Sending
try(OutputStream os = urlConnection.getOutputStream()) {
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.length);
}
// Receiving
BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
in.close();
int responseCode = urlConnection.getResponseCode();
System.out.println("Response code: "+responseCode);
}
using System;
using System.Net.Http;

using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

using System.Security.Cryptography.X509Certificates;

public void SendHTTPRequest(HttpClient client){
client.DefaultRequestHeaders.Add("Integration-Key", "Your integration key");

//Starting the POST request
var syncRequest = new HttpRequestMessage("https://192.168.1.105/api/v1/Payments")
{
Content = new StringContent(JsonConvert.SerializeObject(
new
{
amounts = new
{
currencySymbol = "SEK",
@base = 100
},
sendReceipt = true,
},
Formatting.Indented, new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
}
), Encoding.UTF8, "application/json")
};


var response = client.Send(syncRequest);
var statuscode1 = response.StatusCode;
}

public HttpClientHandler CertHandler()
{
try
{
//generic common name
var commonName = "wl-samport-terminal-server-v1";

//path to cert
var path = "Certs\\ECR-REST.crt";

X509Certificate2 cert = new X509Certificate2(path);

var handler = new HttpClientHandler();
//specify our own ServerCertificateCustomValidationCallback in order to
//supply our custom root certificate and to validate the commonname
handler.ServerCertificateCustomValidationCallback = (requestMessage, certificate, chain, sslErrors) =>
{
if (certificate != null && chain != null)
{
chain.ChainPolicy.TrustMode = X509ChainTrustMode.CustomRootTrust;
chain.ChainPolicy.CustomTrustStore.Add(cert);

// We can also return choose to simply "return true;" here, We dont have
// to confirm the commonName if we dont want to(doesn't decrease the amount of encryption)
return chain.Build(certificate) && certificate.Subject.Contains("CN=" + commonName);
}
return false;
};
return handler;
}
catch (Exception e)
{
Console.WriteLine("Exception: "+ e.Message);
}
return new HttpClientHandler();
}
1
Become a Partner
  • Complete the Worldline onboarding process. Refer to Become a Partner section.
  • Register your merchant account.
  • Obtain your UMID, UTID, and API credentials.
2
Gather Your Credentials

Before you begin, ensure you have:

  • UMID (Unique Merchant ID)
  • UTID (Unique Terminal ID)
  • API Bearer Token
  • A registered payment terminal
  • Internet connectivity
3
Install Terminal API

If Terminal API is already installed, skip this step.

1. Open the terminal launcher.

2. Open the App Drawer.

3. Launch SmartPOS Store.

4. Open the All tab.

testSamport