laravel / cashier-paddle

Cashier Paddle provides an expressive, fluent interface to Paddle's subscription billing services.

Home Page:https://laravel.com/docs/cashier-paddle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

createAsCustomer Invalid Request

haszzam opened this issue · comments

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

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.

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

Great, thank you!