Esempio n. 1
0
function fn_yotpo_create_account_platform($app_key, $secret_token, $shop_url)
{
    $token = fn_grant_oauth_access($app_key, $secret_token);
    if (isset($token)) {
        $data = array();
        $data['utoken'] = $token;
        $platform_type = array();
        $platform_type['platform_type_id'] = YOTPO_PLATFORM_ID;
        $platform_type['shop_domain'] = $shop_url;
        $data['account_platform'] = $platform_type;
        return Http::post(YOTPO_API_URL . '/apps/' . $app_key . '/account_platform', json_encode($data), array('headers' => array('Content-Type: application/json'), 'timeout' => YOTPO_HTTP_REQUEST_TIMEOUT));
    }
    return $token;
}
Esempio n. 2
0
                 fn_set_notification('N', 'Yotpo sign up', 'Account successfully created', 'S');
             } else {
                 fn_set_notification('E', 'Yotpo sign up', $signUpMessage, 'S');
             }
         } else {
             fn_set_notification('E', 'Yotpo sign up', $message, 'S');
         }
     }
 } elseif ($mode == 'past_orders') {
     if (!empty($appKey) && !empty($secret)) {
         if ($cSettings->getValue('yotpo_is_past_order_sent', 'yotpo', Settings::ADDON_SECTION) == 'false') {
             $cSettings->updateValue('yotpo_is_past_order_sent', 'true', 'yotpo');
             $data = fn_yotpo_get_past_orders($auth);
             $is_success = true;
             $message = '';
             $token = fn_grant_oauth_access($appKey, $secret);
             if (isset($token)) {
                 foreach ($data as $post_bulk) {
                     if (!is_null($post_bulk)) {
                         if (isset($token)) {
                             $post_bulk['utoken'] = $token;
                             $result = Http::post(YOTPO_API_URL . '/apps/' . $appKey . "/purchases/mass_create", json_encode($post_bulk), array('headers' => array('Content-Type: application/json'), 'timeout' => YOTPO_HTTP_REQUEST_TIMEOUT));
                             $result = json_decode($result, true);
                             if ($result['code'] != 200 && $is_success) {
                                 $message = $result['message'];
                                 $is_success = false;
                             }
                         }
                     }
                 }
             } else {