Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 33d3142

Browse files
committed
feat(lune-integration): Add Lune integration custom shipping code and transaction weebhook for CO2 shipping rate estimates and creating CO2 offset orders in Lune
1 parent 19f3df2 commit 33d3142

File tree

4 files changed

+707
-26
lines changed

4 files changed

+707
-26
lines changed

config.js

+34-26
Original file line numberDiff line numberDiff line change
@@ -13,56 +13,64 @@ function env(envVar) {
1313
const config = {
1414
datastore: {
1515
error: {
16-
insufficientInventory: env('FOXY_ERROR_INSUFFICIENT_INVENTORY') || env('FX_ERROR_INSUFFICIENT_INVENTORY'),
17-
priceMismatch: env('FOXY_ERROR_PRICE_MISMATCH') || env('FX_ERROR_PRICE_MISMATCH')
16+
insufficientInventory:
17+
env("FOXY_ERROR_INSUFFICIENT_INVENTORY") ||
18+
env("FX_ERROR_INSUFFICIENT_INVENTORY"),
19+
priceMismatch:
20+
env("FOXY_ERROR_PRICE_MISMATCH") || env("FX_ERROR_PRICE_MISMATCH"),
1821
},
1922
field: {
20-
code: env('FOXY_FIELD_CODE') || env('FX_FIELD_CODE'),
21-
inventory: env('FOXY_FIELD_INVENTORY') || env('FX_FIELD_INVENTORY'),
22-
price: env('FOXY_FIELD_PRICE') || env('FX_FIELD_PRICE')
23+
code: env("FOXY_FIELD_CODE") || env("FX_FIELD_CODE"),
24+
inventory: env("FOXY_FIELD_INVENTORY") || env("FX_FIELD_INVENTORY"),
25+
price: env("FOXY_FIELD_PRICE") || env("FX_FIELD_PRICE"),
2326
},
2427
provider: {
2528
orderDesk: {
2629
apiKey: env("FOXY_ORDERDESK_API_KEY"),
2730
storeId: env("FOXY_ORDERDESK_STORE_ID"),
2831
},
2932
webflow: {
30-
collection: env('FOXY_WEBFLOW_COLLECTION'),
31-
token: env('FOXY_WEBFLOW_TOKEN') || env('WEBFLOW_TOKEN'),
32-
}
33+
collection: env("FOXY_WEBFLOW_COLLECTION"),
34+
token: env("FOXY_WEBFLOW_TOKEN") || env("WEBFLOW_TOKEN"),
35+
},
3336
},
3437
skipUpdate: {
35-
inventory: env('FOXY_SKIP_INVENTORY_UPDATE_CODES')
38+
inventory: env("FOXY_SKIP_INVENTORY_UPDATE_CODES"),
3639
},
3740
skipValidation: {
38-
inventory: env('FOXY_SKIP_INVENTORY_CODES') || env('FX_SKIP_INVENTORY_CODES'),
39-
price: env('FOXY_SKIP_PRICE_CODES') || env('FX_SKIP_PRICE_CODES'),
40-
updateinfo: env('FOXY_SKIP_UPDATEINFO_NAME')
41+
inventory:
42+
env("FOXY_SKIP_INVENTORY_CODES") || env("FX_SKIP_INVENTORY_CODES"),
43+
price: env("FOXY_SKIP_PRICE_CODES") || env("FX_SKIP_PRICE_CODES"),
44+
updateinfo: env("FOXY_SKIP_UPDATEINFO_NAME"),
4145
},
4246
},
4347
default: {
44-
autoshipFrequency: env('FOXY_DEFAULT_AUTOSHIP_FREQUENCY') || env('DEFAULT_AUTOSHIP_FREQUENCY')
48+
autoshipFrequency:
49+
env("FOXY_DEFAULT_AUTOSHIP_FREQUENCY") ||
50+
env("DEFAULT_AUTOSHIP_FREQUENCY"),
4551
},
4652
foxy: {
4753
api: {
48-
clientId: env('FOXY_API_CLIENT_ID'),
49-
clientSecret: env('FOXY_API_CLIENT_SECRET'),
50-
refreshToken: env('FOXY_API_REFRESH_TOKEN')
54+
clientId: env("FOXY_API_CLIENT_ID"),
55+
clientSecret: env("FOXY_API_CLIENT_SECRET"),
56+
refreshToken: env("FOXY_API_REFRESH_TOKEN"),
5157
},
5258
webhook: {
53-
encryptionKey: env('FOXY_WEBHOOK_ENCRYPTION_KEY'),
54-
}
59+
encryptionKey: env("FOXY_WEBHOOK_ENCRYPTION_KEY"),
60+
},
5561
},
5662
idevAffiliate: {
57-
apiUrl: env('FOXY_IDEV_API_URL') || env('IDEV_API_URL'),
58-
secretKey: env('FOXY_IDEV_SECRET_KEY') || env('IDEV_SECRET_KEY'),
63+
apiUrl: env("FOXY_IDEV_API_URL") || env("IDEV_API_URL"),
64+
secretKey: env("FOXY_IDEV_SECRET_KEY") || env("IDEV_SECRET_KEY"),
65+
},
66+
lune: {
67+
apiKey: env("LUNE_API_KEY"),
5968
},
6069
vatlayer: {
61-
accessKey: env('VATLAYER_ACCESS_KEY'),
62-
}
63-
}
64-
70+
accessKey: env("VATLAYER_ACCESS_KEY"),
71+
},
72+
};
6573

6674
module.exports = {
67-
config
68-
}
75+
config,
76+
};
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Lune Integration for CO2 Offset Order creation
2+
3+
This Foxy.io-Lune integration provides you with:
4+
5+
- a **custom shipping code** to add to the Custom Shipping Code feature on your Foxy Store Admin [Shipping Page](https://admin.foxycart.com/admin.php?ThisAction=ShippingSetup), for getting live shipping rates with CO2 offset estimates. The code is on the `custom-shipping-code.js` file under this folder.
6+
- a **transaction webhook** to create an CO2 offset Order in Lune when a transaction is created.
7+
8+
## Usage
9+
10+
### Overview
11+
12+
- Sign up with Lune, and get an API key.
13+
- Create Foxy OAuth Client Integration on the [Foxy Admin Integrations page](https://admin.foxycart.com/admin.php?ThisAction=AddIntegration), and save the credentials.
14+
- Add the custom shipping code on your Foxy Store Admin [Shipping Page](https://admin.foxycart.com/admin.php?ThisAction=ShippingSetup), using the code on the `custom-shipping-code.js` file, filling in the data needed on the code from the OAuth client and Lune. There are other configuration variables that need data for the shipping code to work correctly, like the originAddress.
15+
- Deploy this repository to your Netlify account.
16+
- Set the environment variables
17+
- Deploy the site
18+
19+
You will also need to configure your Lune account default project bundles, and billing info.
20+
21+
### Deploy this repository to Netlify
22+
23+
1. Click the **Fork** button at the top right corner of this page
24+
2. Log in your Netlify account
25+
3. Add a new site and select the **Import an existing project** option
26+
4. Connect your GitHub account and choose your repository (the repository name should be something like `your-github-username/foxy-node-netlify-functions`)
27+
5. In the site settings, click the **Show advanced** button
28+
6. Under the Advanced build settings section, click the **New variable** button, yoyu will add two environment variables.
29+
7. In the Key field, enter `LUNE_API_KEY`
30+
8. In the Value field, enter your Lune API key
31+
9. Deploy the site
32+
33+
### Create a new Foxy Weebhok
34+
35+
After the deploy is complete, click the "functions" tab, look for the `lune-integration` function and copy the **Endpoint URL**.
36+
37+
Configure your webhook using your endpoint URL.
38+
39+
Specify a query string value within the `API filter query string` with the following parameters:
40+
41+
```
42+
zoom=applied_taxes,billing_addresses,custom_fields,customer,discounts,items,items:item_category,items:item_options,payments,shipments,attributes
43+
```
44+
45+
Then click on `Update Weebhooks Next`
46+
47+
## Upgrade your webhook
48+
49+
When new upgrades to this webhook are published, you can use the GitHub Action available in the "Actions" tab in your repository to upgrade your Webhook.
50+
51+
- Click the "Actions" tab. Agree to use GitHub Actions.
52+
- Click the SyncFork workflow and then "run workflow"
53+
54+
This will upgrade your repository.
55+
56+
If you've made customizations, there may be conflicts. In this case you can pull the changes and resolve the conflicts manually.

0 commit comments

Comments
 (0)