xvilo / ovpay-api
用PHP编写的OVpay API客户端
v0.6.2
2024-02-24 13:31 UTC
Requires
- php: ^8.1
- lcobucci/jwt: ^4.2 || ^5.0
- php-http/client-common: ^2.6
- php-http/discovery: ^1.14
- symfony/serializer: ^5.4 || ^6.4 || ^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.13
- nyholm/psr7: ^1.5
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.0
- ramsey/uuid: ^4.7
- rector/rector: ^1.0
- symfony/http-client: ^5.4 || ^6.4 || ^7.0
- symfony/property-access: ^5.4 || ^6.4 || ^7.0
- symfony/var-dumper: ^7.0
This package is auto-updated.
Last update: 2024-09-28 11:43:54 UTC
README
非官方的OVPay API包装器。这是一个正在进行中的工作,基于未记录的API。 稳定性无法保证。
目前仅提供未认证的API路由,但将会有更多。
待办事项
- 添加模型
- 添加认证支持,然后
- 添加对
Trips的支持 - 添加对
PaymentCards的支持 - 添加对
Payments的支持
- 添加对
- 添加工作令牌刷新逻辑
- 添加更好的错误响应处理
示例
请求行程,然后请求行程详情
<?php declare(strict_types=1); use Lcobucci\JWT\Encoding\JoseEncoder; use Lcobucci\JWT\Token\Parser; use Xvilo\OVpayApi\Authentication\TokenMethod; use Xvilo\OVpayApi\Client; use Xvilo\OVpayApi\Models\Trip; // Include dependencies include 'vendor/autoload.php'; // Create JWT parser $parser = new Parser(new JoseEncoder()); // Create API client and configure authenticated requests $client = new Client(); $client->Authenticate(new TokenMethod($parser->parse('eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIs...'))); // Get payment cards $card = $client->tokens()->getPaymentCards()[0]; // Get trips for specified Card xtat UUID $trips = $client->trips()->getTrips($card->getExternalTransitAccountToken()); // Get last trip $items = $trips->getItems(); /** @var Trip $trip */ $trip = end($items)->getTrip(); // Get trip details by ID var_dump($client->trips()->getTrip($trip->getExternalBackOfficeToken(), $trip->getId())); // class Xvilo\OVpayApi\Models\Receipt\ReceiptTrip#94 (4) { // private readonly ?array $correctionOptions => // NULL // private readonly Xvilo\OVpayApi\Models\Trip $trip => // class Xvilo\OVpayApi\Models\Trip#131 (13) { // private readonly string $xbot => // string(36) "8126d60f-bded-46d3-9a70-30915a61008b" // private readonly int $id => // int(12345678) // private readonly int $version => // int(1) // private readonly string $transport => // string(4) "RAIL" // private readonly string $status => // string(8) "COMPLETE" // private readonly string $checkInLocation => // string(16) "Utrecht Centraal" // private readonly DateTimeImmutable $checkInTimestamp => // class DateTimeImmutable#79 (3) { // public $date => // string(26) "2022-12-30 08:55:30.000000" // public $timezone_type => // int(1) // public $timezone => // string(6) "+01:00" // } // private readonly ?string $checkOutLocation => // string(5) "Baarn" // private readonly ?DateTimeImmutable $checkOutTimestamp => // class DateTimeImmutable#101 (3) { // public $date => // string(26) "2022-12-30 09:45:30.000000" // public $timezone_type => // int(1) // public $timezone => // string(6) "+01:00" // } // private readonly string $currency => // string(3) "EUR" // private readonly int $fare => // int(540) // private readonly string $organisationName => // string(2) "NS" // private readonly bool $loyaltyOrDiscount => // bool(false) // } // private readonly mixed $correctedFrom => // NULL // private readonly mixed $correctedFromType => // NULL // }