3using System.Collections.Generic;
4using System.Reflection;
6using System.Threading.Tasks;
40 private readonly Dictionary<string, Wallet> wallets =
new Dictionary<string, Wallet>();
43 private string defaultCurrency =
null;
63 this.
RegisterIqGetHandler(
"buyEDalerProviders", NamespaceEDaler, this.GetBuyEDalerProvidersHandler,
false);
64 this.
RegisterIqSetHandler(
"initiateGetOptionsBuyEDaler", NamespaceEDaler, this.InitiateGetOptionsBuyEDalerHandler,
false);
65 this.
RegisterIqSetHandler(
"initiateBuyEDaler", NamespaceEDaler, this.InitiateBuyEDalerHandler,
false);
66 this.
RegisterIqGetHandler(
"sellEDalerProviders", NamespaceEDaler, this.GetSellEDalerProvidersHandler,
false);
67 this.
RegisterIqSetHandler(
"initiateGetOptionsSellEDaler", NamespaceEDaler, this.InitiateGetOptionsSellEDalerHandler,
false);
68 this.
RegisterIqSetHandler(
"initiateSellEDaler", NamespaceEDaler, this.InitiateSellEDalerHandler,
false);
79 this.transactions.Dispose();
87 this.
UnregisterIqGetHandler(
"buyEDalerProviders", NamespaceEDaler, this.GetBuyEDalerProvidersHandler,
false);
88 this.
UnregisterIqSetHandler(
"initiateGetOptionsBuyEDaler", NamespaceEDaler, this.InitiateGetOptionsBuyEDalerHandler,
false);
90 this.
UnregisterIqGetHandler(
"sellEDalerProviders", NamespaceEDaler, this.GetSellEDalerProvidersHandler,
false);
91 this.
UnregisterIqSetHandler(
"initiateGetOptionsSellEDaler", NamespaceEDaler, this.InitiateGetOptionsSellEDalerHandler,
false);
115 if (this.defaultCurrency is
null)
118 return this.defaultCurrency;
123 string Key = AccountName.LowerCase +
"@" + Domain.
LowerCase;
128 if (this.wallets.TryGetValue(Key, out
Wallet))
132 bool Created =
false;
146 Account = AccountName,
149 Created = DateTime.Now
154 else if (
string.IsNullOrEmpty(
Wallet.Currency))
162 if (this.wallets.TryGetValue(Key, out
Wallet Wallet2))
165 this.wallets[Key] =
Wallet;
174 private async Task GetWalletBalanceHandler(
object Sender,
IqEventArgs e)
178 await e.
IqErrorForbidden(e.
To,
"Access to wallet only granted to accounts on broker.",
"en");
186 await e.
IqErrorForbidden(e.
To,
"Access to wallet only granted to accounts on broker.",
"en");
201 Wallet Wallet = await this.GetWallet(AccountName, Domain);
202 StringBuilder Xml =
new StringBuilder();
204 Xml.Append(
"<balance xmlns='");
206 Xml.Append(
"' amount='");
211 Xml.Append(
"' reserved='");
215 Xml.Append(
"' currency='");
217 Xml.Append(
"' timestamp='");
226 Xml.Append(
"</balance>");
232 public static bool IsValidCurrencySymbol(
string Currency)
234 if (Currency.Length > 5)
237 Currency = Currency.ToUpper();
239 foreach (
char ch
in Currency)
241 if (ch < 'A' || ch >
'Z')
248 public static Task<string> GenerateIssueUrl(decimal Amount,
string Currency,
int ExpiresDays,
string FreeText,
251 return GenerateIssueUrl(
string.Empty, Amount, Currency, ExpiresDays, FreeText, ManagerPassword, Request,
User);
254 public static async Task<string> GenerateIssueUrl(
string To, decimal Amount,
string Currency,
int ExpiresDays,
string FreeText,
257 if (
User is
null || !(
User?.HasPrivilege(
"Admin.eDaler.Generate") ??
false))
260 string Uri = await GenerateUrl(To, Amount, Currency, ExpiresDays, FreeText, ManagerPassword, Request,
User,
"is",
true);
261 KeyValuePair<string, object>[] Tags = await GetTags(Amount, Currency, ExpiresDays, FreeText, Request);
269 public static async Task<string> GenerateDestroyUrl(decimal Amount,
string Currency,
int ExpiresDays,
string FreeText,
272 if (
User is
null || !(
User?.HasPrivilege(
"Admin.eDaler.Destroy") ??
false))
275 string Uri = await GenerateUrl(
string.Empty, Amount, Currency, ExpiresDays, FreeText, ManagerPassword, Request,
User,
"xx",
false);
276 KeyValuePair<string, object>[] Tags = await GetTags(Amount, Currency, ExpiresDays, FreeText, Request);
284 private async
static Task<KeyValuePair<string, object>[]> GetTags(decimal Amount,
string Currency,
int ExpiresDays,
string FreeText,
HttpRequest Request)
287 new KeyValuePair<string, object>(
"Amount", Amount),
288 new KeyValuePair<string, object>(
"Currency", Currency),
289 new KeyValuePair<string, object>(
"ExpiresDays", ExpiresDays),
290 new KeyValuePair<string, object>(
"FreeText", FreeText),
291 new KeyValuePair<string, object>(
"RemoteEndpoint", Request.
RemoteEndPoint));
294 private static async Task<string> GenerateUrl(
string To, decimal Amount,
string Currency,
int ExpiresDays,
string FreeText,
string ManagerPassword,
298 throw new ArgumentException(
"Amount must be positive.", nameof(Amount));
300 if (
string.IsNullOrEmpty(Currency))
301 throw new ArgumentException(
"No currency specified.");
303 if (!IsValidCurrencySymbol(Currency))
304 throw new ArgumentException(
"Invalid currency symbol.");
306 if (ExpiresDays <= 0)
307 throw new ArgumentException(
"Expiry interval must be positive.", nameof(Amount));
309 if (
string.IsNullOrEmpty(FreeText))
310 throw new ArgumentException(
"No free text specified.");
322 StringBuilder sb =
new StringBuilder();
324 sb.Append(
"This endpoint (");
326 sb.Append(
") has been blocked from the system.");
331 sb =
new StringBuilder();
332 DateTime TP = Result.
Next.Value;
333 DateTime Today = DateTime.Today;
335 sb.Append(
"Too many failed login attempts in a row registered. Try again after ");
336 sb.Append(TP.ToLongTimeString());
338 if (TP.Date != Today)
340 if (TP.Date == Today.AddDays(1))
341 sb.Append(
" tomorrow");
345 sb.Append(TP.ToShortDateString());
349 sb.Append(
". Remote Endpoint: ");
367 StringBuilder Uri =
new StringBuilder();
368 Guid Id = Guid.NewGuid();
369 DateTime Created = DateTime.UtcNow;
371 Uri.Append(
"edaler:");
376 Uri.Append(Id.ToString());
378 if (!
string.IsNullOrEmpty(To))
380 int i = To.IndexOf(
'@');
381 if (i > 0 && Guid.TryParse(To.Substring(0, i), out _))
394 Uri.Append(Currency);
396 Uri.Append(
XML.
Encode(Created.Date.AddDays(ExpiresDays),
true));
398 Uri.Append(Convert.ToBase64String(Encoding.UTF8.GetBytes(FreeText)));
402 byte[] PreSign = Encoding.UTF8.GetBytes(Uri.ToString());
406 Uri.Append(Convert.ToBase64String(S));
409 return Uri.ToString();
412 private async Task SetUriHandler(
object Sender,
IqEventArgs e)
422 await e.
IqErrorForbidden(e.
To,
"Access to wallet only granted to accounts on broker.",
"en");
426 string UriString = e.
Query.InnerText;
442 public async Task<string>
ProcessUri(
string Uri,
string From)
447 if (ParsedUri is
null)
452 if (!await this.
ProcessUri(ParsedUri, ParsedFrom))
461 bool OnPrincipal = Uri.PrincipalDomain == this.
Server.
Domain;
463 bool RemotelyControlled =
false;
466 if (OnPrincipal || FromPrincipal || ContractualPayment)
468 RemotelyControlled = (!OnPrincipal && FromPrincipal) || ContractualPayment;
470 List<ITransaction> Parts =
new List<ITransaction>();
473 if (Parts.Count == 1)
474 UriTransaction = Parts[0];
483 if (!await UriTransaction.
Prepare())
495 if (RemotelyControlled)
497 UriTransaction.Tag =
new RemoteControlState()
503 this.transactions.Register(UriTransaction);
511 if (await UriTransaction.
Execute())
513 if (await UriTransaction.
Commit())
525 await UriTransaction.
Abort();
534 private class RemoteControlState
540 private async Task ExecuteHandler(
object Sender,
IqEventArgs e)
551 await e.
IqErrorConflict(e.
To,
"Unable to execute transaction: " + State.Uri.State.ErrorMessage,
"en");
567 private async Task<ITransaction> PrepareTransaction(
IqEventArgs e)
571 if (!Guid.TryParse(IdStr, out Guid Id))
585 await e.
IqErrorForbidden(e.
To,
"You are not authorized to control this transaction.",
"en");
594 private async Task CommitHandler(
object Sender,
IqEventArgs e)
605 await e.
IqErrorConflict(e.
To,
"Unable to commit transaction: " + State.Uri.State.ErrorMessage,
"en");
623 private async Task RollbackHandler(
object Sender,
IqEventArgs e)
634 await e.
IqErrorConflict(e.
To,
"Unable to roll transaction back: " + State.Uri.State.ErrorMessage,
"en");
652 private async Task GetAccountEventsHandler(
object Sender,
IqEventArgs e)
656 await e.
IqErrorForbidden(e.
To,
"Access to wallet only granted to accounts on broker.",
"en");
664 await e.
IqErrorForbidden(e.
To,
"Access to wallet only granted to accounts on broker.",
"en");
674 IEnumerable<AccountEvent> Events;
679 if (!e.
Query.HasAttribute(
"from") ||
692 StringBuilder Xml =
new StringBuilder();
694 Xml.Append(
"<events xmlns=\"");
702 Xml.Append(
"<more/>");
709 Xml.Append(
"</events>");
714 private async Task GetBuyEDalerProvidersHandler(
object Sender,
IqEventArgs e)
718 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
726 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
736 LegalIdentity Identity = await this.legal.GetCurrentApprovedLegalIdentityAsync(AccountName);
737 if (Identity is
null)
743 string Country = Identity[
"COUNTRY"];
744 if (
string.IsNullOrEmpty(Country))
746 await e.
IqErrorForbidden(e.
To,
"Approved legal identity lacks country specified.",
"en");
751 StringBuilder Xml =
new StringBuilder();
753 Xml.Append(
"<providers xmlns='");
759 foreach (Type T
in ServiceTypes)
773 Xml.Append(
"<provider id='");
775 Xml.Append(
"' type='");
777 Xml.Append(
"' name='");
780 if (!
string.IsNullOrEmpty(Service.
IconUrl))
782 Xml.Append(
"' iconUrl='");
784 Xml.Append(
"' iconWidth='");
785 Xml.Append(Service.
IconWidth.ToString());
786 Xml.Append(
"' iconHeight='");
792 Xml.Append(
"' templateId='");
800 Xml.Append(
"</providers>");
805 private async Task InitiateGetOptionsBuyEDalerHandler(
object Sender,
IqEventArgs e)
809 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
817 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
827 LegalIdentity Identity = await this.legal.GetCurrentApprovedLegalIdentityAsync(AccountName);
828 if (Identity is
null)
834 string Country = Identity[
"COUNTRY"];
835 if (
string.IsNullOrEmpty(Country))
837 await e.
IqErrorForbidden(e.
To,
"Approved legal identity lacks country specified.",
"en");
846 string TransactionId = e.
Query.HasAttribute(
"tid") ?
XML.
Attribute(e.
Query,
"tid") : Guid.NewGuid().ToString();
848 if (
string.IsNullOrEmpty(ServiceId))
870 await e.
IqErrorBadRequest(e.
To,
"Service Provider does not support buying of eDaler.",
"en");
889 StringBuilder Xml =
new StringBuilder();
891 Xml.Append(
"<transaction xmlns='");
893 Xml.Append(
"' tid='");
899 Task _ = Task.Run(async () =>
903 Dictionary<CaseInsensitiveString, CaseInsensitiveString> BuyerIdParameters =
new Dictionary<CaseInsensitiveString, CaseInsensitiveString>();
905 foreach (
Property P
in Identity.Properties)
908 IDictionary<CaseInsensitiveString, object>[] Options;
913 SuccessUrl, FailureUrl, CancelUrl, async (sender, e2) =>
917 Xml.Append(
"<buyEDalerOptionsClientUrl xmlns='");
919 Xml.Append(
"' tid='");
921 Xml.Append(
"' url='");
931 Xml.Append(
"<buyEDalerOptionsCompleted xmlns='");
933 Xml.Append(
"' tid='");
937 if (!(Options is
null))
939 foreach (IDictionary<CaseInsensitiveString, object> Option
in Options)
941 Xml.Append(
"<option>");
943 foreach (KeyValuePair<CaseInsensitiveString, object> P
in Option)
946 Xml.Append(
"</option>");
950 Xml.Append(
"</buyEDalerOptionsCompleted>");
959 Xml.Append(
"<buyEDalerOptionsError xmlns='");
961 Xml.Append(
"' tid='");
965 Xml.Append(
"</buyEDalerOptionsError>");
978 private async Task InitiateBuyEDalerHandler(
object Sender,
IqEventArgs e)
982 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
990 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
1000 LegalIdentity Identity = await this.legal.GetCurrentApprovedLegalIdentityAsync(AccountName);
1001 if (Identity is
null)
1007 string Country = Identity[
"COUNTRY"];
1008 if (
string.IsNullOrEmpty(Country))
1010 await e.
IqErrorForbidden(e.
To,
"Approved legal identity lacks country specified.",
"en");
1021 string TransactionId = e.
Query.HasAttribute(
"tid") ?
XML.
Attribute(e.
Query,
"tid") : Guid.NewGuid().ToString();
1035 if (
string.IsNullOrEmpty(ServiceId))
1057 await e.
IqErrorBadRequest(e.
To,
"Service Provider does not support buying of eDaler.",
"en");
1063 if (Service is
null)
1071 await e.
IqErrorNotAllowed(e.
To,
"Selected service provider cannot perform action.",
"en");
1077 await e.
IqErrorNotAllowed(e.
To,
"Selected service provider does not support selected currency (" + Currency +
").",
"en");
1083 await e.
IqErrorForbidden(e.
To,
"Service provider requires a signed contract to perform payment. See associated Contract Template ID.",
"en");
1087 Dictionary<CaseInsensitiveString, object> ContractParameters =
new Dictionary<CaseInsensitiveString, object>()
1089 {
"Amount", Amount },
1090 {
"Currency", Currency.
Value.ToUpper() }
1092 Dictionary<CaseInsensitiveString, CaseInsensitiveString> BuyerIdParameters =
new Dictionary<CaseInsensitiveString, CaseInsensitiveString>();
1094 foreach (
Property P
in Identity.Properties)
1097 StringBuilder Xml =
new StringBuilder();
1099 Xml.Append(
"<transaction xmlns='");
1101 Xml.Append(
"' tid='");
1107 Task _ = Task.Run(async () =>
1112 FailureUrl, CancelUrl, Service,
this, Identity.Id,
null, ContractParameters, BuyerIdParameters, TransactionId,
1113 async (sender, e2) =>
1117 Xml.Append(
"<buyEDalerClientUrl xmlns='");
1119 Xml.Append(
"' tid='");
1121 Xml.Append(
"' url='");
1133 Xml.Append(
"<buyEDalerCompleted xmlns='");
1134 Xml.Append(NamespaceEDaler);
1135 Xml.Append(
"' tid='");
1136 Xml.Append(XML.Encode(TransactionId));
1137 Xml.Append(
"' amount='");
1138 Xml.Append(CommonTypes.Encode(PaymentResult.Amount));
1139 Xml.Append(
"' currency='");
1140 Xml.Append(XML.Encode(PaymentResult.Currency));
1143 await this.Server.SendMessage(string.Empty, string.Empty, e.To, e.From.ToBareJID(), string.Empty, Xml.ToString());
1150 Xml.Append(
"<buyEDalerError xmlns='");
1151 Xml.Append(NamespaceEDaler);
1152 Xml.Append(
"' tid='");
1153 Xml.Append(XML.Encode(TransactionId));
1155 Xml.Append(XML.Encode(PaymentResult.Error));
1156 Xml.Append(
"</buyEDalerError>");
1158 await this.Server.SendMessage(string.Empty, string.Empty, e.To, e.From.ToBareJID(), string.Empty, Xml.ToString());
1162 catch (Exception ex)
1169 private async Task GetSellEDalerProvidersHandler(
object Sender,
IqEventArgs e)
1173 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
1179 if (Account is
null)
1181 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
1191 LegalIdentity Identity = await this.legal.GetCurrentApprovedLegalIdentityAsync(AccountName);
1192 if (Identity is
null)
1198 string Country = Identity[
"COUNTRY"];
1199 if (
string.IsNullOrEmpty(Country))
1201 await e.
IqErrorForbidden(e.
To,
"Approved legal identity lacks country specified.",
"en");
1206 StringBuilder Xml =
new StringBuilder();
1208 Xml.Append(
"<providers xmlns='");
1214 foreach (Type T
in ServiceTypes)
1228 Xml.Append(
"<provider id='");
1230 Xml.Append(
"' type='");
1232 Xml.Append(
"' name='");
1235 if (!
string.IsNullOrEmpty(Service.
IconUrl))
1237 Xml.Append(
"' iconUrl='");
1239 Xml.Append(
"' iconWidth='");
1240 Xml.Append(Service.
IconWidth.ToString());
1241 Xml.Append(
"' iconHeight='");
1247 Xml.Append(
"' templateId='");
1255 Xml.Append(
"</providers>");
1260 private async Task InitiateGetOptionsSellEDalerHandler(
object Sender,
IqEventArgs e)
1264 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
1270 if (Account is
null)
1272 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
1282 LegalIdentity Identity = await this.legal.GetCurrentApprovedLegalIdentityAsync(AccountName);
1283 if (Identity is
null)
1289 string Country = Identity[
"COUNTRY"];
1290 if (
string.IsNullOrEmpty(Country))
1292 await e.
IqErrorForbidden(e.
To,
"Approved legal identity lacks country specified.",
"en");
1301 string TransactionId = e.
Query.HasAttribute(
"tid") ?
XML.
Attribute(e.
Query,
"tid") : Guid.NewGuid().ToString();
1303 if (
string.IsNullOrEmpty(ServiceId))
1325 await e.
IqErrorBadRequest(e.
To,
"Service Provider does not support selling of eDaler.",
"en");
1332 if (Service is
null)
1340 await e.
IqErrorNotAllowed(e.
To,
"Selected service provider cannot perform action.",
"en");
1344 StringBuilder Xml =
new StringBuilder();
1346 Xml.Append(
"<transaction xmlns='");
1348 Xml.Append(
"' tid='");
1354 Task _ = Task.Run(async () =>
1358 Dictionary<CaseInsensitiveString, CaseInsensitiveString> SellerIdParameters =
new Dictionary<CaseInsensitiveString, CaseInsensitiveString>();
1360 foreach (
Property P
in Identity.Properties)
1363 IDictionary<CaseInsensitiveString, object>[] Options;
1368 SuccessUrl, FailureUrl, CancelUrl, async (sender, e2) =>
1372 Xml.Append(
"<sellEDalerOptionsClientUrl xmlns='");
1374 Xml.Append(
"' tid='");
1376 Xml.Append(
"' url='");
1386 Xml.Append(
"<sellEDalerOptionsCompleted xmlns='");
1388 Xml.Append(
"' tid='");
1392 if (!(Options is
null))
1394 foreach (IDictionary<CaseInsensitiveString, object> Option
in Options)
1396 Xml.Append(
"<option>");
1398 foreach (KeyValuePair<CaseInsensitiveString, object> P
in Option)
1401 Xml.Append(
"</option>");
1405 Xml.Append(
"</sellEDalerOptionsCompleted>");
1410 catch (Exception ex)
1414 Xml.Append(
"<sellEDalerOptionsError xmlns='");
1416 Xml.Append(
"' tid='");
1420 Xml.Append(
"</sellEDalerOptionsError>");
1426 catch (Exception ex)
1433 private async Task InitiateSellEDalerHandler(
object Sender,
IqEventArgs e)
1437 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
1443 if (Account is
null)
1445 await e.
IqErrorForbidden(e.
To,
"Access to service providers only granted to accounts on broker.",
"en");
1455 LegalIdentity Identity = await this.legal.GetCurrentApprovedLegalIdentityAsync(AccountName);
1456 if (Identity is
null)
1462 string Country = Identity[
"COUNTRY"];
1463 if (
string.IsNullOrEmpty(Country))
1465 await e.
IqErrorForbidden(e.
To,
"Approved legal identity lacks country specified.",
"en");
1476 string TransactionId = e.
Query.HasAttribute(
"tid") ?
XML.
Attribute(e.
Query,
"tid") : Guid.NewGuid().ToString();
1490 if (
string.IsNullOrEmpty(ServiceId))
1512 await e.
IqErrorBadRequest(e.
To,
"Service Provider does not support selling of eDaler.",
"en");
1518 if (Service is
null)
1526 await e.
IqErrorNotAllowed(e.
To,
"Selected service provider cannot perform action.",
"en");
1532 await e.
IqErrorNotAllowed(e.
To,
"Selected service provider does not support selected currency (" + Currency +
").",
"en");
1538 await e.
IqErrorForbidden(e.
To,
"Service provider requires a signed contract to perform payment. See associated Contract Template ID.",
"en");
1542 Dictionary<CaseInsensitiveString, object> ContractParameters =
new Dictionary<CaseInsensitiveString, object>()
1544 {
"Amount", Amount },
1545 {
"Currency", Currency.
Value.ToUpper() }
1547 Dictionary<CaseInsensitiveString, CaseInsensitiveString> SellerIdParameters =
new Dictionary<CaseInsensitiveString, CaseInsensitiveString>();
1549 foreach (
Property P
in Identity.Properties)
1552 StringBuilder Xml =
new StringBuilder();
1554 Xml.Append(
"<transaction xmlns='");
1556 Xml.Append(
"' tid='");
1562 Task _ = Task.Run(async () =>
1567 FailureUrl, CancelUrl, Service,
this, Identity.Id,
null, ContractParameters, SellerIdParameters, TransactionId,
1568 async (sender, e2) =>
1572 Xml.Append(
"<sellEDalerClientUrl xmlns='");
1574 Xml.Append(
"' tid='");
1576 Xml.Append(
"' url='");
1588 Xml.Append(
"<sellEDalerCompleted xmlns='");
1589 Xml.Append(NamespaceEDaler);
1590 Xml.Append(
"' tid='");
1591 Xml.Append(XML.Encode(TransactionId));
1592 Xml.Append(
"' amount='");
1593 Xml.Append(CommonTypes.Encode(PaymentResult.Amount));
1594 Xml.Append(
"' currency='");
1595 Xml.Append(XML.Encode(PaymentResult.Currency));
1598 await this.Server.SendMessage(string.Empty, string.Empty, e.To, e.From.ToBareJID(), string.Empty, Xml.ToString());
1605 Xml.Append(
"<sellEDalerError xmlns='");
1606 Xml.Append(NamespaceEDaler);
1607 Xml.Append(
"' tid='");
1608 Xml.Append(XML.Encode(TransactionId));
1610 Xml.Append(XML.Encode(PaymentResult.Error));
1611 Xml.Append(
"</sellEDalerError>");
1613 await this.Server.SendMessage(string.Empty, string.Empty, e.To, e.From.ToBareJID(), string.Empty, Xml.ToString());
1617 catch (Exception ex)
Contains information about a service provider that users can use to buy eDaler.
Result of request payment.
bool Ok
If payment was successful or not.
Contains information about a service provider that users can use to sell eDaler.
Contains information about a service provider.
Helps with parsing of commong data types.
static string Encode(bool x)
Encodes a Boolean for use in XML and other formats.
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.
override string ToString()
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.
static void Notice(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs a notice event.
The server understood the request, but is refusing to fulfill it. Authorization will not help and the...
Represents an HTTP request.
string RemoteEndPoint
Remote end-point.
Base class for components.
void RegisterIqSetHandler(string LocalName, string Namespace, EventHandlerAsync< IqEventArgs > Handler, bool PublishNamespaceAsFeature)
Registers an IQ-Set handler.
CaseInsensitiveString Subdomain
Subdomain name.
void RegisterIqGetHandler(string LocalName, string Namespace, EventHandlerAsync< IqEventArgs > Handler, bool PublishNamespaceAsFeature)
Registers an IQ-Get handler.
string Name
Component name.
XmppServer Server
XMPP Server.
bool UnregisterIqGetHandler(string LocalName, string Namespace, EventHandlerAsync< IqEventArgs > Handler, bool RemoveNamespaceAsFeature)
Unregisters an IQ-Get handler.
bool UnregisterIqSetHandler(string LocalName, string Namespace, EventHandlerAsync< IqEventArgs > Handler, bool RemoveNamespaceAsFeature)
Unregisters an IQ-Set handler.
Event arguments for IQ queries.
XmppAddress From
From address attribute
Task IqResult(string Xml, string From)
Returns a response to the current request.
Task IqErrorItemNotFound(XmppAddress From, string ErrorText, string Language)
Returns a item-not-found error.
XmlElement Query
Query element, if found, null otherwise.
Task IqErrorNotAllowed(XmppAddress From, string ErrorText, string Language)
Returns a not-allowed error.
XmppAddress To
To address attribute
async Task IqError(string ErrorType, string Xml, XmppAddress From, string ErrorText, string Language)
Returns an error response to the current request.
Task IqErrorServiceUnavailable(XmppAddress From, string ErrorText, string Language)
Returns a service-unavailable error.
Task IqErrorConflict(XmppAddress From, string ErrorText, string Language)
Returns a conflict error.
Task IqErrorBadRequest(XmppAddress From, string ErrorText, string Language)
Returns a bad-request error.
Task IqErrorForbidden(XmppAddress From, string ErrorText, string Language)
Returns a forbidden error.
Contains information about one XMPP address.
override string ToString()
object.ToString()
bool HasAccount
If the address has an account part.
CaseInsensitiveString Domain
Domain
XmppAddress ToBareJID()
Returns the Bare JID as an XmppAddress object.
CaseInsensitiveString BareJid
Bare JID
static readonly XmppAddress Empty
Empty address.
CaseInsensitiveString Account
Account
Task< bool > SendMessage(string Type, string Id, string From, string To, string Language, string ContentXml)
Sends a Message stanza to a recipient.
bool IsServerDomain(CaseInsensitiveString Domain, bool IncludeAlternativeDomains)
Checks if a domain is the server domain, or optionally, an alternative domain.
CaseInsensitiveString Domain
Domain name.
Represents a case-insensitive string.
string Value
String-representation of the case-insensitive string. (Representation is case sensitive....
string LowerCase
Lower-case representation of the case-insensitive string.
static bool IsNullOrEmpty(CaseInsensitiveString value)
Indicates whether the specified string is null or an CaseInsensitiveString.Empty string.
Static interface for database persistence. In order to work, a database provider has to be assigned t...
static async Task Update(object Object)
Updates an object in the database.
static Task< IEnumerable< object > > Find(string Collection, params string[] SortOrder)
Finds objects in a given collection.
static async Task Insert(object Object)
Inserts an object into the default collection of the database.
This filter selects objects that conform to all child-filters provided.
Custom filter used to filter objects using an external expression.
This filter selects objects that have a named field equal to a given value.
This filter selects objects that have a named field lesser than a given value.
Static class that dynamically manages types and interfaces available in the runtime environment.
static Type GetType(string FullName)
Gets a type, given its full name.
static object[] NoParameters
Contains an empty array of parameter values.
static object Instantiate(Type Type, params object[] Arguments)
Returns an instance of the type Type . If one needs to be created, it is. If the constructor requires...
static Type[] GetTypesImplementingInterface(string InterfaceFullName)
Gets all types implementing a given interface.
static ConstructorInfo GetDefaultConstructor(Type Type)
Gets the default constructor of a type, if one exists.
Static class managing persistent settings.
static async Task< string > GetAsync(string Key, string DefaultValue)
Gets a string-valued setting.
A transaction built up of a set of sub-transactions.
Abstract base class for transactions.
async Task< bool > Commit()
Commits any changes made during the execution phase.
object Tag
Caller can use this property to tag the transaction with information.
async Task< bool > Execute()
Executes the transaction.
async Task< bool > Rollback()
Rolls back any changes made during the execution phase.
Module making sure no unfinished transactions are left when system ends.
static bool Running
If the transaction module is running.
Maintains a collection of active transactions.
Class that monitors login events, and help applications determine malicious intent....
static async Task< KeyValuePair< string, object >[]> Annotate(string RemoteEndpoint, params KeyValuePair< string, object >[] Tags)
Annotates a remote endpoint.
Contains information about a login attempt.
DateTime? Next
Time when a new login can be attempted.
LoginResultType Type
Type of login result.
Corresponds to a user in the system.
Maintains the collection of all users in the system.
static async Task< LoginResult > Login(string UserName, string Password, string RemoteEndPoint, string Protocol)
Attempts to login in the system.
Manages eDaler on accounts connected to the broker.
override bool SupportsAccounts
If the component supports accounts (true), or if the subdomain name is the only valid address.
override void Dispose()
IDisposable.Dispose
async Task< string > ProcessUri(string Uri, string From)
Processes an eDaler URI.
LegalComponent Legal
Legal component
const string NamespaceEDaler
Namespace of eDaler component.
EDalerComponent(XmppServer Server, CaseInsensitiveString Subdomain, string Name, LegalComponent Legal)
Manages eDaler on accounts connected to the broker.
async Task< string > GetDefaultCurrency()
Gets the default currency
Relays processing of the URI to the principal domain.
eDaler URI representing a contractual payment of eDaler from a sender to a receiver.
Abstract base class for eDaler URIs
abstract void AddTransactionParts(List< ITransaction > Subtransactions, bool LocalOnly, LegalComponent Legal)
Adds subtransaction objects necessary to process the URI.
EDalerUriState State
URI State object.
CaseInsensitiveString PrincipalDomain
Principal domain (i.e domain controlling the execution of the transaction.)
static async Task< EDalerUri > Parse(string Uri, EDalerUriState State, EDalerComponent EDaler)
Parses an eDaler URI
virtual void Error(EDalerUriErrorType ErrorType, string ErrorMessage, bool LogAsNotice)
Reports an error with the URI
string ErrorMessage
Error message, or null if no error.
Current state of URI from external source
Current state of URI from internal source
Retains the current balance of an account.
CaseInsensitiveString Name
Property name
CaseInsensitiveString Value
Property value
Provisioning and registry service component.
Marketplace processor, brokering sales of items via tenders and offers defined in smart contracts.
Service Module hosting the XMPP broker and its components.
Interface for information about a service provider that users can use to buy eDaler.
string BuyEDalerTemplateContractId
Contract ID of Template, for buying e-Daler
Task< IDictionary< CaseInsensitiveString, object >[]> GetPaymentOptionsForBuyingEDaler(IDictionary< CaseInsensitiveString, CaseInsensitiveString > IdentityProperties, string SuccessUrl, string FailureUrl, string CancelUrl, ClientUrlEventHandler ClientUrlCallback, object State)
Gets available payment options for buying eDaler.
Task< bool > CanBuyEDaler(CaseInsensitiveString AccountName)
If the service provider can be used to process a request to buy eDaler of a certain amount,...
Interface for information about a service provider that users can use to buy eDaler.
Task< IBuyEDalerService[]> GetServicesForBuyingEDaler(CaseInsensitiveString Currency, CaseInsensitiveString Country)
Gets available payment services.
Interface for information about a service provider that users can use to sell eDaler.
Task< bool > CanSellEDaler(CaseInsensitiveString AccountName)
If the service provider can be used to process a request to sell eDaler of a certain amount,...
string SellEDalerTemplateContractId
Contract ID of Template, for selling e-Daler
Task< IDictionary< CaseInsensitiveString, object >[]> GetPaymentOptionsForSellingEDaler(IDictionary< CaseInsensitiveString, CaseInsensitiveString > IdentityProperties, string SuccessUrl, string FailureUrl, string CancelUrl, ClientUrlEventHandler ClientUrlCallback, object State)
Gets available payment options for selling eDaler.
Interface for information about a service provider that users can use to sell eDaler.
Task< ISellEDalerService[]> GetServicesForSellingEDaler(CaseInsensitiveString Currency, CaseInsensitiveString Country)
Gets available payment services.
string Id
ID of service provider.
int IconWidth
Width of icon, if available.
string IconUrl
Optional URL to icon of service provider.
int IconHeight
Height of icon, if available.
string Name
Displayable name of service provider.
CaseInsensitiveString UserName
User Name
bool Enabled
If the account is enabled.
Interface for XMPP user accounts.
Grade Supports(T Object)
If the interface understands objects such as Object .
Interface for transactions
Task< bool > Execute()
Executes the transaction.
Task< bool > Prepare()
Prepares the transaction for execution. This step can be used for validation and authorization of the...
Task< bool > Rollback()
Rolls back any changes made during the execution phase.
Task Abort()
Aborts the transaction.
Task< bool > Commit()
Commits any changes made during the execution phase.
Basic interface for a user.
LoginResultType
Result of login attempt
EDalerUriErrorType
Type of URI Error