php - Square 连接 API | 通过 API 生成个人访问令牌
问题描述
我正在使用 Square Dashboard 中的个人访问令牌来使用 Square Connect PHP SDK 创建付款。
一切都很好,现在我在文档中的某个地方读到访问令牌每 30 天过期一次。这意味着我网站上的付款将在 30 天后停止工作?因为我找不到任何 API 来获取新的个人访问令牌。而且我不想每 30 天手动插入一次访问令牌。
$api_config = new \SquareConnect\Configuration();
$api_config->setHost($host_url);
$api_config->setAccessToken($access_token);
$api_client = new \SquareConnect\ApiClient($api_config);
$payments_api = new \SquareConnect\Api\PaymentsApi($api_client);
$request_body = array (
"source_id" =>$data['nonce'],
"amount_money" => array (
"amount" => $amount,
"currency" => $currency
),
"shipping_address" => array (
"address_line_1" => $data['address_1'],
"address_line_2" => $data['address_2'],
"postal_code" => $data['postal_code'],
"country" => $data['country'],
"first_name" => $data['first_name'],
"last_name" => $data['last_name'],
),
"customer_id" => $transaction->user_id,
"buyer_email_address" => $data['email'],
"reference_id" => $transaction->id,
"note" => $note,
"idempotency_key" => uniqid()
);
PS:Square API 文档是有史以来最烂的文档!!!
解决方案
推荐阅读
- amazon-web-services - 仅向堆栈中的资源授予 Cloudformation 权限
- java - 如何拆分单词的所有实例,不包括该单词是引号中的子字符串?
- javascript - 不等待带有异步过滤器的 await message.awaitReaction
- amazon-web-services - AWS ECS:VPC 终端节点和 NAT 网关
- import - H2OConnectionError:未连接到集群
- python - 从文件中读取并拆分为单独的列表
- amazon-web-services - 如何将已注册 Google 域的根指向 AWS Elastic Load Balancer?
- c# - 为什么 Microsoft.AspNetCore.Http.StatusCodes 不设计为枚举?
- java - 如何在循环中使用paintComponent?
- python - 保留原始输入作为打印语句的一部分