コード例 #1
0
        /// <summary>
        /// Updates the Mollie payment in the database.
        /// </summary>
        public void Update()
        {
            var key = WebConfigurationManager.AppSettings["MollieLiveKey"];

            var client = new MollieClient {
                ApiKey = key
            };
            var updatedPayment = client.GetStatus(MollieId);

            var oldStatus = Status;

            Status            = updatedPayment.Status;
            AmountRefunded    = updatedPayment.AmountRefunded;
            AmountRemaining   = updatedPayment.AmountRemaining;
            CancelledDateTime = updatedPayment.CancelledDateTime;
            CreatedDateTime   = updatedPayment.CreatedDateTime;
            Details           = updatedPayment.Details;
            PaidDateTime      = updatedPayment.PaidDateTime;
            ExpiredDateTime   = updatedPayment.ExpiredDateTime;
            Locale            = updatedPayment.Locale;

            Mongo.Payments.Save(this);

            var team = Mongo.Teams.FindOne(Query <Team> .Where(x => x.Id == TeamId));

            // If payment status did not change, return
            if (oldStatus == Status)
            {
                return;
            }

            // Cancel team in database
            if (Status == PaymentStatus.Cancelled || Status == PaymentStatus.Expired)
            {
                team.Cancelled = true;

                Mongo.Teams.Save(team);

                // Send email
                var captain = team.Participants.Single(x => x.IsCaptain);
                EmailHelper.SendPaymentFailure(captain.Email, captain.FullName, Status);
            }
            else if (Status == PaymentStatus.Refunded)
            {
                // Send email
                var captain = team.Participants.Single(x => x.IsCaptain);
                EmailHelper.SendPaymentPartialRefund(captain.Email, captain.FullName);

                Mongo.Teams.Save(team);
            }
            else if (Status == PaymentStatus.Paid)
            {
                // Send email
                var captain = team.Participants.Single(x => x.IsCaptain);
                EmailHelper.SendPaymentSuccess(captain.Email, captain.FullName);

                // Force summoner scrape
                try
                {
                    new RiotApiScrapeJob().ScrapeSummoners(null);
                }
                catch (Exception)
                {
                }
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            MollieClient mollieClient = new MollieClient();

            mollieClient.setApiKey(ConfigurationManager.AppSettings["mollie_api_key"]);

            Console.WriteLine("Loading iDeal issuers ...");
            Issuers issuers = mollieClient.GetIssuers();

            foreach (Issuer issuer in issuers.data)
            {
                Console.WriteLine(issuer.name);
            }

            Console.WriteLine("Starting payment without method ...");

            Payment payment = new Payment
            {
                amount      = 99.99M,
                description = "Test payment",
                redirectUrl = "http://www.foxip.net/completed/?orderId=1245",
            };

            PaymentStatus status = mollieClient.StartPayment(payment);

            Console.WriteLine("The status is: " + status.status);
            Console.WriteLine("Please follow this link to start the payment:");
            Console.WriteLine(status.links.paymentUrl);

            Console.WriteLine("Press [enter] to continue ...");
            Console.ReadLine();

            Console.WriteLine("Getting status ...");
            status = mollieClient.GetStatus(status.id);
            Console.WriteLine("The status is now: " + status.status);

            //Refunds only for iDEAL, Bancontact/Mister Cash, SOFORT Banking, creditcard and banktransfer
            Console.WriteLine("Refunding ...");
            try
            {
                RefundStatus refundStatus = mollieClient.Refund(status.id);
                Console.WriteLine("The status is now: " + refundStatus.payment.status);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: " + ex.Message);
            }

            Console.WriteLine("Starting payment with a specific method ...");
            status = mollieClient.StartPayment(new Payment
            {
                amount      = 1.99M,
                method      = Method.mistercash,
                description = "Test payment",
                redirectUrl = "http://www.foxip.net/completed/?orderId=12345"
            });
            Console.WriteLine("The status is: " + status.status);
            Console.WriteLine("Please follow this link to start the payment:");
            Console.WriteLine(status.links.paymentUrl);
            Console.WriteLine("Press [enter] to continue ...");
            Console.ReadLine();
        }
コード例 #3
0
        /// <summary>
        /// This function needs to process and returned message from the bank.
        /// Thsi processing may vary widely between banks.
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            var modCtrl = new NBrightBuyController();
            var info    = ProviderUtils.GetProviderSettings("DnnCMolliepayment");

            try
            {
                var debugMode = info.GetXmlPropertyBool("genxml/checkbox/debugmode");

                var debugMsg = "START CALL" + DateTime.Now.ToString("s") + " </br>";
                debugMsg += "returnmessage: " + context.Request.Form.Get("returnmessage") + "</br>";
                if (debugMode)
                {
                    info.SetXmlProperty("genxml/debugmsg", debugMsg);
                    modCtrl.Update(info);
                }

                debugMsg = "DnnCMollie DEBUG: " + DateTime.Now.ToString("s") + " </br>";


                var rtnMsg = "version=2" + Environment.NewLine + "cdr=1";

                // ------------------------------------------------------------------------
                // In this case the payment provider passes back data via form POST.
                // Get the data we need.
                //string returnmessage = "";
                //int DnnCMollieStoreOrderID = 0;
                //string DnnCMollieCartID = "";
                //string DnnCMollieClientLang = "";



                var testMode   = info.GetXmlPropertyBool("genxml/checkbox/testmode");
                var testApiKey = info.GetXmlProperty("genxml/textbox/testapikey");
                var liveApiKey = info.GetXmlProperty("genxml/textbox/liveapikey");

                var nbi           = new NBrightInfo();
                var paymentMethod = nbi.GetXmlProperty("genxml/textbox/paymentmethod");
                var paymentBank   = nbi.GetXmlProperty("genxml/textbox/paymentbank");
                var apiKey        = testApiKey;

                if (!testMode)
                {
                    apiKey = liveApiKey;
                }

                string molliePaymentId = context.Request.Form["id"];
                int    oId             = -1;

                int.TryParse(context.Request.Form["orderid"], out oId);
                if (oId <= 0)
                {
                    int.TryParse(context.Request.Form["ordid"], out oId);
                }

                MollieClient mollieClient = new MollieClient();
                mollieClient.setApiKey(apiKey);
                PaymentStatus paymentStatus = mollieClient.GetStatus(molliePaymentId);

                var orderid = paymentStatus.metadata;
                var nbInfo  = modCtrl.Get(Convert.ToInt32(orderid), "ORDER");
                if (nbi != null)
                {
                    var orderData = new OrderData(nbInfo.ItemID);

                    switch (paymentStatus.status.Value)
                    {
                    case Status.paid:
                        orderData.PaymentOk();
                        break;

                    case Status.cancelled:
                        //set order status to Cancelled
                        orderData.PaymentOk("030");
                        break;

                    case Status.failed:
                        //set order status to payment failed
                        orderData.PaymentFail();
                        break;

                    case Status.open:
                        //set order status to Waiting for payment
                        orderData.PaymentOk("060");
                        break;

                    case Status.pending:
                        //set order status to Waiting for payment
                        orderData.PaymentOk("060");
                        break;

                    case Status.expired:
                        //set order status to Incomplete
                        orderData.PaymentOk("010");
                        break;
                    }

                    var rtnStr = paymentStatus.status.Value + "<br/> id = " + molliePaymentId;
                    rtnStr += "<br/> orderId = " + orderid;
                    rtnStr += "<br/> status = " + orderData.OrderStatus;

                    File.WriteAllText(PortalSettings.Current.HomeDirectoryMapPath + "\\debug_DnnC_IPN_return.html", rtnStr.ToString());
                }
            }
            catch { }
        } //end