iaplocal

package module
v0.0.0-...-82c6a72 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2018 License: BSD-3-Clause Imports: 6 Imported by: 0

README

GoDoc Build Status

Description

iaplocal is a Go library that supports Apple Local In-App Purchase (IAP) receipt processing.

  • Verify the receipt signature against App Root CA certificate.
  • Parse the receipt from binary, extract in-app receipts.
  • Validate the receipts hash with host GUID.

Installation

go install github.com/googollee/iaplocal

Usage

The simplest possible usage is:

rootBytes, _ := ioutil.ReadFile("./AppleComputerRootCertificate.cer")
rootCA, _ := x509.ParseCertificate(rootBytes)

receiptB64, _ := ioutil.ReadFile("./receipt_b64")
receiptBytes, _ := base64.StdEncoding.DecodeString(string(receiptB64))
receipt, _ := iaplocal.Parse(rootCA, receiptBytes)

guid, _ := uuid.FromString(hostGUID)
receipt.Verify(guid)

License

See LICENSE.

Documentation

Overview

Package iaplocal supports Apple Local In-App Purchase (IAP) receipt processing.

It loads the receipt from binary, parses the receipt's attributes, and verifies the receipt signature and hash.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidCertificate returns when parse a receipt
	// with invalid certificate from given root certificate.
	ErrInvalidCertificate = errors.New("iaplocal: invalid certificate in receipt")
	// ErrInvalidSignature returns when parse a receipt
	// which improperly signed.
	ErrInvalidSignature = errors.New("iaplocal: invalid signature of receipt")
)

Functions

This section is empty.

Types

type Receipt

type Receipt struct {
	Quantity              int
	ProductID             string
	TransactionID         string
	PurchaseDate          time.Time
	OriginalTransactionID string
	OriginalPurchaseDate  time.Time
	ExpiresDate           time.Time
	WebOrderLineItemID    int
	CancellationDate      time.Time
}

Receipt is the receipt for an in-app purchase.

type Receipts

type Receipts struct {
	BundleID                   string
	ApplicationVersion         string
	OpaqueValue                []byte
	SHA1Hash                   []byte
	ReceiptCreationDate        time.Time
	InApp                      []Receipt
	OriginalApplicationVersion string
	ExpirationDate             time.Time
	// contains filtered or unexported fields
}

Receipts is the app receipt.

func Parse

func Parse(root *x509.Certificate, data []byte) (Receipts, error)

Parse parses a receipt binary which certificates with root certificate. Need decode to DER binary if recevied a base64 file.

func (*Receipts) Verify

func (r *Receipts) Verify(guid []byte) bool

Verify verifys the receipts with given guid. TestReceiptValidate shows how to get GUID from string. Check https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateLocally.html#//apple_ref/doc/uid/TP40010573-CH1-SW5

Jump to

Keyboard shortcuts

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