Documentation
¶
Index ¶
- Constants
- Variables
- func GetPurchaseV2Google(ctx context.Context, httpc *http.Client, ...) (*runtime.PurchaseV2GoogleResponse, error)
- func GetSubscriptionV2Google(ctx context.Context, httpc *http.Client, ...) (*runtime.SubscriptionV2GoogleResponse, []byte, error)
- func ValidateAppleJwsSignature(receipt string) error
- func ValidateReceiptGoogle(ctx context.Context, httpc *http.Client, ...) (*ValidateReceiptGoogleResponse, *ReceiptGoogle, []byte, error)
- func ValidateReceiptHuawei(ctx context.Context, httpc *http.Client, ...) (*ValidateReceiptHuaweiResponse, *InAppPurchaseDataHuawei, []byte, error)
- type FacebookInstantPaymentInfo
- type InAppPurchaseDataHuawei
- type ReceiptGoogle
- type ValidateReceiptAppleResponse
- func ValidateLegacyReceiptApple(ctx context.Context, httpc *http.Client, password, receipt string) (*ValidateReceiptAppleResponse, []byte, error)
- func ValidateLegacyReceiptAppleWithUrl(ctx context.Context, httpc *http.Client, url, receipt, password string) (*ValidateReceiptAppleResponse, []byte, error)
- type ValidateReceiptAppleResponseLatestReceiptInfo
- type ValidateReceiptAppleResponsePendingRenewalInfo
- type ValidateReceiptAppleResponseReceipt
- type ValidateReceiptAppleResponseReceiptInApp
- type ValidateReceiptGoogleResponse
- type ValidateReceiptHuaweiResponse
- type ValidateSubscriptionReceiptGoogleResponse
- type ValidationError
Constants ¶
const ( AppleReceiptValidationUrlSandbox = "https://sandbox.itunes.apple.com/verifyReceipt" AppleReceiptValidationUrlProduction = "https://buy.itunes.apple.com/verifyReceipt" )
const ( AppleReceiptIsValid = 0 HuaweiReceiptIsValid = 0 HuaweiSandboxPurchaseType = 0 AppleReceiptIsFromTestSandbox = 21007 // Receipt from test env was sent to prod. Should retry against the sandbox env. )
const ( AppleSandboxEnvironment = "Sandbox" AppleProductionEnvironment = "Production" )
const AppleRootPEM = `` /* 848-byte string literal not displayed */
Variables ¶
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 GetPurchaseV2Google ¶ added in v3.32.0
func GetSubscriptionV2Google ¶ added in v3.32.0
func ValidateAppleJwsSignature ¶ added in v3.38.0
func ValidateReceiptGoogle ¶
func ValidateReceiptGoogle(ctx context.Context, httpc *http.Client, clientEmail, privateKey, 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 FacebookInstantPaymentInfo ¶
type FacebookInstantPaymentInfo struct {
Algorithm string `json:"algorithm"`
AppId string `json:"app_id"`
IsConsumed bool `json:"is_consumed"`
IssuedAt float64 `json:"issued_at"`
PaymentActionType string `json:"payment_action_type"`
PaymentId string `json:"payment_id"`
ProductId string `json:"product_id"`
PurchasePrice struct {
Amount string `json:"amount"`
Currency string `json:"currency"`
} `json:"purchase_price"`
PurchaseTime float64 `json:"purchase_time"`
PurchaseToken string `json:"purchase_token"`
}
func ValidateReceiptFacebookInstant ¶
func ValidateReceiptFacebookInstant(appSecret, signedRequest string) (*FacebookInstantPaymentInfo, string, error)
ValidateReceiptFacebookInstant from: https://developers.facebook.com/docs/games/monetize/in-app-purchases/instant-games#verification
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 ReceiptGoogle struct {
OrderID string `json:"orderId"`
PackageName string `json:"packageName"`
ProductID string `json:"productId"`
PurchaseState int `json:"purchaseState"`
PurchaseTime int64 `json:"purchaseTime"`
PurchaseToken string `json:"purchaseToken"`
}
func ValidateSubscriptionReceiptGoogle ¶
func ValidateSubscriptionReceiptGoogle(ctx context.Context, httpc *http.Client, clientEmail string, privateKey string, receipt string) (*runtime.SubscriptionV2GoogleResponse, *ReceiptGoogle, []byte, error)
Validate an IAP Subscription receipt with the Android Publisher API and the Google credentials.
type ValidateReceiptAppleResponse ¶
type ValidateReceiptAppleResponse struct {
Environment string `json:"environment"` // possible values: 'Sandbox', 'Production'.
IsRetryable bool `json:"is-retryable"` // If true, request must be retried later.
LatestReceipt string `json:"latest_receipt"`
LatestReceiptInfo []ValidateReceiptAppleResponseLatestReceiptInfo `json:"latest_receipt_info"`
PendingRenewalInfo []ValidateReceiptAppleResponsePendingRenewalInfo `json:"pending_renewal_info"` // Only returned for auto-renewable subscriptions.
Receipt *ValidateReceiptAppleResponseReceipt `json:"receipt"`
Status int `json:"status"`
}
func ValidateLegacyReceiptApple ¶ added in v3.38.0
func ValidateLegacyReceiptApple(ctx context.Context, httpc *http.Client, password, receipt string) (*ValidateReceiptAppleResponse, []byte, error)
Validate an IAP receipt with Apple. This function will check against both the production and sandbox Apple URLs.
func ValidateLegacyReceiptAppleWithUrl ¶ added in v3.38.0
func ValidateLegacyReceiptAppleWithUrl(ctx context.Context, httpc *http.Client, url, receipt, password string) (*ValidateReceiptAppleResponse, []byte, error)
Validate an IAP receipt with Apple against the specified URL.
type ValidateReceiptAppleResponseLatestReceiptInfo ¶
type ValidateReceiptAppleResponseLatestReceiptInfo struct {
CancellationDateMs string `json:"cancellation_date_ms"`
CancellationReason string `json:"cancellation_reason"`
ExpiresDateMs string `json:"expires_date_ms"`
InAppOwnershipType string `json:"in_app_ownership_type"`
IsInIntroOfferPeriod string `json:"is_in_intro_offer_period"` // "true" or "false"
IsTrialPeriod string `json:"is_trial_period"`
IsUpgraded string `json:"is_upgraded"`
OfferCodeRefName string `json:"offer_code_ref_name"`
OriginalPurchaseDateMs string `json:"original_purchase_date_ms"`
OriginalTransactionId string `json:"original_transaction_id"` // First subscription transaction
ProductId string `json:"product_id"`
PromotionalOfferId string `json:"promotional_offer_id"`
PurchaseDateMs string `json:"purchase_date_ms"`
Quantity string `json:"quantity"`
SubscriptionGroupIdentifier string `json:"subscription_group_identifier"`
TransactionId string `json:"transaction_id"` // Different from OriginalTransactionId if the user Auto-renews subscription or restores a purchase.
}
type ValidateReceiptAppleResponsePendingRenewalInfo ¶
type ValidateReceiptAppleResponsePendingRenewalInfo struct {
AutoRenewProductId string `json:"auto_renew_product_id"`
AutoRenewStatus string `json:"auto_renew_status"` // 1: subscription will renew at end of current subscription period, 0: the customer has turned off automatic renewal for the subscription.
ExpirationIntent string `json:"expiration_intent"`
GracePeriodExpiresDateMs string `json:"grace_period_expires_date_ms"`
IsInBillingRetryPeriod string `json:"is_in_billing_retry_period"`
OfferCodeRefName string `json:"offer_code_ref_name"`
OriginalTransactionId string `json:"original_transaction_id"`
PriceConsentStatus string `json:"price_consent_status"`
ProductId string `json:"product_id"`
PromotionalOfferId string `json:"promotional_offer_id"`
}
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 from 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"`
CancellationDateMs string `json:"cancellation_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"` //Possible values are: 0. Purchased 1. Canceled 2. Pending
PurchaseTimeMillis string `json:"purchaseTimeMillis"`
PurchaseType int `json:"purchaseType"`
RegionCode string `json:"regionCode"`
}
https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.products#ProductPurchase
type ValidateReceiptHuaweiResponse ¶
type ValidateReceiptHuaweiResponse struct {
ResponseCode string `json:"responseCode"`
ResponseMessage string `json:"responseMessage"`
PurchaseTokenData InAppPurchaseDataHuawei `json:"purchaseTokenData"`
DataSignature string `json:"dataSignature"`
}
type ValidateSubscriptionReceiptGoogleResponse ¶
type ValidateSubscriptionReceiptGoogleResponse struct {
Kind string `json:"kind"`
StartTimeMillis string `json:"startTimeMillis"`
ExpiryTimeMillis string `json:"expiryTimeMillis"`
AutoResumeTimeMillis string `json:"autoResumeTimeMillis"`
AutoRenewing bool `json:"autoRenewing"`
PriceCurrencyCode string `json:"priceCurrencyCode"`
PriceAmountMicros string `json:"priceAmountMicros"`
CountryCode string `json:"countryCode"`
DeveloperPayload string `json:"developerPayload"`
PaymentState int `json:"paymentState"`
CancelReason int `json:"cancelReason"`
UserCancellationTimeMillis string `json:"userCancellationTimeMillis"`
OrderId string `json:"orderId"`
LinkedPurchaseToken string `json:"linkedPurchaseToken"`
PurchaseType int `json:"purchaseType"`
ProfileName string `json:"profileName"`
EmailAddress string `json:"emailAddress"`
GivenName string `json:"givenName"`
FamilyName string `json:"familyName"`
ProfileId string `json:"profileId"`
AcknowledgementState int `json:"acknowledgementState"`
ExternalAccountId string `json:"externalAccountId"`
PromotionType int `json:"promotionType"`
PromotionCode string `json:"promotionCode"`
ObfuscatedExternalAccountId string `json:"obfuscatedExternalAccountId"`
ObfuscatedExternalProfileId string `json:"obfuscatedExternalProfileId"`
}
https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions#get
type ValidationError ¶
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
func (*ValidationError) Unwrap ¶
func (e *ValidationError) Unwrap() error