Reply
Highlighted
Member
Posts: 3
Registered: ‎04-16-2012
Accepted Solution

Prior Authorization Capture using C# SDK

I have my test system setup using the C# SDK for AIM , and due to our company's ordering process, we need to do an Authorization first, then capture the authorization separately. I initially did this using the Capture transaction type, but that obviously isn't correct, because it creates a new transaction. I can't find anything in the SDK about doing a PriorAuthCapture transaction type.

 

Am I missing something, or is there another way to do the PriorAuthCapture using the C# SDK?


Accepted Solutions
Highlighted
Solution
Accepted by topic author cpoirier
‎08-21-2015 01:58 AM
Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: Prior Authorization Capture using C# SDK

It is missing from the SDK. You can modify the source.

View solution in original post

Highlighted
Solution
Accepted by topic author cpoirier
‎08-21-2015 01:58 AM
Member
Posts: 3
Registered: ‎04-16-2012

Re: Prior Authorization Capture using C# SDK

Thanks for the heads-up on the source download RaynorC1emen7, I didn't notice that those were two separate links. I downloaded the source and added a PriorAuthCaptureRequest class in AuthorizeNET/AIM/Requests/ (I just copied and modified the CaptureRequest class. Here is the source:

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AuthorizeNet {
    /// <summary>
    /// A request representing a PriorAuthCaptureRequest - the final transfer of funds that happens after an AuthorizationRequest.
    /// </summary>
    public class PriorAuthCaptureRequest:GatewayRequest {

        /// <summary>
        /// Initializes a new instance of the <see cref="PriorAuthCaptureRequest"/> class.
        /// </summary>
        /// <param name="amount">The amount.</param>
        /// <param name="transactionId">The transaction id.</param>
        /// <param name="authCode">The auth code.</param>
        public PriorAuthCaptureRequest(decimal amount, string transactionId, string authCode)
        {
            this.SetApiAction(RequestAction.PriorAuthCapture);
            this.Queue(ApiFields.Amount, amount.ToString());
            this.Queue(ApiFields.TransactionID, transactionId);
            this.Queue(ApiFields.AuthorizationCode, authCode);
        }

    }
}


View solution in original post


All Replies
Highlighted
Solution
Accepted by topic author cpoirier
‎08-21-2015 01:58 AM
Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: Prior Authorization Capture using C# SDK

It is missing from the SDK. You can modify the source.

Highlighted
Member
Posts: 3
Registered: ‎04-17-2012

Re: Prior Authorization Capture using C# SDK

How would we modify the source to perform a Prior Authorization Capture?

 

The class library is pre-compiled into the AuthorizeNet.dll. Can you send a working sample? I'm having the exact same issue. Thanks!

Highlighted
Member
Posts: 3
Registered: ‎04-17-2012

Re: Prior Authorization Capture using C# SDK

How did you get this working? If you don't mind, can you share a C# sample?

Highlighted
Member
Posts: 3
Registered: ‎04-16-2012

Re: Prior Authorization Capture using C# SDK

I haven't done this yet, but my plan is to write a class that extends GatewayRequest and submits the raw XML request. I will post code when I have done this so that others can use it.

Highlighted
Member
Posts: 3
Registered: ‎04-17-2012

Re: Prior Authorization Capture using C# SDK

[ Edited ]

I found a solution using System.Reflection. I downloaded .Net Reflector and found the hidden mothod names inside the GatewayRequest class.

 

I then found a hidden method named "SetApiAction". This internal method takes the RequestAction Enum as a parameter.

 

Here's the VB.net code:

 

'Decalre your CaptureRequest class

Dim auth As CaptureRequest = New AuthorizeNet.CaptureRequest(ord.OrderTotal, ord.ResponseTransactionID, ord.ResponseAuthorizationCode)

 

'Modify the SDK using System.Reflection, so you can make a prior_auth_capture request

Dim mi As MethodInfo = GetType(CaptureRequest).GetMethod("SetApiAction", BindingFlags.NonPublic Or BindingFlags.Instance)
mi.Invoke(auth, New Object() {RequestAction.PriorAuthCapture})

 

Let me know if it works for you!

Highlighted
Expert
Posts: 4,525
Registered: ‎03-08-2010

Re: Prior Authorization Capture using C# SDK

C# SDKs have two different download, dll or source. Source on the left, dll(binary) on the right.

 

Highlighted
Solution
Accepted by topic author cpoirier
‎08-21-2015 01:58 AM
Member
Posts: 3
Registered: ‎04-16-2012

Re: Prior Authorization Capture using C# SDK

Thanks for the heads-up on the source download RaynorC1emen7, I didn't notice that those were two separate links. I downloaded the source and added a PriorAuthCaptureRequest class in AuthorizeNET/AIM/Requests/ (I just copied and modified the CaptureRequest class. Here is the source:

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AuthorizeNet {
    /// <summary>
    /// A request representing a PriorAuthCaptureRequest - the final transfer of funds that happens after an AuthorizationRequest.
    /// </summary>
    public class PriorAuthCaptureRequest:GatewayRequest {

        /// <summary>
        /// Initializes a new instance of the <see cref="PriorAuthCaptureRequest"/> class.
        /// </summary>
        /// <param name="amount">The amount.</param>
        /// <param name="transactionId">The transaction id.</param>
        /// <param name="authCode">The auth code.</param>
        public PriorAuthCaptureRequest(decimal amount, string transactionId, string authCode)
        {
            this.SetApiAction(RequestAction.PriorAuthCapture);
            this.Queue(ApiFields.Amount, amount.ToString());
            this.Queue(ApiFields.TransactionID, transactionId);
            this.Queue(ApiFields.AuthorizationCode, authCode);
        }

    }
}