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

Command icon 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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir created an issue. See original summary.

Berdir’s picture

Status: Active » Needs review

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

  • Berdir committed e9d40c9 on 2.0.x
    Issue #3200057 by Berdir: Handle declined and other non-successful...
Berdir’s picture

Further improvements can happen later, also got confirmation from a client that this works. Merging.

Berdir’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.