This commit is contained in:
2023-01-17 01:58:09 +00:00
parent b81e5c1a83
commit 64337d1e42
9 changed files with 148 additions and 16 deletions

View File

@@ -569,11 +569,13 @@ namespace Sockeye.Api.Controllers
}
else if (keyNameInLowerCase == StringUtil.TrimTypeName(typeof(ProductGroup).ToString()).ToLowerInvariant())
{
TranslationKeysToFetch.Add("ProductGroupNotSet");
TranslationKeysToFetch.Add("ProductGroupMisc");
TranslationKeysToFetch.Add("ProductGroupAyaNova7");
TranslationKeysToFetch.Add("ProductGroupRavenPerpetual");
TranslationKeysToFetch.Add("ProductGroupRavenSubscription");
var LT = await TranslationBiz.GetSubsetStaticAsync(TranslationKeysToFetch, translationId);
var LT = await TranslationBiz.GetSubsetStaticAsync(TranslationKeysToFetch, translationId);
ReturnList.Add(new NameIdItem() { Name = LT["ProductGroupNotSet"], Id = (long)ProductGroup.NotSet });
ReturnList.Add(new NameIdItem() { Name = LT["ProductGroupMisc"], Id = (long)ProductGroup.Misc });
ReturnList.Add(new NameIdItem() { Name = LT["ProductGroupAyaNova7"], Id = (long)ProductGroup.AyaNova7 });
ReturnList.Add(new NameIdItem() { Name = LT["ProductGroupRavenPerpetual"], Id = (long)ProductGroup.RavenPerpetual });

View File

@@ -0,0 +1,84 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Logging;
using Sockeye.Models;
using Sockeye.Api.ControllerHelpers;
using Newtonsoft.Json.Linq;
using System;
namespace Sockeye.Api.Controllers
{
[Produces("application/json")]
[Route("api/order")]
public class OrderController : ControllerBase
{
private readonly AyContext ct;
private readonly ILogger<OrderController> log;
private readonly ApiServerState serverState;
/// <summary>
/// ctor
/// </summary>
/// <param name="dbcontext"></param>
/// <param name="logger"></param>
/// <param name="apiServerState"></param>
public OrderController(AyContext dbcontext, ILogger<OrderController> logger, ApiServerState apiServerState)
{
ct = dbcontext;
log = logger;
serverState = apiServerState;
}
//Receive an order notification from ShareIt
//https://account.mycommerce.com/home/wiki/7479805
[HttpPost("shareit")]
public async Task<IActionResult> Post([FromHeader] string Authorization, [FromBody] JObject j)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
try
{
//do stuff with the notification
(string username, string password) = Sockeye.Util.AutoOrderProcessingUtil.GetUsernameAndPasswordFromAuthorizeHeader(Authorization);
// Now use username and password with whatever authentication process you want
if (username == "Y24PYYDQSA1L12905N5MKU" && password == "MA8GMQK2PC3FDNT1RTR68R")
{
//put the jobject notification into the db as json string freeform notification information
//to be processed by other code later. i.e. just capture it as is cleanly and don't bother trying to do anything fancy here this should be tight and focused and side effect free
TODO
//although...on second thought it could just make a purchase record with some sort of state of unprocessed so a job could swing by and process it or we could
//do that manually so then there would be no need for extra UI and stuff, and it wont' conflict with the need to process immediately and lightly here
//i.e. two stage: one is to make the record barebones for purchase then a job comes along and turns it into a real purchase
//also add error handling here iwth proper notification see trial request code so we get notified on error
//and don't return OK / 200 unless the order is stored successfully in db as shareit will retry until it's successful several times, see the link below for deets
//save it to the database
var VendorNotification = new VendorNotification();
VendorNotification.Vendor = "shareit";
VendorNotification.Data = j.ToString();
VendorNotification.Processed = false;
await ct.VendorNotification.AddAsync(VendorNotification);
await ct.SaveChangesAsync();
}
}
catch (Exception ex)
{
//todo Log this here
System.Diagnostics.Debug.WriteLine($"order/shareit - Exception processing request: {ex.Message}");
}
return Ok("ok");//shareit robot looks for an OK response to know if it should resend or not https://account.mycommerce.com/home/wiki/7479805
}
//------------
}//eoc
}//eons

View File

@@ -17,7 +17,7 @@ namespace Sockeye.Api.Controllers
{
private readonly AyContext ct;
private readonly ILogger<RvfController> log;
private readonly ILogger<RvrController> log;
private readonly ApiServerState serverState;
/// <summary>
@@ -26,7 +26,7 @@ namespace Sockeye.Api.Controllers
/// <param name="dbcontext"></param>
/// <param name="logger"></param>
/// <param name="apiServerState"></param>
public RvrController(AyContext dbcontext, ILogger<RvfController> logger, ApiServerState apiServerState)
public RvrController(AyContext dbcontext, ILogger<RvrController> logger, ApiServerState apiServerState)
{
ct = dbcontext;
log = logger;