Viincenttt / MollieApi

This project allows you to easily add the Mollie payment provider to your application.
MIT License
150 stars 85 forks source link

No status response #117

Closed gijsstrik closed 5 years ago

gijsstrik commented 5 years ago

I don't get a payment response if I use version 2.0.4. in an asp.net forms application. If I use the same code in a console application I do get a response (stucks after execution of last line). The same code in version 2.0.1.1. does give me a response. Of course I use a valid (test) key and a valid redirect url. c#, .net 4.6, visual studio community 2017. ???

        string apiKey = "test_xxxxxxx enz.";
        PaymentClient paymentClient = new PaymentClient(apiKey);
        var md = JsonConvert.SerializeObject(new { id = 11, reference = "Blabla" });
        PaymentRequest paymentRequest = new PaymentRequest()
        {
            Amount = new Mollie.Api.Models.Amount { Currency = "EUR", Value = "20.00" },
            Description = "Test payment of the an project",
            RedirectUrl = "http://99.99.99.99",
            Locale = "en_US",
            Metadata = md
        };

        PaymentResponse paymentResponse = paymentClient.CreatePaymentAsync(paymentRequest).Result;
lgoudriaan commented 5 years ago

Duplicate of #114.

Viincenttt commented 5 years ago

Hi @gijsstrik

You should use await when calling async methods. Take a look at the example project and the following link for more information: https://blog.stephencleary.com/2012/07/dont-block-on-async-code.html

Kind regards, Vincent

gijsstrik commented 5 years ago

Hi Vincent,

I created an empty web forms application (.net 4.6). Added masterpage with scriptmanager and pagemethods enabled.

Added default.aspx page linking to the masterpage. Added public static [webmethod] with async and await.

Call webmethod with pagemethods but cannot get past CreatePaymentAsync.

See attachement with master and default page. Api code and redirect url replaced with ‘xxx’.

Mvg Gijs

I now use a workaround by sending the data back to the page via a javascript generated form and using redirect.


Van: Vincent Kok notifications@github.com Verzonden: Tuesday, March 26, 2019 9:14:04 PM Aan: Viincenttt/MollieApi CC: gijsstrik; Mention Onderwerp: Re: [Viincenttt/MollieApi] No status response (#117)

Hi @gijsstrikhttps://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fgijsstrik&data=02%7C01%7C%7Cf9b6ea475c6f4054c7d408d6b2279862%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636892280455637813&sdata=3ULFLG3So%2B4C0yRR6x2c%2FBIYAb%2BiZ84zuHRFHmOQEjU%3D&reserved=0

You should use await when calling async methods. Take a look at the example project and the following link for more information: https://blog.stephencleary.com/2012/07/dont-block-on-async-code.htmlhttps://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fblog.stephencleary.com%2F2012%2F07%2Fdont-block-on-async-code.html&data=02%7C01%7C%7Cf9b6ea475c6f4054c7d408d6b2279862%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636892280455647824&sdata=ET45eNahVWlGNJUI9NqfhtbJGxEUaRTd1UgoNc9rRwU%3D&reserved=0

Kind regards, Vincent

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FViincenttt%2FMollieApi%2Fissues%2F117%23issuecomment-476829813&data=02%7C01%7C%7Cf9b6ea475c6f4054c7d408d6b2279862%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636892280455657841&sdata=R3549Did%2Be9%2F1sjXBh6sMQhWf7JePMkj0AOE7MVJXN4%3D&reserved=0, or mute the threadhttps://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAuqC3u67sVFfpVSl3D6j4vImBIRYZEx-ks5van-MgaJpZM4cHa4C&data=02%7C01%7C%7Cf9b6ea475c6f4054c7d408d6b2279862%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636892280455667840&sdata=rQksnBiN7VUFnuwcjmB1eRyf1FkHhrUVkBZNcLUymXE%3D&reserved=0.

Viincenttt commented 5 years ago

Hi @gijsstrik

I don't see any attachment. Can you try to add it again?

Kind regards, Vincent

gijsstrik commented 5 years ago

Hi Vincent,

I’ll paste the texts. Thanks!

Master (no code but for standard empty page load). <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="MollieTest.Site1" %>

<!DOCTYPE html>

Default.aspx; <%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MollieTest.Default" %>

Start Payment » Default.aspx.cs: using Mollie.Api.Client; using Mollie.Api.Models.Payment.Request; using Mollie.Api.Models.Payment.Response; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Web; using System.Web.Services; using System.Web.UI; using System.Web.UI.WebControls; namespace MollieTest { public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } [WebMethod] public static async Task Pay() { string apiKey = "xxx"; PaymentClient paymentClient = new PaymentClient(apiKey); var md = JsonConvert.SerializeObject(new { id = 11, reference = "Blabla" }); PaymentRequest paymentRequest = new PaymentRequest() { Amount = new Mollie.Api.Models.Amount { Currency = "EUR", Value = "20.00" }, Description = "Test payment of the an project", RedirectUrl = "xxx", Locale = "en_US", Metadata = md, }; PaymentResponse paymentResponse = await paymentClient.CreatePaymentAsync(paymentRequest); return paymentResponse.Links.Checkout.Href; } } } Mvg Gijs ________________________________ Van: Vincent Kok Verzonden: Friday, March 29, 2019 10:56:29 AM Aan: Viincenttt/MollieApi CC: gijsstrik; Mention Onderwerp: Re: [Viincenttt/MollieApi] No status response (#117) Hi @gijsstrik I don't see any attachment. Can you try to add it again? Kind regards, Vincent — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
Viincenttt commented 5 years ago

Thanks, I've managed to reproduce the issue. I suspect it has something to do with .asmx/WebMethods, since a simple await Task.Delay(2000) also never completes. I'll look into it.

gijsstrik commented 5 years ago

Thanks!

Mvg Gijs


Van: Vincent Kok notifications@github.com Verzonden: Saturday, March 30, 2019 11:00:16 AM Aan: Viincenttt/MollieApi CC: gijsstrik; Mention Onderwerp: Re: [Viincenttt/MollieApi] No status response (#117)

Thanks, I've managed to reproduce the issue. I suspect it has something to do with .asmx/WebMethods, since a simple await Task.Delay(2000) also never completes. I'll look into it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FViincenttt%2FMollieApi%2Fissues%2F117%23issuecomment-478229341&data=02%7C01%7C%7Cb5027c09bc014b37ba3708d6b4f6826f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636895368168334673&sdata=lz9vT9iaG25egyVSw7TD2aU3dY%2Bv%2FZxeWEOQsB0rLmY%3D&reserved=0, or mute the threadhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAuqC3iEubHhOa0ilgPq9GZs_dns5mDHKks5vbzWwgaJpZM4cHa4C&data=02%7C01%7C%7Cb5027c09bc014b37ba3708d6b4f6826f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636895368168344678&sdata=5SdbLMvGE5hqIrfohEluOUHXvPZpYGhvBUiFGoRZTvI%3D&reserved=0.

Viincenttt commented 5 years ago

Hi @gijsstrik

Unfortnatly it appears that async/await methods aren't supported in asmx/webmethods. Take a look at the following links for more information:

Apparently there are ways to get it working, but that is beyond the scope of support I am willing to provide for this library.

Kind regards, Vincent

lgoudriaan commented 5 years ago

Hi @gijsstrik,

This is the only way I got it working, but definitely recommended:

var response = Task.Run(async () => await new PaymentClient(accessToken).CreatePaymentAsync(paymentRequest)).GetAwaiter().GetResult();

Greetings

gijsstrik commented 5 years ago

Thanks a lot. I will certainly try it out.

Do you know why it worked in an older version e.g. 2.0.1.1?

Regards, Gijs

Verzonden vanuit Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 voor Windows 10


Van: lgoudriaan notifications@github.com Verzonden: Tuesday, April 16, 2019 10:37:23 AM Aan: Viincenttt/MollieApi CC: gijsstrik; Mention Onderwerp: Re: [Viincenttt/MollieApi] No status response (#117)

Hi @gijsstrikhttps://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fgijsstrik&data=02%7C01%7C%7C6f45e49f50e849d7c07908d6c246bfa8%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636910006443385675&sdata=wYczxWZew56aX02P7QY1c9sMgILs%2BoPBzbH0PdHOKQo%3D&reserved=0,

This is the only way I got it working, but definitely recommended:

var response = Task.Run(async () => await new PaymentClient(accessToken).CreatePaymentAsync(paymentRequest)).GetAwaiter().GetResult();

Greetings

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FViincenttt%2FMollieApi%2Fissues%2F117%23issuecomment-483566266&data=02%7C01%7C%7C6f45e49f50e849d7c07908d6c246bfa8%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636910006443395686&sdata=bOHBQAoUCCtC5sDpd5VEsZfCz9xZ4C3KeAkhhJxAWaA%3D&reserved=0, or mute the threadhttps://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAuqC3rjWPfiT09A1hm4HPamriIeSEfyxks5vhYvDgaJpZM4cHa4C&data=02%7C01%7C%7C6f45e49f50e849d7c07908d6c246bfa8%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636910006443405691&sdata=EPmRDgGNCdH%2FOSGzVSAPU74KWx1ipVoW%2F5UNA5VhBto%3D&reserved=0.