I'm trying to build a dynamic subscription system and came acroos this issue and I tried posting this question on the discord channel but I got no response.
Issue
I have a subscription with two items item (A) is the base item has a fixed quantity of 1, And item (B) users can increase the quantity and this should be added to the next billing cost.
The problem is, I was trying to display the next billing information for the user and I was getting the wrong total when using the nextPayment() method on the user's subscription.
Here's an example to make this clear.
My Items
Item (A): $10 (Quantity fixed cannot be increased)
Item (B): $5 (Can increase the quantity)
When a user first subscription he must at least have 1x item (B) so the initial subscription costs $15
Now if the user increase the quantity of item (B) to be 2, then the next payment should be $25 like so:
$10 (Item (A)) + $10 (2x Item(B)) + $5 prorated amount from last month.
Now when you try to get the next billing details using nextPayment() you get $30 which is not correct.
I inspected the nextPayment() method and the API response coming from Paddle and found that Paddle return multiple totals.
subtotal, 'grand_total', and total
The grand_total was the correct value.
And I talked to Paddle support and they said grand_total is the actual value paddle will charge the customer.
so grand_total should be the default total value return by nextPayment() method.
Here's how the customer support explained this to me
grand_total is the amount that will be charged by our payment processor.
The "$30" in this case is related to how Paddle calculates the next payment. The first transaction of subscription was $15 with 1 Item A ($10) and 1 Item B ($5); You increased the quantity of Item B ($5) to 2 and selected to charge the full amount of the added item on the next billing date. In this case, there are 3 entries involved in the scheduled payment:
2 Item B($10) for 2023-12-16 to 2024-01-16;
2 Item B($10) for 2023-01-16 to 2024-02-16;
1 Item A($10) for 2024-01-16 to 2024-02-16;
The total amount of the above 3 entries is $30. However, 1 Item B($5) for 2023-12-16 to 2024-01-16 was already paid in the first transaction, so this created a credit of $5. The final grand_total became $30-$5=$25.
I hope this makes sense, It's a bit confusing and it's very common to display the next billing amount for the user so there would be no hidden cost.
As a workaround I manually fetched the next payment inside my controller, But I hope this could be fixed.
Thanks!
Steps To Reproduce
Install and configure laravel + cashier-paddle
Create a subscription plan with multiple items
Create a dummy subscription to this plan
Try increasing the quantity for one the items
Try getting the next billing details using nextPayment() method.
Cashier Paddle Version
2.x
Laravel Version
10.10
PHP Version
8.2
Database Driver & Version
No response
Description
I'm trying to build a dynamic subscription system and came acroos this issue and I tried posting this question on the discord channel but I got no response.
Issue
I have a subscription with two items item (A) is the base item has a fixed quantity of 1, And item (B) users can increase the quantity and this should be added to the next billing cost.
The problem is, I was trying to display the next billing information for the user and I was getting the wrong total when using the
nextPayment()
method on the user's subscription.Here's an example to make this clear.
My Items Item (A): $10 (Quantity fixed cannot be increased) Item (B): $5 (Can increase the quantity)
When a user first subscription he must at least have 1x item (B) so the initial subscription costs $15
Now if the user increase the quantity of item (B) to be 2, then the next payment should be $25 like so: $10 (Item (A)) + $10 (2x Item(B)) + $5 prorated amount from last month.
Now when you try to get the next billing details using
nextPayment()
you get $30 which is not correct.I inspected the
nextPayment()
method and the API response coming from Paddle and found that Paddle return multiple totals.subtotal
, 'grand_total', andtotal
The
grand_total
was the correct value.And I talked to Paddle support and they said
grand_total
is the actual value paddle will charge the customer.so
grand_total
should be the default total value return bynextPayment()
method.Here's how the customer support explained this to me
I hope this makes sense, It's a bit confusing and it's very common to display the next billing amount for the user so there would be no hidden cost.
As a workaround I manually fetched the next payment inside my controller, But I hope this could be fixed.
Thanks!
Steps To Reproduce
nextPayment()
method.