#include <iostream>
#include <string>
using namespace std;
int main()
{
string merchantSMS, payConfirmSMS;
cout << "The Merchant invoke payment SMS: ";
getline (cin, merchantSMS);
cout << "The Payservice payment confirmation SMS: ";
getline (cin, payConfirmSMS);
//Convert SMS’s to uppercase
for (int i = 0; i < [Link](); i++)
{
merchantSMS[i] = toupper (merchantSMS[i]);
}
//Check for correct format of Merchant SMS
//getline (cin, text);
if ([Link] ('#') != string::npos)
{
cout << "Contains # character" << endl;
}
else
{
cout << "Incorrect SMS format. Error: Does not contain the #
character!" << endl;
}
//Check if Merchant SMS transaction is tied to a previous transaction
int nextProcess
int position = [Link] ('#');
if (position != string::npos)
{
if ([Link] ('#', position+1) != string::npos)
{
cout << "Contains 2 # separation hence has previous
transaction number" << endl;
nextProcess=1;
}
else
{
cout << "New transaction!" << endl;
nextProcess=2;
}
}
else
{
cout << " Incorrect SMS format. Error: Does not contain the #
character!" << endl;
}
//Get Buyer number and confirm if is correct length
if (position != 11)
{
cout << "The buyer phone number is incorrect!" << endl;
}
else
{
cout << "Correct phone number length!" << endl;
}
//Confirm if Buyer phone number has correct phone number format i.e 07-- ------
//get the phone number from string
string buyerPhoneNumber
for (int i = 0; i < 9; i++)
{
buyerPhoneNumber[i] = merchantSMS[i];
}
//check for invalid characters in the phone number
if (buyerPhoneNumber.find_first_not_of ("1234567890") !=
string::npos)
{
cout << "The buyer phone number entered contains
invalid characters"
<< endl;
}
//check if the first two characters of the phone number are ‘07’
string bPNcheck
for (int i = 0; i < 1; i++)
{
bPNcheck[i] = buyerPhoneNumber[i];
}
if (bPNcheck !=”07”)
{
cout << "The buyer phone number is invalid!"
<< endl;
}
else
{
bPNcheck= buyerPhoneNumber;
}
//Get the Amount to be paid
if (nextProcess == 1)
{
string payableAmount
int position = [Link] ('#');
for (int i = position+1; i < [Link](); i++)
{
payableAmount = payableAmount + merchantSMS[i]);
}
elseif (nextProcess == 2)
{
string payableAmount
int position = [Link] ('#');
int position2 = [Link] ('#', position+1);
for (int i = position+1; i < position2; i++)
{
payableAmount = payableAmount + merchantSMS[i]);
}
}
else
{
cout << "Error getting the payable amount!" << endl;
}
//Get previous transaction number (where relevant)
if (nextProcess == 2)
{
string prevTransactionNo
int position = [Link] ('#');
int position2 = [Link] ('#', position+1);
for (int i = position2+1; i < [Link](); i++)
{
prevTransactionNo[i] = merchantSMS[i]);
}
}
else
{
cout << "Error getting the previous transaction number!" <<
endl;
}
//Display the acquired fields
cout << "Buyer Phone Number: " << bPNcheck << " Payable Amount: " <<
payableAmount << "Previous Transaction Number: " << prevTransactionNo <<
endl;
return 0;
}