广场连接 API |通过 API 生成个人访问令牌
Square Connect API | Generate Personal Access Token via API
我正在使用我的 Square 仪表板中的个人访问令牌来使用 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()
);
P.S:Square API 文档是有史以来最垃圾的文档!!!
个人访问令牌永不过期。如果您将 OAuth, then the access tokens do expire every 30 days, and you would use the ObtainToken 与 refresh_token
一起使用以生成新的访问令牌。
此外,请随时将您对我们文档的反馈发送给 Square 的 Developer Support 团队,以便我们改进它。
我正在使用我的 Square 仪表板中的个人访问令牌来使用 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()
);
P.S:Square API 文档是有史以来最垃圾的文档!!!
个人访问令牌永不过期。如果您将 OAuth, then the access tokens do expire every 30 days, and you would use the ObtainToken 与 refresh_token
一起使用以生成新的访问令牌。
此外,请随时将您对我们文档的反馈发送给 Square 的 Developer Support 团队,以便我们改进它。