Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong type for field 'callback_duration' in class 'Operation' #22

Open
immeo-rru opened this issue Sep 6, 2023 · 1 comment
Open

Wrong type for field 'callback_duration' in class 'Operation' #22

immeo-rru opened this issue Sep 6, 2023 · 1 comment

Comments

@immeo-rru
Copy link

immeo-rru commented Sep 6, 2023

Problem: the data returned from Quickpay containing data from aquirer cannot always be serialized. This results in an error that cannot be handled in my own code.

Solution: change type for field callback_duration from "string" to "int?".

Details:
Looking at the part of the JSON returned for an operaion looks like this:

{
            "id": 2,
            "type": "authorize",
            "amount": 148,
            "pending": false,
            "qp_status_code": "20000",
            "qp_status_msg": "Approved",
            "aq_status_code": "0",
            "aq_status_msg": "Accepted, The agreement has been accepted.",
            "data": {},
            "callback_url": "https://13f5-147-78-28-145.ngrok-free.app/subscriptions/callback",
            "callback_success": false,
            "callback_response_code": null,
            "callback_duration": 30002,
            "acquirer": "mobilepaysubscriptions",
            "3d_secure_status": null,
            "callback_at": "2023-09-06T11:54:00Z",
            "created_at": "2023-09-06T11:50:58Z"
 }

Test:

private string JsonOperation = @"{
		""id"": 2,
		""type"": ""authorize"",
		""amount"": 148,
		""pending"": false,
		""qp_status_code"": ""20000"",
		""qp_status_msg"": ""Approved"",
		""aq_status_code"": ""0"",
		""aq_status_msg"": ""Accepted, The agreement has been accepted."",
		""data"": { },
		""callback_url"": ""https://13f5-147-78-28-145.ngrok-free.app/subscriptions/callback"",
		""callback_success"": false,
		""callback_response_code"": null,
		""callback_duration"": 30002,
		""acquirer"": ""mobilepaysubscriptions"",
		""3d_secure_status"": null,
		""callback_at"": ""2023-09-06T11:54:00Z"",
		""created_at"": ""2023-09-06T11:50:58Z""
	}";

[TestMethod]
public void ParseOperation_OneOperation_Fail()
{
	try
	{
		var operation = System.Text.Json.JsonSerializer.Deserialize<Quickpay.Models.Payments.Operation>(JsonOperation);
	}
	catch (Exception e)
	{
		Assert.Fail(e.Message);
	}
}

public class OperationFixed : Quickpay.Models.Payments.Operation
{
	public new int? callback_duration { get; set; }
}

[TestMethod]
public void ParseOperation_OneOperation_Success()
{
	try
	{
		var operation = System.Text.Json.JsonSerializer.Deserialize<OperationFixed>(JsonOperation);
	}
	catch (Exception e)
	{
		Assert.Fail(e.Message);
	}
	Assert.IsTrue(true);
}
@immeo-rru immeo-rru changed the title Wong fieldtype for callback_duration in class "Operation" Wong type for field 'callback_duration' in class 'Operation' Sep 6, 2023
@immeo-rru immeo-rru changed the title Wong type for field 'callback_duration' in class 'Operation' Wrong type for field 'callback_duration' in class 'Operation' Sep 6, 2023
@tuk1976
Copy link

tuk1976 commented Sep 18, 2023

We are having the same issue. When retrieving data using GetAllPayments, most of the records cannot be retrieved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants