A library for using WebMoney XML interfaces on the .NET platform (WM-API)

This article is intended for developers who want to use WebMoney Transfer interfaces in Microsoft .NET applications.

The purpose of this article: provide brief information about the WebMoney.XmlInterfaces library (code name _WM-

API_) sufficient for using the library in your own projects.

The WebMoney.XmlInterfaces library was created for simplifying the work with the XML-interfaces of the

WMTransfer system. Written in managed C#, it is distributed with open source codes and an "MIT" license:

http://www.opensource.org/licenses/mit-license.php. The program also uses a digital signature generation module

called WMSignerFX.

The latest 1.0 version of the library was released on December 16, 2010.

Basic information about the library structure

Contents

  1. List of modules.
  2. Special types.
  3. Request and response classes.
  4. Special types for business process exceptions.
  5. Library initialization in the program code.
  6. Library initialization using a configuration file.
  7. General library usage scenario.
  8. Exception logging process.
  9. Usage examples.

1 List of modules

Name Purpose
BusinessTools.Cryptography.dll, WebMoney.Cryptography.dll Generation of a digital signature. See WMSignerFX.
BusinessTools.Logging.dll, log4net.dll, NLog.dll Logging of exceptions.
CertificateValidator.dll Server certificate validation(used if the publisher's certificate has not been added to the root storage).
Finance.Entities.dll, WebMoney.BasicObjects.dll Special types.
WebMoney.XmlInterfaces.Configuration.dll Used for initializing the library with parameters set in the configuration file.
WebMoney.XmlInterfaces.dll Types of requests/responses. Special types for exceptional situations.
XmlInterfaces.General.dll Kernel. Base classes for server requests/responses.

Detailed information about each of the modules is provided below.

2 Special types

The library uses special types for representing the main system entities.

The most general types are defined in the Finance.Entities library (not directly related to the WebMoney system).

Type name Meaning Comment
Amount Amount Can be implicitly converted into a decimal value. The decimal type can be explicitly converted into an Amount value (preserving 2 digits after the period).
BankAccount Bank account Can contain digits only.
BankCard Payment card Can contain digits only. No additional checks are performed in version 1.0.
Currency Payment currency Can assume the following values in version 1.0: USD, EUR, RUR, UAH.
PaymentSystem Payment system For use with the X19 interface. Can assume the following values in version 1.0: RbkMoney, PayPal, MoneyBookers, Qiwi, MoneyYandex, EasyPay.
Percent Percent value Used for wm.exhanger.ru interfaces
Phone Phone number For use with the X19 interface. The phone number can be saved in 2 formats: +000000000000 and 000000000000.
Rate Exchange rate Can be implicitly converted into a decimal value. The decimal type can be explicitly converted into an Amount value. When the value is converted into a string, 4 digits after the period are preserved.

These types can be serialized/deserialized. Below is a class diagram for these data types:

Types related to WebMoney only are defined in the WebMoney.BasicObjects library.

Type name Meaning Comment
ConfirmationFlag Confirmation Used with the interfaceX2
ContractType Contract type The type of contract in the Arbitrage (for the interfaceX17). Can assume the following values: Public (for an agreement), Private (for a contract).
Description A short string (up to 256 characters) Can be implicitly converted into a System.String value. The System.String type can be explicitly converted into an Info type value (preserving the initial 255 characters). Use: comments to operations, delivery address, protection code.
ExchangeType Exchange type For use with the X19 interface.
InvoiceState Invoice status Enumeration, can assume the following values: NotPaid (not paid), PaidProtection (paid with protection), Paid (paid without protection), Refusal (rejected).
Message Long string (up to 1024 characters) For use with the interface X6.
PartnerAvailability Payment permissions For use with the interface X8. Can assume the following values: InvoiceForbidden, MessageForbidden, TransferForbidden (several ).
PassportAppointment Title For the interface X11. Assumes one of the following values: PrivatePerson, Director, Accountant, Representative, PrivateEntrepreneur
PassportDegree Passport level For the interface X11. Assumes one of the following values: Alias, Formal, Initial, Personal, Merchant, Capitaller, Developer, Registrar, Guarantor, Service1, Service2, Operator
PassportStatus Status For the interface X11. Assumes one of the following values: PrivatePerson (individual), Entity (company).
PaymerType Check type For the interface X18. Can assume one of the following values: Paymer, WMnote, Check.
Purse Purse Data structure, consists of a PurseType value (the type of purse: Z, E, R, U, B, Y, G, D, C) and a ulong value (purse number).
TransferType Transfer type Can assume the following values: Normal (regular), Protection (with payment protection), ProtectionCancel (with payment protection, cancelled).
WmCurrency Type of WM currency I version 1.0, the following currencies are defined: Z, E, R, U, B, Y, G, D, C.
WmDate Date Can be implicitly converted into a System.DateTime value. The System.DateTime type can be explicitly converted into WMDate (losing the time value). The time zone is taken into account during conversion.
WmDateTime Date and time Can be fully converted into a System.DateTime value. The time zone is taken into account during conversion.
WmId WebMoney identifier Can be implicitly converted into a ulong value. The ulong type can be explicitly converted into a WmId value (max value: 999999999999).

These types can be serialized/deserialized. Below is a class diagram for these types:

3 Requests and responses

For each interface request and response, there exists a special type that icapsulates the data of a corresponding

request/response:

# Interface function Request class Response class
X1 Invoice generation OriginalInvoice RecentInvoice
X2 Funds transfer OriginalTransfer RecentTransfer
X3 History of operations TransferFilter TransferRegister
X4 List of generated invoices OutgoingInvoiceFilter OutgoingInvoiceRegister
X5 Completion of operations with protection ProtectionFinisher ProtectionReport
X6 Messaging OriginalMessage RecentMessage
X7 Signature validation SignatureInspector SignatureInference
X8 Search by purse or identifier WmIdFinder WmIdReport
X9 Purse balance PurseInfoFilter PurseInfoRegister
X10 Incoming invoices IncomingInvoiceFilter IncomingInvoiceRegister
X11 Password information PassportFinder Passport
X13 Rejection of protected payments ProtectionRejector ProtectionReport
X14 Funds transfer rejection TransferRejector MoneybackReport
X15.1 My trusts OutgoingTrustFilter TrustRegister
X15.2 Incoming trusts IncomingTrustFilter TrustRegister
X15.3 Trust creation or modification OriginalTrust TrustRegister
X16 Purse creation OriginalPurse RecentPurse
X17.1 Contract creation OriginalContract RecentContract
X17.2 Information about acceptors AcceptorFilter AcceptorRegister
X18 Merchant operation details MerchantOperationFilter ExistentMerchantOperation
X19 Client inspector ClientInspector ClientEvidence

Types of responses for incoming/outgoing invoices and transfers are inherited from the Operation base class. For

convenience, see the class diagram below:

4 Special types of exceptions

The system has special types for all exceptions of the business process generated by the WebMoney server. In the

most general case, an exception of the WmException type is thrown (the error number is saved in the error number

ErrorNumber property). This type is extended for some interfaces.

Type of exception Interface number
WmException The base type for all business exceptions. Used for all interfaces besides the ones listed in the table.
ClientInspectorException X19. Client validation
OriginalInvoiceException X1. Invoice generation
OriginalMessageException X6. Sending a message
OriginalPurseException X16. Creation of a purse
OriginalTransferException X2. Funds transfer
TransferRejectorException X14. No-commission payment rejection

You can identify an error by its number using the TranslateDescription method.

Types of exceptions can be serialized/deserialized. Below is a class diagram for these types:

5 Library initialization in the code

You need to initialize a library before using it. This can be done in two ways: (1) directly in the program code,

(2) in the configuration file.

An example of program configuration from the code using a Keeper Classic key:

var masterWmId = (WmId) 111111111111; // alternatively, you can write WmId.Parse("111111111111")
KeeperKey keeperKey = new KeeperKey("Enter the XML key you got from the .kwm file using the Key Extractor tool");

var initializer = new Initializer(masterWmId, keeperKey);
initializer.StartDate = new DateTime(1983, 1, 1).ToUniversalTime(); // for forming ReqN
initializer.Apply();

The primaryWmId variable here is an object of a WmId type keeping a identifier of the owner of the private

key. The keeperKey variable contains an object of the KeeperKey type from the WebMoney.Cryptography.dll library

(see. WMSignerFX).

An example of program configuration from the code using a Keeper Light key:

var initializer = new Initializer(certificate);
initializer.StartDate = new DateTime(1983, 1, 1).ToUniversalTime(); // for forming ReqN
initializer.Apply();

A certificate here is an object of the standard .NET X509Certificate class.

Once the parameters have been set, you need to call the Apply method. The configuration will be applied globally

(this can be done just once before the interfaces are called). In some cases, it may result in some problems (for

instance, if a clustered architecture is being used), but you can avoid using global static objects. To do that,

pass the local object of the Initializer class to the type-response constructor.

6 Library initialization in the configuration file

The second way to initialize the library is to set the parameters in the configuration file.

To perform authentication using a WM Keeper Classic key, you need to specify the following:

  1. The main WMID.
  2. A string representation of a WM Keeper key obtained with the help of Key Extractor.
  3. The necessary data for a request number generation: reference date and update time in milliseconds.

To perform authentication using a WM Keeper Light key, you will need to specify the following:

  1. Location of the X.509 WM Keeper Light key: storage name and type. Alternative option: specify the Base-64 representation of the certificate and private key obtained with the help of Key Extractor.
  2. A thumbprint of the WMKeeper Light private key certificate. If a Base-64 certificate and private key representation are specified, you don't need to specify a certificate thumbprint.
  3. The data for generating a request number: reference date and refresh period in milliseconds.

Note: if the library is used with a WM Keeper Light key, the code must have FullTrust priviledges.

An example of a configiration file for authentication based on a WM Keeper Classic key:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <configSections>
    <sectionGroup name="webMoneyConfiguration">
        <section name="applicationInterfaces" type="WebMoney.XmlInterfaces.Configuration.ConfigurationHandler,WebMoney.XmlInterfaces.Configuration" />
      </sectionGroup>
  </configSections>

  <webMoneyConfiguration>
    <applicationInterfaces>
      <authorizationMode>Classic</authorizationMode>
      <keeperClassic>
        <wmId>712300479010</wmId>
        <wmKey>&lt;RSAKeyValue&gt;&lt;Modulus&gt;ccqACxc2qzE3t+zJntCBGrw/qZTmrmJEPhmkVGUwhc+ZhDiIr4qwAvhnNwIme9r5YjWEdi7wm/XDnsp096aNjlkI&lt;Modulus&gt;&lt;D&gt;FW1RaQMqZ6zHl6+wx+16uDB4zAmRr9sbBP7xVxzIg4vuIG4/w5b5XzFNv2sfSsmu+I3roO7E7qYmoeIn8otCeHgD&lt;/D&gt;&lt;/RSAKeyValue&gt;</wmKey>
      </keeperClassic>
      <requestNumber>
        <startTime>01.01.2009 00:00:00</startTime>
        <period>1000</period>
      </requestNumber>
    </applicationInterfaces>
  </webMoneyConfiguration>

</configuration>

The wmKey parameter here is the value of a private key in the XML format obtained using
Key Extractor. Attention! XML-Encoding was applied to the key value ('<' and '>' symbols were replaced).

An example of a configuration file for authentication using a WM Keeper Light key where storage is specified:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <configSections>
    <sectionGroup name="webMoneyConfiguration">
        <section name="applicationInterfaces" type="WebMoney.XmlInterfaces.Configuration.ConfigurationHandler, 

WebMoney.XmlInterfaces.Configuration" />
      </sectionGroup>
  </configSections>

  <webMoneyConfiguration>
    <applicationInterfaces>
      <authorizationMode>Light</authorizationMode>
      <keeperLight>
        <containerInfo>
          <storeName>My</storeName>
          <storeLocation>CurrentUser</storeLocation>
          <thumbprint>65d4308da7fe18fe2788acee2ec48f453b4461d1</thumbprint>
        </containerInfo>
      </keeperLight>
      <requestNumber>
        <startTime>01.01.2009 00:00:00</startTime>
        <period>1000</period>
      </requestNumber>
    </applicationInterfaces>
  </webMoneyConfiguration>

</configuration>

An example of a configuration file for authentication using a WM Keeper Light key where Base-64 private key and certificate representations are specified:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <configSections>
    <sectionGroup name="webMoneyConfiguration">
        <section name="applicationInterfaces" type="WebMoney.XmlInterfaces.Configuration.ConfigurationHandler,WebMoney.XmlInterfaces.Configuration" />
      </sectionGroup>
  </configSections>

  <webMoneyConfiguration>
    <applicationInterfaces>
      <authorizationMode>Light</authorizationMode>
      <keeperLight>
        <rawData>MIIE+gIBAzCCBLoGCSqGSIb3DQEHAaCCBKsEggSnMIIEozCCBJ8GCSqGSIb3DQEHBqCCBJAwggSMAgEAMIIEhQYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQIR0XXduV1U7YCAgfQgIIEWLbDls7e99zCoPINitqYT1xaz4GQsU/5UwaBXc6Ux+dTdAB2ZVLdWRJ7XDDisQx0I4TIbmOEPTHSRHcqasLn9/nqEps0qikST4PVVoHeFgYFWP7LZkmhrZnbNNhU+yDe4IGdZgDq+owLn2ZnnxFKQwJhk3yUC6cLoPGK/b+2FeiObAa1rKk3+xMcBy+AdGvSOLpY0hpHEWI3vRJ12mpWzQdhcc+eyrxYArBWa0tUEkFjqQPZk8+yaOfn+mB20pPuVgSJAOVACYA46nB2IY0UiQDVAiC2+SOKdUqQEK5XDDTIInHyG/y4wHAR1B1RORS4IPEdKySaaae5Mi8/8FXYb6kGI57XjdOMXR8gSgohinTLiKXbvL02FgwHHPKnIh7N2k+siwxND/eKVgQ6fElbm3XLTsjhraWICbr2zJBmE6pI/w9M1UGnNNrG8b4THmr0HIguw7V3D0kZI9BbG51+RiHb58pFkiSdGSt9PFYUwoix/wNmuzs9LM9itrVCV6HqWkxi82bIynsaPU8SDCz7BAbYlO+F35JROQR07FypMCl4LXdsLdWPeW7htZnvB7iUExs+WfMITrbSFvL+DatJ5euFuJu9mNpmM/rYuidGHgXmHN1bteMDXq1PWnfeOnnGJoXEp2zRBHk3ETwQtdKxYMzqfFNuCxrnx3mH9PBV/DWUwMAnZgb2autq+EJrLEXxpJPqWIcJNKwzx49Lx1gvqB6vv4I1u3VK+nFWOcv59m4KCbRPy7t1JbGVKCXXPstmhm2jq1byT3G3a/EKmG56BdyrzUZ2d7b6IgnSA+0E8X56UIYVgAr7rg3ciZYCFNupLwz0eqlOuDzehLnXzS+17TyEPF+sqKqJP16PwFCQaGlDd5kycvOk1i0tnM0EvHON1maZjfB/C4Wqzp+bqPjezfRiNo1VS6e8vryWb4DIy7Xgfe/C8Xxf4DzDlq+hyWcux+ewDj7qqZvc5geysjV6iYCK3JZ/IB2FNhYW+J2Os/WbK8jUFvfTO/Ha0IyO8rcQJwwliacky5LOo8Ib9Dero19S78sz39GfPmS918HLktl8fMR7ZqLnCVnvOgo0cg7IgoqfDOrBm3WGt7WQYGBaam00apf3YDtIuLsVgQT/8ZKv3WotAiyI/8vk8uc7pjC9cZdzL+aEo/e0PkETYei76QxQDJbGxp2jzTuy980AN3Mv/gZF7rYkVxVKNWOwv56npRyAyHd45th+2o2H/TIaaSOq2gwlGSQ58kO09viU1NlccNJApD4G3DaKnTm1n1e3QwiZkwQm9VyJ4IVWGYarR/0HcTXewV3a5hG4k+zhfZdrydT8UN2ViHm+vMD2Fggtz8EuXZKu6kwtt+LmsRW/6BwcL8hNAPyQp4QrUzK41O0cBuEuv2mgqspDcjNNpNJpjpRC/5Qgrzz2siwCfUyquie8A3xPqCZ2KhKVU1suGVpeGdg2ikkM6K+5SMM3WiErX3ER8uY/8vrMDcwHzAHBgUrDgMCGgQUqXXnEeizaXIhJeucy/eUUMITrakEFIfBnx2/Q82NU4rCl21Ny863Lnha</rawData>
      </keeperLight>
      <requestNumber>
        <startTime>01.01.2009 00:00:00</startTime>
        <period>1000</period>
      </requestNumber>
    </applicationInterfaces>
  </webMoneyConfiguration>

</configuration>

Note: for ASP.Net applications, the configuration file is called "Web.config" and is located in the root folder of the site. For Win32 applications, the file has the same name as the application's executable file with".config" added to it (example: MyApplication.exe.config) and is located in the same folder.

Starting from version 1.0, you need to explicitly specify that you are going to use parameters from a configuration

file (once before the first interface call):

Initializer initializer = new Configurator();
initializer.Apply();

The Configurator class is located in the WebMoney.XmlInterfaces.Configuration.dll build.

7 Using the library

Once the library is initialized, it's ready to be used. The use of the library with WM Keeper Classic and [[WM

Keeper Light]] keys is absolutely identical.

Usage scenarios:

1. Initialize the library (see the 2 methods above).
2. Create a request object. To use local initialization, pass an Initializer class object to the constructor of the

request object.
3. Call the Submit method. This method will return a response object (see the table of request and response

classes above).

Calling the method may lead to a business exception inherited from WmException being thrown.

8 Logging of exceptions

If an exception is thrown while processing a request, the libarary automatically creates a log file with error

details. The file is created in the root directory.

Attention! Business exceptions (inherited from WmException) have a Debug level. All other exceptions have an

Error level.

You can control the logging process using the NLog configuration file. By default, it contains all types of

exceptions, business and all others.

9 Usage examples

The code samples are in C#:

General test data (used in many examples).

// Test data
var primaryWmId = WmId.Parse("111111111111"); // string parsing
var secondaryWmId = (WmId) 222222222222; // the ulong type can be explicitly converted into the WMID type
var primaryPurse = Purse.Parse("R111111111111"); // a purse with money
var secondaryPurse = new Purse(WmCurrency.R, 222222222222); // an alternative record
var amount = (Amount)0.01M; // can use string parsing: Amount.Parse("0.01");

// An order number in the store. Can be used for searching operations. No unique.
uint orderId = 1;

// A transfer number. Used for preventing transfer or message duplicates.
int transferId = 1;

X1. Invoice generation

var originalInvoice = new OriginalInvoice(orderId, primaryWmId, secondaryPurse, amount);
originalInvoice.Description = (Description)("Invoice validation");
originalInvoice.Address = (Description)"Store address";
originalInvoice.Expiration = 3; // payment expiration period (180 days by default)
originalInvoice.Period = 1; // protection period, if payment with proteсtion is allowed

try
{
   var recentInvoice = originalInvoice.Submit();

   Console.WriteLine("Success. Invoice number: " + recentInvoice.Id);
}
catch (WmException wmException)
{
   Console.WriteLine("Error: " + wmException.Message);
}

_Note. When the Submit us called, a WmException business exception can be thrown. This applies to all interfaces.

A WebException can also be thrown (you will need to call the Submit method again)._

X2. Fund transfers

var originalTransfer = new OriginalTransfer(2, new Purse(WmCurrency.Z, 1), Purse.Parse("Z123456789012"), 

Amount.Parse(1));
originalTransfer.Description = (Description) "Test transfer";
originalTransfer.InvoiceId = recentInvoice.Id; // if the transfer is being made according to an invoice

var recentTransfer = originalTransfer.Submit();

X3. History of operations

var transferFilter = new TransferFilter(primaryPurse, DateTime.Now.AddMinutes(-5), DateTime.Now);
var transferRegister = transferFilter.Submit();

foreach (var transfer in transferRegister.TransferList)
{
   Console.WriteLine(transfer.Id + " " + transfer.Amount);
}

X4. History of outgoing invoices (search by invoice number)

var outgoingInvoiceFilter = new OutgoingInvoiceFilter(primaryPurse, DateTime.Now.AddMinutes(-5), DateTime.Now);
//outgoingInvoiceFilter.InvoiceId = recentInvoice.Id; search by invoice number

var outgoingInvoiceRegister = outgoingInvoiceFilter.Submit();

foreach (var outgoingInvoice in outgoingInvoiceRegister.OutgoingInvoiceList)
{
   Console.WriteLine(outgoingInvoice.Id + " " + outgoingInvoice.InvoiceState);
}

X5. Finishing an operation with protection

var protectionFinisher = new ProtectionFinisher(recentTransfer.Id, code);
var protectionReport = protectionFinisher.Submit();

X6. Sending a message

var subject = (Description)"Validation";
var content = (Message)"Text message (not more than 1024 characters).";

var originalMessage = new OriginalMessage(secondaryWmId, subject, content);
var recentMessage = originalMessage.Submit();

X7. Signature validation

var signer = new Signer();
signer.Initialize(
                "<RSAKeyValue><Modulus>ccqACxc2qzE3t+zJntCBGrw/qZTmrmJEPhmkVGUwhc

+ZhDiIr4qwAvhnNwIme9r5YjWEdi7wm/XDnsp096aNjlkI</Modulus><D>FW1RaQMqZ6zHl6+wx

+16uDB4zAmRr9sbBP7xVxzIg4vuIG4/w5b5XzFNv2sfSsmu+I3roO7E7qYmoeIn8otCeHgD</D></RSAKeyValue>");

string message1 = "Message1";
string message2 = "Message2";
string signature = signer.Sign(message1);

var signatureInspector1 = new SignatureInspector(WmId.Parse("712300479010"), (Message)message1,
                                                             (Description)signature);
var signatureEvidence1 = signatureInspector1.Submit();

var signatureInspector2 = new SignatureInspector(WmId.Parse("712300479010"), (Message)message2,
                                                             (Description)signature);
var signatureEvidence2 = signatureInspector2.Submit();

if (!signatureEvidence1.VerificationResult)
   Console.WriteLine("!signatureEvidence1.VerificationResult");

if (signatureEvidence2.VerificationResult)
   Console.WriteLine("signatureEvidence2.VerificationResult");

X8. Search by an identifier or purse

var wmIdFinder = new WmIdFinder(WmId.Parse("712300479010"));
var wmIdReport = wmIdFinder.Submit();

Console.WriteLine(wmIdReport.Success);

X9. Purse balance

var purseInfoFilter = new PurseInfoFilter(primaryWmId);
var purseInfoRegister = purseInfoFilter.Submit();

foreach (var purseInfo in purseInfoRegister.PurseInfoList)
{
   Console.WriteLine(purseInfo.Purse + " " + purseInfo.Amount);
}

X10. List of incoming invoices

var incomingInvoiceFilter = new IncomingInvoiceFilter(primaryWmId, DateTime.Now.AddDays(-1), DateTime.Now);
var incomingInvoiceRegister = incomingInvoiceFilter.Submit();

foreach (var incomingInvoice in incomingInvoiceRegister.IncomingInvoiceList)
{
   Console.WriteLine(incomingInvoice.TargetWmId + " " incomingInvoice.InvoiceState);
}

X11. Passport information

var passportFinder = new PassportFinder(secondaryWmId);
var passport = passportFinder.Submit();

Console.WriteLine(passport.PassportDegreeToLocalString()); // the type of passport in English or Russian, depending 

on the current culture

X13. Rejection of protected payments

var protectionRejector = new ProtectionRejector(transferId);
var protectionReport = protectionRejector.Submit();

X14. No-commission payment rejection

var transferRejector = new TransferRejector(transferId, amount);
var moneybackReport = transferRejector.Submit();

X15.1 List of my trusts

    
var outgoingTrustFilter = new OutgoingTrustFilter(primaryWmId);
var trustRegister = outgoingTrustFilter.Submit();

foreach (var trust in trustRegister.TrustList)
{
   Console.WriteLine(trust.Master + " " + trust.TransferAllowed);
}

X15.2 List of incoming trusts

var incomingTrustFilter = new IncomingTrustFilter(primaryWmId);
var trustRegister = incomingTrustFilter.Submit();

foreach (var trust in trustRegister.TrustList)
{
  Console.WriteLine(trust.Purse + " " + trust.DayAmount);
}

X15.3 Creation or modification of a trust

 
var originalTrust = new OriginalTrust(secondaryWmId, primaryPurse);
originalTrust.InvoiceAllowed = true;
var trustRegister = originalTrust.Submit();

X16. Creation of a purse

var originalPurse = new OriginalPurse(_primaryWmId, WmCurrency.G, (Description)"Temp");
var recentPurse = originalPurse.Submit();

X17.1 Creating a cotract

var originalContract = new OriginalContract((Description)"Test contract", ContractType.Private,
 "The contract is created for testing the WM-API library.");

originalContract.AcceptorList = new List<WmId>();
originalContract.AcceptorList.Add(primaryWmId);
originalContract.AcceptorList.Add(secondaryWmId);

X17.2 Information about acceptors

var acceptorFilter = new AcceptorFilter(recentContract.ContractId);
var acceptorRegister = acceptorFilter.Submit();

foreach (var acceptor in acceptorRegister.AcceptorList)
{
   if (null != acceptor.AcceptTime) // if not signed, the data is set to null
      Console.WriteLine(acceptor.WmId);
}

X18. Operation details via merchant

 
var merchantOperationFilter = new MerchantOperationFilter(primaryPurse, 200000);
var merchantOperation = merchantOperationFilter.Submit();

X19. WMID data validation

var amount = Amount.Parse("0.01");

// Add/withdraw WM in cash at one of the exchange offices
var clientInspector = new ClientInspector(WmCurrency.U, amount, secondaryWmId, (Description)"AA000001", 

(Description)"Doe", (Description)"John");
//clientInspector.Output = false;
var clientEvidence = clientInspector.Submit();

// Add/withdraw WM in cash via a money exchange system
var clientInspector = new ClientInspector(WmCurrency.U, amount, secondaryWmId, (Description)"Doe", 

(Description)"John");
//clientInspector.Output = false;
var clientEvidence = clientInspector.Submit();

// Add/withdraw WM from a bank account
var clientInspector = new ClientInspector(WmCurrency.U, amount, secondaryWmId, (Description)"Doe", 

(Description)"John", (Description)"Citibank", BankAccount.Parse("111222"));
//clientInspector.Output = false;
var clientEvidence = clientInspector.Submit();

// Add/withdraw WM from a credit card
var clientInspector = new ClientInspector(WmCurrency.U, amount, secondaryWmId, (Description)"Doe", 

(Description)"John", (Description)"Citibank", BankCard.Parse("4246667766776677"));
//clientInspector.Output = false;
var clientEvidence = clientInspector.Submit();

// Exchange WM for a another electronic currency
var clientInspector = new ClientInspector(WmCurrency.U, amount, secondaryWmId, PaymentSystem.MoneyYandex, 

(Description)"41001231231231");
//clientInspector.Output = false;
string s = clientInspector.Compile();

// Add WM via SMS (operation/direction=2 only)
var clientInspector = new ClientInspector(WmCurrency.U, amount, secondaryWmId, Phone.Parse("+380440000001"));
clientInspector.Output = false;
var clientEvidence = clientInspector.Submit();

Links:

latest version can be found in tags/1.0.0.

Mirrors on CodePlex and Google Code are no longer supported.