Skip to content

Mutation deletePaymentToken just disables and hide instead of deleting? #36137

Open
@rafaelpatro

Description

@rafaelpatro

Pre Conditions (*)
Magento 2.4-develop with Credit card payment and vault enabled.

Description

I'm having some issues with disabled tokens.
And I figured out the repository for tokens never deletes the registries. Actually they are just disabled by setting visibility and activation flags to zero.

public function delete(Data\PaymentTokenInterface $paymentToken)
{
/** @var PaymentToken $tokenModel */
$tokenModel = $this->getById($paymentToken->getEntityId());
if (empty($tokenModel->getPublicHash())) {
return false;
}
$tokenModel->setIsActive(false);
$tokenModel->setIsVisible(false);
$tokenModel->save();
return true;
}

So I was wondering why not removing these registries when requested by the customer.
Is there a reason for this? Is it a good practice to keep in table old and disabled tokens?

Manual steps to reproduce (*)

  1. Generate customer token using "generateCustomerToken" mutation
  2. Login to store-front and place order with Credit card vault enabled (with Save card for future option)
  3. Run "customerPaymentTokens" query and retrieve public_hash
  4. Run deletePaymentToken mutation
  5. Run deletePaymentToken mutation again using same public_hash

Issue: deletePaymentToken mutation always returining true. No error message displayed.
No payment tokens are removed from vault_payment_token DB table.
6. Run "customerPaymentTokens" query again
No issue: Empty set retrieved in the response as the payment token is deleted.
5. Run deletePaymentToken mutation with invalid public_hash
No issue: Expected error is retrieved in the response

Expected result:
Could not find a token .. Error message should be displayed. Just like if invalid public_hash is given.

Actual Result:
deletePaymentToken mutation always returining true.

Additional Information
#36137 (comment)

Metadata

Metadata

Assignees

Labels

Area: PaymentsComponent: GraphQLGraphQLIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P3May be fixed according to the position in the backlog.Progress: dev in progressProject: GraphQLReported on 2.4.xIndicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions