Make your first request
Send your certificate and private key with every request. The gateway accepts TLS 1.3 only.
Net Money gives you the gateway URL for each environment. The examples use it as a variable:
export GATEWAY_URL=https://gateway.example.comcurl --cert merchant.crt --key merchant.key \ "$GATEWAY_URL/v1/payment/<transactionId>/status"If Net Money gave you a CA certificate for the environment (for example on staging), add --cacert net-money-ca.crt.
A request that is authenticated but asks for an unknown payment returns 404. This already proves that your certificate works.
Combine the certificate and key into a PKCS12 keystore:
openssl pkcs12 -export -in merchant.crt -inkey merchant.key \ -out merchant.p12 -name merchantThen load it into an SSLContext:
KeyStore keyStore = KeyStore.getInstance("PKCS12");try (var in = Files.newInputStream(Path.of("merchant.p12"))) { keyStore.load(in, password);}KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());kmf.init(keyStore, password);
SSLContext ssl = SSLContext.getInstance("TLSv1.3");ssl.init(kmf.getKeyManagers(), null, null);
HttpClient client = HttpClient.newBuilder().sslContext(ssl).build();Node.js
Section titled “Node.js”Node’s built-in fetch cannot send a client certificate on its own; use the undici package:
import fs from 'node:fs';import {Agent, fetch} from 'undici';
const dispatcher = new Agent({ connect: { cert: fs.readFileSync('merchant.crt'), key: fs.readFileSync('merchant.key'), minVersion: 'TLSv1.3', },});
const res = await fetch(`${process.env.GATEWAY_URL}/v1/payment/<transactionId>/status`, {dispatcher});Python
Section titled “Python”import requests
r = requests.get( f"{GATEWAY_URL}/v1/payment/<transactionId>/status", cert=("merchant.crt", "merchant.key"),)
