Skip to content

demo(payments): enforce policy before signing#97

Open
EfeDurmaz16 wants to merge 2 commits into
agentcommercekit:mainfrom
EfeDurmaz16:demo/ack-pay-policy-before-signing
Open

demo(payments): enforce policy before signing#97
EfeDurmaz16 wants to merge 2 commits into
agentcommercekit:mainfrom
EfeDurmaz16:demo/ack-pay-policy-before-signing

Conversation

@EfeDurmaz16
Copy link
Copy Markdown

Summary

  • Add a tiny local payment policy guard for the payments demo
  • Enforce policy after payment request verification but before returning an execution URL or signing the receipt-service payload
  • Cover approved, approval-required, and denied policy outcomes with focused tests
  • Document that this is an example pattern, not a normative ACK-Pay policy engine

Fixes #91

Verification

  • pnpm --filter ./demos/payments check:types
  • pnpm --filter ./demos/payments exec vitest run
  • pnpm exec oxfmt --check demos/payments/README.md demos/payments/src/payment-policy.ts demos/payments/src/payment-policy.test.ts demos/payments/src/payment-service.ts
  • git diff --check

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

Warning

Rate limit exceeded

@EfeDurmaz16 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 16 minutes and 51 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ccddbb7d-3825-45bf-8ee1-6baf323befb6

📥 Commits

Reviewing files that changed from the base of the PR and between 6f65936 and f0f5df8.

📒 Files selected for processing (4)
  • demos/payments/README.md
  • demos/payments/src/payment-policy.test.ts
  • demos/payments/src/payment-policy.ts
  • demos/payments/src/payment-service.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 264bbd2bf0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread demos/payments/src/payment-service.ts Outdated
const decision = evaluatePaymentPolicy(paymentOption, {
allowedRecipients: [],
maxAutonomousAmount: 1_000_000,
trustedRequestIssuer,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not trust each request's own issuer

When this payment service is reachable by any client, a third party can submit a valid PaymentRequest JWT it signed itself with a Stripe option whose recipient is that same DID; because trustedRequestIssuer is set from the token's own parsed.issuer, the empty allowlist is bypassed and the service will return a payment URL and later sign the receipt-service payload for an unapproved merchant. The policy should compare against a configured trusted server/merchant DID or explicit allowlist, not the self-asserted issuer from the request being evaluated.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in f0f5df8 by removing approval based on the Payment Request token’s own issuer. The demo now derives the autonomous recipient allowlist from the configured server identity and keeps self-asserted recipients in approval_required unless explicitly allowlisted.\n\nVerification:\n- pnpm --filter ./demos/payments test -- payment-policy.test.ts\n- pnpm exec oxfmt --check demos/payments/README.md demos/payments/src/payment-policy.ts demos/payments/src/payment-policy.test.ts demos/payments/src/payment-service.ts\n- git diff --check\n\nI also tried pnpm --filter ./demos/payments check:types, but this checkout currently fails to resolve the workspace agentcommercekit package and reports existing demo type errors outside this change.

Signed-off-by: EfeDurmaz16 <efebarandurmaz05@gmail.com>
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.

demo(ack-pay): show policy-before-signing enforcement

1 participant