Gracefully handle unrefundable ticket refund attempts #1063
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.
CampTix allows users to refund their ticket purchases, but Stipe and PayPal only allow refunds within a certain number of days after the ticket purchase.
transaction_is_refundable
method was added toCampTix_Payment_Method
with it defaulting to true in order to maintain backwards compatibility.CampTix_Payment_Method_Stripe
andCampTix_Payment_Method_PayPal
override that method with their own, quite similar checks.If the method class recognises that the transaction is not refundable,
WP_Error
is returned for passing a nice message to the tickets frontend if refunds are otherwise enabled.Also if someone tries to go directly to the refund URL, they will be sent to the tickets page with an error and that will be logged. Some code styling was made on the same go.
Fixes #577
Props @iandunn @actual-saurabh @ePascalC
Screenshots
How to test the changes in this Pull Request: