/// <summary> /// Submit bankers order /// </summary> /// <param name="connectionDetails">ConnectionDetails object must atleast contain the fields: Url, HBCIVersion, UserId, Pin, Blz, IBAN, BIC, AccountHolder</param> /// <param name="mobileServiceProvider"></param> /// <param name="phoneNumber"></param> /// <param name="amount"></param> /// <param name="receiverName"></param> /// <param name="receiverIBAN"></param> /// <param name="receiverBIC"></param> /// <param name="amount">Amount to transfer</param> /// <param name="purpose">Short description of the transfer (dt. Verwendungszweck)</param> /// <param name="firstTimeExecutionDay"></param> /// <param name="timeUnit"></param> /// <param name="rota"></param> /// <param name="executionDay"></param> /// <param name="HIRMS">Numerical SecurityMode; e.g. 972 for "Sparkasse chipTan optisch"</param> /// <param name="pictureBox">Picturebox which shows the TAN</param> /// <param name="anonymous"></param> /// <returns> /// Bank return codes /// </returns> public static string SubmitBankersOrder(ConnectionDetails connectionDetails, string receiverName, string receiverIBAN, string receiverBIC, decimal amount, string purpose, DateTime firstTimeExecutionDay, HKCDE.TimeUnit timeUnit, string rota, int executionDay, string HIRMS, PictureBox pictureBox, bool anonymous) { if (Transaction.INI(connectionDetails, anonymous) == true) { TransactionConsole.Output = string.Empty; if (!String.IsNullOrEmpty(HIRMS)) { Segment.HIRMS = HIRMS; } var BankCode = Transaction.HKCDE(connectionDetails, receiverName, receiverIBAN, receiverBIC, amount, purpose, firstTimeExecutionDay, timeUnit, rota, executionDay); if (BankCode.Contains("+0030::")) { Helper.Parse_BankCode(BankCode, pictureBox); return("OK"); } else { var msg = Helper.Parse_BankCode_Error(BankCode); Log.Write(msg); return(msg); } } else { return("Error"); } }
internal async Task <HBCIDialogResult> InitializeConnection(string hkTanSegmentId = "HKIDN") { HBCIDialogResult result; string BankCode; // Check if the user provided a SystemID if (ConnectionDetails.CustomerSystemId == null) { result = await Synchronization(); if (!result.IsSuccess) { Log.Write("Synchronisation failed."); return(result); } } else { SystemId = ConnectionDetails.CustomerSystemId; } BankCode = await Transaction.INI(this, hkTanSegmentId); var bankMessages = Helper.Parse_BankCode(BankCode); result = new HBCIDialogResult(bankMessages, BankCode); if (!result.IsSuccess) { Log.Write("Initialisation failed: " + result); } return(result); }
/// <summary> /// Get terminated transfers /// </summary> /// <returns> /// Banker's orders /// </returns> public async Task <HBCIDialogResult> GetTerminatedTransfers(TANDialog tanDialog) { var result = await InitializeConnection(); if (!result.IsSuccess) { return(result); } result = await ProcessSCA(result, tanDialog); if (!result.IsSuccess) { return(result); } // Success string BankCode = await Transaction.HKCSB(this); result = new HBCIDialogResult(Helper.Parse_BankCode(BankCode), BankCode); if (!result.IsSuccess) { return(result); } result = await ProcessSCA(result, tanDialog); return(result); }
/// <summary> /// Collective collect money from other accounts /// </summary> /// <param name="connectionDetails">ConnectionDetails object must atleast contain the fields: Url, HBCIVersion, UserId, Pin, Blz, IBAN, BIC, AccountHolder</param> /// <param name="settlementDate"></param> /// <param name="painData"></param> /// <param name="numberOfTransactions"></param> /// <param name="totalAmount"></param> /// <param name="HIRMS">Numerical SecurityMode; e.g. 972 for "Sparkasse chipTan optisch"</param> /// <param name="pictureBox">Picturebox which shows the TAN</param> /// <param name="anonymous"></param> /// <returns> /// Bank return codes /// </returns> public static string CollectiveCollect(ConnectionDetails connectionDetails, DateTime settlementDate, List <pain00800202_cc_data> painData, string numberOfTransactions, decimal totalAmount, string HIRMS, PictureBox pictureBox, bool anonymous) { if (Transaction.INI(connectionDetails, anonymous) == true) { TransactionConsole.Output = string.Empty; if (!String.IsNullOrEmpty(HIRMS)) { Segment.HIRMS = HIRMS; } var BankCode = Transaction.HKDME(connectionDetails, settlementDate, painData, numberOfTransactions, totalAmount); if (BankCode.Contains("+0030::")) { Helper.Parse_BankCode(BankCode, pictureBox); return("OK"); } else { var msg = Helper.Parse_BankCode_Error(BankCode); Log.Write(msg); return(msg); } } else { return("Error"); } }
/// <summary> /// Request tan medium name /// </summary> /// <param name="connectionDetails">ConnectionDetails object must atleast contain the fields: Url, HBCIVersion, UserId, Pin, Blz</param> /// <returns> /// TAN Medium Name /// </returns> public async Task <HBCIDialogResult <List <string> > > RequestTANMediumName() { HKTAN.SegmentId = "HKTAB"; HBCIDialogResult result = await InitializeConnection(); if (!result.IsSuccess) { return(result.TypedResult <List <string> >()); } // Should not be needed when processing HKTAB //result = ProcessSCA(connectionDetails, result, tanDialog); //if (!result.IsSuccess) // return result.TypedResult<List<string>>(); string BankCode = await Transaction.HKTAB(this); result = new HBCIDialogResult <List <string> >(Helper.Parse_BankCode(BankCode), BankCode); if (!result.IsSuccess) { return(result.TypedResult <List <string> >()); } // Should not be needed when processing HKTAB //result = ProcessSCA(connectionDetails, result, tanDialog); //if (!result.IsSuccess) // return result.TypedResult<List<string>>(); BankCode = result.RawData; string BankCode_ = "HITAB" + Helper.Parse_String(BankCode, "'HITAB", "'"); return(result.TypedResult(Helper.Parse_TANMedium(BankCode_))); }
/// <summary> /// Rebook money from one to another account /// </summary> /// <param name="connectionDetails">ConnectionDetails object must atleast contain the fields: Url, HBCIVersion, UserId, Pin, Blz, IBAN, BIC, AccountHolder</param> /// <param name="receiverName">Name of the recipient</param> /// <param name="receiverIBAN">IBAN of the recipient</param> /// <param name="receiverBIC">BIC of the recipient</param> /// <param name="amount">Amount to transfer</param> /// <param name="purpose">Short description of the transfer (dt. Verwendungszweck)</param> /// <param name="HIRMS">Numerical SecurityMode; e.g. 972 for "Sparkasse chipTan optisch"</param> /// <param name="pictureBox">Picturebox which shows the TAN</param> /// <param name="anonymous"></param> /// <returns> /// Bank return codes /// </returns> public static string Rebooking(ConnectionDetails connectionDetails, string receiverName, string receiverIBAN, string receiverBIC, decimal amount, string purpose, string HIRMS, PictureBox pictureBox, bool anonymous) { if (Transaction.INI(connectionDetails, anonymous) == true) { TransactionConsole.Output = string.Empty; if (!String.IsNullOrEmpty(HIRMS)) { Segment.HIRMS = HIRMS; } var BankCode = Transaction.HKCUM(connectionDetails, receiverName, receiverIBAN, receiverBIC, amount, purpose); if (BankCode.Contains("+0030::")) { Helper.Parse_BankCode(BankCode, pictureBox); return("OK"); } else { var msg = Helper.Parse_BankCode_Error(BankCode); Log.Write(msg); return(msg); } } else { return("Error"); } }
/// <summary> /// Collect money from another account /// </summary> /// <param name="connectionDetails">ConnectionDetails object must atleast contain the fields: Url, HBCIVersion, UserId, Pin, Blz, IBAN, BIC, AccountHolder</param> /// <param name="payerName">Name of the payer</param> /// <param name="payerIBAN">IBAN of the payer</param> /// <param name="payerBIC">BIC of the payer</param> /// <param name="amount">Amount to transfer</param> /// <param name="purpose">Short description of the transfer (dt. Verwendungszweck)</param> /// <param name="settlementDate"></param> /// <param name="mandateNumber"></param> /// <param name="mandateDate"></param> /// <param name="creditorIdNumber"></param> /// <param name="HIRMS">Numerical SecurityMode; e.g. 972 for "Sparkasse chipTan optisch"</param> /// <param name="pictureBox">Picturebox which shows the TAN</param> /// <param name="anonymous"></param> /// <returns> /// Bank return codes /// </returns> public static string Collect(ConnectionDetails connectionDetails, string payerName, string payerIBAN, string payerBIC, decimal amount, string purpose, DateTime settlementDate, string mandateNumber, DateTime mandateDate, string creditorIdNumber, string HIRMS, PictureBox pictureBox, bool anonymous) { if (Transaction.INI(connectionDetails, anonymous) == true) { TransactionConsole.Output = string.Empty; if (!String.IsNullOrEmpty(HIRMS)) { Segment.HIRMS = HIRMS; } var BankCode = Transaction.HKDSE(connectionDetails, payerName, payerIBAN, payerBIC, amount, purpose, settlementDate, mandateNumber, mandateDate, creditorIdNumber); if (BankCode.Contains("+0030::")) { Helper.Parse_BankCode(BankCode, pictureBox); return("OK"); } else { var msg = Helper.Parse_BankCode_Error(BankCode); Log.Write(msg); return(msg); } } else { return("Error"); } }
/// <summary> /// Load mobile phone prepaid card /// </summary> /// <param name="connectionDetails">ConnectionDetails object must atleast contain the fields: Url, HBCIVersion, UserId, Pin, Blz, IBAN, BIC</param> /// <param name="mobileServiceProvider"></param> /// <param name="phoneNumber"></param> /// <param name="amount">Amount to transfer</param> /// <param name="HIRMS">Numerical SecurityMode; e.g. 972 for "Sparkasse chipTan optisch"</param> /// <param name="pictureBox">Picturebox which shows the TAN</param> /// <param name="anonymous"></param> /// <returns> /// Bank return codes /// </returns> public static string Prepaid(ConnectionDetails connectionDetails, int mobileServiceProvider, string phoneNumber, int amount, string HIRMS, PictureBox pictureBox, bool anonymous) { if (Transaction.INI(connectionDetails, anonymous) == true) { TransactionConsole.Output = string.Empty; if (!String.IsNullOrEmpty(HIRMS)) { Segment.HIRMS = HIRMS; } var BankCode = Transaction.HKPPD(connectionDetails, mobileServiceProvider, phoneNumber, amount); if (BankCode.Contains("+0030::")) { Helper.Parse_BankCode(BankCode, pictureBox); return("OK"); } else { var msg = Helper.Parse_BankCode_Error(BankCode); Log.Write(msg); return(msg); } } else { return("Error"); } }
/// <summary> /// Confirm order with TAN /// </summary> /// <param name="TAN"></param> /// <param name="MediumName"></param> /// <returns> /// Bank return codes /// </returns> public async Task <HBCIDialogResult> TAN4(string TAN, string MediumName) { string BankCode = await Transaction.TAN4(this, TAN, MediumName); var result = new HBCIDialogResult(Helper.Parse_BankCode(BankCode), BankCode); return(result); }
/// <summary> /// Synchronize bank connection /// </summary> /// <param name="conn">ConnectionDetails object must atleast contain the fields: Url, HBCIVersion, UserId, Pin, Blz</param> /// <returns> /// Customer System ID /// </returns> public async Task <HBCIDialogResult <string> > Synchronization() { string BankCode = await Transaction.HKSYN(this); var messages = Helper.Parse_BankCode(BankCode); return(new HBCIDialogResult <string>(messages, BankCode, SystemId)); }
private async Task <HBCIDialogResult> ProcessSCA(HBCIDialogResult result, TANDialog tanDialog) { tanDialog.DialogResult = result; if (result.IsSCARequired) { string tan = await Helper.WaitForTanAsync(this, result, tanDialog); if (tan == null) { string BankCode = await Transaction.HKEND(this, HNHBK); result = new HBCIDialogResult(Helper.Parse_BankCode(BankCode), BankCode); } else { result = await TAN(tan); } } return(result); }
/// <summary> /// Collect money from another account - General method /// </summary> /// <param name="payerName">Name of the payer</param> /// <param name="payerIBAN">IBAN of the payer</param> /// <param name="payerBIC">BIC of the payer</param> /// <param name="amount">Amount to transfer</param> /// <param name="purpose">Short description of the transfer (dt. Verwendungszweck)</param> /// <param name="settlementDate"></param> /// <param name="mandateNumber"></param> /// <param name="mandateDate"></param> /// <param name="creditorIdNumber"></param> /// <param name="HIRMS">Numerical SecurityMode; e.g. 911 for "Sparkasse chipTan optisch"</param> /// <param name="pictureBox">Picturebox which shows the TAN</param> /// <param name="flickerImage">(Out) reference to an image object that shall receive the FlickerCode as GIF image</param> /// <param name="flickerWidth">Width of the flicker code</param> /// <param name="flickerHeight">Height of the flicker code</param> /// <param name="renderFlickerCodeAsGif">Renders flicker code as GIF, if 'true'</param> /// <returns> /// Bank return codes /// </returns> public async Task <HBCIDialogResult> Collect(TANDialog tanDialog, string payerName, string payerIBAN, string payerBIC, decimal amount, string purpose, DateTime settlementDate, string mandateNumber, DateTime mandateDate, string creditorIdNumber, string hirms) { var result = await InitializeConnection(); if (!result.IsSuccess) { return(result); } result = await ProcessSCA(result, tanDialog); if (!result.IsSuccess) { return(result); } TransactionConsole.Output = string.Empty; if (!string.IsNullOrEmpty(hirms)) { HIRMS = hirms; } string BankCode = await Transaction.HKDSE(this, payerName, payerIBAN, payerBIC, amount, purpose, settlementDate, mandateNumber, mandateDate, creditorIdNumber); result = new HBCIDialogResult(Helper.Parse_BankCode(BankCode), BankCode); if (!result.IsSuccess) { return(result); } result = await ProcessSCA(result, tanDialog); return(result); }
/// <summary> /// Account balance /// </summary> /// <param name="tanDialog">The TAN Dialog</param> /// <returns>The balance for this account</returns> public async Task <HBCIDialogResult <AccountBalance> > Balance(TANDialog tanDialog) { HBCIDialogResult result = await InitializeConnection(); if (!result.IsSuccess) { return(result.TypedResult <AccountBalance>()); } result = await ProcessSCA(result, tanDialog); if (!result.IsSuccess) { return(result.TypedResult <AccountBalance>()); } // Success string BankCode = await Transaction.HKSAL(this); result = new HBCIDialogResult(Helper.Parse_BankCode(BankCode), BankCode); if (!result.IsSuccess) { return(result.TypedResult <AccountBalance>()); } result = await ProcessSCA(result, tanDialog); if (!result.IsSuccess) { return(result.TypedResult <AccountBalance>()); } BankCode = result.RawData; AccountBalance balance = Helper.Parse_Balance(BankCode); return(result.TypedResult(balance)); }
public async Task <HBCIDialogResult> ModifyBankersOrder(TANDialog tanDialog, string OrderId, string receiverName, string receiverIBAN, string receiverBIC, decimal amount, string purpose, DateTime firstTimeExecutionDay, TimeUnit timeUnit, string rota, int executionDay, DateTime?lastExecutionDay, string hirms) { var result = await InitializeConnection(); if (!result.IsSuccess) { return(result); } result = await ProcessSCA(result, tanDialog); if (!result.IsSuccess) { return(result); } TransactionConsole.Output = string.Empty; if (!string.IsNullOrEmpty(hirms)) { HIRMS = hirms; } string BankCode = await Transaction.HKCDN(this, OrderId, receiverName, receiverIBAN, receiverBIC, amount, purpose, firstTimeExecutionDay, timeUnit, rota, executionDay, lastExecutionDay); result = new HBCIDialogResult(Helper.Parse_BankCode(BankCode), BankCode); if (!result.IsSuccess) { return(result); } result = await ProcessSCA(result, tanDialog); return(result); }
/// <summary> /// Transfer money - General method /// </summary> /// <param name="receiverName">Name of the recipient</param> /// <param name="receiverIBAN">IBAN of the recipient</param> /// <param name="receiverBIC">BIC of the recipient</param> /// <param name="amount">Amount to transfer</param> /// <param name="purpose">Short description of the transfer (dt. Verwendungszweck)</param> /// <param name="HIRMS">Numerical SecurityMode; e.g. 911 for "Sparkasse chipTan optisch"</param> /// <param name="pictureBox">Picturebox which shows the TAN</param> /// <param name="flickerImage">(Out) reference to an image object that shall receive the FlickerCode as GIF image</param> /// <param name="flickerWidth">Width of the flicker code</param> /// <param name="flickerHeight">Height of the flicker code</param> /// <param name="renderFlickerCodeAsGif">Renders flicker code as GIF, if 'true'</param> /// <returns> /// Bank return codes /// </returns> public async Task <HBCIDialogResult> Transfer(TANDialog tanDialog, string receiverName, string receiverIBAN, string receiverBIC, decimal amount, string purpose, string hirms) { var result = await InitializeConnection(); if (!result.IsSuccess) { return(result); } result = await ProcessSCA(result, tanDialog); if (!result.IsSuccess) { return(result); } TransactionConsole.Output = string.Empty; if (!string.IsNullOrEmpty(hirms)) { HIRMS = hirms; } string BankCode = await Transaction.HKCCS(this, receiverName, receiverIBAN, receiverBIC, amount, purpose); result = new HBCIDialogResult(Helper.Parse_BankCode(BankCode), BankCode); if (!result.IsSuccess) { return(result); } result = await ProcessSCA(result, tanDialog); return(result); }
public async Task <HBCIDialogResult> DeleteTerminatedTransfer(TANDialog tanDialog, string orderId, string receiverName, string receiverIBAN, string receiverBIC, decimal amount, string usage, DateTime executionDay, string hirms) { var result = await InitializeConnection(); if (!result.IsSuccess) { return(result); } result = await ProcessSCA(result, tanDialog); if (!result.IsSuccess) { return(result); } TransactionConsole.Output = string.Empty; if (!string.IsNullOrEmpty(hirms)) { HIRMS = hirms; } string BankCode = await Transaction.HKCSL(this, orderId, receiverName, receiverIBAN, receiverBIC, amount, usage, executionDay); result = new HBCIDialogResult(Helper.Parse_BankCode(BankCode), BankCode); if (!result.IsSuccess) { return(result); } result = await ProcessSCA(result, tanDialog); return(result); }
/// <summary> /// Load mobile phone prepaid card - General method /// </summary> /// <param name="mobileServiceProvider"></param> /// <param name="phoneNumber"></param> /// <param name="amount">Amount to transfer</param> /// <param name="HIRMS">Numerical SecurityMode; e.g. 911 for "Sparkasse chipTan optisch"</param> /// <param name="pictureBox">Picturebox which shows the TAN</param> /// <param name="flickerImage">(Out) reference to an image object that shall receive the FlickerCode as GIF image</param> /// <param name="flickerWidth">Width of the flicker code</param> /// <param name="flickerHeight">Height of the flicker code</param> /// <param name="renderFlickerCodeAsGif">Renders flicker code as GIF, if 'true'</param> /// <returns> /// Bank return codes /// </returns> public async Task <HBCIDialogResult> Prepaid(TANDialog tanDialog, int mobileServiceProvider, string phoneNumber, int amount, string hirms) { var result = await InitializeConnection(); if (!result.IsSuccess) { return(result); } result = await ProcessSCA(result, tanDialog); if (!result.IsSuccess) { return(result); } TransactionConsole.Output = string.Empty; if (!string.IsNullOrEmpty(hirms)) { HIRMS = hirms; } string BankCode = await Transaction.HKPPD(this, mobileServiceProvider, phoneNumber, amount); result = new HBCIDialogResult(Helper.Parse_BankCode(BankCode), BankCode); if (!result.IsSuccess) { return(result); } result = await ProcessSCA(result, tanDialog); return(result); }
/// <summary> /// Transfer money - General method /// </summary> /// <param name="connectionDetails">ConnectionDetails object must atleast contain the fields: Url, HBCIVersion, UserId, Pin, Blz, IBAN, BIC, AccountHolder</param> /// <param name="receiverName">Name of the recipient</param> /// <param name="receiverIBAN">IBAN of the recipient</param> /// <param name="receiverBIC">BIC of the recipient</param> /// <param name="amount">Amount to transfer</param> /// <param name="purpose">Short description of the transfer (dt. Verwendungszweck)</param> /// <param name="HIRMS">Numerical SecurityMode; e.g. 911 for "Sparkasse chipTan optisch"</param> /// <param name="pictureBox">Picturebox which shows the TAN</param> /// <param name="anonymous"></param> /// <param name="flickerImage">(Out) reference to an image object that shall receive the FlickerCode as GIF image</param> /// <param name="flickerWidth">Width of the flicker code</param> /// <param name="flickerHeight">Height of the flicker code</param> /// <param name="renderFlickerCodeAsGif">Renders flicker code as GIF, if 'true'</param> /// <returns> /// Bank return codes /// </returns> public static string Transfer(ConnectionDetails connectionDetails, string receiverName, string receiverIBAN, string receiverBIC, decimal amount, string purpose, string HIRMS, PictureBox pictureBox, bool anonymous, out Image flickerImage, int flickerWidth = 320, int flickerHeight = 120, bool renderFlickerCodeAsGif = false) { flickerImage = null; if (Transaction.INI(connectionDetails, anonymous) == true) { TransactionConsole.Output = string.Empty; if (!String.IsNullOrEmpty(HIRMS)) { Segment.HIRMS = HIRMS; } var BankCode = Transaction.HKCCS(connectionDetails, receiverName, receiverIBAN, receiverBIC, amount, purpose); if (BankCode.Contains("+0030::")) { // Gif image instead of picture box Helper.Parse_BankCode(BankCode, pictureBox, out flickerImage, flickerWidth, flickerHeight, renderFlickerCodeAsGif); return("OK"); } else { var msg = Helper.Parse_BankCode_Error(BankCode); Log.Write(msg); return(msg); } } else { return("Error"); } }
/// <summary> /// Collective transfer money terminated - General method /// </summary> /// <param name="painData"></param> /// <param name="numberOfTransactions"></param> /// <param name="totalAmount"></param> /// <param name="ExecutionDay"></param> /// <param name="HIRMS">Numerical SecurityMode; e.g. 911 for "Sparkasse chipTan optisch"</param> /// <param name="pictureBox">Picturebox which shows the TAN</param> /// <param name="flickerImage">(Out) reference to an image object that shall receive the FlickerCode as GIF image</param> /// <param name="flickerWidth">Width of the flicker code</param> /// <param name="flickerHeight">Height of the flicker code</param> /// <param name="renderFlickerCodeAsGif">Renders flicker code as GIF, if 'true'</param> /// <returns> /// Bank return codes /// </returns> public async Task <HBCIDialogResult> CollectiveTransfer_Terminated(TANDialog tanDialog, List <Pain00100203CtData> painData, string numberOfTransactions, decimal totalAmount, DateTime executionDay, string hirms) { var result = await InitializeConnection(); if (!result.IsSuccess) { return(result); } result = await ProcessSCA(result, tanDialog); if (!result.IsSuccess) { return(result); } TransactionConsole.Output = string.Empty; if (!string.IsNullOrEmpty(hirms)) { HIRMS = hirms; } string BankCode = await Transaction.HKCME(this, painData, numberOfTransactions, totalAmount, executionDay); result = new HBCIDialogResult(Helper.Parse_BankCode(BankCode), BankCode); if (!result.IsSuccess) { return(result); } result = await ProcessSCA(result, tanDialog); return(result); }
/// <summary> /// INI /// </summary> public static HBCIDialogResult Init_INI(ConnectionDetails connectionDetails, bool anonymous) { if (!anonymous) { /// <summary> /// Sync /// </summary> try { // If there is no customer system ID available, perform sync to get one if (connectionDetails.CustomerSystemId == null) { var BankCode = Transaction.HKSYN(connectionDetails); var syncResult = new HBCIDialogResult(Helper.Parse_BankCode(BankCode)); if (!syncResult.IsSuccess) { Log.Write("Synchronisation failed."); return(syncResult); } } else { Segment.HISYN = connectionDetails.CustomerSystemId; } string segments; /// <summary> /// INI /// </summary> if (connectionDetails.HBCIVersion == 220) { string segments_ = "HKIDN:" + SEGNUM.SETVal(3) + ":2+280:" + connectionDetails.BlzPrimary + "+" + connectionDetails.UserId + "+" + Segment.HISYN + "+1'" + "HKVVB:" + SEGNUM.SETVal(4) + ":2+0+0+0+" + Program.Buildname + "+" + Program.Version + "'"; segments = segments_; } else if (connectionDetails.HBCIVersion == 300) { string segments_ = "HKIDN:" + SEGNUM.SETVal(3) + ":2+280:" + connectionDetails.BlzPrimary + "+" + connectionDetails.UserId + "+" + Segment.HISYN + "+1'" + "HKVVB:" + SEGNUM.SETVal(4) + ":3+0+0+0+" + Program.Buildname + "+" + Program.Version + "'"; segments = segments_; } else { //Since connectionDetails is a re-usable object, this shouldn't be cleared. //connectionDetails.UserId = string.Empty; //connectionDetails.Pin = null; Log.Write("HBCI version not supported"); throw new Exception("HBCI version not supported"); } SEG.NUM = SEGNUM.SETInt(4); var message = FinTSMessage.Create(connectionDetails.HBCIVersion, MSG.SETVal(1), DLG.SETVal(0), connectionDetails.BlzPrimary, connectionDetails.UserId, connectionDetails.Pin, Segment.HISYN, segments, Segment.HIRMS, SEG.NUM); var response = FinTSMessage.Send(connectionDetails.Url, message); var bankMessages = Helper.Parse_Segment(connectionDetails.UserId, connectionDetails.Blz, connectionDetails.HBCIVersion, response); var result = new HBCIDialogResult(bankMessages); if (!result.IsSuccess) { Log.Write("Initialisation failed: " + result); } return(result); } catch (Exception ex) { //Since connectionDetails is a re-usable object, this shouldn't be cleared. //connectionDetails.UserId = string.Empty; //connectionDetails.Pin = null; Log.Write(ex.ToString()); throw new Exception("Software error", ex); } } else { /// <summary> /// Sync /// </summary> try { Log.Write("Starting Synchronisation anonymous"); string segments; if (connectionDetails.HBCIVersion == 300) { string segments_ = "HKIDN:" + SEGNUM.SETVal(2) + ":2+280:" + connectionDetails.BlzPrimary + "+" + "9999999999" + "+0+0'" + "HKVVB:" + SEGNUM.SETVal(3) + ":3+0+0+1+" + Program.Buildname + "+" + Program.Version + "'"; segments = segments_; } else { //Since connectionDetails is a re-usable object, this shouldn't be cleared. //connectionDetails.UserId = string.Empty; //connectionDetails.Pin = null; Log.Write("HBCI version not supported"); throw new Exception("HBCI version not supported"); } SEG.NUM = SEGNUM.SETInt(4); string message = FinTSMessageAnonymous.Create(connectionDetails.HBCIVersion, MSG.SETVal(1), DLG.SETVal(0), connectionDetails.Blz, connectionDetails.UserId, connectionDetails.Pin, SYS.SETVal(0), segments, null, SEG.NUM); string response = FinTSMessage.Send(connectionDetails.Url, message); var messages = Helper.Parse_Segment(connectionDetails.UserId, connectionDetails.Blz, connectionDetails.HBCIVersion, response); var result = new HBCIDialogResult(messages); if (!result.IsSuccess) { Log.Write("Synchronisation anonymous failed. " + result); return(result); } // Sync OK Log.Write("Synchronisation anonymous ok"); /// <summary> /// INI /// </summary> if (connectionDetails.HBCIVersion == 300) { string segments__ = "HKIDN:" + SEGNUM.SETVal(3) + ":2+280:" + connectionDetails.BlzPrimary + "+" + connectionDetails.UserId + "+" + Segment.HISYN + "+1'" + "HKVVB:" + SEGNUM.SETVal(4) + ":3+0+0+0+" + Program.Buildname + "+" + Program.Version + "'" + "HKSYN:" + SEGNUM.SETVal(5) + ":3+0'"; segments = segments__; } else { //Since connectionDetails is a re-usable object, this shouldn't be cleared. //connectionDetails.UserId = string.Empty; //connectionDetails.Pin = null; Log.Write("HBCI version not supported"); throw new Exception("HBCI version not supported"); } SEG.NUM = SEGNUM.SETInt(5); message = FinTSMessage.Create(connectionDetails.HBCIVersion, MSG.SETVal(1), DLG.SETVal(0), connectionDetails.BlzPrimary, connectionDetails.UserId, connectionDetails.Pin, Segment.HISYN, segments, Segment.HIRMS, SEG.NUM); response = FinTSMessage.Send(connectionDetails.Url, message); messages = Helper.Parse_Segment(connectionDetails.UserId, connectionDetails.Blz, connectionDetails.HBCIVersion, response); result = new HBCIDialogResult(messages); if (!result.IsSuccess) { Log.Write("Initialisation failed."); } return(result); } catch (Exception ex) { //Since connectionDetails is a re-usable object, this shouldn't be cleared. //connectionDetails.UserId = string.Empty; //connectionDetails.Pin = null; Log.Write(ex.ToString()); DEBUG.Write("Software error: " + ex.ToString()); throw new Exception("Software error: " + ex.ToString()); } } }
/// <summary> /// Account transactions in SWIFT-format /// </summary> /// <param name="connectionDetails">ConnectionDetails object must atleast contain the fields: Url, HBCIVersion, UserId, Pin, Blz, Account, IBAN, BIC</param> /// <param name="anonymous"></param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <returns> /// Transactions /// </returns> public async Task <HBCIDialogResult <List <SwiftStatement> > > Transactions(TANDialog tanDialog, DateTime?startDate = null, DateTime?endDate = null, bool saveMt940File = false) { var result = await InitializeConnection(); if (!result.IsSuccess) { return(result.TypedResult <List <SwiftStatement> >()); } result = await ProcessSCA(result, tanDialog); if (!result.IsSuccess) { return(result.TypedResult <List <SwiftStatement> >()); } string startDateStr = startDate?.ToString("yyyyMMdd"); string endDateStr = endDate?.ToString("yyyyMMdd"); // Success string BankCode = await Transaction.HKKAZ(this, startDateStr, endDateStr, null); result = new HBCIDialogResult(Helper.Parse_BankCode(BankCode), BankCode); if (!result.IsSuccess) { return(result.TypedResult <List <SwiftStatement> >()); } result = await ProcessSCA(result, tanDialog); if (!result.IsSuccess) { return(result.TypedResult <List <SwiftStatement> >()); } BankCode = result.RawData; var TransactionsMt940 = new StringBuilder(); var TransactionsMt942 = new StringBuilder(); Regex regex = new Regex(@"HIKAZ:.+?@\d+@(?<mt940>.+?)(\+@\d+@(?<mt942>.+?))?('{1,2}H[A-Z]{4}:\d+:\d+)", RegexOptions.Singleline); Match match = regex.Match(BankCode); if (match.Success) { TransactionsMt940.Append(match.Groups["mt940"].Value); TransactionsMt942.Append(match.Groups["mt942"].Value); } string BankCode_ = BankCode; while (BankCode_.Contains("+3040::")) { Helper.Parse_Message(this, BankCode_); string Startpoint = new Regex(@"\+3040::[^:]+:(?<startpoint>[^']+)'").Match(BankCode_).Groups["startpoint"].Value; BankCode_ = await Transaction.HKKAZ(this, startDateStr, endDateStr, Startpoint); result = new HBCIDialogResult(Helper.Parse_BankCode(BankCode_), BankCode_); if (!result.IsSuccess) { return(result.TypedResult <List <SwiftStatement> >()); } result = await ProcessSCA(result, tanDialog); if (!result.IsSuccess) { return(result.TypedResult <List <SwiftStatement> >()); } BankCode_ = result.RawData; match = regex.Match(BankCode_); if (match.Success) { TransactionsMt940.Append(match.Groups["mt940"].Value); TransactionsMt942.Append(match.Groups["mt942"].Value); } } var swiftStatements = new List <SwiftStatement>(); swiftStatements.AddRange(MT940.Serialize(TransactionsMt940.ToString(), ConnectionDetails.Account, saveMt940File)); swiftStatements.AddRange(MT940.Serialize(TransactionsMt942.ToString(), ConnectionDetails.Account, saveMt940File, true)); return(result.TypedResult(swiftStatements)); }
/// <summary> /// Get banker's orders /// </summary> /// <param name="tanDialog">The TAN dialog</param> /// <returns> /// Banker's orders /// </returns> public async Task <HBCIDialogResult <List <BankersOrder> > > GetBankersOrders(TANDialog tanDialog) { var result = await InitializeConnection(); if (!result.IsSuccess) { return(result.TypedResult <List <BankersOrder> >()); } result = await ProcessSCA(result, tanDialog); if (!result.IsSuccess) { return(result.TypedResult <List <BankersOrder> >()); } // Success string BankCode = await Transaction.HKCDB(this); result = new HBCIDialogResult(Helper.Parse_BankCode(BankCode), BankCode); if (!result.IsSuccess) { return(result.TypedResult <List <BankersOrder> >()); } result = await ProcessSCA(result, tanDialog); if (!result.IsSuccess) { return(result.TypedResult <List <BankersOrder> >()); } BankCode = result.RawData; int startIdx = BankCode.IndexOf("HICDB"); if (startIdx < 0) { return(result.TypedResult <List <BankersOrder> >()); } var data = new List <BankersOrder>(); string BankCode_ = BankCode.Substring(startIdx); for (; ;) { var match = Regex.Match(BankCode_, @"HICDB.+?(?<xml><\?xml.+?</Document>)\+(?<orderid>.*?)\+(?<firstdate>\d*):(?<turnus>[MW]):(?<rota>\d+):(?<execday>\d+)(:(?<lastdate>\d+))?", RegexOptions.Singleline); if (match.Success) { string xml = match.Groups["xml"].Value; // xml ist UTF-8 xml = Converter.ConvertEncoding(xml, Encoding.GetEncoding("ISO-8859-1"), Encoding.UTF8); string orderId = match.Groups["orderid"].Value; string firstExecutionDateStr = match.Groups["firstdate"].Value; var firstExecutionDate = !string.IsNullOrWhiteSpace(firstExecutionDateStr) ? DateTime.ParseExact(firstExecutionDateStr, "yyyyMMdd", CultureInfo.InvariantCulture) : default(DateTime?); string timeUnitStr = match.Groups["turnus"].Value; var timeUnit = timeUnitStr == "M" ? TimeUnit.Monthly : TimeUnit.Weekly; string rota = match.Groups["rota"].Value; string executionDayStr = match.Groups["execday"].Value; int executionDay = Convert.ToInt32(executionDayStr); string lastExecutionDateStr = match.Groups["lastdate"].Value; var lastExecutionDate = !string.IsNullOrWhiteSpace(lastExecutionDateStr) ? DateTime.ParseExact(lastExecutionDateStr, "yyyyMMdd", CultureInfo.InvariantCulture) : default(DateTime?); var painData = Pain00100103CtData.Create(xml); if (firstExecutionDate.HasValue && executionDay > 0) { var item = new BankersOrder(orderId, painData, firstExecutionDate.Value, timeUnit, rota, executionDay, lastExecutionDate); data.Add(item); } } int endIdx = BankCode_.IndexOf("'"); if (BankCode_.Length <= endIdx + 1) { break; } BankCode_ = BankCode_.Substring(endIdx + 1); startIdx = BankCode_.IndexOf("HICDB"); if (startIdx < 0) { break; } } // Success return(result.TypedResult(data)); }
/// <summary> /// Get terminated transfers /// </summary> /// <returns> /// Banker's orders /// </returns> public async Task <HBCIDialogResult <List <TerminatedTransfer> > > GetTerminatedTransfers(TANDialog tanDialog) { var result = await InitializeConnection(); if (!result.IsSuccess) { return(result.TypedResult <List <TerminatedTransfer> >()); } result = await ProcessSCA(result, tanDialog); if (!result.IsSuccess) { return(result.TypedResult <List <TerminatedTransfer> >()); } // Success string BankCode = await Transaction.HKCSB(this); result = new HBCIDialogResult(Helper.Parse_BankCode(BankCode), BankCode); if (!result.IsSuccess) { return(result.TypedResult <List <TerminatedTransfer> >()); } result = await ProcessSCA(result, tanDialog); if (!result.IsSuccess) { return(result.TypedResult <List <TerminatedTransfer> >()); } BankCode = result.RawData; int startIdx = BankCode.IndexOf("HICSB"); if (startIdx < 0) { return(result.TypedResult <List <TerminatedTransfer> >()); } var data = new List <TerminatedTransfer>(); string BankCode_ = BankCode.Substring(startIdx); for (; ;) { var match = Regex.Match(BankCode_, @"HICSB.+?(?<xml><\?xml.+?</Document>)\+(?<orderid>.*?)(\+(?<deleteable>j|n))?(\+(?<modifiable>j|n))?'", RegexOptions.Singleline | RegexOptions.IgnoreCase); if (match.Success) { string xml = match.Groups["xml"].Value; // xml ist UTF-8 xml = Converter.ConvertEncoding(xml, Encoding.GetEncoding("ISO-8859-1"), Encoding.UTF8); string orderId = match.Groups["orderid"].Value; bool? deleteable = null; if (match.Groups["deleteable"].Success) { deleteable = match.Groups["deleteable"].Value.Equals("j", StringComparison.OrdinalIgnoreCase) ? true : false; } bool?modifiable = null; if (match.Groups["modifiable"].Success) { modifiable = match.Groups["modifiable"].Value.Equals("j", StringComparison.OrdinalIgnoreCase) ? true : false; } var painData = Pain00100103CtData.Create(xml); var item = new TerminatedTransfer(orderId, deleteable, modifiable, painData); data.Add(item); } int endIdx = BankCode_.IndexOf("'"); if (BankCode_.Length <= endIdx + 1) { break; } BankCode_ = BankCode_.Substring(endIdx + 1); startIdx = BankCode_.IndexOf("HICSB"); if (startIdx < 0) { break; } } // Success return(result.TypedResult(data)); }
/// <summary> /// Account transactions in camt format /// </summary> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <returns> /// Transactions /// </returns> public async Task <HBCIDialogResult <List <CamtStatement> > > Transactions_camt(TANDialog tanDialog, CamtVersion camtVers, DateTime?startDate = null, DateTime?endDate = null, bool saveCamtFile = false) { var result = await InitializeConnection(); if (!result.IsSuccess) { return(result.TypedResult <List <CamtStatement> >()); } result = await ProcessSCA(result, tanDialog); if (!result.IsSuccess) { return(result.TypedResult <List <CamtStatement> >()); } // Plain camt message string camt = string.Empty; string startDateStr = startDate?.ToString("yyyyMMdd"); string endDateStr = endDate?.ToString("yyyyMMdd"); // Success string BankCode = await Transaction.HKCAZ(this, startDateStr, endDateStr, null, camtVers); result = new HBCIDialogResult <List <CamtStatement> >(Helper.Parse_BankCode(BankCode), BankCode); if (!result.IsSuccess) { return(result.TypedResult <List <CamtStatement> >()); } result = await ProcessSCA(result, tanDialog); if (!result.IsSuccess) { return(result.TypedResult <List <CamtStatement> >()); } BankCode = result.RawData; var statements = new List <CamtStatement>(); Camt052Parser camt052Parser = null; Camt053Parser camt053Parser = null; var encoding = Encoding.GetEncoding("ISO-8859-1"); string BankCode_ = BankCode; // Es kann sein, dass in der payload mehrere Dokumente enthalten sind int xmlStartIdx = BankCode_.IndexOf("<?xml version="); int xmlEndIdx = BankCode_.IndexOf("</Document>") + "</Document>".Length; while (xmlStartIdx >= 0) { if (xmlStartIdx > xmlEndIdx) { break; } camt = "<?xml version=" + Helper.Parse_String(BankCode_, "<?xml version=", "</Document>") + "</Document>"; switch (camtVers) { case CamtVersion.Camt052: if (camt052Parser == null) { camt052Parser = new Camt052Parser(); } if (saveCamtFile) { // Save camt052 statement to file string camt052f = Camt052File.Save(ConnectionDetails.Account, camt, encoding); // Process the camt052 file camt052Parser.ProcessFile(camt052f); } else { camt052Parser.ProcessDocument(camt, encoding); } statements.AddRange(camt052Parser.statements); break; case CamtVersion.Camt053: if (camt053Parser == null) { camt053Parser = new Camt053Parser(); } if (saveCamtFile) { // Save camt053 statement to file string camt053f = Camt053File.Save(ConnectionDetails.Account, camt, encoding); // Process the camt053 file camt053Parser.ProcessFile(camt053f); } else { camt053Parser.ProcessDocument(camt, encoding); } statements.AddRange(camt053Parser.statements); break; } BankCode_ = BankCode_.Substring(xmlEndIdx); xmlStartIdx = BankCode_.IndexOf("<?xml version"); xmlEndIdx = BankCode_.IndexOf("</Document>") + "</Document>".Length; } BankCode_ = BankCode; while (BankCode_.Contains("+3040::")) { string Startpoint = new Regex(@"\+3040::[^:]+:(?<startpoint>[^']+)'").Match(BankCode_).Groups["startpoint"].Value; BankCode_ = await Transaction.HKCAZ(this, startDateStr, endDateStr, Startpoint, camtVers); result = new HBCIDialogResult <List <CamtStatement> >(Helper.Parse_BankCode(BankCode_), BankCode_); if (!result.IsSuccess) { return(result.TypedResult <List <CamtStatement> >()); } BankCode_ = result.RawData; // Es kann sein, dass in der payload mehrere Dokumente enthalten sind xmlStartIdx = BankCode_.IndexOf("<?xml version="); xmlEndIdx = BankCode_.IndexOf("</Document>") + "</Document>".Length; while (xmlStartIdx >= 0) { if (xmlStartIdx > xmlEndIdx) { break; } camt = "<?xml version=" + Helper.Parse_String(BankCode_, "<?xml version=", "</Document>") + "</Document>"; switch (camtVers) { case CamtVersion.Camt052: // Save camt052 statement to file string camt052f_ = Camt052File.Save(ConnectionDetails.Account, camt); // Process the camt052 file camt052Parser.ProcessFile(camt052f_); // Add all items statements.AddRange(camt052Parser.statements); break; case CamtVersion.Camt053: // Save camt053 statement to file string camt053f_ = Camt053File.Save(ConnectionDetails.Account, camt); // Process the camt053 file camt053Parser.ProcessFile(camt053f_); // Add all items to existing statement statements.AddRange(camt053Parser.statements); break; } BankCode_ = BankCode_.Substring(xmlEndIdx); xmlStartIdx = BankCode_.IndexOf("<?xml version"); xmlEndIdx = BankCode_.IndexOf("</Document>") + "</Document>".Length; } } return(result.TypedResult(statements)); }