Skip to content

Commit

Permalink
Bug fix; Stripe token on 0$ trial period. See: wpsharks/s2member#326
Browse files Browse the repository at this point in the history
  • Loading branch information
JasWSInc committed Sep 8, 2014
1 parent 83bce7a commit d05bd77
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static function stripe_checkout()
)
{
$GLOBALS['ws_plugin__s2member_pro_stripe_checkout_response'] = array(); // This holds the global response details.
$global_response = & $GLOBALS['ws_plugin__s2member_pro_stripe_checkout_response'];
$global_response = &$GLOBALS['ws_plugin__s2member_pro_stripe_checkout_response'];

$post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST['s2member_pro_stripe_checkout']));
$post_vars['attr'] = (!empty($post_vars['attr'])) ? (array)unserialize(c_ws_plugin__s2member_utils_encryption::decrypt($post_vars['attr'])) : array();
Expand Down Expand Up @@ -141,7 +141,7 @@ public static function stripe_checkout()
if(!is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::get_customer($user_id, $user->user_email, $post_vars['first_name'], $post_vars['last_name'])))
$global_response = array('response' => $stripe_customer, 'error' => TRUE);

else if(!is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_card_token($stripe_customer->id, $post_vars['card_token'])))
else if(!is_object($stripe_customer = $stripe_customer_w_card_token = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_card_token($stripe_customer->id, $post_vars['card_token'])))
$global_response = array('response' => $stripe_customer, 'error' => TRUE);

else if(!is_object($stripe_charge = c_ws_plugin__s2member_pro_stripe_utilities::create_customer_charge($stripe_customer->id, ($post_vars['attr']['tp'] && $cost_calculations['trial_total'] > 0) ? $cost_calculations['trial_total'] : $cost_calculations['total'], $cost_calculations['cur'], $cost_calculations['desc'])))
Expand All @@ -159,12 +159,12 @@ public static function stripe_checkout()
if(!is_object($stripe_plan = c_ws_plugin__s2member_pro_stripe_utilities::get_plan($plan_attr)))
$global_response = array('response' => $stripe_plan, 'error' => TRUE);

else if((!isset($stripe_customer) || !is_object($stripe_customer))
else if((empty($stripe_customer) || !is_object($stripe_customer))
&& !is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::get_customer($user_id, $user->user_email, $post_vars['first_name'], $post_vars['last_name']))
) $global_response = array('response' => $stripe_customer, 'error' => TRUE);

else if((!isset($stripe_customer) || !is_object($stripe_customer))
&& !is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_card_token($stripe_customer->id, $post_vars['card_token']))
else if((empty($stripe_customer_w_card_token) || !is_object($stripe_customer_w_card_token))
&& !is_object($stripe_customer = $stripe_customer_w_card_token = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_card_token($stripe_customer->id, $post_vars['card_token']))
) $global_response = array('response' => $stripe_customer, 'error' => TRUE);

else if(!is_object($stripe_subscription = c_ws_plugin__s2member_pro_stripe_utilities::create_customer_subscription($stripe_customer->id, $stripe_plan->id)))
Expand Down Expand Up @@ -270,7 +270,7 @@ public static function stripe_checkout()
if(!is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::get_customer(0, $post_vars['email'], $post_vars['first_name'], $post_vars['last_name'])))
$global_response = array('response' => $stripe_customer, 'error' => TRUE);

else if(!is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_card_token($stripe_customer->id, $post_vars['card_token'])))
else if(!is_object($stripe_customer = $stripe_customer_w_card_token = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_card_token($stripe_customer->id, $post_vars['card_token'])))
$global_response = array('response' => $stripe_customer, 'error' => TRUE);

else if(!is_object($stripe_charge = c_ws_plugin__s2member_pro_stripe_utilities::create_customer_charge($stripe_customer->id, ($post_vars['attr']['tp'] && $cost_calculations['trial_total'] > 0) ? $cost_calculations['trial_total'] : $cost_calculations['total'], $cost_calculations['cur'], $cost_calculations['desc'])))
Expand All @@ -288,12 +288,12 @@ public static function stripe_checkout()
if(!is_object($stripe_plan = c_ws_plugin__s2member_pro_stripe_utilities::get_plan($plan_attr)))
$global_response = array('response' => $stripe_plan, 'error' => TRUE);

else if((!isset($stripe_customer) || !is_object($stripe_customer))
else if((empty($stripe_customer) || !is_object($stripe_customer))
&& !is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::get_customer(0, $post_vars['email'], $post_vars['first_name'], $post_vars['last_name']))
) $global_response = array('response' => $stripe_customer, 'error' => TRUE);

else if((!isset($stripe_customer) || !is_object($stripe_customer))
&& !is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_card_token($stripe_customer->id, $post_vars['card_token']))
else if((empty($stripe_customer_w_card_token) || !is_object($stripe_customer_w_card_token))
&& !is_object($stripe_customer = $stripe_customer_w_card_token = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_card_token($stripe_customer->id, $post_vars['card_token']))
) $global_response = array('response' => $stripe_customer, 'error' => TRUE);

else if(!is_object($stripe_subscription = c_ws_plugin__s2member_pro_stripe_utilities::create_customer_subscription($stripe_customer->id, $stripe_plan->id)))
Expand Down Expand Up @@ -431,7 +431,7 @@ public static function stripe_checkout()
if(!is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::get_customer($user_id, $user->user_email, $post_vars['first_name'], $post_vars['last_name'])))
$global_response = array('response' => $stripe_customer, 'error' => TRUE);

else if(!is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_card_token($stripe_customer->id, $post_vars['card_token'])))
else if(!is_object($stripe_customer = $stripe_customer_w_card_token = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_card_token($stripe_customer->id, $post_vars['card_token'])))
$global_response = array('response' => $stripe_customer, 'error' => TRUE);

else if(!is_object($stripe_charge = c_ws_plugin__s2member_pro_stripe_utilities::create_customer_charge($stripe_customer->id, $cost_calculations['total'], $cost_calculations['cur'], $cost_calculations['desc'])))
Expand Down Expand Up @@ -509,7 +509,7 @@ public static function stripe_checkout()
if(!is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::get_customer(0, $post_vars['email'], $post_vars['first_name'], $post_vars['last_name'])))
$global_response = array('response' => $stripe_customer, 'error' => TRUE);

else if(!is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_card_token($stripe_customer->id, $post_vars['card_token'])))
else if(!is_object($stripe_customer = $stripe_customer_w_card_token = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_card_token($stripe_customer->id, $post_vars['card_token'])))
$global_response = array('response' => $stripe_customer, 'error' => TRUE);

else if(!is_object($stripe_charge = c_ws_plugin__s2member_pro_stripe_utilities::create_customer_charge($stripe_customer->id, $cost_calculations['total'], $cost_calculations['cur'], $cost_calculations['desc'])))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static function stripe_sp_checkout()
)
{
$GLOBALS['ws_plugin__s2member_pro_stripe_sp_checkout_response'] = array(); // This holds the global response details.
$global_response = & $GLOBALS['ws_plugin__s2member_pro_stripe_sp_checkout_response'];
$global_response = &$GLOBALS['ws_plugin__s2member_pro_stripe_sp_checkout_response'];

$post_vars = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST['s2member_pro_stripe_sp_checkout']));
$post_vars['attr'] = (!empty($post_vars['attr'])) ? (array)unserialize(c_ws_plugin__s2member_utils_encryption::decrypt($post_vars['attr'])) : array();
Expand Down Expand Up @@ -91,7 +91,7 @@ public static function stripe_sp_checkout()
if(!is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::get_customer(get_current_user_id(), $post_vars['email'], $post_vars['first_name'], $post_vars['last_name'])))
$global_response = array('response' => $stripe_customer, 'error' => TRUE);

else if(!is_object($stripe_customer = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_card_token($stripe_customer->id, $post_vars['card_token'])))
else if(!is_object($stripe_customer = $stripe_customer_w_card_token = c_ws_plugin__s2member_pro_stripe_utilities::set_customer_card_token($stripe_customer->id, $post_vars['card_token'])))
$global_response = array('response' => $stripe_customer, 'error' => TRUE);

else if(!is_object($stripe_charge = c_ws_plugin__s2member_pro_stripe_utilities::create_customer_charge($stripe_customer->id, $cost_calculations['total'], $cost_calculations['cur'], $cost_calculations['desc'])))
Expand Down

0 comments on commit d05bd77

Please # to comment.