<?php
 declare(strict_types=1); namespace Shopify\Rest\Admin2024_01; use Shopify\Auth\Session; use Shopify\Rest\Base; class Payment extends Base { public static string $API_VERSION = "2024-01"; protected static array $HAS_ONE = [ "transaction" => Transaction::class, "checkout" => Checkout::class ]; protected static array $HAS_MANY = []; protected static array $PATHS = [ ["http_method" => "get", "operation" => "count", "ids" => ["checkout_id"], "path" => "checkouts/<checkout_id>/payments/count.json"], ["http_method" => "get", "operation" => "get", "ids" => ["checkout_id"], "path" => "checkouts/<checkout_id>/payments.json"], ["http_method" => "get", "operation" => "get", "ids" => ["checkout_id", "id"], "path" => "checkouts/<checkout_id>/payments/<id>.json"], ["http_method" => "post", "operation" => "post", "ids" => ["checkout_id"], "path" => "checkouts/<checkout_id>/payments.json"] ]; public static function find( Session $session, $id, array $urlIds = [], array $params = [] ): ?Payment { $result = parent::baseFind( $session, array_merge(["id" => $id], $urlIds), $params, ); return !empty($result) ? $result[0] : null; } public static function all( Session $session, array $urlIds = [], array $params = [] ): array { return parent::baseFind( $session, $urlIds, $params, ); } public static function count( Session $session, array $urlIds = [], array $params = [] ): ?array { $response = parent::request( "get", "count", $session, $urlIds, $params, [], ); return $response->getDecodedBody(); } public function __get(string $name): mixed { if ($name == "token") { return $this->checkout ? $this->checkout->token : null; } return parent::__get($name); } public function __set( string $name, $value ): void { if ($name == "token") { $this->checkout = $this->checkout ?: new Checkout($this->session); $this->checkout->token = $value; return; } parent::__set($name, $value); } } 