Skip to content

Commit

Permalink
Merge pull request #44 from australiangreens/js_fix_legacy_payment_pr…
Browse files Browse the repository at this point in the history
…ocessor_tokens

Limit Payment tokens found to ones that work with the selected payment processor and handle for tokens created by legacy eway recurring payment processor
  • Loading branch information
agileware-justin authored Jan 15, 2025
2 parents 4699485 + 44b7abc commit 0d53d44
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 0d53d44

Please sign in to comment.