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

Sandbox Accept Hosted Payment Fails #253

Open
grantgoodart opened this Issue Feb 27, 2019 · 6 comments

Comments

Projects
None yet
5 participants
@grantgoodart
Copy link

grantgoodart commented Feb 27, 2019

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>
@sstalder

This comment has been minimized.

Copy link

sstalder commented Mar 5, 2019

Just wanted to say I also posted this issue on the samples repository - AuthorizeNet/sample-code-csharp#99

@nthomson-choicescreening

This comment has been minimized.

Copy link

nthomson-choicescreening commented Mar 5, 2019

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.

@gnongsie

This comment has been minimized.

Copy link
Contributor

gnongsie commented Mar 6, 2019

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 gnongsie added the has-pr label Mar 6, 2019

@nthomson-choicescreening

This comment has been minimized.

Copy link

nthomson-choicescreening commented Mar 7, 2019

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?

@Kishkumen32

This comment has been minimized.

Copy link

Kishkumen32 commented Mar 7, 2019

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

@gnongsie

This comment has been minimized.

Copy link
Contributor

gnongsie commented Mar 13, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.