From ea7c8c0a4ba19738140362ecdc3480222139bf75 Mon Sep 17 00:00:00 2001 From: "Panche I." Date: Wed, 12 Aug 2026 17:02:35 +0200 Subject: [PATCH] feat(pay): optional name/imageUrl on paymentLinks.create; expose on PaymentLink (2.1.0) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds optional `name` and `imageUrl` to CreatePaymentLinkParams and exposes them (nullable) on the PaymentLink response type. Purely additive — the server already accepts `name` and defaults it from `description` when omitted, so this is a non-breaking SDK change. Changeset marks it minor (2.0.0 -> 2.1.0) for @agentaos/pay. Co-Authored-By: Claude Opus 4.8 --- .changeset/paymentlink-name.md | 5 +++++ packages/pay/README.md | 3 +++ .../src/resources/create-request-body.test.ts | 18 ++++++++++++++++++ packages/pay/src/resources/resources.test.ts | 9 +++++++++ packages/pay/src/types.ts | 10 ++++++++++ 5 files changed, 45 insertions(+) create mode 100644 .changeset/paymentlink-name.md diff --git a/.changeset/paymentlink-name.md b/.changeset/paymentlink-name.md new file mode 100644 index 0000000..4a7f90a --- /dev/null +++ b/.changeset/paymentlink-name.md @@ -0,0 +1,5 @@ +--- +"@agentaos/pay": minor +--- + +Add optional `name` (and `imageUrl`) to `paymentLinks.create`, and expose `name`/`imageUrl` on the `PaymentLink` type. diff --git a/packages/pay/README.md b/packages/pay/README.md index 06e7eaf..9574336 100644 --- a/packages/pay/README.md +++ b/packages/pay/README.md @@ -137,6 +137,7 @@ const link = await agentaos.paymentLinks.create({ amount: 29.99, currency: 'EUR', description: 'Pro plan', + name: 'Pro Plan', // shown in the dashboard's Products grid; defaults from `description` if omitted successUrl: 'https://shop.com/success', cancelUrl: 'https://shop.com/cancel', webhookUrl: 'https://shop.com/webhooks', @@ -173,6 +174,8 @@ const subscription = await agentaos.paymentLinks.create({ | `checkoutUrl` | `string` | Shareable payment URL | | `amount` | `number` | Payment amount | | `currency` | `string` | Settlement currency | +| `name` | `string \| null` | Product name shown in the dashboard's Products grid | +| `imageUrl` | `string \| null` | Product thumbnail shown in the dashboard's Products grid | | `status` | `'active' \| 'cancelled'` | Link status | | `sellerMode` | `'mor' \| 'crypto'` | How this link settles | | `type` | `'one_time' \| 'subscription'` | Link type | diff --git a/packages/pay/src/resources/create-request-body.test.ts b/packages/pay/src/resources/create-request-body.test.ts index b9e8538..f73b9fd 100644 --- a/packages/pay/src/resources/create-request-body.test.ts +++ b/packages/pay/src/resources/create-request-body.test.ts @@ -70,4 +70,22 @@ describe('create forwards the new additive fields', () => { await new AgentaOS('sk_test_x').checkouts.create({ amount: 10, dueDate: '2026-09-30' }); expect(bodies[0]?.dueDate).toBe('2026-09-30'); }); + + it('paymentLinks.create forwards name and imageUrl', async () => { + const bodies = captureRequestBodies(); + await new AgentaOS('sk_test_x').paymentLinks.create({ + amount: 29.99, + name: 'Pro Plan', + imageUrl: 'https://cdn.example.com/pro-plan.png', + }); + expect(bodies[0]?.name).toBe('Pro Plan'); + expect(bodies[0]?.imageUrl).toBe('https://cdn.example.com/pro-plan.png'); + }); + + it('paymentLinks.create omits name and imageUrl when not provided', async () => { + const bodies = captureRequestBodies(); + await new AgentaOS('sk_test_x').paymentLinks.create({ amount: 29.99 }); + expect(bodies[0]).not.toHaveProperty('name'); + expect(bodies[0]).not.toHaveProperty('imageUrl'); + }); }); diff --git a/packages/pay/src/resources/resources.test.ts b/packages/pay/src/resources/resources.test.ts index e077bda..207999c 100644 --- a/packages/pay/src/resources/resources.test.ts +++ b/packages/pay/src/resources/resources.test.ts @@ -110,6 +110,15 @@ describe('paymentLinks', () => { expect(calls[0]?.method).toBe('DELETE'); expect(pathOf(calls[0])).toBe('/api/v1/gateway/payment-links/pl_9'); }); + + it('camelizes the create response, including name and image_url', async () => { + stubRoutes({ id: 'pl_1', name: 'Pro Plan', image_url: 'https://cdn.example.com/pro-plan.png' }); + const link = await client().paymentLinks.create({ amount: 29.99 }); + expect(link).toMatchObject({ + name: 'Pro Plan', + imageUrl: 'https://cdn.example.com/pro-plan.png', + }); + }); }); describe('transactions', () => { diff --git a/packages/pay/src/types.ts b/packages/pay/src/types.ts index c840cf9..9c6a428 100644 --- a/packages/pay/src/types.ts +++ b/packages/pay/src/types.ts @@ -71,6 +71,12 @@ export interface CreatePaymentLinkParams { /** 'EUR' | 'USD', default from org settings */ currency?: string; description?: string; + /** Product name shown in the dashboard's Products grid. Optional — if omitted, + * the server defaults it from `description`. Set it to give the link a clean + * product title. */ + name?: string; + /** Product thumbnail shown in the dashboard's Products grid. */ + imageUrl?: string; /** HTTPS only */ webhookUrl?: string; /** HTTPS only */ @@ -95,6 +101,10 @@ export interface PaymentLink { amount: number; currency: string; description: string | null; + /** Product name shown in the dashboard's Products grid. Defaults from `description` when not set. */ + name: string | null; + /** Product thumbnail shown in the dashboard's Products grid. */ + imageUrl: string | null; status: 'active' | 'cancelled'; /** Settlement mode: 'mor' (card + bank) or 'crypto' (on-chain to your wallet). */ sellerMode: 'mor' | 'crypto';