coretava_flutter 1.0.5
coretava_flutter: ^1.0.5 copied to clipboard
Coretava Core Loyalty is a Flutter package for integrating loyalty programs, managing points, transactions, and user rewards with seamless API communication.
coretava_flutter #
Introduction #
The Coretava Cashback Program is designed to help businesses engage customers by offering cashback rewards based on their purchases. Through seamless integration with Coretava, this program provides merchants with an easy way to boost customer retention, increase sales, and enhance the shopping experience. Customers can earn cashback in the form of monetary rewards, which can be redeemed during future purchases. With a simple and effective setup, the Coretava Cashback Program offers a powerful solution for e-commerce stores and physical retailers alike.
Features #
- Easy Integration: Easily integrate the Coretava Cashback Program into your Flutter-based app with minimal configuration.
- Automatic Cashback Calculation: The program automatically calculates cashback based on user purchases, either as a fixed amount or percentage of the total order value.
- Customizable Rewards: Tailor the cashback rewards based on product categories, customer segments, or specific promotional campaigns.
- Monetary Rewards: Offer cashback in the form of real currency, allowing flexibility based on business needs.
- Redemption Options: Customers can redeem cashback rewards on future purchases, enhancing customer loyalty and increasing repeat sales.
- Pop-Up Notifications: Inform customers about available cashback rewards with customizable pop-up notifications, improving engagement and conversion.
- Multi-Platform Support: The Coretava Cashback Program works seamlessly across different platforms such as Shopify, VTEX, and custom integrations.
- Real-Time Updates: Customers' cashback balances and reward statuses are updated in real-time, providing immediate feedback after each transaction.
- Flexible Configurations: Admins can set up multiple campaigns, customize reward rules, and adjust settings to match their business goals.
Getting Started #
Prerequisites #
-
Create Coretava Account
Begin by creating a Coretava account by initiating the admin setup API. This will trigger an email to the admin for verification and provide access to the Coretava dashboard. -
Complete the Onboarding Process
After account creation, go through the onboarding process in your Coretava dashboard. This includes configuring your loyalty program details. -
Retrieve APP_ID and APP_KEY
The prerequisites will provide you with the APP_ID and APP_KEY, which will be used in the next steps.
Configuration and Initialization #
The initialization of the Coretava SDK should be triggered at the point where you are injecting the CoreLoyalty widget into your application.
The widget requires specific configurations depending on whether the user is logged in or not.
Configuration Overview
Properties
Property | Description | Type |
---|---|---|
app | Coretava app ID | string |
user.externalId | Logged in user externalId | string |
user.email | Logged in user email | string |
user.firstName | Logged in user first name (optional) | string | undefined |
user.lastName | Logged in user last name (optional) | string | undefined |
user.hash | Logged in user HMAC SHA 256 hash generated on your server | string |
CartDelegate.onRetrieveData | The onRetrieveData method is invoked when the widget needs to retrieve the current cart data. This is typically used to retrieve the current state of the shopping cart and pass it to the widget. The returned data must match the CartData structure provided below. | Future |
CartDelegate.onApplyDiscount | The onApplyDiscount method is called when the widget needs to apply a discount code to the cart. You are responsible for processing the provided code and applying the discount logic. | Future |
CartData Structure
Property | Description | Type |
---|---|---|
id | Cart ID | string |
itemsTotal | Total items in the cart | double |
total | Total value of the cart | double |
discountCodes | Applied discount codes | List |
User Structure
Property | Description | Type |
---|---|---|
externalId | User External Id | string | undefined |
User's email address | string | |
firstName | User's first name (optional) | string | undefined |
lastName | User's last name (optional) | string | undefined |
hash | HMAC SHA 256 hash | string |
For Not Logged-In Users
Use the following code for users who are not logged in:
class SampleAppCartDelegate extends CartDelegate {
final CartData _cartData = CartData(
id: 'CART_ID', // Optional
itemsTotal: 3, // Example: Total items in the cart
total: 120.00, // Example: Total value of the cart
discountCodes: ["SUMMER10"], // Example: Applied discount codes
);
@override
Future<CartData> onRetrieveData() async {
// Logic to load current cart data
return _cartData;
}
@override
Future<void> onApplyDiscount(String code) async {
// Logic to apply discount code to the cart
if (code == "VALID_CODE") {
// Example: Successfully applied discount
_cartData.discountCodes.add(code);
}
}
}
await coreLoyalty.initialize(
appId: "YOUR_APP_ID",
cartDelegate: SampleAppCartDelegate()
);
For Logged-In Users
For logged-in users, you must calculate a user hash to securely identify the user. This hash is an HMAC SHA 256 of the string APP_ID|USER_EMAIL
signed with the APP_KEY
.
Important: The user hash must be calculated on your server to secure the
APP_KEY
. Never expose theAPP_KEY
on the client side.
Use the following initialization code for logged-in users:
class SampleAppCartDelegate extends CartDelegate {
final CartData _cartData = CartData(
id: 'CART_ID', // Optional
itemsTotal: 3, // Example: Total items in the cart
total: 120.00, // Example: Total value of the cart
discountCodes: ["SUMMER10"], // Example: Applied discount codes
);
@override
Future<CartData> onRetrieveData() async {
// Logic to load current cart data
return _cartData;
}
@override
Future<void> onApplyDiscount(String code) async {
// Logic to apply discount code to the cart
if (code == "VALID_CODE") {
// Example: Successfully applied discount
_cartData.discountCodes.add(code);
}
}
}
await coreLoyalty.initialize(
appId: 'YOUR_APP_ID',
user: User(
externalId: "USER_EXTERNALID"
email: "USER_EMAIL",
firstName: "USER_FIRST_NAME",
lastName: "USER_LAST_NAME",
hash: "USER_HASH"
)
cartDelegate: SampleAppCartDelegate()
);
Replace the placeholders:
USER_EXTERNALID
: The user's externalId.USER_FIRST_NAME
: The user's first name.USER_LAST_NAME
: The user's last name.USER_EMAIL
: The user's email address.USER_HASH
: The HMAC SHA 256 hash generated on your server.
App Injection #
To properly inject the CoreLoyalty widget into your Flutter application, check the following example:
Widget build(BuildContext context) {
return MaterialApp(
title: 'Sample app',
// Inject CoreLoyaltyApp to the Flutter app
home: CoreLoyaltyApp(
child: Center(),
));
}