jeudi 27 juin 2019

Overwrite function to the Controller in laravel Cashier

i getting 1 problem. the quetion is subscription the customer . when i use stripe cashier in the laravel. https://appdividend.com/2018/12/05/laravel-stripe-payment-gateway-integration-tutorial-with-example/ this link give me perfect answer. but now i want to remove some column on subscriptions table which is the cashier provided. i want to remove quantity on table.

My controller:

 //SubscriptionController.php

 class SubscriptionController extends Controller
    {
        public function create(Request $request, Plan $plan)
        {
            $plan = Plan::findOrFail($request->get('plan'));
            $stripeToken = $request->stripeToken;
            $user = $request->user();
            $stripeplan = $request->stripe_plan;
            $planid = $request->plan;
            $user->newSubscription($user->name, $planid)->create($stripeToken);
            return redirect()->route('home')->with('success', 'Your plan subscribed successfully');
        }
    }

now stripe Cashier

//Billable

    public function subscription($subscription = 'default')
        {
            return $this->subscriptions->sortByDesc(function ($value) {
                return $value->created_at->getTimestamp();
            })->first(function ($value) use ($subscription) {
                return $value->name === $subscription;
            });
        }

//subscriptionBuilder.php

    public function create($token = null, array $options = [])
        {
            $customer = $this->getStripeCustomer($token, $options);

            $subscription = $customer->subscriptions->create($this->buildPayload());

            if (in_array($subscription->status, ['incomplete', 'incomplete_expired'])) {
                $subscription->cancel();

                throw SubscriptionCreationFailed::incomplete($subscription);
            }

            if ($this->skipTrial) {
                $trialEndsAt = null;
            } else {
                $trialEndsAt = $this->trialExpires;
            }

            return $this->owner->subscriptions()->create([
                'name' => $this->name,
                'stripe_id' => $subscription->id,
                'stripe_plan' => $this->plan,
                'quantity' => $this->quantity,
                'trial_ends_at' => $trialEndsAt,
                'ends_at' => null,

            ]);
        }

I want to delete this three:

 'quantity' => $this->quantity,
 'trial_ends_at' => $trialEndsAt,
 'ends_at' => null,

from using subscription controller. how to overwrite



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2KFSGta
via IFTTT

Aucun commentaire:

Enregistrer un commentaire