thephpleague / omnipay-common

Core components for the Omnipay PHP payment processing library
MIT License
329 stars 242 forks source link

Proposal - add NotifiyRequest functions to AbstractResponse #245

Open eileenmcnaughton opened 3 years ago

eileenmcnaughton commented 3 years ago

Sagepay requires that after a NotifyRequest is received calls are made back to the mothership. In order to facilitate this it has 3 functions:

The difference between reject & invalid is a little confusing but putting that aside for now - I think ideally the code that implemets omnipay could to

     $response = $this->gateway->acceptNotification($params)->send();
     $this->loadStoredDataAboutTransaction($response->getTransactionId();
     if ($response->isSuccessful()) {

         // do some validation to check it's in the DB & is legit.
         // we also set some params on the gateway from that stored data as accept does a checksum
         // comparison and then....
          $this->gateway->accept();
     }

without having to adapt the code by gateway to see if the method exists. Although Sagepay is a bit of an outlier there are others - for example mercanet has to call confirm() in order to echo the right thing for Mercanet to see the IPN as successful. I also suspect it's likely to become more common over time as the Sagepay one is a bit more secure..

A complication is Sagepay actually returns an instance of a request rather than a response - but I think that is something that should be fixed within sagepay