This method uploads batch disbursement transactions using Microsoft Excel (.xlsx) or CSV files. For payload explanations for both request and response, click here
using OneKhusa.SDK; 
using OneKhusa.SDK.Models.Transactions.BatchDisbursements; 
using OneKhusa.SDK.Models.Constants.Shared; 
 
//code omitted for brevity 

OneKhusaResponse<UploadBatchFileResponse> response = await client 
    .Transactions 
    .BatchDisbursements 
    .UploadFileAsync(new UploadBatchFileRequest 
    { 
        MerchantAccountNumber = 12345678, 
        ContentType = ContentTypes.MicrosoftExcel, 
        IsBatchScheduled = false, 
        FileContent = File.ReadAllBytes(@"file-directory\batch_payouts.xlsx"), 
        CapturedBy = "joe.doe@example.com" 
    }); 

if (response is { IsSuccess: true, Data: not null }) 
{ 
    Console.WriteLine($""" 
        MerchantAccountNumber: {response.Data.MerchantAccountNumber};  
        BatchNumber: {response.Data.BatchNumber};
        BatchStatusCode: {response.Data. BatchStatusCode};
    """); 
    Console.ReadLine(); 
    return; 
} 
//it means an error has occurred: RFC7807 compliant error object
Console.WriteLine($"""
        Type: {response.Error?.Type};
        Title: {response.Error?.Title};
        Detail: {response.Error?.Detail};
        ErrorCode: {response.Error?.ErrorCode};
        Status: {response.Error?.Status};
        Instance: {response.Error?.Instance};
        Errors: {string.Join(";", response.Error?.Errors ?? [])}
""");
Console.ReadLine(); 
Note:
  • This method accepts custom idempotency key generated by your system. By default, if not specified, it will create one on your behalf.
  • To schedule the batch, set IsBatchScheduled to true and set future date to ScheduledDate.
  • Use streaming approach to improve performance when reading large files to avoid API request timeouts.