3using System.Collections.Generic;
4using System.Threading.Tasks;
28 : base(
"Wallet/InitiateSellEDaler",
29 new KeyValuePair<Type,
Expression>(typeof(Dictionary<string, object>), new
Expression(jsonPattern)),
52 string Country = Identity[
"COUNTRY"];
53 if (
string.IsNullOrEmpty(Country))
56 string ServiceId = (string)Parameters[
"PServiceId"].AssociatedObjectValue;
57 string ServiceProvider = (string)Parameters[
"PServiceProvider"].AssociatedObjectValue;
58 decimal Amount = (decimal)((
double)Parameters[
"PAmount"].AssociatedObjectValue);
60 string SuccessUrl = Parameters.TryGetValue(
"PSuccessUrl", out
IElement E) ? (string)E?.AssociatedObjectValue :
null;
61 string FailureUrl = Parameters.TryGetValue(
"PFailureUrl", out E) ? (string)E?.AssociatedObjectValue :
null;
62 string CancelUrl = Parameters.TryGetValue(
"PCancelUrl", out E) ? (string)E?.AssociatedObjectValue :
null;
63 string TransactionIdStr = Parameters.TryGetValue(
"PTransactionId", out E) ? (string)E?.AssociatedObjectValue :
null;
64 string TabId = Parameters.TryGetValue(
"PTabId", out E) ? (string)E?.AssociatedObjectValue :
null;
65 string FunctionName = Parameters.TryGetValue(
"PFunctionName", out E) ? (string)E?.AssociatedObjectValue :
null;
68 if (
string.IsNullOrEmpty(TransactionIdStr))
69 TransactionId = Guid.NewGuid();
70 else if (!Guid.TryParse(TransactionIdStr, out TransactionId))
79 if (
string.IsNullOrEmpty(ServiceId))
101 throw new ForbiddenException(
"Selected service provider does not support selected currency (" + Currency +
").");
104 throw new ForbiddenException(
"Service provider requires a signed contract to perform payment. See associated Contract Template ID.");
107 List<NamedDictionary<string, object>> Providers =
new List<NamedDictionary<string, object>>();
109 Dictionary<CaseInsensitiveString, object> ContractParameters =
new Dictionary<CaseInsensitiveString, object>()
111 {
"Amount", Amount },
112 {
"Currency", Currency.
Value.ToUpper() }
114 Dictionary<CaseInsensitiveString, CaseInsensitiveString> SellerIdParameters =
new Dictionary<CaseInsensitiveString, CaseInsensitiveString>();
116 foreach (
Property P
in Identity.Properties)
119 SellEDalerTransaction Transaction = PaymentTransactions.Add<SellEDalerTransaction>(
120 TransactionId, ServiceId,
ServiceProvider, Amount, Currency, SuccessUrl,
121 FailureUrl, CancelUrl, TabId, FunctionName, User.UserName, Service,
122 Identity.
Id, ContractParameters, SellerIdParameters);
124 if (!await Transaction.Prepare())
127 await Response.Return(Transaction.GetInformation());
129 Task _ = Task.Run(async () =>
133 await Transaction.Process();
Contains information about a service provider that users can use to sell eDaler.
Contains information about a service provider.
string Id
ID of service provider.
Static class managing loading of resources stored as embedded resources or in content files.
static string LoadResourceAsText(string ResourceName)
Loads a text resource from an embedded resource.
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 class managing the runtime environment of the IoT Gateway.
static CaseInsensitiveString Domain
Domain name.
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
The server understood the request, but is refusing to fulfill it. Authorization will not help and the...
Represents an HTTP request.
Represets a response of an HTTP client request.
The server has not found anything matching the Request-URI. No indication is given of whether the con...
The server is currently unable to handle the request due to a temporary overloading or maintenance of...
Represents a case-insensitive string.
string Value
String-representation of the case-insensitive string. (Representation is case sensitive....
static bool IsNullOrEmpty(CaseInsensitiveString value)
Indicates whether the specified string is null or an CaseInsensitiveString.Empty string.
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 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...
Class managing a script expression.
string UserName
User Name.
Retains the current balance of an account.
CaseInsensitiveString Name
Property name
CaseInsensitiveString Value
Property value
Abstract base class for agent resources supporting the POST method.
static AccountUser AssertUserAuthenticated(HttpRequest Request)
Makes sure the request is made by an authenticated API user.
Initiates the process of selling eDaler.
override async Task POST(HttpRequest Request, HttpResponse Response, Dictionary< string, IElement > Parameters)
Executes the POST method on the resource.
InitiateSellEDaler()
Initiates the process of selling eDaler.
Service Module hosting the XMPP broker and its components.
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
Interface for information about a service provider that users can use to sell eDaler.
Grade Supports(T Object)
If the interface understands objects such as Object .
Basic interface for all types of elements.