laravel-cashier-mollie
laravel-cashier-mollie copied to clipboard
Applied coupons not subtracted from the reimbursable amount
Hi there,
I noticed the applied coupons were not subtracted from the reimbursable amount when swapping a subscription. The issue occurs when calling ->toArray()
on the order item collection. total
is a accessor on the OrderItem model and since the appends array on the model is empty the value won't be included when casting to an array.
Alternatively, you could either add a $appends
array containing the total
key or call $this->append('total');
in the OrderItemCollection@getTotal
method (available since L9 according to the docs).
Hi @sander3,
could you add a test for this issue please?
I hope to find some time later this week.
Btw, the handlePaymentFailed
method on the AppliedCoupon
model causes the coupon to not be subtracted from the reimbursableAmount
as well. Having a failed payment before swapping plans is cheaper for the customer haha.
Btw, the
handlePaymentFailed
method on theAppliedCoupon
model causes the coupon to not be subtracted from thereimbursableAmount
as well. Having a failed payment before swapping plans is cheaper for the customer haha.
Hi @sander3,
can you explain this to me please?
Btw, the
handlePaymentFailed
method on theAppliedCoupon
model causes the coupon to not be subtracted from thereimbursableAmount
as well. Having a failed payment before swapping plans is cheaper for the customer haha.Hi @sander3,
can you explain this to me please?
If a subscription payment fails, the AppliedCoupon
self-deletes in ->handlePaymentFailed()
causing it to be unavailable in the subscription reimbursableAmount()
on line 788:
$appliedCoupons = $this->appliedCoupons()->with('orderItems')->get();
Therefor, the applied coupon (which remains "applied" to the already existing order, aka the customer has received a discount) is not available in order to be reduced from the reimbursableAmount()
.