Skip to content

fix(maya): capture missing response fields + surface raw connector response - #2134

Merged
kanikac199 merged 4 commits into
mainfrom
fix/maya-response-missing-fields
Aug 17, 2026
Merged

fix(maya): capture missing response fields + surface raw connector response#2134
kanikac199 merged 4 commits into
mainfrom
fix/maya-response-missing-fields

Conversation

@kanikac199

@kanikac199 kanikac199 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Description

Two related connector-response improvements for the Maya connector (one commit each):

1. Capture missing PSync & refund response fields via the money framework
Maya's payment-inquiry (PSync) and refund responses returned fields the connector was neither deserializing nor handing back, so they were dropped from the emitted response.

  • PSync (MayaWebhookBody): add isPaid, amount, currency, canCapture, createdAt, updatedAt. amount is modeled as StringMajorUnit (Maya serializes it as a JSON string "100", despite the API reference documenting a number), run through AmountConvertor::convert_back and surfaced via PaymentSynIntegrityObject. The non-money flags/timestamps go through connector_metadata.
  • Refund (MayaRefundResponse): add amount (also a string) + currencyRefundIntegrityObject.
  • RSync's integrity object is identity-based, so its amount is modeled/consumed but not wired to an amount check.

2. Surface raw connector response on all flows
Populate raw_connector_response in connector code for Authorize / PSync / Void / Refund / RSync (mirrors flywire/kount and Maya's existing webhook path), plus the error path (get_error_response). This captures the raw response independent of the return_raw_connector_data config flag (off in development).

  1. Removed user_id from request
    No need to pass user_id , since it is optional and not needed for current implementation.

Motivation and Context

The connector was silently dropping response data Maya returns. Because the emitted response body is re-serialized from the typed structs, any unmodeled field never reached the caller — losing amount/currency (needed for money-framework integrity verification) and operational flags (isPaid, canVoid, canRefund, canCapture) as well as the raw connector payload. This models those fields and routes amount/currency through the money framework so PSync/refund amounts are verified against intent, and makes the raw connector response available on every flow.

Additional Changes

  • This PR modifies the API contract
  • This PR modifies application configuration/environment variables

(No proto/contract change — the response fields already exist; they are now populated. No config changes committed.)

How did you test it?

@kanikac199
kanikac199 requested a review from a team as a code owner August 14, 2026 11:07
@kanikac199
kanikac199 force-pushed the fix/maya-response-missing-fields branch from c29ad9c to 4398720 Compare August 14, 2026 11:17
@kanikac199 kanikac199 changed the title fix(maya): capture and surface missing PSync & refund response fields fix(maya): capture missing PSync & refund response fields via amount framework Aug 14, 2026
@kanikac199
kanikac199 force-pushed the fix/maya-response-missing-fields branch from 4398720 to 07e96eb Compare August 14, 2026 11:26
@kanikac199 kanikac199 changed the title fix(maya): capture missing PSync & refund response fields via amount framework fix(maya): capture missing PSync & refund response fields via money framework Aug 14, 2026
Maya's payment-inquiry (PSync) and refund responses return fields the
connector was neither deserializing nor handing back, so they were
silently dropped from the response body we emit.

Amount/currency now go through Prism's money framework
(`AmountConvertor::convert_back` -> `MinorUnit`) and feed each flow's
integrity check, matching the house pattern (stripe/xendit/airwallex):

- PSync (`MayaWebhookBody`): add `isPaid`, `amount`, `currency`,
  `canCapture`, `createdAt`, `updatedAt`. `amount` is modeled as
  `StringMajorUnit` because Maya's live payment response serializes it as
  a decimal string (e.g. "100") -- despite the API reference documenting a
  JSON number (verified end-to-end against the sandbox). `convert_back`
  via `StringMajorUnitForConnector` populates `PaymentSynIntegrityObject`.
  `isPaid`/`canCapture`/`canVoid`/`canRefund`/`createdAt`/`updatedAt` have
  no typed slot, so they are surfaced via `connector_metadata`.
- Refund (`MayaRefundResponse`): add `amount` (also a JSON string ->
  `StringMajorUnit`) and `currency`; `convert_back` populates
  `RefundIntegrityObject`.

Integrity objects are only set when Maya returns both amount and currency
(it omits them for e.g. expired payments); all new fields are optional
with `#[serde(default)]`. RSync's integrity object is identity-based
(connector txn/refund id), so its amount is modeled but not wired to an
amount integrity check.

Validated end-to-end against Maya sandbox via the Prism HTTP server:
authorize -> wallet payment -> PSync (PAYMENT_SUCCESS) -> refund
(REFUND_SUCCESS); the new fields now appear in the typed connector
response and integrity amount converts "100" -> 10000 minor.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kanikac199
kanikac199 force-pushed the fix/maya-response-missing-fields branch from 07e96eb to 47c8ff1 Compare August 14, 2026 12:02
Populate `raw_connector_response` in connector code for every Maya flow,
mirroring the flywire/kount pattern (and Maya's existing webhook path),
so the connector's response body is captured regardless of the
`return_raw_connector_data` config flag.

- Authorize / PSync / Void / Refund / RSync transformers: set
  `resource_common_data.raw_connector_response` to the serialized parsed
  response (`serde_json::to_string(&item.response)`), wrapped in `Secret`.
- Error path (`get_error_response`): set `raw_connector_response` to the
  byte-exact response body (`String::from_utf8_lossy(&res.response)`)
  instead of `None`.

Verified end-to-end against the Maya sandbox with the flag OFF
(development): `raw_connector_response` now appears in the authorize and
PSync composite responses.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kanikac199 kanikac199 changed the title fix(maya): capture missing PSync & refund response fields via money framework fix(maya): capture missing response fields + surface raw connector response Aug 14, 2026
Comment thread crates/integrations/connector-integration/src/connectors/maya/transformers.rs Outdated
The PSync transformer stuffed isPaid/canVoid/canRefund/canCapture/
createdAt/updatedAt into `connector_metadata`. These are now already
surfaced through `raw_connector_response` and `typed_connector_response`
(the full payment object), and nothing consumes the metadata back, so it
was pure duplication. Removed.

Addresses review comment.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kanikac199
kanikac199 enabled auto-merge August 17, 2026 07:23
@kanikac199
kanikac199 added this pull request to the merge queue Aug 17, 2026
Merged via the queue into main with commit 317e347 Aug 17, 2026
18 checks passed
@kanikac199
kanikac199 deleted the fix/maya-response-missing-fields branch August 17, 2026 08:20
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.

5 participants