There is a good example on Blackbaud Labs of a custom donation form for Netcommunity. It's a good example that you can build on and use to create (for example) a shop feature for Netcommunity, or some other kind of custom part that can take payment.
A while ago I converted the code to C#. It worked really nicely - payment would be taken from a card, and the transaction sent into the Netcommunity plug-in in Raiser's Edge.
However, I noticed that if an invalid card number was entered and submitted, the 'Thank you for donating' message would still come up, even though the transaction was not processed and the money was not taken. This is the bit of code that deals with it:
try
{
BBNCExtensions.API.Transactions.Donations.RecordDonationReply oReply = this.API.Transactions.RecordDonation(oArgs);
}
There are a series of catch statements following this that are intended to catch any problems that might arise. None of them seem to catch an invalid card number or anything like that, though. This means that any code in the try statement will be executed, irrespective of whether or not the card has been approved, as no error appears to be thrown.
One way of checking whether the transaction has been authorised and it's OK to go on is by including this just after RecordDonation:
if (oReply.CreditCardAuthorizationResponse.ResultCode.ToString() == "Approved")
If 'Approved' is returned, you're good to carry on.
I'm not sure whether this problem is unique to us and our merchant (IATS), but this solution seems to have solved the problem.
Thursday, 20 January 2011
Subscribe to:
Post Comments (Atom)
Hi,
ReplyDeleteDo you know if it is possible to insert some of the standard functionality to a custom part? I'm wanting to insert the default select fund and amount and 'add donation'.
Thanks,
I’ve been a lurker around your blog for a few months. I love this article and your entire site! Looking forward to reading more!
ReplyDeleteThis is my first time i visit here. I found so many entertaining stuff in your blog.
ReplyDelete