Click or drag to resize

AdministrationClientLoadTransactionBatch Method

Submitting a single file or multiple files containing Transactions.

If more than 1 file is being submitted, the set the value for BatchOStagingTransaction.Final = 1

Optimum number of Transaction rows per file is 20.

This method is a step in the workflow for Transaction File Batch submission.

Remarks
Transaction File Batch submission workflow:
  • Initialise Batch - call Web Service Method: OpenTransactionBatch
  • Submit Transaction File(s) - call Web Service Method: LoadTransactionBatch
  • Monitor submitted Transaction Batch Progress - call Web Service Method: QueryTransactionBatch
  • Stop The Transaction Batch Processing - call Web Service Method: CancelTransactionBatch
  • Analyse the final results of The Transaction Batch Processing - call Web Service Method: ReportTransactionBatch
Syntax
C#
public ResultOfBatch LoadTransactionBatch(
	ManagementGroupRequestOfBatchOfStagingTransaction LoadBatch
)

Parameters

LoadBatch
Type: AdministrationServiceManagementGroupRequestOfBatchOfStagingTransaction

Return Value

Type: ResultOfBatch
Examples
C#
using (var svc = new AdministrationService.AdministrationClient())
{
  var request = new AdministrationService.ManagementGroupRequestOfBatchOfStagingTransaction();
  request.Token = "Token";//Required - Token returned from AccountService.ManagementGroupLogin
  request.ManagementGroup = "Management group";//Required - ManagementGroup supplied when calling AccountService.ManagementGroupLogin

  var stagingTransactionList = new List<AdministrationService.StagingTransaction>();

  var batch_RSN = new Guid("95ebf05d-3176-43c9-a109-31772542273f");;//Returned from AdministrationService.OpenTransactionBatch (ResultOfBatch.Key)

  for (int i = 0; i < 50; i++) // loop through records for batch creation eg. 50 records
  {
    var stagingTransaction = new AdministrationService.StagingTransaction();
    stagingTransaction.BatchControl_RSN = batch_RSN;//Required - Returned from AdministrationService.OpenTransactionBatch (ResultOfBatch.Key)
    stagingTransaction.CardNumber = "21000005"; //Required
    stagingTransaction.Card_RSN = new Guid("14c59173-ec87-438a-9572-0191ac685fb4");;//Optional - RSN of card
    stagingTransaction.ImportFile_Row_Number = 0;//Optional
    stagingTransaction.ItemDescription = "";//Optional
    stagingTransaction.Organisation_RSN = new Guid("b621dd24-7819-4377-8c5d-3f784f72917c");;//Optional
    stagingTransaction.Product_RSN = new Guid("fc7203af-bc1b-476f-a4f2-c0e4debce876");;//Optional
    stagingTransaction.TransactionItem_RSN = new Guid("0d7dfb36-e50b-4554-adc6-01542ea9e8c1");;//Optional
    stagingTransaction.TransactionSet_RSN = new Guid("8ac502c3-1cc8-44f3-8d5a-24984733aa92");;//Optional
    stagingTransaction.Transaction_RSN = new Guid("2cdcdf3c-5463-4633-854a-3e855fb1fae2");;//Optional
    stagingTransaction.TransactionType = "Adjustment"; //Required - Valid values are : 'Adjustment', 'Bonus', 'Payment', 'Reward', 'Sale', 'Store Topup', 'Points Redemption', 'Voucher Redemption', 'Activity' or 'Pre Load' (case sensitive)";
    stagingTransaction.TransactionDate = DateTime.Now; //Required - cannot be a future date
    stagingTransaction.TransactionID = "Transaction ID"; //Optional - Must be unique. Will be generated if not supplied
    stagingTransaction.Points = 20.85M; //Required

    stagingTransaction.PartnerID = string.Empty; //Optional
    stagingTransaction.Reference = "REF_123";//Optional
    stagingTransaction.AdjustmentType = "Goodwill";//Optional
    stagingTransaction.AdjustmentReason = "Item not satisfactory";//Optional
    stagingTransaction.AdjustmentReasonNote = "Item needs repair";//Optional
    stagingTransaction.AdjustmentInternalNote = "Customer returning item";//Optional
    stagingTransaction.TransactionNotes = "Please process transaction with haste"; //Optional
    stagingTransaction.BrandName = string.Empty; //Optional
    stagingTransaction.ProductCode = "Product_123"; //Optional
    stagingTransaction.CategoryCode = string.Empty; //Optional
    stagingTransaction.CategoryName = string.Empty; //Optional
    stagingTransaction.DepartmentCode = string.Empty; //Optional
    stagingTransaction.DepartmentName = string.Empty; //Optional
    stagingTransaction.TerminalID = "Terminal_ID_1 ID"; //Optional
    stagingTransaction.Quantity = 2; //Optional
    stagingTransaction.Value = 10.55M; //Optional
    stagingTransaction.Value2 = 15.5M; //Optional
    stagingTransaction.PointsPending = 0; //Optional
    stagingTransaction.VoucherCode = string.Empty; //Optional 

    //Optional Custom Values
    var profileCustomFieldValues = new AdministrationService.ProfileCustomFieldValues();
    profileCustomFieldValues.CustomText_1 = string.Empty; //Optional CustomText_2 - CustomText_15 available
    profileCustomFieldValues.CustomBoolean_1 = false; //Optional CustomBoolean_2 - CustomBoolean_20 available
    profileCustomFieldValues.CustomDate_1 = DateTime.MinValue; //Optional CustomDate_2 - CustomDate_15 available
    profileCustomFieldValues.CustomDecimal_1 = 0.0M; //Optional CustomDecimal_2 - CustomDecimal_5 available
    profileCustomFieldValues.CustomInteger_1 = 0; //Optional CustomInteger_2 - CustomInteger_10 available
    stagingTransaction.CustomFieldValues = profileCustomFieldValues;

    stagingTransactionList.Add(stagingTransaction);
  }

  bool endOfData = false;
  int j = 0;
  int rowCount = 0;
  while (endOfData == false)
  {
    var stagingTransactions = stagingTransactionList.Skip(j * 20).Take(20); //It is recommend to queue around 20 records per call

    rowCount += stagingTransactions.Count();
    j++;

    var batchOfStagingTransaction = new AdministrationService.BatchOfStagingTransaction();
    batchOfStagingTransaction.Items = stagingTransactions.ToArray(); //Required
    batchOfStagingTransaction.Key = batch_RSN; //Required - Returned from AdministrationService.OpenTransactionBatch (ResultOfBatch.Key)

    if (rowCount == stagingTransactionList.Count) // check if this is the last batch of records to send to service
    {
      endOfData = true; // flag to exit loop
      batchOfStagingTransaction.Final = true; //Set to true when you have finished loading items into a batch.
    }

    // add batchOfStagingMember to request
    request.Value = batchOfStagingTransaction;//Required

    AdministrationService.ResultOfBatch result = svc.LoadTransactionBatch(request);

    if (result.FaultCode == 0)
    {

    }
    else
    {
      endOfData = true; // flag to exit loop

      //Request failed
      throw new Exception(result.FaultDescription);
    }
  }
}
See Also