Payment History Email Template

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
ZLA
Commodore (COMO)
Commodore (COMO)
Posts: 496
Joined: Fri Mar 13, 2009 2:55 pm

Payment History Email Template

Post by ZLA » Wed Apr 21, 2010 3:30 pm

I'm trying to add the payment history to a Authorization Failed Email Template. I had the following:

Code: Select all

<table class="Email">
#foreach($payment in $order.Payments)
#beforeall  
<tr class="detailHeader">
<td>Payment Method</td>
<td>Ref#</td>
<td>Amount</td>
<td>Status</td>
<td>Reason</td>
</tr>
#each
<tr class="Email">
<td class="Email" style="text-align: center;">
$payment.PaymentMethodName
</td>
<td class="Email">
$payment.ReferenceNumber
</td>
<td class="Email" style="text-align: right;">
$payment.Amount
</td>
<td class="Email">
$payment.PaymentStatus
</td>
<td class="Email">
$payment.PaymentStatusReason
</td>
</tr>
#afterall
</table>
#end
which is close but not exactly what I want. I'm looking to match the content in the attached image from the PayMyOrder page. In looking at that code, there is a bit of logic involved to produce the necessary values. I'm wondering if there's an easier way than reproducing all of the logic using nVelocity in the template.

Thank you in advance for any assistance you can provide.

ZLA
Commodore (COMO)
Commodore (COMO)
Posts: 496
Joined: Fri Mar 13, 2009 2:55 pm

Re: Payment History Email Template

Post by ZLA » Wed Apr 21, 2010 11:24 pm

I tried doing this but I'm getting some weird results. I implemented the following nvelocity code:

Code: Select all

<table class="Email">
<tr>
<th class="Email">Payments for Order $order.OrderNumber</th>
</tr>
</table>
<table class="Email">
#foreach($payment in $order.Payments)
#beforeall  
<tr class="detailHeader">
<td style="text-align: center;">Date</td>
<td style="text-align: center;">Type</td>
<td style="text-align: center;">Amount</td>
<td>Status</td>
<td>Reason</td>
</tr>
#each
<tr class="Email">
<td class="Email" style="text-align: center;">
$payment.PaymentDate.ToString("G")
</td>
<td class="Email" style="text-align: center;">
$payment.PaymentMethodName $payment.ReferenceNumber
</td>
<td class="Email" style="text-align: right;">
$payment.Amount.ToString("ulc")
</td>
<td class="Email">
$payment.PaymentStatus
</td>
<td class="Email">
#set ($Reason = "")
#if ($payment.PaymentStatus == "Void")
#foreach($trans in $payment.Transactions)
#if (($trans.TransactionType == "Authorize") || ($trans.TransactionType == "AuthorizeCapture") || ($trans.TransactionType == "AuthorizeRecurring"))
#set ($Reason = "")
#if ($trans.TransactionStatus == "Failed")
#set ($Reason = $trans.ResponseMessage)
#end
#end
#end
#end					  
$Reason
</td>
</tr>
#afterall
</table>
#end
  • The first time I submit a failed transaction, I get a status of Unprocessed and a blank reason.
  • If I resubmit the payment (but still have it fail), I get two transactions. The first one now says Void and Transaction Failed; the second one has a status of AuthorizationFailed with a blank reason.
  • If I resubmit the payment (but still have it fail), I get three transactions. The first and second ones say Void and Transaction Failed; the third one has a status of AuthorizationFailed with a blank reason.
What's strange is that all three payments and their transactions are identical. All the payments have PaymentStatusId = 10 (Void) and null for the PaymentStatusReason. Each payment has two transactions: the first is the AuthorizeCapture with a ResponseMessage of TransactionFailed; the second is the Void with a ResponseMessage of Manual Void Successful.

It looks like during the first pass, the email is generated before the database is written to. And somewhere I must have a logic error to cause the last payment line to say AuthorizationFailed with a blank reason.

I would appreciate if someone can tell me my error. Thank you.

Post Reply