curl -X POST "https://mydiscount.eservicii.md/MyDiscountApp/erp/CheckApiKey" \ -H "Content-Type: application/json" \ -d '{ "mAPIKey": "00000000-0000-0000-0000-000000000000" }'
using System.Net.Http; using System.Net.Http.Json; var client = new HttpClient { BaseAddress = new Uri("https://mydiscount.eservicii.md/MyDiscountApp/erp/") }; var payload = new { mAPIKey = Guid.Parse("00000000-0000-0000-0000-000000000000") }; var response = await client.PostAsJsonAsync("CheckApiKey", payload); var result = await response.Content.ReadFromJsonAsync<ResponseCheckApiKey>();
{
"ErrorCode": 0,
"ErrorMessage": null
}| Company | |
| Card | |
| Cash | |
| CashTransaction | |
| ValidatedCard | |
| DiscountProfile |
curl -X POST "https://mydiscount.eservicii.md/MyDiscountApp/erp/AddBonus" \ -H "Content-Type: application/json" \ -d '{ "APIKey": "11111111-2222-3333-4444-555555555555", "CardID": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "Amount": 25.00, "CashBack": 5.0, "Details": "Invoice #INV-12345", "DateTimeOfSale": "2026-04-30T14:35:00", "PlaceOfSale": "Central Store, Cashier 3" }'
var request = new CashData { APIKey = Guid.Parse(apiKey), CardID = cardId, Amount = 25.00m, CashBack = 5.0m, Details = "Invoice #INV-12345", DateTimeOfSale = DateTime.Now, PlaceOfSale = "Central Store, Cashier 3" }; var response = await client.PostAsJsonAsync("AddBonus", request); var result = await response.Content.ReadFromJsonAsync<ResponseSetCashBack>();
CheckApiKey
POST/MyDiscountApp/erp/CheckApiKey
| mAPIKey | Guid |
| ErrorCode | EnErrorCode | |
| ErrorMessage | string? |
curl -X POST "https://mydiscount.eservicii.md/MyDiscountApp/erp/CheckApiKey" \ -H "Content-Type: application/json" \ -d '{ "mAPIKey": "YOUR-API-KEY-HERE" }'
var payload = new { mAPIKey = Guid.Parse(apiKey) }; var resp = await client.PostAsJsonAsync("CheckApiKey", payload);
GetInfoBonusAmount
POST/MyDiscountApp/erp/GetInfoBonusAmount
| CardID | Guid | ||
| mAPIKey | Guid |
| Amount | decimal | |
| ErrorCode | EnErrorCode | |
| ErrorMessage | string? |
curl -X POST "https://mydiscount.eservicii.md/MyDiscountApp/erp/GetInfoBonusAmount" \ -H "Content-Type: application/json" \ -d '{ "CardID": "...", "mAPIKey": "YOUR-API-KEY" }'
var payload = new { CardID = cardId, mAPIKey = apiKey }; var resp = await client.PostAsJsonAsync("GetInfoBonusAmount", payload);
AddBonus
POST/MyDiscountApp/erp/AddBonus
| APIKey | Guid | ||
| CardID | Guid | ||
| Amount | decimal | ||
| CashBack | decimal | ||
| Details | string | ||
| DateTimeOfSale | DateTime | ||
| PlaceOfSale | string |
| TransactionID | Guid | |
| ErrorCode | EnErrorCode | |
| ErrorMessage | string? |
GetBonus
POST/MyDiscountApp/erp/GetBonus
Transaction
POST/MyDiscountApp/erp/Transaction
| APIKey | Guid | ||
| CardID | Guid | ||
| Amount | decimal | ||
| BillID | string |
BulkImport
POST/MyDiscountApp/CompanyCards/bulk-import
| APIKey | Guid | ||
| UniqueIdentifier | UniqueField | ||
| PurgeExisting | bool | ||
| Items | CompanyCardImportItem[] |
| 0 | Barcode | |
| 1 | ExternalId | |
| 2 | Phone |
| Barcode | string | |
| ExternalId | string | |
| Phone | string | |
| AccumulatedAmount | decimal | |
| Category | CardCategory | |
| Status | CardStatus | |
| IssuedAt | DateTime | |
| ExpiresAt | DateTime? | |
| Note | string | |
| Description | string |
| Ok | bool | |
| InsertedCount | int | |
| UpdatedCount | int | |
| DeletedCount | int | |
| SkippedCount | int | |
| Errors | string[] |
curl -X POST "https://mydiscount.eservicii.md/MyDiscountApp/CompanyCards/bulk-import" \ -H "Content-Type: application/json" \ -d '{ "APIKey": "11111111-2222-3333-4444-555555555555", "UniqueIdentifier": 0, "PurgeExisting": false, "Items": [ { "Barcode": "5949000000017", "ExternalId": "ERP-1001", "Phone": "+37369123456", "AccumulatedAmount": 250.50, "Category": 1, "Status": 0, "IssuedAt": "2026-01-15T10:00:00Z", "ExpiresAt": "2028-01-15T00:00:00Z", "Note": "VIP customer" }, { "Barcode": "5949000000024", "ExternalId": "ERP-1002", "Phone": "+37369765432", "Category": 0, "Status": 0 } ] }'
var request = new BulkImportRequest { APIKey = Guid.Parse(apiKey), UniqueIdentifier = UniqueField.Barcode, PurgeExisting = false, Items = new List<CompanyCardImportItem> { new() { Barcode = "5949000000017", ExternalId = "ERP-1001", Phone = "+37369123456", AccumulatedAmount = 250.50m, Category = CardCategory.VIP, Status = CardStatus.Active, IssuedAt = DateTime.UtcNow, ExpiresAt = DateTime.UtcNow.AddYears(2), Note = "VIP customer" }, new() { Barcode = "5949000000024", ExternalId = "ERP-1002", Phone = "+37369765432", Category = CardCategory.Standard, Status = CardStatus.Active } } }; var resp = await client.PostAsJsonAsync("CompanyCards/bulk-import", request); var result = await resp.Content.ReadFromJsonAsync<BulkImportResult>(); Console.WriteLine($"Inserted: {result.InsertedCount}, Updated: {result.UpdatedCount}, Skipped: {result.SkippedCount}"); if (result.Errors?.Count > 0) Console.WriteLine($"Errors: {string.Join('\n', result.Errors)}");
{
"Ok": true,
"InsertedCount": 2,
"UpdatedCount": 0,
"DeletedCount": 0,
"SkippedCount": 0,
"Errors": []
}CashData
JSON Schema
{
"APIKey": Guid,
"CardID": Guid,
"Amount": decimal,
"CashBack": decimal,
"Details": string,
"DateTimeOfSale": DateTime,
"PlaceOfSale": string // max 200 chars
}BillData
JSON Schema
{
"APIKey": Guid,
"CardID": Guid,
"Amount": decimal,
"BillID": string
}ResponseAuthorizeCard
JSON Schema
{
"ErrorCode": EnErrorCode,
"ErrorMessage": string,
"Key": Guid,
"Amount": decimal,
"UserName": string,
"PHID": string,
"PushToken": string,
"DiscountPercent": decimal
}ResponseSetCashBack
JSON Schema
{
"ErrorCode": EnErrorCode,
"ErrorMessage": string,
"TransactionID": Guid
}ResponseGetInfoBonusAmount
JSON Schema
{
"ErrorCode": EnErrorCode,
"ErrorMessage": string,
"Amount": decimal
}BulkImportRequest
JSON Schema
{
"APIKey": Guid,
"UniqueIdentifier": UniqueField, // 0=Barcode, 1=ExternalId, 2=Phone
"PurgeExisting": bool,
"Items": CompanyCardImportItem[]
}CompanyCardImportItem
JSON Schema
{
"Barcode": string,
"ExternalId": string,
"Phone": string,
"AccumulatedAmount": decimal,
"Category": CardCategory,
"Status": CardStatus,
"IssuedAt": DateTime,
"ExpiresAt": DateTime?,
"Note": string, // max 500
"Description": string // max 5000
}BulkImportResult
JSON Schema
{
"Ok": bool,
"InsertedCount": int,
"UpdatedCount": int,
"DeletedCount": int,
"SkippedCount": int,
"Errors": string[]
}| 0 | NoError | |
| — | Invalid_ID | |
| — | Card_not_exist | |
| — | Expired_token | |
| — | Time_card_ID_expired | |
| — | Insufficient_amount_on_card | |
| — | The_amount_is_incorrect | |
| — | APIKey_not_exist | |
| — | Internal_error |
// 1. var auth = await client.GetFromJsonAsync<ResponseAuthorizeCard>( $"AuthorizeCard?TID={tid}&APIKey={apiKey}&PlaceOfSale=Casa-1"); if (auth.ErrorCode != EnErrorCode.NoError) throw new Exception($"Invalid card: {auth.ErrorCode}"); // 2. var info = await client.PostAsJsonAsync("GetInfoBonusAmount", new { CardID = auth.Key, mAPIKey = apiKey }); var infoData = await info.Content.ReadFromJsonAsync<ResponseGetInfoBonusAmount>(); // 3. decimal deUsing = Math.Min(infoData.Amount, 80m); var use = await client.PostAsJsonAsync("GetBonus", new CashData { APIKey = apiKey, CardID = auth.Key, Amount = deUsing, Details = "Partial cashback", DateTimeOfSale = DateTime.Now, PlaceOfSale = "Casa-1" }); // 4. decimal dePlatit = 80m - deUsing;
decimal totalBon = 200m; decimal bonusDeAdaugat = totalBon * 0.05m; var add = await client.PostAsJsonAsync("AddBonus", new CashData { APIKey = apiKey, CardID = cardId, Amount = bonusDeAdaugat, CashBack = 5m, Details = $"Cashback 5% on bill {billId}", DateTimeOfSale = DateTime.Now, PlaceOfSale = "Casa-1" }); var result = await add.Content.ReadFromJsonAsync<ResponseSetCashBack>();
// 1. var allErpCards = await _erp.GetAllLoyaltyCardsAsync(); // e.g. 12,500 cards // 2. const int batchSize = 1500; int totalInserted = 0, totalUpdated = 0, totalSkipped = 0; for (int i = 0; i < allErpCards.Count; i += batchSize) { var batch = allErpCards.Skip(i).Take(batchSize).ToList(); var request = new BulkImportRequest { APIKey = apiKey, UniqueIdentifier = UniqueField.ExternalId, // match după ID-ul ERP PurgeExisting = false, // sync, nu reset Items = batch.Select(c => new CompanyCardImportItem { ExternalId = c.ErpId, Barcode = c.Barcode, Phone = c.CustomerPhone, AccumulatedAmount = c.Balance, Category = c.IsVip ? CardCategory.VIP : CardCategory.Standard, Status = c.IsActive ? CardStatus.Active : CardStatus.Blocked, IssuedAt = c.CreatedAt, ExpiresAt = c.ValidUntil }).ToList() }; var resp = await client.PostAsJsonAsync("CompanyCards/bulk-import", request); var res = await resp.Content.ReadFromJsonAsync<BulkImportResult>(); if (!res.Ok) { _logger.LogError($"Batch {i} failed: {string.Join(';', res.Errors)}"); continue; // batch-urile sunt independente } totalInserted += res.InsertedCount; totalUpdated += res.UpdatedCount; totalSkipped += res.SkippedCount; } _logger.LogInformation( $"Sync complete: +{totalInserted} inserted, ~{totalUpdated} updated, {totalSkipped} skipped");
| INTELECTSOFT | |
| sales.edi.md | |
| +373 22 835 312 | |