Documentation ¶
Index ¶
- Constants
- Variables
- func ValidateReceiptGoogle(ctx context.Context, httpc *http.Client, clientEmail string, privateKey string, ...) (*ValidateReceiptGoogleResponse, *ReceiptGoogle, []byte, error)
- func ValidateReceiptHuawei(ctx context.Context, httpc *http.Client, ...) (*ValidateReceiptHuaweiResponse, *InAppPurchaseDataHuawei, []byte, error)
- type InAppPurchaseDataHuawei
- type ReceiptGoogle
- type ValidateReceiptAppleResponse
- type ValidateReceiptAppleResponseReceipt
- type ValidateReceiptAppleResponseReceiptInApp
- type ValidateReceiptGoogleResponse
- type ValidateReceiptHuaweiResponse
- type ValidationError
Constants ¶
View Source
const ( AppleReceiptValidationUrlSandbox = "https://sandbox.itunes.apple.com/verifyReceipt" AppleReceiptValidationUrlProduction = "https://buy.itunes.apple.com/verifyReceipt" )
View Source
const ( AppleReceiptIsValid = 0 HuaweiReceiptIsValid = 0 HuaweiSandboxPurchaseType = 0 AppleReceiptIsFromTestSandbox = 21007 // Receipt from test env was sent to prod. Should retry against the sandbox env. )
View Source
const ( AppleSandboxEnvironment = "Sandbox" AppleProductionEnvironment = "Production" )
Variables ¶
View Source
var ( ErrNon200ServiceApple = errors.New("non-200 response from Apple service") ErrNon200ServiceGoogle = errors.New("non-200 response from Google service") ErrNon200ServiceHuawei = errors.New("non-200 response from Huawei service") ErrInvalidSignatureHuawei = errors.New("inAppPurchaseData invalid signature") )
Functions ¶
func ValidateReceiptGoogle ¶
func ValidateReceiptGoogle(ctx context.Context, httpc *http.Client, clientEmail string, privateKey string, receipt string) (*ValidateReceiptGoogleResponse, *ReceiptGoogle, []byte, error)
Validate an IAP receipt with the Android Publisher API and the Google credentials.
func ValidateReceiptHuawei ¶
func ValidateReceiptHuawei(ctx context.Context, httpc *http.Client, pubKey, clientID, clientSecret, purchaseData, signature string) (*ValidateReceiptHuaweiResponse, *InAppPurchaseDataHuawei, []byte, error)
Validate an IAP receipt with the Huawei API
Types ¶
type InAppPurchaseDataHuawei ¶
type InAppPurchaseDataHuawei struct { ApplicationID string `json:"applicationId"` AutoRenewing bool `json:"autoRenewing"` OrderId string `json:"orderId"` Kind int `json:"kind"` PackageName string `json:"packageName"` ProductId string `json:"productId"` PurchaseTime int64 `json:"purchaseTime"` PurchaseToken string `json:"purchaseToken"` AccountFlag int `json:"accountFlag"` PurchaseType int `json:"purchaseType"` // Omitted field in production, value set to 0 in sandbox env. }
type ReceiptGoogle ¶
type ValidateReceiptAppleResponse ¶
type ValidateReceiptAppleResponse struct { IsRetryable bool `json:"is-retryable"` // If true, request must be retried later. Status int `json:"status"` Receipt *ValidateReceiptAppleResponseReceipt `json:"receipt"` Environment string `json:"environment"` // possible values: 'Sandbox', 'Production'. }
func ValidateReceiptApple ¶
func ValidateReceiptApple(ctx context.Context, httpc *http.Client, receipt, password string) (*ValidateReceiptAppleResponse, []byte, error)
Validate an IAP receipt with Apple. This function will check against both the production and sandbox Apple URLs.
func ValidateReceiptAppleWithUrl ¶
func ValidateReceiptAppleWithUrl(ctx context.Context, httpc *http.Client, url, receipt, password string) (*ValidateReceiptAppleResponse, []byte, error)
Validate an IAP receipt with Apple against the specified URL.
type ValidateReceiptAppleResponseReceipt ¶
type ValidateReceiptAppleResponseReceipt struct { OriginalPurchaseDateMs string `json:"original_purchase_date_ms"` InApp []*ValidateReceiptAppleResponseReceiptInApp `json:"in_app"` }
type ValidateReceiptAppleResponseReceiptInApp ¶
type ValidateReceiptAppleResponseReceiptInApp struct { OriginalTransactionID string `json:"original_transaction_id"` TransactionId string `json:"transaction_id"` // Different than OriginalTransactionId if the user Auto-renews subscription or restores a purchase. ProductID string `json:"product_id"` ExpiresDateMs string `json:"expires_date_ms"` // Subscription expiration or renewal date. PurchaseDateMs string `json:"purchase_date_ms"` }
type ValidateReceiptGoogleResponse ¶
type ValidateReceiptGoogleResponse struct { AcknowledgementState int `json:"acknowledgementState"` ConsumptionState int `json:"consumptionState"` DeveloperPayload string `json:"developerPayload"` Kind string `json:"kind"` OrderId string `json:"orderId"` PurchaseState int `json:"purchaseState"` PurchaseTimeMillis string `json:"purchaseTimeMillis"` PurchaseType int `json:"purchaseType"` RegionCode string `json:"regionCode"` }
type ValidateReceiptHuaweiResponse ¶
type ValidateReceiptHuaweiResponse struct { ResponseCode string `json:"responseCode"` ResponseMessage string `json:"responseMessage"` PurchaseTokenData InAppPurchaseDataHuawei `json:"purchaseTokenData"` DataSignature string `json:"dataSignature"` }
type ValidationError ¶
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
func (*ValidationError) Unwrap ¶
func (e *ValidationError) Unwrap() error
Click to show internal directories.
Click to hide internal directories.