HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/LHouwen1/embeddedplaza.com/CMS/MolliePaymentUpdate.ashx
<%@ WebHandler Language = "C#" Class="MolliePaymentUpdate" %>

using System;
using System.Web;
using CMS.DataEngine;
using CMS.Ecommerce;
using CMS.EcommerceProvider;
using CMS.EventLog;
using CMS.Helpers;
using CMS.Localization;
using CMS.SiteProvider;
using Mollie.Api.Client;
using Mollie.Api.Models.Payment;
using Mollie.Api.Models.Payment.Response;

public class MolliePaymentUpdate : IHttpHandler
{

    private string mOrderId;

    public void ProcessRequest(HttpContext context)
    {
        var request = context.Request;

        // Get order id
        mOrderId = ValidationHelper.GetString(request["id"], "");

        if (!string.IsNullOrEmpty(mOrderId))
        {
            string api_key =
                Convert.ToBoolean(SettingsKeyInfoProvider.GetValue(SiteContext.CurrentSiteName + ".testmode"))
                    ? SettingsKeyInfoProvider.GetValue(SiteContext.CurrentSiteName + ".testapikey")
                    : SettingsKeyInfoProvider.GetValue(SiteContext.CurrentSiteName + ".prodapikey");
            MollieClient mollieClient = new MollieClient(api_key);
            PaymentResponse mResponse = mollieClient.GetPaymentAsync(mOrderId).Result;
            if (mResponse != null)
            {
                try
                {
                    string order = mResponse.Metadata.Split(':')
                        .GetValue(1)
                        .ToString()
                        .Replace("\"", "")
                        .Replace("}", "");
                    if (!string.IsNullOrEmpty(order))
                    {
                        OrderInfo orderInfo = OrderInfoProvider.GetOrderInfo(Int32.Parse(order));
                        orderInfo.OrderCustomData["PaymentMethod"] = mResponse.Method.Value.ToString();
                        switch (mResponse.Status)
                        {
                            case PaymentStatus.Cancelled:
                            case PaymentStatus.Expired:
                            case PaymentStatus.Failed:
                                orderInfo.OrderStatusID = 6;
                                orderInfo.OrderIsPaid = false;
                                break;
                            case PaymentStatus.Paid:
                                orderInfo.OrderStatusID = 7;
                                orderInfo.OrderIsPaid = true;
                                break;
                            default:
                                break;
                        }
                        OrderInfoProvider.SetOrderInfo(orderInfo);
                    }
                }
                catch (Exception ex)
                {
                    EventLogProvider.LogEvent(EventType.ERROR, "Mollie Error", "MOLLIE",
                        eventDescription: ex.ToString());
                }
            }
        }
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}