PHP code example of dmitriymikheev / yii2-odysseq

1. Go to this page and download the library: Download dmitriymikheev/yii2-odysseq library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dmitriymikheev / yii2-odysseq example snippets


return [
    //some config code
    'components' => [
        'odysseq' => [
            'class' => 'dmitriymikheev\odysseq\OdysseqComponent',
            'access_token' => 'your_access_token',
            'notification_secret_key' => 'your_notification_secret_key',
        ],
    ]
    //some config code
];

public function actions()
{
    return [
        'odysseq-callback' => [
            'class' => \dmitriymikheev\odysseq\actions\CallbackAction::class,
            'callback' => [$this, 'successCallback'],
            'component_id' => 'odysseq' //component id that was specified in the config file
        ]
    ];
}

public function behaviors()
{
    return [
        'verbs' => [
            'class' => VerbFilter::className(),
            'actions' => [
                'odysseq-callback' => ['post'],
            ],
        ],
    ];
}

public function beforeAction($action)
{
    if ($action->id == 'odysseq-callback') {
        $this->enableCsrfValidation = false;
    }
    return parent::beforeAction($action);
}

public function successCallback($model)
{
    //here you can change the status of the bid in your database
    
    //Remember that to inform the service about the successful processing of the notification, please return a json response {"status": 200}
    //Example:
    $response = Yii::$app->getResponse();
    $response->format = yii\web\Response::FORMAT_JSON;
    $response->data = ['status' => 200];
    return $response->send();
}