Skip to content

fix(SettlementTerm): open enum for acceptedPaymentMethods + add UPI, PAYMENT_URL#52

Open
ameetdesh wants to merge 1 commit into
beckn:mainfrom
ameetdesh:feat/settlement-term-open-payment-methods
Open

fix(SettlementTerm): open enum for acceptedPaymentMethods + add UPI, PAYMENT_URL#52
ameetdesh wants to merge 1 commit into
beckn:mainfrom
ameetdesh:feat/settlement-term-open-payment-methods

Conversation

@ameetdesh

Copy link
Copy Markdown

Problem

acceptedPaymentMethods used additionalProperties: true on a type: string item to signal extensibility, but this is a no-op in JSON Schema — that keyword only applies to objects, not strings. Validators correctly enforced the two-value enum [CASH_DEPOSIT, BANK_TRANSFER] and rejected any extension values (e.g. "UPI").

Fix

Switch to the standard open-enum pattern using anyOf:

items:
  anyOf:
  - type: string
    enum: [CASH_DEPOSIT, BANK_TRANSFER, UPI, PAYMENT_URL]
  - type: string          # allows any extension value

This means:

  • The known values are still documented and discoverable
  • Any string not in the enum also passes validation (true extensibility)

New enum values

Value When to use
UPI Payment via UPI — pairs with payTo.vpa (e.g. "sellerplatform@hdfc")
PAYMENT_URL Hosted checkout page — pairs with payTo.paymentUrl; gateway handles method selection

Relationship to payTo variants

payTo.accountNumber  →  acceptedPaymentMethods: ["BANK_TRANSFER"]
payTo.vpa            →  acceptedPaymentMethods: ["UPI"]
payTo.paymentUrl     →  acceptedPaymentMethods: ["PAYMENT_URL"] or multiple

🤖 Generated with Claude Code

…PAYMENT_URL

The previous `additionalProperties: true` on a `type: string` item was a no-op
— that keyword applies only to objects, not strings. Validators correctly
enforced the two-value enum and rejected any extension values (e.g. "UPI").

Switch to the standard open-enum pattern via anyOf:
  - branch 1: string restricted to the known set [CASH_DEPOSIT, BANK_TRANSFER, UPI, PAYMENT_URL]
  - branch 2: plain string, allowing any extension value to pass validation

New enum values added:
  - UPI  — payment via UPI VPA (pairs with payTo.vpa)
  - PAYMENT_URL — hosted checkout URL handling multiple methods (pairs with payTo.paymentUrl)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ravi-prakash-v

Copy link
Copy Markdown
Contributor

@ameetdesh A better way would be to update this schema - https://github.com/beckn/schemas/blob/main/schema/AcceptedPaymentMethod/v2.0/attributes.yaml, and use a $ref in SettlementTerm to refer to this.

In fact it wouldn't hurt to alias this to just PaymentMethod instead of prefixing it with "Accepted" and deprecate it eventually.

If there are no schemas referring to this currently, we can directly do a rename and push.

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.

2 participants