public function execute(ListenerMessage $msg)
 {
     $tl = new TaggedLogger('CaptureResponseAction');
     if ($msg instanceof Capture) {
         if ($msg->success) {
             $tl->info("Adding record capture job for {$msg->currency} {$msg->amount} with id {$msg->correlationId} and psp reference {$msg->pspReference}.");
             $recordJob = RecordCaptureJob::factory($msg);
             $jobQueue = Configuration::getDefaultConfig()->object('data-store/jobs-adyen');
             $jobQueue->push(json_decode($recordJob->toJson(), true));
         } else {
             $tl->warning("Capture failed for payment with reference {$msg->pspReference} and correlation id {$msg->correlationId}.", $msg);
         }
     }
     return true;
 }
 public function testRecordCapture()
 {
     $verifiedQueue = BaseQueueConsumer::getQueue('verified');
     $verifiedQueue->createTable('verified');
     $capture = KeyedOpaqueStorableObject::fromJsonProxy('SmashPig\\PaymentProviders\\Adyen\\ExpatriatedMessages\\Capture', file_get_contents(__DIR__ . '/../Data/capture.json'));
     $job = RecordCaptureJob::factory($capture);
     $this->assertTrue($job->execute());
     $donorData = $this->pendingDatabase->fetchMessageByGatewayOrderId('adyen', $capture->merchantReference);
     $this->assertNull($donorData, 'RecordCaptureJob left donor data on pending queue');
     $verifiedMessage = $verifiedQueue->pop();
     $this->assertNotNull($verifiedMessage, 'RecordCaptureJob did not send verified message');
     // can we use arraySubset yet?
     $sameKeys = array_intersect(array_keys($verifiedMessage), array_keys($this->pendingMessage));
     foreach ($sameKeys as $key) {
         if ($key === 'gateway_txn_id') {
             $this->assertEquals($capture->originalReference, $verifiedMessage[$key], 'RecordCaptureJob should have set gateway_txn_id');
         } else {
             $this->assertEquals($this->pendingMessage[$key], $verifiedMessage[$key], "Value of key {$key} mutated");
         }
     }
 }