Share
Explore

How to setup Stripe Webhooks

Setting up Stripe Webhook Notifications for Shinara
Shinara supports Stripe Webhooks to enhance the speed and accuracy of webhook deliveries, integration updates, and real-time data for analytics. Here's a detailed guide on how to set this up:

Step 1: Obtain the Shinara Notification URL

Log in to your Shinara dashboard.
Navigate to "Integrations" in the left sidebar.
Click on "In-App Purchase Webhook" in the submenu.
Select "Stripe Webhooks" tab.
Locate the "Webhook" field and Copy it. This is the URL you'll need to provide to Stripe.

Step 2: Configure on Stripe

Open a new tab and log in to your Stripe account.
Click on Developers to go to Stripe Developers Portal.
Click on Webhooks and select Add Destinations
Select Event from “Your Accounts”
Select Events: ``` customer.subscription.created customer.subscription.deleted payment_intent.succeeded customer.created ```
Screenshot 2025-03-03 at 3.49.00 PM.png
Click Continue and select Webhook Endpoint
Paste the URL that you copied from the Shinara dashboard into Endpoint field.

Step 3: Configure Signing Secret and Restricted Key on Shinara

Fetch Signing Secret
Once the webhook is created on Stripe, you also need to setup Signing Secret on Shinara to authenticate webhook requests.
On Stripe’s Webhook details page (for the one you just created), click reveal on Signing secret
Screenshot 2025-03-03 at 3.52.12 PM.png
Copy the secret and paste it into Integrations < In-App Purchase Webhooks < Stripe Webhooks Tab (Stripe Webhook Secret)
Fetch Restricted Key
Visit your
Click “Create Restricted Key”
Select “Provide this key to another Website”
Name: Shinara
Check Customize permissions for this key
Screenshot 2025-03-03 at 3.53.53 PM.png
Click “Create Restricted Key”
We only need Payment Intent Read Permission. You can set all other permissions as `None`
Screenshot 2025-03-03 at 3.58.52 PM.png
Copy the key and paste it into Integrations < In-App Purchase Webhooks < Stripe Webhooks Tab (Stripe Restricted Key)
Screenshot 2025-03-03 at 4.00.29 PM.png
Click Save

Step 4: Integrate Shinara to your Web App

Screenshot 2025-03-03 at 4.20.31 PM.png

Create a Helper Class

class ShinaraHelper {
constructor() {
this.REFERRAL_KEY = "shinara_referral_code";
this.init();
}

init() {
const urlParams = new URLSearchParams(window.location.search);
const referralCode = urlParams.get(this.REFERRAL_KEY);
if (referralCode) {
localStorage.setItem(this.REFERRAL_KEY, referralCode);
}
}

getReferralCode() {
return localStorage.getItem(this.REFERRAL_KEY);
}
}

const shinaraHelper = new ShinaraHelper();
export default shinaraHelper;

Update Your Web App

Shinara will send users to your app with a referral code in a query parameter.
Example: `https://yourwebsite.com/?shinara_referral_code=CODE`
Use helper class to read the query param `shinara_referral_code` and store it into localStorage
import React, { useEffect } from "react";
import shinaraHelper from "./ShinaraHelper"; // import the helper class

const App: React.FC = () => {
useEffect(() => {
// Set the referral code using ShinaraHelper
shinaraHelper.init(); // This will check for the query param and store it if found
}, []);

return (
...
);
};

export default App;

Pass Referral Code to Your Backend for Checkout Session

import React, { useEffect, useState } from "react";
import shinaraHelper from "./ShinaraHelper"; // import the helper class

const App: React.FC = () => {
const [loading, setLoading] = useState(false);

const handleBuySubscription = async () => {
setLoading(true);

// Get the referral code from localStorage
const referralCode = shinaraHelper.getReferralCode();

try {
// Call your backend to create the Stripe session and pass the referral code
const response = await fetch("/api/create-stripe-session", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
referral_code: referralCode,
}),
});

const data = await response.json();

if (response.ok) {
// Redirect the user to Stripe's checkout page
window.location.href = data.stripeCheckoutUrl;
} else {
console.error("Failed to create Stripe session", data.message);
}
} catch (error) {
console.error("Error creating Stripe session:", error);
} finally {
setLoading(false);
}
};

return (
<div>
<h1>Welcome to Shinara App</h1>
<button onClick={handleBuySubscription} disabled={loading}>
{loading ? "Processing..." : "Buy Subscription"}
</button>
</div>
);
};

export default App;

Pass Referral Code when Creating a Stripe Session on your Backend

You'll need to send a Shinara Referral Code to Stripe via metadata when you create a Subscription Session
const session = await stripe.checkout.sessions.create({
success_url: 'https://example.com/success',
cancel_url: 'https://example.com/cancel',
metadata: { 'shinara-referral-code': req.body.referral_code, },
line_items: [ {price: 'price_example', quantity: 1} ],
mode: 'subscription',
});

Support and Contact Information

For any questions or concerns, please don't hesitate to reach out to our dedicated support team:
Email: Support Hours: Monday to Friday, 9 AM to 5 PM EST
We're committed to ensuring a smooth and rewarding experience for all our affiliates. Thank you for choosing Shinara as your affiliate partner!

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.