Skip to content

Commit 36f4edf

Browse files
committed
docs: 添加README.md文件及元数据文件
添加项目README文档,包含功能说明、安装指南、使用示例和API文档 同时添加对应的Unity元数据文件
1 parent 2275064 commit 36f4edf

2 files changed

Lines changed: 121 additions & 0 deletions

File tree

README.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# GameFrameX.Payment
2+
3+
GameFrameX.Payment 是一个 Unity 支付包,为应用内购买和订阅提供统一的接口,支持 Google Play 和 Apple App Store。
4+
5+
## 特性
6+
7+
- 应用内购买和订阅的统一接口。
8+
- 支持 Google Play 和 Apple App Store。
9+
- 易于集成和使用。
10+
11+
## 安装
12+
13+
要使用此包,请将以下行添加到您的 `manifest.json` 文件中:
14+
15+
```json
16+
{
17+
"dependencies": {
18+
"com.gameframex.unity.payment": "https://github.com/GameFrameX/com.gameframex.unity.payment.git"
19+
}
20+
}
21+
```
22+
23+
## 如何使用
24+
25+
1.`PaymentComponent` 添加到场景中的 GameObject。
26+
2. 获取 `PaymentComponent` 实例并初始化它。
27+
3. 使用 `BuyInApp``BuySubs` 方法发起购买。
28+
29+
### 示例
30+
31+
```csharp
32+
using GameFrameX.Payment.Runtime;
33+
using UnityEngine;
34+
35+
public class PaymentExample : MonoBehaviour
36+
{
37+
private PaymentComponent _paymentComponent;
38+
39+
void Start()
40+
{
41+
_paymentComponent = FindObjectOfType<PaymentComponent>();
42+
_paymentComponent.Init();
43+
}
44+
45+
public void BuyProduct(string productId)
46+
{
47+
_paymentComponent.BuyInApp(productId, "orderId");
48+
}
49+
}
50+
```
51+
52+
## API
53+
54+
### `Init(bool isDebug = false, bool isClientVerify = true)`
55+
56+
初始化支付管理器。
57+
58+
- `isDebug`: 是否使用沙盒模式。
59+
- `isClientVerify`: 是否执行客户端购买验证。
60+
61+
### `IsReady()`
62+
63+
检查支付系统是否准备就绪。
64+
65+
### `SetPredefinedProductIds(List<string> inAppProductIds, List<string> subsProductIds)`
66+
67+
设置预定义的商品 ID 用于预加载。
68+
69+
- `inAppProductIds`: 应用内商品 ID 列表。
70+
- `subsProductIds`: 订阅商品 ID 列表。
71+
72+
### `QueryPurchases(string productType)`
73+
74+
查询购买历史。
75+
76+
- `productType`: 商品类型,"inapp" 或 "subs"。
77+
78+
### `ConsumePurchase(string purchaseToken)`
79+
80+
消耗购买。
81+
82+
- `purchaseToken`: 购买令牌。
83+
84+
### `BuyInApp(string productId, string orderId, string offerToken = "", string customData = "")`
85+
86+
发起应用内购买。
87+
88+
- `productId`: 商品 ID 或 SKU。
89+
- `orderId`: 订单 ID。
90+
- `offerToken`: 订阅优惠令牌(仅限订阅)。
91+
- `customData`: 自定义数据。
92+
93+
### `BuySubs(string productId, string orderId, string offerToken = "", string customData = "")`
94+
95+
发起订阅购买。
96+
97+
- `productId`: 商品 ID 或 SKU。
98+
- `orderId`: 订单 ID。
99+
- `offerToken`: 订阅优惠令牌。
100+
- `customData`: 自定义数据。
101+
102+
### `Buy(string productId, string productType, string offerToken, string orderId, string customData)`
103+
104+
发起购买。
105+
106+
- `productId`: 商品 ID 或 SKU。
107+
- `productType`: 商品类型,"inapp" 或 "subs"。
108+
- `offerToken`: 订阅优惠令牌。
109+
- `orderId`: 订单 ID。
110+
- `customData`: 自定义数据。
111+
112+
## 许可证
113+
114+
该项目根据 MIT 许可证授权 - 有关详细信息,请参阅 [LICENSE.md](LICENSE.md) 文件。

README.md.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)