Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createAsCustomer Invalid Request #213

Closed
haszzam opened this issue Dec 7, 2023 · 3 comments · Fixed by #215
Closed

createAsCustomer Invalid Request #213

haszzam opened this issue Dec 7, 2023 · 3 comments · Fixed by #215
Labels

Comments

@haszzam
Copy link

haszzam commented Dec 7, 2023

Cashier Paddle Version

2.1.0

Laravel Version

10.10

PHP Version

8.1

Database Driver & Version

sqlite

Description

I'm trying to integrate the new Paddle Billing with my laravel app, I'm not able to craete a customer.

I want to offer a free trial without payment method upfront and I followed the documentations like so

In the RegisteredUserController Controller right after I create the new user I try to make it as a customer like so

$user->createAsCustomer([ 'trial_ends_at' => now()->addDays(7) ]);

But I keep getting this error and I don't know if it's an issue with Paddle or with Cashier.

image

I have all the required env variables set:

PADDLE_SANDBOX=true
PADDLE_SELLER_ID= # Set to my seller ID
PADDLE_AUTH_CODE= # Set to y API Key
PADDLE_WEBHOOK_SECRET= # Set to my webhook secret

I don't know if anyone else is having this issue, or is it just me.

Steps To Reproduce

  • Install fresh laravel app
  • Install and configure paddle as it's showen in the docs
  • Install laravel/breeze to add authentication
  • in the RegisteredUserController add the following line $user->createAsCustomer([ 'trial_ends_at' => now()->addDays(7) ]); right after you create the user.

image

@haszzam
Copy link
Author

haszzam commented Dec 7, 2023

Ok I found the source for this issue,

The createAsCustomer method sends the trial_ends_at property to paddle with the create customer POST request, and in my case since I want a free trial without payment method upfront Paddle is not expecting trial_ends_at property so it throws the following error

image

I was able to get it to work by updating the createAsCustomer method and unsetting the trial_ends_at from the $options array, like so.

image

This was just to test if it's gonna work or not, but this method needs to be updated to handle generic trials.

@driesvints
Copy link
Member

Thanks! I've sent in a PR for this one.

@haszzam
Copy link
Author

haszzam commented Dec 7, 2023

Great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants