public function getCouponForUser()
    {
        Stripe::setApiKey(config('services.stripe.secret'));

        if (count(Spark::plans()) === 0) {
            abort(404);
        }

        try {
            $customer = StripeCustomer::retrieve(Auth::user()->stripe_id);

            if ($customer->discount) {
                return response()->json(
                    Coupon::fromStripeCoupon(
                        StripeCoupon::retrieve($customer->discount->coupon->id)
                    )
                );
            } else {
                abort(404);
            }
        } catch (Exception $e) {
            abort(404);
        }
    }
public function getCouponForUser()
    {
        Stripe::setApiKey(config('services.stripe.secret'));

        if (count(Spark::plans()) === 0) {
            abort(404);
        }

        try {
            $customer = StripeCustomer::retrieve(Auth::user()->stripe_id);

            if ($customer->discount) {
                return response()->json(
                    Coupon::fromStripeCoupon(
                        StripeCoupon::retrieve($customer->discount->coupon->id)
                    )
                );
            } else {
                abort(404);
            }
        } catch (Exception $e) {
            abort(404);
        }
    }
public function getCouponForUser ( ) { Stripe :: setApiKey ( config ( 'services.stripe.secret' ) ) ; if ( count ( Spark :: plans ( ) ) === 0 ) { abort ( 404 ) ; } try { $ customer = StripeCustomer :: retrieve ( Auth :: user ( ) -> stripe_id ) ; if ( $ customer -> discount ) { return response ( ) -> json ( Coupon :: fromStripeCoupon ( StripeCoupon :: retrieve ( $ customer -> discount -> coupon -> id ) ) ) ; } else { abort ( 404 ) ; } } catch ( Exception $ e ) { abort ( 404 ) ; } }
Get the current coupon for the authenticated user.

Used to display current discount on settings -> subscription tab.

@return \Illuminate\Http\Response
Get the current coupon for the authenticated user .