markdegrootnl / omnipay-ideal

MIT License
7 stars 9 forks source link

It seems #2

Open twicejr opened 8 years ago

twicejr commented 8 years ago

Take care. Even if a payment fails isSuccessful() returns true!

    //First request
    $gateway = \Omnipay\Omnipay::create('Ideal');

  //// ..........payment occurs after redirect etc.................

 //Request 2:
    if($gateway->supportsCompletePurchase())
    {
          $purchaseResponse = $this->gateway()->completePurchase($parameters)->send();
    }

    if($purchaseResponse->isSuccessful())
    {
          //WILL ALWAYS RETURN TRUE AT THE MOMENT 
    } 
markdegrootnl commented 8 years ago

Please explain

twicejr commented 8 years ago

The payment doesn't have to be succesful, for $purchaseResponse->isSuccessful() to return true. Even if the payment is not finished, it returns true.

I fixed it by adding the following to src/Omnipay/Ideal/Message/CompletePurchaseResponse.php:

public function isErrorResponse()
{
     return $this->getData()->Transaction->status != 'Success';
}

(see how isSuccessful works in src/Omnipay/Ideal/Message/AbstractResponse.php):::

    return !$this->isErrorResponse() && isset($this->getData()->Acquirer) && $this->rootElementExists();

Do you also think this is the appropriate solution?