Coder Social home page Coder Social logo

Comments (4)

driesvints avatar driesvints commented on July 28, 2024

Thanks @haszzam. Would maybe not filtering on status be the solution here to fetch all customers?

from cashier-paddle.

haszzam avatar haszzam commented on July 28, 2024

Hi @driesvints

I checked the other discussion and it's the same issue I'm having here.

In your reply here #218 (comment)
You're assuming the customer already exists in the database, and if it does, then ya the createAsCustomer() checks to see if the billable model has a customer attached to it in the daatabse and if so it simply returns this customer instance.

The issue arise when you delete the customer from the database and leave the billable and then try to run createAsCustomer() again on the same billable instance.

The best way to understand this issue is to reproduce it locally on your end with the following steps:

  1. Install a fresh laravel app
  2. Install and configure Cashier (Paddle)
  3. Run the migration
  4. Add the following code to DatabaseSeeder.php file
public function run(): void
{
    $user = \App\Models\User::factory()->create([
        'name'              =>  'John Doe',
        'email'             =>  '[email protected]',
        'password'          =>  bcrypt('password'),
        'email_verified_at' =>  now(),
    ]);

    $user->createAsCustomer();
}
  1. Run php artisan db:seed to create the demo user above
  2. Run php artisan migrate:fresh to clear the database
  3. Run php artisan db:seed to re-create the user again

The last command should fail, because the a customer with this email [email protected] already exists inside paddle.

So the whole point of this method createAsCustomerIfNotExists() is to prevent this failure by checking first if a customer with the same email exists inside paddle before attempting to create a new one.

Again, It's unlikely anyone gonna have this issue in a production environment, It's mostly gonna happen in development where you clear the database for whatever reason.

So This method would only make development a little easier, I don't know if it would make sense to add it to the library but I don't think it would hurt anyway to have available as an option.

from cashier-paddle.

driesvints avatar driesvints commented on July 28, 2024

Thanks @haszzam. Paddle has fixed the filter issue. I've sent in a fix for this now here: #220

Please note that this still will only re-add the customer record. Any previous subscription and transaction records aren't re-added.

from cashier-paddle.

haszzam avatar haszzam commented on July 28, 2024

Hi @driesvints.
Ya I understand it will only create an empty customer instance.

Thanks!

from cashier-paddle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.