summaryrefslogtreecommitdiffstats
path: root/functions
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2017-08-08 22:09:05 -0400
committerWes Bos <wesbos@gmail.com>2017-08-08 22:09:05 -0400
commit222ab374d53a206332b1ab51c7c43f6d5dc7a31e (patch)
tree2b446d96bfc6c7efab07f3d0fbb84d96ecb1253b /functions
yep
Diffstat (limited to 'functions')
-rw-r--r--functions/createCharge.js32
-rw-r--r--functions/index.js2
2 files changed, 34 insertions, 0 deletions
diff --git a/functions/createCharge.js b/functions/createCharge.js
new file mode 100644
index 0000000..2e9f7d4
--- /dev/null
+++ b/functions/createCharge.js
@@ -0,0 +1,32 @@
+const fetch = require('isomorphic-fetch')
+const stripe = require('stripe')('sk_ycLkGc2cAaBDSCKkHiKVBeT71CMxd')
+
+const graphCoolEndpoint = 'https://api.graph.cool/simple/v1/cj5xz8szs28930145gct82bdj'
+
+const createStripeCharge = (token, email = 'wesbos@gmail.com') => {
+ console.log(`Creating stripe charge for ${email}`)
+ return new Promise((resolve, reject) => {
+ stripeCharge = stripe.charges.create({
+ amount: '99999',
+ currency: 'usd',
+ description: 'You Rock 😘',
+ source: 'tok_visa'
+ }, (err, charge) => {
+ if (err) {
+ console.log(`Error creating Stripe charge: ${JSON.stringify(err)}`)
+ reject(err)
+ } else {
+ console.log(`Successfully created Stripe charge: ${charge.id}`);
+ console.log(charge);
+ }
+ })
+ })
+ }
+
+createStripeCharge();
+
+module.exports = function(event) {
+ event.data.charge = 'DEF456';
+ console.log(event.data)
+ return { data: event.data }
+}
diff --git a/functions/index.js b/functions/index.js
new file mode 100644
index 0000000..ee451f6
--- /dev/null
+++ b/functions/index.js
@@ -0,0 +1,2 @@
+module.exports = () => 'Welcome to Micro'
+exports.what = () => 'What'