- Introduction
- How to prepare the environment
- How it works
- Changes made to integrate with Voucherify and Contentful
This showcase application is a Proof of Concept of integration between Emporix, Voucherify and Contentful. This showcase shows how you could use Voucherify promotion engine if you have Emporix store. Additionally, this integration uses Contentful to manage vouchers, promotion tiers and campaigns descriptions. This is possible because Voucherify standalone codes, promotion tiers and campaigns contains references to CMS documents in the metadata.
The Emporix showcase is a client-side application. We have used direct connections to server-side APIs from the front-end application to build this PoC integration faster. Please remember that it's not recommended for production applications as it exposes Emporix, Voucherify and Contentful server-side API keys, which is a major security threat. So please, keep access to this showcase only for trusted users and do not use API keys to production environments.
We use contentful to store descriptions of each voucher, promotion tier and campaign. So simply, when we get qualification, we do a request asking contentful for the promotion description to show to a client. We do that because CMS like Contentful itself makes it easy to manage any content.
Each standalone code, promotion tier and campaign in Voucherify needs a reference to a corresponding document in Contentful. We have prepared a migration script that creates Contentful documents to make an initial configuration easier. Please refer to 2.2.1 section where are more details.
Qualifications are vouchers and promotions that a customer can use immediately or after meeting certain conditions.
Qualification scenarios we use:
- AUDIENCE_ONLY - gives all redeemables that match the given context(customer) considering only the customer's audiences. Does not verify other rules.
- PRODUCTS - gives all that can be applied for the given order(cart). Does not verify rules, just gives by matching products ids.
- CUSTOMER_WALLET - gives all redeemables that are belong to the given customer and match the given context (customer, cart). Verifies the most number of rules.
- ALL - gives all redeemables that match the given context (customer, cart). Verify the most number of rules.
- On home screen you will see
AUDIENCE_ONLY
Voucherify qualification scenario. (readme-images/Integration-1.png) - On products page we show
PRODUCTS
scenario. (readme-images/Integration-2.png) - On product details page we show
PRODUCTS
scenario. (readme-images/Integration-3.png) - On cart page in products table we show
PRODUCTS
scenario. (readme-images/Integration-4.png) - On products page below products table we show
CUSTOMER_WALLET
scenario. (readme-images/Integration-5.png) - Below
CUSTOMER_WALLET
scenario holder, you will see saved vouchers(saved qualifications). (readme-images/Integration-6.png) - Bundles section show qualifications
PRODUCTS
scenario but only if in promotion_tier metadata there isbundle: true
key. (readme-images/Integration-7.png) - Below bundle holder, we show
ALL
scenario, but we filter out allPRODUCTS
andCUSTOMER_WALLET
scenario, so there should be no duplicates. (readme-images/Integration-8.png) - On the checkout page we show
ALL
scenario. (readme-images/Integration-9.png)
You must have access to following services:
- Voucherify account (with access to Qualification API v3)
- Emporix account
- Contentful account
- Emporix
- Manage API Keys
- Voucherify
- Project Settings -> Application Keys
- Contentful
- Account Settings -> Tokens -> Generate personal token
- Go to space -> Settings -> API keys -> Add API key
Create 3 content models:
- CAMPAIGN
- name: campaign
- content id: campaign
- fields
- name - short text
- description - short text
- termsAndConditions - short text
- PROMOTION TIER
- name: promotion_tier
- content id: promotion
- fields
- name - short text
- description - short text
- termsAndConditions - short text
- STANDALONE CODE
- name: standalone voucher
- content id: voucher
- fields
- code - short text
- description - short text
- termsAndConditions - short text
See readme-images/Contentful-X.png
for more information.
- yarn
- node 16.x
- Fill out .env.prod file.
REACT_APP_VOUCHERIFY_API_URL
- Voucherify API endpointREACT_APP_VOUCHERIFY_APP_ID
- Voucherify Application IDREACT_APP_VOUCHERIFY_SECRET_KEY
- Voucherify Secret KeyREACT_APP_EMPORIX_CLIENT_ID
- Emporix API Client ID (Server side)REACT_APP_EMPORIX_CLIENT_SECRET
- Emporix API Secret (Server side)REACT_APP_CONTENTFUL_MODE
- DEV / PROD - ifDEV
only unpublished Contentful content will be reachable by store, ifPROD
only published content will be reachable by this showcase.REACT_APP_CONTENTFUL_PREVIEW_API_ACCESS_TOKEN
- Contentful Content Preview API - access tokenREACT_APP_CONTENTFUL_DELIVERY_API_ACCESS_TOKEN
- Contentful Content Delivery API - access tokenREACT_APP_CONTENTFUL_SPACE_ID
- Contentful Space IDREACT_APP_VOUCHERIFY_QUALIFICATION_MODE_ADVANCED
- Iftrue
, will use qualification ADVANCED method
yarn install
- will install required packagesyarn start:prod
- will start application
The limit of promotions is 5 per cart/order.
We allow you to apply promotion tier (blue container) from anywhere as long as you are eligible for the promotion.
Applying vouchers on the other hand can happen only from cart page, cart sidebar view or checkout page.
So please notice that vouchers qualifications (green container) sometimes have SAVE FOR LATER
button, that is because we don't
want you to lose the promotion you see, but also we cannot guarantee that the voucher you see is valid, so we want just to remind you later
about that voucher, so you will try to apply later on (on cart page).
We implemented additional functionality to bundle type of promotions. You may add missing products to your cart directly from promotion holder. A missing product is a product that is missing to receive a discount. (readme-images/Bundles-1.png)
- Each time a cart changes (products, quantity, etc.) we must recheck cart (see function
recheckCart
insrc/context/cart-provider.js
) - From emporix cart perspective we apply maximum 1 coupon to a cart. That is because at first integration is calculating the discount that
should be applied, we create single coupon for the total discount amount that should be applied. We apply the coupon. And the information about what
coupons are really applied to the cart from Voucherify perspective, are saved in cart
metadata/mixins
. - Additionally, in cart
metadata/mixins
we saveapplicable promtion tiers
, so we know later on, what promotions (blue containers) can be applied, so we can showapply
button, and what promotions we cannot apply, so the button should not be shown.
Following files were modified from the original repository:
- package.json
- src
- components
- Cart
- cart.js
- Utilities
- input
- index.js
- input
- Cart
- context
- cart-provider.js
- user-addresss-context.js
- index.css
- pages
- InvalidTenant
- cart
- CartMobileContent.js
- CartPage.js
- CartTable.js
- checkout
- CheckoutPage.js
- home
- About.js
- product
- EachProduct.js
- EachProductRow.js
- ProductDetailPage.js
- ProductListContent.js
- ProductPage.js
- index.js
- services
- cart.service.js
- components
- yarn.lock
Additionally, we added some files, please see PR https://github.com/rspective/emporix-b2b-showcase/pull/5/files for details.