Geeks With Blogs
Dan Bedassa
As an example of how to create a provider for dashCommerce, I have implemented an Authorize.NET Payment Provider for dashCommerce based on Advanced Integration Method guidelines from Authorize.NET and following the structure of the existing providers in dashCommerce.
Below is the general outline of the implementation:
1. Implement the Store.Services.PaymentService.IPaymentProvider interface.

  • The provider must implement this interface, specifically the Authorize, Charge and Refund methods. You can see the code at Store.Services\PaymentService\AuthorizeNetPaymentProvider.cs
  • The actual implementation of the above methods is in Store\Services\PaymentService\AuthorizeNET\AuthorizeNetService.cs and the provider has a reference to this class.
  • The class instance has a constructor with parameters matching the configuration properties stored (for Authorize.NET, we need to store atleast API Version, API LoginID, TransactionKey and IsTestMode).
  • The implementation for Authorize, Charge and Refund methods are almost the same except on some parameters to Authorize.NET services like transaction type "x_type" ("AUTH_ONLY" = Authorize, "AUTH_CAPTURE" = Charge, "CREDIT" = Refund). For a complete implementation, please see the code. Below is a rough implementation guideline:

i. use a NameValueCollection and build up the arguments like so NameValueCollection objInf = new NameValueCollection(30);
objInf.Add("x_version", account.AuthNetVersion);
objInf.Add("x_login", account.AuthNetLoginID);
objInf.Add("x_card_num", order.CreditCardNumber);
objInf.Add("x_amount", order.Total.ToString());

ii. Pass them to the UploadValues method of the WebClient class, which returns a byte[] response
WebClient objRequest = new WebClient();
objRetBytes = objRequest.UploadValues(objRequest.BaseAddress, "POST", objInf);
iii. Parse that using the Encoding.Ascii.GetString. Split the string by "," and eliminate the field delimiters "".
objRetVals = System.Text.Encoding.ASCII.GetString(objRetBytes).Split(",".ToCharArray());

iv. Process the return values and handle accordingly
// Process Return Values
response.ReturnCode = objRetVals[0].Trim(char.Parse(""));

if (objRetVals[0].Trim(char.Parse("")) == "1")
// Returned Authorisation Code
response.AuthorizationCode = objRetVals[4].Trim(char.Parse(""));
// Returned Transaction ID
response.TransactionID = objRetVals[6].Trim(char.Parse(""));
strMessage = "Transaction completed successfully.";

{//look into the code. There are hundreds of possible errors … can’t put them here …

2. Add a control that creates and saves the configuration settings for the provider in the same order they are used in the class instance above.

  • You can see the code at Web\admin\controls\configuration\paymentproviders\authorizenetconfiguration.ascx.cs
  • When we save/configure the providers, the properties need to be added to the AuthorizeNetPaymentProvider’s ProviderSettings in the order they are expected by the constructor of the payment service above.
3. Configuring the Authorize.NET Payment Provider in Your dashCommerce site:

After this just go ahead and configure the new payment provider as you would with any additional provider.
1. Log In to your dashCommerce web site using your administrator account. Proceed to Payment Configuration -> Configure Payment Providers. Select the AuthorizeNetPaymentProvider from the dropdown list in the PaymentProvider Configuration section and click “Configure Provider”. This will then display the AuthorizeNet Payment Provider Configuration panel, as seen below:

2. Put in the values from your Authorize.NET account in the appropriate boxes.
3. If you are ready to go live with your site, then ensure you check “Is Live”.

4. Press Save when done.
Posted on Friday, January 16, 2009 1:01 PM | Back to top

Comments on this post: Implementing Authorize.NET Payment Provider for DashCommerce

# re: Implementing Authorize.NET Payment Provider for DashCommerce
Requesting Gravatar...
Do you have this code available for download or purchase?
Left by Brad on Apr 01, 2010 1:44 PM

Your comment:
 (will show your gravatar)

Copyright © DanBedassa | Powered by: