receipt

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: Apache-2.0, BSD-3-Clause Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAppleRootCert added in v0.1.2

func GetAppleRootCert() (*x509.Certificate, error)

Types

type CancellationDate

type CancellationDate struct {
	Date    date    `json:"-"`
	DateMS  dateMS  `json:"-"`
	DatePST datePST `json:"-"`
}

CancellationDate is for a transaction that was canceled by Apple customer support

type CreationDate

type CreationDate struct {
	Date    date    `json:"receipt_creation_date"`
	DateMS  dateMS  `json:"receipt_creation_date_ms"`
	DatePST datePST `json:"receipt_creation_date_pst"`
}

CreationDate is the date when the app receipt was created

type ExpiresDate

type ExpiresDate struct {
	Date    date    `json:"-"`
	DateMS  dateMS  `json:"-"`
	DatePST datePST `json:"-"`
}

ExpiresDate is for the subscription

type InApp

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

	IsTrialPeriod string `json:"is_trial_period"`
	ExpiresDate

	PurchaseDate
	OriginalPurchaseDate

	CancellationDate
	CancellationReason string `json:"cancellation_reason,omitempty"`
	IsInIntroPrice     bool   `json:"-"`
}

InApp represents the receipt for in-app purchase https://developer.apple.com/library/content/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html#//apple_ref/doc/uid/TP40010573-CH106-SW12

type OriginalPurchaseDate

type OriginalPurchaseDate struct {
	Date    date    `json:"original_purchase_date"`
	DateMS  dateMS  `json:"original_purchase_date_ms"`
	DatePST datePST `json:"original_purchase_date_pst"`
}

OriginalPurchaseDate is for a transaction that restores a previous transaction, the date of the original transaction.

type PurchaseDate

type PurchaseDate struct {
	Date    date    `json:"purchase_date"`
	DateMS  dateMS  `json:"purchase_date_ms"`
	DatePST datePST `json:"purchase_date_pst"`
}

PurchaseDate is 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"`
	ExpirationDate             date     `json:"-"`

	OpaqueValue []byte `json:"-"`
	SHA1Hash    []byte `json:"-"`
	CreationDate
	RequestDate
	OriginalPurchaseDate
	// contains filtered or unexported fields
}

Receipt for an application https://developer.apple.com/library/content/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html

func Parse

func Parse(root *x509.Certificate, data string) (*Receipt, error)

Parse parsed base 64 encoded receipt data with a given certificate

func ParseWithAppleRootCert

func ParseWithAppleRootCert(data string) (*Receipt, error)

ParseWithAppleRootCert parses base 64 encoded receipt data with Apple Inc Root Certificate

func (*Receipt) Validate

func (r *Receipt) Validate() (Result, error)

Validate is for validating receipt

type RequestDate

type RequestDate struct {
	Date    date    `json:"request_date"`
	DateMS  dateMS  `json:"request_date_ms"`
	DatePST datePST `json:"request_date_pst"`
}

RequestDate is the date when verify request was issued

type Result

type Result struct {
	Status            int      `json:"status"`
	Environment       string   `json:"environment,omitempty"`
	Receipt           *Receipt `json:"receipt,omitempty"`
	LatestReceiptInfo []InApp  `json:"latest_receipt_info,omitempty"`
	LatestReceipt     string   `json:"latest_receipt,omitempty"`
	IsRetryable       bool     `json:"is-retryable,omitempty"`
}

Result is the validation result

Jump to

Keyboard shortcuts

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