/// <summary> /// Collect /// </summary> public static async Task <String> Init_HKDSE(FinTsClient client, string Payer, string PayerIBAN, string PayerBIC, decimal Amount, string Usage, DateTime SettlementDate, string MandateNumber, DateTime MandateDate, string CreditorIDNumber) { Log.Write("Starting job HKDSE: Collect money"); client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg4); var connectionDetails = client.ConnectionDetails; string segments = "HKDSE:" + client.SEGNUM + ":1+" + connectionDetails.Iban + ":" + connectionDetails.Bic + "+urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.008.002.02+@@"; var message = pain00800202.Create(connectionDetails.AccountHolder, connectionDetails.Iban, connectionDetails.Bic, Payer, PayerIBAN, PayerBIC, Amount, Usage, SettlementDate, MandateNumber, MandateDate, CreditorIDNumber); segments = segments.Replace("@@", "@" + (message.Length - 1) + "@") + message; if (Helper.IsTANRequired("HKDSE")) { client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg4); segments = HKTAN.Init_HKTAN(client, segments, "HKDSE"); } var response = await FinTSMessage.Send(client, FinTSMessage.Create(client, client.HNHBS, client.HNHBK, segments, client.HIRMS)); Helper.Parse_Message(client, response); return(response); }
/// <summary> /// Collective collect /// </summary> public static async Task <String> Init_HKDME(FinTsClient client, DateTime SettlementDate, List <Pain00800202CcData> PainData, string NumberofTransactions, decimal TotalAmount) { Log.Write("Starting job HKDME: Collective collect money"); client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg3); var TotalAmount_ = TotalAmount.ToString().Replace(",", "."); var connectionDetails = client.ConnectionDetails; // TODO: Anscheinend wird totalAmount nur in der Version 2 unterstützt, diese hat jedoch nicht jede Bank implementiert. //string segments = "HKDME:" + client.SEGNUM + ":2+" + connectionDetails.Iban + ":" + connectionDetails.Bic + "+" + TotalAmount_ + ":EUR++" + "+urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.008.002.02+@@"; string segments = "HKDME:" + client.SEGNUM + ":1+" + connectionDetails.Iban + ":" + connectionDetails.Bic + "++" + "+urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.008.002.02+@@"; var message = pain00800202.Create(connectionDetails.AccountHolder, connectionDetails.Iban, connectionDetails.Bic, SettlementDate, PainData, NumberofTransactions, TotalAmount); segments = segments.Replace("@@", "@" + (message.Length - 1) + "@") + message; if (Helper.IsTANRequired("HKDME")) { client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg4); segments = HKTAN.Init_HKTAN(client, segments, "HKDME"); } var TAN = await FinTSMessage.Send(client, FinTSMessage.Create(client, client.HNHBS, client.HNHBK, segments, client.HIRMS)); Helper.Parse_Message(client, TAN); return(TAN); }
/// <summary> /// TAN process 4 /// </summary> public static string Send_TAN4(string TAN, string URL, int HBCIVersion, int BLZ, string UserID, string PIN, string MediumName) { Log.Write("Starting job TAN process 4"); string segments = string.Empty; // Version 3, Process 4 if (Segment.HITANS.Substring(0, 1).Equals("3+4")) { segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + Segment.HITANS.Substring(0, 1) + "+4+++++++" + MediumName + "'"; } // Version 4, Process 4 if (Segment.HITANS.Substring(0, 1).Equals("4+4")) { segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + Segment.HITANS.Substring(0, 1) + "+4++++++++" + MediumName + "'"; } // Version 5, Process 4 if (Segment.HITANS.Substring(0, 1).Equals("5+4")) { segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + Segment.HITANS.Substring(0, 1) + "+4++++++++++" + MediumName + "'"; } SEG.NUM = SEGNUM.SETInt(3); return(FinTSMessage.Send(URL, FinTSMessage.Create(HBCIVersion, Segment.HNHBS, Segment.HNHBK, BLZ, UserID, PIN, Segment.HISYN, segments, Segment.HIRMS + ":" + TAN, SEG.NUM))); }
/// <summary> /// Submit bankers order /// </summary> public static string Init_HKCDE(int BLZ, string Accountholder, string AccountholderIBAN, string AccountholderBIC, string Receiver, string ReceiverIBAN, string ReceiverBIC, decimal Amount, string Usage, string FirstTimeExecutionDay, string TimeUnit, string Rota, string ExecutionDay, string URL, int HBCIVersion, string UserID, string PIN) { Log.Write("Starting job HKCDE: Submit bankers order"); string segments = "HKCDE:" + SEGNUM.SETVal(3) + ":1+" + AccountholderIBAN + ":" + AccountholderBIC + "+urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.001.002.03+@@"; var message = pain00100203.Create(Accountholder, AccountholderIBAN, AccountholderBIC, Receiver, ReceiverIBAN, ReceiverBIC, Amount, Usage, "1999-01-01"); message = message.Replace("'", "") + "+" + FirstTimeExecutionDay + ":" + TimeUnit + ":" + Rota + ":" + ExecutionDay + "'"; segments = segments.Replace("@@", "@" + (message.Length - 1) + "@") + message; segments = segments + "HKTAN:" + SEGNUM.SETVal(4) + ":" + Segment.HITANS + "'"; SEG.NUM = SEGNUM.SETInt(4); var TAN = FinTSMessage.Send(URL, FinTSMessage.Create(HBCIVersion, Segment.HNHBS, Segment.HNHBK, BLZ, UserID, PIN, Segment.HISYN, segments, Segment.HIRMS, SEG.NUM)); Segment.HITAN = Helper.Parse_String(Helper.Parse_String(TAN, "HITAN", "'").Replace("?+", "??"), "++", "+").Replace("??", "?+"); Helper.Parse_Message(TAN); return(TAN); }
/// <summary> /// Delete terminated transfer /// </summary> public static async Task <string> Init_HKCSA(FinTsClient client, string OrderId, string Receiver, string ReceiverIBAN, string ReceiverBIC, decimal Amount, string Usage, DateTime ExecutionDay) { Log.Write("Starting job HKCSA: Modify terminated transfer"); client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg3); var connectionDetails = client.ConnectionDetails; string segments = "HKCSA:" + client.SEGNUM + ":1+" + connectionDetails.Iban + ":" + connectionDetails.Bic + "+urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.001.001.03+@@"; var sepaMessage = pain00100103.Create(connectionDetails.AccountHolder, connectionDetails.Iban, connectionDetails.Bic, Receiver, ReceiverIBAN, ReceiverBIC, Amount, Usage, ExecutionDay).Replace("'", ""); segments = segments.Replace("@@", "@" + sepaMessage.Length + "@") + sepaMessage; segments += "+" + OrderId; segments += "'"; if (Helper.IsTANRequired("HKCSA")) { client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg4); segments = HKTAN.Init_HKTAN(client, segments, "HKCSA"); } string message = FinTSMessage.Create(client, client.HNHBS, client.HNHBK, segments, client.HIRMS); var TAN = await FinTSMessage.Send(client, message); Helper.Parse_Message(client, TAN); return(TAN); }
/// <summary> /// TAN /// </summary> public static string Send_TAN(string TAN, string URL, int HBCIVersion, int BLZ, string UserID, string PIN) { Log.Write("Starting TAN process"); string segments = string.Empty; // Version 2, Process 2 if (Segment.HITANS.Substring(0, 1).Equals("2+2")) { segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + Segment.HITANS.Substring(0, 1) + "+2++" + Segment.HITAN + "++N'"; } // Version 3, Process 2 if (Segment.HITANS.Substring(0, 1).Equals("3+2")) { segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + Segment.HITANS.Substring(0, 1) + "+2++" + Segment.HITAN + "++N'"; } // Version 4, Process 2 if (Segment.HITANS.Substring(0, 1).Equals("4+2")) { segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + Segment.HITANS.Substring(0, 1) + "+2++" + Segment.HITAN + "++N'"; } // Version 5, Process 2 if (Segment.HITANS.Substring(0, 1).Equals("5+2")) { segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + Segment.HITANS.Substring(0, 1) + "+2++++" + Segment.HITAN + "++N'"; } else { segments = "HKTAN:" + SEGNUM.SETVal(3) + ":" + Segment.HITANS.Substring(0, 1) + "+2++++" + Segment.HITAN + "++N'"; } SEG.NUM = SEGNUM.SETInt(3); return(FinTSMessage.Send(URL, FinTSMessage.Create(HBCIVersion, Segment.HNHBS, Segment.HNHBK, BLZ, UserID, PIN, Segment.HISYN, segments, Segment.HIRMS + ":" + TAN, SEG.NUM))); }
/// <summary> /// TAN process 4 /// </summary> public static async Task <String> Send_TAN4(FinTsClient client, string TAN, string MediumName) { Log.Write("Starting job TAN process 4"); string segments = string.Empty; // Version 3 if (client.HITANS == 3) { segments = "HKTAN:" + SEG_NUM.Seg3 + ":" + client.HITANS + "+4+++++++" + MediumName + "'"; } // Version 4 else if (client.HITANS == 4) { segments = "HKTAN:" + SEG_NUM.Seg3 + ":" + client.HITANS + "+4++++++++" + MediumName + "'"; } // Version 5 else if (client.HITANS == 5) { segments = "HKTAN:" + SEG_NUM.Seg3 + ":" + client.HITANS + "+4++++++++++" + MediumName + "'"; } client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg3); return(await FinTSMessage.Send(client, FinTSMessage.Create(client, client.HNHBS, client.HNHBK, segments, client.HIRMS + ":" + TAN))); }
/// <summary> /// Rebooking /// </summary> public static async Task <String> Init_HKCUM(FinTsClient client, string Receiver, string ReceiverIBAN, string ReceiverBIC, decimal Amount, string Usage) { Log.Write("Starting job HKCUM: Rebooking money"); client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg3); var connectionDetails = client.ConnectionDetails; string segments = "HKCUM:" + client.SEGNUM + ":1+" + connectionDetails.Iban + ":" + connectionDetails.Bic + "+urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.001.002.03+@@"; var message = pain00100203.Create(connectionDetails.AccountHolder, connectionDetails.Iban, connectionDetails.Bic, Receiver, ReceiverIBAN, ReceiverBIC, Amount, Usage, new DateTime(1999, 1, 1)); segments = segments.Replace("@@", "@" + (message.Length - 1) + "@") + message; if (Helper.IsTANRequired("HKCUM")) { client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg4); segments = HKTAN.Init_HKTAN(client, segments, "HKCUM"); } var TAN = await FinTSMessage.Send(client, FinTSMessage.Create(client, client.HNHBS, client.HNHBK, segments, client.HIRMS)); Helper.Parse_Message(client, TAN); return(TAN); }
/// <summary> /// Collective transfer terminated /// </summary> public static async Task <String> Init_HKCME(FinTsClient client, List <Pain00100203CtData> PainData, string NumberofTransactions, decimal TotalAmount, DateTime ExecutionDay) { Log.Write("Starting job HKCME: Collective transfer money terminated"); var TotalAmount_ = TotalAmount.ToString().Replace(",", "."); client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg3); var connectionDetails = client.ConnectionDetails; string segments = "HKCME:" + client.SEGNUM + ":1+" + connectionDetails.Iban + ":" + connectionDetails.Bic + TotalAmount_ + ":EUR++" + " + urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.001.002.03+@@"; var painMessage = pain00100203.Create(connectionDetails.AccountHolder, connectionDetails.Iban, connectionDetails.Bic, PainData, NumberofTransactions, TotalAmount, ExecutionDay); segments = segments.Replace("@@", "@" + (painMessage.Length - 1) + "@") + painMessage; if (Helper.IsTANRequired("HKCME")) { client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg4); segments = HKTAN.Init_HKTAN(client, segments, "HKCME"); } string message = FinTSMessage.Create(client, client.HNHBS, client.HNHBK, segments, client.HIRMS); var response = await FinTSMessage.Send(client, message); Helper.Parse_Message(client, response); return(response); }
/// <summary> /// Submit bankers order /// </summary> public static async Task <String> Init_HKCDE(FinTsClient client, string Receiver, string ReceiverIBAN, string ReceiverBIC, decimal Amount, string Usage, DateTime FirstTimeExecutionDay, TimeUnit timeUnit, string Rota, int ExecutionDay, DateTime?LastExecutionDay) { Log.Write("Starting job HKCDE: Submit bankers order"); client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg3); var connectionDetails = client.ConnectionDetails; string segments = "HKCDE:" + client.SEGNUM + ":1+" + connectionDetails.Iban + ":" + connectionDetails.Bic + "+urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.001.001.03+@@"; var sepaMessage = pain00100103.Create(connectionDetails.AccountHolder, connectionDetails.Iban, connectionDetails.Bic, Receiver, ReceiverIBAN, ReceiverBIC, Amount, Usage, new DateTime(1999, 1, 1)).Replace("'", ""); segments = segments.Replace("@@", "@" + sepaMessage.Length + "@") + sepaMessage; segments += "+" + FirstTimeExecutionDay.ToString("yyyyMMdd") + ":" + (char)timeUnit + ":" + Rota + ":" + ExecutionDay; if (LastExecutionDay != null) { segments += ":" + LastExecutionDay.Value.ToString("yyyyMMdd"); } segments += "'"; if (Helper.IsTANRequired("HKCDE")) { client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg4); segments = HKTAN.Init_HKTAN(client, segments, "HKCDE"); } string message = FinTSMessage.Create(client, client.HNHBS, client.HNHBK, segments, client.HIRMS); var response = await FinTSMessage.Send(client, message); Helper.Parse_Message(client, response); return(response); }
/// <summary> /// Get bankers orders /// </summary> public static string Init_HKCSB(int BLZ, string IBAN, string BIC, string URL, int HBCIVersion, string UserID, string PIN) { Log.Write("Starting job HKCSB: Get bankers order"); string segments = "HKCSB:" + SEGNUM.SETVal(3) + ":1+" + IBAN + ":" + BIC + "+sepade?:xsd?:pain.001.001.03.xsd'"; SEG.NUM = SEGNUM.SETInt(3); return(FinTSMessage.Send(URL, FinTSMessage.Create(HBCIVersion, Segment.HNHBS, Segment.HNHBK, BLZ, UserID, PIN, Segment.HISYN, segments, Segment.HIRMS, SEG.NUM))); }
/// <summary> /// Request SEPA account connection /// </summary> /// <param name="connectionDetails"></param> /// <returns></returns> public static async Task <String> Init_HKSPA(FinTsClient client) { Log.Write("Starting job HKSPA: Request SEPA account connection"); var connectionDetails = client.ConnectionDetails; string segments = string.Empty; segments = "HKEND:" + SEG_NUM.Seg3 + "1'"; client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg3); return(await FinTSMessage.Send(client, FinTSMessage.Create(client, client.HNHBS, client.HNHBK, segments, client.HIRMS))); }
/// <summary> /// Balance /// </summary> public static async Task <String> Init_HKSAL(FinTsClient client) { Log.Write("Starting job HKSAL: Request balance"); var connectionDetails = client.ConnectionDetails; AccountInformation activeAccount; if (client.activeAccount != null) { activeAccount = client.activeAccount; } else { activeAccount = new AccountInformation() { AccountNumber = connectionDetails.Account, AccountBankCode = connectionDetails.Blz.ToString(), AccountIban = connectionDetails.Iban, AccountBic = connectionDetails.Bic, } }; string segments = string.Empty; client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg3); if (Convert.ToInt16(client.HISALS) >= 7) { segments = "HKSAL:" + client.SEGNUM + ":" + client.HISALS + "+" + activeAccount.AccountIban + ":" + activeAccount.AccountBic + "+N'"; } else { segments = "HKSAL:" + client.SEGNUM + ":" + client.HISALS + "+" + activeAccount.AccountNumber + "::280:" + activeAccount.AccountBankCode + "+N'"; } if (Helper.IsTANRequired("HKSAL")) { client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg4); segments = HKTAN.Init_HKTAN(client, segments, "HKSAL"); } string message = FinTSMessage.Create(client, client.HNHBS, client.HNHBK, segments, client.HIRMS); string response = await FinTSMessage.Send(client, message); Helper.Parse_Message(client, response); return(response); } }
/// <summary> /// End of dialog /// </summary> /// <param name="connectionDetails"></param> /// <param name="dialogID"></param> public static async Task <String> Init_HKEND(FinTsClient client, string dialogID) { Log.Write("Starting job HKEND: End of dialog"); var connectionDetails = client.ConnectionDetails; string segments = string.Empty; segments = "HKEND:" + SEG_NUM.Seg3 + "1+" + dialogID + "'"; client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg3); string message = FinTSMessage.Create(client, client.HNHBS, client.HNHBK, segments, client.HIRMS); return(await FinTSMessage.Send(client, message)); }
/// <summary> /// Request TAN medium name /// </summary> public static async Task <String> Init_HKTAB(FinTsClient client) { Log.Write("Starting job HKTAB: Request tan medium name"); var connectionDetails = client.ConnectionDetails; string segments = string.Empty; segments = "HKTAB:" + SEG_NUM.Seg3 + ":4+0+A'"; client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg3); string message = FinTSMessage.Create(client, client.HNHBS, client.HNHBK, segments, client.HIRMS); return(await FinTSMessage.Send(client, message)); }
/// <summary> /// Load prepaid /// </summary> public static string Init_HKPPD(int BLZ, string IBAN, string BIC, int MobileServiceProvider, string PhoneNumber, int Amount, string URL, int HBCIVersion, string UserID, string PIN) { Log.Write("Starting job HKPPD: Load prepaid"); string segments = "HKPPD:" + SEGNUM.SETVal(3) + ":2+" + IBAN + ":" + BIC + "+" + MobileServiceProvider + "+" + PhoneNumber + "+" + Amount + ",:EUR'"; segments = segments + "HKTAN:" + SEGNUM.SETVal(4) + ":" + Segment.HITANS + "'"; SEG.NUM = SEGNUM.SETInt(4); var TAN = FinTSMessage.Send(URL, FinTSMessage.Create(HBCIVersion, Segment.HNHBS, Segment.HNHBK, BLZ, UserID, PIN, Segment.HISYN, segments, Segment.HIRMS, SEG.NUM)); Segment.HITAN = Helper.Parse_String(Helper.Parse_String(TAN, "HITAN", "'").Replace("?+", "??"), "++", "+").Replace("??", "?+"); Helper.Parse_Message(TAN); return(TAN); }
/// <summary> /// Transfer terminated /// </summary> public static async Task <String> Init_HKCSE(FinTsClient client, string ReceiverName, string ReceiverIBAN, string ReceiverBIC, decimal Amount, string Usage, DateTime ExecutionDay) { Log.Write("Starting job HKCSE: Transfer money terminated"); var connectionDetails = client.ConnectionDetails; string segments = string.Empty; string sepaMessage = string.Empty; client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg3); if (client.HISPAS == 1) { segments = "HKCSE:" + client.SEGNUM + ":1+" + connectionDetails.Iban + ":" + connectionDetails.Bic + "+urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.001.001.03+@@"; sepaMessage = pain00100103.Create(connectionDetails.AccountHolder, connectionDetails.Iban, connectionDetails.Bic, ReceiverName, ReceiverIBAN, ReceiverBIC, Amount, Usage, ExecutionDay); } else if (client.HISPAS == 2) { segments = "HKCSE:" + client.SEGNUM + ":1+" + connectionDetails.Iban + ":" + connectionDetails.Bic + "+urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.001.002.03+@@"; sepaMessage = pain00100203.Create(connectionDetails.AccountHolder, connectionDetails.Iban, connectionDetails.Bic, ReceiverName, ReceiverIBAN, ReceiverBIC, Amount, Usage, ExecutionDay); } else if (client.HISPAS == 3) { segments = "HKCSE:" + client.SEGNUM + ":1+" + connectionDetails.Iban + ":" + connectionDetails.Bic + "+urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.001.003.03+@@"; sepaMessage = pain00100303.Create(connectionDetails.AccountHolder, connectionDetails.Iban, connectionDetails.Bic, ReceiverName, ReceiverIBAN, ReceiverBIC, Amount, Usage, ExecutionDay); } segments = segments.Replace("@@", "@" + (sepaMessage.Length - 1) + "@") + sepaMessage; if (Helper.IsTANRequired("HKCSE")) { client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg4); segments = HKTAN.Init_HKTAN(client, segments, "HKCSE"); } var message = FinTSMessage.Create(client, client.HNHBS, client.HNHBK, segments, client.HIRMS); var response = await FinTSMessage.Send(client, message); Helper.Parse_Message(client, response); return(response); }
/// <summary> /// Load prepaid /// </summary> public static async Task <String> Init_HKPPD(FinTsClient client, int MobileServiceProvider, string PhoneNumber, int Amount) { Log.Write("Starting job HKPPD: Load prepaid"); client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg3); var connectionDetails = client.ConnectionDetails; string segments = "HKPPD:" + client.SEGNUM + ":2+" + connectionDetails.Iban + ":" + connectionDetails.Bic + "+" + MobileServiceProvider + "+" + PhoneNumber + "+" + Amount + ",:EUR'"; if (Helper.IsTANRequired("HKPPD")) { client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg4); segments = HKTAN.Init_HKTAN(client, segments, "HKPPD"); } string message = FinTSMessage.Create(client, client.HNHBS, client.HNHBK, segments, client.HIRMS); var response = await FinTSMessage.Send(client, message); Helper.Parse_Message(client, response); return(response); }
/// <summary> /// Get bankers orders /// </summary> public static async Task <String> Init_HKCDB(FinTsClient client) { Log.Write("Starting job HKCDB: Get bankers order"); client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg3); var connectionDetails = client.ConnectionDetails; string segments = "HKCDB:" + client.SEGNUM + ":1+" + connectionDetails.Iban + ":" + connectionDetails.Bic + "+urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.001.001.03'"; if (Helper.IsTANRequired("HKCDB")) { client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg4); segments = HKTAN.Init_HKTAN(client, segments, "HKCDB"); } string message = FinTSMessage.Create(client, client.HNHBS, client.HNHBK, segments, client.HIRMS); string response = await FinTSMessage.Send(client, message); Helper.Parse_Message(client, response); return(response); }
public void Create_StateUnderTest_ExpectedBehavior() { // Arrange FinTsClient client = null; int MsgNum = 0; string DialogID = null; string Segments = null; string HIRMS_TAN = null; string SystemID = null; // Act var result = FinTSMessage.Create( client, MsgNum, DialogID, Segments, HIRMS_TAN, SystemID); // Assert Assert.True(false); }
/// <summary> /// Collect /// </summary> public static string Init_HKDSE(int BLZ, string Accountholder, string AccountholderIBAN, string AccountholderBIC, string Payer, string PayerIBAN, string PayerBIC, decimal Amount, string Usage, string SettlementDate, string MandateNumber, string MandateDate, string CeditorIDNumber, string URL, int HBCIVersion, string UserID, string PIN) { Log.Write("Starting job HKDSE: Collect money"); string segments = "HKDSE:" + SEGNUM.SETVal(3) + ":1+" + AccountholderIBAN + ":" + AccountholderBIC + "+urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.008.002.02+@@"; var message = pain00800202.Create(Accountholder, AccountholderIBAN, AccountholderBIC, Payer, PayerIBAN, PayerBIC, Amount, Usage, SettlementDate, MandateNumber, MandateDate, CeditorIDNumber); segments = segments.Replace("@@", "@" + (message.Length - 1) + "@") + message; segments = segments + "HKTAN:" + SEGNUM.SETVal(4) + ":" + Segment.HITANS + "'"; SEG.NUM = SEGNUM.SETInt(4); var TAN = FinTSMessage.Send(URL, FinTSMessage.Create(HBCIVersion, Segment.HNHBS, Segment.HNHBK, BLZ, UserID, PIN, Segment.HISYN, segments, Segment.HIRMS, SEG.NUM)); Segment.HITAN = Helper.Parse_String(Helper.Parse_String(TAN, "HITAN", "'").Replace("?+", "??"), "++", "+").Replace("??", "?+"); Helper.Parse_Message(TAN); return(TAN); }
/// <summary> /// TAN /// </summary> public static async Task <String> Send_TAN(FinTsClient client, string TAN) { Log.Write("Starting TAN process"); string segments = string.Empty; if (string.IsNullOrEmpty(client.HITAB)) // TAN Medium Name not set { // Version 2 if (client.HITANS == 2) { segments = "HKTAN:" + SEG_NUM.Seg3 + ":" + client.HITANS + "+2++" + client.HITAN + "++N'"; } // Version 3 else if (client.HITANS == 3) { segments = "HKTAN:" + SEG_NUM.Seg3 + ":" + client.HITANS + "+2++" + client.HITAN + "++N'"; } // Version 4 else if (client.HITANS == 4) { segments = "HKTAN:" + SEG_NUM.Seg3 + ":" + client.HITANS + "+2++" + client.HITAN + "++N'"; } // Version 5 else if (client.HITANS == 5) { segments = "HKTAN:" + SEG_NUM.Seg3 + ":" + client.HITANS + "+2++++" + client.HITAN + "++N'"; } // Version 6 else if (client.HITANS == 6) { segments = "HKTAN:" + SEG_NUM.Seg3 + ":" + client.HITANS + "+2++++" + client.HITAN + "+N'"; } // Version 7 -> decoupled // FinTS_3.0_Security_Sicherheitsverfahren_PINTAN_2020-07-10_final_version.pdf Seite 64 - 65 else if (client.HITANS == 7) { segments = "HKTAN:" + SEG_NUM.Seg3 + ":" + client.HITANS + "+S++++" + client.HITAN + "+N'"; } else // default { segments = "HKTAN:" + SEG_NUM.Seg3 + ":" + client.HITANS + "+2++++" + client.HITAN + "++N'"; } } else { // Version 2 if (client.HITANS == 2) { segments = "HKTAN:" + SEG_NUM.Seg3 + ":" + client.HITANS + "+2++" + client.HITAN + "++N++++" + client.HITAB + "'"; } // Version 3 else if (client.HITANS == 3) { segments = "HKTAN:" + SEG_NUM.Seg3 + ":" + client.HITANS + "+2++" + client.HITAN + "++N++++" + client.HITAB + "'"; } // Version 4 else if (client.HITANS == 4) { segments = "HKTAN:" + SEG_NUM.Seg3 + ":" + client.HITANS + "+2++" + client.HITAN + "++N++++" + client.HITAB + "'"; } // Version 5 else if (client.HITANS == 5) { segments = "HKTAN:" + SEG_NUM.Seg3 + ":" + client.HITANS + "+2++++" + client.HITAN + "++N++++" + client.HITAB + "'"; } // Version 6 else if (client.HITANS == 6) { segments = "HKTAN:" + SEG_NUM.Seg3 + ":" + client.HITANS + "+2++++" + client.HITAN + "+N++++" + client.HITAB + "'"; } // Version 7 -> decoupled // FinTS_3.0_Security_Sicherheitsverfahren_PINTAN_2020-07-10_final_version.pdf Seite 64 - 65 else if (client.HITANS == 7) { segments = "HKTAN:" + SEG_NUM.Seg3 + ":" + client.HITANS + "+S++++" + client.HITAN + "+N++++" + client.HITAB + "'"; } else // default { segments = "HKTAN:" + SEG_NUM.Seg3 + ":" + client.HITANS + "+2++" + client.HITAN + "++N++++" + client.HITAB + "'"; } } client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg3); string message = FinTSMessage.Create(client, client.HNHBS, client.HNHBK, segments, client.HIRMS + (TAN != null ? ":" + TAN : null)); string response = await FinTSMessage.Send(client, message); Helper.Parse_Message(client, response); return(response); }
/// <summary> /// Transactions in camt053 format /// </summary> public static async Task <String> Init_HKCAZ(FinTsClient client, string FromDate, string ToDate, string Startpoint, CamtVersion camtVers) { string segments = string.Empty; var connectionDetails = client.ConnectionDetails; client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg3); switch (camtVers) { case CamtVersion.Camt052: Log.Write("Starting job HKCAZ: Request transactions in camt052 format"); if (string.IsNullOrEmpty(FromDate)) { if (string.IsNullOrEmpty(Startpoint)) { segments = "HKCAZ:" + client.SEGNUM + ":" + client.HICAZS + "+" + connectionDetails.Iban + ":" + connectionDetails.Bic + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + CamtScheme.Camt052 + "+N'"; } else { segments = "HKCAZ:" + client.SEGNUM + ":" + client.HICAZS + "+" + connectionDetails.Iban + ":" + connectionDetails.Bic + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + CamtScheme.Camt052 + "+N++++" + Startpoint + "'"; } } else { if (string.IsNullOrEmpty(Startpoint)) { segments = "HKCAZ:" + client.SEGNUM + ":" + client.HICAZS + "+" + connectionDetails.Iban + ":" + connectionDetails.Bic + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + CamtScheme.Camt052 + "+N+" + FromDate + "+" + ToDate + "'"; } else { segments = "HKCAZ:" + client.SEGNUM + ":" + client.HICAZS + "+" + connectionDetails.Iban + ":" + connectionDetails.Bic + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + CamtScheme.Camt052 + "+N+" + FromDate + "+" + ToDate + "++" + Startpoint + "'"; } } client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg3); break; case CamtVersion.Camt053: Log.Write("Starting job HKCAZ: Request transactions in camt053 format"); if (string.IsNullOrEmpty(FromDate)) { if (string.IsNullOrEmpty(Startpoint)) { segments = "HKCAZ:" + client.SEGNUM + ":" + client.HICAZS + "+" + connectionDetails.Iban + ":" + connectionDetails.Bic + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + CamtScheme.Camt053 + "+N'"; } else { segments = "HKCAZ:" + client.SEGNUM + ":" + client.HICAZS + "+" + connectionDetails.Iban + ":" + connectionDetails.Bic + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + CamtScheme.Camt053 + "+N++++" + Startpoint + "'"; } } else { if (string.IsNullOrEmpty(Startpoint)) { segments = "HKCAZ:" + client.SEGNUM + ":" + client.HICAZS + "+" + connectionDetails.Iban + ":" + connectionDetails.Bic + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + CamtScheme.Camt053 + "+N+" + FromDate + "+" + ToDate + "'"; } else { segments = "HKCAZ:" + client.SEGNUM + ":" + client.HICAZS + "+" + connectionDetails.Iban + ":" + connectionDetails.Bic + ":" + connectionDetails.Account + "::280:" + connectionDetails.Blz + "+" + CamtScheme.Camt053 + "+N+" + FromDate + "+" + ToDate + "++" + Startpoint + "'"; } } break; default: // -> Will never happen, only for compiler return(string.Empty); } if (Helper.IsTANRequired("HKCAZ")) { client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg4); segments = HKTAN.Init_HKTAN(client, segments, "HKCAZ"); } string message = FinTSMessage.Create(client, client.HNHBS, client.HNHBK, segments, client.HIRMS); string response = await FinTSMessage.Send(client, message); Helper.Parse_Message(client, response); return(response); }
/// <summary> /// INI /// </summary> public static async Task <String> Init_INI(FinTsClient client, string hkTanSegmentId = null) { var connectionDetails = client.ConnectionDetails; if (!client.Anonymous) { /// <summary> /// Sync /// </summary> try { string segments; /// <summary> /// INI /// </summary> if (connectionDetails.HbciVersion == Convert.ToInt16(HBCI.v220)) { string segments_ = "HKIDN:" + SEG_NUM.Seg3 + ":2+" + SEG_Country.Germany + ":" + connectionDetails.BlzPrimary + "+" + connectionDetails.UserId + "+" + client.SystemId + "+1'" + "HKVVB:" + SEG_NUM.Seg4 + ":2+0+0+0+" + FinTsGlobals.ProductId + "+" + FinTsGlobals.Version + "'"; segments = segments_; } else if (connectionDetails.HbciVersion == Convert.ToInt16(HBCI.v300)) { string segments_ = "HKIDN:" + SEG_NUM.Seg3 + ":2+" + SEG_Country.Germany + ":" + connectionDetails.BlzPrimary + "+" + connectionDetails.UserId + "+" + client.SystemId + "+1'" + "HKVVB:" + SEG_NUM.Seg4 + ":3+0+0+0+" + FinTsGlobals.ProductId + "+" + FinTsGlobals.Version + "'"; if (client.HITANS == 6) { client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg5); segments_ = HKTAN.Init_HKTAN(client, segments_, hkTanSegmentId); } else { client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg4); } 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"); } var message = FinTSMessage.Create(client, 1, "0", segments, client.HIRMS); var response = await FinTSMessage.Send(client, message); Helper.Parse_Segments(client, response); return(response); } 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 == Convert.ToInt16(HBCI.v300)) { string segments_ = "HKIDN:" + SEG_NUM.Seg2 + ":2+" + SEG_Country.Germany + ":" + connectionDetails.BlzPrimary + "+" + "9999999999" + "+0+0'" + "HKVVB:" + SEG_NUM.Seg3 + ":3+0+0+1+" + FinTsGlobals.ProductId + "+" + FinTsGlobals.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"); } client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg4); string message = FinTsMessageAnonymous.Create(connectionDetails.HbciVersion, "1", "0", connectionDetails.Blz, connectionDetails.UserId, connectionDetails.Pin, "0", segments, null, client.SEGNUM); string response = await FinTSMessage.Send(client, message); var messages = Helper.Parse_Segments(client, response); var result = new HBCIDialogResult(messages, response); if (!result.IsSuccess) { Log.Write("Synchronisation anonymous failed. " + result); return(response); } // Sync OK Log.Write("Synchronisation anonymous ok"); /// <summary> /// INI /// </summary> if (connectionDetails.HbciVersion == Convert.ToInt16(HBCI.v300)) { string segments__ = "HKIDN:" + SEG_NUM.Seg3 + ":2+" + SEG_Country.Germany + ":" + connectionDetails.BlzPrimary + "+" + connectionDetails.UserId + "+" + client.SystemId + "+1'" + "HKVVB:" + SEG_NUM.Seg4 + ":3+0+0+0+" + FinTsGlobals.ProductId + "+" + FinTsGlobals.Version + "'" + "HKSYN:" + SEG_NUM.Seg5 + ":3+0'"; segments = segments__; } else { Log.Write("HBCI version not supported"); throw new Exception("HBCI version not supported"); } client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg5); message = FinTSMessage.Create(client, 1, "0", segments, client.HIRMS); response = await FinTSMessage.Send(client, message); Helper.Parse_Segments(client, response); return(response); } 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> /// Transactions /// </summary> public static async Task <String> Init_HKKAZ(FinTsClient client, string FromDate, string ToDate, string Startpoint) { Log.Write("Starting job HKKAZ: Request transactions"); var connectionDetails = client.ConnectionDetails; string segments = string.Empty; AccountInformation activeAccount; if (client.activeAccount != null) { activeAccount = client.activeAccount; } else { activeAccount = new AccountInformation() { AccountNumber = connectionDetails.Account, AccountBankCode = connectionDetails.Blz.ToString(), AccountIban = connectionDetails.Iban, AccountBic = connectionDetails.Bic, } }; client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg3); if (string.IsNullOrEmpty(FromDate)) { if (string.IsNullOrEmpty(Startpoint)) { if (Convert.ToInt16(client.HIKAZS) < 7) { segments = "HKKAZ:" + client.SEGNUM + ":" + client.HIKAZS + "+" + activeAccount.AccountNumber + "::280:" + activeAccount.AccountBankCode + "+N'"; } else { segments = "HKKAZ:" + client.SEGNUM + ":" + client.HIKAZS + "+" + activeAccount.AccountIban + ":" + activeAccount.AccountBic + ":" + activeAccount.AccountNumber + "::280:" + activeAccount.AccountBankCode + "+N'"; } } else { if (Convert.ToInt16(client.HIKAZS) < 7) { segments = "HKKAZ:" + client.SEGNUM + ":" + client.HIKAZS + "+" + activeAccount.AccountNumber + "::280:" + activeAccount.AccountBankCode + "+N++++" + Startpoint + "'"; } else { segments = "HKKAZ:" + client.SEGNUM + ":" + client.HIKAZS + "+" + activeAccount.AccountIban + ":" + activeAccount.AccountBic + ":" + activeAccount.AccountNumber + "::280:" + activeAccount.AccountBankCode + "+N++++" + Startpoint + "'"; } } } else { if (string.IsNullOrEmpty(Startpoint)) { if (Convert.ToInt16(client.HIKAZS) < 7) { segments = "HKKAZ:" + client.SEGNUM + ":" + client.HIKAZS + "+" + activeAccount.AccountNumber + "::280:" + activeAccount.AccountBankCode + "+N+" + FromDate + "+" + ToDate + "'"; } else { segments = "HKKAZ:" + client.SEGNUM + ":" + client.HIKAZS + "+" + activeAccount.AccountIban + ":" + activeAccount.AccountBic + ":" + activeAccount.AccountNumber + "::280:" + activeAccount.AccountBankCode + "+N+" + FromDate + "+" + ToDate + "'"; } } else { if (Convert.ToInt16(client.HIKAZS) < 7) { segments = "HKKAZ:" + client.SEGNUM + ":" + client.HIKAZS + "+" + activeAccount.AccountNumber + "::280:" + activeAccount.AccountBankCode + "+N+" + FromDate + "+" + ToDate + "++" + Startpoint + "'"; } else { segments = "HKKAZ:" + client.SEGNUM + ":" + client.HIKAZS + "+" + activeAccount.AccountIban + ":" + activeAccount.AccountBic + ":" + activeAccount.AccountNumber + "::280:" + activeAccount.AccountBankCode + "+N+" + FromDate + "+" + ToDate + "++" + Startpoint + "'"; } } } if (Helper.IsTANRequired("HKKAZ")) { client.SEGNUM = Convert.ToInt16(SEG_NUM.Seg4); segments = HKTAN.Init_HKTAN(client, segments, "HKKAZ"); } string message = FinTSMessage.Create(client, client.HNHBS, client.HNHBK, segments, client.HIRMS); string response = await FinTSMessage.Send(client, message); Helper.Parse_Message(client, response); return(response); } }