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)

必需。部分退款的税前金额。应低于交易的剩余税前金额。

FullRefund

此类型没有字段。

全额退还交易的剩余金额。