# Add a Billing API

**URL:** <https://discourse.sst.dev/t/add-a-billing-api/170>\
**Category:** Chapter Comments\
**Created:** [May 9, 2018, 11:17pm UTC](https://discourse.sst.dev/t/add-a-billing-api/170 "2018-05-09T23:17:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [May 9, 2018, 11:17pm UTC](https://discourse.sst.dev/t/add-a-billing-api/170/1 "2018-05-09T23:17:49Z")

</div>

Link to chapter - [https://serverless-stack.com/chapters/add-a-billing-api.html](https://serverless-stack.com/chapters/add-a-billing-api.html)

---

<div class="post-metadata">

**Author:** ![JLKoven](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jlkoven/32/227_2.png) [@JLKoven](https://discourse.sst.dev/u/JLKoven)\
**Post date:** [September 14, 2018, 12:50am UTC](https://discourse.sst.dev/t/add-a-billing-api/170/2 "2018-09-14T00:50:29Z")

</div>

So… if I understand the instructions correctly, we’re supposed to run **sudo npm install --save stripe** in **serverless-stack-2-api** then create a **billing.js** inside **serverless-stack-2-api**?

Because I ran **sudo npm install --save stripe** in both **serverless-stack-2-api** as well as the folder before it (the second run understandably failing due to lacking a **package.json** ), but I couldn’t find an existing **billing.js**

---

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [September 19, 2018, 6:32pm UTC](https://discourse.sst.dev/t/add-a-billing-api/170/3 "2018-09-19T18:32:41Z")

</div>

Yup this chapter deals with the backend API.

---

<div class="post-metadata">

**Author:** ![kpose](https://avatars.discourse-cdn.com/v4/letter/k/96bed5/32.png) [@kpose](https://discourse.sst.dev/u/kpose)\
**Post date:** [January 27, 2020, 3:57am UTC](https://discourse.sst.dev/t/add-a-billing-api/170/4 "2020-01-27T03:57:47Z")

</div>

Yes, you need the package for your backend API

---

<div class="post-metadata">

**Author:** ![victorgrubio](https://avatars.discourse-cdn.com/v4/letter/v/aeb1de/32.png) [@victorgrubio](https://discourse.sst.dev/u/victorgrubio)\
**Post date:** [June 28, 2020, 5:12pm UTC](https://discourse.sst.dev/t/add-a-billing-api/170/5 "2020-06-28T17:12:02Z")

</div>

Hi, found an issue with the stripe env variable. Stripe shows that API\_KEY was missing when using

```auto
const stripe = stripePackage(process.env.stripeSecretKey);

```

However, using the same name as in .env variable, it worked:

```auto
const stripe = stripePackage(process.env.STRIPE_SECRET_KEY);

```

Maybe is an issue on my system, but I think this should be reviewed and chnaged if procedes.

Regards!

---

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [July 2, 2020, 9:01pm UTC](https://discourse.sst.dev/t/add-a-billing-api/170/6 "2020-07-02T21:01:57Z")

</div>

Hmm that’s weird because in the next chapter ([https://serverless-stack.com/chapters/load-secrets-from-env.html](https://serverless-stack.com/chapters/load-secrets-from-env.html)) we do this:

```auto
environment:
    tableName: notes
    stripeSecretKey: ${env:STRIPE_SECRET_KEY}

```

And that sets it as `stripeSecretKey` for your code to use.

---

<div class="post-metadata">

**Author:** ![victorgrubio](https://avatars.discourse-cdn.com/v4/letter/v/aeb1de/32.png) [@victorgrubio](https://discourse.sst.dev/u/victorgrubio)\
**Post date:** [July 9, 2020, 6:13pm UTC](https://discourse.sst.dev/t/add-a-billing-api/170/7 "2020-07-09T18:13:21Z")

</div>

Yeah, the thing is I have added that to the environment but it didn´t work. I don’t know the reason, although the capital letters version works. Just for anyone having a the same issue.

---

<div class="post-metadata">

**Author:** ![paulfries](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/paulfries/32/941_2.png) [@paulfries](https://discourse.sst.dev/u/paulfries)\
**Post date:** [July 24, 2020, 5:07pm UTC](https://discourse.sst.dev/t/add-a-billing-api/170/8 "2020-07-24T17:07:07Z")

</div>

Can the Stripe option be “optional?”

Meaning is it possible to deploy the application as written without the billing portion?

---

<div class="post-metadata">

**Author:** ![jayair](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.sst.dev/jayair/32/9_2.png) [@jayair](https://discourse.sst.dev/u/jayair)\
**Post date:** [August 1, 2020, 6:06pm UTC](https://discourse.sst.dev/t/add-a-billing-api/170/9 "2020-08-01T18:06:24Z")

</div>

Yeah totally. You can ignore the Stripe call here and just pretend that the call was successful.
