public function setUp()
 {
     parent::setUp();
     $this->config = AdyenTestConfiguration::createWithSuccessfulApi();
     Context::initWithLogger($this->config);
     $this->pendingDatabase = PendingDatabase::get();
     $this->pendingMessage = json_decode(file_get_contents(__DIR__ . '/../Data/pending.json'), true);
     $this->pendingDatabase->storeMessage($this->pendingMessage);
     $this->antifraudQueue = BaseQueueConsumer::getQueue('payments-antifraud');
 }
 public function setUp()
 {
     parent::setUp();
     $this->config = AdyenTestConfiguration::createWithSuccessfulApi();
     Context::initWithLogger($this->config);
     $this->pendingDatabase = PendingDatabase::get();
     $this->pendingMessage = json_decode(file_get_contents(__DIR__ . '/../Data/pending.json'), true);
     $this->pendingMessage['captured'] = true;
     $this->pendingDatabase->storeMessage($this->pendingMessage);
 }
 public function processMessage($message)
 {
     $logIdentifier = "message with gateway {$message['gateway']}" . " and order ID {$message['order_id']}";
     if ($this->paymentsInitialDatabase->isTransactionFailed($message)) {
         // Throw the message out if it's already failed
         Logger::info("Skipping failed {$logIdentifier}");
     } else {
         Logger::info("Storing {$logIdentifier} in database");
         $this->pendingDatabase->storeMessage($message);
     }
 }
 public function testDeleteMessage()
 {
     $uniq = mt_rand();
     $message1 = $this->getTestMessage($uniq);
     // Store a second message for a good time, and make sure we delete the
     // right one.
     $message2 = $this->getTestMessage($uniq);
     $this->db->storeMessage($message1);
     $this->db->storeMessage($message2);
     // Confirm work without using the API.
     $pdo = $this->db->getDatabase();
     $result = $pdo->query("\n\t\t\tselect * from pending\n\t\t\twhere gateway='test'\n\t\t\t\tand order_id = '{$message1['order_id']}'");
     $rows = $result->fetchAll(PDO::FETCH_ASSOC);
     $this->assertEquals(2, count($rows), 'Both records were stored.');
     $this->assertNotNull($rows[0]['id'], 'Record includes a primary row id');
     $this->assertNotEquals($rows[0]['id'], $rows[1]['id'], 'Records have unique primary ids');
     $this->db->deleteMessage($message1);
     // Confirm work without using the API.
     $pdo = $this->db->getDatabase();
     $result = $pdo->query("\n\t\t\tselect * from pending\n\t\t\twhere gateway = 'test'\n\t\t\t\tand order_id = '{$message1['order_id']}'");
     $rows = $result->fetchAll(PDO::FETCH_ASSOC);
     $this->assertEquals(0, count($rows), 'All rows deleted.');
 }