@chevre/domain
Version:
Chevre Domain Library for Node.js
294 lines (293 loc) • 8.52 kB
TypeScript
import * as factory from '../../factory';
import { Settings } from '../../settings';
import type { AccountingReportRepo } from '../../repo/accountingReport';
import type { ActionRepo, IMinimizedPurchaseNumberAuthResult } from '../../repo/action';
import type { AssetTransactionRepo } from '../../repo/assetTransaction';
import type { AuthorizationRepo } from '../../repo/authorization';
import type { ConfirmationNumberRepo } from '../../repo/confirmationNumber';
import type { CredentialsRepo } from '../../repo/credentials';
import type { EventRepo } from '../../repo/event';
import type { OrderNumberRepo } from '../../repo/orderNumber';
import type { PaymentServiceRepo } from '../../repo/paymentService';
import type { PaymentServiceProviderRepo } from '../../repo/paymentServiceProvider';
import type { PotentialActionRepo } from '../../repo/potentialAction';
import type { ProductRepo } from '../../repo/product';
import type { ProjectRepo } from '../../repo/project';
import type { SellerPaymentAcceptedRepo } from '../../repo/sellerPaymentAccepted';
import type { TaskRepo } from '../../repo/task';
import type { TicketRepo } from '../../repo/ticket';
import type { TransactionRepo } from '../../repo/transaction';
import type { TransactionNumberRepo } from '../../repo/transactionNumber';
import * as PayTransactionService from '../assetTransaction/pay';
import { onPaymentStatusChanged } from './any/onPaymentStatusChanged';
import { person2username } from './any/person2username';
/**
* 決済承認中止
* タスクから決済承認を取り消す
*/
declare function voidPayTransaction(params: factory.task.IData<factory.taskName.VoidPayTransaction> & {
project: {
id: string;
};
sameAs?: {
id: string;
};
}): (repos: {
accountingReport: AccountingReportRepo;
action: ActionRepo;
assetTransaction: AssetTransactionRepo;
paymentAccepted: SellerPaymentAcceptedRepo;
paymentService: PaymentServiceRepo;
paymentServiceProvider: PaymentServiceProviderRepo;
task: TaskRepo;
transaction: TransactionRepo;
}) => Promise<void>;
declare function invalidatePaymentUrl(params: factory.task.IData<factory.taskName.VoidPayTransaction> & {
sameAs?: {
id: string;
};
}): (repos: {
accountingReport: AccountingReportRepo;
action: ActionRepo;
assetTransaction: AssetTransactionRepo;
paymentAccepted: SellerPaymentAcceptedRepo;
paymentService: PaymentServiceRepo;
paymentServiceProvider: PaymentServiceProviderRepo;
task: TaskRepo;
transaction: TransactionRepo;
}) => Promise<void>;
/**
* 決済承認中止
* apiもしくはタスクから決済承認を取り消す
*/
declare function processVoidPayTransaction(params: factory.task.IData<factory.taskName.VoidPayTransaction> & {
project: {
id: string;
};
sameAs?: {
/**
* 実行元タスクID
*/
id: string;
};
}): (repos: {
action: ActionRepo;
accountingReport: AccountingReportRepo;
assetTransaction: AssetTransactionRepo;
task: TaskRepo;
transaction: TransactionRepo;
}) => Promise<void>;
interface IAuthorizeRepos {
accountingReport: AccountingReportRepo;
action: ActionRepo;
assetTransaction: AssetTransactionRepo;
authorization: AuthorizationRepo;
confirmationNumber: ConfirmationNumberRepo;
credentials: CredentialsRepo;
event: EventRepo;
orderNumber: OrderNumberRepo;
paymentAccepted: SellerPaymentAcceptedRepo;
paymentService: PaymentServiceRepo;
paymentServiceProvider: PaymentServiceProviderRepo;
potentialAction: PotentialActionRepo;
product: ProductRepo;
project: ProjectRepo;
task: TaskRepo;
ticket: TicketRepo;
transaction: TransactionRepo;
transactionNumber: TransactionNumberRepo;
}
type IAuthorizeOperation<T> = (repos: IAuthorizeRepos, settings: Settings) => Promise<T>;
interface IPublishPaymentUrlRepos {
action: ActionRepo;
assetTransaction: AssetTransactionRepo;
authorization: AuthorizationRepo;
orderNumber: OrderNumberRepo;
paymentAccepted: SellerPaymentAcceptedRepo;
paymentService: PaymentServiceRepo;
paymentServiceProvider: PaymentServiceProviderRepo;
project: ProjectRepo;
ticket: TicketRepo;
transaction: TransactionRepo;
transactionNumber: TransactionNumberRepo;
}
type IPublishPaymentUrlOperation<T> = (repos: IPublishPaymentUrlRepos, settings: Settings) => Promise<T>;
type IObjectWithoutDetail = factory.action.authorize.paymentMethod.any.IObjectWithoutDetail & {
ticketToken?: string;
};
/**
* 外部決済ロケーションを発行する
*/
declare function publishPaymentUrl(params: {
project: {
id: string;
};
agent: {
id: string;
};
object: Pick<IObjectWithoutDetail, 'amount' | 'creditCard' | 'issuedThrough' | 'method' | 'paymentMethod'>;
purpose: factory.action.authorize.paymentMethod.any.IPurpose;
paymentServiceType: factory.service.paymentService.PaymentServiceType;
location: factory.action.trade.pay.ILocation;
sameAs?: {
/**
* 実行元タスクID
*/
id: string;
};
/**
* add identifier for an unique index(2025-02-25~)
*/
identifier?: string;
}): IPublishPaymentUrlOperation<Pick<PayTransactionService.IPublishPaymentUrlResult, 'paymentMethodId' | 'paymentUrl'>>;
/**
* 決済承認
*/
declare function authorize(params: {
project: {
id: string;
};
agent: {
id: string;
};
object: IObjectWithoutDetail;
purpose: factory.action.authorize.paymentMethod.any.IPurpose;
paymentServiceType: factory.service.paymentService.PaymentServiceType;
location?: factory.action.trade.pay.ILocation;
options: {
/**
* アクション失敗時に即時に決済取引を中止するかどうか
*/
useCancelPayTransactionOnFailed: boolean;
checkedAction: {
id: string;
};
};
sameAs?: {
/**
* 実行元タスクID
*/
id: string;
};
}): IAuthorizeOperation<{
/**
* 承認アクションID
*/
id: string;
}>;
interface IFindAuthorizeActionResult {
/**
* アクションID
*/
id?: string;
/**
* アクションスタータス
*/
actionStatus: factory.actionStatusType;
/**
* エラー
*/
error?: {
name?: string;
message?: string;
};
}
interface IFindCheckActionResult {
/**
* アクションID
*/
id?: string;
/**
* アクションスタータス
*/
actionStatus: factory.actionStatusType;
/**
* エラー
*/
error?: {
name?: string;
message?: string;
};
result?: {
purchaseNumberAuthResult: IMinimizedPurchaseNumberAuthResult;
};
}
interface IFindAcceptActionResult {
/**
* アクションID
*/
id?: string;
/**
* アクションスタータス
*/
actionStatus: factory.actionStatusType;
/**
* エラー
*/
error?: {
name?: string;
message?: string;
};
result?: factory.action.accept.pay.IResult;
}
declare function findAuthorizeAction(params: {
project: {
id: string;
};
sameAs: {
/**
* task ID
*/
id: string;
};
purpose: {
/**
* transaction ID
*/
id: string;
};
}): (repos: {
action: ActionRepo;
task: TaskRepo;
}) => Promise<IFindAuthorizeActionResult>;
declare function findCheckAction(params: {
project: {
id: string;
};
sameAs: {
/**
* task ID
*/
id: string;
};
purpose: {
/**
* transaction ID
*/
id: string;
};
}): (repos: {
action: ActionRepo;
task: TaskRepo;
}) => Promise<IFindCheckActionResult>;
declare function findAcceptAction(params: {
project: {
id: string;
};
sameAs: {
/**
* task ID
*/
id: string;
};
purpose: {
/**
* transaction ID
*/
id: string;
};
}): (repos: {
action: ActionRepo;
task: TaskRepo;
}) => Promise<IFindAcceptActionResult>;
export { onPaymentStatusChanged, authorize, findAcceptAction, findAuthorizeAction, findCheckAction, invalidatePaymentUrl, voidPayTransaction, person2username, processVoidPayTransaction, publishPaymentUrl };