ValidatePayload example

protected function buildRefundPayload(OrderTransactionCaptureRefundEntity $refund, OrderEntity $order): RefundPayload
    {
        return new RefundPayload(
            $refund,
            $order
        );
    }

    protected function buildValidatePayload(Cart $cart, RequestDataBag $requestDataBag, SalesChannelContext $context): ValidatePayload
    {
        return new ValidatePayload(
            $cart,
            $requestDataBag->all(),
            $context,
        );
    }

    protected function buildCapturePayload(PreparedPaymentTransactionStruct $transaction, Struct $preOrderPaymentStruct): CapturePayload
    {
        return new CapturePayload(
            $transaction->getOrderTransaction(),
            $transaction->getOrder(),
            

#[Package('checkout')] class ValidatePayloadTest extends TestCase
{
    public function testPayload(): void
    {
        $cart = new Cart('hatouken');
        $requestData = ['foo' => 'bar'];
        $salesChannelContext = Generator::createSalesChannelContext();
        $source = new Source('foo', 'bar', '1.0.0');

        $payload = new ValidatePayload($cart$requestData$salesChannelContext);
        $payload->setSource($source);

        static::assertSame($cart$payload->getCart());
        static::assertSame($requestData$payload->getRequestData());
        static::assertSame($salesChannelContext$payload->getSalesChannelContext());
        static::assertSame($source$payload->getSource());
    }
}
Home | Imprint | This part of the site doesn't use cookies.