public/wordpress/wp-content/plugins/wp-courseware/includes/gateways/gateway-stripe.php
/**
	 * Process Subscription Completion.
	 *
	 * @since 4.6.0
	 *
	 * @param Subscription $subscription The subscription object.
	 */
Process Subscription Completion.

@param Subscription $subscription The subscription object.
Process Subscription Completion . @param Subscription $subscription The subscription object .
public function process_subscription_completion( $subscription ) {
		try {
			if ( ! $subscription instanceof Subscription ) {
				throw new Stripe_Exception( 'stripe-subscription-not-setup', __( 'The subscription is not setup. Aborting competion...', 'wp-courseware' ) );
			}
			$this->setup();
			$profile_id = $subscription->get_profile_id();
			if ( empty( $profile_id ) ) {
				throw new Stripe_Exception( 'stripe-subscription-profile-id-not-set', __( 'The subscription profile id is not setup. Aborting completion...', 'wp-courseware' ) );
			}
			$stripe_subscription = $this->get_api()->get_subscription( $profile_id );
			if ( ! empty( $stripe_subscription->error ) ) {
				throw new Stripe_Exception( $stripe_subscription->error->type, $stripe_subscription->error->message );
			}
			$stripe_subscription->cancel();
			$subscription->complete();
		} catch ( Stripe_Exception $exception ) {
			$this->log( sprintf( __( 'An error occurred while trying to complete the subscription. Error Message: %s', 'wp-courseware' ), $exception->getLocalizedMessage() ) );
			return false;
		}
		return true;
	}
public function process_subscription_completion ( $ subscription ) { try { if ( ! $ subscription instanceof Subscription ) { throw new Stripe_Exception ( 'stripe-subscription-not-setup' , __ ( 'The subscription is not setup. Aborting competion...' , 'wp-courseware' ) ) ; } $ this -> setup ( ) ; $ profile_id = $ subscription -> get_profile_id ( ) ; if ( empty ( $ profile_id ) ) { throw new Stripe_Exception ( 'stripe-subscription-profile-id-not-set' , __ ( 'The subscription profile id is not setup. Aborting completion...' , 'wp-courseware' ) ) ; } $ stripe_subscription = $ this -> get_api ( ) -> get_subscription ( $ profile_id ) ; if ( ! empty ( $ stripe_subscription -> error ) ) { throw new Stripe_Exception ( $ stripe_subscription -> error -> type , $ stripe_subscription -> error -> message ) ; } $ stripe_subscription -> cancel ( ) ; $ subscription -> complete ( ) ; } catch ( Stripe_Exception $ exception ) { $ this -> log ( sprintf ( __ ( 'An error occurred while trying to complete the subscription. Error Message: %s' , 'wp-courseware' ) , $ exception -> getLocalizedMessage ( ) ) ) ; return false ; } return true ; }
Process Subscription Completion.
Process Subscription Completion .