summaryrefslogtreecommitdiffstats
path: root/functions/createCharge.js
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2017-10-27 10:10:49 -0400
committerWes Bos <wesbos@gmail.com>2017-10-27 10:10:49 -0400
commitacdfa2840f867e686471a8e9ac3f29353fab7dd1 (patch)
tree1a069ce11e145d9b286084221951272511debbdf /functions/createCharge.js
parent6f44adb59d3542eb21e55e0aae789b1fcc7cf8f1 (diff)
hi
Diffstat (limited to 'functions/createCharge.js')
-rw-r--r--functions/createCharge.js23
1 files changed, 11 insertions, 12 deletions
diff --git a/functions/createCharge.js b/functions/createCharge.js
index 215f8de..8dee76b 100644
--- a/functions/createCharge.js
+++ b/functions/createCharge.js
@@ -1,9 +1,10 @@
const stripe = require('stripe')('sk_ycLkGc2cAaBDSCKkHiKVBeT71CMxd')
-const graphCoolEndpoint = 'https://api.graph.cool/simple/v1/cj5xz8szs28930145gct82bdj'
+;
+const endpoint = 'https://api.graph.cool/simple/v1/cj5xz8szs28930145gct82bdj';
-require('isomorphic-fetch')
+require('isomorphic-fetch');
-const getPrice = (itemId) => {
+const getPrice = itemId => {
const query = `
query SingleItem {
Item(id: "${itemId}") {
@@ -12,23 +13,21 @@ const getPrice = (itemId) => {
}
`;
- return fetch('https://api.graph.cool/simple/v1/cj5xz8szs28930145gct82bdj', {
+ return fetch(endpoint, {
method: 'post',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ query }),
- })
-}
+ });
+};
-const createStripeCharge = (token, amount) => {
- return stripe.charges.create({
+const createStripeCharge = (token, amount) => stripe.charges.create({
amount,
currency: 'usd',
description: `a test charge`,
source: token
- })
-}
+ });
module.exports = function(event) {
return new Promise((resolve, reject) => {
@@ -47,6 +46,6 @@ module.exports = function(event) {
})
.catch(err => {
reject(err);
- })
+ });
});
-}
+};