Ways to accept customer payments in apps-script

1,242 views
Skip to first unread message

Boris Baublys

unread,
Mar 8, 2021, 2:32:29 PM3/8/21
to Google Apps Script Community
Let's say you made an add-on in which the main functionality is free, but there are some premium options that are available to the user on a subscription basis for 1 month, half a year, or a year.
If you use a similar approach in your development, share your experience, please.
Interested in integrating payment systems into your apps-script.

What to use?

PayPal? 
Some colleagues scare me that there are times when PayPal blocks funds for 180 days for some unknown reason. I don't know if this is true.
But PayPal seems attractive to me because of the relative ease of integration.
The functionality of the script is great and the author inspires confidence.
Unfortunately, this is not an add-on that has gone through repeated checks by Google. The script is not distributed through Google Marketplace. It's not clear what's under the hood. It's not even my data that is scared, but the data of my clients.

GooglePay?
There is 100% trust, but even to simply bring a button to the side panel, you need a kilometer of code.

And the integration procedure is not entirely clear. Maybe if it was written by some blogger in simple language, it would be easier to understand, especially when translated from one language into the native one.

I would really appreciate some hints.
What can you recommend?
What and where to read?

Alan Wells

unread,
Mar 8, 2021, 3:28:54 PM3/8/21
to Google Apps Script Community
I would not use Google Pay.  Personally I don't see any advantage to using it, and they recently removed a lot of the functionality.
Google Pay is being drastically restricted by Google.  It could be a sign that it's on the way out.
Stripe is another option to collect payments from customers.
You could have both PayPal and Stripe.
There are horror stories about PayPal, but I wouldn't worry about that.
It's probably very unlikely that it would happen to you.
I'm not saying that it couldn't happen, but if you aren't doing anything that looks suspicious, then I doubt you'll have a problem.
The most important issue is what your customers are willing to use.
If most of your customers prefer something other than PayPal, then use what your customers want.
But that depends upon what your customers know about and use.
It could depend on the region of the world your customers are in.
Part of your implementation will be segregating which code runs freely with no payment test,
and which code must test for payment before running.
If your premium service depends on code that the free users run, then you've got to find a way to have the premium
service code first run through your payment test.  Or you'd need to check the user every time and determine whether that
user is paying for premium services or not.
How easy or hard it is to implement a payment system depends on your needs and what you want.
There are probably many different ways to implement a PayPal payment.
The blog post your gave the link to, has the customer go to your website to make the payment.
It doesn't give an example of an "in app" payment dialog, or a payment button in your add-on.
Also, it uses license keys, which you may or may not want to use.
All you really need is to know when their subscription expires.
I do have some example code for the version 3 of Stripe.


It's not a system for free and premium services.
Unfortunately it's hard to provide a generic example of a payment system that would work for everyone.

Boris Baublys

unread,
Mar 8, 2021, 3:56:07 PM3/8/21
to Google Apps Script Community
Alan, thank you very much for your detailed answer!
About license keys. I also planned to use them. The code for their generation and validation has already been written. The initial idea was this: after payment, the client sends the spreadsheet url (1) from the email address (2), under which he is logged in to work in the  spreadsheet. After checking the receipt of money, using the code generator, based on these two data (1 and 2), I generate a code that I send to the client to enter into the Settings sheet. The add-on's built-in validator validates the code. If it is valid, the client is given access to premium features.
As you can see, all this is very inconvenient, first of all for the client, but also for me.
Especially if the payment is a couple of dollars a month. The overhead is too high.
Therefore I think that the payment verification functionality should be built right into the add-on to avoid all this jumble.
Now the question is only in the integration of the payment system and which one?
And thanks for the link to your developments - now I'll sit down to study.

понедельник, 8 марта 2021 г. в 23:28:54 UTC+3, aj.a...@gmail.com:

Alan Wells

unread,
Mar 8, 2021, 4:33:18 PM3/8/21
to Google Apps Script Community
Because you plan on using very small payments of $2 a month, you should apply to PayPal for micropayments.
It's a little known option, and very hard to find.
Micropayments have a lower fee from PayPal.  If most or all of your prices are under a payment of $12 dollars
then you'll save money using micropayments.
In order to be approved, you must have a website with all your products listed and what they cost.
So, do that first, if you plan on applying.
In order to be approved for micropayments, you need to apply for a PayPal Payments Pro account.


I've read information that you shouldn't have multiple PayPal accounts.
It's tempting to have multiple PayPal accounts, but PayPal might not like it.
If you eventually have multiple add-ons that accept payments, you may want a way to separate out the transactions,
but don't create another PayPal account.

Both PayPal and Stripe have subscription service capability, which could make it easier to implement a payment system.
I'm not advocating for or against that.  Whatever works best for you.

Boris Baublys

unread,
Mar 8, 2021, 5:43:48 PM3/8/21
to Google Apps Script Community
Alan, thanks for the good advice.
But I'm not sure if I understand "you shouldn't have multiple PayPal accounts" correctly.
Do I need a PayPal business account? I already have a personal account. If I additionally create a business account, may PayPal not like it?

вторник, 9 марта 2021 г. в 00:33:18 UTC+3, aj.a...@gmail.com:

Alan Wells

unread,
Mar 8, 2021, 6:26:44 PM3/8/21
to Google Apps Script Community

Boris Baublys

unread,
Mar 9, 2021, 5:00:10 AM3/9/21
to Google Apps Script Community
Alan, thanks for your help.

вторник, 9 марта 2021 г. в 02:26:44 UTC+3, aj.a...@gmail.com:

Boris Baublys

unread,
Mar 13, 2021, 11:45:48 PM3/13/21
to Google Apps Script Community
Hi all. Alan, do you have a live demo page where you can see and try the final result? Like here: https://www.labnol.org/internet/sell-digital-products-online/28554/

вторник, 9 марта 2021 г. в 13:00:10 UTC+3, Boris Baublys:

Alan Wells

unread,
Mar 14, 2021, 10:54:52 AM3/14/21
to Google Apps Script Community
Unfortunately I don't have a code example that is well explained and tested for thoroughness,
and the current, up to date information.

Currently I'm using the PayPal payment system uses Smart Payment Buttons - See: 

  The two most important documentation links are:
  
  For configuration settings there is information at:
  
  Note that this PayPal implementation does NOT require there to be a button definition in your PayPal settings -
  PayPal has multiple different ways to set up a payment system, from basic to custom.
  Trying to create a generic example that would be generally usable would be difficult.

  The PayPal JavaScript client side SDK that I am using is newer than the checkout.js system.
  For an overview of the PayPal checkout with server integration -  

  It is very important to understand the "sandbox" and the "production" settings -

  There are multiple settings that must all be for either "sandbox" or "production"
  If you mix "sandbox" and "production" credentials and API links then your code will not work
  and the error messages may not help you to understand what the real problem is -
  
  Anything to do with "sandbox" is for testing purposes -
  "production" is for accepting live payments from customers -
  
  The terminology that PayPal uses for the credentials is:
  client id - The client side credential key
  secret - The server side credential key
  
  Credentials need to be in three different settings-
  1 - Client side script tag - client id
  2 - Server side variable - client id
  3 - Server side variable - secret
  
  To test your PayPal code you must do multiple things:
  1 - Create sandbox (test) client and secret credentials
  2 - use a special buyer PayPal account:

I do have some code at GitHub at:

But I haven't looked at that code for a while, and I don't know the status,
but it could give you some information.

I think that there are advantages of using both the client side PayPal SDK to create the PayPal buttons,
and the server side integration to complete the transaction.
Your Apps Script server code can inform you of a payment, or log an error, 
and of course server side code is not accessible to the browser.

Boris Baublys

unread,
Mar 14, 2021, 6:07:07 PM3/14/21
to Google Apps Script Community
Thank you very much, Alan, for such a detailed answer! Very valuable. I will delve into it.

воскресенье, 14 марта 2021 г. в 17:54:52 UTC+3, aj.a...@gmail.com:

Adam Morris

unread,
Mar 14, 2021, 6:23:43 PM3/14/21
to google-apps-sc...@googlegroups.com
Great stuff Alan!

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/601f379e-68d3-4777-8c7a-6b1fe59d9652n%40googlegroups.com.
--
Reply all
Reply to author
Forward
0 new messages