diff --git a/CHANGELOG.md b/CHANGELOG.md index 93835ec..a6d8830 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,12 @@ adding additional type guards. ## Unreleased +### Added + +- Added the `checkoutDomains` resource for listing, getting, deleting, and verifying payment methods for checkout + domains. +- Added `verification_in_progress` as a checkout domain response status and list filter. + --- ## 3.10.0 - 2026-08-07 diff --git a/package.json b/package.json index 7319823..d72e5fe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paddle/paddle-node-sdk", - "version": "3.10.0", + "version": "3.11.0", "description": "A Node.js SDK that you can use to integrate Paddle Billing with applications written in server-side JavaScript.", "main": "dist/cjs/index.cjs.node.js", "module": "dist/esm/index.esm.node.js", diff --git a/src/__tests__/mocks/resources/checkout-domains.mock.ts b/src/__tests__/mocks/resources/checkout-domains.mock.ts new file mode 100644 index 0000000..9b58714 --- /dev/null +++ b/src/__tests__/mocks/resources/checkout-domains.mock.ts @@ -0,0 +1,50 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { type VerifyCheckoutDomainPaymentMethodRequestBody } from '../../../resources/index.js'; +import { type ICheckoutDomainResponse } from '../../../types/index.js'; +import { type Response, type ResponsePaginated } from '../../../internal/index.js'; + +export const CheckoutDomainMock: ICheckoutDomainResponse = { + id: 'chedom_01j2abc3def4ghi5jkl6mno7pq', + domain: 'app.example.com', + status: 'verification_in_progress', + payment_method_verification: { + apple_pay: { + status: 'verified', + }, + }, + created_at: '2026-03-04T12:00:00.000Z', + updated_at: '2026-03-04T14:30:00.000Z', +}; + +export const CheckoutDomainMockResponse: Response = { + data: CheckoutDomainMock, + meta: { + request_id: '', + }, +}; + +export const ListCheckoutDomainsMockResponse: ResponsePaginated = { + data: [CheckoutDomainMock], + meta: { + request_id: '', + pagination: { + estimated_total: 1, + has_more: true, + next: '/checkout-domains?after=1', + per_page: 10, + }, + }, +}; + +export const VerifyCheckoutDomainPaymentMethodMock: VerifyCheckoutDomainPaymentMethodRequestBody = { + paymentMethod: 'apple_pay', +}; + +export const VerifyCheckoutDomainPaymentMethodExpectation = { + payment_method: 'apple_pay', +}; diff --git a/src/__tests__/resources/checkout-domains.test.ts b/src/__tests__/resources/checkout-domains.test.ts new file mode 100644 index 0000000..5100f90 --- /dev/null +++ b/src/__tests__/resources/checkout-domains.test.ts @@ -0,0 +1,81 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { getPaddleTestClient } from '../helpers/test-client.js'; +import { + CheckoutDomainMockResponse, + ListCheckoutDomainsMockResponse, + VerifyCheckoutDomainPaymentMethodExpectation, + VerifyCheckoutDomainPaymentMethodMock, +} from '../mocks/resources/checkout-domains.mock.js'; +import { CheckoutDomainsResource } from '../../resources/index.js'; +import { convertToSnakeCase } from '../../internal/index.js'; + +const legacyDomainId = '9b95b0b8-e10f-441a-862e-1936a6d818ab'; + +describe('CheckoutDomainsResource', () => { + test('should filter and return checkout domains with verification in progress', async () => { + const paddleInstance = getPaddleTestClient(); + paddleInstance.get = jest.fn().mockResolvedValue(ListCheckoutDomainsMockResponse); + + const checkoutDomainsResource = new CheckoutDomainsResource(paddleInstance); + const checkoutDomainCollection = checkoutDomainsResource.list({ + status: ['verification_in_progress'], + }); + + let checkoutDomains = await checkoutDomainCollection.next(); + expect(paddleInstance.get).toHaveBeenCalledWith('/checkout-domains?status=verification_in_progress'); + expect(checkoutDomains).toHaveLength(1); + expect(checkoutDomains[0]?.status).toBe('verification_in_progress'); + expect(checkoutDomains[0]?.paymentMethodVerification.applePay.status).toBe('verified'); + + checkoutDomains = await checkoutDomainCollection.next(); + expect(paddleInstance.get).toHaveBeenCalledWith('/checkout-domains?after=1'); + expect(checkoutDomains).toHaveLength(1); + }); + + test('should get a checkout domain using a legacy domain ID', async () => { + const paddleInstance = getPaddleTestClient(); + paddleInstance.get = jest.fn().mockResolvedValue(CheckoutDomainMockResponse); + + const checkoutDomainsResource = new CheckoutDomainsResource(paddleInstance); + const checkoutDomain = await checkoutDomainsResource.get(legacyDomainId); + + expect(paddleInstance.get).toHaveBeenCalledWith(`/checkout-domains/${legacyDomainId}`); + expect(checkoutDomain).toBeDefined(); + }); + + test('should delete a checkout domain using a legacy domain ID', async () => { + const paddleInstance = getPaddleTestClient(); + paddleInstance.delete = jest.fn().mockResolvedValue(undefined); + + const checkoutDomainsResource = new CheckoutDomainsResource(paddleInstance); + const checkoutDomain = await checkoutDomainsResource.delete(legacyDomainId); + + expect(paddleInstance.delete).toHaveBeenCalledWith(`/checkout-domains/${legacyDomainId}`); + expect(checkoutDomain).toBeUndefined(); + }); + + test('should verify a payment method using a legacy domain ID', async () => { + const paddleInstance = getPaddleTestClient(); + paddleInstance.post = jest.fn().mockResolvedValue(CheckoutDomainMockResponse); + + const checkoutDomainsResource = new CheckoutDomainsResource(paddleInstance); + const checkoutDomain = await checkoutDomainsResource.verifyPaymentMethod( + legacyDomainId, + VerifyCheckoutDomainPaymentMethodMock, + ); + + expect(paddleInstance.post).toHaveBeenCalledWith( + `/checkout-domains/${legacyDomainId}/verify-payment-method`, + VerifyCheckoutDomainPaymentMethodMock, + ); + expect(checkoutDomain).toBeDefined(); + expect(convertToSnakeCase(VerifyCheckoutDomainPaymentMethodMock)).toEqual( + VerifyCheckoutDomainPaymentMethodExpectation, + ); + }); +}); diff --git a/src/entities/checkout-domains/checkout-domain-collection.ts b/src/entities/checkout-domains/checkout-domain-collection.ts new file mode 100644 index 0000000..642b32f --- /dev/null +++ b/src/entities/checkout-domains/checkout-domain-collection.ts @@ -0,0 +1,15 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { Collection } from '../../internal/base/index.js'; +import { type ICheckoutDomainResponse } from '../../types/index.js'; +import { CheckoutDomain } from './checkout-domain.js'; + +export class CheckoutDomainCollection extends Collection { + override fromJson(data: ICheckoutDomainResponse): CheckoutDomain { + return new CheckoutDomain(data); + } +} diff --git a/src/entities/checkout-domains/checkout-domain-payment-method-verification.ts b/src/entities/checkout-domains/checkout-domain-payment-method-verification.ts new file mode 100644 index 0000000..4e0c386 --- /dev/null +++ b/src/entities/checkout-domains/checkout-domain-payment-method-verification.ts @@ -0,0 +1,24 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { type CheckoutDomainPaymentMethodVerificationStatus } from '../../enums/index.js'; +import { type ICheckoutDomainPaymentMethodVerificationResponse } from '../../types/index.js'; + +export class CheckoutDomainApplePayVerification { + public readonly status: CheckoutDomainPaymentMethodVerificationStatus; + + constructor(status: CheckoutDomainPaymentMethodVerificationStatus) { + this.status = status; + } +} + +export class CheckoutDomainPaymentMethodVerification { + public readonly applePay: CheckoutDomainApplePayVerification; + + constructor(paymentMethodVerification: ICheckoutDomainPaymentMethodVerificationResponse) { + this.applePay = new CheckoutDomainApplePayVerification(paymentMethodVerification.apple_pay.status); + } +} diff --git a/src/entities/checkout-domains/checkout-domain.ts b/src/entities/checkout-domains/checkout-domain.ts new file mode 100644 index 0000000..875b51c --- /dev/null +++ b/src/entities/checkout-domains/checkout-domain.ts @@ -0,0 +1,29 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { type CheckoutDomainApprovalStatus } from '../../enums/index.js'; +import { type ICheckoutDomainResponse } from '../../types/index.js'; +import { CheckoutDomainPaymentMethodVerification } from './checkout-domain-payment-method-verification.js'; + +export class CheckoutDomain { + public readonly id: string; + public readonly domain: string; + public readonly status: CheckoutDomainApprovalStatus; + public readonly paymentMethodVerification: CheckoutDomainPaymentMethodVerification; + public readonly createdAt: string; + public readonly updatedAt: string; + + constructor(checkoutDomain: ICheckoutDomainResponse) { + this.id = checkoutDomain.id; + this.domain = checkoutDomain.domain; + this.status = checkoutDomain.status; + this.paymentMethodVerification = new CheckoutDomainPaymentMethodVerification( + checkoutDomain.payment_method_verification, + ); + this.createdAt = checkoutDomain.created_at; + this.updatedAt = checkoutDomain.updated_at; + } +} diff --git a/src/entities/checkout-domains/index.ts b/src/entities/checkout-domains/index.ts new file mode 100644 index 0000000..669b7be --- /dev/null +++ b/src/entities/checkout-domains/index.ts @@ -0,0 +1,9 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export * from './checkout-domain.js'; +export * from './checkout-domain-collection.js'; +export * from './checkout-domain-payment-method-verification.js'; diff --git a/src/entities/index.ts b/src/entities/index.ts index be65ca1..7ed24ab 100644 --- a/src/entities/index.ts +++ b/src/entities/index.ts @@ -16,6 +16,7 @@ export * from './subscription/index.js'; export * from './address/index.js'; export * from './discount/index.js'; export * from './discount-group/index.js'; +export * from './checkout-domains/index.js'; export * from './events/index.js'; export * from './payment-method/index.js'; export * from './payout/index.js'; diff --git a/src/enums/checkout-domains/checkout-domain-approval-status.ts b/src/enums/checkout-domains/checkout-domain-approval-status.ts new file mode 100644 index 0000000..01af296 --- /dev/null +++ b/src/enums/checkout-domains/checkout-domain-approval-status.ts @@ -0,0 +1,18 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +/** + * Approval status for a checkout domain. + * + * `in_review`: Ops has requested action from the seller and is waiting for a response. + */ +export type CheckoutDomainApprovalStatus = + | 'pending_review' + | 'approved' + | 'rejected' + | 'in_review' + | 'action_required' + | 'verification_in_progress'; diff --git a/src/enums/checkout-domains/checkout-domain-payment-method-verification-status.ts b/src/enums/checkout-domains/checkout-domain-payment-method-verification-status.ts new file mode 100644 index 0000000..ab3619d --- /dev/null +++ b/src/enums/checkout-domains/checkout-domain-payment-method-verification-status.ts @@ -0,0 +1,7 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export type CheckoutDomainPaymentMethodVerificationStatus = 'verified' | 'unverified'; diff --git a/src/enums/checkout-domains/checkout-domain-payment-method.ts b/src/enums/checkout-domains/checkout-domain-payment-method.ts new file mode 100644 index 0000000..d819549 --- /dev/null +++ b/src/enums/checkout-domains/checkout-domain-payment-method.ts @@ -0,0 +1,7 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export type CheckoutDomainPaymentMethod = 'apple_pay'; diff --git a/src/enums/checkout-domains/index.ts b/src/enums/checkout-domains/index.ts new file mode 100644 index 0000000..2bafdf6 --- /dev/null +++ b/src/enums/checkout-domains/index.ts @@ -0,0 +1,9 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export * from './checkout-domain-approval-status.js'; +export * from './checkout-domain-payment-method.js'; +export * from './checkout-domain-payment-method-verification-status.js'; diff --git a/src/enums/index.ts b/src/enums/index.ts index 4bf8f26..ca56dec 100644 --- a/src/enums/index.ts +++ b/src/enums/index.ts @@ -5,6 +5,7 @@ */ export * from './shared/index.js'; +export * from './checkout-domains/index.js'; export * from './metrics/index.js'; export * from './subscription/index.js'; export * from './discount/index.js'; diff --git a/src/paddle.ts b/src/paddle.ts index 4513024..c1d2c77 100644 --- a/src/paddle.ts +++ b/src/paddle.ts @@ -4,6 +4,7 @@ import { AddressesResource, AdjustmentsResource, BusinessesResource, + CheckoutDomainsResource, CustomerPortalSessionsResource, CustomersResource, DiscountGroupsResource, @@ -43,6 +44,7 @@ export class Paddle { public customerPortalSessions: CustomerPortalSessionsResource; public addresses: AddressesResource; public businesses: BusinessesResource; + public checkoutDomains: CheckoutDomainsResource; public discounts: DiscountsResource; public discountGroups: DiscountGroupsResource; public subscriptions: SubscriptionsResource; @@ -75,6 +77,7 @@ export class Paddle { this.customerPortalSessions = new CustomerPortalSessionsResource(this.client); this.addresses = new AddressesResource(this.client); this.businesses = new BusinessesResource(this.client); + this.checkoutDomains = new CheckoutDomainsResource(this.client); this.discounts = new DiscountsResource(this.client); this.discountGroups = new DiscountGroupsResource(this.client); this.subscriptions = new SubscriptionsResource(this.client); diff --git a/src/resources/checkout-domains/index.ts b/src/resources/checkout-domains/index.ts new file mode 100644 index 0000000..63b7f0f --- /dev/null +++ b/src/resources/checkout-domains/index.ts @@ -0,0 +1,74 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { BaseResource, PathParameters, QueryParameters } from '../../internal/base/index.js'; +import { type ErrorResponse, type Response } from '../../internal/index.js'; +import { CheckoutDomain, CheckoutDomainCollection } from '../../entities/index.js'; +import { type ICheckoutDomainResponse } from '../../types/index.js'; +import { + type ListCheckoutDomainsQueryParameters, + type VerifyCheckoutDomainPaymentMethodRequestBody, +} from './operations/index.js'; + +const CheckoutDomainPaths = { + list: '/checkout-domains', + get: '/checkout-domains/{domain_id}', + delete: '/checkout-domains/{domain_id}', + verifyPaymentMethod: '/checkout-domains/{domain_id}/verify-payment-method', +} as const; + +export * from './operations/index.js'; + +export class CheckoutDomainsResource extends BaseResource { + public list(queryParams?: ListCheckoutDomainsQueryParameters): CheckoutDomainCollection { + const queryParameters = new QueryParameters(queryParams); + return new CheckoutDomainCollection(this.client, CheckoutDomainPaths.list + queryParameters.toQueryString()); + } + + public async get(domainId: string): Promise { + const urlWithPathParams = new PathParameters(CheckoutDomainPaths.get, { + domain_id: domainId, + }).deriveUrl(); + + const response = await this.client.get | ErrorResponse>( + urlWithPathParams, + ); + + const data = this.handleResponse(response); + + return new CheckoutDomain(data); + } + + public async delete(domainId: string): Promise { + const urlWithPathParams = new PathParameters(CheckoutDomainPaths.delete, { + domain_id: domainId, + }).deriveUrl(); + + const response = await this.client.delete(urlWithPathParams); + + if (response) { + this.handleResponse(response); + } + } + + public async verifyPaymentMethod( + domainId: string, + requestBody: VerifyCheckoutDomainPaymentMethodRequestBody, + ): Promise { + const urlWithPathParams = new PathParameters(CheckoutDomainPaths.verifyPaymentMethod, { + domain_id: domainId, + }).deriveUrl(); + + const response = await this.client.post< + VerifyCheckoutDomainPaymentMethodRequestBody, + Response | ErrorResponse + >(urlWithPathParams, requestBody); + + const data = this.handleResponse(response); + + return new CheckoutDomain(data); + } +} diff --git a/src/resources/checkout-domains/operations/index.ts b/src/resources/checkout-domains/operations/index.ts new file mode 100644 index 0000000..289ddda --- /dev/null +++ b/src/resources/checkout-domains/operations/index.ts @@ -0,0 +1,8 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export * from './list-checkout-domains-query-parameters.js'; +export * from './verify-checkout-domain-payment-method-request-body.js'; diff --git a/src/resources/checkout-domains/operations/list-checkout-domains-query-parameters.ts b/src/resources/checkout-domains/operations/list-checkout-domains-query-parameters.ts new file mode 100644 index 0000000..f3860c4 --- /dev/null +++ b/src/resources/checkout-domains/operations/list-checkout-domains-query-parameters.ts @@ -0,0 +1,15 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { type CheckoutDomainApprovalStatus } from '../../../enums/index.js'; + +export interface ListCheckoutDomainsQueryParameters { + after?: string; + orderBy?: string; + perPage?: number; + domain?: string; + status?: CheckoutDomainApprovalStatus[]; +} diff --git a/src/resources/checkout-domains/operations/verify-checkout-domain-payment-method-request-body.ts b/src/resources/checkout-domains/operations/verify-checkout-domain-payment-method-request-body.ts new file mode 100644 index 0000000..aa4b087 --- /dev/null +++ b/src/resources/checkout-domains/operations/verify-checkout-domain-payment-method-request-body.ts @@ -0,0 +1,11 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { type CheckoutDomainPaymentMethod } from '../../../enums/index.js'; + +export interface VerifyCheckoutDomainPaymentMethodRequestBody { + paymentMethod: CheckoutDomainPaymentMethod; +} diff --git a/src/resources/index.ts b/src/resources/index.ts index fafd87b..677712e 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -7,6 +7,7 @@ export * from './addresses/index.js'; export * from './adjustments/index.js'; export * from './businesses/index.js'; +export * from './checkout-domains/index.js'; export * from './customers/index.js'; export * from './customer-portal-sessions/index.js'; export * from './discounts/index.js'; diff --git a/src/types/checkout-domains/checkout-domain-payment-method-verification-response.ts b/src/types/checkout-domains/checkout-domain-payment-method-verification-response.ts new file mode 100644 index 0000000..e443008 --- /dev/null +++ b/src/types/checkout-domains/checkout-domain-payment-method-verification-response.ts @@ -0,0 +1,13 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { type CheckoutDomainPaymentMethodVerificationStatus } from '../../enums/index.js'; + +export interface ICheckoutDomainPaymentMethodVerificationResponse { + apple_pay: { + status: CheckoutDomainPaymentMethodVerificationStatus; + }; +} diff --git a/src/types/checkout-domains/checkout-domain-response.ts b/src/types/checkout-domains/checkout-domain-response.ts new file mode 100644 index 0000000..b479cdf --- /dev/null +++ b/src/types/checkout-domains/checkout-domain-response.ts @@ -0,0 +1,17 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +import { type CheckoutDomainApprovalStatus } from '../../enums/index.js'; +import { type ICheckoutDomainPaymentMethodVerificationResponse } from './checkout-domain-payment-method-verification-response.js'; + +export interface ICheckoutDomainResponse { + id: string; + domain: string; + status: CheckoutDomainApprovalStatus; + payment_method_verification: ICheckoutDomainPaymentMethodVerificationResponse; + created_at: string; + updated_at: string; +} diff --git a/src/types/checkout-domains/index.ts b/src/types/checkout-domains/index.ts new file mode 100644 index 0000000..c0741dc --- /dev/null +++ b/src/types/checkout-domains/index.ts @@ -0,0 +1,8 @@ +/** + * ! Autogenerated code ! + * Do not make changes to this file. + * Changes may be overwritten as part of auto-generation. + */ + +export * from './checkout-domain-response.js'; +export * from './checkout-domain-payment-method-verification-response.js'; diff --git a/src/types/index.ts b/src/types/index.ts index eb68113..856f4f9 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -16,6 +16,7 @@ export * from './subscription/index.js'; export * from './address/index.js'; export * from './discount/index.js'; export * from './discount-group/index.js'; +export * from './checkout-domains/index.js'; export * from './payment-method/index.js'; export * from './pricing-preview/index.js'; export * from './events/index.js';