Page 1 of 1

Void a Transaction

Posted: Tue Jan 13, 2015 11:56 am
by oa2a
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!

Re: Void a Transaction

Posted: Wed Jan 14, 2015 8:41 am
by oa2a
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

Re: Void a Transaction

Posted: Fri Jan 16, 2015 12:11 am
by mazhar
Make sure you marked in SupportedTransactions property of provider that it supports the Void transactions.

Re: Void a Transaction

Posted: Fri Jan 16, 2015 10:06 am
by oa2a
It is marked as True but the Void method is not being called. Please help!

Thanks

Re: Void a Transaction

Posted: Wed Jan 21, 2015 2:20 am
by mazhar
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.