I am able to initiate a transaction fine by using the below code:
var invoiceNumber = Random.Shared.Next(1, 1001);
paynow.Instance.ResultUrl = $"http://domain.com/return?invoice={hashids.Encode(invoiceNumber)}";
var dict = new Dictionary<string,decimal>();
dict.Add("Bananas", 1);
dict.Add("Apples", 1);
var payment = paynow.Instance.CreatePayment($"Invoice-{hashids.Encode(invoiceNumber)}",
dict,"email@address.domain");
var response = await paynow.Instance.SendAsync(payment);
However, when I try to poll for the transaction I get an exception that says:
System.FormatException: The input string '2.00' was not in a correct format
I am polling for the transaction like this:
if (response.Success())
{
// Get the url to redirect the user to so they can make payment
var link = response.RedirectLink();
// Get the poll url of the transaction
var pollUrl = response.PollUrl();
var list = new List<string>();
list.Add(pollUrl);
list.Add(link);
try
{
var pollResponse = await paynow.Instance.PollTransactionAsync(pollUrl);
}
catch (Exception ex)
{
// ignored
}
return Results.Ok(list);
}
I have even setup a separate endpoint to poll the transaction and it gets the same error.
Am I using the wrong method to initiate the transaction?
Is this polling endpoint deprecated?
I took these snippets step by step following the integration documentation from the .Net SDK in the PayNow docs.
If anyone knows any work-arounds or a way to do this better please let me know.