Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


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.  

...

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);

}

}

Update a Payment

private void btnUpdatePayment_Click(object sender, EventArgs e)
{

try

{

Console.WriteLine("Update 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();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

Object result = null;
string url = restURL.Text + "api/Payment/" + employeeID.Text;
url += "/" + paymentPayElement.Text + "/" + paymentStartDate.Text.Replace("/", "-");
output.Text = output.Text + "\r\nDoing POST to URL: " + url;
Console.WriteLine("About to POST 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)

}

);

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

{

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

}

else

{

Console.WriteLine("Update was not successful: " + response2.StatusCode);
output.Text = output.Text + "\r\nUpdate Payment failed: " + response2.StatusCode;
output.Text = output.Text + "\r\nUpdate Payment failed: " + response2.ToString();
output.Text = output.Text + "\r\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());
output.Text = output.Text + ".\r\nUpdate Payment returned:" + result.ToString();

}

}

}

catch (Exception ex)

{

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

}

}

Delete a Payment

private void btnDeletePayment_Click(object sender, EventArgs e)

{

try

{

Console.WriteLine("Delete 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();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

Object result = null;
string url = restURL.Text + "api/Payment/" + employeeID.Text;
url += "/" + paymentPayElement.Text + "/" + paymentStartDate.Text.Replace("/", "-");

output.Text = output.Text + "\r\nDoing DELETE to URL: " + url;
Console.WriteLine("About to DELETE to " + url);

HttpResponseMessage response2 = client.DeleteAsync(url).Result;

if (response2.IsSuccessStatusCode)

{

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

}

else

{

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

}

if (result == null)

{

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

}
else

{

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

}

}

}

catch (Exception ex)

{

Console.WriteLine("Exception in Delete 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