Plugin Directory

Changeset 2575552


Ignore:
Timestamp:
07/30/2021 10:41:55 PM (5 years ago)
Author:
servicebot
Message:

Update to version 2.1.1 from GitHub

Location:
servicebot
Files:
6 edited
1 copied

Legend:

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

    r2529292 r2575552  
    33Tags: stripe,subscriptions,payments,pricing page,subscription management
    44Requires at least: 5.0
    5 Tested up to: 5.5.1
     5Tested up to: 5.8.0
    66Requires PHP: 7.1
    77License: GPLv2
     
    9797= Can I change the style of these pages? =
    9898 
    99 Yes you can, check out our docs here to learn more about styling these pages [here](https://docs.billflow.io/subscription-portal/pricing-page/customize-style-and-features-of-pricing-page).
     99Yes you can, check out our docs here to learn more about styling these pages [here](https://docs.billflow.io/how-to/change-style).
    100100
    101101= Where is the documentation for the plugin? =
    102102 
    103 Join us [here](https://docs.billflow.io/subscription-portal/integrations/wordpress), and feel free to message us on our website with any questions.
     103Join us [here](https://docs.billflow.io/no-code-integrations/no-code-app-builders/wordpress), and feel free to message us on our website with any questions.
    104104
    105105== Screenshots ==
  • servicebot/tags/2.1.1/public/class-servicebot-public.php

    r2458625 r2575552  
    117117    }
    118118
     119}
     120
     121function billflow_log_in_user($user_id, $email, $user_login, $password){
     122   
     123    $wp_auth = wp_authenticate($user_login, $password);
     124
     125    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        ), 401 );
     132    }else{
     133        // Login the new user
     134        wp_clear_auth_cookie();
     135        wp_set_current_user ( $user_id ); // Set the current user detail
     136        wp_set_auth_cookie  ( $user_id ); // Set auth details in cookie
     137       
     138        // remove the meta that indicates need password update because they got the right password already
     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_user_by_password' => true,
     147            'refresh'=> true
     148        ), 200 );
     149    }
    119150}
    120151
     
    158189                    ), 200 );
    159190    }else{
    160 
     191        // try to fetch the user by email
     192        $existing_user = get_user_by('email', $email);
    161193        // if user already exists
    162         $existing_user = get_user_by('email', $email);
    163         $user_id = $existing_user->get('id');
    164         // if the user hasn't been updated with a password
    165         if(get_user_meta( $user_id, "billflow_stripe_webhook_created", TRUE )){
    166             // and if the user has the matching subscription
    167             if(get_user_meta( $user_id, "billflow_stripe_subscription_id", TRUE) === $subscription_id){
    168                 // remove the meta that indicates need password update
    169                 delete_user_meta($user->get('id'), "billflow_stripe_webhook_created");
    170                 // update the password
    171                 wp_set_password($password, $user_id);
    172                 // Login the new user
    173                 wp_clear_auth_cookie();
    174                 wp_set_current_user ( $user_id ); // Set the current user detail
    175                 wp_set_auth_cookie  ( $user_id ); // Set auth details in cookie
    176 
    177                 wp_send_json( array(  'email' => $email,
    178                         'user_already_exists' => true,
    179                         'password_updated' => true,
    180                 ), 200 );
     194        if($existing_user){
     195            $user_id = $existing_user->get('id');
     196            $user_login = $existing_user->get('user_login');
     197       
     198            // if the user hasn't been updated with a password
     199            // this is when the user is just newly created by stripe webhook
     200            if(get_user_meta( $user_id, "billflow_stripe_webhook_created", TRUE )){
     201                // and if the user has the matching subscription
     202                if(get_user_meta( $user_id, "billflow_stripe_subscription_id", TRUE) === $subscription_id){
     203                    // set the password automatically here because the subscription id matches.
     204                    wp_set_password($password, $user_id);
     205                    // Login the new user with the provided password
     206                    billflow_log_in_user($user_id, $email, $user_login, $password);
     207                }else{
     208                    // if the subscription id doesn't match
     209                    // still try login the user with the user input password to see if they are the owner
     210                    // because user exists, but provided a password.
     211                    billflow_log_in_user($user_id, $email, $user_login, $password);
     212                }
    181213            }else{
    182                 // the case if some one else put an existing email in.
    183                 wp_send_json_error( array(  'email' => $email,
    184                         'user_already_exists' => true,
    185                         'checkout_sid' => $subscription_id,
    186                         // 'existing_sid' => get_user_meta( $user_id, "billflow_stripe_subscription_id", TRUE),
    187                         'error' => 'User is created by webhook, but subscription does not match.',
    188                 ), 591 );
     214                // if user exists but not newly created by webhook
     215                // because user exists, but provided a password.
     216                billflow_log_in_user($user_id, $email, $user_login, $password);
    189217            }
    190218        }else{
     219            // WP_Error but not existing user, some other unhandled errors.
     220            // for some reason other than an existing user with the same email.
    191221            wp_send_json_error( array(  'email' => $email,
    192                 'error' => 'Unable to create user.',
    193             ), 592 );
     222                'error' => $user_id->get_error_message(),
     223            ), 500 );
    194224        }
    195225    }
  • servicebot/tags/2.1.1/servicebot.php

    r2565264 r2575552  
    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.0
     19 * Version:           2.1.1
    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.0' );
     38define( 'SERVICEBOT_VERSION', '2.1.1' );
    3939
    4040/**
  • servicebot/trunk/README.txt

    r2529292 r2575552  
    33Tags: stripe,subscriptions,payments,pricing page,subscription management
    44Requires at least: 5.0
    5 Tested up to: 5.5.1
     5Tested up to: 5.8.0
    66Requires PHP: 7.1
    77License: GPLv2
     
    9797= Can I change the style of these pages? =
    9898 
    99 Yes you can, check out our docs here to learn more about styling these pages [here](https://docs.billflow.io/subscription-portal/pricing-page/customize-style-and-features-of-pricing-page).
     99Yes you can, check out our docs here to learn more about styling these pages [here](https://docs.billflow.io/how-to/change-style).
    100100
    101101= Where is the documentation for the plugin? =
    102102 
    103 Join us [here](https://docs.billflow.io/subscription-portal/integrations/wordpress), and feel free to message us on our website with any questions.
     103Join us [here](https://docs.billflow.io/no-code-integrations/no-code-app-builders/wordpress), and feel free to message us on our website with any questions.
    104104
    105105== Screenshots ==
  • servicebot/trunk/public/class-servicebot-public.php

    r2458625 r2575552  
    117117    }
    118118
     119}
     120
     121function billflow_log_in_user($user_id, $email, $user_login, $password){
     122   
     123    $wp_auth = wp_authenticate($user_login, $password);
     124
     125    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        ), 401 );
     132    }else{
     133        // Login the new user
     134        wp_clear_auth_cookie();
     135        wp_set_current_user ( $user_id ); // Set the current user detail
     136        wp_set_auth_cookie  ( $user_id ); // Set auth details in cookie
     137       
     138        // remove the meta that indicates need password update because they got the right password already
     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_user_by_password' => true,
     147            'refresh'=> true
     148        ), 200 );
     149    }
    119150}
    120151
     
    158189                    ), 200 );
    159190    }else{
    160 
     191        // try to fetch the user by email
     192        $existing_user = get_user_by('email', $email);
    161193        // if user already exists
    162         $existing_user = get_user_by('email', $email);
    163         $user_id = $existing_user->get('id');
    164         // if the user hasn't been updated with a password
    165         if(get_user_meta( $user_id, "billflow_stripe_webhook_created", TRUE )){
    166             // and if the user has the matching subscription
    167             if(get_user_meta( $user_id, "billflow_stripe_subscription_id", TRUE) === $subscription_id){
    168                 // remove the meta that indicates need password update
    169                 delete_user_meta($user->get('id'), "billflow_stripe_webhook_created");
    170                 // update the password
    171                 wp_set_password($password, $user_id);
    172                 // Login the new user
    173                 wp_clear_auth_cookie();
    174                 wp_set_current_user ( $user_id ); // Set the current user detail
    175                 wp_set_auth_cookie  ( $user_id ); // Set auth details in cookie
    176 
    177                 wp_send_json( array(  'email' => $email,
    178                         'user_already_exists' => true,
    179                         'password_updated' => true,
    180                 ), 200 );
     194        if($existing_user){
     195            $user_id = $existing_user->get('id');
     196            $user_login = $existing_user->get('user_login');
     197       
     198            // if the user hasn't been updated with a password
     199            // this is when the user is just newly created by stripe webhook
     200            if(get_user_meta( $user_id, "billflow_stripe_webhook_created", TRUE )){
     201                // and if the user has the matching subscription
     202                if(get_user_meta( $user_id, "billflow_stripe_subscription_id", TRUE) === $subscription_id){
     203                    // set the password automatically here because the subscription id matches.
     204                    wp_set_password($password, $user_id);
     205                    // Login the new user with the provided password
     206                    billflow_log_in_user($user_id, $email, $user_login, $password);
     207                }else{
     208                    // if the subscription id doesn't match
     209                    // still try login the user with the user input password to see if they are the owner
     210                    // because user exists, but provided a password.
     211                    billflow_log_in_user($user_id, $email, $user_login, $password);
     212                }
    181213            }else{
    182                 // the case if some one else put an existing email in.
    183                 wp_send_json_error( array(  'email' => $email,
    184                         'user_already_exists' => true,
    185                         'checkout_sid' => $subscription_id,
    186                         // 'existing_sid' => get_user_meta( $user_id, "billflow_stripe_subscription_id", TRUE),
    187                         'error' => 'User is created by webhook, but subscription does not match.',
    188                 ), 591 );
     214                // if user exists but not newly created by webhook
     215                // because user exists, but provided a password.
     216                billflow_log_in_user($user_id, $email, $user_login, $password);
    189217            }
    190218        }else{
     219            // WP_Error but not existing user, some other unhandled errors.
     220            // for some reason other than an existing user with the same email.
    191221            wp_send_json_error( array(  'email' => $email,
    192                 'error' => 'Unable to create user.',
    193             ), 592 );
     222                'error' => $user_id->get_error_message(),
     223            ), 500 );
    194224        }
    195225    }
  • servicebot/trunk/servicebot.php

    r2565264 r2575552  
    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.0
     19 * Version:           2.1.1
    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.0' );
     38define( 'SERVICEBOT_VERSION', '2.1.1' );
    3939
    4040/**
Note: See TracChangeset for help on using the changeset viewer.