Paperflow offers multiple ways of uploading vouchers to our system. The quickest and easiest way is via mail upload - this is done by simply sending an email with an attached voucher file to the 'mail_forward_address' of the organization. Although this is very easy to set up we generally do recommend using our API endpoint when uploading vouchers since it gives you more flexibility by allowing an optional voucher note, user payment type, and even a callback URL.
We have attached a simple C# example (works with .NET CORE also) that takes a file, converts it to base64, and uploads it to a specific organization. Please note that the VoucherRequest class has multiple properties which are all optional (except VoucherData) that allow for easier integration between Bilagscan and your system. For example, if you send a Note when uploading the voucher that voucher will have a note property when viewing its data (same with ErpFolderId).
It is also possible to send a callback url with the voucher, this is explained in more detail (link to callback URL)
internal class Program {
private static void Main(string[] args) {
new Program().UploadVoucher().Wait();
}
private readonly string _accessToken = "myAccessToken";
public async Task UploadVoucher() {
var fileSrc = @ "C:\Users\Thorup's Mac\Desktop\48.pdf";
var fileBytes = Convert.ToBase64String(File.ReadAllBytes(fileSrc));
var voucherRequest = new VoucherRequest {
VoucherData = fileBytes
};
var organizationId = 3435;
var serializedRequest = JsonConvert.SerializeObject(voucherRequest);
using(var client = new HttpClient()) {
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _accessToken);
var content = new StringContent(serializedRequest, Encoding.UTF8, "application/json");
var response = await client.PostAsync(
$ "https://api.bilagscan.dk/v1/organizations/{organizationId}/vouchers", content);
var res = await response.Content.ReadAsStringAsync();
Console.WriteLine(res);
}
}
public class VoucherRequest {
[JsonProperty(PropertyName = "voucher_data")]
public string VoucherData {
get;
set;
}
[JsonProperty(PropertyName = "callback_url")]
public string CallbackUrl {
get;
set;
}
[JsonProperty(PropertyName = "note")]
public string Note {
get;
set;
}
[JsonProperty(PropertyName = "erp_project_id")]
public string ErpFolderId {
get;
set;
}
}
}
Comments
0 comments
Please sign in to leave a comment.