public IActionResult ReturnUrlEventHandler()
        {
            try
            {
                Dictionary <String, StringValues> query      = QueryHelpers.ParseQuery(Request.QueryString.Value);
                Dictionary <String, String>       dictionary = GetDictionary(query);

                // Parse the response and check if the signature is valid (an exception will be thrown if this is not the case).
                var response = PaymentCompletedResponse.Create(dictionary, _raboOmniKassaPaymentSettings.SigningKey);

                var  order   = _orderService.GetOrderById(Convert.ToInt32(response.OrderId));
                bool success = HandleOrderStatus(order, response.Status);
                if (success)
                {
                    return(RedirectToRoute("CheckoutCompleted", new { orderId = order.Id }));
                }
                else
                {
                    _logger.Error($"OmniKassa error: Order with id {response.OrderId} was not found");
                }
            }

            catch (RabobankSdkException ex)
            {
                _logger.Error(ex.InnerException != null ? ex.InnerException.Message : ex.Message);
            }

            return(RedirectToAction("Index", "Home", new { area = "" }));
        }
Esempio n. 2
0
        public void TestThatIsValidReturnsFalseForInvalidSignatures()
        {
            var signingKey = new SigningKey("secret");
            var paymentCompletedResponse = PaymentCompletedResponse.CreateInstance("1", "CANCELLED", "ffb94fef027526bab3f98eaa432974daea4e743f09de86ab732208497805bb12", signingKey);

            Assert.IsNull(paymentCompletedResponse, "The given payment complete response was valid, but should be invalid");
        }
Esempio n. 3
0
        public void TestThatLettersinOrderIdIsValid()
        {
            var signingKey = new SigningKey("secret");
            var paymentCompletedResponse = PaymentCompletedResponse.CreateInstance("Test1234", "COMPLETED", "bf4f5b787d954296b9c2e15028c2311df5e31a3d94c540e361faf1d0951b7858041089d430e17730f1efd3a308881c094355f55e09b993ca53f2063859d1eb4b", signingKey);

            Assert.IsNotNull(paymentCompletedResponse);
            Assert.AreEqual("Test1234", paymentCompletedResponse.OrderId);
            Assert.AreEqual("COMPLETED", paymentCompletedResponse.Status);
        }
Esempio n. 4
0
        public void TestThatIsValidReturnsTrueForUnderscoreInStatus()
        {
            var signingKey = new SigningKey("secret");
            var paymentCompletedResponse = PaymentCompletedResponse.CreateInstance("1", "IN_PROGRESS", "1a551027bc3cc041a56b9efa252640c76b2e5815f816dd123fa1b32b4683729e904b5fa711870b956f1d9b16c714168d129068a48f875c2f91185d6c18eccf61", signingKey);

            Assert.IsNotNull(paymentCompletedResponse);
            Assert.AreEqual("1", paymentCompletedResponse.OrderId);
            Assert.AreEqual("IN_PROGRESS", paymentCompletedResponse.Status);
        }
Esempio n. 5
0
        public void TestThatIsValidReturnsTrueForAValidSignature()
        {
            var signingKey = new SigningKey("secret");
            var paymentCompletedResponse = PaymentCompletedResponse.CreateInstance("1", "COMPLETED", "b890b2f3c6f102bb853ed448dd58d2c13cc695541f5eecca713470e68ced6f2c1a5f5ddd529a732ff51a019126ffefa8bd1d0193b596b393339ffcbf6f335241", signingKey);

            Assert.IsNotNull(paymentCompletedResponse);
            Assert.AreEqual("1", paymentCompletedResponse.OrderId);
            Assert.AreEqual("COMPLETED", paymentCompletedResponse.Status);
        }
        public ActionResult Callback()
        {
            SetVersionViewData();
            CreateOrderIfRequired();

            try
            {
                webShopModel.PaymentCompleted = PaymentCompletedResponse.Create(Request.QueryString, SIGNING_KEY);
            }
            catch (RabobankSdkException ex)
            {
                webShopModel.Error = ex.Message;
            }

            return(View("Index", webShopModel));
        }
Esempio n. 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var orderId    = Request.QueryString["order_id"];
        var status     = Request.QueryString["status"];
        var signature  = Request.QueryString["signature"];
        var signingKey = new SigningKey(Convert.FromBase64String(WebConfigurationManager.AppSettings["SigningKey"]));
        var paymentCompletedResponse = PaymentCompletedResponse.CreateInstance(orderId, status, signature, signingKey);

        if (paymentCompletedResponse == null)
        {
            throw new Exception("The payment completed response was invalid.");
        }

        // Use these variables instead of using the URL parameters ($orderId and $status). Input validation has been performed on these values.
        var validatedMerchantOrderId = paymentCompletedResponse.OrderId;
        var validatedStatus          = paymentCompletedResponse.Status;
        // ... complete payment
    }
        public ActionResult Callback()
        {
            try
            {
                Dictionary <String, StringValues> query      = QueryHelpers.ParseQuery(Request.QueryString.Value);
                Dictionary <String, String>       dictionary = GetDictionary(query);

                PaymentCompletedResponse response = PaymentCompletedResponse.Create(dictionary, SIGNING_KEY);
                String        validatedOrderId    = response.OrderId;
                PaymentStatus?validatedStatus     = response.Status;

                ViewData["OrderId"] = response.OrderId;
                ViewData["Status"]  = response.Status;
            }
            catch (IllegalSignatureException)
            {
            }
            catch (RabobankSdkException)
            {
            }

            return(View());
        }