Plugin Directory

Changeset 2575845


Ignore:
Timestamp:
07/31/2021 08:44:13 PM (5 years ago)
Author:
servicebot
Message:

Update to version 2.1.4 from GitHub

Location:
servicebot
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • servicebot/tags/2.1.4/README.txt

    r2575552 r2575845  
    1212
    1313== Upgrade Notice ==
    14 IMPORTANT!! This 2.0.0 version upgrade could introduce some breaking change!
    15 If you are using this plugin's 1.x.x version already, please test this plugin thoroughly!
     14IMPORTANT!! Starting in 2.0.0 version upgrade could introduce some breaking change if
     15you are currently using this plugin's 1.x.x version, please test this plugin thoroughly
     16in a test environment before upgrading production to > 2.0.0!
     17
     18Steps to take to upgrade from v1 to v2 of this plugin:
     19 1. Go to the plugin's settings page and delete all setting fields and save.
     20 2. Go to the plugins page and update to the latest version.
     21 3. Make sure to use the new updated shortcodes listed below.
     22 4. make sure your billing page in dashboard.billflow.io are using the latest version.
     23
    1624Some standard tests you should do:
    1725 * Check all you embed pages and test all flows
     
    3139= Billflow =
    3240Launch a subscription business faster than ever with the Stripe Billing plugin by Billflow.
    33 This plugin automatically connects your Stripe account to your Wordpress site allowing you to show beautiful pricing pages, take payments for Stripe Subscriptions, and let customers manage their accounts. The plugin uses Wordpress's default user authentication to allow your customers to log-in and manage their subscriptions.
     41This plugin automatically connects your Stripe account to your Wordpress site allowing you to show beautiful pricing pages, take payments for Stripe Subscriptions, and let customers manage their accounts. The plugin uses WordPress's default user authentication to allow your customers to log-in and manage their subscriptions.
    3442Features:
    3543 * Beautiful Pricing pages that can handle any Stripe pricing model
     
    93101= Do I need to have a Billflow account? =
    94102 
    95 Yes, the plugin is there to connect your wordpress with your Billflow account. You can signup [here](https://dashboard.billflow.io/signup?ref="wordpress-plugin-page").
     103Yes, the plugin is there to connect your wordpress with your Billflow account. You can sign up [here](https://dashboard.billflow.io/signup?ref="wordpress-plugin-page").
    96104
    97105= Can I change the style of these pages? =
     
    105113== Screenshots ==
    1061141. Pricing Pages
    107 2. Signup Forms
     1152. Sign up Forms
    1081163. Subscription Management Portal
  • servicebot/tags/2.1.4/public/class-servicebot-public.php

    r2575614 r2575845  
    119119}
    120120
    121 function billflow_log_in_user($user_id, $email, $user_login, $password, $caller){
     121function billflow_log_in_user($user_id, $email, $user_login, $password, $subscription_id, $caller){
    122122   
    123     $wp_auth = wp_authenticate($user_login, $password);
     123    $is_webhook_new_user = get_user_meta( $user_id, "billflow_stripe_webhook_created", TRUE );
     124    $user_subscription_id_matched = get_user_meta( $user_id, "billflow_stripe_subscription_id", TRUE) === $subscription_id;
     125    $real_password = $is_webhook_new_user ? $subscription_id : $password;
     126    $wp_auth = wp_authenticate($user_login, $real_password);
    124127
    125128    if(is_wp_error($wp_auth)){
    126         // this is probably someone else used the same email OR put in the wrong password.
    127         wp_send_json_error( array( 
    128             'email' => $email,
    129             'user_already_exists' => true,
    130             'password_match' => false,
    131             'caller' => $caller
    132         ), 401 );
     129
     130        if($is_webhook_new_user && $user_subscription_id_matched){
     131            // safe to set the password for this user since they have matching OR
     132            // they are the newly created by webhook and have matching subscription id
     133            // subscription id and is a new webhook created user.
     134            wp_set_password( $password, $user_id );
     135            wp_clear_auth_cookie(); // Login the new user
     136            wp_set_current_user ( $user_id ); // Set the current user detail
     137            wp_set_auth_cookie  ( $user_id ); // Set auth details in cookie
     138            // remove the meta that indicates need password update
     139            delete_user_meta($user_id, "billflow_stripe_webhook_created");
     140           
     141            wp_send_json( array( 
     142                'email' => $email,
     143                'user_id' => $user_id,
     144                'user_login' => $user_login,
     145                'password' => '****************************',
     146                'login_by_webhook_subscription' => true,
     147                'is_webhook_new_user' => $is_webhook_new_user,
     148                'user_subscription_id_matched' => $user_subscription_id_matched,
     149                'refresh'=> true,
     150                'caller' => $caller
     151            ), 200 );
     152
     153        }else{
     154            // this is probably someone else used the same email OR put in the wrong password.
     155            wp_send_json_error( array( 
     156                'email' => $email,
     157                'user_already_exists' => true,
     158                'password_match' => false,
     159                'is_webhook_new_user' => $is_webhook_new_user,
     160                'user_subscription_id_matched' => $user_subscription_id_matched,
     161                'caller' => $caller
     162            ), 401 );
     163        }
    133164    }else{
    134165        // Login the new user
     
    173204    if ( ! is_wp_error( $user_id ) ) {
    174205
    175         // add user meta to note that this is created by Stripe webhook
     206        // add user meta to note that this is created by ajax
    176207        update_user_meta($user_id, "billflow_checkout_created", TRUE);
    177208        update_user_meta($user_id, "billflow_created", TRUE);
     
    202233            // if user exists but not newly created by webhook
    203234            // because user exists and provided a password.
    204             billflow_log_in_user($user_id, $email, $user_login, $password, 'billflow_login_by_password');
     235            billflow_log_in_user($user_id, $email, $user_login, $password, $subscription_id,'billflow_login_by_password');
    205236
    206237        }else{
     
    272303    $userdata = array(
    273304        'user_login'  => $email,
    274         'user_email' => $email
     305        'user_email' => $email,
     306        'password' => $subscription_id
    275307    );
     308
    276309    $user_id = wp_insert_user( $userdata );
    277310
  • servicebot/tags/2.1.4/public/widgets/js/billflow-widget.js

    r2575606 r2575845  
    9696        }
    9797        return false
     98    }
     99
     100    function delayed(time, callback, payload){
     101        return new Promise((resolve, reject) => {
     102            console.debug(`Waiting ${time} milliseconds then make the call`)
     103            setTimeout(async function(){
     104                console.debug("Calling create user ajax after delay")
     105                try{
     106                    resolve(await callback(payload))
     107                    console.debug("Create user ajax call finished")
     108                }catch(e){
     109                    reject(e)
     110                }
     111            }, time);
     112        })
    98113    }
    99114
     
    154169            const ajax_url = admin_ajax_url;
    155170
    156             if(event === "create_subscription" && !logged_in_email){
     171            if(!logged_in_email){
     172                // if not already logged in, then try to create the user with
     173                // the email provided by the user
    157174                console.debug("Creating user", response, extras);
     175
    158176                const payload = {
    159177                    action: "create_user",
     
    163181                    password: password
    164182                };
    165                 await createUserPromise(payload);
     183
     184                // await delayed(10000, createUserPromise, payload);
     185                await createUserPromise(payload)
     186                // console.debug("Delayed call finished")
    166187            }
    167188
  • servicebot/tags/2.1.4/servicebot.php

    r2575614 r2575845  
    1717 * Plugin URI:        http://www.wpexplorer.com/servicebot/
    1818 * Description:       Provides NO-CODE integration between WordPress and Billflow, an UI layer on top of Stripe Billing.
    19  * Version:           2.1.3
     19 * Version:           2.1.4
    2020 * Author:            Billflow
    2121 * Author URI:        https://billflow.io
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define( 'SERVICEBOT_VERSION', '2.1.3' );
     38define( 'SERVICEBOT_VERSION', '2.1.4' );
    3939
    4040/**
  • servicebot/trunk/README.txt

    r2575552 r2575845  
    1212
    1313== Upgrade Notice ==
    14 IMPORTANT!! This 2.0.0 version upgrade could introduce some breaking change!
    15 If you are using this plugin's 1.x.x version already, please test this plugin thoroughly!
     14IMPORTANT!! Starting in 2.0.0 version upgrade could introduce some breaking change if
     15you are currently using this plugin's 1.x.x version, please test this plugin thoroughly
     16in a test environment before upgrading production to > 2.0.0!
     17
     18Steps to take to upgrade from v1 to v2 of this plugin:
     19 1. Go to the plugin's settings page and delete all setting fields and save.
     20 2. Go to the plugins page and update to the latest version.
     21 3. Make sure to use the new updated shortcodes listed below.
     22 4. make sure your billing page in dashboard.billflow.io are using the latest version.
     23
    1624Some standard tests you should do:
    1725 * Check all you embed pages and test all flows
     
    3139= Billflow =
    3240Launch a subscription business faster than ever with the Stripe Billing plugin by Billflow.
    33 This plugin automatically connects your Stripe account to your Wordpress site allowing you to show beautiful pricing pages, take payments for Stripe Subscriptions, and let customers manage their accounts. The plugin uses Wordpress's default user authentication to allow your customers to log-in and manage their subscriptions.
     41This plugin automatically connects your Stripe account to your Wordpress site allowing you to show beautiful pricing pages, take payments for Stripe Subscriptions, and let customers manage their accounts. The plugin uses WordPress's default user authentication to allow your customers to log-in and manage their subscriptions.
    3442Features:
    3543 * Beautiful Pricing pages that can handle any Stripe pricing model
     
    93101= Do I need to have a Billflow account? =
    94102 
    95 Yes, the plugin is there to connect your wordpress with your Billflow account. You can signup [here](https://dashboard.billflow.io/signup?ref="wordpress-plugin-page").
     103Yes, the plugin is there to connect your wordpress with your Billflow account. You can sign up [here](https://dashboard.billflow.io/signup?ref="wordpress-plugin-page").
    96104
    97105= Can I change the style of these pages? =
     
    105113== Screenshots ==
    1061141. Pricing Pages
    107 2. Signup Forms
     1152. Sign up Forms
    1081163. Subscription Management Portal
  • servicebot/trunk/public/class-servicebot-public.php

    r2575614 r2575845  
    119119}
    120120
    121 function billflow_log_in_user($user_id, $email, $user_login, $password, $caller){
     121function billflow_log_in_user($user_id, $email, $user_login, $password, $subscription_id, $caller){
    122122   
    123     $wp_auth = wp_authenticate($user_login, $password);
     123    $is_webhook_new_user = get_user_meta( $user_id, "billflow_stripe_webhook_created", TRUE );
     124    $user_subscription_id_matched = get_user_meta( $user_id, "billflow_stripe_subscription_id", TRUE) === $subscription_id;
     125    $real_password = $is_webhook_new_user ? $subscription_id : $password;
     126    $wp_auth = wp_authenticate($user_login, $real_password);
    124127
    125128    if(is_wp_error($wp_auth)){
    126         // this is probably someone else used the same email OR put in the wrong password.
    127         wp_send_json_error( array( 
    128             'email' => $email,
    129             'user_already_exists' => true,
    130             'password_match' => false,
    131             'caller' => $caller
    132         ), 401 );
     129
     130        if($is_webhook_new_user && $user_subscription_id_matched){
     131            // safe to set the password for this user since they have matching OR
     132            // they are the newly created by webhook and have matching subscription id
     133            // subscription id and is a new webhook created user.
     134            wp_set_password( $password, $user_id );
     135            wp_clear_auth_cookie(); // Login the new user
     136            wp_set_current_user ( $user_id ); // Set the current user detail
     137            wp_set_auth_cookie  ( $user_id ); // Set auth details in cookie
     138            // remove the meta that indicates need password update
     139            delete_user_meta($user_id, "billflow_stripe_webhook_created");
     140           
     141            wp_send_json( array( 
     142                'email' => $email,
     143                'user_id' => $user_id,
     144                'user_login' => $user_login,
     145                'password' => '****************************',
     146                'login_by_webhook_subscription' => true,
     147                'is_webhook_new_user' => $is_webhook_new_user,
     148                'user_subscription_id_matched' => $user_subscription_id_matched,
     149                'refresh'=> true,
     150                'caller' => $caller
     151            ), 200 );
     152
     153        }else{
     154            // this is probably someone else used the same email OR put in the wrong password.
     155            wp_send_json_error( array( 
     156                'email' => $email,
     157                'user_already_exists' => true,
     158                'password_match' => false,
     159                'is_webhook_new_user' => $is_webhook_new_user,
     160                'user_subscription_id_matched' => $user_subscription_id_matched,
     161                'caller' => $caller
     162            ), 401 );
     163        }
    133164    }else{
    134165        // Login the new user
     
    173204    if ( ! is_wp_error( $user_id ) ) {
    174205
    175         // add user meta to note that this is created by Stripe webhook
     206        // add user meta to note that this is created by ajax
    176207        update_user_meta($user_id, "billflow_checkout_created", TRUE);
    177208        update_user_meta($user_id, "billflow_created", TRUE);
     
    202233            // if user exists but not newly created by webhook
    203234            // because user exists and provided a password.
    204             billflow_log_in_user($user_id, $email, $user_login, $password, 'billflow_login_by_password');
     235            billflow_log_in_user($user_id, $email, $user_login, $password, $subscription_id,'billflow_login_by_password');
    205236
    206237        }else{
     
    272303    $userdata = array(
    273304        'user_login'  => $email,
    274         'user_email' => $email
     305        'user_email' => $email,
     306        'password' => $subscription_id
    275307    );
     308
    276309    $user_id = wp_insert_user( $userdata );
    277310
  • servicebot/trunk/public/widgets/js/billflow-widget.js

    r2575606 r2575845  
    9696        }
    9797        return false
     98    }
     99
     100    function delayed(time, callback, payload){
     101        return new Promise((resolve, reject) => {
     102            console.debug(`Waiting ${time} milliseconds then make the call`)
     103            setTimeout(async function(){
     104                console.debug("Calling create user ajax after delay")
     105                try{
     106                    resolve(await callback(payload))
     107                    console.debug("Create user ajax call finished")
     108                }catch(e){
     109                    reject(e)
     110                }
     111            }, time);
     112        })
    98113    }
    99114
     
    154169            const ajax_url = admin_ajax_url;
    155170
    156             if(event === "create_subscription" && !logged_in_email){
     171            if(!logged_in_email){
     172                // if not already logged in, then try to create the user with
     173                // the email provided by the user
    157174                console.debug("Creating user", response, extras);
     175
    158176                const payload = {
    159177                    action: "create_user",
     
    163181                    password: password
    164182                };
    165                 await createUserPromise(payload);
     183
     184                // await delayed(10000, createUserPromise, payload);
     185                await createUserPromise(payload)
     186                // console.debug("Delayed call finished")
    166187            }
    167188
  • servicebot/trunk/servicebot.php

    r2575614 r2575845  
    1717 * Plugin URI:        http://www.wpexplorer.com/servicebot/
    1818 * Description:       Provides NO-CODE integration between WordPress and Billflow, an UI layer on top of Stripe Billing.
    19  * Version:           2.1.3
     19 * Version:           2.1.4
    2020 * Author:            Billflow
    2121 * Author URI:        https://billflow.io
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define( 'SERVICEBOT_VERSION', '2.1.3' );
     38define( 'SERVICEBOT_VERSION', '2.1.4' );
    3939
    4040/**
Note: See TracChangeset for help on using the changeset viewer.