Skip to content

fix(payment-square): validate refund amount money#812

Merged
ralyodio merged 1 commit into
profullstack:masterfrom
aiirvizionz:clientkit/square-refund-amount-money
Jul 22, 2026
Merged

fix(payment-square): validate refund amount money#812
ralyodio merged 1 commit into
profullstack:masterfrom
aiirvizionz:clientkit/square-refund-amount-money

Conversation

@aiirvizionz

Copy link
Copy Markdown
Contributor

Summary

  • validate Square refund amounts and currencies before calling the API
  • send refund amount_money as a normalized { amount, currency } object instead of passing raw config
  • add coverage for valid refund payloads and invalid refund amounts

Verification

  • vitest run packages/targets/payment-square/src/index.test.ts (8 passed)
  • tsc -p packages/targets/payment-square/tsconfig.json --noEmit
  • git diff --check

Note: running through pnpm in this workspace currently triggers an unrelated lockfile policy failure for @profullstack/autoblog@0.4.0 missing tarball integrity, so I ran the local Vitest and TypeScript binaries directly.

Copilot AI review requested due to automatic review settings July 21, 2026 22:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the Square payment target’s refund command by validating refund amount_money inputs before calling Square and ensuring the refund payload matches Square’s expected Money shape.

Changes:

  • Validate refund amount as a positive integer and normalize currency to a 3-letter uppercase ISO code.
  • Send amount_money as { amount, currency } for refunds (consistent with create).
  • Add Vitest coverage for a valid refund payload and for rejecting invalid refund amounts before any API call.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/targets/payment-square/src/index.ts Adds refund amount/currency validation and normalizes amount_money payload.
packages/targets/payment-square/src/index.test.ts Adds tests covering validated refund payloads and invalid refund amount rejection.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

payment_id: id,
amount_money: config.args?.amount,
amount_money: { amount, currency },
reason: (config.args?.reason as string) || 'requested_by_customer',
@github-actions

Copy link
Copy Markdown

🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: git fetch upstream master && git rebase upstream/master.

@ralyodio
ralyodio merged commit 42b6520 into profullstack:master Jul 22, 2026
4 checks passed
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.

3 participants