In-App Purchase History API
Return the user's Google Play purchase history as window.purchaseHistory so your web app can list subscriptions or unlock premium content client-side.
应用内购买历史 API 返回用户之前通过 Google Play Billing 进行的购买记录列表(产品 ID、时间戳、令牌),并将其作为 window.purchaseHistory 注入到您的 Web 应用中。如果您打算在最终产品中使用此功能,请确保拥有 WebViewGold 的扩展许可证。
使用方法:
<a href="getpurchasehistory://" onclick="setTimeout(renderHistory, 300)">My purchases</a>
<script>
function renderHistory() {
const data = window.purchaseHistory;
if (!data) return;
data.purchases.forEach(function (p) {
console.log(p.productId, p.purchaseTime, p.orderId);
});
}
</script>
载荷结构:
{
"purchases": [
{
"productId": "com.example.premium",
"purchaseTime": 1721600000000,
"orderId": "GPA.xxxx-xxxx-xxxx",
"purchaseToken": "..."
}
]
}
确切的字段取决于商店记录 — 请将该值视为可迭代的 JSON 数组。
典型用例:
- 在您的 Web 应用内显示"我的订阅"或"我的购买"页面。
- 基于过往购买记录在客户端解锁高级内容,而无需请求您的后端。
- 调试和客户支持工作流程。
说明: 列表仅包含在此设备上当前登录的 Google Play 账户下进行的购买。