Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "4.35.0"
".": "4.36.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 96
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-1345a8e288e34d5477b0e189877225f83939a59078c22fbb5367712e376c5d19.yml
configured_endpoints: 97
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-bf3e71b33372f4a9307f4b6cb689ea46b3cf583ecc5d79eee9601cd0b0467c9a.yml
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 4.36.0 (2024-11-15)

Full Changelog: [v4.35.0...v4.36.0](https://github.com/orbcorp/orb-node/compare/v4.35.0...v4.36.0)

### Features

* **api:** api update ([#394](https://github.com/orbcorp/orb-node/issues/394)) ([abc8949](https://github.com/orbcorp/orb-node/commit/abc894968c9ad04705f73a84d560225781d6b8a9))

## 4.35.0 (2024-11-06)

Full Changelog: [v4.34.0...v4.35.0](https://github.com/orbcorp/orb-node/compare/v4.34.0...v4.35.0)
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ for (const coupon of page.data) {

// Convenience methods are provided for manually paginating:
while (page.hasNextPage()) {
page = page.getNextPage();
page = await page.getNextPage();
// ...
}
```
Expand Down Expand Up @@ -350,6 +350,15 @@ TypeScript >= 4.5 is supported.

The following runtimes are supported:

- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)
- Node.js 18 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
- Deno v1.28.0 or higher, using `import Orb from "npm:orb-billing"`.
- Bun 1.0 or later.
- Cloudflare Workers.
- Vercel Edge Runtime.
- Jest 28 or greater with the `"node"` environment (`"jsdom"` is not supported at this time).
- Nitro v2.6 or greater.

Note that React Native is not supported at this time.

If you are interested in other runtime environments, please open or upvote an issue on GitHub.
Expand Down
1 change: 1 addition & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ Methods:
- <code title="get /invoices/upcoming">client.invoices.<a href="./src/resources/invoices.ts">fetchUpcoming</a>({ ...params }) -> InvoiceFetchUpcomingResponse</code>
- <code title="post /invoices/{invoice_id}/issue">client.invoices.<a href="./src/resources/invoices.ts">issue</a>(invoiceId, { ...params }) -> Invoice</code>
- <code title="post /invoices/{invoice_id}/mark_paid">client.invoices.<a href="./src/resources/invoices.ts">markPaid</a>(invoiceId, { ...params }) -> Invoice</code>
- <code title="post /invoices/{invoice_id}/pay">client.invoices.<a href="./src/resources/invoices.ts">pay</a>(invoiceId) -> Invoice</code>
- <code title="post /invoices/{invoice_id}/void">client.invoices.<a href="./src/resources/invoices.ts">void</a>(invoiceId) -> Invoice</code>

# Items
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orb-billing",
"version": "4.35.0",
"version": "4.36.0",
"description": "The official TypeScript library for the Orb API",
"author": "Orb <[email protected]>",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -45,7 +45,6 @@
"jest": "^29.4.0",
"prettier": "^3.0.0",
"ts-jest": "^29.1.0",
"ts-morph": "^19.0.0",
"ts-node": "^10.5.0",
"tsc-multi": "^1.1.0",
"tsconfig-paths": "^4.0.0",
Expand Down
61 changes: 29 additions & 32 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,37 +328,6 @@ export class Orb extends Core.APIClient {
static fileFromPath = Uploads.fileFromPath;
}

export {
OrbError,
APIError,
APIConnectionError,
APIConnectionTimeoutError,
APIUserAbortError,
URLNotFound,
NotFoundError,
ConflictError,
RateLimitError,
BadRequestError,
RequestTooLarge,
TooManyRequests,
ResourceNotFound,
ResourceConflict,
ResourceTooLarge,
AuthenticationError,
InternalServerError,
ConstraintViolation,
FeatureNotAvailable,
PermissionDeniedError,
RequestValidationError,
OrbAuthenticationError,
OrbInternalServerError,
UnprocessableEntityError,
DuplicateResourceCreation,
} from './error';

export import toFile = Uploads.toFile;
export import fileFromPath = Uploads.fileFromPath;

Orb.TopLevel = TopLevel;
Orb.Coupons = Coupons;
Orb.CouponsPage = CouponsPage;
Expand All @@ -382,7 +351,6 @@ Orb.SubscriptionsPage = SubscriptionsPage;
Orb.SubscriptionFetchScheduleResponsesPage = SubscriptionFetchScheduleResponsesPage;
Orb.Alerts = Alerts;
Orb.AlertsPage = AlertsPage;

export declare namespace Orb {
export type RequestOptions = Core.RequestOptions;

Expand Down Expand Up @@ -539,4 +507,33 @@ export declare namespace Orb {
export type TrialDiscount = API.TrialDiscount;
}

export { toFile, fileFromPath } from './uploads';
export {
OrbError,
APIError,
APIConnectionError,
APIConnectionTimeoutError,
APIUserAbortError,
URLNotFound,
NotFoundError,
ConflictError,
RateLimitError,
BadRequestError,
RequestTooLarge,
TooManyRequests,
ResourceNotFound,
ResourceConflict,
ResourceTooLarge,
AuthenticationError,
InternalServerError,
ConstraintViolation,
FeatureNotAvailable,
PermissionDeniedError,
RequestValidationError,
OrbAuthenticationError,
OrbInternalServerError,
UnprocessableEntityError,
DuplicateResourceCreation,
} from './error';

export default Orb;
82 changes: 82 additions & 0 deletions src/resources/invoices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ export class Invoices extends APIResource {
return this._client.post(`/invoices/${invoiceId}/mark_paid`, { body, ...options });
}

/**
* This endpoint collects payment for an invoice using the customer's default
* payment method. This action can only be taken on invoices with status "issued".
*/
pay(invoiceId: string, options?: Core.RequestOptions): Core.APIPromise<Invoice> {
return this._client.post(`/invoices/${invoiceId}/pay`, options);
}

/**
* This endpoint allows an invoice's status to be set the `void` status. This can
* only be done to invoices that are in the `issued` status.
Expand Down Expand Up @@ -368,6 +376,11 @@ export interface Invoice {
*/
paid_at: string | null;

/**
* A list of payment attempts associated with the invoice
*/
payment_attempts: Array<Invoice.PaymentAttempt>;

/**
* If payment was attempted on this invoice but failed, this will be the time of
* the most recent attempt.
Expand Down Expand Up @@ -1292,6 +1305,38 @@ export namespace Invoice {
minimum_amount: string;
}

export interface PaymentAttempt {
/**
* The ID of the payment attempt.
*/
id: string;

/**
* The amount of the payment attempt.
*/
amount: string;

/**
* The time at which the payment attempt was created.
*/
created_at: string;

/**
* The payment provider that attempted to collect the payment.
*/
payment_provider: 'stripe' | null;

/**
* The ID of the payment attempt in the payment provider.
*/
payment_provider_id: string | null;

/**
* Whether the payment attempt succeeded.
*/
succeeded: boolean;
}

export interface ShippingAddress {
city: string | null;

Expand Down Expand Up @@ -1537,6 +1582,11 @@ export interface InvoiceFetchUpcomingResponse {
*/
paid_at: string | null;

/**
* A list of payment attempts associated with the invoice
*/
payment_attempts: Array<InvoiceFetchUpcomingResponse.PaymentAttempt>;

/**
* If payment was attempted on this invoice but failed, this will be the time of
* the most recent attempt.
Expand Down Expand Up @@ -2466,6 +2516,38 @@ export namespace InvoiceFetchUpcomingResponse {
minimum_amount: string;
}

export interface PaymentAttempt {
/**
* The ID of the payment attempt.
*/
id: string;

/**
* The amount of the payment attempt.
*/
amount: string;

/**
* The time at which the payment attempt was created.
*/
created_at: string;

/**
* The payment provider that attempted to collect the payment.
*/
payment_provider: 'stripe' | null;

/**
* The ID of the payment attempt in the payment provider.
*/
payment_provider_id: string | null;

/**
* Whether the payment attempt succeeded.
*/
succeeded: boolean;
}

export interface ShippingAddress {
city: string | null;

Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = '4.35.0'; // x-release-please-version
export const VERSION = '4.36.0'; // x-release-please-version
18 changes: 18 additions & 0 deletions tests/api-resources/invoices.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,24 @@ describe('resource invoices', () => {
});
});

test('pay', async () => {
const responsePromise = client.invoices.pay('invoice_id');
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
expect(response).not.toBeInstanceOf(Response);
const dataAndResponse = await responsePromise.withResponse();
expect(dataAndResponse.data).toBe(response);
expect(dataAndResponse.response).toBe(rawResponse);
});

test('pay: request options instead of params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(client.invoices.pay('invoice_id', { path: '/_stainless_unknown_path' })).rejects.toThrow(
Orb.NotFoundError,
);
});

test('void', async () => {
const responsePromise = client.invoices.void('invoice_id');
const rawResponse = await responsePromise.asResponse();
Expand Down
40 changes: 0 additions & 40 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -759,16 +759,6 @@
dependencies:
"@swc/counter" "^0.1.3"

"@ts-morph/common@~0.20.0":
version "0.20.0"
resolved "https://registry.yarnpkg.com/@ts-morph/common/-/common-0.20.0.tgz#3f161996b085ba4519731e4d24c35f6cba5b80af"
integrity sha512-7uKjByfbPpwuzkstL3L5MQyuXPSKdoNG93Fmi2JoDcTf3pEP731JdRFAduRVkOs8oqxPsXKA+ScrWkdQ8t/I+Q==
dependencies:
fast-glob "^3.2.12"
minimatch "^7.4.3"
mkdirp "^2.1.6"
path-browserify "^1.0.1"

"@tsconfig/node10@^1.0.7":
version "1.0.8"
resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.8.tgz#c1e4e80d6f964fbecb3359c43bd48b40f7cadad9"
Expand Down Expand Up @@ -1314,11 +1304,6 @@ co@^4.6.0:
resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184"
integrity sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==

code-block-writer@^12.0.0:
version "12.0.0"
resolved "https://registry.yarnpkg.com/code-block-writer/-/code-block-writer-12.0.0.tgz#4dd58946eb4234105aff7f0035977b2afdc2a770"
integrity sha512-q4dMFMlXtKR3XNBHyMHt/3pwYNA69EDk00lloMOaaUMKPUXBw6lpXtbu3MMVG6/uOihGnRDOlkyqsONEUj60+w==

collect-v8-coverage@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz#c0b29bcd33bcd0779a1344c2136051e6afd3d9e9"
Expand Down Expand Up @@ -2681,23 +2666,11 @@ minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2:
dependencies:
brace-expansion "^1.1.7"

minimatch@^7.4.3:
version "7.4.6"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-7.4.6.tgz#845d6f254d8f4a5e4fd6baf44d5f10c8448365fb"
integrity sha512-sBz8G/YjVniEz6lKPNpKxXwazJe4c19fEfV2GDMX6AjFz+MX9uDWIZW8XreVhkFW3fkIdTv/gxWr/Kks5FFAVw==
dependencies:
brace-expansion "^2.0.1"

minimist@^1.2.6:
version "1.2.6"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==

mkdirp@^2.1.6:
version "2.1.6"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-2.1.6.tgz#964fbcb12b2d8c5d6fbc62a963ac95a273e2cc19"
integrity sha512-+hEnITedc8LAtIP9u3HJDFIdcLV2vXP33sqLLIzkv1Db1zO/1OxbvYf0Y1OC/S/Qo5dxHXepofhmxL02PsKe+A==

[email protected]:
version "2.1.2"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
Expand Down Expand Up @@ -2861,11 +2834,6 @@ parse-json@^5.2.0:
json-parse-even-better-errors "^2.3.0"
lines-and-columns "^1.1.6"

path-browserify@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-1.0.1.tgz#d98454a9c3753d5790860f16f68867b9e46be1fd"
integrity sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==

path-exists@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3"
Expand Down Expand Up @@ -3279,14 +3247,6 @@ ts-jest@^29.1.0:
semver "^7.5.3"
yargs-parser "^21.0.1"

ts-morph@^19.0.0:
version "19.0.0"
resolved "https://registry.yarnpkg.com/ts-morph/-/ts-morph-19.0.0.tgz#43e95fb0156c3fe3c77c814ac26b7d0be2f93169"
integrity sha512-D6qcpiJdn46tUqV45vr5UGM2dnIEuTGNxVhg0sk5NX11orcouwj6i1bMqZIz2mZTZB1Hcgy7C3oEVhAT+f6mbQ==
dependencies:
"@ts-morph/common" "~0.20.0"
code-block-writer "^12.0.0"

ts-node@^10.5.0:
version "10.7.0"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.7.0.tgz#35d503d0fab3e2baa672a0e94f4b40653c2463f5"
Expand Down
Loading