Method: externaltransactions.createexternaltransaction

  • Creates a new external transaction using an HTTP POST request to a specified URL.

  • Requires providing path and query parameters, including parent to specify the app package and a unique externalTransactionId.

  • The request body needs to contain an ExternalTransaction object, while a successful response returns a newly created ExternalTransaction.

  • Authorization is needed using the https://www.googleapis.com/auth/androidpublisher OAuth scope.

Creates a new external transaction.

HTTP request

POST https://androidpublisher.googleapis.com/androidpublisher/v3/{parent=applications/*}/externalTransactions

The URL uses gRPC Transcoding syntax.

Path parameters

Parameters
parent

string

Required. The parent resource where this external transaction will be created. Format: applications/{packageName}

Query parameters

Parameters
externalTransactionId

string

Required. The id to use for the external transaction. Must be unique across all other transactions for the app. This value should be 1-63 characters and valid characters are /a-zA-Z0-9_-/. Do not use this field to store any Personally Identifiable Information (PII) such as emails. Attempting to store PII in this field may result in requests being blocked.

Request body

The request body contains an instance of ExternalTransaction.

Response body

If successful, the response body contains a newly created instance of ExternalTransaction.

Sample

The following is a sample request:

curl \
  -X POST \
  'https://androidpublisher.googleapis.com/androidpublisher/v3/applications/com.example.app/externalTransactions?externalTransactionId=exampleExternalTransactionId' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
  -H 'Content-Type: application/json' \
  -d '{ \
    "originalPreTaxAmount": { \
      "currency": "USD", \
      "priceMicros": "1000000" \
    }, \
    "originalTaxAmount": { \
      "currency": "USD", \
      "priceMicros": "100000" \
    }, \
    "transactionTime": "2023-05-05T12:00:00Z", \
    "oneTimeTransaction": { \
      "externalTransactionToken": "token-123" \
    }, \
    "userTaxAddress": { \
      "regionCode": "US" \
    } \
  }'

The following is a sample response:

{
  "createTime": "2023-04-20T14:23:18.121Z",
  "currentPreTaxAmount": {
    "currency": "USD",
    "priceMicros": "12000000"
  },
  "currentTaxAmount": {
    "currency": "USD",
    "priceMicros": "1200000"
  },
  "externalTransactionId": "ext-trans-id-1234",
  "oneTimeTransaction": {
    "externalTransactionToken": "one-time-token-abc"
  },
  "originalPreTaxAmount": {
    "currency": "USD",
    "priceMicros": "15000000"
  },
  "originalTaxAmount": {
    "currency": "USD",
    "priceMicros": "1500000"
  },
  "packageName": "com.example.app",
  "recurringTransaction": {
    "externalSubscription": {
      "subscriptionType": "RECURRING"
    },
    "externalTransactionToken": "recurring-token-xyz",
    "initialExternalTransactionId": "ext-trans-id-5678",
    "otherRecurringProduct": {}
  },
  "testPurchase": {},
  "transactionProgramCode": 11,
  "transactionState": "TRANSACTION_REPORTED",
  "transactionTime": "2023-04-20T14:20:00.000Z",
  "userTaxAddress": {
    "regionCode": "US"
  }
}

Authorization scopes

Requires the following OAuth scope:

  • https://www.googleapis.com/auth/androidpublisher