sdk-dotnet icon indicating copy to clipboard operation
sdk-dotnet copied to clipboard

Sandbox Accept Hosted Payment Fails

Open grantgoodart opened this issue 6 years ago • 15 comments

Including the order property on the transactionRequestType causes payments to fail using the Accept Hosted Sandbox form. I created a new MVC Application in Visual Studio using .NET Framework 4.5.2. The code below works if I use nuget package version 1.9.6, but if I use 1.9.7 this same payment will fail until I remove the transactionRequestType order property.

Global.asax.cs

public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
    }

HomeController.cs

public class HomeController : Controller
    {
        public ActionResult Index()
        {
            var invoiceId = "18448294934052571560";
            var custacct = "000000000010";
            var custom_data = string.Format("{0}-{1}", invoiceId, custacct);

            ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
            ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType
            {
                name = "<LoginID>>",
                Item = "<TransactionKey>",
                ItemElementName = ItemChoiceType.transactionKey
            };

            var controller = new getHostedPaymentPageController(new getHostedPaymentPageRequest
            {
                hostedPaymentSettings = new settingType[]
                {
                    new settingType
                    {
                       settingName = "hostedPaymentReturnOptions",
                       settingValue =  string.Format(@"{{""showReceipt"":false,""url"":""{0}""}}",
                       "<Ngrok Address for me>/AuthNetTest/Home/Receipt")
                    },
                    new settingType
                    {
                        settingName = "hostedPaymentButtonOptions",
                        settingValue = "{\"text\":\"Pay\"}"
                    },
                    new settingType
                    {
                        settingName = "hostedPaymentPaymentOptions",
                        settingValue = string.Format(@"{{""cardCodeRequired"": false, ""showCreditCard"": {0}, ""showBankAccount"": {1}}}",
                            "true",
                            "false")
                    },
                    new settingType
                    {
                        settingName = "hostedPaymentSecurityOptions",
                        settingValue = "{\"captcha\": false}"
                    },
                    new settingType
                    {
                        settingName = "hostedPaymentShippingAddressOptions",
                        settingValue = "{\"show\": false, \"required\": false}"
                    },
                    new settingType
                    {
                        settingName = "hostedPaymentBillingAddressOptions",
                        settingValue = "{\"show\": true, \"required\": false}"
                    },
                    new settingType
                    {
                        settingName = "hostedPaymentCustomerOptions",
                        settingValue = "{\"showEmail\": true, \"requiredEmail\": false, \"addPaymentProfile\": false}"
                    }
                },
                transactionRequest = new transactionRequestType
                {
                    amount = 10.00M,
                    transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),
                    order = new orderType
                    {
                        invoiceNumber = invoiceId,
                        description = invoiceId,

                    },
                    userFields = new userField[]
                    {
                        new userField
                        {
                            name = nameof(custom_data),
                            value = custom_data
                        }
                    }

                },

            });

            var hostedPaymentResult =  controller.ExecuteWithApiResponse();
            ViewBag.Token = hostedPaymentResult.token;
            return View();
        }

        public ActionResult Receipt()
        {
            ViewBag.Message = "Payment Finished";

            return View();
        }

Index.cshtml

@{
    ViewBag.Title = "Home Page";
}

<form method="post" action="https://test.authorize.net/payment/payment" id="formAuthorizeNetTestPage" name="formAuthorizeNetTestPage">
    <input type="hidden" name="token" value="@(ViewBag.Token)" />
    Continue to Authorize.Net to Payment Page
    <button id="btnContinue">Continue to next page</button>
</form>

grantgoodart avatar Feb 27 '19 16:02 grantgoodart

Just wanted to say I also posted this issue on the samples repository - https://github.com/AuthorizeNet/sample-code-csharp/issues/99

sstalder avatar Mar 05 '19 20:03 sstalder

Running into the same issue with the 2.0.0 release.

I attempted to run the sandbox with the 1.9.7 SDK version. It through the same ambiguous error as described above.

When I backed it down to 1.9.6, it works again. So there is something blowing up in the purchase process for the hosted payment page and whatever that error might be is not being rendered.

Hi, Apologies for the inconvenience caused. There seems to be a bug in the way that DateTime values are handled in the C# SDK.

A fix has been sent and is pending release ( #257 ). A temporary workaround for this is to include a valid date for order.purchaseOrderDateUTC in the format "YYYY-mm-dd".

transactionRequest = new transactionRequestType {
        amount = "100.00",
        transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),
        order = new orderType {
            invoiceNumber = invoiceId,
            description = invoiceId,
            purchaseOrderDateUTC = new DateTime(2018, 03, 23, 11, 00, 00, DateTimeKind.Utc)
        }
}

gnongsie avatar Mar 06 '19 09:03 gnongsie

Sadly, the above workaround does not solve my problem. I am attempting to use the 2.0.0 SDK and it still throws the generic error. Is there any way to find out what the error is that is being thrown?

I have tried the above work around, and it has not fixed the issue for me either....

Kishkumen32 avatar Mar 07 '19 14:03 Kishkumen32

Hi, Apologies for the inconvenience. I initially thought that this would fix it.

In any case, I've escalated this to the relevant team and I will keep this thread updated with the progress.

gnongsie avatar Mar 13 '19 05:03 gnongsie

So sad. After three months, there are no fixes. We are not expecting this from Authorize.net. Only the 1.9.6 version is working fine.

NST77 avatar May 13 '19 10:05 NST77

Still no fix? happens to me in Italy ( but not with my colleague in USA )

DavideMeneghello avatar Nov 19 '19 14:11 DavideMeneghello

Still no fix for this. Confirmed that rolling back to the 1.9.6 version works correctly. Honestly surprised that the pr (1 line change!) hasn't been merged yet?

Daxton47 avatar Nov 20 '19 19:11 Daxton47

Any update on what the issue is and when it will get fixed. Can't test a new integration for a client.

ahawes-clarity avatar Apr 15 '20 09:04 ahawes-clarity

The only way I got around this for now is to exclude the "order" in transactionRequest.

sstalder avatar Apr 15 '20 13:04 sstalder

The only way I got around this for now is to exclude the "order" in transactionRequest.

Yes, that would work, except I actually need to send order information. I reverted back to 1.9.6 and things seem to be working. I tried 1.9.7 but it didn't work either.

ahawes-clarity avatar Apr 16 '20 05:04 ahawes-clarity

@gnongsie, is there any update on this? It seems there are many developers hoping for a solution.

kwhite5 avatar Sep 09 '20 10:09 kwhite5

@gnongsie, is there any update on this? It seems there are many developers hoping for a solution.

No update... Waiting till May 13th, 2019

NST77 avatar Sep 09 '20 11:09 NST77

It seems that the issue is still not fixed even in version 2.0.1. The only latest working version is 1.9.6

m-imran38 avatar Jan 12 '21 08:01 m-imran38