Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 16 Next »


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 NIDetails = results.Value<JObject>("NIDetail").Properties();
var NIDict = NIDetails.ToDictionary(k => k.Name, v => v.Value.ToString());

Dictionary<string, string> paymentDict;
if (results.Value<JObject>("PaymentDetail") != null)

{

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;

}

}
if (personDict["SMSPayslipNotification"] != null)
{

if (Boolean.Parse(personDict["SMSPayslipNotification"]))
{

smsPayslipNotification.CheckState = CheckState.Checked;

}
else
{

smsPayslipNotification.CheckState = CheckState.Unchecked;

}

}

if (personDict["PostponeDate"] != null && personDict["PostponeDate"] != "")
{

postponeDate.CustomFormat = "yyyy/MM/dd";
postponeDate.Text = personDict["PostponeDate"];

}
else
{

postponeDate.CustomFormat = " ";

}
if (personDict["OptOutDate"] != null && personDict["OptOutDate"] != "")
{


optOutDate.CustomFormat = "yyyy/MM/dd";
optOutDate.Text = personDict["OptOutDate"];

}
else
{

optOutDate.CustomFormat = " ";

}
if (personDict["Method"] != null) method.Text = personDict["Method"];
if (personDict["HolidayScheme"] != null) holidayScheme.Text = personDict["HolidayScheme"];
if (personDict["AccrueDaysOverride"] != null) accrueDaysOverride.Text = personDict["AccrueDaysOverride"];
if (personDict["OSPScheme"] != null) ospScheme.Text = personDict["OSPScheme"];

if (addressDict["Date"] != null && addressDict["Date"] != "")
{

addressDate.CustomFormat = "yyyy/MM/dd";
addressDate.Text = addressDict["Date"];

}
else
{

addressDate.CustomFormat = " ";

}

if (addressDict["AddressLine1"] != null) addressLine1.Text = addressDict["AddressLine1"];
if (addressDict["AddressLine2"] != null) addressLine2.Text = addressDict["AddressLine2"];
if (addressDict["AddressLine3"] != null) addressLine3.Text = addressDict["AddressLine3"];
if (addressDict["Town"] != null) town.Text = addressDict["Town"];
if (addressDict["County"] != null) county.Text = addressDict["County"];
if (addressDict["Postcode"] != null) postcode.Text = addressDict["Postcode"];

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"] != null) hoursCategory.Text = employmentDict["HoursCategory"];
if (employmentDict["IrregularPayments"] != null)
{

if (Boolean.Parse(employmentDict["IrregularPayments"]))
{

irregularPayments.CheckState = CheckState.Checked;

}
else
{

irregularPayments.CheckState = CheckState.Unchecked;

}

}
if (employmentDict["OffPayrollWorker"] != null)
{

if (Boolean.Parse(employmentDict["OffPayrollWorker"]))
{

offPayrollWorker.CheckState = CheckState.Checked;

}
else
{

offPayrollWorker.CheckState = CheckState.Unchecked;

}

}

if (employmentDict["Apprentice"] != null)
{

if (Boolean.TryParse(employmentDict["Apprentice"], out bool apprentice))
{

if (apprentice)
{

Apprentice.CheckState = CheckState.Checked;

}

else

{

Apprentice.CheckState = CheckState.Unchecked;

}
}
else
{

Apprentice.CheckState = CheckState.Unchecked;

}

}

if (employmentDict["JobTitle"] != null) strtJobTitle.Text = employmentDict["JobTitle"];
if (employmentDict["WorkerPayType"] != null) workerPayType.Text = employmentDict["WorkerPayType"];

if (employmentDict["ContractedHours"] != null)
{

contractedHours.Text = employmentDict["ContractedHours"];

}
else
{

contractedHours.Text = "";

}

if (NIDict["NINumber"] != null) niNumber.Text = NIDict["NINumber"];
if (NIDict["NITableLetter"] != null) niTableLetter.Text = NIDict["NITableLetter"];
if (NIDict["Director"] != null)
{

if (Boolean.Parse(NIDict["Director"]))

{

director.CheckState = CheckState.Checked;

}
else
{

director.CheckState = CheckState.Unchecked;

}

}
if (NIDict["NonCumulativeNI"] != null)
{

if (Boolean.Parse(NIDict["NonCumulativeNI"]))
{

nonCumulativeNI.CheckState = CheckState.Checked;

}
else
{

nonCumulativeNI.CheckState = CheckState.Unchecked;

}

}
if (NIDict["DirectorStartDate"] != null && NIDict["DirectorStartDate"] != "")
{

directorStartDate.CustomFormat = "yyyy/MM/dd";
directorStartDate.Text = NIDict["DirectorStartDate"];

}
else
{

directorStartDate.CustomFormat = " ";

}

if (paymentDict != null)
{

if (paymentDict["AccountName"] != null) accountName.Text = paymentDict["AccountName"];
if (paymentDict["AccountNumber"] != null) accountNumber.Text = paymentDict["AccountNumber"];
if (paymentDict["SortCode"] != null) sortCode.Text = paymentDict["SortCode"];
if (paymentDict["RollNumber"] != null) rollNumber.Text = paymentDict["RollNumber"];

}

if (starterStatementDict != null)
{

if (starterStatementDict["StarterStatement"] != null) starterStatement.Text = starterStatementDict["StarterStatement"];
if (starterStatementDict["StudentLoanPlanType"] != null) studentLoanPlanType.Text = starterStatementDict["StudentLoanPlanType"];
if (starterStatementDict["StudentLoanRepayDirectly"] != null) studentLoanRepayDirectly.Checked = Boolean.Parse(starterStatementDict["StudentLoanRepayDirectly"]);
if (starterStatementDict["StudentLoanBeforeLast6April"] != null) studentLoanBeforeLast6April.Checked = Boolean.Parse(starterStatementDict["StudentLoanBeforeLast6April"]);

}

if (p45Dict != null)
{

if (p45Dict["P45EmployersReference"] != null) p45EmployersReference.Text = p45Dict["P45EmployersReference"];
if (p45Dict["P45LeavingDate"] != null && p45Dict["P45LeavingDate"] != "")

{

p45LeavingDate.CustomFormat = "yyyy/MM/dd";
p45LeavingDate.Text = p45Dict["P45LeavingDate"];

}
else
{

p45LeavingDate.CustomFormat = " ";

}

if (p45Dict["P45PeriodNo"] != null) p45PeriodNo.Text = p45Dict["P45PeriodNo"];
if (p45Dict["P45TaxablePay"] != null) p45TaxablePay.Text = p45Dict["P45TaxablePay"];
if (p45Dict["P45TaxPaid"] != null) p45TaxPaid.Text = p45Dict["P45TaxPaid"];
if (p45Dict["P45TaxCode"] != null) p45TaxCode.Text = p45Dict["P45TaxCode"];
if (p45Dict["P45Wk1Mth1"] != null)

{

if (Boolean.Parse(p45Dict["P45Wk1Mth1"]))
{

p45Wk1Mth1.CheckState = CheckState.Checked;

}
else
{

p45Wk1Mth1.CheckState = CheckState.Unchecked;

}

}

if (p45Dict["P45TaxDistrictNo"] != null) p45TaxDistrictNo.Text = p45Dict["P45TaxDistrictNo"];
if (p45Dict["P45PayFrequency"] != null) p45PayFrequency.Text = p45Dict["P45PayFrequency"];

}

if (taxDict != null)
{

if (taxDict["StartDate"] != null) taxStartDate.Text = taxDict["StartDate"];
if (taxDict["TaxCode"] != null) taxTaxCode.Text = taxDict["TaxCode"];
if (taxDict["TaxBasis"] != null)

{

if (Boolean.Parse(taxDict["TaxBasis"]))

{

taxTaxBasis.CheckState = CheckState.Checked;

}
else
{

taxTaxBasis.CheckState = CheckState.Unchecked;

}

}

}

}

}
else
{

Console.WriteLine("GET person was not successful: " + response2.StatusCode);
output.Text = output.Text + "\r\nGet person failed: " + response2.StatusCode;

}

if (person == null)
{

output.Text = output.Text + "\r\nGet Person returned null";

}
else
{

Console.WriteLine("Get Person returned:" + person.ToString());
output.Text = output.Text + ".\r\nGet Person returned:" + person.ToString();

}

}

}
catch (Exception ex)
{

Console.WriteLine("Exception in Get Person:" + ex);

}
}



Add a Payment

private void btnAddPayment_Click(object sender, EventArgs e)
{

try
{


Console.WriteLine("Add Payment clicked");
output.Text = "";
var token = Authenticate();


if (String.IsNullOrEmpty(token))
{


output.Text = output.Text + "\r\nAuthentication failed ";

}
else
{

output.Text = output.Text + "\r\nAuthenticated: " + token.ToString();

Object result = null;
string url = restURL.Text + "api/Payment/" + employeeID.Text;
output.Text = output.Text + "\r\nDoing PUT to URL: " + url;
Console.WriteLine("About to PUT to " + url);

//Load scheme details in to request body
FormUrlEncodedContent content = new FormUrlEncodedContent(new[]

{

new KeyValuePair<string, string>("PayElement", paymentPayElement.Text),
new KeyValuePair<string, string>("StartDate", paymentStartDate.Text),
new KeyValuePair<string, string>("EndDate", paymentEndDate.Text),
new KeyValuePair<string, string>("AnnualAmount", annualAmount.Text),
new KeyValuePair<string, string>("PeriodAmount", periodAmount.Text),
new KeyValuePair<string, string>("Balance", balance.Text),
new KeyValuePair<string, string>("RateEffectiveDate", paymentRateEffectiveDate.Text)

});

var requestMessage = new HttpRequestMessage(HttpMethod.Put, url);
requestMessage.Headers.Add("Authorization", "Bearer " + token);
requestMessage.Content = content;
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

HttpResponseMessage response2 = client.PutAsync(url, content).Result;
if (response2.IsSuccessStatusCode)

{

Task<Object> res2 = response2.Content.ReadAsAsync<Object>();
Console.WriteLine("Add Payment result: " + res2.Result);
result = res2.Result;

}

else

{

Console.WriteLine("Add Payment was not successful: " + response2.StatusCode);
output.Text = output.Text + "\r\nAdd Payment failed: " + response2.StatusCode;
output.Text = output.Text + "\r\nAdd Payment failed: " + response2.ToString();
output.Text = output.Text + "\r\nAdd Payment failed: " + response2.ReasonPhrase;

}

if (result == null)
{

output.Text = output.Text + "\r\nAdd Payment returned null";

}

else

{

Console.WriteLine("Add Payment returned:" + result.ToString());
output.Text = output.Text + ".\r\nAdd Payment returned:" + result.ToString();

}

}

}

catch (Exception ex)

{

Console.WriteLine("Exception in Add Payment:" + ex);

}

}


Whilst using the InTime Web Services, some fields have expected values from a range of constants. These are detailed below.

FieldConstant

Comment

Notes
Client


invoice period0Weekly

1Two-Weekly

2Four-Weekly

3Calendar Monthly

44-4-5




Worker


workerTypepayeFor PAYE Workers

ltdFor Ltd Company Workers

external-contractorFor Non Ltd Company Workers

cisFor CIS Workers

umbFor Workers operating through an UmbrellaYou must specify the umbrella against the worker, otherwise the worker will appear as LTD.




cisBusinessTypeSoleTrader


Company


Trust


Partnership





cisPercentage0


20


30





paymentFrequencyweekly


monthly


<InPay Payroll Name>If InPay connected, for PAYE workers, use the InPay Payroll Name




timesheetsOnInvoices0Timesheets On Invoices

1Timesheets Not On Invoices




paperOnInvoices-1Agency Default

0No Attachments

1Attach Paper Timesheets

2Attach Expense Group Paper

4Attach Expense Receipts Paper

<sum of the above>Attach the appropriate paperFor example, 5 to attach timesheets and receipts




genderM


F


UUnkown




LTD invoice period0Weekly

1Two-Weekly

2Four-Weekly

3Calendar Monthly

44-4-5




Payment Methodbacs


cheque


cash


chaps


ach


international


building society





Placement


layoutstandard
See Maintaining Placements

calendar





timesheetDateCalculatorweekly
See Maintaining Placements. You can see all possible values for this in the ui.

monthly


<many more>See UI for all options.




Rates


period60For hourly rates entered in hours format (hours only or start, break, finish).

1440For fixed rates of a specified duration entered in decimal format (decimal or tickbox)




periodDuration<any integer>The duration in minutes for the fixed rate (e.g. 60 for hours, 480 for a day).




timePatterndefaultWill use the selected default time pattern

<any string>The string should match the name of a time pattern in the system




timesheetFieldsSTART_FINISH_BREAKEnter start, break, finishOnly when period above is 60

HOURSEnter hours onlyOnly when period above is 60

DECIMALEnter time as a decimalOnly when period above is 1440

DAYTickbox only (equivalent to entering decimals as 1.00)Only when period above is 1440
  • No labels