Changeset 2575845
- Timestamp:
- 07/31/2021 08:44:13 PM (5 years ago)
- Location:
- servicebot
- Files:
-
- 8 edited
- 1 copied
-
tags/2.1.4 (copied) (copied from servicebot/trunk)
-
tags/2.1.4/README.txt (modified) (4 diffs)
-
tags/2.1.4/public/class-servicebot-public.php (modified) (4 diffs)
-
tags/2.1.4/public/widgets/js/billflow-widget.js (modified) (3 diffs)
-
tags/2.1.4/servicebot.php (modified) (2 diffs)
-
trunk/README.txt (modified) (4 diffs)
-
trunk/public/class-servicebot-public.php (modified) (4 diffs)
-
trunk/public/widgets/js/billflow-widget.js (modified) (3 diffs)
-
trunk/servicebot.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
servicebot/tags/2.1.4/README.txt
r2575552 r2575845 12 12 13 13 == 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! 14 IMPORTANT!! Starting in 2.0.0 version upgrade could introduce some breaking change if 15 you are currently using this plugin's 1.x.x version, please test this plugin thoroughly 16 in a test environment before upgrading production to > 2.0.0! 17 18 Steps 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 16 24 Some standard tests you should do: 17 25 * Check all you embed pages and test all flows … … 31 39 = Billflow = 32 40 Launch 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 Word press's default user authentication to allow your customers to log-in and manage their subscriptions.41 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. 34 42 Features: 35 43 * Beautiful Pricing pages that can handle any Stripe pricing model … … 93 101 = Do I need to have a Billflow account? = 94 102 95 Yes, 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").103 Yes, 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"). 96 104 97 105 = Can I change the style of these pages? = … … 105 113 == Screenshots == 106 114 1. Pricing Pages 107 2. Sign up Forms115 2. Sign up Forms 108 116 3. Subscription Management Portal -
servicebot/tags/2.1.4/public/class-servicebot-public.php
r2575614 r2575845 119 119 } 120 120 121 function billflow_log_in_user($user_id, $email, $user_login, $password, $ caller){121 function billflow_log_in_user($user_id, $email, $user_login, $password, $subscription_id, $caller){ 122 122 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); 124 127 125 128 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 } 133 164 }else{ 134 165 // Login the new user … … 173 204 if ( ! is_wp_error( $user_id ) ) { 174 205 175 // add user meta to note that this is created by Stripe webhook206 // add user meta to note that this is created by ajax 176 207 update_user_meta($user_id, "billflow_checkout_created", TRUE); 177 208 update_user_meta($user_id, "billflow_created", TRUE); … … 202 233 // if user exists but not newly created by webhook 203 234 // 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'); 205 236 206 237 }else{ … … 272 303 $userdata = array( 273 304 'user_login' => $email, 274 'user_email' => $email 305 'user_email' => $email, 306 'password' => $subscription_id 275 307 ); 308 276 309 $user_id = wp_insert_user( $userdata ); 277 310 -
servicebot/tags/2.1.4/public/widgets/js/billflow-widget.js
r2575606 r2575845 96 96 } 97 97 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 }) 98 113 } 99 114 … … 154 169 const ajax_url = admin_ajax_url; 155 170 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 157 174 console.debug("Creating user", response, extras); 175 158 176 const payload = { 159 177 action: "create_user", … … 163 181 password: password 164 182 }; 165 await createUserPromise(payload); 183 184 // await delayed(10000, createUserPromise, payload); 185 await createUserPromise(payload) 186 // console.debug("Delayed call finished") 166 187 } 167 188 -
servicebot/tags/2.1.4/servicebot.php
r2575614 r2575845 17 17 * Plugin URI: http://www.wpexplorer.com/servicebot/ 18 18 * Description: Provides NO-CODE integration between WordPress and Billflow, an UI layer on top of Stripe Billing. 19 * Version: 2.1. 319 * Version: 2.1.4 20 20 * Author: Billflow 21 21 * Author URI: https://billflow.io … … 36 36 * Rename this for your plugin and update it as you release new versions. 37 37 */ 38 define( 'SERVICEBOT_VERSION', '2.1. 3' );38 define( 'SERVICEBOT_VERSION', '2.1.4' ); 39 39 40 40 /** -
servicebot/trunk/README.txt
r2575552 r2575845 12 12 13 13 == 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! 14 IMPORTANT!! Starting in 2.0.0 version upgrade could introduce some breaking change if 15 you are currently using this plugin's 1.x.x version, please test this plugin thoroughly 16 in a test environment before upgrading production to > 2.0.0! 17 18 Steps 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 16 24 Some standard tests you should do: 17 25 * Check all you embed pages and test all flows … … 31 39 = Billflow = 32 40 Launch 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 Word press's default user authentication to allow your customers to log-in and manage their subscriptions.41 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. 34 42 Features: 35 43 * Beautiful Pricing pages that can handle any Stripe pricing model … … 93 101 = Do I need to have a Billflow account? = 94 102 95 Yes, 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").103 Yes, 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"). 96 104 97 105 = Can I change the style of these pages? = … … 105 113 == Screenshots == 106 114 1. Pricing Pages 107 2. Sign up Forms115 2. Sign up Forms 108 116 3. Subscription Management Portal -
servicebot/trunk/public/class-servicebot-public.php
r2575614 r2575845 119 119 } 120 120 121 function billflow_log_in_user($user_id, $email, $user_login, $password, $ caller){121 function billflow_log_in_user($user_id, $email, $user_login, $password, $subscription_id, $caller){ 122 122 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); 124 127 125 128 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 } 133 164 }else{ 134 165 // Login the new user … … 173 204 if ( ! is_wp_error( $user_id ) ) { 174 205 175 // add user meta to note that this is created by Stripe webhook206 // add user meta to note that this is created by ajax 176 207 update_user_meta($user_id, "billflow_checkout_created", TRUE); 177 208 update_user_meta($user_id, "billflow_created", TRUE); … … 202 233 // if user exists but not newly created by webhook 203 234 // 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'); 205 236 206 237 }else{ … … 272 303 $userdata = array( 273 304 'user_login' => $email, 274 'user_email' => $email 305 'user_email' => $email, 306 'password' => $subscription_id 275 307 ); 308 276 309 $user_id = wp_insert_user( $userdata ); 277 310 -
servicebot/trunk/public/widgets/js/billflow-widget.js
r2575606 r2575845 96 96 } 97 97 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 }) 98 113 } 99 114 … … 154 169 const ajax_url = admin_ajax_url; 155 170 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 157 174 console.debug("Creating user", response, extras); 175 158 176 const payload = { 159 177 action: "create_user", … … 163 181 password: password 164 182 }; 165 await createUserPromise(payload); 183 184 // await delayed(10000, createUserPromise, payload); 185 await createUserPromise(payload) 186 // console.debug("Delayed call finished") 166 187 } 167 188 -
servicebot/trunk/servicebot.php
r2575614 r2575845 17 17 * Plugin URI: http://www.wpexplorer.com/servicebot/ 18 18 * Description: Provides NO-CODE integration between WordPress and Billflow, an UI layer on top of Stripe Billing. 19 * Version: 2.1. 319 * Version: 2.1.4 20 20 * Author: Billflow 21 21 * Author URI: https://billflow.io … … 36 36 * Rename this for your plugin and update it as you release new versions. 37 37 */ 38 define( 'SERVICEBOT_VERSION', '2.1. 3' );38 define( 'SERVICEBOT_VERSION', '2.1.4' ); 39 39 40 40 /**
Note: See TracChangeset
for help on using the changeset viewer.