Documentation ¶
Index ¶
- Constants
- Variables
- func ValidateReceiptGoogle(ctx context.Context, httpc *http.Client, clientEmail string, privateKey string, ...) (*ReceiptGoogleResponse, *ReceiptGoogle, []byte, error)
- func ValidateSubscriptionReceiptGoogle(ctx context.Context, httpc *http.Client, clientEmail string, privateKey string, ...) (*ReceiptSubscriptionGoogleResponse, *ReceiptGoogle, []byte, error)
- type Environment
- type IAPAppleConfig
- type IAPGoogleConfig
- type InApp
- type PendingRenewalInfo
- type Purchase
- type ReceiptGoogle
- type ReceiptGoogleResponse
- type ReceiptSubscriptionGoogleResponse
- type ResponseReceipt
- type Store
- type SubscriptionPurchase
- type ValidateReceiptAppleResponse
Constants ¶
View Source
const ( AppleUrlSandbox = "https://sandbox.itunes.apple.com/verifyReceipt" AppleUrlProduction = "https://buy.itunes.apple.com/verifyReceipt" )
View Source
const ( AppleReceiptIsValid = 0 AppleReceiptIsSandbox = 21007 )
View Source
const ( AppleSandboxEnv = "Sandbox" AppleProductionEnv = "Production" )
View Source
const ( APPLE string = "0" GOOGLE string = "1" )
Variables ¶
View Source
var ( ErrPurchasesListInvalidCursor = errors.New("purchases list cursor invalid") ErrFailedPrecondition = errors.New("invalid Receipt") ErrPurchaseReceiptAlreadySeen = errors.New("Purchase Receipt Already Seen") )
View Source
var (
ErrNon200Apple = errors.New("non 200 response from apple")
)
View Source
var (
ErrNon200ServiceGoogle = errors.New("non 200 response from Google service")
)
Functions ¶
func ValidateReceiptGoogle ¶
func ValidateReceiptGoogle(ctx context.Context, httpc *http.Client, clientEmail string, privateKey string, receipt string) (*ReceiptGoogleResponse, *ReceiptGoogle, []byte, error)
ValidateReceiptGoogle validate an IAP receipt with the Android Publisher API and the Google credentials.
func ValidateSubscriptionReceiptGoogle ¶
func ValidateSubscriptionReceiptGoogle(ctx context.Context, httpc *http.Client, clientEmail string, privateKey string, receipt string) (*ReceiptSubscriptionGoogleResponse, *ReceiptGoogle, []byte, error)
ValidateSubscriptionReceiptGoogle validate an IAP receipt with subscription type
Types ¶
type Environment ¶
type Environment int32
Environment where the purchase took place
const ( // Unknown environment. UNKNOWN Environment = 0 // Sandbox /test environment. SANDBOX Environment = 1 // Production environment. PRODUCTION Environment = 2 )
type IAPAppleConfig ¶
type IAPAppleConfig struct {
PrivateKey string `json:"private_key" usage:"Apple App Specific Shared Secret"`
}
type IAPGoogleConfig ¶
type InApp ¶
type InApp 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"` // Only returned for Subscription expiration or renewal date. PurchaseDateMs string `json:"purchase_date_ms"` CancellationDateMs string `json:"cancellation_date_ms"` // canceled a transaction This field is only present for refunded transactions CancellationReason string `json:"cancellation_reason"` // reason for a refunded transaction Possible values: 1, 0 PendingRenewalInfo []PendingRenewalInfo `json:"pending_renewal_info"` // Only returned for app receipts that contain auto-renewable subscriptions. }
type PendingRenewalInfo ¶
type PendingRenewalInfo struct {
AutoRenewStatus string `json:"auto_renew_status"` // Possible values: 1, 0
}
type ReceiptGoogle ¶
type ReceiptGoogleResponse ¶
type ReceiptGoogleResponse 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 ReceiptSubscriptionGoogleResponse ¶
type ReceiptSubscriptionGoogleResponse struct { AcknowledgementState int `json:"acknowledgementState"` DeveloperPayload string `json:"developerPayload"` Kind string `json:"kind"` OrderId string `json:"orderId"` PurchaseType int `json:"purchaseType"` // This field is only set if this purchase was not made using the standard in-app billing flow. // Possible values are: 0. Test (i.e. purchased from a license testing account) 1. Promo (i.e. purchased using a promo code) AutoRenewing bool `json:"autoRenewing"` StartSubscriptionTimeMillis int64 `json:"startTimeMillis,string,omitempty"` ExpirySubscriptionTimeMillis int64 `json:"expiryTimeMillis,string,omitempty"` LinkedPurchaseToken string `json:"linkedPurchaseToken"` CancelReason int `json:"cancelReason"` //0 User canceled the subscription //1 Subscription was canceled by the system, for example because of a billing problem //2 Subscription was replaced with a new subscription //3 Subscription was canceled by the developer UserCancellationTimeMillis string `json:"userCancellationTimeMillis"` // Only present if cancelReason is 0. PaymentState int `json:"paymentState"` }
type ResponseReceipt ¶
type SubscriptionPurchase ¶
func PurchaseSubscriptionGoogle ¶
func PurchaseSubscriptionGoogle(ctx context.Context, config IAPGoogleConfig, receipt string) (*SubscriptionPurchase, error)
func PurchasesSubscriptionApple ¶
func PurchasesSubscriptionApple(ctx context.Context, config IAPAppleConfig, receipt string) (*SubscriptionPurchase, error)
type ValidateReceiptAppleResponse ¶
type ValidateReceiptAppleResponse struct { IsRetryable bool `json:"is-retryable"` // If true, must be retried later. Status int `json:"status"` Receipt *ResponseReceipt `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)
ValidateReceiptApple this function will check against both the production and sandbox Apple URLs follow by Apple suggestion. return response struct and raw data. Do what ever you want.
func ValidateSubscriptionReceiptApple ¶
func ValidateSubscriptionReceiptApple(ctx context.Context, httpc *http.Client, receipt, password string) (*ValidateReceiptAppleResponse, []byte, error)
ValidateSubscriptionReceiptApple this function for purchase subscription will check against both the production and sandbox Apple URLs follow by Apple suggestion. required password return response struct and raw data. Do what ever you want.
Click to show internal directories.
Click to hide internal directories.