omnipay-authorizenet
omnipay-authorizenet copied to clipboard
deleteCard with cardReference
deleting cards does not work when your provide a cardReference string.
In order to fix this, please add these three lines at the top of the getData() method in CIMDeletePaymentProfileRequest.
$cardRef = $this->getCardReference(false);
$this->setCustomerProfileId($cardRef->getCustomerProfileId());
$this->setCustomerPaymentProfileId($cardRef->getPaymentProfileId());
Place these before the call to validate(). This will parse the string and get the customerProfileId and customerPaymentProfileId from the card reference json string.
Can submit a pull request if needed, let me know.
If I am reading this right, this fix assumes only the card reference is supplied, and overwrites the customerProfileId and customerPaymentProfileId regardless of whether they are set. Is this the intended action?
Yes, you are correct. The whole point of using omnipay is to provide a universal interface to use when performing common actions on any flavor of gateway. It has been my experience that many of the drivers were not fully developed with this in mind. Deleting a card is one of these common actions that should be universal without any gateway specific dependencies needing to be set. You should be able to pass in a cardReference and have the gateway take care of the rest without having to set any special properties gateway to gateway.
Coming back to this after a long time...I know.
My query was really concerning people who are already using this driver, and are setting the customerProfileId and customerPaymentProfileId fields explicitly. This change would break their applications. My suggestion is to check whether the fields are already set before overwriting them.