Links
💸

In-App Purchases (Beta)

Before reading this page, please make sure you've set up your RevenueCat account.

🧋 Bubble.io Plugin

[Element] Natively - Purchases

Events:
  • Purchase Success
  • Purchase Failed
  • Set Customer Success
  • Set Customer Failed
  • Purchase Cancelled
  • Customer ID Received
States:
  • Latest Transaction Id - Transaction Id after Purchase Package
  • Latest Customer Id - Customer Id after Set Customer ID or Purchase Package
  • Latest Error - Empty if no error
Actions:
  • Purchase Package - Initiate purchase of product or subscription
  • Set Customer ID - Link your user's id with RevenueCat customer
    • Customer Identifier - (We're recommending using a Current User's unique id to identify customers in the RevenueCat dashboard)
  • Reset Customer ID - Unlink Customer ID from a device
How to use?
  1. 1.
    Make sure you've set up your Revenue Cat for your app
  2. 2.
    Add revenuecat_apiKey in plugin settings. To find API Key, go to RevenueCat App > API keys > Secret API keys.
  3. 3.
    Call Set Customer ID
  4. 4.
    Call Purchase Package action

How to verify User's subscription?

Make sure you've added revenuecat_apiKey in plugin settings. To find API Key, go to RevenueCat App > API keys > Secret API keys.
RevenueCat - Verify Subscription
  • Customer ID - Revenue cat user id that was used on RevenueCat Login.
A new customer will be created if the customer with such ID does not exist. More details here
  • Entitlements ID - your entitlements id, more details here.
Returns a result as:
  • Product ID - text
  • Purchase Date - date
  • Grace Period Expires Date - date
  • Expiration Date - date
  • Is Active - yes / no (Expiration Date > Current Date)
  • Error - empty text if no error

🛠 JavaScript SDK

NativelyPurchases

1
const purchases = new NativelyPurchases();
2
const login_callback = function(resp) {
3
console.log(resp.status); // SUCCESS or FAILED
4
console.log(resp.customerId); // Customer Id
5
6
// Empty if no error (should contain an error if status === "FAILED"
7
console.log(resp.error);
8
};
9
10
// Link your user with the customer on RevenueCat
11
const userId = "sdfdsr-2345-3rsd-fsd3432";
12
purchases.login(userId, login_callback);
13
14
// Unlink your user with the customer on RevenueCat
15
const logout_callback = function(resp) {
16
console.log("Logged out");
17
}
18
purchases.logout(logout_callback);
19
20
// Get the current user's customer id (Useful in case you're not linking the user with the RevenueCat customer)
21
const customer_id_callback = function(resp) {
22
console.log(resp.customerId);
23
}
24
purchases.customerId(customer_id_callback);
25
26
// Make a purchase
27
const packageId = "$rc_monthly";
28
const purchases_package_callback = function(resp) {
29
console.log(resp.status);
30
console.log(resp.transactionId);
31
console.log(resp.error);
32
};
33
purchases.purchasePackage(packageId, purchases_package_callback);

How to verify subscription with JS?

You need to fetch a user from RevenueCat API and verify it's entitlements. More details can be found here.

Where to find Package ID?

You can find it in your RevenueCat App dashboard, more details here

How to find Package ID
We recommend checking this guide if you plan to use a Stripe subscription through RevenueCat.
Create a request in API Connector (more details about the endpoint you can find here)
Where fetch_token & app_user_id is: