Skip to content

Add dnqr (DuitNow QR) payment method support - #3

Open
wzul wants to merge 5 commits into
mainfrom
feature/dnqr-support
Open

Add dnqr (DuitNow QR) payment method support#3
wzul wants to merge 5 commits into
mainfrom
feature/dnqr-support

Conversation

@wzul

@wzul wzul commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Mirrors the proven chip-for-woocommerce dnqr resolver pattern.

  • Adds dnqr (modern DuitNow QR) to the DuitNow QR group, interchangeable with legacy duitnow_qr.
  • Merchant keeps selecting the single duitnow_qr entry; dnqr is resolved at runtime via /payment_methods/.
  • Resolver: expand group in-memory → short-circuit if no group member → static cache (brand+currency+amount-bucket) → intersect with available methods → prioritize dnqr → fallback to expanded whitelist on API failure.

@wzul

wzul commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator Author

Generalised the DuitNow QR resolver into resolve_payment_method_groups() to also handle the modern ShopeePay group.

  • Added SHOPEE_GROUP = ['razer_shopeepay', 'shopee_pay'].
  • One /payment_methods/ call + one static cache serves both groups.
  • dnqr: prefer dnqr, drop duitnow_qr. shopee: prefer shopee_pay, drop razer_shopeepay.
  • Short-circuits (no API) when neither group is configured; falls back to expanded whitelist on API failure.
  • Comma-string setting + validation unchanged; no separate selectable shopee option added.

@wzul

wzul commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator Author

Shopee Pay → shopee_pay (modern) with backward-compatible migration

Merchant dashboard now stores shopee_pay instead of razer_shopeepay.

Changes (PluginChip.php):

  • Description: whitelist field now recommends shopee_pay; razer_shopeepay noted as legacy (auto-migrated).
  • Validation allow-list: accepts shopee_pay (keeps razer_shopeepay).
  • In-memory migration: if whitelist contains razer_shopeepay and not shopee_pay, it is replaced with shopee_pay before the resolver runs.
  • Resolver: preferred key for the Shopee group changed from shopee to shopee_pay so the modern method wins when both are available (previously the preference check never matched, so both could be emitted). SHOPEE_GROUP constant unchanged. DuitNow QR untouched.

Potential Risks & Review Items

  • Resolver preference fix: the preferred key was shopee (never a member), so the priority branch was dead code — both Shopee methods could be emitted. Now shopee_pay is preferred. Confirm this matches intended behavior.
  • Migration is in-memory only: stored dashboard value is not rewritten; migration re-runs on every payment. No DB write, so no persistence risk, but the stored value stays razer_shopeepay until manually updated.
  • Backward compat: merchants with razer_shopeepay still work (migrated at runtime); merchants with shopee_pay unaffected.
  • No DuitNow QR changesduitnow_qr/dnqr group untouched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant