R10 nHibernate error when payment profile is deleted

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

R10 nHibernate error when payment profile is deleted

Post by AbleMods » Wed Dec 09, 2015 5:28 am

I can't tell if this is something I've caused, or I'm missing a foreign key constraint or what.

If a GatewayPaymentProfileId is deleted i.e. a shopper deletes a stored card profile, accessing any related payment records GatewayPaymentProfile child class throws an exception:
No row with the given identifier exists[CommerceBuilder.Payments.GatewayPaymentProfile#1805]
Obviously the 1805 is the gateway profile Id that was deleted.

Shouldn't the ac_Payments.GatewayPaymentProfileId be set to null via a foreign key constraint when a profile is deleted?
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

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

Re: R10 nHibernate error when payment profile is deleted

Post by mazhar » Wed Dec 09, 2015 5:40 am

On which page you get this exception? We don't have a constraint or cascade defined for this field, I will check our logs to see why its this way. You are correct setting the id to null makes sense.

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: R10 nHibernate error when payment profile is deleted

Post by AbleMods » Wed Dec 09, 2015 5:47 am

It's in my Quickbooks module.

When I transfer a payment to Quickbooks, I have to identify the payment card type i.e. Visa,MasterCard etc. Before card profiles, payment card type was readily accessible on the Payment object.

When card profiles were introduced, payment card type was no longer on the Payment object when the payment was the result of a stored card profile. But it was in the stored card profile object.

So in my code, I do a check if (payment.GatewayCardProfile != null) and that's when the exception gets thrown.

Looking at the data, I can easily see several payments from the shopper where profile Id 1805 was assigned to the payment. But looking in the gateway profiles table, 1805 no longer exists.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

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

Re: R10 nHibernate error when payment profile is deleted

Post by mazhar » Wed Dec 09, 2015 6:02 am

As a workaround you should wrap your code in a try catch. If accessing this property throws ObjectNotFoundException it would mean its deleted.

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: R10 nHibernate error when payment profile is deleted

Post by AbleMods » Wed Dec 09, 2015 6:13 am

Yup will do. Thanks for the quick responses !
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

Post Reply