laravel / cashier-paddle

Cashier Paddle provides an expressive, fluent interface to Paddle's subscription billing services.
https://laravel.com/docs/cashier-paddle
MIT License
245 stars 57 forks source link

createAsCustomer Invalid Request #213

Closed haszzam closed 11 months ago

haszzam commented 11 months ago

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

image

haszzam commented 11 months ago

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 commented 11 months ago

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

haszzam commented 11 months ago

Great, thank you!