export const extFirestoreRevenueCatPurchasesHandler = onRequest(
async (request, response) => {
const {processUserCredits} = require("./functions/userCredits");
await processUserCredits(request);
response.status(200).send('Webhook received');
});
export interface RCEvent {
api_version: string
event: {
aliases: string[]
app_id: string
app_user_id: string
country_code: string
currency: string
entitlement_id: string
entitlement_ids: string[]
environment: string
event_timestamp_ms: number
expiration_at_ms: number
id: string
is_family_share: boolean
offer_code?: string
original_app_user_id: string
original_transaction_id: string
period_type: string
presented_offering_id: string
price: number
price_in_purchased_currency: number
product_id: string
purchased_at_ms: number
store: string
subscriber_attributes: any
takehome_percentage: number
transaction_id: string
type: string
}
}
export async function processUserCredits(request: any) {
const innerBody = request.body as RCEvent;
const productId = innerBody.event.product_id;
const userId = innerBody.event.app_user_id;
//throws event is undefined
innerbody is undefined and I have no idea why. Can someone please help figure this out?
This is a firebase cloud functions.