Page 1 of 1
Denied Credit Card Orders - Note code revision
Posted: Fri Mar 28, 2008 7:10 pm
by nickc
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
Posted: Fri Mar 28, 2008 7:15 pm
by compunerdy
Posted: Fri Mar 28, 2008 7:28 pm
by nickc
hmm. thanks - I never would have thought of this as a "feature" - I've been limiting my searching to the general forum.
Re: Denied Credit Card Orders
Posted: Thu Apr 03, 2008 3:14 pm
by nickc
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
Code: Select all
CheckoutResponse checkoutResponse = basket.Checkout(checkoutRequest);
insert
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();
}
I send the site user an e-mail with the denial details, using the auth failed trigger:
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>
Revised 4/3/08 2:42pm PT
Cheers,
-Nick
Re: Denied Credit Card Orders
Posted: Fri Apr 04, 2008 12:23 am
by Logan Rhodehamel
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.
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.