CalumChilds's avatar

CalumChilds liked a comment+100 XP

1mo ago

I skimmed the forum, tried some searches, and am hoping to get a little more clarity on what I need to do to import an already existing subscription system into Laravel Cashier.

We have a lot of subscribers. So I am going to have to sync them and their data.

We have a couple of products people can subscribe to. 2 different monthly ones, and a yearly one.

I am simply asking for a cliff notes version of what features/methods/classes to utilize to pull this off. I am familiar with Laravel, but not Cashier, and I don't know much about Stripe other than using from the front end lol. I see that Cashier can use the Stripe SDK directly.

What methods/classes am I looking for to fetch the products, and what ones do I need to use to add them into Cashier?

What methods/classes am I looking for to fetch the users and their subscription data, and what ones do I need to add them into Cashier?

Not every user of the system is found in Stripe. Only the paid subscribers are in Stripe. So a person who created a free account isn't found in Stripe, and just is a user of the Wordpress site. So during the loops, I would have to check if they are even in Stripe. - During this data rebuilding, should even the free users have a customer entry in Stripe? They just obviously wouldn't have any subscriptions. Just asking in case it's easier down the line for some case.

Outline of the process:

Products:

  • Fetch all products from Stripe
  • Add products to Cashier

Users:

  • Fetch all the users in chunks of maybe 500
  • Foreach user:
    • create user
    • if found in Stripe, retrieve/import their Stripe subscription (to matching product) data into Cashier

I am hoping someone can tell me the methods/classes I am going to need. Like, "You are going to need the retrieveProducts() method on the X class, loop through them and use insertProduct() to add the product into Cashier. Then for each user, use the findStripeUser() method of the Foo class then use insertUser() method from the Bar class to add them into Cashier".

I am not wanting to mess with any existing subscriptions or invoices or anything. So when adding the data into Cashier, I can't be creating a new subscription or have it sending emails to the users lol. Literally, I am just trying to copy the data. Then with the webhooks, both systems can be in synch until we rip the bandaid off and make the final swap and ditch the Wordpress system.

PS: I know it may be a bit for someone to answer. I noticed other people asking about importing and they didn't get much of a response. So answering the above might help others in the future. Cashier shouldn't be just a system you use from the start or never use it. We have to be able to import an existing setup. I am not asking Cashier to implement an "import" feature, but even if it results in a 3rd party library and/or YouTube tutorials on how to do it, it would help the community and onboarding to Cashier.

CalumChilds's avatar

CalumChilds liked a comment+100 XP

2mos ago

hello guys thanks for your support i have found my issue. it was actually twofold case one was

Gate::before(function($user, $ability) {
            return $user->isAdmin();
        });

so if you where a normal user and not admin this naturally returns false so that makes the result false

Gate::before(function($user, $ability) {
            if ($user->isAdmin()) {
                return true;
            }

        });

so with this if a user is admin will return true else it will proceed to the policy

the second actually comes from a previous comment @wilburpowery

where i replied that the documentation says that you suppose to send a full class name if it is not receiving an instance

 public function view(User $user, Lecture $lecture)
    {
        return $user->isSubscribed();
    }

the documentation actually refers to the case of create ex.

    public function create(User $user)
    {
        //
    }

so thank you all for your comment.

CalumChilds's avatar

CalumChilds liked a comment+100 XP

2mos ago

How can I access a field error inside a blade component.

@error('{{ $fieldName }}') {{ $message }} @enderror

I used the above code template but won't work

CalumChilds's avatar

CalumChilds liked a comment+100 XP

2mos ago

I want to get validation errors inside of blade component(php file), how to do that? in typical blade pages I could use @error, and get the message if there is corresponding validation error.

CalumChilds's avatar

CalumChilds wrote a reply+100 XP

2mos ago

Thank you, I was having a similar issue and adding /public/ before the URL I wanted to access worked for me. Like this:

http://localhost/public/home

CalumChilds's avatar

CalumChilds liked a comment+100 XP

2mos ago

I am new to laravel. I installed properly laravel last week and it was work properly. Unfortunately today it is not working. When I issue the php artisan serve command it is not working. Pl help me.

CalumChilds's avatar

CalumChilds liked a comment+100 XP

2mos ago

@sisilchandana

I suggest two solutions-

Way One:

  • Remove vendor folder and run the composer install again to download.
  • Then try to run php artisan serve.

Way Two: