summaryrefslogtreecommitdiffstats
path: root/functions/createCharge.js
diff options
context:
space:
mode:
Diffstat (limited to 'functions/createCharge.js')
-rw-r--r--functions/createCharge.js19
1 files changed, 9 insertions, 10 deletions
diff --git a/functions/createCharge.js b/functions/createCharge.js
index ecd22a1..215f8de 100644
--- a/functions/createCharge.js
+++ b/functions/createCharge.js
@@ -3,15 +3,15 @@ const graphCoolEndpoint = 'https://api.graph.cool/simple/v1/cj5xz8szs28930145gct
require('isomorphic-fetch')
-const query = `
-query SingleItem {
- Item(id: "cj64bs7vuuqgu0116ul5cm223") {
- price
- }
-}
-`;
+const getPrice = (itemId) => {
+ const query = `
+ query SingleItem {
+ Item(id: "${itemId}") {
+ price
+ }
+ }
+ `;
-const getPrice = (id) => {
return fetch('https://api.graph.cool/simple/v1/cj5xz8szs28930145gct82bdj', {
method: 'post',
headers: {
@@ -33,7 +33,7 @@ const createStripeCharge = (token, amount) => {
module.exports = function(event) {
return new Promise((resolve, reject) => {
// first find out the price of the item
- getPrice()
+ getPrice(event.data.itemId)
.then(res => res.json())
.then(res => {
console.log(`Back with the price ${res.data.Item.price}!`);
@@ -43,7 +43,6 @@ module.exports = function(event) {
console.log(`Back! charge ${res.id} for the amount ${res.amount}`);
event.data.charge = res.id;
event.data.amount = res.amount;
- console.log(event.data);
resolve(event);
})
.catch(err => {