Skip to content

Latest commit

 

History

History
93 lines (77 loc) · 6.05 KB

MIGRATING.md

File metadata and controls

93 lines (77 loc) · 6.05 KB

Migrating from Legacy Authorize.Net Classes

Authorize.Net no longer supports several legacy classes, including AIM, ARB and others listed below, as part of sdk-dotnet. If you are using any of these, we recommend that you update your code to use the new Authorize.Net API classes under (sdk-dotnet/Authorize.NET/Api).

For details on the deprecation and replacement of legacy Authorize.Net APIs, visit https://developer.authorize.net/api/upgrade_guide/.

Full list of classes that are no longer supported

Class New Feature Sample Codes directory/repository
AIM (Authorize.NET/AIM) PaymentTransactions sample-code-csharp/PaymentTransactions
ARB (Authorize.NET/ARB) RecurringBilling sample-code-csharp/Recurring Billing
CIM (Authorize.NET/CIM) CustomerProfiles sample-code-csharp/CustomerProfiles
SIM (Authorize.NET/SIM) Accept Hosted Not available
Reporting (Authorize.NET/Reporting) TransactionReporting sample-code-csharp/TransactionReporting
CP (Authorize.NET/CP) PaymentTransactions sample-code-csharp/PaymentTransactions
DPM (Authorize.NET/DPM) Accept.JS Sample Accept Application

Example

Sample new model code for (charge-credit-card)

using System;
using AuthorizeNet.Api.Controllers;
using AuthorizeNet.Api.Contracts.V1;
using AuthorizeNet.Api.Controllers.Bases;

namespace net.authorize.sample
{
 public class ChargeCreditCard
 {
     public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, decimal amount)
     {

 		// Set the request to operate in either the sandbox or production environment
 		ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;

         // define the merchant information (authentication / transaction id)
         ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
         {
             name = ApiLoginID,
             ItemElementName = ItemChoiceType.transactionKey,
             Item = ApiTransactionKey,
         };

 		// define the CreditCard information
         var creditCard = new creditCardType
         {
             cardNumber = "4111111111111111",
             expirationDate = "0828",
             cardCode = "123"
         };

 		// define the Billing address
         var billingAddress = new customerAddressType
         {
             firstName = "John",
             lastName = "Doe",
             address = "123 My St",
             city = "OurTown",
             zip = "98004"
         };

         //standard api call to retrieve response
         var paymentType = new paymentType { Item = creditCard };

         // Add line Items
         var lineItems = new lineItemType[2];
         lineItems[0] = new lineItemType { itemId = "1", name = "t-shirt", quantity = 2, unitPrice = new Decimal(15.00) };
         lineItems[1] = new lineItemType { itemId = "2", name = "snowboard", quantity = 1, unitPrice = new Decimal(450.00) };

 		// Create the payment transaction object
         var transactionRequest = new transactionRequestType
         {
             transactionType = transactionTypeEnum.authCaptureTransaction.ToString(),    
 			// charge the card
             amount = amount,
             payment = paymentType,
             billTo = billingAddress,
             lineItems = lineItems
         };
         
         var request = new createTransactionRequest { transactionRequest = transactionRequest };
         
         // instantiate the controller that will call the service
         var controller = new createTransactionController(request);
         controller.Execute();
         
         // get the response from the service (errors contained if any)
         var response = controller.GetApiResponse();
 		
 	}
 }
}