10 Home
Xu Chang edited this page 2025-03-19 11:42:20 +08:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

简介

oak-pay-business是为oak框架所设计的、专注于支付能力的库。本库的目标是为了实现众多商业项目中都需要的订单、支付、退款、分帐、物流等能力提供具有扩展性和鲁棒性的支付能力代码。

oak-pay-business依赖于oak-general-business两者必须同时使用

集成

  1. 安装oak-pay-business到项目依赖列表中
npm i --save oak-pay-business
  1. 修改src/configuration/dependency.ts增加对oak-pay-dependency的依赖
import { DependencyConfiguration } from 'oak-domain/lib/types/Configuration';

const dependencyConfiguration: DependencyConfiguration = ['oak-general-business', 'oak-pay-business'];

export default dependencyConfiguration;
  1. 执行oak依赖编译再重新构建entities
npm run make:dep

npm run make:domain

此时可以看到在src/oak-app-domain中oak-pay-business中所需要的对象实体OrderPay等都已经建立起来了。

注意,如果您的项目不是一个新项目,需要手工完成以下适配过程:

  • 在make:dep过程中像src/features/indexsrc/context/BackendContext等文件均被覆盖可能您之前编写的部分代码需要手动恢复
  • 如果您原来编写的entity中有extend了oak-general-business中的User/System这里要改成继承oak-pay-business中的User/System
  • 注意您原来编写的entity不要和oak-pay-business中的产生同名

使用

要使用oak-pay-business来实现支付能力首先需要了解它的基本设计理念

在了解了基本设计理念的基础之上,可以按照以下简明文档进行使用:

配置系统支付

集成支付能力的第一步要以System为单位对支付进行相关配置配置的详细说明见配置说明

帐户管理

将帐户管理集成到项目当中最简单的方案是将oak-pay-business所提供好的组件直接集成到页面上详见帐户管理集成

订单交易

如果要进行订单交易需要在应用中使用或继承oak-pay-business中的Order对象详见订单交易

后台管理

支付从整体来说是一个比较复杂的行为oak-pay-business本身也提供了较为完善的后台管理功能供应用集成详见后台管理