package
1.0.17
Repository: https://github.com/parinyapt/golang_utils.git
Documentation: pkg.go.dev

# README

PTGU Google

Import

import (
	PTGUgoogle "github.com/parinyapt/golang_utils/google/v1"
)

Example

Generate Access Token

google := PTGUgoogle.NewGoogle(&PTGUgoogle.GoogleConfig{
  GenerateAccessToken: PTGUgoogle.GoogleConfigGenerateAccessToken{
    ClientEmail:  "[email protected]",
    PrivateKeyID: "xxxxxx",
    PrivateKey:   "-----BEGIN PRIVATE KEY-----\nXXXXXXXXXXXXXXXXXXXXXXX\n-----END PRIVATE KEY-----\n",
    Scopes: []string{
      "https://www.googleapis.com/xxxxx",
    },
  },
})
token, err := google.GenerateGoolgeAccessTokenWithoutOAuth(context.Background())
if err != nil {
  panic(err)
}
fmt.Println(token)

Documentations:

Verify Google Play Product Purchase

  • Don't forget to add scope https://www.googleapis.com/auth/androidpublisher in Scopes when generate access token
googleToken := PTGUgoogle.NewGoogle(&PTGUgoogle.GoogleConfig{
  AccessToken: token,
})
response, err := googleToken.ValidateGoogleProductPurchase(PTGUgoogle.GooglePurchaseValidateParam{
  PackageName:   "com.xxx.xxx",
  ProductID:     "prinpt_1",
  PurchaseToken: "XXXXXX",
})
if err != nil {
  panic(err)
}
fmt.Println(response.OrderID)
fmt.Println(response.PurchaseTimeMillis)

Verify Google Play Subscription Purchase

  • Don't forget to add scope https://www.googleapis.com/auth/androidpublisher in Scopes when generate access token
googleToken := PTGUgoogle.NewGoogle(&PTGUgoogle.GoogleConfig{
  AccessToken: token,
})
response, err := googleToken.ValidateGoogleSubscriptionsPurchase(PTGUgoogle.GoogleSubscriptionsPurchaseValidateParam{
  PackageName:   "com.xxx.xxx",
  PurchaseToken: "XXXXXX",
})
if err != nil {
  panic(err)
}
fmt.Println(response.subscriptionState)
fmt.Println(response.latestOrderId)

if response.LinkedPurchaseToken != nil {
  fmt.Println(PTGUdata.PointerToStringValue(response.LinkedPurchaseToken))
}else{
  fmt.Println("Response LinkedPurchaseToken is nil")
}

Documentations:

Reference:

# Functions

No description provided by the author

# Constants

No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author