credit card declined / custom email sent at CheckedOut event

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
cmorganmcp
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 36
Joined: Mon Dec 08, 2008 10:41 am

credit card declined / custom email sent at CheckedOut event

Post by cmorganmcp » Wed Jan 28, 2009 8:57 am

Ok, so I needed to add some custom fields to the order confirmation email. I added logic to the CheckedOut event in a copy of the OnePageCheckout control to manually send an email. The problem is that the email is always sent even though the credit card is sometimes declined. Should I move this logic to another place?

-chad

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

Re: credit card declined / custom email sent at CheckedOut event

Post by mazhar » Wed Jan 28, 2009 10:40 am

well you can wrap your Email sending code inside an if statement that can check the payment status before sending the Email. For example it could be something as below

Code: Select all

Order order = OrderDataSource.Load(e.OrderId);
        if (order.PaymentStatus == OrderPaymentStatus.Paid)
        { 
            //Your custom Email code here
        }

cmorganmcp
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 36
Joined: Mon Dec 08, 2008 10:41 am

Re: credit card declined / custom email sent at CheckedOut event

Post by cmorganmcp » Wed Jan 28, 2009 10:51 am

ok, but if it hasn't completed processing yet (not accepted or declined) then wouldn't that mean that an email wouldn't get sent? If that's the case then is there a better place to send that custom email after payment has been verified?

-chad

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

Re: credit card declined / custom email sent at CheckedOut event

Post by mazhar » Wed Jan 28, 2009 10:58 am

Well then may be should put the code in the Website/Checkout/PaymentForms/ user controls. For example if you handle this for credit card payments then you can edit the CreditCardPaymentForm.ascx and locate the following code

Code: Select all

if (checkOut)
            {
                //PROCESS A CHECKOUT
                CheckoutRequest checkoutRequest = new CheckoutRequest(payment);
                CheckoutResponse checkoutResponse = Token.Instance.User.Basket.Checkout(checkoutRequest);
                if (checkoutResponse.Success)
                {
                    if (CheckedOut != null) CheckedOut(this, new CheckedOutEventArgs(checkoutResponse.OrderId));
                    Response.Redirect(NavigationHelper.GetReceiptUrl(checkoutResponse.OrderId));
                }
                else
                {
                    List<string> warningMessages = checkoutResponse.WarningMessages;
                    warningMessages.Insert(0, "The order could not be completed because the basket contents changed during checkout.  Please review your basket contents and try again.");
                }
            }
You can put the Email code in success section of the code.

cmorganmcp
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 36
Joined: Mon Dec 08, 2008 10:41 am

Re: credit card declined / custom email sent at CheckedOut event

Post by cmorganmcp » Wed Jan 28, 2009 11:20 am

Thanks, I'll check it out and post my results back here

-chad

cmorganmcp
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 36
Joined: Mon Dec 08, 2008 10:41 am

Re: credit card declined / custom email sent at CheckedOut event

Post by cmorganmcp » Wed Jan 28, 2009 5:21 pm

At what point is the attempt made to actually charge the credit card? After looking at this code I noticed that on "success" it just fires the CheckedOut event which is basically where I'm currently sending the email. So when it gets to this point it seems like the payment still hasn't been approved or declined. Is this the case?

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

Re: credit card declined / custom email sent at CheckedOut event

Post by mazhar » Thu Jan 29, 2009 5:16 am

The actual attempt to charge the card is implemented under the payment gateway you are using. For example if you have configured Authorize.Net as payment gateway then all attempts charge are happening in the Authorize.Net gateway code. If you want application to automatically capture the payments as well then in gateway configurations you have to set the option to Authorize and Capture.

User avatar
sohaib
Developer
Developer
Posts: 1079
Joined: Fri Jan 23, 2004 1:38 am

Re: credit card declined / custom email sent at CheckedOut event

Post by sohaib » Thu Jan 29, 2009 7:22 am

The CheckedOut event handler in OnePageCheckout page is the right place for this kind of code.

If you have set your payment gateway to authorize and capture in one step then in the CheckedOut even handler if e.CheckoutResponse.Success is true the customer has been successfully charged.

If you have set your payment gateway to authorize first step and capture later then in CheckedOut event handler if e.CheckoutResponse.Success is true it only means that the customers credit card has be 'authorized' successfully but it has not been charged yet.

Carolharry
Commander (CMDR)
Commander (CMDR)
Posts: 121
Joined: Wed Dec 17, 2008 9:13 am

Re: credit card declined / custom email sent at CheckedOut event

Post by Carolharry » Mon Feb 02, 2009 3:35 pm

Hi Mazhar,

Where can I find Pay Pal Payflow Pro gateway code(source files path in Ablecommerce project). I would like to see how it is resolving Test mode transaction or live mode transaction.

Thanks alot,
Carol

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

Re: credit card declined / custom email sent at CheckedOut event

Post by mazhar » Tue Feb 03, 2009 4:15 am

PayFlow gateway source code is in dll. The gateway source code is not available in standard purchase. The live or test mode configuration option can be seen on the gateway configuration page in merchant module. Also you can have a look at the sample payment gateway
http://wiki.ablecommerce.com/index.php/ ... nt_Gateway
That can help you understand how live or test mode are handled in code.

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

Re: credit card declined / custom email sent at CheckedOut event

Post by mazhar » Tue Feb 03, 2009 9:27 am

The source of Authorize.Net is available in following thread here
viewtopic.php?f=47&t=5926

Post Reply