Skip to content

fix(ios): label the Apple Pay total with the merchant name - #34

Open
jkasprzyk17 wants to merge 1 commit into
mainfrom
fix/apple-pay-total-label
Open

jkasprzyk17 wants to merge 1 commit into
mainfrom
fix/apple-pay-total-label

Conversation

@jkasprzyk17

@jkasprzyk17 jkasprzyk17 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • iOS: always append the Apple Pay total item, labelled with merchantName, also for a one-item cart. Before, a single item became the total ("Pay Coffee"), and a cart with several items and no merchantName read "Pay Total".
  • If merchantName is missing or blank, the total uses the app's display name (CFBundleDisplayName, then CFBundleName). No configuration produces "Pay Total" or "Pay " anymore.
  • Fix the merchantName JSDoc (it is not "primarily Google Pay"), document the total line, and set merchantName in every README/docs/example snippet. Examples that passed a "Total" item now pass a real line item.
  • The total type from the items (point 4 of Apple Pay sheet total is labelled with the item name or "Total" instead of the merchant #19) already landed in fix(android): send valid Google Pay display items and estimated totals #28, so this PR doesn't change it.

Test plan

  • cd package && bun run typecheck (pass)
  • cd package && bun run lint (pass; changed files also pass --max-warnings 0)
  • cd package && bun run test (7 suites, 89 tests pass)
  • cd package && npx nitrogen (no diff)
  • bun run docs:build (pass)
  • cd example && npx expo prebuild && xcodebuild for the iOS simulator (pass), then checked the Apple Pay sheet on an iPhone 17 Pro simulator (iOS 26.5):
    • one item + merchantName: button "Pay React Native Pay Demo, 19,99 US$"; summary "Custom Item 19,99", then the total
    • several items, no merchantName: button "Pay example, 5,49 US$" (app display name); summary Coffee 4,99, Tax 0,50, then the total 5,49
  • XCTest for the summary-item builder (no iOS test target yet, see Add native unit tests and native build jobs to CI #22)
  • cd example && bunx expo run:android (not run: no Kotlin changes)

Risk

  • iOS behavior change: apps that passed their own "Total" item now see it as a line item above the merchant total. The CHANGELOG and docs say to remove it.
  • No API change. merchantName stays optional.

Notes

  • In the expanded "Payment Summary", iOS 26 labels the last row "Total" itself. The merchant name appears in the header ("Merchant Name: …") and on the "Pay …" button.
  • Follow-up to consider, not changed here: since fix(android): send valid Google Pay display items and estimated totals #28, a cart with a pending item gets a .pending total. On iOS, Apple Pay then hides the total amount and shows "Amount Pending" instead of "Pay " (checked on the simulator). Google Pay's ESTIMATED still shows the amount.

Closes #19


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

PassKit shows the last summary item as the grand total ("Pay <label>").
A one-item cart sent that item as the total ("Pay Coffee"), and a cart
with several items and no merchantName read "Pay Total".

Always append a total item, labelled with merchantName, falling back to
CFBundleDisplayName, then CFBundleName, so the sheet never reads
"Pay Total" or "Pay <item>".

Document merchantName for both platforms and set it in every example.

Closes #19
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 18aaa354-5d4b-44c6-b330-24beb1006895
📥 Commits

Reviewing files that changed from the base of the PR and between 687bb48 and bb3aa95.

📒 Files selected for processing: 17
  • CHANGELOG.md
  • README.md
  • docs/docs/api/hybrid-payment-handler.md
  • docs/docs/api/types.md
  • docs/docs/api/use-payment-checkout.md
  • docs/docs/api/utils.md
  • docs/docs/examples.md
  • docs/docs/guides/dynamic-cart.md
  • docs/docs/guides/manual-flow.md
  • docs/docs/integrations/przelewy24.md
  • docs/docs/quick-start.md
  • docs/docs/setup/ios-apple-pay.md
  • example/app/(tabs)/index.tsx
  • package/ios/HybridPaymentHandler.swift
  • package/src/hooks/usePaymentCheckout.ts
  • package/src/types/Payment.ts
  • package/src/utils/paymentHelpers.ts

Included review availability: This review used your included allowance. 4 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.

📝 Summary

Summary by CodeRabbit

  • New Features

    • Apple Pay payment sheets now always display a merchant-labeled total, including single-item carts.
    • Merchant labels use the configured merchant name and fall back to the app’s display name when unavailable.
    • Caller-provided “Total” entries are treated as regular line items.
  • Documentation

    • Clarified merchant name behavior across checkout, payment requests, Apple Pay, and Google Pay.
    • Updated examples and setup guides to show merchant name configuration.
    • Clarified confirmed versus pending amounts in dynamic cart guidance.

The iOS payment summary now always appends a total item labeled with the merchant name or an app-name fallback. Documentation and examples describe this behavior and add merchantName to checkout and payment-request configurations.

Changes: Apple Pay total and merchant name

Layer / File(s) Summary
Build and document the Apple Pay total
package/ios/HybridPaymentHandler.swift, CHANGELOG.md, README.md, docs/docs/api/hybrid-payment-handler.md, docs/docs/api/types.md, docs/docs/setup/ios-apple-pay.md, docs/docs/guides/dynamic-cart.md
iOS now appends a final total item for single-item and multi-item payments. Its label uses the first nonblank value among merchantName, CFBundleDisplayName, CFBundleName, and the process name. The documentation describes the generated total and advises against adding a separate "Total" item.
Document and configure merchant names
package/src/hooks/usePaymentCheckout.ts, package/src/types/Payment.ts, package/src/utils/paymentHelpers.ts, example/app/(tabs)/index.tsx, README.md, docs/docs/api/*, docs/docs/examples.md, docs/docs/guides/manual-flow.md, docs/docs/integrations/przelewy24.md, docs/docs/quick-start.md
API descriptions explain where merchantName appears and document platform defaults. Checkout and payment-request examples now supply a merchant name.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: piotr-graczyk-dev

Merge Risk: ⚪ Minimal · up to bb3aa

The Apple Pay changes are mergeable with normal checks.

Pre-merge checks: Passed 4 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Linked Issues check Warning The Swift implementation satisfies the main behavior in #19. It always appends a total, skips blank merchantName values, uses CFBundleDisplayName and CFBundleName fallbacks, and avoids "Total"… Add an iOS XCTest target and automated tests for the summary-item builder. Cover one-item carts, multiple items, explicit merchantName, blank or missing merchantName, bundle-name fallbacks, and total type behavior.
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 5 files. (12 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title accurately describes the iOS Apple Pay total-labeling change and uses the required fix: prefix. It is 58 characters, which exceeds the ideal 50-character limit, but remains concise and descr…
Description check Passed The description clearly explains the Apple Pay total behavior, fallback logic, documentation updates, testing, risks, and scope. It is directly related to the changeset.
Out of Scope Changes check Passed The changed Swift code, changelog, JSDoc, README, documentation, and examples support the Apple Pay total-label objective in #19. The documentation about total item types clarifies behavior already de…
Security Check Passed No medium-, high-, or critical-severity vulnerability is introduced. The only security-relevant code change is in package/ios/HybridPaymentHandler.swift: it selects a display label from the request …
Full details: Title check

Explanation

The title accurately describes the iOS Apple Pay total-labeling change and uses the required fix: prefix. It is 58 characters, which exceeds the ideal 50-character limit, but remains concise and descriptive.

Full details: Out of Scope Changes check

Explanation

The changed Swift code, changelog, JSDoc, README, documentation, and examples support the Apple Pay total-label objective in #19. The documentation about total item types clarifies behavior already delivered in #28 and remains related to the requested payment-summary change. No unrelated product behavior is shown in the reviewed changes.

Full details: Security Check

Explanation

No medium-, high-, or critical-severity vulnerability is introduced. The only security-relevant code change is in package/ios/HybridPaymentHandler.swift: it selects a display label from the request merchant name or local bundle metadata and appends it to PKPaymentRequest.paymentSummaryItems. The label is passed to PassKit as UI text; it is not used in a shell, SQL, URL, file path, authorization, or deserialization sink. The existing amount validation still rejects invalid amounts and negative totals. The remaining changes are documentation or example configuration changes.

Full details: Linked Issues check

Explanation

The Swift implementation satisfies the main behavior in #19. It always appends a total, skips blank merchantName values, uses CFBundleDisplayName and CFBundleName fallbacks, and avoids "Total" and the item label. The JSDoc and examples also match this behavior. The required XCTest coverage for the summary-item builder remains absent. The test plan marks it unchecked, and the repository contains no iOS XCTest target or test file.

Resolution

Add an iOS XCTest target and automated tests for the summary-item builder. Cover one-item carts, multiple items, explicit merchantName, blank or missing merchantName, bundle-name fallbacks, and total type behavior.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 5 files. (12 skipped: 12 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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.

Apple Pay sheet total is labelled with the item name or "Total" instead of the merchant

1 participant