I've just moved my store from test to live mode for credit processing (authorize.net) and I'm seeing some behavior I didn't expect. When a credit card purchase is denied, the order is still created. This is not what I want. I would prefer that the user see a notice that their card was denied, and allow them to select an alternate method of payment (or retry). Can this be done natively with AC7?
-Nick
Denied Credit Card Orders - Note code revision
Denied Credit Card Orders - Note code revision
Last edited by nickc on Thu Apr 03, 2008 4:46 pm, edited 1 time in total.
- compunerdy
- Admiral (ADM)
- Posts: 1283
- Joined: Sun Nov 18, 2007 3:55 pm
Re: Denied Credit Card Orders
If anyone is interested, until this issue is resolved by Able, I've automated cancellation of orders that are checked out with a denied credit card, so I don't have to manage them. I'm using an anonymous checkout so there is no account for the site user to return to and fix the problem themselves. Coupons and Gift Certificates used in tandem with these orders are restored so they can be reused.
In Checkout\PaymentForms\CreditCardPaymentForm.ascx, below
insert
I send the site user an e-mail with the denial details, using the auth failed trigger:
Revised 4/3/08 2:42pm PT
Cheers,
-Nick
In Checkout\PaymentForms\CreditCardPaymentForm.ascx, below
Code: Select all
CheckoutResponse checkoutResponse = basket.Checkout(checkoutRequest);
Code: Select all
if (payment.IsFailed)
{
Order cancelorder = new Order();
cancelorder.Load(checkoutResponse.OrderId);
// restore coupons
if (cancelorder.Coupons != null && cancelorder.Coupons.Count > 0)
{
foreach (OrderCoupon oc in cancelorder.Coupons)
{
oc.Delete();
// Alternate method, preserve database record and add one more use
// Coupon c = new Coupon();
// c = CouponDataSource.LoadForCouponCode(oc.CouponCode);
// c.MaxUses += 1;
// c.MaxUsesPerCustomer += 1;
// c.Save();
}
}
// delete payment and restore previous balance to vouchers or gift certificates
if (cancelorder.Payments != null && cancelorder.Payments.Count > 0)
{
foreach (Payment p in cancelorder.Payments)
{
if (p.PaymentMethod.PaymentGatewayId == 2) // Default GC provider
{
p.Delete();
}
}
foreach (GiftCertificateTransaction gct in cancelorder.GiftCertificateTransactions)
{
GiftCertificate gc = new GiftCertificate();
gc.Load(gct.GiftCertificateId);
gc.Balance = gc.Balance + (LSDecimal)System.Math.Abs((Decimal)gct.Amount);
gc.Save();
gct.Delete();
}
}
// cancel the order
cancelorder.Cancel();
}
Code: Select all
<body>
We are sorry, but your order has been cancelled at this time due to an error with your payment method. <br>
If you used an e-code or voucher with your order, its value has been restored and you will still be able to use it. <br>
<br>
Please confirm your billing information and resubmit your order.<br>
<br>
Thank you – support@<br><br>
<table class="Email">
<tr><th colspan="4">Payments for Order $order.OrderId</th></tr>
<tr>
<th>Payment</th><th>Ref#</th><th>Amount</th><th>Status</th>
</tr>
#foreach($payment in $order.Payments)
<tr>
<td valign="top">$payment.PaymentMethodName</td>
<td valign="top">$payment.ReferenceNumber</td>
<td valign="top">$payment.Amount.ToString("C")</td>
<td valign="top">#foreach($transaction in $payment.Transactions)
$transaction.TransactionType $transaction.TransactionStatus ($transaction.ProviderTransactionId) - $transaction.ResponseMessage
#end
</td>
</tr>
#end
</table>
</body>
Cheers,
-Nick
Nick Cole
http://www.ethofy.com
http://www.ethofy.com
- Logan Rhodehamel
- Developer
- Posts: 4116
- Joined: Wed Dec 10, 2003 5:26 pm
Re: Denied Credit Card Orders
In case you are interested, if you check the forum thread linked in your first reply, this morning I posted a patch that we prepared to address the issue.nickc wrote:If anyone is interested, until this issue is resolved by Able, I've automated cancellation of orders that are checked out with a denied credit card, so I don't have to manage them.