Skip to content

Commit 2841671

Browse files
feat(api): api update
1 parent 3630df1 commit 2841671

File tree

8 files changed

+67
-15
lines changed

8 files changed

+67
-15
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 139
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-6b1440d47f0b1b1b92f2e40f9ad5efd301d90f66e2e05c5a932902608935aa64.yml
3-
openapi_spec_hash: 14f386604d0d87d9459352b8a7b84eff
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-ebac75191b7fecb0dc03df5b9eeb62d99811905552ddc2a2bd5a7a77dbfe00d3.yml
3+
openapi_spec_hash: 1b96488643f8c4bc07ea184aa2505ca7
44
config_hash: c01c1191b1cd696c7ca855ff6d28a8df

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ Methods:
370370
- <code title="post /invoices/summary/{invoice_id}/issue">client.invoices.<a href="./src/resources/invoices.ts">issueSummary</a>(invoiceId, { ...params }) -> InvoiceIssueSummaryResponse</code>
371371
- <code title="get /invoices/summary">client.invoices.<a href="./src/resources/invoices.ts">listSummary</a>({ ...params }) -> InvoiceListSummaryResponsesPage</code>
372372
- <code title="post /invoices/{invoice_id}/mark_paid">client.invoices.<a href="./src/resources/invoices.ts">markPaid</a>(invoiceId, { ...params }) -> Invoice</code>
373-
- <code title="post /invoices/{invoice_id}/pay">client.invoices.<a href="./src/resources/invoices.ts">pay</a>(invoiceId) -> Invoice</code>
373+
- <code title="post /invoices/{invoice_id}/pay">client.invoices.<a href="./src/resources/invoices.ts">pay</a>(invoiceId, { ...params }) -> Invoice</code>
374374
- <code title="post /invoices/{invoice_id}/void">client.invoices.<a href="./src/resources/invoices.ts">void</a>(invoiceId) -> Invoice</code>
375375

376376
# Items

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
InvoiceListSummaryResponse,
4545
InvoiceListSummaryResponsesPage,
4646
InvoiceMarkPaidParams,
47+
InvoicePayParams,
4748
InvoiceUpdateParams,
4849
Invoices,
4950
} from './resources/invoices';
@@ -614,6 +615,7 @@ export declare namespace Orb {
614615
type InvoiceIssueSummaryParams as InvoiceIssueSummaryParams,
615616
type InvoiceListSummaryParams as InvoiceListSummaryParams,
616617
type InvoiceMarkPaidParams as InvoiceMarkPaidParams,
618+
type InvoicePayParams as InvoicePayParams,
617619
};
618620

619621
export {

src/resources/customers/customers.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,13 @@ export namespace Customer {
543543
*/
544544
provider_type: 'stripe';
545545

546+
/**
547+
* The ID of a shared payment token granted by an agent to use as the default
548+
* payment instrument for this customer. When set, auto-collection will use this
549+
* token instead of the customer's default payment method.
550+
*/
551+
default_shared_payment_token?: string | null;
552+
546553
/**
547554
* List of Stripe payment method types to exclude for this customer. Excluded
548555
* payment methods will not be available for the customer to select during payment,
@@ -902,6 +909,13 @@ export namespace CustomerCreateParams {
902909
*/
903910
provider_type: 'stripe';
904911

912+
/**
913+
* The ID of a shared payment token granted by an agent to use as the default
914+
* payment instrument for this customer. When set, auto-collection will use this
915+
* token instead of the customer's default payment method.
916+
*/
917+
default_shared_payment_token?: string | null;
918+
905919
/**
906920
* List of Stripe payment method types to exclude for this customer. Excluded
907921
* payment methods will not be available for the customer to select during payment,
@@ -1230,6 +1244,13 @@ export namespace CustomerUpdateParams {
12301244
*/
12311245
provider_type: 'stripe';
12321246

1247+
/**
1248+
* The ID of a shared payment token granted by an agent to use as the default
1249+
* payment instrument for this customer. When set, auto-collection will use this
1250+
* token instead of the customer's default payment method.
1251+
*/
1252+
default_shared_payment_token?: string | null;
1253+
12331254
/**
12341255
* List of Stripe payment method types to exclude for this customer. Excluded
12351256
* payment methods will not be available for the customer to select during payment,
@@ -1568,6 +1589,13 @@ export namespace CustomerUpdateByExternalIDParams {
15681589
*/
15691590
provider_type: 'stripe';
15701591

1592+
/**
1593+
* The ID of a shared payment token granted by an agent to use as the default
1594+
* payment instrument for this customer. When set, auto-collection will use this
1595+
* token instead of the customer's default payment method.
1596+
*/
1597+
default_shared_payment_token?: string | null;
1598+
15711599
/**
15721600
* List of Stripe payment method types to exclude for this customer. Excluded
15731601
* payment methods will not be available for the customer to select during payment,

src/resources/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export {
9696
type InvoiceIssueSummaryParams,
9797
type InvoiceListSummaryParams,
9898
type InvoiceMarkPaidParams,
99+
type InvoicePayParams,
99100
} from './invoices';
100101
export {
101102
ItemsPage,

src/resources/invoices.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,17 @@ export class Invoices extends APIResource {
214214
}
215215

216216
/**
217-
* This endpoint collects payment for an invoice using the customer's default
218-
* payment method. This action can only be taken on invoices with status "issued".
217+
* This endpoint collects payment for an invoice. By default, it uses the
218+
* customer's default payment method. Optionally, a shared payment token (SPT) can
219+
* be provided to pay using agent-granted credentials instead. This action can only
220+
* be taken on invoices with status "issued".
219221
*/
220-
pay(invoiceId: string, options?: Core.RequestOptions): Core.APIPromise<Shared.Invoice> {
221-
return this._client.post(`/invoices/${invoiceId}/pay`, options);
222+
pay(
223+
invoiceId: string,
224+
body: InvoicePayParams,
225+
options?: Core.RequestOptions,
226+
): Core.APIPromise<Shared.Invoice> {
227+
return this._client.post(`/invoices/${invoiceId}/pay`, { body, ...options });
222228
}
223229

224230
/**
@@ -2002,6 +2008,13 @@ export interface InvoiceMarkPaidParams {
20022008
notes?: string | null;
20032009
}
20042010

2011+
export interface InvoicePayParams {
2012+
/**
2013+
* The ID of a shared payment token granted by an agent to use for this payment.
2014+
*/
2015+
shared_payment_token_id: string;
2016+
}
2017+
20052018
Invoices.InvoiceListSummaryResponsesPage = InvoiceListSummaryResponsesPage;
20062019

20072020
export declare namespace Invoices {
@@ -2018,6 +2031,7 @@ export declare namespace Invoices {
20182031
type InvoiceIssueSummaryParams as InvoiceIssueSummaryParams,
20192032
type InvoiceListSummaryParams as InvoiceListSummaryParams,
20202033
type InvoiceMarkPaidParams as InvoiceMarkPaidParams,
2034+
type InvoicePayParams as InvoicePayParams,
20212035
};
20222036
}
20232037

tests/api-resources/customers/customers.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ describe('resource customers', () => {
4747
hierarchy: { child_customer_ids: ['string'], parent_customer_id: 'parent_customer_id' },
4848
metadata: { foo: 'string' },
4949
payment_configuration: {
50-
payment_providers: [{ provider_type: 'stripe', excluded_payment_method_types: ['string'] }],
50+
payment_providers: [
51+
{
52+
provider_type: 'stripe',
53+
default_shared_payment_token: 'default_shared_payment_token',
54+
excluded_payment_method_types: ['string'],
55+
},
56+
],
5157
},
5258
payment_provider: 'quickbooks',
5359
payment_provider_id: 'payment_provider_id',

tests/api-resources/invoices.test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,10 @@ describe('resource invoices', () => {
300300
});
301301
});
302302

303-
test('pay', async () => {
304-
const responsePromise = client.invoices.pay('invoice_id');
303+
test('pay: only required params', async () => {
304+
const responsePromise = client.invoices.pay('invoice_id', {
305+
shared_payment_token_id: 'shared_payment_token_id',
306+
});
305307
const rawResponse = await responsePromise.asResponse();
306308
expect(rawResponse).toBeInstanceOf(Response);
307309
const response = await responsePromise;
@@ -311,11 +313,10 @@ describe('resource invoices', () => {
311313
expect(dataAndResponse.response).toBe(rawResponse);
312314
});
313315

314-
test('pay: request options instead of params are passed correctly', async () => {
315-
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
316-
await expect(client.invoices.pay('invoice_id', { path: '/_stainless_unknown_path' })).rejects.toThrow(
317-
Orb.NotFoundError,
318-
);
316+
test('pay: required and optional params', async () => {
317+
const response = await client.invoices.pay('invoice_id', {
318+
shared_payment_token_id: 'shared_payment_token_id',
319+
});
319320
});
320321

321322
test('void', async () => {

0 commit comments

Comments
 (0)