You can install the package via composer:
composer require combindma/yotpo-api
You can publish the config file with:
php artisan vendor:publish --provider="Combindma\YotpoApi\YotpoApiServiceProvider" --tag="yotpo-config"
This is the contents of the published config file:
return [
/*
* Enable or disable Yotpo api. Useful for local development when runing tests.
*/
'api_enabled' => env('YOTPO_API_ENABLED', false),
/*
* Enable or disable Yotpo Loyalty. Useful for local development when runing tests.
*/
'loyalty_enabled' => env('YOTPO_LOYALTY_ENABLED', false),
/*
* Core API V3 Credentials
*/
'app_key' => env('YOTPO_APP_KEY'),
'secret_key' => env('YOTPO_SECRET_KEY'),
/*
* Loyalty & Referrals API Credentials
*/
'loyalty_api_key' => env('LOYALTY_API_KEY'),
'loyalty_guid_key' => env('LOYALTY_GUID_KEY'),
/*
* CDNs
* */
'loyalty_js_sdk_url' => env('LOYALTY_JS_SDK_URL'),
'loyalty_modules_loader_url' => env('LOYALTY_MODULES_LOADER_URL'),
/*
* Refer link used by Loyalty Program
* */
'refer_link' => 'http://rwrd.io',
/*
* Default currency code you want to use. Make sure to have the same in your Yotpo Loyalty admin: https://loyalty.yotpo.com/general-settings
* */
'currency' => env('YOTPO_DEFAULT_CURRENCY', 'MAD'),
/*
* Default country code you want to use. This is important for API requests when submitting the phone number
* */
'country' => env('YOTPO_DEFAULT_COUNTRY', 'MA')
];
- You should create a free account in https://yotpo.com and add your credentials in .env file
- You must add
Combindma\YotpoApi\Traits\YotpoCustomer
to user model or implement yours. Just be sure to have the same structure (same array keys). - You must add
Combindma\YotpoApi\Traits\YotpoPurchase
to order model or implement yours. Just be sure to have the same structure (same array keys).
For further documentation
- Loyalty API Documentation: https://loyaltyapi.yotpo.com/reference
- Core API V3 Documentation: https://core-api.yotpo.com/reference
Example of use: create a customer in loyality program
use Combindma\YotpoApi\Facades\YotpoApi;
//yotpoApiData is implemented in Combindma\YotpoApi\Traits\YotpoCustomer. You can create yours.
YotpoApi::createOrUpdateLoyaltyCustomer($user->yotpoApiData());
composer test
Please see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.