|
1 | 1 | # Netlify Serverless Functions for the Foxy.io API
|
2 | 2 |
|
3 |
| -This repository allows for easily creating serverless functions to work with the Foxy.io API, deployed using Netlify. The goal is to make this as approachable as possible, so we're avoiding unnecessary |
| 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. |
4 | 4 |
|
5 | 5 | ## Functions
|
6 | 6 |
|
7 |
| -The functions provided in this repository can be used independently, or as a reference for building your own functinos. |
8 |
| -Be sure to check the README for each function in the functions folder. |
| 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. |
9 | 8 |
|
10 |
| -- [cart](src/functions/cart): Converts a cart between recurring and non-recurring. |
11 |
| -- [idevaffiliate-marketplace](src/functions/idevaffiliate-marketplace): |
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. |
| 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 | +- 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. |
| 13 | + - [datastore-integration-orderdesk](src/functions/datastore-integration-orderdesk): Validates the cart against OrderDesk and updates the inventory upon successful transaction. |
| 14 | + |
| 15 | +### Data Store Integrations |
| 16 | + |
| 17 | +Data store integrations allow you to verify the cart against a third-party Data Store. |
| 18 | + |
| 19 | +Your customer workflow is basically unchanged. |
| 20 | + |
| 21 | +The image below shows the order flow, with the gray steps showing the functionality provided by these functions (invisible to the customer). Notice that upon cart submit the pre-payment validation is triggered. The webhook makes a request to this function, which then gets the inventory and price information from your data store (Webflow or OrderDesk), and checks if the cart is valid. |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | +- You may choose not to validate prices at all or for specific items. |
| 26 | +- You may choose not to validate the inventory. |
| 27 | +- Depending on your data store, you may have other configuration available. |
| 28 | + |
| 29 | + |
| 30 | +#### Available DataStores |
| 31 | + |
| 32 | +- [OrderDesk](https://www.orderdesk.com) |
| 33 | +- [Webflow CMS](https://webflow.com) |
| 34 | + |
| 35 | +#### The Foxy Pre-Payment Webhook |
| 36 | + |
| 37 | +The pre-payment webhook fires before a transaction is submitted to the payment processor (Stripe, Authorize.net, PayPal, etc.). We'll use that with these functions to prevent overselling, and also to prevent product link/form tampering if you can't use Foxy's [link+form signing](https://wiki.foxycart.com/v/2.0/hmac_validation) (either directly or via [the Cloudflare Worker hmac signing function](https://github.com/Foxy/foxy-cloudflare-addtocart-signing) to do it automatically). |
| 38 | + |
| 39 | +**It ignores existing subscriptions**. If a subscription start date is "today", the price will be checked. If it is in the past, the price is not checked. |
| 40 | + |
| 41 | +#### Limitations |
| 42 | + |
| 43 | +- It does not handle discounts. |
| 44 | +- It does not handle item options, such as `price_mod`. |
| 45 | +- Due to netlify time limit, and the need to make requests to the datastore, it |
| 46 | + may break against large product databases if the Datastore do not allow for |
| 47 | + requesting specific items directly. Check the README for your datastore |
| 48 | + integration about this issue. |
| 49 | + |
| 50 | +#### Usage |
| 51 | + |
| 52 | +1. Read the short **Configuration** section in the datastore integration page. |
| 53 | + - **Important**: Your datastore must meet some criteria for the webhook to work. Product items need a `code` field. |
| 54 | +1. Grab the credentials needed for integrating with your datastore. Check the details in your datastore integration page. |
| 55 | +1. Click the **deploy to Netlify** button at the end of this page. |
| 56 | + - Netlify will provide you with a form for you to provide your configuration. |
| 57 | + - The Webflow Prepayment Webhook requires only `FOXY_WEBFLOW_TOKEN`. The other settings are used for the other services in this repository. |
| 58 | +1. Grab the URL for your webhook in Netlify. Be sure to get the correct URL for your specific webhook. |
| 59 | + - To do this, after the deploy is finished, click the "functions" tab, look for your webhook function and copy the **Endpoint URL**. |
| 60 | +1. Configure your prepayment webhook using your endpoint. Check the docs here: https://wiki.foxycart.com/v/2.0/pre_payment_webhook |
| 61 | + |
| 62 | + |
| 63 | +# Development |
13 | 64 |
|
14 | 65 | ## Localdev Setup
|
15 | 66 |
|
|
0 commit comments