-
Notifications
You must be signed in to change notification settings - Fork 0
docs: add WebView-based data collection docs #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Replace native field-by-field data collection with WebView-based approach for Information Capture (IC). The CollectDataAction model now uses a `url` field pointing to a WalletConnect-hosted form. When present, wallets display it in a WebView instead of building native forms. The WebView handles form rendering, validation, T&C acceptance, and communicates completion via JS bridge messages (IC_COMPLETE / IC_ERROR). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…refill examples - Remove PaymentResultInfo from ConfirmPaymentResponse across all docs - Add resultInfo: PaymentResultInfo? to PaymentOptionsResponse in all platform docs and AI prompts - Add pobAddress field to all prefill data examples - Document that schema's required list can be used to determine prefill fields Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| } | ||
|
|
||
| // Step 6: Confirm payment | ||
| // Step 6: Confirm payment (no collectedData when WebView is used) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Step 6: Confirm payment (no collectedData when WebView is used) | |
| // Step 6: Confirm payment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 3bb4277
| } | ||
|
|
||
| // Step 5: Confirm payment | ||
| // Step 5: Confirm payment (no collectedData when WebView is used) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Step 5: Confirm payment (no collectedData when WebView is used) | |
| // Step 5: Confirm payment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 3bb4277
| } | ||
|
|
||
| // Step 6: Confirm payment | ||
| // Step 6: Confirm payment (no collectedData when WebView is used) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Step 6: Confirm payment (no collectedData when WebView is used) | |
| // Step 6: Confirm payment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 3bb4277
| // 6. Confirm payment | ||
|
|
||
| // 6. Confirm payment (no collectedData when WebView is used) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // 6. Confirm payment (no collectedData when WebView is used) | |
| // 6. Confirm payment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 3bb4277
| ``` | ||
|
|
||
| ### Step 5: Handle Data Collection (Optional) | ||
| ### Step 5: Handle Data Collection via WebView (Optional) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ### Step 5: Handle Data Collection via WebView (Optional) | |
| ### Step 5: Handle Data Collection via WebView |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 3bb4277
| - **Handle errors**: Listen for `IC_ERROR` messages and display a user-facing error message with an option to retry | ||
| - **External links**: Open Terms & Conditions and Privacy Policy links in the system browser rather than navigating within the WebView | ||
| - **Domain restriction**: Only allow navigation to WalletConnect pay domains and HTTPS URLs | ||
| - **Back navigation**: Handle back/dismiss gracefully — confirm cancellation with the user before closing the WebView mid-flow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also add an item for devs to test how the app behaves when the keyboard is opened. If its not well handled, the keyboard could show above the inputs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added keyboard behavior testing item to best practices in 3bb4277
| pobAddress: "123 Main St, New York, NY 10001", | ||
| }; | ||
| const prefillBase64 = btoa(JSON.stringify(prefillData)); | ||
| const webViewUrl = `${options.collectData.url}?prefill=${prefillBase64}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const webViewUrl = `${options.collectData.url}?prefill=${prefillBase64}`; | |
| const webViewUrl = `${options.collectData.url}&prefill=${prefillBase64}`; |
I think the url already contains parameters so the prefix has to be added with &, only the first param is set with ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in react-native sample wallet we have this util code
function buildUrlWithPrefill(baseUrl: string): string {
const prefillJson = JSON.stringify(PREFILL_DATA);
const prefillBase64 = btoa(prefillJson);
if (baseUrl.includes('prefill=')) {
return baseUrl.replace(/prefill=([^&]*)/, `prefill=${prefillBase64}`);
}
const separator = baseUrl.includes('?') ? '&' : '?';
return `${baseUrl}${separator}prefill=${prefillBase64}`;
}
it checks if there is already ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 3bb4277 — updated all platforms to use proper URL builders that handle existing query parameters (Uri.buildUpon for Kotlin, URLComponents for Swift, Uri.replace for Flutter, separator check for JS/RN)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Applied the pattern across all platforms using platform-native URL builders in 3bb4277
- Remove Sdk-Name/Sdk-Version/Sdk-Platform headers (internal SDK use only) - Remove Client-Id header (internal use only) - Add optional App-Id header to all endpoints - Add url and schema fields to CollectData schema - Add account field to PaymentOption schema - Add networkIconUrl to AmountDisplay schema - Update confirm endpoint description (commitment point) - Update API-first page with Api-Key prerequisite and Sdk-* warning Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…nfirm example - Reorder API-first flow diagram: data collection now happens before option selection - Remove Sdk-* warning block from API-first page - Add tosConfirmed field to confirm payment request example Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… comments - Remove "(no collectedData when WebView is used)" from confirm payment step comments - Remove "(Optional)" from Flutter AI prompt WebView step heading - Add keyboard behavior testing to WebView best practices - Fix prefill URL construction to handle existing query parameters using platform-native URL builders (Uri.buildUpon for Kotlin, URLComponents for Swift, Uri.replace for Flutter, separator check for JS/RN) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tion Co-Authored-By: mirna@reown.com <mirna@reown.com>
| Yes. | ||
|
|
||
| Wallets that choose to implement custom UI assume responsibility for keeping their forms in sync with changes, which can introduce delays and potential jurisdictional blockers. Wallets also must ensure the user has accepted: | ||
| - [WalletConnect Terms and Conditions](https://walletconnect.com/terms) | ||
| - [WalletConnect Privacy Policy](https://walletconnect.com/privacy) | ||
|
|
||
| The required user information can be sent to WalletConnect using schema in the `collect_data` object. | ||
|
|
||
| We strongly recommend using the WebView-based flow over building custom native UI. Data collection requirements are driven by regulation and can evolve. The hosted WebView form is maintained and updated centrally so that wallets can automatically pick up changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Yes. | |
| Wallets that choose to implement custom UI assume responsibility for keeping their forms in sync with changes, which can introduce delays and potential jurisdictional blockers. Wallets also must ensure the user has accepted: | |
| - [WalletConnect Terms and Conditions](https://walletconnect.com/terms) | |
| - [WalletConnect Privacy Policy](https://walletconnect.com/privacy) | |
| The required user information can be sent to WalletConnect using schema in the `collect_data` object. | |
| We strongly recommend using the WebView-based flow over building custom native UI. Data collection requirements are driven by regulation and can evolve. The hosted WebView form is maintained and updated centrally so that wallets can automatically pick up changes. | |
| Yes, with a caveat. | |
| Wallets that choose to implement custom UI assume responsibility for keeping their forms in sync with these changes. When changes are rolled out, wallets must implement them immediately. If the provided data is not what is requested, users in the relevant jurisdiction(s) will be unable to pay until the custom integration is updated. The WebView approach eliminates this overhead and ensures a consistent, up-to-date experience with minimal integration effort. | |
| Wallets also must ensure the user has accepted: | |
| - [WalletConnect Terms and Conditions](https://walletconnect.com/terms) | |
| - [WalletConnect Privacy Policy](https://walletconnect.com/privacy) | |
| The required user information can be sent to WalletConnect using schema in the `collect_data` object. | |
| We strongly recommend using the WebView-based flow over building custom native UI. Data collection requirements are driven by regulation and can evolve. The hosted WebView form is maintained and updated centrally so that wallets can automatically pick up changes. |
| - Gateway | ||
| summary: Confirm a payment | ||
| description: This endpoint confirms a payment and submits it to the blockchain for processing. | ||
| description: "This endpoint confirms a payment and submits it to the blockchain for processing. This is the COMMITMENT point - after this succeeds, the payment is durable." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to say this. This is internal information. Looks like it came from our spec, I'll remove.
| description: "This endpoint confirms a payment and submits it to the blockchain for processing. This is the COMMITMENT point - after this succeeds, the payment is durable." | |
| description: "This endpoint confirms a payment and submits it to the blockchain for processing." |
Based on patterns from the WCPay SDK (Yttrium): payment link detection, action resolution, result submission, polling, retry strategy, data collection, and expiration handling. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
CollectDataActionmodel now usesurl(WebView URL) andschema(JSON schema) instead offieldsarrayconfirmPayment()no longer requirescollectedDataparameter when WebView is used — the WebView submits data directlyPaymentResultInfomodel added toConfirmPaymentResponsewithtxIdandoptionAmountFiles Changed
snippets/webview-data-collection-*.mdxpayments/wallets/standalone/{kotlin,swift,react-native,flutter}.mdxpayments/wallets/walletkit/{kotlin,swift,flutter,web}.mdxpayments/wallets/walletkit/ai-prompts/{kotlin,swift,flutter,react-native}.mdxpayments/wallets/{overview,api-first}.mdxWhat changed in each doc
flowchart TD A[Payment Options Response] --> B{collectDataAction.url present?} B -->|Yes| C[Display WebView] B -->|No| D[Skip to Confirm] C --> E[User fills form in WebView] E --> F{JS Bridge Message} F -->|IC_COMPLETE| G[Proceed to confirmPayment - no collectedData needed] F -->|IC_ERROR| H[Show error, allow retry] G --> I[Payment Complete]WebView, iOSWKWebView, Flutterwebview_flutter, RNreact-native-webview)CollectDataAction→{url, schema}, removedCollectDataField/CollectDataFieldTypeCollectingDatastate →WebViewDataCollection, addedonWebViewComplete()/onWebViewError()handlersPlatform-Specific Bridge Names
android.webkit.WebViewAndroidWalletWKWebViewpayDataCollectionCompletewebview_flutter(4.10+)ReactNativeWebView(via JS bridge)react-native-webview(13.16+)ReactNativeWebView(native)Updates since last revision
Added three FAQ entries to
payments/wallets/overview.mdx:collect_dataschema.Review & Testing Checklist for Human
payments/wallets/overview.mdxrender correctly (AccordionGroup items) — runmint devand check the overview pageTest Plan
mint devlocally/payments/wallets/overviewand expand each FAQ accordionNotes