3using System.Collections.Generic;
5using System.Threading.Tasks;
30 internal const string EDalerBalanceKeyPrefix =
"EDaler.Balance.";
31 internal const string EDalerRemoteKeyPrefix =
"EDaler.Remote.Key.";
34 private readonly
string componentAddress;
103 public Task
GetBalance(EventHandlerAsync<BalanceIqResultEventArgs> Callback,
object State)
105 return this.
GetBalance(this.componentAddress, Callback, State);
116 StringBuilder Xml =
new StringBuilder();
118 Xml.Append(
"<balance xmlns='");
122 return this.
client.
SendIqGet(ComponentAddress, Xml.ToString(), async (Sender, e) =>
128 !((E = e.FirstElement) is
null) &&
129 E.LocalName ==
"balance" &&
132 Balance = await this.ParseBalance(E);
137 await this.BalanceReported(Balance);
152 string LastBalanceKey = EDalerBalanceKeyPrefix + this.
client.
BareJID;
153 if (this.balance is
null)
156 bool Changed =
false;
158 if (this.balance is
null ||
162 if (this.balance is
null)
168 Timestamp = Balance.Timestamp
183 List<PendingPayment> Pending =
new List<PendingPayment>();
184 DateTime Today = DateTime.Today;
194 Pending.Add(Payment);
198 this.balance.Pending = Pending.ToArray();
221 TaskCompletionSource<Balance> Result =
new TaskCompletionSource<Balance>();
223 await this.
GetBalance(ComponentAddress, async (Sender, e) =>
227 await this.BalanceReported(e.Balance);
228 Result.TrySetResult(e.Balance);
231 Result.TrySetException(e.StanzaError ??
new Exception(
"Unable to get current balance."));
235 return await Result.Task;
240 if (e.
From !=
this.componentAddress)
244 await this.BalanceReported(
Balance);
249 private async Task<Balance> ParseBalance(XmlElement Xml)
252 DateTime? Timestamp =
null;
254 decimal Reserved = 0;
257 foreach (XmlAttribute Attr
in Xml.Attributes)
276 Currency = Attr.
Value;
288 if (!
Balance.HasValue || Currency is
null || !Timestamp.HasValue)
291 foreach (XmlNode N
in Xml.ChildNodes)
293 if (N is XmlElement E && E.LocalName ==
"event" && E.NamespaceURI ==
NamespaceEDaler)
319 public Task
SendEDalerUri(
string Uri, EventHandlerAsync<TransactionEventArgs> Callback,
object State)
321 return this.
SendEDalerUri(this.componentAddress, Uri, Callback, State);
333 StringBuilder Xml =
new StringBuilder();
335 Xml.Append(
"<uri xmlns=\"");
339 Xml.Append(
"</uri>");
341 return this.
client.
SendIqSet(ComponentAddress, Xml.ToString(), async (Sender, e) =>
343 if (Callback is
null)
350 if (e.FirstElement is null ||
351 e.FirstElement.LocalName !=
"tr" ||
352 e.FirstElement.NamespaceURI != NamespaceEDaler)
371 return this.SendEDalerUriAsync(this.componentAddress, Uri);
381 TaskCompletionSource<Transaction> Result =
new TaskCompletionSource<Transaction>();
383 await this.SendEDalerUri(ComponentAddress, Uri, (Sender, e) =>
386 Result.TrySetResult(e.Transaction);
390 Result.TrySetException(
new Exception(
"Unable to process eDaler URI."));
392 return Task.CompletedTask;
395 return await Result.Task;
400 #region eDaler Account events
408 public Task
GetAccountEvents(
int MaxEvents, EventHandlerAsync<AccountEventsEventArgs> Callback,
object State)
410 return this.GetAccountEvents(this.componentAddress, MaxEvents, DateTime.MaxValue, Callback, State);
420 public Task
GetAccountEvents(
string ComponentAddress,
int MaxEvents, EventHandlerAsync<AccountEventsEventArgs> Callback,
object State)
422 return this.GetAccountEvents(ComponentAddress, MaxEvents, DateTime.MaxValue, Callback, State);
432 public Task
GetAccountEvents(
int MaxEvents, DateTime From, EventHandlerAsync<AccountEventsEventArgs> Callback,
object State)
434 return this.GetAccountEvents(this.componentAddress, MaxEvents, From, Callback, State);
445 public Task
GetAccountEvents(
string ComponentAddress,
int MaxEvents, DateTime From, EventHandlerAsync<AccountEventsEventArgs> Callback,
object State)
447 StringBuilder Xml =
new StringBuilder();
449 Xml.Append(
"<events xmlns=\"");
450 Xml.Append(NamespaceEDaler);
451 Xml.Append(
"\" maxCount=\"");
452 Xml.Append(MaxEvents.ToString());
454 if (From != DateTime.MaxValue)
456 Xml.Append(
"\" from=\"");
462 return this.client.SendIqGet(ComponentAddress, Xml.ToString(), async (Sender, e) =>
464 List<AccountEvent> Events =
new List<AccountEvent>();
469 if (e.FirstElement is
null ||
470 e.FirstElement.LocalName !=
"events" ||
471 e.FirstElement.NamespaceURI != NamespaceEDaler)
477 foreach (XmlNode N
in e.FirstElement.ChildNodes)
479 if (!(N is XmlElement E) || E.NamespaceURI != NamespaceEDaler)
509 return this.GetAccountEventsAsync(this.componentAddress, MaxEvents, DateTime.MaxValue);
520 return this.GetAccountEventsAsync(ComponentAddress, MaxEvents, DateTime.MaxValue);
531 return this.GetAccountEventsAsync(this.componentAddress, MaxEvents, From);
545 await this.GetAccountEvents(ComponentAddress, MaxEvents, From, async (Sender, e) =>
551 if (this.balance is null)
552 await this.GetBalanceAsync();
554 if (!(this.balance.Pending is null) && this.balance.Pending.Length > 0)
556 Dictionary<Guid, PendingPayment> Pending = new Dictionary<Guid, PendingPayment>();
557 DateTime Today = DateTime.Today;
558 bool Changed = false;
560 foreach (PendingPayment Payment in this.balance.Pending)
562 if (Payment.Expires.AddDays(1) < Today)
565 Pending[Payment.Id] = Payment;
568 foreach (AccountEvent Event in e.Events)
570 if (Pending.Remove(Event.TransactionId))
576 PendingPayment[] Pending2 = new PendingPayment[Pending.Count];
577 Pending.Values.CopyTo(Pending2, 0);
578 this.balance.Pending = Pending2;
580 await RuntimeSettings.SetAsync(EDalerBalanceKeyPrefix + this.client.BareJID, this.balance);
584 Result.TrySetResult((e.Events, e.More));
588 Result.TrySetException(ex);
594 Result.TrySetException(
new Exception(
"Unable to process eDaler URI."));
598 return await Result.Task;
616 return this.CreateFullPaymentUri(
string.Empty, Amount, AmountExtra, Currency, ValidNrDays,
string.Empty);
631 return this.CreateFullPaymentUri(ToBareJid, Amount, AmountExtra, Currency, ValidNrDays,
string.Empty);
647 await this.ValidatePaymentArguments(Amount, AmountExtra, Currency, ValidNrDays);
649 StringBuilder Uri =
new StringBuilder();
650 DateTime Created = DateTime.UtcNow;
651 DateTime Expires = DateTime.Today.AddDays(ValidNrDays);
652 Guid Id = Guid.NewGuid();
654 Uri.Append(
"edaler:id=");
655 Uri.Append(Id.ToString());
657 Uri.Append(
XML.
Encode(
this.client.BareJID));
659 if (!
string.IsNullOrEmpty(ToBareJid))
661 if (ToBareJid.IndexOf(
'@') < 0)
676 if (AmountExtra.HasValue)
689 if (!
string.IsNullOrEmpty(Message))
692 Uri.Append(Convert.ToBase64String(Encoding.UTF8.GetBytes(Message)));
695 await this.SignAndCheckBalance(Uri, Amount, AmountExtra, Currency, Id, Expires, ToBareJid);
697 return Uri.ToString();
700 private async Task ValidatePaymentArguments(decimal Amount, decimal? AmountExtra,
CaseInsensitiveString Currency,
int ValidNrDays)
702 if (ValidNrDays <= 0)
703 throw new ArgumentException(
"Must be a positive integer.", nameof(ValidNrDays));
706 throw new ArgumentException(
"Amount must be positive.", nameof(Amount));
708 if (AmountExtra.HasValue && AmountExtra.Value <= 0)
709 throw new ArgumentException(
"Amount must be positive.", nameof(AmountExtra));
711 if (this.balance is
null)
712 await this.GetBalanceAsync();
716 throw new ArgumentException(
"Currency does not correspond to currency of wallet.", nameof(Currency));
719 private async Task SignAndCheckBalance(StringBuilder Uri, decimal Amount, decimal? AmountExtra,
string Currency,
720 Guid Id, DateTime Expires,
string To)
722 byte[] PreSign = Encoding.UTF8.GetBytes(Uri.ToString());
723 byte[]
Signature = await this.contractsClient.SignAsync(PreSign,
SignWith.LatestApprovedId);
726 Uri.Append(Convert.ToBase64String(
Signature));
729 DateTime Today = DateTime.Today;
730 List<PendingPayment> Pending;
731 decimal PendingAmount;
736 Pending =
new List<PendingPayment>();
739 if (!(
Balance.Pending is
null))
751 if (Amount + (AmountExtra ?? 0) + PendingAmount >
Balance.
Balance)
753 StringBuilder Msg =
new StringBuilder();
755 Msg.Append(
"Amount larger than current balance. Amount: ");
756 Msg.Append(Amount.ToString());
758 if (AmountExtra.HasValue)
760 Msg.Append(
". Extra: ");
761 Msg.Append(AmountExtra.Value.ToString());
764 if (PendingAmount > 0)
766 Msg.Append(
". Pending: ");
767 Msg.Append(PendingAmount.ToString());
770 Msg.Append(
". Balance: ");
773 Msg.Append(
". Difference: ");
774 Msg.Append((
Balance.
Balance - Amount - (AmountExtra ?? 0) - PendingAmount).ToString());
776 throw new InvalidOperationException(Msg.ToString());
784 Amount = Amount + (AmountExtra ?? 0),
785 From = this.client.BareJID,
790 Balance.Pending = Pending.ToArray();
794 while (this.balance !=
Balance);
809 return this.CreateFullPaymentUri(ToLegalId, Amount, AmountExtra, Currency, ValidNrDays,
string.Empty);
826 if (ToLegalId is
null)
827 throw new ArgumentNullException(
"Legal ID cannot be null.", nameof(ToLegalId));
830 throw new ArgumentNullException(
"Legal ID lacks a public key.", nameof(ToLegalId));
832 await this.ValidatePaymentArguments(Amount, AmountExtra, Currency, ValidNrDays);
834 StringBuilder Uri =
new StringBuilder();
835 DateTime Created = DateTime.UtcNow;
836 DateTime Expires = DateTime.Today.AddDays(ValidNrDays);
837 Guid Id = Guid.NewGuid();
839 byte[] MessageBin = Encoding.UTF8.GetBytes(PrivateMessage ??
string.Empty);
840 (
byte[] EncryptedMessage,
byte[] LocalPublicKey) = this.contractsClient.Encrypt(MessageBin, Id.ToByteArray(), ToLegalId.
ClientPubKey, ToLegalId.
ClientKeyName);
843 string FromLegalId = await this.contractsClient.GetLatestApprovedLegalId(LocalPublicKey);
845 Uri.Append(
"edaler:id=");
846 Uri.Append(Id.ToString());
848 if (FromLegalId is
null)
851 Uri.Append(
XML.
Encode(
this.client.BareJID));
864 if (AmountExtra.HasValue)
877 if (!
string.IsNullOrEmpty(PrivateMessage))
880 Uri.Append(Convert.ToBase64String(EncryptedMessage));
882 Uri.Append(Convert.ToBase64String(LocalPublicKey));
885 await this.SignAndCheckBalance(Uri, Amount, AmountExtra, Currency, Id, Expires, ToLegalId.
Id);
887 return Uri.ToString();
901 return this.CreateIncompletePayMeUri(BareJid,
"t", Amount, AmountExtra, Currency, Message);
916 string Currency,
string PrivateMessage)
918 return this.CreateIncompletePayMeUri(Id.
Id,
"ti", Amount, AmountExtra, Currency, PrivateMessage);
921 private string CreateIncompletePayMeUri(
string To,
string ToType, decimal? Amount, decimal? AmountExtra,
922 string Currency,
string Message)
924 StringBuilder Uri =
new StringBuilder();
926 Uri.Append(
"edaler:cu=");
927 Uri.Append(Currency);
935 if (AmountExtra.HasValue)
946 if (!
string.IsNullOrEmpty(Message))
949 Uri.Append(Convert.ToBase64String(Encoding.UTF8.GetBytes(Message)));
952 return Uri.ToString();
962 public async Task<string>
DecryptMessage(
byte[] EncryptedMessage,
byte[] PublicKey, Guid TransactionId)
964 if (EncryptedMessage is
null)
967 if (PublicKey is
null)
968 return Encoding.UTF8.GetString(EncryptedMessage);
974 if (PublicKey is
null)
975 Decrypted = EncryptedMessage;
977 Decrypted = await this.contractsClient.Decrypt(EncryptedMessage, PublicKey, TransactionId.ToByteArray());
979 return Encoding.UTF8.GetString(Decrypted);
995 public async Task<string>
DecryptMessage(
byte[] EncryptedMessage,
byte[] PublicKey, Guid TransactionId,
string RemoteEndpoint)
997 if (!
string.IsNullOrEmpty(RemoteEndpoint) && !(PublicKey is
null))
1001 if (!
string.IsNullOrEmpty(RemotePublicKey))
1005 PublicKey = Convert.FromBase64String(RemotePublicKey);
1007 catch (Exception ex)
1014 return await this.DecryptMessage(EncryptedMessage, PublicKey, TransactionId);
1019 #region Pending Payments
1027 if (this.balance is
null)
1028 await this.GetBalanceAsync();
1030 List<PendingPayment> PendingPayments =
new List<PendingPayment>();
1031 DateTime Today = DateTime.Today;
1033 decimal PendingAmount = 0;
1035 if (!(
Balance.Pending is
null))
1049 Uri = PendingPayment.Uri
1062 #region Service Providers for buying eDaler
1071 return this.GetServiceProvidersForBuyingEDaler(this.componentAddress, Callback, State);
1081 EventHandlerAsync<BuyEDalerServiceProvidersEventArgs> Callback,
object State)
1083 StringBuilder Xml =
new StringBuilder();
1085 Xml.Append(
"<buyEDalerProviders xmlns='");
1086 Xml.Append(NamespaceEDaler);
1089 return this.client.SendIqGet(ComponentAddress, Xml.ToString(), async (Sender, e) =>
1091 List<IBuyEDalerServiceProvider> Providers =
null;
1095 !((E = e.FirstElement) is
null) &&
1096 E.LocalName ==
"providers" &&
1097 E.NamespaceURI == NamespaceEDaler)
1099 Providers = new List<IBuyEDalerServiceProvider>();
1101 foreach (XmlNode N in E.ChildNodes)
1103 if (N is XmlElement E2 &&
1104 E2.LocalName ==
"provider" &&
1105 E2.NamespaceURI == NamespaceEDaler)
1107 IBuyEDalerServiceProvider Provider = this.ParseServiceProvider<BuyEDalerServiceProvider>(E2);
1109 if (!(Provider is null))
1110 Providers.Add(Provider);
1122 private T ParseServiceProvider<T>(XmlElement Xml)
1128 string IconUrl =
null;
1129 string TemplateId =
null;
1131 int IconHeight = -1;
1133 foreach (XmlAttribute Attr
in Xml.Attributes)
1150 IconUrl = Attr.Value;
1154 if (!
int.TryParse(Attr.Value, out
int i))
1161 if (!
int.TryParse(Attr.Value, out i))
1168 TemplateId = Attr.Value;
1173 if (Id is
null || Type is
null || Name is
null)
1176 if (
string.IsNullOrEmpty(IconUrl))
1179 return (T)Temp.Create(Id, Type, Name, TemplateId);
1183 if (IconWidth < 0 || IconHeight < 0)
1187 return (T)Temp.Create(Id, Type, Name, IconUrl, IconWidth, IconHeight, TemplateId);
1196 return this.GetServiceProvidersForBuyingEDalerAsync(this.componentAddress);
1205 TaskCompletionSource<IBuyEDalerServiceProvider[]> Providers =
new TaskCompletionSource<IBuyEDalerServiceProvider[]>();
1207 await this.GetServiceProvidersForBuyingEDaler(ComponentAddress, (Sender, e) =>
1210 Providers.TrySetResult(e.ServiceProviders);
1212 Providers.TrySetException(e.
StanzaError ??
new Exception(
"Unable to get service providers."));
1214 return Task.CompletedTask;
1218 return await Providers.Task;
1223 #region Service Providers for selling eDaler
1232 return this.GetServiceProvidersForSellingEDaler(this.componentAddress, Callback, State);
1242 EventHandlerAsync<SellEDalerServiceProvidersEventArgs> Callback,
object State)
1244 StringBuilder Xml =
new StringBuilder();
1246 Xml.Append(
"<sellEDalerProviders xmlns='");
1247 Xml.Append(NamespaceEDaler);
1250 return this.client.SendIqGet(ComponentAddress, Xml.ToString(), async (Sender, e) =>
1252 List<ISellEDalerServiceProvider> Providers =
null;
1256 !((E = e.FirstElement) is
null) &&
1257 E.LocalName ==
"providers" &&
1258 E.NamespaceURI == NamespaceEDaler)
1260 Providers = new List<ISellEDalerServiceProvider>();
1262 foreach (XmlNode N in E.ChildNodes)
1264 if (N is XmlElement E2 &&
1265 E2.LocalName ==
"provider" &&
1266 E2.NamespaceURI == NamespaceEDaler)
1268 ISellEDalerServiceProvider Provider = this.ParseServiceProvider<SellEDalerServiceProvider>(E2);
1270 if (!(Provider is null))
1271 Providers.Add(Provider);
1288 return this.GetServiceProvidersForSellingEDalerAsync(this.componentAddress);
1297 TaskCompletionSource<ISellEDalerServiceProvider[]> Providers =
new TaskCompletionSource<ISellEDalerServiceProvider[]>();
1299 await this.GetServiceProvidersForSellingEDaler(ComponentAddress, (Sender, e) =>
1302 Providers.TrySetResult(e.ServiceProviders);
1304 Providers.TrySetException(e.
StanzaError ??
new Exception(
"Unable to get service providers."));
1306 return Task.CompletedTask;
1310 return await Providers.Task;
1315 #region Initiation of getting Payment options for buying eDaler using smart contracts
1325 EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
1327 return this.InitiateGetOptionsBuyEDaler(this.componentAddress, ServiceId,
ServiceProvider, Callback, State);
1339 EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
1341 return this.InitiateGetOptionsBuyEDaler(ComponentAddress, ServiceId,
ServiceProvider,
null,
null,
null,
null, Callback, State);
1356 string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl, EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
1358 return this.InitiateGetOptionsBuyEDaler(this.componentAddress, ServiceId,
ServiceProvider, TransactionId, SuccessUrl, FailureUrl, CancelUrl, Callback, State);
1374 string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl, EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
1376 if (!
string.IsNullOrEmpty(SuccessUrl))
1377 SuccessUrl = SuccessUrl.Replace(
"{TID}", TransactionId);
1379 if (!
string.IsNullOrEmpty(FailureUrl))
1380 FailureUrl = FailureUrl.Replace(
"{TID}", TransactionId);
1382 if (!
string.IsNullOrEmpty(CancelUrl))
1383 CancelUrl = CancelUrl.Replace(
"{TID}", TransactionId);
1385 StringBuilder Xml =
new StringBuilder();
1387 Xml.Append(
"<initiateGetOptionsBuyEDaler xmlns='");
1388 Xml.Append(NamespaceEDaler);
1389 Xml.Append(
"' serviceId='");
1391 Xml.Append(
"' serviceProvider='");
1394 if (!
string.IsNullOrEmpty(TransactionId))
1396 Xml.Append(
"' tid='");
1400 if (!
string.IsNullOrEmpty(SuccessUrl))
1402 Xml.Append(
"' successUrl='");
1406 if (!
string.IsNullOrEmpty(FailureUrl))
1408 Xml.Append(
"' failureUrl='");
1412 if (!
string.IsNullOrEmpty(CancelUrl))
1414 Xml.Append(
"' cancelUrl='");
1420 return this.client.SendIqSet(ComponentAddress, Xml.ToString(), async (Sender, e) =>
1422 TransactionId =
null;
1426 !((E = e.FirstElement) is
null) &&
1427 E.LocalName ==
"transaction" &&
1428 E.NamespaceURI == NamespaceEDaler)
1430 TransactionId = XML.Attribute(E,
"tid");
1450 return this.InitiateGetOptionsBuyEDalerAsync(this.componentAddress, ServiceId,
ServiceProvider,
null,
null,
null,
null);
1466 string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl)
1468 return this.InitiateGetOptionsBuyEDalerAsync(this.componentAddress, ServiceId,
ServiceProvider, TransactionId, SuccessUrl, FailureUrl, CancelUrl);
1485 string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl)
1487 TaskCompletionSource<string> Result =
new TaskCompletionSource<string>();
1489 await this.InitiateGetOptionsBuyEDaler(ComponentAddress, ServiceId,
ServiceProvider, TransactionId, SuccessUrl, FailureUrl, CancelUrl,
1493 Result.TrySetResult(e.TransactionId);
1495 Result.TrySetException(e.
StanzaError ??
new Exception(
"Unable to initiate payment process."));
1497 return Task.CompletedTask;
1500 return await Result.Task;
1503 private Task BuyEDalerOptionsClientUrlEventHandler(
object Sender,
MessageEventArgs e)
1519 private async Task BuyEDalerOptionsCompletedEventHandler(
object Sender,
MessageEventArgs e)
1522 List<Dictionary<CaseInsensitiveString, object>> Options =
new List<Dictionary<CaseInsensitiveString, object>>();
1524 foreach (XmlNode N
in e.
Content.ChildNodes)
1526 if (N is XmlElement E && E.LocalName ==
"option" && E.NamespaceURI == NamespaceEDaler)
1528 Dictionary<CaseInsensitiveString, object> Option =
new Dictionary<CaseInsensitiveString, object>();
1531 foreach (XmlNode N2
in E.ChildNodes)
1533 if (N2 is XmlElement E2 && E2.LocalName ==
"variable" && E2.NamespaceURI == NamespaceEDaler)
1536 object Value = await ParseVariable(E2,
Variables);
1538 Option[Name] = Value;
1542 Options.Add(Option);
1546 await this.BuyEDalerOptionsCompleted.Raise(
this,
new PaymentOptionsEventArgs(e, TransactionId, Options.ToArray()));
1549 private async
static Task<object> ParseVariable(XmlElement VariableDefinition,
Variables Variables)
1551 object Value =
null;
1553 foreach (XmlNode N2
in VariableDefinition.ChildNodes)
1555 if (!(N2 is XmlElement E2))
1558 switch (E2.LocalName)
1580 if (sbyte.TryParse(E2.InnerText, out sbyte i8))
1585 if (
short.TryParse(E2.InnerText, out
short i16))
1590 if (
int.TryParse(E2.InnerText, out
int i32))
1595 if (
long.TryParse(E2.InnerText, out
long i64))
1600 if (
byte.TryParse(E2.InnerText, out
byte ui8))
1605 if (ushort.TryParse(E2.InnerText, out ushort ui16))
1610 if (uint.TryParse(E2.InnerText, out uint ui32))
1615 if (ulong.TryParse(E2.InnerText, out ulong ui64))
1630 if (
XML.
TryParse(E2.InnerText, out DateTimeOffset TPO))
1635 if (TimeSpan.TryParse(E2.InnerText, out TimeSpan TS))
1645 Value = E2.InnerText;
1656 Value = E2.InnerText;
1671 private Task BuyEDalerOptionsErrorEventHandler(
object Sender,
MessageEventArgs e)
1674 string Error = e.
Content.InnerText;
1687 #region Initiation of getting Payment options for selling eDaler using smart contracts
1697 EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
1699 return this.InitiateGetOptionsSellEDaler(this.componentAddress, ServiceId,
ServiceProvider, Callback, State);
1711 EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
1713 return this.InitiateGetOptionsSellEDaler(ComponentAddress, ServiceId,
ServiceProvider,
null,
null,
null,
null, Callback, State);
1728 string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl, EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
1730 return this.InitiateGetOptionsSellEDaler(this.componentAddress, ServiceId,
ServiceProvider, TransactionId, SuccessUrl, FailureUrl, CancelUrl, Callback, State);
1746 string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl, EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
1748 if (!
string.IsNullOrEmpty(SuccessUrl))
1749 SuccessUrl = SuccessUrl.Replace(
"{TID}", TransactionId);
1751 if (!
string.IsNullOrEmpty(FailureUrl))
1752 FailureUrl = FailureUrl.Replace(
"{TID}", TransactionId);
1754 if (!
string.IsNullOrEmpty(CancelUrl))
1755 CancelUrl = CancelUrl.Replace(
"{TID}", TransactionId);
1757 StringBuilder Xml =
new StringBuilder();
1759 Xml.Append(
"<initiateGetOptionsSellEDaler xmlns='");
1760 Xml.Append(NamespaceEDaler);
1761 Xml.Append(
"' serviceId='");
1763 Xml.Append(
"' serviceProvider='");
1766 if (!
string.IsNullOrEmpty(TransactionId))
1768 Xml.Append(
"' tid='");
1772 if (!
string.IsNullOrEmpty(SuccessUrl))
1774 Xml.Append(
"' successUrl='");
1778 if (!
string.IsNullOrEmpty(FailureUrl))
1780 Xml.Append(
"' failureUrl='");
1784 if (!
string.IsNullOrEmpty(CancelUrl))
1786 Xml.Append(
"' cancelUrl='");
1792 return this.client.SendIqSet(ComponentAddress, Xml.ToString(), (Sender, e) =>
1794 TransactionId = null;
1798 !((E = e.FirstElement) is null) &&
1799 E.LocalName ==
"transaction" &&
1800 E.NamespaceURI == NamespaceEDaler)
1802 TransactionId = XML.Attribute(E,
"tid");
1822 return this.InitiateGetOptionsSellEDalerAsync(this.componentAddress, ServiceId,
ServiceProvider,
null,
null,
null,
null);
1838 string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl)
1840 return this.InitiateGetOptionsSellEDalerAsync(this.componentAddress, ServiceId,
ServiceProvider, TransactionId, SuccessUrl, FailureUrl, CancelUrl);
1857 string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl)
1859 TaskCompletionSource<string> Result =
new TaskCompletionSource<string>();
1861 await this.InitiateGetOptionsSellEDaler(ComponentAddress, ServiceId,
ServiceProvider, TransactionId, SuccessUrl, FailureUrl, CancelUrl,
1865 Result.TrySetResult(e.TransactionId);
1867 Result.TrySetException(e.
StanzaError ??
new Exception(
"Unable to initiate payment process."));
1869 return Task.CompletedTask;
1872 return await Result.Task;
1875 private Task SellEDalerOptionsClientUrlEventHandler(
object Sender,
MessageEventArgs e)
1891 private async Task SellEDalerOptionsCompletedEventHandler(
object Sender,
MessageEventArgs e)
1894 List<Dictionary<CaseInsensitiveString, object>> Options =
new List<Dictionary<CaseInsensitiveString, object>>();
1896 foreach (XmlNode N
in e.
Content.ChildNodes)
1898 if (N is XmlElement E && E.LocalName ==
"option" && E.NamespaceURI == NamespaceEDaler)
1900 Dictionary<CaseInsensitiveString, object> Option =
new Dictionary<CaseInsensitiveString, object>();
1903 foreach (XmlNode N2
in E.ChildNodes)
1905 if (N2 is XmlElement E2 && E2.LocalName ==
"variable" && E2.NamespaceURI == NamespaceEDaler)
1908 object Value = await ParseVariable(E2,
Variables);
1910 Option[Name] = Value;
1914 Options.Add(Option);
1918 await this.SellEDalerOptionsCompleted.Raise(
this,
new PaymentOptionsEventArgs(e, TransactionId, Options.ToArray()));
1927 private Task SellEDalerOptionsErrorEventHandler(
object Sender,
MessageEventArgs e)
1930 string Error = e.
Content.InnerText;
1943 #region Initiation of buying eDaler using non-contract based services
1955 decimal Amount,
string Currency, EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
1957 return this.InitiateBuyEDaler(this.componentAddress, ServiceId,
ServiceProvider, Amount, Currency, Callback, State);
1971 decimal Amount,
string Currency, EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
1973 return this.InitiateBuyEDaler(ComponentAddress, ServiceId,
ServiceProvider, Amount, Currency,
null,
null,
null,
null, Callback, State);
1990 decimal Amount,
string Currency,
string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl, EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
1992 return this.InitiateBuyEDaler(this.componentAddress, ServiceId,
ServiceProvider, Amount, Currency, TransactionId, SuccessUrl, FailureUrl, CancelUrl, Callback, State);
2010 decimal Amount,
string Currency,
string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl, EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
2012 if (!
string.IsNullOrEmpty(SuccessUrl))
2013 SuccessUrl = SuccessUrl.Replace(
"{TID}", TransactionId);
2015 if (!
string.IsNullOrEmpty(FailureUrl))
2016 FailureUrl = FailureUrl.Replace(
"{TID}", TransactionId);
2018 if (!
string.IsNullOrEmpty(CancelUrl))
2019 CancelUrl = CancelUrl.Replace(
"{TID}", TransactionId);
2021 StringBuilder Xml =
new StringBuilder();
2023 Xml.Append(
"<initiateBuyEDaler xmlns='");
2024 Xml.Append(NamespaceEDaler);
2025 Xml.Append(
"' serviceId='");
2027 Xml.Append(
"' serviceProvider='");
2029 Xml.Append(
"' amount='");
2031 Xml.Append(
"' currency='");
2034 if (!
string.IsNullOrEmpty(TransactionId))
2036 Xml.Append(
"' tid='");
2040 if (!
string.IsNullOrEmpty(SuccessUrl))
2042 Xml.Append(
"' successUrl='");
2046 if (!
string.IsNullOrEmpty(FailureUrl))
2048 Xml.Append(
"' failureUrl='");
2052 if (!
string.IsNullOrEmpty(CancelUrl))
2054 Xml.Append(
"' cancelUrl='");
2060 return this.client.SendIqSet(ComponentAddress, Xml.ToString(), (Sender, e) =>
2062 TransactionId = null;
2066 !((E = e.FirstElement) is null) &&
2067 E.LocalName ==
"transaction" &&
2068 E.NamespaceURI == NamespaceEDaler)
2070 TransactionId = XML.Attribute(E,
"tid");
2092 return this.InitiateBuyEDalerAsync(this.componentAddress, ServiceId,
ServiceProvider, Amount, Currency);
2107 decimal Amount,
string Currency)
2109 return this.InitiateBuyEDalerAsync(ComponentAddress, ServiceId,
ServiceProvider, Amount, Currency,
null,
null,
null,
null);
2127 decimal Amount,
string Currency,
string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl)
2129 return this.InitiateBuyEDalerAsync(this.componentAddress, ServiceId,
ServiceProvider, Amount, Currency, TransactionId, SuccessUrl, FailureUrl, CancelUrl);
2148 decimal Amount,
string Currency,
string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl)
2150 TaskCompletionSource<string> Result =
new TaskCompletionSource<string>();
2152 await this.InitiateBuyEDaler(ComponentAddress, ServiceId,
ServiceProvider, Amount, Currency, TransactionId, SuccessUrl, FailureUrl, CancelUrl,
2156 Result.TrySetResult(e.TransactionId);
2158 Result.TrySetException(e.
StanzaError ??
new Exception(
"Unable to initiate payment process."));
2160 return Task.CompletedTask;
2163 return await Result.Task;
2166 private Task BuyEDalerClientUrlEventHandler(
object Sender,
MessageEventArgs e)
2181 private Task BuyEDalerCompletedEventHandler(
object Sender,
MessageEventArgs e)
2199 string Error = e.
Content.InnerText;
2212 #region Initiation of selling eDaler using non-contract based services
2224 decimal Amount,
string Currency, EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
2226 return this.InitiateSellEDaler(this.componentAddress, ServiceId,
ServiceProvider, Amount, Currency, Callback, State);
2240 decimal Amount,
string Currency, EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
2242 return this.InitiateSellEDaler(ComponentAddress, ServiceId,
ServiceProvider, Amount, Currency,
null,
null,
null,
null, Callback, State);
2259 decimal Amount,
string Currency,
string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl,
2260 EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
2262 return this.InitiateSellEDaler(this.componentAddress, ServiceId,
ServiceProvider, Amount, Currency, TransactionId, SuccessUrl, FailureUrl, CancelUrl, Callback, State);
2280 decimal Amount,
string Currency,
string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl,
2281 EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
2283 if (!
string.IsNullOrEmpty(SuccessUrl))
2284 SuccessUrl = SuccessUrl.Replace(
"{TID}", TransactionId);
2286 if (!
string.IsNullOrEmpty(FailureUrl))
2287 FailureUrl = FailureUrl.Replace(
"{TID}", TransactionId);
2289 if (!
string.IsNullOrEmpty(CancelUrl))
2290 CancelUrl = CancelUrl.Replace(
"{TID}", TransactionId);
2292 StringBuilder Xml =
new StringBuilder();
2294 Xml.Append(
"<initiateSellEDaler xmlns='");
2295 Xml.Append(NamespaceEDaler);
2296 Xml.Append(
"' serviceId='");
2298 Xml.Append(
"' serviceProvider='");
2300 Xml.Append(
"' amount='");
2302 Xml.Append(
"' currency='");
2305 if (!
string.IsNullOrEmpty(TransactionId))
2307 Xml.Append(
"' tid='");
2311 if (!
string.IsNullOrEmpty(SuccessUrl))
2313 Xml.Append(
"' successUrl='");
2317 if (!
string.IsNullOrEmpty(FailureUrl))
2319 Xml.Append(
"' failureUrl='");
2323 if (!
string.IsNullOrEmpty(CancelUrl))
2325 Xml.Append(
"' cancelUrl='");
2331 return this.client.SendIqSet(ComponentAddress, Xml.ToString(), (Sender, e) =>
2333 TransactionId = null;
2337 !((E = e.FirstElement) is null) &&
2338 E.LocalName ==
"transaction" &&
2339 E.NamespaceURI == NamespaceEDaler)
2341 TransactionId = XML.Attribute(E,
"tid");
2363 return this.InitiateSellEDalerAsync(this.componentAddress, ServiceId,
ServiceProvider, Amount, Currency);
2377 decimal Amount,
string Currency)
2379 return this.InitiateSellEDalerAsync(ComponentAddress, ServiceId,
ServiceProvider, Amount, Currency,
null,
null,
null,
null);
2396 decimal Amount,
string Currency,
string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl)
2398 return this.InitiateSellEDalerAsync(this.componentAddress, ServiceId,
ServiceProvider, Amount, Currency, TransactionId, SuccessUrl, FailureUrl, CancelUrl);
2416 decimal Amount,
string Currency,
string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl)
2418 TaskCompletionSource<string> Result =
new TaskCompletionSource<string>();
2420 await this.InitiateSellEDaler(ComponentAddress, ServiceId,
ServiceProvider, Amount, Currency, TransactionId, SuccessUrl, FailureUrl, CancelUrl,
2424 Result.TrySetResult(e.TransactionId);
2426 Result.TrySetException(e.
StanzaError ??
new Exception(
"Unable to initiate payment process."));
2428 return Task.CompletedTask;
2431 return await Result.Task;
2434 private Task SellEDalerClientUrlEventHandler(
object Sender,
MessageEventArgs e)
2449 private Task SellEDalerCompletedEventHandler(
object Sender,
MessageEventArgs e)
2464 private Task SellEDalerErrorEventHandler(
object Sender,
MessageEventArgs e)
2467 string Error = e.
Content.InnerText;
Guid TransactionId
Transaction ID
Contains information about a balance.
CaseInsensitiveString Currency
Currency of amount.
AccountEvent Event
Any account event associated to the balance message.
decimal Amount
Amount at given point in time.
DateTime Timestamp
Timestamp of balance.
Balance(DateTime Timestamp, decimal Amount, decimal Reserved, CaseInsensitiveString Currency, AccountEvent Event)
Contains information about a balance.
override string[] Extensions
Implemented extensions.
Task InitiateSellEDaler(string ServiceId, string ServiceProvider, decimal Amount, string Currency, EventHandlerAsync< TransactionIdEventArgs > Callback, object State)
Initiates a process for selling eDaler.
Task GetAccountEvents(int MaxEvents, DateTime From, EventHandlerAsync< AccountEventsEventArgs > Callback, object State)
Gets account events associated with the wallet of the account.
EDalerClient(XmppClient Client, ContractsClient ContractsClient, string ComponentAddress)
eDaler XMPP client.
Task GetBalance(string ComponentAddress, EventHandlerAsync< BalanceIqResultEventArgs > Callback, object State)
Gets the current balance of the eDaler wallet associated with the account.
Task GetServiceProvidersForSellingEDaler(string ComponentAddress, EventHandlerAsync< SellEDalerServiceProvidersEventArgs > Callback, object State)
Gets available service providers who can help the user sell eDaler.
EventHandlerAsync< PaymentErrorEventArgs > BuyEDalerOptionsError
Event raised when a process of getting payment options for buying eDaler, initiated using a call to I...
async Task< string > DecryptMessage(byte[] EncryptedMessage, byte[] PublicKey, Guid TransactionId)
Decrypts a message that was aimed at the client using the current keys.
Task< string > InitiateBuyEDalerAsync(string ComponentAddress, string ServiceId, string ServiceProvider, decimal Amount, string Currency)
Initiates a process for buying eDaler.
Task InitiateSellEDaler(string ComponentAddress, string ServiceId, string ServiceProvider, decimal Amount, string Currency, string TransactionId, string SuccessUrl, string FailureUrl, string CancelUrl, EventHandlerAsync< TransactionIdEventArgs > Callback, object State)
Initiates a process for selling eDaler.
async Task< string > InitiateBuyEDalerAsync(string ComponentAddress, string ServiceId, string ServiceProvider, decimal Amount, string Currency, string TransactionId, string SuccessUrl, string FailureUrl, string CancelUrl)
Initiates a process for buying eDaler.
string CreateIncompletePayMeUri(LegalIdentity Id, decimal? Amount, decimal? AmountExtra, string Currency, string PrivateMessage)
Generates an incomplete eDaler PayMe URI.
Task GetBalance(EventHandlerAsync< BalanceIqResultEventArgs > Callback, object State)
Gets the current balance of the eDaler wallet associated with the account.
async Task< ISellEDalerServiceProvider[]> GetServiceProvidersForSellingEDalerAsync(string ComponentAddress)
Gets available service providers who can help the user sell eDaler.
Task InitiateSellEDaler(string ComponentAddress, string ServiceId, string ServiceProvider, decimal Amount, string Currency, EventHandlerAsync< TransactionIdEventArgs > Callback, object State)
Initiates a process for selling eDaler.
Task<(AccountEvent[], bool)> GetAccountEventsAsync(int MaxEvents)
Gets account events associated with the wallet of the account.
Task< string > InitiateGetOptionsBuyEDalerAsync(string ServiceId, string ServiceProvider, string TransactionId, string SuccessUrl, string FailureUrl, string CancelUrl)
Initiates a process for getting payment options for buying eDaler.
Task<(AccountEvent[], bool)> GetAccountEventsAsync(int MaxEvents, DateTime From)
Gets account events associated with the wallet of the account.
const string NamespaceEDaler
Namespace of eDaler component.
Task< Balance > GetBalanceAsync()
Gets the current balance of the eDaler wallet associated with the account.
Task InitiateGetOptionsSellEDaler(string ComponentAddress, string ServiceId, string ServiceProvider, string TransactionId, string SuccessUrl, string FailureUrl, string CancelUrl, EventHandlerAsync< TransactionIdEventArgs > Callback, object State)
Initiates a process for getting payment options for selling eDaler.
override void Dispose()
IDisposable.Dispose
async Task< Transaction > SendEDalerUriAsync(string ComponentAddress, string Uri)
Sends an eDaler URI to the server
async Task< string > CreateFullPaymentUri(string ToBareJid, decimal Amount, decimal? AmountExtra, CaseInsensitiveString Currency, int ValidNrDays, string Message)
Creates a full payment URI.
Task<(AccountEvent[], bool)> GetAccountEventsAsync(string ComponentAddress, int MaxEvents)
Gets account events associated with the wallet of the account.
EventHandlerAsync< SellEDalerClientUrlEventArgs > SellEDalerOptionsClientUrlReceived
Event raised when a Client URL has been sent to the client as part of a process of getting payment op...
EventHandlerAsync< PaymentErrorEventArgs > SellEDalerOptionsError
Event raised when a process of getting payment options for selling eDaler, initiated using a call to ...
string CreateIncompletePayMeUri(string BareJid, decimal? Amount, decimal? AmountExtra, string Currency, string Message)
Generates an incomplete eDaler PayMe URI.
EventHandlerAsync< PaymentErrorEventArgs > BuyEDalerError
Event raised when a process of buying eDaler, initiated using a call to InitiateBuyEDalerAsync,...
Task GetServiceProvidersForBuyingEDaler(string ComponentAddress, EventHandlerAsync< BuyEDalerServiceProvidersEventArgs > Callback, object State)
Gets available service providers who can help the user buy eDaler.
Task< string > CreateFullPaymentUri(LegalIdentity ToLegalId, decimal Amount, decimal? AmountExtra, CaseInsensitiveString Currency, int ValidNrDays)
Creates a full payment URI.
async Task< string > InitiateSellEDalerAsync(string ComponentAddress, string ServiceId, string ServiceProvider, decimal Amount, string Currency, string TransactionId, string SuccessUrl, string FailureUrl, string CancelUrl)
Initiates a process for selling eDaler.
Task GetServiceProvidersForBuyingEDaler(EventHandlerAsync< BuyEDalerServiceProvidersEventArgs > Callback, object State)
Gets available service providers who can help the user buy eDaler.
async Task<(decimal, string, PendingPayment[])> GetPendingPayments()
Gets the amount of payments pending to be processed.
Task< string > InitiateBuyEDalerAsync(string ServiceId, string ServiceProvider, decimal Amount, string Currency)
Initiates a process for buying eDaler.
Task< Transaction > SendEDalerUriAsync(string Uri)
Sends an eDaler URI to the server
async Task< string > InitiateGetOptionsSellEDalerAsync(string ComponentAddress, string ServiceId, string ServiceProvider, string TransactionId, string SuccessUrl, string FailureUrl, string CancelUrl)
Initiates a process for getting payment options for selling eDaler.
Task SendEDalerUri(string ComponentAddress, string Uri, EventHandlerAsync< TransactionEventArgs > Callback, object State)
Sends an eDaler URI to the server
Task InitiateGetOptionsSellEDaler(string ServiceId, string ServiceProvider, string TransactionId, string SuccessUrl, string FailureUrl, string CancelUrl, EventHandlerAsync< TransactionIdEventArgs > Callback, object State)
Initiates a process for getting payment options for selling eDaler.
EventHandlerAsync< PaymentOptionsEventArgs > BuyEDalerOptionsCompleted
Event raised when a process of getting payment options for buying eDaler, initiated using a call to I...
EventHandlerAsync< PaymentErrorEventArgs > SellEDalerError
Event raised when a process of selling eDaler, initiated using a call to InitiateSellEDalerAsync,...
Task< string > InitiateSellEDalerAsync(string ServiceId, string ServiceProvider, decimal Amount, string Currency, string TransactionId, string SuccessUrl, string FailureUrl, string CancelUrl)
Initiates a process for selling eDaler.
Task InitiateBuyEDaler(string ServiceId, string ServiceProvider, decimal Amount, string Currency, EventHandlerAsync< TransactionIdEventArgs > Callback, object State)
Initiates a process for buying eDaler.
Task InitiateGetOptionsBuyEDaler(string ComponentAddress, string ServiceId, string ServiceProvider, string TransactionId, string SuccessUrl, string FailureUrl, string CancelUrl, EventHandlerAsync< TransactionIdEventArgs > Callback, object State)
Initiates a process for getting payment options for buying eDaler.
Task InitiateGetOptionsBuyEDaler(string ServiceId, string ServiceProvider, EventHandlerAsync< TransactionIdEventArgs > Callback, object State)
Initiates a process for getting payment options for buying eDaler.
async Task< Balance > GetBalanceAsync(string ComponentAddress)
Gets the current balance of the eDaler wallet associated with the account.
Task< string > CreateFullPaymentUri(decimal Amount, decimal? AmountExtra, CaseInsensitiveString Currency, int ValidNrDays)
Creates a full payment URI to anyone who is the first in claiming the URI.
Task InitiateGetOptionsSellEDaler(string ServiceId, string ServiceProvider, EventHandlerAsync< TransactionIdEventArgs > Callback, object State)
Initiates a process for getting payment options for selling eDaler.
EventHandlerAsync< PaymentOptionsEventArgs > SellEDalerOptionsCompleted
Event raised when a process of getting payment options for selling eDaler, initiated using a call to ...
EventHandlerAsync< BuyEDalerClientUrlEventArgs > BuyEDalerOptionsClientUrlReceived
Event raised when a Client URL has been sent to the client as part of a process of getting payment op...
Task InitiateSellEDaler(string ServiceId, string ServiceProvider, decimal Amount, string Currency, string TransactionId, string SuccessUrl, string FailureUrl, string CancelUrl, EventHandlerAsync< TransactionIdEventArgs > Callback, object State)
Initiates a process for selling eDaler.
EventHandlerAsync< PaymentCompletedEventArgs > BuyEDalerCompleted
Event raised when a process of buying eDaler, initiated using a call to InitiateBuyEDalerAsync,...
Task InitiateBuyEDaler(string ComponentAddress, string ServiceId, string ServiceProvider, decimal Amount, string Currency, string TransactionId, string SuccessUrl, string FailureUrl, string CancelUrl, EventHandlerAsync< TransactionIdEventArgs > Callback, object State)
Initiates a process for buying eDaler.
EventHandlerAsync< PaymentCompletedEventArgs > SellEDalerCompleted
Event raised when a process of selling eDaler, initiated using a call to InitiateSellEDalerAsync,...
Task< IBuyEDalerServiceProvider[]> GetServiceProvidersForBuyingEDalerAsync()
Gets available service providers who can help the user buy eDaler.
Task< ISellEDalerServiceProvider[]> GetServiceProvidersForSellingEDalerAsync()
Gets available service providers who can help the user sell eDaler.
Task InitiateGetOptionsSellEDaler(string ComponentAddress, string ServiceId, string ServiceProvider, EventHandlerAsync< TransactionIdEventArgs > Callback, object State)
Initiates a process for getting payment options for selling eDaler.
EventHandlerAsync< SellEDalerClientUrlEventArgs > SellEDalerClientUrlReceived
Event raised when a Client URL has been sent to the client as part of a process of selling eDaler sta...
EventHandlerAsync< BuyEDalerClientUrlEventArgs > BuyEDalerClientUrlReceived
Event raised when a Client URL has been sent to the client as part of a process of buying eDaler star...
Task GetAccountEvents(string ComponentAddress, int MaxEvents, EventHandlerAsync< AccountEventsEventArgs > Callback, object State)
Gets account events associated with the wallet of the account.
async Task< string > CreateFullPaymentUri(LegalIdentity ToLegalId, decimal Amount, decimal? AmountExtra, CaseInsensitiveString Currency, int ValidNrDays, string PrivateMessage)
Creates a full payment URI.
Task InitiateGetOptionsBuyEDaler(string ServiceId, string ServiceProvider, string TransactionId, string SuccessUrl, string FailureUrl, string CancelUrl, EventHandlerAsync< TransactionIdEventArgs > Callback, object State)
Initiates a process for getting payment options for buying eDaler.
Task GetAccountEvents(int MaxEvents, EventHandlerAsync< AccountEventsEventArgs > Callback, object State)
Gets account events associated with the wallet of the account.
async Task< string > InitiateGetOptionsBuyEDalerAsync(string ComponentAddress, string ServiceId, string ServiceProvider, string TransactionId, string SuccessUrl, string FailureUrl, string CancelUrl)
Initiates a process for getting payment options for buying eDaler.
Task GetServiceProvidersForSellingEDaler(EventHandlerAsync< SellEDalerServiceProvidersEventArgs > Callback, object State)
Gets available service providers who can help the user sell eDaler.
string ComponentAddress
Address of eDaler component
Task SendEDalerUri(string Uri, EventHandlerAsync< TransactionEventArgs > Callback, object State)
Sends an eDaler URI to the server
Task< string > InitiateGetOptionsSellEDalerAsync(string ServiceId, string ServiceProvider)
Initiates a process for getting payment options for selling eDaler.
EventHandlerAsync< BalanceEventArgs > BalanceUpdated
Event raised when the client receives notification that the balance has been updated.
Task InitiateBuyEDaler(string ServiceId, string ServiceProvider, decimal Amount, string Currency, string TransactionId, string SuccessUrl, string FailureUrl, string CancelUrl, EventHandlerAsync< TransactionIdEventArgs > Callback, object State)
Initiates a process for buying eDaler.
async Task< IBuyEDalerServiceProvider[]> GetServiceProvidersForBuyingEDalerAsync(string ComponentAddress)
Gets available service providers who can help the user buy eDaler.
async Task< string > DecryptMessage(byte[] EncryptedMessage, byte[] PublicKey, Guid TransactionId, string RemoteEndpoint)
Decrypts a message that was aimed at the client using the current keys.
Task< string > CreateFullPaymentUri(string ToBareJid, decimal Amount, decimal? AmountExtra, CaseInsensitiveString Currency, int ValidNrDays)
Creates a full payment URI.
Task InitiateBuyEDaler(string ComponentAddress, string ServiceId, string ServiceProvider, decimal Amount, string Currency, EventHandlerAsync< TransactionIdEventArgs > Callback, object State)
Initiates a process for buying eDaler.
Task< string > InitiateGetOptionsBuyEDalerAsync(string ServiceId, string ServiceProvider)
Initiates a process for getting payment options for buying eDaler.
Task< string > InitiateBuyEDalerAsync(string ServiceId, string ServiceProvider, decimal Amount, string Currency, string TransactionId, string SuccessUrl, string FailureUrl, string CancelUrl)
Initiates a process for buying eDaler.
async Task<(AccountEvent[], bool)> GetAccountEventsAsync(string ComponentAddress, int MaxEvents, DateTime From)
Gets account events associated with the wallet of the account.
Task GetAccountEvents(string ComponentAddress, int MaxEvents, DateTime From, EventHandlerAsync< AccountEventsEventArgs > Callback, object State)
Gets account events associated with the wallet of the account.
Task< string > InitiateSellEDalerAsync(string ServiceId, string ServiceProvider, decimal Amount, string Currency)
Initiates a process for selling eDaler.
Task< string > InitiateSellEDalerAsync(string ComponentAddress, string ServiceId, string ServiceProvider, decimal Amount, string Currency)
Initiates a process for selling eDaler.
Task< string > InitiateGetOptionsSellEDalerAsync(string ServiceId, string ServiceProvider, string TransactionId, string SuccessUrl, string FailureUrl, string CancelUrl)
Initiates a process for getting payment options for selling eDaler.
Task InitiateGetOptionsBuyEDaler(string ComponentAddress, string ServiceId, string ServiceProvider, EventHandlerAsync< TransactionIdEventArgs > Callback, object State)
Initiates a process for getting payment options for buying eDaler.
Account events event arguments.
Wallet balance event arguments.
Wallet balance event arguments.
Event arguments for events where a client URL needs to be displayed when buying eDaler.
Service Providers for buying eDaler event arguments.
Event arguments for event signalling the completion of a payment operation.
Event arguments for event signalling an error of a payment operation.
Event arguments for operations returning payment options.
Event arguments for events where a client URL needs to be displayed when selling eDaler.
Service Providers for selling eDaler event arguments.
Event arguments for operations returning a transaction object.
Event arguments for operations returning a transaction ID.
Information about last balance statement
PendingPayment[] Pending
Pending payments
DateTime Timestamp
Balance timestamp
Contains information about a pending payment.
DateTime Expires
When payment expires
CaseInsensitiveString Currency
Payment Currency
Represents a transaction in the eDaler network.
static Transaction FromXml(XmlElement Xml)
Parses inforation about a transaction from XML.
Helps with parsing of commong data types.
static string Encode(bool x)
Encodes a Boolean for use in XML and other formats.
static bool TryParse(string s, out double Value)
Tries to decode a string encoded double.
Helps with common XML-related tasks.
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
static string Encode(string s)
Encodes a string for use in XML.
static bool TryParse(string s, out DateTime Value)
Tries to decode a string encoded DateTime.
Class representing an event.
Static class managing the application event log. Applications and services log events on this static ...
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
Adds support for legal identities, smart contracts and signatures to an XMPP client.
bool HasClientPublicKey
If the identity has a client public key
string ClientKeyName
Type of key used for client signatures
byte[] ClientPubKey
Client Public key
string Id
ID of the legal identity
Contains information about a service provider.
Abstract base class of signatures
Event arguments for message events.
string From
From where the message was received.
bool Ok
If the response is an OK result response (true), or an error response (false).
XmlElement Content
Content of the message. For messages that are processed by registered message handlers,...
XmppException StanzaError
Any stanza error returned.
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
bool UnregisterMessageHandler(string LocalName, string Namespace, EventHandlerAsync< MessageEventArgs > Handler, bool RemoveNamespaceAsClientFeature)
Unregisters a Message handler.
void RegisterMessageHandler(string LocalName, string Namespace, EventHandlerAsync< MessageEventArgs > Handler, bool PublishNamespaceAsClientFeature)
Registers a Message handler.
Task< uint > SendIqSet(string To, string Xml, EventHandlerAsync< IqResultEventArgs > Callback, object State)
Sends an IQ Set request.
Task< uint > SendIqGet(string To, string Xml, EventHandlerAsync< IqResultEventArgs > Callback, object State)
Sends an IQ Get request.
Base class for XMPP Extensions.
XmppClient client
XMPP Client used by the extension.
Task Exception(Exception Exception)
Called to inform the viewer of an exception state.
XmppClient Client
XMPP Client.
Represents a case-insensitive string.
string Value
String-representation of the case-insensitive string. (Representation is case sensitive....
Static class managing persistent settings.
static async Task< string > GetAsync(string Key, string DefaultValue)
Gets a string-valued setting.
static async Task< bool > SetAsync(string Key, string Value)
Sets a string-valued setting.
Class managing a script expression.
async Task< object > EvaluateAsync(Variables Variables)
Evaluates the expression, using the variables provided in the Variables collection....
Interface for information about a service provider.
SignWith
Options on what keys to use when signing data.
Represents a duration value, as defined by the xsd:duration data type: http://www....
static bool TryParse(string s, out Duration Result)
Tries to parse a duration value.