Ce document liste et décrit les types de notifications en temps réel pour les développeurs que Google Play peut envoyer.
Encodage
Chaque publication effectuée sur un sujet Cloud Pub/Sub ne contient qu'un seul champ de données encodé en base64.
{
  "message": {
    "attributes": {
      "key": "value"
    },
    "data": "eyAidmVyc2lvbiI6IHN0cmluZywgInBhY2thZ2VOYW1lIjogc3RyaW5nLCAiZXZlbnRUaW1lTWlsbGlzIjogbG9uZywgIm9uZVRpbWVQcm9kdWN0Tm90aWZpY2F0aW9uIjogT25lVGltZVByb2R1Y3ROb3RpZmljYXRpb24sICJzdWJzY3JpcHRpb25Ob3RpZmljYXRpb24iOiBTdWJzY3JpcHRpb25Ob3RpZmljYXRpb24sICJ0ZXN0Tm90aWZpY2F0aW9uIjogVGVzdE5vdGlmaWNhdGlvbiB9",
    "messageId": "136969346945"
  },
  "subscription": "projects/myproject/subscriptions/mysubscription"
}
Après avoir décodé le champ de données encodé en base64, DeveloperNotification contient les champs suivants :
{
  "version": string,
  "packageName": string,
  "eventTimeMillis": long,
  "oneTimeProductNotification": OneTimeProductNotification,
  "subscriptionNotification": SubscriptionNotification,
  "voidedPurchaseNotification": VoidedPurchaseNotification,
  "testNotification": TestNotification
}
Ces champs sont décrits dans le tableau suivant.
| Nom de la propriété | Valeur | Description | 
| version | string | Version de cette notification. Dans un premier temps, la version correspond à "1.0". Cette version est différente des autres champs de version. | 
| packageName | string | Nom de package de l'application auquel cette notification se rapporte (par exemple, "com.exemple.XXX"). | 
| eventTimeMillis | long | Horodatage de l'événement (en millisecondes à partir de la date initiale de référence du système d'exploitation). | 
| subscriptionNotification | SubscriptionNotification | Si ce champ est présent, cette notification est liée à un abonnement. Ce champ contient des informations supplémentaires sur l'abonnement. Notez que les champs oneTimeProductNotification, voidedPurchaseNotification et testNotification s'excluent mutuellement. | 
| oneTimeProductNotification | OneTimeProductNotification | Si ce champ est présent, cette notification est associée à un achat ponctuel, et ce champ contient des informations supplémentaires concernant l'achat. Notez que les champs subscriptionNotification, voidedPurchaseNotification et testNotification s'excluent mutuellement. | 
| voidedPurchaseNotification | VoidedPurchaseNotification | Si ce champ est présent, cette notification est liée à un achat annulé, et ce champ contient des informations supplémentaires la concernant. Notez que les champs oneTimeProductNotification, subscriptionNotification et testNotification s'excluent mutuellement. | 
| testNotification | TestNotification | Si ce champ est présent, cette notification est liée à une publication test. Elle n'est envoyée que via la Google Play Console. Notez que les champs oneTimeProductNotification, subscriptionNotification et voidedPurchaseNotification s'excluent mutuellement. | 
SubscriptionNotification
SubscriptionNotification contient les champs suivants :
{
  "version": string,
  "notificationType": int,
  "purchaseToken": string
}
| Nom de la propriété | Valeur | Description | 
| version | string | Version de cette notification. Dans un premier temps, la version correspond à "1.0". Cette version est différente des autres champs de version. | 
| notificationType | int | Le type de notification d'un abonnemment peut avoir les valeurs suivantes :
  | 
  
| purchaseToken | string | Jeton fourni à l'appareil de l'utilisateur lors de la souscription de l'abonnement. | 
Exemple
Voici un exemple de notification concernant un nouvel abonnement :
{
  "version":"1.0",
  "packageName":"com.some.thing",
  "eventTimeMillis":"1503349566168",
  "subscriptionNotification":
  {
    "version":"1.0",
    "notificationType":4,
    "purchaseToken":"PURCHASE_TOKEN"
  }
}
OneTimeProductNotification
OneTimeProductNotification contient les champs suivants :
{
  "version": string,
  "notificationType": int,
  "purchaseToken": string,
  "sku": string
}
| Nom de la propriété | Valeur | Description | 
| version | string | Version de cette notification. Dans un premier temps, la version correspond à "1.0". Cette version est différente des autres champs de version. | 
| notificationType | int | Type de notification. Les valeurs suivantes sont possibles :
  | 
  
| purchaseToken | string | Jeton fourni à l'appareil de l'utilisateur lors de l'achat. | 
| sku | string | ID du produit ponctuel acheté (par exemple, "épée_001") | 
Exemple
Voici un exemple de notification concernant un nouvel achat ponctuel :
{
  "version":"1.0",
  "packageName":"com.some.thing",
  "eventTimeMillis":"1503349566168",
  "oneTimeProductNotification":
  {
    "version":"1.0",
    "notificationType":1,
    "purchaseToken":"PURCHASE_TOKEN",
    "sku":"my.sku"
  }
}
VoidedPurchaseNotification
VoidedPurchaseNotification contient les champs suivants :
Nom de la propriété  | 
    Valeur  | 
    Description  | 
  
  | 
    
  | 
    Jeton associé à l'achat annulé. Ces informations sont fournies au développeur lorsqu'un nouvel achat est effectué.  | 
  
  | 
    
  | 
    ID de commande unique associé à la transaction annulée. Pour les achats uniques, il s'agit du seul ID de commande généré pour l'achat. Pour les abonnements à renouvellement automatique, un nouvel ID de commande est généré pour chaque transaction de renouvellement.  | 
  
  | 
    
  | 
    Le  
  | 
  
  | 
    
  | 
    Le  
 Notez que lorsque la quantité totale restante d'un achat à quantité multiple est remboursée, l'état   | 
  
Exemple
Voici un exemple de notification concernant un nouvel achat annulé :
{
  "version":"1.0",
  "packageName":"com.some.app",
  "eventTimeMillis":"1503349566168",
  "voidedPurchaseNotification":
  {
    "purchaseToken":"PURCHASE_TOKEN",
    "orderId":"GS.0000-0000-0000",
    "productType":1
    "refundType":1
  }
}
Utiliser VoidedPurchaseNotification
Lorsque votre client RTDN reçoit une notification VoidedPurchaseNotification, tenez compte des informations suivantes :
packageName: identifie l'application.eventTimeMillis: vous informe de l'heure à laquelle le changement d'état s'est produit.purchaseToken: jeton fourni à l'appareil de l'utilisateur lors de l'achat du produit.orderId: identifie la commande associée à la transaction annulée.productType: indique si l'achat annulé était un achat via une application ou un abonnement.refundType: spécifie le type de remboursement qui a annulé l'achat.
TestNotification
TestNotification contient les champs suivants :
{
  "version": string
}
| Nom de la propriété | Valeur | Description | 
| version | string | Version de cette notification. Dans un premier temps, la version correspond à "1.0". Cette version est différente des autres champs de version. | 
Exemple
Voici un exemple de notification test :
{
  "version":"1.0",
  "packageName":"com.some.thing",
  "eventTimeMillis":"1503350156918",
  "testNotification":
  {
    "version":"1.0"
  }
}