Get Stated
Airtime API enables you to send airtime from your EtherOne Wallet to specified registered mobile money numbers. You must ensure that you have subscribed to the Airtime API in the EtherOne Dashboard
Authentication ( Optional )
SHA256 RSA Signature
In order to add extra authentication to the airtime API, it is necessary to apply RSA encryption to your data. First, you need to generate a key pair and then upload the public key to the EtherOne dashboard, specifically on the airtime subscription page. To create a signature, follow these steps:
1. Create the data using the following format: phoneNumber&transactionID&amount. Example: "876767672323&256757121212&5000"
2. Use your private key to sign the data and generate a signature. Example: Using the private key "abcd1234", the signature might be "xxxxxxx".
3. Include the generated signature in the JSON body when sending the request. Example: {"signature": "xxxxxxxxx" }
You can use the code samples below to sign your data
// Sample Code In PHP
// Step 1: Prepare the data
$msisdn = "256757121212";
$transactionID = "876767672323";
$amount = "5000";
$data = $msisdn."&".$transactionID."&".$amount;
// Step 2: Load your private key
$privateKey = openssl_pkey_get_private("path/to/private_key.pem");
// Make sure to replace 'path/to/private_key.pem' with the actual path to your private key file
// Step 3: Sign the data
openssl_sign($data, $signature, $privateKey, OPENSSL_ALGO_SHA256);
// Step 4: Encode the signature
$encodedSignature = base64_encode($signature);
// Print or use the JSON string as needed
echo $encodedSignature;// Sample Code In Java
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.*;
import java.util.Base64;
public class RSASigningExample {
public static void main(String[] args) throws Exception {
// Step 1: Prepare the data
String msisdn = "256757121212";
String transactionID = "876767672323";
String amount = "5000";
String data = msisdn + "&" + transactionID +"&" + amount;
// Step 2: Load your private key
byte[] privateKeyBytes = Files.readAllBytes(Paths.get("/path/to/private_key.pem"));
// Make sure to replace "/path/to/private_key.pem" with the actual path to your private key file
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
PKCS8EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(privateKeyBytes);
PrivateKey privateKey = keyFactory.generatePrivate(privateKeySpec);
// Step 3: Sign the data
Signature signature = Signature.getInstance("SHA256withRSA");
signature.initSign(privateKey);
signature.update(data.getBytes(StandardCharsets.UTF_8));
byte[] signedData = signature.sign();
// Step 4: Encode the signature
String encodedSignature = Base64.getEncoder().encodeToString(signedData);
// Print or use the JSON body as needed
System.out.println(encodedSignature);
}
}
Last updated