Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
If the limit is reached or if a wrong expiration date is entered, datatrans returns the user to the success URL with a payment status declined. No payment is created, but we also do not abort and require another payment.
Steps to reproduce
Use 12/99 or amount 9000 with a limit-card.
Proposed resolution
Throw a gateway exception in such a case, I also refactored things a bit to avoid unnecessary API requests when we already have a payment.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork commerce_datatrans-3200057
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
BerdirPushed some improvements to the merge request. Any unexpected status will now result in an exception. I first tried to make an error that is specific to declined, but that is only inside the details and I'm not sure how reliable those are. It is also a bit unfortuante that commerce_payment will then log this as an (system) error, but it's just failed validation and is kind of an expected flow.
I also did some cleanup and minor improvement to onReturn(), so that we don't do an API request just to realize that we already have a payment, so checking that first. In this case, that would explicitly not happen as the webhook will not create a payment and we have to check again. I'm not sure if it would be better to persist it as a failed payment, that would also give us a way to store the relevant information if a customer calls support and asks why they can't pay.
Comment #5
BerdirFurther improvements can happen later, also got confirmation from a client that this works. Merging.
Comment #6
Berdir