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

Applied coupons not subtracted from the reimbursable amount #207

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sander3
Copy link
Contributor

@sander3 sander3 commented Oct 2, 2023

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).

@Naoray
Copy link
Collaborator

Naoray commented Oct 3, 2023

Hi @sander3,

could you add a test for this issue please?

@sander3
Copy link
Contributor Author

sander3 commented Oct 4, 2023

I hope to find some time later this week.

@sander3
Copy link
Contributor Author

sander3 commented Oct 5, 2023

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.

@Naoray
Copy link
Collaborator

Naoray commented Nov 2, 2023

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.

Hi @sander3,

can you explain this to me please?

@sander3
Copy link
Contributor Author

sander3 commented Nov 2, 2023

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.

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().

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

Successfully merging this pull request may close these issues.

2 participants