Skip to content

Commit

Permalink
Limit Payment tokens found to ones that work with the selected paymen…
Browse files Browse the repository at this point in the history
…t processor and handle for tokens created by legacy eway recurring payment processor
  • Loading branch information
seamuslee001 committed Dec 4, 2024
1 parent 4699485 commit 44b7abc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion js/eway.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ CRM.eway.setPaymentTokenOptions = async function () {
where: [
['contact_id', '=', CRM.eway.contact_id],
['expiry_date', '>', 'now'],
['payment_processor_id', '=', CRM.eway.ppid],
],
orderBy: {expiry_date: 'DESC'}
});
Expand Down Expand Up @@ -37,7 +38,13 @@ CRM.eway.updateOptions = function (values) {
month = '0' + month;
}

html += `<option value="${value.id}">${value.masked_account_number.slice(-4)} - ${month}/${expireDate.getFullYear()}</option>`;
// Handle for tokens created via the legacy payment processor.
if (value.masked_account_number) {
html += `<option value="${value.id}">${value.masked_account_number.slice(-4)} - ${month}/${expireDate.getFullYear()}</option>`;
}
else {
html += `<option value="${value.id}">${month}/${expireDate.getFullYear()}</option>`;
}
}

const $select = CRM.$('#contact_payment_token');
Expand Down

0 comments on commit 44b7abc

Please sign in to comment.