Method: externaltransactions.refundexternaltransaction
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
HTTP 请求
POST https://androidpublisher.googleapis.com/androidpublisher/v3/{name=applications/*/externalTransactions/*}:refund
网址采用 gRPC 转码语法。
路径参数
参数 |
name |
string
必需。将要进行退款的外部交易的名称。格式:applications/{packageName}/externalTransactions/{externalTransaction}
|
请求正文
请求正文中包含结构如下的数据:
JSON 表示法 |
{
"refundTime": string,
// Union field refund_type can be only one of the following:
"partialRefund": {
object (PartialRefund )
},
"fullRefund": {
object (FullRefund )
}
// End of list of possible types for union field refund_type .
} |
字段 |
refundTime |
string (Timestamp format)
必需。交易退款发生的时间。 采用 RFC 3339 标准,生成的输出将始终在末尾带 Z,并使用 0、3、6 或 9 个小数位。不带“Z”的偏差时间也是可以接受的。示例:"2014-10-02T15:01:23Z" 、"2014-10-02T15:01:23.045123456Z" 或 "2014-10-02T15:01:23+05:30" 。
|
联合字段 refund_type 。必需。外部交易退款的类型。refund_type 只能是下列其中一项: |
partialRefund |
object (PartialRefund )
部分退款。
|
fullRefund |
object (FullRefund )
全额退款。
|
响应正文
如果成功,则响应正文包含一个 ExternalTransaction
实例。
示例
以下是一个示例请求:
curl \
-X POST \
'https://androidpublisher.googleapis.com/androidpublisher/v3/applications/com.example.app/externalTransactions/foo:refund' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
-H 'Content-Type: application/json' \
-d '{ \
"partialRefund": { \
"refundId": "my_refund_id", \
"refundPreTaxAmount": { \
"currency": "USD", \
"priceMicros": "10120000" \
} \
}, \
"refundTime": "2023-10-20T16:43:32.852Z" \
}'
以下是示例响应:
{
"externalTransactionId": "1234567890123456789012345678901234567890123456789012345678901234",
"originalPreTaxAmount": {
"currency": "USD",
"priceMicros": "1990000"
},
"originalTaxAmount": {
"currency": "USD",
"priceMicros": "11400000"
},
"packageName": "com.example.app",
"transactionState": "TRANSACTION_CANCELED",
"transactionTime": "2023-04-01T12:00:00Z",
"userTaxAddress": {
"regionCode": "US"
},
"createTime": "2023-04-01T11:55:00Z",
"currentPreTaxAmount": {
"currency": "USD",
"priceMicros": "0"
},
"currentTaxAmount": {
"currency": "USD",
"priceMicros": "0"
},
"testPurchase": {},
"recurringTransaction": {
"initialExternalTransactionId": "9876543210987654321098765432109876543210987654321098765432109876",
"externalSubscription": {
"subscriptionType": "RECURRING"
}
}
}
授权范围
需要以下 OAuth 范围:
https://www.googleapis.com/auth/androidpublisher
PartialRefund
JSON 表示法 |
{
"refundId": string,
"refundPreTaxAmount": {
object (Price )
}
} |
字段 |
refundId |
string
必需。区分此部分退款的唯一 ID。如果退款成功,后续具有相同 ID 的退款将会失败。对于单笔交易的退款,此 ID 必须具有唯一性。
|
refundPreTaxAmount |
object (Price )
必需。部分退款的税前金额。应低于交易的剩余税前金额。
|
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eRefunds or partially refunds an existing external transaction using an HTTP POST request.\u003c/p\u003e\n"],["\u003cp\u003eRequires providing the external transaction name as a path parameter and refund details in the request body.\u003c/p\u003e\n"],["\u003cp\u003eThe request body specifies the refund time and either a partial or full refund type.\u003c/p\u003e\n"],["\u003cp\u003eSuccessful requests will receive a response containing the updated external transaction details.\u003c/p\u003e\n"],["\u003cp\u003eAuthorization requires the \u003ccode\u003ehttps://www.googleapis.com/auth/androidpublisher\u003c/code\u003e OAuth scope.\u003c/p\u003e\n"]]],["This document details how to refund an external transaction via a POST request to the specified URL. The request requires a `name` path parameter, indicating the transaction to be refunded. The request body includes a `refundTime` timestamp and either a `partialRefund` object with a unique `refundId` and `refundPreTaxAmount`, or a `fullRefund` object. Successful requests return an `ExternalTransaction` instance and needs the `androidpublisher` OAuth scope.\n"],null,["# Method: externaltransactions.refundexternaltransaction\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Request body](#body.request_body)\n - [JSON representation](#body.request_body.SCHEMA_REPRESENTATION)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n- [PartialRefund](#PartialRefund)\n - [JSON representation](#PartialRefund.SCHEMA_REPRESENTATION)\n- [FullRefund](#FullRefund)\n- [Try it!](#try-it)\n\nRefunds or partially refunds an existing external transaction.\n\n### HTTP request\n\n`POST https://androidpublisher.googleapis.com/androidpublisher/v3/{name=applications/*/externalTransactions/*}:refund`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `name` | `string` Required. The name of the external transaction that will be refunded. Format: applications/{packageName}/externalTransactions/{externalTransaction} |\n\n### Request body\n\nThe request body contains data with the following structure:\n\n| JSON representation |\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"refundTime\": string, // Union field `refund_type` can be only one of the following: \"partialRefund\": { object (/android-publisher/api-ref/rest/v3/externaltransactions/refundexternaltransaction#PartialRefund) }, \"fullRefund\": { object (/android-publisher/api-ref/rest/v3/externaltransactions/refundexternaltransaction#FullRefund) } // End of list of possible types for union field `refund_type`. } ``` |\n\n| Fields ||\n|-----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `refundTime` | `string (`[Timestamp](https://protobuf.dev/reference/protobuf/google.protobuf/#timestamp)` format)` Required. The time that the transaction was refunded. Uses RFC 3339, where generated output will always be Z-normalized and uses 0, 3, 6 or 9 fractional digits. Offsets other than \"Z\" are also accepted. Examples: `\"2014-10-02T15:01:23Z\"`, `\"2014-10-02T15:01:23.045123456Z\"` or `\"2014-10-02T15:01:23+05:30\"`. |\n| Union field `refund_type`. Required. Type of external transaction refund. `refund_type` can be only one of the following: ||\n| `partialRefund` | `object (`[PartialRefund](/android-publisher/api-ref/rest/v3/externaltransactions/refundexternaltransaction#PartialRefund)`)` A partial refund. |\n| `fullRefund` | `object (`[FullRefund](/android-publisher/api-ref/rest/v3/externaltransactions/refundexternaltransaction#FullRefund)`)` A full-amount refund. |\n\n### Response body\n\nIf successful, the response body contains an instance of [ExternalTransaction](/android-publisher/api-ref/rest/v3/externaltransactions#ExternalTransaction).\n\n### Sample\n\nThe following is a sample request: \n\n```json\ncurl \\\n -X POST \\\n 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications/com.example.app/externalTransactions/foo:refund' \\\n -H 'Accept: application/json' \\\n -H 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \\\n -H 'Content-Type: application/json' \\\n -d '{ \\\n \"partialRefund\": { \\\n \"refundId\": \"my_refund_id\", \\\n \"refundPreTaxAmount\": { \\\n \"currency\": \"USD\", \\\n \"priceMicros\": \"10120000\" \\\n } \\\n }, \\\n \"refundTime\": \"2023-10-20T16:43:32.852Z\" \\\n }'\n```\n\nThe following is a sample response: \n\n```json\n{\n \"externalTransactionId\": \"1234567890123456789012345678901234567890123456789012345678901234\",\n \"originalPreTaxAmount\": {\n \"currency\": \"USD\",\n \"priceMicros\": \"1990000\"\n },\n \"originalTaxAmount\": {\n \"currency\": \"USD\",\n \"priceMicros\": \"11400000\"\n },\n \"packageName\": \"com.example.app\",\n \"transactionState\": \"TRANSACTION_CANCELED\",\n \"transactionTime\": \"2023-04-01T12:00:00Z\",\n \"userTaxAddress\": {\n \"regionCode\": \"US\"\n },\n \"createTime\": \"2023-04-01T11:55:00Z\",\n \"currentPreTaxAmount\": {\n \"currency\": \"USD\",\n \"priceMicros\": \"0\"\n },\n \"currentTaxAmount\": {\n \"currency\": \"USD\",\n \"priceMicros\": \"0\"\n },\n \"testPurchase\": {},\n \"recurringTransaction\": {\n \"initialExternalTransactionId\": \"9876543210987654321098765432109876543210987654321098765432109876\",\n \"externalSubscription\": {\n \"subscriptionType\": \"RECURRING\"\n }\n }\n}\n```\n\n### Authorization scopes\n\nRequires the following OAuth scope:\n\n- `https://www.googleapis.com/auth/androidpublisher`\n\nPartialRefund\n-------------\n\nA partial refund of a transaction.\n\n| JSON representation |\n|-------------------------------------------------------------------------------------------------------------|\n| ``` { \"refundId\": string, \"refundPreTaxAmount\": { object (/android-publisher/api-ref/rest/v3/Price) } } ``` |\n\n| Fields ||\n|----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `refundId` | `string` Required. A unique id distinguishing this partial refund. If the refund is successful, subsequent refunds with the same id will fail. Must be unique across refunds for one individual transaction. |\n| `refundPreTaxAmount` | `object (`[Price](/android-publisher/api-ref/rest/v3/Price)`)` Required. The pre-tax amount of the partial refund. Should be less than the remaining pre-tax amount of the transaction. |\n\nFullRefund\n----------\n\nThis type has no fields.\nA full refund of the remaining amount of a transaction."]]