Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
var adyenAction = JSON.parse(paymentInstrument.custom.adyenAction);
var adyenPaymentMethod = paymentInstrument.custom.adyenPaymentMethod;
}
var mode : String = dw.system.Site.getCurrent().getCustomPreferenceValue("Adyen_Mode");
var urlPrefixType : String = 'test';
if (mode == 'LIVE') {
urlPrefixType = 'live';
}
Comment on lines +16 to +19
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For conciseness and better readability, you can use a ternary operator to assign the value to urlPrefixType.

	var urlPrefixType : String = (mode === 'LIVE') ? 'live' : 'test';

</isscript>
<BR><BR>

Expand All @@ -26,22 +31,32 @@
</tr>
</thead>
<tbody>
<tr>
<td class='infobox_title'>PSP reference</td>
<td class='infobox_item'>
<isscript>
var mode : String = dw.system.Site.getCurrent().getCustomPreferenceValue("Adyen_Mode");
var urlPrefixType : String = 'test';
if (mode == 'LIVE') {
urlPrefixType = 'live';
}
</isscript>
<A target='new' HREF='https://ca-${urlPrefixType}.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=${order.custom.Adyen_pspReference}&txType=Payment'>
<isprint value="${order.custom.Adyen_pspReference}">
</A>
</td>
</tr>
<tr><td class='infobox_title'>Payment Method</td><td class='infobox_item'><isprint value="${order.custom.Adyen_paymentMethod}"></td></tr>
<isif condition="${order.getPaymentInstruments().size() > 1}">
<isloop items="${order.getPaymentInstruments()}" var="paymentInstrument" status="piStatus">
<tr>
<isif condition="${paymentInstrument.paymentTransaction.custom.Adyen_pspReference != null}">
<td class='infobox_title'>PSP reference</td>
<td class='infobox_item'>
<A target='new' HREF='https://ca-${urlPrefixType}.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=${paymentInstrument.paymentTransaction.custom.Adyen_pspReference}&txType=Payment'>
<isprint value="${paymentInstrument.paymentTransaction.custom.Adyen_pspReference}">
</A>
</td>
<td class='infobox_item'><isprint value="${paymentInstrument.custom.adyenPaymentMethod}"></td>
</isif>
</tr>
</isloop>
<iselse/>
<tr>
<td class='infobox_title'>PSP reference</td>
<td class='infobox_item'>
<A target='new' HREF='https://ca-${urlPrefixType}.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=${order.custom.Adyen_pspReference}&txType=Payment'>
<isprint value="${order.custom.Adyen_pspReference}">
</A>
</td>
</tr>
<tr><td class='infobox_title'>Payment Method</td><td class='infobox_item'><isprint value="${order.custom.Adyen_paymentMethod}"></td></tr>
</isif>

Comment on lines +34 to +59
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The logic to handle single and multiple payment instruments can be greatly simplified. The current implementation has a few issues:

  1. Code Duplication: The <isif> and <iselse> blocks contain very similar logic for displaying payment information.
  2. Inconsistent UI: The layout for multiple payments (three columns in one row) is different from the single payment layout (two columns over two rows).
  3. Invalid HTML: The multi-payment case renders three <td> elements in a <tr>, but the table's <thead> only defines two columns, which is invalid HTML and can cause rendering issues.
  4. Empty Rows: The loop for multiple payments can render empty <tr> elements if a payment instrument has no PSP reference.

A single loop over all payment instruments can handle all cases (0, 1, or many) correctly and consistently. This removes the need for the isif/iselse check on the number of instruments and resolves all the issues mentioned above.

		<isloop items="${order.getPaymentInstruments()}" var="paymentInstrument" status="piStatus">
			<isif condition="${paymentInstrument.paymentTransaction.custom.Adyen_pspReference != null}">
				<tr>
					<td class='infobox_title'>PSP reference</td>
					<td class='infobox_item'>
						<A target='new' HREF='https://ca-${urlPrefixType}.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=${paymentInstrument.paymentTransaction.custom.Adyen_pspReference}&txType=Payment'>
							<isprint value="${paymentInstrument.paymentTransaction.custom.Adyen_pspReference}">
						</A>
					</td>
				</tr>
				<tr>
					<td class='infobox_title'>Payment Method</td>
					<td class='infobox_item'><isprint value="${paymentInstrument.custom.adyenPaymentMethod}"></td>
				</tr>
			</isif>
		</isloop>

<tr><td class='infobox_title'>Eventcode</td><td class='infobox_item'><isprint value="${order.custom.Adyen_eventCode}"></td></tr>
<isif condition="${adyenAdditionalPaymentData != null}">
<isloop items="${adyenAdditionalPaymentData}" var="additionalItem" status="loopstate">
Expand Down