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
8 changes: 5 additions & 3 deletions client/client/client.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const createClient = (config: Config = {}): Client => {
...options,
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
headers: mergeHeaders(_config.headers, options.headers),
serializedBody: undefined,
serializedBody: undefined as string | undefined,
};

if (opts.security) {
Expand All @@ -52,7 +52,7 @@ export const createClient = (config: Config = {}): Client => {
}

if (opts.body !== undefined && opts.bodySerializer) {
opts.serializedBody = opts.bodySerializer(opts.body);
opts.serializedBody = opts.bodySerializer(opts.body) as string | undefined;
}

// remove Content-Type header if body is empty to avoid sending invalid requests
Expand Down Expand Up @@ -258,8 +258,10 @@ export const createClient = (config: Config = {}): Client => {
});
};

const _buildUrl: Client['buildUrl'] = (options) => buildUrl({ ..._config, ...options });

return {
buildUrl,
buildUrl: _buildUrl,
connect: makeMethodFn('CONNECT'),
delete: makeMethodFn('DELETE'),
get: makeMethodFn('GET'),
Expand Down
14 changes: 6 additions & 8 deletions client/core/bodySerializer.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { ArrayStyle, ObjectStyle, SerializerOptions } from './pathSerialize

export type QuerySerializer = (query: Record<string, unknown>) => string;

export type BodySerializer = (body: any) => any;
export type BodySerializer = (body: unknown) => unknown;

type QuerySerializerOptionsObject = {
allowReserved?: boolean;
Expand Down Expand Up @@ -39,12 +39,10 @@ const serializeUrlSearchParamsPair = (data: URLSearchParams, key: string, value:
};

export const formDataBodySerializer = {
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(
body: T,
): FormData => {
bodySerializer: (body: unknown): FormData => {
const data = new FormData();

Object.entries(body).forEach(([key, value]) => {
Object.entries(body as Record<string, unknown>).forEach(([key, value]) => {
if (value === undefined || value === null) {
return;
}
Expand All @@ -60,15 +58,15 @@ export const formDataBodySerializer = {
};

export const jsonBodySerializer = {
bodySerializer: <T>(body: T): string =>
bodySerializer: (body: unknown): string =>
JSON.stringify(body, (_key, value) => (typeof value === 'bigint' ? value.toString() : value)),
};

export const urlSearchParamsBodySerializer = {
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(body: T): string => {
bodySerializer: (body: unknown): string => {
const data = new URLSearchParams();

Object.entries(body).forEach(([key, value]) => {
Object.entries(body as Record<string, unknown>).forEach(([key, value]) => {
if (value === undefined || value === null) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion client/core/params.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ interface Params {

const stripEmptySlots = (params: Params) => {
for (const [slot, value] of Object.entries(params)) {
if (value && typeof value === 'object' && !Object.keys(value).length) {
if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) {
delete params[slot as Slot];
}
}
Expand Down
2 changes: 2 additions & 0 deletions client/sdk.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export const getAllPaymentMethods = <ThrowOnError extends boolean = false>(optio

/**
* Create Payment Method
*
* **このエンドポイントはテストモードでのみ使用できます。**
*/
export const createPaymentMethod = <ThrowOnError extends boolean = false>(options: Options<CreatePaymentMethodData, ThrowOnError>) => (options.client ?? client).post<CreatePaymentMethodResponses, CreatePaymentMethodErrors, ThrowOnError>({
security: [{ scheme: 'basic', type: 'http' }, { scheme: 'bearer', type: 'http' }],
Expand Down
48 changes: 48 additions & 0 deletions client/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3025,6 +3025,12 @@ export type ProductDetailsResponse = {
* 商品 ID
*/
id: string;
/**
* Livemode
*
* 本番環境かどうか
*/
livemode: boolean;
/**
* Name
*
Expand Down Expand Up @@ -3061,6 +3067,18 @@ export type ProductDetailsResponse = {
* この製品の公開されているウェブページの URL
*/
url: string | null;
/**
* Created At
*
* 作成日時 (UTC, ISO 8601 形式)
*/
created_at: string;
/**
* Updated At
*
* 更新日時 (UTC, ISO 8601 形式)
*/
updated_at: string;
};

/**
Expand Down Expand Up @@ -3679,6 +3697,12 @@ export type TaxRateDetailsResponse = {
* 税率 ID
*/
id: string;
/**
* Livemode
*
* 本番環境かどうか
*/
livemode: boolean;
/**
* Display Name
*
Expand Down Expand Up @@ -3713,6 +3737,18 @@ export type TaxRateDetailsResponse = {
* 説明。管理画面内のみで表示され、顧客には表示されません。
*/
description: string | null;
/**
* Created At
*
* 作成日時 (UTC, ISO 8601 形式)
*/
created_at: string;
/**
* Updated At
*
* 更新日時 (UTC, ISO 8601 形式)
*/
updated_at: string;
/**
* Metadata
*
Expand Down Expand Up @@ -5887,6 +5923,18 @@ export type GetAllTaxRatesData = {
* このIDより前のデータを取得
*/
ending_before?: string;
/**
* Active
*
* この税率が有効であるかどうか。無効にした場合でも、すでに設定されている定期課金などでは使用可能です。
*/
active?: boolean | null;
/**
* Inclusive
*
* 税込みかどうか。税込 = `true` 税抜 = `false`
*/
inclusive?: boolean | null;
};
url: '/v2/tax_rates';
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@payjp/payjpv2",
"version": "1.0.6",
"version": "1.0.7",
"type": "module",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
Expand Down
2 changes: 1 addition & 1 deletion payjpv2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
type Client,
} from "./client/client";

const BINDINGS_VERSION = '1.0.6';
const BINDINGS_VERSION = '1.0.7';
const DEFAULT_BASE_URL = "https://api.pay.jp";

export interface ClientConfig {
Expand Down
Loading