Skip to content

Instantly share code, notes, and snippets.

View d-sea's full-sized avatar

Hiro Fukami d-sea

View GitHub Profile
@d-sea
d-sea / purchase.js
Last active October 19, 2023 23:48
firebase functions Android サブスク更新をチェックして最新レシートをFirestoreに保存する
exports.verifySubscriptionAndroid = functions.pubsub.schedule('0 2 * * 0').timeZone('Asia/Tokyo').onRun(async (context) => {
// 該当レシートを検索
const now = Date.now();
const termTime = 24 * 60 * 60 * 1000; // 24時間間隔でチェックするため
const minTime = now - termTime;
const receiptsSnapshot = await admin.firestore().collectionGroup("receipts")
.where("expires_date_ms", "<=", now)
.where("expires_date_ms", ">", minTime)
.orderBy("expires_date_ms")
@d-sea
d-sea / purchase.js
Last active October 19, 2023 23:49
firebase functions iOS サブスク更新をチェックして最新レシートをFirestoreに保存する
exports.verifySubscriptionIos = functions.pubsub.schedule('0 1 * * 0').timeZone('Asia/Tokyo').onRun(async (context) => {
// 該当レシートを検索
const now = Date.now();
const termTime = 24 * 60 * 60 * 1000; // 24時間間隔でチェックするため
const minTime = now - termTime;
const receiptsSnapshot = await admin.firestore().collectionGroup("receipts")
.where("expires_date_ms", "<=", now)
.where("expires_date_ms", ">", minTime)
.orderBy("expires_date_ms")