Gumroad Payments Setup
This guide provides detailed instructions on how to integrate Gumroad payments into your ChromeQuick project, allowing you to monetize your extension through one-time purchases or subscriptions.
Overview
Gumroad is an effective platform for handling digital sales and subscriptions which can save a ton of time and effort. This section will guide you through creating a Gumroad account, setting up your products, and integrating payment verification into your project using Firebase Functions.
Setting Up Gumroad for Payment processing
Step 1: Create a Gumroad Account
-
Visit Gumroad's website and create a new account.
-
Follow the prompts to complete your profile setup, including payment details to receive earnings from your sales.
Step 2: Create Your Product
-
Navigate to the Products section in your Gumroad dashboard.
-
Click on "Add a product". Choose whether it's a standard digital product for a one-time purchase or a membership for recurring payments.
-
Set up your product details:
- Enter a name, description, and price for your product.
- Upload any relevant files or provide access details for your extension if necessary.
Step 3: Configure License Keys
- Enable license keys for your product:
- Go to your product’s "Content" tab, click on the settings icon (three dots), and select "License Keys".
- Check the option to generate license keys for each sale. This is crucial for verifying user purchases in your Chrome extension.
- Customize your license settings if needed, such as the number of allowed activations per key.
Step 4: Obtain Your Product API Key
-
Expand the License Key section to view more options.
-
Find and copy your Product API Key:
- This key will be used in your Firebase Functions to verify the validity of license keys during user authentication or access checks.
Integrating Gumroad with Firebase Functions
Now that you have set up your product on Gumroad, integrate the license key verification in your ChromeQuick project:
- Navigate to your Firebase project:
- Open the functions/src/index.ts file where your server-side logic resides.
- Modify the existing API call to verify Gumroad license keys:
app.post("/api/proxy/activateLicense", async (req, res) => {
const { licenseKey } = req.body;
const apiUrl = "https://api.gumroad.com/v2/licenses/verify";
const productId = "your_product_id_here"; // Replace with your actual product ID
try {
const response = await fetch(apiUrl, {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: `product_id=${productId}&license_key=${licenseKey}`,
});
const data = await response.json();
res.json(data);
} catch (error) {
console.error("Proxy request failed:", error);
res.status(500).json({ error: "Proxy request failed" });
}
});
- Deploy your updated Firebase Functions:
firebase deploy --only functions
Conclusion
By integrating Gumroad for payments, your Chrome extension can securely handle transactions whether for one-time purchases or subscriptions. The license key system ensures that only legitimate users can access premium features, enhancing the overall security and value of your product. Remember to test the payment and verification process thoroughly to ensure a smooth user experience.