Hello RevenueCat team and community!
I’m trying to integrate Stripe with RC and so far i’ve been following the steps of this documentation.
The documentation says “When using Stripe Checkout, you should listen to and send subscriptions to RevenueCat after both the customer.subscription.created and checkout.session.completed events.”
It works when event is checkout.session.completed but it doesn`t if event is customer.subscription.created.
This is script sample
if (
self.event_type == "customer.subscription.created"
or self.event_type == "checkout.session.completed"
):
url = "https://api.revenuecat.com/v1/receipts"
headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"X-Platform": "stripe",
"Authorization": "Bearer strp_XXXXXXXXXX",
}
data = {
"app_user_id": self.event_object.get("customer"),
"fetch_token": self.event_object.get("id"),
}
try:
response = requests.post(url, json=data, headers=headers)
except Exception as e:
print(e)
if response.status_code == 200:
print("Subscription updated successfully")
else:
print(
f"Failed to update subscription: {response.status_code} - {response.json()}"
)
Why it doesn`t work with customer.subscription.created and why we need to sent POST to revenuecat two times?