@metronome/sdk 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +65 -0
- package/bin/cli +5 -12
- package/internal/to-file.d.mts +1 -1
- package/internal/to-file.d.ts +1 -1
- package/internal/to-file.js +1 -1
- package/internal/to-file.mjs +1 -1
- package/package.json +1 -1
- package/resources/shared.d.mts +129 -5
- package/resources/shared.d.mts.map +1 -1
- package/resources/shared.d.ts +129 -5
- package/resources/shared.d.ts.map +1 -1
- package/resources/v1/alerts.d.mts +68 -64
- package/resources/v1/alerts.d.mts.map +1 -1
- package/resources/v1/alerts.d.ts +68 -64
- package/resources/v1/alerts.d.ts.map +1 -1
- package/resources/v1/alerts.js +40 -39
- package/resources/v1/alerts.js.map +1 -1
- package/resources/v1/alerts.mjs +40 -39
- package/resources/v1/alerts.mjs.map +1 -1
- package/resources/v1/contracts/contracts.d.mts +28 -6
- package/resources/v1/contracts/contracts.d.mts.map +1 -1
- package/resources/v1/contracts/contracts.d.ts +28 -6
- package/resources/v1/contracts/contracts.d.ts.map +1 -1
- package/resources/v1/contracts/contracts.js +4 -3
- package/resources/v1/contracts/contracts.js.map +1 -1
- package/resources/v1/contracts/contracts.mjs +4 -3
- package/resources/v1/contracts/contracts.mjs.map +1 -1
- package/resources/v1/customers/alerts.d.mts +98 -77
- package/resources/v1/customers/alerts.d.mts.map +1 -1
- package/resources/v1/customers/alerts.d.ts +98 -77
- package/resources/v1/customers/alerts.d.ts.map +1 -1
- package/resources/v1/customers/alerts.js +65 -46
- package/resources/v1/customers/alerts.js.map +1 -1
- package/resources/v1/customers/alerts.mjs +65 -46
- package/resources/v1/customers/alerts.mjs.map +1 -1
- package/resources/v1/customers/customers.d.mts +17 -16
- package/resources/v1/customers/customers.d.mts.map +1 -1
- package/resources/v1/customers/customers.d.ts +17 -16
- package/resources/v1/customers/customers.d.ts.map +1 -1
- package/resources/v1/customers/customers.js +7 -4
- package/resources/v1/customers/customers.js.map +1 -1
- package/resources/v1/customers/customers.mjs +7 -4
- package/resources/v1/customers/customers.mjs.map +1 -1
- package/resources/v1/customers/index.d.mts +1 -1
- package/resources/v1/customers/index.d.mts.map +1 -1
- package/resources/v1/customers/index.d.ts +1 -1
- package/resources/v1/customers/index.d.ts.map +1 -1
- package/resources/v1/customers/index.js.map +1 -1
- package/resources/v1/customers/index.mjs.map +1 -1
- package/resources/v1/customers/invoices.d.mts +117 -2
- package/resources/v1/customers/invoices.d.mts.map +1 -1
- package/resources/v1/customers/invoices.d.ts +117 -2
- package/resources/v1/customers/invoices.d.ts.map +1 -1
- package/resources/v1/customers/invoices.js +49 -0
- package/resources/v1/customers/invoices.js.map +1 -1
- package/resources/v1/customers/invoices.mjs +49 -0
- package/resources/v1/customers/invoices.mjs.map +1 -1
- package/resources/v1/index.d.mts +1 -0
- package/resources/v1/index.d.mts.map +1 -1
- package/resources/v1/index.d.ts +1 -0
- package/resources/v1/index.d.ts.map +1 -1
- package/resources/v1/index.js +3 -1
- package/resources/v1/index.js.map +1 -1
- package/resources/v1/index.mjs +1 -0
- package/resources/v1/index.mjs.map +1 -1
- package/resources/v1/payments.d.mts +116 -0
- package/resources/v1/payments.d.mts.map +1 -0
- package/resources/v1/payments.d.ts +116 -0
- package/resources/v1/payments.d.ts.map +1 -0
- package/resources/v1/payments.js +71 -0
- package/resources/v1/payments.js.map +1 -0
- package/resources/v1/payments.mjs +67 -0
- package/resources/v1/payments.mjs.map +1 -0
- package/resources/v1/usage.d.mts +4 -2
- package/resources/v1/usage.d.mts.map +1 -1
- package/resources/v1/usage.d.ts +4 -2
- package/resources/v1/usage.d.ts.map +1 -1
- package/resources/v1/usage.js +4 -2
- package/resources/v1/usage.js.map +1 -1
- package/resources/v1/usage.mjs +4 -2
- package/resources/v1/usage.mjs.map +1 -1
- package/resources/v1/v1.d.mts +4 -0
- package/resources/v1/v1.d.mts.map +1 -1
- package/resources/v1/v1.d.ts +4 -0
- package/resources/v1/v1.d.ts.map +1 -1
- package/resources/v1/v1.js +4 -0
- package/resources/v1/v1.js.map +1 -1
- package/resources/v1/v1.mjs +4 -0
- package/resources/v1/v1.mjs.map +1 -1
- package/resources/v2/contracts.d.mts +109 -3
- package/resources/v2/contracts.d.mts.map +1 -1
- package/resources/v2/contracts.d.ts +109 -3
- package/resources/v2/contracts.d.ts.map +1 -1
- package/src/internal/to-file.ts +1 -1
- package/src/resources/shared.ts +160 -5
- package/src/resources/v1/alerts.ts +68 -64
- package/src/resources/v1/contracts/contracts.ts +32 -6
- package/src/resources/v1/customers/alerts.ts +98 -77
- package/src/resources/v1/customers/customers.ts +18 -15
- package/src/resources/v1/customers/index.ts +1 -0
- package/src/resources/v1/customers/invoices.ts +142 -1
- package/src/resources/v1/index.ts +11 -0
- package/src/resources/v1/payments.ts +170 -0
- package/src/resources/v1/usage.ts +4 -2
- package/src/resources/v1/v1.ts +26 -0
- package/src/resources/v2/contracts.ts +144 -3
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
InvoiceListBreakdownsResponsesCursorPage,
|
|
49
49
|
InvoiceListParams,
|
|
50
50
|
InvoiceRetrieveParams,
|
|
51
|
+
InvoiceRetrievePdfParams,
|
|
51
52
|
InvoiceRetrieveResponse,
|
|
52
53
|
Invoices,
|
|
53
54
|
InvoicesCursorPage,
|
|
@@ -203,7 +204,7 @@ export class Customers extends APIResource {
|
|
|
203
204
|
* - Ingest aliases remain idempotent for archived customers. In order to reuse an
|
|
204
205
|
* ingest alias, first remove the ingest alias from the customer prior to
|
|
205
206
|
* archiving.
|
|
206
|
-
* - Any
|
|
207
|
+
* - Any notifications associated with the customer will no longer be triggered.
|
|
207
208
|
*
|
|
208
209
|
* @example
|
|
209
210
|
* ```ts
|
|
@@ -276,10 +277,10 @@ export class Customers extends APIResource {
|
|
|
276
277
|
}
|
|
277
278
|
|
|
278
279
|
/**
|
|
279
|
-
* Preview how a set of events will affect a customer's
|
|
280
|
-
*
|
|
280
|
+
* Preview how a set of events will affect a customer's invoices. Generates draft
|
|
281
|
+
* invoices for a customer using their current contract configuration and the
|
|
281
282
|
* provided events. This is useful for testing how new events will affect the
|
|
282
|
-
* customer's
|
|
283
|
+
* customer's invoices before they are actually processed.
|
|
283
284
|
*
|
|
284
285
|
* @example
|
|
285
286
|
* ```ts
|
|
@@ -340,6 +341,9 @@ export class Customers extends APIResource {
|
|
|
340
341
|
* through system A (e.g. Stripe) but will now be billed through system B (e.g.
|
|
341
342
|
* AWS). Once created, the new configuration can then be associated to the
|
|
342
343
|
* customer's contract.
|
|
344
|
+
* - Multiple configurations can be added per destination. For example, you can
|
|
345
|
+
* create two Stripe billing configurations for a Metronome customer that each
|
|
346
|
+
* have a distinct `collection_method`.
|
|
343
347
|
*
|
|
344
348
|
* ### Delivery method options:
|
|
345
349
|
*
|
|
@@ -546,6 +550,11 @@ export interface CustomerDetail {
|
|
|
546
550
|
|
|
547
551
|
name: string;
|
|
548
552
|
|
|
553
|
+
/**
|
|
554
|
+
* RFC 3339 timestamp indicating when the customer was last updated.
|
|
555
|
+
*/
|
|
556
|
+
updated_at: string;
|
|
557
|
+
|
|
549
558
|
/**
|
|
550
559
|
* RFC 3339 timestamp indicating when the customer was archived. Null if the
|
|
551
560
|
* customer is active.
|
|
@@ -691,7 +700,7 @@ export namespace CustomerListCostsResponse {
|
|
|
691
700
|
}
|
|
692
701
|
|
|
693
702
|
export interface CustomerPreviewEventsResponse {
|
|
694
|
-
data: InvoicesAPI.Invoice
|
|
703
|
+
data: Array<InvoicesAPI.Invoice>;
|
|
695
704
|
}
|
|
696
705
|
|
|
697
706
|
export interface CustomerRetrieveBillingConfigurationsResponse {
|
|
@@ -966,13 +975,6 @@ export namespace CustomerPreviewEventsParams {
|
|
|
966
975
|
export interface Event {
|
|
967
976
|
event_type: string;
|
|
968
977
|
|
|
969
|
-
/**
|
|
970
|
-
* This has no effect for preview events, but may be set for consistency with Event
|
|
971
|
-
* objects. They will be processed even if they do not match the customer's ID or
|
|
972
|
-
* ingest aliases.
|
|
973
|
-
*/
|
|
974
|
-
customer_id?: string;
|
|
975
|
-
|
|
976
978
|
properties?: { [key: string]: unknown };
|
|
977
979
|
|
|
978
980
|
/**
|
|
@@ -981,9 +983,9 @@ export namespace CustomerPreviewEventsParams {
|
|
|
981
983
|
timestamp?: string;
|
|
982
984
|
|
|
983
985
|
/**
|
|
984
|
-
*
|
|
985
|
-
*
|
|
986
|
-
* request.
|
|
986
|
+
* Optional unique identifier for event deduplication. When provided, preview
|
|
987
|
+
* events are automatically deduplicated against historical events from the past 34
|
|
988
|
+
* days. Duplicate transaction IDs within the same request will return an error.
|
|
987
989
|
*/
|
|
988
990
|
transaction_id?: string;
|
|
989
991
|
}
|
|
@@ -1165,6 +1167,7 @@ export declare namespace Customers {
|
|
|
1165
1167
|
type InvoiceListParams as InvoiceListParams,
|
|
1166
1168
|
type InvoiceAddChargeParams as InvoiceAddChargeParams,
|
|
1167
1169
|
type InvoiceListBreakdownsParams as InvoiceListBreakdownsParams,
|
|
1170
|
+
type InvoiceRetrievePdfParams as InvoiceRetrievePdfParams,
|
|
1168
1171
|
};
|
|
1169
1172
|
|
|
1170
1173
|
export {
|
|
@@ -4,6 +4,7 @@ import { APIResource } from '../../../core/resource';
|
|
|
4
4
|
import * as Shared from '../../shared';
|
|
5
5
|
import { APIPromise } from '../../../core/api-promise';
|
|
6
6
|
import { CursorPage, type CursorPageParams, PagePromise } from '../../../core/pagination';
|
|
7
|
+
import { buildHeaders } from '../../../internal/headers';
|
|
7
8
|
import { RequestOptions } from '../../../internal/request-options';
|
|
8
9
|
import { path } from '../../../internal/utils/path';
|
|
9
10
|
|
|
@@ -219,6 +220,55 @@ export class Invoices extends APIResource {
|
|
|
219
220
|
{ query, ...options },
|
|
220
221
|
);
|
|
221
222
|
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Retrieve a PDF version of a specific invoice by its unique identifier. This
|
|
226
|
+
* endpoint generates a professionally formatted invoice document suitable for
|
|
227
|
+
* sharing with customers, accounting teams, or for record-keeping purposes.
|
|
228
|
+
*
|
|
229
|
+
* ### Use this endpoint to:
|
|
230
|
+
*
|
|
231
|
+
* - Provide customers with downloadable or emailable copies of their invoices
|
|
232
|
+
* - Support accounting and finance teams with official billing documents
|
|
233
|
+
* - Maintain accurate records of billing transactions for audits and compliance
|
|
234
|
+
*
|
|
235
|
+
* ### Key response details:
|
|
236
|
+
*
|
|
237
|
+
* - The response is a binary PDF file representing the full invoice
|
|
238
|
+
* - The PDF includes all standard invoice information such as line items, totals,
|
|
239
|
+
* billing period, and customer details
|
|
240
|
+
* - The document is formatted for clarity and professionalism, suitable for
|
|
241
|
+
* official use
|
|
242
|
+
*
|
|
243
|
+
* ### Usage guidelines:
|
|
244
|
+
*
|
|
245
|
+
* - Ensure the `invoice_id` corresponds to an existing invoice for the specified
|
|
246
|
+
* `customer_id`
|
|
247
|
+
* - The PDF is generated on-demand; frequent requests for the same invoice may
|
|
248
|
+
* impact performance
|
|
249
|
+
* - Use appropriate headers to handle the binary response in your application
|
|
250
|
+
* (e.g., setting `Content-Type: application/pdf`)
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```ts
|
|
254
|
+
* const response =
|
|
255
|
+
* await client.v1.customers.invoices.retrievePdf({
|
|
256
|
+
* customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',
|
|
257
|
+
* invoice_id: '6a37bb88-8538-48c5-b37b-a41c836328bd',
|
|
258
|
+
* });
|
|
259
|
+
*
|
|
260
|
+
* const content = await response.blob();
|
|
261
|
+
* console.log(content);
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
retrievePdf(params: InvoiceRetrievePdfParams, options?: RequestOptions): APIPromise<Response> {
|
|
265
|
+
const { customer_id, invoice_id } = params;
|
|
266
|
+
return this._client.get(path`/v1/customers/${customer_id}/invoices/${invoice_id}/pdf`, {
|
|
267
|
+
...options,
|
|
268
|
+
headers: buildHeaders([{ Accept: 'application/pdf' }, options?.headers]),
|
|
269
|
+
__binaryResponse: true,
|
|
270
|
+
});
|
|
271
|
+
}
|
|
222
272
|
}
|
|
223
273
|
|
|
224
274
|
export type InvoicesCursorPage = CursorPage<Invoice>;
|
|
@@ -245,7 +295,7 @@ export interface Invoice {
|
|
|
245
295
|
/**
|
|
246
296
|
* This field's availability is dependent on your client's configuration.
|
|
247
297
|
*/
|
|
248
|
-
billable_status?:
|
|
298
|
+
billable_status?: unknown;
|
|
249
299
|
|
|
250
300
|
/**
|
|
251
301
|
* Custom fields to be added eg. { "key1": "value1", "key2": "value2" }
|
|
@@ -654,7 +704,49 @@ export namespace Invoice {
|
|
|
654
704
|
|
|
655
705
|
invoice_id?: string;
|
|
656
706
|
|
|
707
|
+
/**
|
|
708
|
+
* The subtotal amount invoiced, if available from the billing provider.
|
|
709
|
+
*/
|
|
710
|
+
invoiced_sub_total?: number;
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* The total amount invoiced, if available from the billing provider.
|
|
714
|
+
*/
|
|
715
|
+
invoiced_total?: number;
|
|
716
|
+
|
|
657
717
|
issued_at_timestamp?: string;
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* A URL to the PDF of the invoice, if available from the billing provider.
|
|
721
|
+
*/
|
|
722
|
+
pdf_url?: string;
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* Tax details for the invoice, if available from the billing provider.
|
|
726
|
+
*/
|
|
727
|
+
tax?: CorrectedExternalInvoice.Tax;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
export namespace CorrectedExternalInvoice {
|
|
731
|
+
/**
|
|
732
|
+
* Tax details for the invoice, if available from the billing provider.
|
|
733
|
+
*/
|
|
734
|
+
export interface Tax {
|
|
735
|
+
/**
|
|
736
|
+
* The total tax amount applied to the invoice.
|
|
737
|
+
*/
|
|
738
|
+
total_tax_amount?: number;
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* The total taxable amount of the invoice.
|
|
742
|
+
*/
|
|
743
|
+
total_taxable_amount?: number;
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* The transaction ID associated with the tax calculation.
|
|
747
|
+
*/
|
|
748
|
+
transaction_id?: string;
|
|
749
|
+
}
|
|
658
750
|
}
|
|
659
751
|
}
|
|
660
752
|
|
|
@@ -684,7 +776,49 @@ export namespace Invoice {
|
|
|
684
776
|
|
|
685
777
|
invoice_id?: string;
|
|
686
778
|
|
|
779
|
+
/**
|
|
780
|
+
* The subtotal amount invoiced, if available from the billing provider.
|
|
781
|
+
*/
|
|
782
|
+
invoiced_sub_total?: number;
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* The total amount invoiced, if available from the billing provider.
|
|
786
|
+
*/
|
|
787
|
+
invoiced_total?: number;
|
|
788
|
+
|
|
687
789
|
issued_at_timestamp?: string;
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* A URL to the PDF of the invoice, if available from the billing provider.
|
|
793
|
+
*/
|
|
794
|
+
pdf_url?: string;
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* Tax details for the invoice, if available from the billing provider.
|
|
798
|
+
*/
|
|
799
|
+
tax?: ExternalInvoice.Tax;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
export namespace ExternalInvoice {
|
|
803
|
+
/**
|
|
804
|
+
* Tax details for the invoice, if available from the billing provider.
|
|
805
|
+
*/
|
|
806
|
+
export interface Tax {
|
|
807
|
+
/**
|
|
808
|
+
* The total tax amount applied to the invoice.
|
|
809
|
+
*/
|
|
810
|
+
total_tax_amount?: number;
|
|
811
|
+
|
|
812
|
+
/**
|
|
813
|
+
* The total taxable amount of the invoice.
|
|
814
|
+
*/
|
|
815
|
+
total_taxable_amount?: number;
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* The transaction ID associated with the tax calculation.
|
|
819
|
+
*/
|
|
820
|
+
transaction_id?: string;
|
|
821
|
+
}
|
|
688
822
|
}
|
|
689
823
|
|
|
690
824
|
export interface InvoiceAdjustment {
|
|
@@ -891,6 +1025,12 @@ export interface InvoiceListBreakdownsParams extends CursorPageParams {
|
|
|
891
1025
|
window_size?: 'HOUR' | 'DAY';
|
|
892
1026
|
}
|
|
893
1027
|
|
|
1028
|
+
export interface InvoiceRetrievePdfParams {
|
|
1029
|
+
customer_id: string;
|
|
1030
|
+
|
|
1031
|
+
invoice_id: string;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
894
1034
|
export declare namespace Invoices {
|
|
895
1035
|
export {
|
|
896
1036
|
type Invoice as Invoice,
|
|
@@ -903,5 +1043,6 @@ export declare namespace Invoices {
|
|
|
903
1043
|
type InvoiceListParams as InvoiceListParams,
|
|
904
1044
|
type InvoiceAddChargeParams as InvoiceAddChargeParams,
|
|
905
1045
|
type InvoiceListBreakdownsParams as InvoiceListBreakdownsParams,
|
|
1046
|
+
type InvoiceRetrievePdfParams as InvoiceRetrievePdfParams,
|
|
906
1047
|
};
|
|
907
1048
|
}
|
|
@@ -121,6 +121,17 @@ export {
|
|
|
121
121
|
type InvoiceRegenerateParams,
|
|
122
122
|
type InvoiceVoidParams,
|
|
123
123
|
} from './invoices';
|
|
124
|
+
export {
|
|
125
|
+
Payments,
|
|
126
|
+
type Payment,
|
|
127
|
+
type PaymentStatus,
|
|
128
|
+
type PaymentAttemptResponse,
|
|
129
|
+
type PaymentCancelResponse,
|
|
130
|
+
type PaymentListParams,
|
|
131
|
+
type PaymentAttemptParams,
|
|
132
|
+
type PaymentCancelParams,
|
|
133
|
+
type PaymentsBodyCursorPage,
|
|
134
|
+
} from './payments';
|
|
124
135
|
export {
|
|
125
136
|
Plans,
|
|
126
137
|
type PlanDetail,
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../../core/resource';
|
|
4
|
+
import * as Shared from '../shared';
|
|
5
|
+
import { APIPromise } from '../../core/api-promise';
|
|
6
|
+
import { BodyCursorPage, type BodyCursorPageParams, PagePromise } from '../../core/pagination';
|
|
7
|
+
import { RequestOptions } from '../../internal/request-options';
|
|
8
|
+
|
|
9
|
+
export class Payments extends APIResource {
|
|
10
|
+
/**
|
|
11
|
+
* Fetch all payment attempts for the given invoice.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* // Automatically fetches more pages as needed.
|
|
16
|
+
* for await (const payment of client.v1.payments.list({
|
|
17
|
+
* customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',
|
|
18
|
+
* invoice_id: '6162d87b-e5db-4a33-b7f2-76ce6ead4e85',
|
|
19
|
+
* statuses: ['pending', 'requires_intervention'],
|
|
20
|
+
* })) {
|
|
21
|
+
* // ...
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
list(body: PaymentListParams, options?: RequestOptions): PagePromise<PaymentsBodyCursorPage, Payment> {
|
|
26
|
+
return this._client.getAPIList('/v1/payments/list', BodyCursorPage<Payment>, {
|
|
27
|
+
body,
|
|
28
|
+
method: 'post',
|
|
29
|
+
...options,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Trigger a new attempt by canceling any existing attempts for this invoice and
|
|
35
|
+
* creating a new Payment. This will trigger another attempt to charge the
|
|
36
|
+
* Customer's configured Payment Gateway. Payment can only be attempted if all of
|
|
37
|
+
* the following are true:
|
|
38
|
+
*
|
|
39
|
+
* - The Metronome Invoice is finalized
|
|
40
|
+
* - PLG Invoicing is configured for the Customer
|
|
41
|
+
* - You cannot attempt payments for invoices that have already been `paid` or
|
|
42
|
+
* `voided`.
|
|
43
|
+
*
|
|
44
|
+
* Attempting to payment on an ineligible Invoice or Customer will result in a
|
|
45
|
+
* `400` response.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const response = await client.v1.payments.attempt({
|
|
50
|
+
* customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',
|
|
51
|
+
* invoice_id: '6162d87b-e5db-4a33-b7f2-76ce6ead4e85',
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
attempt(body: PaymentAttemptParams, options?: RequestOptions): APIPromise<PaymentAttemptResponse> {
|
|
56
|
+
return this._client.post('/v1/payments/attempt', { body, ...options });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Cancel an existing payment attempt for an invoice.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const response = await client.v1.payments.cancel({
|
|
65
|
+
* customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',
|
|
66
|
+
* invoice_id: '6162d87b-e5db-4a33-b7f2-76ce6ead4e85',
|
|
67
|
+
* });
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
cancel(body: PaymentCancelParams, options?: RequestOptions): APIPromise<PaymentCancelResponse> {
|
|
71
|
+
return this._client.post('/v1/payments/cancel', { body, ...options });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type PaymentsBodyCursorPage = BodyCursorPage<Payment>;
|
|
76
|
+
|
|
77
|
+
export interface Payment {
|
|
78
|
+
id: string;
|
|
79
|
+
|
|
80
|
+
amount?: number;
|
|
81
|
+
|
|
82
|
+
amount_paid?: number;
|
|
83
|
+
|
|
84
|
+
contract_id?: string;
|
|
85
|
+
|
|
86
|
+
created_at?: string;
|
|
87
|
+
|
|
88
|
+
customer_id?: string;
|
|
89
|
+
|
|
90
|
+
error_message?: string;
|
|
91
|
+
|
|
92
|
+
fiat_credit_type?: Shared.CreditTypeData;
|
|
93
|
+
|
|
94
|
+
invoice_id?: string;
|
|
95
|
+
|
|
96
|
+
payment_gateway?: Payment.PaymentGateway;
|
|
97
|
+
|
|
98
|
+
status?: PaymentStatus;
|
|
99
|
+
|
|
100
|
+
updated_at?: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export namespace Payment {
|
|
104
|
+
export interface PaymentGateway {
|
|
105
|
+
stripe: PaymentGateway.Stripe;
|
|
106
|
+
|
|
107
|
+
type: 'stripe';
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export namespace PaymentGateway {
|
|
111
|
+
export interface Stripe {
|
|
112
|
+
payment_intent_id: string;
|
|
113
|
+
|
|
114
|
+
error?: Stripe.Error;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export namespace Stripe {
|
|
118
|
+
export interface Error {
|
|
119
|
+
code?: string;
|
|
120
|
+
|
|
121
|
+
decline_code?: string;
|
|
122
|
+
|
|
123
|
+
type?: string;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export type PaymentStatus = 'pending' | 'requires_intervention' | 'paid' | 'canceled';
|
|
130
|
+
|
|
131
|
+
export interface PaymentAttemptResponse {
|
|
132
|
+
data: Payment;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface PaymentCancelResponse {
|
|
136
|
+
data: Payment;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface PaymentListParams extends BodyCursorPageParams {
|
|
140
|
+
customer_id: string;
|
|
141
|
+
|
|
142
|
+
invoice_id: string;
|
|
143
|
+
|
|
144
|
+
statuses?: Array<PaymentStatus>;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface PaymentAttemptParams {
|
|
148
|
+
customer_id: string;
|
|
149
|
+
|
|
150
|
+
invoice_id: string;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface PaymentCancelParams {
|
|
154
|
+
customer_id: string;
|
|
155
|
+
|
|
156
|
+
invoice_id: string;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export declare namespace Payments {
|
|
160
|
+
export {
|
|
161
|
+
type Payment as Payment,
|
|
162
|
+
type PaymentStatus as PaymentStatus,
|
|
163
|
+
type PaymentAttemptResponse as PaymentAttemptResponse,
|
|
164
|
+
type PaymentCancelResponse as PaymentCancelResponse,
|
|
165
|
+
type PaymentsBodyCursorPage as PaymentsBodyCursorPage,
|
|
166
|
+
type PaymentListParams as PaymentListParams,
|
|
167
|
+
type PaymentAttemptParams as PaymentAttemptParams,
|
|
168
|
+
type PaymentCancelParams as PaymentCancelParams,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
@@ -81,8 +81,7 @@ export class Usage extends APIResource {
|
|
|
81
81
|
* ingestion, supports backdating 34 days, and is built to handle mission-critical
|
|
82
82
|
* usage data with enterprise-grade reliability. Metronome supports 100,000 events
|
|
83
83
|
* per second without requiring pre-aggregation or rollups and can scale up from
|
|
84
|
-
* there. See
|
|
85
|
-
* [Getting usage into Metronome](https://docs.metronome.com/connect-metronome/) to
|
|
84
|
+
* there. See the [Send usage events](/guides/events/send-usage-events) guide to
|
|
86
85
|
* learn more about usage events.
|
|
87
86
|
*
|
|
88
87
|
* ### Use this endpoint to:
|
|
@@ -125,6 +124,9 @@ export class Usage extends APIResource {
|
|
|
125
124
|
* }
|
|
126
125
|
* ```
|
|
127
126
|
*
|
|
127
|
+
* Learn more about
|
|
128
|
+
* [usage event structure definitions](/guides/events/design-usage-events).
|
|
129
|
+
*
|
|
128
130
|
* #### Transaction ID
|
|
129
131
|
*
|
|
130
132
|
* The transaction_id serves as your idempotency key, ensuring events are processed
|
package/src/resources/v1/v1.ts
CHANGED
|
@@ -69,6 +69,18 @@ import {
|
|
|
69
69
|
InvoiceVoidResponse,
|
|
70
70
|
Invoices,
|
|
71
71
|
} from './invoices';
|
|
72
|
+
import * as PaymentsAPI from './payments';
|
|
73
|
+
import {
|
|
74
|
+
Payment,
|
|
75
|
+
PaymentAttemptParams,
|
|
76
|
+
PaymentAttemptResponse,
|
|
77
|
+
PaymentCancelParams,
|
|
78
|
+
PaymentCancelResponse,
|
|
79
|
+
PaymentListParams,
|
|
80
|
+
PaymentStatus,
|
|
81
|
+
Payments,
|
|
82
|
+
PaymentsBodyCursorPage,
|
|
83
|
+
} from './payments';
|
|
72
84
|
import * as PlansAPI from './plans';
|
|
73
85
|
import {
|
|
74
86
|
PlanDetail,
|
|
@@ -180,6 +192,7 @@ export class V1 extends APIResource {
|
|
|
180
192
|
services: ServicesAPI.Services = new ServicesAPI.Services(this._client);
|
|
181
193
|
invoices: InvoicesAPI.Invoices = new InvoicesAPI.Invoices(this._client);
|
|
182
194
|
contracts: ContractsAPI.Contracts = new ContractsAPI.Contracts(this._client);
|
|
195
|
+
payments: PaymentsAPI.Payments = new PaymentsAPI.Payments(this._client);
|
|
183
196
|
}
|
|
184
197
|
|
|
185
198
|
V1.Alerts = Alerts;
|
|
@@ -195,6 +208,7 @@ V1.BillableMetrics = BillableMetrics;
|
|
|
195
208
|
V1.Services = Services;
|
|
196
209
|
V1.Invoices = Invoices;
|
|
197
210
|
V1.Contracts = Contracts;
|
|
211
|
+
V1.Payments = Payments;
|
|
198
212
|
|
|
199
213
|
export declare namespace V1 {
|
|
200
214
|
export {
|
|
@@ -364,4 +378,16 @@ export declare namespace V1 {
|
|
|
364
378
|
type ContractSetUsageFilterParams as ContractSetUsageFilterParams,
|
|
365
379
|
type ContractUpdateEndDateParams as ContractUpdateEndDateParams,
|
|
366
380
|
};
|
|
381
|
+
|
|
382
|
+
export {
|
|
383
|
+
Payments as Payments,
|
|
384
|
+
type Payment as Payment,
|
|
385
|
+
type PaymentStatus as PaymentStatus,
|
|
386
|
+
type PaymentAttemptResponse as PaymentAttemptResponse,
|
|
387
|
+
type PaymentCancelResponse as PaymentCancelResponse,
|
|
388
|
+
type PaymentsBodyCursorPage as PaymentsBodyCursorPage,
|
|
389
|
+
type PaymentListParams as PaymentListParams,
|
|
390
|
+
type PaymentAttemptParams as PaymentAttemptParams,
|
|
391
|
+
type PaymentCancelParams as PaymentCancelParams,
|
|
392
|
+
};
|
|
367
393
|
}
|