Skip to content
This repository was archived by the owner on Apr 2, 2023. It is now read-only.

combindma/yotpo-api

Repository files navigation

Yotpo Core API V3 & Loyalty & Referrals API implementation for Laravel

Latest Version on Packagist GitHub Code Style Action Status Total Downloads

Installation

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')
];

Usage

  • 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

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());

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

Yotpo Api

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages