Skip to content

[COMSE-27] Example app: Cash App Pay on-file vs one-time grant mode toggle#296

Closed
noahjalex wants to merge 1 commit into
afterpay:masterfrom
noahjalex:nalexander/comse-27-sdk-ios-example-app-add-cash-app-pay-on-file-vs-one-time
Closed

[COMSE-27] Example app: Cash App Pay on-file vs one-time grant mode toggle#296
noahjalex wants to merge 1 commit into
afterpay:masterfrom
noahjalex:nalexander/comse-27-sdk-ios-example-app-add-cash-app-pay-on-file-vs-one-time

Conversation

@noahjalex
Copy link
Copy Markdown

🚧 Draft / WIP — pushed to avoid losing work; not yet ready for review.

Linear: COMSE-27

Summary

Adds a One-time / On-file segmented control to the Example app's cart so the V3 Cash App Pay flow can request either PayKit grant type. Both modes hit the same Afterpay V3 CAP endpoints (POST /v3/button, /v2/payments/sign-payment, /v3/button/confirm); only the PayKit PaymentAction attached to the customer request differs:

  • .oneTimePayment(scopeID:, money:) — current behavior, single-use authorization.
  • .onFilePayment(scopeID:, accountReferenceID:) — grant suitable for on-file storage / merchant-initiated transactions.

This is purely Example-app plumbing for support / validation work — no changes to the public Afterpay SDK API.

Changes

  • Example/Example/Purchase/ButtonCashAppPayCheckout.swift
    • New CashAppPayMode enum (.oneTime / .onFile).
    • checkoutV3(consumer:cartTotal:mode:) stores the selected mode and threads it through createCustomerRequest, which now branches the PaymentAction.
    • NSLog("[CAP-AP] …") traces across checkoutV3, customer-request creation, PayKit state changes, approval, and confirmCheckout.
  • Example/Example/Purchase/CartViewController.swift
    • UISegmentedControl ("One-time" / "On-file") above the V3-CAP button; hidden whenever the V3-CAP button is hidden.
    • New event payload Event.didTapSingleUseCardButtonWithCashAppPay(CashAppPayMode).
  • Example/Example/Purchase/PurchaseFlowController.swift / PurchaseLogicController.swift
    • Pass mode through to payWithAfterpayV3WithCashAppPay(mode:).

Out of scope

  • Public SDK surface (Afterpay.checkoutV3WithCashAppPay / checkoutV3ConfirmForCashAppPay) is unchanged.
  • Recurring/MIT capture flow (this PR only validates the grant; capture is server-side).

Test plan (not yet executed)

  • Run Example app, switch checkout option to V3, toggle mode = One-time, confirm Cash App Pay flow completes (existing path).
  • Toggle mode = On-file, confirm PayKit returns an approved customer request whose grant.action is onFilePayment and that /v3/button/confirm succeeds.
  • Inspect [CAP-AP] logs for both modes.

…oggle

Add a UISegmentedControl to the cart screen so the V3 Cash App Pay flow
can request either a `.oneTimePayment` (current behavior) or
`.onFilePayment` PayKit grant. Both modes use the same Afterpay V3 CAP
endpoints — only the PayKit PaymentAction differs.

- ButtonCashAppPayCheckout: new CashAppPayMode enum, branched
  PaymentAction in createCustomerRequest, NSLog tracing across the
  checkoutV3 / customer-request / approval / confirm steps.
- CartViewController: One-time / On-file segmented control, only shown
  with the V3-CAP button; threads selection through
  Event.didTapSingleUseCardButtonWithCashAppPay(CashAppPayMode).
- PurchaseFlowController / PurchaseLogicController: forward mode to
  payWithAfterpayV3WithCashAppPay(mode:).

No SDK API changes. Draft — not ready for review.

Amp-Thread-ID: https://ampcode.com/threads/T-019de021-58ff-7799-b997-d3447d1abf2b
Co-authored-by: Amp <amp@ampcode.com>
@noahjalex noahjalex closed this by deleting the head repository Apr 30, 2026
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.

1 participant