Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements some improvements and new API's for discount handling.
First of all, a new
PromotionCode
class was added that wraps aStripe\PromotionCode
object. This object represents a promotion code applied to either a customer or subscription.Further, the
Discount
class now also features apromotionCode
method to easily retrieve the promotion code should one have been used to apply a discount. Besides that, the class got dedicated methods to transform thestart
andend
timestamps of a discount intoCarbon\Carbon
objects.Other than that it's now easy to retrieve a
PromotionCode
by its code:It's now also easy to retrieve the applied discount on a customer or subscription:
And it's easy now to apply a new coupon or promotion code on either a customer or subscription. These need the ID of their respective object:
I was thinking to add also some validation rules like
coupon
,promotion_code
orcoupon_or_promotion_code
but decided to not extend the scope of this PR any further.Closes #852