Platforms to show: All Mac Windows Linux Cross-Platform

/MacCloud/Verify App Receipt and In-App Purchases/Verify App Receipt and In-App Purchases


Required plugins for this example: MBS MacCloud Plugin, MBS Main Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCloud/Verify App Receipt and In-App Purchases/Verify App Receipt and In-App Purchases

This example is the version from Thu, 6th Apr 2016.

Project "Verify App Receipt and In-App Purchases.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open() // with file 'AppReceiptMBS.setAppleRootCertificate FindFile("AppleIncRootCertificate.cer") // with certificate in app AppReceiptMBS.setAppleRootCertificate AppleIncRootCertificate End EventHandler
Function FindFile(name as string) As FolderItem // Look for file in parent folders from executable on dim parent as FolderItem = app.ExecutableFile.Parent while parent<>Nil dim file as FolderItem = parent.Child(name) if file<>Nil and file.Exists then Return file end if parent = parent.Parent wend End Function
End Class
Class Window1 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control OpenButton Inherits PushButton
ControlInstance OpenButton Inherits PushButton
EventHandler Sub Action() dim f as FolderItem = GetOpenFolderItem("") if f = nil then Return ShowReceipt f End EventHandler
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control bundleIdentifier Inherits TextField
ControlInstance bundleIdentifier Inherits TextField
End Control
Control Label2 Inherits Label
ControlInstance Label2 Inherits Label
End Control
Control bundleVersion Inherits TextField
ControlInstance bundleVersion Inherits TextField
End Control
Control TestButton Inherits PushButton
ControlInstance TestButton Inherits PushButton
EventHandler Sub Action() List.DeleteAllRows receipt = AppReceiptMBS.bundleReceipt ShowReceipt End EventHandler
End Control
Control Label3 Inherits Label
ControlInstance Label3 Inherits Label
End Control
Function FormatDate(d as date) As string if d <> nil then Return d.SQLDateTime else Return "n/a" end if End Function
Sub ShowIAP(Receipt as AppReceiptMBS) dim inAppPurchases() as AppReceiptIAPMBS = Receipt.inAppPurchases List.AddRow "inAppPurchases: "+str(UBound(inAppPurchases)+1) for each p as AppReceiptIAPMBS in inAppPurchases List.AddRow "" List.AddRow "productIdentifier: "+p.productIdentifier List.AddRow "quantity: "+str(p.quantity) List.AddRow "transactionIdentifier: "+p.transactionIdentifier List.AddRow "originalTransactionIdentifier: "+p.originalTransactionIdentifier List.AddRow "purchaseDate: "+FormatDate(p.purchaseDate) List.AddRow "originalPurchaseDate: "+FormatDate(p.originalPurchaseDate) List.AddRow "subscriptionExpirationDate: "+FormatDate(p.subscriptionExpirationDate) List.AddRow "cancellationDate: "+FormatDate(p.cancellationDate) List.AddRow "webOrderLineItemID: "+str(p.webOrderLineItemID) next End Sub
Sub ShowReceipt() if Receipt = nil then MsgBox "Receipt Invalid!" else List.AddRow "bundleIdentifier: "+Receipt.bundleIdentifier List.AddRow "bundleIdentifierData: "+EncodeHex(Receipt.bundleIdentifierData) List.AddRow "appVersion: "+Receipt.appVersion List.AddRow "opaqueValue: "+EncodeHex(Receipt.opaqueValue) List.AddRow "receiptHash: "+EncodeHex(Receipt.receiptHash) List.AddRow "originalAppVersion: "+Receipt.originalAppVersion List.AddRow "expirationDate: "+FormatDate(Receipt.expirationDate) List.AddRow "creationDate: "+FormatDate(Receipt.creationDate) List.AddRow "transactionDate: "+FormatDate(Receipt.transactionDate) List.AddRow "purchaseDate: "+FormatDate(Receipt.purchaseDate) dim v as new AppReceiptVerificatorMBS if bundleIdentifier.Text <> "" then v.bundleIdentifier = bundleIdentifier.Text end if if bundleVersion.Text <> "" then v.bundleVersion = bundleVersion.Text end if if v.verifyReceipt(receipt) then List.AddRow "Verification: valid" else List.AddRow "Verification: invalid: "+v.FailReason end if List.AddRow "" ShowIAP Receipt v = nil receipt = nil end if End Sub
Sub ShowReceipt(f as FolderItem) List.DeleteAllRows receipt = AppReceiptMBS.ReceiptForFile(f) ShowReceipt End Sub
Property Receipt As AppReceiptMBS
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
ExternalFile AppleIncRootCertificate
End ExternalFile
End Project

The items on this page are in the following plugins: MBS MacCloud Plugin.


The biggest plugin in space...