|
1 | 1 | # Netlify Serverless Functions for the Foxy.io API
|
2 | 2 |
|
3 |
| -This repository allows you to (more) easily create serverless functions to work with the Foxy.io API, deployed using Netlify. The goal is to make this as approachable as possible, so we try to have reasonable default behaviours, and Netlify is a great choice because of the one-click deployment. Once you deploy to Netlify, you can modify your own GitHub files to customize as needed. |
| 3 | +This repository allows you to (more) easily create serverless functions to work with the Foxy.io API, deployed using Netlify. |
| 4 | +The goal is to make this as [approachable](#Built to be approachable) as possible, so we try to have reasonable default behaviours, and Netlify is a great choice because of the one-click deployment. |
| 5 | +Once you deploy to Netlify, you can modify your own GitHub files to customize as needed. |
| 6 | + |
| 7 | +You may use this repository: |
| 8 | +- directly, configuring it to your needs with environment variables |
| 9 | +- as usage examples, to better understand the usage of Foxy API and FoxySDK. |
4 | 10 |
|
5 | 11 | ## Functions
|
6 | 12 |
|
7 |
| -The functions provided in this repository can be used independently, or as a reference for building your own functions. Be sure to check the README for each function in the functions folder. |
| 13 | +The functions provided in this repository are used independently. |
| 14 | + |
| 15 | +Be sure to check the README for each function in the functions folder, as they provide specific documentation. |
8 | 16 |
|
9 |
| -- [cart](src/functions/cart): Converts a cart between recurring and non-recurring. Useful in an upsell flow. |
10 |
| -- [idevaffiliate-marketplace](src/functions/idevaffiliate-marketplace): A marketplace-style integration, using iDevAffiliate. |
11 | 17 | - Datastore integrations:
|
12 |
| - - [pre-payment-webhook-webflow](src/functions/pre-payment-webhook-webflow): Validates the price and/or availability of items against Webflow CMS collections before a payment is processed. |
| 18 | + - [datastore-integration-webflow](src/functions/pre-payment-webhook-webflow): Validates the price and/or availability of items against Webflow CMS collections before a payment is processed. |
13 | 19 | - [datastore-integration-orderdesk](src/functions/datastore-integration-orderdesk): Validates the cart against OrderDesk and updates the inventory upon successful transaction.
|
14 |
| -- [ShipTheory](src/functions/shiptheory): Creates shipments in your ShipTheory account upon successful transactions. |
| 20 | +- Other features: |
| 21 | + - [cart](src/functions/cart): Converts a cart between recurring and non-recurring. Useful in an upsell flow. |
| 22 | + - [idevaffiliate-marketplace](src/functions/idevaffiliate-marketplace): A marketplace-style integration, using iDevAffiliate. |
| 23 | + - [shiptheory](src/functions/shiptheory): Creates shipments in your ShipTheory account upon successful transactions. |
15 | 24 |
|
16 | 25 |
|
17 | 26 | ### Data Store Integrations
|
@@ -61,9 +70,74 @@ The pre-payment webhook fires before a transaction is submitted to the payment p
|
61 | 70 | - To do this, after the deploy is finished, click the "functions" tab, look for your webhook function and copy the **Endpoint URL**.
|
62 | 71 | 1. Configure your prepayment webhook using your endpoint. Check the docs here: https://wiki.foxycart.com/v/2.0/pre_payment_webhook
|
63 | 72 |
|
| 73 | +# Configuration Reference |
| 74 | + |
| 75 | +This section contains all **environment variables** you can use to configure the webhooks in this repository. |
| 76 | + |
| 77 | +**You do not need to configure all these.** Check the documentation for the functions you are using for the configuration relevant to them. |
| 78 | + |
| 79 | +This list is provided for your quick reference. |
| 80 | + |
| 81 | +**Please, note** that the default values for these variables may be different for each function. |
| 82 | +We try to have sensible defaults for each third party service we are integrating with and for each task we are performing. |
| 83 | + |
| 84 | +## How to set **environment variables** in Netlify |
| 85 | + |
| 86 | +These are set with **environment variables** that you can set directly in Netlify dashboard. |
| 87 | + |
| 88 | +To configure your **environment variables** follow these steps: |
| 89 | +- go to your site admin dashboard in Netlify |
| 90 | +- click "Site settings" button |
| 91 | +- click the "Build & deploy" tab in the left menu |
| 92 | +- under **Environment**, click "Edit variables" |
| 93 | + |
| 94 | +Please, notice that the default values where chosen to match the default OrderDesk settings. |
| 95 | +You shouldn't need to change these values unless you are not using OrderDesk default fields. |
| 96 | + |
| 97 | +This section contains all possible customizations you can do by setting environment variables. |
| 98 | + |
| 99 | +After changing your environment variables you will want to redeploy your webhook. |
| 100 | + |
| 101 | +| Environment Variable | Description | |
| 102 | +| ------- | --- | |
| 103 | +|`FOXY_API_CLIENT_ID`| [description in Foxy Webhook doc](src/foxy/README.md#environment-variables)| |
| 104 | +|`FOXY_API_CLIENT_SECRET`| [description in Foxy Webhook doc](src/foxy/README.md#environment-variables)| |
| 105 | +|`FOXY_API_REFRESH_TOKEN`| [description in Foxy Webhook doc](src/foxy/README.md#environment-variables)| |
| 106 | +|`FOXY_DEFAULT_AUTOSHIP_FREQUENCY`|[description in Cart doc](src/functions/cart#environment-variables)| |
| 107 | +|`FOXY_ERROR_INSUFFICIENT_INVENTORY`| [description in Foxy Webhook doc](src/foxy/README.md#environment-variables)| |
| 108 | +|`FOXY_ERROR_PRICE_MISMATCH`| [description in Foxy Webhook doc](src/foxy/README.md#environment-variables)| |
| 109 | +|`FOXY_FIELD_CODE`| [description in Foxy Webhook doc](src/foxy/README.md#environment-variables)| |
| 110 | +|`FOXY_FIELD_INVENTORY`| [description in Foxy Webhook doc](src/foxy/README.md#environment-variables)| |
| 111 | +|`FOXY_FIELD_PRICE`| [description in Foxy Webhook doc](src/foxy/README.md#environment-variables)| |
| 112 | +|`FOXY_IDEV_API_URL`|[description in Idev Affiliate doc](src/functions/idevaffiliate-marketplace/README.md#environment-variables)| |
| 113 | +|`FOXY_IDEV_SECRET_KEY`|[description in Idev Affiliate doc](src/functions/idevaffiliate-marketplace/README.md#environment-variables)| |
| 114 | +|`FOXY_ORDERDESK_API_KEY`|[description in Idev Affiliate doc](src/functions/datastore-integration-orderdesk/README.md#environment-variables)| |
| 115 | +|`FOXY_ORDERDESK_STORE_ID`|[description in Idev Affiliate doc](src/functions/datastore-integration-orderdesk/README.md#environment-variables)| |
| 116 | +|`FOXY_SKIP_INVENTORY_CODES`| [description in Foxy Webhook doc](src/foxy/README.md#environment-variables)| |
| 117 | +|`FOXY_SKIP_INVENTORY_UPDATE_CODES`| [description in Foxy Webhook doc](src/foxy/README.md#environment-variables)| |
| 118 | +|`FOXY_SKIP_PRICE_CODES`| [description in Foxy Webhook doc](src/foxy/README.md#environment-variables)| |
| 119 | +|`FOXY_WEBFLOW_TOKEN`|[description in Idev Affiliate doc](src/functions/datastore-integration-webflow/README.md#environment-variables)| |
| 120 | +|`FOXY_WEBHOOK_ENCRYPTION_KEY`| [description in Foxy Webhook doc](src/foxy/README.md#environment-variables)| |
64 | 121 |
|
65 | 122 | # Development
|
66 | 123 |
|
| 124 | +## Built to be approachable |
| 125 | + |
| 126 | +This repository aims to used as a reference to users who wish to extend their use of Foxy by adding custom server-side features. |
| 127 | + |
| 128 | +Here are some choices we've made: |
| 129 | + |
| 130 | +- Javascript: the language is approachable in itself and widely known. |
| 131 | +- Netlify: provides easy deployment and continuous integration with near zero configuration. |
| 132 | +- Default behaviours: are set in according to the task, tunned to feel natural for users of the tools each function is integrating with |
| 133 | +- Specific instructions: each function has its own README file that should be the only required reading to implement that function. This does not mean we will repeat instructions everywhere, but simply that by reading the docs of the function user will find everything needed, either on that page or on clearly provided links. |
| 134 | + |
| 135 | +These are some goals: |
| 136 | + |
| 137 | +- users should be able to navigate the code with ease, without usage or knowledge of advanced tools |
| 138 | +- users should be able to copy and customize code with relative ease, without the need |
| 139 | + |
| 140 | + |
67 | 141 | ## Localdev Setup
|
68 | 142 |
|
69 | 143 | 1. `npm install -g netlify-cli`
|
|
0 commit comments