Repository navigation
fix(ad-hoc): Support redirect result in nAPM tokenization flow - #406
Open
andrii-vysotskyi-cko wants to merge 8 commits into
Open
andrii-vysotskyi-cko wants to merge 8 commits into
andrii-vysotskyi-cko wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The WebView fallback fails to deliver its return URI to tokenization, while ignored redirect-step errors can leave required follow-up steps undisplayed until polling times out.
2 open issues
What changed in this PR
This PR routes native alternative payment tokenization redirects to /tokenize instead of the invoice-only /apm-payments endpoint, while preserving authorization routing.
Changes:
- Adds flow-specific redirect handling and recognition of additional redirect validation errors.
- Extends token creation with verification options, return URLs, invoice settings, and device data.
- Updates the example to request token verification with a deep-link return URL.
| File | Description |
|---|---|
ui/src/main/kotlin/com/processout/sdk/ui/napm/NativeAlternativePaymentInteractor.kt |
Routes redirects by flow and centralizes redirect failure handling. |
sdk/src/main/kotlin/com/processout/sdk/core/POFailure.kt |
Adds two redirect validation codes. |
sdk/src/main/kotlin/com/processout/sdk/api/repository/DefaultCustomerTokensRepository.kt |
Adds device data and maps token creation fields. |
sdk/src/main/kotlin/com/processout/sdk/api/network/CustomerTokensApi.kt |
Uses the device-enriched token creation body. |
sdk/src/main/kotlin/com/processout/sdk/api/model/request/POCreateCustomerTokenRequest.kt |
Extends token creation options and defines the network payload. |
sdk/src/main/kotlin/com/processout/sdk/api/model/request/napm/v2/PONativeAlternativePaymentRedirectConfirmation.kt |
Adds an internal redirect result URL. |
example/src/main/kotlin/com/processout/example/ui/screen/nativeapm/NativeApmViewModel.kt |
Enables verification and supplies the deep-link return URL. |
Review effort: Balanced
Add return_url, invoice_id and manual_invoice_cancellation to the create customer token request and attach device data, matching iOS. The existing returnUrl field is now sent as return_url; invoice_return_url moves to the new invoiceReturnUrl field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Create the customer token with verify enabled and the deep link return URL so the native APM tokenization flow can be tested. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add an internal `result.url` to the redirect confirmation so the return URL can be sent along with `success`, matching iOS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deep links were always resolved via `/apm-payments`, which only supports invoice payments, so tokenization flows failed with invoice not found after a web redirect. Tokenization now posts the full return URL as the redirect result to `/tokenize`; authorization keeps resolving via `/apm-payments`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dling Add `redirect-result-unexpected` and `redirect-result-unexpected-for-step` validation codes and ignore them alongside `redirect-result-invalid` when handling deep links, matching iOS. The payment continues and polling picks up the latest state instead of failing the flow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Restore the `(Boolean)` constructor of `PONativeAlternativePaymentRedirectConfirmation` so code compiled against previous versions keeps working, and send the customer token `returnUrl` as both `return_url` and `invoice_return_url`, matching iOS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Report a warning to telemetry when a redirect result error is ignored while the native alternative payment is in the next step state, since nothing else advances the payment there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Capture polling only stops on success, so a payment that advanced to another step is not shown until polling times out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vitalii-vanziak-cko
force-pushed
the
fix/napm-tokenization-customer-token-request
branch
from
December 3, 2026 13:30
6df939c to
ad7f1fa
Compare
vitalii-vanziak-cko
approved these changes
Dec 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
In
Flow.Tokenization, the return URL from a web redirect was resolved viaPOST /apm-payments, which only supports invoice payments. Tokenization return URLs carry noinvoice_id/processout_token, so the flow failed withresource.invoice.not-found(e.g. Revolut Pay, PayPal REST).Solution
handleDeepLinkbranches on the flow: authorization keeps/apm-payments, tokenization postsredirect: { success: true, result: { url } }to/tokenize, matching iOS.PONativeAlternativePaymentRedirectConfirmationgets an internalresult.url(@ProcessOutInternalApi, like iOS@_spi(PO)).redirect-result-unexpectedandredirect-result-unexpected-for-step(newValidationCodes), matching iOS.return_url,invoice_id,manual_invoice_cancellationand sends device data; the example creates the token withverify: trueand the deep link return URL.