Void a Transaction

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
oa2a
Ensign (ENS)
Ensign (ENS)
Posts: 7
Joined: Wed Oct 01, 2014 7:12 am

Void a Transaction

Post by oa2a » Tue Jan 13, 2015 11:56 am

Hello,
I have implemented DoVoid() method in my custom PaymentGateway.dll following the Authorize.NET example. In the same file (PaymentGateway.dll) there is DoAuthorize() and other DoXXX() methods that work successfully when "Pay with card" button is clicked on the shopping cart checkout screen. However the DoVoid() method is never fired when the "Void" button is clicked on the Admin screen for voiding transactions. Is there something that needs to be added on the void transactions screen code behind?

thanks!

oa2a
Ensign (ENS)
Ensign (ENS)
Posts: 7
Joined: Wed Oct 01, 2014 7:12 am

Re: Void a Transaction

Post by oa2a » Wed Jan 14, 2015 8:41 am

Additional details:
I'm using Able Commerce gold

Code snippets:

public override Transaction DoVoid(VoidTransactionRequest voidRequest)

in PaymentGateway.cs:

.................................
public override Transaction DoVoid(VoidTransactionRequest voidRequest)
{
this.RecordCommunication(this.Name, CommunicationDirection.Receive, "--------------DoVoid() ---------", null);


//BUILD THE REQUEST
string gatewayRequest = BuildGatewayRequest_Void(voidRequest);
//RECORD REQUEST
if (this.UseDebugMode)
{
//ALWAYS MASK THE CREDENTIALS
string credentials = String.Format("x_login={0}&x_tran_key={1}", this.MerchantLogin, this.TransactionKey);
string debugCredentials = "x_login=xxxxxxxx&x_tran_key=xxxxxxxx";
this.RecordCommunication(this.Name, CommunicationDirection.Send, gatewayRequest.Replace(credentials, debugCredentials), null);
}
//SEND REQUEST
string response = this.SendRequestToGateway(gatewayRequest);
//RECORD RESPONSE
if (this.UseDebugMode) this.RecordCommunication(this.Name, CommunicationDirection.Receive, response, null);
//PROCESS RESPONSE AND RETURN RESULT
return this.ProcessGatewayResponse_Void(voidRequest.Payment, response, voidRequest);
}


................................

in VoidPayment.aspx.cs:

protected void SubmitVoidButton_Click(object sender, EventArgs e)
{
_Payment.Void();
if (!string.IsNullOrEmpty(CustomerNote.Text))
{
OrderNote note = new OrderNote(_Order.Id, AbleContext.Current.UserId, DateTime.UtcNow, CustomerNote.Text, NoteType.Public);
_Order.Notes.Add(note);
_Order.Save(false, false);
}


Response.Redirect("Default.aspx?OrderNumber=" + _Order.OrderNumber.ToString());
}
..............

As I have mentioned above the DoVoid() method is never called.


Please advise!

Thanks in advance,
Lena

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Void a Transaction

Post by mazhar » Fri Jan 16, 2015 12:11 am

Make sure you marked in SupportedTransactions property of provider that it supports the Void transactions.

oa2a
Ensign (ENS)
Ensign (ENS)
Posts: 7
Joined: Wed Oct 01, 2014 7:12 am

Re: Void a Transaction

Post by oa2a » Fri Jan 16, 2015 10:06 am

It is marked as True but the Void method is not being called. Please help!

Thanks

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Void a Transaction

Post by mazhar » Wed Jan 21, 2015 2:20 am

By this I seems like you are saying Void is included in supportedTransactions. For example if provider is supporting Authorize, AuthorizeCapture, Capture, PartialRefund, Refund and Void transactions then SupportedTransactions will be overridden in following way

Code: Select all

public override SupportedTransactions SupportedTransactions
        {
            get
            {
                return (SupportedTransactions.Authorize | SupportedTransactions.AuthorizeCapture | SupportedTransactions.Capture | SupportedTransactions.PartialRefund | SupportedTransactions.Refund | SupportedTransactions.Void);
            }
        }
Then make sure all supported transactions are handled for example for Void make sure you have overridden the DoVoid handle like this

Code: Select all

public override Transaction DoVoid(VoidTransactionRequest voidRequest)
{
// YOUR CUSTOM CODE HERE
}
Now in testing if you have a successfully authorized transaction and you trigger a void system should call DoVoid.

Post Reply