build($options); $data = $serializer->serialize($instance); $request = new CreatePaymentMethodRequest($options); $expected = $request->toArray(); self::assertEquals($expected, $data); } /** * @throws Exception */ public static function validDataProvider(): array { return [[ ['type' => SavePaymentMethodType::BANK_CARD]], [[ 'type' => SavePaymentMethodType::BANK_CARD, 'card' => [ 'number' => Random::str(16, '0123456789'), 'expiry_year' => (string) Random::int(2023, 2045), 'expiry_month' => str_pad((string) Random::int(1, 12), 2, '0', STR_PAD_LEFT), 'cardholder' => Random::str(1, 26, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ \'-'), 'csc' => Random::str(3, 4, '0123456789'), ], 'holder' => [ 'gateway_id' => Random::str(1, 256), ], 'client_ip' => Internet::localIpv4(), 'confirmation' => [ 'type' => ConfirmationType::REDIRECT, 'enforce' => Random::bool(), 'return_url' => Random::str(1,2048), 'locale' => Random::value(['ru_RU', 'en_US']), ] ] ]]; // $metadata = new Metadata(); // $metadata->test = 'test'; // $result = [ // [ // [ // 'payment_data' => [ // 'amount' => new MonetaryAmount(Random::int(1, 1000000)), // ], // 'cart' => [ // [ // 'description' => Random::str(5, 128), // 'price' => new MonetaryAmount(Random::int(1, 1000000)), // 'discount_price' => null, // 'quantity' => Random::int(1, 10), // ] // ], // 'delivery_method_data' => null, // 'expires_at' => new DateTime('+ 1 hour'), // 'locale' => null, // 'description' => null, // 'metadata' => null, // ], // ], // [ // [ // 'payment_data' => [ // 'amount' => new MonetaryAmount(Random::int(1, 1000000)), // 'save_payment_method' => true, // 'description' => Random::str(5, 128), // 'client_ip' => Internet::localIpv4(), // ], // 'cart' => [ // new LineItem([ // 'description' => Random::str(5, 128), // 'price' => new MonetaryAmount(Random::int(1, 1000000)), // 'discount_price' => null, // 'quantity' => Random::int(1, 10), // ]), // ], // 'delivery_method_data' => ['type' => 'self'], // 'expires_at' => new DateTime('+ 1 day'), // 'locale' => Random::value(['ru_RU', 'en_US', null]), // 'description' => '', // 'metadata' => [Random::str(1)], // ], // ], // ]; // for ($i = 0; $i < 10; $i++) { // $even = ($i % 3); // $request = [ // 'payment_data' => new PaymentData([ // 'amount' => new MonetaryAmount(Random::int(1, 1000000)), // 'save_payment_method' => true, // 'description' => Random::str(5, 128), // 'client_ip' => Internet::localIpv4(), // ]), // 'cart' => [ // $even ? [ // 'description' => Random::str(5, 128), // 'price' => new MonetaryAmount(Random::int(1, 1000000)), // 'discount_price' => null, // 'quantity' => Random::int(1, 10), // ] : new LineItem([ // 'description' => Random::str(5, 128), // 'price' => new MonetaryAmount(Random::int(1, 1000000)), // 'discount_price' => null, // 'quantity' => Random::int(1, 10), // ]), // ], // 'delivery_method_data' => $even ? ['type' => 'self'] : null, // 'expires_at' => $even ? new DateTime('+ 1 month') : '2024-10-18T10:51:18.139Z', // 'locale' => Random::value(['ru_RU', 'en_US', null]), // 'description' => Random::str(5, 128), // 'metadata' => $even ? $metadata : ['test' => 'test'], // ]; // $result[] = [$request]; // } // // return $result; } }