Page 1 of 1

R10 nHibernate error when payment profile is deleted

Posted: Wed Dec 09, 2015 5:28 am
by AbleMods
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?

Re: R10 nHibernate error when payment profile is deleted

Posted: Wed Dec 09, 2015 5:40 am
by mazhar
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.

Re: R10 nHibernate error when payment profile is deleted

Posted: Wed Dec 09, 2015 5:47 am
by AbleMods
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.

Re: R10 nHibernate error when payment profile is deleted

Posted: Wed Dec 09, 2015 6:02 am
by mazhar
As a workaround you should wrap your code in a try catch. If accessing this property throws ObjectNotFoundException it would mean its deleted.

Re: R10 nHibernate error when payment profile is deleted

Posted: Wed Dec 09, 2015 6:13 am
by AbleMods
Yup will do. Thanks for the quick responses !