Stripe for Google Sheets: script and web-hook

You can deal with Stripe directly now…
just get an API key from Stripe, and you can generate payment links… it works! no more 10% fees for Glide… I hope they gonna rethink these fees!


Excellent will be usable in lots of use cases :slight_smile:

1 Like

Is there any option for a URL to redirect to after payment via the payment link?

const STRIPE_API_KEY     = "YOUR API";
const STRIPE_SUCCESS_URL = "succes URL";
const STRIPE_CANCEL_URL  = "fail URL";

 * Generate Stripe payment links in Google Sheets
 * @param {number} amount The amount to be paid using Stripe
 * @param {string} currency The 3-letter currency code (optional)
 * @param {string} description A short description of the item name (optional)
 * @return Stripe checkout session link
 * @customfunction

const STRIPE = (amount, currency, description) => {

  const input = {
    "line_items[0][price_data][currency]": currency || "USD",
    "line_items[0][price_data][product_data][name]": description || "Name",
    "line_items[0][price_data][unit_amount]": Math.ceil(amount * 100),
    "line_items[0][quantity]": 1,

  const cacheKey = JSON.stringify(input);

  const cachedLink = CacheService.getScriptCache().get(cacheKey);

  if (cachedLink) return cachedLink;

  const params = {
    cancel_url: STRIPE_CANCEL_URL,
    success_url: STRIPE_SUCCESS_URL,
    mode: "payment",
    billing_address_collection: "required",
    "payment_method_types[]": "card",

  const payload = Object.entries(params)
    .map(([key, value]) =>
      [encodeURIComponent(key), encodeURIComponent(value)].join("=")

  const response = UrlFetchApp.fetch(
      method: "POST",
      headers: {
        Authorization: `Bearer ${STRIPE_API_KEY}`,
        "Content-Type": "application/x-www-form-urlencoded",
      muteHttpExceptions: true,

  const { url, error } = JSON.parse(response);

  if (url) {
    CacheService.getScriptCache().put(cacheKey, url, 21600);

  return error ? error.message : url;

so… i’m playing with it… now i set up a webhook in Stripe and I got the feedback to my GS!!!
this is great!! :slight_smile:

code for the web app to use in the webhook URL:

function doPost(e) {

    var jsonString = e.postData.getDataAsString();
    var event = JSON.parse(jsonString)
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = ss.getSheetByName("data");
    var timeStamp = new Date();
    var time = Utilities.formatDate(timeStamp, "GMT+08:00", "MM/dd/yy, h:mm a");
    var lastRow = sheet.getLastRow();
    var getHookType = event["type"];
switch (getHookType)  {
  case "customer.created":
    var hookType = "New Customer"
    var customerId = event["data"];
    var customerEmail = event["data"];
  case "customer.subscription.created":       
    var hookType = "New Paid Subscriber";
    var customerId = event["data"].object.customer;
  case "charge.succeeded":
    var hookType = "Payment";
    var customerId = event["data"].object.customer;
  case "subscription_schedule.canceled":
    var hookType = "Cancelled";
    var customerId = event["data"].object.customer;
    //Insert the data into the sheet  
    sheet.getRange(lastRow + 1, 1).setValue(time); 
    sheet.getRange(lastRow + 1, 2).setValue(hookType); 
    sheet.getRange(lastRow + 1, 3).setValue(event["data"]);   
    sheet.getRange(lastRow + 1, 4).setValue(customerEmail);
    sheet.getRange(lastRow + 1, 5).setValue(customerId);

  return HtmlService.createHtmlOutput(200);
1 Like

Holy Cow!!! bye, bye Glide transaction fees! LOL
So now… I can create free Apps that have a better desktop view than PRO, unlimited rows, and no transactions fees…

So you pay nothing? I don’t know how much Glide will like this business model of yours, I don’t think they can work for us for free.
I’m worried and disagree.

i don’t think 10% is a fair rate, Stripe is charging only 2.9%… hitting you with an extra 10% on top…??? I don’t mind paying, but when is fair… most of the profits are set to 20% markup… so they wanna take half of your work

I think too that 10% is too much, but sorry you have brought up something else.
Pay the fair and pay everyone, as in a civil society, to ensure development, continuity and reliability. That’s my opinion

i agree… i have many PRO apps and many transactions going through them… i would not look for a solution if I don’t feel like a bit too much extra… especially since this is not a custom platform… it is a global system, which has millions of users… they should act more commercial… anyway, there are so many solutions like that out there, so it is just another one… that will keep users from not going to a different platform… I can bet, many of us simply give customers cash app, zele, western union, PayPal… when they have some serious sale going on… Glide could capitalize on that by simply reducing fees below 3% for free apps and 0% to 0.5% on paid apps

We agree on this. I must say that you have focused on a particularly important issue.

1 Like

all set and ready for production! Yea…



This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.