InPay provides a REST Web Service Interface that allows two-way flow of information to external systems. This enables automated and efficient transfer of data to and from your other systems reducing effort and duplication.
If you wish to know the commercials or costs involved in using Web Services then please contact the Client Account Management team. If you would like to enable the use of Web Services please contact our Support team and an estimate will be raised. It will need to be enabled on your system and a set of credentials for accessing the service will be supplied.
The full technical https://inpay.es.rsmuk.com/WebServicesREST/Help
Scenarios and uses
This section describes various scenarios of how the Web Services can be used.
Authentication
Before you can call any other InPay Web Service method you must first call the authenticate() method. Providing valid credentials to this method will return an authentication token that must be provided with all other Web Service calls.
Data Retrieval (Read operations)
There are a number of methods that enable you to read back the full details of an entity. Examples are api/Person/{employeeNo} where providing the correct employee number will return the full Person object and api/Payment/{employeeNo} which will return all the permanent payments in the system for an employee
Data Creation (Write Operations)
It is now possible to create data in InPay via the Web Services. This includes the following the person entity and many of the entities related to the worker (for example pension and absence records)
C# Code
Authenticate
private string Authenticate()
{
string token = null;
if (String.IsNullOrEmpty(username.Text) || String.IsNullOrEmpty(password.Text) || String.IsNullOrEmpty(companyID.Text))
{
return "Credentials missing";
}
FormUrlEncodedContent content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("grant_type", "password"),
new KeyValuePair<string, string>("companyId", companyID.Text),
new KeyValuePair<string, string>("username", username.Text),
new KeyValuePair<string, string>("password", password.Text)
});
var request = new HttpRequestMessage(HttpMethod.Post, restURL.Text + "token");
request.Content = content;
HttpResponseMessage response = client.PostAsync(restURL.Text + "token", content).Result;
if (response.IsSuccessStatusCode)
{
Task<Object> res = response.Content.ReadAsAsync<Object>();
Console.WriteLine("Auth result: " + res);
Console.WriteLine("Auth result type: " + res.GetType());
Console.WriteLine("Auth result string: " + res.Result);
Newtonsoft.Json.Linq.JObject jObj = (Newtonsoft.Json.Linq.JObject)res.Result;
//get the ticjket out of the json object returned
token = jObj.GetValue("access_token").ToString();
Console.WriteLine("Auth token: " + token);
}
else
{
Console.WriteLine("Auth Was not successful: " + response.StatusCode);
output.Text = output.Text + "\r\nAuth Was not successful: " + response.StatusCode;
}
response.Dispose();
return token;
}
Retrieve a Worker
private void GetPerson()
{
try
{
if (String.IsNullOrEmpty(token))
{
output.Text = output.Text + "\r\nAuthentication failed ";
}
else
{
output.Text = output.Text + "\r\nAuthenticated: " + token.ToString();
Object person = null;
string url = restURL.Text + "api/Person/" + employeeID.Text;
output.Text = output.Text + "\r\nDoing GET from URL: " + url;
var requestMessage = new HttpRequestMessage(HttpMethod.Get, url);
requestMessage.Headers.Add("Authorization", "Bearer " + token);
Console.WriteLine("About to do GET from " + url);
HttpResponseMessage response2 = client.SendAsync(requestMessage).Result;
if (response2.IsSuccessStatusCode)
{
Task<Object> res2 = response2.Content.ReadAsAsync<Object>();
Console.WriteLine("GET Person result: " + res2);
Console.WriteLine("GET Person result string: " + res2.Result);
person = res2.Result;
var results = JObject.Parse(res2.Result.ToString());
if (results["message"] != null)
{
Console.WriteLine("GET Person was not successful: " + results["message"]);
output.Text = output.Text + "\r\nGet Person failed: " + results["message"];
}
else
{
var personDetails = results.Value<JObject>("Person").Properties();
var personDict = personDetails.ToDictionary(k => k.Name, v => v.Value.ToString());
var addressDetails = results.Value<JObject>("AddressDetail").Properties();
var addressDict = addressDetails.ToDictionary(k => k.Name, v => v.Value.ToString());
var employmentDetails = results.Value<JObject>("EmploymentDetail").Properties();
var employmentDict = employmentDetails.ToDictionary(k => k.Name, v => v.Value.ToString());
...
{
var paymentDetails = results.Value<JObject>("PaymentDetail").Properties();
paymentDict = paymentDetails.ToDictionary(k => k.Name, v => v.Value.ToString());
}
else
{
paymentDict = null;
}
Dictionary<string, string> starterStatementDict;
if (results.Value<JObject>("StarterStatementDetail") != null)
{
var starterStatmentDetails = results.Value<JObject>("StarterStatementDetail").Properties();
starterStatementDict = starterStatmentDetails.ToDictionary(k => k.Name, v => v.Value.ToString());
}
else
{
starterStatementDict = null;
}
Dictionary<string, string> p45Dict;
if (results.Value<JObject>("P45Detail") != null)
{
var p45Details = results.Value<JObject>("P45Detail").Properties();
p45Dict = p45Details.ToDictionary(k => k.Name, v => v.Value.ToString());
}
else
{
p45Dict = null;
}
Dictionary<string, string> taxDict;
if (results.Value<JObject>("TaxDetail") != null)
{
var taxDetails = results.Value<JObject>("TaxDetail").Properties();
taxDict = taxDetails.ToDictionary(k => k.Name, v => v.Value.ToString());
}
else
{
taxDict = null;
}
Console.WriteLine("personDetails:" + personDict);
if (personDict["EmployeeNumber"] != null) employeeNumber.Text = personDict["EmployeeNumber"];
if (personDict["Title"] != null) title.Text = personDict["Title"];
if (personDict["FirstName"] != null) firstName.Text = personDict["FirstName"];
if (personDict["MiddleNames"] != null) middleNames.Text = personDict["MiddleNames"];
if (personDict["LastName"] != null) lastName.Text = personDict["LastName"];
if (personDict["KnownAs"] != null) knownAs.Text = personDict["KnownAs"];
if (personDict["DateOfBirth"] != null) dateOfBirth.Text = personDict["DateOfBirth"];
if (personDict["Gender"] != null) gender.Text = personDict["Gender"];
if (personDict["Email"] != null) email.Text = personDict["Email"];
if (personDict["PayslipNotification"] != null)
{
if (Boolean.Parse(personDict["PayslipNotification"]))
{
payslipNotification.CheckState = CheckState.Checked;
}
else
{
payslipNotification.CheckState = CheckState.Unchecked;
}
...
InPay provides a REST Web Service Interface that allows two-way flow of information to external systems. This enables automated and efficient transfer of data to and from your other systems reducing effort and duplication.
If you wish to know the commercials or costs involved in using Web Services then please contact the Account Management team. If you would like to enable the use of Web Services please contact our Support team and an estimate will be raised. It will need to be enabled on your system and a set of credentials for accessing the service will be supplied.
The full technical https://inpay.es.rsmuk.com/WebServicesREST/Help
Scenarios and uses
This section describes various scenarios of how the Web Services can be used.
Authentication
Before you can call any other InPay Web Service method you must first call the authenticate() method. Providing valid credentials to this method will return an authentication token that must be provided with all other Web Service calls.
Data Retrieval (Read operations)
There are a number of methods that enable you to read back the full details of an entity. Examples are api/Person/{employeeNo} where providing the correct employee number will return the full Person object and api/Payment/{employeeNo} which will return all the permanent payments in the system for an employee
Data Creation (Write Operations)
It is now possible to create data in InPay via the Web Services. This includes the person entity and many of the entities related to the worker (for example pension and absence records)
C# Code
Authenticate
private string Authenticate() { string token = null; if (String.IsNullOrEmpty(username.Text) || String.IsNullOrEmpty(password.Text) || String.IsNullOrEmpty(companyID.Text)) { return "Credentials missing"; } FormUrlEncodedContent content = new FormUrlEncodedContent(new[] { new KeyValuePair<string, string>("grant_type", "password"), }); var request = new HttpRequestMessage(HttpMethod.Post, restURL.Text + "token"); HttpResponseMessage response = client.PostAsync(restURL.Text + "token", content).Result; { Task<Object> res = response.Content.ReadAsAsync<Object>(); Newtonsoft.Json.Linq.JObject jObj = (Newtonsoft.Json.Linq.JObject)res.Result; } else { Console.WriteLine("Auth Was not successful: " + response.StatusCode); } response.Dispose(); } |
---|
Retrieve a Worker
private void GetPerson() try { if (String.IsNullOrEmpty(token)) { output.Text = output.Text + "\r\nAuthentication failed "; } else { output.Text = output.Text + "\r\nAuthenticated: " + token.ToString(); Object person = null; output.Text = output.Text + "\r\nDoing GET from URL: " + url; if (response2.IsSuccessStatusCode) { Task<Object> res2 = response2.Content.ReadAsAsync<Object>(); var results = JObject.Parse(res2.Result.ToString()); { Console.WriteLine("GET Person was not successful: " + results["message"]); } else { var personDetails = results.Value<JObject>("Person").Properties(); var addressDetails = results.Value<JObject>("AddressDetail").Properties(); var employmentDetails = results.Value<JObject>("EmploymentDetail").Properties(); var NIDetails = results.Value<JObject>("NIDetail").Properties(); { var paymentDetails = results.Value<JObject>("PaymentDetail").Properties(); } else { paymentDict = null; } Dictionary<string, string> starterStatementDict; { var starterStatmentDetails = results.Value<JObject>("StarterStatementDetail").Properties(); } else { starterStatementDict = null; } Dictionary<string, string> p45Dict; var p45Details = results.Value<JObject>("P45Detail").Properties(); } p45Dict = null; } var taxDetails = results.Value<JObject>("TaxDetail").Properties(); } taxDict = null; } if (personDict["EmployeeNumber"] != null) employeeNumber.Text = personDict["EmployeeNumber"]; if (Boolean.Parse(personDict["PayslipNotification"])) payslipNotification.CheckState = CheckState.Checked; } payslipNotification.CheckState = CheckState.Unchecked; } } if (Boolean.Parse(personDict["SMSPayslipNotification"])) smsPayslipNotification.CheckState = CheckState.Checked; } smsPayslipNotification.CheckState = CheckState.Unchecked; } } if (personDict["PostponeDate"] != null && personDict["PostponeDate"] != "") postponeDate.CustomFormat = "yyyy/MM/dd"; } postponeDate.CustomFormat = " "; }
} optOutDate.CustomFormat = " "; } addressDate.CustomFormat = "yyyy/MM/dd"; } addressDate.CustomFormat = " "; } if (addressDict["AddressLine1"] != null) addressLine1.Text = addressDict["AddressLine1"]; if (employmentDict["DateOfJoining"] != null) dateOfJoining.Text = employmentDict["DateOfJoining"]; if (Boolean.Parse(personDictemploymentDict["SMSPayslipNotificationIrregularPayments"])) smsPayslipNotificationirregularPayments.CheckState = CheckState.Checked; } smsPayslipNotificationirregularPayments.CheckState = CheckState.Unchecked; } } if (Boolean.Parse(employmentDict[" PostponeDateOffPayrollWorker"] != "")) offPayrollWorker. CustomFormat = "yyyy/MM/dd";postponeDate.Text = personDict["PostponeDate"] CheckState = CheckState.Checked; } offPayrollWorker.CheckState = CheckState.Unchecked; } } if (personDictemploymentDict["OptOutDateApprentice"] != null && personDict) if (Boolean.TryParse(employmentDict["OptOutDate"] != ""Apprentice"], out bool apprentice)) if (apprentice) Apprentice. CustomFormat = "yyyy/MM/dd";optOutDate.Text = personDict["OptOutDate"]; CheckState = CheckState.Checked; } else { Apprentice.CheckState = CheckState.Unchecked; } Apprentice. CustomFormat = " "CheckState = CheckState.Unchecked; } if (personDict["Method"] != null) method.Text = personDict["Method"]; } if ( personDictemploymentDict[" HolidaySchemeJobTitle"] != null) holidaySchemestrtJobTitle.Text = personDict["HolidayScheme"];if (personDict["AccrueDaysOverride"] != null) accrueDaysOverride.Text = personDict["AccrueDaysOverride employmentDict["JobTitle"]; employmentDict[" OSPSchemeWorkerPayType"] != null) ospSchemeworkerPayType.Text = personDictemploymentDict[" OSPSchemeWorkerPayType"]; if ( addressDictemploymentDict[" DateContractedHours"] != null && addressDict["Date"] != "") addressDate. contractedHours.Text = addressDictemploymentDict[" DateContractedHours"]; } addressDate.CustomFormat = " "; } if (addressDict["AddressLine1"] != null) addressLine1contractedHours.Text = addressDict[ "AddressLine1"]; } if ( addressDictNIDict[" AddressLine2NINumber"] != null) addressLine2niNumber.Text = addressDictNIDict[" AddressLine2NINumber"]; NIDict[" AddressLine3NITableLetter"] != null) addressLine3niTableLetter.Text = addressDictNIDict[" AddressLine3NITableLetter"]; NIDict[" TownDirector"] != null) town.Text = addressDict["Town"];if (addressDict["County
if (Boolean.Parse(NIDict["Director"])) { director.CheckState = CheckState.Checked; } director.CheckState = CheckState.Unchecked; } if (employmentDict["DateOfJoining"] != null) dateOfJoining.Text = employmentDict["DateOfJoining"];if (employmentDict["ServiceStartDate"] != null) serviceStartDate.Text = employmentDict["ServiceStartDate"]; if (employmentDict["Payroll"] != null) payroll.Text = employmentDict["Payroll"]; if (employmentDict["Workgroup"] != null) workgroup.Text = employmentDict["Workgroup"]; if (employmentDict["HoursCategory } if (addressDict["Postcode"] != null) postcode.Text = addressDict["Postcode"];
if (Boolean.Parse(NIDict["NonCumulativeNI"])) nonCumulativeNI.CheckState = CheckState.Checked; } nonCumulativeNI.CheckState = CheckState.Unchecked; } } directorStartDate.CustomFormat = "yyyy/MM/dd"; } directorStartDate.CustomFormat = " "; } if (paymentDict != null) if (paymentDict["AccountName"] != null) hoursCategoryaccountName.Text = employmentDictpaymentDict["HoursCategoryAccountName"]; if (Boolean.Parse(employmentDict["IrregularPayments"])) irregularPayments.CheckState = CheckState.Checked; } irregularPayments.CheckState = CheckState.Unchecked; } } if (Boolean.Parse(employmentDict["OffPayrollWorker"])) offPayrollWorker.CheckState = CheckState.Checked; } offPayrollWorker.CheckState = CheckState.Unchecked; } } if (employmentDict["ApprenticesortCode.Text = paymentDict["SortCode"]; } if (starterStatementDict != null) if (starterStatementDict["StarterStatement"] != null) if (Boolean.TryParse(employmentDict["Apprentice"], out bool apprentice)) if (apprentice) Apprentice.CheckState = CheckState.Checked; } else { Apprentice.CheckState = CheckState.Unchecked; } Apprentice.CheckState = CheckState.Unchecked; } } if (employmentDict["JobTitlestarterStatement.Text = starterStatementDict["StarterStatement"]; studentLoanBeforeLast6April. Text = employmentDict["JobTitle"];Checked = Boolean.Parse(starterStatementDict["StudentLoanBeforeLast6April"]); } if (p45Dict != null) if ( employmentDictp45Dict[" WorkerPayTypeP45EmployersReference"] != null) workerPayTypep45EmployersReference.Text = employmentDictp45Dict[" WorkerPayTypeP45EmployersReference"]; p45Dict[" ContractedHoursP45LeavingDate"] != null && p45Dict["P45LeavingDate"] != "") {contractedHours p45LeavingDate.CustomFormat = "yyyy/MM/dd"; p45Dict[" ContractedHoursP45LeavingDate"]; } contractedHours p45LeavingDate.CustomFormat = " "; } if (p45Dict["P45PeriodNo"] != null) p45PeriodNo.Text = p45Dict["P45PeriodNo"]; } if ( NIDictp45Dict[" NINumberP45TaxablePay"] != null) niNumberp45TaxablePay.Text = NIDictp45Dict[" NINumberP45TaxablePay"]; p45Dict[" NITableLetterP45TaxPaid"] != null) niTableLetterp45TaxPaid.Text = NIDictp45Dict[" NITableLetterP45TaxPaid"]; p45Dict[" DirectorP45TaxCode"] != null) { if (Boolean.Parse(NIDict["Director"])) { director.CheckState = CheckState.Checked; } director.CheckState = CheckState.Unchecked; } }if (NIDict["NonCumulativeNI p45TaxCode.Text = p45Dict["P45TaxCode"]; { if (Boolean.Parse( NIDictp45Dict[" NonCumulativeNIP45Wk1Mth1"])) p45Wk1Mth1.CheckState = CheckState.Checked; } p45Wk1Mth1.CheckState = CheckState.Unchecked; } } if ( NIDictp45Dict[" DirectorStartDateP45TaxDistrictNo"] != null && NIDict["DirectorStartDate"] != ""){ directorStartDate.CustomFormat = "yyyy/MM/dd"; } directorStartDate.CustomFormat = " "; } if (paymentDict != null) if (paymentDict["AccountName) p45TaxDistrictNo.Text = p45Dict["P45TaxDistrictNo"]; } if ( paymentDicttaxDict != null) if (taxDict["AccountNumberStartDate"] != null) accountNumbertaxStartDate.Text = paymentDicttaxDict["AccountNumberStartDate"]; } if (starterStatementDict != null) if (starterStatementDict["StarterStatement"] != null) starterStatement.Text = starterStatementDict["StarterStatement"]; } if (p45Dict != null) if (p45Dict["P45EmployersReference"] != null) p45EmployersReference.Text = p45Dict["P45EmployersReference"]; { p45LeavingDate.CustomFormat = "yyyy/MM/dd"; } p45LeavingDate.CustomFormat = " "; } if (p45Dict["P45PeriodNo"] != null) p45PeriodNo.Text = p45Dict["P45PeriodNo"]; { if (Boolean.Parse(p45Dict["P45Wk1Mth1"])) p45Wk1Mth1.CheckState = CheckState.Checked; } p45Wk1Mth1.CheckState = CheckState.Unchecked; } } if (p45Dict["P45TaxDistrictNo"] != null) p45TaxDistrictNo.Text = p45Dict["P45TaxDistrictNo"]; } if (taxDict != null) if (taxDict["StartDate"] != null) taxStartDate.Text = taxDict["StartDate"]; { if (Boolean.Parse(taxDict["TaxBasis"])) { taxTaxBasis.CheckState = CheckState.Checked; } taxTaxBasis.CheckState = CheckState.Unchecked; } } } } }{ if (Boolean.Parse(taxDict["TaxBasis"])) { taxTaxBasis.CheckState = CheckState.Checked; } taxTaxBasis.CheckState = CheckState.Unchecked; } } } } } Console.WriteLine("GET person was not successful: " + response2.StatusCode); } if (person == null) output.Text = output.Text + "\r\nGet Person returned null"; } Console.WriteLine("Get Person returned:" + person.ToString()); } } } Console.WriteLine("Exception in Get Person:" + ex); } |
---|
Add a Payment
private void btnAddPayment_Click(object sender, EventArgs e) try
} output.Text = output.Text + "\r\nAuthenticated: " + token.ToString(); Object result = null; //Load scheme details in to request body { new KeyValuePair<string, string>("PayElement", paymentPayElement.Text), }); var requestMessage = new HttpRequestMessage(HttpMethod.Put, url); HttpResponseMessage response2 = client.PutAsync(url, content).Result; { Task<Object> res2 = response2.Content.ReadAsAsync<Object>(); } else { Console.WriteLine(" |
---|
Add Payment was not successful: " + response2.StatusCode); |
---|
nAdd Payment failed: " + response2.StatusCode; } if ( |
---|
result == null) output.Text = output.Text + "\r\ |
---|
nAdd Payment returned null"; } else { Console.WriteLine(" |
---|
Add Payment returned:" + |
---|
result.ToString()); |
---|
nAdd Payment returned:" + |
---|
result.ToString(); } } } catch (Exception ex) { Console.WriteLine("Exception in |
---|
Add Payment:" + ex); } } |
---|
...
Update a Payment
private void |
---|
btnUpdatePayment_Click(object sender, EventArgs e) try { Console.WriteLine(" |
---|
Update Payment clicked"); if (String.IsNullOrEmpty(token)) output.Text = output.Text + "\r\nAuthentication failed "; } else { output.Text = output.Text + "\r\nAuthenticated: " + token.ToString(); Object result = null; |
---|
/Payment/" + employeeID.Text; |
---|
POST to URL: " + url; |
---|
POST to " + url); //Load scheme details in to request body { new KeyValuePair<string, string>("PayElement", paymentPayElement.Text), |
---|
});
var requestMessage = new HttpRequestMessage(HttpMethod.Put, url);requestMessage.Headers.Add("Authorization", "Bearer " + token);
requestMessage.Content = content;
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token
("RateEffectiveDate", paymentRateEffectiveDate.Text) } ); HttpResponseMessage response2 = client. |
---|
PostAsync(url, content).Result; { Task<Object> res2 = response2.Content.ReadAsAsync<Object>(); |
---|
Update Payment result: " + res2.Result); } else { Console.WriteLine(" |
---|
Update was not successful: " + response2.StatusCode); |
---|
nUpdate Payment failed: " + response2.StatusCode; |
---|
nUpdate Payment failed: " + response2.ToString(); |
---|
nUpdate Payment failed: " + response2.ReasonPhrase; } if (result == null) { output.Text = output.Text + "\r\ |
---|
nUpdate Payment returned null"; } else { Console.WriteLine(" |
---|
Update Payment returned:" + result.ToString()); |
---|
nUpdate Payment returned:" + result.ToString(); } } } catch (Exception ex) { Console.WriteLine("Exception in |
---|
}
}
Whilst using the InTime Web Services, some fields have expected values from a range of constants. These are detailed below.
Comment
Update Payment:" + ex); } } |
---|
Delete a Payment
private void btnDeletePayment_Click(object sender, EventArgs e) { try { Console.WriteLine("Delete Payment clicked"); if (String.IsNullOrEmpty(token)) { output.Text = output.Text + "\r\nAuthentication failed "; } else { output.Text = output.Text + "\r\nAuthenticated: " + token.ToString(); Object result = null; output.Text = output.Text + "\r\nDoing DELETE to URL: " + url; HttpResponseMessage response2 = client.DeleteAsync(url).Result; if (response2.IsSuccessStatusCode) { Task<Object> res2 = response2.Content.ReadAsAsync<Object>(); } else { Console.WriteLine("Delete was not successful: " + response2.StatusCode); } if (result == null) { output.Text = output.Text + "\r\nDelete Payment returned null"; } { Console.WriteLine("Delete Payment returned:" + result.ToString()); } } } catch (Exception ex) { Console.WriteLine("Exception in Delete Payment:" + ex); } } |
---|
Whilst using the InPay Web Services, some fields have expected values from a range of constants. These are detailed below.
Field | Constant | Comment | Notes |
---|---|---|---|
Person | |||
Method | CASH | Cash | This is the method of payment |
CHEQUE | Cheque | ||
BACS | Bacs or payment via other banking software | ||
HoursCategory | A | Up to 15.99 | Required for the FPS submission |
B | 24 - 29.99 | ||
C | 30 hrs or more | ||
D | Other | ||
E | 16 - 23.99 | ||
Worker Pay Type | 1 | Salaried | Not Mandatory |
2 | Grade | ||
3 | Hourly | ||
AbsenceDetail | |||
AbsenceType | 1 | Holiday | |
2 | Sickness | ||
AbsenceExt | 1 | Sickness | |
2 | Maternity | ||
3 | Adoption | ||
4 | Paternity Adoption | ||
5 | Paternity Birth | ||
6 | Paid Leave | ||
7 | Shared Parental Leaver Adoption | ||
8 | Shared Parental Leaver Birth | ||
9 | Parental Bereavement |