[Parent] Store more transaction specific information on Payment entities

Created on 6 March 2020, over 4 years ago
Updated 20 August 2024, 3 months ago

Problem

When an order is placed a payment is created and referenced by that order. The payment stores information pertinent to the transaction. However it only stores information that is gateway inspecific. For credit card gateways there is a host of other information relevant to the payment that is not stored with the payment. This information is important for order processing and having transaction history readily available with the order.

The following gateway specific information is not stored with the payment:

  • Card Type
  • Last 4 digits
  • Expiration
  • CVV Verification Result
  • AVS Code

commerce_authnet stores a payment method whenever a card is used. This is referenced by the payment. However the information stored can be changed or removed by the user or an administrator.

Permission to modify and/or delete payment methods can be taken away to preserve stored information but this opens up numerous other issues. Giving users control over their payment methods is important as they may not want to store their credit card information or need to make a correction during checkout if they enter their payment method details incorrectly. Their card will eventually expire and they will need to enter a new one and remove the old entry so they don't have to pick between expired and valid cards during checkout.

If payment methods can be marked as deleted and removed from the UI this does not address the transaction specific details which would be inappropriate to store on the payment method.

Possible Solution

Allow gateways to create custom fields on the payment entity to store gateway specific payment information. (Similar to how payment methods work with gateway specific fields)

This gateway specific information can be presented with the payment on the payment tab of an order for easy reference or exported to other systems.

✨ Feature request
Status

Needs review

Version

2.0

Component

Payment

Created by

πŸ‡ΊπŸ‡ΈUnited States rhovland Oregon

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States rhovland Oregon

    Here is a patch that adds fields to store card payment details and adds it to the payment view.

    I considered adding an update hook to copy payment method details to payments from existing orders. However the payment methods could have been edited since then and it would be copying over incorrect information.

  • πŸ‡ΊπŸ‡ΈUnited States rhovland Oregon

    Realized I didn't finish the modifications to the payment view. Now displays the payment method details properly.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 7 months ago
    772 pass, 3 fail
  • Pipeline finished with Failed
    7 months ago
    Total: 523s
    #156066
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 7 months ago
    793 pass
  • Pipeline finished with Success
    7 months ago
    Total: 470s
    #156106
  • Status changed to Needs review 7 months ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 7 months ago
    772 pass, 3 fail
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 7 months ago
    765 pass, 5 fail
  • πŸ‡ΊπŸ‡ΈUnited States rhovland Oregon

    Putting this up for review. Has tests and upgrade hook for the added fields.

    Maybe we want to create a new issue for the 3.x branch for having different payment types (credit card, giftcard, check, ACH, crypto, etc).

  • Pipeline finished with Success
    3 months ago
    Total: 436s
    #258492
  • Pipeline finished with Success
    3 months ago
    Total: 485s
    #258503
  • πŸ‡ΊπŸ‡ΈUnited States rhovland Oregon

    After talking a bit about the implementation in slack I decided to rename the fields and functions so the changes are less credit card specific and can be used for other payment types.

    Examples: Paypal payment gateway could set payment_type to be whatever was used to actually pay such as Visa, ACH, PayPal Credit, Pay in 4, etc. Or if it was paid for with crypto, the payment_type would be the coin used. Credit card gateways would fill in the card type such as Visa, Mastercard, etc.

    The payment_identifier would be anything that would help identify the payment method used without having to lookup transaction details on the payment provider's systems, if they still exist. This could be last 4 digits of a credit card number for credit card gateways, a wallet id, etc.

  • Pipeline finished with Failed
    3 months ago
    Total: 1062s
    #259700
  • Pipeline finished with Success
    3 months ago
    Total: 412s
    #259712
Production build 0.71.5 2024