Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string jsonData = new StreamReader(Request.InputStream).ReadToEnd();

        if (string.IsNullOrWhiteSpace(jsonData))
        {
            throw new Exception("Invalid notification call.");
        }

        var refreshToken = WebConfigurationManager.AppSettings["RefreshToken"];
        var signingKey   = WebConfigurationManager.AppSettings["SigningKey"];
        var testMode     = bool.Parse(WebConfigurationManager.AppSettings["TestMode"]);
        var client       = new OmniKassaApiClient(refreshToken, signingKey, testMode);

        var announcementResponse = RaboOmniKassaApi.Net.Models.Response.Response.CreateInstance <AnnouncementResponse>(jsonData, new SigningKey(Convert.FromBase64String(signingKey)));

        bool moreResultsAvailable;

        do
        {
            var response = client.RetrieveAnnouncement(announcementResponse);

            //... Update the order statuses

            moreResultsAvailable = response.MoreOrderResultsAvailable;
        } while (moreResultsAvailable);
    }
        public void TestRetrieveAnnouncement()
        {
            var announcementResponse              = AnnouncementResponseBuilder.NewInstance();
            var merchantOrderStatusResponse       = MerchantOrderStatusResponseBuilder.NewInstance();
            var merchantOrderStatusResponseAsJson = MerchantOrderStatusResponseBuilder.NewInstanceAsJson();

            _connector.Setup(s => s.GetAnnouncementData(announcementResponse)).Returns(merchantOrderStatusResponseAsJson);

            var result = _client.RetrieveAnnouncement(announcementResponse);

            Assert.AreEqual(merchantOrderStatusResponse, result);
        }