Coding Cluster

In this post we will learn how to get response from
Authorize.Net credit card payment using ASP.NET MVC4

One of my client projects I need to implement Authorize.net
payment gateway. So just implemented using SIM (Server Integration Method). But
my client wants, if the payment getting success then shown a custom receipt
page and save the transaction details in to our own database. In other case if the
payment getting fail then provides repayment option.

In SIM method this is not possible (or not advisable) because
we using “x_relay_response” to get response from Authorize.net. Note,this is just relay the url, not redirect to the result page. And URL always points to
the https://test.authorize.net/gateway/transact.dll.
And the response time also only 10 seconds. If your server not responds within
10 seconds then you get time out error like

“An error occurred while trying to report this transaction
to the merchant. An email has been sent to the merchant informing them of the
error. The following is a result of the attempt to charge your credit card.”

This error indicates that Authorize.Net is unable to connect
to the page that you have specified as your relay response URL. To avoid this
kind of errors you need to go with Authorize.net’s another one integration
method AIM (Advanced Integration Method)

Error:
"Error during serialization or deserialization using the json javascriptserializer. the length of the string exceeds kendoui" I faced this error in Kendo-Grid.Reason:
This exception is raised when the length of the data serialized as JSON exceeds the default MaxJsonLength. It means The JavaScript Serialization settings allow maximum 2097152 character by default. But getMethod return string larger then this then it throw above error.

Solutions:
According from the documents There are few possible solutions available to fix this issue

Setting the MaxJsonLength property of a JavascriptSerializer object to perform your serialization.

Enable paging by calling the Pageable method

Use a View Model to serialize only the required properties of your model

Solution 1: Setting the MaxJsonLength property default value within your web.config
The MaxJsonLength property which can be set within the web.config of your application controls the maximum size of the JSON strings that are accepted by the JsonSerializer class. The default value is 2097152 characterswhich is equivalent to 4 MB of Unicode string data.

This will only apply to web-services that handle JSON.

You can just copy and paste the following code to your web.config file to increase the size of this value

Solution 3: Setting the MaxJsonLength property of a JavascriptSerializer object

Using an instance of a JavascriptSerializer will not actually inherit the previously defined within the web.config (as the web.config only applies to Web Services that handle the JSON) so you can easily just create an instance of the serializer and set the property accordingly :

.bind():
The .bind() method registers the type of event and an event handler directly to the DOM element in question. This method has been around the longest and in its day it was a nice abstraction around the various cross-browser issues that existed. This method is still very handy when wiring-up event handlers, but there are various performance concerns as are listed below.

The .bind() method will attach the event handler to all of the anchors that are matched! That is not good. Not only is that expensive to implicitly iterate over all of those items to attach an event handler, but it is also wasteful since it is the same event handler over and over again.

Pros
This methods works across various browser implementations.
It is pretty easy and quick to wire-up event handlers. The shorthand methods (.click(), .hover(), etc...) make it even easier to wire-up event handlers. For a simple ID selector, using .bind() not only wires-up quickly, but also when the event fires the event handler is invoked almost immediately.

Cons
The method attaches the same event handler to every matched element in the selection.
It doesn't work for elements added dynamically that matches the same selector.
There are performance concerns when dealing with a large selection.
The attachment is done upfront which can have performance issues on page load.

.live():
The .live method attaches the event handler to the root level document along with the associated selector and event information. By registering this information on the document it allows one event handler to be used for all events that have bubbled (a.k.a. delegated, propagated) up to it. Once an event has bubbled up to the document jQuery looks at the selector/event metadata to determine which handler it should invoke, if any. This extra work has some impact on performance at the point of user interaction, but the initial register process is fairly speedy.

The good thing about this code as compared to the .bind() example above is that it is only attaching the event handler once to the document instead of multiple times. This not only is faster, but less wasteful,

Pros
There is only one event handler registered instead of the numerous event handlers that could have been registered with the .bind() method.The upgrade path from .bind() to .live() is very small. All you have to do is replace "bind" to "live". Elements dynamically added to the DOM that match the selector magically work because the real information was registered on the document. You can wire-up event handlers before the document ready event helping you utilize possibly unused time.

Cons
This method is deprecated as of jQuery 1.7 and you should start phasing out its use in your code.
Chaining is not properly supported using this method.
The selection that is made is basically thrown away since it is only used to register the event handler on the document.

Using event.stopPropagation() is no longer helpful because the event has already delegated all the way up to the document.Since all selector/event information is attached to the document once an event does occur jQuery has match through its large metadata store using the matchesSelector method to determine which event handler to invoke, if any.
Your events always delegate all the way up to the document. This can affect performance if your DOM is deep.