appstore

package
v0.0.0-...-9b7d3f6 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2015 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleError

func HandleError(status int) error

HandleError returns error message by status code

Types

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) (IAPResponse, 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 IAPClient

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

IAPClient is an interface to call validation API in App Store

type IAPRequest

type IAPRequest struct {
	ReceiptData string `json:"receipt-data"`
}

The IAPRequest type has the request parameter

type IAPResponse

type IAPResponse struct {
	Status      int     `json:"status"`
	Environment string  `json:"environment"`
	Receipt     Receipt `json:"receipt"`
}

The IAPResponse type has the response properties

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"`
	IsTrialPeriod             string `json:"is_trial_period"`
	ExpiresDate               string `json:"expires_date"`
	CancellationDate          string `json:"cancellation_date"`
	AppItemID                 string `json:"app_item_id"`
	VersionExternalIdentifier string `json:"version_external_identifier"`
	WebOrderLineItemID        string `json:"web_order_line_item_id"`
	PurchaseDate
	OriginalPurchaseDate
}

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 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"`
	BundleID                   string  `json:"bundle_id"`
	ApplicationVersion         string  `json:"application_version"`
	OriginalApplicationVersion string  `json:"original_application_version"`
	InApp                      []InApp `json:"in_app"`
	RequestDate
}

The Receipt type has whole data of receipt

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