Fold apple_pay/google_pay into the card bucket, keep everything else under other
Per feedback: card-network wallet payments (Apple Pay, Google Pay) should report and filter as "card" on the user payment history page rather than "other", since they settle the same way as a card payment. Any other gateway-reported method still falls under "other". Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -350,14 +350,18 @@ const getPayments = async (req, res) => {
|
||||
};
|
||||
|
||||
// Payment.method is free-text — online checkouts get tagged with whatever wallet type the
|
||||
// gateway reports (apple_pay, google_pay, yoco, ...), not just the manual-entry methods below.
|
||||
// For the user-facing dashboard we don't want to expose every raw gateway string, so anything
|
||||
// that isn't one of the methods staff can manually choose is just shown/filtered as "other".
|
||||
// gateway reports (apple_pay, google_pay, ...), not just the manual-entry methods below.
|
||||
// For the user-facing dashboard: card-network wallets count as "card" (same settlement, no
|
||||
// separate float); anything else unrecognized falls into "other".
|
||||
const USER_FACING_METHODS = ['cash', 'card', 'eft', 'voucher'];
|
||||
const CARD_ALIASES = ['apple_pay', 'google_pay'];
|
||||
const KNOWN_METHODS = [...USER_FACING_METHODS, ...CARD_ALIASES];
|
||||
|
||||
function normalizeUserMethod(method) {
|
||||
const m = String(method || '').toLowerCase();
|
||||
return USER_FACING_METHODS.includes(m) ? m : 'other';
|
||||
if (USER_FACING_METHODS.includes(m)) return m;
|
||||
if (CARD_ALIASES.includes(m)) return 'card';
|
||||
return 'other';
|
||||
}
|
||||
|
||||
// @desc Get user payments (paginated, excludes donations, supports date range/method/kind filters)
|
||||
@@ -381,11 +385,16 @@ const getUserPayments = async (req, res) => {
|
||||
|
||||
if (req.query.method) {
|
||||
const requested = String(req.query.method).toLowerCase();
|
||||
if (requested === 'other') {
|
||||
// "Other" covers every method that isn't one of the four explicit buckets —
|
||||
// e.g. gateway-reported wallet types like apple_pay, google_pay, yoco, etc.
|
||||
if (requested === 'card') {
|
||||
// "Card" also covers card-network wallet types (apple_pay, google_pay) — same
|
||||
// settlement as a card payment, no separate float to reconcile.
|
||||
where.AND = [{
|
||||
OR: ['card', ...CARD_ALIASES].map(m => ({ method: { equals: m, mode: 'insensitive' } }))
|
||||
}];
|
||||
} else if (requested === 'other') {
|
||||
// "Other" covers every method that isn't one of the recognized buckets above.
|
||||
where.NOT = {
|
||||
OR: USER_FACING_METHODS.map(m => ({ method: { equals: m, mode: 'insensitive' } }))
|
||||
OR: KNOWN_METHODS.map(m => ({ method: { equals: m, mode: 'insensitive' } }))
|
||||
};
|
||||
} else if (USER_FACING_METHODS.includes(requested)) {
|
||||
where.method = { equals: requested, mode: 'insensitive' };
|
||||
|
||||
Reference in New Issue
Block a user