| @@ -36,9 +36,9 @@ | ||
| 36 | 36 | * @since 6.5 |
| 37 | 37 | * |
| 38 | 38 | * @param array $atts |
| 39 | 39 | * |
| 40 | - * @return int|string $sub_id | |
| 40 | + * @return int|string Sub ID. | |
| 41 | 41 | */ |
| 42 | 42 | public static function create_new_subscription( $atts ) { |
| 43 | 43 | $atts['charge'] = (object) $atts['charge']; |
| 44 | 44 | |
| @@ -100,17 +100,17 @@ | ||
| 100 | 100 | */ |
| 101 | 101 | private static function get_plan_for_action( $action ) { |
| 102 | 102 | $plan_id = $action->post_content['plan_id']; |
| 103 | 103 | |
| 104 | - if ( ! $plan_id ) { | |
| 105 | - // The amount has already been formatted, so add the decimal back in. | |
| 106 | - $amount = $action->post_content['amount']; | |
| 107 | - $action->post_content['amount'] = number_format( $amount / 100, 2, '.', '' ); | |
| 108 | - $plan_opts = self::prepare_plan_options( $action->post_content ); | |
| 109 | - $plan_id = self::maybe_create_plan( $plan_opts ); | |
| 104 | + if ( $plan_id ) { | |
| 105 | + return $plan_id; | |
| 110 | 106 | } |
| 111 | 107 | |
| 112 | - return $plan_id; | |
| 108 | + // The amount has already been formatted, so add the decimal back in. | |
| 109 | + $amount = $action->post_content['amount']; | |
| 110 | + $action->post_content['amount'] = number_format( $amount / 100, 2, '.', '' ); | |
| 111 | + $plan_opts = self::prepare_plan_options( $action->post_content ); | |
| 112 | + return self::maybe_create_plan( $plan_opts ); | |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | 116 | * @since 6.5 |
| @@ -126,9 +126,9 @@ | ||
| 126 | 126 | 'amount' => $amount, |
| 127 | 127 | 'interval' => $settings['interval'], |
| 128 | 128 | 'interval_count' => $settings['interval_count'], |
| 129 | 129 | 'currency' => $settings['currency'], |
| 130 | - 'name' => empty( $settings['description'] ) ? $default_description : $settings['description'], | |
| 130 | + 'name' => ! empty( $settings['description'] ) ? $settings['description'] : $default_description, | |
| 131 | 131 | ); |
| 132 | 132 | |
| 133 | 133 | if ( ! empty( $settings['trial_interval_count'] ) ) { |
| 134 | 134 | $plan_opts['trial_period_days'] = self::get_trial_with_default( $settings['trial_interval_count'] ); |
| @@ -146,9 +146,8 @@ | ||
| 146 | 146 | * |
| 147 | 147 | * @return mixed |
| 148 | 148 | */ |
| 149 | 149 | public static function maybe_create_plan( $plan ) { |
| 150 | - FrmStrpLiteAppHelper::call_stripe_helper_class( 'initialize_api' ); | |
| 151 | 150 | return FrmStrpLiteAppHelper::call_stripe_helper_class( 'maybe_create_plan', $plan ); |
| 152 | 151 | } |
| 153 | 152 | |
| 154 | 153 | /** |