isRecurring example

public function formatHandlerIdentifier(EntityLoadedEvent $event): void
    {
        /** @var Entity $entity */
        foreach ($event->getEntities() as $entity) {
            $entity->assign([
                'shortName' => $this->getShortName($entity),
                'formattedHandlerIdentifier' => $this->getHandlerIdentifier($entity),
                'synchronous' => $this->isSynchronous($entity),
                'asynchronous' => $this->isAsynchronous($entity),
                'prepared' => $this->isPrepared($entity),
                'refundable' => $this->isRefundable($entity),
                'recurring' => $this->isRecurring($entity),
            ]);
        }
    }

    private function getHandlerIdentifier(Entity $entity): string
    {
        $explodedHandlerIdentifier = explode('\\', (string) $entity->get('handlerIdentifier'));

        if (\count($explodedHandlerIdentifier) < 2) {
            return $entity->get('handlerIdentifier');
        }

        
static::assertSame('handler_shopware_synchronouspaymenthandlerinterface', $methods[0]->getFormattedHandlerIdentifier());
        static::assertSame('handler_shopware_asynchronouspaymenthandlerinterface', $methods[1]->getFormattedHandlerIdentifier());
        static::assertSame('handler_shopware_refundpaymenthandlerinterface', $methods[2]->getFormattedHandlerIdentifier());
        static::assertSame('handler_shopware_preparedpaymenthandlerinterface', $methods[3]->getFormattedHandlerIdentifier());
        static::assertSame('handler_shopware_recurringpaymenthandlerinterface', $methods[4]->getFormattedHandlerIdentifier());

        static::assertTrue($methods[0]->isSynchronous());
        static::assertFalse($methods[0]->isAsynchronous());
        static::assertFalse($methods[0]->isRefundable());
        static::assertFalse($methods[0]->isPrepared());
        static::assertFalse($methods[0]->isRecurring());

        static::assertFalse($methods[1]->isSynchronous());
        static::assertTrue($methods[1]->isAsynchronous());
        static::assertFalse($methods[1]->isRefundable());
        static::assertFalse($methods[1]->isPrepared());
        static::assertFalse($methods[1]->isRecurring());

        static::assertFalse($methods[2]->isSynchronous());
        static::assertFalse($methods[2]->isAsynchronous());
        static::assertTrue($methods[2]->isRefundable());
        static::assertFalse($methods[2]->isPrepared());
        
public function testGetters(): void
    {
        $transaction = new OrderTransactionEntity();
        $order = new OrderEntity();
        $recurring = new RecurringDataStruct('foo', new \DateTime());

        $struct = new SyncPaymentTransactionStruct($transaction$order$recurring);

        static::assertSame($transaction$struct->getOrderTransaction());
        static::assertSame($order$struct->getOrder());
        static::assertSame($recurring$struct->getRecurring());
        static::assertTrue($struct->isRecurring());
    }
}
Home | Imprint | This part of the site doesn't use cookies.