5using System.Threading.Tasks;
29 internal const string EDalerBalanceKeyPrefix =
"EDaler.Balance.";
30 internal const string EDalerRemoteKeyPrefix =
"EDaler.Remote.Key.";
33 private readonly
string componentAddress;
102 public Task
GetBalance(EventHandlerAsync<BalanceIqResultEventArgs> Callback,
object State)
104 return this.
GetBalance(this.componentAddress, Callback, State);
115 StringBuilder Xml =
new StringBuilder();
117 Xml.Append(
"<balance xmlns='");
121 return this.
client.
SendIqGet(ComponentAddress, Xml.ToString(), async (Sender, e) =>
127 !((E = e.FirstElement) is
null) &&
128 E.LocalName ==
"balance" &&
131 Balance = await this.ParseBalance(E);
136 await this.BalanceReported(Balance);
151 string LastBalanceKey = EDalerBalanceKeyPrefix + this.
client.
BareJID;
152 bool Changed =
false;
156 if (this.balance is
null ||
160 if (this.balance is
null)
166 Timestamp = Balance.Timestamp
181 List<PendingPayment> Pending =
new List<PendingPayment>();
182 DateTime Today = DateTime.Today;
192 Pending.Add(Payment);
196 this.balance.Pending = Pending.ToArray();
219 TaskCompletionSource<Balance> Result =
new TaskCompletionSource<Balance>();
221 await this.
GetBalance(ComponentAddress, async (Sender, e) =>
225 await this.BalanceReported(e.Balance);
226 Result.TrySetResult(e.Balance);
229 Result.TrySetException(e.StanzaError ??
new Exception(
"Unable to get current balance."));
233 return await Result.Task;
238 if (e.
From !=
this.componentAddress)
242 await this.BalanceReported(
Balance);
247 private async Task<Balance> ParseBalance(XmlElement Xml)
250 DateTime? Timestamp =
null;
252 decimal Reserved = 0;
255 foreach (XmlAttribute Attr
in Xml.Attributes)
274 Currency = Attr.
Value;
286 if (!
Balance.HasValue || Currency is
null || !Timestamp.HasValue)
289 foreach (XmlNode N
in Xml.ChildNodes)
291 if (N is XmlElement E && E.LocalName ==
"event" && E.NamespaceURI ==
NamespaceEDaler)
317 public Task
SendEDalerUri(
string Uri, EventHandlerAsync<TransactionEventArgs> Callback,
object State)
319 return this.
SendEDalerUri(this.componentAddress, Uri, Callback, State);
331 StringBuilder Xml =
new StringBuilder();
333 Xml.Append(
"<uri xmlns=\"");
337 Xml.Append(
"</uri>");
339 return this.
client.
SendIqSet(ComponentAddress, Xml.ToString(), async (Sender, e) =>
341 if (Callback is
null)
348 if (e.FirstElement is null ||
349 e.FirstElement.LocalName !=
"tr" ||
350 e.FirstElement.NamespaceURI != NamespaceEDaler)
369 return this.SendEDalerUriAsync(this.componentAddress, Uri);
379 TaskCompletionSource<Transaction> Result =
new TaskCompletionSource<Transaction>();
381 await this.SendEDalerUri(ComponentAddress, Uri, (Sender, e) =>
384 Result.TrySetResult(e.Transaction);
388 Result.TrySetException(
new Exception(
"Unable to process eDaler URI."));
390 return Task.CompletedTask;
393 return await Result.Task;
398 #region eDaler Account events
406 public Task
GetAccountEvents(
int MaxEvents, EventHandlerAsync<AccountEventsEventArgs> Callback,
object State)
408 return this.GetAccountEvents(this.componentAddress, MaxEvents, DateTime.MaxValue, Callback, State);
418 public Task
GetAccountEvents(
string ComponentAddress,
int MaxEvents, EventHandlerAsync<AccountEventsEventArgs> Callback,
object State)
420 return this.GetAccountEvents(ComponentAddress, MaxEvents, DateTime.MaxValue, Callback, State);
430 public Task
GetAccountEvents(
int MaxEvents, DateTime From, EventHandlerAsync<AccountEventsEventArgs> Callback,
object State)
432 return this.GetAccountEvents(this.componentAddress, MaxEvents, From, Callback, State);
443 public Task
GetAccountEvents(
string ComponentAddress,
int MaxEvents, DateTime From, EventHandlerAsync<AccountEventsEventArgs> Callback,
object State)
445 StringBuilder Xml =
new StringBuilder();
447 Xml.Append(
"<events xmlns=\"");
448 Xml.Append(NamespaceEDaler);
449 Xml.Append(
"\" maxCount=\"");
450 Xml.Append(MaxEvents.ToString());
452 if (From != DateTime.MaxValue)
454 Xml.Append(
"\" from=\"");
460 return this.client.SendIqGet(ComponentAddress, Xml.ToString(), async (Sender, e) =>
462 List<AccountEvent> Events =
new List<AccountEvent>();
467 if (e.FirstElement is
null ||
468 e.FirstElement.LocalName !=
"events" ||
469 e.FirstElement.NamespaceURI != NamespaceEDaler)
475 foreach (XmlNode N
in e.FirstElement.ChildNodes)
477 if (!(N is XmlElement E) || E.NamespaceURI != NamespaceEDaler)
507 return this.GetAccountEventsAsync(this.componentAddress, MaxEvents, DateTime.MaxValue);
518 return this.GetAccountEventsAsync(ComponentAddress, MaxEvents, DateTime.MaxValue);
529 return this.GetAccountEventsAsync(this.componentAddress, MaxEvents, From);
543 await this.GetAccountEvents(ComponentAddress, MaxEvents, From, async (Sender, e) =>
549 if (this.balance is null)
550 await this.GetBalanceAsync();
552 if (!(this.balance.Pending is null) && this.balance.Pending.Length > 0)
554 Dictionary<Guid, PendingPayment> Pending = new Dictionary<Guid, PendingPayment>();
555 DateTime Today = DateTime.Today;
556 bool Changed = false;
558 foreach (PendingPayment Payment in this.balance.Pending)
560 if (Payment.Expires.AddDays(1) < Today)
563 Pending[Payment.Id] = Payment;
566 foreach (AccountEvent Event in e.Events)
568 if (Pending.Remove(Event.TransactionId))
574 PendingPayment[] Pending2 = new PendingPayment[Pending.Count];
575 Pending.Values.CopyTo(Pending2, 0);
576 this.balance.Pending = Pending2;
578 await RuntimeSettings.SetAsync(EDalerBalanceKeyPrefix + this.client.BareJID, this.balance);
582 Result.TrySetResult((e.Events, e.More));
586 Result.TrySetException(ex);
592 Result.TrySetException(
new Exception(
"Unable to process eDaler URI."));
596 return await Result.Task;
614 return this.CreateFullPaymentUri(
string.Empty, Amount, AmountExtra, Currency, ValidNrDays,
string.Empty);
629 return this.CreateFullPaymentUri(ToBareJid, Amount, AmountExtra, Currency, ValidNrDays,
string.Empty);
645 await this.ValidatePaymentArguments(Amount, AmountExtra, Currency, ValidNrDays);
647 StringBuilder Uri =
new StringBuilder();
648 DateTime Created = DateTime.UtcNow;
649 DateTime Expires = DateTime.Today.AddDays(ValidNrDays);
650 Guid Id = Guid.NewGuid();
652 Uri.Append(
"edaler:id=");
653 Uri.Append(Id.ToString());
655 Uri.Append(
XML.
Encode(
this.client.BareJID));
657 if (!
string.IsNullOrEmpty(ToBareJid))
659 if (ToBareJid.IndexOf(
'@') < 0)
674 if (AmountExtra.HasValue)
687 if (!
string.IsNullOrEmpty(Message))
690 Uri.Append(Convert.ToBase64String(Encoding.UTF8.GetBytes(Message)));
693 await this.SignAndCheckBalance(Uri, Amount, AmountExtra, Currency, Id, Expires, ToBareJid);
695 return Uri.ToString();
698 private async Task ValidatePaymentArguments(decimal Amount, decimal? AmountExtra,
CaseInsensitiveString Currency,
int ValidNrDays)
700 if (ValidNrDays <= 0)
701 throw new ArgumentException(
"Must be a positive integer.", nameof(ValidNrDays));
704 throw new ArgumentException(
"Amount must be positive.", nameof(Amount));
706 if (AmountExtra.HasValue && AmountExtra.Value <= 0)
707 throw new ArgumentException(
"Amount must be positive.", nameof(AmountExtra));
709 if (this.balance is
null)
710 await this.GetBalanceAsync();
715 throw new ArgumentException(
"Currency in payment (" + Currency.
Value +
721 private async Task SignAndCheckBalance(StringBuilder Uri, decimal Amount, decimal? AmountExtra,
string Currency,
722 Guid Id, DateTime Expires,
string To)
724 byte[] PreSign = Encoding.UTF8.GetBytes(Uri.ToString());
725 byte[]
Signature = await this.contractsClient.SignAsync(PreSign,
SignWith.LatestApprovedId);
728 Uri.Append(Convert.ToBase64String(
Signature));
731 DateTime Today = DateTime.Today;
732 List<PendingPayment> Pending;
733 decimal PendingAmount;
738 Pending =
new List<PendingPayment>();
741 if (!(
Balance.Pending is
null))
753 if (Amount + (AmountExtra ?? 0) + PendingAmount >
Balance.
Balance)
755 StringBuilder Msg =
new StringBuilder();
757 Msg.Append(
"Amount larger than current balance. Amount: ");
758 Msg.Append(Amount.ToString());
760 if (AmountExtra.HasValue)
762 Msg.Append(
". Extra: ");
763 Msg.Append(AmountExtra.Value.ToString());
766 if (PendingAmount > 0)
768 Msg.Append(
". Pending: ");
769 Msg.Append(PendingAmount.ToString());
772 Msg.Append(
". Balance: ");
775 Msg.Append(
". Difference: ");
776 Msg.Append((
Balance.
Balance - Amount - (AmountExtra ?? 0) - PendingAmount).ToString());
778 throw new InvalidOperationException(Msg.ToString());
786 Amount = Amount + (AmountExtra ?? 0),
787 From = this.client.BareJID,
792 Balance.Pending = Pending.ToArray();
796 while (this.balance !=
Balance);
811 return this.CreateFullPaymentUri(ToLegalId, Amount, AmountExtra, Currency, ValidNrDays,
string.Empty);
827 int ValidNrDays,
string PrivateMessage)
829 if (RecipientLegalId is
null)
830 throw new ArgumentNullException(
"Recipient Legal ID cannot be null.", nameof(RecipientLegalId));
833 throw new ArgumentNullException(
"Recipient Legal ID lacks a public key.", nameof(RecipientLegalId));
835 await this.ValidatePaymentArguments(Amount, AmountExtra, Currency, ValidNrDays);
837 StringBuilder Uri =
new StringBuilder();
838 DateTime Created = DateTime.UtcNow;
839 DateTime Expires = DateTime.Today.AddDays(ValidNrDays);
840 Guid Id = Guid.NewGuid();
842 byte[] MessageBin = Encoding.UTF8.GetBytes(PrivateMessage ??
string.Empty);
843 (
byte[] EncryptedMessage,
byte[] LocalPublicKey) = this.contractsClient.Encrypt(MessageBin, Id.ToByteArray(), RecipientLegalId.
ClientPubKey, RecipientLegalId.
ClientKeyName);
846 string FromLegalId = await this.contractsClient.GetLatestApprovedLegalId(LocalPublicKey);
848 Uri.Append(
"edaler:id=");
849 Uri.Append(Id.ToString());
851 if (FromLegalId is
null)
854 Uri.Append(
XML.
Encode(
this.client.BareJID));
867 if (AmountExtra.HasValue)
880 if (!
string.IsNullOrEmpty(PrivateMessage))
883 Uri.Append(Convert.ToBase64String(EncryptedMessage));
885 Uri.Append(Convert.ToBase64String(LocalPublicKey));
888 await this.SignAndCheckBalance(Uri, Amount, AmountExtra, Currency, Id, Expires, RecipientLegalId.
Id);
890 return Uri.ToString();
904 return this.CreateIncompletePayMeUri(BareJid,
"t", Amount, AmountExtra, Currency, Message);
919 string Currency,
string PrivateMessage)
921 return this.CreateIncompletePayMeUri(Id.
Id,
"ti", Amount, AmountExtra, Currency, PrivateMessage);
924 private string CreateIncompletePayMeUri(
string To,
string ToType, decimal? Amount, decimal? AmountExtra,
925 string Currency,
string Message)
927 StringBuilder Uri =
new StringBuilder();
929 Uri.Append(
"edaler:cu=");
930 Uri.Append(Currency);
938 if (AmountExtra.HasValue)
949 if (!
string.IsNullOrEmpty(Message))
952 Uri.Append(Convert.ToBase64String(Encoding.UTF8.GetBytes(Message)));
955 return Uri.ToString();
967 Guid TransactionId,
bool LocalIsRecipient)
969 if (EncryptedMessage is
null)
972 if (PublicKey is
null)
973 return Encoding.UTF8.GetString(EncryptedMessage);
979 if (PublicKey is
null)
980 Decrypted = EncryptedMessage;
981 else if (LocalIsRecipient)
983 Decrypted = this.contractsClient.DecryptReceivedMessage(EncryptedMessage, PublicKey,
984 TransactionId.ToByteArray());
988 Decrypted = this.contractsClient.DecryptSentMessage(EncryptedMessage, PublicKey,
989 TransactionId.ToByteArray());
992 return Encoding.UTF8.GetString(Decrypted);
1010 Guid TransactionId,
string RemoteEndPoint,
bool LocalIsRecipient)
1012 if (!
string.IsNullOrEmpty(RemoteEndPoint) && PublicKey is
null)
1014 string RemotePublicKey = await
RuntimeSettings.
GetAsync(EDalerRemoteKeyPrefix + RemoteEndPoint,
string.Empty);
1016 if (!
string.IsNullOrEmpty(RemotePublicKey))
1020 PublicKey = Convert.FromBase64String(RemotePublicKey);
1022 catch (Exception ex)
1029 return this.DecryptMessage(EncryptedMessage, PublicKey, TransactionId, LocalIsRecipient);
1034 #region Pending Payments
1042 if (this.balance is
null)
1043 await this.GetBalanceAsync();
1045 List<PendingPayment> PendingPayments =
new List<PendingPayment>();
1046 DateTime Today = DateTime.Today;
1048 decimal PendingAmount = 0;
1050 if (!(
Balance.Pending is
null))
1064 Uri = PendingPayment.Uri
1077 #region Service Providers for buying eDaler
1086 return this.GetServiceProvidersForBuyingEDaler(this.componentAddress, Callback, State);
1096 EventHandlerAsync<BuyEDalerServiceProvidersEventArgs> Callback,
object State)
1098 StringBuilder Xml =
new StringBuilder();
1100 Xml.Append(
"<buyEDalerProviders xmlns='");
1101 Xml.Append(NamespaceEDaler);
1104 return this.client.SendIqGet(ComponentAddress, Xml.ToString(), async (Sender, e) =>
1106 List<IBuyEDalerServiceProvider> Providers =
null;
1110 !((E = e.FirstElement) is
null) &&
1111 E.LocalName ==
"providers" &&
1112 E.NamespaceURI == NamespaceEDaler)
1114 Providers = new List<IBuyEDalerServiceProvider>();
1116 foreach (XmlNode N in E.ChildNodes)
1118 if (N is XmlElement E2 &&
1119 E2.LocalName ==
"provider" &&
1120 E2.NamespaceURI == NamespaceEDaler)
1122 IBuyEDalerServiceProvider Provider = this.ParseServiceProvider<BuyEDalerServiceProvider>(E2);
1124 if (!(Provider is null))
1125 Providers.Add(Provider);
1137 private T ParseServiceProvider<T>(XmlElement Xml)
1143 string IconUrl =
null;
1144 string TemplateId =
null;
1146 int IconHeight = -1;
1148 foreach (XmlAttribute Attr
in Xml.Attributes)
1165 IconUrl = Attr.Value;
1169 if (!
int.TryParse(Attr.Value, out
int i))
1176 if (!
int.TryParse(Attr.Value, out i))
1183 TemplateId = Attr.Value;
1188 if (Id is
null || Type is
null || Name is
null)
1191 if (
string.IsNullOrEmpty(IconUrl))
1194 return (T)Temp.Create(Id, Type, Name, TemplateId);
1198 if (IconWidth < 0 || IconHeight < 0)
1202 return (T)Temp.Create(Id, Type, Name, IconUrl, IconWidth, IconHeight, TemplateId);
1211 return this.GetServiceProvidersForBuyingEDalerAsync(this.componentAddress);
1220 TaskCompletionSource<IBuyEDalerServiceProvider[]> Providers =
new TaskCompletionSource<IBuyEDalerServiceProvider[]>();
1222 await this.GetServiceProvidersForBuyingEDaler(ComponentAddress, (Sender, e) =>
1225 Providers.TrySetResult(e.ServiceProviders);
1227 Providers.TrySetException(e.
StanzaError ??
new Exception(
"Unable to get service providers."));
1229 return Task.CompletedTask;
1233 return await Providers.Task;
1238 #region Service Providers for selling eDaler
1247 return this.GetServiceProvidersForSellingEDaler(this.componentAddress, Callback, State);
1257 EventHandlerAsync<SellEDalerServiceProvidersEventArgs> Callback,
object State)
1259 StringBuilder Xml =
new StringBuilder();
1261 Xml.Append(
"<sellEDalerProviders xmlns='");
1262 Xml.Append(NamespaceEDaler);
1265 return this.client.SendIqGet(ComponentAddress, Xml.ToString(), async (Sender, e) =>
1267 List<ISellEDalerServiceProvider> Providers =
null;
1271 !((E = e.FirstElement) is
null) &&
1272 E.LocalName ==
"providers" &&
1273 E.NamespaceURI == NamespaceEDaler)
1275 Providers = new List<ISellEDalerServiceProvider>();
1277 foreach (XmlNode N in E.ChildNodes)
1279 if (N is XmlElement E2 &&
1280 E2.LocalName ==
"provider" &&
1281 E2.NamespaceURI == NamespaceEDaler)
1283 ISellEDalerServiceProvider Provider = this.ParseServiceProvider<SellEDalerServiceProvider>(E2);
1285 if (!(Provider is null))
1286 Providers.Add(Provider);
1303 return this.GetServiceProvidersForSellingEDalerAsync(this.componentAddress);
1312 TaskCompletionSource<ISellEDalerServiceProvider[]> Providers =
new TaskCompletionSource<ISellEDalerServiceProvider[]>();
1314 await this.GetServiceProvidersForSellingEDaler(ComponentAddress, (Sender, e) =>
1317 Providers.TrySetResult(e.ServiceProviders);
1319 Providers.TrySetException(e.
StanzaError ??
new Exception(
"Unable to get service providers."));
1321 return Task.CompletedTask;
1325 return await Providers.Task;
1330 #region Initiation of getting Payment options for buying eDaler using smart contracts
1340 EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
1342 return this.InitiateGetOptionsBuyEDaler(this.componentAddress, ServiceId,
ServiceProvider, Callback, State);
1354 EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
1356 return this.InitiateGetOptionsBuyEDaler(ComponentAddress, ServiceId,
ServiceProvider,
null,
null,
null,
null, Callback, State);
1371 string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl, EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
1373 return this.InitiateGetOptionsBuyEDaler(this.componentAddress, ServiceId,
ServiceProvider, TransactionId, SuccessUrl, FailureUrl, CancelUrl, Callback, State);
1389 string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl, EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
1391 if (!
string.IsNullOrEmpty(SuccessUrl))
1392 SuccessUrl = SuccessUrl.Replace(
"{TID}", TransactionId);
1394 if (!
string.IsNullOrEmpty(FailureUrl))
1395 FailureUrl = FailureUrl.Replace(
"{TID}", TransactionId);
1397 if (!
string.IsNullOrEmpty(CancelUrl))
1398 CancelUrl = CancelUrl.Replace(
"{TID}", TransactionId);
1400 StringBuilder Xml =
new StringBuilder();
1402 Xml.Append(
"<initiateGetOptionsBuyEDaler xmlns='");
1403 Xml.Append(NamespaceEDaler);
1404 Xml.Append(
"' serviceId='");
1406 Xml.Append(
"' serviceProvider='");
1409 if (!
string.IsNullOrEmpty(TransactionId))
1411 Xml.Append(
"' tid='");
1415 if (!
string.IsNullOrEmpty(SuccessUrl))
1417 Xml.Append(
"' successUrl='");
1421 if (!
string.IsNullOrEmpty(FailureUrl))
1423 Xml.Append(
"' failureUrl='");
1427 if (!
string.IsNullOrEmpty(CancelUrl))
1429 Xml.Append(
"' cancelUrl='");
1435 return this.client.SendIqSet(ComponentAddress, Xml.ToString(), async (Sender, e) =>
1437 TransactionId =
null;
1441 !((E = e.FirstElement) is
null) &&
1442 E.LocalName ==
"transaction" &&
1443 E.NamespaceURI == NamespaceEDaler)
1445 TransactionId = XML.Attribute(E,
"tid");
1465 return this.InitiateGetOptionsBuyEDalerAsync(this.componentAddress, ServiceId,
ServiceProvider,
null,
null,
null,
null);
1481 string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl)
1483 return this.InitiateGetOptionsBuyEDalerAsync(this.componentAddress, ServiceId,
ServiceProvider, TransactionId, SuccessUrl, FailureUrl, CancelUrl);
1500 string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl)
1502 TaskCompletionSource<string> Result =
new TaskCompletionSource<string>();
1504 await this.InitiateGetOptionsBuyEDaler(ComponentAddress, ServiceId,
ServiceProvider, TransactionId, SuccessUrl, FailureUrl, CancelUrl,
1508 Result.TrySetResult(e.TransactionId);
1510 Result.TrySetException(e.
StanzaError ??
new Exception(
"Unable to initiate payment process."));
1512 return Task.CompletedTask;
1515 return await Result.Task;
1518 private Task BuyEDalerOptionsClientUrlEventHandler(
object Sender,
MessageEventArgs e)
1534 private async Task BuyEDalerOptionsCompletedEventHandler(
object Sender,
MessageEventArgs e)
1537 List<Dictionary<CaseInsensitiveString, object>> Options =
new List<Dictionary<CaseInsensitiveString, object>>();
1539 foreach (XmlNode N
in e.
Content.ChildNodes)
1541 if (N is XmlElement E && E.LocalName ==
"option" && E.NamespaceURI == NamespaceEDaler)
1543 Dictionary<CaseInsensitiveString, object> Option =
new Dictionary<CaseInsensitiveString, object>();
1546 foreach (XmlNode N2
in E.ChildNodes)
1548 if (N2 is XmlElement E2 && E2.LocalName ==
"variable" && E2.NamespaceURI == NamespaceEDaler)
1551 object Value = await ParseVariable(E2,
Variables);
1553 Option[Name] = Value;
1557 Options.Add(Option);
1561 await this.BuyEDalerOptionsCompleted.Raise(
this,
new PaymentOptionsEventArgs(e, TransactionId, Options.ToArray()));
1564 private async
static Task<object> ParseVariable(XmlElement VariableDefinition,
Variables Variables)
1566 object Value =
null;
1568 foreach (XmlNode N2
in VariableDefinition.ChildNodes)
1570 if (!(N2 is XmlElement E2))
1573 switch (E2.LocalName)
1595 if (sbyte.TryParse(E2.InnerText, out sbyte i8))
1600 if (
short.TryParse(E2.InnerText, out
short i16))
1605 if (
int.TryParse(E2.InnerText, out
int i32))
1610 if (
long.TryParse(E2.InnerText, out
long i64))
1615 if (
byte.TryParse(E2.InnerText, out
byte ui8))
1620 if (ushort.TryParse(E2.InnerText, out ushort ui16))
1625 if (uint.TryParse(E2.InnerText, out uint ui32))
1630 if (ulong.TryParse(E2.InnerText, out ulong ui64))
1645 if (
XML.
TryParse(E2.InnerText, out DateTimeOffset TPO))
1650 if (TimeSpan.TryParse(E2.InnerText, out TimeSpan TS))
1660 Value = E2.InnerText;
1671 Value = E2.InnerText;
1686 private Task BuyEDalerOptionsErrorEventHandler(
object Sender,
MessageEventArgs e)
1689 string Error = e.
Content.InnerText;
1702 #region Initiation of getting Payment options for selling eDaler using smart contracts
1712 EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
1714 return this.InitiateGetOptionsSellEDaler(this.componentAddress, ServiceId,
ServiceProvider, Callback, State);
1726 EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
1728 return this.InitiateGetOptionsSellEDaler(ComponentAddress, ServiceId,
ServiceProvider,
null,
null,
null,
null, Callback, State);
1743 string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl, EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
1745 return this.InitiateGetOptionsSellEDaler(this.componentAddress, ServiceId,
ServiceProvider, TransactionId, SuccessUrl, FailureUrl, CancelUrl, Callback, State);
1761 string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl, EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
1763 if (!
string.IsNullOrEmpty(SuccessUrl))
1764 SuccessUrl = SuccessUrl.Replace(
"{TID}", TransactionId);
1766 if (!
string.IsNullOrEmpty(FailureUrl))
1767 FailureUrl = FailureUrl.Replace(
"{TID}", TransactionId);
1769 if (!
string.IsNullOrEmpty(CancelUrl))
1770 CancelUrl = CancelUrl.Replace(
"{TID}", TransactionId);
1772 StringBuilder Xml =
new StringBuilder();
1774 Xml.Append(
"<initiateGetOptionsSellEDaler xmlns='");
1775 Xml.Append(NamespaceEDaler);
1776 Xml.Append(
"' serviceId='");
1778 Xml.Append(
"' serviceProvider='");
1781 if (!
string.IsNullOrEmpty(TransactionId))
1783 Xml.Append(
"' tid='");
1787 if (!
string.IsNullOrEmpty(SuccessUrl))
1789 Xml.Append(
"' successUrl='");
1793 if (!
string.IsNullOrEmpty(FailureUrl))
1795 Xml.Append(
"' failureUrl='");
1799 if (!
string.IsNullOrEmpty(CancelUrl))
1801 Xml.Append(
"' cancelUrl='");
1807 return this.client.SendIqSet(ComponentAddress, Xml.ToString(), (Sender, e) =>
1809 TransactionId = null;
1813 !((E = e.FirstElement) is null) &&
1814 E.LocalName ==
"transaction" &&
1815 E.NamespaceURI == NamespaceEDaler)
1817 TransactionId = XML.Attribute(E,
"tid");
1837 return this.InitiateGetOptionsSellEDalerAsync(this.componentAddress, ServiceId,
ServiceProvider,
null,
null,
null,
null);
1853 string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl)
1855 return this.InitiateGetOptionsSellEDalerAsync(this.componentAddress, ServiceId,
ServiceProvider, TransactionId, SuccessUrl, FailureUrl, CancelUrl);
1872 string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl)
1874 TaskCompletionSource<string> Result =
new TaskCompletionSource<string>();
1876 await this.InitiateGetOptionsSellEDaler(ComponentAddress, ServiceId,
ServiceProvider, TransactionId, SuccessUrl, FailureUrl, CancelUrl,
1880 Result.TrySetResult(e.TransactionId);
1882 Result.TrySetException(e.
StanzaError ??
new Exception(
"Unable to initiate payment process."));
1884 return Task.CompletedTask;
1887 return await Result.Task;
1890 private Task SellEDalerOptionsClientUrlEventHandler(
object Sender,
MessageEventArgs e)
1906 private async Task SellEDalerOptionsCompletedEventHandler(
object Sender,
MessageEventArgs e)
1909 List<Dictionary<CaseInsensitiveString, object>> Options =
new List<Dictionary<CaseInsensitiveString, object>>();
1911 foreach (XmlNode N
in e.
Content.ChildNodes)
1913 if (N is XmlElement E && E.LocalName ==
"option" && E.NamespaceURI == NamespaceEDaler)
1915 Dictionary<CaseInsensitiveString, object> Option =
new Dictionary<CaseInsensitiveString, object>();
1918 foreach (XmlNode N2
in E.ChildNodes)
1920 if (N2 is XmlElement E2 && E2.LocalName ==
"variable" && E2.NamespaceURI == NamespaceEDaler)
1923 object Value = await ParseVariable(E2,
Variables);
1925 Option[Name] = Value;
1929 Options.Add(Option);
1933 await this.SellEDalerOptionsCompleted.Raise(
this,
new PaymentOptionsEventArgs(e, TransactionId, Options.ToArray()));
1942 private Task SellEDalerOptionsErrorEventHandler(
object Sender,
MessageEventArgs e)
1945 string Error = e.
Content.InnerText;
1958 #region Initiation of buying eDaler using non-contract based services
1970 decimal Amount,
string Currency, EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
1972 return this.InitiateBuyEDaler(this.componentAddress, ServiceId,
ServiceProvider, Amount, Currency, Callback, State);
1986 decimal Amount,
string Currency, EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
1988 return this.InitiateBuyEDaler(ComponentAddress, ServiceId,
ServiceProvider, Amount, Currency,
null,
null,
null,
null, Callback, State);
2005 decimal Amount,
string Currency,
string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl, EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
2007 return this.InitiateBuyEDaler(this.componentAddress, ServiceId,
ServiceProvider, Amount, Currency, TransactionId, SuccessUrl, FailureUrl, CancelUrl, Callback, State);
2025 decimal Amount,
string Currency,
string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl, EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
2027 if (!
string.IsNullOrEmpty(SuccessUrl))
2028 SuccessUrl = SuccessUrl.Replace(
"{TID}", TransactionId);
2030 if (!
string.IsNullOrEmpty(FailureUrl))
2031 FailureUrl = FailureUrl.Replace(
"{TID}", TransactionId);
2033 if (!
string.IsNullOrEmpty(CancelUrl))
2034 CancelUrl = CancelUrl.Replace(
"{TID}", TransactionId);
2036 StringBuilder Xml =
new StringBuilder();
2038 Xml.Append(
"<initiateBuyEDaler xmlns='");
2039 Xml.Append(NamespaceEDaler);
2040 Xml.Append(
"' serviceId='");
2042 Xml.Append(
"' serviceProvider='");
2044 Xml.Append(
"' amount='");
2046 Xml.Append(
"' currency='");
2049 if (!
string.IsNullOrEmpty(TransactionId))
2051 Xml.Append(
"' tid='");
2055 if (!
string.IsNullOrEmpty(SuccessUrl))
2057 Xml.Append(
"' successUrl='");
2061 if (!
string.IsNullOrEmpty(FailureUrl))
2063 Xml.Append(
"' failureUrl='");
2067 if (!
string.IsNullOrEmpty(CancelUrl))
2069 Xml.Append(
"' cancelUrl='");
2075 return this.client.SendIqSet(ComponentAddress, Xml.ToString(), (Sender, e) =>
2077 TransactionId = null;
2081 !((E = e.FirstElement) is null) &&
2082 E.LocalName ==
"transaction" &&
2083 E.NamespaceURI == NamespaceEDaler)
2085 TransactionId = XML.Attribute(E,
"tid");
2107 return this.InitiateBuyEDalerAsync(this.componentAddress, ServiceId,
ServiceProvider, Amount, Currency);
2122 decimal Amount,
string Currency)
2124 return this.InitiateBuyEDalerAsync(ComponentAddress, ServiceId,
ServiceProvider, Amount, Currency,
null,
null,
null,
null);
2142 decimal Amount,
string Currency,
string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl)
2144 return this.InitiateBuyEDalerAsync(this.componentAddress, ServiceId,
ServiceProvider, Amount, Currency, TransactionId, SuccessUrl, FailureUrl, CancelUrl);
2163 decimal Amount,
string Currency,
string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl)
2165 TaskCompletionSource<string> Result =
new TaskCompletionSource<string>();
2167 await this.InitiateBuyEDaler(ComponentAddress, ServiceId,
ServiceProvider, Amount, Currency, TransactionId, SuccessUrl, FailureUrl, CancelUrl,
2171 Result.TrySetResult(e.TransactionId);
2173 Result.TrySetException(e.
StanzaError ??
new Exception(
"Unable to initiate payment process."));
2175 return Task.CompletedTask;
2178 return await Result.Task;
2181 private Task BuyEDalerClientUrlEventHandler(
object Sender,
MessageEventArgs e)
2196 private Task BuyEDalerCompletedEventHandler(
object Sender,
MessageEventArgs e)
2214 string Error = e.
Content.InnerText;
2227 #region Initiation of selling eDaler using non-contract based services
2239 decimal Amount,
string Currency, EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
2241 return this.InitiateSellEDaler(this.componentAddress, ServiceId,
ServiceProvider, Amount, Currency, Callback, State);
2255 decimal Amount,
string Currency, EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
2257 return this.InitiateSellEDaler(ComponentAddress, ServiceId,
ServiceProvider, Amount, Currency,
null,
null,
null,
null, Callback, State);
2274 decimal Amount,
string Currency,
string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl,
2275 EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
2277 return this.InitiateSellEDaler(this.componentAddress, ServiceId,
ServiceProvider, Amount, Currency, TransactionId, SuccessUrl, FailureUrl, CancelUrl, Callback, State);
2295 decimal Amount,
string Currency,
string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl,
2296 EventHandlerAsync<TransactionIdEventArgs> Callback,
object State)
2298 if (!
string.IsNullOrEmpty(SuccessUrl))
2299 SuccessUrl = SuccessUrl.Replace(
"{TID}", TransactionId);
2301 if (!
string.IsNullOrEmpty(FailureUrl))
2302 FailureUrl = FailureUrl.Replace(
"{TID}", TransactionId);
2304 if (!
string.IsNullOrEmpty(CancelUrl))
2305 CancelUrl = CancelUrl.Replace(
"{TID}", TransactionId);
2307 StringBuilder Xml =
new StringBuilder();
2309 Xml.Append(
"<initiateSellEDaler xmlns='");
2310 Xml.Append(NamespaceEDaler);
2311 Xml.Append(
"' serviceId='");
2313 Xml.Append(
"' serviceProvider='");
2315 Xml.Append(
"' amount='");
2317 Xml.Append(
"' currency='");
2320 if (!
string.IsNullOrEmpty(TransactionId))
2322 Xml.Append(
"' tid='");
2326 if (!
string.IsNullOrEmpty(SuccessUrl))
2328 Xml.Append(
"' successUrl='");
2332 if (!
string.IsNullOrEmpty(FailureUrl))
2334 Xml.Append(
"' failureUrl='");
2338 if (!
string.IsNullOrEmpty(CancelUrl))
2340 Xml.Append(
"' cancelUrl='");
2346 return this.client.SendIqSet(ComponentAddress, Xml.ToString(), (Sender, e) =>
2348 TransactionId = null;
2352 !((E = e.FirstElement) is null) &&
2353 E.LocalName ==
"transaction" &&
2354 E.NamespaceURI == NamespaceEDaler)
2356 TransactionId = XML.Attribute(E,
"tid");
2378 return this.InitiateSellEDalerAsync(this.componentAddress, ServiceId,
ServiceProvider, Amount, Currency);
2392 decimal Amount,
string Currency)
2394 return this.InitiateSellEDalerAsync(ComponentAddress, ServiceId,
ServiceProvider, Amount, Currency,
null,
null,
null,
null);
2411 decimal Amount,
string Currency,
string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl)
2413 return this.InitiateSellEDalerAsync(this.componentAddress, ServiceId,
ServiceProvider, Amount, Currency, TransactionId, SuccessUrl, FailureUrl, CancelUrl);
2431 decimal Amount,
string Currency,
string TransactionId,
string SuccessUrl,
string FailureUrl,
string CancelUrl)
2433 TaskCompletionSource<string> Result =
new TaskCompletionSource<string>();
2435 await this.InitiateSellEDaler(ComponentAddress, ServiceId,
ServiceProvider, Amount, Currency, TransactionId, SuccessUrl, FailureUrl, CancelUrl,
2439 Result.TrySetResult(e.TransactionId);
2441 Result.TrySetException(e.
StanzaError ??
new Exception(
"Unable to initiate payment process."));
2443 return Task.CompletedTask;
2446 return await Result.Task;
2449 private Task SellEDalerClientUrlEventHandler(
object Sender,
MessageEventArgs e)
2464 private Task SellEDalerCompletedEventHandler(
object Sender,
MessageEventArgs e)
2479 private Task SellEDalerErrorEventHandler(
object Sender,
MessageEventArgs e)
2482 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...
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.
async Task< string > CreateFullPaymentUri(LegalIdentity RecipientLegalId, decimal Amount, decimal? AmountExtra, CaseInsensitiveString Currency, int ValidNrDays, string PrivateMessage)
Creates a full payment URI.
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 > DecryptMessage(byte[] EncryptedMessage, byte[] PublicKey, Guid TransactionId, string RemoteEndPoint, bool LocalIsRecipient)
Decrypts a message that was aimed at the client using the current keys.
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...
string DecryptMessage(byte[] EncryptedMessage, byte[] PublicKey, Guid TransactionId, bool LocalIsRecipient)
Decrypts a message that was aimed at the client using the current keys.
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.
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.
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.
void 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.