Sonata\Component\Payment\TransactionInterface::setInformation PHP Method

setInformation() public method

public setInformation ( string $message )
$message string
    public function setInformation($message);

Usage Example

Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function callback(TransactionInterface $transaction)
 {
     // check if the order exists
     if (!$transaction->getOrder()) {
         $transaction->setStatusCode(TransactionInterface::STATUS_ORDER_UNKNOWN);
         $transaction->setState(TransactionInterface::STATE_KO);
         $transaction->setInformation('The order does not exist');
         return $this->handleError($transaction);
     }
     // check if the request is valid
     if (!$this->isRequestValid($transaction)) {
         $transaction->setStatusCode(TransactionInterface::STATUS_WRONG_REQUEST);
         $transaction->setState(TransactionInterface::STATE_KO);
         $transaction->setInformation('The request is not valid');
         return $this->handleError($transaction);
     }
     // check if the callback is valid
     if (!$this->isCallbackValid($transaction)) {
         $transaction->setStatusCode(TransactionInterface::STATUS_WRONG_CALLBACK);
         $transaction->setState(TransactionInterface::STATE_KO);
         $transaction->setInformation('The callback reference is not valid');
         return $this->handleError($transaction);
     }
     // apply the transaction id
     $this->applyTransactionId($transaction);
     // if the order is not open, then something already happen ... (duplicate callback)
     if (!$transaction->getOrder()->isOpen()) {
         $transaction->setState(TransactionInterface::STATE_OK);
         // the transaction is valid, but not the order state
         $transaction->setStatusCode(TransactionInterface::STATUS_ORDER_NOT_OPEN);
         $transaction->setInformation('The order is not open, then something already happen ... (duplicate callback)');
         return $this->handleError($transaction);
     }
     // send the confirmation request to the bank
     if (!($response = $this->sendConfirmationReceipt($transaction))) {
         $transaction->setInformation('Fail to send the confirmation receipt');
         $response = $this->handleError($transaction);
     }
     return $response;
 }