Hello!
SheetKit is being built to be easy to use and to make your once-static websites come alive with server-side functionality.
To get started with SheetKit, you'll need to go through our checkout process. Once we fulfill your order, just open your Google spreadsheet. From inside you'll get your API key, enabling our JavaScript API as is detailed here. Please don't hesitate to contact us if we can help in any way!
SheetKit is in development and not quite ready.
—
Colin Mathews
Creator of SheetKit
@colinmathews
Place this script on your page and enter your API key.
<script data-sheetkit-key="[YOUR KEY]" src="//d209ue3xilo57p.cloudfront.net/1.0.0/sheetkit.js"></script>
Wrap all of your code in a call to SheetKit.ready
.
SheetKit.ready(function(err){
if (err)
return alert("Something's not quite right.");
// SheetKit is ready!
});
All operations are asynchronous and take two parameters: an object of options and a callback function. An optional third scope parameter can be passed so that this
refers to an object of your choice.
Each callback function take two arguments: an error object if something went wrong and a result.
A list of key-value options.
The callback function to invoke when the operation completes taking error and result.
The context to use for this
in the callback function.
service.operationName({
option1 : 'value'
}, function(err, result){
// Handle failure or success
}, this);
Most raw values can be specified as native JavaScript types such as
'John Doe'
, 5
, true
, and new Date()
.
You can store JSON strings in your spreadsheet by passing an object in your
operations. This could be useful, for instance, in storing variable user settings in a single spreadsheet column.
db.add({
sheet : 'Sheet1',
data : {
Text : 'Text value',
Numeric : 64,
Boolean : true,
Date : new Date(),
Json : {
field1 : 'value1'
},
// Here are the special types
Password : {
type : 'password',
value : 'thisismypassword'
},
Guid : {
type : 'guid',
value : ''
}
}
}, function(err, result){
// Handle failure or success
}, this);
id | Text | Numeric | Boolean | Date | Json | Password | Guid | created | updated |
---|---|---|---|---|---|---|---|---|---|
a95bfc6e-1b6d-eb2e-bc5c-df7613d81f27 | Text value | 64 | TRUE | 1/14/2015 2:31 PM | {"field1":"value1"} | {"type":"password","value":"du2uGj..uM="} | e3bad449-ac29-dd6a-d170-03cd00efe2fe | 1/14/2015 2:31 PM | 1/14/2015 2:31 PM |
Here are the special types you can use:
Creates a SHA-256 HMAC of the value so that it remains encrypted. Exact matching can be done on these fields. When rows with this type are queried, this field is omitted from the response.
Creates a unique, unguessable value.
Every sheet in your spreadsheet will automatically get and track the following fields:
A non-guessable id to uniquely identify a row.
The date when this row was created.
The date when this row was last updated.
id | created | updated |
---|---|---|
a95bfc6e-1b6d-eb2e-bc5c-df7613d81f27 | 1/14/2015 2:31 PM | 1/14/2015 2:31 PM |
Inside your spreadsheet you'll see a way to store a JSON-formatted configuration. This stores security information, secret values, and other details to make your sheet run just the way you need it to. Without a configuration, you'll get smart defaults: you'll be able to add rows, update them if you know their id, and run searches.
Here's a sample configuration that shows most of our features:
{
// Random characters used to securely store passwords.
// Changing this value will corrupt all password data in your spreadsheet.
"sheetKitSecret" : "somerandomcharactersandsymbols",
// Store the recaptcha secret for each website you use SheetKit on
"recaptcha" : {
"www.mywebsite.com" : {
"secret" : "abcdefghijklmnop"
}
},
// Info needed to integrate with Stripe
"stripe" : {
"live" : {
"publishableKey" : "pk_live_VM123456",
"secret" : "sk_live_7qabcdefgh"
},
"test" : {
"publishableKey" : "pk_test_pU4098765",
"secret" : "sk_test_jzSzxywvtabcdef"
}
},
// Info needed to send notifications
"notify" : {
"contactus" : {
"from" : "myteam@mycompany.com",
"to" : "support@mycompany.com",
"requireCaptcha" : false
}
},
"security" : {
// Pages that know this key can bypass all security
"godModeKeys" : ["thisisasecretkey"],
// Database security is implemented on a per-sheet basis
"sheets" : {
// Require captcha on this sheet when creating new rows.
// Only allow searching if an exact email and password combination is specified.
"Users" : {
"find" : ["Email Address", "Password"],
"recaptcha" : {
"add" : true
}
},
// Support for sheets with multiple words
"Multi Word Sheet Name" : {
// Allow searching, but rows won't be able to be modified
// because they'll be missing their id fields
"find" : "readonly"
},
// This sheet will not allow the "Color" column to be updated
"Favorite Colors" : {
"add" : false,
"readonly" : ["Color"]
},
// This sheet will be inaccessible to the API
"Movies" : {
"add" : false,
"updateOne" : false,
"find" : false
}
},
// Specify security for the SheetKit.Remote class
"remote" : {
// To disable this class altogther, just flip this setting
"enabled" : false,
// Restrict what urls can be accessed (case insensitive)
"urlsMustStartWith" : ["https://somedomain.com/api", "https://someotherdomain.com/api"],
// A collection of configurations to alter how requests are made
"config" : {
// Specifies how requests to MyFavoriteCloudService should be altered
"MyFavoriteCloudService" : {
// These values will be forced onto the HTTP request
"data" : {
"apiKey" : "abcdefghijklmnop"
}
},
// Another one
"Service2" : {
// Pass headers
"headers" : {
"Authorization" : "Basic ZnJlZDpmcmVk"
}
}
}
}
}
}
SheetKit was made to help you get up and running with supreme quickness. This convenience means a smart person could use your SheetKit API from their browser and programmatically add rows to your spreadsheet. For many use cases this isn't really a serious problem, but if you get to a point where it is, you're hopefully getting enough traction to outgrow SheetKit (hooray!). That being said, SheetKit has several security settings to help prevent abuse.
You can configure each sheet in your spreadsheet to have various levels of security. For each spreadsheet, these are the settings you can enable:
true
to allow adding to this sheet. Defaults to true
.
true
to allow rows to be updated on this sheet by their unique ID. Defaults to true
.
true
to allow multiple rows to be updated on this sheet by a query. Defaults to false
.
For increased security, you can allow mass updates, but require exact matches on
the fields queried so that end-users can only update
certain rows.
For instance, to update a "User" by their email
address and password, use ["Email address", "Password"]
.
true
to allow searching. Defaults to "readonly"
.
Set to "readonly"
to allow searching, but to not return
row ids so they cannot be subsequently updated.
For increased security, you can allow searching but require exact matching on specific fields.
For instance, to look "Users" up by their email
address and password, use ["Email address", "Password"]
.
true
to allow single rows to be removed from this sheet by their ids. Defaults to false
.
true
to allow multiple rows to be removed from this sheet by a query. Defaults to false
.
For increased security, you can allow mass removes, but require exact matches on
the fields queried so that end-users can only update
certain rows.
For instance, to remove a "User" by their email
address and password, use ["Email address", "Password"]
.
A list of fields (in addition to automatic fields) that cannot be modified by updates.
Here's a sample configuration to make a sheet named "Movies" read-only.
{
"security" : {
"sheets" : {
"Movies" : {
"add" : false,
"updateOne" : false
}
}
}
}
Here's a sample configuration to allow searching without returning row ids. Unique ids must be known to update or remove rows.
{
"security" : {
"sheets" : {
"Movies" : {
"find" : 'readonly'
}
}
}
}
Here's a sample to make a sheet named "Users" only searchable by an exact email address and password combination.
{
"security" : {
"sheets" : {
"Users" : {
"find" : ["Email address", "Password"]
}
}
}
}
Here's a sample to make a sheet named "Users" only updatable and removable by an exact email address and password combination (or their unique row id).
{
"security" : {
"sheets" : {
"Users" : {
"find" : ["Email address", "Password"],
"updateMany" : ["Email address", "Password"],
"removeMany" : ["Email address", "Password"]
}
}
}
}
In some cases you may want to allow operations, but help prevent programmatic abuse. You can set each operation to require a reCAPTCHA value from Google's free reCAPTCHA service.
First, you need to store your secret from Google so we can validate your requests. You will have a different secret for each website you use SheetKit on, so each secret is tied to the domain used.
{
"recaptcha" : {
"www.mywebsite.com" : {
"secret" : "abcdefghijklmnop"
},
"www.myotherwebsite.com" : {
"secret" : "zyxwfsdfkerusdfk"
}
}
}
Then, in your security settings for each sheet you can require reCAPTCHA values for various operations.
true
to require a reCAPTCHA value for add
operations to be allowed.
true
to require a reCAPTCHA value for updateOne
operations to be allowed.
true
to require a reCAPTCHA value for updateMany
operations to be allowed.
true
to require a reCAPTCHA value for find
operations to be allowed.
true
to require a reCAPTCHA value for removeOne
operations to be allowed.
true
to require a reCAPTCHA value for removeMany
operations to be allowed.
Here's a sample configuration to make a sheet named "Users" require reCAPTCHA values to create new rows and to disable searching. This is a great way to represent users in your database.
{
"security" : {
"sheets" : {
"Users" : {
"add" : true,
"find" : false,
"requireCaptcha" : {
"add" : true
}
}
}
}
}
And here's a sample add
call against this sheet. The recaptcha
value should come from Google's JavaScript reCAPTCHA service.
SheetKit.DB.add({
sheet : 'Users',
recaptcha : '...',
data : {
Username : 'user101',
Password : {
type : 'password',
value : 'thisismypassword'
}
}
}, function(err, row){
// Handle success or failure
});
Here's a really cool example. Using SheetKit's parsing, you can let SheetKit automatically plug in the user's recaptcha response.
<script src='https://www.google.com/recaptcha/api.js'></script>
<div id="add-user">
<input type="text" name="Username">
<input type="password" name="Password">
<div class="g-recaptcha" data-sitekey="[YOUR RECAPTCHA CLIENT KEY]"></div>
</div>
SheetKit.DB.add({
sheet : 'Users',
data : document.getElementById('add-user')
}, function(err, row){
// Handle success or failure
});
In some cases you may want a secret page that can perform all operations despite your security settings. Good examples include an admin panel for your site, a development-only website, or a personal site that won't be exposed to too many people.
In your security configuration, you can specify a list of "God mode" secret keys that if used, will bypass your security. Then your calling code just needs to send one of these keys for each operation.
Here's a sample configuration with a single God mode key that normally disallows all operations on the "Users" spreadsheet.
{
"security" : {
"godModeKeys" : ["thisisasecretkey"],
"sheets" : {
"Users" : {
"add" : false,
"find" : false,
"updateOne" : false
}
}
}
}
And here's a sample find
call against this sheet to list all rows.
db.find({
godMode : 'thisisasecretkey',
sheet : 'Users'
}, function(err, rows){
// All rows returned, even if find is not allowed
});
SheetKit can process payments via your Stripe account. Enable this capability by storing settings for live and/or test modes.
{
"stripe" : {
"live" : {
"publishableKey" : "pk_live_VM123456",
"secret" : "sk_live_7qabcdefgh"
},
"test" : {
"publishableKey" : "pk_test_pU4098765",
"secret" : "sk_test_jzSzxywvtabcdef"
}
}
}
SheetKit.Remote executes HTTP requests. You can configure security to enforce limitations and to alter requests as they are sent.
false
to disallow this service. Defaults to true
.
An array of url fragments that any executed request must start with (case ignored). If this is omitted or blank, any url will be allowed.
A series of configuration objects for named services.
Each key is the name of the configuration and can be anything you like.
The key is passed in for the configuration
parameter to
SheetKit.Remote.send.
Each configuration object can look like this:
A list of key-value pairs that will be added to any outgoing HTTP request. Use this to specify secret API keys.
A list of key-value pairs that will be added as headers to any outgoing HTTP request. Use this to specify API authentication or to configure how the service should respond.
Here's a sample way to configure a service with the user-defined key of "MyFavoriteCloudService":
{
"security" : {
"remote" : {
"config" : {
"MyFavoriteCloudService" : {
"data" : {
"apiKey" : "abcdefghijklmnop"
},
"headers" : {
"Authorization" : "Basic ZnJlZDpmcmVk"
}
}
}
}
}
}
And here's how you use this configuration:
var remote = new SheetKit.Remote();
remote.send({
url : '...',
configuration : 'MyFavoriteCloudService'
}, function(err, result){
// Handle failure or success
});
SheetKit.Notify allows you to send email notifications. In order to use this feature you must open your SheetKit spreadsheet and click the "Authorize Email Account" menu item.
The from address to send "contact us" emails from. When you go through your SheetKit spreadsheet's authorization menu item, this value will be defaulted to the Google account you authenticate with.
Who to send "contact us" emails to in your organization. When you go through your SheetKit spreadsheet's authorization menu item, this value will be defaulted to the Google account you authenticate with.
false
to disallow "contact us" emails. Defaults to true
.
true
to require the user pass Google's Recaptcha test. Defaults to false
.
Here's a sample configuration:
{
"notify" : {
"contactus" : {
"from" : "myteam@mycompany.com",
"to" : "support@mycompany.com"
}
}
}
The entry point of the API.
Sets up the page for working with SheetKit. All of your code should be wrapped inside a call to this method.
None.
SheetKit.ready(function(err){
if (err)
return alert("Something's not quite right.");
// SheetKit is ready!
});
Represents any error reported by the SheetKit framework.
You can detect this error using instanceof
.
A human-readable message indicating the problem.
True if this message can be displayed directly to end users.
if (err instanceof SheetKit.Error)
{
if (err.isFriendly)
alert(err.message);
else
alert('Something went wrong!');
}
Service to help with user interface interactions.
Reads an element and pulls out any form fields and translates them into a data object that can be used to create rows. Each form field with a "name" attribute will be read.
NOTE: Unlike most calls, this is a synchronous method call that accepts an HTMLElement and returns an object.
An HTMLElement to read data from.
You can alternatively specify a CSS selector like: "#my-forms .form-1"
A data object representing the form fields.
<div id="add-user">
<input type="text" name="Username">
<textarea name="Bio"></textarea>
<input type="password" name="Password">
<input type="checkbox" name="IsAdmin">
<select name="FavoriteColor">
<option>Blue</option>
<option>Red</option>
<option>Green</option>
</select>
</div>
var data = SheetKit.UI.parseForm('#add-user');
// Parsed data looks like this
{
Username : 'person101',
Bio : 'My bio...',
Password : {
type : 'password',
value : 'mypassword'
},
FavoriteColor : 'Blue'
}
Provides miscellaneous utilities.
Determines if the text that's given is a well-formed email address.
NOTE: Unlike most methods, this method is synchronous and takes a string input.
The text to examine.
True/false if this text represents an email
if (!SheetKit.Util.isValidEmail('person@example.com'))
alert('Please enter a valid email address');
You can optionally set this property if all of your operations on the database will be against a single spreadsheet sheet. This just saves you from entering it in each operation.
SheetKit.DB is a static class that lets you perform operations against your spreadsheet as if it were a database.
Creates new rows of data. Data fields that don't match columns in your spreadsheet are ignored.
The name of the sheet that houses this data in your spreadsheet.
An object of data to save for this row. Each key should match a column name in your spreadsheet (wrap the column name in quotes if it contains spaces).
You can pass in an HTML element and all of the form fields will be parsed using their "name" attribute.
You can also pass an array objects to add multiple rows at once. If so, the result will be an array of rows instead of just a single row.
The value of Google's reCAPTCHA response to prove that this request came from a human interaction.
To make this parameter truly useful, update your security configuration to require reCAPTCHA on this type of operation.
To bypass your security settings, enter a God mode key.
A SheetKit.Row object representing the created row.
SheetKit.DB.add({
sheet : 'Movies',
data : {
Title : 'What About Bob?',
Year : 1991
}
}, function(err, row){
// Handle failure or success
});
Pass in HTMLElements for the data
parameter and SheetKit
will parse form fields. Password fields are automatically converted to SheetKit
password types.
<script src='https://www.google.com/recaptcha/api.js'></script>
<div id="add-user">
<input type="text" name="Username">
<input type="password" name="Password">
<div class="g-recaptcha" data-sitekey="[YOUR RECAPTCHA CLIENT KEY]"></div>
</div>
SheetKit.DB.add({
sheet : 'Users',
data : document.getElementById('add-user')
}, function(err, row){
// Handle success or failure
});
Queries your spreadsheet to find matching rows. Queries are formed in a Mongo-esque style.
The name of the sheet that houses the data in your spreadsheet to be searched.
A query for finding rows that match certain characteristics.
False to enforce case-sensitivity in searching.
By default this is true
.
The value of Google's reCAPTCHA response to prove that this request came from a human interaction.
To make this parameter truly useful, update your security configuration to require reCAPTCHA on this type of operation.
To bypass your security settings, enter a God mode key.
An array of found SheetKit.Rows.
SheetKit.DB.find({
sheet : 'Movies',
query : {
Year : {
$gt : 1990
}
}
}, function(err, rows){
// Handle failure or success
});
Specify an object mapping field names to values you want to match. Multiple fields can be specified and the query will ensure ALL fields match. Here's a simple query that only finds movies named "Ghostbusters" with a release year of 1991.
SheetKit.DB.find({
sheet : 'Movies',
query : {
Title : 'Ghostbusters',
Year : 1991
}
}, function(err, rows){
// Handle failure or success
});
Complex data types can be specified in the same way that they were created. For instance, here's a query to match on a password field (the spreadsheet will store a HMAC of the password).
SheetKit.DB.find({
sheet : 'Users',
query : {
Username : 'myusername',
Password : {
type : 'password',
password : 'thisismypassword'
}
}
}, function(err, rows){
// Handle failure or success
});
Instead of simple matching, you can execute supported operators. For instance, here's a query to find movies that were released after 1990.
SheetKit.DB.find({
sheet : 'Movies',
query : {
Year : {
$gt : 1990
}
}
}, function(err, rows){
// Handle failure or success
});
And of course, you can specify multiple operators and multiple fields. The query below finds all movies released between 1985 and 1995 that were directed by Frank Oz.
SheetKit.DB.find({
sheet : 'Movies',
query : {
Year : {
$gt : 1985,
$lt : 1995
},
Director : 'Frank Oz'
}
}, function(err, rows){
// Handle failure or success
});
True if the field is an exact match to your value.
True if the field is not an exact match to your value.
True if the field is greater than your value.
True if the field is less than your value.
True if the field is greater than or equal to your value.
True if the field is less than or equal to your value.
True if the field is starts with your value. Mainly useful for basic string matching.
True if the field is ends with your value. Mainly useful for basic string matching.
True if the field is contains your value. Mainly useful for basic string matching.
True if the field matches your regular expression. Mainly useful for complex string matching.
Fetches a single row by its id value and returns null if the row does not exist.
The name of the sheet that houses this data in your spreadsheet.
The unique ID of this row.
A SheetKit.Row object if found, null otherwise.
SheetKit.DB.get({
sheet : 'Movies',
id : '...'
}, function(err, row){
// Handle failure or success
});
Updates a single row by its id. You can also call update
directly on SheetKit.Row objects.
The name of the sheet that houses this data in your spreadsheet.
The unique id of the row you want to update.
An object of data to save for this row. Each key should match a column name in your spreadsheet (wrap the column name in quotes if it contains spaces).
You can pass in an HTML element and all of the form fields will be parsed using their "name" attribute.
The value of Google's reCAPTCHA response to prove that this request came from a human interaction.
To make this parameter truly useful, update your security configuration to require reCAPTCHA on this type of operation.
To bypass your security settings, enter a God mode key.
A SheetKit.Row object representing the updated row.
SheetKit.DB.updateOne({
sheet : 'Movies',
id : '...',
data : {
Director : 'Frank Oz'
}
}, function(err, row){
// Handle failure or success
});
All update operations can utilize these special operators:
Increments the value by the amount given.
Increment the votes for this movie.
SheetKit.DB.updateOne({
sheet : 'Movies',
id : '...',
data : {
$inc : {
Votes : 1
}
}
}, function(err, row){
// Handle failure or success
});
Updates multiple rows by a query similar to the find operation. By default this is disabled. Update your security configuration to allow this operation.
The name of the sheet that houses this data in your spreadsheet.
The query to find rows to update.
False to enforce case-sensitivity in searching. By default this is true
.
An object of columns to update for the found rows. Each key should match a column name in your spreadsheet (wrap the column name in quotes if it contains spaces).
You can pass in an HTML element and all of the form fields will be parsed using their "name" attribute.
The value of Google's reCAPTCHA response to prove that this request came from a human interaction.
To make this parameter truly useful, update your security configuration to require reCAPTCHA on this type of operation.
To bypass your security settings, enter a God mode key.
A list of the updated SheetKit.Rows.
This example updates all movies released in 1990 and sets "Frank Oz" as their director.
SheetKit.DB.updateMany({
sheet : 'Movies',
query : {
Year : 1990
},
data : {
Director : 'Frank Oz'
}
}, function(err, rows){
// Handle failure or success
});
Removes a single row. You can also call a similar operation directly on SheetKit.Row objects. By default this is disabled. Update your security configuration to allow this operation.
The name of the sheet that houses this data in your spreadsheet.
The unique id of the row you want to remove.
The value of Google's reCAPTCHA response to prove that this request came from a human interaction.
To make this parameter truly useful, update your security configuration to require reCAPTCHA on this type of operation.
To bypass your security settings, enter a God mode key.
None.
SheetKit.DB.removeOne({
sheet : 'Movies',
id : '...'
}, function(err, row){
// Handle failure or success
});
Removes multiple rows by a query similar to the find operation. By default this is disabled. Update your security configuration to allow this operation.
The name of the sheet that houses this data in your spreadsheet.
The query to find rows to remove.
False to enforce case-sensitivity in searching. By default this is true
.
The value of Google's reCAPTCHA response to prove that this request came from a human interaction.
To make this parameter truly useful, update your security configuration to require reCAPTCHA on this type of operation.
To bypass your security settings, enter a God mode key.
A count of the number of rows that were deleted
This example removes all movies released in 1990.
SheetKit.DB.removeMany({
sheet : 'Movies',
query : {
Year : 1990
}
}, function(err, count){
// Handle failure or success
});
Represents a single row in your spreadsheet.
The name of the sheet that this row belongs to.
The data stored in this row including the generated column "id" which is this row's unique identifier.
The SheetKit.Row constructor can be used to set properties.
var row = new SheetKit.Row({
sheet : 'Movies',
data : {
Title : 'What About Bob?',
Year : 1991
}
});
Persists the data in this object as a new row. SheetKit.DB.add is the preferred way of adding rows but this works, too!
No options are needed, but the sheet
and data
properties
for this row must be set.
The value of Google's reCAPTCHA response to prove that this request came from a human interaction.
To make this parameter truly useful, update your security configuration to require reCAPTCHA on this type of operation.
To bypass your security settings, enter a God mode key.
Your row object will have been updated with its new id, but for convenience it is also sent as a result to this operation.
var row = new SheetKit.Row({
sheet : 'Movies',
data : {
Title : 'What About Bob?',
Year : 1991
}
});
row.add({}, function(err, row){
// Handle failure or success
});
Attempts to find this row and udpate its contents.
No options are needed, but the sheet
and data
properties
for this row must be set.
Your row object will automatically be updated with it's latest data, but for convenience it is also sent as a result to this operation. If this row no longer exists, null will be returned instead of this row object.
var row = new SheetKit.Row();
row.get({
sheet : 'Movies',
id : '46d5c062-9b89-9a12-c577-64d81a33fb4c'
}, function(err, row){
// Handle failure or success
});
Updates the spreadsheet row with data in this object. This can
only be called if sheet
and data
properties are set.
The data to update for this row. Any missing parameters will be left as they were.
You can pass in an HTML element and all of the form fields will be parsed using their "name" attribute.
The value of Google's reCAPTCHA response to prove that this request came from a human interaction.
To make this parameter truly useful, update your security configuration to require reCAPTCHA on this type of operation.
To bypass your security settings, enter a God mode key.
Your row object will have been updated, but for convenience it is also sent as a result to this operation.
row.update({
data : {
Director : 'Frank Oz'
}
}, function(err, row){
// Handle failure or success
});
Removes this row from the spreadsheet. By default this is disabled. Update your security configuration to allow this operation.
No options are needed, but the sheet
and data
properties
for this row must be set.
The value of Google's reCAPTCHA response to prove that this request came from a human interaction.
To make this parameter truly useful, update your security configuration to require reCAPTCHA on this type of operation.
To bypass your security settings, enter a God mode key.
None.
row.remove({}, function(err){
// Handle failure or success
});
First, make sure you've set up your payment configuration settings. SheetKit.Pay is a static class that lets you process credit card transactions.
Charges someone's credit card. If a Stripe customer ID is given,
the customer's on-file credit card will be charged and the credit card field won't be required.
Otherwise, unless you specify dontCreateCustomer
, a new Stripe customer will be created so that you can charge their card
again later.
The amount to charge.
False to run live charges, otherwise everything runs in Stripe's test environment.
The description of what's being charged. Your customers can see this text.
The email where receipts will be sent for this customer.
The 3-character identifier for the currency of this transaction.
The description that will be displayed on the customer's credit card statement for this charge.
True if you don't want Stripe to store this credit card for future use.
Specifies an existing customer in Stripe that you'd like to charge.
If this value is specified, you can omit the card
field
and the customer's on-file card will be charged.
NOTE: not required if stripeCustomerID
is used
Pass in a form element to collect data like this Stripe tutorial.
Or pass an object representing the details of a credit card:
The credit card number.
The security code for this card.
The two-digit expiration month of the card.
The four-digit expiration year of the card.
Information about the customer and created charge.
SheetKit.Pay.chargeCard({
testMode : true,
total : 24,
description : 'Widget #1',
card : {
number : '4242424242424242',
code : '123',
expMonth : '12',
expYear : '2018'
}
}, function(err, result){
// Result might look like:
{
"stripeChargeID": "ch_15Ry43B9GmHV5skzyANVlxnT",
"stripeCustomerID": "cus_5dEX7XRSbOxFzO",
"amount": 2,
"testMode": true,
"cardBrand": "Visa",
"last4": "4242",
"expMonth": 12,
"expYear": 2015
}
});
Enrolls someone in one of your recurring subscription plans in Stripe. If a Stripe customer ID is given, the customer's on-file credit card will be charged and the credit card field won't be required. Otherwise a new Stripe customer will be created.
The Stripe ID of the subscription plan.
False to run live charges, otherwise everything runs in Stripe's test environment.
An email address for this customer where receipts will be sent.
The default currency for this customer. This parameter is only applied
when creating new Stripe customers. If using stripeCustomerID
, their
settings will remain as they already were.
A Stripe coupon code to apply.
The date when this subscription's free trial will end and the subscription charge
will be executed. You can specify the string "now"
to
expire a trial immediately.
Not usually used, but you can multiple a customer's subscription cost by setting a quantity higher than 1. For example, if your plan is $10/user/month, and your customer has 5 users, you could pass 5 as the quantity to have the customer charged $50 (5 x $10) monthly.
Add a tax percentage to your subscription (specify a number between 1 and 100).
Specifies an existing customer in Stripe that you'd like to charge.
If this value is specified, you can omit the card
field
and the customer's on-file card will be charged.
NOTE: not required if stripeCustomerID
is used
Pass in a form element to collect data like this Stripe tutorial.
Or pass an object representing the details of a credit card:
The credit card number.
The security code for this card.
The two-digit expiration month of the card.
The four-digit expiration year of the card.
The result of the customer and subscription created.
SheetKit.Pay.subscribe({
testMode : true,
plan : 'pro',
card : {
number : '4242424242424242',
code : '123',
expMonth : '12',
expYear : '2018'
}
}, function(err, result){
// Result might look like:
{
"stripeSubscriptionID": "sub_5dSPkiWpv7NaHz",
"stripeCustomerID": "cus_5dSOiC7wGrTF0z",
"stripePlanID": "pro",
"stripePlanName": "Pro",
"testMode": true
}
});
Update's a customer's on-file credit card.
False to run live charges, otherwise everything runs in Stripe's test environment.
Specifies the customer in Stripe that you'd like to update.
An object representing the details of a credit card:
The credit card number.
The security code for this card.
The two-digit expiration month of the card.
The four-digit expiration year of the card.
None.
SheetKit.Pay.updateCard({
testMode : true,
stripeCustomerID : '...',
card : {
number : '4242424242424242',
code : '123',
expMonth : '12',
expYear : '2018'
}
}, function(err, result){
});
This never needs to be called, but doing so will make the first operation on SheetKit.Pay execute faster.
NOTE: Unlike most methods, this method executes synchronously (no need for a callback).
Specifies the publishable key from Stripe for test mode.
Specifies the publishable key from Stripe for live transactions.
None.
SheetKit.Pay.setPublishableKeys({
testPublishableKey : 'pk_test_pU4098765',
livePublishableKey : 'pk_live_VM123456'
});
SheetKit.Notify is a static class that lets you send email notifications.
Send a "contact us" email from the end user to your team.
The email address of your end user.
The message they'd like to send to you.
If you'd like your end users to pass Recaptcha, send in their recaptcha value here.
Instead of sending in email, message, and recaptcha, you can send in your form element instead.
None.
SheetKit.Notify.contactUs({
email : "john@customer.com",
message : "Hello there! I have a question..."
}, function(err, result){
});
SheetKit.Pay is a static class to interact with remote resources like APIs.
Send remote HTTP requests from your spreadsheet and have the response proxied back to you.
In addition to getting around cross-origin problems, you can integrate with most any HTTP-based API. With some configuration, you can store secret values privately in your spreadsheet's settings (API keys for instance).
The url to send this request to.
The HTTP method to send (POST, GET, PUT, DELETE, etc.). Default is GET
.
A list of key-value pairs that will be sent as your HTTP payload.
The type of data you expect the service to respond with: json
,
xml
, plain
, or base64
.
By default this is false
and any response that represents a failure
will result in an error object. If you need to parse the raw response for errors
yourself, set this to true
.
Invokes the security options defined in your configuration so secret API keys can be added to requests or other customization can be performed.
True to include the response headers in our result. Default is false
.
The value of Google's reCAPTCHA response to prove that this request came from a human interaction.
To make this parameter truly useful, update your security configuration to require reCAPTCHA on this type of operation.
Information about the response.
SheetKit.Remote.send({
url : '...',
method : 'POST',
data : {
param1 : 'value'
},
getHeaders : true,
format : 'json'
}, function(err, result){
// Result might look like:
{
headers : {
header1 : 'value'
},
response : {
// JSON from the service
}
}
});