Ejemplo n.º 1
0
 /// <summary>
 /// Updates tender as complete. Throws an exception if data is invalid
 /// </summary>
 /// <param name="tender"></param>
 /// <param name="order"></param>
 void UpdateTender(ref Tender tender, Order order)
 {
     var uri = String.Format("{0}/api/tenders/{1}?key={2}", BaseUri, tender.Id, ApiKey);
     tender.TenderState = TenderState.CompleteSuccessful;
     var r = JsonConvert.DeserializeObject<PATResponse>(PutJsonString(uri, JsonConvert.SerializeObject(new PATRequest() { Tender = tender }), DebugTrace));
     if (r.Tender == null)
         throw new Exception("No tender in PUT response");
     // Update our tender with the details from the response
     tender = r.Tender;
     Console.WriteLine("Tender updated");
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Create a "DoTransaction" EFTPOS command, throws an exception if data is invalid
 /// </summary>
 /// <param name="eftposRequestCommand"></param>
 /// <param name="tender"></param>
 void CreateEFTPOSRequest(ref EFTPOSCommand eftposRequestCommand, Tender tender)
 {
     var uri = String.Format("{0}/api/eftpos/commands?key={1}", BaseUri, ApiKey);
     eftposRequestCommand = new EFTPOSCommand() { EFTPOSCommandType = EFTPOSCommandType.DoTransaction, TenderId = tender.Id, AmtPurchase = tender.AmountPurchase, TxnType = "P", TxnRef = String.Format("{0:yyddMMHHmmsszzz}", DateTime.Now) };
     var r = JsonConvert.DeserializeObject<PATResponse>(PostJsonString(uri, JsonConvert.SerializeObject(new PATRequest() { EFTPOSCommand = eftposRequestCommand }), DebugTrace));
     if (r.EFTPOSCommand == null)
         throw new Exception("No EFTPOSCommand in POST response");
     Console.WriteLine("DoTransaction EFTPOSCommand Created");
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Create a tender, throws an exception if data is invalid
 /// </summary>
 /// <param name="tender"></param>
 /// <param name="tenderOption"></param>
 void CreateTender(ref Tender tender, TenderOption tenderOption, Order order)
 {
     tender = new Tender() { AmountPurchase = order.AmountOwing, OriginalAmountPurchase = order.AmountOwing, TenderState = TenderState.Pending, OrderId = order.Id };
     var uri = String.Format("{0}/api/tenders?key={1}", BaseUri, ApiKey);
     var r = JsonConvert.DeserializeObject<PATResponse>(PostJsonString(uri, JsonConvert.SerializeObject(new PATRequest() { Tender = tender }), DebugTrace));
     if (r.Tender == null)
         throw new Exception("No tender in POST response");
     // Update our tender with the details from the response
     tender = r.Tender;
     Console.WriteLine("Tender created");
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Create a "TransactionEvent" EFTPOS command, throws an exception if data is invalid
 /// </summary>
 /// <param name="eftposEventCommand"></param>
 /// <param name="eftposRequestCommand"></param>
 /// <param name="tender"></param>
 void CreateEFTPOSEvent(ref EFTPOSCommand eftposEventCommand, EFTPOSCommand eftposRequestCommand, Tender tender)
 {
     var uri = String.Format("{0}/api/eftpos/commands?key={1}", BaseUri, ApiKey);
     eftposEventCommand = new EFTPOSCommand()
     {
         EFTPOSCommandType = EFTPOSCommandType.TransactionEvent,
         TenderId = tender.Id,
         OriginalEFTPOSCommandId = eftposRequestCommand.Id,
         AmtPurchase = eftposRequestCommand.AmtPurchase,
         TxnType = "P",
         STAN = "26",
         ResponseType = "210",
         Caid = "000008156005003",
         Catid = "00000000",
         Date = "000000",
         Time = "000000",
         ResponseCode = "00",
         ResponseText = "APPROVED",
         Merchant = "0",
         Success = true,
         AccountType = "Credit",
         CardType = "DEBIT CARD AC",
         CardName = "00",
         TxnRef = eftposRequestCommand.TxnRef,
         DateSettlement = "000000",
         AuthCode = "000023",
         CsdReservedBool1 = false,
         Rrn = "000000000023",
         Track2 = "4343000000000005=0101?",
         Pan = "4343000000000005"
     };
     var r = JsonConvert.DeserializeObject<PATResponse>(PostJsonString(uri, JsonConvert.SerializeObject(new PATRequest() { EFTPOSCommand = eftposEventCommand }), DebugTrace));
     if (r.EFTPOSCommand == null)
         throw new Exception("No EFTPOSCommand in POST response");
     Console.WriteLine("TransactionEvent EFTPOSCommand Created");
 }