Method: externaltransactions.refundexternaltransaction
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Zwrot środków lub częściowy zwrot środków za istniejące transakcje zewnętrzne.
Żądanie HTTP
POST https://androidpublisher.googleapis.com/androidpublisher/v3/{name=applications/*/externalTransactions/*}:refund
Adres URL używa składni transkodowania gRPC.
Parametry ścieżki
Parametry |
name |
string
Wymagane. Nazwa transakcji zewnętrznej, która zostanie zwrócona. Format: applications/{packageName}/externalTransactions/{externalTransaction}
|
Treść żądania
Treść żądania zawiera dane o następującej strukturze:
Zapis 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 .
} |
Pola |
refundTime |
string (Timestamp format)
Wymagane. Czas zwrotu środków za transakcję. Używa standardu RFC 3339, w którym wygenerowany wynik jest zawsze znormalizowany według normy Z i zawiera 0, 3, 6 lub 9 cyfr ułamkowych. Dopuszczalne są też przesunięcia inne niż „Z”. Przykłady: "2014-10-02T15:01:23Z" , "2014-10-02T15:01:23.045123456Z" lub "2014-10-02T15:01:23+05:30" .
|
Pole unii refund_type . Wymagane. Typ zwrotu środków z transakcji zewnętrznej. refund_type może być tylko jednym z tych elementów: |
partialRefund |
object (PartialRefund )
częściowy zwrot środków,
|
fullRefund |
object (FullRefund )
Zwrot pełnej kwoty.
|
Treść odpowiedzi
W przypadku powodzenia treść odpowiedzi obejmuje wystąpienie elementu ExternalTransaction
.
Przykład
Oto przykładowa prośba:
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" \
}'
Oto przykładowa odpowiedź:
{
"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"
}
}
}
Zakresy autoryzacji
Wymaga następującego zakresu OAuth:
https://www.googleapis.com/auth/androidpublisher
PartialRefund
częściowy zwrot środków za transakcję;
Zapis JSON |
{
"refundId": string,
"refundPreTaxAmount": {
object (Price )
}
} |
Pola |
refundId |
string
Wymagane. Unikalny identyfikator, który odróżnia ten częściowy zwrot środków. Jeśli zwrot środków się powiedzie, kolejne zwroty środków o tym samym identyfikatorze nie będą możliwe. Musi być niepowtarzalny w przypadku zwrotów środków za jedną transakcję.
|
refundPreTaxAmount |
object (Price )
Wymagane. kwota częściowego zwrotu środków przed opodatkowaniem; Powinna być mniejsza niż pozostała kwota transakcji przed opodatkowaniem.
|
FullRefund
Ten typ nie ma pól.
pełny zwrot pozostałej kwoty transakcji;
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-26 UTC.
[null,null,["Ostatnia aktualizacja: 2025-07-26 UTC."],[[["\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."]]