Revenue Cat
RevenueCat functions exposed through the WebToNative for your seamless in-app purchases and subscription management across iOS and Android.
const { configure, isInitialized, setUserId, getCustomerInfo, showPaywall, makePurchase, restorePurchase } = window.WTN.RevenueCat;
//Initialises the RevenueCat SDK on iOS/Android.
configure({
apiKey: "YOUR_REVENUECAT_API_KEY",
appUserId: "optional_user_id", // optional
callback: (response) => {
console.log(response);
}
});
//Check If SDK Is Initialised
isInitialised({
callback: (response) => {
console.log(response);
}
})
//Setting User Id
setUserId({
userId: "user_id",
callback: (response) => {
console.log(response);
}
})
//Getting customer info
getCustomerInfo({
callback: (response) => {
console.log(response);
}
})
//Showing th paywall
showPaywall({
offeringId:"revenue_cat_offering_id",
callback: (response) => {
console.log(response);
}
})
//Invoke default In App Purchase
makePurchase({
productId:"store_product_id",
callback: (response) => {
console.log(response);
}
})
//Restoring a purchase
restorePurchase({
callback: (response) => {
console.log(response);
}
})import { configure, isInitialized, setUserId, getCustomerInfo, showPaywall, makePurchase, restorePurchase } from "webtonative/RevenueCat";
//Initialises the RevenueCat SDK on iOS/Android.
configure({
apiKey: "YOUR_REVENUECAT_API_KEY",
appUserId: "optional_user_id", // optional
callback: (response) => {
console.log(response);
}
});
//Check If SDK Is Initialised
isInitialised({
callback: (response) => {
console.log(response);
}
})
//Setting User Id
setUserId({
userId: "user_id",
callback: (response) => {
console.log(response);
}
})
//Getting customer info
getCustomerInfo({
callback: (response) => {
console.log(response);
}
})
//Showing th paywall
showPaywall({
offeringId:"revenue_cat_offering_id",
callback: (response) => {
console.log(response);
}
})
//Invoke default In App Purchase
makePurchase({
productId:"store_product_id",
callback: (response) => {
console.log(response);
}
})
//Restoring a purchase
restorePurchase({
callback: (response) => {
console.log(response);
}
})Responses for the above fuctions
// 1. Configure
Success - { "type": "configure", "success": true }
Failure - { "type": "configure", "success": false, "error": "API_KEY_MISSING" }
// 2. Initialisation
Success - { "type": "isInitialized", "success": true, "isInitialized": true }
Failure - { "type": "isInitialized", "success": false, "isInitialized": false, "error": "ERROR_STRING" }
// 3. Setting User Id
Success - { "type": "setUserId", "success": true, "customerInfo": CustomerInfo }
Failure - { "type": "setUserId", "success": false, "error": "Error String" }
// 4. Getting Customer Info
Success - { "success": true, "customerInfo": CustomerInfo RevenueCat obj }
Failure - { "success": false, "error": Error String }
// 5. Showing Paywall
Success -
// Purchase Success
{
"type": "showPaywall",
"success": true,
// FOR IOS
"transaction": {
"transactionId": "STRING",
"productId": "STRING",
"purchaseDate": "STRING",
"appUserId": "STRING",
"storefrontId": "STRING"
}
// FOR ANDROID
"transaction" :{
"productId": "STRING",
"purchaseDate": "STRING",
"appUserId": "STRING",
"transactionId": "STRING",
"googleOrderId": "STRING"
}
}
// Restore Success
{ "type": "showPaywall", "success": true, "restore": true, "customerInfo": CustomerInfo }
Failure -
//User Cancelled
{ "type": "showPaywall", "success": false, "error": "PURCHASE_FLOW_CANCELLED" }
// Purchase Failed
{ "type": "showPaywall", "success": false, "error": "Error String" }
// Restore Failed
{ "type": "showPaywall", "success": false, "restore": true, "error": "Error String" }
// 6. Make Purchase
Success -
{
"type": "makePurchase",
"success": true,
// For IOS
"transaction": {
"transactionId": "STRING",
"productId": "STRING",
"purchaseDate": "STRING",
"storefrontId": "STRING",
"appUserId": "STRING"
}
// FOR ANDROID
"transaction" :{
"productId": "STRING",
"purchaseDate": "STRING",
"appUserId": "STRING",
"purchaseToken": "STRING",
"googleOrderId": "STRING"
}
}
Failure -
//User Cancelled
{ "type": "makePurchase", "success": false, "error": "PURCHASE_FLOW_CANCELLED" }
/Purchase Failed
{ "type": "makePurchase", "success": false, "error": "Error String" }Last updated
Was this helpful?