mywaygames/api-client

Myway Games 商店 API 的 PHP API 客户端

1.0 2022-02-16 15:55 UTC

This package is auto-updated.

Last update: 2024-09-16 21:22:52 UTC


README

MywayGames 商店 API 客户端

MywayGames API 客户端是一个 PHP 库,帮助您将 MywayGames 账户集成到您的电子商务系统中,允许您下订单、查询余额、列出产品、自动同步价格。

更多信息请查看 MywayGames API 文档

安装

使用 composer

composer require mywaygames/api-client

如果您收到错误 无法找到 mywaygames/api-client 包的版本,请升级到 composer 2

从 github

git clone https://github.com/mywaygames/api-client.git
cd api-client
composer install

使用方法

在包含 vendor/autoload.php 之后,您可以像这样初始化客户端:

$apiClient = new MywayGames\ApiClient;

// Set the API base URI, if you are not sure please contact your admin
$apiClient->setBaseUri('https://test.myway-games.com/api/v1/');

获取测试账户(仅在 test.myway-games.com 上可用)

var_dump($apiClient->createTestAccount()->response());

使用您的用户名/密码进行 API 验证

$apiClient->auth(["username" => "YOUR_USERANEM","password" => "YOUR_USERANEM"]);

使用有效的 API 令牌(api_key)进行验证

$apiClient->auth(["api_key" => "YOUR_API_KEY"]);

获取您的账户信息

$apiClient->getUserData()->response()->userdata;

获取您的账户余额

$apiClient->getUserData()->response()->userdata->balance;

获取主要产品列表

$apiClient->products()->response();

获取所有面额列表

$apiClient->denominations('all')->response();

获取主要产品列表

$apiClient->products()->response();

获取特定类别(例如:2)的面额列表

$apiClient->denominations(2)->response();

创建订单

$order_args = [];

// Unuque uuidv4 token that you need to generate to avoid placing duplicate orders.
$order_args['orderToken'] = $apiClient->generateToken();

// The denomination_id you want to buy "which you received by calling ->denominations()"
$order_args['denomination_id'] = 1;

// Optional, default is 1
$order_args['qty'] = 1;

// Required only if the product you want to order is a topup product "i.e has require_playerid = true"
$order_args['args'] = ["playerid" => "111"];

var_dump($apiClient->createOrder($order_args)->response());

检查订单状态“通常订单需要2分钟处理”

$apiClient->orderDetails(21)->response();

依赖项

MywayGames API 客户端使用 guzzlehttp 连接到远程 API