Page 1 of 1

Loosing Payment Account Data With A Custom Gateway

Posted: Mon Mar 29, 2010 3:49 pm
by Diavan
I have a Custom Gateway that is built following the template provided on the AbleCommerce wiki http://wiki.ablecommerce.com/index.php/ ... nt_Gateway.
Its only implementing Authorize & Capture for now and is working as expected. However whenever this gateway is triggered on checkout form the payment object looses any information in the AccountData field.

The checkout form is a little bit modified version of the existing PurchaseOrder form.
Every other info in the payment object is saved in the database except the Account Data. If I remove the Custom Gateway from the payment method the data is saved fine.

Code: Select all

if (checkOut)
{
	//PROCESS THE CHECKOUT
	CheckoutRequest checkoutRequest = new CheckoutRequest(payment);
	CheckoutResponse checkoutResponse = Token.Instance.User.Basket.Checkout(checkoutRequest);	  // Looses AccountData Info on this line
	if (checkoutResponse.Success)
	{
		//....
	}
	else
	{
		//...
	}
}
Appreciate any help.
Thanks.

Re: Loosing Payment Account Data With A Custom Gateway

Posted: Tue Mar 30, 2010 8:07 am
by mazhar
Seems like may be you are missing something in your custom code some required step. I think you should better compare the Account Data manipulation with Authorize.Net code available for community to figure out any potential difference. The sample code is avoidable in wiki topic http://wiki.ablecommerce.com/index.php/ ... nt_Gateway for payment provider, direct link is this ftp://ftp.ablecommerce.com/evals/AuthorizeNet.zip

Re: Loosing Payment Account Data With A Custom Gateway

Posted: Wed Mar 31, 2010 3:07 pm
by Diavan
Mazhar,
The Payment object within the AuthorizeTransactionRequest object is used in the gateway to read the values from. The Payment object is not saved to DB in the Gateway. Correct??
I have rechecked the Gateway code many times and this Payment object is never modified in the method DoAuthorize.
The DoAuthorize method returns the Transaction object shown below. I'm not setting any ResponseCode, AuthorizationCode, AVSResultCode, CVVResultCode. Do I need to set these values?
Does the AccountData field of Payment Object persist in some other form, perhaps some property of Transaction object that is returned??

Code: Select all

Transaction transaction = new Transaction();
transaction.PaymentGatewayId = this.PaymentGatewayId;
transaction.TransactionType = request.TransactionType;
transaction.ProviderTransactionId = response.TransactionId;
transaction.TransactionDate = DateTime.UtcNow;
transaction.Amount = request.Amount;
transaction.TransactionStatus = TransactionStatus.Successful;
transaction.ResponseMessage = "... Some Message ...";
transaction.RemoteIP = request.RemoteIP;
return transaction;
Thanks.

Re: Loosing Payment Account Data With A Custom Gateway

Posted: Wed Mar 31, 2010 3:29 pm
by Diavan
The DoAuthorize is called when the Checkout method is called on the Basket object.

Code: Select all

CheckoutResponse checkoutResponse = Token.Instance.User.Basket.Checkout(checkoutRequest);
The Payment object is already saved in to the Database by the time DoAuthorize is called. The AccountData has some values.

Code: Select all

exec sp_executesql N'INSERT INTO ac_Payments (OrderId, SubscriptionId, PaymentMethodId, PaymentMethodName, ReferenceNumber, Amount, CurrencyCode, PaymentDate, PaymentStatusId, PaymentStatusReason, CompletedDate, EncryptedAccountData, ReCrypt) VALUES (@OrderId, @SubscriptionId, @PaymentMethodId, @PaymentMethodName, @ReferenceNumber, @Amount, @CurrencyCode, @PaymentDate, @PaymentStatusId, @PaymentStatusReason, @CompletedDate, @EncryptedAccountData, @ReCrypt); SELECT Scope_Identity()',N'@PaymentId int,@OrderId int,@SubscriptionId int,@PaymentMethodId int,@PaymentMethodName nvarchar(14),@ReferenceNumber nvarchar(11),@Amount decimal(5,2),@CurrencyCode nvarchar(3),@PaymentDate datetime,@PaymentStatusId smallint,@PaymentStatusReason nvarchar(4000),@CompletedDate datetime,@EncryptedAccountData nvarchar(22),@ReCrypt bit',@PaymentId=0,@OrderId=32,@SubscriptionId=NULL,@PaymentMethodId=8,@PaymentMethodName=N'XYZ Credit',@ReferenceNumber=N'1N-0119-FOO',@Amount=181.29,@CurrencyCode=N'USD',@PaymentDate='2010-03-31 20:31:19:380',@PaymentStatusId=0,@PaymentStatusReason=NULL,@CompletedDate=NULL,@EncryptedAccountData=N'CustomerPO=1N-0119-FOO',@ReCrypt=0
The DoAuthorize method is then called where the Payment properties are read. It then returns the Transaction object.
Somewhere after the DoAuthorize ends and Checkout finishes the Payment Object is updated again.

Code: Select all

exec sp_executesql N'UPDATE ac_Payments SET OrderId = @OrderId, SubscriptionId = @SubscriptionId, PaymentMethodId = @PaymentMethodId, PaymentMethodName = @PaymentMethodName, ReferenceNumber = @ReferenceNumber, Amount = @Amount, CurrencyCode = @CurrencyCode, PaymentDate = @PaymentDate, PaymentStatusId = @PaymentStatusId, PaymentStatusReason = @PaymentStatusReason, CompletedDate = @CompletedDate, EncryptedAccountData = @EncryptedAccountData, ReCrypt = @ReCrypt WHERE PaymentId = @PaymentId',N'@PaymentId int,@OrderId int,@SubscriptionId int,@PaymentMethodId int,@PaymentMethodName nvarchar(14),@ReferenceNumber nvarchar(11),@Amount decimal(5,2),@CurrencyCode nvarchar(3),@PaymentDate datetime,@PaymentStatusId smallint,@PaymentStatusReason nvarchar(4000),@CompletedDate datetime,@EncryptedAccountData nvarchar(4000),@ReCrypt bit',@PaymentId=41,@OrderId=32,@SubscriptionId=NULL,@PaymentMethodId=8,@PaymentMethodName=N'XYZ Credit',@ReferenceNumber=N'1N-0119-FOO',@Amount=181.29,@CurrencyCode=N'USD',@PaymentDate='2010-03-31 20:31:19:380',@PaymentStatusId=5,@PaymentStatusReason=NULL,@CompletedDate='2010-03-31 20:31:19:473',@EncryptedAccountData=NULL,@ReCrypt=0
This time the AccountData is set to NULL.
Is the AccountData property is read & updated from the Transaction object which is returned from the DoAuthorize method??

Thanks.

Re: Loosing Payment Account Data With A Custom Gateway

Posted: Thu Apr 01, 2010 11:57 am
by mazhar
A quick question did you enabled the credit card storage option. Under Administration > Configure > Security > General page enable the credit card storage and then specify number of days you want to retain card data and give a try again.

Re: Loosing Payment Account Data With A Custom Gateway

Posted: Thu Apr 01, 2010 7:56 pm
by Diavan
Aah - That did it. I changed the number of days from default 0 and it saved the Account Data successfully.
Just wondering why the Account Data was getting saved with other built-in Gateways with number of days '0'.
Is this account data going to be deleted after the number of days I just specified now?
Many thanks for making it to work Mazhar.

Re: Loosing Payment Account Data With A Custom Gateway

Posted: Fri Apr 02, 2010 7:04 am
by mazhar
I am not sure that its behavior of default gateways or may be your turned on credit card storage for testing when using default providers. Secondly yes Account data will be removed after specified number of days.