public/wordpress/wp-content/plugins/wp-courseware/includes/gateways/stripe/stripe-subscription.php
/**
	 * Maybe Create Plan.
	 *
	 * @since 4.3.0
	 *
	 * @return Plan|object The stripe plan object or an error object on failure.
	 */
Maybe Create Plan.

@return Plan|object The stripe plan object or an error object on failure.
Maybe Create Plan . @return Plan|object The stripe plan object or an error object on failure .
protected function maybe_create_plan() {
		if ( empty( $this->order_item ) ) {
			return;
		}
		if ( ! empty( $this->plan ) && $this->plan instanceof Plan ) {
			return $this->plan;
		}
		try {
			$this->plan = $this->gateway->get_api()->get_plan( $this->get_plan_id() );
			$currency   = strtolower( wpcw_get_currency() );
			if ( ! empty( $this->plan->error ) ) {
				throw new Stripe_Exception( $this->plan->error->type, $this->plan->error->message );
			}
			if ( strtolower( $this->plan->currency ) !== $currency ) {
				$plan_id   = $this->get_plan_id() . '_' . $currency;
				$plan_args = $this->get_plan_args();
				try {
					$this->plan = $this->gateway->get_api()->get_plan( $this->get_plan_id() );
					if ( ! empty( $this->plan->error ) ) {
						throw new Stripe_Exception( $this->plan->error->type, $this->plan->error->message );
					}
				} catch ( Stripe_Exception $exception ) {
					$plan_args['id'] = $plan_id;
					$this->plan      = $this->create_plan( $plan_args );
					if ( ! empty( $this->plan->error ) ) {
						throw new Stripe_Exception( $this->plan->error->type, $this->plan->error->message );
					}
				}
			}
		} catch ( Stripe_Exception $exception ) {
			$this->plan = $this->create_plan();
			if ( ! empty( $this->plan->error ) ) {
				throw new Stripe_Exception( $this->plan->error->type, $this->plan->error->message );
			}
		}
	}
protected function maybe_create_plan ( ) { if ( empty ( $ this -> order_item ) ) { return ; } if ( ! empty ( $ this -> plan ) && $ this -> plan instanceof Plan ) { return $ this -> plan ; } try { $ this -> plan = $ this -> gateway -> get_api ( ) -> get_plan ( $ this -> get_plan_id ( ) ) ; $ currency = strtolower ( wpcw_get_currency ( ) ) ; if ( ! empty ( $ this -> plan -> error ) ) { throw new Stripe_Exception ( $ this -> plan -> error -> type , $ this -> plan -> error -> message ) ; } if ( strtolower ( $ this -> plan -> currency ) !== $ currency ) { $ plan_id = $ this -> get_plan_id ( ) . '_' . $ currency ; $ plan_args = $ this -> get_plan_args ( ) ; try { $ this -> plan = $ this -> gateway -> get_api ( ) -> get_plan ( $ this -> get_plan_id ( ) ) ; if ( ! empty ( $ this -> plan -> error ) ) { throw new Stripe_Exception ( $ this -> plan -> error -> type , $ this -> plan -> error -> message ) ; } } catch ( Stripe_Exception $ exception ) { $ plan_args [ 'id' ] = $ plan_id ; $ this -> plan = $ this -> create_plan ( $ plan_args ) ; if ( ! empty ( $ this -> plan -> error ) ) { throw new Stripe_Exception ( $ this -> plan -> error -> type , $ this -> plan -> error -> message ) ; } } } } catch ( Stripe_Exception $ exception ) { $ this -> plan = $ this -> create_plan ( ) ; if ( ! empty ( $ this -> plan -> error ) ) { throw new Stripe_Exception ( $ this -> plan -> error -> type , $ this -> plan -> error -> message ) ; } } }
Maybe Create Plan.
Maybe Create Plan .