appstore

package
v0.0.0-...-1e8cd38 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SandboxURL is the endpoint for sandbox environment.
	SandboxURL string = "https://sandbox.itunes.apple.com/verifyReceipt"
	// ProductionURL is the endpoint for production environment.
	ProductionURL string = "https://buy.itunes.apple.com/verifyReceipt"
)

Variables

This section is empty.

Functions

func HandleError

func HandleError(status int) error

HandleError returns error message by status code

Types

type CancellationDate

type CancellationDate struct {
	CancellationDate    string `json:"cancellation_date"`
	CancellationDateMS  string `json:"cancellation_date_ms"`
	CancellationDatePST string `json:"cancellation_date_pst"`
}

The CancellationDate type indicates the time and date of the cancellation by Apple customer support

type Client

type Client struct {
	URL     string
	TimeOut time.Duration
}

Client implements IAPClient

func New

func New() Client

New creates a client object

func NewWithConfig

func NewWithConfig(config Config) Client

NewWithConfig creates a client with configuration

func (*Client) Verify

func (c *Client) Verify(req IAPRequest, result interface{}) error

Verify sends receipts and gets validation result

type Config

type Config struct {
	IsProduction bool
	TimeOut      time.Duration
}

Config is a configuration to initialize client

type ExpiresDate

type ExpiresDate struct {
	ExpiresDate    string `json:"expires_date"`
	ExpiresDateMS  string `json:"expires_date_ms"`
	ExpiresDatePST string `json:"expires_date_pst"`
}

The ExpiresDate type indicates the expiration date for the subscription

type IAPClient

type IAPClient interface {
	Verify(IAPRequest, interface{}) error
}

IAPClient is an interface to call validation API in App Store

type IAPRequest

type IAPRequest struct {
	ReceiptData string `json:"receipt-data"`
	// Only used for receipts that contain auto-renewable subscriptions.
	Password string `json:"password,omitempty"`
	// Only used for iOS7 style app receipts that contain auto-renewable or non-renewing subscriptions.
	// If value is true, response includes only the latest renewal transaction for any subscriptions.
	ExcludeOldTransactions bool `json:"exclude-old-transactions"`
}

https://developer.apple.com/library/content/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html The IAPRequest type has the request parameter

type IAPResponse

type IAPResponse struct {
	Status             int                  `json:"status"`
	Environment        string               `json:"environment"`
	Receipt            Receipt              `json:"receipt"`
	LatestReceiptInfo  []InApp              `json:"latest_receipt_info"`
	LatestReceipt      string               `json:"latest_receipt"`
	PendingRenewalInfo []PendingRenewalInfo `json:"pending_renewal_info"`
	IsRetryable        bool                 `json:"is-retryable"`
	// contains filtered or unexported fields
}

The IAPResponse type has the response properties We defined each field by the current IAP response, but some fields are not mentioned in the following Apple's document; https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html If you get other types or fileds from the IAP response, you should use the struct you defined.

func (*IAPResponse) Bytes

func (v *IAPResponse) Bytes() ([]byte, error)

type InApp

type InApp struct {
	Quantity              string `json:"quantity"`
	ProductID             string `json:"product_id"`
	TransactionID         string `json:"transaction_id"`
	OriginalTransactionID string `json:"original_transaction_id"`
	WebOrderLineItemID    string `json:"web_order_line_item_id"`

	IsTrialPeriod string `json:"is_trial_period"`
	ExpiresDate

	PurchaseDate
	OriginalPurchaseDate

	CancellationDate
	CancellationReason string `json:"cancellation_reason"`
}

The InApp type has the receipt attributes

type OriginalPurchaseDate

type OriginalPurchaseDate struct {
	OriginalPurchaseDate    string `json:"original_purchase_date"`
	OriginalPurchaseDateMS  string `json:"original_purchase_date_ms"`
	OriginalPurchaseDatePST string `json:"original_purchase_date_pst"`
}

The OriginalPurchaseDate type indicates the beginning of the subscription period

type PendingRenewalInfo

type PendingRenewalInfo struct {
	SubscriptionExpirationIntent   string `json:"expiration_intent"`
	SubscriptionAutoRenewProductID string `json:"auto_renew_product_id"`
	SubscriptionRetryFlag          string `json:"is_in_billing_retry_period"`
	SubscriptionAutoRenewStatus    string `json:"auto_renew_status"`
	SubscriptionPriceConsentStatus string `json:"price_consent_status"`
	ProductID                      string `json:"product_id"`
}

A pending renewal may refer to a renewal that is scheduled in the future or a renewal that failed in the past for some reason.

type PurchaseDate

type PurchaseDate struct {
	PurchaseDate    string `json:"purchase_date"`
	PurchaseDateMS  string `json:"purchase_date_ms"`
	PurchaseDatePST string `json:"purchase_date_pst"`
}

The PurchaseDate type indicates the date and time that the item was purchased

type Receipt

type Receipt struct {
	ReceiptType                string  `json:"receipt_type"`
	AdamID                     int64   `json:"adam_id"`
	AppItemID                  int64   `json:"app_item_id"`
	BundleID                   string  `json:"bundle_id"`
	ApplicationVersion         string  `json:"application_version"`
	DownloadID                 int64   `json:"download_id"`
	VersionExternalIdentifier  int64   `json:"version_external_identifier"`
	OriginalApplicationVersion string  `json:"original_application_version"`
	InApp                      []InApp `json:"in_app"`
	ReceiptCreationDate
	RequestDate
	OriginalPurchaseDate
}

The Receipt type has whole data of receipt

type ReceiptCreationDate

type ReceiptCreationDate struct {
	CreationDate    string `json:"receipt_creation_date"`
	CreationDateMS  string `json:"receipt_creation_date_ms"`
	CreationDatePST string `json:"receipt_creation_date_pst"`
}

The ReceiptCreationDate type indicates the date when the app receipt was created.

type RequestDate

type RequestDate struct {
	RequestDate    string `json:"request_date"`
	RequestDateMS  string `json:"request_date_ms"`
	RequestDatePST string `json:"request_date_pst"`
}

The RequestDate type indicates the date and time that the request was sent

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL