Skip to content

Improve DOKU error reporting and add QRIS generation probe - #442

Merged
mnindrazaka merged 1 commit into
mainfrom
claude/vigilant-ptolemy-50dmqj
Sep 11, 2026
Merged

Improve DOKU error reporting and add QRIS generation probe#442
mnindrazaka merged 1 commit into
mainfrom
claude/vigilant-ptolemy-50dmqj

Conversation

@mnindrazaka

Copy link
Copy Markdown
Collaborator

Summary

Enhanced error handling and diagnostics for DOKU payment gateway integration by providing detailed failure messages and adding a QRIS generation probe to the credential verification tool.

Key Changes

  • Better error messages: Extract and include DOKU's responseCode and responseMessage in error details, with truncation for oversized responses
  • Trailing slash handling: Normalize BaseURL by removing trailing slashes to prevent signature computation issues
  • Enhanced dokucheck tool: Extended credential verification to optionally probe QRIS generation with dokucheck generate, helping diagnose merchant/terminal configuration issues
  • Improved logging: Log DOKU's actual error response details for better debugging

Implementation Details

  • Added describeFailure() function to parse DOKU error responses and format them consistently, with a 512-character limit to prevent log spam
  • Modified doSignedRequest() to include failure details in both error messages and structured logs
  • Updated GenerateQris() error message to use the same formatting as HTTP-level failures
  • Extended dokucheck main to accept optional "generate" argument that sends a real QRIS request and displays the response reference number and QR content
  • Updated .env.example documentation to explain the new dokucheck capabilities

https://claude.ai/code/session_01PRC2MG3QCca6Qa7sevUPxi

…s status

A failed qr-mpm-generate reported nothing but the HTTP status, because the
non-2xx branch discarded the response body before anything parsed it. DOKU
answers every rejection with a responseCode and responseMessage naming the
cause, so "failed with status 500" hid the one detail needed to fix it.

The rejection path now parses that body, falling back to the raw payload
(truncated) when DOKU answers with something other than its own error shape,
and carries it into both the log line and the returned error. The generate
rejection message gains the responseCode alongside the message for the same
reason.

NewClient also trims a trailing slash off DOKU_BASE_URL: the signature is
computed over the single-slash path while the request would go to a
double-slash one, which the access token call survives (its signature does
not cover the path) and every transactional call does not.

`dokucheck generate` sends a real qr-mpm-generate and prints DOKU's reply,
so the endpoint can be exercised without going through checkout.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PRC2MG3QCca6Qa7sevUPxi
@vercel

vercel Bot commented Sep 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
gatherloop-pos Ready Ready Preview Sep 11, 2026 5:09am UTC
gatherloop-ui-storybook Ready Ready Preview Sep 11, 2026 5:09am UTC

@mnindrazaka
mnindrazaka merged commit 9bcbdd4 into main Sep 11, 2026
6 of 7 checks passed
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.

2 participants