Update a product
curl --request PATCH \
--url https://merchant-api-prod.anyway.sh/v1/product/{id} \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"name": "<string>",
"description": "<string>"
}
'import requests
url = "https://merchant-api-prod.anyway.sh/v1/product/{id}"
payload = {
"name": "<string>",
"description": "<string>"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>', description: '<string>'})
};
fetch('https://merchant-api-prod.anyway.sh/v1/product/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://merchant-api-prod.anyway.sh/v1/product/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'description' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://merchant-api-prod.anyway.sh/v1/product/{id}"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"description\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://merchant-api-prod.anyway.sh/v1/product/{id}")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"description\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://merchant-api-prod.anyway.sh/v1/product/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"description\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"createdAt": "<string>",
"description": "<string>",
"id": "<string>",
"name": "<string>",
"orgId": "<string>",
"paymentLinks": [
{
"amount": 123,
"createdAt": "<string>",
"currency": "<string>",
"flexibleAmount": true,
"isActive": true,
"name": "<string>",
"paymentLinkUrl": "<string>",
"pricingId": "<string>",
"pricingType": "<string>",
"provider": "<string>",
"title": "<string>",
"description": "<string>",
"minAmount": 123,
"maxAmount": 123,
"successUrl": "<string>"
}
],
"productId": "<string>",
"status": "<string>",
"updatedAt": "<string>"
},
"error": {
"code": "<string>",
"message": "<string>"
},
"message": "<string>",
"success": true
}{
"data": "<unknown>",
"error": {
"code": "<string>",
"message": "<string>"
},
"message": "<string>",
"success": true
}{
"data": "<unknown>",
"error": {
"code": "<string>",
"message": "<string>"
},
"message": "<string>",
"success": true
}{
"data": "<unknown>",
"error": {
"code": "<string>",
"message": "<string>"
},
"message": "<string>",
"success": true
}{
"data": "<unknown>",
"error": {
"code": "<string>",
"message": "<string>"
},
"message": "<string>",
"success": true
}{
"data": "<unknown>",
"error": {
"code": "<string>",
"message": "<string>"
},
"message": "<string>",
"success": true
}Merchant API 端点
更新产品
修改产品的名称或描述。
PATCH
/
v1
/
product
/
{id}
Update a product
curl --request PATCH \
--url https://merchant-api-prod.anyway.sh/v1/product/{id} \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"name": "<string>",
"description": "<string>"
}
'import requests
url = "https://merchant-api-prod.anyway.sh/v1/product/{id}"
payload = {
"name": "<string>",
"description": "<string>"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>', description: '<string>'})
};
fetch('https://merchant-api-prod.anyway.sh/v1/product/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://merchant-api-prod.anyway.sh/v1/product/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'description' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://merchant-api-prod.anyway.sh/v1/product/{id}"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"description\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://merchant-api-prod.anyway.sh/v1/product/{id}")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"description\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://merchant-api-prod.anyway.sh/v1/product/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"description\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"createdAt": "<string>",
"description": "<string>",
"id": "<string>",
"name": "<string>",
"orgId": "<string>",
"paymentLinks": [
{
"amount": 123,
"createdAt": "<string>",
"currency": "<string>",
"flexibleAmount": true,
"isActive": true,
"name": "<string>",
"paymentLinkUrl": "<string>",
"pricingId": "<string>",
"pricingType": "<string>",
"provider": "<string>",
"title": "<string>",
"description": "<string>",
"minAmount": 123,
"maxAmount": 123,
"successUrl": "<string>"
}
],
"productId": "<string>",
"status": "<string>",
"updatedAt": "<string>"
},
"error": {
"code": "<string>",
"message": "<string>"
},
"message": "<string>",
"success": true
}{
"data": "<unknown>",
"error": {
"code": "<string>",
"message": "<string>"
},
"message": "<string>",
"success": true
}{
"data": "<unknown>",
"error": {
"code": "<string>",
"message": "<string>"
},
"message": "<string>",
"success": true
}{
"data": "<unknown>",
"error": {
"code": "<string>",
"message": "<string>"
},
"message": "<string>",
"success": true
}{
"data": "<unknown>",
"error": {
"code": "<string>",
"message": "<string>"
},
"message": "<string>",
"success": true
}{
"data": "<unknown>",
"error": {
"code": "<string>",
"message": "<string>"
},
"message": "<string>",
"success": true
}请使用属于该产品所在组织、且为全部权限或勾选了
products:products:write 权限(控制台中“可创建和修改”下的产品)的 API 密钥进行认证。只有 Owner 和 Admin 角色可以授予该权限。
id是你组织内的产品 ID,无论该产品是通过 API 还是在控制台创建的。- 请求体包含
name和description,均为可选。只有你传入的字段会被修改。 - 响应结构与读取产品相同。
- 未知字段会被拒绝,返回
400。该接口没有Idempotency-Key。
银行卡结账页显示的是产品的名称和描述,因此修改后,所有已有支付链接的结账页会立即显示新内容。支付链接自己的标题显示在付款成功页上;如需修改,请使用更新支付链接。
| 状态码 | 错误码 | 含义 |
|---|---|---|
400 | 校验失败:未知字段、name 为空、name 超过 255 个字符,或 description 超过 2000。 | |
401 | API 密钥缺失或无效。 | |
403 | INSUFFICIENT_SCOPE | 密钥缺少 products:products:write。 |
404 | 产品不存在,或属于其他组织。 | |
413 | PAYLOAD_TOO_LARGE | 请求体超过 64 KiB。 |
授权
Merchant API key (format: ak_BASE64)
路径参数
Product ID
请求体
application/json
Fields to change